@anhlp/alp 0.0.1-beta.4 → 0.0.1-beta.7
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 +11 -412
- package/bin/alp.js +3 -0
- package/package.json +11 -103
- package/dist/THIRD-PARTY-NOTICES.txt +0 -626
- package/dist/acp.js +0 -19936
- package/dist/alpd.js +0 -49562
- package/docs/modular-monorepo.md +0 -214
- package/packages/cli/README.md +0 -7
- package/packages/cli/dist/THIRD-PARTY-NOTICES.txt +0 -651
- package/packages/cli/dist/acp/agent.d.ts +0 -37
- package/packages/cli/dist/acp/agent.js +0 -489
- package/packages/cli/dist/acp/main.d.ts +0 -4
- package/packages/cli/dist/acp/main.js +0 -23
- package/packages/cli/dist/acp.js +0 -19936
- package/packages/cli/dist/alp-web/THIRD-PARTY-NOTICES.txt +0 -2590
- package/packages/cli/dist/alp-web/alp-boundary.json +0 -15
- package/packages/cli/dist/alp-web/apple-touch-icon.png +0 -0
- package/packages/cli/dist/alp-web/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/packages/cli/dist/alp-web/assets/TerminalPanel-PrU2l3u5.js +0 -16
- package/packages/cli/dist/alp-web/assets/index-BJdBTDFX.css +0 -1
- package/packages/cli/dist/alp-web/assets/index-DpfiPv5s.js +0 -52
- package/packages/cli/dist/alp-web/favicon-attention.svg +0 -6
- package/packages/cli/dist/alp-web/favicon-running.svg +0 -6
- package/packages/cli/dist/alp-web/favicon.svg +0 -5
- package/packages/cli/dist/alp-web/index.html +0 -20
- package/packages/cli/dist/alp-web.js +0 -9640
- package/packages/cli/dist/alpd.js +0 -49562
- package/packages/cli/dist/backup.d.ts +0 -4
- package/packages/cli/dist/backup.js +0 -146
- package/packages/cli/dist/build-manifest.json +0 -240
- package/packages/cli/dist/cli.d.ts +0 -2
- package/packages/cli/dist/cli.js +0 -30
- package/packages/cli/dist/daemon.d.ts +0 -35
- package/packages/cli/dist/daemon.js +0 -126
- package/packages/cli/dist/index.d.ts +0 -1
- package/packages/cli/dist/index.js +0 -5
- package/packages/cli/dist/interfaces.d.ts +0 -24
- package/packages/cli/dist/interfaces.js +0 -156
- package/packages/cli/dist/library.d.ts +0 -140
- package/packages/cli/dist/library.js +0 -319
- package/packages/cli/dist/paths.d.ts +0 -3
- package/packages/cli/dist/paths.js +0 -18
- package/packages/cli/dist/projects.d.ts +0 -9
- package/packages/cli/dist/projects.js +0 -159
- package/packages/cli/dist/schedules.d.ts +0 -2
- package/packages/cli/dist/schedules.js +0 -45
- package/packages/cli/dist/sessions.d.ts +0 -43
- package/packages/cli/dist/sessions.js +0 -458
- package/packages/cli/dist/tasks.d.ts +0 -29
- package/packages/cli/dist/tasks.js +0 -345
- package/packages/cli/dist/terminal.d.ts +0 -8
- package/packages/cli/dist/terminal.js +0 -79
- package/packages/cli/dist/usage.d.ts +0 -3
- package/packages/cli/dist/usage.js +0 -78
- package/packages/cli/dist/web-service.d.ts +0 -38
- package/packages/cli/dist/web-service.js +0 -119
- package/packages/client/README.md +0 -29
- package/packages/client/dist/acp-probe.d.ts +0 -44
- package/packages/client/dist/acp-probe.js +0 -37
- package/packages/client/dist/antigravity-probe.d.ts +0 -34
- package/packages/client/dist/antigravity-probe.js +0 -95
- package/packages/client/dist/command.d.ts +0 -5
- package/packages/client/dist/command.js +0 -33
- package/packages/client/dist/doctor.d.ts +0 -13
- package/packages/client/dist/doctor.js +0 -587
- package/packages/client/dist/index.d.ts +0 -151
- package/packages/client/dist/index.js +0 -533
- package/packages/client/dist/integration-lock.d.ts +0 -35
- package/packages/client/dist/integration-lock.js +0 -179
- package/packages/client/dist/ipc.d.ts +0 -42
- package/packages/client/dist/ipc.js +0 -69
- package/packages/client/dist/library-test.d.ts +0 -94
- package/packages/client/dist/library-test.js +0 -37
- package/packages/client/dist/mcp-probe.d.ts +0 -24
- package/packages/client/dist/mcp-probe.js +0 -147
- package/packages/client/dist/portable.d.ts +0 -19
- package/packages/client/dist/portable.js +0 -33
- package/packages/client/dist/prompt.d.ts +0 -32
- package/packages/client/dist/prompt.js +0 -59
- package/packages/client/dist/render.d.ts +0 -6
- package/packages/client/dist/render.js +0 -120
- package/packages/client/dist/rpc/client.d.ts +0 -82
- package/packages/client/dist/rpc/client.js +0 -292
- package/packages/client/dist/rpc/errors.d.ts +0 -42
- package/packages/client/dist/rpc/errors.js +0 -34
- package/packages/client/dist/rpc/framing.d.ts +0 -21
- package/packages/client/dist/rpc/framing.js +0 -57
- package/packages/client/dist/rpc/handshake.d.ts +0 -19
- package/packages/client/dist/rpc/handshake.js +0 -8
- package/packages/client/dist/rpc/reconnect.d.ts +0 -97
- package/packages/client/dist/rpc/reconnect.js +0 -227
- package/packages/client/dist/rpc/registry.d.ts +0 -211
- package/packages/client/dist/rpc/registry.js +0 -145
- package/packages/client/dist/rpc/timers.d.ts +0 -11
- package/packages/client/dist/rpc/timers.js +0 -11
- package/packages/client/dist/service.d.ts +0 -50
- package/packages/client/dist/service.js +0 -143
- package/packages/client/dist/setup.d.ts +0 -2
- package/packages/client/dist/setup.js +0 -146
- package/packages/client/dist/supervise.d.ts +0 -14
- package/packages/client/dist/supervise.js +0 -87
- package/packages/client/dist/websocket.d.ts +0 -51
- package/packages/client/dist/websocket.js +0 -190
- package/packages/core/README.md +0 -7
- package/packages/core/dist/adapter.d.ts +0 -20
- package/packages/core/dist/adapter.js +0 -30
- package/packages/core/dist/atomic.d.ts +0 -2
- package/packages/core/dist/atomic.js +0 -28
- package/packages/core/dist/backup.d.ts +0 -27
- package/packages/core/dist/backup.js +0 -681
- package/packages/core/dist/beads.d.ts +0 -65
- package/packages/core/dist/beads.js +0 -213
- package/packages/core/dist/delegation.d.ts +0 -2
- package/packages/core/dist/delegation.js +0 -32
- package/packages/core/dist/errors.d.ts +0 -4
- package/packages/core/dist/errors.js +0 -11
- package/packages/core/dist/formulas.d.ts +0 -25
- package/packages/core/dist/formulas.js +0 -201
- package/packages/core/dist/hook-run.d.ts +0 -44
- package/packages/core/dist/hook-run.js +0 -60
- package/packages/core/dist/hooks.d.ts +0 -35
- package/packages/core/dist/hooks.js +0 -30
- package/packages/core/dist/index.d.ts +0 -31
- package/packages/core/dist/index.js +0 -65
- package/packages/core/dist/init.d.ts +0 -30
- package/packages/core/dist/init.js +0 -89
- package/packages/core/dist/library-edit.d.ts +0 -93
- package/packages/core/dist/library-edit.js +0 -368
- package/packages/core/dist/library.d.ts +0 -28
- package/packages/core/dist/library.js +0 -108
- package/packages/core/dist/log.d.ts +0 -37
- package/packages/core/dist/log.js +0 -156
- package/packages/core/dist/migrations.d.ts +0 -9
- package/packages/core/dist/migrations.js +0 -95
- package/packages/core/dist/models.d.ts +0 -11
- package/packages/core/dist/models.js +0 -44
- package/packages/core/dist/permissions.d.ts +0 -14
- package/packages/core/dist/permissions.js +0 -229
- package/packages/core/dist/profiles.d.ts +0 -27
- package/packages/core/dist/profiles.js +0 -122
- package/packages/core/dist/promptsafe.d.ts +0 -1
- package/packages/core/dist/promptsafe.js +0 -13
- package/packages/core/dist/providers.d.ts +0 -90
- package/packages/core/dist/providers.js +0 -101
- package/packages/core/dist/resolver.d.ts +0 -41
- package/packages/core/dist/resolver.js +0 -240
- package/packages/core/dist/safe-path.d.ts +0 -2
- package/packages/core/dist/safe-path.js +0 -24
- package/packages/core/dist/shell.d.ts +0 -16
- package/packages/core/dist/shell.js +0 -22
- package/packages/core/dist/state-schema.d.ts +0 -9
- package/packages/core/dist/state-schema.js +0 -54
- package/packages/core/dist/task-rows.d.ts +0 -47
- package/packages/core/dist/task-rows.js +0 -45
- package/packages/core/dist/tasks.d.ts +0 -128
- package/packages/core/dist/tasks.js +0 -835
- package/packages/core/dist/teams.d.ts +0 -80
- package/packages/core/dist/teams.js +0 -159
- package/packages/core/dist/template-path.d.ts +0 -2
- package/packages/core/dist/template-path.js +0 -10
- package/packages/core/dist/trust.d.ts +0 -8
- package/packages/core/dist/trust.js +0 -47
- package/packages/core/dist/types.d.ts +0 -51
- package/packages/core/dist/upgrade.d.ts +0 -10
- package/packages/core/dist/upgrade.js +0 -200
- package/packages/core/dist/user-settings.d.ts +0 -6
- package/packages/core/dist/user-settings.js +0 -72
- package/packages/core/dist/user-worktree.d.ts +0 -29
- package/packages/core/dist/user-worktree.js +0 -242
- package/packages/core/dist/validation.d.ts +0 -17
- package/packages/core/dist/validation.js +0 -296
- package/packages/core/dist/verify.d.ts +0 -15
- package/packages/core/dist/verify.js +0 -123
- package/packages/core/dist/workflow.d.ts +0 -45
- package/packages/core/dist/workflow.js +0 -33
- package/templates/ALP.md +0 -52
- package/templates/agents/lead/AGENT.md +0 -90
- package/templates/agents/main/AGENT.md +0 -150
- package/templates/agents/oracle/AGENT.md +0 -44
- package/templates/agents/peer/AGENT.md +0 -55
- package/templates/agents/reviewer/AGENT.md +0 -80
- package/templates/agents/supervisor/AGENT.md +0 -72
- package/templates/providers/antigravity.json +0 -6
- package/templates/providers/opencode.json +0 -7
- package/templates/role-skills.json +0 -8
- package/templates/skills/bug-loop/SKILL.md +0 -44
- package/templates/skills/bug-loop/references/test-proof.md +0 -25
- package/templates/skills/goal-griller/SKILL.md +0 -49
- package/templates/skills/prompt-leverage/SKILL.md +0 -37
- package/templates/skills/prompt-leverage/references/brief-template.md +0 -27
- package/templates/skills/sequence-execution-plan/SKILL.md +0 -42
- package/templates/skills/sequence-execution-plan/references/plan-template.md +0 -22
- package/templates/skills/smart-commits/SKILL.md +0 -40
- package/templates/skills/xia/SKILL.md +0 -42
- package/templates/teams/cafe/HOUSE_RULES.md +0 -1
- package/templates/teams/cafe/team.json +0 -15
- package/templates/teams/pho/HOUSE_RULES.md +0 -1
- package/templates/teams/pho/team.json +0 -14
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/interfaces.js
|
|
2
|
-
import { execFile, spawn } from "node:child_process";
|
|
3
|
-
import { readFile, stat } from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { parseArgs } from "node:util";
|
|
6
|
-
import { alpHome, discoverIntegration, startIntegration } from "@anhlp/alp-client/index";
|
|
7
|
-
import { UsageError } from "./usage.js";
|
|
8
|
-
import { built, start, running } from "./daemon.js";
|
|
9
|
-
import { DAEMON_ENTRY, distributionEntry } from "./paths.js";
|
|
10
|
-
import { alpWebEntry, refusal, stopPreRenamePaseo, stopWebService, webOwner } from "./web-service.js";
|
|
11
|
-
var PASEO = "paseo";
|
|
12
|
-
var WEB = "web";
|
|
13
|
-
async function startPaseoIntegration(home) {
|
|
14
|
-
const entry = await discoverIntegration(PASEO, { home });
|
|
15
|
-
if (!entry) {
|
|
16
|
-
const legacy = path.join(home, "integrations", "web.json");
|
|
17
|
-
const legacyEntry = await legacyDescriptorEntry(legacy, home);
|
|
18
|
-
if (legacyEntry) {
|
|
19
|
-
console.error(`Using the Paseo integration registered before its rename (${legacy}); run \`alp-paseo-integration --register\` to register it again.`);
|
|
20
|
-
return startIntegration({ name: PASEO, entry: legacyEntry, home });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return startIntegration({ name: PASEO, home });
|
|
24
|
-
}
|
|
25
|
-
async function legacyDescriptorEntry(file, home) {
|
|
26
|
-
const raw = await readFile(file, "utf8").then((text) => JSON.parse(text)).catch(() => void 0);
|
|
27
|
-
const isFile = (candidate) => stat(candidate).then((info) => info.isFile(), () => false);
|
|
28
|
-
for (const field of ["main", "entry", "path", "command"]) {
|
|
29
|
-
const value = raw?.[field];
|
|
30
|
-
if (typeof value !== "string" || !value.trim()) continue;
|
|
31
|
-
const candidates = path.isAbsolute(value) ? [value] : [path.resolve(path.dirname(file), value), path.resolve(home, value)];
|
|
32
|
-
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
33
|
-
}
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
async function projectArgs() {
|
|
37
|
-
const cwd = process.cwd();
|
|
38
|
-
return await stat(path.join(cwd, ".alp")).then((info) => info.isDirectory(), () => false) ? ["--project", cwd] : [];
|
|
39
|
-
}
|
|
40
|
-
async function webDisabled(home) {
|
|
41
|
-
const settings = await readFile(path.join(home, "settings.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
|
|
42
|
-
return settings?.web?.enabled === false;
|
|
43
|
-
}
|
|
44
|
-
var DISABLED = 'alp web is disabled by settings ("web.enabled": false).';
|
|
45
|
-
async function serveWeb(home, entry) {
|
|
46
|
-
await stopPreRenamePaseo(home);
|
|
47
|
-
const held = await webOwner(home);
|
|
48
|
-
const published = await readFile(path.join(home, "web.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
|
|
49
|
-
const claimed = published?.app === "alp-web" && published.pid === await readFile(path.join(home, "integrations", "web.lock"), "utf8").then((text) => JSON.parse(text)?.pid, () => void 0);
|
|
50
|
-
if ("reason" in held && held.alive && held.kind === "foreign" && !claimed) throw new Error(`${refusal(home)} (${held.reason}). Stop it, then run alp web again.`);
|
|
51
|
-
let lock;
|
|
52
|
-
try {
|
|
53
|
-
lock = await startIntegration({ name: WEB, entry, home, args: await projectArgs() });
|
|
54
|
-
} catch (error) {
|
|
55
|
-
const owner = await webOwner(home);
|
|
56
|
-
if ("reason" in owner && owner.alive) throw new Error(`${error?.message ?? error}
|
|
57
|
-
${refusal(home)} (${owner.reason}). If it is not alp web, stop it, then run alp web again.`, { cause: error });
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
const info = await readFile(path.join(home, "web.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
|
|
61
|
-
if (info?.app !== "alp-web" || info.pid !== lock.pid) {
|
|
62
|
-
const owner = await webOwner(home);
|
|
63
|
-
throw new Error(`${refusal(home)}${"reason" in owner ? ` (${owner.reason})` : ""}. Stop pid ${lock.pid}, then run alp web again.`);
|
|
64
|
-
}
|
|
65
|
-
if (typeof info.url !== "string" || typeof info.token !== "string") throw new Error(`alp web published no address; see ${path.join(home, "logs", "integrations", "alp-web.log")}`);
|
|
66
|
-
return `${info.url}#token=${info.token}`;
|
|
67
|
-
}
|
|
68
|
-
async function webCommand(args) {
|
|
69
|
-
if (args[0] === "pair") return pairCommand(args.slice(1));
|
|
70
|
-
if (args[0] === "rotate") return rotateCommand(args.slice(1));
|
|
71
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { print: { type: "boolean" } } });
|
|
72
|
-
if (positionals.length) throw new UsageError();
|
|
73
|
-
const entry = alpWebEntry();
|
|
74
|
-
const home = alpHome();
|
|
75
|
-
if (await webDisabled(home)) throw new Error(DISABLED);
|
|
76
|
-
await start();
|
|
77
|
-
const url = await serveWeb(home, entry);
|
|
78
|
-
console.log(url);
|
|
79
|
-
if (values.print) return;
|
|
80
|
-
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
|
|
81
|
-
spawn(opener, [url], { stdio: "ignore", detached: true }).on("error", () => console.error("Open the address above in your browser")).unref();
|
|
82
|
-
}
|
|
83
|
-
async function rotateCommand(args) {
|
|
84
|
-
if (args.length) throw new UsageError();
|
|
85
|
-
const entry = alpWebEntry();
|
|
86
|
-
const home = alpHome();
|
|
87
|
-
await start();
|
|
88
|
-
const project = await projectArgs();
|
|
89
|
-
for (let attempt = 1; ; attempt++) {
|
|
90
|
-
await stopWebService(home);
|
|
91
|
-
const rotated = await new Promise((resolve) => {
|
|
92
|
-
execFile(
|
|
93
|
-
process.execPath,
|
|
94
|
-
[entry, "--rotate", ...project],
|
|
95
|
-
{ env: { ...process.env, ALP_HOME: home }, encoding: "utf8", timeout: 6e4, killSignal: "SIGTERM" },
|
|
96
|
-
(error, stdout, stderr) => resolve({ code: error ? typeof error.code === "number" ? error.code : 1 : 0, output: `${stderr}${stdout}`.trim() })
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
if (rotated.code === 0) break;
|
|
100
|
-
if (rotated.code !== 3 || attempt >= 3) throw new Error(`alp web could not rotate its token${rotated.output ? `:
|
|
101
|
-
${rotated.output.slice(-2e3)}` : ""}`);
|
|
102
|
-
}
|
|
103
|
-
if (await webDisabled(home)) {
|
|
104
|
-
console.log(`alp web has a new token; the old one no longer works. ${DISABLED.replace(/\.$/, "")}, so it was not started.`);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
console.log(await serveWeb(home, entry));
|
|
108
|
-
}
|
|
109
|
-
async function requestPairing(client, params, attempts = 50) {
|
|
110
|
-
let last;
|
|
111
|
-
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
112
|
-
const outcome = await client.request("web.pairing", params).then((value) => ({ value }), (error) => ({ error }));
|
|
113
|
-
if (!outcome.error) return outcome.value;
|
|
114
|
-
last = outcome.error;
|
|
115
|
-
const unknown = outcome.error?.code === -32601 || /unknown method|not available|not registered/i.test(outcome.error?.message ?? "");
|
|
116
|
-
if (!unknown) throw outcome.error;
|
|
117
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
118
|
-
}
|
|
119
|
-
throw last ?? new Error("alpd did not register web.pairing; run `alp web` to let the integration start, then retry");
|
|
120
|
-
}
|
|
121
|
-
async function pairCommand(args) {
|
|
122
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { on: { type: "boolean" }, off: { type: "boolean" } } });
|
|
123
|
-
if (positionals.length || values.on && values.off) throw new UsageError();
|
|
124
|
-
await start();
|
|
125
|
-
const home = alpHome();
|
|
126
|
-
await startPaseoIntegration(home);
|
|
127
|
-
const client = await running();
|
|
128
|
-
try {
|
|
129
|
-
const pairing = await requestPairing(client, values.on ? { enable: true } : values.off ? { enable: false } : {});
|
|
130
|
-
if (!pairing.relayEnabled) {
|
|
131
|
-
console.log(`The relay is off${values.off ? " now" : ""}. Turn it on with: alp web pair --on`);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
console.log(`Relay ${pairing.endpoint}: ${pairing.connected ? "connected" : "connecting"}`);
|
|
135
|
-
console.log(`Open this link on the device that runs Paseo's app:
|
|
136
|
-
${pairing.url}`);
|
|
137
|
-
const password = await readFile(path.join(home, `${PASEO}.json`), "utf8").then((text) => JSON.parse(text)?.token).catch(() => void 0);
|
|
138
|
-
if (typeof password === "string" && password) console.log(`When Paseo's app asks for a password, give it: ${password}`);
|
|
139
|
-
else console.log(`When Paseo's app asks for a password, give it the token in ${path.join(home, `${PASEO}.json`)}.`);
|
|
140
|
-
} finally {
|
|
141
|
-
client.close();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async function acpCommand(args) {
|
|
145
|
-
if (args.length) throw new UsageError();
|
|
146
|
-
await built();
|
|
147
|
-
const { runAcp } = await import(distributionEntry("acp.js"));
|
|
148
|
-
await runAcp({ daemonEntry: DAEMON_ENTRY });
|
|
149
|
-
}
|
|
150
|
-
export {
|
|
151
|
-
acpCommand,
|
|
152
|
-
pairCommand,
|
|
153
|
-
requestPairing,
|
|
154
|
-
startPaseoIntegration,
|
|
155
|
-
webCommand
|
|
156
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
export function libraryCommand(kind: any, args: any): Promise<void>;
|
|
2
|
-
/** `--project` may stand alone, meaning the current directory. */
|
|
3
|
-
export function projectFlag(args: any): any[];
|
|
4
|
-
export function pairs(list: any, what: any): {
|
|
5
|
-
[k: string]: any;
|
|
6
|
-
};
|
|
7
|
-
export function names(text: any): any;
|
|
8
|
-
export const EDIT_OPTIONS: {
|
|
9
|
-
project: {
|
|
10
|
-
type: string;
|
|
11
|
-
};
|
|
12
|
-
json: {
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
15
|
-
from: {
|
|
16
|
-
type: string;
|
|
17
|
-
};
|
|
18
|
-
description: {
|
|
19
|
-
type: string;
|
|
20
|
-
short: string;
|
|
21
|
-
};
|
|
22
|
-
provider: {
|
|
23
|
-
type: string;
|
|
24
|
-
};
|
|
25
|
-
model: {
|
|
26
|
-
type: string;
|
|
27
|
-
};
|
|
28
|
-
thinking: {
|
|
29
|
-
type: string;
|
|
30
|
-
};
|
|
31
|
-
mode: {
|
|
32
|
-
type: string;
|
|
33
|
-
};
|
|
34
|
-
skills: {
|
|
35
|
-
type: string;
|
|
36
|
-
};
|
|
37
|
-
mcp: {
|
|
38
|
-
type: string;
|
|
39
|
-
};
|
|
40
|
-
hooks: {
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
instructions: {
|
|
44
|
-
type: string;
|
|
45
|
-
};
|
|
46
|
-
label: {
|
|
47
|
-
type: string;
|
|
48
|
-
};
|
|
49
|
-
main: {
|
|
50
|
-
type: string;
|
|
51
|
-
};
|
|
52
|
-
member: {
|
|
53
|
-
type: string;
|
|
54
|
-
multiple: boolean;
|
|
55
|
-
};
|
|
56
|
-
'member-model': {
|
|
57
|
-
type: string;
|
|
58
|
-
multiple: boolean;
|
|
59
|
-
};
|
|
60
|
-
'member-thinking': {
|
|
61
|
-
type: string;
|
|
62
|
-
multiple: boolean;
|
|
63
|
-
};
|
|
64
|
-
delegate: {
|
|
65
|
-
type: string;
|
|
66
|
-
multiple: boolean;
|
|
67
|
-
};
|
|
68
|
-
'max-peers': {
|
|
69
|
-
type: string;
|
|
70
|
-
};
|
|
71
|
-
supervisor: {
|
|
72
|
-
type: string;
|
|
73
|
-
};
|
|
74
|
-
'supervisor-model': {
|
|
75
|
-
type: string;
|
|
76
|
-
};
|
|
77
|
-
'supervisor-thinking': {
|
|
78
|
-
type: string;
|
|
79
|
-
};
|
|
80
|
-
'no-supervisor': {
|
|
81
|
-
type: string;
|
|
82
|
-
};
|
|
83
|
-
rules: {
|
|
84
|
-
type: string;
|
|
85
|
-
};
|
|
86
|
-
file: {
|
|
87
|
-
type: string;
|
|
88
|
-
};
|
|
89
|
-
command: {
|
|
90
|
-
type: string;
|
|
91
|
-
};
|
|
92
|
-
arg: {
|
|
93
|
-
type: string;
|
|
94
|
-
multiple: boolean;
|
|
95
|
-
};
|
|
96
|
-
env: {
|
|
97
|
-
type: string;
|
|
98
|
-
multiple: boolean;
|
|
99
|
-
};
|
|
100
|
-
cwd: {
|
|
101
|
-
type: string;
|
|
102
|
-
};
|
|
103
|
-
url: {
|
|
104
|
-
type: string;
|
|
105
|
-
};
|
|
106
|
-
header: {
|
|
107
|
-
type: string;
|
|
108
|
-
multiple: boolean;
|
|
109
|
-
};
|
|
110
|
-
event: {
|
|
111
|
-
type: string;
|
|
112
|
-
};
|
|
113
|
-
blocking: {
|
|
114
|
-
type: string;
|
|
115
|
-
};
|
|
116
|
-
timeout: {
|
|
117
|
-
type: string;
|
|
118
|
-
};
|
|
119
|
-
'match-agent': {
|
|
120
|
-
type: string;
|
|
121
|
-
};
|
|
122
|
-
'match-label': {
|
|
123
|
-
type: string;
|
|
124
|
-
};
|
|
125
|
-
kind: {
|
|
126
|
-
type: string;
|
|
127
|
-
};
|
|
128
|
-
'read-only-mode': {
|
|
129
|
-
type: string;
|
|
130
|
-
};
|
|
131
|
-
models: {
|
|
132
|
-
type: string;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
/** The content of an entry after a CLI new or edit: the current content with the options applied. */
|
|
136
|
-
export function edited(kind: any, name: any, current: any, values: any): Promise<any>;
|
|
137
|
-
/** alp agent|team|skill|mcp|hook: create, change, copy, rename, remove and test library entries. */
|
|
138
|
-
export function editCommand(kind: any, args: any): Promise<void>;
|
|
139
|
-
/** alp trust: the workspaces whose hooks run without asking (ALPD §45). */
|
|
140
|
-
export function teamsCommand(args: any): Promise<void>;
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/library.js
|
|
2
|
-
import { access, readFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { parseArgs } from "node:util";
|
|
5
|
-
import { seedLibrary } from "@anhlp/alp-core/library";
|
|
6
|
-
import { libraryEntries } from "@anhlp/alp-core/resolver";
|
|
7
|
-
import { listTeams, resolveTeam } from "@anhlp/alp-core/teams";
|
|
8
|
-
import { deleteEntry, duplicateEntry, getEntry, renameEntry, saveEntry } from "@anhlp/alp-core/library-edit";
|
|
9
|
-
import { testEntry } from "@anhlp/alp-client/library-test";
|
|
10
|
-
import { alpHome } from "@anhlp/alp-client/index";
|
|
11
|
-
import { UsageError } from "./usage.js";
|
|
12
|
-
import { taskProject } from "./tasks.js";
|
|
13
|
-
async function libraryCommand(kind, args) {
|
|
14
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
15
|
-
if (positionals.length) throw new UsageError();
|
|
16
|
-
if (kind === "providers") await seedLibrary(alpHome());
|
|
17
|
-
const root = path.resolve(values.project ?? process.cwd());
|
|
18
|
-
const rows = await libraryEntries(kind, root, { library: alpHome() });
|
|
19
|
-
if (values.json) {
|
|
20
|
-
console.log(JSON.stringify(rows));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (!rows.length) {
|
|
24
|
-
console.log(kind === "providers" ? `No providers in ${path.join(alpHome(), kind)}; add an ACP agent with alp provider add` : `No ${kind} in ${path.join(alpHome(), kind)} or ${path.join(root, ".alp", kind)}`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const width = Math.max(...rows.map((row) => row.name.length));
|
|
28
|
-
for (const row of rows) {
|
|
29
|
-
const where = row.source === "builtin" ? "built-in" : row.source;
|
|
30
|
-
const notes = [
|
|
31
|
-
row.overrides ? `overrides the ${row.overrides === "builtin" ? "built-in" : row.overrides} one` : "",
|
|
32
|
-
row.usedBy ? `used by ${row.usedBy.join(", ")}` : "",
|
|
33
|
-
row.description ?? ""
|
|
34
|
-
].filter(Boolean);
|
|
35
|
-
console.log(`${row.name.padEnd(width)} ${where.padEnd(8)}${notes.length ? ` ${notes.join("; ")}` : ""}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function projectFlag(args) {
|
|
39
|
-
const result = [...args];
|
|
40
|
-
for (let i = 0; i < result.length; i++) if (result[i] === "--project" && (i + 1 === result.length || result[i + 1].startsWith("-"))) result.splice(i + 1, 0, ".");
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
var pairs = (list, what) => Object.fromEntries((list ?? []).map((item) => {
|
|
44
|
-
const at = item.indexOf("=");
|
|
45
|
-
if (at <= 0) throw new Error(`${what} takes name=value, not '${item}'`);
|
|
46
|
-
return [item.slice(0, at), item.slice(at + 1)];
|
|
47
|
-
}));
|
|
48
|
-
var names = (text) => text === void 0 ? void 0 : text.split(",").map((name) => name.trim()).filter(Boolean);
|
|
49
|
-
var EDIT_OPTIONS = {
|
|
50
|
-
project: { type: "string" },
|
|
51
|
-
json: { type: "boolean" },
|
|
52
|
-
from: { type: "string" },
|
|
53
|
-
description: { type: "string", short: "d" },
|
|
54
|
-
// agent
|
|
55
|
-
provider: { type: "string" },
|
|
56
|
-
model: { type: "string" },
|
|
57
|
-
thinking: { type: "string" },
|
|
58
|
-
mode: { type: "string" },
|
|
59
|
-
skills: { type: "string" },
|
|
60
|
-
mcp: { type: "string" },
|
|
61
|
-
hooks: { type: "string" },
|
|
62
|
-
instructions: { type: "string" },
|
|
63
|
-
// team
|
|
64
|
-
label: { type: "string" },
|
|
65
|
-
main: { type: "string" },
|
|
66
|
-
member: { type: "string", multiple: true },
|
|
67
|
-
"member-model": { type: "string", multiple: true },
|
|
68
|
-
"member-thinking": { type: "string", multiple: true },
|
|
69
|
-
delegate: { type: "string", multiple: true },
|
|
70
|
-
"max-peers": { type: "string" },
|
|
71
|
-
supervisor: { type: "string" },
|
|
72
|
-
"supervisor-model": { type: "string" },
|
|
73
|
-
"supervisor-thinking": { type: "string" },
|
|
74
|
-
"no-supervisor": { type: "boolean" },
|
|
75
|
-
rules: { type: "string" },
|
|
76
|
-
// skill, mcp, hook
|
|
77
|
-
file: { type: "string" },
|
|
78
|
-
command: { type: "string" },
|
|
79
|
-
arg: { type: "string", multiple: true },
|
|
80
|
-
env: { type: "string", multiple: true },
|
|
81
|
-
cwd: { type: "string" },
|
|
82
|
-
url: { type: "string" },
|
|
83
|
-
header: { type: "string", multiple: true },
|
|
84
|
-
event: { type: "string" },
|
|
85
|
-
blocking: { type: "boolean" },
|
|
86
|
-
timeout: { type: "string" },
|
|
87
|
-
"match-agent": { type: "string" },
|
|
88
|
-
"match-label": { type: "string" },
|
|
89
|
-
// provider
|
|
90
|
-
kind: { type: "string" },
|
|
91
|
-
"read-only-mode": { type: "string" },
|
|
92
|
-
models: { type: "string" }
|
|
93
|
-
};
|
|
94
|
-
async function edited(kind, name, current, values) {
|
|
95
|
-
const content = structuredClone(current ?? {});
|
|
96
|
-
const set = (target, key, value) => {
|
|
97
|
-
if (value !== void 0) {
|
|
98
|
-
if (value === "") delete target[key];
|
|
99
|
-
else target[key] = value;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
if (kind === "agents") {
|
|
103
|
-
if (values.instructions !== void 0) content.instructions = await readFile(values.instructions, "utf8");
|
|
104
|
-
content.instructions ??= `# ${name}
|
|
105
|
-
|
|
106
|
-
Describe what this agent does, and how.
|
|
107
|
-
`;
|
|
108
|
-
const config = content.config ?? {};
|
|
109
|
-
set(config, "description", values.description);
|
|
110
|
-
for (const key of ["provider", "model", "thinking", "mode"]) set(config, key, values[key]);
|
|
111
|
-
for (const key of ["skills", "mcp", "hooks"]) {
|
|
112
|
-
const list = names(values[key]);
|
|
113
|
-
if (list) {
|
|
114
|
-
if (list.length) config[key] = list;
|
|
115
|
-
else delete config[key];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
content.config = config;
|
|
119
|
-
} else if (kind === "teams") {
|
|
120
|
-
const team = content.team ?? { label: name, main: "main", members: { main: {} }, delegation: {} };
|
|
121
|
-
set(team, "label", values.label);
|
|
122
|
-
set(team, "description", values.description);
|
|
123
|
-
if (values.main !== void 0 && values.main !== team.main) {
|
|
124
|
-
delete team.members[team.main];
|
|
125
|
-
delete team.delegation[team.main];
|
|
126
|
-
team.main = values.main;
|
|
127
|
-
team.members[values.main] = { ...team.members[values.main] ?? {} };
|
|
128
|
-
delete team.members[values.main].role;
|
|
129
|
-
}
|
|
130
|
-
if (values.member?.length) {
|
|
131
|
-
const roles = pairs(values.member, "--member");
|
|
132
|
-
team.members = { [team.main]: team.members[team.main] ?? {}, ...Object.fromEntries(Object.entries(roles).filter(([member]) => member !== team.main).map(([member, role]) => [member, { ...team.members[member] ?? {}, role }])) };
|
|
133
|
-
}
|
|
134
|
-
for (const [option, key] of [["member-model", "model"], ["member-thinking", "thinking"]]) {
|
|
135
|
-
for (const [member, value] of Object.entries(pairs(values[option], `--${option}`))) {
|
|
136
|
-
if (!team.members[member]) throw new Error(`--${option}: ${member} is not a member of ${name}`);
|
|
137
|
-
set(team.members[member], key, value);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (values.delegate?.length) team.delegation = Object.fromEntries(Object.entries(pairs(values.delegate, "--delegate")).map(([owner, targets]) => [owner, names(targets)]));
|
|
141
|
-
if (values["max-peers"] !== void 0) {
|
|
142
|
-
if (values["max-peers"] === "") delete team.maxPeers;
|
|
143
|
-
else team.maxPeers = Number(values["max-peers"]);
|
|
144
|
-
}
|
|
145
|
-
if (values["no-supervisor"]) team.supervisor = false;
|
|
146
|
-
else if (values.supervisor !== void 0 || values["supervisor-model"] !== void 0 || values["supervisor-thinking"] !== void 0) {
|
|
147
|
-
const watcher = team.supervisor || { agent: "supervisor" };
|
|
148
|
-
set(watcher, "agent", values.supervisor);
|
|
149
|
-
set(watcher, "model", values["supervisor-model"]);
|
|
150
|
-
set(watcher, "thinking", values["supervisor-thinking"]);
|
|
151
|
-
team.supervisor = watcher;
|
|
152
|
-
}
|
|
153
|
-
content.team = team;
|
|
154
|
-
if (values.rules !== void 0) content.houseRules = await readFile(values.rules, "utf8");
|
|
155
|
-
} else if (kind === "skills") {
|
|
156
|
-
if (values.file !== void 0) content.body = await readFile(values.file, "utf8");
|
|
157
|
-
content.body ??= `---
|
|
158
|
-
name: ${name}
|
|
159
|
-
description: When to use this skill.
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
# ${name}
|
|
163
|
-
|
|
164
|
-
Steps and checks.
|
|
165
|
-
`;
|
|
166
|
-
} else if (kind === "mcp") {
|
|
167
|
-
if (values.command !== void 0 || values.url !== void 0) content.server = {};
|
|
168
|
-
const server = content.server ?? {};
|
|
169
|
-
set(server, "command", values.command);
|
|
170
|
-
if (values.arg?.length) server.args = values.arg;
|
|
171
|
-
if (values.env?.length) server.env = pairs(values.env, "--env");
|
|
172
|
-
set(server, "cwd", values.cwd);
|
|
173
|
-
set(server, "url", values.url);
|
|
174
|
-
if (values.header?.length) server.headers = pairs(values.header, "--header");
|
|
175
|
-
content.server = server;
|
|
176
|
-
} else if (kind === "hooks") {
|
|
177
|
-
const hook = content.hook ?? {};
|
|
178
|
-
set(hook, "description", values.description);
|
|
179
|
-
set(hook, "event", values.event);
|
|
180
|
-
set(hook, "command", values.command);
|
|
181
|
-
if (values.blocking !== void 0) hook.blocking = values.blocking;
|
|
182
|
-
if (values.timeout !== void 0) hook.timeoutSec = Number(values.timeout);
|
|
183
|
-
if (values["match-agent"] !== void 0 || values["match-label"] !== void 0) {
|
|
184
|
-
const match = hook.match ?? {};
|
|
185
|
-
set(match, "agent", values["match-agent"]);
|
|
186
|
-
set(match, "label", values["match-label"]);
|
|
187
|
-
if (Object.keys(match).length) hook.match = match;
|
|
188
|
-
else delete hook.match;
|
|
189
|
-
}
|
|
190
|
-
content.hook = hook;
|
|
191
|
-
} else if (kind === "providers") {
|
|
192
|
-
const isAntigravity = name === "antigravity" || values.kind === "antigravity";
|
|
193
|
-
const provider = content.provider ?? { kind: isAntigravity ? "antigravity" : "acp" };
|
|
194
|
-
if (values.kind !== void 0) provider.kind = values.kind;
|
|
195
|
-
if (isAntigravity) {
|
|
196
|
-
if (provider.command === void 0 && values.command === void 0) provider.command = "agy";
|
|
197
|
-
if (provider.label === void 0 && values.label === void 0) provider.label = "Antigravity";
|
|
198
|
-
}
|
|
199
|
-
set(provider, "label", values.label);
|
|
200
|
-
set(provider, "description", values.description);
|
|
201
|
-
set(provider, "command", values.command);
|
|
202
|
-
set(provider, "readOnlyMode", values["read-only-mode"]);
|
|
203
|
-
if (values.arg?.length) provider.args = values.arg;
|
|
204
|
-
if (values.env?.length) provider.env = pairs(values.env, "--env");
|
|
205
|
-
const models = names(values.models);
|
|
206
|
-
if (models) {
|
|
207
|
-
if (models.length) provider.models = models.map((id) => provider.models?.find((model) => model.id === id) ?? { id });
|
|
208
|
-
else delete provider.models;
|
|
209
|
-
}
|
|
210
|
-
content.provider = provider;
|
|
211
|
-
}
|
|
212
|
-
return content;
|
|
213
|
-
}
|
|
214
|
-
async function editCommand(kind, args) {
|
|
215
|
-
const { values, positionals } = parseArgs({ args: projectFlag(args), allowPositionals: true, options: EDIT_OPTIONS });
|
|
216
|
-
const [action, name, target] = positionals;
|
|
217
|
-
if (kind === "providers" && action !== "add") await seedLibrary(alpHome());
|
|
218
|
-
const creates = { agents: "new", teams: "new", skills: "new", mcp: "add", hooks: "add", providers: "add" }[kind];
|
|
219
|
-
if (!name || positionals.length > (["cp", "mv"].includes(action) ? 3 : 2) || ["cp", "mv"].includes(action) && !target) throw new UsageError();
|
|
220
|
-
const scope = values.project !== void 0 ? "project" : "library";
|
|
221
|
-
let root = values.project !== void 0 ? path.resolve(values.project) : void 0;
|
|
222
|
-
if (scope === "project") await taskProject(root);
|
|
223
|
-
root ??= await access(path.join(process.cwd(), ".alp")).then(() => process.cwd(), () => void 0);
|
|
224
|
-
const options = { scope, root, library: alpHome() };
|
|
225
|
-
const done = (result2, line) => console.log(values.json ? JSON.stringify(result2) : line);
|
|
226
|
-
const where = scope === "project" ? `the project ${root}` : `your library ${alpHome()}`;
|
|
227
|
-
if (action === "show") {
|
|
228
|
-
const entry = await getEntry(kind, name, { root, library: alpHome(), ...values.project !== void 0 ? { scope } : {} });
|
|
229
|
-
if (values.json) {
|
|
230
|
-
console.log(JSON.stringify(entry));
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
console.log(`${name} ${entry.source === "builtin" ? "built-in" : entry.source}${entry.overrides ? `, overrides the ${entry.overrides === "builtin" ? "built-in" : entry.overrides} one` : ""}${entry.usedBy.length ? `; used by ${entry.usedBy.join(", ")}` : ""}`);
|
|
234
|
-
for (const [key, value] of Object.entries(entry.content)) console.log(`--- ${key}
|
|
235
|
-
${typeof value === "string" ? value.trimEnd() : JSON.stringify(value, null, 2)}`);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (action === "rm") {
|
|
239
|
-
const result2 = await deleteEntry(kind, name, options);
|
|
240
|
-
done(result2, `Removed ${name} from ${where}${result2.now ? `; the ${result2.now === "builtin" ? "built-in" : result2.now} one applies again` : ""}.`);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (action === "mv") {
|
|
244
|
-
done(await renameEntry(kind, name, target, options), `Renamed ${name} to ${target} in ${where}.`);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
if (action === "cp") {
|
|
248
|
-
done(await duplicateEntry(kind, name, target, options), `Copied ${name} to ${target} in ${where}.`);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (action === "test") {
|
|
252
|
-
if (!["mcp", "hooks", "providers"].includes(kind)) throw new UsageError();
|
|
253
|
-
const result2 = await testEntry(kind, name, { root, library: alpHome(), ...values.project !== void 0 ? { scope } : {} });
|
|
254
|
-
if (values.json) console.log(JSON.stringify(result2));
|
|
255
|
-
else if (kind === "providers") {
|
|
256
|
-
if (result2.agent?.name === "antigravity") {
|
|
257
|
-
console.log(`${name}: ${result2.agent?.title ?? "Antigravity"} ${result2.agent?.version ?? ""} (models: ${result2.models?.length ?? 0}, mode: ${result2.currentMode ?? "full-access"})`);
|
|
258
|
-
} else {
|
|
259
|
-
console.log(`${name}: ${result2.agent?.title ?? result2.agent?.name ?? "agent"} ${result2.agent?.version ?? ""} speaks ACP ${result2.protocolVersion}; ${result2.loadSession ? "resumes sessions" : "cannot resume sessions"}${result2.mcpHttp ? "; takes HTTP MCP servers" : ""}${result2.authMethods?.length ? `; signs in with ${result2.authMethods.join(", ")}` : ""}`);
|
|
260
|
-
}
|
|
261
|
-
} else if (kind === "mcp") console.log(`${name}: ${result2.server?.name ?? "server"} ${result2.server?.version ?? ""} offers ${result2.tools.length} tools${result2.tools.length ? `:
|
|
262
|
-
${result2.tools.map((tool) => ` ${tool.name}${tool.description ? ` ${tool.description.split("\n")[0]}` : ""}`).join("\n")}` : ""}`);
|
|
263
|
-
else console.log(`${name}: ${result2.timedOut ? "timed out" : `exit ${result2.exitCode ?? result2.signal}`} in ${result2.durationMs} ms${result2.wouldBlock ? "; as a blocking hook it would refuse the action" : ""}${result2.stdout.trim() ? `
|
|
264
|
-
stdout: ${result2.stdout.trim()}` : ""}${result2.stderr.trim() ? `
|
|
265
|
-
stderr: ${result2.stderr.trim()}` : ""}`);
|
|
266
|
-
if (!result2.ok) process.exitCode = 1;
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (action !== creates && action !== "edit") throw new UsageError();
|
|
270
|
-
let current;
|
|
271
|
-
let revision = null;
|
|
272
|
-
if (action === creates) {
|
|
273
|
-
if (values.from !== void 0) current = (await getEntry(kind, values.from, { root, library: alpHome() })).content;
|
|
274
|
-
} else {
|
|
275
|
-
const entry = await getEntry(kind, name, { root, library: alpHome() }).catch((error) => {
|
|
276
|
-
if (error.code === "NOT_FOUND") throw new Error(`No ${kind} entry '${name}'; create it with alp ${kind.replace(/s$/, "")} ${creates}`);
|
|
277
|
-
throw error;
|
|
278
|
-
});
|
|
279
|
-
const own = await getEntry(kind, name, { root, library: alpHome(), scope }).catch(() => void 0);
|
|
280
|
-
current = (own ?? entry).content;
|
|
281
|
-
revision = own ? own.revision : null;
|
|
282
|
-
}
|
|
283
|
-
const result = await saveEntry(kind, name, await edited(kind, name, current, values), { ...options, revision });
|
|
284
|
-
done(result, `${action === "edit" ? "Saved" : "Created"} ${name} in ${where}.`);
|
|
285
|
-
}
|
|
286
|
-
async function teamsCommand(args) {
|
|
287
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
288
|
-
if (positionals.length) throw new UsageError();
|
|
289
|
-
const root = path.resolve(values.project ?? process.cwd());
|
|
290
|
-
const options = { library: alpHome() };
|
|
291
|
-
const rows = [];
|
|
292
|
-
for (const row of await listTeams(root, options)) rows.push(row.error ? row : { ...row, team: await resolveTeam(root, row.id, options) });
|
|
293
|
-
if (values.json) {
|
|
294
|
-
console.log(JSON.stringify(rows.map(({ team, ...row }) => ({ ...row, ...team ? { main: team.main, members: team.members, delegation: team.delegation, maxPeers: team.maxPeers, supervisor: team.supervisor } : {} }))));
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
for (const { team, ...row } of rows) {
|
|
298
|
-
const where = row.source === "builtin" ? "built-in" : row.source;
|
|
299
|
-
console.log(`${row.id} ${row.label ?? ""} ${where}${row.overrides ? `, overrides the ${row.overrides === "builtin" ? "built-in" : row.overrides} one` : ""}`);
|
|
300
|
-
if (row.error) {
|
|
301
|
-
console.log(` error: ${row.error}`);
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
const member = (name, { role, model, thinking }) => `${name}${role ? ` (${role})` : " (main)"}${model ? ` on ${model}${thinking ? `, ${thinking}` : ""}` : ""}`;
|
|
305
|
-
console.log(` members: ${Object.entries(team.members).map(([name, value]) => member(name, value)).join(", ")}`);
|
|
306
|
-
console.log(` delegation: ${Object.entries(team.delegation).map(([owner, targets]) => `${owner} \u2192 ${targets.join(", ")}`).join("; ") || "none"}`);
|
|
307
|
-
console.log(` supervisor: ${team.supervisor ? member(team.supervisor.agent, { role: "watches main", model: team.supervisor.model, thinking: team.supervisor.thinking }) : "none"}${team.maxPeers ? `; at most ${team.maxPeers} peers` : ""}`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
export {
|
|
311
|
-
EDIT_OPTIONS,
|
|
312
|
-
editCommand,
|
|
313
|
-
edited,
|
|
314
|
-
libraryCommand,
|
|
315
|
-
names,
|
|
316
|
-
pairs,
|
|
317
|
-
projectFlag,
|
|
318
|
-
teamsCommand
|
|
319
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/paths.js
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
function distributionEntry(name) {
|
|
6
|
-
const entry = process.argv[1] && path.basename(process.argv[1]) === "cli.js" ? pathToFileURL(path.resolve(process.argv[1])) : void 0;
|
|
7
|
-
const candidates = [
|
|
8
|
-
...entry ? [new URL(`../dist/${name}`, entry)] : [],
|
|
9
|
-
new URL(`../dist/${name}`, import.meta.url),
|
|
10
|
-
new URL(`../../../dist/${name}`, import.meta.url)
|
|
11
|
-
];
|
|
12
|
-
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
|
|
13
|
-
}
|
|
14
|
-
var DAEMON_ENTRY = fileURLToPath(distributionEntry("alpd.js"));
|
|
15
|
-
export {
|
|
16
|
-
DAEMON_ENTRY,
|
|
17
|
-
distributionEntry
|
|
18
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function project(command: any, args: any): Promise<void>;
|
|
2
|
-
export function permissionsCommand(args: any): Promise<void>;
|
|
3
|
-
/** Lists one library kind: where each entry comes from, what it overrides, and who uses it. */
|
|
4
|
-
export function trustCommand(args: any): Promise<void>;
|
|
5
|
-
/** alp teams: each team with where it comes from, its main, members and delegation. */
|
|
6
|
-
export function language(args: any): Promise<void>;
|
|
7
|
-
/** alp verify: run the project's verify commands here, in the project root. */
|
|
8
|
-
export function verify(args: any): Promise<void>;
|
|
9
|
-
export function doctor(args: any): Promise<void>;
|