Skip to content

008 agent session linking - #14

Merged
S2thend merged 4 commits into
mainfrom
008-agent-session-linking
Apr 3, 2026
Merged

S2thend merged 4 commits into
mainfrom
008-agent-session-linking

Conversation

@S2thend

@S2thend S2thend commented Apr 3, 2026

Copy link
Copy Markdown
Owner

agent as tool issue #7

S2thend added 4 commits April 2, 2026 18:39
Clarify the 008-agent-session-linking artifacts based on the follow-up finding review.

- add structured JSON ambiguity and not-found lookup requirements

- distinguish unresolved agent references from direct lookup not-found failures

- require cross-platform path validation and documented caveats

- require anonymized Claude JSONL contract coverage and export round-trip validation

- add repeatable 100+ session performance validation for list and lookup flows

- align the plan file map and task dependency graph so US3 depends on US1 and US2
Add recursive discovery for Claude subagent transcripts stored under
<main-session>/subagents/, and replace project-wide agent guessing with
per-session link resolution that prefers explicit main-session references
while retaining nested path ownership as fallback evidence.

Expose unresolved referenced child-agent IDs separately from discoverable
linked agent IDs, keep main-session list rows scoped to parent sessions,
and preserve linked/unresolved agent metadata in CLI views and exports.

Extend direct lookup to accept bare and prefixed agent IDs, fail safely on
duplicate matches with AmbiguousAgentSessionError, and emit structured JSON
lookup failures for ambiguous and missing direct agent IDs.

Add nested, conflict, contract, legacy flat-agent, and 100+ session
performance coverage, update documentation and quickstart examples, and
mark the feature task plan complete.

Validation performed:
- npm test
- npm run typecheck
- npm run lint
- npm run build
- Real-data CLI smoke/regression checks against ~/.claude sessions

Per-file summaries:
- README.md: Document direct agent lookup, linked/unresolved metadata, and path caveat.
- specs/008-agent-session-linking/quickstart.md: Update validation commands and JSON error examples.
- specs/008-agent-session-linking/tasks.md: Mark all feature tasks complete.
- src/cli/commands/view.ts: Support agent IDs and emit structured ambiguity/not-found JSON errors.
- src/cli/formatters/session.ts: Display linked and unresolved agent metadata in session headers.
- src/cli/utils/config.ts: Add direct-agent lookup detection and JSON lookup error payload helpers.
- src/cli/utils/errors.ts: Refine CLI error handling for agent lookup failure modes.
- src/lib/errors.ts: Add AmbiguousAgentSessionError and its type guard.
- src/lib/export.ts: Preserve linked and unresolved agent metadata in Markdown exports.
- src/lib/index.ts: Re-export ambiguity helpers and updated metadata-bearing types.
- src/lib/parser.ts: Extract explicit child-agent references from raw Claude session entries.
- src/lib/platform.ts: Add recursive session discovery and nested owner path parsing helpers.
- src/lib/session.ts: Implement precise parent-agent linkage, recursive discovery, and ambiguity-safe lookup.
- src/lib/types.ts: Add unresolvedAgentIds to SessionSummary and Session.
- tests/fixtures/contracts/claude-main-session.jsonl: Add anonymized contract main-session fixture.
- tests/fixtures/contracts/claude-main-session/subagents/agent-linked.jsonl: Add anonymized nested agent contract fixture.
- tests/fixtures/nested-agent-conflict-session.jsonl: Add explicit-vs-path conflict agent fixture.
- tests/fixtures/nested-agent-session.jsonl: Add nested linked agent fixture.
- tests/fixtures/nested-main-session.jsonl: Add nested parent session fixture with unresolved references.
- tests/fixtures/performance/perf-main-session-001.jsonl: Add first performance fixture session.
- tests/fixtures/performance/perf-main-session-101.jsonl: Add 101st performance fixture session.
- tests/helpers/agent-linking.ts: Add shared helpers for temporary Claude fixture trees.
- tests/integration/cli/view.test.ts: Cover direct agent lookup, ambiguity JSON, and missing-agent JSON behavior.
- tests/integration/contract/claude-session-contract.test.ts: Verify anonymized nested Claude contract parsing and lookup.
- tests/integration/export-sessions.test.ts: Verify export metadata round-trips and no project-wide agent guessing.
- tests/integration/get-session.test.ts: Cover nested, fallback, conflict, duplicate, and legacy flat-agent retrieval.
- tests/integration/list-sessions.test.ts: Ensure top-level lists stay main-session-only with scoped agent metadata.
- tests/integration/performance/session-lookup.test.ts: Add 100+ session list/get/view performance validation.
- tests/unit/cli/commands/view.test.ts: Update mocked sessions and assert direct agent lookup error payloads.
- tests/unit/cli/formatters/session.test.ts: Verify linked and unresolved metadata rendering.
- tests/unit/parser.test.ts: Cover explicit child-agent reference extraction from multiple raw shapes.
- tests/unit/platform.test.ts: Cover recursive discovery and nested owner parsing across path variants.
Promote the release version to 0.7.0 because the nested agent-session work is
an additive feature release with new metadata fields, direct agent lookup
semantics, and structured CLI error behavior, not a patch-only bugfix.

Apply Prettier output to the touched TypeScript files so the branch is fully
formatted after the feature implementation commit.

Validation performed:
- npm run typecheck
- npm test

Per-file summaries:
- package.json: Bump package version to 0.7.0.
- package-lock.json: Sync root package and lockfile package versions to 0.7.0.
- src/cli/commands/view.ts: Apply Prettier formatting to the direct agent lookup error branch.
- src/cli/utils/errors.ts: Apply Prettier formatting to usage and not-found error helpers.
- src/lib/platform.ts: Apply Prettier formatting to nested path helper signatures.
- src/lib/session.ts: Apply Prettier formatting to link-resolution and lookup helpers.
- tests/integration/cli/view.test.ts: Apply Prettier formatting to CLI ambiguity assertions.
- tests/integration/performance/session-lookup.test.ts: Apply Prettier formatting to performance fixture setup and lookup timing checks.
@S2thend
S2thend merged commit 96d827b into main Apr 3, 2026
2 checks passed
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