Skip to content

V0.1.3/m1/claude code refactor#3

Open
Vedansi18 wants to merge 3 commits into
hi0001234d:user-experience-improvements-sub-7from
Vedansi18:v0.1.3/m1/claude-code-refactor
Open

V0.1.3/m1/claude code refactor#3
Vedansi18 wants to merge 3 commits into
hi0001234d:user-experience-improvements-sub-7from
Vedansi18:v0.1.3/m1/claude-code-refactor

Conversation

@Vedansi18
Copy link
Copy Markdown
Collaborator

Refactors Claude Code's install logic into a reusable HookAdapter via a new agent registry. Foundation for adding Cursor/Windsurf/Codex/etc. adapters in later milestones
without touching the existing pipeline (nexpath auto, nexpath stop, classifier, decision-session, store).

What changed

  • Moved 6 Claude Code hook helpers (getClaudeSettingsPath, buildHookCommand, buildStopHookCommand, buildHookEntry, writeHookEntry, removeHookEntry) verbatim
    from src/cli/commands/install.tssrc/agents/adapters/claude-code.ts. Function bodies are byte-identical; install.ts re-exports them for backward compatibility with
    install.test.ts and other importers.
  • Added claudeCodeAdapter: HookAdapter that wraps the moved functions and self-registers via src/agents/index.ts side-effect import.
  • Refactored installAction's Claude Code branch in the for-loop to delegate to getAdapter('claude-code').install(ctx). The other 6 agent branches stay inline (per v1
    scope: only Claude Code is an adapter in M1).
  • Added optional settingsPath?: string field on InstallContext so callers (tests) can decouple the target file path from homedir() — preserves the pre-refactor
    pattern where paths.claudeSettings was passed independently.
  • Added src/agents/adapters/claude-code.test.ts — 18 unit tests covering helpers + adapter contract + settingsPath override.

Vedansi18 and others added 3 commits May 13, 2026 17:25
Adds the new src/agents/ module: four adapter interfaces (HookAdapter,
VSCodeExtensionAdapter, CLIWrapAdapter, BrowserExtensionAdapter), an
in-process registry (registerAdapter, detectAll, getAdapter), and an
empty index.ts placeholder for future adapter registrations. Unit tests
in registry.test.ts cover the registry behaviour.

Adds src/cli/commands/install.snapshot.test.ts plus its generated
baseline snapshot. The snapshot captures current installAction output
(settings.json bytes + stdout) with $HOME and platform-dependent
strings normalised so the snapshot is portable across machines. This
is the zero-diff safety net for M1 Branch 2 (claude-code refactor):
that branch must keep this snapshot byte-identical.

No existing source code is modified. Per dev plan §1.6 in
reviewduel-submodule.

Branch: v0.1.3/m1/foundation-scaffold

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Moves the six Claude Code hook helpers (getClaudeSettingsPath,
buildHookCommand, buildStopHookCommand, buildHookEntry, writeHookEntry,
removeHookEntry) from src/cli/commands/install.ts to
src/agents/adapters/claude-code.ts. Function bodies are byte-identical.
install.ts re-exports them so existing imports (and install.test.ts)
continue to work unchanged.

Adds claudeCodeAdapter (HookAdapter) that wraps the moved functions and
self-registers via src/agents/index.ts side-effect import.
installAction's Claude Code branch in the for-loop now delegates to the
adapter via getAdapter('claude-code').install(ctx).

Adds optional settingsPath override to InstallContext so callers can
decouple the target file path from ctx.home — preserves the pre-refactor
pattern where paths.claudeSettings was passed independently of homedir()
(used by install.test.ts to inject custom tmp paths without stubbing
HOME). Without this, tests would write hook entries to the real
~/.claude/settings.json instead of their tmp dir.

Adds src/agents/adapters/claude-code.test.ts (18 unit tests) covering
the moved helpers + adapter contract (detect, settingsPath, buildHooks,
install, uninstall) + the settingsPath override behaviour.

Zero-diff invariant preserved: install snapshot from M1 Branch 1 remains
byte-identical. All 177 relevant tests pass. typecheck clean.

Branch: v0.1.3/m1/claude-code-refactor (off v0.1.3/m1/foundation-scaffold,
which sits on upstream/user-experience-improvements-sub-7).

Per dev plan §3.0 in reviewduel-submodule.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The original install.ts comment was a single line:
  // Register the advisory pipeline hook (separate from MCP — different file)

The previous M1/B2 commit (d93852e) expanded this into a four-line
comment explaining the adapter delegation. Per team feedback, comments
on existing pre-refactor code should be kept verbatim — the §1.5 strict
zero-diff guarantee includes comments on existing code.

No behavioural change. Tests + snapshot unchanged (177/177 pass, install
snapshot remains byte-identical with M1 Branch 1's baseline).

Branch: v0.1.3/m1/claude-code-refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Vedansi18 added a commit to Vedansi18/nexpath that referenced this pull request May 28, 2026
…dry-run

Resolves dev plan §6 Q3 (VS Code extension marketplace ID): chose
emptyops.nexpath-vscode over nexpath.coding-agent-hooks — org-scoped
under the emptyops publisher namespace, lower collision risk on both
marketplaces, durable across future browser / JetBrains / etc. Nexpath
extensions that'll share the publisher.

Changes:
- package.json#publisher: nexpath -> emptyops
- cursor.ts / windsurf.ts MARKETPLACE_ID + their tests
- PUBLISH.md / CROSS-OS-VERIFY.md / SMOKE-TEST.md URLs
- publish-extension.yml sanity-check URLs

Snapshot invariant preserved: install.snapshot.test.ts.snap doesn't
embed the marketplace ID (cursor/windsurf detect() returns false in
tmpHome -> those adapters never run in the snapshot scenario).

Drift hi0001234d#3 fix: pinned CI runners from floating *-latest labels to
specific versions (ubuntu-22.04, windows-2022, macos-14) so the
matrix is reproducible. macos-13 was already pinned.

New PUBLISH.md section "Pre-merge CI dry-run" walks the engineer
through triggering the workflow with publish=false to validate every
platform's .vsix builds clean before opening the B6 PR.

Verification:
- Sub-package vitest: 224 / 224 across 18 files
- Root vitest: 2119 passing + 18 pre-existing TtySelectFn
- Root + sub-package tsc clean
- Local vsce package --target linux-x64: clean 3.83 MB .vsix, zero warnings

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Vedansi18 Vedansi18 changed the base branch from main to user-experience-improvements-sub-7 May 29, 2026 04:51
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