fix(session-context): select top-level opencode sessions, add --root flag#445
Conversation
…flag opencode stores sub-agent runs as child sessions (parent_id set) that share the parent's directory, so recency-based selection with --skip returned sub-agent transcripts instead of the main development session. opencode skills also run inline in the calling session (they do not create their own session row), so the shipped '--skip 1' guidance skipped the very session it was meant to read. - Only top-level sessions (parent_id IS NULL) participate in recency selection; --session-id can still read any session, incl. children - New --root flag resolves a --session-id child session to its top-level ancestor by walking the parent_id chain (cycle-guarded) - Skip-overflow error and available list now reflect top-level sessions - Docs updated (en/nb/pt-br): accurate directory-matching semantics, new --root row, reworded --skip Verified end-to-end against a real opencode.db where '--skip 1' returned a '@general subagent' child session instead of the parent development session. Claude-Session: https://claude.ai/code/session_011LcL4xUi6VWYRyz7LpiC6L Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
|
| Cohort / File(s) | Summary |
|---|---|
Core selection logic (src/helpers/session-context-opencode.ts) |
Added root option, parent_id tracking, top-level-only skip/recency filtering, ancestor-walk resolution, updated message fetch and returned sessionId |
CLI wiring (src/commands/session-context/opencode.ts) |
Added --root flag wired to helper, updated --skip help text |
Tests (tests/commands/..., tests/helpers/...) |
Updated call-site expectations, added test helpers (makeSimpleSession, insertMessage, insertPart), added/refactored tests for child-session exclusion, sessionId targeting, skip limits, and root resolution |
| Documentation (public + en/nb/pt-br mdx) | Rewrote opencode session matching description, --skip/--session-id semantics, added --root flag documentation and usage examples |
Agent memory (.claude/agent-memory/...) |
Added operational notes and a new project fix record documenting the skip/root behavior change |
Sequence Diagram(s)
sequenceDiagram
participant CLI as opencode command
participant Helper as readOpencodeSession
participant DB as SQLite session table
CLI->>Helper: readOpencodeSession(options incl. root, skip, sessionId)
Helper->>DB: query sessions with parent_id
DB-->>Helper: session rows
Helper->>Helper: select top-level session via skip/recency or sessionId
alt root true and selected has parent_id
Helper->>Helper: walk parent_id chain to top-level ancestor
end
Helper->>DB: fetch messages for selected.id
DB-->>Helper: message rows
Helper-->>CLI: transcript and sessionId
Related PRs: None identified.
Suggested labels: documentation, enhancement, cli
Suggested reviewers: archgate-developer
Poem
A rabbit dug through parent trees,
past sub-agent burrows, deep and breezy,
found the root where sessions start,
skipping siblings, playing it smart.
With --root in paw, the path is clear—
top-level warrens, session found here! 🐇
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main change: top-level session selection and the new --root flag. |
| Description check | ✅ Passed | The description matches the PR and explains the bug, fix, docs, 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.
Comment @coderabbitai help to get the list of available commands.
Deploying archgate-cli with
|
| Latest commit: |
57d1a2d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e1dcb158.archgate-cli.pages.dev |
| Branch Preview URL: | https://claude-giggly-floating-willo.archgate-cli.pages.dev |
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 `@docs/public/llms-full.txt`:
- Around line 4391-4402: docs/public/llms-full.txt is stale and needs to be
regenerated from the source docs. Run the llms-full generator script and commit
the updated output so the generated content matches the current docs; use the
existing docs/public/llms-full.txt entry and the
docs/scripts/generate-llms-full.ts generator as the identifiers to locate the
fix.
In `@docs/src/content/docs/pt-br/reference/cli/session-context.mdx`:
- Around line 63-68: The `--skip` table row in the session context docs is
missing the “always” nuance present in the other locales. Update the Portuguese
text for that row in the session options table so it explicitly says sub-agent
sessions are always excluded, matching the meaning used by the corresponding
`--skip` descriptions elsewhere.
🪄 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: 1511ef46-164b-4e30-9cf1-f0b9762eaa93
📒 Files selected for processing (9)
.claude/agent-memory/archgate-developer/MEMORY.mddocs/public/llms-full.txtdocs/src/content/docs/nb/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxsrc/commands/session-context/opencode.tssrc/helpers/session-context-opencode.tstests/commands/session-context/opencode.test.tstests/helpers/session-context-opencode.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Cloudflare Pages
⚠️ CI failures not shown inline (11)
GitHub Actions: DCO / DCO Sign-off Check: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run base="a53b30507a139db915271095a5a29ccefbd7cecf"
�[36;1mbase="a53b30507a139db915271095a5a29ccefbd7cecf"�[0m
�[36;1mhead="05f5ba45d879572fc420096be0cae45b2fa31050"�[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): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run base="a53b30507a139db915271095a5a29ccefbd7cecf"
�[36;1mbase="a53b30507a139db915271095a5a29ccefbd7cecf"�[0m
�[36;1mhead="05f5ba45d879572fc420096be0cae45b2fa31050"�[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: Code Quality: PR #445 / Analyze (go): Code Quality: PR #445
Conclusion: failure
"bundleSupportsIncludeLogs":true,"bundleSupportsOverlay":true,"databaseInterpretResultsSupportsSarifRunProperty":true,"featuresInVersionResult":true,"indirectTracingSupportsStaticBinaries":false,"informsAboutUnsupportedPathFilters":true,"supportsPython312":true,"mrvaPackCreate":true,"threatModelOption":true,"traceCommandUseBuildMode":true,"v2ramSizing":true,"mrvaPackCreateMultipleQueries":true,"setsCodeqlRunnerEnvVar":true,"sarifMergeRunsFromEqualCategory":true,"forceOverwrite":true,"generateSummarySymbolMap":true,"pythonDefaultIsToNotExtractStdlib":true,"queryServerRunQueries":true,"queryServerTrimCacheWithMode":true,"builtinExtractorsSpecifyDefaultQueries":true,"bqrsDiffResultSets":true,"bundleSupportsIncludeOption":true,"suppressesMissingFileBaselineWarning":true}}}
CODEQL_ACTION_GO_BINARY: /home/runner/work/_temp/codeql-action-go-tracing/bin/go
CODEQL_RAM: 14575
CODEQL_THREADS: 4
CODEQL_PROXY_HOST:
CODEQL_PROXY_PORT:
CODEQL_PROXY_CA_CERTIFICATE:
CODEQL_PROXY_URLS:
##[endgroup]
##[group]Attempting to automatically build go code
[command]/opt/hostedtoolcache/CodeQL/2.25.6/x64/codeql/codeql database trace-command --use-build-mode --working-dir /home/runner/work/cli/cli /home/runner/work/_temp/codeql_databases/go
Picked up JAVA_TOOL_OPTIONS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
Running command in /home/runner/work/cli/cli: [/opt/hostedtoolcache/CodeQL/2.25.6/x64/codeql/go/tools/autobuild.sh]
[] [build-stderr] 2026/07/01 22:51:40 Autobuilder was built with go1.26.0, environment has go1.24.13
[] [build-stderr] 2026/07/01 22:51:40 LGTM_SRC is /home/runner/work/cli/cli
[] [build-stderr] 2026/07/01 22:51:40 Found no go.work files in the workspace; looking for go.mod files...
[] [build-stderr] 2026/07/01 22:51:40 Found 1 go.mod files in: shims/go/go.mod.
[] [build-stderr] 2026/07/01 22:51:40 Found 1 go.mod file(s).
[] [build-stderr] 2026/07/01 22:51:40 Import path is 'github.com/archgate/cli'
[] [build-stderr] 2026/07/0...
GitHub Actions: Code Quality: PR #445 / 4_Analyze (go).txt: Code Quality: PR #445
Conclusion: failure
1 Extracting types for package crypto/aes.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/aes.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/des.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/des.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/des.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/internal/fips140/nistec/fiat.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/internal/fips140/nistec/fiat.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/internal/fips140/nistec/fiat.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/internal/fips140/nistec.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/internal/fips140/nistec.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/internal/fips140/nistec.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/internal/fips140/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/internal/fips140/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/internal/fips140/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/internal/fips140/edwards25519/field.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/internal/fips140/edwards25519/field.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/internal/fips140/edwards25519/field.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Done extracting types for package crypto/ecdh.
[] [build-stderr] 2026/07/01 22:51:51 Processing package crypto/elliptic.
[] [build-stderr] 2026/07/01 22:51:51 Extracting types for package crypto/elliptic.
[] [build-...
GitHub Actions: Validate / Validate Code: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run # shim-tests is skipped when no shim files changed — treat skipped as success.
�[36;1m# shim-tests is skipped when no shim files changed — treat skipped as success.�[0m
�[36;1mSHIM_OK="skipped"�[0m
�[36;1mif [[ "$SHIM_OK" == "skipped" ]]; then SHIM_OK="success"; fi�[0m
�[36;1m�[0m
�[36;1mif [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "$SHIM_OK" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]]; then�[0m
�[36;1m echo "::error::One or more jobs failed:"�[0m
GitHub Actions: Validate / 0_Validate Code.txt: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run # shim-tests is skipped when no shim files changed — treat skipped as success.
�[36;1m# shim-tests is skipped when no shim files changed — treat skipped as success.�[0m
�[36;1mSHIM_OK="skipped"�[0m
�[36;1mif [[ "$SHIM_OK" == "skipped" ]]; then SHIM_OK="success"; fi�[0m
�[36;1m�[0m
�[36;1mif [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "$SHIM_OK" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]] || \�[0m
�[36;1m [[ "success" != "success" ]]; then�[0m
�[36;1m echo "::error::One or more jobs failed:"�[0m
GitHub Actions: Validate / Lint, Test & Check: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run bun run docs/scripts/generate-llms-full.ts
�[36;1mbun run docs/scripts/generate-llms-full.ts�[0m
�[36;1mgit diff --exit-code docs/public/llms-full.txt || {�[0m
�[36;1m echo "::error::docs/public/llms-full.txt is out of date. Run 'bun run docs/scripts/generate-llms-full.ts' and commit the result."�[0m
GitHub Actions: Validate / 1_Coverage Report.txt: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run COVERAGE="90.0"
�[36;1mCOVERAGE="90.0"�[0m
�[36;1mMIN_COVERAGE=90�[0m
�[36;1mBELOW=$(awk "BEGIN{print ($COVERAGE < $MIN_COVERAGE) ? 1 : 0}")�[0m
�[36;1mif [ "$BELOW" = "1" ]; then�[0m
�[36;1m echo "::error::Code coverage is ${COVERAGE}%, which is below the minimum threshold of ${MIN_COVERAGE}%."�[0m
GitHub Actions: Validate / Smoke Test (Linux) _ Linux: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run if [ -z "$ARCHGATE_VERSION" ]; then
�[36;1mif [ -z "$ARCHGATE_VERSION" ]; then�[0m
�[36;1m # Find the newest release that already has the Linux asset uploaded.�[0m
�[36;1m # On release-commit pushes the Validate and Release workflows start�[0m
�[36;1m # concurrently, so the latest tag may exist before its binaries are�[0m
�[36;1m # uploaded by release-binaries.yml — hitting a 404.�[0m
�[36;1m asset="archgate-linux-x64.tar.gz"�[0m
�[36;1m tags="$(gh release list --limit 5 --json tagName --jq '.[].tagName' 2>/dev/null || true)"�[0m
�[36;1m if [ -z "$tags" ]; then�[0m
�[36;1m echo "::warning::No releases found, skipping install.sh smoke test"�[0m
�[36;1m exit 0�[0m
�[36;1m fi�[0m
�[36;1m found=""�[0m
�[36;1m for tag in $tags; do�[0m
�[36;1m assets="$(gh release view "$tag" --json assets --jq '.assets[].name' 2>/dev/null || true)"�[0m
�[36;1m if echo "$assets" | grep -qF "$asset"; then�[0m
�[36;1m ARCHGATE_VERSION="$tag"�[0m
�[36;1m found=1�[0m
�[36;1m break�[0m
�[36;1m fi�[0m
�[36;1m done�[0m
�[36;1m if [ -z "$found" ]; then�[0m
�[36;1m echo "::warning::No release with $asset found, skipping install.sh smoke test"�[0m
�[36;1m exit 0�[0m
�[36;1m fi�[0m
�[36;1m export ARCHGATE_VERSION�[0m
�[36;1mfi�[0m
�[36;1mecho "Testing install.sh with version $ARCHGATE_VERSION"�[0m
�[36;1m�[0m
�[36;1mexport ARCHGATE_INSTALL_DIR="$(mktemp -d)"�[0m
�[36;1m�[0m
�[36;1msh install.sh�[0m
�[36;1m�[0m
�[36;1mif [ ! -f "$ARCHGATE_INSTALL_DIR/archgate" ]; then�[0m
�[36;1m echo "::error::archgate binary not found at $ARCHGATE_INSTALL_DIR/archgate after install"�[0m
GitHub Actions: Validate / Coverage Report: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run COVERAGE="90.0"
�[36;1mCOVERAGE="90.0"�[0m
�[36;1mMIN_COVERAGE=90�[0m
�[36;1mBELOW=$(awk "BEGIN{print ($COVERAGE < $MIN_COVERAGE) ? 1 : 0}")�[0m
�[36;1mif [ "$BELOW" = "1" ]; then�[0m
�[36;1m echo "::error::Code coverage is ${COVERAGE}%, which is below the minimum threshold of ${MIN_COVERAGE}%."�[0m
GitHub Actions: Validate / 3_Smoke Test (Linux) _ Linux.txt: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run if [ -z "$ARCHGATE_VERSION" ]; then
�[36;1mif [ -z "$ARCHGATE_VERSION" ]; then�[0m
�[36;1m # Find the newest release that already has the Linux asset uploaded.�[0m
�[36;1m # On release-commit pushes the Validate and Release workflows start�[0m
�[36;1m # concurrently, so the latest tag may exist before its binaries are�[0m
�[36;1m # uploaded by release-binaries.yml — hitting a 404.�[0m
�[36;1m asset="archgate-linux-x64.tar.gz"�[0m
�[36;1m tags="$(gh release list --limit 5 --json tagName --jq '.[].tagName' 2>/dev/null || true)"�[0m
�[36;1m if [ -z "$tags" ]; then�[0m
�[36;1m echo "::warning::No releases found, skipping install.sh smoke test"�[0m
�[36;1m exit 0�[0m
�[36;1m fi�[0m
�[36;1m found=""�[0m
�[36;1m for tag in $tags; do�[0m
�[36;1m assets="$(gh release view "$tag" --json assets --jq '.assets[].name' 2>/dev/null || true)"�[0m
�[36;1m if echo "$assets" | grep -qF "$asset"; then�[0m
�[36;1m ARCHGATE_VERSION="$tag"�[0m
�[36;1m found=1�[0m
�[36;1m break�[0m
�[36;1m fi�[0m
�[36;1m done�[0m
�[36;1m if [ -z "$found" ]; then�[0m
�[36;1m echo "::warning::No release with $asset found, skipping install.sh smoke test"�[0m
�[36;1m exit 0�[0m
�[36;1m fi�[0m
�[36;1m export ARCHGATE_VERSION�[0m
�[36;1mfi�[0m
�[36;1mecho "Testing install.sh with version $ARCHGATE_VERSION"�[0m
�[36;1m�[0m
�[36;1mexport ARCHGATE_INSTALL_DIR="$(mktemp -d)"�[0m
�[36;1m�[0m
�[36;1msh install.sh�[0m
�[36;1m�[0m
�[36;1mif [ ! -f "$ARCHGATE_INSTALL_DIR/archgate" ]; then�[0m
�[36;1m echo "::error::archgate binary not found at $ARCHGATE_INSTALL_DIR/archgate after install"�[0m
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use TypeScript strict mode, ESNext target, and ES modules throughout
UsesafeParse()when validating with Zod schemas
Use minimal dependencies; prefer Bun built-ins per ARCH-006
Files:
tests/commands/session-context/opencode.test.tssrc/commands/session-context/opencode.tstests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.ts
tests/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Test files must mirror
src/directory structure with fixtures intests/fixtures/
Files:
tests/commands/session-context/opencode.test.tstests/helpers/session-context-opencode.test.ts
**/*.{ts,tsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Runtime must use Bun (>=1.2.21), not Node.js compatible
Files:
tests/commands/session-context/opencode.test.tssrc/commands/session-context/opencode.tstests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.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/commands/session-context/opencode.test.tstests/helpers/session-context-opencode.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/session-context/opencode.test.tssrc/commands/session-context/opencode.tstests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.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/session-context/opencode.test.tstests/helpers/session-context-opencode.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/session-context/opencode.test.tssrc/commands/session-context/opencode.tstests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.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 + 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 → 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.GitHub Act...
Files:
tests/commands/session-context/opencode.test.tsdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxsrc/commands/session-context/opencode.tsdocs/public/llms-full.txtdocs/src/content/docs/nb/reference/cli/session-context.mdxtests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.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/session-context/opencode.test.tsdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxsrc/commands/session-context/opencode.tsdocs/public/llms-full.txtdocs/src/content/docs/nb/reference/cli/session-context.mdxtests/helpers/session-context-opencode.test.tssrc/helpers/session-context-opencode.ts
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.mdxpage in that directory must correspond to exactly one top-level command.
Files:
docs/src/content/docs/reference/cli/session-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
.mdxpage.Every parent CLI reference page in
docs/src/content/docs/reference/cli/must contain headings for its direct subcommands using the exactarchgate <parent> <sub>format, and must not keep headings for subcommands that no longer exist.
Files:
docs/src/content/docs/reference/cli/session-context.mdx
{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:
docs/src/content/docs/reference/cli/session-context.mdx
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 underdocs/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/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/nb/reference/cli/session-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>.mdxand add the page todocs/astro.config.mjssidebar configuration.
Files:
docs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/nb/reference/cli/session-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/session-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/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/nb/reference/cli/session-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 underdocs/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, andlink/href/slugattribute 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/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/nb/reference/cli/session-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/session-context.mdx
src/commands/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
src/commands/**/*.ts: Commands must exportregister*Command(program)function that handles I/O only, with no business logic
UsestyleText()fromnode:utilfor output formatting; support--jsonflag 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 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 pr...
Files:
src/commands/session-context/opencode.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: UselogError()fromsrc/helpers/log.tsfor user-facing errors instead of printing errors directly.
Exit with code1for 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 code2.
Include actionable suggestions in user-facing error messages whenever possible.
Write user-facing errors to stderr vialogError(); do not send them to stdout.
WhenfindProjectRoot()returnsnullfor commands that do not require.archgate/, fall back toprocess.cwd()as the path key or working directory.
CatchExitPromptErrorfrom Inquirer in the top-level error boundary and treat it as user cancellation: exit with code130without logging an error or sending it to Sentry.
Do not useconsole.error()directly; uselogError()for consistent formatting.
Do not exit with codes other than0,1,2, or130.
Do not send user-cancellation errors such as InquirerExitPromptErrorto Sentry; filter them inbeforeSend.
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 de...
Files:
src/commands/session-context/opencode.tssrc/helpers/session-context-opencode.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/session-context/opencode.tssrc/helpers/session-context-opencode.ts
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
duform and correct Norwegian characters (æ,ø,å).
Files:
docs/src/content/docs/nb/reference/cli/session-context.mdx
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. Command files are exempt because they are the I/O layer.
Files:
src/helpers/session-context-opencode.ts
🧠 Learnings (1)
📚 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
🪛 GitHub Actions: Validate / 6_Lint, Test & Check.txt
docs/public/llms-full.txt
[error] 1-1: CI check failed: docs/public/llms-full.txt is out of date. Run 'bun run docs/scripts/generate-llms-full.ts' and commit the result.
🪛 GitHub Actions: Validate / Lint, Test & Check
docs/public/llms-full.txt
[error] 1-1: docs/public/llms-full.txt is out of date. Run 'bun run docs/scripts/generate-llms-full.ts' and commit the result.
🪛 LanguageTool
docs/src/content/docs/pt-br/reference/cli/session-context.mdx
[uncategorized] ~57-~57: Pontuação duplicada
Context: ...essão principal de desenvolvimento. Use --session-id para ler uma sessão específi...
(DOUBLE_PUNCTUATION_XML)
[style] ~65-~65: Evite abreviações de internet. Considere escrever “não” por extenso. Se quis dizer “n”, coloque entre aspas.
Context: ...----------------------------------- | | --max-entries <n> | Máximo de entradas a retornar (padr...
(INTERNET_ABBREVIATIONS)
[style] ~66-~66: Evite abreviações de internet. Considere escrever “não” por extenso. Se quis dizer “n”, coloque entre aspas.
Context: ... | | --skip <n> | Pular as N sessões de nível ...
(INTERNET_ABBREVIATIONS)
[grammar] ~66-~66: Possível erro de concordância de número.
Context: ...>` | Pular as N sessões de nível superior mais recentes (sessões de sub-agente são excluídas) ...
(GENERAL_NUMBER_AGREEMENT_ERRORS)
🔇 Additional comments (7)
.claude/agent-memory/archgate-developer/MEMORY.md (1)
46-48: LGTM!src/helpers/session-context-opencode.ts (1)
26-32: LGTM!Also applies to: 55-68, 98-103, 125-162, 174-174, 223-223
src/commands/session-context/opencode.ts (1)
19-19: LGTM!Also applies to: 31-42
tests/commands/session-context/opencode.test.ts (1)
187-187: LGTM!tests/helpers/session-context-opencode.test.ts (1)
91-97: LGTM!Also applies to: 129-175, 207-208, 224-224, 243-253, 356-368, 384-483
docs/src/content/docs/reference/cli/session-context.mdx (1)
57-68: LGTM!docs/src/content/docs/nb/reference/cli/session-context.mdx (1)
57-68: LGTM!
- Port the sibling fan-out regression test from #444, adapted to the new semantics (--skip 1 errors honestly; default and --root resolve the parent) with unconditional control assertions - Enrich the root option JSDoc with the inline-skill / sibling fan-out rationale - Document the multi-top-level-session caveat and deterministic resolution via --session-id <id> --root in the CLI reference (en/nb/pt-br) and regenerate llms-full.txt - pt-br: add the missing "sempre" nuance to the --skip row - Port agent-memory captures from #444 (generated plugins skill files; session-context skip/root fix incl. the open claude-code/cursor follow-up) Claude-Session: https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/helpers/session-context-opencode.ts (2)
135-172: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winNo test coverage for the cycle-protection path in the
--rootwalk.The
seenset guards against aparent_idcycle causing an infinite loop, but this is a safety-critical path (prevents a hang) that doesn't appear to be exercised by any of the added tests (fan-out, skip, explicit child read, root resolution). Consider adding a regression test with a synthetic cycle (e.g. A'sparent_id→ B, B'sparent_id→ A) to lock in the termination behavior.🤖 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 `@src/helpers/session-context-opencode.ts` around lines 135 - 172, Add a regression test for the `options.root` parent-walk in `session-context-opencode.ts` to cover the `seen` cycle guard. Create a synthetic session chain with a `parent_id` loop (for example, two sessions pointing to each other) and verify the selection logic terminates and returns a stable result instead of hanging. Place the test alongside the existing session selection coverage so `matching`, `selected`, and the `--root` traversal behavior are exercised together.
135-172: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low valueRoot-walk
byIdmap spans all sessions, not just the matched project — consider scoping tomatching.The
--rootancestor walk buildsbyIdfromallSessions(unfiltered by directory) rather than the directory-filteredmatchinglist. Per the documented invariant, sub-agent children always share their parent'sdirectory, so this is currently safe — but if that invariant is ever violated (e.g. a sub-agent spawned with a differentcwd, or corruptedparent_iddata), the walk would silently resolve to — and return transcript data for — a session from a different project, with no indication to the caller.Separately, when
byId.get(selected.parent_id)misses (danglingparent_id), the loop breaks andselectedis returned as-is even though it may not be the true root — again silently, with no signal that resolution was incomplete.Building
byIdfrommatchinginstead ofallSessionswould contain any leakage to the current project as a defense-in-depth measure, at no behavioral cost when the invariant holds.🛡️ Suggested defensive fix
let selected = target; if (options?.root === true) { - const byId = new Map(allSessions.map((s) => [s.id, s])); + const byId = new Map(matching.map((s) => [s.id, s])); const seen = new Set<string>();Since this depends on an assumption about opencode's own session-graph invariants (that sub-agents always inherit the parent's
directory), it would help to confirm this against opencode's actual behavior/schema.🤖 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 `@src/helpers/session-context-opencode.ts` around lines 135 - 172, The --root ancestor walk in session-context-opencode should not resolve parents from the global allSessions set because that can leak across projects if parent_id or directory invariants are broken. Update the root-walk logic around the selected/byId lookup so the ancestor map is built from matching instead of allSessions, keeping resolution scoped to the current project. Also make the missing-parent case in the while loop explicit in the SessionContext selection flow so a dangling parent_id does not silently return a non-root session as if root resolution succeeded.
🤖 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.
Outside diff comments:
In `@src/helpers/session-context-opencode.ts`:
- Around line 135-172: Add a regression test for the `options.root` parent-walk
in `session-context-opencode.ts` to cover the `seen` cycle guard. Create a
synthetic session chain with a `parent_id` loop (for example, two sessions
pointing to each other) and verify the selection logic terminates and returns a
stable result instead of hanging. Place the test alongside the existing session
selection coverage so `matching`, `selected`, and the `--root` traversal
behavior are exercised together.
- Around line 135-172: The --root ancestor walk in session-context-opencode
should not resolve parents from the global allSessions set because that can leak
across projects if parent_id or directory invariants are broken. Update the
root-walk logic around the selected/byId lookup so the ancestor map is built
from matching instead of allSessions, keeping resolution scoped to the current
project. Also make the missing-parent case in the while loop explicit in the
SessionContext selection flow so a dangling parent_id does not silently return a
non-root session as if root resolution succeeded.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9f40ee50-0585-4bbb-bb16-dc3ce8cfca1a
📒 Files selected for processing (9)
.claude/agent-memory/archgate-developer/MEMORY.md.claude/agent-memory/archgate-developer/project_plugins_generated_skill_files.md.claude/agent-memory/archgate-developer/project_session_context_skip_root_fix.mddocs/public/llms-full.txtdocs/src/content/docs/nb/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxsrc/helpers/session-context-opencode.tstests/helpers/session-context-opencode.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
- GitHub Check: Cursor Bugbot
- GitHub Check: Smoke Test (Windows) / Windows
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (csharp)
- GitHub Check: Cloudflare Pages
⚠️ CI failures not shown inline (2)
GitHub Actions: DCO / DCO Sign-off Check: fix(session-context): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run base="a53b30507a139db915271095a5a29ccefbd7cecf"
�[36;1mbase="a53b30507a139db915271095a5a29ccefbd7cecf"�[0m
�[36;1mhead="918c0870091f6d8fa41744424f6cb43d90f889a4"�[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): select top-level opencode sessions, add --root flag
Conclusion: failure
##[group]Run base="a53b30507a139db915271095a5a29ccefbd7cecf"
�[36;1mbase="a53b30507a139db915271095a5a29ccefbd7cecf"�[0m
�[36;1mhead="918c0870091f6d8fa41744424f6cb43d90f889a4"�[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 (21)
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 underdocs/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/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-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>.mdxand add the page todocs/astro.config.mjssidebar configuration.
Files:
docs/src/content/docs/nb/reference/cli/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-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/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-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 underdocs/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, andlink/href/slugattribute 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/session-context.mdxdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-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
duform and correct Norwegian characters (æ,ø,å).
Files:
docs/src/content/docs/nb/reference/cli/session-context.mdx
**
⚙️ 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 + 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 → 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.GitHub Act...
Files:
docs/src/content/docs/nb/reference/cli/session-context.mdxdocs/public/llms-full.txtdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxsrc/helpers/session-context-opencode.tstests/helpers/session-context-opencode.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.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:
docs/src/content/docs/nb/reference/cli/session-context.mdxdocs/public/llms-full.txtdocs/src/content/docs/reference/cli/session-context.mdxdocs/src/content/docs/pt-br/reference/cli/session-context.mdxsrc/helpers/session-context-opencode.tstests/helpers/session-context-opencode.test.ts
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.mdxpage in that directory must correspond to exactly one top-level command.
Files:
docs/src/content/docs/reference/cli/session-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
.mdxpage.Every parent CLI reference page in
docs/src/content/docs/reference/cli/must contain headings for its direct subcommands using the exactarchgate <parent> <sub>format, and must not keep headings for subcommands that no longer exist.
Files:
docs/src/content/docs/reference/cli/session-context.mdx
{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:
docs/src/content/docs/reference/cli/session-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/session-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/session-context.mdx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use TypeScript strict mode, ESNext target, and ES modules throughout
UsesafeParse()when validating with Zod schemas
Use minimal dependencies; prefer Bun built-ins per ARCH-006
Files:
src/helpers/session-context-opencode.tstests/helpers/session-context-opencode.test.ts
**/*.{ts,tsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Runtime must use Bun (>=1.2.21), not Node.js compatible
Files:
src/helpers/session-context-opencode.tstests/helpers/session-context-opencode.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: UselogError()fromsrc/helpers/log.tsfor user-facing errors instead of printing errors directly.
Exit with code1for 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 code2.
Include actionable suggestions in user-facing error messages whenever possible.
Write user-facing errors to stderr vialogError(); do not send them to stdout.
WhenfindProjectRoot()returnsnullfor commands that do not require.archgate/, fall back toprocess.cwd()as the path key or working directory.
CatchExitPromptErrorfrom Inquirer in the top-level error boundary and treat it as user cancellation: exit with code130without logging an error or sending it to Sentry.
Do not useconsole.error()directly; uselogError()for consistent formatting.
Do not exit with codes other than0,1,2, or130.
Do not send user-cancellation errors such as InquirerExitPromptErrorto Sentry; filter them inbeforeSend.
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 de...
Files:
src/helpers/session-context-opencode.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. Command files are exempt because they are the I/O layer.
Files:
src/helpers/session-context-opencode.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/helpers/session-context-opencode.tstests/helpers/session-context-opencode.test.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/helpers/session-context-opencode.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/helpers/session-context-opencode.tstests/helpers/session-context-opencode.test.ts
tests/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Test files must mirror
src/directory structure with fixtures intests/fixtures/
Files:
tests/helpers/session-context-opencode.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 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/helpers/session-context-opencode.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/helpers/session-context-opencode.test.ts
🧠 Learnings (1)
📚 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_plugins_generated_skill_files.md.claude/agent-memory/archgate-developer/project_session_context_skip_root_fix.md.claude/agent-memory/archgate-developer/MEMORY.md
🪛 LanguageTool
docs/src/content/docs/pt-br/reference/cli/session-context.mdx
[style] ~67-~67: Evite abreviações de internet. Considere escrever “não” por extenso. Se quis dizer “n”, coloque entre aspas.
Context: ...----------------------------------- | | --max-entries <n> | Máximo de entradas a retornar (padr...
(INTERNET_ABBREVIATIONS)
[style] ~68-~68: Evite abreviações de internet. Considere escrever “não” por extenso. Se quis dizer “n”, coloque entre aspas.
Context: ... | | --skip <n> | Pular as N sessões de nível ...
(INTERNET_ABBREVIATIONS)
[grammar] ~68-~68: Possível erro de concordância de número.
Context: ...>` | Pular as N sessões de nível superior mais recentes (sessões de sub-agente são sempre exclu...
(GENERAL_NUMBER_AGREEMENT_ERRORS)
🪛 markdownlint-cli2 (0.22.1)
.claude/agent-memory/archgate-developer/project_plugins_generated_skill_files.md
[warning] 8-8: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
.claude/agent-memory/archgate-developer/project_session_context_skip_root_fix.md
[warning] 8-8: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🔇 Additional comments (12)
.claude/agent-memory/archgate-developer/MEMORY.md (1)
46-48: LGTM!Also applies to: 86-90
.claude/agent-memory/archgate-developer/project_plugins_generated_skill_files.md (1)
8-12: LGTM!.claude/agent-memory/archgate-developer/project_session_context_skip_root_fix.md (1)
8-16: LGTM!docs/src/content/docs/pt-br/reference/cli/session-context.mdx (2)
65-70: Previously-flagged "sempre" nuance now present.The earlier review comment about the pt-br
--skiprow dropping the "always" nuance is resolved — line 68 now reads "sessões de sub-agente são sempre excluídas", matching en/nb.
57-64: LGTM!Also applies to: 103-108
src/helpers/session-context-opencode.ts (3)
26-43: LGTM!
105-113: LGTM!
184-184: LGTM!Also applies to: 233-233
tests/helpers/session-context-opencode.test.ts (1)
452-480: LGTM! Good regression coverage for the exact fan-out scenario described in the PR objective (newer siblings must not shadow the parent).docs/public/llms-full.txt (1)
4391-4404: LGTM! Content is consistent with the updateddocs/src/content/docs/reference/cli/session-context.mdx, and the previously-flagged staleness issue appears resolved.Also applies to: 4438-4442
docs/src/content/docs/nb/reference/cli/session-context.mdx (1)
57-70: LGTM!Also applies to: 103-108
docs/src/content/docs/reference/cli/session-context.mdx (1)
57-70: LGTM!Also applies to: 103-108
- Haiku reviewer await-on-sync false positive recurred (ARCH-NONE) - Git Bash /tmp paths are invisible to Windows-native tools - plugins-repo validate fails locally on Windows (service test /tmp sqlite path); use build/check-artifacts scripts locally instead Claude-Session: https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
The plugins repo is private while this repo is public — the ported memory files exposed its internals (repo paths, build scripts, service test structure). Remove the generated-skill-files memory and the Sibling Repo section, and sanitize the remaining notes to only reference the publicly distributed plugin behavior. The detailed memories move to the private plugins repo. Claude-Session: https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
…ip and its false premise (#446) ## Problem Follow-up to #445. The `--skip` flag on every session-context subcommand existed for one advertised purpose: "skip the sub-agent's own session to read the parent." Verified false on real data (skills run inline; Agent-tool sub-agents create no project session files; zero `isSidechain` entries). With that premise dead, positional recency guessing had no remaining role — reading the current conversation needs no knobs, and addressing an earlier session should be explicit. ## New API (breaking) Each editor subcommand is now a command group; the editor is the namespace, so no `--editor` flag anywhere: | Command | Purpose | |---|---| | `session-context <editor> [--max-entries]` | Read the **current conversation** (default action) | | `session-context <editor> list` | That editor's sessions for the project as JSON (`id` + `updatedAt`; opencode adds `title`, lists top-level sessions only) | | `session-context <editor> show <session-id> [--max-entries]` | Read a specific session; `--root` exists only on `opencode show` (child → top-level ancestor) | Removed: `--skip` everywhere; `--session-id` flags; `--root` from the opencode read. (Intermediate shapes iterated on this unreleased branch — per-editor `--list`/`--session-id` flags, then top-level `list`/`show` subcommands with `--editor` — are also gone.) ## Notes - Sub-subcommands are documented as `####` blocks inside each editor's docs section — same pattern as `adr domain`, matching ARCH-016's one-level rule scope - list/show behavior tests spawn the real CLI with HOME/USERPROFILE/XDG redirected (Bun's `mock.module` state is process-global across test files, so in-process tests would race the sibling tests' helper mocks) - `bun run validate` green (1349 tests, 39/39 ADR checks); live smoke test: `claude-code list`, `claude-code show <real-id>` verified against real stores; `session-context list` and `--session-id` correctly rejected - Docs rewritten in en/nb/pt-br; `llms-full.txt` regenerated; agent memory updated with the final API ## Release sequencing The distributed lessons-learned skill's escape-hatch text references `<editor> list`/`<editor> show` — **this CLI must release before the plugin change ships**, and the plugin release should follow promptly (already-installed skills referencing `--skip 1` will hit their error-fallback path on the new CLI). https://claude.ai/code/session_01SGjSjrywTnZDcUqgHWGrTj --------- Signed-off-by: Rhuan Barreto <rhuan@barreto.work> Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# archgate ## [0.46.0](v0.45.7...v0.46.0) (2026-07-02) ### ⚠ BREAKING CHANGES * **session-context:** per-editor list/show subcommands; remove --skip and its false premise (#446) ### Features * **session-context:** per-editor list/show subcommands; remove --skip and its false premise ([#446](#446)) ([dd96230](dd96230)) ### Bug Fixes * **ci:** read POSTHOG_PROJECT_ID from secrets, not vars, in release annotation ([#443](#443)) ([a53b305](a53b305)) * detect opencode Desktop app installs, not just the CLI ([#439](#439)) ([ed92b2b](ed92b2b)) * **hooks:** force bash shell for WorktreeCreate hook on Windows ([#442](#442)) ([9da86cf](9da86cf)) * **release:** cap breaking-change bumps to minor while pre-1.0 ([#447](#447)) ([3df6c91](3df6c91)), closes [#446](#446) [#440](#440) [#440](#440) [#440](#440) * repair broken WorktreeCreate hook and add PR approval policy ([#441](#441)) ([de5e97d](de5e97d)) * **session-context:** select top-level opencode sessions, add --root flag ([#445](#445)) ([29b13f4](29b13f4)) --- 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>
Problem
archgate session-context opencode --skip 1returned the wrong session. Evidence from a realopencode.db: the lessons-learned skill ran--skip 1in the main dev session and got back a "General process ADR review (@general subagent)" child session — 17 entries of[tool: bash]noise instead of the development transcript.Two compounding causes:
parent_idset) sharing the parent'sdirectory, so the--skipindex was meaningless (e.g. 1 top-level + 4 child sessions for the same project).--skip 1guidance was built on a false premise. opencode skills run inline in the calling session (no own session row — verified in the DB: the tool call is recorded in the parent session), so--skip 1skipped the exact session it was meant to read.Fix
parent_id IS NULL);--session-idcan still read any session, including children--rootflag resolves a--session-idchild session to its top-level ancestor by walking theparent_idchain (cycle-guarded); without--session-idit is an explicit alias for the new defaultavailablelist now reflect top-level sessionsllms-full.txt): corrected matching description (sessiondirectoryfield, notpathmetadata), documented--rootVerification
opencode.db: old--skip 1→ sub-agent session in 2/2 projects; new default/--root→ correct main session;--session-id <child> --root→ resolves to main;--skip 1now errors honestlybun run validategreen (1316 tests),archgate check39/39, reviewer skill APPROVED--session-id, skip indexing over top-level only,--rootchain walk (incl. grandchild)Release sequencing
The companion plugins-repo PR updates the opencode
archgate-lessons-learnedSKILL.md to use--root. This CLI change must release first — the skill references the new flag (with a plain-command fallback for older CLIs).https://claude.ai/code/session_011LcL4xUi6VWYRyz7LpiC6L