@agentage/cli 0.51.1 → 0.52.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/README.md +26 -15
- package/dist/commands/auth/setup.d.ts +2 -0
- package/dist/commands/auth/setup.js +4 -1
- package/dist/commands/daemon/daemon.d.ts +38 -0
- package/dist/commands/daemon/daemon.js +75 -0
- package/dist/commands/daemon/installer.d.ts +11 -0
- package/dist/commands/daemon/installer.js +87 -0
- package/dist/commands/daemon/move-plan.d.ts +17 -0
- package/dist/commands/daemon/move-plan.js +67 -0
- package/dist/commands/daemon/move-settings.d.ts +5 -0
- package/dist/commands/daemon/move-settings.js +50 -0
- package/dist/commands/daemon/move.d.ts +17 -0
- package/dist/commands/daemon/move.js +106 -0
- package/dist/commands/daemon/run.d.ts +6 -0
- package/dist/commands/daemon/run.js +36 -0
- package/dist/commands/extension/build.d.ts +13 -4
- package/dist/commands/extension/build.js +67 -25
- package/dist/commands/extension/configure.d.ts +26 -0
- package/dist/commands/extension/configure.js +100 -0
- package/dist/commands/extension/create-install.d.ts +26 -0
- package/dist/commands/extension/create-install.js +81 -0
- package/dist/commands/extension/create.d.ts +6 -1
- package/dist/commands/extension/create.js +33 -12
- package/dist/commands/extension/delegate.js +3 -1
- package/dist/commands/extension/doctor.d.ts +1 -1
- package/dist/commands/extension/doctor.js +8 -7
- package/dist/commands/extension/install-once.d.ts +17 -0
- package/dist/commands/extension/install-once.js +57 -0
- package/dist/commands/extension/kit-tool.d.ts +1 -1
- package/dist/commands/extension/lifecycle-commands.d.ts +19 -0
- package/dist/commands/extension/lifecycle-commands.js +80 -0
- package/dist/commands/extension/lifecycle-list.d.ts +26 -0
- package/dist/commands/extension/lifecycle-list.js +92 -0
- package/dist/commands/extension/lifecycle.d.ts +41 -0
- package/dist/commands/extension/lifecycle.js +142 -0
- package/dist/commands/extension/line.d.ts +1 -0
- package/dist/commands/extension/line.js +2 -0
- package/dist/commands/extension/list.d.ts +4 -14
- package/dist/commands/extension/list.js +11 -96
- package/dist/commands/extension/package-build.d.ts +15 -0
- package/dist/commands/extension/package-build.js +51 -0
- package/dist/commands/extension/plan.d.ts +4 -2
- package/dist/commands/extension/plan.js +37 -37
- package/dist/commands/extension/profile-plan.d.ts +16 -0
- package/dist/commands/extension/profile-plan.js +48 -0
- package/dist/commands/extension/release.d.ts +2 -1
- package/dist/commands/extension/release.js +10 -9
- package/dist/commands/extension/row-lines.d.ts +1 -2
- package/dist/commands/extension/row-lines.js +5 -6
- package/dist/commands/extension/rows.js +6 -4
- package/dist/commands/extension/setup-cloud.d.ts +2 -2
- package/dist/commands/extension/setup-cloud.js +6 -5
- package/dist/commands/extension/setup-install.d.ts +8 -0
- package/dist/commands/extension/setup-install.js +56 -0
- package/dist/commands/extension/setup.d.ts +4 -1
- package/dist/commands/extension/setup.js +56 -18
- package/dist/commands/extension/sync.d.ts +6 -11
- package/dist/commands/extension/sync.js +8 -50
- package/dist/commands/extension/up-commands.d.ts +9 -0
- package/dist/commands/extension/up-commands.js +74 -0
- package/dist/commands/extension/up-local.d.ts +21 -0
- package/dist/commands/extension/up-local.js +94 -0
- package/dist/commands/extension/up-run.d.ts +23 -0
- package/dist/commands/extension/up-run.js +75 -0
- package/dist/commands/extension/up.d.ts +10 -10
- package/dist/commands/extension/up.js +62 -74
- package/dist/commands/update/update.d.ts +9 -1
- package/dist/commands/update/update.js +20 -6
- package/dist/core/installer/compare-lock.d.ts +0 -2
- package/dist/core/installer/compare-lock.js +0 -12
- package/dist/core/installer/compat.js +5 -3
- package/dist/core/installer/npm.d.ts +1 -0
- package/dist/core/installer/npm.js +6 -0
- package/dist/core/installer/old-tree.d.ts +3 -0
- package/dist/core/installer/old-tree.js +45 -0
- package/dist/core/installer/package-dir.d.ts +11 -0
- package/dist/core/installer/package-dir.js +53 -0
- package/dist/core/installer/resolve.js +1 -2
- package/dist/core/installer/tree.d.ts +0 -5
- package/dist/core/installer/tree.js +1 -25
- package/dist/core/kit-id.d.ts +1 -0
- package/dist/core/kit-id.js +20 -0
- package/dist/core/loader/discover.d.ts +7 -1
- package/dist/core/loader/discover.js +5 -4
- package/dist/core/loader/installed.d.ts +9 -0
- package/dist/core/loader/installed.js +51 -0
- package/dist/core/loader/manifest.d.ts +4 -0
- package/dist/core/loader/manifest.js +25 -3
- package/dist/core/loader/scan.d.ts +2 -1
- package/dist/core/loader/scan.js +17 -4
- package/dist/core/loader/secrets.d.ts +0 -7
- package/dist/core/loader/secrets.js +0 -11
- package/dist/core/loader/verbs.d.ts +0 -1
- package/dist/core/loader/verbs.js +1 -13
- package/dist/core/profile/machine.d.ts +0 -1
- package/dist/core/profile/machine.js +0 -5
- package/dist/lib/auth/introspect.js +1 -2
- package/dist/lib/auth/sign-in.js +3 -0
- package/dist/lib/child-env.d.ts +1 -0
- package/dist/lib/child-env.js +6 -0
- package/dist/lib/daemon/daemon-answer.d.ts +8 -0
- package/dist/lib/daemon/daemon-answer.js +38 -0
- package/dist/lib/daemon/daemon-client.d.ts +17 -0
- package/dist/lib/daemon/daemon-client.js +112 -0
- package/dist/lib/daemon/daemon-file.d.ts +16 -0
- package/dist/lib/daemon/daemon-file.js +30 -0
- package/dist/lib/daemon/daemon-health.d.ts +16 -0
- package/dist/lib/daemon/daemon-health.js +36 -0
- package/dist/lib/daemon/daemon-probe.d.ts +32 -0
- package/dist/lib/daemon/daemon-probe.js +41 -0
- package/dist/lib/daemon/daemon-stop.d.ts +13 -0
- package/dist/lib/daemon/daemon-stop.js +42 -0
- package/dist/lib/daemon/host-client.d.ts +40 -0
- package/dist/lib/daemon/host-client.js +45 -0
- package/dist/lib/exit-code.d.ts +2 -0
- package/dist/lib/exit-code.js +8 -0
- package/dist/lib/fs/json-file.d.ts +1 -0
- package/dist/lib/fs/json-file.js +1 -1
- package/dist/lib/json-output.d.ts +36 -0
- package/dist/lib/json-output.js +163 -0
- package/dist/lib/net/market-error.d.ts +12 -0
- package/dist/lib/net/market-error.js +28 -0
- package/dist/lib/net/market.d.ts +17 -2
- package/dist/lib/net/market.js +92 -18
- package/dist/lib/wait.d.ts +6 -0
- package/dist/lib/wait.js +17 -0
- package/dist/lib/with-action.d.ts +12 -0
- package/dist/lib/with-action.js +33 -0
- package/dist/program-deps.d.ts +2 -0
- package/dist/program-deps.js +95 -0
- package/dist/program.d.ts +29 -21
- package/dist/program.js +41 -75
- package/package.json +8 -6
- package/CHANGELOG.md +0 -68
- package/dist/commands/extension/install-load.d.ts +0 -7
- package/dist/commands/extension/install-load.js +0 -42
- package/dist/commands/extension/install.d.ts +0 -12
- package/dist/commands/extension/install.js +0 -49
- package/dist/commands/extension/latest.d.ts +0 -2
- package/dist/commands/extension/latest.js +0 -71
- package/dist/commands/extension/remove.d.ts +0 -15
- package/dist/commands/extension/remove.js +0 -86
- package/dist/commands/extension/secrets-prompt.d.ts +0 -6
- package/dist/commands/extension/secrets-prompt.js +0 -47
- package/dist/core/installer/installer.d.ts +0 -28
- package/dist/core/installer/installer.js +0 -87
- package/dist/core/installer/latest.d.ts +0 -27
- package/dist/core/installer/latest.js +0 -90
- package/dist/core/profile/edit.d.ts +0 -4
- package/dist/core/profile/edit.js +0 -27
package/dist/program.d.ts
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type SetupOptions } from './commands/auth/setup.js';
|
|
3
|
+
import { type DaemonOptions } from './commands/daemon/daemon.js';
|
|
3
4
|
import { type ExtensionBuildOptions, type ExtensionCheckOptions } from './commands/extension/build.js';
|
|
4
5
|
import { type ExtensionCreateOptions } from './commands/extension/create.js';
|
|
5
6
|
import { type ExtensionDoctorOptions } from './commands/extension/doctor.js';
|
|
6
|
-
import { type
|
|
7
|
-
import { type
|
|
8
|
-
import { type
|
|
7
|
+
import { type ConfigureOptions } from './commands/extension/configure.js';
|
|
8
|
+
import { type InstallOptions, type RemoveOptions } from './commands/extension/lifecycle.js';
|
|
9
|
+
import { type ExtensionUpdateOptions, type ListOptions } from './commands/extension/lifecycle-list.js';
|
|
9
10
|
import { type LoadKitTool } from './commands/extension/kit-tool.js';
|
|
10
11
|
import { type ExtensionReleaseOptions } from './commands/extension/release.js';
|
|
11
|
-
import { type ExtensionDownOptions, type ExtensionTokenOptions, type
|
|
12
|
+
import { type ExtensionDownOptions, type ExtensionTokenOptions, type ExtensionUpFlags } from './commands/extension/up.js';
|
|
12
13
|
import { type StatusOptions } from './commands/status/status.js';
|
|
13
14
|
import { type UpdateOptions } from './commands/update/update.js';
|
|
15
|
+
type Run<T> = (opts: T) => Promise<unknown>;
|
|
14
16
|
export interface ProgramDeps {
|
|
15
|
-
setup:
|
|
16
|
-
status:
|
|
17
|
-
update:
|
|
18
|
-
extensionInstall:
|
|
19
|
-
extensionRemove:
|
|
20
|
-
extensionList:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
setup: Run<SetupOptions>;
|
|
18
|
+
status: Run<StatusOptions>;
|
|
19
|
+
update: Run<UpdateOptions>;
|
|
20
|
+
extensionInstall: Run<InstallOptions>;
|
|
21
|
+
extensionRemove: Run<RemoveOptions>;
|
|
22
|
+
extensionList: Run<ListOptions>;
|
|
23
|
+
extensionUpdate: Run<ExtensionUpdateOptions>;
|
|
24
|
+
extensionEnabled: Run<{
|
|
25
|
+
id: string;
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
json?: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
extensionConfigure: Run<ConfigureOptions>;
|
|
30
|
+
extensionDoctor: Run<ExtensionDoctorOptions>;
|
|
31
|
+
extensionCreate: Run<ExtensionCreateOptions>;
|
|
32
|
+
extensionCheck: Run<ExtensionCheckOptions>;
|
|
33
|
+
extensionBuild: Run<ExtensionBuildOptions>;
|
|
34
|
+
extensionRelease: Run<ExtensionReleaseOptions>;
|
|
35
|
+
extensionUp: Run<ExtensionUpFlags>;
|
|
36
|
+
extensionDown: Run<ExtensionDownOptions>;
|
|
37
|
+
extensionToken: Run<ExtensionTokenOptions>;
|
|
38
|
+
daemon: Record<'status' | 'stop' | 'restart' | 'run', Run<DaemonOptions>>;
|
|
29
39
|
kitTool: LoadKitTool;
|
|
30
40
|
updateHint: () => string | null;
|
|
31
41
|
refreshUpdateCache: () => Promise<void>;
|
|
32
42
|
writeOut: (text: string) => void;
|
|
33
43
|
writeErr: (text: string) => void;
|
|
34
44
|
}
|
|
35
|
-
export declare const EXIT_OK = 0;
|
|
36
|
-
export declare const EXIT_FAILED = 1;
|
|
37
|
-
export declare const EXIT_USAGE = 2;
|
|
38
45
|
export declare const createProgram: (deps?: ProgramDeps, argv?: string[]) => Command;
|
|
39
46
|
export declare const run: (argv?: string[], deps?: ProgramDeps) => Promise<number>;
|
|
47
|
+
export {};
|
package/dist/program.js
CHANGED
|
@@ -1,75 +1,26 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
3
|
import { registerSetup } from './commands/auth/setup.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { registerDaemon } from './commands/daemon/daemon.js';
|
|
5
|
+
import {} from './commands/extension/build.js';
|
|
6
|
+
import {} from './commands/extension/create.js';
|
|
6
7
|
import { registerDelegates } from './commands/extension/delegate.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { signedInAccount } from './commands/extension/account.js';
|
|
8
|
+
import {} from './commands/extension/doctor.js';
|
|
9
|
+
import {} from './commands/extension/configure.js';
|
|
10
|
+
import {} from './commands/extension/lifecycle.js';
|
|
11
|
+
import {} from './commands/extension/lifecycle-list.js';
|
|
12
|
+
import { registerExtension } from './commands/extension/list.js';
|
|
13
13
|
import { KIT_EXIT } from './commands/extension/kit-commands.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
14
|
+
import {} from './commands/extension/kit-tool.js';
|
|
15
|
+
import {} from './commands/extension/release.js';
|
|
16
|
+
import {} from './commands/extension/up.js';
|
|
17
|
+
import { registerStatus } from './commands/status/status.js';
|
|
18
|
+
import { registerUpdate } from './commands/update/update.js';
|
|
19
|
+
import { takeExit } from './lib/exit-code.js';
|
|
20
|
+
import { messageOf, writeError } from './lib/json-output.js';
|
|
21
|
+
import { ACTION_FAILED, EXIT_FAILED, EXIT_OK, EXIT_USAGE, pinned, withAction, } from './lib/with-action.js';
|
|
22
|
+
import { defaultDeps } from './program-deps.js';
|
|
23
23
|
import { VERSION } from './utils/version.js';
|
|
24
|
-
const setupDeps = {
|
|
25
|
-
ensureSignedIn: (signInOpts) => ensureSignedIn(signInOpts),
|
|
26
|
-
signOut: () => signOut(),
|
|
27
|
-
printStatus: (opts) => runStatus(opts, statusDeps(false)),
|
|
28
|
-
};
|
|
29
|
-
// What a profile edit reaches: npm, and the account it syncs with when signed in.
|
|
30
|
-
const editDeps = { npm: () => prepareNpm(), npmMajor: () => npmMajor(), account: signedInAccount };
|
|
31
|
-
const defaultDeps = {
|
|
32
|
-
setup: (opts) => runExtensionSetup(opts, { ...setupDeps, ...editDeps }),
|
|
33
|
-
status: (opts) => runStatus(opts),
|
|
34
|
-
update: (opts) => runUpdate(opts),
|
|
35
|
-
extensionInstall: (opts) => runExtensionInstall(opts, {
|
|
36
|
-
...editDeps,
|
|
37
|
-
manifest: () => prepareManifest(),
|
|
38
|
-
market: openMarket(),
|
|
39
|
-
}),
|
|
40
|
-
extensionRemove: (opts) => runExtensionRemove(opts, { ...editDeps, io: terminalIo() }),
|
|
41
|
-
extensionList: (opts) => runExtensionList(opts, openMarket()),
|
|
42
|
-
extensionDoctor: (opts) => runExtensionDoctor(opts),
|
|
43
|
-
extensionCreate: (opts) => runExtensionCreate(opts),
|
|
44
|
-
extensionCheck: (opts) => runExtensionCheck(opts),
|
|
45
|
-
extensionBuild: (opts) => runExtensionBuild(opts),
|
|
46
|
-
extensionRelease: (opts) => runExtensionRelease(opts),
|
|
47
|
-
extensionUp: (opts) => runExtensionUp(opts),
|
|
48
|
-
extensionDown: (opts) => runExtensionDown(opts),
|
|
49
|
-
extensionToken: (opts) => runExtensionToken(opts),
|
|
50
|
-
kitTool: loadKitTool,
|
|
51
|
-
updateHint,
|
|
52
|
-
refreshUpdateCache: () => refreshUpdateCache(),
|
|
53
|
-
writeOut: (text) => void process.stdout.write(text),
|
|
54
|
-
writeErr: (text) => void process.stderr.write(text),
|
|
55
|
-
};
|
|
56
|
-
export const EXIT_OK = 0;
|
|
57
|
-
export const EXIT_FAILED = 1;
|
|
58
|
-
export const EXIT_USAGE = 2;
|
|
59
|
-
const ACTION_FAILED = 'agentage.actionFailed';
|
|
60
|
-
const messageOf = (err) => (err instanceof Error ? err.message : String(err));
|
|
61
|
-
// One failure path: a red stderr line, exit 1; an extension's --help or usage error keeps its code.
|
|
62
|
-
const withAction = (deps, fn, prefix = '') => async (opts) => {
|
|
63
|
-
try {
|
|
64
|
-
await fn(opts);
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
if (err instanceof CommanderError)
|
|
68
|
-
throw err;
|
|
69
|
-
deps.writeErr(`${chalk.red(`${prefix}${messageOf(err)}`)}\n`);
|
|
70
|
-
throw new CommanderError(EXIT_FAILED, ACTION_FAILED, messageOf(err));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
24
|
// status and update report update state themselves; the hint never touches --json stdout.
|
|
74
25
|
const hintAfter = (deps) => (_program, action) => {
|
|
75
26
|
if (action.name() === 'status' || action.name() === 'update')
|
|
@@ -85,9 +36,12 @@ const addExtensions = (program, deps, argv) => {
|
|
|
85
36
|
install: withAction(deps, deps.extensionInstall),
|
|
86
37
|
remove: withAction(deps, deps.extensionRemove),
|
|
87
38
|
list: withAction(deps, deps.extensionList),
|
|
88
|
-
|
|
39
|
+
update: withAction(deps, deps.extensionUpdate),
|
|
40
|
+
enabled: withAction(deps, deps.extensionEnabled),
|
|
41
|
+
configure: withAction(deps, deps.extensionConfigure),
|
|
42
|
+
doctor: withAction(deps, deps.extensionDoctor, '', pinned),
|
|
89
43
|
create: withAction(deps, deps.extensionCreate),
|
|
90
|
-
check: withAction(deps, deps.extensionCheck),
|
|
44
|
+
check: withAction(deps, deps.extensionCheck, '', pinned),
|
|
91
45
|
build: withAction(deps, deps.extensionBuild),
|
|
92
46
|
release: withAction(deps, deps.extensionRelease),
|
|
93
47
|
up: withAction(deps, deps.extensionUp),
|
|
@@ -111,14 +65,21 @@ export const createProgram = (deps = defaultDeps, argv = process.argv) => {
|
|
|
111
65
|
.configureOutput({ writeOut: deps.writeOut, writeErr: deps.writeErr })
|
|
112
66
|
.addHelpText('after', '\nNew here? Run: agentage setup to connect this machine.')
|
|
113
67
|
.hook('postAction', hintAfter(deps));
|
|
114
|
-
registerSetup(program, withAction(deps, deps.setup, 'Setup failed: '));
|
|
115
|
-
registerStatus(program, withAction(deps, deps.status));
|
|
68
|
+
registerSetup(program, withAction(deps, deps.setup, 'Setup failed: ', (o) => !!(o.dryRun || o.check)));
|
|
69
|
+
registerStatus(program, withAction(deps, deps.status, '', pinned));
|
|
116
70
|
registerUpdate(program, withAction(deps, deps.update));
|
|
71
|
+
const daemon = (fn) => withAction(deps, fn);
|
|
72
|
+
registerDaemon(program, {
|
|
73
|
+
status: daemon(deps.daemon.status),
|
|
74
|
+
stop: daemon(deps.daemon.stop),
|
|
75
|
+
restart: daemon(deps.daemon.restart),
|
|
76
|
+
run: daemon(deps.daemon.run),
|
|
77
|
+
});
|
|
117
78
|
addExtensions(program, deps, argv);
|
|
118
79
|
return program;
|
|
119
80
|
};
|
|
120
|
-
// --help and --version stay 0; a kit command keeps its code;
|
|
121
|
-
const exitCodeOf = (err, deps) => {
|
|
81
|
+
// --help and --version stay 0; a kit command keeps its code; other commander errors are usage.
|
|
82
|
+
const exitCodeOf = (err, deps, argv) => {
|
|
122
83
|
if (!(err instanceof CommanderError)) {
|
|
123
84
|
deps.writeErr(`${chalk.red(messageOf(err))}\n`);
|
|
124
85
|
return EXIT_FAILED;
|
|
@@ -127,7 +88,12 @@ const exitCodeOf = (err, deps) => {
|
|
|
127
88
|
return EXIT_FAILED;
|
|
128
89
|
if (err.code === KIT_EXIT)
|
|
129
90
|
return err.exitCode;
|
|
130
|
-
|
|
91
|
+
if (err.exitCode === 0)
|
|
92
|
+
return EXIT_OK;
|
|
93
|
+
if (!argv.includes('--json'))
|
|
94
|
+
return EXIT_USAGE;
|
|
95
|
+
writeError(deps, err, 'usage'); // a usage error under --json is still one envelope
|
|
96
|
+
return EXIT_FAILED;
|
|
131
97
|
};
|
|
132
98
|
// Returns the exit code instead of exiting, so piped stdout is never cut short.
|
|
133
99
|
export const run = async (argv = process.argv, deps = defaultDeps) => {
|
|
@@ -135,9 +101,9 @@ export const run = async (argv = process.argv, deps = defaultDeps) => {
|
|
|
135
101
|
chalk.level = 0; // chalk ignores NO_COLOR on its own
|
|
136
102
|
try {
|
|
137
103
|
await createProgram(deps, argv).parseAsync(argv);
|
|
138
|
-
return EXIT_OK;
|
|
104
|
+
return takeExit() ?? EXIT_OK;
|
|
139
105
|
}
|
|
140
106
|
catch (err) {
|
|
141
|
-
return exitCodeOf(err, deps);
|
|
107
|
+
return exitCodeOf(err, deps, argv);
|
|
142
108
|
}
|
|
143
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "The agentage CLI - connect this machine to agentage from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/agentage/cli/issues"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
"CHANGELOG.md"
|
|
34
|
+
"dist"
|
|
36
35
|
],
|
|
37
36
|
"engines": {
|
|
38
37
|
"node": ">=22.0.0",
|
|
@@ -43,8 +42,8 @@
|
|
|
43
42
|
"type-check": "tsc --noEmit && tsc -p fixtures",
|
|
44
43
|
"lint": "eslint src e2e fixtures",
|
|
45
44
|
"lint:fix": "eslint src e2e fixtures --fix",
|
|
46
|
-
"format": "prettier --write \"{src,e2e}/**/*.ts\" \"fixtures/**/*.{js,json}\"",
|
|
47
|
-
"format:check": "prettier --check \"{src,e2e}/**/*.ts\" \"fixtures/**/*.{js,json}\"",
|
|
45
|
+
"format": "prettier --write \"{src,e2e}/**/*.ts\" \"fixtures/**/*.{js,json}\" \"{docs,e2e}/**/*.md\" README.md CLAUDE.md",
|
|
46
|
+
"format:check": "prettier --check \"{src,e2e}/**/*.ts\" \"fixtures/**/*.{js,json}\" \"{docs,e2e}/**/*.md\" README.md CLAUDE.md",
|
|
48
47
|
"test": "vitest run",
|
|
49
48
|
"test:watch": "vitest",
|
|
50
49
|
"test:coverage": "vitest run --coverage",
|
|
@@ -55,13 +54,16 @@
|
|
|
55
54
|
"prepublishOnly": "npm run verify"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"@agentage/extension": "^0.
|
|
57
|
+
"@agentage/extension": "^0.14.0",
|
|
58
|
+
"@electric-sql/pglite": "^0.5.16",
|
|
59
59
|
"chalk": "^6.0.0",
|
|
60
60
|
"commander": "^15.0.0",
|
|
61
|
+
"express": "^5.3.0",
|
|
61
62
|
"open": "^11.0.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@playwright/test": "latest",
|
|
66
|
+
"@types/express": "5.0.6",
|
|
65
67
|
"@types/node": "latest",
|
|
66
68
|
"@typescript-eslint/eslint-plugin": "latest",
|
|
67
69
|
"@typescript-eslint/parser": "latest",
|
package/CHANGELOG.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to Agentage CLI will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## [0.0.4] - 2026-07-09
|
|
11
|
-
|
|
12
|
-
### Breaking
|
|
13
|
-
|
|
14
|
-
- Removed the standalone `agentage mcp` stdio command. MCP is now served by the local daemon over Streamable HTTP at `http://127.0.0.1:4243/mcp` (on by default; disable with `daemon start --no-mcp` or `AGENTAGE_DAEMON_NO_MCP=1`). Point clients at the daemon URL: `claude mcp add --transport http agentage http://127.0.0.1:4243/mcp`.
|
|
15
|
-
|
|
16
|
-
### New Features
|
|
17
|
-
|
|
18
|
-
- Account sync: the daemon syncs account (cloud) vaults, with live autodiscovery of new vaults and account-vault provisioning.
|
|
19
|
-
- `setup` now starts the daemon after a successful sign-in, so sync and MCP are ready immediately.
|
|
20
|
-
- `status` now reports the daemon (pid, port, uptime), MCP serving state, a `target` reachability check, and a per-vault breakdown (name, sync channel, status).
|
|
21
|
-
- Outgoing requests now identify the caller with `User-Agent` and CLI/daemon version headers.
|
|
22
|
-
|
|
23
|
-
### Improvements
|
|
24
|
-
|
|
25
|
-
- Auth: sessions refresh silently; a transient auth-server hiccup (429/5xx/network) is retried instead of being reported as a signed-out session.
|
|
26
|
-
- A credential for a different environment than the current target is now reported as an env mismatch (with a recovery hint), not a misleading "session expired".
|
|
27
|
-
- `status` auth line reads `signed in (session active)` rather than a raw UTC token-expiry timestamp.
|
|
28
|
-
- README rewritten for non-technical readers, with the full command and integration reference moved to `docs/reference.md`.
|
|
29
|
-
- Daemon hardened against CSRF and DNS rebinding on its local API; lifecycle and port-in-use races fixed.
|
|
30
|
-
- Sync: remote-URL allowlist and redaction; channel-based internal structure.
|
|
31
|
-
- Offline commands no longer hang; cleaner stdout/stderr discipline.
|
|
32
|
-
|
|
33
|
-
### Fixed
|
|
34
|
-
|
|
35
|
-
- Data integrity: concurrent writers can no longer silently drop registry updates. The advisory file lock now creates atomically (write-then-link) and never steals a live holder's lock under CPU contention.
|
|
36
|
-
- Packaging hygiene: dependency pins, trimmed npm tarball, removed tracked build artifacts.
|
|
37
|
-
|
|
38
|
-
### Internal
|
|
39
|
-
|
|
40
|
-
- `src/lib` and `src/commands` regrouped into domain folders; oversized modules split.
|
|
41
|
-
|
|
42
|
-
## [0.0.3] - 2026-06-27
|
|
43
|
-
|
|
44
|
-
### Fixed
|
|
45
|
-
|
|
46
|
-
- `status` now reaches the backend at the dedicated `api.<fqdn>` host (the apex `<fqdn>/api` was retired in the 2026-06-17 subdomain cutover), so production no longer reports the endpoint unreachable.
|
|
47
|
-
- `status` no longer crashes when the bearer maps to no active session (`get-session` returns `200 + null`); it now reports signed-out with a `run: agentage setup` hint.
|
|
48
|
-
|
|
49
|
-
## [0.0.2] - 2026-06-26
|
|
50
|
-
|
|
51
|
-
### New Features
|
|
52
|
-
- Add `setup` and `status` commands as part of the agentage Memory client reboot
|
|
53
|
-
- Add daemon autostart on boot/login (platform-aware configuration)
|
|
54
|
-
- Handle machine tombstoned state (410 response) gracefully in the daemon
|
|
55
|
-
|
|
56
|
-
### Improvements
|
|
57
|
-
- Route daemon version-mismatch notice and update notice to stderr for cleaner stdout output
|
|
58
|
-
- Reduce update-check cache from 24h to 1h for more timely update notifications
|
|
59
|
-
|
|
60
|
-
## [0.0.1] - 2026-06-12
|
|
61
|
-
|
|
62
|
-
### Added
|
|
63
|
-
|
|
64
|
-
- `setup` - browser OAuth 2.1 sign-in (Dynamic Client Registration + PKCE) with a
|
|
65
|
-
localhost callback; tokens stored in `~/.agentage/auth.json` (mode 0600); flags:
|
|
66
|
-
`--disconnect`, `--reauth`, `--no-browser`.
|
|
67
|
-
- `status` - one line per fact: CLI version, target, sign-in state, and endpoint
|
|
68
|
-
reachability (`--json` supported).
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type InstallSet } from '../../core/installer/installer.js';
|
|
2
|
-
import { type Npm } from '../../core/installer/npm.js';
|
|
3
|
-
import { type DiscoveredExtension } from '../../core/loader/discover.js';
|
|
4
|
-
export declare const line: (label: string, value: string) => string;
|
|
5
|
-
export declare const counted: (n: number) => string;
|
|
6
|
-
export declare const listSecrets: (extensions: DiscoveredExtension[]) => Promise<void>;
|
|
7
|
-
export declare const installAndLoad: (set: InstallSet, npm: () => Promise<Npm>, installed?: () => Promise<unknown>) => Promise<void>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { install } from '../../core/installer/installer.js';
|
|
2
|
-
import {} from '../../core/installer/npm.js';
|
|
3
|
-
import {} from '../../core/loader/discover.js';
|
|
4
|
-
import { missingSecrets } from '../../core/loader/secrets.js';
|
|
5
|
-
import { writeHeld } from '../../core/loader/verbs.js';
|
|
6
|
-
import { failedError, loadAndGather } from './doctor.js';
|
|
7
|
-
import { printWarnings, rowLines } from './row-lines.js';
|
|
8
|
-
import { gatherExtensions } from './rows.js';
|
|
9
|
-
import { askSecrets } from './secrets-prompt.js';
|
|
10
|
-
export const line = (label, value) => `${label.padEnd(10)} ${value}`;
|
|
11
|
-
export const counted = (n) => n === 0 ? 'no extensions' : `${n} extension${n === 1 ? '' : 's'}`;
|
|
12
|
-
const installLine = (result) => {
|
|
13
|
-
const how = result.reused ? 'reused' : result.npm ? `npm ${result.npm}` : 'npm skipped';
|
|
14
|
-
return line('install', `${counted(result.count)} in tree ${result.tree} (${how})`);
|
|
15
|
-
};
|
|
16
|
-
// Asks for, or lists, the secrets the extensions about to load declare and this machine lacks.
|
|
17
|
-
export const listSecrets = (extensions) => askSecrets(missingSecrets(extensions));
|
|
18
|
-
// Who holds each top-level verb is kept for the next install; one line per namespaced command.
|
|
19
|
-
const settleVerbs = ({ verbs }) => {
|
|
20
|
-
writeHeld(verbs.top);
|
|
21
|
-
for (const { id, name, why } of verbs.namespaced)
|
|
22
|
-
console.log(line('namespaced', `agentage ${id} ${name} (agentage ${name} ${why})`));
|
|
23
|
-
};
|
|
24
|
-
// Rows print either way, only a good install loads; `installed` runs before anything loads.
|
|
25
|
-
export const installAndLoad = async (set, npm, installed = async () => undefined) => {
|
|
26
|
-
const outcome = await install(set, npm).then((result) => ({ result, error: null }), (error) => ({ result: null, error }));
|
|
27
|
-
if (outcome.result)
|
|
28
|
-
console.log(installLine(outcome.result));
|
|
29
|
-
if (outcome.result)
|
|
30
|
-
await installed();
|
|
31
|
-
const gathered = outcome.result ? await loadAndGather(listSecrets) : await gatherExtensions();
|
|
32
|
-
for (const text of rowLines(gathered.status.extensions))
|
|
33
|
-
console.log(text);
|
|
34
|
-
if (outcome.result)
|
|
35
|
-
settleVerbs(gathered);
|
|
36
|
-
printWarnings(gathered.warnings);
|
|
37
|
-
if (outcome.error)
|
|
38
|
-
throw outcome.error;
|
|
39
|
-
const failed = failedError(gathered.status.extensions);
|
|
40
|
-
if (failed)
|
|
41
|
-
throw failed;
|
|
42
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type NpmManifest } from '../../core/installer/npm.js';
|
|
2
|
-
import { type Market } from '../../lib/net/market.js';
|
|
3
|
-
import { type EditDeps } from './sync.js';
|
|
4
|
-
export interface ExtensionInstallOptions {
|
|
5
|
-
name: string;
|
|
6
|
-
off?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface ExtensionInstallDeps extends EditDeps {
|
|
9
|
-
manifest: () => Promise<NpmManifest>;
|
|
10
|
-
market?: Market;
|
|
11
|
-
}
|
|
12
|
-
export declare const runExtensionInstall: (opts: ExtensionInstallOptions, deps: ExtensionInstallDeps) => Promise<void>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { needs } from '../../core/installer/compat.js';
|
|
2
|
-
import {} from '../../core/installer/npm.js';
|
|
3
|
-
import { registryLookup, resolveName } from '../../core/installer/resolve.js';
|
|
4
|
-
import { addExtension } from '../../core/profile/edit.js';
|
|
5
|
-
import { loadMachine, setDev } from '../../core/profile/machine.js';
|
|
6
|
-
import { editableProfile } from '../../core/profile/profile.js';
|
|
7
|
-
import {} from '../../lib/net/market.js';
|
|
8
|
-
import {} from '../../core/profile/schema.js';
|
|
9
|
-
import { installAndLoad, line } from './install-load.js';
|
|
10
|
-
import { finishEdit, pullForEdit } from './sync.js';
|
|
11
|
-
const addPackage = async (target, off, deps) => {
|
|
12
|
-
for (const newer of target.skipped)
|
|
13
|
-
console.log(line('skipped', needs(newer)));
|
|
14
|
-
const synced = await pullForEdit(deps);
|
|
15
|
-
const { id } = await loadMachine();
|
|
16
|
-
const note = line('added', `${target.name} ${target.spec}${off ? ' (off on this machine)' : ''}`);
|
|
17
|
-
const add = (profile) => addExtension(profile, target.name, target.spec, id, off);
|
|
18
|
-
await finishEdit(synced, add, deps, note);
|
|
19
|
-
};
|
|
20
|
-
// A dev extension is this machine's own: it replaces an installed copy, and never syncs.
|
|
21
|
-
const addDev = async (target, off, deps) => {
|
|
22
|
-
if (off)
|
|
23
|
-
throw new Error(`--off does not apply to ${target.path}: a dev extension always loads`);
|
|
24
|
-
await setDev(target.name, target.path);
|
|
25
|
-
if (target.kit)
|
|
26
|
-
console.log(line('linked', `${target.name} (working copy)`));
|
|
27
|
-
else
|
|
28
|
-
console.log(line('dev', `${target.name} ${target.path}`));
|
|
29
|
-
await installAndLoad(editableProfile(), deps.npm);
|
|
30
|
-
};
|
|
31
|
-
const ID = /^[a-z][a-z0-9-]*$/;
|
|
32
|
-
// A bare id takes the version the market's /latest names; a private entry has no npm package.
|
|
33
|
-
const marketName = async (name, market) => {
|
|
34
|
-
const latest = ID.test(name) ? await market?.latest(name) : null;
|
|
35
|
-
if (!latest)
|
|
36
|
-
return name;
|
|
37
|
-
if (latest.package === null)
|
|
38
|
-
throw new Error(`${name}: private entry, no npm package; it cannot be installed from npm`);
|
|
39
|
-
return `${latest.package}@${latest.version}`;
|
|
40
|
-
};
|
|
41
|
-
// Never signs in: the name is looked up in the registries the local profile routes.
|
|
42
|
-
export const runExtensionInstall = async (opts, deps) => {
|
|
43
|
-
const { registries } = editableProfile();
|
|
44
|
-
const target = await resolveName(await marketName(opts.name, deps.market), registryLookup(deps.manifest, registries));
|
|
45
|
-
if (target.kind === 'dev')
|
|
46
|
-
await addDev(target, opts.off === true, deps);
|
|
47
|
-
else
|
|
48
|
-
await addPackage(target, opts.off === true, deps);
|
|
49
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { needsText } from '../../core/installer/compat.js';
|
|
2
|
-
import {} from '../../core/installer/installer.js';
|
|
3
|
-
import { updateLatest, } from '../../core/installer/latest.js';
|
|
4
|
-
import {} from '../../core/installer/npm.js';
|
|
5
|
-
import { editableProfile, mutateProfile } from '../../core/profile/profile.js';
|
|
6
|
-
import { pushBody } from '../../core/profile/push.js';
|
|
7
|
-
import { loadAndGather } from './doctor.js';
|
|
8
|
-
import { line, listSecrets } from './install-load.js';
|
|
9
|
-
import { printWarnings, rowLines } from './row-lines.js';
|
|
10
|
-
import {} from './rows.js';
|
|
11
|
-
import { localLock, pullForEdit, pushApplied } from './sync.js';
|
|
12
|
-
const changeLine = ({ name, from, to }) => {
|
|
13
|
-
if (from === null)
|
|
14
|
-
return `+ add ${name} ${to}`;
|
|
15
|
-
if (to === null)
|
|
16
|
-
return `- remove ${name} ${from}`;
|
|
17
|
-
return `~ update ${name} ${from} -> ${to}`;
|
|
18
|
-
};
|
|
19
|
-
const heldLine = ({ name, version, newer, ...range }) => line('kept', `${name} ${version} (${newer} ${needsText(range)})`);
|
|
20
|
-
const printDiff = (result, tree) => {
|
|
21
|
-
for (const held of result.held)
|
|
22
|
-
console.log(heldLine(held));
|
|
23
|
-
for (const change of result.changes)
|
|
24
|
-
console.log(changeLine(change));
|
|
25
|
-
const counts = `${result.changes.length} updated, ${result.unchanged} unchanged`;
|
|
26
|
-
console.log(tree === null ? 'latest: nothing to update' : `latest: ${counts} in tree ${tree}`);
|
|
27
|
-
};
|
|
28
|
-
// Clean: nothing in the new tree failed to load or is invalid.
|
|
29
|
-
const notClean = (rows) => {
|
|
30
|
-
const bad = rows.filter((row) => row.state === 'failed' || row.state === 'invalid');
|
|
31
|
-
if (bad.length === 0)
|
|
32
|
-
return null;
|
|
33
|
-
const named = bad.map((row) => `${row.id ?? row.package} ${row.state}`).join(', ');
|
|
34
|
-
return new Error(`not updated: ${named}; extensions/current is unchanged`);
|
|
35
|
-
};
|
|
36
|
-
// Runs inside the install lock: the diff, then the new tree loaded before it becomes current.
|
|
37
|
-
const loadStaged = (outcome) => async (staged) => {
|
|
38
|
-
printDiff(staged, staged.tree);
|
|
39
|
-
const gathered = await loadAndGather(listSecrets, staged.dir);
|
|
40
|
-
for (const text of rowLines(gathered.status.extensions))
|
|
41
|
-
console.log(text);
|
|
42
|
-
printWarnings(gathered.warnings);
|
|
43
|
-
outcome.failure = notClean(gathered.status.extensions);
|
|
44
|
-
return outcome.failure === null;
|
|
45
|
-
};
|
|
46
|
-
// One `npm update` of `set`; throws when the new tree did not load clean.
|
|
47
|
-
const latestOnce = async (set, npm) => {
|
|
48
|
-
const outcome = { failure: null };
|
|
49
|
-
const result = await updateLatest(set, npm, loadStaged(outcome));
|
|
50
|
-
if (result.tree === null)
|
|
51
|
-
printDiff(result, null);
|
|
52
|
-
if (outcome.failure)
|
|
53
|
-
throw outcome.failure;
|
|
54
|
-
return result;
|
|
55
|
-
};
|
|
56
|
-
// The account's profile as it is, with the lock of the new tree once it loaded.
|
|
57
|
-
const applyLatest = (deps) => async (base) => {
|
|
58
|
-
await mutateProfile(() => base.profile);
|
|
59
|
-
const result = await latestOnce({ ...base.profile, lock: base.lock }, deps.npm);
|
|
60
|
-
const kept = { lock: base.lock, npmMajor: base.npmMajor };
|
|
61
|
-
return pushBody(base.profile, base, result.current ? await localLock(deps) : kept);
|
|
62
|
-
};
|
|
63
|
-
// `setup --latest`: never signs in; a copy of the account's profile is pushed after a clean load.
|
|
64
|
-
export const runSetupLatest = async (deps) => {
|
|
65
|
-
const synced = await pullForEdit(deps);
|
|
66
|
-
if (synced === null)
|
|
67
|
-
return void (await latestOnce(editableProfile(), deps.npm));
|
|
68
|
-
const done = await pushApplied(synced, applyLatest(deps), { lockCounts: true });
|
|
69
|
-
if (done.pushed)
|
|
70
|
-
console.log(line('profile', `pushed to your account (etag ${done.etag})`));
|
|
71
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type EditDeps } from './sync.js';
|
|
2
|
-
export interface ExtensionRemoveOptions {
|
|
3
|
-
name: string;
|
|
4
|
-
purge?: boolean;
|
|
5
|
-
yes?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface ConfirmIo {
|
|
8
|
-
isTTY: boolean;
|
|
9
|
-
prompt: (question: string) => Promise<string>;
|
|
10
|
-
}
|
|
11
|
-
export interface ExtensionRemoveDeps extends EditDeps {
|
|
12
|
-
io: ConfirmIo;
|
|
13
|
-
}
|
|
14
|
-
export declare const terminalIo: () => ConfirmIo;
|
|
15
|
-
export declare const runExtensionRemove: (opts: ExtensionRemoveOptions, deps: ExtensionRemoveDeps) => Promise<void>;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { createInterface } from 'node:readline/promises';
|
|
4
|
-
import { candidatesFor } from '../../core/installer/resolve.js';
|
|
5
|
-
import { ID_PATTERN } from '../../core/loader/manifest.js';
|
|
6
|
-
import { scan } from '../../core/loader/scan.js';
|
|
7
|
-
import { dataDir, stateDir } from '../../core/paths.js';
|
|
8
|
-
import { dropExtension } from '../../core/profile/edit.js';
|
|
9
|
-
import { loadMachine, setDev } from '../../core/profile/machine.js';
|
|
10
|
-
import { editableProfile } from '../../core/profile/profile.js';
|
|
11
|
-
import { installAndLoad, line } from './install-load.js';
|
|
12
|
-
import { finishEdit, pullForEdit } from './sync.js';
|
|
13
|
-
const askLine = async (question) => {
|
|
14
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
15
|
-
try {
|
|
16
|
-
return await rl.question(question);
|
|
17
|
-
}
|
|
18
|
-
finally {
|
|
19
|
-
rl.close();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export const terminalIo = () => ({
|
|
23
|
-
isTTY: process.stdin.isTTY === true,
|
|
24
|
-
prompt: askLine,
|
|
25
|
-
});
|
|
26
|
-
const idOf = (pkg, found) => {
|
|
27
|
-
const id = found.found.extensions.find((e) => e.pkg === pkg)?.id ?? null;
|
|
28
|
-
return id !== null && ID_PATTERN.test(id) ? id : null;
|
|
29
|
-
};
|
|
30
|
-
// A package name, then the names a short name stands for, then an extension id.
|
|
31
|
-
const targetOf = (input, found) => {
|
|
32
|
-
const names = new Set([...Object.keys(found.eff.install), ...Object.keys(found.eff.dev)]);
|
|
33
|
-
const pkg = [input, ...candidatesFor(input)].find((name) => names.has(name)) ??
|
|
34
|
-
found.found.extensions.find((e) => e.id === input)?.pkg;
|
|
35
|
-
if (pkg === undefined)
|
|
36
|
-
throw new Error(`${input} is not installed`);
|
|
37
|
-
return { pkg, id: idOf(pkg, found) };
|
|
38
|
-
};
|
|
39
|
-
// Checked against every extension the profile or a dev path names, not only what loads here.
|
|
40
|
-
const refuseDependents = (pkg, found) => {
|
|
41
|
-
const dependents = found.found.extensions
|
|
42
|
-
.filter((e) => e.pkg !== pkg && e.peers.includes(pkg) && !e.optionalPeers.includes(pkg))
|
|
43
|
-
.map((e) => e.id ?? e.pkg)
|
|
44
|
-
.join(', ');
|
|
45
|
-
if (dependents)
|
|
46
|
-
throw new Error(`${pkg} is needed by ${dependents}; remove ${dependents} first`);
|
|
47
|
-
};
|
|
48
|
-
// Asked before anything changes, so a refusal or Ctrl+C leaves everything as it was.
|
|
49
|
-
const purgeConfirmed = async (opts, target, io) => {
|
|
50
|
-
if (!opts.purge)
|
|
51
|
-
return false;
|
|
52
|
-
if (target.id === null)
|
|
53
|
-
throw new Error(`--purge needs the extension id of ${target.pkg}, which is not installed here`);
|
|
54
|
-
const data = dataDir(target.id);
|
|
55
|
-
if (opts.yes)
|
|
56
|
-
return true;
|
|
57
|
-
if (!io.isTTY)
|
|
58
|
-
throw new Error(`--purge without a terminal needs --yes (it deletes ${data})`);
|
|
59
|
-
return /^y(es)?$/i.test((await io.prompt(`delete ${data} and everything in it? [y/N] `)).trim());
|
|
60
|
-
};
|
|
61
|
-
// This machine's traces of it: the dev path, the state file and, with --purge, its data.
|
|
62
|
-
const dropHere = async ({ pkg, id }, found, purge) => {
|
|
63
|
-
if (pkg in found.eff.dev)
|
|
64
|
-
await setDev(pkg, null);
|
|
65
|
-
if (id !== null)
|
|
66
|
-
rmSync(join(stateDir(), `${id}.json`), { force: true });
|
|
67
|
-
console.log(line('removed', pkg));
|
|
68
|
-
if (!purge || id === null)
|
|
69
|
-
return;
|
|
70
|
-
rmSync(dataDir(id), { recursive: true, force: true });
|
|
71
|
-
console.log(line('purged', dataDir(id)));
|
|
72
|
-
};
|
|
73
|
-
// Nothing stays loaded to dispose: the CLI process loads extensions only for one command.
|
|
74
|
-
export const runExtensionRemove = async (opts, deps) => {
|
|
75
|
-
editableProfile(); // an invalid or newer profile.json stops here, before anything changes
|
|
76
|
-
const found = scan(await loadMachine());
|
|
77
|
-
const { pkg, id } = targetOf(opts.name, found);
|
|
78
|
-
refuseDependents(pkg, found);
|
|
79
|
-
const purge = await purgeConfirmed(opts, { pkg, id }, deps.io);
|
|
80
|
-
const inProfile = pkg in found.eff.install;
|
|
81
|
-
const synced = inProfile ? await pullForEdit(deps) : null;
|
|
82
|
-
await dropHere({ pkg, id }, found, purge);
|
|
83
|
-
if (!inProfile)
|
|
84
|
-
return installAndLoad(editableProfile(), deps.npm);
|
|
85
|
-
await finishEdit(synced, (profile) => dropExtension(profile, pkg, found.machine.id), deps);
|
|
86
|
-
};
|