Skip to content

refactor(#1473): one definition each for ensureDir, escapeRegex, formatTimestamp, truncateToWidth, parseIssueNumber - #1558

Merged
admarble merged 7 commits into
mainfrom
feature/1473-refactor-lib-one-definition-each-for-ensuredir-esc
Oct 19, 2026
Merged

admarble merged 7 commits into
mainfrom
feature/1473-refactor-lib-one-definition-each-for-ensuredir-esc

Conversation

@admarble

@admarble admarble commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Branch feature/1473-refactor-lib-one-definition-each-for-ensuredir-esc is pushed with two commits. I opened no PR, because the orchestrator opens it (#1247).

Fixed this session: the first commit missed part of AC-4. src/lib/cli-ui/truncate.ts had no truncateAtWord, and the assess renderer had been switched to the TUI's hard-cut truncateToWidth, which would have changed its output. I moved the renderer's word-boundary function there unchanged as truncateAtWord, pointed the renderer at it, and added two tests. This is commit 258bfce63.

AC verification

AC Status Evidence
AC-1 ✅ the five helpers each show 1 definition and parseIssue shows 0
AC-2 ✅ ensureDir tests in assessment.test.ts and writer.test.ts pass
AC-3 ✅ format.test.ts passes
AC-4 ✅ both truncate.js importers found (2), truncateAtWord exported (1 in truncate.ts), no SKILL.md or snapshot files in the diff, renderer and skill-example tests pass
AC-5 ✅ cli-flags.test.ts passes; locks still sets exit 1 and worktree exit 2
AC-6 ✅ the accretion detector prints none

AC-4's evidence command names src/ui/tui/truncate.test.ts, but the first commit moved that file to src/lib/cli-ui/truncate.test.ts. I ran the moved file instead.

Checks

Mutation-verified: AC-2 — wrapped both ensureDir calls in assessment.ts in a swallowing try { … } catch {} (the pre-#1473 behaviour); src/lib/upstream/tests/assessment.test.ts > ensureDir > a write error rejects with the mkdir diagnostic failed; restored.
Mutation-verified: AC-5 — deleted the null branch of parseIssueNumber; src/lib/cli-flags.test.ts > parseIssueNumber > non-numeric input returns null failed (and zero returns null); restored.

Pre-PR Confidence Check

  • Weakest part: truncateAtWord is also covered only by two new tests plus the existing renderer and skill-example tests.
  • Coverage gaps: none for the changed files; each has a test file.

CHANGELOG: N/A (internal refactor). PR status: left to the orchestrator.

Next: open the PR and run the QA phase.

Fixes #1473

QA verdict: AC_MET_BUT_NOT_A_PLUS — acceptance criteria met, but not A+. The run broke to this PR for review rather than entering the quality loop; see the QA review comment for improvement notes.

Runner verification (2026-10-19)

After a final merge of main (23a60b3), the runner re-ran every AC at 56bacd2:

  • AC-1: 1 1 1 1 1 / 0
  • The 8 AC test files: 338 passed
  • AC-4: 2 1 0
  • AC-5: kept
  • AC-6: none
  • Lint green; build exit 0.

The baseline now records emptyCatch.total 117 and unusedExports 341. CI test passed.

First pass:

The runner re-ran AC-1..AC-6 verbatim in the worktree after merging main (with #1503's stricter lint):

  • AC-1: 1 1 1 1 1 / 0
  • AC-2: 3 passed
  • AC-3: 3 passed
  • AC-4: 2 and 1; the renderer, skill-examples and TUI truncate tests: 51 passed; snapshot/SKILL.md diff 0
  • AC-5: 3 passed, kept
  • AC-6: none
  • npm run lint green; build exit 0.

The runner also ran both mutations above.

Added by the runner, from QA's findings:

  • locks check-batch used a third inline copy of the issue-number parse; it now calls parseIssueNumber. Smoke test through the built CLI: abc and 0 exit 2 with "Invalid issue number", and 1471 --json exits 0.
  • The missing [Unreleased] CHANGELOG entry.
  • The baseline now records emptyCatch.total 118 (down from 119) and unusedExports 341 (down from 342). lint:health reported no rise first.

Settled against base: driver-conformance.test.ts > commit: git add and git commit succeed inside the driver's default sandbox also fails on main at ace33fc in this checkout (1 failed, 33 passed; macOS only). That failure is #1480, and CI on Linux passes it.

D-3 amended by the owner (2026-10-19): two exports, truncateToWidth (hard cut) and truncateAtWord (the renderer's rule, unchanged), so the output pinned by frozen SKILL.md does not move.


🤖 Generated with Claude Code

…atTimestamp, truncateToWidth, parseIssueNumber

Entire-Checkpoint: 2d6e7bb8ee2e
…nline copy QA found)

Entire-Checkpoint: d8c7c1593365
…usedExports 341

Entire-Checkpoint: c9c2e1a2383e
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.

refactor(lib): one definition each for ensureDir, escapeRegex, formatTimestamp, truncateToWidth, parseIssueNumber

1 participant