Optimize the skill + extract resolve-session to CLI#5
Merged
Conversation
Adds `askdiff resolve-session` (typed options, JSON output, fixture
tests) and replaces the inline find/grep bash that motivated the
"Do not simplify" footgun list.
Also fixes two pre-existing bugs found during testing:
- Commander v14 routes `--cwd` to the parent program when both parent
and subcommand declare it, so the resolve-session subcommand always
saw the default. Read cwd from `program.opts()` instead.
- Step 4b prefix-glob used `shopt -s nullglob` (bash-only, silently
fails in zsh) and `${matches[0]}` (zsh arrays are 1-indexed). Use
`find` + `while read` + iteration via `"${matches[@]}"`.
Lazy-loads `@askdiff/protocol`/`@askdiff/server` inside `runServer` so
`tsx src/index.ts resolve-session …` works in dev (the protocol
package is CJS and ESM-static-importing it failed under tsx).
Tests: 89 → 111 (+17 unit, +5 CLI integration including a tsx-path
regression guard). Lint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two phases of work, two commits:
Phase 1 —
07b78a4 Simplify the skill: ~30% prose reduction on bothaskdiff/SKILL.mdandaskdiff-dev/SKILL.md(Steps 1–4 kept in sync). No behavior change. Drops dead branches (e.g. the(none …)troubleshooting paragraph for a code path that now throws), collapses 13-line footgun blocks into 3-line inline notes, removes "tell the user" enumerations that just restate what's already in the bash output.Phase 2 —
f18342c Extract keyword session search to resolve-session CLI subcommand: moves Step 4c's inlinemktemp/find/grep -cFfbash into a typed CLI subcommand (packages/cli/src/resolve-session.ts), keeping the public-facing skill behavior identical but making the search testable and shell-safe.Bugs found and fixed during testing
--cwdoverlap: parent and subcommand both declared-c, --cwd, so commander silently routed the flag to the parent — the subcommand always sawprocess.cwd(). Read fromprogram.opts()instead.shopt -s nullglob(bash-only) and${matches[0]}(zsh is 1-indexed, so empty). Replaced withfind+while read+for "${matches[@]}"— works in both shells.tsxinvocation: the CLI's staticimport { PROTOCOL_VERSION } from "@askdiff/protocol"failed under ESM because the protocol package is CJS. Lazy-loaded insiderunServerso resolve-session never triggers protocol load.--diff-fileonly for description-based diffs" — original bash always extracted paths. Reverted to "always pass; omit--sha/--branchfor working-tree."Test plan
pnpm lintcleanpnpm test111 passing (was 89; +17 unit, +5 integration including a tsx-path regression guard)pnpm run buildclean (CLI bundle 32K, skill.md with bothASKDIFF_VERSIONlines pinned)~/.claude-personal/projects/<this>/*.jsonlfor 9 flag combinationsnode packages/cli/dist/index.js resolve-session …workspnpm --filter askdiff exec tsx src/index.ts resolve-session …workslast commit, branch comparison, vague description w/ commit-ladder, explicit prefix in zsh after fix, full UUID, keyword + working-tree, etc.)/askdiffand/askdiff-devafter merge.Stats
askdiff/SKILL.mdaskdiff-dev/SKILL.mdmktemp/find/grepbashresolve-session.tsSuggested release
v0.4.0(minor) — adds public CLI subcommandresolve-session, includes two user-facing bug fixes for the/askdiff session <prefix>and/askdiff-devkeyword-search paths.🤖 Generated with Claude Code