@anhlp/alp 0.0.1-beta.3 → 0.0.1-beta.6
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 +14 -410
- package/bin/alp.js +5 -0
- package/lib/launcher.js +136 -0
- package/package.json +19 -104
- package/dist/THIRD-PARTY-NOTICES.txt +0 -626
- package/dist/acp.js +0 -19903
- package/dist/alpd.js +0 -42558
- package/docs/modular-monorepo.md +0 -210
- package/packages/cli/README.md +0 -7
- package/packages/cli/dist/THIRD-PARTY-NOTICES.txt +0 -626
- 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 -19903
- package/packages/cli/dist/alpd.js +0 -42558
- 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 -142
- package/packages/cli/dist/cli.d.ts +0 -2
- package/packages/cli/dist/cli.js +0 -28
- 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 -16
- package/packages/cli/dist/interfaces.js +0 -96
- 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/sessions.d.ts +0 -41
- package/packages/cli/dist/sessions.js +0 -447
- package/packages/cli/dist/tasks.d.ts +0 -29
- package/packages/cli/dist/tasks.js +0 -345
- package/packages/cli/dist/usage.d.ts +0 -3
- package/packages/cli/dist/usage.js +0 -72
- package/packages/client/README.md +0 -24
- 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 -116
- package/packages/client/dist/index.js +0 -500
- 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 -18
- package/packages/client/dist/portable.js +0 -27
- 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/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 -12
- 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 -582
- 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 -30
- package/packages/core/dist/index.js +0 -63
- 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/validation.d.ts +0 -17
- package/packages/core/dist/validation.js +0 -295
- 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,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>;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/projects.js
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
|
-
import { initProject } from "@anhlp/alp-core/init";
|
|
4
|
-
import { upgradeProject } from "@anhlp/alp-core/upgrade";
|
|
5
|
-
import { seedLibrary } from "@anhlp/alp-core/library";
|
|
6
|
-
import { commandDecision, profileFor } from "@anhlp/alp-core/permissions";
|
|
7
|
-
import { describeVerification, runVerify, verifyConfig } from "@anhlp/alp-core/verify";
|
|
8
|
-
import { diagnose, repair } from "@anhlp/alp-client/doctor";
|
|
9
|
-
import { discoverAgents } from "@anhlp/alp-core/resolver";
|
|
10
|
-
import { probeAntigravity } from "@anhlp/alp-client/antigravity-probe";
|
|
11
|
-
import { isTrusted, revokeProject, trustProject, trustedProjects } from "@anhlp/alp-core/trust";
|
|
12
|
-
import { getTask, recordVerification } from "@anhlp/alp-core/tasks";
|
|
13
|
-
import { alpHome } from "@anhlp/alp-client/index";
|
|
14
|
-
import { languageSetting, setLanguage } from "@anhlp/alp-core/user-settings";
|
|
15
|
-
import { UsageError } from "./usage.js";
|
|
16
|
-
import { taskProject } from "./tasks.js";
|
|
17
|
-
import { DAEMON_ENTRY } from "./paths.js";
|
|
18
|
-
var DOCTOR_MARK = { ok: "\u2713", info: "\xB7", warn: "!", fail: "\u2717" };
|
|
19
|
-
async function project(command, args) {
|
|
20
|
-
if (args.length > 1) throw new UsageError();
|
|
21
|
-
try {
|
|
22
|
-
const result = await (command === "upgrade" ? upgradeProject : initProject)(args[0] ?? process.cwd(), { library: alpHome() });
|
|
23
|
-
console.log(`ALP initialized: ${result.created.length} files created, ${result.preserved.length} existing files preserved.`);
|
|
24
|
-
const library = await seedLibrary(alpHome());
|
|
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 (command === "init" && result.updated?.length) console.log(`Template model profiles refreshed: ${result.updated.join(", ")}`);
|
|
27
|
-
if (command === "upgrade") {
|
|
28
|
-
console.log(`ALP upgraded: ${result.updated.length} files updated.${result.backup ? ` Backup: ${result.backup}` : ""}`);
|
|
29
|
-
if (result.customInstructions.length) console.log(`Custom instructions preserved; reconcile with templates if needed: ${result.customInstructions.join(", ")}`);
|
|
30
|
-
const copies = result.removed.filter((name) => /^\.alp\/agents\/[^/]+$/.test(name));
|
|
31
|
-
const skills = result.removed.filter((name) => !copies.includes(name));
|
|
32
|
-
if (skills.length) console.log(`Retired skills archived: ${skills.join(", ")}`);
|
|
33
|
-
if (copies.length) console.log(`Unedited agent copies put away; the project now uses ALP's built-ins: ${copies.join(", ")}`);
|
|
34
|
-
if (result.customSkills.length) console.log(`Customized retired skills preserved for review: ${result.customSkills.join(", ")}`);
|
|
35
|
-
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.error(`ALP initialization failed: ${error.message}`);
|
|
38
|
-
process.exitCode = 1;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function permissionsCommand(args) {
|
|
42
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, json: { type: "boolean" } } });
|
|
43
|
-
const root = await taskProject(values.project);
|
|
44
|
-
if (positionals[0] === "check") {
|
|
45
|
-
if (positionals.length !== 3) throw new UsageError();
|
|
46
|
-
const profile = await profileFor(root, alpHome(), positionals[1]);
|
|
47
|
-
const decision = profile ? commandDecision(profile, positionals[2]) : void 0;
|
|
48
|
-
const result = { agent: positionals[1], profile: profile?.name ?? null, base: profile?.base ?? null, decision: decision ?? "mode" };
|
|
49
|
-
if (values.json) {
|
|
50
|
-
console.log(JSON.stringify(result));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
console.log(decision === "deny" ? `deny: a deny rule of profile ${profile.name} covers it` : decision === "ask" ? `ask: profile ${profile.name} asks the user each time` : decision === "allow" ? `allow: profile ${profile.name} lets ${result.agent} run it, even beyond its ${profile.base} mode` : `no rule covers it: ${result.agent}'s mode decides${profile ? ` (at most ${profile.base})` : ""}`);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (positionals.length) throw new UsageError();
|
|
57
|
-
const rows = [];
|
|
58
|
-
for (const agent of await discoverAgents(root, { library: alpHome() })) rows.push({ agent, profile: await profileFor(root, alpHome(), agent) });
|
|
59
|
-
if (values.json) {
|
|
60
|
-
console.log(JSON.stringify(rows));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
for (const { agent, profile } of rows) {
|
|
64
|
-
console.log(profile ? `${agent} profile ${profile.name}, at most ${profile.base}${profile.beyondMode === "ask" ? "; asks the user beyond it" : ""}` : `${agent} no profile: the mode its requester or the user chooses`);
|
|
65
|
-
if (profile?.allow.length) console.log(` allow: ${profile.allow.join(", ")}`);
|
|
66
|
-
if (profile?.ask.length) console.log(` ask: ${profile.ask.join(", ")}`);
|
|
67
|
-
if (profile?.deny.length) console.log(` deny: ${profile.deny.join(", ")}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function trustCommand(args) {
|
|
71
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, revoke: { type: "boolean" }, list: { type: "boolean" }, json: { type: "boolean" } } });
|
|
72
|
-
if (positionals.length || values.revoke && values.list) throw new UsageError();
|
|
73
|
-
if (values.list) {
|
|
74
|
-
const rows = await trustedProjects(alpHome());
|
|
75
|
-
if (values.json) console.log(JSON.stringify(rows));
|
|
76
|
-
else console.log(rows.length ? rows.map((row) => `${row.root} since ${row.trustedAt.slice(0, 10)} (${row.by})`).join("\n") : "No workspace is trusted yet; ALP asks before a project's hooks first run.");
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const root = await taskProject(values.project);
|
|
80
|
-
if (values.revoke) {
|
|
81
|
-
const was = await revokeProject(alpHome(), root);
|
|
82
|
-
console.log(was ? `ALP asks again before the hooks of ${root} run.` : `${root} was not trusted.`);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (await isTrusted(alpHome(), root)) {
|
|
86
|
-
console.log(`${root} is already trusted.`);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
await trustProject(alpHome(), root, "alp trust");
|
|
90
|
-
console.log(`The hooks of ${root} now run without asking, including hooks added or changed later.`);
|
|
91
|
-
}
|
|
92
|
-
async function language(args) {
|
|
93
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { reset: { type: "boolean" }, json: { type: "boolean" } } });
|
|
94
|
-
if (positionals.length > 1 || values.reset && positionals.length) throw new UsageError();
|
|
95
|
-
const state = values.reset ? await setLanguage(alpHome(), null) : positionals.length ? await setLanguage(alpHome(), positionals[0]) : await languageSetting(alpHome());
|
|
96
|
-
if (values.json) console.log(JSON.stringify(state));
|
|
97
|
-
else console.log(state.language ? `Language: ${state.language}` : `Language: ${state.applies} (the default; not set)`);
|
|
98
|
-
}
|
|
99
|
-
async function verify(args) {
|
|
100
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, task: { type: "string" }, json: { type: "boolean" } } });
|
|
101
|
-
if (positionals[0] === "antigravity") {
|
|
102
|
-
const result = await probeAntigravity({}, { cwd: process.cwd() });
|
|
103
|
-
if (values.json) console.log(JSON.stringify(result));
|
|
104
|
-
else console.log(`Antigravity ${result.version || "installed"}: ok (${result.models.length} models)`);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (positionals.length) throw new UsageError();
|
|
108
|
-
const root = await taskProject(values.project);
|
|
109
|
-
const config = await verifyConfig(root);
|
|
110
|
-
if (!config) throw new Error(`${root} has no verify commands; add "verify": { "test": "npm test" } to .alp/settings.json`);
|
|
111
|
-
if (values.task) await getTask(root, values.task);
|
|
112
|
-
const verification = await runVerify(root, config);
|
|
113
|
-
if (values.task) await recordVerification(root, values.task, { ...verification, where: "checkout" }, "user");
|
|
114
|
-
if (values.json) console.log(JSON.stringify(verification));
|
|
115
|
-
else {
|
|
116
|
-
for (const command of verification.commands) {
|
|
117
|
-
console.log(`${command.exitCode === 0 ? "\u2713" : "\u2717"} ${command.step}: ${command.command} (${(command.ms / 1e3).toFixed(1)} s${command.timedOut ? ", timed out" : command.exitCode ? `, exit ${command.exitCode}` : ""})`);
|
|
118
|
-
if (command.exitCode !== 0 && command.output) console.log(` ${command.output.trimEnd().split("\n").slice(-30).join("\n ")}`);
|
|
119
|
-
}
|
|
120
|
-
console.log(`${describeVerification(verification)}${values.task ? `; recorded on ${values.task}` : ""}`);
|
|
121
|
-
}
|
|
122
|
-
if (!verification.passed) process.exitCode = 1;
|
|
123
|
-
}
|
|
124
|
-
async function doctor(args) {
|
|
125
|
-
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { project: { type: "string" }, fix: { type: "boolean" }, json: { type: "boolean" } } });
|
|
126
|
-
if (positionals.length) throw new UsageError();
|
|
127
|
-
const project2 = values.project ? await taskProject(values.project) : await taskProject(void 0).catch(() => void 0);
|
|
128
|
-
const sandbox = await import("../dist/runtime/index.js").then((runtime) => runtime.claudeSandboxAvailable(), () => void 0);
|
|
129
|
-
const options = { home: alpHome(), project: project2, sandbox, daemonEntry: DAEMON_ENTRY };
|
|
130
|
-
let checks = await diagnose(options);
|
|
131
|
-
const fixed = values.fix ? await repair(checks) : [];
|
|
132
|
-
if (fixed.length) checks = await diagnose(options);
|
|
133
|
-
if (values.json) {
|
|
134
|
-
console.log(JSON.stringify({ project: project2 ?? null, checks: checks.map(({ fix, ...check }) => ({ ...check, ...fix ? { fix: fix.describe } : {} })), fixed }));
|
|
135
|
-
} else {
|
|
136
|
-
for (const { id, result } of fixed) console.log(`fixed ${id}: ${result}`);
|
|
137
|
-
if (fixed.length) console.log("");
|
|
138
|
-
for (const check of checks) {
|
|
139
|
-
console.log(`${DOCTOR_MARK[check.status]} ${check.id.padEnd(13)} ${check.summary}`);
|
|
140
|
-
for (const detail of check.details ?? []) console.log(` ${detail}`);
|
|
141
|
-
if (check.fix) console.log(` --fix: ${check.fix.describe}`);
|
|
142
|
-
if (check.hint) console.log(` ${check.hint}`);
|
|
143
|
-
}
|
|
144
|
-
const failed = checks.filter((check) => check.status === "fail").length;
|
|
145
|
-
const warned = checks.filter((check) => check.status === "warn").length;
|
|
146
|
-
const fixable = checks.filter((check) => check.fix).length;
|
|
147
|
-
console.log(`
|
|
148
|
-
${failed || warned ? `${failed} failed, ${warned} to look at` : "All good"}${project2 ? "" : " (no ALP project here; pass --project to check one)"}${fixable ? `; alp doctor --fix repairs ${fixable}` : ""}`);
|
|
149
|
-
}
|
|
150
|
-
if (checks.some((check) => check.status === "fail")) process.exitCode = 1;
|
|
151
|
-
}
|
|
152
|
-
export {
|
|
153
|
-
doctor,
|
|
154
|
-
language,
|
|
155
|
-
permissionsCommand,
|
|
156
|
-
project,
|
|
157
|
-
trustCommand,
|
|
158
|
-
verify
|
|
159
|
-
};
|