Skip to content

feat(cli)!: emit lean agent-facing JSON payloads by default - #476

Merged
rhuanbarreto merged 6 commits into
mainfrom
feat/lean-agent-payloads
Jul 16, 2026
Merged

feat(cli)!: emit lean agent-facing JSON payloads by default#476
rhuanbarreto merged 6 commits into
mainfrom
feat/lean-agent-payloads

Conversation

@rhuanbarreto

@rhuanbarreto rhuanbarreto commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Breaking change — default JSON output shape

This changes the default JSON emitted by three commands. A script or CI step that parses them may need --verbose, or a switch to adr show. Human output, --ci output, aggregate counts, and exit codes are all unchanged.

command what the default output loses how to restore it
adr list --json entries drop files and respectGitignore; only id, title, domain, rules remain archgate adr show <id> for the full frontmatter
check --json results[] carries only rules with findings (failures, rule errors, warning/info); no entry per passing rule --verbose restores every rule; total/passed counts are unchanged
review-context [--run-checks] ADR entries drop decision/dosAndDonts prose; checkSummary.results drops clean-passing rules --verbose restores the prose

Pre-1.0, this bumps the minor version (per .simple-release.js), not major.

Why

Agent harnesses spill an oversized tool result to a file, at which point the payload stops being readable inline — which defeats the purpose of emitting JSON for an agent at all. Three commands crossed that threshold on a project with a few dozen ADRs.

ARCH-003 already mandated compact JSON for agents and claimed a "30-50% token reduction". Dumping an entire record was therefore fully compliant with the ADR as written — which is how this shipped. Compaction and field selection are different levers: compaction scales a payload by a constant, but field selection is what keeps output inline-readable as N grows.

What changed

Measured on a 38-ADR project (and on this repo for review-context):

command before after
adr list --json 6,314 B 3,856 B −39%
check --json 25,158 B 919 B −96%
review-context --run-checks 80,755 B 8,759 B −90%

Each payload now scales with the number of findings rather than the number of rules/ADRs, so it stops degrading as a project grows.

  • adr list returned the parsed frontmatter verbatim (.map(a => a.frontmatter)), including files glob arrays that are useless for deciding what to read next. Now projects to the four fields the human table already renders; adr show <id> still has the rest.
  • check --json emitted an entry per rule, including cleanly-passing ones whose entry only restates static ADR text (99% of the payload; description alone was 43%). The documented example in check.mdx already showed the lean shape (total: 4, passed: 3, results: [1 fail]), so this aligns the implementation with its own contract. --verbose restores the full list.
  • review-context carried every applicable ADR's Decision + Do's/Don'ts prose — 78% of the payload. Now opt-in behind --verbose; the default says which ADRs apply and the consumer drills down. checkSummary gets the same projection via a shared resultsWithFindings() so the two paths cannot drift.

Recorded as ARCH-003 key convention 7 ("progressive disclosure for agent payloads"). Docs updated in all three locales.

Reviewer notes

The filter predicate is "has nothing to report", not "passed". buildSummary sets status: "fail" only for error-severity violations, so a warning-only rule is status: "pass" with a non-empty violations[]. The obvious status !== "pass" filter silently swallows every warning — caught by a probe test, and a real project had a live warning that would have vanished. ARCH-003 gained a Don't guarding against exactly this, and there's a regression test.

--verbose is deliberately the same word on both commands — "give me the full detail". It already existed on check (documented as "Show passing rules and timing info") but only gated the console path.

A prior hypothesis was wrong and is worth not re-attempting: deduping ADR briefings across domains saves 0 bytes — an ADR has exactly one domain in its frontmatter, so cross-domain duplication is structurally impossible (measured duplication factor: 1.00x).

Known follow-up: the installed reviewer skill (v0.13.2) still expects briefings in review-context's default output. It degrades gracefully (it's LLM prompt guidance, not a parser — sub-agents read the ADR files themselves), but should start passing --verbose if batched briefings are still wanted.

The test-isolation commits

The new review-context integration test passed alone and failed in the full suite. Root cause was pre-existing and unrelated to this feature: env.X = undefined assigns the literal string "undefined" and leaves the key present — it does not unset. The idiomatic const orig = Bun.env.HOME; …; Bun.env.HOME = orig restore therefore leaked HOME="undefined" (normally unset on Windows) into Bun's shared test process and every subprocess it spawns, making review-context report zero changed files.

Fixed via restoreEnv() in tests/test-utils.ts + a custom oxlint rule test-isolation/no-bare-env-restore.

The rule tracks whether the assigned identifier was itself captured from an env read, rather than matching a original* naming convention — because both are spelled Bun.env.HOME = <identifier>, and the real call sites used savedHome, savedXdg, savedDistro, savedAppData, origCI too. It found 3 genuinely unguarded restores that two rounds of manual grepping missed (check-action.test.ts, binary-upgrade.test.ts, init-project.test.ts — two of them leaking HOME). The other 28 sites were correct-but-verbose guards, now collapsed.

Most telling: vscode-settings.test.ts already had a local helper whose docstring described this exact bug — "would stringify undefined into the literal 'undefined', corrupting the env for subsequent test files" — while five other files leaked it. The knowledge existed but was inconsistently applied, which is what a mechanical check catches and review does not.

Verification

  • bun run validate fully green: 1452 pass / 0 fail, lint clean, 43/43 ADR rules, build check.
  • Each commit is independently green (verified commit 1 in isolation: 1443 pass / 0 fail), so the branch bisects cleanly.
  • The lint rule was fire-tested in both directions: dogfooded (31 sites / 17 files, no false positives on overrides) and verified to flag a reintroduced bare restore at the expected line.
  • Payload numbers re-measured before/after against real projects, not fixtures.

The last commit also carries an in-flight edit to feedback_prefer_tests_over_adr_rules.md authored outside this change but present in the working tree.


BREAKING CHANGE: The default --json output of adr list, check, and review-context now omits fields and entries that were previously always present. adr list --json entries drop files and respectGitignore (recover via archgate adr show <id>); check --json results[] includes only rules with findings (pass --verbose for every rule); review-context omits each ADR's decision/dosAndDonts prose and clean-passing checkSummary.results entries (pass --verbose). Aggregate counts, human-readable output, --ci output, and exit codes are unchanged.

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_159c2517-f9d7-466c-828b-319998d7d006)

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: dc415bf
Status: ✅  Deploy successful!
Preview URL: https://c3a07c53.archgate-cli.pages.dev
Branch Preview URL: https://feat-lean-agent-payloads.archgate-cli.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds identity-only JSON projections for adr list, reportable-result filtering for check payloads, and a --verbose path for full rule entries and ADR prose. Review-context briefing options and check summaries now follow these payload rules. A shared restoreEnv helper replaces direct environment restoration in tests, while a new oxlint plugin detects unsafe captured-value restores. Documentation, ADRs, tests, and engineering guidance were updated accordingly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.19% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: default agent-facing JSON payloads are leaner.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the lean JSON output, verbose restore path, and related test/lint work.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

`Bun.env.X = undefined` assigns the literal string "undefined" and leaves the
key present — it does not unset. The idiomatic capture-and-restore

    const original = Bun.env.HOME; ...; Bun.env.HOME = original;

therefore leaked HOME="undefined" whenever the variable was unset to begin
with, which is the normal case on Windows for HOME and GIT_CONFIG_GLOBAL.
Bun's test runner shares one process across test files, so the bogus value
escaped into every later test file and into every subprocess they spawned.

The observed symptom was a test that passed in isolation and failed in the
full suite: a leaked HOME="undefined" made `review-context` report zero
changed files. Bun.env and process.env are the same store, so both accessors
are affected.

Add `restoreEnv(key, original)` to tests/test-utils.ts, which deletes the key
when the captured original was undefined, and route every env restore under
tests/ through it. This also collapses the correct-but-verbose
`if (orig === undefined) delete ... else ...` guards that several files had
already grown independently.

Three restores were genuinely unguarded rather than merely verbose:
check-action.test.ts (CI), binary-upgrade.test.ts (HOME) and
init-project.test.ts (HOME).

vscode-settings.test.ts already had a local bulk helper implementing the
correct semantics; it is renamed restoreEnvAll and now delegates to the
shared helper rather than duplicating the logic.

Document the rule as a Do/Don't in ARCH-005.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
ARCH-005 documents that tests must restore environment variables via
restoreEnv(), but the rule was manual-enforcement only — and the preceding
commit showed why that is not enough: several files guarded one variable
correctly with an explicit undefined check while leaving HOME bare, and
vscode-settings.test.ts carried a docstring describing the exact bug that five
other files were leaking. The knowledge was present but inconsistently
applied, which is what a mechanical check catches and review does not.

The invariant is purely syntactic, so it belongs in the linter (the same
reasoning recorded in .archgate/lint/oxlint.ts). Follows lint/expect-expect.ts
as the model: a custom oxlint JS plugin enabled for tests/**/*.test.ts.

The rule flags `Bun.env.NAME = <identifier>` / `process.env.NAME = <identifier>`
only when that identifier was itself captured from an env read earlier in the
same file. Tracking the capture — rather than matching a naming convention
such as `original*` — is what distinguishes a restore from an override: both
are spelled `Bun.env.HOME = <identifier>`, so `Bun.env.HOME = tempDir` is
correctly left alone. This matters in practice: the real call sites named
their variables savedHome, savedXdg, savedDistro, savedInterop, savedAppData
and origCI as often as original*. Computed access (`Bun.env[key]`) is also
left alone, being the shape of the restoreEnv helper itself.

Verified in both directions: dogfooded against the repo (31 sites, 17 files,
no false positives on overrides), and fire-tested by reintroducing a bare
restore, which the rule flagged at the expected line.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Agent harnesses spill an oversized tool result to a file, at which point the
payload stops being readable inline — which defeats the purpose of emitting
JSON for an agent. Three commands crossed that threshold on a project with a
few dozen ADRs. Measured on a 38-ADR project (and this repo for
review-context):

  adr list --json              6314 B ->  3856 B  (-39%)
  check --json                25158 B ->   919 B  (-96%)
  review-context --run-checks 80755 B ->  8759 B  (-90%)

More importantly, each payload now scales with the number of findings rather
than the number of rules or ADRs, so it stops degrading as a project grows.

- adr list: emitted the parsed frontmatter verbatim, including `files` glob
  arrays that are useless for deciding what to read next. Now projects to the
  four fields the human table already renders; `adr show <id>` still has the
  rest.

- check --json: emitted an entry for every rule, including cleanly-passing
  ones whose entry only restates static ADR text (99% of the payload; the
  `description` field alone was 43%). Now carries only rules with something to
  report. The documented example in check.mdx already showed this shape, so
  this aligns the implementation with its own contract. `--verbose` restores
  the full list, matching reportConsole and the flag's documented meaning.

- review-context: each ADR's Decision and Do's/Don'ts prose was 78% of the
  payload. Now opt-in behind `--verbose`; the default identifies which ADRs
  apply and the consumer drills down with `adr show <id>`. checkSummary gets
  the same projection as check --json, via a shared resultsWithFindings()
  helper so the two cannot drift.

The filter predicate is "has nothing to report", not "passed": buildSummary
sets status "fail" only for error-severity violations, so a warning-only rule
is status "pass" with a non-empty violations[]. Filtering on status alone
would silently swallow every warning — a regression test covers this.

Record the convention as ARCH-003 key convention 7, with a Don't guarding
against that exact misimplementation. Docs updated in all three locales.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
…n lesson

- project_test_isolation_gotchas: the existing entry described the env-leak
  symptom and a consumer-side workaround (resetting git vars in the runCli
  call) but never identified the cause — the restore itself. Record that
  `env.X = undefined` assigns the string "undefined", that Bun.env and
  process.env are one store, and point at restoreEnv.
- project_rules_engine_internals: a reviewer sub-agent will misquote the file
  it is reviewing, not just the ADR it cites — it reported a Norwegian
  misspelling that was not in the file, where applying the "fix" would have
  introduced the error. Grep the claimed string before acting on it.
- MEMORY.md: index entries updated to match.

Also includes an in-flight edit to feedback_prefer_tests_over_adr_rules.md
(ADR rules that only assert implementation shape) authored outside this
change but present in the working tree.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto
rhuanbarreto force-pushed the feat/lean-agent-payloads branch from 03c3665 to 5e8e8ec Compare July 15, 2026 22:43
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_02fba72d-bb6f-41cd-b942-7fbd5c669bef)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration/review-context.test.ts (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove redundant per-test timeouts.

As per coding guidelines, use overrides only to grant genuinely slow tests more time than the global timeout. Setting this to 60000ms is redundant since it matches the global default.

  • tests/integration/review-context.test.ts#L187-187: remove the , 60000 argument from this test.
  • tests/integration/review-context.test.ts#L220-220: remove the , 60000 argument from this test.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/review-context.test.ts` at line 1, Remove the redundant
60000 timeout arguments from the two tests in review-context.test.ts, leaving
their existing test bodies and assertions unchanged so they use the global
timeout.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/check.test.ts`:
- Around line 213-216: Extend the integration test around runCli with a
companion check that runs the ADR-filtered JSON command without --verbose and
verifies clean rules are omitted, then runs it with --verbose and verifies both
passing rule entries are present. Keep the existing exit-code assertions and use
the parsed JSON output to validate the mode-dependent behavior.

---

Outside diff comments:
In `@tests/integration/review-context.test.ts`:
- Line 1: Remove the redundant 60000 timeout arguments from the two tests in
review-context.test.ts, leaving their existing test bodies and assertions
unchanged so they use the global timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cc5a1ae6-6b92-4b29-beac-a107b413023c

📥 Commits

Reviewing files that changed from the base of the PR and between cdc18af and 03c3665.

📒 Files selected for processing (46)
  • .archgate/adrs/ARCH-003-output-formatting.md
  • .archgate/adrs/ARCH-005-testing-standards.md
  • .claude/agent-memory/archgate-developer/MEMORY.md
  • .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md
  • .claude/agent-memory/archgate-developer/project_rules_engine_internals.md
  • .claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md
  • .oxlintrc.json
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • lint/no-bare-env-restore.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
  • src/commands/review-context.ts
  • src/engine/context.ts
  • src/engine/reporter.ts
  • tests/commands/adr/list.test.ts
  • tests/commands/check-action.test.ts
  • tests/commands/clean.test.ts
  • tests/commands/review-context.test.ts
  • tests/commands/upgrade.test.ts
  • tests/engine/context.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/init-project.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/sentry.test.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/check.test.ts
  • tests/integration/review-context.test.ts
  • tests/test-utils.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (20)
**/*.{ts,tsx,js,jsx,mjs,cjs}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-006-dependency-policy.md)

**/*.{ts,tsx,js,jsx,mjs,cjs}: Use Bun built-ins for file I/O (Bun.file, Bun.write), HTTP, subprocess execution (Bun.spawn), globbing (Bun.Glob), and testing (bun:test).
Do not use Node.js-specific APIs when Bun alternatives exist; for example, use Bun.file() instead of fs.readFile() for simple reads.
Prefer node: built-in modules such as node:util, node:path, and node:fs over npm alternatives.
Do not use utility libraries for single functions, such as importing lodash for one helper like pick.
Do not use path aliases (tsconfig paths); use relative imports with Bun's native module resolution.
Do not install packages globally during development; use bunx for one-off tools.

Files:

  • tests/helpers/exit.test.ts
  • tests/commands/review-context.test.ts
  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/output.test.ts
  • tests/commands/check-action.test.ts
  • tests/helpers/sentry.test.ts
  • tests/test-utils.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/integration/check.test.ts
  • src/commands/adr/list.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/init-project.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/commands/adr/list.test.ts
  • src/engine/reporter.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/clean.test.ts
  • lint/no-bare-env-restore.ts
  • tests/engine/context.test.ts
  • src/commands/check.ts
  • src/engine/context.ts
tests/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)

In test files, use _resetPlatformCache() to simulate different platforms instead of mocking or mutating process.platform directly.

tests/**/*.ts: Use Bun's built-in bun:test runner for all tests, importing test utilities from bun:test rather than node:test.
Place tests under tests/, mirroring the corresponding src/ directory structure; place reusable fixtures under tests/fixtures/.
Use temporary directories created with mkdtemp for filesystem tests and clean them up in afterEach or afterAll.
Restore overridden environment variables with restoreEnv(key, original); do not use bare assignments that can leave the literal string "undefined".
Close external SDK instances such as servers, clients, and transports in lifecycle hooks using their cleanup methods.
Configure local Git user.email and user.name immediately after git init before creating commits in temporary repositories.
Test public module interfaces rather than private implementation details, and do not depend on network access in unit tests.
Maintain at least 90% total line coverage, enforced in CI.
Tests must be isolated from network access, temporary-file leaks, external-resource leaks, environment leakage, and real user-scope writes.

Files:

  • tests/helpers/exit.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/output.test.ts
  • tests/commands/check-action.test.ts
  • tests/helpers/sentry.test.ts
  • tests/test-utils.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/integration/check.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/init-project.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/commands/adr/list.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/clean.test.ts
  • tests/engine/context.test.ts
{src,tests}/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/LEGAL-001-spdx-license-headers.md)

{src,tests}/**/*.ts: Every TypeScript source file in src/ and tests/ must begin with // SPDX-License-Identifier: Apache-2.0 followed by // Copyright 2026 Archgate.
If a TypeScript file has a shebang line (for example #!/usr/bin/env bun in src/cli.ts), the SPDX license header must appear immediately after the shebang.
Use single-line // comments for the SPDX header; do not use block comments (/* */) or alternate license identifiers.

Files:

  • tests/helpers/exit.test.ts
  • tests/commands/review-context.test.ts
  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/output.test.ts
  • tests/commands/check-action.test.ts
  • tests/helpers/sentry.test.ts
  • tests/test-utils.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/integration/check.test.ts
  • src/commands/adr/list.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/init-project.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/commands/adr/list.test.ts
  • src/engine/reporter.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/clean.test.ts
  • tests/engine/context.test.ts
  • src/commands/check.ts
  • src/engine/context.ts
tests/**/*.test.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-005-testing-standards.md)

tests/**/*.test.ts: Name test files with the .test.ts suffix and use descriptive names that explain expected behavior.
Every runnable test() or it() must contain at least one expect() assertion; make implicit no-throw contracts explicit with appropriate assertions.
Use test.skip, test.todo, or explicit skip APIs for intentionally disabled tests; do not use bare early returns or empty callbacks.
Import expect from bun:test when adding assertions to an existing test file.
Mock HTTP fetch by assigning directly to globalThis.fetch, and restore the original implementation after each test.
Wrap inline spyOn or mockImplementation lifecycles in try/finally, or manage them in test hooks, so mocks are always restored.
Inject small configurable thresholds into production code when testing large numeric thresholds instead of creating thousands of fixture files.
Never set a per-test timeout below the global bun test --timeout 60000; use overrides only to grant genuinely slow tests more time.
Mock first-party modules with namespace imports and spyOn, not mock.module(); do not split production modules solely to work around mock leakage.
When redirecting user-scope paths, mock os.homedir() rather than relying on runtime HOME overrides; restore the spy afterward.
Do not write real user-scope state; spy out writers or redirect os.homedir() to a temporary directory.
Do not use mock.module("node:fetch", ...) to intercept HTTP calls; it does not replace Bun's globalThis.fetch.
Do not use mock.module() for first-party modules imported by other test files because it is process-global and retroactive.
Do not skip tests without a tracking issue.

Files:

  • tests/helpers/exit.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/output.test.ts
  • tests/commands/check-action.test.ts
  • tests/helpers/sentry.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/integration/check.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/init-project.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/commands/adr/list.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/clean.test.ts
  • tests/engine/context.test.ts
**

⚙️ CodeRabbit configuration file

**: This project uses Archgate — an AI governance framework based on
Architecture Decision Records (ADRs). The ADRs in .archgate/adrs/
are the authoritative rules for this codebase. Each ADR has a companion
.rules.ts file with automated checks that run via archgate check.

When reviewing, you must:

  1. Treat ADR violations as blocking issues, not suggestions.
  2. Cite the specific ADR ID when flagging a violation (e.g., "Violates ARCH-006").
  3. Focus on semantic and contextual violations that automated rules cannot catch —
    the .rules.ts files already cover syntactic/structural patterns.
  4. If you are unsure whether something violates an ADR, flag it as a question
    rather than approving it.

Files:

  • tests/helpers/exit.test.ts
  • tests/commands/review-context.test.ts
  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/output.test.ts
  • tests/commands/check-action.test.ts
  • tests/helpers/sentry.test.ts
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • tests/test-utils.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/plugin-install.test.ts
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/telemetry.test.ts
  • docs/src/content/docs/reference/cli/check.mdx
  • tests/helpers/telemetry-config.test.ts
  • tests/integration/check.test.ts
  • src/commands/adr/list.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/review-context.test.ts
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • tests/helpers/plugin-install-cleanup.test.ts
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • tests/helpers/init-project.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/commands/adr/list.test.ts
  • src/engine/reporter.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/clean.test.ts
  • lint/no-bare-env-restore.ts
  • tests/engine/context.test.ts
  • docs/src/content/docs/reference/cli/review-context.mdx
  • src/commands/check.ts
  • src/engine/context.ts
src/commands/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-001-command-structure.md)

src/commands/**/*.ts: Each command module under src/commands/ must export a register*Command(program) function, with one command per file (or one command group via index.ts).
Command files must be thin: they should only parse arguments, call engine/helpers, and format output; business logic must live in src/engine/, src/helpers/, or src/formats/.
Command modules must not use executableDir() for command discovery, must not call .parse() themselves, and must not spawn child processes for subcommand execution.
Subcommand groups should live in nested directories with an index.ts that composes child commands (for example, src/commands/adr/index.ts).

src/commands/**/*.ts: In command files under src/commands/**/*.ts, options that need type narrowing beyond plain strings MUST use new Option() with .addOption() instead of plain .option().
In src/commands/**/*.ts, import Option from @commander-js/extra-typings alongside Command so typed options get full type inference.
In src/commands/**/*.ts, enum-like options with a fixed set of allowed values must use .choices() on an Option to provide runtime validation and compile-time type narrowing.
In src/commands/**/*.ts, options that require type conversion must use .argParser() on an Option object, not a parser function passed as the third argument to .option().
In src/commands/**/*.ts, register typed options with .addOption() rather than .option().
In src/commands/**/*.ts, pass both the choices array and default values with as const when using .choices() and .default() to preserve literal types.
In src/commands/**/*.ts, do not add manual validation for choice options (for example if (!VALID.includes(val))), because Commander handles invalid-value rejection automatically.

Command modules must export register*Command(program) and contain I/O only; business logic belongs elsewhere.

src/commands/**/*.ts: Commands that operate on .archgate/ project resourc...

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
src/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-004-no-barrel-files.md)

src/**/*.ts: Do not re-export symbols from another module in any source file; statements like export { X } from "./other" and export type { X } from "./other" are forbidden.
Import symbols directly from the module that defines them; do not import from a directory path such as ../formats expecting implicit index.ts resolution.

src/**/*.ts: In Archgate CLI TypeScript source files, all subprocess execution must use Bun.spawn with array-based arguments; Bun.$ shell template literals are forbidden.
Do not import $ from bun in Archgate CLI TypeScript source files, because it exposes the forbidden Bun shell API.
When using Bun.spawn in Archgate CLI TypeScript source files, pass command and arguments as an array and do not use shell features such as pipes (|), redirects (>), or globbing (*) in the subprocess arguments.
After reading subprocess stdout or stderr via Bun.spawn, always await proc.exited to ensure the process has terminated.
Wrap CLI availability checks in try/catch and return a boolean, since the command may not exist on the system.

src/**/*.ts: Use await Bun.file(path).json() when reading JSON files in Bun TypeScript source code; do not use JSON.parse(await Bun.file(path).text()) or JSON.parse(fs.readFileSync(path, "utf-8")) for file reads.
Use Bun.JSONC.parse() when reading files that may contain comments, such as tsconfig.json, instead of plain JSON.parse() on file contents.
Reserve JSON.parse() for parsing JSON strings from non-file sources such as API responses or string variables; do not use it as the default for reading JSON files.

src/**/*.ts: In TypeScript source files under src/, use Bun.env instead of process.env for all environment variable reads and writes; process.env must not be used.
In TypeScript source files under src/, use nullish coalescing for environment-variable defaults, e.g. Bun.env.NODE_ENV ?? "production".
In TypeScript source files under src/, use `Boolean(Bun.env.C...

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/engine/reporter.ts
  • src/commands/check.ts
  • src/engine/context.ts
src/**/!(*platform).ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)

src/**/!(*platform).ts: In src/ TypeScript source files, do not read process.platform directly; use src/helpers/platform.ts (isWindows(), isMacOS(), isLinux(), isWSL(), getPlatformInfo()) for all platform detection.
Use the centralized platform helper instead of duplicating OS/WSL detection logic inline anywhere in src/ TypeScript source.
When behavior differs between Linux and Windows, account for WSL by using isWSL() rather than assuming `

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/engine/reporter.ts
  • src/commands/check.ts
  • src/engine/context.ts
src/commands/{*.ts,*/index.ts}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Every top-level CLI command registered via register*Command(program) must live in src/commands/<name>.ts or src/commands/<name>/index.ts so it can be matched to a docs page.

Files:

  • src/commands/review-context.ts
  • src/commands/check.ts
{src/commands/{*.ts,*/index.ts},docs/src/content/docs/reference/cli/!(index).mdx}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

{src/commands/{*.ts,*/index.ts},docs/src/content/docs/reference/cli/!(index).mdx}: When a top-level command is added, its docs page must be added in the same change; when a top-level command is removed, its matching docs page must be deleted in the same change.
Keep command and documentation stems aligned when renaming a top-level command file; renaming src/commands/<name>.ts or src/commands/<name>/index.ts must be paired with renaming docs/src/content/docs/reference/cli/<name>.mdx.

Files:

  • src/commands/review-context.ts
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • src/commands/check.ts
docs/src/content/docs/**/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

docs/src/content/docs/**/*.mdx: Use MDX (.mdx) for all content pages under docs/src/content/docs/.
Escape literal curly braces in MDX when showing template syntax; do not use bare {} in prose or code-fence labels.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
{docs/src/content/docs/**/*.mdx,docs/astro.config.mjs}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

When adding a new documentation page, create the MDX file in docs/src/content/docs/<category>/<slug>.mdx and add the page to docs/astro.config.mjs sidebar configuration.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/**

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

Do not create documentation content files outside docs/src/content/docs/; Starlight content must live in that exact directory structure.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

docs/src/content/docs/**/*.{mdx,md}: For every English docs page under docs/src/content/docs/, create a translated file in each locale directory with the exact same relative path and filename, and ensure every locale file corresponds to an existing root file (no orphan translations).
When adding or modifying English documentation content, update the corresponding locale files in the same pull request.
Translate all user-facing prose in docs pages, including titles, descriptions, headings, paragraphs, list items, table text, and admonition content.
Translate user-visible text props in Starlight components such as <Card title="..."> and <LinkCard description="...">.
Keep code blocks, CLI commands, file paths, TypeScript identifiers, technical terms, import statements, component names, and link/href/slug attribute values in English.
Keep internal links unchanged and do not add locale prefixes (for example, use /guides/... rather than /pt-br/guides/...).
Preserve MDX curly-brace escaping (\{\}) in translated content.
Preserve Starlight component import statements identically in translated files.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/nb/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

Use Norwegian Bokmål (not Nynorsk) for Norwegian translations, with the informal du form and correct Norwegian characters (æ, ø, å).

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
docs/src/content/docs/pt-br/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

Use correct Portuguese diacritical marks in Brazilian Portuguese translations; never write unaccented Portuguese.

Files:

  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
docs/src/content/docs/reference/cli/!(index).mdx

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Every top-level CLI command must have a corresponding reference page at docs/src/content/docs/reference/cli/<name>.mdx, and every non-index.mdx page in that directory must correspond to exactly one top-level command.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/reference/cli/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Do not create separate reference pages for subcommands; subcommand documentation must stay inline within the parent command’s .mdx page.

Every parent CLI reference page in docs/src/content/docs/reference/cli/ must contain headings for its direct subcommands using the exact archgate <parent> <sub> format, and must not keep headings for subcommands that no longer exist.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/reference/**/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

Keep reference pages accurate to the CLI source code; when CLI APIs change, update the corresponding reference docs in the same PR.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
src/{helpers,engine}/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-002-error-handling.md)

Do not use console.log(), console.warn(), or console.info() directly in helper or engine files; use logInfo() or logWarn() instead.

Files:

  • src/engine/reporter.ts
  • src/engine/context.ts
🧠 Learnings (2)
📚 Learning: 2026-06-11T12:50:28.661Z
Learnt from: rhuanbarreto
Repo: archgate/cli PR: 406
File: .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md:8-18
Timestamp: 2026-06-11T12:50:28.661Z
Learning: In `archgate/cli`, for markdown files under `.claude/agent-memory/`, follow the established convention: use YAML frontmatter (with a `name:` field used as the document title) and do not require a top-level `#` (H1) heading. During code review, do not flag missing first-line/first-top-level H1 headings (e.g., MD041) for these agent-memory files since markdownlint is not part of the repo’s `bun run validate` lint pipeline (oxlint/oxfmt only).

Applied to files:

  • .claude/agent-memory/archgate-developer/project_rules_engine_internals.md
  • .claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md
  • .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md
  • .claude/agent-memory/archgate-developer/MEMORY.md
📚 Learning: 2026-07-11T13:03:15.386Z
Learnt from: rhuanbarreto
Repo: archgate/cli PR: 467
File: .archgate/adrs/ARCH-011-consistent-project-root-resolution.md:0-0
Timestamp: 2026-07-11T13:03:15.386Z
Learning: For Markdown files formatted by oxfmt (especially ADRs), avoid inline code spans that contain escaped backticks, e.g. `\`...\`` inside a single `` `...` `` span. oxfmt may mis-parse these and, on re-format, can collapse spaces after later inline code spans on the same line, effectively removing any manually re-added spacing. Instead, rephrase the text so the message stays plain quoted text, and put any embedded command/fragment that needs code formatting (e.g., `archgate init`) in its own separate inline code span; keep surrounding punctuation/spacing outside the code span.

Applied to files:

  • .archgate/adrs/ARCH-005-testing-standards.md
  • .archgate/adrs/ARCH-003-output-formatting.md
🪛 LanguageTool
.claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md

[style] ~10-~10: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s NOT unset.** So the idiomatic-looking const orig = Bun.env.X; …; Bun.env.X = orig silently leaks X="undefined" ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

docs/src/content/docs/pt-br/reference/cli/review-context.mdx

[uncategorized] ~32-~32: Pontuação duplicada
Context: ...isar com archgate adr show <id>. Use --verbose para incorporar na resposta o t...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~32-~32: Pontuação duplicada
Context: ...o e busque os detalhes sob demanda; use --verbose apenas quando um único payload ...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~34-~34: Pontuação duplicada
Context: ...ntido for realmente necessário. Quando --run-checks é usado, checkSummary segu...

(DOUBLE_PUNCTUATION_XML)

.archgate/adrs/ARCH-005-testing-standards.md

[style] ~67-~67: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rocess.env.X = originalassignment** —env.X = undefined` assigns the literal string...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

.claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md

[style] ~12-~12: Possibly, ‘actually’ is redundant. Consider using “only”.
Context: ...he rules — _"your proposal for rules is actually only testing the implementation and not the ...

(ADVERB_ONLY)

docs/src/content/docs/pt-br/reference/cli/check.mdx

[uncategorized] ~132-~132: Pontuação duplicada
Context: ...lse. ## Formato da saída JSON Quando --json` é usado, a saída é um único objeto...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~134-~134: Pontuação duplicada
Context: ...ecutadas e quantas foram aprovadas. Use --verbose para incluir todas as regras em...

(DOUBLE_PUNCTUATION_XML)

🔇 Additional comments (64)
.claude/agent-memory/archgate-developer/MEMORY.md (2)

24-24: LGTM!


45-45: LGTM!

.claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md (3)

3-3: LGTM!


12-12: LGTM!


16-17: LGTM!

.claude/agent-memory/archgate-developer/project_rules_engine_internals.md (1)

12-12: LGTM!

.claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md (1)

10-10: LGTM!

.archgate/adrs/ARCH-005-testing-standards.md (2)

43-43: LGTM!

Also applies to: 67-67, 234-234, 252-252


43-43: LGTM!

Also applies to: 67-67, 234-234, 252-252

.oxlintrc.json (2)

2-6: LGTM!

Also applies to: 26-29


2-6: LGTM!

Also applies to: 26-29

lint/no-bare-env-restore.ts (2)

1-183: LGTM!


1-183: LGTM!

tests/helpers/binary-upgrade.test.ts (2)

26-26: LGTM!

Also applies to: 468-468


26-26: LGTM!

Also applies to: 468-468

tests/helpers/telemetry-config.test.ts (2)

8-9: LGTM!

Also applies to: 24-28, 237-237


8-9: LGTM!

Also applies to: 24-28, 237-237

tests/helpers/telemetry.test.ts (2)

8-9: LGTM!

Also applies to: 29-34


8-9: LGTM!

Also applies to: 29-34

tests/helpers/update-check.test.ts (2)

12-12: LGTM!

Also applies to: 73-73, 297-303


12-12: LGTM!

Also applies to: 73-73, 297-303

tests/helpers/vscode-settings.test.ts (2)

21-33: LGTM!

Also applies to: 112-112, 174-174, 326-326, 343-343


21-33: LGTM!

Also applies to: 112-112, 174-174, 326-326, 343-343

tests/test-utils.ts (1)

30-46: LGTM!

tests/commands/check-action.test.ts (1)

24-24: LGTM!

Also applies to: 303-303

tests/commands/clean.test.ts (1)

17-17: LGTM!

Also applies to: 61-62

tests/commands/upgrade.test.ts (1)

19-19: LGTM!

Also applies to: 71-73

tests/helpers/auth.test.ts (1)

8-9: LGTM!

Also applies to: 38-47

tests/helpers/exit.test.ts (1)

13-13: LGTM!

Also applies to: 25-25

tests/helpers/init-project.test.ts (1)

12-12: LGTM!

Also applies to: 216-217

tests/helpers/opencode-settings.test.ts (1)

13-13: LGTM!

Also applies to: 61-62, 85-85

tests/helpers/credential-store.test.ts (2)

13-13: LGTM!


35-41: LGTM!

tests/helpers/output.test.ts (2)

6-6: LGTM!


16-16: LGTM!

tests/helpers/platform.test.ts (2)

14-14: LGTM!


183-184: LGTM!

tests/helpers/plugin-install-cleanup.test.ts (2)

31-31: LGTM!


110-111: LGTM!

tests/helpers/plugin-install.test.ts (2)

37-37: LGTM!


126-127: LGTM!

tests/helpers/sentry.test.ts (2)

8-9: LGTM!


27-32: LGTM!

tests/helpers/session-context-copilot.test.ts (2)

12-12: LGTM!


37-37: LGTM!

tests/helpers/session-context-opencode.test.ts (2)

13-13: LGTM!


40-40: LGTM!

.archgate/adrs/ARCH-003-output-formatting.md (1)

36-36: LGTM!

Also applies to: 48-48, 60-61, 155-155, 178-178

src/commands/adr/list.ts (1)

9-25: LGTM!

Also applies to: 61-61

src/engine/reporter.ts (1)

47-63: LGTM!

Also applies to: 268-294

src/commands/check.ts (1)

142-147: LGTM!

tests/commands/adr/list.test.ts (1)

34-46: LGTM!

Also applies to: 148-175

tests/engine/reporter.test.ts (1)

138-180: LGTM!

docs/src/content/docs/nb/reference/cli/check.mdx (1)

132-134: LGTM!

docs/src/content/docs/pt-br/reference/cli/check.mdx (1)

132-134: LGTM!

docs/src/content/docs/reference/cli/check.mdx (1)

132-134: LGTM!

src/commands/review-context.ts (1)

25-28: LGTM!

Also applies to: 44-47

tests/commands/review-context.test.ts (1)

55-62: LGTM!

src/engine/context.ts (1)

11-289: LGTM!

tests/engine/context.test.ts (1)

84-265: LGTM!

docs/src/content/docs/nb/reference/cli/review-context.mdx (1)

20-34: LGTM!

docs/src/content/docs/pt-br/reference/cli/review-context.mdx (1)

20-34: LGTM!

docs/src/content/docs/reference/cli/review-context.mdx (1)

20-34: LGTM!

tests/integration/review-context.test.ts (1)

179-181: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove duplicate property declarations.

There are multiple identical checkSummary property declarations here, likely due to a copy-paste error.

♻️ Proposed fix
     const ctx = JSON.parse(stdout) as {
       checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
     };
			> Likely an incorrect or invalid review comment.

Comment thread tests/integration/check.test.ts
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.8% (7848 / 8644)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 89.0% 1959 / 2200
src/engine/ 92.0% 1749 / 1901
src/formats/ 98.7% 148 / 150
src/helpers/ 90.9% 3992 / 4393

…timeouts

reporter.test.ts exercises reportJSON directly, so nothing caught check.ts
passing the wrong verbose value through to it. The --adr filter test covers
verbose=true (it asserts per-rule entries are present), but a hardcoded true
would have shipped undetected. Add an end-to-end test asserting the default
omits a cleanly-passing rule while the counts still report it, and that
--verbose restores the entry. Fire-tested: hardcoding verbose=true in check.ts
fails exactly this test.

Also drop the `, 60000` per-test overrides from the two new review-context
tests. ARCH-005 permits an override solely to grant a genuinely slow test MORE
time than the global `--timeout 60000`; an override equal to the global grants
nothing.

Both raised in CodeRabbit review of #476.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_ac4d1846-6701-4f9e-bf8f-7e3a49f4ff29)

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/engine/reporter.ts`:
- Line 294: Replace the direct console.log call in the reporter output path with
process.stdout.write, preserving formatJSON(payload, forcePretty) exactly and
explicitly appending a newline so the emitted output remains pure JSON with
equivalent line termination.

In `@tests/commands/adr/list.test.ts`:
- Around line 151-154: Replace the writeFileSync call in the ADR list test setup
with Bun.write, preserving the existing target path and ADR_CONTENT_WITH_FILES
contents.

In `@tests/commands/clean.test.ts`:
- Around line 61-62: Replace HOME/USERPROFILE environment overrides with an
os.homedir() spy in tests/commands/clean.test.ts (61-62),
tests/commands/upgrade.test.ts (71-73), and tests/helpers/auth.test.ts (38-47);
replace the HOME override/restore with the same spy in
tests/helpers/init-project.test.ts (216-217) and
tests/helpers/opencode-settings.test.ts (61-62). Configure each spy to return
the test home path and restore it after each test, removing the corresponding
environment restoration calls.

In `@tests/commands/review-context.test.ts`:
- Around line 56-62: Extend the test around registerReviewContextCommand to
execute the review-context command or spy on buildReviewContext, verifying that
--verbose forwards briefings: true and invocation without --verbose leaves
briefings unset or false. Retain the existing registration assertion, and use
the command’s established execution and dependency setup.

In `@tests/helpers/telemetry-config.test.ts`:
- Around line 24-28: Replace HOME environment overrides and restorations with
os.homedir() spies, restoring each spy after its test. In
tests/helpers/telemetry-config.test.ts lines 24-28 and
tests/helpers/telemetry.test.ts lines 29-34, remove HOME handling and mock
os.homedir(); in tests/helpers/binary-upgrade.test.ts line 468,
tests/helpers/session-context-copilot.test.ts line 37, and
tests/helpers/update-check.test.ts lines 73 and 297-303, replace HOME
restoration with restoration of the os.homedir mock.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4caa3d24-38ed-4205-9fc7-f1868c5869f5

📥 Commits

Reviewing files that changed from the base of the PR and between 03c3665 and 4c5daa6.

📒 Files selected for processing (47)
  • .archgate/adrs/ARCH-003-output-formatting.md
  • .archgate/adrs/ARCH-005-testing-standards.md
  • .claude/agent-memory/archgate-developer/MEMORY.md
  • .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md
  • .claude/agent-memory/archgate-developer/project_rules_engine_internals.md
  • .claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md
  • .oxlintrc.json
  • docs/public/llms-full.txt
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • lint/no-bare-env-restore.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
  • src/commands/review-context.ts
  • src/engine/context.ts
  • src/engine/reporter.ts
  • tests/commands/adr/list.test.ts
  • tests/commands/check-action.test.ts
  • tests/commands/clean.test.ts
  • tests/commands/review-context.test.ts
  • tests/commands/upgrade.test.ts
  • tests/engine/context.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/init-project.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/platform.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/helpers/sentry.test.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/vscode-settings.test.ts
  • tests/integration/check.test.ts
  • tests/integration/review-context.test.ts
  • tests/test-utils.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Smoke Test (Windows) / Windows
  • GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (20)
src/commands/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-001-command-structure.md)

src/commands/**/*.ts: Each command module under src/commands/ must export a register*Command(program) function, with one command per file (or one command group via index.ts).
Command files must be thin: they should only parse arguments, call engine/helpers, and format output; business logic must live in src/engine/, src/helpers/, or src/formats/.
Command modules must not use executableDir() for command discovery, must not call .parse() themselves, and must not spawn child processes for subcommand execution.
Subcommand groups should live in nested directories with an index.ts that composes child commands (for example, src/commands/adr/index.ts).

src/commands/**/*.ts: In command files under src/commands/**/*.ts, options that need type narrowing beyond plain strings MUST use new Option() with .addOption() instead of plain .option().
In src/commands/**/*.ts, import Option from @commander-js/extra-typings alongside Command so typed options get full type inference.
In src/commands/**/*.ts, enum-like options with a fixed set of allowed values must use .choices() on an Option to provide runtime validation and compile-time type narrowing.
In src/commands/**/*.ts, options that require type conversion must use .argParser() on an Option object, not a parser function passed as the third argument to .option().
In src/commands/**/*.ts, register typed options with .addOption() rather than .option().
In src/commands/**/*.ts, pass both the choices array and default values with as const when using .choices() and .default() to preserve literal types.
In src/commands/**/*.ts, do not add manual validation for choice options (for example if (!VALID.includes(val))), because Commander handles invalid-value rejection automatically.

Command modules must export register*Command(program) and contain I/O only; business logic belongs elsewhere.

src/commands/**/*.ts: Commands that operate on .archgate/ project resourc...

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
src/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-004-no-barrel-files.md)

src/**/*.ts: Do not re-export symbols from another module in any source file; statements like export { X } from "./other" and export type { X } from "./other" are forbidden.
Import symbols directly from the module that defines them; do not import from a directory path such as ../formats expecting implicit index.ts resolution.

src/**/*.ts: In Archgate CLI TypeScript source files, all subprocess execution must use Bun.spawn with array-based arguments; Bun.$ shell template literals are forbidden.
Do not import $ from bun in Archgate CLI TypeScript source files, because it exposes the forbidden Bun shell API.
When using Bun.spawn in Archgate CLI TypeScript source files, pass command and arguments as an array and do not use shell features such as pipes (|), redirects (>), or globbing (*) in the subprocess arguments.
After reading subprocess stdout or stderr via Bun.spawn, always await proc.exited to ensure the process has terminated.
Wrap CLI availability checks in try/catch and return a boolean, since the command may not exist on the system.

src/**/*.ts: Use await Bun.file(path).json() when reading JSON files in Bun TypeScript source code; do not use JSON.parse(await Bun.file(path).text()) or JSON.parse(fs.readFileSync(path, "utf-8")) for file reads.
Use Bun.JSONC.parse() when reading files that may contain comments, such as tsconfig.json, instead of plain JSON.parse() on file contents.
Reserve JSON.parse() for parsing JSON strings from non-file sources such as API responses or string variables; do not use it as the default for reading JSON files.

src/**/*.ts: In TypeScript source files under src/, use Bun.env instead of process.env for all environment variable reads and writes; process.env must not be used.
In TypeScript source files under src/, use nullish coalescing for environment-variable defaults, e.g. Bun.env.NODE_ENV ?? "production".
In TypeScript source files under src/, use `Boolean(Bun.env.C...

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
  • src/engine/reporter.ts
  • src/engine/context.ts
**/*.{ts,tsx,js,jsx,mjs,cjs}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-006-dependency-policy.md)

**/*.{ts,tsx,js,jsx,mjs,cjs}: Use Bun built-ins for file I/O (Bun.file, Bun.write), HTTP, subprocess execution (Bun.spawn), globbing (Bun.Glob), and testing (bun:test).
Do not use Node.js-specific APIs when Bun alternatives exist; for example, use Bun.file() instead of fs.readFile() for simple reads.
Prefer node: built-in modules such as node:util, node:path, and node:fs over npm alternatives.
Do not use utility libraries for single functions, such as importing lodash for one helper like pick.
Do not use path aliases (tsconfig paths); use relative imports with Bun's native module resolution.
Do not install packages globally during development; use bunx for one-off tools.

Files:

  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/init-project.test.ts
  • src/commands/adr/list.ts
  • tests/integration/check.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/commands/clean.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • src/commands/check.ts
  • tests/test-utils.ts
  • tests/helpers/platform.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/adr/list.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/sentry.test.ts
  • tests/engine/context.test.ts
  • tests/commands/check-action.test.ts
  • src/engine/reporter.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/update-check.test.ts
  • lint/no-bare-env-restore.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/vscode-settings.test.ts
  • src/engine/context.ts
src/**/!(*platform).ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)

src/**/!(*platform).ts: In src/ TypeScript source files, do not read process.platform directly; use src/helpers/platform.ts (isWindows(), isMacOS(), isLinux(), isWSL(), getPlatformInfo()) for all platform detection.
Use the centralized platform helper instead of duplicating OS/WSL detection logic inline anywhere in src/ TypeScript source.
When behavior differs between Linux and Windows, account for WSL by using isWSL() rather than assuming `

Files:

  • src/commands/review-context.ts
  • src/commands/adr/list.ts
  • src/commands/check.ts
  • src/engine/reporter.ts
  • src/engine/context.ts
src/commands/{*.ts,*/index.ts}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Every top-level CLI command registered via register*Command(program) must live in src/commands/<name>.ts or src/commands/<name>/index.ts so it can be matched to a docs page.

Files:

  • src/commands/review-context.ts
  • src/commands/check.ts
{src/commands/{*.ts,*/index.ts},docs/src/content/docs/reference/cli/!(index).mdx}

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

{src/commands/{*.ts,*/index.ts},docs/src/content/docs/reference/cli/!(index).mdx}: When a top-level command is added, its docs page must be added in the same change; when a top-level command is removed, its matching docs page must be deleted in the same change.
Keep command and documentation stems aligned when renaming a top-level command file; renaming src/commands/<name>.ts or src/commands/<name>/index.ts must be paired with renaming docs/src/content/docs/reference/cli/<name>.mdx.

Files:

  • src/commands/review-context.ts
  • src/commands/check.ts
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
{src,tests}/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/LEGAL-001-spdx-license-headers.md)

{src,tests}/**/*.ts: Every TypeScript source file in src/ and tests/ must begin with // SPDX-License-Identifier: Apache-2.0 followed by // Copyright 2026 Archgate.
If a TypeScript file has a shebang line (for example #!/usr/bin/env bun in src/cli.ts), the SPDX license header must appear immediately after the shebang.
Use single-line // comments for the SPDX header; do not use block comments (/* */) or alternate license identifiers.

Files:

  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/init-project.test.ts
  • src/commands/adr/list.ts
  • tests/integration/check.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/commands/clean.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • src/commands/check.ts
  • tests/test-utils.ts
  • tests/helpers/platform.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/adr/list.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/sentry.test.ts
  • tests/engine/context.test.ts
  • tests/commands/check-action.test.ts
  • src/engine/reporter.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/vscode-settings.test.ts
  • src/engine/context.ts
**

⚙️ CodeRabbit configuration file

**: This project uses Archgate — an AI governance framework based on
Architecture Decision Records (ADRs). The ADRs in .archgate/adrs/
are the authoritative rules for this codebase. Each ADR has a companion
.rules.ts file with automated checks that run via archgate check.

When reviewing, you must:

  1. Treat ADR violations as blocking issues, not suggestions.
  2. Cite the specific ADR ID when flagging a violation (e.g., "Violates ARCH-006").
  3. Focus on semantic and contextual violations that automated rules cannot catch —
    the .rules.ts files already cover syntactic/structural patterns.
  4. If you are unsure whether something violates an ADR, flag it as a question
    rather than approving it.

Files:

  • src/commands/review-context.ts
  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/init-project.test.ts
  • src/commands/adr/list.ts
  • tests/integration/check.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/commands/clean.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • src/commands/check.ts
  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • tests/test-utils.ts
  • tests/helpers/platform.test.ts
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • tests/commands/upgrade.test.ts
  • tests/commands/adr/list.test.ts
  • docs/public/llms-full.txt
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/sentry.test.ts
  • tests/engine/context.test.ts
  • tests/commands/check-action.test.ts
  • docs/src/content/docs/reference/cli/check.mdx
  • src/engine/reporter.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/telemetry.test.ts
  • docs/src/content/docs/reference/cli/review-context.mdx
  • tests/integration/review-context.test.ts
  • tests/helpers/update-check.test.ts
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
  • lint/no-bare-env-restore.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/vscode-settings.test.ts
  • src/engine/context.ts
tests/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)

In test files, use _resetPlatformCache() to simulate different platforms instead of mocking or mutating process.platform directly.

tests/**/*.ts: Use Bun's built-in bun:test runner for all tests, and import test utilities from bun:test rather than node:test.
Shared test helpers must also restore environment variables with restoreEnv; do not rely on the test-only lint rule to cover helper files.

Files:

  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/init-project.test.ts
  • tests/integration/check.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/commands/clean.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/test-utils.ts
  • tests/helpers/platform.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/adr/list.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/sentry.test.ts
  • tests/engine/context.test.ts
  • tests/commands/check-action.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/vscode-settings.test.ts
tests/**/*.test.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-005-testing-standards.md)

tests/**/*.test.ts: Place tests under tests/ mirroring the src/ structure, and name test files with the .test.ts suffix.
Use isolated temporary directories created with mkdtemp for filesystem tests and clean them up in afterEach or afterAll.
Close external SDK resources such as servers, clients, and transports in lifecycle hooks using their cleanup methods.
When committing in a temporary Git repository, configure local user.email and user.name immediately after git init.
Test public module interfaces rather than private implementation details, avoid network access in unit tests, and use descriptive behavior-focused test names.
Every runnable test() or it() must contain at least one expect() assertion; express does-not-throw contracts with explicit assertions, and use test.skip or test.todo for intentional placeholders.
Restore environment variables with restoreEnv(key, original) rather than assigning a captured value directly to Bun.env or process.env.
Mock HTTP requests by assigning directly to globalThis.fetch and restore the original implementation after each test; do not mock node:fetch.
Mock first-party modules with import * as mod and spyOn(mod, "fn"), not process-global mock.module(). Reserve mock.module() for suitable third-party modules.
Wrap inline spyOn or mockImplementation usage in try/finally so mockRestore() always executes, or manage spies in beforeEach and afterEach.
When redirecting user-scope paths, mock os.homedir() rather than relying on runtime HOME overrides; restore the spy after each test.
Make large production thresholds injectable and use small injected values in tests instead of creating thousands of fixture files.
Per-test timeout overrides may exceed the global 60-second timeout, but must never be shorter than it.
Do not write real user-scope state; spy out the writer or redirect os.homedir() to an isolated mkdtemp directory.
Do not skip tests without a tracking issue, ...

Files:

  • tests/helpers/session-context-copilot.test.ts
  • tests/helpers/credential-store.test.ts
  • tests/commands/review-context.test.ts
  • tests/helpers/opencode-settings.test.ts
  • tests/helpers/init-project.test.ts
  • tests/integration/check.test.ts
  • tests/helpers/output.test.ts
  • tests/helpers/plugin-install.test.ts
  • tests/commands/clean.test.ts
  • tests/helpers/session-context-opencode.test.ts
  • tests/helpers/binary-upgrade.test.ts
  • tests/helpers/plugin-install-cleanup.test.ts
  • tests/helpers/platform.test.ts
  • tests/commands/upgrade.test.ts
  • tests/commands/adr/list.test.ts
  • tests/helpers/telemetry-config.test.ts
  • tests/helpers/exit.test.ts
  • tests/helpers/sentry.test.ts
  • tests/engine/context.test.ts
  • tests/commands/check-action.test.ts
  • tests/engine/reporter.test.ts
  • tests/helpers/telemetry.test.ts
  • tests/integration/review-context.test.ts
  • tests/helpers/update-check.test.ts
  • tests/helpers/auth.test.ts
  • tests/helpers/vscode-settings.test.ts
docs/src/content/docs/**/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

docs/src/content/docs/**/*.mdx: Use MDX (.mdx) for all content pages under docs/src/content/docs/.
Escape literal curly braces in MDX when showing template syntax; do not use bare {} in prose or code-fence labels.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
{docs/src/content/docs/**/*.mdx,docs/astro.config.mjs}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

When adding a new documentation page, create the MDX file in docs/src/content/docs/<category>/<slug>.mdx and add the page to docs/astro.config.mjs sidebar configuration.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
docs/src/content/docs/**

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

Do not create documentation content files outside docs/src/content/docs/; Starlight content must live in that exact directory structure.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
docs/src/content/docs/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

docs/src/content/docs/**/*.{mdx,md}: For every English docs page under docs/src/content/docs/, create a translated file in each locale directory with the exact same relative path and filename, and ensure every locale file corresponds to an existing root file (no orphan translations).
When adding or modifying English documentation content, update the corresponding locale files in the same pull request.
Translate all user-facing prose in docs pages, including titles, descriptions, headings, paragraphs, list items, table text, and admonition content.
Translate user-visible text props in Starlight components such as <Card title="..."> and <LinkCard description="...">.
Keep code blocks, CLI commands, file paths, TypeScript identifiers, technical terms, import statements, component names, and link/href/slug attribute values in English.
Keep internal links unchanged and do not add locale prefixes (for example, use /guides/... rather than /pt-br/guides/...).
Preserve MDX curly-brace escaping (\{\}) in translated content.
Preserve Starlight component import statements identically in translated files.

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
docs/src/content/docs/nb/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

Use Norwegian Bokmål (not Nynorsk) for Norwegian translations, with the informal du form and correct Norwegian characters (æ, ø, å).

Files:

  • docs/src/content/docs/nb/reference/cli/check.mdx
  • docs/src/content/docs/nb/reference/cli/review-context.mdx
docs/src/content/docs/pt-br/**/*.{mdx,md}

📄 CodeRabbit inference engine (.archgate/adrs/GEN-002-docs-i18n.md)

Use correct Portuguese diacritical marks in Brazilian Portuguese translations; never write unaccented Portuguese.

Files:

  • docs/src/content/docs/pt-br/reference/cli/check.mdx
  • docs/src/content/docs/pt-br/reference/cli/review-context.mdx
docs/src/content/docs/reference/cli/!(index).mdx

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Every top-level CLI command must have a corresponding reference page at docs/src/content/docs/reference/cli/<name>.mdx, and every non-index.mdx page in that directory must correspond to exactly one top-level command.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/reference/cli/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-015-cli-command-documentation-coverage.md)

Do not create separate reference pages for subcommands; subcommand documentation must stay inline within the parent command’s .mdx page.

Every parent CLI reference page in docs/src/content/docs/reference/cli/ must contain headings for its direct subcommands using the exact archgate <parent> <sub> format, and must not keep headings for subcommands that no longer exist.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
docs/src/content/docs/reference/**/*.mdx

📄 CodeRabbit inference engine (.archgate/adrs/GEN-001-documentation-site.md)

Keep reference pages accurate to the CLI source code; when CLI APIs change, update the corresponding reference docs in the same PR.

Files:

  • docs/src/content/docs/reference/cli/check.mdx
  • docs/src/content/docs/reference/cli/review-context.mdx
src/{helpers,engine}/**/*.ts

📄 CodeRabbit inference engine (.archgate/adrs/ARCH-002-error-handling.md)

Do not use console.log(), console.warn(), or console.info() directly in helper or engine files; use logInfo() or logWarn() instead.

Files:

  • src/engine/reporter.ts
  • src/engine/context.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: archgate/cli

Timestamp: 2026-07-15T22:45:33.463Z
Learning: Maintain at least 90% total line coverage, enforced in CI; coverage below the threshold blocks the pull request.
Learnt from: CR
Repo: archgate/cli

Timestamp: 2026-07-15T22:45:33.463Z
Learning: Every source file must have a corresponding test file under the mirrored `tests/` path.
📚 Learning: 2026-06-11T12:50:28.661Z
Learnt from: rhuanbarreto
Repo: archgate/cli PR: 406
File: .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md:8-18
Timestamp: 2026-06-11T12:50:28.661Z
Learning: In `archgate/cli`, for markdown files under `.claude/agent-memory/`, follow the established convention: use YAML frontmatter (with a `name:` field used as the document title) and do not require a top-level `#` (H1) heading. During code review, do not flag missing first-line/first-top-level H1 headings (e.g., MD041) for these agent-memory files since markdownlint is not part of the repo’s `bun run validate` lint pipeline (oxlint/oxfmt only).

Applied to files:

  • .claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md
  • .claude/agent-memory/archgate-developer/project_rules_engine_internals.md
  • .claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md
  • .claude/agent-memory/archgate-developer/MEMORY.md
📚 Learning: 2026-07-11T13:03:15.386Z
Learnt from: rhuanbarreto
Repo: archgate/cli PR: 467
File: .archgate/adrs/ARCH-011-consistent-project-root-resolution.md:0-0
Timestamp: 2026-07-11T13:03:15.386Z
Learning: For Markdown files formatted by oxfmt (especially ADRs), avoid inline code spans that contain escaped backticks, e.g. `\`...\`` inside a single `` `...` `` span. oxfmt may mis-parse these and, on re-format, can collapse spaces after later inline code spans on the same line, effectively removing any manually re-added spacing. Instead, rephrase the text so the message stays plain quoted text, and put any embedded command/fragment that needs code formatting (e.g., `archgate init`) in its own separate inline code span; keep surrounding punctuation/spacing outside the code span.

Applied to files:

  • .archgate/adrs/ARCH-005-testing-standards.md
  • .archgate/adrs/ARCH-003-output-formatting.md
🪛 LanguageTool
.claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md

[style] ~10-~10: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s NOT unset.** So the idiomatic-looking const orig = Bun.env.X; …; Bun.env.X = orig silently leaks X="undefined" ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

docs/src/content/docs/pt-br/reference/cli/check.mdx

[uncategorized] ~132-~132: Pontuação duplicada
Context: ...lse. ## Formato da saída JSON Quando --json` é usado, a saída é um único objeto...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~134-~134: Pontuação duplicada
Context: ...ecutadas e quantas foram aprovadas. Use --verbose para incluir todas as regras em...

(DOUBLE_PUNCTUATION_XML)

.archgate/adrs/ARCH-005-testing-standards.md

[style] ~67-~67: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rocess.env.X = originalassignment** —env.X = undefined` assigns the literal string...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

.claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md

[style] ~12-~12: Possibly, ‘actually’ is redundant. Consider using “only”.
Context: ...he rules — _"your proposal for rules is actually only testing the implementation and not the ...

(ADVERB_ONLY)

docs/src/content/docs/pt-br/reference/cli/review-context.mdx

[uncategorized] ~32-~32: Pontuação duplicada
Context: ...isar com archgate adr show <id>. Use --verbose para incorporar na resposta o t...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~32-~32: Pontuação duplicada
Context: ...o e busque os detalhes sob demanda; use --verbose apenas quando um único payload ...

(DOUBLE_PUNCTUATION_XML)


[uncategorized] ~34-~34: Pontuação duplicada
Context: ...ntido for realmente necessário. Quando --run-checks é usado, checkSummary segu...

(DOUBLE_PUNCTUATION_XML)

🪛 markdownlint-cli2 (0.23.0)
.claude/agent-memory/archgate-developer/project_rules_engine_internals.md

[warning] 8-8: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

🔇 Additional comments (36)
.claude/agent-memory/archgate-developer/MEMORY.md (1)

24-25: LGTM!

Also applies to: 45-45

.claude/agent-memory/archgate-developer/feedback_prefer_tests_over_adr_rules.md (1)

3-3: LGTM!

Also applies to: 12-17

.claude/agent-memory/archgate-developer/project_rules_engine_internals.md (1)

8-9: LGTM!

Also applies to: 14-14

.claude/agent-memory/archgate-developer/project_test_isolation_gotchas.md (1)

10-10: LGTM!

.archgate/adrs/ARCH-003-output-formatting.md (1)

36-36: LGTM!

Also applies to: 48-48, 60-61, 155-155, 178-178

src/commands/adr/list.ts (1)

9-25: LGTM!

Also applies to: 61-61

src/commands/check.ts (1)

142-147: LGTM!

tests/engine/reporter.test.ts (1)

138-149: LGTM!

Also applies to: 151-158, 159-166, 167-180

docs/public/llms-full.txt (1)

4081-4083: LGTM!

Also applies to: 4555-4570

docs/src/content/docs/nb/reference/cli/check.mdx (1)

132-134: LGTM!

docs/src/content/docs/pt-br/reference/cli/check.mdx (1)

132-134: LGTM!

docs/src/content/docs/reference/cli/check.mdx (1)

132-134: LGTM!

src/commands/review-context.ts (1)

25-28: LGTM!

Also applies to: 44-47

src/engine/context.ts (1)

11-11: LGTM!

Also applies to: 20-23, 83-84, 99-136, 172-172, 185-187, 240-241, 266-269, 281-289

tests/engine/context.test.ts (1)

84-84: LGTM!

Also applies to: 93-106, 123-124, 135-135, 145-145, 154-160, 248-265

tests/integration/review-context.test.ts (2)

109-111: LGTM!

Also applies to: 149-178, 182-187, 189-220


179-181: 📐 Maintainability & Code Quality | 🟡 Minor | 💤 Low value

Remove duplicated property declarations.

The checkSummary property declaration has been duplicated multiple times, likely due to a copy-paste error. This should be cleaned up to a single property definition.

🧹 Proposed fix
     const ctx = JSON.parse(stdout) as {
       checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
-      checkSummary: { total: number; passed: number; results: unknown[] };
     };
			> Likely an incorrect or invalid review comment.
docs/src/content/docs/nb/reference/cli/review-context.mdx (1)

20-21: LGTM!

Also applies to: 22-27, 28-34

docs/src/content/docs/pt-br/reference/cli/review-context.mdx (1)

20-21: LGTM!

Also applies to: 22-27, 28-34

docs/src/content/docs/reference/cli/review-context.mdx (1)

20-21: LGTM!

Also applies to: 22-27, 28-34

tests/integration/check.test.ts (1)

213-216: 🎯 Functional Correctness | ⚡ Quick win

Assert both verbose and non-verbose output modes.

This change updates the existing invocation to use --verbose but still does not verify that the default (non-verbose) JSON output actually omits cleanly-passing rules. Please add a companion assertion that runs the command without --verbose and verifies the default output behavior, as previously requested.

.archgate/adrs/ARCH-005-testing-standards.md (1)

43-43: LGTM!

Also applies to: 67-67, 234-234, 252-252

.oxlintrc.json (1)

2-6: LGTM!

Also applies to: 26-29

lint/no-bare-env-restore.ts (1)

1-182: LGTM!

tests/helpers/exit.test.ts (1)

13-13: LGTM!

Also applies to: 25-25

tests/helpers/vscode-settings.test.ts (1)

21-34: LGTM!

Also applies to: 112-112, 174-174, 326-326, 343-343

tests/test-utils.ts (1)

30-46: LGTM!

tests/commands/check-action.test.ts (1)

24-24: LGTM!

Also applies to: 303-303

tests/helpers/opencode-settings.test.ts (1)

85-85: LGTM!

tests/helpers/session-context-opencode.test.ts (1)

13-13: LGTM!

Also applies to: 40-40

tests/helpers/credential-store.test.ts (1)

13-13: LGTM!

Also applies to: 35-41

tests/helpers/output.test.ts (1)

6-6: LGTM!

Also applies to: 16-16

tests/helpers/platform.test.ts (1)

14-14: LGTM!

Also applies to: 183-184

tests/helpers/plugin-install-cleanup.test.ts (1)

31-31: LGTM!

Also applies to: 110-111

tests/helpers/plugin-install.test.ts (1)

37-37: LGTM!

Also applies to: 126-127

tests/helpers/sentry.test.ts (1)

8-9: LGTM!

Also applies to: 27-32

Comment thread src/engine/reporter.ts
Comment thread tests/commands/adr/list.test.ts
Comment thread tests/commands/clean.test.ts
Comment thread tests/commands/review-context.test.ts
Comment thread tests/helpers/telemetry-config.test.ts
@rhuanbarreto

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

The one actionable comment from the previous review is addressed in dc415bf (added an end-to-end test for check --json default vs --verbose, and dropped the redundant , 60000 per-test overrides). All review threads are resolved. Requesting a re-review so the stale CHANGES_REQUESTED can be re-evaluated against the current head.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

@rhuanbarreto Thanks for the update — I'll re-review the current head now that the environment-restoration test coverage and per-test timeout cleanup have been addressed in dc415bf.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rhuanbarreto

Copy link
Copy Markdown
Contributor Author

Re-review triage: all 5 findings verified against the code; none required a change. Reasoning is on each thread, and all are resolved.

One note on scope — the re-review states it covered 03c3665..4c5daa6, which excludes dc415bf (my fix commit, pushed after the bot's docs: regenerate llms-full.txt). So the repeated tests/integration/check.test.ts finding ("assert both verbose and non-verbose output modes... as previously requested") is stale — that test landed in dc415bf and is at tests/integration/check.test.ts:230, fire-tested against a hardcoded verbose = true.

The checkSummary "duplicate property declarations" finding also recurred; there is exactly one declaration at tests/integration/review-context.test.ts:179. CodeRabbit self-flagged it as likely invalid both times — applying that diff would delete a real property.

bun run validate remains green: 1464 pass / 0 fail, 44/44 ADR rules, coverage 90.8%.

@rhuanbarreto rhuanbarreto changed the title feat(cli): emit lean agent-facing JSON payloads by default feat(cli)!: emit lean agent-facing JSON payloads by default Jul 16, 2026
@rhuanbarreto
rhuanbarreto enabled auto-merge (squash) July 16, 2026 08:53
@rhuanbarreto
rhuanbarreto merged commit 04affa3 into main Jul 16, 2026
34 checks passed
@rhuanbarreto
rhuanbarreto deleted the feat/lean-agent-payloads branch July 16, 2026 08:56
@archgatebot archgatebot Bot mentioned this pull request Jul 16, 2026
rhuanbarreto pushed a commit that referenced this pull request Jul 16, 2026
# archgate

## [0.49.0](v0.48.4...v0.49.0)
(2026-07-16)

### ⚠ BREAKING CHANGES

* **engine:** block naming runtime globals to close reflective sandbox
escapes (#481)
* **engine:** close rule-file sandbox escapes via module allowlist
(#477)
* **cli:** emit lean agent-facing JSON payloads by default (#476)

### Features

* **cli:** emit lean agent-facing JSON payloads by default
([#476](#476))
([04affa3](04affa3))
* **engine:** base-revision + comment access for ctx.ast() (closes
[#479](#479))
([#480](#480))
([49feb1f](49feb1f)),
closes [#477](#477)

### Bug Fixes

* **engine:** block naming runtime globals to close reflective sandbox
escapes ([#481](#481))
([6666df2](6666df2)),
closes [#477](#477)
[#480](#480)
* **engine:** close rule-file sandbox escapes via module allowlist
([#477](#477))
([18db14d](18db14d))

---
This PR was generated with
[simple-release](https://github.com/TrigenSoftware/simple-release).

<details>
<summary>📄 Cheatsheet</summary>
<br>



You can configure the bot's behavior through a pull request comment
using the `!simple-release/set-options` command.

### Command Format

````md
!simple-release/set-options

```json
{
  "bump": {},
  "publish": {}
}
```
````

### Useful Parameters

#### Bump

| Parameter | Type | Description |
|-----------|------|-------------|
| `version` | `string` | Force set specific version |
| `as` | `'major' \| 'minor' \| 'patch' \| 'prerelease'` | Release type
|
| `prerelease` | `string` | Pre-release identifier (e.g., "alpha",
"beta") |
| `firstRelease` | `boolean` | Whether this is the first release |
| `skip` | `boolean` | Skip version bump |
| `byProject` | `Record<string, object>` | Per-project bump options for
monorepos |

#### Publish

| Parameter | Type | Description |
|-----------|------|-------------|
| `skip` | `boolean` | Skip publishing |
| `access` | `'public' \| 'restricted'` | Package access level |
| `tag` | `string` | Tag for npm publication |

### Usage Examples

#### Force specific version

````md
!simple-release/set-options

```json
{
  "bump": {
    "version": "2.0.0"
  }
}
```
````

#### Force major bump

````md
!simple-release/set-options

```json
{
  "bump": {
    "as": "major"
  }
}
```
````

#### Create alpha pre-release

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "alpha"
  }
}
```
````

#### Publish with specific access and tag

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "beta"
  },
  "publish": {
    "access": "public",
    "tag": "beta"
  }
}
```
````

### Access Restrictions

The command can only be used by users with permissions:
- repository owner
- organization member
- collaborator

### Notes

- The last comment with `!simple-release/set-options` command takes
priority
- JSON must be valid, otherwise the command will be ignored
- Parameters apply only to the current release execution
- The command can be updated by editing the comment or adding a new one


</details>

<!--
  Please do not edit this comment.
  simple-release-pull-request: true
  simple-release-branch-from: release
  simple-release-branch-to: main
-->

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

1 participant