@agentage/cli 0.39.0 → 0.41.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 +126 -25
- package/dist/commands/auth/setup.d.ts +8 -2
- package/dist/commands/auth/setup.js +38 -7
- package/dist/commands/extension/account.d.ts +5 -0
- package/dist/commands/extension/account.js +18 -0
- package/dist/commands/extension/build.d.ts +10 -0
- package/dist/commands/extension/build.js +27 -0
- package/dist/commands/extension/delegate.d.ts +6 -0
- package/dist/commands/extension/delegate.js +57 -0
- package/dist/commands/extension/doctor.d.ts +13 -0
- package/dist/commands/extension/doctor.js +44 -0
- package/dist/commands/extension/install-load.d.ts +7 -0
- package/dist/commands/extension/install-load.js +42 -0
- package/dist/commands/extension/install.d.ts +10 -0
- package/dist/commands/extension/install.js +38 -0
- package/dist/commands/extension/kit-commands.d.ts +13 -0
- package/dist/commands/extension/kit-commands.js +42 -0
- package/dist/commands/extension/kit-tool.d.ts +31 -0
- package/dist/commands/extension/kit-tool.js +5 -0
- package/dist/commands/extension/latest.d.ts +2 -0
- package/dist/commands/extension/latest.js +71 -0
- package/dist/commands/extension/list.d.ts +22 -0
- package/dist/commands/extension/list.js +116 -0
- package/dist/commands/extension/plan.d.ts +8 -0
- package/dist/commands/extension/plan.js +67 -0
- package/dist/commands/extension/remove.d.ts +15 -0
- package/dist/commands/extension/remove.js +86 -0
- package/dist/commands/extension/row-lines.d.ts +4 -0
- package/dist/commands/extension/row-lines.js +68 -0
- package/dist/commands/extension/rows.d.ts +58 -0
- package/dist/commands/extension/rows.js +67 -0
- package/dist/commands/extension/secrets-prompt.d.ts +6 -0
- package/dist/commands/extension/secrets-prompt.js +47 -0
- package/dist/commands/extension/setup-cloud.d.ts +6 -0
- package/dist/commands/extension/setup-cloud.js +98 -0
- package/dist/commands/extension/setup.d.ts +5 -0
- package/dist/commands/extension/setup.js +68 -0
- package/dist/commands/extension/sync.d.ts +22 -0
- package/dist/commands/extension/sync.js +81 -0
- package/dist/commands/extension/up.d.ts +22 -0
- package/dist/commands/extension/up.js +76 -0
- package/dist/commands/status/account-status.d.ts +3 -0
- package/dist/commands/status/account-status.js +27 -0
- package/dist/commands/status/status.d.ts +3 -2
- package/dist/commands/status/status.js +36 -36
- package/dist/core/installer/compare-lock.d.ts +8 -0
- package/dist/core/installer/compare-lock.js +51 -0
- package/dist/core/installer/compat.d.ts +20 -0
- package/dist/core/installer/compat.js +44 -0
- package/dist/core/installer/installer.d.ts +28 -0
- package/dist/core/installer/installer.js +87 -0
- package/dist/core/installer/latest.d.ts +27 -0
- package/dist/core/installer/latest.js +90 -0
- package/dist/core/installer/npm.d.ts +11 -0
- package/dist/core/installer/npm.js +76 -0
- package/dist/core/installer/plan.d.ts +25 -0
- package/dist/core/installer/plan.js +52 -0
- package/dist/core/installer/resolve.d.ts +26 -0
- package/dist/core/installer/resolve.js +140 -0
- package/dist/core/installer/tree.d.ts +21 -0
- package/dist/core/installer/tree.js +100 -0
- package/dist/core/kit-version.d.ts +1 -0
- package/dist/core/kit-version.js +15 -0
- package/dist/core/loader/config.d.ts +7 -0
- package/dist/core/loader/config.js +59 -0
- package/dist/core/loader/ctx.d.ts +16 -0
- package/dist/core/loader/ctx.js +76 -0
- package/dist/core/loader/dev-path.d.ts +1 -0
- package/dist/core/loader/dev-path.js +20 -0
- package/dist/core/loader/discover.d.ts +17 -11
- package/dist/core/loader/discover.js +50 -31
- package/dist/core/loader/dispose.d.ts +4 -0
- package/dist/core/loader/dispose.js +24 -0
- package/dist/core/loader/kit-manifest.d.ts +9 -0
- package/dist/core/loader/kit-manifest.js +52 -0
- package/dist/core/loader/load.d.ts +14 -0
- package/dist/core/loader/load.js +78 -0
- package/dist/core/loader/log.d.ts +3 -0
- package/dist/core/loader/log.js +23 -0
- package/dist/core/loader/manifest.d.ts +8 -4
- package/dist/core/loader/manifest.js +54 -12
- package/dist/core/loader/order.d.ts +2 -0
- package/dist/core/loader/order.js +20 -0
- package/dist/core/loader/register.d.ts +19 -0
- package/dist/core/loader/register.js +39 -0
- package/dist/core/loader/scan.d.ts +18 -0
- package/dist/core/loader/scan.js +34 -0
- package/dist/core/loader/secrets.d.ts +9 -0
- package/dist/core/loader/secrets.js +28 -0
- package/dist/core/loader/state.d.ts +4 -4
- package/dist/core/loader/state.js +17 -7
- package/dist/core/loader/states.d.ts +2 -2
- package/dist/core/loader/states.js +5 -5
- package/dist/core/loader/timeout.d.ts +1 -0
- package/dist/core/loader/timeout.js +8 -0
- package/dist/core/loader/use.d.ts +8 -0
- package/dist/core/loader/use.js +18 -0
- package/dist/core/loader/verbs.d.ts +15 -0
- package/dist/core/loader/verbs.js +57 -0
- package/dist/core/paths.d.ts +6 -1
- package/dist/core/paths.js +6 -1
- package/dist/core/profile/cloud.d.ts +53 -0
- package/dist/core/profile/cloud.js +109 -0
- package/dist/core/profile/edit.d.ts +4 -0
- package/dist/core/profile/edit.js +27 -0
- package/dist/core/profile/machine.d.ts +11 -11
- package/dist/core/profile/machine.js +66 -43
- package/dist/core/profile/merge.d.ts +1 -1
- package/dist/core/profile/merge.js +7 -2
- package/dist/core/profile/profile.d.ts +6 -6
- package/dist/core/profile/profile.js +50 -16
- package/dist/core/profile/push.d.ts +16 -0
- package/dist/core/profile/push.js +49 -0
- package/dist/core/profile/register.d.ts +5 -0
- package/dist/core/profile/register.js +57 -0
- package/dist/core/profile/schema.d.ts +3 -1
- package/dist/core/profile/schema.js +39 -17
- package/dist/core/semver-range.d.ts +1 -0
- package/dist/core/semver-range.js +8 -0
- package/dist/extension-test.d.ts +7 -0
- package/dist/extension-test.js +49 -0
- package/dist/extension.d.ts +83 -0
- package/dist/extension.js +6 -0
- package/dist/lib/auth/api.d.ts +2 -2
- package/dist/lib/auth/api.js +3 -3
- package/dist/lib/fs/file-lock.d.ts +3 -1
- package/dist/lib/fs/file-lock.js +26 -11
- package/dist/lib/fs/json-file.d.ts +1 -0
- package/dist/lib/fs/json-file.js +3 -2
- package/dist/lib/net/fetch.js +1 -1
- package/dist/lib/net/origins.d.ts +1 -0
- package/dist/lib/net/origins.js +11 -11
- package/dist/lib/npm/npm-cli.d.ts +2 -0
- package/dist/lib/npm/npm-cli.js +4 -4
- package/dist/program.d.ts +17 -1
- package/dist/program.js +61 -11
- package/package.json +9 -4
- package/dist/commands/plugins/status-print.d.ts +0 -2
- package/dist/commands/plugins/status-print.js +0 -44
- package/dist/commands/plugins/status-rows.d.ts +0 -51
- package/dist/commands/plugins/status-rows.js +0 -58
- package/dist/core/flag.d.ts +0 -1
- package/dist/core/flag.js +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plugin.js +0 -2
package/dist/lib/fs/json-file.js
CHANGED
|
@@ -27,11 +27,11 @@ const unlinkQuiet = (path) => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
// Unique temp sibling + chmod before rename: never half-written, never briefly world-readable.
|
|
30
|
-
export const
|
|
30
|
+
export const writeTextAtomic = (path, text, mode = 0o600) => {
|
|
31
31
|
const tmp = `${path}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
|
|
32
32
|
let renamed = false;
|
|
33
33
|
try {
|
|
34
|
-
writeFileSync(tmp,
|
|
34
|
+
writeFileSync(tmp, text, { encoding: 'utf-8', mode });
|
|
35
35
|
chmodSync(tmp, mode);
|
|
36
36
|
renameSync(tmp, path);
|
|
37
37
|
renamed = true;
|
|
@@ -41,3 +41,4 @@ export const writeJsonAtomic = (path, value, mode = 0o600) => {
|
|
|
41
41
|
unlinkQuiet(tmp);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
+
export const writeJsonAtomic = (path, value, mode = 0o600) => writeTextAtomic(path, JSON.stringify(value, null, 2) + '\n', mode);
|
package/dist/lib/net/fetch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requestHeaders } from './user-agent.js';
|
|
2
2
|
export const DEFAULT_TIMEOUT_MS = 10_000;
|
|
3
3
|
export const AUTH_TIMEOUT_MS = 15_000;
|
|
4
|
-
// Captured at load:
|
|
4
|
+
// Captured at load: extensions loaded later must not be able to swap the fetch that carries tokens.
|
|
5
5
|
const baseFetch = globalThis.fetch;
|
|
6
6
|
// redirect: 'manual' so a bearer or form body is never replayed to a redirect target.
|
|
7
7
|
export const cliFetch = (url, init = {}, opts = {}) => baseFetch(url, {
|
|
@@ -7,4 +7,5 @@ export interface Links {
|
|
|
7
7
|
export declare const normalizeFqdn: (raw?: string) => string;
|
|
8
8
|
export declare const siteFqdn: () => string;
|
|
9
9
|
export declare const environment: (fqdn: string) => Env;
|
|
10
|
+
export declare const apiOrigin: (fqdn: string) => string;
|
|
10
11
|
export declare const links: (fqdn: string) => Links;
|
package/dist/lib/net/origins.js
CHANGED
|
@@ -17,19 +17,19 @@ const stubOrigin = (fqdn) => {
|
|
|
17
17
|
return m ? `http://127.0.0.1:${m[1]}` : null;
|
|
18
18
|
};
|
|
19
19
|
export const environment = (fqdn) => isLocal(fqdn) || fqdn.startsWith('dev.') ? 'development' : 'production';
|
|
20
|
+
// The account routes (/v1/...) sit at the root of the API origin; `links().api` is its /api family.
|
|
21
|
+
export const apiOrigin = (fqdn) => {
|
|
22
|
+
const stub = stubOrigin(fqdn);
|
|
23
|
+
if (stub)
|
|
24
|
+
return stub;
|
|
25
|
+
return isLocal(fqdn) ? 'http://localhost:3001' : `https://api.${fqdn}`;
|
|
26
|
+
};
|
|
20
27
|
export const links = (fqdn) => {
|
|
21
28
|
const stub = stubOrigin(fqdn);
|
|
29
|
+
const api = `${apiOrigin(fqdn)}/api`;
|
|
22
30
|
if (stub)
|
|
23
|
-
return { site: stub, api
|
|
31
|
+
return { site: stub, api, auth: stub };
|
|
24
32
|
return isLocal(fqdn)
|
|
25
|
-
? {
|
|
26
|
-
|
|
27
|
-
api: 'http://localhost:3001/api',
|
|
28
|
-
auth: 'http://localhost:3010',
|
|
29
|
-
}
|
|
30
|
-
: {
|
|
31
|
-
site: `https://${fqdn}`,
|
|
32
|
-
api: `https://api.${fqdn}/api`,
|
|
33
|
-
auth: `https://auth.${fqdn}`,
|
|
34
|
-
};
|
|
33
|
+
? { site: 'http://localhost:3000', api, auth: 'http://localhost:3010' }
|
|
34
|
+
: { site: `https://${fqdn}`, api, auth: `https://auth.${fqdn}` };
|
|
35
35
|
};
|
|
@@ -7,11 +7,13 @@ export interface RunNpmOptions {
|
|
|
7
7
|
cwd?: string;
|
|
8
8
|
env?: NodeJS.ProcessEnv;
|
|
9
9
|
timeoutMs: number;
|
|
10
|
+
npmCli?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface ResolveNpmOptions {
|
|
12
13
|
execPath?: string;
|
|
13
14
|
env?: NodeJS.ProcessEnv;
|
|
14
15
|
}
|
|
15
16
|
export declare const resolveNpmCli: (opts?: ResolveNpmOptions) => string;
|
|
17
|
+
export declare const scrubNpmEnv: (parent: NodeJS.ProcessEnv, env?: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
16
18
|
export declare const runNpm: (args: string[], opts: RunNpmOptions) => Promise<NpmResult>;
|
|
17
19
|
export declare const requireNpm10: (run?: typeof runNpm) => Promise<string>;
|
package/dist/lib/npm/npm-cli.js
CHANGED
|
@@ -43,8 +43,8 @@ export const resolveNpmCli = (opts = {}) => {
|
|
|
43
43
|
};
|
|
44
44
|
const isScrubbed = (key) => /^npm_config_/i.test(key) || key.toUpperCase() === 'NODE_OPTIONS';
|
|
45
45
|
// Inherited npm_config_* (an `npx` or `npm run` parent) would redirect a global install.
|
|
46
|
-
const
|
|
47
|
-
...Object.fromEntries(Object.entries(
|
|
46
|
+
export const scrubNpmEnv = (parent, env = {}) => ({
|
|
47
|
+
...Object.fromEntries(Object.entries(parent).filter(([key]) => !isScrubbed(key))),
|
|
48
48
|
...env,
|
|
49
49
|
});
|
|
50
50
|
const failureNote = (err, timeoutMs) => {
|
|
@@ -55,10 +55,10 @@ const failureNote = (err, timeoutMs) => {
|
|
|
55
55
|
return `\nnpm could not run (${String(err.code ?? err.signal ?? 'unknown')})`;
|
|
56
56
|
};
|
|
57
57
|
export const runNpm = (args, opts) => new Promise((resolve) => {
|
|
58
|
-
const argv = [resolveNpmCli(), ...args, '--no-audit', '--no-fund'];
|
|
58
|
+
const argv = [opts.npmCli ?? resolveNpmCli(), ...args, '--no-audit', '--no-fund'];
|
|
59
59
|
const options = {
|
|
60
60
|
cwd: opts.cwd,
|
|
61
|
-
env:
|
|
61
|
+
env: scrubNpmEnv(process.env, opts.env),
|
|
62
62
|
timeout: opts.timeoutMs,
|
|
63
63
|
maxBuffer: MAX_BUFFER,
|
|
64
64
|
windowsHide: true,
|
package/dist/program.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type SetupOptions } from './commands/auth/setup.js';
|
|
3
|
+
import { type ExtensionBuildOptions } from './commands/extension/build.js';
|
|
4
|
+
import { type ExtensionDoctorOptions } from './commands/extension/doctor.js';
|
|
5
|
+
import { type ExtensionInstallOptions } from './commands/extension/install.js';
|
|
6
|
+
import { type ExtensionListOptions } from './commands/extension/list.js';
|
|
7
|
+
import { type ExtensionRemoveOptions } from './commands/extension/remove.js';
|
|
8
|
+
import { type LoadKitTool } from './commands/extension/kit-tool.js';
|
|
9
|
+
import { type ExtensionDownOptions, type ExtensionTokenOptions, type ExtensionUpOptions } from './commands/extension/up.js';
|
|
3
10
|
import { type StatusOptions } from './commands/status/status.js';
|
|
4
11
|
import { type UpdateOptions } from './commands/update/update.js';
|
|
5
12
|
export interface ProgramDeps {
|
|
6
13
|
setup: (opts: SetupOptions) => Promise<void>;
|
|
7
14
|
status: (opts: StatusOptions) => Promise<void>;
|
|
8
15
|
update: (opts: UpdateOptions) => Promise<void>;
|
|
16
|
+
extensionInstall: (opts: ExtensionInstallOptions) => Promise<void>;
|
|
17
|
+
extensionRemove: (opts: ExtensionRemoveOptions) => Promise<void>;
|
|
18
|
+
extensionList: (opts: ExtensionListOptions) => Promise<void>;
|
|
19
|
+
extensionDoctor: (opts: ExtensionDoctorOptions) => Promise<void>;
|
|
20
|
+
extensionBuild: (opts: ExtensionBuildOptions) => Promise<void>;
|
|
21
|
+
extensionUp: (opts: ExtensionUpOptions) => Promise<void>;
|
|
22
|
+
extensionDown: (opts: ExtensionDownOptions) => Promise<void>;
|
|
23
|
+
extensionToken: (opts: ExtensionTokenOptions) => Promise<void>;
|
|
24
|
+
kitTool: LoadKitTool;
|
|
9
25
|
updateHint: () => string | null;
|
|
10
26
|
refreshUpdateCache: () => Promise<void>;
|
|
11
27
|
writeOut: (text: string) => void;
|
|
@@ -14,5 +30,5 @@ export interface ProgramDeps {
|
|
|
14
30
|
export declare const EXIT_OK = 0;
|
|
15
31
|
export declare const EXIT_FAILED = 1;
|
|
16
32
|
export declare const EXIT_USAGE = 2;
|
|
17
|
-
export declare const createProgram: (deps?: ProgramDeps) => Command;
|
|
33
|
+
export declare const createProgram: (deps?: ProgramDeps, argv?: string[]) => Command;
|
|
18
34
|
export declare const run: (argv?: string[], deps?: ProgramDeps) => Promise<number>;
|
package/dist/program.js
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
|
-
import { registerSetup
|
|
4
|
-
import {
|
|
3
|
+
import { registerSetup } from './commands/auth/setup.js';
|
|
4
|
+
import { runExtensionBuild } from './commands/extension/build.js';
|
|
5
|
+
import { registerDelegates } from './commands/extension/delegate.js';
|
|
6
|
+
import { deprecatedCheck, runExtensionDoctor, } from './commands/extension/doctor.js';
|
|
7
|
+
import { runExtensionInstall } from './commands/extension/install.js';
|
|
8
|
+
import { registerExtension, runExtensionList, } from './commands/extension/list.js';
|
|
9
|
+
import { runExtensionRemove, terminalIo, } from './commands/extension/remove.js';
|
|
10
|
+
import { signedInAccount } from './commands/extension/account.js';
|
|
11
|
+
import { KIT_EXIT } from './commands/extension/kit-commands.js';
|
|
12
|
+
import { loadKitTool } from './commands/extension/kit-tool.js';
|
|
13
|
+
import { runExtensionSetup } from './commands/extension/setup.js';
|
|
14
|
+
import { runExtensionDown, runExtensionToken, runExtensionUp, } from './commands/extension/up.js';
|
|
15
|
+
import { registerStatus, runStatus, statusDeps, } from './commands/status/status.js';
|
|
5
16
|
import { registerUpdate, runUpdate } from './commands/update/update.js';
|
|
17
|
+
import { npmMajor, prepareManifest, prepareNpm } from './core/installer/npm.js';
|
|
6
18
|
import { ensureSignedIn, signOut } from './lib/auth/sign-in.js';
|
|
7
19
|
import { refreshUpdateCache, updateHint } from './lib/update/update-cache.js';
|
|
8
20
|
import { VERSION } from './utils/version.js';
|
|
21
|
+
const setupDeps = {
|
|
22
|
+
ensureSignedIn: (signInOpts) => ensureSignedIn(signInOpts),
|
|
23
|
+
signOut: () => signOut(),
|
|
24
|
+
printStatus: (opts) => runStatus(opts, statusDeps(false)),
|
|
25
|
+
};
|
|
26
|
+
// What a profile edit reaches: npm, and the account it syncs with when signed in.
|
|
27
|
+
const editDeps = { npm: () => prepareNpm(), npmMajor: () => npmMajor(), account: signedInAccount };
|
|
9
28
|
const defaultDeps = {
|
|
10
|
-
setup: (opts) =>
|
|
11
|
-
ensureSignedIn: (signInOpts) => ensureSignedIn(signInOpts),
|
|
12
|
-
signOut: () => signOut(),
|
|
13
|
-
printStatus: () => runStatus({}),
|
|
14
|
-
}),
|
|
29
|
+
setup: (opts) => runExtensionSetup(opts, { ...setupDeps, ...editDeps }),
|
|
15
30
|
status: (opts) => runStatus(opts),
|
|
16
31
|
update: (opts) => runUpdate(opts),
|
|
32
|
+
extensionInstall: (opts) => runExtensionInstall(opts, { ...editDeps, manifest: () => prepareManifest() }),
|
|
33
|
+
extensionRemove: (opts) => runExtensionRemove(opts, { ...editDeps, io: terminalIo() }),
|
|
34
|
+
extensionList: (opts) => runExtensionList(opts),
|
|
35
|
+
extensionDoctor: (opts) => runExtensionDoctor(opts),
|
|
36
|
+
extensionBuild: (opts) => runExtensionBuild(opts),
|
|
37
|
+
extensionUp: (opts) => runExtensionUp(opts),
|
|
38
|
+
extensionDown: (opts) => runExtensionDown(opts),
|
|
39
|
+
extensionToken: (opts) => runExtensionToken(opts),
|
|
40
|
+
kitTool: loadKitTool,
|
|
17
41
|
updateHint,
|
|
18
42
|
refreshUpdateCache: () => refreshUpdateCache(),
|
|
19
43
|
writeOut: (text) => void process.stdout.write(text),
|
|
@@ -24,12 +48,14 @@ export const EXIT_FAILED = 1;
|
|
|
24
48
|
export const EXIT_USAGE = 2;
|
|
25
49
|
const ACTION_FAILED = 'agentage.actionFailed';
|
|
26
50
|
const messageOf = (err) => (err instanceof Error ? err.message : String(err));
|
|
27
|
-
// One failure path
|
|
51
|
+
// One failure path: a red stderr line, exit 1; an extension's --help or usage error keeps its code.
|
|
28
52
|
const withAction = (deps, fn, prefix = '') => async (opts) => {
|
|
29
53
|
try {
|
|
30
54
|
await fn(opts);
|
|
31
55
|
}
|
|
32
56
|
catch (err) {
|
|
57
|
+
if (err instanceof CommanderError)
|
|
58
|
+
throw err;
|
|
33
59
|
deps.writeErr(`${chalk.red(`${prefix}${messageOf(err)}`)}\n`);
|
|
34
60
|
throw new CommanderError(EXIT_FAILED, ACTION_FAILED, messageOf(err));
|
|
35
61
|
}
|
|
@@ -43,7 +69,28 @@ const hintAfter = (deps) => (_program, action) => {
|
|
|
43
69
|
deps.writeErr(`${chalk.dim(hint)}\n`);
|
|
44
70
|
void deps.refreshUpdateCache();
|
|
45
71
|
};
|
|
46
|
-
|
|
72
|
+
// Extension manifests are read as data; whatever goes wrong there, today's commands still run.
|
|
73
|
+
const addExtensions = (program, deps, argv) => {
|
|
74
|
+
registerExtension(program, {
|
|
75
|
+
install: withAction(deps, deps.extensionInstall),
|
|
76
|
+
remove: withAction(deps, deps.extensionRemove),
|
|
77
|
+
list: withAction(deps, deps.extensionList),
|
|
78
|
+
doctor: withAction(deps, deps.extensionDoctor),
|
|
79
|
+
check: withAction(deps, deprecatedCheck(deps.extensionDoctor, deps.writeErr)),
|
|
80
|
+
build: withAction(deps, deps.extensionBuild),
|
|
81
|
+
up: withAction(deps, deps.extensionUp),
|
|
82
|
+
down: withAction(deps, deps.extensionDown),
|
|
83
|
+
token: withAction(deps, deps.extensionToken),
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
registerDelegates(program, argv, (fn) => withAction(deps, fn), deps.kitTool);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
deps.writeErr(`${chalk.yellow(`warning: extension commands skipped: ${messageOf(err)}`)}\n`);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// `argv` reaches an extension's own Command unchanged, so it parses exactly what was typed.
|
|
93
|
+
export const createProgram = (deps = defaultDeps, argv = process.argv) => {
|
|
47
94
|
const program = new Command()
|
|
48
95
|
.name('agentage')
|
|
49
96
|
.description('Connect this machine to agentage from the terminal')
|
|
@@ -55,9 +102,10 @@ export const createProgram = (deps = defaultDeps) => {
|
|
|
55
102
|
registerSetup(program, withAction(deps, deps.setup, 'Setup failed: '));
|
|
56
103
|
registerStatus(program, withAction(deps, deps.status));
|
|
57
104
|
registerUpdate(program, withAction(deps, deps.update));
|
|
105
|
+
addExtensions(program, deps, argv);
|
|
58
106
|
return program;
|
|
59
107
|
};
|
|
60
|
-
//
|
|
108
|
+
// --help and --version stay 0; a kit command keeps its code; any other commander error is usage.
|
|
61
109
|
const exitCodeOf = (err, deps) => {
|
|
62
110
|
if (!(err instanceof CommanderError)) {
|
|
63
111
|
deps.writeErr(`${chalk.red(messageOf(err))}\n`);
|
|
@@ -65,6 +113,8 @@ const exitCodeOf = (err, deps) => {
|
|
|
65
113
|
}
|
|
66
114
|
if (err.code === ACTION_FAILED)
|
|
67
115
|
return EXIT_FAILED;
|
|
116
|
+
if (err.code === KIT_EXIT)
|
|
117
|
+
return err.exitCode;
|
|
68
118
|
return err.exitCode === 0 ? EXIT_OK : EXIT_USAGE;
|
|
69
119
|
};
|
|
70
120
|
// Returns the exit code instead of exiting, so piped stdout is never cut short.
|
|
@@ -72,7 +122,7 @@ export const run = async (argv = process.argv, deps = defaultDeps) => {
|
|
|
72
122
|
if (process.env['NO_COLOR'])
|
|
73
123
|
chalk.level = 0; // chalk ignores NO_COLOR on its own
|
|
74
124
|
try {
|
|
75
|
-
await createProgram(deps).parseAsync(argv);
|
|
125
|
+
await createProgram(deps, argv).parseAsync(argv);
|
|
76
126
|
return EXIT_OK;
|
|
77
127
|
}
|
|
78
128
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.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",
|
|
@@ -10,9 +10,13 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"default": "./dist/
|
|
13
|
+
"./extension": {
|
|
14
|
+
"types": "./dist/extension.d.ts",
|
|
15
|
+
"default": "./dist/extension.js"
|
|
16
|
+
},
|
|
17
|
+
"./extension/test": {
|
|
18
|
+
"types": "./dist/extension-test.d.ts",
|
|
19
|
+
"default": "./dist/extension-test.js"
|
|
16
20
|
},
|
|
17
21
|
"./package.json": "./package.json"
|
|
18
22
|
},
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"prepublishOnly": "npm run verify"
|
|
52
56
|
},
|
|
53
57
|
"dependencies": {
|
|
58
|
+
"@agentage/extension": "^0.2.0",
|
|
54
59
|
"chalk": "^6.0.0",
|
|
55
60
|
"commander": "^15.0.0",
|
|
56
61
|
"open": "^11.0.0"
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import {} from '../../core/loader/states.js';
|
|
3
|
-
import {} from './status-rows.js';
|
|
4
|
-
const COLOR = {
|
|
5
|
-
installed: chalk.green,
|
|
6
|
-
off: chalk.dim,
|
|
7
|
-
blocked: chalk.yellow,
|
|
8
|
-
invalid: chalk.red,
|
|
9
|
-
missing: chalk.yellow,
|
|
10
|
-
};
|
|
11
|
-
const STATE_WIDTH = Math.max(...Object.keys(COLOR).map((state) => state.length));
|
|
12
|
-
const line = (label, value) => `${label.padEnd(10)} ${value}`;
|
|
13
|
-
const profileText = (profile) => {
|
|
14
|
-
if (profile.state === 'missing')
|
|
15
|
-
return 'no profile';
|
|
16
|
-
if (profile.state === 'invalid')
|
|
17
|
-
return chalk.red('profile.json is invalid');
|
|
18
|
-
const readOnly = profile.readOnly ? chalk.yellow(', read-only') : '';
|
|
19
|
-
return `version ${profile.version} (source: ${profile.source}${readOnly})`;
|
|
20
|
-
};
|
|
21
|
-
const lastRunText = (run) => {
|
|
22
|
-
if (run === null)
|
|
23
|
-
return '';
|
|
24
|
-
const error = run.error === null ? '' : ` "${run.error}"`;
|
|
25
|
-
return ` last run: ${run.state}${error} at ${run.at}`;
|
|
26
|
-
};
|
|
27
|
-
const pluginLine = (row, idWidth) => {
|
|
28
|
-
const id = (row.id ?? '?').padEnd(idWidth);
|
|
29
|
-
const state = COLOR[row.state](row.state.padEnd(STATE_WIDTH));
|
|
30
|
-
const wanted = row.mode === 'dev' ? 'dev' : `wants ${row.wanted ?? '?'}`;
|
|
31
|
-
const pkg = `${row.package} ${row.installed ?? '-'} (${wanted})`;
|
|
32
|
-
const commands = row.commands.length > 0 ? ` commands: ${row.commands.join(', ')}` : '';
|
|
33
|
-
const error = row.error === null ? '' : chalk.dim(` ${row.error}`);
|
|
34
|
-
return ` ${id} ${state} ${pkg}${commands}${lastRunText(row.lastRun)}${error}`;
|
|
35
|
-
};
|
|
36
|
-
export const pluginStatusLines = (status) => {
|
|
37
|
-
const idWidth = Math.max(0, ...status.plugins.map((row) => (row.id ?? '?').length));
|
|
38
|
-
return [
|
|
39
|
-
line('machine', `${status.machine.id} (${status.machine.name})`),
|
|
40
|
-
line('profile', profileText(status.profile)),
|
|
41
|
-
line('plugins', status.plugins.length === 0 ? 'none' : String(status.plugins.length)),
|
|
42
|
-
...status.plugins.map((row) => pluginLine(row, idWidth)),
|
|
43
|
-
];
|
|
44
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { type DiscoverInput, type Discovery } from '../../core/loader/discover.js';
|
|
2
|
-
import { type RunState } from '../../core/loader/state.js';
|
|
3
|
-
import { type StaticState } from '../../core/loader/states.js';
|
|
4
|
-
import { type MachineFile, type ProfileSource } from '../../core/profile/machine.js';
|
|
5
|
-
import { type ProfileParse } from '../../core/profile/schema.js';
|
|
6
|
-
export interface PluginRow {
|
|
7
|
-
id: string | null;
|
|
8
|
-
package: string;
|
|
9
|
-
mode: 'installed' | 'dev';
|
|
10
|
-
wanted: string | null;
|
|
11
|
-
installed: string | null;
|
|
12
|
-
state: StaticState;
|
|
13
|
-
error: string | null;
|
|
14
|
-
commands: string[];
|
|
15
|
-
lastRun: {
|
|
16
|
-
at: string;
|
|
17
|
-
state: string;
|
|
18
|
-
error: string | null;
|
|
19
|
-
} | null;
|
|
20
|
-
}
|
|
21
|
-
export type ProfileStatus = {
|
|
22
|
-
state: 'missing';
|
|
23
|
-
} | {
|
|
24
|
-
state: 'invalid';
|
|
25
|
-
errors: string[];
|
|
26
|
-
} | {
|
|
27
|
-
state: 'ok';
|
|
28
|
-
version: number;
|
|
29
|
-
source: ProfileSource;
|
|
30
|
-
readOnly: boolean;
|
|
31
|
-
};
|
|
32
|
-
export interface PluginsStatus {
|
|
33
|
-
machine: {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
};
|
|
37
|
-
profile: ProfileStatus;
|
|
38
|
-
plugins: PluginRow[];
|
|
39
|
-
}
|
|
40
|
-
export interface PluginsGather {
|
|
41
|
-
status: PluginsStatus;
|
|
42
|
-
warnings: string[];
|
|
43
|
-
}
|
|
44
|
-
export interface StatusRowsDeps {
|
|
45
|
-
loadMachine: () => Promise<MachineFile>;
|
|
46
|
-
readProfile: () => ProfileParse | null;
|
|
47
|
-
discover: (input: DiscoverInput) => Discovery;
|
|
48
|
-
readRunState: (id: string) => RunState | null;
|
|
49
|
-
pluginsDir: () => string;
|
|
50
|
-
}
|
|
51
|
-
export declare const gatherPluginStatus: (deps?: StatusRowsDeps) => Promise<PluginsGather>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { discover, } from '../../core/loader/discover.js';
|
|
2
|
-
import { readRunState } from '../../core/loader/state.js';
|
|
3
|
-
import { staticStates } from '../../core/loader/states.js';
|
|
4
|
-
import { pluginsDir } from '../../core/paths.js';
|
|
5
|
-
import { loadMachine } from '../../core/profile/machine.js';
|
|
6
|
-
import { effective } from '../../core/profile/merge.js';
|
|
7
|
-
import { readProfile } from '../../core/profile/profile.js';
|
|
8
|
-
import {} from '../../core/profile/schema.js';
|
|
9
|
-
const defaultDeps = {
|
|
10
|
-
loadMachine: () => loadMachine(),
|
|
11
|
-
readProfile: () => readProfile(),
|
|
12
|
-
discover: (input) => discover(input),
|
|
13
|
-
readRunState: (id) => readRunState(id),
|
|
14
|
-
pluginsDir,
|
|
15
|
-
};
|
|
16
|
-
const profileStatus = (parsed, machine) => {
|
|
17
|
-
if (parsed === null)
|
|
18
|
-
return { state: 'missing' };
|
|
19
|
-
if (!parsed.ok)
|
|
20
|
-
return { state: 'invalid', errors: parsed.errors };
|
|
21
|
-
const { version } = parsed.profile;
|
|
22
|
-
return { state: 'ok', version, source: machine.profileSource, readOnly: parsed.readOnly };
|
|
23
|
-
};
|
|
24
|
-
// A row for an invalid manifest has no trustworthy id, so it never shows another plugin's run.
|
|
25
|
-
const lastRunOf = (p, s, deps) => {
|
|
26
|
-
const run = p.id === null || s.state === 'invalid' ? null : deps.readRunState(p.id);
|
|
27
|
-
return run && { at: run.at, state: run.state, error: run.error };
|
|
28
|
-
};
|
|
29
|
-
const toRow = (p, eff, s, deps) => ({
|
|
30
|
-
id: p.id,
|
|
31
|
-
package: p.pkg,
|
|
32
|
-
mode: p.source === 'dev' ? 'dev' : 'installed',
|
|
33
|
-
wanted: eff.install[p.pkg] ?? null,
|
|
34
|
-
installed: p.version,
|
|
35
|
-
state: s.state,
|
|
36
|
-
error: s.error,
|
|
37
|
-
commands: p.commands,
|
|
38
|
-
lastRun: lastRunOf(p, s, deps),
|
|
39
|
-
});
|
|
40
|
-
const UNKNOWN = { state: 'invalid', error: null };
|
|
41
|
-
// Reads manifests, profile and state files; writes only a missing machine.json.
|
|
42
|
-
export const gatherPluginStatus = async (deps = defaultDeps) => {
|
|
43
|
-
const machine = await deps.loadMachine();
|
|
44
|
-
const parsed = deps.readProfile();
|
|
45
|
-
const eff = effective(parsed?.ok ? parsed.profile : null, machine);
|
|
46
|
-
const names = Object.keys(eff.install);
|
|
47
|
-
const found = deps.discover({ pluginsDir: deps.pluginsDir(), names, dev: eff.dev });
|
|
48
|
-
const states = staticStates(found.plugins, eff.off);
|
|
49
|
-
const plugins = found.plugins
|
|
50
|
-
.map((p) => toRow(p, eff, states.get(p.pkg) ?? UNKNOWN, deps))
|
|
51
|
-
.sort((a, b) => (a.package < b.package ? -1 : 1));
|
|
52
|
-
const status = {
|
|
53
|
-
machine: { id: machine.id, name: machine.name },
|
|
54
|
-
profile: profileStatus(parsed, machine),
|
|
55
|
-
plugins,
|
|
56
|
-
};
|
|
57
|
-
return { status, warnings: [...(parsed?.ok ? parsed.warnings : []), ...found.warnings] };
|
|
58
|
-
};
|
package/dist/core/flag.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const pluginsEnabled: () => boolean;
|
package/dist/core/flag.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const pluginsEnabled = () => process.env['AGENTAGE_PLUGINS'] === '1';
|
package/dist/plugin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PLUGIN_API_VERSION = "1.0.0";
|
package/dist/plugin.js
DELETED