Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .codesight/CODESIGHT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

> 0 routes | 0 models | 0 components | 200 lib files | 25 env vars | 7 middleware | 1 events | 0% test coverage
> **Token savings:** this file is ~18,200 tokens. Without it, AI exploration would cost ~66,400 tokens. **Saves ~48,200 tokens per conversation.**
> **Last scanned:** 2026-09-20 15:47 — re-run after significant changes
> **Last scanned:** 2026-09-20 16:17 — re-run after significant changes

---

Expand Down Expand Up @@ -293,8 +293,8 @@
- type InvalidArgsError
- type MissingFileError
- type FileReadError
- type ParseFailureError
- _...5 more_
- type FileWriteError
- _...6 more_
- `packages/cli/src/evals/artifact-bundle.ts`
- function computeRunIdPrefix: (gitSha, assembledAt) => string
- function computeRunId: (prefix, sequence) => string
Expand Down Expand Up @@ -539,6 +539,7 @@
- _...2 more_
- `packages/cli/src/fs/file-system.ts`
- function describeFileSystemError: (error) => string
- function toConfigFileReader: (fs) => ConfigFileReader
- class BunFileSystem
- class MemoryFileSystem
- interface FileSystem
Expand Down Expand Up @@ -979,11 +980,11 @@
## Most Imported Files (change these carefully)

- `packages/cli/src/evals/types.ts` — imported by **48** files
- `packages/cli/src/io/terminal.ts` — imported by **22** files
- `packages/cli/src/theme/colors.ts` — imported by **22** files
- `packages/cli/src/io/terminal.ts` — imported by **21** files
- `packages/cli/src/fs/file-system.ts` — imported by **20** files
- `packages/cli/src/evals/openrouter-client.ts` — imported by **20** files
- `packages/cli/src/evals/report-schema.ts` — imported by **18** files
- `packages/cli/src/fs/file-system.ts` — imported by **17** files
- `packages/adapters/opencode2/src/sdk-types.ts` — imported by **16** files
- `packages/engine/src/runtime/types.ts` — imported by **16** files
- `packages/cli/src/args.ts` — imported by **15** files
Expand All @@ -1002,11 +1003,11 @@
## Import Map (who imports what)

- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +43 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/theme/colors.ts` ← `packages/cli/src/__tests__/theme.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +16 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +15 more
- `packages/cli/src/evals/openrouter-client.ts` ← `packages/cli/src/evals/__tests__/loom-routing-runner.test.ts`, `packages/cli/src/evals/__tests__/loom-routing-runner.trajectory.test.ts`, `packages/cli/src/evals/__tests__/pattern-planning-runner.test.ts`, `packages/cli/src/evals/__tests__/runner.test.ts`, `packages/cli/src/evals/__tests__/shuttle-execution-runner.test.ts` +15 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +13 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +12 more
- `packages/adapters/opencode2/src/sdk-types.ts` ← `packages/adapters/opencode2/src/__tests__/reconcile-agent.test.ts`, `packages/adapters/opencode2/src/adapter.ts`, `packages/adapters/opencode2/src/errors.ts`, `packages/adapters/opencode2/src/plugin.ts`, `packages/adapters/opencode2/src/reconcile-agent.ts` +11 more
- `packages/engine/src/runtime/types.ts` ← `packages/engine/src/__tests__/runtime-command-operations.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts` +11 more
- `packages/cli/src/args.ts` ← `packages/cli/src/__tests__/args.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +10 more
Expand All @@ -1023,7 +1024,7 @@
# Test Coverage

> **0%** of routes and models are covered by tests
> 200 test files found
> 201 test files found

---

Expand Down
2 changes: 1 addition & 1 deletion .codesight/coverage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test Coverage

> **0%** of routes and models are covered by tests
> 200 test files found
> 201 test files found
8 changes: 4 additions & 4 deletions .codesight/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
## Most Imported Files (change these carefully)

- `packages/cli/src/evals/types.ts` — imported by **48** files
- `packages/cli/src/io/terminal.ts` — imported by **22** files
- `packages/cli/src/theme/colors.ts` — imported by **22** files
- `packages/cli/src/io/terminal.ts` — imported by **21** files
- `packages/cli/src/fs/file-system.ts` — imported by **20** files
- `packages/cli/src/evals/openrouter-client.ts` — imported by **20** files
- `packages/cli/src/evals/report-schema.ts` — imported by **18** files
- `packages/cli/src/fs/file-system.ts` — imported by **17** files
- `packages/adapters/opencode2/src/sdk-types.ts` — imported by **16** files
- `packages/engine/src/runtime/types.ts` — imported by **16** files
- `packages/cli/src/args.ts` — imported by **15** files
Expand All @@ -26,11 +26,11 @@
## Import Map (who imports what)

- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +43 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/theme/colors.ts` ← `packages/cli/src/__tests__/theme.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +16 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +15 more
- `packages/cli/src/evals/openrouter-client.ts` ← `packages/cli/src/evals/__tests__/loom-routing-runner.test.ts`, `packages/cli/src/evals/__tests__/loom-routing-runner.trajectory.test.ts`, `packages/cli/src/evals/__tests__/pattern-planning-runner.test.ts`, `packages/cli/src/evals/__tests__/runner.test.ts`, `packages/cli/src/evals/__tests__/shuttle-execution-runner.test.ts` +15 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +13 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +12 more
- `packages/adapters/opencode2/src/sdk-types.ts` ← `packages/adapters/opencode2/src/__tests__/reconcile-agent.test.ts`, `packages/adapters/opencode2/src/adapter.ts`, `packages/adapters/opencode2/src/errors.ts`, `packages/adapters/opencode2/src/plugin.ts`, `packages/adapters/opencode2/src/reconcile-agent.ts` +11 more
- `packages/engine/src/runtime/types.ts` ← `packages/engine/src/__tests__/runtime-command-operations.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts` +11 more
- `packages/cli/src/args.ts` ← `packages/cli/src/__tests__/args.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +10 more
Expand Down
5 changes: 3 additions & 2 deletions .codesight/libs.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@
- type InvalidArgsError
- type MissingFileError
- type FileReadError
- type ParseFailureError
- _...5 more_
- type FileWriteError
- _...6 more_
- `packages/cli/src/evals/artifact-bundle.ts`
- function computeRunIdPrefix: (gitSha, assembledAt) => string
- function computeRunId: (prefix, sequence) => string
Expand Down Expand Up @@ -528,6 +528,7 @@
- _...2 more_
- `packages/cli/src/fs/file-system.ts`
- function describeFileSystemError: (error) => string
- function toConfigFileReader: (fs) => ConfigFileReader
- class BunFileSystem
- class MemoryFileSystem
- interface FileSystem
Expand Down
27 changes: 21 additions & 6 deletions docs/testing-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,26 @@ documented as needing source mutation to demonstrate); the other suppressed
cases use `skipIf` and are legitimately gated on platform or env.

**10. The buckets are scaffolded, not populated.** `tests/` holds one scenario
file per bucket. Of the CLI's seven commands only `validate` has black-box
coverage, and only two (`validate`, `init`) even accept an injectable
filesystem — the other five cannot be driven through `run()` hermetically. Of
the four adapters with source in this repo, only `claude-code` has a scenario
file.
file per bucket, and of the four adapters with source in this repo only
`claude-code` has one.

On the CLI side the original wording — "five commands cannot be driven through
`run()`" — was imprecise. Each command already had *a* seam; they were just
different ones, and `run()` threaded none of them:

| Command | Seam it already had |
| --- | --- |
| `validate`, `init` | `fs` |
| `migrate` | `fs` (required; reached through `init`) |
| `prompt` | `configLoader`, `cwd` |
| `runtime` | `cwd`, `storeFactory`, `dbExists` |
| `eval` | `env`, `runner`, validator overrides |
| `compose` | none — used `Bun.file`, `process.cwd()` and `homedir()` directly |

Threading `cwd` alone also turned out to be insufficient: `loadConfig()` falls
back to its own Bun-backed reader, so a command handed an injected `cwd` still
read the real disk. `toConfigFileReader()` bridges a `FileSystem` into config
discovery, which is what actually closes the gap.

### Landed

Expand Down Expand Up @@ -177,7 +192,7 @@ Every finding maps to a step; steps are ordered by value per unit of risk.
| 7 | Cover `packages/adapters/pi` | 9 | Its four api-extractor configs now run under `validate:declarations` | **done, reduced** |
| 2 | Retire `execution-lifecycle.test.ts` into the existing split, keeping only cases the split lacks | 4 | −9.8k lines | open |
| 3 | Make the 23 ambient-state tests hermetic | 2 | Suite becomes trustworthy locally | **done** — #185, #186 |
| 8 | Thread `fs` through the remaining five CLI commands (`prompt`, `eval`, `compose`, `runtime`, `migrate`) | 10 | Prerequisite: without it those commands cannot be driven hermetically through `run()` | open |
| 8 | Thread an injected filesystem and environment through `run()` to every command | 10 | Prerequisite for the CLI bucket; `compose` gained a seam, `prompt` and `runtime` gained fs-backed config discovery | **done** |
| 4 | Promote existing end-to-end coverage into `tests/`, starting with `claude-code/integration.test.ts` and the opencode/opencode2 translation tests | 1, 8 | Real scenarios, refactor-proof | open |
| 9 | Populate the buckets: DSL (workflows, `tool_policy`, prompt templates, config merge), CLI (the six uncovered commands), Adapters (opencode, opencode2, copilot) | 10 | The taxonomy stops being a scaffold | open |
| 6 | Consolidate duplicated factories into `tests/support/` and per-package `__tests__/support/` | 6 | Fixtures named after situations | open |
Expand Down
22 changes: 18 additions & 4 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ export interface CliDeps {
* real filesystem inside each handler. Black-box CLI tests inject a
* `MemoryFileSystem` here so a whole `weave ...` invocation can be driven
* end to end without touching the developer's disk or `$HOME`.
*
* Commands that take a project root rather than a filesystem receive
* `fs.cwd()`, so one injected filesystem settles where every command looks.
*/
fs?: FileSystem;
/**
* Environment consulted by commands that read it — currently `weave eval`,
* for its filter allowlists. Defaults to `Bun.env` inside the handler.
*/
env?: Record<string, string | undefined>;
}

function defaultDeps(): CliDeps {
Expand All @@ -49,11 +57,15 @@ function defaultDeps(): CliDeps {
export async function run(
deps?: Partial<CliDeps>,
): Promise<Result<number, CliError>> {
const { argv, terminal, colorEnabled, fs } = {
const { argv, terminal, colorEnabled, fs, env } = {
...defaultDeps(),
...deps,
};

// Commands that locate work by path rather than by filesystem still need to
// agree with an injected filesystem about where "here" is.
const cwd = fs?.cwd();

const theme = defaultThemeManager.getTheme(colorEnabled);

const parsed = parseArgs(argv);
Expand Down Expand Up @@ -137,6 +149,8 @@ export async function run(
theme,
subcommand,
limit: flags.limit,
cwd,
fs,
});
}

Expand All @@ -158,17 +172,17 @@ export async function run(
);
return ok(1);
}
return runPrompt({ terminal, theme, flags, rest });
return runPrompt({ terminal, theme, flags, rest, cwd, fs });
}

case "eval": {
const { runEval } = await import("./commands/eval.js");
return runEval({ terminal, theme, flags });
return runEval({ terminal, theme, flags, env });
}

case "compose": {
const { runCompose } = await import("./commands/compose.js");
return runCompose({ terminal, theme, flags });
return runCompose({ terminal, theme, flags, fs });
}

case "unknown": {
Expand Down
Loading
Loading