273 Commits

Author SHA1 Message Date
Affaan Mustafa
a64a294b29 test: add 3 edge-case tests for looksLikePath heuristic, falsy title coercion, and checkbox regex (Round 102)
- getSessionStats with Unix nonexistent .tmp path triggers looksLikePath
  heuristic → readFile returns null → zeroed stats via null content path
- setAlias with title=0 silently converts to null (0 || null === null)
- parseSessionMetadata skips [x] checked items in In Progress section
  (regex only matches unchecked [ ] checkboxes)

Total tests: 866
2026-02-13 16:02:18 -08:00
Affaan Mustafa
4d016babbb test: round 101 — output() circular crash, getSessionStats type confusion, appendSessionContent null
- output() throws TypeError on circular reference object (JSON.stringify has no try/catch)
- getSessionStats(123) throws TypeError (number reaches parseSessionMetadata, .match() fails)
- appendSessionContent(null) returns false (TypeError caught by try/catch)

Total tests: 863
2026-02-13 15:54:02 -08:00
Affaan Mustafa
d2c1281e97 test: round 100 — findFiles maxAge+recursive interaction, parseSessionMetadata ### truncation, cleanupAliases falsy coercion
- findFiles with both maxAge AND recursive combined (option interaction test)
- parseSessionMetadata truncates item text at embedded ### due to lazy regex
- cleanupAliases callback returning 0 (falsy non-boolean) removes alias via !0 coercion

Total tests: 860
2026-02-13 15:49:06 -08:00
Affaan Mustafa
78ad952433 test: add 3 tests for no-match rewrite, CR-only grepFile, and null write (R99)
- replaceInFile returns true even when pattern doesn't match (silent rewrite)
- grepFile treats CR-only (\r) file as single line (splits on \n only)
- writeSessionContent(null) returns false (TypeError caught by try/catch)
2026-02-13 15:41:15 -08:00
Affaan Mustafa
274cca025e test: add 3 tests for null-input crashes and negative maxAge boundary (R98)
- getSessionById(null) throws TypeError at line 297 (null.length)
- parseSessionFilename(null) throws TypeError at line 30 (null.match())
- findFiles with maxAge: -1 deterministically excludes all files
2026-02-13 15:35:18 -08:00
Affaan Mustafa
18fcb88168 test: add 3 tests for whitespace ID, lastIndex reuse, and whitespace search (Round 97) 2026-02-13 15:28:06 -08:00
Affaan Mustafa
8604583d16 test: add 3 tests for session-manager edge cases (Round 96)
- parseSessionFilename rejects Feb 30 (Date rollover check)
- getAllSessions with limit: Infinity bypasses pagination
- getAllSessions with limit: null demonstrates destructuring default bypass (null !== undefined)

Total: 848 tests, all passing
2026-02-13 15:13:55 -08:00
Affaan Mustafa
233b341557 test: add 3 tests for alternation regex, double-negative clamping, and self-rename (Round 95) 2026-02-13 14:50:49 -08:00
Affaan Mustafa
a95fb54ee4 test: add 3 tests for scoped pkg detection, empty env var, and tools-without-files (Round 94)
- detectFromPackageJson with scoped package name (@scope/pkg@version)
  returns null because split('@')[0] yields empty string
- getPackageManager skips empty string CLAUDE_PACKAGE_MANAGER via
  falsy short-circuit (distinct from unknown PM name test)
- session-end buildSummarySection includes Tools Used but omits
  Files Modified when transcript has only Read/Grep tools

Total tests: 842
2026-02-13 14:44:40 -08:00
Affaan Mustafa
910ffa5530 test: add 3 tests for regex boundary and flag logic gaps (round 93)
- getSessionStats: drive letter without slash (Z:nosession.tmp) treated as content
- countInFile: case-insensitive regex with g flag auto-appended (/foo/i → /foo/ig)
- countInFile: case-insensitive regex with g flag preserved (/foo/gi stays /foo/gi)
2026-02-13 14:21:03 -08:00
Affaan Mustafa
b9a38b2680 test: add Round 92 tests for object pattern, UNC path, and empty packageManager
- Test countInFile returns 0 for object pattern type (non-string non-RegExp)
- Test getSessionStats treats Windows UNC path as content (not file path)
- Test detectFromPackageJson returns null for empty string packageManager field

Total tests: 836
2026-02-13 14:05:24 -08:00
Affaan Mustafa
14dfe4d110 test: add Round 91 tests for empty action pattern, whitespace PM, and mixed separators
- Test getCommandPattern('') produces valid regex for empty action string
- Test detectFromPackageJson returns null for whitespace-only packageManager
- Test getSessionStats treats mixed Windows path separators as file path

Total tests: 833
2026-02-13 14:02:41 -08:00
Affaan Mustafa
3e98be3e39 test: add Round 90 tests for readStdinJson timeout and saveAliases double failure
- Test readStdinJson timeout path when stdin never closes (resolves with {})
- Test readStdinJson timeout path with partial invalid JSON (catch resolves with {})
- Test saveAliases backup restore double failure (inner restoreErr catch at line 135)

Total tests: 830
2026-02-13 13:59:03 -08:00
Affaan Mustafa
3ec59c48bc test: add 3 tests for subdirectory skip, TypeScript error detection, and entry.name fallback (Round 89)
- getAllSessions skips subdirectories in sessions dir (!entry.isFile() branch)
- post-edit-typecheck.js error detection path when tsc reports errors (relevantLines > 0)
- extractSessionSummary extracts tools via entry.name + entry.input fallback format
2026-02-13 13:39:16 -08:00
Affaan Mustafa
e70d4d2237 test: add 3 tests for replaceInFile deletion, parseSessionMetadata null fields, countInFile zero matches (Round 88)
- replaceInFile with empty replacement string verifies text deletion works
- parseSessionMetadata asserts date/started/lastUpdated are null when fields absent
- countInFile with valid file but non-matching pattern returns 0

Total: 824 tests
2026-02-13 12:49:53 -08:00
Affaan Mustafa
9b286ab3f8 test: add 3 tests for stdin 1MB overflow and analyzePhase async method (round 87)
- post-edit-format.js: verify MAX_STDIN truncation at 1MB limit
- post-edit-typecheck.js: verify MAX_STDIN truncation at 1MB limit
- skill-create-output.js: test analyzePhase() returns Promise and writes output
2026-02-13 12:42:20 -08:00
Affaan Mustafa
b3e362105d test: add 3 tests for typeof guard, empty package.json, and learned_skills_path override (round 86)
- loadAliases resets to defaults when aliases field is a truthy non-object (string)
- detectFromPackageJson returns null for empty (0-byte) package.json
- evaluate-session uses learned_skills_path config override with ~ expansion
2026-02-13 12:23:34 -08:00
Affaan Mustafa
8cacf0f6a6 fix: use nullish coalescing for confidence default + add 3 tests (round 85)
Fix confidence=0 showing 80% instead of 0% in patterns() (|| → ??).
Test evaluate-session.js config parse error catch, getSessionIdShort
fallback at root CWD, and precise confidence=0 assertion.
2026-02-13 12:11:26 -08:00
Affaan Mustafa
cedcf9a701 test: add 3 tests for TOCTOU catch paths and NaN date sort fallback (round 84)
- getSessionById returns null for broken symlink (session-manager.js:307-310)
- findFiles skips broken symlinks matching the pattern (utils.js:170-173)
- listAliases sorts entries with invalid/missing dates via getTime() || 0 fallback
2026-02-13 11:35:22 -08:00
Affaan Mustafa
15717d6d04 test: cover whitespace-only frontmatter field, empty SKILL.md, and getAllSessions TOCTOU symlink 2026-02-13 11:20:44 -08:00
Affaan Mustafa
c8b7d41e42 test: cover tool_name OR fallback, Notification/SubagentStop events, and template regex no-match 2026-02-13 11:12:03 -08:00
Affaan Mustafa
9bec3d7625 test: cover suggest-compact upper bound, getSessionStats null input, and non-string content branch 2026-02-13 11:02:46 -08:00
Affaan Mustafa
2573cbb7b0 test: cover session-end message.role path, getExecCommand non-string args, and legacy hooks format
Round 80: Three previously untested conditional branches:
- session-end.js: entry.message?.role === 'user' third OR condition
  (fires when type is not 'user' but message.role is)
- package-manager.js: getExecCommand with truthy non-string args
  (typeof check short-circuits, value still appended via ternary)
- validate-hooks.js: legacy array format parsing path (lines 115-135)
  with 'Hook N' error labels instead of 'EventType[N]'
2026-02-13 10:39:35 -08:00
Affaan Mustafa
9dccdb9068 test: cover countInFile/grepFile string patterns and validate-commands warnings suffix
Round 79 — untested conditional branches in utils.js and validate-commands.js:
- countInFile: exercise typeof pattern === 'string' branch with valid string
- grepFile: exercise string pattern branch (not RegExp)
- validate-commands: verify (N warnings) suffix in output when warnCount > 0
2026-02-13 10:26:58 -08:00
Affaan Mustafa
f000d9b02d test: cover getSessionStats file-path read, hasContent field, and wrapped hooks format
Round 78 — shifted from catch blocks to untested conditional branches:
- getSessionStats: exercise looksLikePath → getSessionContent path (real .tmp file)
- getAllSessions: verify hasContent true/false for non-empty vs empty files
- validate-hooks: test wrapped { hooks: { PreToolUse: [...] } } production format
2026-02-13 10:21:06 -08:00
Affaan Mustafa
27ae5ea299 test: cover evaluate-session/suggest-compact main().catch and validate-hooks JSON parse
- evaluate-session: main().catch when HOME is non-directory (ENOTDIR)
- suggest-compact: main().catch double-failure when TMPDIR is non-directory
- validate-hooks: invalid JSON in hooks.json triggers error exit

Total tests: 831 → 834
2026-02-13 10:03:48 -08:00
Affaan Mustafa
723e69a621 test: cover deleteSession catch, pre-compact and session-end main().catch
- session-manager: deleteSession returns false when dir is read-only (EACCES)
- pre-compact: main().catch handler when HOME is non-directory (ENOTDIR)
- session-end: main().catch handler when HOME is non-directory (ENOTDIR)

Total tests: 828 → 831
2026-02-13 09:59:48 -08:00
Affaan Mustafa
241c35a589 test: cover setGlobal/setProject catch blocks and session-start main().catch
- setup-package-manager: setGlobal catch when HOME is non-directory (ENOTDIR)
- setup-package-manager: setProject catch when CWD is read-only (EACCES)
- session-start: main().catch handler when ensureDir throws (exit 0, don't block)

Total tests: 825 → 828
2026-02-13 09:55:00 -08:00
Affaan Mustafa
0c67e0571e test: cover cleanupAliases save failure, setAlias save failure, and validate-commands statSync catch
Round 73: Add 3 tests for genuine untested code paths:
- session-aliases cleanupAliases returns failure when save blocked after removing aliases
- session-aliases setAlias returns failure when save blocked on new alias creation
- validate-commands silently skips broken symlinks in skill directory scanning
2026-02-13 09:42:25 -08:00
Affaan Mustafa
02d5986049 test: cover setProjectPM save failure, deleteAlias save failure, hooks async/timeout validation
Round 72: Add 4 tests for untested code paths (818 → 822):
- package-manager.js: setProjectPackageManager wraps writeFile errors (lines 275-279)
- session-aliases.js: deleteAlias returns failure when saveAliases fails (line 299)
- validate-hooks.js: rejects non-boolean async field (line 28-31)
- validate-hooks.js: rejects negative timeout value (lines 32-35)
2026-02-13 08:12:27 -08:00
Affaan Mustafa
f623e3b429 test: cover findFiles unreadable subdir, session-start default PM, setPreferredPM save failure
Round 71: Add 3 tests for untested code paths (815 → 818):
- utils.js findFiles: recursive scan silently skips unreadable subdirectories (line 188 catch)
- session-start.js: shows getSelectionPrompt when pm.source is 'default' (lines 69-72)
- package-manager.js: setPreferredPackageManager wraps saveConfig errors (lines 250-254)
2026-02-13 08:01:15 -08:00
Affaan Mustafa
44b5a4f9f0 test: add 3 tests for untested fallback/skip/failure paths (Round 70)
- session-end.js: entry.name/entry.input fallback in direct tool_use entries
- validate-commands.js: "would create:" regex alternation skip line
- session-aliases.js: updateAliasTitle save failure with read-only dir
2026-02-13 07:48:39 -08:00
Affaan Mustafa
567664091d test: add 3 tests for untested code paths (Round 69, 812 total)
- getGitModifiedFiles: all-invalid patterns skip filtering (compiled.length === 0)
- getSessionById: returns null when sessions directory doesn't exist
- getPackageManager: global-config success path returns source 'global-config'
2026-02-13 07:35:20 -08:00
Affaan Mustafa
5031a84d6e test: add 3 tests for setup-pm --project success, demo export, --list marker (Round 68) 2026-02-13 07:23:16 -08:00
Affaan Mustafa
702c3f54b4 test: add 3 tests for session-aliases empty file, null resolve, metadata backfill (Round 67) 2026-02-13 07:18:28 -08:00
Affaan Mustafa
162222a46c test: add 3 tests for session-manager noIdMatch, session-end fallbacks (Round 66)
- session-manager.js: getSessionById with date-only string exercises the
  noIdMatch path for old-format sessions (2026-02-10 → 2026-02-10-session.tmp)
- session-end.js: extract user messages from role-only JSONL format
  ({"role":"user",...} without type field) exercises line 48 fallback
- session-end.js: nonexistent transcript_path triggers "Transcript not found"
  log path (lines 153-155), creates session with blank template

Total: 803 tests, all passing
2026-02-13 07:10:54 -08:00
Affaan Mustafa
485def8582 test: add 3 tests for evaluate-session regex, empty rules/skills dirs (Round 65)
- evaluate-session.js: verify regex whitespace tolerance around colon
  matches "type" : "user" (with spaces), not just compact JSON
- validate-rules.js: empty directory with no .md files yields Validated 0
- validate-skills.js: directory with only files, no subdirectories yields
  Validated 0

Total: 800 tests, all passing
2026-02-13 07:04:55 -08:00
Affaan Mustafa
cba6b44c61 test: add 3 tests for suggest-compact, session-aliases, typecheck (Round 64)
- suggest-compact: 'default' session ID fallback when CLAUDE_SESSION_ID empty
- session-aliases: loadAliases backfills missing version and metadata fields
- post-edit-typecheck: valid JSON without tool_input passes through unchanged

Total: 797 tests, all passing
2026-02-13 06:59:08 -08:00
Affaan Mustafa
1fcdf12b62 test: add 3 CI validator tests for untested code paths (Round 63)
- validate-hooks: object-format matcher missing matcher field (line 97-100)
- validate-commands: readFileSync catch block for unreadable .md files (lines 56-62)
- validate-commands: empty commands directory with no .md files (Validated 0)

Total: 794 tests, all passing
2026-02-13 06:55:30 -08:00
Affaan Mustafa
85a86f6747 test: add --global success, bare PM name, and source label tests (Round 62)
- setup-package-manager.test.js: --global npm writes config and exits 0
- setup-package-manager.test.js: bare PM name sets global preference
- setup-package-manager.test.js: --detect with env var shows source 'environment'

791 tests total, all passing.
2026-02-13 06:49:29 -08:00
Affaan Mustafa
3ec0aa7b50 test: add replaceInFile write failure, empty sessions dir, and corrupted global config tests (Round 61)
- utils.test.js: replaceInFile returns false on read-only file (catch block)
- session-manager.test.js: getAllSessions returns empty when sessions dir missing
- package-manager.test.js: getPackageManager falls through corrupted global config to npm default

788 tests total, all passing.
2026-02-13 06:44:52 -08:00
Affaan Mustafa
9afecedb21 test: add replaceInFile failure, console-warn overflow, and missing tool_input tests (Round 60) 2026-02-13 06:25:35 -08:00
Affaan Mustafa
7db0d316f5 test: add unreadable session file, stdin overflow, and read-only compact tests (Round 59) 2026-02-13 06:19:02 -08:00
Affaan Mustafa
99fc51dda7 test: add unreadable agent file, colonIdx edge case, and command-as-object tests (Round 58) 2026-02-13 06:14:06 -08:00
Affaan Mustafa
2fea46edc7 test: add SKILL.md-as-directory, broken symlink, and adjacent code block tests (Round 57) 2026-02-13 06:02:56 -08:00
Affaan Mustafa
990c08159c test: add tsconfig walk-up, compact fallback, and Windows atomic write tests (Round 56) 2026-02-13 05:59:07 -08:00
Affaan Mustafa
43808ccf78 test: add maxAge boundary, multi-session injection, and stdin overflow tests (Round 55)
- session-start.js excludes sessions older than 7 days (6.9d vs 8d boundary)
- session-start.js injects newest session when multiple recent sessions exist
- session-end.js handles stdin exceeding 1MB MAX_STDIN limit via env var fallback
2026-02-13 05:48:34 -08:00
Affaan Mustafa
3bc0929c6e test: add search scope, path utility, and zero-value analysis tests (Round 54)
- getAllSessions search matches only shortId, not title/content
- getSessionPath returns absolute path with correct directory structure
- analysisResults handles zero values for all data fields without crash
2026-02-13 05:43:29 -08:00
Affaan Mustafa
ad40bf3aad test: add env var fallback, console.log max matches, and format non-existent file tests
Round 53: Adds 3 hook tests — validates evaluate-session.js
falls back to CLAUDE_TRANSCRIPT_PATH env var when stdin JSON
is invalid, post-edit-console-warn.js truncates output to max
5 matches, and post-edit-format.js passes through data when
the target .tsx file doesn't exist.
2026-02-13 05:34:59 -08:00
Affaan Mustafa
f1a693f7cf test: add inline backtick ref, workflow whitespace, and code-only rule tests
Round 52: Adds 3 CI validator tests — validates command refs
inside inline backticks are checked (not stripped like fenced
blocks), workflow arrows with irregular whitespace pass, and
rule files containing only fenced code blocks are accepted.
2026-02-13 05:29:04 -08:00