@detergent-software/atk 9.4.0-dev.9 → 9.4.1-dev.1
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 +401 -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 +161 -90
- 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/PreferredScopeWarning.d.ts +4 -3
- package/build/components/PreferredScopeWarning.d.ts.map +1 -1
- package/build/components/PreferredScopeWarning.js +5 -2
- package/build/components/PreferredScopeWarning.js.map +1 -1
- 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/preferred-scope.d.ts +19 -5
- package/build/lib/preferred-scope.d.ts.map +1 -1
- package/build/lib/preferred-scope.js +38 -18
- package/build/lib/preferred-scope.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-config.js
CHANGED
|
@@ -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` and whose `powershell` is `powershellCommand` (the `command` without one).
|
|
6
|
+
*/
|
|
7
|
+
export function buildHookEntry(placement, command, binding, powershellCommand = command) {
|
|
8
|
+
if (placement.configHookFormat !== 'copilot') {
|
|
9
|
+
return buildHookGroup(command, binding);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
bash: command,
|
|
13
|
+
powershell: powershellCommand,
|
|
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.
|
|
@@ -16,8 +33,14 @@ export function buildHookGroup(command, binding) {
|
|
|
16
33
|
/**
|
|
17
34
|
* Derive the hook command string from the placement's command prefix and the
|
|
18
35
|
* installed script's project-relative POSIX path.
|
|
19
|
-
* e.g. ("$CLAUDE_PROJECT_DIR/
|
|
20
|
-
* -> "$CLAUDE_PROJECT_DIR/.claude/hooks/notify-on-stop.sh
|
|
36
|
+
* e.g. (': "$(exit 0)"; exec "$CLAUDE_PROJECT_DIR"/', ".claude/hooks/notify-on-stop.sh")
|
|
37
|
+
* -> ': "$(exit 0)"; exec "$CLAUDE_PROJECT_DIR"/.claude/hooks/notify-on-stop.sh'
|
|
38
|
+
*
|
|
39
|
+
* Claude Code's prefix is for Copilot CLI, which runs the hooks in `.claude/settings.json` too, in
|
|
40
|
+
* PowerShell on Windows (ATK-849). PowerShell can't parse `"$CLAUDE_PROJECT_DIR"/…` as a command, so
|
|
41
|
+
* that entry failed, and on preToolUse Copilot denied every tool. Bash expands `$(exit 0)` to nothing
|
|
42
|
+
* and `exec` runs the script with its stdin and exit code; PowerShell parses the line and runs the
|
|
43
|
+
* `exit 0` while evaluating `:`'s argument, so the entry steps aside there.
|
|
21
44
|
*/
|
|
22
45
|
export function deriveHookCommand(commandPrefix, installedRelPath) {
|
|
23
46
|
return `${commandPrefix ?? ''}${installedRelPath}`;
|
|
@@ -26,46 +49,135 @@ export function deriveHookCommand(commandPrefix, installedRelPath) {
|
|
|
26
49
|
* The command a hook placement registers for an asset: the placement's `configCommand` template
|
|
27
50
|
* when it has one (a command that doesn't name the installed path, such as a user hook's
|
|
28
51
|
* `"${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}.
|
|
52
|
+
* node hook's, or as `{homePath}`), otherwise {@link deriveHookCommand}. `{homePath}` is the
|
|
53
|
+
* user-root-relative path from `$HOME`, which bash and PowerShell both expand, or the path itself
|
|
54
|
+
* when it is absolute (a moved user config directory on another drive).
|
|
30
55
|
*/
|
|
31
56
|
export function hookCommand(placement, assetName) {
|
|
32
|
-
const installedPath = placement.path.replace(/\{name\}/g, assetName);
|
|
33
57
|
if (placement.configCommand !== undefined) {
|
|
34
|
-
return placement.configCommand
|
|
58
|
+
return fillCommandTemplate(placement.configCommand, placement, assetName);
|
|
35
59
|
}
|
|
36
|
-
return deriveHookCommand(placement.configCommandPrefix,
|
|
60
|
+
return deriveHookCommand(placement.configCommandPrefix, placement.path.replace(/\{name\}/g, assetName));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The events a hook placement registers for a `hookConfig`, by the tool's own names
|
|
64
|
+
* (`configHookEvents`), and the ones it leaves out: an event the map doesn't know, and, for
|
|
65
|
+
* Copilot CLI, a binding with a `matcher`, whose tool names are Claude Code's (`Bash`) and which
|
|
66
|
+
* a Copilot entry can't hold (run on every tool instead, a filtered hook would do the wrong thing).
|
|
67
|
+
* An event already named as the tool names it is taken as it is; a second binding for an event
|
|
68
|
+
* already taken is left out.
|
|
69
|
+
*/
|
|
70
|
+
export function hookEventsFor(placement, hookConfig) {
|
|
71
|
+
const events = [];
|
|
72
|
+
const leftOut = [];
|
|
73
|
+
const names = placement.configHookEvents;
|
|
74
|
+
const toolNames = new Set(Object.values(names ?? {}));
|
|
75
|
+
for (const [event, binding] of Object.entries(hookConfig ?? {})) {
|
|
76
|
+
const toolEvent = names ? (names[event] ?? (toolNames.has(event) ? event : undefined)) : event;
|
|
77
|
+
if (toolEvent === undefined) {
|
|
78
|
+
leftOut.push({ event, reason: 'unknown-event' });
|
|
79
|
+
}
|
|
80
|
+
else if (events.some((e) => e.event === toolEvent)) {
|
|
81
|
+
leftOut.push({ event, reason: 'duplicate' });
|
|
82
|
+
}
|
|
83
|
+
else if (placement.configHookFormat === 'copilot' && binding?.matcher) {
|
|
84
|
+
leftOut.push({ event, reason: 'matcher' });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
events.push({ binding, event: toolEvent });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { events, leftOut };
|
|
37
91
|
}
|
|
38
92
|
/**
|
|
39
93
|
* 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
|
|
94
|
+
* entries include the given command — i.e. the group ATK owns for that asset —
|
|
95
|
+
* or a Copilot CLI entry whose `bash` command is it.
|
|
41
96
|
* Tolerant of arbitrary/foreign group shapes (returns false rather than throwing).
|
|
42
97
|
*/
|
|
43
98
|
export function hookGroupOwnsCommand(group, command) {
|
|
44
99
|
if (!group || typeof group !== 'object') {
|
|
45
100
|
return false;
|
|
46
101
|
}
|
|
102
|
+
if (group.bash === command) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
47
105
|
const hooks = group.hooks;
|
|
48
106
|
if (!Array.isArray(hooks)) {
|
|
49
107
|
return false;
|
|
50
108
|
}
|
|
51
109
|
return hooks.some((h) => !!h && typeof h === 'object' && h.command === command);
|
|
52
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The command a Copilot CLI entry's `powershell` runs on Windows: the placement's
|
|
113
|
+
* `configCommandPowershell` template, filled as {@link hookCommand} fills `configCommand`, or the
|
|
114
|
+
* {@link hookCommand} itself without one. A `.sh` hook's template finds Git Bash, since the `bash`
|
|
115
|
+
* PowerShell finds first on `PATH` is often WSL's (`System32\bash.exe`).
|
|
116
|
+
*/
|
|
117
|
+
export function hookPowershellCommand(placement, assetName) {
|
|
118
|
+
if (placement.configCommandPowershell === undefined) {
|
|
119
|
+
return hookCommand(placement, assetName);
|
|
120
|
+
}
|
|
121
|
+
return fillCommandTemplate(placement.configCommandPowershell, placement, assetName);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether a config file holds nothing once ATK's entries are out of it: no keys, or only the
|
|
125
|
+
* `version` of a Copilot CLI hook file, which ATK writes and is the whole file without its hooks.
|
|
126
|
+
*/
|
|
127
|
+
export function isEmptyHookConfig(config) {
|
|
128
|
+
const keys = Object.keys(config);
|
|
129
|
+
return keys.length === 0 || (keys.length === 1 && keys[0] === 'version');
|
|
130
|
+
}
|
|
53
131
|
/** Whether a hook's manifest entrypoint is an ES module, which a placement's `nodeEntrypoint` runs with node. */
|
|
54
132
|
export function isNodeHookEntrypoint(entrypoint) {
|
|
55
133
|
return entrypoint?.endsWith('.mjs') ?? false;
|
|
56
134
|
}
|
|
135
|
+
/** Why a hook placement leaves out a `hookConfig` event, as the end of a sentence. */
|
|
136
|
+
export function leftOutHookEventReason(left, toolName) {
|
|
137
|
+
switch (left.reason) {
|
|
138
|
+
case 'duplicate':
|
|
139
|
+
return `another of its events has the same name in ${toolName}`;
|
|
140
|
+
case 'matcher':
|
|
141
|
+
return `its matcher names Claude Code's tools, and ${toolName} has no matcher for it`;
|
|
142
|
+
case 'unknown-event':
|
|
143
|
+
return `${toolName} has no such hook event`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* {@link placementForEntrypoint}, with `{name}` in its `configFile` filled in: a placement that
|
|
148
|
+
* writes one config file per hook (Copilot CLI's `.github/hooks/{name}.json`) names it after the
|
|
149
|
+
* asset. A shared config file has no `{name}` and stays as it is.
|
|
150
|
+
*/
|
|
151
|
+
export function placementForAsset(placement, entrypoint, assetName) {
|
|
152
|
+
const resolved = placementForEntrypoint(placement, entrypoint);
|
|
153
|
+
if (!resolved?.configFile?.includes('{name}')) {
|
|
154
|
+
return resolved;
|
|
155
|
+
}
|
|
156
|
+
return { ...resolved, configFile: resolved.configFile.replace(/\{name\}/g, assetName) };
|
|
157
|
+
}
|
|
57
158
|
/**
|
|
58
159
|
* The placement a hook asset is placed with: its `nodeEntrypoint` path and command when the asset's
|
|
59
|
-
* entrypoint is an ES module,
|
|
60
|
-
*
|
|
160
|
+
* entrypoint is an ES module, its `jsonEntrypoint` path alone (no config merge) when the entrypoint
|
|
161
|
+
* is the tool's own hook config, otherwise the placement itself. A `.sh` hook is run by the shell
|
|
162
|
+
* the tool picks, which on Windows can be cmd, where neither `$VAR` nor a `.sh` script works; an
|
|
61
163
|
* `.mjs` hook run by node behaves the same under every shell.
|
|
62
164
|
*/
|
|
63
165
|
export function placementForEntrypoint(placement, entrypoint) {
|
|
166
|
+
if (placement?.jsonEntrypoint && entrypoint?.endsWith('.json')) {
|
|
167
|
+
return { path: placement.jsonEntrypoint.path };
|
|
168
|
+
}
|
|
64
169
|
if (!placement?.nodeEntrypoint || !isNodeHookEntrypoint(entrypoint)) {
|
|
65
170
|
return placement;
|
|
66
171
|
}
|
|
67
|
-
const { configCommandPrefix: _prefix, nodeEntrypoint, ...rest } = placement;
|
|
68
|
-
return {
|
|
172
|
+
const { configCommandPowershell: _powershell, configCommandPrefix: _prefix, nodeEntrypoint, ...rest } = placement;
|
|
173
|
+
return {
|
|
174
|
+
...rest,
|
|
175
|
+
configCommand: nodeEntrypoint.configCommand,
|
|
176
|
+
...(nodeEntrypoint.configCommandPowershell !== undefined
|
|
177
|
+
? { configCommandPowershell: nodeEntrypoint.configCommandPowershell }
|
|
178
|
+
: {}),
|
|
179
|
+
path: nodeEntrypoint.path,
|
|
180
|
+
};
|
|
69
181
|
}
|
|
70
182
|
/**
|
|
71
183
|
* Remove the hook group owned by `command` from `config[configKey][event]` (an array),
|
|
@@ -98,4 +210,16 @@ export function removeHookGroup(config, configKey, event, command) {
|
|
|
98
210
|
}
|
|
99
211
|
return true;
|
|
100
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* A hook command template with its placeholders filled for an asset: `{path}` (the placed path),
|
|
215
|
+
* `{homePath}` (`$HOME/` + that path, or the path itself when it is absolute) and `{name}`.
|
|
216
|
+
*/
|
|
217
|
+
function fillCommandTemplate(template, placement, assetName) {
|
|
218
|
+
const installedPath = placement.path.replace(/\{name\}/g, assetName);
|
|
219
|
+
const homePath = isAbsolute(installedPath) ? installedPath : `$HOME/${installedPath}`;
|
|
220
|
+
return template
|
|
221
|
+
.replace(/\{path\}/g, installedPath)
|
|
222
|
+
.replace(/\{homePath\}/g, homePath)
|
|
223
|
+
.replace(/\{name\}/g, assetName);
|
|
224
|
+
}
|
|
101
225
|
//# sourceMappingURL=hook-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-config.js","sourceRoot":"","sources":["../../src/lib/hook-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook-config.js","sourceRoot":"","sources":["../../src/lib/hook-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAsEvC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,SAAoD,EACpD,OAAe,EACf,OAAqC,EACrC,iBAAiB,GAAG,OAAO;IAE3B,IAAI,SAAS,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,OAAqC;IACnF,MAAM,WAAW,GAAgB;QAC/B,OAAO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,WAAW,EAAE,SAAS,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC;IACtF,OAAO,QAAQ;SACZ,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC;SACnC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC;SAClC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { PlacementConfig } from './schemas/adapter.js';
|
|
2
|
+
import type { InstalledAsset } from './schemas/lockfile.js';
|
|
3
|
+
/** Whether `content` is a published file of the hook (see `isPublishedContent`). */
|
|
4
|
+
export type PublishedCheck = (content: Uint8Array) => Promise<boolean>;
|
|
2
5
|
/**
|
|
3
6
|
* Project-relative path of the script a hook placement registers as its command, or
|
|
4
7
|
* undefined when the tool does not run the installed file directly.
|
|
@@ -12,15 +15,57 @@ import type { PlacementConfig } from './schemas/adapter.js';
|
|
|
12
15
|
* ships lands at this same path, and skills such as `/worktree-gc` run that wrapper directly.
|
|
13
16
|
*/
|
|
14
17
|
export declare function hookScriptPath(placement: PlacementConfig | undefined, assetName: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the file at `path` is the hook file ATK generates for hook `name` (Copilot CLI's
|
|
20
|
+
* `.github/hooks/{name}.json`): readable config holding nothing but the hook's own entries, each
|
|
21
|
+
* owned by one of `recorded` (the commands the asset's lockfile entries recorded for the tool, which
|
|
22
|
+
* may be an older CLI's) or by a command the placement's scripts register for the hook now (`.sh`,
|
|
23
|
+
* or `.mjs` run with node). Another hook's entry, or one the user wrote, makes it someone else's.
|
|
24
|
+
* `placement` is the adapter's hook placement, not one resolved for an entrypoint.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isGeneratedHookFile(placement: PlacementConfig | undefined, name: string, path: string, recorded?: string[]): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* The absolute path a hook whose `entrypoint` is the tool's own hook JSON is placed at, when the
|
|
29
|
+
* adapter's hook `placement` writes a script version's hook file there too (Copilot CLI's
|
|
30
|
+
* `.github/hooks/{name}.json`), or undefined for any other hook or placement.
|
|
31
|
+
*/
|
|
32
|
+
export declare function jsonHookFilePath(placement: PlacementConfig | undefined, entrypoint: string | undefined, name: string, projectDir: string): string | undefined;
|
|
15
33
|
/**
|
|
16
34
|
* True when the file exists but the current user cannot execute it. Always false on
|
|
17
35
|
* Windows, which has no exec bit, and for a missing file (checksum checks report that).
|
|
18
36
|
*/
|
|
19
37
|
export declare function lacksExecBit(filePath: string, platform?: NodeJS.Platform): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* The scripts the adapter's hook `placement` places for hook `name` (`{name}.sh`, and `{name}.mjs`
|
|
40
|
+
* for an ES module) that hold a file of the hook: the bytes of a file the given entries of the asset
|
|
41
|
+
* recorded or, with `published`, of a file a published version of it shipped. Under a version whose
|
|
42
|
+
* entrypoint is the tool's own hook JSON, those that version doesn't place itself beside the JSON
|
|
43
|
+
* are what a script version left (ATK-818); the caller leaves out the ones it places. Anything else
|
|
44
|
+
* at those paths stays. Absolute paths.
|
|
45
|
+
*/
|
|
46
|
+
export declare function leftoverHookScripts(placement: PlacementConfig | undefined, name: string, installed: Array<Pick<InstalledAsset, 'files'> | undefined>, projectDir: string, published?: PublishedCheck): Promise<string[]>;
|
|
20
47
|
/**
|
|
21
48
|
* Add an exec bit wherever the file has a read bit, like `chmod +x` under the user's
|
|
22
49
|
* umask: 644 becomes 755 and 600 becomes 700. The registry stores scripts as 644 and the
|
|
23
50
|
* API serves bytes only, so the installer has to set the mode itself. No-op on Windows.
|
|
24
51
|
*/
|
|
25
52
|
export declare function makeExecutable(filePath: string, platform?: NodeJS.Platform): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* The absolute path of a file of the hook at the path of its own config file (Copilot CLI's
|
|
55
|
+
* `.github/hooks/{name}.json`), which the hook file is written to in its place, or undefined when
|
|
56
|
+
* there is none:
|
|
57
|
+
* - the copy of the hook's script that a CLI before ATK-204 saved there, which the tool can't read
|
|
58
|
+
* as config: it holds the bytes of a file the given entries of the asset recorded, or is a script
|
|
59
|
+
* (`#!`), which no config file starts with (the lockfile may already record a newer version);
|
|
60
|
+
* - with `json`, the hook's own JSON, which a version whose entrypoint it is placed there as it is
|
|
61
|
+
* (ATK-818): it holds the bytes of a recorded file or of a file a published version shipped,
|
|
62
|
+
* since a sync over a lockfile a teammate's update wrote has no record of it. ATK's own hook file,
|
|
63
|
+
* by its current commands or the ones `json.recorded` names, is not one, and neither is config
|
|
64
|
+
* with anything else in it: the hook's entries are merged into both.
|
|
65
|
+
* `placement` is the adapter's hook placement, not one resolved for an entrypoint.
|
|
66
|
+
*/
|
|
67
|
+
export declare function misplacedHookCopy(placement: PlacementConfig | undefined, name: string, installed: Array<Pick<InstalledAsset, 'files'> | undefined>, projectDir: string, json?: {
|
|
68
|
+
published: PublishedCheck;
|
|
69
|
+
recorded: string[];
|
|
70
|
+
}): Promise<string | undefined>;
|
|
26
71
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"hook-script.d.ts","sourceRoot":"","sources":["../../src/lib/hook-script.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO5D,oFAAoF;AACpF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,eAAe,GAAG,SAAS,EAAE,SAAS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AE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GACvD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiB7B"}
|
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,OAAO,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAsC,EACtC,IAAY,EACZ,IAAY,EACZ,WAAqB,EAAE;IAEvB,IAAI,CAAC,SAAS,EAAE,eAAe,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3F,IAAI,MAA+B,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,mB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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":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