fix(check): user-error handling overhaul — file filters, error boundaries, UserError guards - #467
Conversation
An agent harness passed a temp-file path outside the project root to `archgate check`, and the run died with "Path ... escapes project root" reported to Sentry as an internal crash (exit 2) instead of a user error (Sentry CLI-5). Three compounding defects, all fixed: - runner: out-of-root `[files...]` filter paths are now skipped with a warning instead of failing the run — filter paths are never read, only intersected with ADR-scoped files, so they can never match. The rule-context sandbox (readFile/grep/glob/ast) is unchanged. - check command: full ARCH-012 error boundary around the action body (previously only loadRuleAdrs was covered, so runChecks errors escaped to main().catch()). - cli entry: main().catch() now handles UserError as an expected failure — logError + exit 1, no Sentry capture — mirroring handleCommandError(). Follow-up hardening: the ARCH-012/async-action-error-boundary rule is rewritten on ctx.ast() and now flags top-level awaited statements that sit outside the action's try block (awaits of exitWith and handleCommandError are exempt as sanctioned exit paths). Dogfooding the new rule caught a second live instance of the same escape pattern in review-context.ts (await resolveBaseRef outside the try), fixed here. ARCH-002/ARCH-012 docs updated to codify both policies. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_f38bc82f-c575-448a-a75e-36280fa69c3d) |
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe CLI distinguishes escaped 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Deploying archgate-cli with
|
| Latest commit: |
076f6fb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3f397235.archgate-cli.pages.dev |
| Branch Preview URL: | https://fix-check-user-error-boundar.archgate-cli.pages.dev |
Code Coverage
Full HTML report available in workflow artifacts. Per-directory breakdown
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.archgate/adrs/ARCH-012-command-error-boundaries.rules.ts:
- Around line 157-162: Report a diagnostic when ctx.ast(file, "typescript")
fails instead of silently returning. Update the catch block in the surrounding
rule function to call ctx.report.warning with the affected file and parse error
details, then return so processing remains safe.
- Around line 92-113: findAsyncActionBodies currently ignores implicit-return
async action handlers, allowing ARCH-012 violations to bypass validation. Update
findAsyncActionBodies to retain or report non-BlockStatement handler bodies, and
ensure the rule emits the existing “missing try-catch boundary” diagnostic
directly for expression-bodied handlers while preserving current block-body
checks for missing try/catch and escaped awaits.
🪄 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: 702aef5e-bd62-4ec1-b8b2-31084d239630
📒 Files selected for processing (10)
.archgate/adrs/ARCH-002-error-handling.md.archgate/adrs/ARCH-012-command-error-boundaries.md.archgate/adrs/ARCH-012-command-error-boundaries.rules.ts.claude/agent-memory/archgate-developer/MEMORY.md.claude/agent-memory/archgate-developer/project_rules_engine_internals.mdsrc/cli.tssrc/commands/check.tssrc/commands/review-context.tssrc/engine/runner.tstests/engine/runner-file-filter.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: CodeRabbit
- GitHub Check: Smoke Test (Windows) / Windows
- GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (14)
src/commands/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-001-command-structure.md)
src/commands/**/*.ts: Each command module undersrc/commands/must export aregister*Command(program)function, with one command per file (or one command group viaindex.ts).
Command files must be thin: they should only parse arguments, call engine/helpers, and format output; business logic must live insrc/engine/,src/helpers/, orsrc/formats/.
Command modules must not useexecutableDir()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 anindex.tsthat composes child commands (for example,src/commands/adr/index.ts).
src/commands/**/*.ts: In command files undersrc/commands/**/*.ts, options that need type narrowing beyond plain strings MUST usenew Option()with.addOption()instead of plain.option().
Insrc/commands/**/*.ts, importOptionfrom@commander-js/extra-typingsalongsideCommandso typed options get full type inference.
Insrc/commands/**/*.ts, enum-like options with a fixed set of allowed values must use.choices()on anOptionto provide runtime validation and compile-time type narrowing.
Insrc/commands/**/*.ts, options that require type conversion must use.argParser()on anOptionobject, not a parser function passed as the third argument to.option().
Insrc/commands/**/*.ts, register typed options with.addOption()rather than.option().
Insrc/commands/**/*.ts, pass both the choices array and default values withas constwhen using.choices()and.default()to preserve literal types.
Insrc/commands/**/*.ts, do not add manual validation for choice options (for exampleif (!VALID.includes(val))), because Commander handles invalid-value rejection automatically.
src/commands/**/*.ts: Commands that operate on.archgate/project resources must usefindProjectRoot()fromsrc/helpers/paths.tsto locate the project root; direct use of `process.cw...
Files:
src/commands/review-context.tssrc/commands/check.ts
src/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-003-output-formatting.md)
src/**/*.ts: UsestyleText(format, text)fromnode:utilfor all terminal colors and formatting in CLI source files; do not use raw ANSI escape codes or third-party color libraries.
Commands that produce structured results and support--jsonmust emit machine-readable JSON to stdout with no colors or decorative formatting.
When a command supports--json, useformatJSON()fromsrc/helpers/output.tsfor JSON serialization, and passforcePretty: truewhen the user explicitly provided--json.
UseisAgentContext()fromsrc/helpers/output.tsto enable auto-JSON behavior for commands that support both human-readable and JSON output modes.
CLI output must not include emoji; use text symbols and colors instead.
Send normal command output to stdout withconsole.log(), and send errors, warnings, and debug messages to stderr vialogError(),logWarn(), andlogDebug().
Keep CLI output concise and scannable by using whitespace and alignment instead of long text blocks.
RespectNO_COLORautomatically by relying onstyleText; do not add custom color-environment handling in CLI code.
Do not output progress spinners unless there is a TTY check.
Do not assume piped output means agent context whenCIis set; CI runners should still receive human-readable output.
src/**/*.ts: Do not re-export symbols from another module in any source file; statements likeexport { X } from "./other"andexport type { X } from "./other"are forbidden.
Import symbols directly from the module that defines them; do not import from a directory path such as../formatsexpecting implicitindex.tsresolution.Make large production thresholds injectable via an optional parameter that defaults to the module constant, so tests can supply a small value instead of generating huge fixtures.
src/**/*.ts: In Archgate CLI TypeScript source files, all subprocess execution must useBun.spawnwith array-based arguments;Bun.$shell template literals are forbidden.
Do not...
Files:
src/commands/review-context.tssrc/cli.tssrc/engine/runner.tssrc/commands/check.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, useBun.file()instead offs.readFile()for simple reads.
Prefernode:built-in modules such asnode:util,node:path, andnode:fsover npm alternatives.
Do not use utility libraries for single functions, such as importing lodash for one helper likepick.
Do not use path aliases (tsconfig paths); use relative imports with Bun's native module resolution.
Do not install packages globally during development; usebunxfor one-off tools.
Files:
src/commands/review-context.tssrc/cli.tstests/engine/runner-file-filter.test.tssrc/engine/runner.tssrc/commands/check.ts
src/**/!(*platform).ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)
src/**/!(*platform).ts: Insrc/TypeScript source files, do not readprocess.platformdirectly; usesrc/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 insrc/TypeScript source.
When behavior differs between Linux and Windows, account for WSL by usingisWSL()rather than assuming `
Files:
src/commands/review-context.tssrc/cli.tssrc/engine/runner.tssrc/commands/check.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 insrc/commands/<name>.tsorsrc/commands/<name>/index.tsso it can be matched to a docs page.
Files:
src/commands/review-context.tssrc/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; renamingsrc/commands/<name>.tsorsrc/commands/<name>/index.tsmust be paired with renamingdocs/src/content/docs/reference/cli/<name>.mdx.
Files:
src/commands/review-context.tssrc/commands/check.ts
{src,tests}/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/LEGAL-001-spdx-license-headers.md)
{src,tests}/**/*.ts: Every TypeScript source file insrc/andtests/must begin with// SPDX-License-Identifier: Apache-2.0followed by// Copyright 2026 Archgate.
If a TypeScript file has a shebang line (for example#!/usr/bin/env buninsrc/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.tssrc/cli.tstests/engine/runner-file-filter.test.tssrc/engine/runner.tssrc/commands/check.ts
**
⚙️ CodeRabbit configuration file
**: # CLAUDE.mdArchgate is a CLI tool for AI governance via Architecture Decision Records (ADRs) — combining human-readable docs with machine-checkable rules. The CLI dogfoods itself via ADRs in
.archgate/adrs/. AI features are delivered as a Claude Code plugin (../plugins/claude-code), not via direct API calls.Technology Stack
- Runtime: Bun (>=1.2.21) — not Node.js compatible
- Language: TypeScript (strict mode, ESNext, ES modules)
- CLI framework: Commander.js (
@commander-js/extra-typings)- Linter: Oxlint | Formatter: Oxfmt | Dead exports: Knip | Commits: Conventional Commits
Commands
bun run src/cli.ts <command> # run CLI locally bun run lint # oxlint bun run typecheck # tsc --build bun run format # oxfmt --write bun run format:check # oxfmt --check bun run test # all tests (not bare `bun test` — picks up --timeout; see GEN-003) bun run knip # dead export detection bun run validate # MANDATORY: lint + typecheck + format:check + test + ADR check + knip + build check bun run build:check # verify build compiles (CI builds binaries via release workflow) bun run commit # conventional commit wizardValidation Gate
bun run validatemust pass before any task is considered complete. Fail-fast pipeline: lint → typecheck → format:check → test → ADR check → knip → build check. Mirrors CI in.github/workflows/code-pull-request.yml.Git Hooks (Git 2.54+)
Config-based hooks in
.githooksrun validation locally before commits and pushes:
- pre-commit: lint + typecheck + format:check (~15s)
- pre-push: full
bun run validate(~60s, mirrors CI)Activate once per clone:
git config --local include.path ../.githooksOpt out of a specific hook:
git config --local hook.<name>.enabled false. Skip all hooks for a single commit:git commit --no-verify.#...
Files:
src/commands/review-context.tssrc/cli.tstests/engine/runner-file-filter.test.tssrc/engine/runner.tssrc/commands/check.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.tsfile with automated checks that run viaarchgate check.When reviewing, you must:
- Treat ADR violations as blocking issues, not suggestions.
- Cite the specific ADR ID when flagging a violation (e.g., "Violates ARCH-006").
- Focus on semantic and contextual violations that automated rules cannot catch —
the.rules.tsfiles already cover syntactic/structural patterns.- If you are unsure whether something violates an ADR, flag it as a question
rather than approving it.
Files:
src/commands/review-context.tssrc/cli.tstests/engine/runner-file-filter.test.tssrc/engine/runner.tssrc/commands/check.ts
src/cli.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-001-command-structure.md)
src/cli.ts: The main entry point must explicitly import and register every command; no auto-discovery is allowed.
All async bootstrap logic insrc/cli.tsmust be wrapped in an asyncmain()function and invoked withmain().catch((err) => { logError(String(err)); process.exit(2); }); top-level await is forbidden.
The CLI must run in-process in the same Bun process as the entry point; command execution should not rely on child processes.The CLI entry point must be
src/cli.tsand use the#!/usr/bin/env bunshebang.In
main().catch(), handleUserErroras an expected failure by callinglogError(), exiting with code 1, and not sending it to Sentry; only other errors follow the exit-2 andcaptureException()path.
Files:
src/cli.ts
tests/**/*.test.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-005-testing-standards.md)
tests/**/*.test.ts: Use Bun's built-in test runner (bun:test) for all test files, and place tests undertests/mirroring thesrc/directory structure with<module-name>.test.tsnaming.
Use temp directories (mkdtemp) for filesystem tests, and clean them up inafterEachorafterAll.
Close external SDK instances (servers, clients, transports, connections) inafterEachorafterAll, managing their lifecycle in hooks rather than inside individual test bodies.
When a test creates a temporary git repository and runsgit commit, configure localuser.emailanduser.nameimmediately aftergit init.
Test public module interfaces, not private implementation details.
Use descriptive test names that explain the expected behavior.
Every runnabletest()/it()must contain at least oneexpect()assertion; smoke tests must make the contract explicit withexpect(() => fn()).not.toThrow()orawait expect(promise).resolves.toBeUndefined().
Usetest.skip,test.skipIf, ortest.todofor intentionally empty or disabled tests; do not use barereturnor empty callbacks to skip work.
If the firstexpect()is being added to a previously assertion-less test file, addexpectto thebun:testimport.
When mockingfetchin tests, assign directly toglobalThis.fetchand restore the original or usemock.restore()afterward.
WrapspyOn()and inlinemockImplementation()usage intry/finally, or create and restore spies in hooks, somockRestore()always runs.
Only raise a per-test timeout above the globalbun test --timeout 60000; never set a shorter per-test timeout.
Mock first-party modules withimport * as modplusspyOn(mod, "fn"), notmock.module().
When a test needs to redirect user-scope paths, mockos.homedir()instead of relying onHOME/Bun.env.HOME; restore the spy in test hooks.
Do not depend on network access in unit tests.
Do not leave temp files after test runs.
Do not leave external SDK instances open after tests...
Files:
tests/engine/runner-file-filter.test.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 mutatingprocess.platformdirectly.
Files:
tests/engine/runner-file-filter.test.ts
.archgate/adrs/**
⚙️ CodeRabbit configuration file
.archgate/adrs/**: ---
id: ARCH-001
title: Command Structure
domain: architecture
rules: true
files: ["src/commands/**/*.ts"]Context
The CLI needs a consistent pattern for defining and registering commands. As the command surface grows (init, check, adr, review-context, session-context, upgrade, clean), the registration mechanism must scale without introducing hidden coupling or making the dependency graph opaque.
Alternatives considered:
- Auto-discovery via
executableDir()— Commander.js supports automatic command discovery by scanning a directory for executable files. This eliminates manual imports but hides the dependency graph: adding or removing a command has no type-checked reference, making dead command detection impossible. It also requires each command to be a standalone executable, which prevents in-process testing and forces separate process spawning for every subcommand invocation.- Plugin-based registration — A plugin system where commands register themselves via a manifest or hook (similar to Oclif or Clipanion). This adds flexibility for third-party extensions but introduces significant complexity for an internal CLI with a known, finite set of commands. The indirection makes it harder to trace which code handles which command.
- Single-file command map — Define all commands in a single file as a map of name-to-handler. Simple but creates a monolithic file that grows with every command, making merge conflicts frequent and readability poor.
The explicit register pattern strikes the right balance: each command owns its registration logic, the entry point makes all commands visible at a glance, and in-process execution enables straightforward testing without process spawning.
Decision
Commands live in src/commands/ and export a register*Command(program) function. The main entry point (src/cli.ts) explicitly imports and calls each register function. Subcommands (e.g., adr create, adr list) use nested directories wi...
Files:
.archgate/adrs/ARCH-002-error-handling.md.archgate/adrs/ARCH-012-command-error-boundaries.rules.ts.archgate/adrs/ARCH-012-command-error-boundaries.md
src/engine/runner.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-022-ast-aware-rule-context.md)
src/engine/runner.ts: Implementctx.ast(path, language)insidecreateRuleContext()with all dispatch hidden from rule authors.
Forlanguage: "typescript"and"javascript",ctx.ast()must reuse the existing in-processmeriyahparser; no subprocess may be spawned for these branches.
Factor the duplicatedparseModule()logic into a shared helper that is used by bothrule-scanner.tsand thectx.ast()TypeScript/JavaScript branch.
Forlanguage: "python"and"ruby",ctx.ast()must useBun.spawnwith array-based arguments only, with no shell interpolation.
Before any Python/Ruby interpreter is invoked,ctx.ast()must run the guardrail sequence in order: path safety, language plausibility check, interpreter availability probe, then guarded invocation.
ctx.ast()must use the samesafePath()sandboxing asreadFile/globbefore accessing a target file.
ctx.ast()must reject files whose extension and/or leading content do not plausibly match the requested language before running an interpreter.
ctx.ast()must probe interpreter availability once percheckinvocation, cache the result, and reuse the first working candidate executable name.
On Windows, the interpreter probe must consider platform-appropriate candidates in order (includingpyviaisWindows()); on non-Windows, it must use the non-Windows candidate order.
The Python branch must run in isolated mode (python -I -c ...) to prevent the working directory from shadowing standard-library imports.
The Python and Ruby serializers must strip a leading UTF-8 BOM before parsing.
ctx.ast()must throw on missing interpreter or parse failure, and must not returnnullor any other sentinel value.
The thrown error messages fromctx.ast()must distinguish interpreter-unavailable failures from parse-failure errors.
ctx.ast()must not exposeBun.spawn,child_process, or any other raw subprocess primitive onRuleContext; it is the only sanctioned tooling entrypoint.
`ctx.ast(...
Files:
src/engine/runner.ts
src/{helpers,engine}/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-002-error-handling.md)
Do not use
console.log(),console.warn(), orconsole.info()directly in helper or engine files; uselogInfo()orlogWarn()instead.
Files:
src/engine/runner.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: archgate/cli
Timestamp: 2026-07-11T01:13:46.707Z
Learning: Synchronous command actions and command group index files that only register subcommands are exempt from the async error-boundary requirement.
📚 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/MEMORY.md.claude/agent-memory/archgate-developer/project_rules_engine_internals.md
🔇 Additional comments (9)
src/engine/runner.ts (1)
16-16: LGTM!Also applies to: 39-59, 431-448
tests/engine/runner-file-filter.test.ts (1)
21-28: 🩺 Stability & AvailabilityNo
git initis needed here.getGitTrackedFiles()returnsnullfor a non-repo, andresolveScopedFiles()treats that as no gitignore filtering, so the two violation assertions still hold as written.> Likely an incorrect or invalid review comment..archgate/adrs/ARCH-002-error-handling.md (1)
53-53: LGTM!Also applies to: 64-64
.archgate/adrs/ARCH-012-command-error-boundaries.md (1)
60-68: LGTM!Also applies to: 89-94
src/cli.ts (1)
47-47: LGTM!Also applies to: 195-204
src/commands/check.ts (1)
44-190: LGTM!src/commands/review-context.ts (1)
26-55: LGTM!.claude/agent-memory/archgate-developer/MEMORY.md (1)
44-44: LGTM!.claude/agent-memory/archgate-developer/project_rules_engine_internals.md (1)
12-12: LGTM!
…ailures Two gaps in the ARCH-012 boundary rule from PR review: - Implicit-return arrow actions (`.action(async () => run())`) were silently skipped even though they structurally cannot contain a try-catch — now flagged as a missing boundary with a convert-to-block fix hint. - ctx.ast() parse failures silently treated the file as compliant — now surfaced as a warning so a transpiler edge case cannot mask coverage loss. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_679364ae-c5ef-4a49-8308-2c7fb29cb9a9) |
…itWith Review feedback: with the full action-body error boundary in place, the early-return guards (missing project root, invalid --max-warnings) can simply throw UserError — handleCommandError logs the message and exits 1 without Sentry, identical behavior with less ceremony and consistent with the user-error.ts doctrine. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_3f601024-d94e-4fd0-a0f3-e116fc5c1d5f) |
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_97540d10-5886-4208-a7f5-155b59dab8e5) |
…throws
Extends the PR-review UserError pattern across the CLI. The
`if (!x) { logError(...); await exitWith(1); return; }` guard appeared
at ~40 sites in 18 command files; the project-root variant alone was
copy-pasted 10 times.
- Add requireProjectRoot() to helpers/paths.ts — returns the root or
throws UserError("No .archgate/ directory found. Run `archgate init`
first."), handled by each action's ARCH-012 boundary (exit 1, no
Sentry).
- Convert adr create/show/list/update/sync/import, adr domain
add/remove/list, review-context, check, and plugin install (the
"Not logged in" guard). show.ts's "ADR not found" also throws.
- Guards that sat BEFORE the try block now live inside it, giving
those actions full-body boundary coverage.
- Deliberately unchanged: login/init (catch-block TLS translation),
upgrade (custom Sentry flow), session-context (Result-style helper
errors + cwd fallback semantics).
- ARCH-011 codifies the convention; test assertions updated to the
standardized message.
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_7d808520-7d56-4836-8ac2-9d8b8bde8066) |
|
Scope expansion (requested in review follow-up): commit 301c2d6 sweeps the
|
requireProjectRoot() was inserted between findProjectRoot's doc comment and the function, orphaning the doc. Move requireProjectRoot below findProjectRoot instead. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_2f7e8dbe-7a47-4422-89f9-a0d00114a2d9) |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.archgate/adrs/ARCH-011-consistent-project-root-resolution.md:
- Line 41: Update the affected Markdown sentence in ARCH-011 to add spaces
around the inline code spans `session-context`, `findProjectRoot()`, and `null`,
while preserving the existing wording and formatting.
In `@src/commands/adr/show.ts`:
- Around line 6-10: Update the ADR-not-found error construction in the command’s
show flow to pass an actionable suggestion as the additional UserError detail,
guiding users to create or initialize the governance directory. Follow the
existing requireProjectRoot() pattern and preserve the current error message and
handling behavior.
🪄 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: 80057813-e0a5-447e-9285-b31820f81e56
📒 Files selected for processing (18)
.archgate/adrs/ARCH-011-consistent-project-root-resolution.md.claude/agent-memory/archgate-developer/MEMORY.md.claude/agent-memory/archgate-developer/feedback_throw_usererror_in_guards.mdsrc/commands/adr/create.tssrc/commands/adr/domain/add.tssrc/commands/adr/domain/list.tssrc/commands/adr/domain/remove.tssrc/commands/adr/import.tssrc/commands/adr/list.tssrc/commands/adr/show.tssrc/commands/adr/sync.tssrc/commands/adr/update.tssrc/commands/check.tssrc/commands/plugin/install.tssrc/commands/review-context.tssrc/helpers/paths.tstests/commands/check-action.test.tstests/commands/review-context.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
- GitHub Check: CodeRabbit
- GitHub Check: Smoke Test (Windows) / Windows
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (java-kotlin)
- GitHub Check: Analyze (csharp)
- GitHub Check: Cloudflare Pages
🧰 Additional context used
📓 Path-based instructions (13)
tests/**/*.test.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-005-testing-standards.md)
tests/**/*.test.ts: Use Bun's built-in test runner (bun:test) for all test files, and place tests undertests/mirroring thesrc/directory structure with<module-name>.test.tsnaming.
Use temp directories (mkdtemp) for filesystem tests, and clean them up inafterEachorafterAll.
Close external SDK instances (servers, clients, transports, connections) inafterEachorafterAll, managing their lifecycle in hooks rather than inside individual test bodies.
When a test creates a temporary git repository and runsgit commit, configure localuser.emailanduser.nameimmediately aftergit init.
Test public module interfaces, not private implementation details.
Use descriptive test names that explain the expected behavior.
Every runnabletest()/it()must contain at least oneexpect()assertion; smoke tests must make the contract explicit withexpect(() => fn()).not.toThrow()orawait expect(promise).resolves.toBeUndefined().
Usetest.skip,test.skipIf, ortest.todofor intentionally empty or disabled tests; do not use barereturnor empty callbacks to skip work.
If the firstexpect()is being added to a previously assertion-less test file, addexpectto thebun:testimport.
When mockingfetchin tests, assign directly toglobalThis.fetchand restore the original or usemock.restore()afterward.
WrapspyOn()and inlinemockImplementation()usage intry/finally, or create and restore spies in hooks, somockRestore()always runs.
Only raise a per-test timeout above the globalbun test --timeout 60000; never set a shorter per-test timeout.
Mock first-party modules withimport * as modplusspyOn(mod, "fn"), notmock.module().
When a test needs to redirect user-scope paths, mockos.homedir()instead of relying onHOME/Bun.env.HOME; restore the spy in test hooks.
Do not depend on network access in unit tests.
Do not leave temp files after test runs.
Do not leave external SDK instances open after tests...
Files:
tests/commands/check-action.test.tstests/commands/review-context.test.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, useBun.file()instead offs.readFile()for simple reads.
Prefernode:built-in modules such asnode:util,node:path, andnode:fsover npm alternatives.
Do not use utility libraries for single functions, such as importing lodash for one helper likepick.
Do not use path aliases (tsconfig paths); use relative imports with Bun's native module resolution.
Do not install packages globally during development; usebunxfor one-off tools.
Files:
tests/commands/check-action.test.tssrc/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tstests/commands/review-context.test.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.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 mutatingprocess.platformdirectly.
Files:
tests/commands/check-action.test.tstests/commands/review-context.test.ts
{src,tests}/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/LEGAL-001-spdx-license-headers.md)
{src,tests}/**/*.ts: Every TypeScript source file insrc/andtests/must begin with// SPDX-License-Identifier: Apache-2.0followed by// Copyright 2026 Archgate.
If a TypeScript file has a shebang line (for example#!/usr/bin/env buninsrc/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/commands/check-action.test.tssrc/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tstests/commands/review-context.test.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.ts
**
⚙️ CodeRabbit configuration file
**: # CLAUDE.mdArchgate is a CLI tool for AI governance via Architecture Decision Records (ADRs) — combining human-readable docs with machine-checkable rules. The CLI dogfoods itself via ADRs in
.archgate/adrs/. AI features are delivered as a Claude Code plugin (../plugins/claude-code), not via direct API calls.Technology Stack
- Runtime: Bun (>=1.2.21) — not Node.js compatible
- Language: TypeScript (strict mode, ESNext, ES modules)
- CLI framework: Commander.js (
@commander-js/extra-typings)- Linter: Oxlint | Formatter: Oxfmt | Dead exports: Knip | Commits: Conventional Commits
Commands
bun run src/cli.ts <command> # run CLI locally bun run lint # oxlint bun run typecheck # tsc --build bun run format # oxfmt --write bun run format:check # oxfmt --check bun run test # all tests (not bare `bun test` — picks up --timeout; see GEN-003) bun run knip # dead export detection bun run validate # MANDATORY: lint + typecheck + format:check + test + ADR check + knip + build check bun run build:check # verify build compiles (CI builds binaries via release workflow) bun run commit # conventional commit wizardValidation Gate
bun run validatemust pass before any task is considered complete. Fail-fast pipeline: lint → typecheck → format:check → test → ADR check → knip → build check. Mirrors CI in.github/workflows/code-pull-request.yml.Git Hooks (Git 2.54+)
Config-based hooks in
.githooksrun validation locally before commits and pushes:
- pre-commit: lint + typecheck + format:check (~15s)
- pre-push: full
bun run validate(~60s, mirrors CI)Activate once per clone:
git config --local include.path ../.githooksOpt out of a specific hook:
git config --local hook.<name>.enabled false. Skip all hooks for a single commit:git commit --no-verify.#...
Files:
tests/commands/check-action.test.tssrc/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tstests/commands/review-context.test.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.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.tsfile with automated checks that run viaarchgate check.When reviewing, you must:
- Treat ADR violations as blocking issues, not suggestions.
- Cite the specific ADR ID when flagging a violation (e.g., "Violates ARCH-006").
- Focus on semantic and contextual violations that automated rules cannot catch —
the.rules.tsfiles already cover syntactic/structural patterns.- If you are unsure whether something violates an ADR, flag it as a question
rather than approving it.
Files:
tests/commands/check-action.test.tssrc/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tstests/commands/review-context.test.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.ts
src/commands/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-001-command-structure.md)
src/commands/**/*.ts: Each command module undersrc/commands/must export aregister*Command(program)function, with one command per file (or one command group viaindex.ts).
Command files must be thin: they should only parse arguments, call engine/helpers, and format output; business logic must live insrc/engine/,src/helpers/, orsrc/formats/.
Command modules must not useexecutableDir()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 anindex.tsthat composes child commands (for example,src/commands/adr/index.ts).
src/commands/**/*.ts: In command files undersrc/commands/**/*.ts, options that need type narrowing beyond plain strings MUST usenew Option()with.addOption()instead of plain.option().
Insrc/commands/**/*.ts, importOptionfrom@commander-js/extra-typingsalongsideCommandso typed options get full type inference.
Insrc/commands/**/*.ts, enum-like options with a fixed set of allowed values must use.choices()on anOptionto provide runtime validation and compile-time type narrowing.
Insrc/commands/**/*.ts, options that require type conversion must use.argParser()on anOptionobject, not a parser function passed as the third argument to.option().
Insrc/commands/**/*.ts, register typed options with.addOption()rather than.option().
Insrc/commands/**/*.ts, pass both the choices array and default values withas constwhen using.choices()and.default()to preserve literal types.
Insrc/commands/**/*.ts, do not add manual validation for choice options (for exampleif (!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: All commands that operate on.archgate/project res...
Files:
src/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.ts
src/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-003-output-formatting.md)
src/**/*.ts: UsestyleText(format, text)fromnode:utilfor all terminal colors and formatting in CLI source files; do not use raw ANSI escape codes or third-party color libraries.
Commands that produce structured results and support--jsonmust emit machine-readable JSON to stdout with no colors or decorative formatting.
When a command supports--json, useformatJSON()fromsrc/helpers/output.tsfor JSON serialization, and passforcePretty: truewhen the user explicitly provided--json.
UseisAgentContext()fromsrc/helpers/output.tsto enable auto-JSON behavior for commands that support both human-readable and JSON output modes.
CLI output must not include emoji; use text symbols and colors instead.
Send normal command output to stdout withconsole.log(), and send errors, warnings, and debug messages to stderr vialogError(),logWarn(), andlogDebug().
Keep CLI output concise and scannable by using whitespace and alignment instead of long text blocks.
RespectNO_COLORautomatically by relying onstyleText; do not add custom color-environment handling in CLI code.
Do not output progress spinners unless there is a TTY check.
Do not assume piped output means agent context whenCIis set; CI runners should still receive human-readable output.
src/**/*.ts: Do not re-export symbols from another module in any source file; statements likeexport { X } from "./other"andexport type { X } from "./other"are forbidden.
Import symbols directly from the module that defines them; do not import from a directory path such as../formatsexpecting implicitindex.tsresolution.Make large production thresholds injectable via an optional parameter that defaults to the module constant, so tests can supply a small value instead of generating huge fixtures.
src/**/*.ts: In Archgate CLI TypeScript source files, all subprocess execution must useBun.spawnwith array-based arguments;Bun.$shell template literals are forbidden.
Do not...
Files:
src/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.ts
src/**/!(*platform).ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-009-platform-detection-helper.md)
src/**/!(*platform).ts: Insrc/TypeScript source files, do not readprocess.platformdirectly; usesrc/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 insrc/TypeScript source.
When behavior differs between Linux and Windows, account for WSL by usingisWSL()rather than assuming `
Files:
src/commands/adr/import.tssrc/commands/adr/domain/remove.tssrc/commands/adr/create.tssrc/helpers/paths.tssrc/commands/adr/list.tssrc/commands/plugin/install.tssrc/commands/adr/show.tssrc/commands/adr/sync.tssrc/commands/adr/domain/add.tssrc/commands/adr/update.tssrc/commands/adr/domain/list.tssrc/commands/review-context.tssrc/commands/check.ts
src/helpers/**/*.ts
📄 CodeRabbit inference engine (.archgate/adrs/ARCH-002-error-handling.md)
In helper files, use
logInfo()orlogWarn()instead of directconsole.log()orconsole.warn()calls.
Files:
src/helpers/paths.ts
src/commands/plugin/install.ts
📄 CodeRabbit inference engine (CLAUDE.md)
When adding a new editor target, extend
.choices([...]), add a case ininstallForEditor, and update the manual-instructionscatchpath.
Files:
src/commands/plugin/install.ts
.archgate/adrs/**
⚙️ CodeRabbit configuration file
.archgate/adrs/**: ---
id: ARCH-001
title: Command Structure
domain: architecture
rules: true
files: ["src/commands/**/*.ts"]Context
The CLI needs a consistent pattern for defining and registering commands. As the command surface grows (init, check, adr, review-context, session-context, upgrade, clean), the registration mechanism must scale without introducing hidden coupling or making the dependency graph opaque.
Alternatives considered:
- Auto-discovery via
executableDir()— Commander.js supports automatic command discovery by scanning a directory for executable files. This eliminates manual imports but hides the dependency graph: adding or removing a command has no type-checked reference, making dead command detection impossible. It also requires each command to be a standalone executable, which prevents in-process testing and forces separate process spawning for every subcommand invocation.- Plugin-based registration — A plugin system where commands register themselves via a manifest or hook (similar to Oclif or Clipanion). This adds flexibility for third-party extensions but introduces significant complexity for an internal CLI with a known, finite set of commands. The indirection makes it harder to trace which code handles which command.
- Single-file command map — Define all commands in a single file as a map of name-to-handler. Simple but creates a monolithic file that grows with every command, making merge conflicts frequent and readability poor.
The explicit register pattern strikes the right balance: each command owns its registration logic, the entry point makes all commands visible at a glance, and in-process execution enables straightforward testing without process spawning.
Decision
Commands live in src/commands/ and export a register*Command(program) function. The main entry point (src/cli.ts) explicitly imports and calls each register function. Subcommands (e.g., adr create, adr list) use nested directories wi...
Files:
.archgate/adrs/ARCH-011-consistent-project-root-resolution.md
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 insrc/commands/<name>.tsorsrc/commands/<name>/index.tsso it can be matched to a docs page.
Files:
src/commands/review-context.tssrc/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; renamingsrc/commands/<name>.tsorsrc/commands/<name>/index.tsmust be paired with renamingdocs/src/content/docs/reference/cli/<name>.mdx.
Files:
src/commands/review-context.tssrc/commands/check.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: archgate/cli
Timestamp: 2026-07-11T12:45:14.402Z
Learning: Code reviewers must verify that error messages include actionable suggestions where possible and that no try-catch block swallows errors without logging or re-throwing.
Learnt from: CR
Repo: archgate/cli
Timestamp: 2026-07-11T12:45:25.203Z
Learning: The top-level main().catch() in cli.ts must remain as a safety net for truly unexpected errors and should not be the primary command error handler.
Learnt from: CR
Repo: archgate/cli
Timestamp: 2026-07-11T12:45:25.203Z
Learning: Code reviewers must verify that every new asynchronous command has an error boundary covering the entire action body.
📚 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/feedback_throw_usererror_in_guards.md.claude/agent-memory/archgate-developer/MEMORY.md
📚 Learning: 2026-07-02T16:03:33.031Z
Learnt from: rhuanbarreto
Repo: archgate/cli PR: 446
File: src/helpers/session-context-opencode.ts:81-100
Timestamp: 2026-07-02T16:03:33.031Z
Learning: For synchronous helper functions that use Bun’s sqlite sync API (i.e., they must remain synchronous), it’s acceptable to use `existsSync` from `node:fs` to check whether the SQLite database file exists. Avoid using `Bun.file(path).exists()` for this purpose because it’s async and would force the helper to become async (no equivalent synchronous Bun alternative). If the DB file is missing, throw/return a clear, actionable "No database found" error (per ARCH-006) rather than letting the sqlite open fail with a generic DB-open error.
Applied to files:
src/helpers/paths.ts
🪛 markdownlint-cli2 (0.22.1)
.claude/agent-memory/archgate-developer/feedback_throw_usererror_in_guards.md
[warning] 8-8: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
.archgate/adrs/ARCH-011-consistent-project-root-resolution.md
[warning] 41-41: Spaces inside code span elements
(MD038, no-space-in-code)
🔇 Additional comments (17)
src/helpers/paths.ts (1)
8-8: LGTM!Also applies to: 176-194
src/commands/check.ts (1)
18-22: LGTM! Past-review feedback on both guards (project-root and--max-warnings) is fully addressed here — both now throwUserErrorand are handled uniformly byhandleCommandError.Also applies to: 45-57, 99-115, 117-145, 147-176, 176-181
src/commands/adr/create.ts (1)
7-9: LGTM!Also applies to: 31-32
src/commands/adr/domain/add.ts (1)
5-7: LGTM!Also applies to: 19-20
src/commands/adr/domain/list.ts (1)
7-9: LGTM!Also applies to: 18-19
tests/commands/check-action.test.ts (1)
171-175: LGTM!src/commands/review-context.ts (1)
7-9: LGTM!Also applies to: 26-34
src/commands/adr/domain/remove.ts (1)
5-7: LGTM!Also applies to: 21-22
src/commands/adr/import.ts (1)
18-20: LGTM!Also applies to: 42-42
src/commands/adr/list.ts (1)
9-11: LGTM!Also applies to: 21-22
src/commands/adr/sync.ts (1)
14-16: LGTM!Also applies to: 145-146
src/commands/adr/update.ts (1)
6-8: LGTM!Also applies to: 32-42
src/commands/plugin/install.ts (1)
30-30: LGTM!Also applies to: 247-250
tests/commands/review-context.test.ts (1)
102-103: LGTM!.claude/agent-memory/archgate-developer/MEMORY.md (1)
27-27: LGTM!Also applies to: 45-45
.claude/agent-memory/archgate-developer/feedback_throw_usererror_in_guards.md (1)
1-13: LGTM!.archgate/adrs/ARCH-011-consistent-project-root-resolution.md (1)
45-49: LGTM!
…acing - adr show's "ADR not found" UserError now suggests `archgate adr list` (ARCH-002: actionable suggestions accompany error messages). - ARCH-011: rephrase the requireProjectRoot() Do to drop escaped backticks nested inside a code span — oxfmt mis-parses the span boundaries and eats the spaces after subsequent code spans on the line, which is what produced the malformed markdown CodeRabbit flagged (and silently re-produced it after a naive space fix). Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Bugbot couldn't run - usage limit reachedBugbot 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_e892c9a2-d950-4dac-8213-7e556663e3ed) |
# archgate ## [0.48.2](v0.48.1...v0.48.2) (2026-07-11) ### Bug Fixes * **check:** user-error handling overhaul — file filters, error boundaries, UserError guards ([#467](#467)) ([7ae6440](7ae6440)) --- 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>
What
Started as a fix for Sentry CLI-5 and grew (by review feedback) into a consistent user-error handling overhaul across the CLI.
1. The CLI-5 fix (
9c7ba33)archgate checkdied withUserError: Path "...\Temp\archgate-check.json" escapes project root — access denied, reported to Sentry as an internal crash (exit 2) when an agent harness passed a temp-file path as a file argument. Three compounding defects:src/engine/runner.ts— out-of-root[files...]filter paths are now skipped with a warning instead of failing the run. Filter paths are never read — only intersected with ADR-scoped files — so an out-of-root path can never match. The rule-context security sandbox (ctx.readFile/grep/glob/ast) is unchanged.src/commands/check.ts— full ARCH-012 error boundary around the action body (previously onlyloadRuleAdrswas covered).src/cli.ts—main().catch()now handlesUserErroras an expected failure (logError + exit 1, no Sentry capture), mirroringhandleCommandError(). Protects every command.2. ARCH-012 rule hardening (
9c7ba33,85c7420)ARCH-012/async-action-error-boundaryrewritten onctx.ast():exitWith/handleCommandErrorexempt as sanctioned exit paths).action(async () => run())) — they structurally cannot contain a boundary (CodeRabbit)ctx.ast()parse failures instead of silently passing the file (CodeRabbit)await resolveBaseRef(...)outside the try inreview-context.ts— fixed3. UserError guard sweep (
27c1443,301c2d6) (review feedback from @rhuanbarreto)The
logError(...) + await exitWith(1) + returnguard appeared at ~40 sites in 18 files, including a 10× copy-pasted project-root check:requireProjectRoot()helper inhelpers/paths.ts— returns the root or throwsUserError, handled by each action's boundary (exit 1, no Sentry). Replaces all 11 project-root guards.adrcreate/show/list/update/sync/import,adr domainadd/remove/list,review-context,check,plugin install("Not logged in"),adr show("ADR not found")login/initcatch-block TLS hint translation,upgrade's custom Sentry flow,session-context/*(Result-style helper errors + cwd-fallback semantics)Governance updates
main().catch()must treatUserErroras expected (exit 1, never Sentry)requireProjectRoot()for project-requiring commands; bans hand-rolled guardsReviewer notes
tests/engine/runner-file-filter.test.ts; assertions updated incheck-action.test.tsandreview-context.test.ts(exit spy now seesexitWith(1, { errorKind: "user" }); standardized root-missing message)archgate check <path-outside-root>warns and continues instead of exiting 1 — the filter can only narrow, so skipping ≡ matching nothing; (2)check/review-context's missing-project message is now the standardized "No .archgate/ directory found. Run `archgate init` first."bun run validatepasses end-to-end (lint, typecheck, format, 1444 tests, 43/43 ADR checks, knip, build); net −54 lines from the sweep