test: add 15 unit tests for lib/state.ts - #263
Open
TerminalGravity wants to merge 4 commits into
Open
Conversation
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/.
…dLog, readLog, now)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds comprehensive test coverage for
src/lib/state.ts— the state persistence layer used by checkpoint, session-health, and most tools.15 tests covering:
loadState: missing file, valid JSON, corrupt JSONsaveState: creates dir, writes JSON, overwrites existingappendLog: creates file, appends JSONL, multiple entries, log rotation at 5MBreadLog: missing file, all entries, lastN slicing, corrupt line skipping, empty filenow: valid ISO format, timestamp accuracyAll tests use temp directories — no side effects on the real workspace.