Skip to content

fix(session-context): apply --max-entries on the show subcommands#448

Merged
rhuanbarreto merged 3 commits into
mainfrom
fix/show-max-entries-hoisting
Jul 3, 2026
Merged

fix(session-context): apply --max-entries on the show subcommands#448
rhuanbarreto merged 3 commits into
mainfrom
fix/show-max-entries-hoisting

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Problem

Found while live-verifying the plugin skill instructions against v0.46.0: archgate session-context <editor> show <id> --max-entries N silently ignores the flag — show ... --max-entries 2 returned a 138-entry transcript.

Cause: the parent editor command also declares --max-entries, and commander hoists parent-known options from anywhere in argv (positional options mode is off). The flag is parsed onto the parent command, the child's opts.maxEntries stays undefined, and the helper falls back to its 200 default.

Fix

The four show actions now read the merged value via command.optsWithGlobals() (child value preferred when present). The option stays declared on both levels so show --help still documents it.

Verification

  • Per-editor in-process regression tests assert the hoisted flag reaches the reader with the parsed number
  • Subprocess test proves end-to-end trimming (show <id> --max-entries 1 → 1 transcript entry)
  • Live against real opencode fan-out data: show <child> --root --max-entries 2 → parent session, 138 relevant entries, transcript trimmed to 2
  • bun run validate green (39/39 ADR checks)

Ships as 0.46.1. The distributed skill text is unaffected (it never passes --max-entries to show), but the docs advertise the flag, so it should work.

https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj

The parent editor commands also declare --max-entries, and commander
hoists parent-known options from anywhere on the command line — so
`session-context <editor> show <id> --max-entries N` parked the value
on the parent command and the show action read undefined, silently
returning the untrimmed transcript (found live: show --max-entries 2
returned 138 entries).

Read the merged value via command.optsWithGlobals() in all four show
actions. Regression tests: per-editor in-process assertions that the
hoisted flag reaches the reader, plus a subprocess test proving the
transcript is actually trimmed end-to-end.

Claude-Session: https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rhuanbarreto, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 057f63aa-eaaf-4e01-a6c7-f1f27504d031

📥 Commits

Reviewing files that changed from the base of the PR and between 92ad488 and 4b3aa72.

📒 Files selected for processing (5)
  • .claude/agent-memory/archgate-developer/MEMORY.md
  • src/commands/session-context/claude-code.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/cursor.ts
  • src/commands/session-context/opencode.ts
📝 Walkthrough

Walkthrough

The change updates the show subcommand action handlers in claude-code, copilot, cursor, and opencode session-context commands to accept the Commander command object. Each handler now resolves maxEntries as opts.maxEntries ?? command.optsWithGlobals().maxEntries, ensuring the --max-entries flag is correctly read when declared on a parent command. Corresponding regression tests were added or updated across all four commands' test files to verify this option-hoisting behavior.

Changes

Cohort / File(s) Summary
src/commands/session-context/claude-code.ts Updated show action to accept command and merge maxEntries via optsWithGlobals() fallback
src/commands/session-context/copilot.ts Updated show action to accept command and merge maxEntries via optsWithGlobals() fallback
src/commands/session-context/cursor.ts Updated show action to accept command and merge maxEntries via optsWithGlobals() fallback
src/commands/session-context/opencode.ts Updated show action to accept command and merge maxEntries via optsWithGlobals() fallback
tests/commands/session-context/claude-code.test.ts Added in-process and subprocess regression tests; updated assertion for trimmed transcript content
tests/commands/session-context/copilot.test.ts Added regression test for --max-entries hoisting
tests/commands/session-context/cursor.test.ts Added regression test for --max-entries hoisting
tests/commands/session-context/opencode.test.ts Added regression test for --max-entries hoisting

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant ShowAction
  participant Command
  participant SessionReader
  CLI->>ShowAction: show(sessionId, opts, command)
  alt opts.maxEntries set
    ShowAction->>SessionReader: read(sessionId, opts.maxEntries)
  else opts.maxEntries unset
    ShowAction->>Command: optsWithGlobals()
    Command-->>ShowAction: maxEntries
    ShowAction->>SessionReader: read(sessionId, maxEntries)
  end
Loading

Related PRs: None identified.

Suggested labels: bug, tests

Suggested reviewers: None identified.

🐰 A flag once lost on a parent's line,
Now hops down through the command chain fine,
Four handlers fixed, each show made whole,
Max-entries reaches its rightful goal,
Tests confirm the hop is sound and true.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: applying --max-entries to the show subcommands.
Description check ✅ Passed The description is directly related to the changeset and explains the bug, fix, and verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4b3aa72
Status: ✅  Deploy successful!
Preview URL: https://aa76a767.archgate-cli.pages.dev
Branch Preview URL: https://fix-show-max-entries-hoistin.archgate-cli.pages.dev

View logs

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.0% (7183 / 7977)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.7% 1994 / 2249
src/engine/ 90.9% 1463 / 1610
src/formats/ 100.0% 142 / 142
src/helpers/ 90.1% 3584 / 3976

@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

🤖 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/commands/session-context/claude-code.ts`:
- Around line 84-94: The maxEntries fallback logic in the session-context
commands is duplicated across claude-code.ts, copilot.ts, cursor.ts, and
opencode.ts, making the Commander.js workaround hard to keep in sync. Extract
the shared resolution into a small helper near makeMaxEntriesOption() (for
example, resolveMaxEntries(opts, command)) and have the action handler in
claude-code.ts use that helper instead of inlining the opts.maxEntries ??
command.optsWithGlobals().maxEntries pattern and comment. Keep the helper
responsible for the documented parent/child option collision workaround so
future changes only need to update one place.
🪄 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: 38e72c82-0952-4ace-b843-5b6e0e1f4180

📥 Commits

Reviewing files that changed from the base of the PR and between 417c093 and 92ad488.

📒 Files selected for processing (8)
  • src/commands/session-context/claude-code.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/cursor.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/copilot.test.ts
  • tests/commands/session-context/cursor.test.ts
  • tests/commands/session-context/opencode.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Smoke Test (Windows) / Windows
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Analyze (java-kotlin)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Cloudflare Pages
⚠️ CI failures not shown inline (2)

GitHub Actions: DCO / DCO Sign-off Check: fix(session-context): apply --max-entries on the show subcommands

Conclusion: failure

View job details

##[group]Run base="417c093527cc38d3916249bbd0f8bd3fc5e57999"
 �[36;1mbase="417c093527cc38d3916249bbd0f8bd3fc5e57999"�[0m
 �[36;1mhead="92ad48825c3df23ccb42c4f59b2365852b55c77f"�[0m
 �[36;1mfailed=0�[0m
 �[36;1m�[0m
 �[36;1mfor sha in $(git rev-list --no-merges "$base".."$head"); do�[0m
 �[36;1m  if ! git log -1 --format='%B' "$sha" | grep -qiE '^Signed-off-by: .+ <.+>'; then�[0m
 �[36;1m    echo "::error::Commit $sha is missing a DCO Signed-off-by line."�[0m

GitHub Actions: DCO / 0_DCO Sign-off Check.txt: fix(session-context): apply --max-entries on the show subcommands

Conclusion: failure

View job details

##[group]Run base="417c093527cc38d3916249bbd0f8bd3fc5e57999"
 �[36;1mbase="417c093527cc38d3916249bbd0f8bd3fc5e57999"�[0m
 �[36;1mhead="92ad48825c3df23ccb42c4f59b2365852b55c77f"�[0m
 �[36;1mfailed=0�[0m
 �[36;1m�[0m
 �[36;1mfor sha in $(git rev-list --no-merges "$base".."$head"); do�[0m
 �[36;1m  if ! git log -1 --format='%B' "$sha" | grep -qiE '^Signed-off-by: .+ <.+>'; then�[0m
 �[36;1m    echo "::error::Commit $sha is missing a DCO Signed-off-by line."�[0m
🧰 Additional context used
📓 Path-based instructions (11)
src/commands/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

src/commands/**/*.ts: Commands must export register*Command(program) function that handles I/O only, with no business logic
Use styleText() from node:util for output formatting; support --json flag for machine-readable output and auto-compact JSON in non-TTY/non-CI contexts
Exit with code 0 for success, 1 for violations, 2 for internal errors, and 130 for user cancellation (SIGINT)

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 pr...

Files:

  • src/commands/session-context/cursor.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • src/commands/session-context/claude-code.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use TypeScript strict mode, ESNext target, and ES modules throughout
Use safeParse() when validating with Zod schemas
Use minimal dependencies; prefer Bun built-ins per ARCH-006

Files:

  • src/commands/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.ts
**/*.{ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Runtime must use Bun (>=1.2.21), not Node.js compatible

Files:

  • src/commands/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.ts
src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

AI features must be delivered as a Claude Code plugin (../plugins/claude-code), not via direct API calls

src/**/*.ts: Use logError() from src/helpers/log.ts for user-facing errors instead of printing errors directly.
Exit with code 1 for expected failures such as missing config, invalid input, or validation violations.
Let unexpected errors crash naturally so they are treated as internal errors with exit code 2.
Include actionable suggestions in user-facing error messages whenever possible.
Write user-facing errors to stderr via logError(); do not send them to stdout.
When findProjectRoot() returns null for commands that do not require .archgate/, fall back to process.cwd() as the path key or working directory.
Catch ExitPromptError from Inquirer in the top-level error boundary and treat it as user cancellation: exit with code 130 without logging an error or sending it to Sentry.
Do not use console.error() directly; use logError() for consistent formatting.
Do not exit with codes other than 0, 1, 2, or 130.
Do not send user-cancellation errors such as Inquirer ExitPromptError to Sentry; filter them in beforeSend.

src/**/*.ts: Use styleText(format, text) from node:util for 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 --json must emit machine-readable JSON to stdout with no colors or decorative formatting.
When a command supports --json, use formatJSON() from src/helpers/output.ts for JSON serialization, and pass forcePretty: true when the user explicitly provided --json.
Use isAgentContext() from src/helpers/output.ts to 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 with console.log(), and send errors, warnings, and de...

Files:

  • src/commands/session-context/cursor.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • src/commands/session-context/claude-code.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/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.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/session-context/cursor.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • src/commands/session-context/claude-code.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:

  • src/commands/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.ts
**

⚙️ CodeRabbit configuration file

**: # CLAUDE.md

Archgate 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 + test + ADR check + knip + build check
bun run build:check            # verify build compiles (CI builds binaries via release workflow)
bun run commit                # conventional commit wizard

Validation Gate

bun run validate must pass before any task is considered complete. Fail-fast pipeline: lint → typecheck → format → test → ADR check → knip → build check. Mirrors CI in .github/workflows/code-pull-request.yml.

Git Hooks (Git 2.54+)

Config-based hooks in .githooks run 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 ../.githooks

Opt out of a specific hook: git config --local hook.<name>.enabled false. Skip all hooks for a single commit: git commit --no-verify.

GitHub Act...

Files:

  • src/commands/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.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:

  • src/commands/session-context/cursor.ts
  • tests/commands/session-context/opencode.test.ts
  • src/commands/session-context/copilot.ts
  • src/commands/session-context/opencode.ts
  • tests/commands/session-context/copilot.test.ts
  • src/commands/session-context/claude-code.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.ts
tests/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Test files must mirror src/ directory structure with fixtures in tests/fixtures/

Files:

  • tests/commands/session-context/opencode.test.ts
  • tests/commands/session-context/copilot.test.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.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 under tests/ mirroring the src/ directory structure with <module-name>.test.ts naming.
Use temp directories (mkdtemp) for filesystem tests, and clean them up in afterEach or afterAll.
Close external SDK instances (servers, clients, transports, connections) in afterEach or afterAll, managing their lifecycle in hooks rather than inside individual test bodies.
When a test creates a temporary git repository and runs git commit, configure local user.email and user.name immediately after git init.
Test public module interfaces, not private implementation details.
Use descriptive test names that explain the expected behavior.
Every runnable test()/it() must contain at least one expect() assertion; smoke tests must make the contract explicit with expect(() => fn()).not.toThrow() or await expect(promise).resolves.toBeUndefined().
Use test.skip, test.skipIf, or test.todo for intentionally empty or disabled tests; do not use bare return or empty callbacks to skip work.
If the first expect() is being added to a previously assertion-less test file, add expect to the bun:test import.
When mocking fetch in tests, assign directly to globalThis.fetch and restore the original or use mock.restore() afterward.
Wrap spyOn() and inline mockImplementation() usage in try/finally, or create and restore spies in hooks, so mockRestore() always runs.
Only raise a per-test timeout above the global bun test --timeout 60000; never set a shorter per-test timeout.
Mock first-party modules with import * as mod plus spyOn(mod, "fn"), not mock.module().
When a test needs to redirect user-scope paths, mock os.homedir() instead of relying on HOME/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/session-context/opencode.test.ts
  • tests/commands/session-context/copilot.test.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.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 mutating process.platform directly.

Files:

  • tests/commands/session-context/opencode.test.ts
  • tests/commands/session-context/copilot.test.ts
  • tests/commands/session-context/claude-code.test.ts
  • tests/commands/session-context/cursor.test.ts
🔇 Additional comments (7)
src/commands/session-context/copilot.ts (1)

66-76: Same duplicated maxEntries resolution/comment block as claude-code.ts; see refactor suggestion there.

src/commands/session-context/cursor.ts (1)

66-76: Same duplicated maxEntries resolution/comment block as claude-code.ts; see refactor suggestion there.

src/commands/session-context/opencode.ts (1)

68-78: Same duplicated maxEntries resolution/comment block as claude-code.ts; see refactor suggestion there.

tests/commands/session-context/claude-code.test.ts (1)

252-273: LGTM!

Also applies to: 330-350, 361-363

tests/commands/session-context/copilot.test.ts (1)

247-268: LGTM!

tests/commands/session-context/cursor.test.ts (1)

247-268: LGTM!

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

259-281: LGTM!

Comment thread src/commands/session-context/claude-code.ts Outdated
Per review: the optsWithGlobals fallback (and its explanatory comment)
was copy-pasted across the four show actions. Extract it next to the
already-shared makeMaxEntriesOption in claude-code.ts — a new shared
file under src/commands/ would trip ARCH-001's register-export rule.

Claude-Session: https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto rhuanbarreto enabled auto-merge (squash) July 3, 2026 10:22
@rhuanbarreto rhuanbarreto merged commit e29c70b into main Jul 3, 2026
20 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/show-max-entries-hoisting branch July 3, 2026 10:25
@archgatebot archgatebot Bot mentioned this pull request Jul 3, 2026
rhuanbarreto pushed a commit that referenced this pull request Jul 3, 2026
# archgate

## [0.46.1](v0.46.0...v0.46.1)
(2026-07-03)

### Bug Fixes

* **session-context:** apply --max-entries on the show subcommands
([#448](#448))
([e29c70b](e29c70b))

---
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