Skip to content

fix: rewrite glob expansion (component-split, char-walk matcher, backslash-tolerant) + v1.0.3 - #11

Merged
JordanNewell merged 2 commits into
mainfrom
fix/glob-expansion
Nov 23, 2026
Merged

JordanNewell merged 2 commits into
mainfrom
fix/glob-expansion

Conversation

@JordanNewell

Copy link
Copy Markdown
Collaborator

The bug

Glob input expansion in src/cli.ts (expandInputs + simpleGlobMatch) failed silently — zero matches, No .jsonl files matched. — for several common invocations:

  • '<dir>/**/*.jsonl': the root computation (base.slice(0, base.lastIndexOf("/") + 1)) swallows the ** component, and join() normalizes away the prefix that p.slice(root.length) expects to strip, so no file path ever matches the suffix.
  • '*.jsonl' (prefix-less): root resolves to "." but the suffix/slice math still misaligns.
  • Backslash globs (<dir>\**\*.jsonl) on Windows: lastIndexOf("/") finds nothing, root degenerates.
  • ** on nested trees matched files exactly one level deep only: simpleGlobMatch's replace-chain turned ** into a wildcard but left the literal / of **/ required, so **/ could never match zero directories.
  • ? was never escaped and acted as a bare regex quantifier.
  • isAbsolute appeared only in a no-op ternary (lastIndexOf(isAbsolute(input) ? "/" : "/")) — vestigial.

Bug proven by curt-claudeai's Task 6 quality review (same code inherited there); this repo ships the same defect.

The fix

Mirrored exactly from curt-claudeai commit de8f516 ("fix: rewrite glob expansion (component-split, backslash-tolerant) + JSONL hint, drop unused import"), which went through that repo's review cycles. Two adaptations only:

  • Glob branch: kept curt-convert's directory-walk/directory-form on .jsonl (curt-claudeai's parse-error JSONL hint block and its .json-oriented handling were NOT carried over — everything here is JSONL).
  • Removed the now-unused isAbsolute import.
  • No other changes: curt-convert's own --stdout behavior untouched. Version bump only, 1.0.2 → 1.0.3.

Verification matrix (real files: C:/tmp/globfix-scratch/parent.jsonl + C:/tmp/globfix-scratch/a/b/child.jsonl)

=== 1. C:/tmp/globfix-scratch/**/*.jsonl -o out ===
hello-child child.curt  <-  C:\tmp\globfix-scratch\a\b\child.jsonl  (1 msgs, 0 tool calls, ...)
hello-parent parent.curt  <-  C:\tmp\globfix-scratch\parent.jsonl  (1 msgs, 0 tool calls, ...)
exit=0  → BOTH files converted (parent proves ** matches zero dirs)

=== 2. '*.jsonl' from inside scratch root ===
hello-parent parent.curt  <-  C:\tmp\globfix-scratch\parent.jsonl  (1 msgs, 0 tool calls, ...)
exit=0  → prefix-less glob now finds root-level file (child correctly excluded)

=== 3. 'C:\tmp\globfix-scratch\**\*.jsonl' (backslash form) ===
hello-child child.curt  <-  C:\tmp\globfix-scratch\a\b\child.jsonl  (1 msgs, 0 tool calls, ...)
hello-parent parent.curt  <-  C:\tmp\globfix-scratch\parent.jsonl  (1 msgs, 0 tool calls, ...)
exit=0  → both files

=== 4. directory form 'C:/tmp/globfix-scratch' ===
both files converted, exit=0  → unchanged behavior

=== 5. single-file form 'C:/tmp/globfix-scratch/a/b/child.jsonl' ===
child converted, exit=0  → unchanged behavior

Suite: npx vitest run → 30 passed (30), green. npm run build clean.

Merge-order note

PR #10 (docs: npm repo.url note) is still OPEN. This branch is cut from main at 123129b (before #10). Both PRs add lines under the same ## [Unreleased] CHANGELOG heading, so whichever merges second will need a trivial CHANGELOG conflict resolution (keep both lines). No other overlapping files.

After merge

Publish after merge: npm publish (Jordan OTP — 2FA required on npm).

@JordanNewell
JordanNewell merged commit d3d2408 into main Nov 23, 2026
8 checks passed
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