@agentage/cli 0.51.0 → 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 +95 -127
- 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 +58 -16
- 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 -95
- 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/stack-owner.d.ts +4 -0
- package/dist/commands/extension/stack-owner.js +45 -0
- 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 +12 -11
- package/dist/commands/extension/up.js +65 -71
- 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/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
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { secretsFor } from '../../core/loader/secrets.js';
|
|
2
|
-
const ENTER = ['\r', '\n', '\u0004'];
|
|
3
|
-
const CTRL_C = '\u0003';
|
|
4
|
-
const BACKSPACE = '\u007f';
|
|
5
|
-
// One keypress: the answer so far, or null once Enter ends it.
|
|
6
|
-
const typed = (answer, char) => {
|
|
7
|
-
if (ENTER.includes(char))
|
|
8
|
-
return null;
|
|
9
|
-
return char === BACKSPACE ? answer.slice(0, -1) : answer + char;
|
|
10
|
-
};
|
|
11
|
-
// Raw mode keeps the answer off the screen; Ctrl+C still interrupts once the terminal is restored.
|
|
12
|
-
const readHidden = (question) => new Promise((resolve) => {
|
|
13
|
-
const { stdin, stderr } = process;
|
|
14
|
-
let answer = '';
|
|
15
|
-
const onData = (chunk) => {
|
|
16
|
-
for (const char of chunk.toString('utf-8')) {
|
|
17
|
-
const next = char === CTRL_C ? null : typed(answer, char);
|
|
18
|
-
if (next === null)
|
|
19
|
-
return finish(char === CTRL_C);
|
|
20
|
-
answer = next;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const finish = (interrupted) => {
|
|
24
|
-
stdin.off('data', onData).setRawMode(false).pause();
|
|
25
|
-
stderr.write('\n');
|
|
26
|
-
resolve(answer);
|
|
27
|
-
if (interrupted)
|
|
28
|
-
process.kill(process.pid, 'SIGINT');
|
|
29
|
-
};
|
|
30
|
-
stderr.write(question);
|
|
31
|
-
stdin.setRawMode(true).resume().on('data', onData);
|
|
32
|
-
});
|
|
33
|
-
const terminal = () => ({ isTTY: process.stdin.isTTY === true, prompt: readHidden });
|
|
34
|
-
const nameOf = ({ id, key }) => `${id}.${key}`;
|
|
35
|
-
// Before loading: a terminal is asked for each missing secret, anything else gets the list.
|
|
36
|
-
export const askSecrets = async (missing, io = terminal()) => {
|
|
37
|
-
if (missing.length === 0)
|
|
38
|
-
return;
|
|
39
|
-
if (!io.isTTY)
|
|
40
|
-
return void console.log(`secrets to set: ${missing.map(nameOf).join(', ')}`);
|
|
41
|
-
for (const secret of missing) {
|
|
42
|
-
const described = secret.description === null ? '' : ` (${secret.description})`;
|
|
43
|
-
const value = await io.prompt(`${nameOf(secret)}${described}: `);
|
|
44
|
-
if (value !== '')
|
|
45
|
-
await secretsFor(secret.id).set(secret.key, value);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type Profile } from '../profile/schema.js';
|
|
2
|
-
import { type Npm, type NpmCommand } from './npm.js';
|
|
3
|
-
import { type TreeFiles } from './tree.js';
|
|
4
|
-
export type InstallSet = Pick<Profile, 'extensions' | 'registries'> & {
|
|
5
|
-
lock?: Record<string, unknown> | null;
|
|
6
|
-
};
|
|
7
|
-
export interface InstallPlan extends TreeFiles {
|
|
8
|
-
extensionsDir: string;
|
|
9
|
-
install: Record<string, string>;
|
|
10
|
-
registries: Record<string, string>;
|
|
11
|
-
npm: NpmCommand | null;
|
|
12
|
-
tree: string | null;
|
|
13
|
-
reuse: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface InstallResult {
|
|
16
|
-
tree: string;
|
|
17
|
-
npm: NpmCommand | null;
|
|
18
|
-
reused: boolean;
|
|
19
|
-
count: number;
|
|
20
|
-
}
|
|
21
|
-
export declare const planInstall: (set: InstallSet) => InstallPlan;
|
|
22
|
-
export declare const lastLines: (output: string, count?: number) => string;
|
|
23
|
-
export declare const runNpmInto: (staging: string, command: NpmCommand, npm: Npm, packages?: string[]) => Promise<{
|
|
24
|
-
tree: string;
|
|
25
|
-
lock: string;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const refuseDrift: (dir: string) => void;
|
|
28
|
-
export declare const install: (set: InstallSet, prepare?: () => Promise<Npm>) => Promise<InstallResult>;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import {} from '../../lib/npm/npm-cli.js';
|
|
3
|
-
import { extensionsDir } from '../paths.js';
|
|
4
|
-
import {} from '../profile/schema.js';
|
|
5
|
-
import { lockAgrees, lockEntries, parseLock } from './compare-lock.js';
|
|
6
|
-
import { prepareNpm } from './npm.js';
|
|
7
|
-
import { driftLines, lockDrift } from './plan.js';
|
|
8
|
-
import { clearStaging, collectTrees, commitTree, discardTree, isComplete, LOCK_FILE, manifestText, npmrcText, pointCurrent, promoteFiles, readText, sortedSet, stageTree, treeName, withInstallLock, } from './tree.js';
|
|
9
|
-
// The current lock rides into the staged tree, so npm keeps every pin it can.
|
|
10
|
-
const lockPlan = (dir, install, raw) => {
|
|
11
|
-
if (Object.keys(install).length === 0) {
|
|
12
|
-
const tree = treeName([]);
|
|
13
|
-
return { lock: null, npm: null, tree, reuse: isComplete(dir, tree) };
|
|
14
|
-
}
|
|
15
|
-
const lock = parseLock(raw);
|
|
16
|
-
if (lock === null)
|
|
17
|
-
return { lock: null, npm: 'install', tree: null, reuse: false };
|
|
18
|
-
if (!lockAgrees(lock, install))
|
|
19
|
-
return { lock: raw, npm: 'install', tree: null, reuse: false };
|
|
20
|
-
const tree = treeName(lockEntries(lock));
|
|
21
|
-
const reuse = isComplete(dir, tree);
|
|
22
|
-
return { lock: raw, npm: reuse ? null : 'ci', tree, reuse };
|
|
23
|
-
};
|
|
24
|
-
// Reads only: `setup --dry-run` prints this and stops.
|
|
25
|
-
export const planInstall = (set) => {
|
|
26
|
-
const dir = extensionsDir();
|
|
27
|
-
const install = sortedSet(set.extensions);
|
|
28
|
-
const registries = sortedSet(set.registries);
|
|
29
|
-
const files = { manifest: manifestText(install), npmrc: npmrcText(registries) };
|
|
30
|
-
const raw = set.lock ? `${JSON.stringify(set.lock, null, 2)}\n` : readText(join(dir, LOCK_FILE));
|
|
31
|
-
const lock = lockPlan(dir, install, raw);
|
|
32
|
-
return { extensionsDir: dir, install, registries, ...files, ...lock };
|
|
33
|
-
};
|
|
34
|
-
// npm's last lines, enough to see why it failed.
|
|
35
|
-
export const lastLines = (output, count = 20) => output
|
|
36
|
-
.split(/\r?\n/)
|
|
37
|
-
.filter((line) => line.trim() !== '')
|
|
38
|
-
.slice(-count)
|
|
39
|
-
.join('\n');
|
|
40
|
-
const npmFailure = (command, res) => new Error(`npm ${command} failed (exit ${res.code}); extensions/current is unchanged\n` +
|
|
41
|
-
lastLines(`${res.stdout}\n${res.stderr}`));
|
|
42
|
-
// The staged tree's name and lock text, once npm succeeded in it; `packages` limits an update.
|
|
43
|
-
export const runNpmInto = async (staging, command, npm, packages = []) => {
|
|
44
|
-
const res = await npm(command, staging, packages);
|
|
45
|
-
if (res.code !== 0)
|
|
46
|
-
throw npmFailure(command, res);
|
|
47
|
-
const lock = readText(join(staging, LOCK_FILE));
|
|
48
|
-
const parsed = parseLock(lock);
|
|
49
|
-
if (lock === null || parsed === null)
|
|
50
|
-
throw new Error(`npm ${command} wrote no usable ${LOCK_FILE}`);
|
|
51
|
-
return { tree: treeName(lockEntries(parsed)), lock };
|
|
52
|
-
};
|
|
53
|
-
const build = async (plan, prepare) => {
|
|
54
|
-
const npm = plan.npm === null ? null : await prepare();
|
|
55
|
-
const staging = stageTree(plan.extensionsDir, plan);
|
|
56
|
-
try {
|
|
57
|
-
const built = npm === null || plan.npm === null
|
|
58
|
-
? { tree: treeName([]), lock: null }
|
|
59
|
-
: await runNpmInto(staging, plan.npm, npm);
|
|
60
|
-
commitTree(plan.extensionsDir, staging, built.tree);
|
|
61
|
-
return built;
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
discardTree(staging);
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
// A lock that disagrees with its own tree on a package's bytes is never built on.
|
|
69
|
-
export const refuseDrift = (dir) => {
|
|
70
|
-
const { integrity } = lockDrift(dir);
|
|
71
|
-
if (integrity.length > 0)
|
|
72
|
-
throw new Error(driftLines(integrity).join('\n'));
|
|
73
|
-
};
|
|
74
|
-
const execute = async (plan, prepare) => {
|
|
75
|
-
refuseDrift(plan.extensionsDir);
|
|
76
|
-
clearStaging(plan.extensionsDir);
|
|
77
|
-
const built = plan.reuse && plan.tree !== null
|
|
78
|
-
? { tree: plan.tree, lock: plan.lock }
|
|
79
|
-
: await build(plan, prepare);
|
|
80
|
-
pointCurrent(plan.extensionsDir, built.tree);
|
|
81
|
-
promoteFiles(plan.extensionsDir, { manifest: plan.manifest, lock: built.lock });
|
|
82
|
-
collectTrees(plan.extensionsDir, built.tree);
|
|
83
|
-
const count = Object.keys(plan.install).length;
|
|
84
|
-
return { tree: built.tree, npm: plan.npm, reused: plan.reuse, count };
|
|
85
|
-
};
|
|
86
|
-
// Plans again under the lock: a run that waited sees the tree the first one built.
|
|
87
|
-
export const install = async (set, prepare = prepareNpm) => withInstallLock(extensionsDir(), () => execute(planInstall(set), prepare));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type InstallSet } from './installer.js';
|
|
2
|
-
import { type Npm } from './npm.js';
|
|
3
|
-
export interface VersionChange {
|
|
4
|
-
name: string;
|
|
5
|
-
from: string | null;
|
|
6
|
-
to: string | null;
|
|
7
|
-
}
|
|
8
|
-
export interface Held {
|
|
9
|
-
name: string;
|
|
10
|
-
version: string;
|
|
11
|
-
newer: string;
|
|
12
|
-
engine: string;
|
|
13
|
-
kit: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface LatestResult {
|
|
16
|
-
changes: VersionChange[];
|
|
17
|
-
held: Held[];
|
|
18
|
-
unchanged: number;
|
|
19
|
-
tree: string | null;
|
|
20
|
-
current: boolean;
|
|
21
|
-
}
|
|
22
|
-
export type Staged = Omit<LatestResult, 'tree' | 'current'> & {
|
|
23
|
-
tree: string;
|
|
24
|
-
dir: string;
|
|
25
|
-
};
|
|
26
|
-
export type Check = (staged: Staged) => Promise<boolean>;
|
|
27
|
-
export declare const updateLatest: (set: InstallSet, prepare: () => Promise<Npm>, check: Check) => Promise<LatestResult>;
|