Skip to content

Add the pnpm workspace and packages/core - #4

Open
masaok wants to merge 1 commit into
agent-instructionsfrom
workspace-core
Open

masaok wants to merge 1 commit into
agent-instructionsfrom
workspace-core

Conversation

@masaok

@masaok masaok commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Why

The engine has to exist as packages a command-line tool and a worker can run, separate from the Next.js app. This adds the workspace and the first package, which every later package depends on: the shape of a cost line, the shape of a finding and the money math.

Scope

  • pnpm-workspace.yaml gains packages/*. The app stays at the repository root.
  • packages/core (@costexplorer/core, private for now):
    • costRecordSchema, the subset of the FinOps FOCUS columns the analyzers will use, in camelCase.
    • findingSchema and Finding, the public contract from the plan, with rankFindings and totalMonthlySavingUsd.
    • sumUsd, monthlyFromHourly, floorToCents and HOURS_PER_MONTH.
  • Vitest runs packages/*/src/**/*.test.ts inside pnpm test and fails under 90% coverage.
  • pnpm typecheck also runs each package's own tsc. Packages use tsconfig.packages.json, which allows only syntax Node can run without a build.
  • Lint rejects react, react-dom and next imports in every package except a future packages/ui.
  • README.md, CONTRIBUTING.md, the guardrails table and the audit are updated.

Stacked on #2. Merge #1 and #2 first.

Tradeoffs

Three things in the plan were left out on purpose. Each has a row under "Not adopted" in docs/engineering-practices.md saying when to adopt it.

  • Turborepo. The gate takes about 15 seconds.
  • Changesets. Nothing is published yet. It belongs with the npm release.
  • Moving the app to apps/web. It rewrites every check, the feature map and the agent instructions, and no engine code needs it.

AGENTS.md does not mention packages/ yet. That file changes only in a pull request of its own, so it is a follow-up.

Savings are ranked by dollars alone. Whether confidence should affect the order is a product call, left for review.

Verification

VERIFIED. pnpm verify on Node 24.21.0.

$ next typegen && tsc --noEmit && pnpm -r typecheck
✓ Types generated successfully
$ eslint --max-warnings 0
All matched files use Prettier code style!
PASS feature-map (2 surfaces in code, 2 rows)
PASS docs-links (30 relative links in 11 markdown files)
PASS versions (Node 24, 2 workflow files)
ℹ tests 13
ℹ pass 13
ℹ fail 0
 Test Files  3 passed (3)
      Tests  19 passed (19)
Statements   : 100% ( 26/26 )
Branches     : 100% ( 9/9 )
Functions    : 100% ( 10/10 )
Lines        : 100% ( 22/22 )
✓ Compiled successfully
PASS GET / 200, text "To get started, edit the"
PASS GET /favicon.ico 200, type "image/x-icon"
2 surfaces requested, 0 failures

Each new check was watched failing:

  • Coverage: ERROR: Coverage for branches (88.88%) does not meet global threshold (90%) with one comparator branch untested.
  • Package typecheck: src/zz.ts(1,14): error TS2322: Type 'string' is not assignable to type 'number'. with a bad file added and removed.
  • The framework-import rule has a test in scripts/checks/lint-boundaries.test.mjs.

https://claude.ai/code/session_01WTtRZcdke1yYdYUAanaf7V

The engine starts as @costexplorer/core: the cost record schema aligned
to the FOCUS columns, money math that adds in micro-dollars, and the
Finding contract with ranking. The app stays at the repository root and
packages live beside it.

Vitest runs the package tests with a 90% coverage threshold. Lint keeps
React and Next.js out of the engine packages.

Claude-Session: https://claude.ai/code/session_01WTtRZcdke1yYdYUAanaf7V
Copilot AI balanced review requested due to automatic review settings October 2, 2026 00:03
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
costexplorer Ready Ready Preview Oct 2, 2026 12:03am UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch was successfully deployed

1 active deployment
Preview — 03210ff2 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants