@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `atk upgrade`: install the newest CLI on an npm dist-tag over the running one (ATK-873), as
|
|
3
|
+
* `conduct upgrade` does for the conductor (apps/conductor/src/upgrade.ts).
|
|
4
|
+
*
|
|
5
|
+
* npm replaces the package while this process runs from it. That works on Windows too: Node holds
|
|
6
|
+
* no handle on a module once it has loaded it, and npm rewrites the `atk.cmd` shim with the same
|
|
7
|
+
* bytes. So everything this module needs is a static import, loaded before the install, and the
|
|
8
|
+
* new version is read from the installed `package.json` on disk, never from `CLI_VERSION`.
|
|
9
|
+
*/
|
|
10
|
+
import { spawn } from 'node:child_process';
|
|
11
|
+
import { realpathSync } from 'node:fs';
|
|
12
|
+
import { posix, win32 } from 'node:path';
|
|
13
|
+
import { eq as semverEq, lt as semverLt, valid as semverValid } from 'semver';
|
|
14
|
+
import { ApiCodeError } from './errors.js';
|
|
15
|
+
import { isOffline } from './offline.js';
|
|
16
|
+
import { readDistTagsFresh } from './update-check.js';
|
|
17
|
+
import { channelOf, CLI_VERSION, npmInstallCommand, PACKAGE_DIR, PACKAGE_NAME, readInstalledVersion, UPGRADE_COMMAND, } from './version.js';
|
|
18
|
+
export const UPGRADE_TAGS = ['dev', 'latest'];
|
|
19
|
+
/** npm can take a while on a slow network; past this the install is stopped and reported. */
|
|
20
|
+
const NPM_INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
21
|
+
const NPM_ROOT_TIMEOUT_MS = 30 * 1000;
|
|
22
|
+
/** How much of npm's output a failed install shows. */
|
|
23
|
+
const OUTPUT_TAIL_CHARS = 1500;
|
|
24
|
+
/** Why `atk upgrade` installed nothing, or why its install failed. */
|
|
25
|
+
export class UpgradeError extends ApiCodeError {
|
|
26
|
+
name = 'UpgradeError';
|
|
27
|
+
constructor(code, message, options = {}) {
|
|
28
|
+
super(message, { ...options, code });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** The real npm, the running package and the update check's npm read. */
|
|
32
|
+
export function defaultUpgradeDeps(progress) {
|
|
33
|
+
return {
|
|
34
|
+
cliPath: realpathSync(PACKAGE_DIR),
|
|
35
|
+
currentVersion: CLI_VERSION,
|
|
36
|
+
installedVersion: readInstalledVersion,
|
|
37
|
+
// --prefer-online: npm resolves the exact version against a fresh packument, not a cached one
|
|
38
|
+
// that may not list it yet (ATK-558).
|
|
39
|
+
npmInstall: (spec) => runNpm(['install', '--global', '--prefer-online', spec], NPM_INSTALL_TIMEOUT_MS),
|
|
40
|
+
npmRoot: async () => npmRootOf(await runNpm(['root', '--global'], NPM_ROOT_TIMEOUT_MS)),
|
|
41
|
+
offline: isOffline(),
|
|
42
|
+
progress,
|
|
43
|
+
tagVersions: readDistTagsFresh,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** True when cliPath lies under npm's global node_modules. A linked checkout and npx's cache resolve outside it. */
|
|
47
|
+
export function isGlobalInstall(cliPath, npmRoot, platform = process.platform) {
|
|
48
|
+
const path = platform === 'win32' ? win32 : posix;
|
|
49
|
+
const rel = path.relative(npmRoot, cliPath);
|
|
50
|
+
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The realpath of the folder `npm root --global` printed. stdout alone: npm writes its warnings
|
|
54
|
+
* (an unknown .npmrc key, its update notice) to stderr. Throws when npm failed.
|
|
55
|
+
*/
|
|
56
|
+
export function npmRootOf(result) {
|
|
57
|
+
if (result.code !== 0) {
|
|
58
|
+
throw new Error(tail(result.output) || `npm root --global exited ${String(result.code)}`);
|
|
59
|
+
}
|
|
60
|
+
return realpathSync(result.stdout.trim());
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Install the tag's version over the running CLI. Refuses, before it installs anything: offline,
|
|
64
|
+
* outside an npm global install, a tag npm doesn't have, and a version older than the running one
|
|
65
|
+
* unless allowDowngrade. Does nothing when the tag's version is the running one.
|
|
66
|
+
*/
|
|
67
|
+
export async function upgradeCli(options, deps) {
|
|
68
|
+
const from = deps.currentVersion;
|
|
69
|
+
const tag = options.tag ?? channelOf(from);
|
|
70
|
+
const manual = npmInstallCommand(tag);
|
|
71
|
+
if (deps.offline) {
|
|
72
|
+
throw new UpgradeError('offline', "Can't upgrade with --offline: the new version comes from npm.", {
|
|
73
|
+
command: UPGRADE_COMMAND,
|
|
74
|
+
hint: 'Run it again without --offline.',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
deps.progress('Finding the npm global install...');
|
|
78
|
+
let root;
|
|
79
|
+
try {
|
|
80
|
+
root = await deps.npmRoot();
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
throw notGlobal(`Couldn't ask npm for its global folder (${err instanceof Error ? err.message : String(err)}).`, manual);
|
|
84
|
+
}
|
|
85
|
+
if (!isGlobalInstall(deps.cliPath, root, deps.platform)) {
|
|
86
|
+
throw notGlobal(`This atk (${deps.cliPath}) isn't an npm global install (${root}).`, manual);
|
|
87
|
+
}
|
|
88
|
+
deps.progress(`Reading the ${tag} version from npm...`);
|
|
89
|
+
const tags = await deps.tagVersions();
|
|
90
|
+
if (!tags) {
|
|
91
|
+
throw new UpgradeError('npm_unreachable', `Couldn't read ${PACKAGE_NAME}'s dist-tags from npm.`, {
|
|
92
|
+
command: UPGRADE_COMMAND,
|
|
93
|
+
hint: 'Check your network connection and run it again.',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const target = tags[tag];
|
|
97
|
+
if (!target || !semverValid(target)) {
|
|
98
|
+
throw new UpgradeError('tag_missing', `npm has no ${PACKAGE_NAME}@${tag}.`, {
|
|
99
|
+
hint: `Pick the other channel with --tag ${tag === 'dev' ? 'latest' : 'dev'}.`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (semverValid(from) && semverEq(target, from)) {
|
|
103
|
+
return { from, outcome: 'current', tag, to: from };
|
|
104
|
+
}
|
|
105
|
+
const downgrade = semverValid(from) !== null && semverLt(target, from);
|
|
106
|
+
if (downgrade && !options.allowDowngrade) {
|
|
107
|
+
throw new UpgradeError('downgrade_refused', `${PACKAGE_NAME}@${tag} is ${target}, older than this CLI's ${from}; nothing was installed.`, {
|
|
108
|
+
command: `${UPGRADE_COMMAND} --tag ${tag} --allow-downgrade`,
|
|
109
|
+
hint: 'Add --allow-downgrade to install it anyway.',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// The version just compared, not the tag, which may move before npm resolves it.
|
|
113
|
+
const exact = `${PACKAGE_NAME}@${target}`;
|
|
114
|
+
deps.progress(`Installing ${exact}...`);
|
|
115
|
+
const installed = await deps.npmInstall(exact);
|
|
116
|
+
if (installed.code !== 0) {
|
|
117
|
+
const output = tail(installed.output);
|
|
118
|
+
throw new UpgradeError('install_failed', `npm couldn't install ${exact}${installed.code === null ? ' (it was stopped)' : ` (exit ${String(installed.code)})`}.${output ? `\n${output}` : ''}`, { command: npmInstallCommand(target) });
|
|
119
|
+
}
|
|
120
|
+
// npm can succeed and leave this copy alone: one nested in another global package's node_modules.
|
|
121
|
+
const to = deps.installedVersion();
|
|
122
|
+
if (to !== target) {
|
|
123
|
+
throw new UpgradeError('install_failed', `npm installed ${exact}, but this atk (${deps.cliPath}) still reads ${to}: it isn't the copy npm replaced.`, { command: npmInstallCommand(target), hint: 'Run `atk --version` to see which copy is on your PATH.' });
|
|
124
|
+
}
|
|
125
|
+
return { from, outcome: downgrade ? 'downgraded' : 'upgraded', tag, to };
|
|
126
|
+
}
|
|
127
|
+
function notGlobal(message, manual) {
|
|
128
|
+
return new UpgradeError('not_npm_global', `${message} Nothing was installed.`, {
|
|
129
|
+
command: manual,
|
|
130
|
+
hint: 'atk upgrade only replaces an npm global install. Under npx or a linked checkout, run the npm command; with pnpm, yarn or bun, upgrade the package with that tool.',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** What an npm argument may hold: flags and package specs, nothing a shell would read (`&`, `^`, `%`, quotes). */
|
|
134
|
+
const SAFE_NPM_ARG = /^[\w@./:+-]+$/;
|
|
135
|
+
/**
|
|
136
|
+
* npm, with its output captured. On Windows npm is `npm.cmd`, which only a shell starts, so the
|
|
137
|
+
* command goes as one quoted line, and an argument a shell could read otherwise is refused.
|
|
138
|
+
*/
|
|
139
|
+
function runNpm(args, timeoutMs) {
|
|
140
|
+
const unsafe = args.find((a) => !SAFE_NPM_ARG.test(a));
|
|
141
|
+
if (unsafe !== undefined) {
|
|
142
|
+
return Promise.resolve({ code: null, output: `refused an npm argument a shell could read: ${unsafe}`, stdout: '' });
|
|
143
|
+
}
|
|
144
|
+
return new Promise((resolve) => {
|
|
145
|
+
const onWindows = process.platform === 'win32';
|
|
146
|
+
const stdio = ['ignore', 'pipe', 'pipe'];
|
|
147
|
+
const child = onWindows
|
|
148
|
+
? spawn(['npm', ...args.map((a) => `"${a}"`)].join(' '), [], { shell: true, stdio, windowsHide: true })
|
|
149
|
+
: spawn('npm', [...args], { stdio, windowsHide: true });
|
|
150
|
+
let output = '';
|
|
151
|
+
let stdout = '';
|
|
152
|
+
let timedOut = false;
|
|
153
|
+
child.stdout.on('data', (chunk) => {
|
|
154
|
+
stdout += chunk.toString();
|
|
155
|
+
output += chunk.toString();
|
|
156
|
+
});
|
|
157
|
+
child.stderr.on('data', (chunk) => (output += chunk.toString()));
|
|
158
|
+
const timer = setTimeout(() => {
|
|
159
|
+
timedOut = true;
|
|
160
|
+
if (onWindows && child.pid !== undefined) {
|
|
161
|
+
// Killing the shell alone would leave npm running; /T ends the tree.
|
|
162
|
+
spawn('taskkill', ['/pid', String(child.pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true }).on('error', () => { });
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
child.kill();
|
|
166
|
+
}
|
|
167
|
+
}, timeoutMs);
|
|
168
|
+
child.on('error', (err) => {
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
resolve({ code: null, output: `${output}${err.message}`, stdout });
|
|
171
|
+
});
|
|
172
|
+
child.on('close', (code) => {
|
|
173
|
+
clearTimeout(timer);
|
|
174
|
+
// taskkill /F leaves exit code 1 on Windows; a stopped npm reads the same on every platform.
|
|
175
|
+
resolve({ code: timedOut ? null : code, output, stdout });
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function tail(output) {
|
|
180
|
+
const trimmed = output.trim();
|
|
181
|
+
return trimmed.length > OUTPUT_TAIL_CHARS ? `…${trimmed.slice(-OUTPUT_TAIL_CHARS)}` : trimmed;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=self-upgrade.js.map
|
|
@@ -0,0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AAI,CAAC,MAAc;IAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC"}
|
package/build/lib/sync.d.ts
CHANGED
|
@@ -27,9 +27,23 @@ export interface ClassifySyncEntriesOptions {
|
|
|
27
27
|
export interface ClassifySyncEntriesResult {
|
|
28
28
|
/** Assets skipped because they were uninstalled for this tool (`excludedTools`). */
|
|
29
29
|
excludedSkipped: number;
|
|
30
|
+
/** Assets skipped because they are frozen, counted in `frozenSkipped`. */
|
|
31
|
+
frozen: InstalledAsset[];
|
|
30
32
|
frozenSkipped: number;
|
|
33
|
+
/**
|
|
34
|
+
* Assets whose copy passed every check, counted in `skipped`. Their folder can still hold files
|
|
35
|
+
* another version left, which the entry doesn't name (ATK-856).
|
|
36
|
+
*/
|
|
37
|
+
inPlace: InstalledAsset[];
|
|
31
38
|
/** Assets not synced because files they placed were edited (see {@link localEditsAmong}); only without `force`. */
|
|
32
39
|
localEdits: LocalEdits[];
|
|
40
|
+
/**
|
|
41
|
+
* Hooks whose locked entrypoint this tool can't take (see `takesEntrypoint`) that it still has the
|
|
42
|
+
* copy an older CLI placed of, which sync removes. Nothing is recorded for them: the lockfile's
|
|
43
|
+
* `entrypoint` already says the tool doesn't take them. Counted in `skipped`, like a type the tool
|
|
44
|
+
* has no placement for: nothing restores them, so they aren't exclusions.
|
|
45
|
+
*/
|
|
46
|
+
misplaced: InstalledAsset[];
|
|
33
47
|
skipped: number;
|
|
34
48
|
toSync: SyncEntry[];
|
|
35
49
|
/**
|
|
@@ -89,6 +103,22 @@ export interface SyncFailure extends ErrorGuidance {
|
|
|
89
103
|
org?: string;
|
|
90
104
|
version: string;
|
|
91
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The files in an asset's folder that another version of it left and its locked version doesn't
|
|
108
|
+
* ship, which sync removed (or, in a dry run, would): see `findLeftoverFiles` (ATK-854, ATK-856).
|
|
109
|
+
*/
|
|
110
|
+
export interface SyncLeftoverFiles {
|
|
111
|
+
/**
|
|
112
|
+
* POSIX paths relative to the scope's root, sorted, as the progress lines show them: `../` leads
|
|
113
|
+
* to a user config directory moved outside the user root.
|
|
114
|
+
*/
|
|
115
|
+
files: string[];
|
|
116
|
+
name: string;
|
|
117
|
+
org?: string;
|
|
118
|
+
type: InstalledAsset['type'];
|
|
119
|
+
/** The locked version, which doesn't ship them. */
|
|
120
|
+
version: string;
|
|
121
|
+
}
|
|
92
122
|
export type SyncOutcome = {
|
|
93
123
|
/** Configured tools not run because an earlier tool stopped at a run-wide failure. */
|
|
94
124
|
notRunTools?: string[];
|
|
@@ -122,9 +152,16 @@ export interface ToolDryRunResult {
|
|
|
122
152
|
wouldFail?: SyncFailure[];
|
|
123
153
|
/** Hooks whose copy a live sync removes: their locked version doesn't declare this tool. Absent when none. */
|
|
124
154
|
wouldRemove?: SyncRemoval[];
|
|
155
|
+
/** Files other versions left that a live sync removes from assets' folders. Absent when none. */
|
|
156
|
+
wouldRemoveFiles?: SyncLeftoverFiles[];
|
|
125
157
|
}
|
|
126
158
|
export interface ToolSyncResult {
|
|
127
159
|
bootstrapHint?: string;
|
|
160
|
+
/**
|
|
161
|
+
* The entry names sync added to the tool's enabled list (e.g. Claude Code's
|
|
162
|
+
* `enabledMcpjsonServers`) for copies it left as they were. Absent when none.
|
|
163
|
+
*/
|
|
164
|
+
enabled?: string[];
|
|
128
165
|
/** Assets skipped because they were uninstalled for this tool. Absent when zero. */
|
|
129
166
|
excludedSkipped?: number;
|
|
130
167
|
failures: SyncFailure[];
|
|
@@ -138,6 +175,8 @@ export interface ToolSyncResult {
|
|
|
138
175
|
notAttempted?: string[];
|
|
139
176
|
/** Hooks whose copy was removed: their locked version doesn't declare this tool. Absent when none. */
|
|
140
177
|
removed?: SyncRemoval[];
|
|
178
|
+
/** Files other versions left that were removed from assets' folders. Absent when none. */
|
|
179
|
+
removedFiles?: SyncLeftoverFiles[];
|
|
141
180
|
skipped: number;
|
|
142
181
|
synced: SyncEntry[];
|
|
143
182
|
tool: string;
|
package/build/lib/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/lib/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAY,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/lib/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAY,MAAM,uBAAuB,CAAC;AAuBtE,OAAO,EAGL,KAAK,aAAa,EAElB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAwC,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAkB1G,OAAO,EAAE,KAAK,KAAK,EAAiB,MAAM,YAAY,CAAC;AAcvD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,EAAE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E,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,SAAU,SAAQ,WAAW;IAC/B,IAAI,SAAe;CAC7B;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA+LjH;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoFxF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAmTtF"}
|
package/build/lib/sync.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { configDirMove, resolveInstalledPaths } from './adapter.js';
|
|
2
|
-
import { declarationAllows, excludeToolFromAsset, isExcludedAtVersion, isExcludedForTool, supportsType, withToolExcluded, } from './asset-tools.js';
|
|
2
|
+
import { declarationAllows, excludeToolFromAsset, isExcludedAtVersion, isExcludedForTool, supportsType, takesEntrypoint, withToolExcluded, } from './asset-tools.js';
|
|
3
3
|
import { getCredential } from './auth.js';
|
|
4
4
|
import { upgradeConfigEntryChecksums } from './checksum.js';
|
|
5
5
|
import { getConfigEntriesForTool, lacksHookRegistration, needsConfigRegistration, staleHookCommandEntries, } from './config-entries.js';
|
|
6
|
+
import { readConfigFile, resolveConfigFormat } from './config-file.js';
|
|
6
7
|
import { isFrozenInConfig } from './config.js';
|
|
8
|
+
import { addToEnabledList } from './enabled-list.js';
|
|
7
9
|
import { asSentence, errorGuidance, errorMessage, GuidedError, isRunWideFailure, } from './errors.js';
|
|
8
10
|
import { restoreFiles, snapshotFiles } from './file-snapshot.js';
|
|
9
|
-
import { hookScriptPath, lacksExecBit } from './hook-script.js';
|
|
10
|
-
import { executeInstallPlan, fetchPlanFiles, installFailureMessage } from './installer.js';
|
|
11
|
-
import { changedAmong, editedFiles, localEditsAmong } from './local-edits.js';
|
|
12
|
-
import { addAssetToLockfile, getLockfilePath, identityKey, LockfileError, readLockfile, removeAssetFromLockfile, withLockfileErrorHandling, writeLockfile, } from './lockfile.js';
|
|
13
|
-
import { scopeSwitchGuidance } from './org.js';
|
|
11
|
+
import { hookScriptPath, isGeneratedHookFile, jsonHookFilePath, lacksExecBit } from './hook-script.js';
|
|
12
|
+
import { entrypointMisfit, executeInstallPlan, fetchPlanFiles, installFailureMessage, } from './installer.js';
|
|
13
|
+
import { changedAmong, editedFiles, isRunWide, localEditsAmong } from './local-edits.js';
|
|
14
|
+
import { addAssetToLockfile, findInstalledAsset, getLockfilePath, identityKey, LockfileError, readLockfile, removeAssetFromLockfile, withLockfileErrorHandling, writeLockfile, } from './lockfile.js';
|
|
15
|
+
import { formatOrgName, scopeSwitchGuidance } from './org.js';
|
|
14
16
|
import { verifyOwnConfigEntries, verifyOwnFiles } from './owned-paths.js';
|
|
17
|
+
import { toRelativePosix } from './paths.js';
|
|
15
18
|
import { findAsset, versionHookConfig, versionTools } from './registry.js';
|
|
16
19
|
import { resolveInstallPlan } from './resolver.js';
|
|
17
20
|
import { fromRoot } from './root-path.js';
|
|
18
21
|
import { scopedCommand } from './scope.js';
|
|
19
22
|
import { reinstallTouchedPaths } from './touched-paths.js';
|
|
20
|
-
import { hasCopyForTool, removeSingleAsset, UninstallerError } from './uninstaller.js';
|
|
23
|
+
import { findLeftoverFiles, hasCopyForTool, removeLeftoverFiles, removeSingleAsset, UninstallerError, } from './uninstaller.js';
|
|
21
24
|
export class SyncError extends GuidedError {
|
|
22
25
|
name = 'SyncError';
|
|
23
26
|
}
|
|
@@ -47,7 +50,10 @@ export class SyncError extends GuidedError {
|
|
|
47
50
|
*/
|
|
48
51
|
export async function classifySyncEntries(options) {
|
|
49
52
|
const { adapter, assets, force, only, onProgress, projectConfig, projectDir, registry } = options;
|
|
53
|
+
const frozen = [];
|
|
54
|
+
const inPlace = [];
|
|
50
55
|
const localEdits = [];
|
|
56
|
+
const misplaced = [];
|
|
51
57
|
const toSync = [];
|
|
52
58
|
const undeclared = [];
|
|
53
59
|
let excludedSkipped = 0;
|
|
@@ -58,6 +64,7 @@ export async function classifySyncEntries(options) {
|
|
|
58
64
|
continue;
|
|
59
65
|
onProgress?.(`Checking ${asset.name}...`);
|
|
60
66
|
if (isFrozenInConfig(projectConfig, asset.name, asset.type, asset.org)) {
|
|
67
|
+
frozen.push(asset);
|
|
61
68
|
frozenSkipped++;
|
|
62
69
|
continue;
|
|
63
70
|
}
|
|
@@ -105,6 +112,21 @@ export async function classifySyncEntries(options) {
|
|
|
105
112
|
}
|
|
106
113
|
continue;
|
|
107
114
|
}
|
|
115
|
+
// A hook whose locked entrypoint this tool can't take (a script where the tool reads hook
|
|
116
|
+
// config) is not placed for it, even under `force`. A copy an older CLI placed is removed,
|
|
117
|
+
// unless the user edited it.
|
|
118
|
+
if (!takesEntrypoint(adapter, asset.type, asset.entrypoint)) {
|
|
119
|
+
onProgress?.(`Skipping ${asset.name}: ${entrypointMisfit(asset, adapter, asset.entrypoint)}`);
|
|
120
|
+
if (await hasCopyForTool(asset, adapter, projectDir, { lockfile: { assets }, placedByAtk: true })) {
|
|
121
|
+
const edits = force ? undefined : await editedFiles(asset, adapter, projectDir, { assets }, registry);
|
|
122
|
+
if (edits)
|
|
123
|
+
localEdits.push(edits);
|
|
124
|
+
else
|
|
125
|
+
misplaced.push(asset);
|
|
126
|
+
}
|
|
127
|
+
skipped++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
108
130
|
// Still excluded here, so the exclusion is lifted: ATK never placed the hook for this tool, and
|
|
109
131
|
// the install records it. A file at its path is not ATK's, so the install refuses it.
|
|
110
132
|
if (isExcludedForTool(asset, adapter.tool)) {
|
|
@@ -135,8 +157,18 @@ export async function classifySyncEntries(options) {
|
|
|
135
157
|
const checksumFailures = await verifyOwnFiles(filesToCheck, asset, { assets }, adapter, projectDir);
|
|
136
158
|
// A file the user edited is kept: the reinstall would overwrite it, also when another of the
|
|
137
159
|
// asset's files is missing. One holding a published version's content is only stale, and is
|
|
138
|
-
// placed again.
|
|
139
|
-
|
|
160
|
+
// placed again. So is the hook file ATK generated for a script version of a hook, where a
|
|
161
|
+
// version whose entrypoint is the tool's hook JSON goes (ATK-818): a lockfile a teammate's
|
|
162
|
+
// update wrote records the JSON, and the old version's hook file still runs the old script.
|
|
163
|
+
const hookFile = asset.type === 'hook'
|
|
164
|
+
? jsonHookFilePath(adapter.placements.hook, asset.entrypoint, asset.name, projectDir)
|
|
165
|
+
: undefined;
|
|
166
|
+
const ownHookFile = hookFile &&
|
|
167
|
+
checksumFailures.some((f) => f.path === hookFile) &&
|
|
168
|
+
(await isGeneratedHookFile(adapter.placements.hook, asset.name, hookFile))
|
|
169
|
+
? hookFile
|
|
170
|
+
: undefined;
|
|
171
|
+
const changed = changedAmong(resolved.files, checksumFailures, projectDir).filter((f) => fromRoot(projectDir, f.installedPath) !== ownHookFile);
|
|
140
172
|
const edits = await localEditsAmong(asset, changed, projectDir, registry);
|
|
141
173
|
if (edits) {
|
|
142
174
|
localEdits.push(edits);
|
|
@@ -169,6 +201,7 @@ export async function classifySyncEntries(options) {
|
|
|
169
201
|
!needsRegistration &&
|
|
170
202
|
!staleCommand &&
|
|
171
203
|
!notExecutable) {
|
|
204
|
+
inPlace.push(asset);
|
|
172
205
|
skipped++;
|
|
173
206
|
continue;
|
|
174
207
|
}
|
|
@@ -181,7 +214,7 @@ export async function classifySyncEntries(options) {
|
|
|
181
214
|
reason: hasMissing ? 'missing' : 'modified',
|
|
182
215
|
});
|
|
183
216
|
}
|
|
184
|
-
return { excludedSkipped, frozenSkipped, localEdits, skipped, toSync, undeclared };
|
|
217
|
+
return { excludedSkipped, frozen, frozenSkipped, inPlace, localEdits, misplaced, skipped, toSync, undeclared };
|
|
185
218
|
}
|
|
186
219
|
/**
|
|
187
220
|
* Perform a dry-run sync: read the lockfile (without locking), classify each
|
|
@@ -242,6 +275,15 @@ export async function dryRunSync(options) {
|
|
|
242
275
|
if (await hasCopyForTool(asset, adapter, projectDir, { lockfile }))
|
|
243
276
|
wouldRemove.push(toSyncRemoval(asset));
|
|
244
277
|
}
|
|
278
|
+
wouldRemove.push(...classified.misplaced.map(toSyncRemoval));
|
|
279
|
+
// The files another version left that a live sync removes: from each copy in place, and from each
|
|
280
|
+
// copy it reinstalls, which it checks in full once the reinstall is done. A reinstall places the
|
|
281
|
+
// version the entry already records, so its files are the same before and after. A moved copy is
|
|
282
|
+
// placed in another directory, which the copy in this one says nothing about.
|
|
283
|
+
const wouldRemoveFiles = await leftoverFilesFor([
|
|
284
|
+
...classified.inPlace.map((asset) => ({ asset, registryFilesOnly: true })),
|
|
285
|
+
...toSync.filter((e) => e.reason !== 'moved').map(({ asset }) => ({ asset, registryFilesOnly: false })),
|
|
286
|
+
], { adapter, dryRun: true, lockfile, onProgress, projectDir, registry, toolName });
|
|
245
287
|
toolResults.push({
|
|
246
288
|
...(classified.excludedSkipped > 0 ? { excludedSkipped: classified.excludedSkipped } : {}),
|
|
247
289
|
frozenSkipped: classified.frozenSkipped,
|
|
@@ -251,6 +293,7 @@ export async function dryRunSync(options) {
|
|
|
251
293
|
toSync,
|
|
252
294
|
...(wouldFail.length > 0 ? { wouldFail } : {}),
|
|
253
295
|
...(wouldRemove.length > 0 ? { wouldRemove } : {}),
|
|
296
|
+
...(wouldRemoveFiles.length > 0 ? { wouldRemoveFiles } : {}),
|
|
254
297
|
});
|
|
255
298
|
}
|
|
256
299
|
return toolResults;
|
|
@@ -336,13 +379,45 @@ export async function syncAssets(options) {
|
|
|
336
379
|
}
|
|
337
380
|
await writeLockfile(projectDir, lockfile);
|
|
338
381
|
}
|
|
382
|
+
// Remove the copy an older CLI placed of each hook whose entrypoint this tool can't take (a
|
|
383
|
+
// script under the name of its hook config). The lockfile entry stays as it is.
|
|
384
|
+
for (const asset of classified.misplaced) {
|
|
385
|
+
try {
|
|
386
|
+
await removeSingleAsset(asset, adapter, projectDir, { lockfile, onProgress, placedByAtk: true });
|
|
387
|
+
onProgress?.(`Removed ${asset.name} for ${toolName}: ${entrypointMisfit(asset, adapter, asset.entrypoint)}`);
|
|
388
|
+
removed.push(toSyncRemoval(asset));
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
const message = `Failed to remove the ${toolName} copy: ${asSentence(errorMessage(error))}`;
|
|
392
|
+
onProgress?.(`${asset.name}: ${message}`);
|
|
393
|
+
failures.push({
|
|
394
|
+
assetName: asset.name,
|
|
395
|
+
assetType: asset.type,
|
|
396
|
+
error: message,
|
|
397
|
+
...(asset.org ? { org: asset.org } : {}),
|
|
398
|
+
version: asset.version,
|
|
399
|
+
...errorGuidance(error),
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// A copy in place can still hold files another version left, when the lockfile moved to a
|
|
404
|
+
// version whose listed files it already has (ATK-856). Nothing is reinstalled for them.
|
|
405
|
+
const removedFiles = await leftoverFilesFor(classified.inPlace.map((asset) => ({ asset, registryFilesOnly: true })), { adapter, dryRun: false, lockfile, onProgress, projectDir, registry, toolName });
|
|
406
|
+
// The servers of the copies sync leaves as they are still need the tool's approval: the
|
|
407
|
+
// installer gives it only when it merges an entry (ATK-867). The reinstalls below give theirs.
|
|
408
|
+
const enabled = await approveEnabledEntries([...classified.frozen, ...classified.inPlace], adapter, projectDir, onProgress);
|
|
409
|
+
for (const name of enabled)
|
|
410
|
+
onProgress?.(`Approved ${name} for ${toolName}`);
|
|
411
|
+
const enabledField = enabled.length > 0 ? { enabled } : {};
|
|
339
412
|
if (classified.toSync.length === 0) {
|
|
340
413
|
toolResults.push({
|
|
414
|
+
...enabledField,
|
|
341
415
|
...(classified.excludedSkipped > 0 ? { excludedSkipped: classified.excludedSkipped } : {}),
|
|
342
416
|
failures,
|
|
343
417
|
frozenSkipped: classified.frozenSkipped,
|
|
344
418
|
...localEditsField(classified),
|
|
345
419
|
...(removed.length > 0 ? { removed } : {}),
|
|
420
|
+
...(removedFiles.length > 0 ? { removedFiles } : {}),
|
|
346
421
|
skipped: classified.skipped,
|
|
347
422
|
synced: [],
|
|
348
423
|
tool: toolName,
|
|
@@ -417,6 +492,24 @@ export async function syncAssets(options) {
|
|
|
417
492
|
// in-memory copy in sync.
|
|
418
493
|
lockfile = await readLockfile(projectDir);
|
|
419
494
|
entry.result = results[0];
|
|
495
|
+
// The copy it replaced may have been another version, with files this one doesn't ship
|
|
496
|
+
// that the entry never named (ATK-854). The sync stands, so a failure here is a warning.
|
|
497
|
+
const reinstalledEntry = findInstalledAsset(lockfile, originalEntry.name, originalEntry.type, originalEntry.org);
|
|
498
|
+
if (reinstalledEntry) {
|
|
499
|
+
try {
|
|
500
|
+
const paths = await removeLeftoverFiles(reinstalledEntry, adapter, projectDir, {
|
|
501
|
+
lockfile,
|
|
502
|
+
onProgress,
|
|
503
|
+
registry,
|
|
504
|
+
});
|
|
505
|
+
if (paths.length > 0)
|
|
506
|
+
removedFiles.push(toSyncLeftoverFiles(reinstalledEntry, paths, projectDir));
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
onProgress?.(`Warning: Failed to remove the files another version of ` +
|
|
510
|
+
`${formatOrgName(originalEntry.org, originalEntry.name)} left for ${toolName} — ${errorMessage(error)}`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
420
513
|
}
|
|
421
514
|
catch (error) {
|
|
422
515
|
// Put the asset back first, also before a lockfile failure aborts the run. A reinstall
|
|
@@ -461,12 +554,14 @@ export async function syncAssets(options) {
|
|
|
461
554
|
}
|
|
462
555
|
}
|
|
463
556
|
toolResults.push({
|
|
557
|
+
...enabledField,
|
|
464
558
|
...(classified.excludedSkipped > 0 ? { excludedSkipped: classified.excludedSkipped } : {}),
|
|
465
559
|
failures,
|
|
466
560
|
frozenSkipped: classified.frozenSkipped,
|
|
467
561
|
...localEditsField(classified),
|
|
468
562
|
...(notAttempted ? { notAttempted } : {}),
|
|
469
563
|
...(removed.length > 0 ? { removed } : {}),
|
|
564
|
+
...(removedFiles.length > 0 ? { removedFiles } : {}),
|
|
470
565
|
skipped: classified.skipped,
|
|
471
566
|
synced: classified.toSync.filter((e) => e.result !== undefined),
|
|
472
567
|
tool: toolName,
|
|
@@ -481,6 +576,47 @@ export async function syncAssets(options) {
|
|
|
481
576
|
return toolResults;
|
|
482
577
|
});
|
|
483
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* Add the entry names of `assets` to the tool's enabled list (e.g. `enabledMcpjsonServers` in
|
|
581
|
+
* `.claude/settings.local.json`), for copies sync leaves as they are: frozen, or in place. The
|
|
582
|
+
* installer approves an entry only when it merges it, and the list's file is often gitignored, so a
|
|
583
|
+
* checkout whose config file came with it has no approval, and the tool prompts (ATK-867). Only an
|
|
584
|
+
* entry the config file holds now is approved, and the config file itself is not written. An asset
|
|
585
|
+
* excluded for the tool, or whose placement has no enabled list, adds nothing. Returns the names added.
|
|
586
|
+
*/
|
|
587
|
+
async function approveEnabledEntries(assets, adapter, projectDir, onProgress) {
|
|
588
|
+
const added = [];
|
|
589
|
+
for (const asset of assets) {
|
|
590
|
+
const placement = adapter.placements[asset.type];
|
|
591
|
+
const { configFile, configKey, disabledListKey, enabledListFile, enabledListKey } = placement ?? {};
|
|
592
|
+
if (!configFile || !configKey || !enabledListFile || !enabledListKey || isExcludedForTool(asset, adapter.tool)) {
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
const prefix = `${configKey}.`;
|
|
596
|
+
const recorded = getConfigEntriesForTool(asset, adapter)
|
|
597
|
+
.filter((entry) => entry.key.startsWith(prefix))
|
|
598
|
+
.map((entry) => entry.key.slice(prefix.length));
|
|
599
|
+
if (recorded.length === 0)
|
|
600
|
+
continue;
|
|
601
|
+
const configPath = fromRoot(projectDir, configFile);
|
|
602
|
+
let entries;
|
|
603
|
+
try {
|
|
604
|
+
entries = (await readConfigFile(configPath, resolveConfigFormat(configPath, placement)))[configKey];
|
|
605
|
+
}
|
|
606
|
+
catch {
|
|
607
|
+
// No config file, or one that doesn't parse: there is nothing in it to approve.
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
const present = typeof entries === 'object' && entries !== null ? recorded.filter((name) => Object.hasOwn(entries, name)) : [];
|
|
611
|
+
if (present.length === 0)
|
|
612
|
+
continue;
|
|
613
|
+
added.push(...(await addToEnabledList(fromRoot(projectDir, enabledListFile), enabledListKey, present, {
|
|
614
|
+
disabledListKey,
|
|
615
|
+
onProgress,
|
|
616
|
+
})));
|
|
617
|
+
}
|
|
618
|
+
return added;
|
|
619
|
+
}
|
|
484
620
|
/** The hint for a tool with an empty lockfile: setup has run (sync needs it), so the next step is an install. */
|
|
485
621
|
function emptyLockfileHint(toolName, scope) {
|
|
486
622
|
return `Run "${scopedCommand('atk install <asset>', scope)}" to install assets for ${toolName}`;
|
|
@@ -490,6 +626,32 @@ function isLockfileReadFailure(error, projectDir) {
|
|
|
490
626
|
return (error instanceof LockfileError ||
|
|
491
627
|
(error instanceof Error && 'path' in error && error.path === getLockfilePath(projectDir)));
|
|
492
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* Find (in a dry run) or remove the files another version left in each copy's folder for the tool
|
|
631
|
+
* (see `findLeftoverFiles`), per asset. The copy itself stands either way, so a failure is a warning;
|
|
632
|
+
* one every asset would hit (an expired sign-in) is said once and ends the pass.
|
|
633
|
+
*/
|
|
634
|
+
async function leftoverFilesFor(copies, { adapter, dryRun, lockfile, onProgress, projectDir, registry, toolName, }) {
|
|
635
|
+
const run = dryRun ? findLeftoverFiles : removeLeftoverFiles;
|
|
636
|
+
const verb = dryRun ? 'check' : 'remove';
|
|
637
|
+
const found = [];
|
|
638
|
+
for (const { asset, registryFilesOnly } of copies) {
|
|
639
|
+
try {
|
|
640
|
+
const paths = await run(asset, adapter, projectDir, { lockfile, onProgress, registry, registryFilesOnly });
|
|
641
|
+
if (paths.length > 0)
|
|
642
|
+
found.push(toSyncLeftoverFiles(asset, paths, projectDir));
|
|
643
|
+
}
|
|
644
|
+
catch (error) {
|
|
645
|
+
if (isRunWide(error)) {
|
|
646
|
+
onProgress?.(`Warning: Failed to ${verb} the files other versions left for ${toolName} — ${errorMessage(error)}`);
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
onProgress?.(`Warning: Failed to ${verb} the files another version of ` +
|
|
650
|
+
`${formatOrgName(asset.org, asset.name)} left for ${toolName} — ${errorMessage(error)}`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return found;
|
|
654
|
+
}
|
|
493
655
|
/** A tool result's `localEdits`, absent when there are none. */
|
|
494
656
|
function localEditsField({ localEdits }) {
|
|
495
657
|
return localEdits.length > 0 ? { localEdits } : {};
|
|
@@ -505,6 +667,15 @@ function scopeSwitchError(registry, entry, scope) {
|
|
|
505
667
|
const { message, ...guidance } = scopeSwitchGuidance(entry, current.asset, 'sync', scope);
|
|
506
668
|
return new SyncError(message, guidance);
|
|
507
669
|
}
|
|
670
|
+
function toSyncLeftoverFiles({ name, org, type, version }, paths, projectDir) {
|
|
671
|
+
return {
|
|
672
|
+
files: paths.map((path) => toRelativePosix(projectDir, path)),
|
|
673
|
+
name,
|
|
674
|
+
...(org ? { org } : {}),
|
|
675
|
+
type,
|
|
676
|
+
version,
|
|
677
|
+
};
|
|
678
|
+
}
|
|
508
679
|
function toSyncRemoval({ name, org, type }) {
|
|
509
680
|
return { name, ...(org ? { org } : {}), type };
|
|
510
681
|
}
|