@anhlp/alp-cli 0.0.1-beta.6 → 0.0.1-beta.8
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/dist/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/acp/main.js +1 -1
- package/dist/acp.js +7499 -2325
- package/dist/alp-web/assets/{TerminalPanel-CqTsgY-W.js → TerminalPanel-BbYa_Xkd.js} +1 -1
- package/dist/alp-web/assets/index-DOJh89Ik.js +59 -0
- package/dist/alp-web/assets/index-DwqDSiIi.css +1 -0
- package/dist/alp-web/index.html +2 -2
- package/dist/alp-web.js +252 -249
- package/dist/alpd.js +10508 -4233
- package/dist/backup.js +1 -1
- package/dist/build-manifest.json +11 -2
- package/dist/cli.js +8 -10
- package/dist/daemon.d.ts +1 -1
- package/dist/daemon.js +2 -2
- package/dist/interfaces.js +4 -3
- package/dist/library.d.ts +16 -2
- package/dist/library.js +114 -7
- package/dist/paths.d.ts +1 -1
- package/dist/projects.js +2 -1
- package/dist/roles.d.ts +3 -3
- package/dist/roles.js +1 -3
- package/dist/self-update.d.ts +36 -38
- package/dist/self-update.js +124 -98
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +9 -4
- package/dist/web-service.js +2 -2
- package/package.json +5 -5
- package/src/cli.js +12 -11
- package/src/daemon.js +3 -3
- package/src/interfaces.js +6 -3
- package/src/library.js +108 -9
- package/src/paths.js +1 -1
- package/src/projects.js +3 -1
- package/src/roles.js +4 -6
- package/src/self-update.js +141 -112
- package/src/usage.js +9 -4
- package/src/web-service.js +3 -4
- package/dist/alp-web/assets/index-BMbDUCHW.css +0 -1
- package/dist/alp-web/assets/index-B_RFaj2C.js +0 -59
package/dist/backup.js
CHANGED
|
@@ -7,7 +7,7 @@ import { acquireDaemonLock, alpHome, assertPrivateDirectory, daemonPaths, lockAl
|
|
|
7
7
|
import { daemonHeld, holdDaemon, releaseHold } from "@anhlp/alp-client/supervise";
|
|
8
8
|
import { start, stop } from "./daemon.js";
|
|
9
9
|
import { UsageError } from "./usage.js";
|
|
10
|
-
var VERSION = true ? "0.0.1-beta.
|
|
10
|
+
var VERSION = true ? "0.0.1-beta.8" : "dev";
|
|
11
11
|
var BY = `alp ${VERSION}`;
|
|
12
12
|
var size = (bytes) => bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : bytes >= 1024 ? `${(bytes / 1024).toFixed(1)} KB` : `${bytes} B`;
|
|
13
13
|
var stamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
package/dist/build-manifest.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.1-beta.
|
|
2
|
+
"version": "0.0.1-beta.8",
|
|
3
3
|
"entries": {
|
|
4
4
|
"packages/cli/dist/alpd.js": {
|
|
5
5
|
"inputs": [
|
|
6
|
+
"packages/client/src/acp-probe.js",
|
|
6
7
|
"packages/client/src/index.js",
|
|
7
8
|
"packages/client/src/ipc.js",
|
|
9
|
+
"packages/client/src/mcp-probe.js",
|
|
8
10
|
"packages/client/src/portable.js",
|
|
9
11
|
"packages/client/src/rpc/client.js",
|
|
10
12
|
"packages/client/src/rpc/errors.js",
|
|
@@ -41,6 +43,7 @@
|
|
|
41
43
|
"packages/core/src/resolver.js",
|
|
42
44
|
"packages/core/src/safe-path.js",
|
|
43
45
|
"packages/core/src/shell.js",
|
|
46
|
+
"packages/core/src/skill-validate.js",
|
|
44
47
|
"packages/core/src/state-schema.js",
|
|
45
48
|
"packages/core/src/task-rows.js",
|
|
46
49
|
"packages/core/src/tasks.js",
|
|
@@ -63,6 +66,7 @@
|
|
|
63
66
|
"packages/daemon/src/lifecycle.ts",
|
|
64
67
|
"packages/daemon/src/lock.ts",
|
|
65
68
|
"packages/daemon/src/main.ts",
|
|
69
|
+
"packages/daemon/src/model-catalog.ts",
|
|
66
70
|
"packages/daemon/src/native-terminal.ts",
|
|
67
71
|
"packages/daemon/src/operations.ts",
|
|
68
72
|
"packages/daemon/src/registry.ts",
|
|
@@ -110,13 +114,15 @@
|
|
|
110
114
|
"packages/runtime/src/runtime-context.ts",
|
|
111
115
|
"packages/runtime/src/runtime.ts",
|
|
112
116
|
"packages/runtime/src/session-config.ts",
|
|
117
|
+
"packages/runtime/src/skill-resources.ts",
|
|
113
118
|
"packages/runtime/src/tool-detail.ts",
|
|
114
119
|
"packages/runtime/src/tool-results.ts",
|
|
115
120
|
"packages/runtime/src/tools.ts",
|
|
116
121
|
"packages/runtime/src/transport.ts",
|
|
117
122
|
"packages/runtime/src/usage.ts",
|
|
118
123
|
"packages/runtime/src/workspace.ts",
|
|
119
|
-
"packages/runtime/src/worktree-domain.ts"
|
|
124
|
+
"packages/runtime/src/worktree-domain.ts",
|
|
125
|
+
"packages/runtime/src/write-error.ts"
|
|
120
126
|
],
|
|
121
127
|
"external": [
|
|
122
128
|
"child_process",
|
|
@@ -208,6 +214,7 @@
|
|
|
208
214
|
"packages/client/src/websocket.js",
|
|
209
215
|
"packages/core/src/atomic.js",
|
|
210
216
|
"packages/core/src/errors.js",
|
|
217
|
+
"packages/core/src/gate-ledger.js",
|
|
211
218
|
"packages/core/src/library-edit.js",
|
|
212
219
|
"packages/core/src/library.js",
|
|
213
220
|
"packages/core/src/log.js",
|
|
@@ -218,6 +225,8 @@
|
|
|
218
225
|
"packages/core/src/resolver.js",
|
|
219
226
|
"packages/core/src/safe-path.js",
|
|
220
227
|
"packages/core/src/shell.js",
|
|
228
|
+
"packages/core/src/skill-validate.js",
|
|
229
|
+
"packages/core/src/tasks.js",
|
|
221
230
|
"packages/core/src/teams.js",
|
|
222
231
|
"packages/core/src/template-path.js",
|
|
223
232
|
"packages/core/src/validation.js",
|
package/dist/cli.js
CHANGED
|
@@ -4,22 +4,23 @@
|
|
|
4
4
|
import { setup } from "@anhlp/alp-client/setup";
|
|
5
5
|
import { alpHome } from "@anhlp/alp-client/index";
|
|
6
6
|
import { scrubText } from "@anhlp/alp-core/log";
|
|
7
|
+
import { catalogModels, useLiveModels } from "@anhlp/alp-core/models";
|
|
7
8
|
import { USAGE, UsageError } from "./usage.js";
|
|
8
9
|
import { project, permissionsCommand, trustCommand, language, verify, doctor } from "./projects.js";
|
|
9
10
|
import { daemon } from "./daemon.js";
|
|
10
11
|
import { run, ps, attach, send, questions, answer, top, log, board, models, pause, resume, recall, interrupt, compact } from "./sessions.js";
|
|
11
|
-
import { libraryCommand, editCommand, teamsCommand } from "./library.js";
|
|
12
|
+
import { libraryCommand, editCommand, teamsCommand, packsCommand, packCommand } from "./library.js";
|
|
12
13
|
import { scheduleCommand } from "./schedules.js";
|
|
13
14
|
import { tasksCommand, formulaCommand, taskCommand } from "./tasks.js";
|
|
14
15
|
import { webCommand, acpCommand } from "./interfaces.js";
|
|
15
16
|
import { backupCommand, restoreCommand } from "./backup.js";
|
|
16
17
|
import { terminalCommand } from "./terminal.js";
|
|
17
18
|
import { bridgeCommand } from "./roles.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
19
|
+
import { selfUpdate } from "./self-update.js";
|
|
20
|
+
import { bundleInfo } from "@anhlp/alp-core/packaged";
|
|
20
21
|
import { connect, lockAlive, readLock } from "@anhlp/alp-client/index";
|
|
21
22
|
function alpVersion() {
|
|
22
|
-
return
|
|
23
|
+
return true ? "0.0.1-beta.8" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
23
24
|
}
|
|
24
25
|
async function runningDaemon() {
|
|
25
26
|
const lock = await readLock(alpHome());
|
|
@@ -36,20 +37,17 @@ async function runningDaemon() {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
async function updateCommand(args2) {
|
|
39
|
-
const code = await selfUpdate(args2, {
|
|
40
|
+
const code = await selfUpdate(args2, { bundle: bundleInfo(), version: alpVersion(), daemon: runningDaemon });
|
|
40
41
|
if (code) process.exitCode = code;
|
|
41
42
|
}
|
|
42
|
-
{
|
|
43
|
-
const executable = executablePath();
|
|
44
|
-
if (executable) cleanupOldExecutable(executable);
|
|
45
|
-
}
|
|
46
|
-
var commands = { schedule: scheduleCommand, setup: (args2) => setup(args2, alpHome()), init: (args2) => project("init", args2), "update-template": (args2) => project("upgrade", args2), upgrade: (args2) => project("upgrade", args2), update: updateCommand, daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: (args2) => libraryCommand("agents", args2), skills: (args2) => libraryCommand("skills", args2), mcp: (args2) => ["add", "rm", "mv", "cp", "test", "show", "edit"].includes(args2[0]) ? editCommand("mcp", args2) : libraryCommand("mcp", args2), hooks: (args2) => libraryCommand("hooks", args2), providers: (args2) => libraryCommand("providers", args2), provider: (args2) => editCommand("providers", args2), teams: teamsCommand, trust: trustCommand, agent: (args2) => editCommand("agents", args2), team: (args2) => editCommand("teams", args2), skill: (args2) => editCommand("skills", args2), hook: (args2) => editCommand("hooks", args2), verify, recall, pause, resume, language, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
|
|
43
|
+
var commands = { schedule: scheduleCommand, setup: (args2) => setup(args2, alpHome()), init: (args2) => project("init", args2), "update-template": (args2) => project("upgrade", args2), upgrade: (args2) => project("upgrade", args2), update: updateCommand, daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: (args2) => libraryCommand("agents", args2), skills: (args2) => libraryCommand("skills", args2), mcp: (args2) => ["add", "rm", "mv", "cp", "test", "show", "edit"].includes(args2[0]) ? editCommand("mcp", args2) : libraryCommand("mcp", args2), hooks: (args2) => libraryCommand("hooks", args2), providers: (args2) => libraryCommand("providers", args2), provider: (args2) => editCommand("providers", args2), teams: teamsCommand, packs: packsCommand, pack: packCommand, trust: trustCommand, agent: (args2) => editCommand("agents", args2), team: (args2) => editCommand("teams", args2), skill: (args2) => editCommand("skills", args2), hook: (args2) => editCommand("hooks", args2), verify, recall, pause, resume, language, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
|
|
47
44
|
var [command, ...args] = process.argv.slice(2);
|
|
48
45
|
try {
|
|
49
46
|
if (command === "--version") {
|
|
50
47
|
console.log(alpVersion());
|
|
51
48
|
} else {
|
|
52
49
|
if (!Object.hasOwn(commands, command)) throw new UsageError();
|
|
50
|
+
if (command !== "setup") useLiveModels(catalogModels(alpHome()));
|
|
53
51
|
await commands[command](args);
|
|
54
52
|
}
|
|
55
53
|
} catch (error) {
|
package/dist/daemon.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function built(): Promise<void>;
|
|
2
|
-
/** Waits until an alpd for this home is ready; returns its socket. */
|
|
2
|
+
/** Waits until an alpd for this home is ready; returns its socket. Default wait: ALP_DAEMON_START_TIMEOUT_MS, else 60 s. */
|
|
3
3
|
export function ready(timeoutMs?: number): Promise<any>;
|
|
4
4
|
/** The installed service for this ALP_HOME, if any. */
|
|
5
5
|
export function installed(): Promise<{
|
package/dist/daemon.js
CHANGED
|
@@ -3,7 +3,7 @@ import { access } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { installedProgram, installService, serviceFor, uninstallService } from "@anhlp/alp-client/service";
|
|
5
5
|
import { holdDaemon, startDaemon } from "@anhlp/alp-client/supervise";
|
|
6
|
-
import { alpHome, connect, lockAlive, readLock, withDaemonLifecycle } from "@anhlp/alp-client/index";
|
|
6
|
+
import { alpHome, connect, daemonStartTimeoutMs, lockAlive, readLock, withDaemonLifecycle } from "@anhlp/alp-client/index";
|
|
7
7
|
import { scrubText } from "@anhlp/alp-core/log";
|
|
8
8
|
import { UsageError } from "./usage.js";
|
|
9
9
|
import { DAEMON_ENTRY } from "./paths.js";
|
|
@@ -15,7 +15,7 @@ async function built() {
|
|
|
15
15
|
throw new Error(`alpd is not built (${DAEMON_ENTRY}); run npm run build`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
async function ready(timeoutMs =
|
|
18
|
+
async function ready(timeoutMs = daemonStartTimeoutMs()) {
|
|
19
19
|
const deadline = Date.now() + timeoutMs;
|
|
20
20
|
while (Date.now() < deadline) {
|
|
21
21
|
const lock = await readLock(alpHome());
|
package/dist/interfaces.js
CHANGED
|
@@ -8,7 +8,8 @@ import { alpHome, connect, daemonPaths, discoverIntegration, startIntegration }
|
|
|
8
8
|
import { UsageError } from "./usage.js";
|
|
9
9
|
import { built, start, running } from "./daemon.js";
|
|
10
10
|
import { DAEMON_ENTRY, distributionEntry } from "./paths.js";
|
|
11
|
-
import { entryCommand
|
|
11
|
+
import { entryCommand } from "@anhlp/alp-core/packaged";
|
|
12
|
+
import { isAgentProcess } from "@anhlp/alp-core/tasks";
|
|
12
13
|
import { runRole } from "./roles.js";
|
|
13
14
|
import { alpWebEntry, alpWebScript, isWebClaimed, isWebReady, refusal, stopPreRenamePaseo, stopWebService, webOwner } from "./web-service.js";
|
|
14
15
|
var PASEO = "paseo";
|
|
@@ -144,6 +145,7 @@ ${refusal(home)} (${owner.reason}). If it is not alp web, stop it, then run alp
|
|
|
144
145
|
return `${info.url}#token=${info.token}`;
|
|
145
146
|
}
|
|
146
147
|
async function webCommand(args) {
|
|
148
|
+
if (isAgentProcess()) throw new Error("alp web is the user's: it prints and rotates the user's credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set)");
|
|
147
149
|
if (args[0] === "pair") return pairCommand(args.slice(1));
|
|
148
150
|
if (args[0] === "rotate") return rotateCommand(args.slice(1));
|
|
149
151
|
if (args[0] === "serve") return runRole("web", alpWebScript(), args.slice(1));
|
|
@@ -224,10 +226,9 @@ ${pairing.url}`);
|
|
|
224
226
|
async function acpCommand(args) {
|
|
225
227
|
if (args.length) throw new UsageError();
|
|
226
228
|
await built();
|
|
227
|
-
const acp = packagedInfo()?.roles?.acp;
|
|
228
229
|
const { runAcp } = (
|
|
229
230
|
/** @type {{ runAcp: (options: { daemonEntry: string }) => Promise<void> }} */
|
|
230
|
-
|
|
231
|
+
await import(distributionEntry("acp.js").href)
|
|
231
232
|
);
|
|
232
233
|
await runAcp({ daemonEntry: DAEMON_ENTRY });
|
|
233
234
|
}
|
package/dist/library.d.ts
CHANGED
|
@@ -86,6 +86,12 @@ export const EDIT_OPTIONS: {
|
|
|
86
86
|
file: {
|
|
87
87
|
type: string;
|
|
88
88
|
};
|
|
89
|
+
roles: {
|
|
90
|
+
type: string;
|
|
91
|
+
};
|
|
92
|
+
'no-roles': {
|
|
93
|
+
type: string;
|
|
94
|
+
};
|
|
89
95
|
command: {
|
|
90
96
|
type: string;
|
|
91
97
|
};
|
|
@@ -122,10 +128,10 @@ export const EDIT_OPTIONS: {
|
|
|
122
128
|
'match-label': {
|
|
123
129
|
type: string;
|
|
124
130
|
};
|
|
125
|
-
|
|
131
|
+
strict: {
|
|
126
132
|
type: string;
|
|
127
133
|
};
|
|
128
|
-
|
|
134
|
+
kind: {
|
|
129
135
|
type: string;
|
|
130
136
|
};
|
|
131
137
|
models: {
|
|
@@ -138,3 +144,11 @@ export function edited(kind: any, name: any, current: any, values: any): Promise
|
|
|
138
144
|
export function editCommand(kind: any, args: any): Promise<void>;
|
|
139
145
|
/** alp trust: the workspaces whose hooks run without asking (ALPD §45). */
|
|
140
146
|
export function teamsCommand(args: any): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* alp packs [--project DIR] [--json]: the optional packs ALP ships, and whether the library or the
|
|
149
|
+
* project has them. alp pack install <id> [--project [DIR]] [--assign] [--json]: copies a pack's
|
|
150
|
+
* skills, agents and teams into the library (or the project's .alp/), keeping any entry already
|
|
151
|
+
* there; --assign (library) gives its suggested skills to roles in role-skills.json.
|
|
152
|
+
*/
|
|
153
|
+
export function packsCommand(args: any): Promise<void>;
|
|
154
|
+
export function packCommand(args: any): Promise<void>;
|
package/dist/library.js
CHANGED
|
@@ -5,14 +5,31 @@ import { parseArgs } from "node:util";
|
|
|
5
5
|
import { seedLibrary } from "@anhlp/alp-core/library";
|
|
6
6
|
import { libraryEntries } from "@anhlp/alp-core/resolver";
|
|
7
7
|
import { listTeams, resolveTeam } from "@anhlp/alp-core/teams";
|
|
8
|
-
import { deleteEntry, duplicateEntry, getEntry, renameEntry, saveEntry } from "@anhlp/alp-core/library-edit";
|
|
8
|
+
import { deleteEntry, duplicateEntry, getEntry, listRetiredSkills, renameEntry, restoreSkill, saveEntry, withSkillName } from "@anhlp/alp-core/library-edit";
|
|
9
9
|
import { testEntry } from "@anhlp/alp-client/library-test";
|
|
10
|
+
import { formatValidation, validateSkill } from "@anhlp/alp-core/skill-validate";
|
|
11
|
+
import { installPack, listPacks, packStatus } from "@anhlp/alp-core/packs";
|
|
10
12
|
import { alpHome } from "@anhlp/alp-client/index";
|
|
11
13
|
import { UsageError } from "./usage.js";
|
|
12
14
|
import { taskProject } from "./tasks.js";
|
|
13
15
|
async function libraryCommand(kind, args) {
|
|
14
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
16
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" }, ...kind === "skills" ? { retired: { type: "boolean" } } : {} } });
|
|
15
17
|
if (positionals.length) throw new UsageError();
|
|
18
|
+
if (values.retired) {
|
|
19
|
+
if (values.project !== void 0) throw new UsageError();
|
|
20
|
+
const rows2 = await listRetiredSkills({ library: alpHome() });
|
|
21
|
+
if (values.json) {
|
|
22
|
+
console.log(JSON.stringify(rows2));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!rows2.length) {
|
|
26
|
+
console.log(`No retired skills in ${path.join(alpHome(), "retired-skills")}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const width2 = Math.max(...rows2.map((row) => row.name.length));
|
|
30
|
+
for (const row of rows2) console.log(`${row.name.padEnd(width2)} ${row.retiredAt} ${row.roles === null ? "roles not recorded" : `roles: ${row.roles.join(", ") || "none"}`}${row.agent ? `; by ${row.agent}` : ""}${row.invalid ? `; warning: invalid retired metadata: ${row.invalid}` : ""} ${row.directory}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
16
33
|
if (kind === "providers") await seedLibrary(alpHome());
|
|
17
34
|
const root = path.resolve(values.project ?? process.cwd());
|
|
18
35
|
const rows = await libraryEntries(kind, root, { library: alpHome() });
|
|
@@ -75,6 +92,8 @@ var EDIT_OPTIONS = {
|
|
|
75
92
|
rules: { type: "string" },
|
|
76
93
|
// skill, mcp, hook
|
|
77
94
|
file: { type: "string" },
|
|
95
|
+
roles: { type: "string" },
|
|
96
|
+
"no-roles": { type: "boolean" },
|
|
78
97
|
command: { type: "string" },
|
|
79
98
|
arg: { type: "string", multiple: true },
|
|
80
99
|
env: { type: "string", multiple: true },
|
|
@@ -86,9 +105,9 @@ var EDIT_OPTIONS = {
|
|
|
86
105
|
timeout: { type: "string" },
|
|
87
106
|
"match-agent": { type: "string" },
|
|
88
107
|
"match-label": { type: "string" },
|
|
108
|
+
strict: { type: "boolean" },
|
|
89
109
|
// provider
|
|
90
110
|
kind: { type: "string" },
|
|
91
|
-
"read-only-mode": { type: "string" },
|
|
92
111
|
models: { type: "string" }
|
|
93
112
|
};
|
|
94
113
|
async function edited(kind, name, current, values) {
|
|
@@ -156,12 +175,16 @@ Describe what this agent does, and how.
|
|
|
156
175
|
if (values.file !== void 0) content.body = await readFile(values.file, "utf8");
|
|
157
176
|
content.body ??= `---
|
|
158
177
|
name: ${name}
|
|
159
|
-
description:
|
|
178
|
+
description: ${JSON.stringify(values.description ?? `What ${name} does. Use when the work it is for comes up.`)}
|
|
160
179
|
---
|
|
161
180
|
|
|
162
181
|
# ${name}
|
|
163
182
|
|
|
164
|
-
|
|
183
|
+
## When to use
|
|
184
|
+
|
|
185
|
+
## Workflow
|
|
186
|
+
|
|
187
|
+
## Verification
|
|
165
188
|
`;
|
|
166
189
|
} else if (kind === "mcp") {
|
|
167
190
|
if (values.command !== void 0 || values.url !== void 0) content.server = {};
|
|
@@ -199,7 +222,7 @@ Steps and checks.
|
|
|
199
222
|
set(provider, "label", values.label);
|
|
200
223
|
set(provider, "description", values.description);
|
|
201
224
|
set(provider, "command", values.command);
|
|
202
|
-
|
|
225
|
+
delete provider.readOnlyMode;
|
|
203
226
|
if (values.arg?.length) provider.args = values.arg;
|
|
204
227
|
if (values.env?.length) provider.env = pairs(values.env, "--env");
|
|
205
228
|
const models = names(values.models);
|
|
@@ -211,9 +234,44 @@ Steps and checks.
|
|
|
211
234
|
}
|
|
212
235
|
return content;
|
|
213
236
|
}
|
|
237
|
+
async function checkSkills(name, positionals, values) {
|
|
238
|
+
if (positionals.length > 2) throw new UsageError();
|
|
239
|
+
const root = path.resolve(values.project ?? process.cwd());
|
|
240
|
+
const mode = values.strict ? "strict" : "legacy";
|
|
241
|
+
let targets;
|
|
242
|
+
if (name !== void 0 && (name.includes("/") || name.includes(path.sep) || name.startsWith("."))) targets = [path.resolve(name)];
|
|
243
|
+
else {
|
|
244
|
+
const rows = await libraryEntries("skills", root, { library: alpHome() });
|
|
245
|
+
const chosen = name === void 0 ? rows : rows.filter((row) => row.name === name);
|
|
246
|
+
if (name !== void 0 && !chosen.length) throw new Error(`No skill '${name}' in ${path.join(root, ".alp", "skills")} or ${path.join(alpHome(), "skills")}`);
|
|
247
|
+
targets = chosen.map((row) => path.dirname(row.path));
|
|
248
|
+
}
|
|
249
|
+
const reports = [];
|
|
250
|
+
for (const target of targets) reports.push(await validateSkill(target, { mode }));
|
|
251
|
+
if (values.json) console.log(JSON.stringify(reports));
|
|
252
|
+
else {
|
|
253
|
+
for (const report of reports) console.log(formatValidation(report));
|
|
254
|
+
const failed = reports.filter((report) => !report.ok).length;
|
|
255
|
+
const warned = reports.filter((report) => report.warnings.length).length;
|
|
256
|
+
console.log(`${reports.length} skill${reports.length === 1 ? "" : "s"} checked (${mode}): ${failed} with errors, ${warned} with warnings.${mode === "legacy" && warned ? " Warnings do not stop a skill from loading; fix them when you next edit it." : ""}`);
|
|
257
|
+
}
|
|
258
|
+
if (reports.some((report) => !report.ok)) process.exitCode = 1;
|
|
259
|
+
}
|
|
214
260
|
async function editCommand(kind, args) {
|
|
261
|
+
if (kind === "providers" && args.some((arg) => arg === "--read-only-mode" || arg.startsWith("--read-only-mode="))) throw new Error("--read-only-mode was removed; delete readOnlyMode from provider JSON and choose the session --mode read-only, workspace-write or full-access. Existing native sessions keep their mode.");
|
|
215
262
|
const { values, positionals } = parseArgs({ args: projectFlag(args), allowPositionals: true, options: EDIT_OPTIONS });
|
|
216
263
|
const [action, name, target] = positionals;
|
|
264
|
+
if (kind === "skills" && action === "restore") {
|
|
265
|
+
if (!name || positionals.length > 2 || values.project !== void 0 || values.roles !== void 0 && values["no-roles"]) throw new UsageError();
|
|
266
|
+
const roles = values["no-roles"] ? [] : names(values.roles);
|
|
267
|
+
const result2 = await restoreSkill(name, { library: alpHome(), from: values.from, roles });
|
|
268
|
+
console.log(values.json ? JSON.stringify(result2) : `Restored ${name} to ${result2.restored} from ${result2.from}; ${result2.roles.length ? `given to ${result2.roles.join(", ")}` : "given to no role"}.`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (kind === "skills" && action === "check") {
|
|
272
|
+
await checkSkills(name, positionals, values);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
217
275
|
if (kind === "providers" && action !== "add") await seedLibrary(alpHome());
|
|
218
276
|
const creates = { agents: "new", teams: "new", skills: "new", mcp: "add", hooks: "add", providers: "add" }[kind];
|
|
219
277
|
if (!name || positionals.length > (["cp", "mv"].includes(action) ? 3 : 2) || ["cp", "mv"].includes(action) && !target) throw new UsageError();
|
|
@@ -271,6 +329,7 @@ stderr: ${result2.stderr.trim()}` : ""}`);
|
|
|
271
329
|
let revision = null;
|
|
272
330
|
if (action === creates) {
|
|
273
331
|
if (values.from !== void 0) current = (await getEntry(kind, values.from, { root, library: alpHome() })).content;
|
|
332
|
+
if (kind === "skills" && current?.body !== void 0) current = { ...current, body: withSkillName(current.body, name) };
|
|
274
333
|
} else {
|
|
275
334
|
const entry = await getEntry(kind, name, { root, library: alpHome() }).catch((error) => {
|
|
276
335
|
if (error.code === "NOT_FOUND") throw new Error(`No ${kind} entry '${name}'; create it with alp ${kind.replace(/s$/, "")} ${creates}`);
|
|
@@ -280,8 +339,14 @@ stderr: ${result2.stderr.trim()}` : ""}`);
|
|
|
280
339
|
current = (own ?? entry).content;
|
|
281
340
|
revision = own ? own.revision : null;
|
|
282
341
|
}
|
|
283
|
-
const result = await saveEntry(kind, name, await edited(kind, name, current, values), { ...options, revision });
|
|
342
|
+
const result = await saveEntry(kind, name, await edited(kind, name, current, values), { ...options, revision, strict: kind === "skills" && action === creates });
|
|
284
343
|
done(result, `${action === "edit" ? "Saved" : "Created"} ${name} in ${where}.`);
|
|
344
|
+
if (kind === "skills" && !values.json) {
|
|
345
|
+
const directory = path.join(scope === "project" ? path.join(root, ".alp") : alpHome(), "skills", name);
|
|
346
|
+
const report = await validateSkill(directory);
|
|
347
|
+
const notes = [...result.warnings ?? [], ...report.errors.map((finding) => finding.message), ...report.warnings.map((finding) => finding.message)];
|
|
348
|
+
for (const note of [...new Set(notes)]) console.log(`note: ${note}`);
|
|
349
|
+
}
|
|
285
350
|
}
|
|
286
351
|
async function teamsCommand(args) {
|
|
287
352
|
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
@@ -307,12 +372,54 @@ async function teamsCommand(args) {
|
|
|
307
372
|
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
373
|
}
|
|
309
374
|
}
|
|
375
|
+
async function packsCommand(args) {
|
|
376
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
377
|
+
if (positionals.length) throw new UsageError();
|
|
378
|
+
const root = path.resolve(values.project ?? process.cwd());
|
|
379
|
+
const rows = [];
|
|
380
|
+
for (const pack of await listPacks()) rows.push({ ...pack, installed: await packStatus(pack, { root, library: alpHome() }) });
|
|
381
|
+
if (values.json) {
|
|
382
|
+
console.log(JSON.stringify(rows));
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const width = Math.max(...rows.map((row) => row.id.length));
|
|
386
|
+
for (const row of rows) {
|
|
387
|
+
const contents = [row.skills.length ? `skills: ${row.skills.join(", ")}` : "", row.agents.length ? `agents: ${row.agents.join(", ")}` : "", row.teams.length ? `teams: ${row.teams.join(", ")}` : ""].filter(Boolean).join("; ");
|
|
388
|
+
const where = [row.installed.library ? "library" : "", row.installed.project ? "project" : ""].filter(Boolean).join(", ");
|
|
389
|
+
console.log(`${row.id.padEnd(width)} ${row.description}
|
|
390
|
+
${" ".repeat(width)} ${contents}${where ? ` [installed: ${where}]` : ""}`);
|
|
391
|
+
}
|
|
392
|
+
console.log("Install one with: alp pack install <id> [--project] [--assign]");
|
|
393
|
+
}
|
|
394
|
+
async function packCommand(args) {
|
|
395
|
+
const { values, positionals } = parseArgs({ args: projectFlag(args), allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" }, assign: { type: "boolean" } } });
|
|
396
|
+
const [action, id] = positionals;
|
|
397
|
+
if (action !== "install" || !id || positionals.length > 2) throw new UsageError();
|
|
398
|
+
const scope = values.project !== void 0 ? "project" : "library";
|
|
399
|
+
const root = values.project !== void 0 ? path.resolve(values.project) : void 0;
|
|
400
|
+
if (scope === "project") await taskProject(root);
|
|
401
|
+
const result = await installPack(id, { scope, root, library: alpHome(), assign: values.assign });
|
|
402
|
+
if (values.json) {
|
|
403
|
+
console.log(JSON.stringify(result));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const where = scope === "project" ? `the project ${root}` : `your library ${alpHome()}`;
|
|
407
|
+
for (const entry of result.installed) console.log(`installed ${entry.kind.replace(/s$/, "")} ${entry.name} ${entry.path}`);
|
|
408
|
+
for (const entry of result.kept) console.log(`kept ${entry.kind.replace(/s$/, "")} ${entry.name}: one already exists, and stays as it is (${entry.path})`);
|
|
409
|
+
for (const line of result.permissions.set) console.log(`permission ${line} (agent capped by its permission profile)`);
|
|
410
|
+
for (const line of result.permissions.conflicts) console.log(`warning: ${line}`);
|
|
411
|
+
if (result.assigned.length) console.log(`assigned ${result.assigned.join(", ")} in role-skills.json`);
|
|
412
|
+
else if (!values.assign && scope === "library" && result.installed.some((entry) => entry.kind === "skills")) console.log("No role has these skills yet: rerun with --assign for the pack's suggestion, or alp agent edit <agent> --skills a,b.");
|
|
413
|
+
console.log(`Pack ${id} in ${where}. Start a new session (or close and resume) for agents to see it.`);
|
|
414
|
+
}
|
|
310
415
|
export {
|
|
311
416
|
EDIT_OPTIONS,
|
|
312
417
|
editCommand,
|
|
313
418
|
edited,
|
|
314
419
|
libraryCommand,
|
|
315
420
|
names,
|
|
421
|
+
packCommand,
|
|
422
|
+
packsCommand,
|
|
316
423
|
pairs,
|
|
317
424
|
projectFlag,
|
|
318
425
|
teamsCommand
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Locate artifacts in either the independently shipped CLI or the legacy root build. */
|
|
2
2
|
export function distributionEntry(name: any): URL;
|
|
3
|
-
/** What starts alpd: alpd.js under Node
|
|
3
|
+
/** What starts alpd: alpd.js under Node (named through app/current in the ALP bundle). */
|
|
4
4
|
export const DAEMON_ENTRY: string;
|
package/dist/projects.js
CHANGED
|
@@ -21,8 +21,9 @@ async function project(command, args) {
|
|
|
21
21
|
try {
|
|
22
22
|
const result = await (command === "upgrade" ? upgradeProject : initProject)(args[0] ?? process.cwd(), { library: alpHome() });
|
|
23
23
|
console.log(`ALP initialized: ${result.created.length} files created, ${result.preserved.length} existing files preserved.`);
|
|
24
|
-
const library = await seedLibrary(alpHome());
|
|
24
|
+
const library = await seedLibrary(alpHome(), { offerRoleSkills: command === "upgrade" });
|
|
25
25
|
if (library.created.length || library.updated.length) console.log(`Skill library ${alpHome()}: ${library.created.length} files added, ${library.updated.length} unchanged files updated.`);
|
|
26
|
+
if (library.offered?.length) console.log(`New built-in skills given to roles in your edited role-skills.json: ${library.offered.join(", ")} (remove any you do not want; ALP will not add it again).`);
|
|
26
27
|
if (command === "init" && result.updated?.length) console.log(`Template model profiles refreshed: ${result.updated.join(", ")}`);
|
|
27
28
|
if (command === "upgrade") {
|
|
28
29
|
console.log(`ALP upgraded: ${result.updated.length} files updated.${result.backup ? ` Backup: ${result.backup}` : ""}`);
|
package/dist/roles.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The role subcommands (t-1e02): `alp daemon run`, `alp web serve` and `alp bridge acp|antigravity`
|
|
3
|
-
* run alpd, alp-web and the MCP bridges in this process
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* run alpd, alp-web and the MCP bridges in this process: they import the same scripts that
|
|
4
|
+
* `node alpd.js` and `node alp-web.js` run. Services and MCP entries written by the single-file
|
|
5
|
+
* executable of 0.0.1-beta.5/6 still name them.
|
|
6
6
|
*
|
|
7
7
|
* The role's module reads its options from process.argv as when run directly, so argv is rewritten
|
|
8
8
|
* to `[runtime, entry, ...args]` before the module loads.
|
package/dist/roles.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// packages/cli/src/roles.js
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { runBridge } from "@anhlp/alp-core/bridges";
|
|
4
|
-
import { packagedInfo } from "@anhlp/alp-core/packaged";
|
|
5
4
|
import { UsageError } from "./usage.js";
|
|
6
5
|
async function runRole(role, file, args) {
|
|
7
6
|
process.argv = [process.argv[0], file, ...args];
|
|
8
|
-
|
|
9
|
-
return load ? load() : import(pathToFileURL(file).href);
|
|
7
|
+
return import(pathToFileURL(file).href);
|
|
10
8
|
}
|
|
11
9
|
function bridgeCommand(args) {
|
|
12
10
|
if (args.length !== 1 || !["acp", "antigravity"].includes(args[0])) throw new UsageError();
|
package/dist/self-update.d.ts
CHANGED
|
@@ -58,55 +58,53 @@ export function verifyProvenance(file: string, { repo, env, run, find }: {
|
|
|
58
58
|
}): "unavailable" | "verified";
|
|
59
59
|
/**
|
|
60
60
|
* Runs `action`, again after a pause while Windows reports the file busy: a virus scanner holds an
|
|
61
|
-
* executable it just saw run (the staged
|
|
61
|
+
* executable it just saw run (the staged bundle's --version) for a moment. About 8 s in all.
|
|
62
62
|
* @template T @param {() => T} action @param {(ms: number) => void} [sleep]
|
|
63
63
|
*/
|
|
64
64
|
export function retryBusy<T>(action: () => T, sleep?: (ms: number) => void, attempts?: number): T;
|
|
65
|
+
/** What to say outside the ALP bundle (an npm install). @param {string[]} positionals */
|
|
66
|
+
export function npmMessage(positionals?: string[]): string;
|
|
67
|
+
/** The bundle's own Node and CLI: run without its launcher, so Windows needs no shell for alp.cmd. @param {string} root @param {string} platform */
|
|
68
|
+
export function bundleCommand(root: string, platform?: string): {
|
|
69
|
+
command: string;
|
|
70
|
+
args: string[];
|
|
71
|
+
};
|
|
65
72
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @param {string} staged @param {string} target @param {{ platform?: string, fs?: Pick<typeof nodeFs, 'renameSync' | 'rmSync' | 'existsSync'>, unique?: () => string, sleep?: (ms: number) => void }} [options]
|
|
73
|
+
* Points `<app>/current` at `<app>/<version>`. Unix: a relative symlink renamed over the old one, in
|
|
74
|
+
* one step. Windows: the junction is replaced (removed, then made again; put back on failure).
|
|
75
|
+
* @param {string} app @param {string} version @param {{ platform?: string, fs?: typeof nodeFs, unique?: () => string }} [options]
|
|
70
76
|
*/
|
|
71
|
-
export function
|
|
77
|
+
export function switchCurrent(app: string, version: string, { platform, fs, unique }?: {
|
|
72
78
|
platform?: string;
|
|
73
|
-
fs?:
|
|
79
|
+
fs?: typeof nodeFs;
|
|
74
80
|
unique?: () => string;
|
|
75
|
-
|
|
76
|
-
}): {
|
|
77
|
-
old: undefined;
|
|
78
|
-
} | {
|
|
79
|
-
old: string;
|
|
80
|
-
};
|
|
81
|
-
/** Deletes the alp.old.exe (and alp.old.<hex>.exe) a Windows update left behind; called on every packaged start. @param {string} target @param {{ platform?: string, fs?: Pick<typeof nodeFs, 'rmSync' | 'readdirSync'> }} [options] */
|
|
82
|
-
export function cleanupOldExecutable(target: string, { platform, fs }?: {
|
|
83
|
-
platform?: string;
|
|
84
|
-
fs?: Pick<typeof nodeFs, "rmSync" | "readdirSync">;
|
|
85
|
-
}): boolean;
|
|
81
|
+
}): void;
|
|
86
82
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
83
|
+
* Removes what earlier updates left in `<app>`: versions other than `keep`, and staging directories.
|
|
84
|
+
* A failure (a file still in use on Windows) leaves that entry for the next update. keepAside keeps
|
|
85
|
+
* the copies earlier reinstalls moved aside, which a running alpd may still run from.
|
|
86
|
+
* @param {string} app @param {string[]} keep
|
|
90
87
|
*/
|
|
91
|
-
export function
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
export function pruneVersions(app: string, keep: string[], fs?: typeof nodeFs, { keepAside }?: {
|
|
89
|
+
keepAside?: boolean | undefined;
|
|
90
|
+
}): string[];
|
|
94
91
|
/**
|
|
95
92
|
* @typedef {{
|
|
96
|
-
*
|
|
93
|
+
* bundle: import('@anhlp/alp-core/packaged').BundleInfo | undefined, version: string, env: NodeJS.ProcessEnv, platform: string, arch: string,
|
|
97
94
|
* log: (line: string) => void, warn: (line: string) => void, interactive: boolean,
|
|
98
95
|
* fetchBytes: (url: string) => Promise<Uint8Array>, confirm: (question: string) => Promise<boolean>,
|
|
99
96
|
* provenance: (file: string, repo: string) => string, extract: typeof extract,
|
|
100
|
-
* daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (
|
|
101
|
-
* runVersion: (
|
|
97
|
+
* daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (root: string) => number,
|
|
98
|
+
* runVersion: (root: string) => string,
|
|
102
99
|
* }} UpdateDeps
|
|
103
100
|
*/
|
|
104
101
|
/** @param {string[]} args @param {Partial<UpdateDeps>} [overrides] @returns {Promise<number>} the exit code */
|
|
105
102
|
export function selfUpdate(args: string[], overrides?: Partial<UpdateDeps>): Promise<number>;
|
|
106
103
|
/**
|
|
107
|
-
* `alp update` (t-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
104
|
+
* `alp update` (t-1807): installs a release of the ALP bundle from GitHub Releases beside the running
|
|
105
|
+
* one (<app>/<version>, see @anhlp/alp-core/packaged) and points <app>/current at it, after checking
|
|
106
|
+
* the archive against the release's SHA256SUMS and, when `gh` is installed, its build provenance.
|
|
107
|
+
* The project template upgrade that `alp update` used to run is `alp update-template`.
|
|
110
108
|
*
|
|
111
109
|
* Everything that touches the network, the filesystem or child processes comes in through `deps`
|
|
112
110
|
* so the tests can drive each step.
|
|
@@ -114,16 +112,16 @@ export function selfUpdate(args: string[], overrides?: Partial<UpdateDeps>): Pro
|
|
|
114
112
|
export const DEFAULT_REPO: "phucanh08/alp";
|
|
115
113
|
export const SIGNER_WORKFLOW: ".github/workflows/release-binaries.yml";
|
|
116
114
|
export const NPM_PACKAGE: "@anhlp/alp";
|
|
117
|
-
export const UPDATE_USAGE: "Usage: alp update [--check] [--yes] [--version X] [--base-url URL]\
|
|
115
|
+
export const UPDATE_USAGE: "Usage: alp update [--check] [--yes] [--version X] [--base-url URL]\nInstalls the latest ALP release (or release X) from GitHub Releases beside this one and switches to it, after checking\nit against SHA256SUMS and, when gh is installed, its build provenance. --check only reports.\nALP_UPDATE_BASE_URL (as --base-url, an https:// or file:// mirror) and ALP_INSTALL_REPO (owner/name) override the source.\nThe project template upgrade is `alp update-template [directory]`.";
|
|
118
116
|
export function archiveExtension(platform: string): ".zip" | ".tar.gz";
|
|
119
117
|
export function sha256(bytes: Uint8Array): string;
|
|
120
|
-
/** The largest file alp update downloads: the
|
|
118
|
+
/** The largest file alp update downloads: an archive of the bundle is about 70 MB. */
|
|
121
119
|
export const MAX_DOWNLOAD: number;
|
|
122
|
-
export function
|
|
120
|
+
export function notInstalledMessage(root: string): string;
|
|
121
|
+
export function systemTar(platform?: string, env?: Record<string, string | undefined>): string;
|
|
123
122
|
export type UpdateDeps = {
|
|
124
|
-
|
|
123
|
+
bundle: import("@anhlp/alp-core/packaged").BundleInfo | undefined;
|
|
125
124
|
version: string;
|
|
126
|
-
execPath: string;
|
|
127
125
|
env: NodeJS.ProcessEnv;
|
|
128
126
|
platform: string;
|
|
129
127
|
arch: string;
|
|
@@ -138,14 +136,14 @@ export type UpdateDeps = {
|
|
|
138
136
|
version: string;
|
|
139
137
|
sessions?: number;
|
|
140
138
|
} | undefined>;
|
|
141
|
-
restartDaemon: (
|
|
142
|
-
runVersion: (
|
|
139
|
+
restartDaemon: (root: string) => number;
|
|
140
|
+
runVersion: (root: string) => string;
|
|
143
141
|
};
|
|
144
142
|
import { spawnSync } from 'node:child_process';
|
|
145
143
|
/** Whether a program is on PATH. @param {string} name */
|
|
146
144
|
declare function which(name: string): string | undefined;
|
|
147
145
|
import * as nodeFs from 'node:fs';
|
|
148
|
-
/** Extracts the archive and returns the
|
|
146
|
+
/** Extracts the archive into `directory` and returns the bundle inside it. @param {string} archive @param {string} directory @param {{ name: string }} asset @param {string} platform */
|
|
149
147
|
declare function extract(archive: string, directory: string, asset: {
|
|
150
148
|
name: string;
|
|
151
149
|
}, platform: string, run?: typeof spawnSync): string;
|