@punks/cli 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,399 @@
1
+ # Changelog
2
+
3
+ This changelog tracks `@punks/cli` npm executable release notes from the 2.x line onward.
4
+ Published entries include the npm version and matching git tag or version commit when available.
5
+ Baseline-only releases use `baseline/stable/*` GitHub releases and should still get an entry
6
+ here; `BASELINE_CHANGELOG.md` can carry extra baseline-specific detail.
7
+
8
+ ## 2.3.2 - 2026-06-30
9
+
10
+ Pending npm publish: `@punks/cli@2.3.2`.
11
+
12
+ ### Added
13
+
14
+ - Add `dp check` read-only session-start drift gate for CLI version, scaffold baseline, managed files, pack selection, changelog summaries, and subagent-owned remediation guidance.
15
+
16
+ ### Changed
17
+
18
+ - Bundle runtime changelog metadata into packaged CLI commands so update and baseline drift can be explained without local repository files.
19
+ - Clarify `dp scaffold init`, `dp scaffold setup`, `dp update`, and `$dp-cli` pre-existing skill reconciliation: commands do not detect skill overlaps, preserve blind evidence snapshots, and hand exact-name overlap handling to the follow-up agent.
20
+
21
+ ## 2.3.1 - 2026-06-30
22
+
23
+ Pending npm publish: `@punks/cli@2.3.1`.
24
+
25
+ ### Fixed
26
+
27
+ - Preserve existing Claude settings, including `permissions.allow`, when scaffold setup injects managed hooks.
28
+ - Keep Windows scaffold setup completing when symlink creation is blocked by using directory links or managed mirror copies.
29
+ - Cover issue #58 Windows scaffold mirror and Claude settings preservation regressions.
30
+
31
+ ## 2.3.0 - 2026-06-29
32
+
33
+ Pending npm publish: `@punks/cli@2.3.0`.
34
+
35
+ ### Fixed
36
+
37
+ - Remove `dp update` patch previews and JSON patch bodies, keeping drift output compact path/kind/status summaries.
38
+ - Avoid non-docs scaffold manifests staging wiki alignment drift, and skip generated wiki output directories during docs-owned update alignment.
39
+ - Add regression coverage for CLI scaffold/update drift behavior, database-backed backoffice access, API mutation routes, project activity monotonicity, and OpenAPI route contracts.
40
+
41
+ - Default stable baseline resolution no longer reports false drift from stale control-plane metadata or corrupt cached baselines; it validates cached and materialized baseline assets, then falls back to canonical GitHub stable.
42
+ - Scaffold prompt target detection discovers authored scoped `AGENTS.md` files outside package manifests, so repo-specific surfaces like `infra/opentelemetry` get prompt specs, subagents, and native agent mirrors without Harness-specific placeholder boundaries.
43
+
44
+ ## 2.2.8 - 2026-06-29
45
+
46
+ Pending npm publish: `@punks/cli@2.2.8`.
47
+
48
+ ### Fixed
49
+
50
+ - Publish the npm CLI bin as a portable Node script with bundled scaffold assets instead of a host-native Bun executable, so `dp`, `punks`, and `devpunks` run on Windows package-manager shims.
51
+ - Strengthen release validation to run the built bin through Node and through temp npm-installed `dp`, `punks`, and `devpunks` commands before publishing.
52
+ - Stop treating intentionally selected optional scaffold packs as actionable `dp update --check` pack drift.
53
+ - Report and rewrite stale generated handoff/system-prompt references from `.devpunks/required-tools.json` to `.devpunks/settings.json` while preserving local handoff text.
54
+ - Preserve scaffold-time tailored `.agents/scripts/sync-subagents.mjs` files during update checks and writes.
55
+ - Keep bundled fallback subagent manifest defaults repo-shape neutral instead of shipping Harness-specific app/package paths.
56
+
57
+ ## baseline/stable/2026.06.29-frontend-imagegen-skills - 2026-06-29
58
+
59
+ ### Changed
60
+
61
+ - Release a scaffold baseline with the frontend image-generation skills split into dedicated web and mobile surfaces and included in the frontend skill pack.
62
+
63
+ ## baseline/stable/2026.06.29-lean-goalify-activation - 2026-06-29
64
+
65
+ ### Changed
66
+
67
+ - Release a scaffold baseline with `goalify` rewritten as a very lean goal compiler that activates the goal immediately and uses disclosed examples only when structure is needed.
68
+
69
+ ## baseline/stable/2026.06.29-clawpatch-provider-defaults - 2026-06-29
70
+
71
+ ### Changed
72
+
73
+ - Release a scaffold baseline where ClawPatch bug-discovery and bug-resolution phases inherit the current agent/launcher provider by default.
74
+ - Update operator docs to remove the obsolete provider-cost warning and treat provider/model flags as explicit overrides only.
75
+
76
+ ## 2.2.7 - 2026-06-27
77
+
78
+ Pending npm publish: `@punks/cli@2.2.7`.
79
+
80
+ ### Fixed
81
+
82
+ - Accept legacy `.devpunks/required-tools.json` managed-file entries while keeping `.devpunks/settings.json` as the required-tool source of truth for new scaffold output.
83
+ - Stop reporting project-authored prompt specs, handoff text, scaffold manifest hashes, subagent guidance, and generated agent prompt mirrors as `dp update --check` drift.
84
+
85
+ ## baseline/stable/2026.06.27-high-signal-tdd-tests - 2026-06-27
86
+
87
+ ### Changed
88
+
89
+ - Release a scaffold baseline with high-signal TDD guidance for durable behavior through public seams, contract-safe assertions, and invariant-based regression tests.
90
+
91
+ ## baseline/stable/2026.06.27-design-phase-prototype-routing - 2026-06-27
92
+
93
+ ### Changed
94
+
95
+ - Release a scaffold baseline with the research-pack `$prototype` skill, design-phase prototype routing, and docs-ingested operator guidance for prototype/image artifact handoff.
96
+
97
+ ## baseline/stable/2026.06.25-required-tools-settings - 2026-06-25
98
+
99
+ ### Changed
100
+
101
+ - Release a scaffold baseline that consolidates all required tools in `.devpunks/settings.json` and removes the separate required-tools manifest.
102
+
103
+ ## baseline/stable/2026.06.25-design-phase-asset-evidence - 2026-06-25
104
+
105
+ ### Changed
106
+
107
+ - Release a scaffold baseline with route-gated `design-phase`, durable repo asset management, provider settings authority, and backlog/PR visual evidence handoff guidance.
108
+
109
+ ## 2.2.6 - 2026-06-23
110
+
111
+ Pending npm publish: `@punks/cli@2.2.6`.
112
+
113
+ ### Changed
114
+
115
+ - Sync the simplified `goalify` skill contract from `wearedevpunks/skills@dd95edd`.
116
+
117
+ ### Fixed
118
+
119
+ - Verify refreshed stable baseline metadata against the latest published stable release so stale control-plane metadata cannot hide a newer stable scaffold baseline.
120
+
121
+ ## baseline/stable/2026.06.23-stable-refresh-goalify - 2026-06-23
122
+
123
+ ### Changed
124
+
125
+ - Release a scaffold baseline with the simplified `goalify` skill contract and issue 49 stable-refresh documentation.
126
+
127
+ ## 2.2.5 - 2026-06-23
128
+
129
+ Pending npm publish: `@punks/cli@2.2.5`.
130
+
131
+ ### Changed
132
+
133
+ - Generate root prompt surfaces from scaffold specs so root prompts stay aligned with the managed scaffold copy pipeline.
134
+
135
+ ### Fixed
136
+
137
+ - Preserve repo-specific subagent guidance when syncing generated subagent scripts.
138
+ - Ignore wiki-only roots during pack detection so documentation surfaces do not cause false app/package pack matches.
139
+
140
+ ## baseline/stable/2026.06.23-scaffold-detection-guidance - 2026-06-23
141
+
142
+ ### Changed
143
+
144
+ - Release a scaffold baseline with repo-specific subagent guidance preservation, scaffold-spec-backed root prompt generation, and wiki-root pack detection fixes.
145
+
146
+ ## 2.2.4 - 2026-06-23
147
+
148
+ Pending npm publish: `@punks/cli@2.2.4`.
149
+
150
+ ### Fixed
151
+
152
+ - Detect Bun global installs through the resolved `dp` / `punks` bin symlink, including packaged executable argv shapes, so `dp upgrade` can reinstall a fresh CLI instead of asking for manual reinstall.
153
+ - Run generated scaffold maintenance scripts with `node` by default, with `DP_SCRIPT_RUNTIME` as an override, so packaged CLI installs do not recurse through `process.execPath` or `Bun.execPath` while syncing subagents.
154
+ - Restore public stable baseline downloads through the Harness control plane, with token or `gh` GitHub access retained only as maintainer fallback.
155
+
156
+ ## baseline/stable/2026.06.23-scoped-review-phases - 2026-06-23
157
+
158
+ ### Changed
159
+
160
+ - Release a scaffold baseline with lean scoped review and ClawPatch phase skills.
161
+
162
+ ## 2.2.2 - 2026-06-23
163
+
164
+ Pending npm publish: `@punks/cli@2.2.2`.
165
+
166
+ ### Fixed
167
+
168
+ - Run generated scaffold maintenance scripts through the host runtime in packaged CLI installs so `dp update` and `dp update --check --json` do not re-enter the CLI entrypoint while syncing subagents.
169
+
170
+ ## 2.2.1 - 2026-06-23
171
+
172
+ Pending npm publish: `@punks/cli@2.2.1`.
173
+
174
+ ### Changed
175
+
176
+ - Bump the CLI executable package after app-surfaced wiki root handling and release-validation fixes.
177
+ - Document that all releases, including baseline-only releases, must update `CHANGELOG.md`.
178
+
179
+ ### Fixed
180
+
181
+ - Preserve `app/wiki` for app-surfaced single repos during scaffold init and update without reintroducing competing `wiki/` or `apps/wiki/` roots.
182
+ - Preserve monorepo `apps/wiki`, standalone `wiki`, marker-backed wiki roots, route-only `app/wiki`, stale root cleanup cases, and recorded `repoShapeMode` overrides during update alignment.
183
+ - Add missing routed wiki frontmatter to the CLI tool-validation implementation notes so the wiki production build succeeds.
184
+
185
+ ## 2.2.0 - 2026-06-23
186
+
187
+ Pending npm publish: `@punks/cli@2.2.0`.
188
+
189
+ ### Changed
190
+
191
+ - Add `dp tools ensure` / `punks tools ensure` to check and repair required external Harness tools from `.devpunks/required-tools.json` tool IDs or the default toolchain, using trusted stable/bundled baseline install contracts.
192
+ - Add `dp -v` / `punks -v` as a short alias for `--version`.
193
+ - Build the npm CLI as a Bun standalone executable so installed `dp`, `punks`, and `devpunks` commands no longer require Bun at runtime.
194
+ - Embed bundled scaffold data and skills into the executable while preserving the existing runtime asset copy paths through a temp extraction cache.
195
+ - Document that Bun is required for repository builds and publishing, not for npm-installed CLI usage.
196
+
197
+ ### Fixed
198
+
199
+ - Avoid forcing `agent-browser install` to download Chrome when a supported Chrome, Chromium, or Brave executable is already present.
200
+ - Let already-present required tools validate without Bun, pnpm, or npm on PATH; a package manager is required only when repair is needed.
201
+ - Make the built-dist assertion execute the compiled CLI directly and fail if the package regresses to a Bun shebang.
202
+ - Ad-hoc sign macOS standalone builds so local release validation can execute the compiled binary.
203
+
204
+ ## 2.1.11 - 2026-06-16
205
+
206
+ Pending npm publish: `@punks/cli@2.1.11`.
207
+
208
+ ### Changed
209
+
210
+ - Sync the generic handoff skill into the CLI catalog.
211
+ - Refine docs-ingest routing and bundled context-engineering docs.
212
+
213
+ ### Fixed
214
+
215
+ - Resolve `dp update` report issues.
216
+ - Fix scaffold report output and update drift handling.
217
+
218
+ ## 2.1.10 - 2026-06-12
219
+
220
+ Pending npm publish: `@punks/cli@2.1.10`.
221
+
222
+ ### Changed
223
+
224
+ - Bump the CLI executable after adding scaffolded session-start update checks.
225
+ - Scaffold a Harness update-check hook that runs `dp update --check` for Codex, Claude Code, Cursor, and OpenCode session starts.
226
+
227
+ ### Fixed
228
+
229
+ - Align the built CLI publish assertion with the current `dp report --help` description.
230
+
231
+ ## 2.1.9 - 2026-05-28
232
+
233
+ Pending npm publish: `@punks/cli@2.1.9`. Version commit: `79d8b25`.
234
+
235
+ ### Changed
236
+
237
+ - Add TanStack Start wiki scaffold support with runtime dependencies, package scripts, check wiring, and OG image scaffolding.
238
+ - Tighten scaffolded spec and implementation workflow guidance around lifecycle docs, backlog sync, and subagent usage.
239
+ - Expand report and wiki debt closeout documentation for GitHub-backed reports and TanStack wiki scaffolds.
240
+
241
+ ### Fixed
242
+
243
+ - Gate report GitHub writes and AI metadata behind authenticated/token-backed flows.
244
+ - Deduplicate GitHub-backed backoffice reports and tolerate invalid AI verdict output.
245
+ - Fix wiki scaffold update drift for frontmatter, `.gitignore`, package merges, generated scripts, and TanStack-only route replacements.
246
+
247
+ ## 2.1.8 - 2026-05-27
248
+
249
+ Matched npm publish: `@punks/cli@2.1.8`. Matched git tag: `v2.1.8`.
250
+
251
+ ### Changed
252
+
253
+ - Generate scaffolded Oxlint configs from Ultracite core/framework presets with explicit pack-owned overlays.
254
+ - Update scaffolded review/autoreview skill content and release bookkeeping for categorized GitHub notes.
255
+
256
+ ### Fixed
257
+
258
+ - Fix issue 16 by activating generated OpenCode formatter hooks and routing Python edits through Ruff.
259
+ - Route ESLint-only lint overlay packages through Oxlint `jsPlugins` instead of native Oxlint plugins.
260
+
261
+ ## 2.1.7 - 2026-05-27
262
+
263
+ Matched npm publish: `@punks/cli@2.1.7`. Version commit: `98b61a0`. No matching local `v2.1.7`
264
+ tag was found during changelog update.
265
+
266
+ ### Changed
267
+
268
+ - Improve the scaffold init backlog provider picker flow.
269
+
270
+ ### Fixed
271
+
272
+ - Fix project usage detail rendering in the internal backoffice surface shipped with the release branch.
273
+
274
+ ## 2.1.6 - 2026-05-27
275
+
276
+ Matched npm publish: `@punks/cli@2.1.6`. Matched git tag: `v2.1.6`.
277
+
278
+ ### Changed
279
+
280
+ - Add Mermaid rendering support to scaffolded wiki apps.
281
+ - Align project domain source indexes under `content/docs/project/domains`.
282
+ - Harden scaffold/update handling for existing wiki routes, metadata drift, and CLI release scaffolding.
283
+
284
+ ### Fixed
285
+
286
+ - Close the issue 15 update drift where `dp update` expected the old `apps/wiki/domains` sync contract.
287
+
288
+ ## 2.1.5 - 2026-05-26
289
+
290
+ Matched npm publish: `@punks/cli@2.1.5`. Version commit: `71460ce`. No matching local `v2.1.5`
291
+ tag was found during changelog backfill.
292
+
293
+ ### Changed
294
+
295
+ - Bump the CLI executable after requirements wiki scaffold-path updates.
296
+
297
+ ## 2.1.4 - 2026-05-26
298
+
299
+ Matched npm publish: `@punks/cli@2.1.4`. Version commit: `1c5fc88`. No matching local `v2.1.4`
300
+ tag was found during changelog backfill.
301
+
302
+ ### Changed
303
+
304
+ - Update CLI version and installation docs for the `dp-cli` operator skill flow.
305
+
306
+ ## 2.1.3 - 2026-05-26
307
+
308
+ Matched npm publish: `@punks/cli@2.1.3`. Version commit: `2de8b01`. No matching local `v2.1.3`
309
+ tag was found during changelog backfill.
310
+
311
+ ### Changed
312
+
313
+ - Sync bundled skills and bump the CLI executable package.
314
+
315
+ ## 2.1.2 - 2026-05-26
316
+
317
+ Matched npm publish: `@punks/cli@2.1.2`. Version commit: `40e2aa8`. No matching local `v2.1.2`
318
+ tag was found during changelog backfill.
319
+
320
+ ### Changed
321
+
322
+ - Bump the CLI package after release-test stabilization work.
323
+
324
+ ## 2.1.1 - 2026-05-25
325
+
326
+ Matched npm publish: `@punks/cli@2.1.1`. Matched git tag: `v2.1.1`.
327
+
328
+ ### Changed
329
+
330
+ - Bump the CLI executable after the 2.1.0 baseline release line.
331
+
332
+ ## 2.1.0 - 2026-05-25
333
+
334
+ Matched npm publish: `@punks/cli@2.1.0`. Version commit: `e6a0941`. No matching local `v2.1.0`
335
+ tag was found during changelog backfill.
336
+
337
+ ### Changed
338
+
339
+ - Release the 2.1.0 CLI baseline with updated backoffice auth, report, and stage-skill guidance.
340
+
341
+ ## 2.0.1 - 2026-05-22
342
+
343
+ Matched npm publish: `@punks/cli@2.0.1`. Version commit: `35be311`. No matching local `v2.0.1`
344
+ tag was found during changelog backfill.
345
+
346
+ ### Changed
347
+
348
+ - Bump the CLI executable after device-auth and backoffice follow-up work.
349
+
350
+ ## 2.0.0 - 2026-05-21
351
+
352
+ Matched npm publish: `@punks/cli@2.0.0`. Matched git tag: `v2.0.0`.
353
+
354
+ ### Changed
355
+
356
+ - Promote the Harness Intelligence monorepo-era CLI to the stable 2.0.0 line.
357
+ - Include the private wiki, routed docs, control-plane baseline path, and updated scaffold content from the 2.0.0 delivery branch.
358
+
359
+ ## 2.0.0-beta.4 - 2026-05-14
360
+
361
+ Matched npm publish: `@punks/cli@2.0.0-beta.4`. Matched git tag: `v2.0.0-beta.4`.
362
+
363
+ ### Changed
364
+
365
+ - Bump the beta CLI after private wiki and Harness Intelligence rename work.
366
+
367
+ ## 2.0.0-beta.3 - 2026-05-13
368
+
369
+ Matched npm publish: `@punks/cli@2.0.0-beta.3`. Matched git tag: `v2.0.0-beta.3`.
370
+
371
+ ### Fixed
372
+
373
+ - Publish the sanitized CLI npm package so workspace and catalog specifiers do not leak into the install artifact.
374
+
375
+ ## 2.0.0-beta.2 - 2026-05-13
376
+
377
+ Matched npm publish: `@punks/cli@2.0.0-beta.2`. Version commit: `2dc13cd`. No matching local
378
+ `v2.0.0-beta.2` tag was found during changelog backfill.
379
+
380
+ ### Changed
381
+
382
+ - Bump the beta package version during the 2.0.0 beta release sequence.
383
+
384
+ ## 2.0.0-beta.1 - 2026-05-13
385
+
386
+ Matched npm publish: `@punks/cli@2.0.0-beta.1`. Version commit: `2d0d1f1`. No matching local
387
+ `v2.0.0-beta.1` tag was found during changelog backfill.
388
+
389
+ ### Changed
390
+
391
+ - Bump the beta package version after adding the beta release task.
392
+
393
+ ## 2.0.0-beta.0 - 2026-05-13
394
+
395
+ Matched npm publish: `@punks/cli@2.0.0-beta.0`. Matched git tag: `v2.0.0-beta.0`.
396
+
397
+ ### Added
398
+
399
+ - Introduce the 2.0.0 beta line for Harness phase-skill distribution and monorepo-era scaffold output.
@@ -49,12 +49,21 @@ function commandExists(command, cwd) {
49
49
  return result.status === 0;
50
50
  }
51
51
 
52
- function runUpdateCheck(root) {
52
+ function checkCommand(root) {
53
53
  if (!existsSync(path.join(root, scaffoldManifestFile))) {
54
- return { status: "skipped", message: "" };
54
+ return null;
55
55
  }
56
56
 
57
57
  const command = commandExists("dp", root) ? "dp" : commandExists("punks", root) ? "punks" : null;
58
+ return command === null ? null : [command, "check"];
59
+ }
60
+
61
+ function runUpdateCheck(root) {
62
+ const command = checkCommand(root);
63
+ if (command === null && !existsSync(path.join(root, scaffoldManifestFile))) {
64
+ return { status: "skipped", message: "" };
65
+ }
66
+
58
67
  if (command === null) {
59
68
  return {
60
69
  status: "skipped",
@@ -62,7 +71,9 @@ function runUpdateCheck(root) {
62
71
  };
63
72
  }
64
73
 
65
- const result = spawnSync(command, ["update", "--check"], {
74
+ const [bin, ...args] = command;
75
+ const commandLabel = command.join(" ");
76
+ const result = spawnSync(bin, args, {
66
77
  cwd: root,
67
78
  encoding: "utf8",
68
79
  env: {
@@ -81,7 +92,7 @@ function runUpdateCheck(root) {
81
92
  message: [
82
93
  "Harness scaffold check failed to run.",
83
94
  "",
84
- `${command} update --check error: ${result.error.message}`,
95
+ `${commandLabel} error: ${result.error.message}`,
85
96
  ].join("\n"),
86
97
  };
87
98
  }
@@ -95,11 +106,11 @@ function runUpdateCheck(root) {
95
106
  message: [
96
107
  "Harness scaffold divergence detected.",
97
108
  "",
98
- `Command: ${command} update --check`,
109
+ `Command: ${commandLabel}`,
99
110
  "",
100
111
  output || "(no command output)",
101
112
  "",
102
- "Run `dp update` before relying on scaffolded agents, skills, hooks, or root guidance.",
113
+ "Hand accepted remediation to the assigned subagent before relying on scaffolded agents, skills, hooks, or root guidance.",
103
114
  ].join("\n"),
104
115
  };
105
116
  }
@@ -167,6 +178,7 @@ export const ScaffoldUpdateCheckPlugin = async ({ client, directory, worktree })
167
178
  });
168
179
 
169
180
  export const testHooks = {
181
+ checkCommand,
170
182
  formatForHarness,
171
183
  okMessage,
172
184
  runUpdateCheck,
@@ -1,4 +1,5 @@
1
1
  import {
2
+ cp,
2
3
  lstat,
3
4
  mkdir,
4
5
  readFile,
@@ -52,6 +53,10 @@ const cursorManagedComment =
52
53
  "<!-- Generated by scripts/sync-subagents.mjs. Edit .agents/subagents/manifest.mjs instead. -->";
53
54
  const opencodeManagedComment =
54
55
  "<!-- Generated by scripts/sync-subagents.mjs. Edit .agents/subagents/manifest.mjs instead. -->";
56
+ const claudeUpdateCheckCommand =
57
+ 'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/scaffold-update-check.mjs claude';
58
+ const claudeFormatCommand =
59
+ 'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/format-edited-file.mjs claude';
55
60
 
56
61
  function buildCodexAgentConfig({ hasFormatHook, hasUpdateCheckHook }) {
57
62
  const lines = [
@@ -100,39 +105,80 @@ function buildCodexAgentConfig({ hasFormatHook, hasUpdateCheckHook }) {
100
105
  return lines.join("\n");
101
106
  }
102
107
 
103
- function buildClaudeSettingsConfig({ hasFormatHook, hasUpdateCheckHook }) {
104
- const hooks = {};
108
+ function isObject(value) {
109
+ return typeof value === "object" && value !== null && !Array.isArray(value);
110
+ }
111
+
112
+ function removeClaudeHookCommand(entries, command) {
113
+ if (!Array.isArray(entries)) {
114
+ return [];
115
+ }
116
+
117
+ return entries.flatMap((entry) => {
118
+ if (!isObject(entry) || !Array.isArray(entry.hooks)) {
119
+ return [entry];
120
+ }
121
+
122
+ const hooks = entry.hooks.filter((hook) => !isObject(hook) || hook.command !== command);
123
+ return hooks.length === 0 ? [] : [{ ...entry, hooks }];
124
+ });
125
+ }
126
+
127
+ function setClaudeHookEntries(hooks, key, entries) {
128
+ if (entries.length > 0) {
129
+ hooks[key] = entries;
130
+ } else {
131
+ delete hooks[key];
132
+ }
133
+ }
134
+
135
+ function buildClaudeSettingsConfig(existingConfig, { hasFormatHook, hasUpdateCheckHook }) {
136
+ const config = isObject(existingConfig) ? existingConfig : {};
137
+ const existingHooks = isObject(config.hooks) ? config.hooks : {};
138
+ const hooks = { ...existingHooks };
139
+ const sessionStartHooks = removeClaudeHookCommand(
140
+ existingHooks.SessionStart,
141
+ claudeUpdateCheckCommand,
142
+ );
143
+ const postToolUseHooks = removeClaudeHookCommand(existingHooks.PostToolUse, claudeFormatCommand);
105
144
 
106
145
  if (hasUpdateCheckHook) {
107
146
  hooks.SessionStart = [
147
+ ...sessionStartHooks,
108
148
  {
109
149
  hooks: [
110
150
  {
111
151
  type: "command",
112
- command: 'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/scaffold-update-check.mjs claude',
152
+ command: claudeUpdateCheckCommand,
113
153
  timeout: 60,
114
154
  },
115
155
  ],
116
156
  },
117
157
  ];
158
+ } else {
159
+ setClaudeHookEntries(hooks, "SessionStart", sessionStartHooks);
118
160
  }
119
161
 
120
162
  if (hasFormatHook) {
121
163
  hooks.PostToolUse = [
164
+ ...postToolUseHooks,
122
165
  {
123
166
  matcher: "Edit|Write|MultiEdit",
124
167
  hooks: [
125
168
  {
126
169
  type: "command",
127
- command: 'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/format-edited-file.mjs claude',
170
+ command: claudeFormatCommand,
128
171
  timeout: 30,
129
172
  },
130
173
  ],
131
174
  },
132
175
  ];
176
+ } else {
177
+ setClaudeHookEntries(hooks, "PostToolUse", postToolUseHooks);
133
178
  }
134
179
 
135
180
  return {
181
+ ...config,
136
182
  hooks,
137
183
  };
138
184
  }
@@ -390,7 +436,23 @@ async function ensureSymlink(linkPath, targetPath) {
390
436
  }
391
437
 
392
438
  await rm(linkPath, { force: true, recursive: true });
393
- await symlink(relativeTarget, linkPath);
439
+ const targetStat = process.platform === "win32" ? await lstat(targetPath) : undefined;
440
+ const symlinkType = targetStat?.isDirectory() ? "junction" : undefined;
441
+
442
+ try {
443
+ await symlink(symlinkType === "junction" ? targetPath : relativeTarget, linkPath, symlinkType);
444
+ } catch (error) {
445
+ if (!(error && typeof error === "object" && "code" in error && error.code === "EPERM")) {
446
+ throw error;
447
+ }
448
+
449
+ const copyTargetStat = await lstat(targetPath);
450
+ await cp(targetPath, linkPath, {
451
+ recursive: copyTargetStat.isDirectory(),
452
+ force: true,
453
+ errorOnExist: false,
454
+ });
455
+ }
394
456
  }
395
457
 
396
458
  async function pathExists(filePath) {
@@ -499,7 +561,7 @@ async function main() {
499
561
  await rm(path.join(codexDir, "hooks.json"), { force: true });
500
562
  await writeFile(
501
563
  claudeSettingsPath,
502
- encodeJson(buildClaudeSettingsConfig(availableHooks)),
564
+ encodeJson(buildClaudeSettingsConfig(await readJsonFile(claudeSettingsPath), availableHooks)),
503
565
  "utf8",
504
566
  );
505
567
  await writeFile(cursorHooksJsonPath, encodeJson(buildCursorHooksConfig(availableHooks)), "utf8");