@detergent-software/atk 9.4.0-dev.9 → 9.4.0
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.
- package/CHANGELOG.md +391 -0
- package/README.md +7 -2
- package/build/command-manifest.json +33 -7
- package/build/commands/_app.d.ts.map +1 -1
- package/build/commands/_app.js +4 -2
- package/build/commands/_app.js.map +1 -1
- package/build/commands/audit.d.ts.map +1 -1
- package/build/commands/audit.js +7 -4
- package/build/commands/audit.js.map +1 -1
- package/build/commands/diff.d.ts.map +1 -1
- package/build/commands/diff.js +10 -10
- package/build/commands/diff.js.map +1 -1
- package/build/commands/doctor.d.ts.map +1 -1
- package/build/commands/doctor.js +1 -1
- package/build/commands/doctor.js.map +1 -1
- package/build/commands/info.d.ts.map +1 -1
- package/build/commands/info.js +16 -14
- package/build/commands/info.js.map +1 -1
- package/build/commands/init.d.ts.map +1 -1
- package/build/commands/init.js +1 -1
- package/build/commands/init.js.map +1 -1
- package/build/commands/install.d.ts.map +1 -1
- package/build/commands/install.js +127 -69
- package/build/commands/install.js.map +1 -1
- package/build/commands/move.d.ts.map +1 -1
- package/build/commands/move.js +5 -4
- package/build/commands/move.js.map +1 -1
- package/build/commands/outdated.js +1 -1
- package/build/commands/outdated.js.map +1 -1
- package/build/commands/sync.d.ts.map +1 -1
- package/build/commands/sync.js +6 -4
- package/build/commands/sync.js.map +1 -1
- package/build/commands/update.d.ts +1 -1
- package/build/commands/update.d.ts.map +1 -1
- package/build/commands/update.js +1 -1
- package/build/commands/update.js.map +1 -1
- package/build/commands/upgrade.d.ts +16 -0
- package/build/commands/upgrade.d.ts.map +1 -0
- package/build/commands/upgrade.js +64 -0
- package/build/commands/upgrade.js.map +1 -0
- package/build/commands/why.d.ts.map +1 -1
- package/build/commands/why.js +28 -7
- package/build/commands/why.js.map +1 -1
- package/build/components/DiffView.d.ts +3 -1
- package/build/components/DiffView.d.ts.map +1 -1
- package/build/components/DiffView.js +18 -4
- package/build/components/DiffView.js.map +1 -1
- package/build/components/EnabledEntriesHint.d.ts +14 -0
- package/build/components/EnabledEntriesHint.d.ts.map +1 -0
- package/build/components/EnabledEntriesHint.js +13 -0
- package/build/components/EnabledEntriesHint.js.map +1 -0
- package/build/components/InitSuccess.d.ts.map +1 -1
- package/build/components/InitSuccess.js +4 -1
- package/build/components/InitSuccess.js.map +1 -1
- package/build/components/InstallSummary.d.ts +7 -2
- package/build/components/InstallSummary.d.ts.map +1 -1
- package/build/components/InstallSummary.js +3 -1
- package/build/components/InstallSummary.js.map +1 -1
- package/build/components/LeftoverFilesHint.d.ts +21 -0
- package/build/components/LeftoverFilesHint.d.ts.map +1 -0
- package/build/components/LeftoverFilesHint.js +13 -0
- package/build/components/LeftoverFilesHint.js.map +1 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +2 -0
- package/build/components/index.js.map +1 -1
- package/build/hooks/useInitState.d.ts +9 -1
- package/build/hooks/useInitState.d.ts.map +1 -1
- package/build/hooks/useInitState.js +52 -10
- package/build/hooks/useInitState.js.map +1 -1
- package/build/hooks/useListActions.d.ts.map +1 -1
- package/build/hooks/useListActions.js +4 -1
- package/build/hooks/useListActions.js.map +1 -1
- package/build/hooks/useUninstallState.d.ts.map +1 -1
- package/build/hooks/useUninstallState.js +46 -23
- package/build/hooks/useUninstallState.js.map +1 -1
- package/build/lib/adapter.d.ts +14 -9
- package/build/lib/adapter.d.ts.map +1 -1
- package/build/lib/adapter.js +46 -8
- package/build/lib/adapter.js.map +1 -1
- package/build/lib/api-client.d.ts.map +1 -1
- package/build/lib/api-client.js +2 -1
- package/build/lib/api-client.js.map +1 -1
- package/build/lib/asset-tools.d.ts +8 -0
- package/build/lib/asset-tools.d.ts.map +1 -1
- package/build/lib/asset-tools.js +14 -0
- package/build/lib/asset-tools.js.map +1 -1
- package/build/lib/completion/candidates.d.ts.map +1 -1
- package/build/lib/completion/candidates.js +21 -8
- package/build/lib/completion/candidates.js.map +1 -1
- package/build/lib/config-entries.d.ts +3 -3
- package/build/lib/config-entries.d.ts.map +1 -1
- package/build/lib/config-entries.js +16 -6
- package/build/lib/config-entries.js.map +1 -1
- package/build/lib/config-lock.d.ts +2 -1
- package/build/lib/config-lock.d.ts.map +1 -1
- package/build/lib/config-lock.js +10 -2
- package/build/lib/config-lock.js.map +1 -1
- package/build/lib/cross-scope.d.ts +6 -2
- package/build/lib/cross-scope.d.ts.map +1 -1
- package/build/lib/cross-scope.js +20 -13
- package/build/lib/cross-scope.js.map +1 -1
- package/build/lib/diagnostics.d.ts +3 -2
- package/build/lib/diagnostics.d.ts.map +1 -1
- package/build/lib/diagnostics.js +11 -11
- package/build/lib/diagnostics.js.map +1 -1
- package/build/lib/diff-command.d.ts +9 -3
- package/build/lib/diff-command.d.ts.map +1 -1
- package/build/lib/diff-command.js +58 -21
- package/build/lib/diff-command.js.map +1 -1
- package/build/lib/diff.d.ts +8 -4
- package/build/lib/diff.d.ts.map +1 -1
- package/build/lib/diff.js +23 -4
- package/build/lib/diff.js.map +1 -1
- package/build/lib/doctor-fix.d.ts +8 -3
- package/build/lib/doctor-fix.d.ts.map +1 -1
- package/build/lib/doctor-fix.js +50 -3
- package/build/lib/doctor-fix.js.map +1 -1
- package/build/lib/enabled-list.d.ts +7 -3
- package/build/lib/enabled-list.d.ts.map +1 -1
- package/build/lib/enabled-list.js +7 -5
- package/build/lib/enabled-list.js.map +1 -1
- package/build/lib/gitignore.d.ts +8 -0
- package/build/lib/gitignore.d.ts.map +1 -1
- package/build/lib/gitignore.js +51 -6
- package/build/lib/gitignore.js.map +1 -1
- package/build/lib/hook-config.d.ts +90 -7
- package/build/lib/hook-config.d.ts.map +1 -1
- package/build/lib/hook-config.js +135 -11
- package/build/lib/hook-config.js.map +1 -1
- package/build/lib/hook-script.d.ts +45 -0
- package/build/lib/hook-script.d.ts.map +1 -1
- package/build/lib/hook-script.js +118 -1
- package/build/lib/hook-script.js.map +1 -1
- package/build/lib/init.d.ts +34 -12
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +180 -32
- package/build/lib/init.js.map +1 -1
- package/build/lib/install-targets.d.ts +20 -6
- package/build/lib/install-targets.d.ts.map +1 -1
- package/build/lib/install-targets.js +65 -8
- package/build/lib/install-targets.js.map +1 -1
- package/build/lib/installer.d.ts +15 -5
- package/build/lib/installer.d.ts.map +1 -1
- package/build/lib/installer.js +201 -41
- package/build/lib/installer.js.map +1 -1
- package/build/lib/local-edits.d.ts +15 -2
- package/build/lib/local-edits.d.ts.map +1 -1
- package/build/lib/local-edits.js +40 -13
- package/build/lib/local-edits.js.map +1 -1
- package/build/lib/lockfile.d.ts +2 -2
- package/build/lib/lockfile.js +4 -4
- package/build/lib/lockfile.js.map +1 -1
- package/build/lib/mover.d.ts +5 -4
- package/build/lib/mover.d.ts.map +1 -1
- package/build/lib/mover.js +43 -35
- package/build/lib/mover.js.map +1 -1
- package/build/lib/multi-tool-install.d.ts +28 -5
- package/build/lib/multi-tool-install.d.ts.map +1 -1
- package/build/lib/multi-tool-install.js +105 -26
- package/build/lib/multi-tool-install.js.map +1 -1
- package/build/lib/named-entry.d.ts +12 -0
- package/build/lib/named-entry.d.ts.map +1 -1
- package/build/lib/named-entry.js +16 -8
- package/build/lib/named-entry.js.map +1 -1
- package/build/lib/notices.d.ts +2 -0
- package/build/lib/notices.d.ts.map +1 -1
- package/build/lib/notices.js +10 -0
- package/build/lib/notices.js.map +1 -1
- package/build/lib/schemas/adapter.d.ts +33 -0
- package/build/lib/schemas/adapter.d.ts.map +1 -1
- package/build/lib/schemas/adapter.js +31 -5
- package/build/lib/schemas/adapter.js.map +1 -1
- package/build/lib/self-upgrade.d.ts +66 -0
- package/build/lib/self-upgrade.d.ts.map +1 -0
- package/build/lib/self-upgrade.js +183 -0
- package/build/lib/self-upgrade.js.map +1 -0
- package/build/lib/sync.d.ts +39 -0
- package/build/lib/sync.d.ts.map +1 -1
- package/build/lib/sync.js +181 -10
- package/build/lib/sync.js.map +1 -1
- package/build/lib/touched-paths.d.ts.map +1 -1
- package/build/lib/touched-paths.js +2 -1
- package/build/lib/touched-paths.js.map +1 -1
- package/build/lib/uninstaller.d.ts +29 -1
- package/build/lib/uninstaller.d.ts.map +1 -1
- package/build/lib/uninstaller.js +99 -5
- package/build/lib/uninstaller.js.map +1 -1
- package/build/lib/update-check.d.ts +27 -1
- package/build/lib/update-check.d.ts.map +1 -1
- package/build/lib/update-check.js +74 -8
- package/build/lib/update-check.js.map +1 -1
- package/build/lib/updater.d.ts +2 -0
- package/build/lib/updater.d.ts.map +1 -1
- package/build/lib/updater.js +36 -3
- package/build/lib/updater.js.map +1 -1
- package/build/lib/version.d.ts +12 -4
- package/build/lib/version.d.ts.map +1 -1
- package/build/lib/version.js +19 -7
- package/build/lib/version.js.map +1 -1
- package/package.json +1 -1
- package/tool-adapters/claude-code.json +2 -1
- package/tool-adapters/codex-cli.json +5 -1
- package/tool-adapters/copilot-cli.json +58 -9
package/build/lib/hook-script.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
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 { hookCommand, hookGroupOwnsCommand, placementForEntrypoint } from './hook-config.js';
|
|
6
|
+
import { fromRoot } from './root-path.js';
|
|
2
7
|
/**
|
|
3
8
|
* Project-relative path of the script a hook placement registers as its command, or
|
|
4
9
|
* undefined when the tool does not run the installed file directly.
|
|
@@ -14,6 +19,51 @@ import { access, chmod, constants, stat } from 'node:fs/promises';
|
|
|
14
19
|
export function hookScriptPath(placement, assetName) {
|
|
15
20
|
return placement?.configHookMerge ? placement.path.replace(/\{name\}/g, assetName) : undefined;
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the file at `path` is the hook file ATK generates for hook `name` (Copilot CLI's
|
|
24
|
+
* `.github/hooks/{name}.json`): readable config holding nothing but the hook's own entries, each
|
|
25
|
+
* owned by one of `recorded` (the commands the asset's lockfile entries recorded for the tool, which
|
|
26
|
+
* may be an older CLI's) or by a command the placement's scripts register for the hook now (`.sh`,
|
|
27
|
+
* or `.mjs` run with node). Another hook's entry, or one the user wrote, makes it someone else's.
|
|
28
|
+
* `placement` is the adapter's hook placement, not one resolved for an entrypoint.
|
|
29
|
+
*/
|
|
30
|
+
export async function isGeneratedHookFile(placement, name, path, recorded = []) {
|
|
31
|
+
if (!placement?.configHookMerge || !placement.configKey || !existsSync(path))
|
|
32
|
+
return false;
|
|
33
|
+
let config;
|
|
34
|
+
try {
|
|
35
|
+
config = await readConfigFile(path, resolveConfigFormat(path, placement));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const commands = [
|
|
41
|
+
...recorded,
|
|
42
|
+
hookCommand(placement, name),
|
|
43
|
+
...(placement.nodeEntrypoint ? [hookCommand(placementForEntrypoint(placement, `${name}.mjs`), name)] : []),
|
|
44
|
+
];
|
|
45
|
+
const { [placement.configKey]: section, ...rest } = config;
|
|
46
|
+
if (Object.keys(rest).some((key) => key !== 'version'))
|
|
47
|
+
return false;
|
|
48
|
+
if (section === undefined)
|
|
49
|
+
return true;
|
|
50
|
+
if (!section || typeof section !== 'object' || Array.isArray(section))
|
|
51
|
+
return false;
|
|
52
|
+
return Object.values(section).every((groups) => Array.isArray(groups) &&
|
|
53
|
+
groups.every((group) => commands.some((command) => hookGroupOwnsCommand(group, command))));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The absolute path a hook whose `entrypoint` is the tool's own hook JSON is placed at, when the
|
|
57
|
+
* adapter's hook `placement` writes a script version's hook file there too (Copilot CLI's
|
|
58
|
+
* `.github/hooks/{name}.json`), or undefined for any other hook or placement.
|
|
59
|
+
*/
|
|
60
|
+
export function jsonHookFilePath(placement, entrypoint, name, projectDir) {
|
|
61
|
+
const template = placement?.jsonEntrypoint?.path;
|
|
62
|
+
if (!template || !placement.configHookMerge || placement.configFile !== template || !entrypoint?.endsWith('.json')) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return fromRoot(projectDir, template.replace(/\{name\}/g, name));
|
|
66
|
+
}
|
|
17
67
|
/**
|
|
18
68
|
* True when the file exists but the current user cannot execute it. Always false on
|
|
19
69
|
* Windows, which has no exec bit, and for a missing file (checksum checks report that).
|
|
@@ -31,6 +81,27 @@ export async function lacksExecBit(filePath, platform = process.platform) {
|
|
|
31
81
|
return true;
|
|
32
82
|
}
|
|
33
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The scripts the adapter's hook `placement` places for hook `name` (`{name}.sh`, and `{name}.mjs`
|
|
86
|
+
* for an ES module) that hold a file of the hook: the bytes of a file the given entries of the asset
|
|
87
|
+
* recorded or, with `published`, of a file a published version of it shipped. Under a version whose
|
|
88
|
+
* entrypoint is the tool's own hook JSON, those that version doesn't place itself beside the JSON
|
|
89
|
+
* are what a script version left (ATK-818); the caller leaves out the ones it places. Anything else
|
|
90
|
+
* at those paths stays. Absolute paths.
|
|
91
|
+
*/
|
|
92
|
+
export async function leftoverHookScripts(placement, name, installed, projectDir, published) {
|
|
93
|
+
if (!placement?.configHookMerge)
|
|
94
|
+
return [];
|
|
95
|
+
const leftovers = [];
|
|
96
|
+
for (const template of [placement.path, placement.nodeEntrypoint?.path]) {
|
|
97
|
+
const path = template && fromRoot(projectDir, template.replace(/\{name\}/g, name));
|
|
98
|
+
if (!path || !existsSync(path))
|
|
99
|
+
continue;
|
|
100
|
+
if (await holdsHookFile(await readFile(path), installed, published))
|
|
101
|
+
leftovers.push(path);
|
|
102
|
+
}
|
|
103
|
+
return leftovers;
|
|
104
|
+
}
|
|
34
105
|
/**
|
|
35
106
|
* Add an exec bit wherever the file has a read bit, like `chmod +x` under the user's
|
|
36
107
|
* umask: 644 becomes 755 and 600 becomes 700. The registry stores scripts as 644 and the
|
|
@@ -45,4 +116,50 @@ export async function makeExecutable(filePath, platform = process.platform) {
|
|
|
45
116
|
await chmod(filePath, executable);
|
|
46
117
|
}
|
|
47
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The absolute path of a file of the hook at the path of its own config file (Copilot CLI's
|
|
121
|
+
* `.github/hooks/{name}.json`), which the hook file is written to in its place, or undefined when
|
|
122
|
+
* there is none:
|
|
123
|
+
* - the copy of the hook's script that a CLI before ATK-204 saved there, which the tool can't read
|
|
124
|
+
* as config: it holds the bytes of a file the given entries of the asset recorded, or is a script
|
|
125
|
+
* (`#!`), which no config file starts with (the lockfile may already record a newer version);
|
|
126
|
+
* - with `json`, the hook's own JSON, which a version whose entrypoint it is placed there as it is
|
|
127
|
+
* (ATK-818): it holds the bytes of a recorded file or of a file a published version shipped,
|
|
128
|
+
* since a sync over a lockfile a teammate's update wrote has no record of it. ATK's own hook file,
|
|
129
|
+
* by its current commands or the ones `json.recorded` names, is not one, and neither is config
|
|
130
|
+
* with anything else in it: the hook's entries are merged into both.
|
|
131
|
+
* `placement` is the adapter's hook placement, not one resolved for an entrypoint.
|
|
132
|
+
*/
|
|
133
|
+
export async function misplacedHookCopy(placement, name, installed, projectDir, json) {
|
|
134
|
+
if (!placement?.configHookMerge || !placement.configFile?.includes('{name}'))
|
|
135
|
+
return undefined;
|
|
136
|
+
const path = fromRoot(projectDir, placement.configFile.replace(/\{name\}/g, name));
|
|
137
|
+
if (!existsSync(path))
|
|
138
|
+
return undefined;
|
|
139
|
+
const content = await readFile(path);
|
|
140
|
+
try {
|
|
141
|
+
await readConfigFile(path, resolveConfigFormat(path, placement));
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// Not config: maybe the misplaced copy of the script.
|
|
145
|
+
if (!installed.some(Boolean))
|
|
146
|
+
return undefined;
|
|
147
|
+
return (await holdsHookFile(content, installed)) || content.subarray(0, 2).toString() === '#!' ? path : undefined;
|
|
148
|
+
}
|
|
149
|
+
if (!json)
|
|
150
|
+
return undefined;
|
|
151
|
+
if (await holdsHookFile(content, installed))
|
|
152
|
+
return path;
|
|
153
|
+
// ATK's own hook file needs no published check.
|
|
154
|
+
if (await isGeneratedHookFile(placement, name, path, json.recorded))
|
|
155
|
+
return undefined;
|
|
156
|
+
return (await json.published(content)) ? path : undefined;
|
|
157
|
+
}
|
|
158
|
+
/** Whether `content` is a file one of `installed` recorded or, with `published`, a published one. */
|
|
159
|
+
async function holdsHookFile(content, installed, published) {
|
|
160
|
+
const checksum = hashBytes(content);
|
|
161
|
+
if (installed.some((entry) => entry?.files.some((f) => f.checksum === checksum)))
|
|
162
|
+
return true;
|
|
163
|
+
return published ? published(content) : false;
|
|
164
|
+
}
|
|
48
165
|
//# sourceMappingURL=hook-script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-script.js","sourceRoot":"","sources":["../../src/lib/hook-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"hook-script.js","sourceRoot":"","sources":["../../src/lib/hook-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK5E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,SAAsC,EAAE,SAAiB;IACtF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,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5D,CAAC;AAED,qGAAqG;AACrG,KAAK,UAAU,aAAa,CAC1B,OAAmB,EACnB,SAA2D,EAC3D,SAA0B;IAE1B,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9F,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChD,CAAC"}
|
package/build/lib/init.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Adapter } from './schemas/adapter.js';
|
|
2
|
-
import type { AssetDependency, BundleAssetRef, Registry } from './schemas/index.js';
|
|
2
|
+
import type { AssetDependency, BundleAssetRef, HookConfig, Registry } from './schemas/index.js';
|
|
3
3
|
import type { Lockfile } from './schemas/lockfile.js';
|
|
4
4
|
import { AssetType } from './schemas/index.js';
|
|
5
5
|
/**
|
|
@@ -30,8 +30,15 @@ export interface InitOptions {
|
|
|
30
30
|
dependencies?: AssetDependency[];
|
|
31
31
|
/** Short description. */
|
|
32
32
|
description: string;
|
|
33
|
+
/** The forked asset's entrypoint; a hook forked from an ES module takes `<name>.mjs` as its own. */
|
|
34
|
+
forkEntrypoint?: string;
|
|
33
35
|
/** Fork from an existing installed asset. */
|
|
34
36
|
from?: string;
|
|
37
|
+
/**
|
|
38
|
+
* A hook's event bindings, from the hook it forks (its tools' config for a local path, the registry for an
|
|
39
|
+
* installed hook); without them, a hook gets a single `Stop` binding.
|
|
40
|
+
*/
|
|
41
|
+
hookConfig?: HookConfig;
|
|
35
42
|
/** Asset name (kebab-case). */
|
|
36
43
|
name: string;
|
|
37
44
|
/** Skip registry name availability check. */
|
|
@@ -75,11 +82,14 @@ export declare function checkNameAvailability(name: string, type: InitType, regi
|
|
|
75
82
|
*/
|
|
76
83
|
export declare function detectCompatibleTools(assetType: InitType): Promise<string[]>;
|
|
77
84
|
/**
|
|
78
|
-
* Look up
|
|
79
|
-
* Returns the manifest data
|
|
80
|
-
*
|
|
85
|
+
* Look up the installed asset `--from <fromSpec>` names ({@link findForkSource}) and read its files from disk.
|
|
86
|
+
* Returns the manifest data, file contents and the entrypoint its lockfile entry records (an older
|
|
87
|
+
* entry has none) for pre-filling a new scaffold. A hook forked into a hook (`forType`) also gets
|
|
88
|
+
* its installed version's `hookConfig` from the registry.
|
|
89
|
+
* Returns undefined if nothing of that name is installed.
|
|
81
90
|
*/
|
|
82
|
-
export declare function forkFromInstalled(
|
|
91
|
+
export declare function forkFromInstalled(fromSpec: string, lockfile: Lockfile, adapter: Adapter, projectDir: string, forType?: InitType): Promise<undefined | {
|
|
92
|
+
entrypoint?: string;
|
|
83
93
|
files: Map<string, string>;
|
|
84
94
|
manifest: Record<string, unknown>;
|
|
85
95
|
}>;
|
|
@@ -102,8 +112,9 @@ export declare function forkFromLocal(fromPath: string, assetType: InitType): Pr
|
|
|
102
112
|
/**
|
|
103
113
|
* Generate minimal stub content for an asset entrypoint file.
|
|
104
114
|
* Returns an empty string for types that have no entrypoint (mcp-config, bundle).
|
|
115
|
+
* A hook whose entrypoint is an ES module (`forkEntrypoint`) gets a node stub.
|
|
105
116
|
*/
|
|
106
|
-
export declare function generateEntrypointContent(type: InitType, name: string, description: string): string;
|
|
117
|
+
export declare function generateEntrypointContent(type: InitType, name: string, description: string, forkEntrypoint?: string): string;
|
|
107
118
|
/**
|
|
108
119
|
* Generate a manifest JSON object for the given init options.
|
|
109
120
|
* Produces a manifest.json structure for assets or bundle.json structure for bundles.
|
|
@@ -111,14 +122,16 @@ export declare function generateEntrypointContent(type: InitType, name: string,
|
|
|
111
122
|
export declare function generateManifest(options: InitOptions): Record<string, unknown>;
|
|
112
123
|
/**
|
|
113
124
|
* Generate README.md content for an asset.
|
|
114
|
-
* Includes type-specific sections for hooks and MCP configs.
|
|
125
|
+
* Includes type-specific sections for hooks and MCP configs. A hook's example shows `command`,
|
|
126
|
+
* the command installing it into Claude Code registers, or its `.sh` script's without one.
|
|
115
127
|
*/
|
|
116
|
-
export declare function generateReadmeContent(type: InitType, name: string, description: string): string;
|
|
128
|
+
export declare function generateReadmeContent(type: InitType, name: string, description: string, command?: string): string;
|
|
117
129
|
/**
|
|
118
130
|
* Get the entrypoint filename for a given asset type and name.
|
|
119
131
|
* Returns undefined for fileless types (mcp-config) and bundles.
|
|
132
|
+
* A hook forked from an ES module (`forkEntrypoint`) gets `<name>.mjs`, which the placements run with node.
|
|
120
133
|
*/
|
|
121
|
-
export declare function getEntrypointName(type: InitType, name: string): string | undefined;
|
|
134
|
+
export declare function getEntrypointName(type: InitType, name: string, forkEntrypoint?: string): string | undefined;
|
|
122
135
|
/**
|
|
123
136
|
* The signed-in caller's display name (falling back to their login) from the
|
|
124
137
|
* ATK API's `GET /me`, used to pre-fill the author. Returns undefined when not
|
|
@@ -126,9 +139,10 @@ export declare function getEntrypointName(type: InitType, name: string): string
|
|
|
126
139
|
*/
|
|
127
140
|
export declare function getSignedInUserName(): Promise<string | undefined>;
|
|
128
141
|
/**
|
|
129
|
-
* Returns true if the value looks like a filesystem path rather than
|
|
130
|
-
*
|
|
131
|
-
* `\`, or `.` characters — none of which appear in valid asset names
|
|
142
|
+
* Returns true if the value looks like a filesystem path rather than an
|
|
143
|
+
* installed asset's `[type:][@org/]name`. A value is considered a path if it contains `/`,
|
|
144
|
+
* `\`, or `.` characters — none of which appear in valid asset names — other than the `/`
|
|
145
|
+
* of an `@org/` scope.
|
|
132
146
|
*/
|
|
133
147
|
export declare function isLocalPath(value: string): boolean;
|
|
134
148
|
/**
|
|
@@ -159,6 +173,14 @@ export declare function parseDependencyFlags(values: readonly string[]): {
|
|
|
159
173
|
dependencies?: never;
|
|
160
174
|
error: string;
|
|
161
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* Split an optional `<asset type>:` prefix off a `--from` value: `hook:@acme/x` names @acme's hook `x`.
|
|
178
|
+
* A prefix that isn't an asset type (`global:`, a drive letter) stays part of the name.
|
|
179
|
+
*/
|
|
180
|
+
export declare function parseForkSpec(value: string): {
|
|
181
|
+
spec: string;
|
|
182
|
+
type?: AssetType;
|
|
183
|
+
};
|
|
162
184
|
/**
|
|
163
185
|
* Scaffold a new asset or bundle directory with manifest and starter files.
|
|
164
186
|
*
|
package/build/lib/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/lib/init.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/lib/init.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAkB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAetE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C;;;;GAIG;AACH,eAAO,MAAM,eAAe,oDAAoD,CAAC;AAEjF,eAAO,MAAM,UAAU,wFAAyF,CAAC;AAMjH,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,C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,0BAA0B,CACxC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GACnH;IAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CA0CtD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CA+ClF"}
|
package/build/lib/init.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { mkdir, readFile, stat } from 'node:fs/promises';
|
|
2
|
-
import { basename, extname, join, resolve } from 'node:path';
|
|
2
|
+
import { basename, dirname, extname, join, resolve } from 'node:path';
|
|
3
3
|
import { validRange } from 'semver';
|
|
4
4
|
import { getPlacement, loadAdapter, loadAllAdapters, resolveInstalledPaths } from './adapter.js';
|
|
5
5
|
import { callApi } from './api-client.js';
|
|
6
6
|
import { collectFilesRecursive } from './checksum.js';
|
|
7
7
|
import { parseConfig, resolveConfigFormat } from './config-file.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { asSentence, errorMessage } from './errors.js';
|
|
9
|
+
import { hookCommand, isNodeHookEntrypoint, placementForEntrypoint } from './hook-config.js';
|
|
10
|
+
import { LockfileError } from './lockfile.js';
|
|
11
|
+
import { entrySpec, lookupNamedEntry } from './named-entry.js';
|
|
12
|
+
import { addNotice } from './notices.js';
|
|
13
|
+
import { formatOrgName, parseNameScope, parseOrgFromName } from './org.js';
|
|
10
14
|
import { findProjectRoot } from './paths.js';
|
|
11
|
-
import { filterVisibleAssets, isLatestAlias } from './registry.js';
|
|
15
|
+
import { fetchRegistry, filterVisibleAssets, isLatestAlias, versionHookConfig } from './registry.js';
|
|
12
16
|
import { fromRoot } from './root-path.js';
|
|
13
17
|
import { AssetType } from './schemas/index.js';
|
|
14
18
|
import { searchRegistry } from './search.js';
|
|
@@ -70,13 +74,14 @@ export async function detectCompatibleTools(assetType) {
|
|
|
70
74
|
// Fork from installed asset
|
|
71
75
|
// ---------------------------------------------------------------------------
|
|
72
76
|
/**
|
|
73
|
-
* Look up
|
|
74
|
-
* Returns the manifest data
|
|
75
|
-
*
|
|
77
|
+
* Look up the installed asset `--from <fromSpec>` names ({@link findForkSource}) and read its files from disk.
|
|
78
|
+
* Returns the manifest data, file contents and the entrypoint its lockfile entry records (an older
|
|
79
|
+
* entry has none) for pre-filling a new scaffold. A hook forked into a hook (`forType`) also gets
|
|
80
|
+
* its installed version's `hookConfig` from the registry.
|
|
81
|
+
* Returns undefined if nothing of that name is installed.
|
|
76
82
|
*/
|
|
77
|
-
export async function forkFromInstalled(
|
|
78
|
-
|
|
79
|
-
const installed = (lockfile.assets ?? []).find((a) => a.name === fromName);
|
|
83
|
+
export async function forkFromInstalled(fromSpec, lockfile, adapter, projectDir, forType) {
|
|
84
|
+
const installed = findForkSource(lockfile, fromSpec, forType);
|
|
80
85
|
if (!installed) {
|
|
81
86
|
return undefined;
|
|
82
87
|
}
|
|
@@ -102,7 +107,13 @@ export async function forkFromInstalled(fromName, lockfile, adapter, projectDir)
|
|
|
102
107
|
type: installed.type,
|
|
103
108
|
version: installed.version,
|
|
104
109
|
};
|
|
105
|
-
|
|
110
|
+
// The lockfile doesn't record a hook's events; the registry does, for the installed version.
|
|
111
|
+
if (installed.type === 'hook' && forType === 'hook') {
|
|
112
|
+
const hookConfig = await installedHookConfig(installed);
|
|
113
|
+
if (hookConfig)
|
|
114
|
+
manifest.hookConfig = hookConfig;
|
|
115
|
+
}
|
|
116
|
+
return { ...(installed.entrypoint ? { entrypoint: installed.entrypoint } : {}), files, manifest };
|
|
106
117
|
}
|
|
107
118
|
// ---------------------------------------------------------------------------
|
|
108
119
|
// Local path detection
|
|
@@ -177,6 +188,7 @@ export async function forkFromLocal(fromPath, assetType) {
|
|
|
177
188
|
// --- Hook special case: reconstruct hookConfig from valid tool config ---
|
|
178
189
|
// Scan the config section's event arrays for a group whose command references
|
|
179
190
|
// this asset's script, and recover the { matcher?, timeout? } binding per event.
|
|
191
|
+
const hookConfig = {};
|
|
180
192
|
if (placement.configHookMerge && placement.configFile && placement.configKey) {
|
|
181
193
|
try {
|
|
182
194
|
const projectRoot = findProjectRoot();
|
|
@@ -185,7 +197,6 @@ export async function forkFromLocal(fromPath, assetType) {
|
|
|
185
197
|
const settings = parseConfig(settingsRaw, resolveConfigFormat(settingsPath, placement));
|
|
186
198
|
const section = settings[placement.configKey];
|
|
187
199
|
if (section && typeof section === 'object' && !Array.isArray(section)) {
|
|
188
|
-
const hookConfig = {};
|
|
189
200
|
// An `.mjs` hook is registered as its placement's node command, which names the script mid-string.
|
|
190
201
|
const nodeCommand = placement.nodeEntrypoint
|
|
191
202
|
? hookCommand(placementForEntrypoint(placement, `${derivedName}.mjs`), derivedName)
|
|
@@ -214,15 +225,23 @@ export async function forkFromLocal(fromPath, assetType) {
|
|
|
214
225
|
hookConfig[event] = binding;
|
|
215
226
|
}
|
|
216
227
|
}
|
|
217
|
-
if (Object.keys(hookConfig).length > 0) {
|
|
218
|
-
manifest.hookConfig = hookConfig;
|
|
219
|
-
}
|
|
220
228
|
}
|
|
221
229
|
}
|
|
222
230
|
catch {
|
|
223
231
|
// Settings file not found or not parseable — skip hook config extraction
|
|
224
232
|
}
|
|
225
233
|
}
|
|
234
|
+
// A hook written for Copilot CLI first has its hook file beside the script. It adds the events the
|
|
235
|
+
// Claude Code config doesn't bind; an event both bind keeps Claude Code's binding, which can carry a
|
|
236
|
+
// matcher, and takes the Copilot timeout only when Claude Code's has none.
|
|
237
|
+
if (assetType === 'hook' && stats.isFile() && extname(resolvedPath) !== '.json') {
|
|
238
|
+
for (const [event, binding] of Object.entries(await copilotHookConfig(resolvedPath, derivedName))) {
|
|
239
|
+
hookConfig[event] = { ...binding, ...hookConfig[event] };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (Object.keys(hookConfig).length > 0) {
|
|
243
|
+
manifest.hookConfig = hookConfig;
|
|
244
|
+
}
|
|
226
245
|
return { files, manifest };
|
|
227
246
|
}
|
|
228
247
|
// ---------------------------------------------------------------------------
|
|
@@ -231,8 +250,9 @@ export async function forkFromLocal(fromPath, assetType) {
|
|
|
231
250
|
/**
|
|
232
251
|
* Generate minimal stub content for an asset entrypoint file.
|
|
233
252
|
* Returns an empty string for types that have no entrypoint (mcp-config, bundle).
|
|
253
|
+
* A hook whose entrypoint is an ES module (`forkEntrypoint`) gets a node stub.
|
|
234
254
|
*/
|
|
235
|
-
export function generateEntrypointContent(type, name, description) {
|
|
255
|
+
export function generateEntrypointContent(type, name, description, forkEntrypoint) {
|
|
236
256
|
const displayName = toDisplayName(name);
|
|
237
257
|
switch (type) {
|
|
238
258
|
case 'agent':
|
|
@@ -244,7 +264,9 @@ export function generateEntrypointContent(type, name, description) {
|
|
|
244
264
|
case 'mcp-config':
|
|
245
265
|
return '';
|
|
246
266
|
case 'hook':
|
|
247
|
-
return
|
|
267
|
+
return isNodeHookEntrypoint(forkEntrypoint)
|
|
268
|
+
? `// ${displayName} - ${description}\n\n// TODO: Implement hook logic\n`
|
|
269
|
+
: `#!/usr/bin/env bash\n# ${displayName} - ${description}\n\nset -euo pipefail\n\n# TODO: Implement hook logic\n`;
|
|
248
270
|
}
|
|
249
271
|
}
|
|
250
272
|
/**
|
|
@@ -272,7 +294,7 @@ export function generateManifest(options) {
|
|
|
272
294
|
};
|
|
273
295
|
return bundleManifest;
|
|
274
296
|
}
|
|
275
|
-
const entrypoint = getEntrypointName(options.type, plainName);
|
|
297
|
+
const entrypoint = getEntrypointName(options.type, plainName, options.forkEntrypoint);
|
|
276
298
|
const manifest = {
|
|
277
299
|
$schema: `${SCHEMA_BASE_URL}/manifest.schema.json`,
|
|
278
300
|
author: options.author,
|
|
@@ -280,7 +302,7 @@ export function generateManifest(options) {
|
|
|
280
302
|
description: options.description,
|
|
281
303
|
...(entrypoint ? { entrypoint } : {}),
|
|
282
304
|
files: 'auto',
|
|
283
|
-
...(options.type === 'hook' ? { hookConfig: { Stop: {} } } : {}),
|
|
305
|
+
...(options.type === 'hook' ? { hookConfig: options.hookConfig ?? { Stop: {} } } : {}),
|
|
284
306
|
name: plainName,
|
|
285
307
|
...(org ? { org } : {}),
|
|
286
308
|
tags: options.tags,
|
|
@@ -292,13 +314,14 @@ export function generateManifest(options) {
|
|
|
292
314
|
}
|
|
293
315
|
/**
|
|
294
316
|
* Generate README.md content for an asset.
|
|
295
|
-
* Includes type-specific sections for hooks and MCP configs.
|
|
317
|
+
* Includes type-specific sections for hooks and MCP configs. A hook's example shows `command`,
|
|
318
|
+
* the command installing it into Claude Code registers, or its `.sh` script's without one.
|
|
296
319
|
*/
|
|
297
|
-
export function generateReadmeContent(type, name, description) {
|
|
320
|
+
export function generateReadmeContent(type, name, description, command = `: "$(exit 0)"; exec "$CLAUDE_PROJECT_DIR"/.claude/hooks/${name}.sh`) {
|
|
298
321
|
const displayName = toDisplayName(name);
|
|
299
322
|
let content = `# ${displayName}\n\n${description}\n\n## Usage\n\n<!-- Describe how to use this asset -->\n\n## Configuration\n\n<!-- Describe any configuration options -->\n`;
|
|
300
323
|
if (type === 'hook') {
|
|
301
|
-
content += `\n## Hook Configuration\n\nDeclare the hook event bindings in \`manifest.json\` via the \`hookConfig\` field (event name → optional \`matcher\`/\`timeout\`). On install, ATK derives the command from the installed script path and writes valid tool config.\n\n\`\`\`json\n// manifest.json\n"hookConfig": {\n "Stop": {}\n}\n\`\`\`\n\nInstalling into Claude Code produces the following in \`.claude/settings.json\`:\n\n\`\`\`json\n{\n "hooks": {\n "Stop": [\n {\n "hooks": [\n { "type": "command", "command":
|
|
324
|
+
content += `\n## Hook Configuration\n\nDeclare the hook event bindings in \`manifest.json\` via the \`hookConfig\` field (event name → optional \`matcher\`/\`timeout\`). On install, ATK derives the command from the installed script path and writes valid tool config.\n\n\`\`\`json\n// manifest.json\n"hookConfig": {\n "Stop": {}\n}\n\`\`\`\n\nInstalling into Claude Code produces the following in \`.claude/settings.json\`:\n\n\`\`\`json\n{\n "hooks": {\n "Stop": [\n {\n "hooks": [\n { "type": "command", "command": ${JSON.stringify(command)} }\n ]\n }\n ]\n }\n}\n\`\`\`\n`;
|
|
302
325
|
}
|
|
303
326
|
if (type === 'mcp-config') {
|
|
304
327
|
content += `\n## MCP Server Configuration\n\nThis asset registers the following MCP server configuration:\n\n\`\`\`json\n{\n "mcpServers": {\n "${name}": {\n "command": "npx",\n "args": ["-y", "${name}"]\n }\n }\n}\n\`\`\`\n`;
|
|
@@ -311,15 +334,16 @@ export function generateReadmeContent(type, name, description) {
|
|
|
311
334
|
/**
|
|
312
335
|
* Get the entrypoint filename for a given asset type and name.
|
|
313
336
|
* Returns undefined for fileless types (mcp-config) and bundles.
|
|
337
|
+
* A hook forked from an ES module (`forkEntrypoint`) gets `<name>.mjs`, which the placements run with node.
|
|
314
338
|
*/
|
|
315
|
-
export function getEntrypointName(type, name) {
|
|
339
|
+
export function getEntrypointName(type, name, forkEntrypoint) {
|
|
316
340
|
switch (type) {
|
|
317
341
|
case 'agent':
|
|
318
342
|
return `${name}.md`;
|
|
319
343
|
case 'bundle':
|
|
320
344
|
return undefined;
|
|
321
345
|
case 'hook':
|
|
322
|
-
return `${name}.sh`;
|
|
346
|
+
return isNodeHookEntrypoint(forkEntrypoint) ? `${name}.mjs` : `${name}.sh`;
|
|
323
347
|
case 'mcp-config':
|
|
324
348
|
return undefined;
|
|
325
349
|
case 'memory-template':
|
|
@@ -352,12 +376,16 @@ export async function getSignedInUserName() {
|
|
|
352
376
|
// README generation
|
|
353
377
|
// ---------------------------------------------------------------------------
|
|
354
378
|
/**
|
|
355
|
-
* Returns true if the value looks like a filesystem path rather than
|
|
356
|
-
*
|
|
357
|
-
* `\`, or `.` characters — none of which appear in valid asset names
|
|
379
|
+
* Returns true if the value looks like a filesystem path rather than an
|
|
380
|
+
* installed asset's `[type:][@org/]name`. A value is considered a path if it contains `/`,
|
|
381
|
+
* `\`, or `.` characters — none of which appear in valid asset names — other than the `/`
|
|
382
|
+
* of an `@org/` scope.
|
|
358
383
|
*/
|
|
359
384
|
export function isLocalPath(value) {
|
|
360
|
-
|
|
385
|
+
const { name, org } = parseOrgFromName(parseForkSpec(value).spec);
|
|
386
|
+
if (org !== undefined && !hasPathCharacter(org) && !hasPathCharacter(name))
|
|
387
|
+
return false;
|
|
388
|
+
return hasPathCharacter(value);
|
|
361
389
|
}
|
|
362
390
|
/**
|
|
363
391
|
* Parse `--bundle-assets` values (`[<type>:]<name>[@<version>]`, each value may be
|
|
@@ -439,6 +467,15 @@ export function parseDependencyFlags(values) {
|
|
|
439
467
|
}
|
|
440
468
|
return { dependencies };
|
|
441
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Split an optional `<asset type>:` prefix off a `--from` value: `hook:@acme/x` names @acme's hook `x`.
|
|
472
|
+
* A prefix that isn't an asset type (`global:`, a drive letter) stays part of the name.
|
|
473
|
+
*/
|
|
474
|
+
export function parseForkSpec(value) {
|
|
475
|
+
const colonIndex = value.indexOf(':');
|
|
476
|
+
const type = colonIndex === -1 ? undefined : AssetType.safeParse(value.slice(0, colonIndex).toLowerCase());
|
|
477
|
+
return type?.success ? { spec: value.slice(colonIndex + 1), type: type.data } : { spec: value };
|
|
478
|
+
}
|
|
442
479
|
// ---------------------------------------------------------------------------
|
|
443
480
|
// Entrypoint naming
|
|
444
481
|
// ---------------------------------------------------------------------------
|
|
@@ -463,14 +500,17 @@ export async function scaffoldAsset(options, outputBaseDir) {
|
|
|
463
500
|
await writeJsonFile(manifestPath, manifest);
|
|
464
501
|
filesCreated.push(manifestFileName);
|
|
465
502
|
// Write entrypoint file if applicable
|
|
466
|
-
const entrypoint = getEntrypointName(options.type, options.name);
|
|
503
|
+
const entrypoint = getEntrypointName(options.type, options.name, options.forkEntrypoint);
|
|
467
504
|
if (entrypoint) {
|
|
468
|
-
const content = generateEntrypointContent(options.type, options.name, options.description);
|
|
505
|
+
const content = generateEntrypointContent(options.type, options.name, options.description, options.forkEntrypoint);
|
|
469
506
|
await writeTextFile(join(outputDir, entrypoint), content);
|
|
470
507
|
filesCreated.push(entrypoint);
|
|
471
508
|
}
|
|
472
|
-
// Write README.md
|
|
473
|
-
const
|
|
509
|
+
// Write README.md, whose example for an `.mjs` hook shows the node command Claude Code's placement registers
|
|
510
|
+
const nodeHookPlacement = options.type === 'hook' && isNodeHookEntrypoint(entrypoint)
|
|
511
|
+
? placementForEntrypoint(getPlacement(await loadAdapter('claude-code'), 'hook'), entrypoint)
|
|
512
|
+
: undefined;
|
|
513
|
+
const readmeContent = generateReadmeContent(options.type, options.name, options.description, nodeHookPlacement && hookCommand(nodeHookPlacement, options.name));
|
|
474
514
|
await writeTextFile(join(outputDir, 'README.md'), readmeContent);
|
|
475
515
|
filesCreated.push('README.md');
|
|
476
516
|
return {
|
|
@@ -575,6 +615,88 @@ export function validateAssetName(name) {
|
|
|
575
615
|
}
|
|
576
616
|
return { valid: true };
|
|
577
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* Whether a hook command runs the given script file: the command, less a closing quote, ends with
|
|
620
|
+
* the file's name as a path (`bash ./.github/hooks/notify.sh`, `node "$HOME/.copilot/hooks/x.mjs"`).
|
|
621
|
+
*/
|
|
622
|
+
function commandRunsScript(command, scriptFile) {
|
|
623
|
+
if (typeof command !== 'string')
|
|
624
|
+
return false;
|
|
625
|
+
const cmd = command.trim().replace(/["']$/, '');
|
|
626
|
+
if (!cmd.endsWith(scriptFile))
|
|
627
|
+
return false;
|
|
628
|
+
const before = cmd.at(-scriptFile.length - 1);
|
|
629
|
+
return before === undefined || '/\\ "\''.includes(before);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* The `hookConfig` a Copilot CLI hook file beside a hook's script gives (`<name>.json`, as Copilot
|
|
633
|
+
* CLI reads them from `.github/hooks/` or `~/.copilot/hooks/`): each event with an entry that runs
|
|
634
|
+
* the script, by its ATK name (the inverse of the Copilot adapter's `configHookEvents`), with the
|
|
635
|
+
* entry's `timeoutSec` as `timeout`. A Copilot event with no ATK name is left out. Empty when there
|
|
636
|
+
* is no such file or it doesn't parse.
|
|
637
|
+
*/
|
|
638
|
+
async function copilotHookConfig(scriptPath, name) {
|
|
639
|
+
const hookConfig = {};
|
|
640
|
+
try {
|
|
641
|
+
const placement = getPlacement(await loadAdapter('copilot-cli'), 'hook');
|
|
642
|
+
const atkEvents = new Map(Object.entries(placement?.configHookEvents ?? {}).map(([atkEvent, copilotEvent]) => [copilotEvent, atkEvent]));
|
|
643
|
+
const hookFilePath = join(dirname(scriptPath), `${name}.json`);
|
|
644
|
+
const config = parseConfig(await readFile(hookFilePath, 'utf-8'), resolveConfigFormat(hookFilePath, placement));
|
|
645
|
+
const section = config[placement?.configKey ?? 'hooks'];
|
|
646
|
+
if (!section || typeof section !== 'object' || Array.isArray(section))
|
|
647
|
+
return hookConfig;
|
|
648
|
+
const scriptFile = basename(scriptPath);
|
|
649
|
+
for (const [copilotEvent, entries] of Object.entries(section)) {
|
|
650
|
+
const event = atkEvents.get(copilotEvent);
|
|
651
|
+
if (event === undefined || !Array.isArray(entries))
|
|
652
|
+
continue;
|
|
653
|
+
const entry = entries.find((e) => !!e &&
|
|
654
|
+
typeof e === 'object' &&
|
|
655
|
+
(commandRunsScript(e.bash, scriptFile) ||
|
|
656
|
+
commandRunsScript(e.powershell, scriptFile)));
|
|
657
|
+
if (!entry)
|
|
658
|
+
continue;
|
|
659
|
+
hookConfig[event] = typeof entry.timeoutSec === 'number' ? { timeout: entry.timeoutSec } : {};
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch {
|
|
663
|
+
// No Copilot hook file beside the script, or not parseable — it adds no events
|
|
664
|
+
}
|
|
665
|
+
return hookConfig;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* The installed asset `--from <fromSpec>` names. Its name reads as the commands that take an installed
|
|
669
|
+
* name read it ({@link lookupNamedEntry}): `@org/name`, `global:name`, or a bare name, the lockfile org's
|
|
670
|
+
* entry else the global one; a `<type>:` prefix picks the type. Without one, the type being created
|
|
671
|
+
* (`forType`) is looked for first, then any type, and a name that reaches several types is refused.
|
|
672
|
+
* Undefined when nothing of that name is installed; a name installed only as another type or in another
|
|
673
|
+
* scope is refused with each entry of that name as `--from` names it.
|
|
674
|
+
*/
|
|
675
|
+
function findForkSource(lockfile, fromSpec, forType) {
|
|
676
|
+
const { spec, type } = parseForkSpec(fromSpec);
|
|
677
|
+
const preferred = type ?? AssetType.safeParse(forType).data;
|
|
678
|
+
// One entry per type in a scope, so a typed lookup reaches at most one.
|
|
679
|
+
const ofPreferred = preferred && lookupNamedEntry(lockfile, spec, preferred).matches[0];
|
|
680
|
+
if (ofPreferred)
|
|
681
|
+
return ofPreferred;
|
|
682
|
+
if (!type) {
|
|
683
|
+
const { matches } = lookupNamedEntry(lockfile, spec);
|
|
684
|
+
if (matches.length === 1)
|
|
685
|
+
return matches[0];
|
|
686
|
+
if (matches.length > 1) {
|
|
687
|
+
const candidates = matches.map((a) => `${a.type}:${spec}`).sort();
|
|
688
|
+
throw new LockfileError(`"${fromSpec}" is installed as more than one type. Name the one to fork with its type: ${candidates.join(', ')}.`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
const { name } = parseNameScope(spec);
|
|
692
|
+
const installedAs = (lockfile.assets ?? [])
|
|
693
|
+
.filter((a) => a.name === name)
|
|
694
|
+
.map((a) => `${a.type}:${entrySpec(lockfile, a, a.type)}`)
|
|
695
|
+
.sort();
|
|
696
|
+
if (installedAs.length === 0)
|
|
697
|
+
return undefined;
|
|
698
|
+
throw new LockfileError(`Asset "${fromSpec}" is not installed. Installed as: ${installedAs.join(', ')}.`, installedAs.length === 1 && forType ? { command: `atk init ${forType} --from ${installedAs[0]}` } : {});
|
|
699
|
+
}
|
|
578
700
|
// ---------------------------------------------------------------------------
|
|
579
701
|
// Scaffolding orchestration
|
|
580
702
|
// ---------------------------------------------------------------------------
|
|
@@ -604,6 +726,32 @@ async function forkFromLocalMcpConfig(keyName, placement, manifest) {
|
|
|
604
726
|
manifest.mcpServer = { [keyName]: servers[keyName] };
|
|
605
727
|
return { files: new Map(), manifest };
|
|
606
728
|
}
|
|
729
|
+
function hasPathCharacter(value) {
|
|
730
|
+
return value.includes('/') || value.includes('\\') || value.includes('.');
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* The event bindings the registry gives an installed hook's version. When the registry can't be read,
|
|
734
|
+
* doesn't have that version or gives it no events, a notice says the fork binds the default `Stop` instead.
|
|
735
|
+
*/
|
|
736
|
+
async function installedHookConfig(installed) {
|
|
737
|
+
const spec = `${formatOrgName(installed.org, installed.name)}@${installed.version}`;
|
|
738
|
+
let reason;
|
|
739
|
+
try {
|
|
740
|
+
const hookConfig = versionHookConfig(await fetchRegistry({ stale: true }), installed, installed.version);
|
|
741
|
+
if (hookConfig && Object.keys(hookConfig).length > 0)
|
|
742
|
+
return hookConfig;
|
|
743
|
+
reason = hookConfig === null ? `the registry has no ${spec}.` : `the registry gives ${spec} no hook events.`;
|
|
744
|
+
}
|
|
745
|
+
catch (err) {
|
|
746
|
+
reason = `${spec}'s hook events couldn't be read from the registry. ${asSentence(errorMessage(err))}`;
|
|
747
|
+
}
|
|
748
|
+
addNotice({
|
|
749
|
+
command: `atk info ${formatOrgName(installed.org, installed.name)}`,
|
|
750
|
+
kind: 'fork-hook-config',
|
|
751
|
+
text: `The new hook binds Stop because ${reason} Set its events in its manifest.json's hookConfig.`,
|
|
752
|
+
});
|
|
753
|
+
return undefined;
|
|
754
|
+
}
|
|
607
755
|
// ---------------------------------------------------------------------------
|
|
608
756
|
// Name validation
|
|
609
757
|
// ---------------------------------------------------------------------------
|