Commit Graph

32 Commits

Author SHA1 Message Date
Affaan Mustafa
554b5d6704 fix: header subtitle width mismatch in skill-create-output; add 9 tests (Round 34)
- Fix subtitle padding 55→59 so line 94 matches 64-char border width
- Add 4 header width alignment tests (skill-create-output)
- Add 3 getExecCommand non-string args tests (package-manager)
- Add 2 detectFromPackageJson non-string type tests (package-manager)
2026-02-13 03:58:16 -08:00
Affaan Mustafa
bb9df39d96 test: add 10 tests for birthtime fallback, stdin error, alias rollback (Round 33)
Cover createdTime/birthtime fallback in session-manager, readStdinJson
error event settled-flag guard in utils, renameAlias rollback on naming
conflict in session-aliases, and saveAliases backup preservation on
serialization failure. Total: 713 tests.
2026-02-13 03:50:44 -08:00
Affaan Mustafa
167b105cac fix: reject flags passed as package manager names in setup-package-manager CLI
When --global or --project was followed by another flag (e.g., --global --project),
the flag was treated as a package manager name. Added pmName.startsWith('-') check
to both handlers. Added 20 tests across 4 test files covering argument validation,
ensureDir error propagation, runCommand stderr handling, and saveAliases failure paths.
2026-02-13 03:37:46 -08:00
Affaan Mustafa
b1eb99d961 fix: use local-time Date constructor in session-manager to prevent timezone day shift
new Date('YYYY-MM-DD') creates UTC midnight, which in negative UTC offset
timezones (e.g., Hawaii) causes getDate() to return the previous day.
Replaced with new Date(year, month - 1, day) for correct local-time behavior.

Added 15 tests: session-manager datetime verification and edge cases (7),
package-manager getCommandPattern special characters (4), and
validators model/skill-reference validation (4). Tests: 651 → 666.
2026-02-13 03:29:04 -08:00
Affaan Mustafa
253645b5e4 test: add 22 tests for readStdinJson, evaluate-session config, and suggest-compact hook
- utils.test.js: 5 tests for readStdinJson maxSize truncation, whitespace-only stdin, trailing whitespace, and BOM prefix handling
- evaluate-session.test.js: 4 tests for config file parsing, assistant-only transcripts, malformed JSON lines, and empty stdin
- suggest-compact.test.js: 13 new tests covering counter file creation/increment, threshold suggestion, interval suggestion, env var handling, corrupted/empty counter files, and session isolation
2026-02-13 03:11:51 -08:00
Affaan Mustafa
b3db83d018 test: add 22 tests for validators, skill-create-output, and package-manager edge cases 2026-02-13 03:02:28 -08:00
Affaan Mustafa
d903053830 test: add 15 tests for session-manager and session-aliases edge cases
Cover 30-day month validation (Sep/Nov 31 rejection), getSessionStats
path heuristic with multiline content, combined date+search+pagination
in getAllSessions, ambiguous prefix matching in getSessionById, unclosed
code fence in parseSessionMetadata, empty checklist item behavior,
reserved name case sensitivity (LIST/Help/Set), negative limit in
listAliases, and undefined title in setAlias.
2026-02-13 02:54:23 -08:00
Affaan Mustafa
a62a3a2416 fix: sanitize getExecCommand args, escape regex in getCommandPattern, clean up readStdinJson timeout, add 10 tests
Validate args parameter in getExecCommand() against SAFE_ARGS_REGEX to
prevent command injection when returned string is passed to a shell.
Escape regex metacharacters in getCommandPattern() generic action branch
to prevent malformed patterns and unintended matching. Clean up stdin
listeners in readStdinJson() timeout path to prevent process hanging.
2026-02-13 02:27:04 -08:00
Affaan Mustafa
f33ed4c49e fix: clamp getAllSessions pagination params, add cleanupAliases success field, add 10 tests
- session-manager: clamp offset/limit to safe non-negative integers to
  prevent negative offset counting from end and NaN returning empty results
- session-aliases: add success field to cleanupAliases return value for
  API contract consistency with setAlias/deleteAlias/renameAlias
2026-02-13 02:16:22 -08:00
Affaan Mustafa
c1919bb879 fix: greedy regex in validate-commands captures all refs per line, add 18 tests
The command cross-reference regex /^.*`\/(...)`.*$/gm only captured the
LAST command ref per line due to greedy .* consuming earlier refs.
Replaced with line-by-line processing using non-anchored regex to
capture ALL command references.

New tests:
- 4 validate-commands multi-ref-per-line tests (regression)
- 8 evaluate-session threshold boundary tests (new file)
- 6 session-aliases edge case tests (cleanup, rename, path matching)
2026-02-13 01:52:30 -08:00
Affaan Mustafa
e96b522af0 fix: calendar-accurate date validation in parseSessionFilename, add 22 tests
- Fix parseSessionFilename to reject impossible dates (Feb 31, Apr 31,
  Feb 29 non-leap) using Date constructor month/day roundtrip check
- Add 6 session-manager tests for calendar date validation edge cases
- Add 3 session-manager tests for code blocks/special chars in getSessionStats
- Add 10 package-manager tests for PM-specific command formats (getRunCommand
  and getExecCommand for pnpm, yarn, bun, npm)
- Add 3 integration tests for session-end transcript parsing (mixed JSONL
  formats, malformed lines, nested user messages)
2026-02-13 01:42:56 -08:00
Affaan Mustafa
34edb59e19 test: add 7 package-manager priority and source detection tests
- Test valid project-config detection (.claude/package-manager.json)
- Test priority order: project-config > package.json > lock-file
- Test package.json > lock-file priority
- Test default fallback to npm
- Test setPreferredPackageManager success case
- Test getCommandPattern for test and build actions
2026-02-13 01:38:29 -08:00
Affaan Mustafa
37309d47b7 fix: box alignment in test runner, update metadata counts, add 18 tests
- Fix run-all.js box alignment (hardcoded spaces 1 char short, now using dynamic padEnd)
- Update .opencode/index.ts metadata (12→13 agents, 24→31 commands, 16→37 skills)
- Add commandExists edge case tests (empty, spaces, path separators, metacharacters)
- Add findFiles edge case tests (? wildcard, mtime sorting, maxAge filtering)
- Add ensureDir race condition and return value tests
- Add runCommand output trimming and failure tests
- Add pre-compact session annotation and compaction log timestamp tests
- Add check-console-log invalid JSON handling test
- Add replaceInFile capture group test
- Add readStdinJson Promise type check
2026-02-13 01:36:42 -08:00
Affaan Mustafa
3f651b7c3c fix: typecheck hook false positives, add 11 session-manager tests
- Fix post-edit-typecheck.js error filtering: use relative/absolute path
  matching instead of basename, preventing false positives when multiple
  files share the same name (e.g., src/utils.ts vs tests/utils.ts)
- Add writeSessionContent tests (create, overwrite, invalid path)
- Add appendSessionContent test (append to existing file)
- Add deleteSession tests (delete existing, non-existent)
- Add sessionExists tests (file, non-existent, directory)
- Add getSessionStats empty content edge case
- Add post-edit-typecheck stdout passthrough test
- Total: 391 → 402 tests, all passing
2026-02-13 01:28:59 -08:00
Affaan Mustafa
6f95dbe7ba fix: grepFile global regex lastIndex bug, add 12 tests
Fix grepFile() silently skipping matches when called with /g flag regex.
The global flag makes .test() stateful, causing alternating match/miss
on consecutive matching lines. Strip g flag since per-line testing
doesn't need global state.

Add first-ever tests for evaluate-session.js (5 tests: short session,
long session, missing transcript, malformed stdin, env var fallback)
and suggest-compact.js (5 tests: counter increment, threshold trigger,
periodic suggestions, below-threshold silence, invalid threshold).
2026-02-13 01:18:07 -08:00
Affaan Mustafa
a4848da38b test: add tsconfig depth limit and cleanupAliases exception tests
- post-edit-typecheck: verify 25-level-deep directory completes without
  hanging (tests the max depth=20 walk-up guard)
- cleanupAliases: document behavior when sessionExists callback throws
  (propagates to caller, which is acceptable)
2026-02-13 01:10:30 -08:00
Affaan Mustafa
654731f232 fix: add missing validation in renameAlias, add 6 tests
renameAlias was missing length (>128), reserved name, and empty string
validation that setAlias enforced. This inconsistency allowed renaming
aliases to reserved names like 'list' or 'delete'.

Also adds tests for:
- renameAlias empty string, reserved name, and length limit
- validate-skills whitespace-only SKILL.md rejection
- validate-rules whitespace-only file and recursive subdirectory scan
2026-02-13 01:05:59 -08:00
Affaan Mustafa
926eba97c5 fix: add input validation, date range checks, and security hardening
- validate-agents.js: reject invalid model names in agent frontmatter
- package-manager.js: validate script/binary names against shell injection
- session-manager.js: reject impossible month/day values in filenames
- utils.js: support options.all for replaceInFile string patterns
- strategic-compact/SKILL.md: fix hook matcher syntax and script reference
- install.sh: warn when overwriting existing rule customizations
- Add 24 new tests covering all validation and edge cases
2026-02-12 17:32:04 -08:00
Affaan Mustafa
c0c54d0dae fix: use execFileSync with input option for Windows-compatible stdin tests
Windows cmd.exe treats single quotes literally, so `echo '...' | node -e '...'`
fails. Switched to execFileSync with the `input` option to pipe stdin data
directly without shell quoting issues.
2026-02-12 17:14:03 -08:00
Affaan Mustafa
5107b3669f fix: box() off-by-one alignment, add 5 tests for readStdinJson and box alignment
- skill-create-output.js: fix top border being 1 char narrower than
  middle/bottom lines (width - title - 5 → width - title - 4)
- Add box alignment regression test verifying all lines have equal width
- Add 4 readStdinJson tests via subprocess (valid JSON, invalid JSON,
  empty stdin, nested objects) — last untested exported utility function
- All 338 tests passing
2026-02-12 16:53:06 -08:00
Affaan Mustafa
dc9aefbee1 fix: set USERPROFILE in tests for Windows os.homedir() compatibility
On Windows, os.homedir() uses USERPROFILE env var instead of HOME.
Tests that override HOME to a temp dir must also set USERPROFILE for
the session-manager, session-aliases, and session-start hook tests
to find files in the correct directory.
2026-02-12 16:41:58 -08:00
Affaan Mustafa
b1b28f2f92 fix: capture stderr in typecheck hook, add 13 tests for session-end and utils
- post-edit-typecheck.js: capture both stdout and stderr from tsc
- hooks.test.js: 7 extractSessionSummary tests (JSONL parsing, array content,
  malformed lines, empty transcript, long message truncation, env var fallback)
- utils.test.js: 6 tests (replaceInFile g-flag behavior, string replace,
  capture groups, writeFile overwrite, unicode content)

Total test count: 294 → 307
2026-02-12 16:31:07 -08:00
Affaan Mustafa
e9f0f1334f test: add 33 edge case tests for session-manager, session-aliases, and hooks
- session-manager: CRLF handling, empty sections, multi-heading title, context
  extraction, notes/context detection, MB file size, uppercase ID rejection
- session-aliases: missing timestamps sort, title search, createdAt preservation,
  whitespace-only path rejection, empty string title behavior
- hooks: session-start isolated HOME, template vs real session injection,
  learned skills count, check-console-log passthrough

Total test count: 261 → 294
2026-02-12 16:26:57 -08:00
Affaan Mustafa
bc0520c6c1 fix: broken cross-references, version sync, and enhanced command validator
- Fix /build-and-fix → /build-fix in tdd.md, plan.md (+ cursor, zh-CN)
- Fix non-existent explorer agent → planner in orchestrate.md (+ cursor, zh-CN, zh-TW)
- Fix /python-test → /tdd in python-review.md (+ cursor, zh-CN)
- Sync package.json version from 1.0.0 to 1.4.1 to match plugin.json
- Enhance validate-commands.js with cross-reference checking:
  command refs, agent path refs, skill dir refs, workflow diagrams
- Strip fenced code blocks before scanning to avoid false positives
- Skip hypothetical "Creates:" lines in evolve.md examples
- Add 46 new tests (suggest-compact, session-manager, utils, hooks)
2026-02-12 16:19:04 -08:00
Affaan Mustafa
7d57de1299 test: add 13 tests for package-manager.js untested functions
- setProjectPackageManager: creates config, rejects unknown PM
- setPreferredPackageManager: rejects unknown PM
- detectFromPackageJson: invalid JSON, unknown PM name
- getExecCommand: without args
- getRunCommand: build, dev, and custom scripts
- DETECTION_PRIORITY: order verification
- getCommandPattern: install and custom action patterns

Total tests: 164 → 177
2026-02-12 15:59:56 -08:00
Affaan Mustafa
76b271ab6b fix: 6 bugs fixed, 67 tests added for session-manager and session-aliases
Bug fixes:
- utils.js: prevent duplicate 'g' flag in countInFile regex construction
- validate-agents.js: handle CRLF line endings in frontmatter parsing
- validate-hooks.js: handle \t and \\ escape sequences in inline JS validation
- session-aliases.js: prevent NaN in date sort when timestamps are missing
- session-aliases.js: persist rollback on rename failure instead of silent loss
- session-manager.js: require absolute paths in getSessionStats to prevent
  content strings ending with .tmp from being treated as file paths

New tests (164 total, up from 97):
- session-manager.test.js: 27 tests covering parseSessionFilename,
  parseSessionMetadata, getSessionStats, CRUD operations, getSessionSize,
  getSessionTitle, edge cases (null input, non-existent files, directories)
- session-aliases.test.js: 40 tests covering loadAliases (corrupted JSON,
  invalid structure), setAlias (validation, reserved names), resolveAlias,
  listAliases (sort, search, limit), deleteAlias, renameAlias, updateAliasTitle,
  resolveSessionAlias, getAliasesForSession, cleanupAliases, atomic write

Also includes hook-generated improvements:
- utils.d.ts: document that readStdinJson never rejects
- session-aliases.d.ts: fix updateAliasTitle type to accept null
- package-manager.js: add try-catch to setProjectPackageManager writeFile
2026-02-12 15:50:04 -08:00
Affaan Mustafa
911d38f686 feat: add 3 new skills, JS syntax validation in hooks CI, and edge case tests
- New skills: api-design, database-migrations, deployment-patterns
- validate-hooks.js: validate inline JS syntax in node -e hook commands
- utils.test.js: edge case tests for findFiles with null/undefined inputs
- README: update skill count to 35, add new skills to directory tree
2026-02-12 15:24:28 -08:00
Affaan Mustafa
501bf23ca0 test: update getSelectionPrompt test for new no-spawn behavior
The prompt no longer lists "Available package managers" (which required
spawning processes) — it now shows "Supported package managers" and
mentions lock file detection as a configuration option.

All 69 tests pass.
2026-02-12 12:20:27 -08:00
Affaan Mustafa
a44a0553bb fix: resolve ESLint errors and update tests for project-name fallback
- Fix 16 ESLint no-unused-vars errors across hook scripts and tests
- Add eslint-disable comment for intentional control-regex in ANSI stripper
- Update session file test to use getSessionIdShort() instead of hardcoded 'default'
  (reflects PR #110's project-name fallback behavior)
- Add marketing/ to .gitignore (local drafts)
- Add skill-create-output.js (terminal output formatter)

All 69 tests now pass. CI should be green.
2026-01-29 02:58:51 -08:00
tchoudhary74
81003b1ca6 feat: use project name as session filename fallback
Fixes #99. Falls back to git repo name or directory name when CLAUDE_SESSION_ID is unavailable.
2026-01-28 23:01:19 -08:00
Affaan Mustafa
5c63fa9006 feat: v1.1.0 release - session ID tracking, async hooks, new skills
- Add session ID to session filenames (Issue #62)
- Add getSessionIdShort() helper for unique per-session tracking
- Add async hooks documentation with example
- Create iterative-retrieval skill for progressive context refinement
- Add continuous-learning-v2 skill with instinct-based learning
- Add ecc.tools ecosystem section to README
- Update skills list in README

All 67 tests passing.
2026-01-25 18:21:27 -08:00
zerx-lab
970f8bf884 feat: cross-platform support with Node.js scripts
- Rewrite all bash hooks to Node.js for Windows/macOS/Linux compatibility
- Add package manager auto-detection (npm, pnpm, yarn, bun)
- Add scripts/lib/ with cross-platform utilities
- Add /setup-pm command for package manager configuration
- Add comprehensive test suite (62 tests)

Co-authored-by: zerx-lab
2026-01-22 23:08:07 -08:00