Commit Graph

309 Commits

Author SHA1 Message Date
Affaan Mustafa
e50b05384a test: add Round 121 tests for findFiles ? glob, setAlias path validation, and time metadata extraction
- findFiles: ? glob pattern matches single character only (converted to . regex)
- setAlias: rejects null, empty, whitespace-only, and non-string sessionPath values
- parseSessionMetadata: Started/Last Updated time extraction — present, missing, loose regex

Total tests: 923
2026-02-13 18:25:56 -08:00
Affaan Mustafa
26f3c88902 test: add Round 120 tests for replaceInFile empty search, setAlias length boundary, and notes extraction
- replaceInFile: empty string search — replace prepends at pos 0, replaceAll inserts between every char
- setAlias: 128-char alias accepted (boundary), 129-char rejected (> 128 check)
- parseSessionMetadata: "Notes for Next Session" extraction — last section, empty, ### boundary, markdown

Total tests: 920
2026-02-13 18:23:55 -08:00
Affaan Mustafa
df2d3a6d54 test: add Round 119 tests for appendFile type safety, renameAlias reserved names, and context extraction
- appendFile: null/undefined/number content throws TypeError (no try/catch like writeFile)
- renameAlias: reserved names rejected for newAlias (parallel check to setAlias, case-insensitive)
- parseSessionMetadata: "Context to Load" code block extraction — missing close, nested blocks, empty

Total tests: 917
2026-02-13 18:21:39 -08:00
Affaan Mustafa
25c5d58c44 test: add Round 118 edge-case tests for writeFile type safety, renameAlias self, and reserved alias names
- writeFile: null/undefined/number content throws TypeError (no try/catch unlike replaceInFile)
- renameAlias: same-name rename returns "already exists" (no self-rename short-circuit)
- setAlias: reserved names (list, help, remove, delete, create, set) rejected case-insensitively

Total tests: 914
2026-02-13 18:19:21 -08:00
Affaan Mustafa
06af1acb8d test: add Round 117 edge-case tests for grepFile CRLF, getSessionSize boundaries, and parseSessionFilename case
- grepFile: CRLF content leaves trailing \r on lines, breaking anchored $ patterns
- getSessionSize: boundary formatting at 0B, 1023B→"1023 B", 1024B→"1.0 KB", non-existent→"0 B"
- parseSessionFilename: [a-z0-9] regex rejects uppercase short IDs (case-sensitive design)

Total tests: 911
2026-02-13 18:16:10 -08:00
Affaan Mustafa
6a0b231d34 test: add Round 116 edge-case tests for replaceInFile null coercion, loadAliases extra fields, and ensureDir null path
- replaceInFile: null/undefined replacement coerced to string "null"/"undefined" by JS String.replace ToString
- loadAliases: extra unknown JSON fields silently preserved through load/save round-trip (loose validation)
- ensureDir: null/undefined path throws wrapped Error (ERR_INVALID_ARG_TYPE → re-thrown)

Total tests: 908
2026-02-13 18:11:58 -08:00
Affaan Mustafa
a563df2a52 test: add edge-case tests for countInFile empty pattern, parseSessionMetadata CRLF, and updateAliasTitle empty string coercion (round 115) 2026-02-13 18:05:28 -08:00
Affaan Mustafa
53e06a8850 test: add edge-case tests for listAliases type coercion, replaceInFile options.all with RegExp, and output BigInt serialization (round 114) 2026-02-13 18:01:25 -08:00
Affaan Mustafa
93633e44f2 test: add 3 tests for century leap years, zero-width regex, and markdown titles (Round 113)
- parseSessionFilename rejects Feb 29 in century non-leap years (1900, 2100) but accepts 2000/2400
- replaceInFile with /(?:)/g zero-width regex inserts at every position boundary
- parseSessionMetadata preserves raw markdown formatting (**bold**, `code`, _italic_) in titles

Total: 899 tests
2026-02-13 17:54:48 -08:00
Affaan Mustafa
791da32c6b test: add 3 tests for Unicode alias rejection, newline-in-path heuristic, and read-only append (Round 112)
- resolveAlias rejects Unicode characters (accented, CJK, emoji, Cyrillic homoglyphs)
- getSessionStats treats absolute .tmp paths with embedded newlines as content, not file paths
- appendSessionContent returns false on EACCES for read-only files

Total: 896 tests
2026-02-13 17:47:50 -08:00
Affaan Mustafa
635eb108ab test: add 3 tests for nested backtick context truncation, newline args injection, alias 128-char boundary
Round 111: Tests for parseSessionMetadata context regex truncation at
nested triple backticks (lazy [\s\S]*? stops early), getExecCommand
accepting newline/tab/CR in args via \s in SAFE_ARGS_REGEX, and setAlias
accepting exactly 128-character alias (off-by-one boundary). 893 tests total.
2026-02-13 17:41:58 -08:00
Affaan Mustafa
1e740724ca test: add 3 tests for findFiles root-unreadable, parseSessionFilename year 0000, uppercase ID rejection
Round 110: Tests for findFiles with unreadable root directory returning
empty array (vs Round 71 which tested subdirectory), parseSessionFilename
year 0000 exposing JS Date 0-99→1900-1999 mapping quirk, and uppercase
session ID rejection by [a-z0-9]{8,} regex. 890 tests total.
2026-02-13 17:30:38 -08:00
Affaan Mustafa
6737f3245b test: add 3 tests for appendFile new-file creation, getExecCommand traversal, getAllSessions non-session skip
Round 109:
- appendFile creating new file in non-existent directory (ensureDir + appendFileSync)
- getExecCommand with ../ path traversal in binary (SAFE_NAME_REGEX allows ../)
- getAllSessions skips .tmp files that don't match session filename format
2026-02-13 17:24:36 -08:00
Affaan Mustafa
1b273de13f test: add 3 tests for grepFile Unicode, SAFE_NAME_REGEX traversal, getSessionSize boundary
Round 108:
- grepFile with Unicode/emoji content (UTF-16 string matching on split lines)
- getRunCommand accepts ../ path traversal via SAFE_NAME_REGEX (allows / and . individually)
- getSessionSize exact 1024-byte B→KB boundary and 1MB KB→MB boundary
2026-02-13 17:18:06 -08:00
Affaan Mustafa
882157ac09 test: add 3 tests for Round 107 (881 total)
- grepFile with ^$ pattern verifies empty line matching including trailing newline phantom
- replaceInFile with self-reintroducing replacement confirms single-pass behavior
- setAlias with whitespace-only title exposes missing trim validation vs sessionPath
2026-02-13 17:11:32 -08:00
Affaan Mustafa
69799f2f80 test: add 3 tests for Round 106 (878 total)
- countInFile with named capture groups verifies match(g) ignores group details
- grepFile with multiline (m) flag confirms flag is preserved unlike stripped g
- getAllSessions with array/object limit tests Number() coercion edge cases
2026-02-13 17:07:13 -08:00
Affaan Mustafa
b27c21732f test: add 3 edge-case tests for regex boundary, sticky flag, and type bypass (Round 105)
- parseSessionMetadata: blank line within Completed section truncates items
  due to regex lookahead (?=###|\n\n|$) stopping at \n\n boundary
- grepFile: sticky (y) flag not stripped like g flag, causing stateful
  .test() behavior that misses matching lines
- getExecCommand: object args bypass SAFE_ARGS_REGEX (typeof !== 'string')
  but coerce to "[object Object]" in command string
2026-02-13 16:59:56 -08:00
Affaan Mustafa
332d0f444b test: add Round 104 edge-case tests (detectFromLockFile null, resolveSessionAlias traversal, whitespace notes)
- detectFromLockFile(null): throws TypeError — no input validation before
  path.join (package-manager.js:95)
- resolveSessionAlias('../etc/passwd'): returns path-traversal input unchanged
  when alias lookup fails, documenting the passthrough behavior
- parseSessionMetadata with whitespace-only notes: trim() → "" → hasNotes=false,
  whitespace-only notes treated as absent

Total tests: 872 (all passing)
2026-02-13 16:45:47 -08:00
Affaan Mustafa
45a0b62fcb test: add Round 103 edge-case tests (countInFile bool, grepFile numeric, loadAliases array)
- countInFile(file, false): boolean falls to else-return-0 type guard (utils.js:443)
- grepFile(file, 0): numeric pattern implicitly coerced via RegExp constructor,
  contrasting with countInFile which explicitly rejects non-string non-RegExp
- loadAliases with array aliases: typeof [] === 'object' bypasses validation
  at session-aliases.js:58, returning array instead of plain object

Total tests: 869 (all passing)
2026-02-13 16:08:47 -08:00
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