@detergent-software/atk 9.4.0-dev.13 → 9.4.0-dev.15

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/build/commands/audit.d.ts.map +1 -1
  4. package/build/commands/audit.js +2 -1
  5. package/build/commands/audit.js.map +1 -1
  6. package/build/lib/adapter.d.ts +14 -9
  7. package/build/lib/adapter.d.ts.map +1 -1
  8. package/build/lib/adapter.js +46 -8
  9. package/build/lib/adapter.js.map +1 -1
  10. package/build/lib/asset-tools.d.ts +4 -4
  11. package/build/lib/asset-tools.js +4 -4
  12. package/build/lib/config-entries.d.ts +2 -2
  13. package/build/lib/config-entries.d.ts.map +1 -1
  14. package/build/lib/config-entries.js +15 -5
  15. package/build/lib/config-entries.js.map +1 -1
  16. package/build/lib/hook-config.d.ts +60 -5
  17. package/build/lib/hook-config.d.ts.map +1 -1
  18. package/build/lib/hook-config.js +97 -5
  19. package/build/lib/hook-config.js.map +1 -1
  20. package/build/lib/hook-script.d.ts +10 -0
  21. package/build/lib/hook-script.d.ts.map +1 -1
  22. package/build/lib/hook-script.js +31 -1
  23. package/build/lib/hook-script.js.map +1 -1
  24. package/build/lib/installer.d.ts.map +1 -1
  25. package/build/lib/installer.js +35 -16
  26. package/build/lib/installer.js.map +1 -1
  27. package/build/lib/schemas/adapter.d.ts +24 -0
  28. package/build/lib/schemas/adapter.d.ts.map +1 -1
  29. package/build/lib/schemas/adapter.js +18 -4
  30. package/build/lib/schemas/adapter.js.map +1 -1
  31. package/build/lib/touched-paths.d.ts.map +1 -1
  32. package/build/lib/touched-paths.js +2 -1
  33. package/build/lib/touched-paths.js.map +1 -1
  34. package/build/lib/uninstaller.d.ts.map +1 -1
  35. package/build/lib/uninstaller.js +11 -3
  36. package/build/lib/uninstaller.js.map +1 -1
  37. package/package.json +1 -1
  38. package/tool-adapters/copilot-cli.json +50 -6
@@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EAAE,MAAM,GAChB,CAAC,CAMH;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,eAAe,GAAG,SAAS,EAC1E,SAAS,EAAE,CAAC,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,CAAC,CASH;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CA2BT"}
@@ -1,3 +1,20 @@
1
+ import { isAbsolute } from 'node:path';
2
+ /**
3
+ * Build the entry a hook placement appends under an event, in its `configHookFormat`: a
4
+ * matcher-group ({@link buildHookGroup}) by default, or a Copilot CLI entry, whose timeout is
5
+ * `timeoutSec`.
6
+ */
7
+ export function buildHookEntry(placement, command, binding) {
8
+ if (placement.configHookFormat !== 'copilot') {
9
+ return buildHookGroup(command, binding);
10
+ }
11
+ return {
12
+ bash: command,
13
+ powershell: command,
14
+ type: 'command',
15
+ ...(binding?.timeout !== undefined ? { timeoutSec: binding.timeout } : {}),
16
+ };
17
+ }
1
18
  /**
2
19
  * Build a tool-valid hook matcher-group for a single event binding.
3
20
  * Only includes `matcher`/`timeout` when set, keeping config (and its checksum) minimal.
@@ -26,41 +43,116 @@ export function deriveHookCommand(commandPrefix, installedRelPath) {
26
43
  * The command a hook placement registers for an asset: the placement's `configCommand` template
27
44
  * when it has one (a command that doesn't name the installed path, such as a user hook's
28
45
  * `"${CLAUDE_CONFIG_DIR:-$HOME/.claude}/hooks/x.sh"`, or one that names it as `{path}`, such as a
29
- * node hook's), otherwise {@link deriveHookCommand}.
46
+ * node hook's, or as `{homePath}`), otherwise {@link deriveHookCommand}. `{homePath}` is the
47
+ * user-root-relative path from `$HOME`, which bash and PowerShell both expand, or the path itself
48
+ * when it is absolute (a moved user config directory on another drive).
30
49
  */
31
50
  export function hookCommand(placement, assetName) {
32
51
  const installedPath = placement.path.replace(/\{name\}/g, assetName);
33
52
  if (placement.configCommand !== undefined) {
34
- return placement.configCommand.replace(/\{path\}/g, installedPath).replace(/\{name\}/g, assetName);
53
+ const homePath = isAbsolute(installedPath) ? installedPath : `$HOME/${installedPath}`;
54
+ return placement.configCommand
55
+ .replace(/\{path\}/g, installedPath)
56
+ .replace(/\{homePath\}/g, homePath)
57
+ .replace(/\{name\}/g, assetName);
35
58
  }
36
59
  return deriveHookCommand(placement.configCommandPrefix, installedPath);
37
60
  }
61
+ /**
62
+ * The events a hook placement registers for a `hookConfig`, by the tool's own names
63
+ * (`configHookEvents`), and the ones it leaves out: an event the map doesn't know, and, for
64
+ * Copilot CLI, a binding with a `matcher`, whose tool names are Claude Code's (`Bash`) and which
65
+ * a Copilot entry can't hold (run on every tool instead, a filtered hook would do the wrong thing).
66
+ * An event already named as the tool names it is taken as it is; a second binding for an event
67
+ * already taken is left out.
68
+ */
69
+ export function hookEventsFor(placement, hookConfig) {
70
+ const events = [];
71
+ const leftOut = [];
72
+ const names = placement.configHookEvents;
73
+ const toolNames = new Set(Object.values(names ?? {}));
74
+ for (const [event, binding] of Object.entries(hookConfig ?? {})) {
75
+ const toolEvent = names ? (names[event] ?? (toolNames.has(event) ? event : undefined)) : event;
76
+ if (toolEvent === undefined) {
77
+ leftOut.push({ event, reason: 'unknown-event' });
78
+ }
79
+ else if (events.some((e) => e.event === toolEvent)) {
80
+ leftOut.push({ event, reason: 'duplicate' });
81
+ }
82
+ else if (placement.configHookFormat === 'copilot' && binding?.matcher) {
83
+ leftOut.push({ event, reason: 'matcher' });
84
+ }
85
+ else {
86
+ events.push({ binding, event: toolEvent });
87
+ }
88
+ }
89
+ return { events, leftOut };
90
+ }
38
91
  /**
39
92
  * Return true if a value looks like a hook matcher-group whose nested command
40
- * entries include the given command — i.e. the group ATK owns for that asset.
93
+ * entries include the given command — i.e. the group ATK owns for that asset —
94
+ * or a Copilot CLI entry whose `bash` command is it.
41
95
  * Tolerant of arbitrary/foreign group shapes (returns false rather than throwing).
42
96
  */
43
97
  export function hookGroupOwnsCommand(group, command) {
44
98
  if (!group || typeof group !== 'object') {
45
99
  return false;
46
100
  }
101
+ if (group.bash === command) {
102
+ return true;
103
+ }
47
104
  const hooks = group.hooks;
48
105
  if (!Array.isArray(hooks)) {
49
106
  return false;
50
107
  }
51
108
  return hooks.some((h) => !!h && typeof h === 'object' && h.command === command);
52
109
  }
110
+ /**
111
+ * Whether a config file holds nothing once ATK's entries are out of it: no keys, or only the
112
+ * `version` of a Copilot CLI hook file, which ATK writes and is the whole file without its hooks.
113
+ */
114
+ export function isEmptyHookConfig(config) {
115
+ const keys = Object.keys(config);
116
+ return keys.length === 0 || (keys.length === 1 && keys[0] === 'version');
117
+ }
53
118
  /** Whether a hook's manifest entrypoint is an ES module, which a placement's `nodeEntrypoint` runs with node. */
54
119
  export function isNodeHookEntrypoint(entrypoint) {
55
120
  return entrypoint?.endsWith('.mjs') ?? false;
56
121
  }
122
+ /** Why a hook placement leaves out a `hookConfig` event, as the end of a sentence. */
123
+ export function leftOutHookEventReason(left, toolName) {
124
+ switch (left.reason) {
125
+ case 'duplicate':
126
+ return `another of its events has the same name in ${toolName}`;
127
+ case 'matcher':
128
+ return `its matcher names Claude Code's tools, and ${toolName} has no matcher for it`;
129
+ case 'unknown-event':
130
+ return `${toolName} has no such hook event`;
131
+ }
132
+ }
133
+ /**
134
+ * {@link placementForEntrypoint}, with `{name}` in its `configFile` filled in: a placement that
135
+ * writes one config file per hook (Copilot CLI's `.github/hooks/{name}.json`) names it after the
136
+ * asset. A shared config file has no `{name}` and stays as it is.
137
+ */
138
+ export function placementForAsset(placement, entrypoint, assetName) {
139
+ const resolved = placementForEntrypoint(placement, entrypoint);
140
+ if (!resolved?.configFile?.includes('{name}')) {
141
+ return resolved;
142
+ }
143
+ return { ...resolved, configFile: resolved.configFile.replace(/\{name\}/g, assetName) };
144
+ }
57
145
  /**
58
146
  * The placement a hook asset is placed with: its `nodeEntrypoint` path and command when the asset's
59
- * entrypoint is an ES module, otherwise the placement itself. A `.sh` hook is run by the shell the
60
- * tool picks, which on Windows can be cmd, where neither `$VAR` nor a `.sh` script works; an
147
+ * entrypoint is an ES module, its `jsonEntrypoint` path alone (no config merge) when the entrypoint
148
+ * is the tool's own hook config, otherwise the placement itself. A `.sh` hook is run by the shell
149
+ * the tool picks, which on Windows can be cmd, where neither `$VAR` nor a `.sh` script works; an
61
150
  * `.mjs` hook run by node behaves the same under every shell.
62
151
  */
63
152
  export function placementForEntrypoint(placement, entrypoint) {
153
+ if (placement?.jsonEntrypoint && entrypoint?.endsWith('.json')) {
154
+ return { path: placement.jsonEntrypoint.path };
155
+ }
64
156
  if (!placement?.nodeEntrypoint || !isNodeHookEntrypoint(entrypoint)) {
65
157
  return placement;
66
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hook-config.js","sourceRoot":"","sources":["../../src/lib/hook-config.ts"],"names":[],"mappings":"AA8BA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,OAAqC;IACnF,MAAM,WAAW,GAAgB;QAC/B,OAAO;QACP,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxE,CAAC;IACF,OAAO;QACL,KAAK,EAAE,CAAC,WAAW,CAAC;QACpB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAiC,EAAE,gBAAwB;IAC3F,OAAO,GAAG,aAAa,IAAI,EAAE,GAAG,gBAAgB,EAAE,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH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ACf,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { PlacementConfig } from './schemas/adapter.js';
2
+ import type { InstalledAsset } from './schemas/lockfile.js';
2
3
  /**
3
4
  * Project-relative path of the script a hook placement registers as its command, or
4
5
  * undefined when the tool does not run the installed file directly.
@@ -23,4 +24,13 @@ export declare function lacksExecBit(filePath: string, platform?: NodeJS.Platfor
23
24
  * API serves bytes only, so the installer has to set the mode itself. No-op on Windows.
24
25
  */
25
26
  export declare function makeExecutable(filePath: string, platform?: NodeJS.Platform): Promise<void>;
27
+ /**
28
+ * The absolute path of the copy of a hook script that a CLI before ATK-204 saved under the name of
29
+ * the hook's own config file (Copilot CLI's `.github/hooks/{name}.json`), which the tool can't read
30
+ * as config, or undefined when there is none. That copy is a file that isn't readable config and
31
+ * holds the bytes of one of the files the given entries of the asset recorded, or a script (`#!`),
32
+ * which no config file starts with: the lockfile may already record a newer version than the copy's.
33
+ * `placement` is the adapter's hook placement, not one resolved for an entrypoint.
34
+ */
35
+ export declare function misplacedHookCopy(placement: PlacementConfig | undefined, name: string, installed: Array<Pick<InstalledAsset, 'files'> | undefined>, projectDir: string): Promise<string | undefined>;
26
36
  //# sourceMappingURL=hook-script.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook-script.d.ts","sourceRoot":"","sources":["../../src/lib/hook-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE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ACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc7B"}
@@ -1,4 +1,8 @@
1
- import { access, chmod, constants, stat } from 'node:fs/promises';
1
+ import { existsSync } from 'node:fs';
2
+ import { access, chmod, constants, readFile, stat } from 'node:fs/promises';
3
+ import { hashBytes } from './checksum.js';
4
+ import { readConfigFile, resolveConfigFormat } from './config-file.js';
5
+ import { fromRoot } from './root-path.js';
2
6
  /**
3
7
  * Project-relative path of the script a hook placement registers as its command, or
4
8
  * undefined when the tool does not run the installed file directly.
@@ -45,4 +49,30 @@ export async function makeExecutable(filePath, platform = process.platform) {
45
49
  await chmod(filePath, executable);
46
50
  }
47
51
  }
52
+ /**
53
+ * The absolute path of the copy of a hook script that a CLI before ATK-204 saved under the name of
54
+ * the hook's own config file (Copilot CLI's `.github/hooks/{name}.json`), which the tool can't read
55
+ * as config, or undefined when there is none. That copy is a file that isn't readable config and
56
+ * holds the bytes of one of the files the given entries of the asset recorded, or a script (`#!`),
57
+ * which no config file starts with: the lockfile may already record a newer version than the copy's.
58
+ * `placement` is the adapter's hook placement, not one resolved for an entrypoint.
59
+ */
60
+ export async function misplacedHookCopy(placement, name, installed, projectDir) {
61
+ if (!placement?.configHookMerge || !placement.configFile?.includes('{name}'))
62
+ return undefined;
63
+ const path = fromRoot(projectDir, placement.configFile.replace(/\{name\}/g, name));
64
+ if (!installed.some(Boolean) || !existsSync(path))
65
+ return undefined;
66
+ try {
67
+ await readConfigFile(path, resolveConfigFormat(path, placement));
68
+ return undefined;
69
+ }
70
+ catch {
71
+ // Not config: maybe the misplaced copy.
72
+ }
73
+ const content = await readFile(path);
74
+ const checksum = hashBytes(content);
75
+ const recorded = installed.some((entry) => entry?.files.some((f) => f.checksum === checksum));
76
+ return recorded || content.subarray(0, 2).toString() === '#!' ? path : undefined;
77
+ }
48
78
  //# sourceMappingURL=hook-script.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook-script.js","sourceRoot":"","sources":["../../src/lib/hook-script.ts"],"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AAK,GAAG,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC,EAChG,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,YAAY,GAAG,YAAY,CAAC,GACrE,OAAO,CAAC,QAAQ,CAAC,CAqFnB"}
@@ -10,8 +10,8 @@ import { configLockPath, withConfigLock } from './config-lock.js';
10
10
  import { addToEnabledList, removeFromEnabledList } from './enabled-list.js';
11
11
  import { ApiCodeError, errorGuidance, errorMessage } from './errors.js';
12
12
  import { ensureGitignoreEntries } from './gitignore.js';
13
- import { buildHookGroup, hookCommand, hookGroupOwnsCommand, isNodeHookEntrypoint, placementForEntrypoint, removeHookGroup, } from './hook-config.js';
14
- import { hookScriptPath, makeExecutable } from './hook-script.js';
13
+ import { buildHookEntry, hookCommand, hookEventsFor, hookGroupOwnsCommand, isEmptyHookConfig, isNodeHookEntrypoint, leftOutHookEventReason, placementForAsset, placementForEntrypoint, removeHookGroup, } from './hook-config.js';
14
+ import { hookScriptPath, makeExecutable, misplacedHookCopy } from './hook-script.js';
15
15
  import { isInstalledForTool } from './installed-for-tool.js';
16
16
  import { addAssetToLockfile, findInstalledAsset, readLockfile, removeAssetFromLockfile, writeLockfile, } from './lockfile.js';
17
17
  import { formatOrgName } from './org.js';
@@ -783,7 +783,7 @@ async function installAsset(entry, options, managedPaths, managedEntries, owners
783
783
  assetFiles.some((f) => isNodeHookEntrypoint(f.relativePath))) {
784
784
  throw new InstallerError(`Couldn't read the manifest of "${asset.name}"@${entry.version}, which says how the hook runs, so it wasn't installed.`, { hint: 'Run the command again. If it keeps failing, check the asset in the registry.' });
785
785
  }
786
- const placement = placementForEntrypoint(typePlacement, declaredEntrypoint);
786
+ const placement = placementForAsset(typePlacement, declaredEntrypoint, asset.name);
787
787
  // Find the entrypoint file
788
788
  const entrypointFile = assetFiles.find((f) => isEntrypoint(f.relativePath, asset.type, declaredEntrypoint));
789
789
  // A multi-tool install skips such a hook for the tool (see placeableEntries); any other path
@@ -831,9 +831,17 @@ async function installAsset(entry, options, managedPaths, managedEntries, owners
831
831
  : []),
832
832
  ...staleConfigEntries(previousEntry, declaredEntrypoint, adapter, placement).map((stale) => configEntryPath(stale, previousEntry, adapter, projectDir)),
833
833
  ], asset.name, adapter, projectDir);
834
+ // A CLI before ATK-204 wrote a Copilot hook's script under the name of its hook config. That copy
835
+ // is the file this hook's own config is written to now, so it goes once every check has passed;
836
+ // anything else there is left for the check below to refuse. Another tool's pass of this run may
837
+ // have recorded the new version already, so the entry from before the run counts too.
838
+ const before = options.installedBefore ?? options.managedFrom;
839
+ const misplacedCopy = placement.configHookMerge
840
+ ? await misplacedHookCopy(typePlacement, asset.name, [previousEntry, before && findInstalledAsset(before, asset.name, asset.type, entry.asset.org)], basePath)
841
+ : undefined;
834
842
  // A config file the merge below couldn't read fails the install before any file is placed, so a
835
843
  // reinstall's files keep the content its previous entries run.
836
- if (placement.configFile && placement.configKey && !placement.fileless) {
844
+ if (placement.configFile && placement.configKey && !placement.fileless && !misplacedCopy) {
837
845
  await checkConfigReadable(fromRoot(basePath, placement.configFile), configFormat, placement.configHookMerge ? 'the hook' : `"${asset.name}"`);
838
846
  }
839
847
  // Branch on placement type
@@ -958,7 +966,13 @@ async function installAsset(entry, options, managedPaths, managedEntries, owners
958
966
  // config file as valid event arrays (e.g. settings.json hooks.Stop[]), with the
959
967
  // command derived from the installed script path.
960
968
  const { configFile, configKey } = placement;
961
- const hookEntries = await withConfigLock(lockFile, () => mergeHookConfig(fromRoot(basePath, configFile), configKey, configFormat, entry.versionData.hookConfig, hookCommand(placement, asset.name), projectDir, onProgress, writeOptions));
969
+ if (misplacedCopy)
970
+ await unlink(misplacedCopy);
971
+ const { events, leftOut } = hookEventsFor(placement, entry.versionData.hookConfig);
972
+ for (const left of leftOut) {
973
+ onProgress?.(`Warning: ${asset.name}'s ${left.event} hook is not registered for ${adapter.tool}: ${leftOutHookEventReason(left, adapter.displayName)}`);
974
+ }
975
+ const hookEntries = await withConfigLock(lockFile, () => mergeHookConfig(fromRoot(basePath, configFile), configKey, configFormat, placement, events, hookCommand(placement, asset.name), projectDir, onProgress, writeOptions));
962
976
  configEntries.push(...hookEntries);
963
977
  }
964
978
  else if (placement.configFile && placement.configKey) {
@@ -1167,16 +1181,17 @@ async function mergeFragmentConfig(configFilePath, configKey, format, projectDir
1167
1181
  * Merge a hook asset's event bindings into a tool config file (e.g. .claude/settings.json).
1168
1182
  *
1169
1183
  * Claude Code stores hooks as `hooks.<Event>: [ { matcher?, hooks: [{ type:'command', command }] } ]`,
1170
- * an ARRAY shared by every hook bound to that event. For each event in `hookConfig`, this appends
1171
- * one matcher-group whose command is the installed script path. ATK's group is identified by that
1172
- * command (no marker is written — the tool validates group shape). Idempotent: an existing group
1173
- * owned by this command is dropped before appending, so repeated install/sync doesn't duplicate.
1174
- * Returns one lockfile config entry per event, checksummed over the ATK-owned group only.
1184
+ * an ARRAY shared by every hook bound to that event. For each of `events` (the `hookConfig` events
1185
+ * the placement registers, by the tool's names: {@link hookEventsFor}), this appends one entry in
1186
+ * the placement's format ({@link buildHookEntry}) whose command runs the installed script. ATK's
1187
+ * entry is identified by that command (no marker is written — the tool validates group shape).
1188
+ * Idempotent: an existing entry owned by this command is dropped before appending, so repeated
1189
+ * install/sync doesn't duplicate. A Copilot CLI hook file gets its `"version": 1` too. Returns one
1190
+ * lockfile config entry per event, checksummed over the ATK-owned entry only.
1175
1191
  */
1176
- async function mergeHookConfig(configFilePath, configKey, format, hookConfig, command, projectDir, onProgress, writeOptions = {}) {
1177
- const events = hookConfig ? Object.keys(hookConfig) : [];
1192
+ async function mergeHookConfig(configFilePath, configKey, format, placement, events, command, projectDir, onProgress, writeOptions = {}) {
1178
1193
  if (events.length === 0) {
1179
- // No hookConfig (e.g. legacy asset or un-rebuilt registry index) — write nothing.
1194
+ // No hookConfig (e.g. legacy asset or un-rebuilt registry index), or none the tool has — write nothing.
1180
1195
  return [];
1181
1196
  }
1182
1197
  try {
@@ -1190,13 +1205,16 @@ async function mergeHookConfig(configFilePath, configKey, format, hookConfig, co
1190
1205
  await mkdir(dir, { recursive: true });
1191
1206
  }
1192
1207
  }
1208
+ if (placement.configHookFormat === 'copilot' && config['version'] === undefined) {
1209
+ config = { version: 1, ...config };
1210
+ }
1193
1211
  if (!config[configKey] || typeof config[configKey] !== 'object' || Array.isArray(config[configKey])) {
1194
1212
  config[configKey] = {};
1195
1213
  }
1196
1214
  const section = config[configKey];
1197
1215
  const entries = [];
1198
- for (const event of events) {
1199
- const group = buildHookGroup(command, hookConfig[event]);
1216
+ for (const { binding, event } of events) {
1217
+ const group = buildHookEntry(placement, command, binding);
1200
1218
  const existing = Array.isArray(section[event]) ? section[event] : [];
1201
1219
  // Idempotency: remove any prior group this asset owns before re-appending.
1202
1220
  const next = existing.filter((g) => !hookGroupOwnsCommand(g, command));
@@ -1340,7 +1358,8 @@ async function revertConfigEntry(configFilePath, keyPath, command, format, delet
1340
1358
  delete config[sectionKey];
1341
1359
  }
1342
1360
  }
1343
- if (deleteWhenEmpty && Object.keys(config).length === 0) {
1361
+ const empty = command !== undefined ? isEmptyHookConfig(config) : Object.keys(config).length === 0;
1362
+ if (deleteWhenEmpty && empty) {
1344
1363
  await removeEmptiedConfigFile(configFilePath, format, writeOptions);
1345
1364
  return;
1346
1365
  }