Skip to content

test: add session-parser test suite (20 tests) - #261

Open
TerminalGravity wants to merge 4 commits into
mainfrom
test/session-parser-tests-mar16
Open

test: add session-parser test suite (20 tests)#261
TerminalGravity wants to merge 4 commits into
mainfrom
test/session-parser-tests-mar16

Conversation

@TerminalGravity

Copy link
Copy Markdown
Collaborator

Adds comprehensive test coverage for src/lib/session-parser.ts — a core module that had zero tests.

20 tests covering:

  • User prompt parsing and content extraction (string + array blocks)
  • Correction detection after assistant messages (7 phrase variants via it.each)
  • Tool call extraction from assistant content blocks
  • Sub-agent spawn detection (Task/dispatch_agent)
  • Error detection from tool_result with is_error
  • Compaction event detection from system messages
  • Malformed JSON line handling (graceful skip, no crash)
  • Empty content filtering
  • Epoch timestamp normalization
  • findSessionFiles including subagent directories
  • Edge case: nonexistent directory returns empty

All 63 tests pass (43 existing + 20 new).

Shows 4 concrete scenarios: vague prompt clarification, multi-step
scoping, correction pattern matching, and cross-service awareness.
Each example includes the prompt, triage classification, and the
actual output users can expect.
The README and examples/README.md referenced examples/.preflight/
but the actual config files didn't exist. Added:

- config.yml — profile, related projects, thresholds, embeddings
- triage.yml — keyword rules and strictness settings
- contracts/api.yml — manual contract definition examples

All files are heavily commented so users can copy them into their
project root and customize without needing to reference the docs.
The init wizard resolved the templates directory relative to dist/cli/,
which pointed to dist/templates/ — a path that doesn't exist. Templates
live in src/templates/ and ship in the npm tarball via the 'files' field.

Fixed by going up three levels (dist/cli/init.js → package root) instead
of two, then into src/templates/.
Covers prompt parsing, correction detection, tool call extraction,
sub-agent spawns, error/compaction events, malformed JSON handling,
array content blocks, epoch timestamps, and findSessionFiles.
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