@anhlp/alp-cli 0.0.0-beta.1
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/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +7 -0
- package/dist/THIRD-PARTY-NOTICES.txt +626 -0
- package/dist/acp/agent.d.ts +29 -0
- package/dist/acp/agent.js +390 -0
- package/dist/acp/main.d.ts +4 -0
- package/dist/acp/main.js +23 -0
- package/dist/acp.js +19723 -0
- package/dist/alpd.js +41053 -0
- package/dist/backup.d.ts +4 -0
- package/dist/backup.js +146 -0
- package/dist/build-manifest.json +139 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +24 -0
- package/dist/daemon.d.ts +35 -0
- package/dist/daemon.js +122 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/interfaces.d.ts +16 -0
- package/dist/interfaces.js +96 -0
- package/dist/library.d.ts +140 -0
- package/dist/library.js +319 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.js +18 -0
- package/dist/projects.d.ts +9 -0
- package/dist/projects.js +159 -0
- package/dist/sessions.d.ts +39 -0
- package/dist/sessions.js +425 -0
- package/dist/tasks.d.ts +29 -0
- package/dist/tasks.js +345 -0
- package/dist/usage.d.ts +3 -0
- package/dist/usage.js +72 -0
- package/package.json +159 -0
- package/src/acp/agent.ts +428 -0
- package/src/acp/main.ts +24 -0
- package/src/backup.js +127 -0
- package/src/cli.js +23 -0
- package/src/daemon.js +137 -0
- package/src/index.js +2 -0
- package/src/interfaces.js +100 -0
- package/src/library.js +243 -0
- package/src/paths.js +16 -0
- package/src/projects.js +160 -0
- package/src/sessions.js +384 -0
- package/src/tasks.js +282 -0
- package/src/usage.js +72 -0
package/src/tasks.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { access, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { exportBeads, importBeads, parseJsonl } from '@anhlp/alp-core/beads';
|
|
6
|
+
import { findFormula, formulaDirs, listFormulas, pourFormula } from '@anhlp/alp-core/formulas';
|
|
7
|
+
import { describeVerification } from '@anhlp/alp-core/verify';
|
|
8
|
+
import { ago } from '@anhlp/alp-client/render';
|
|
9
|
+
import { parse as toml } from 'smol-toml';
|
|
10
|
+
import { addGate, blockersOf, checkGates, childrenOf, closeTask, compactTasks, createTask, describeGate, gateOpen, epicReport, gatesOf, linkTask, listTasks, loadTasks, readyTasks, reopenTask, resolveGate, summarize, TASKS_DIR, updateTask } from '@anhlp/alp-core/tasks';
|
|
11
|
+
import { alpHome } from '@anhlp/alp-client/index';
|
|
12
|
+
import { UsageError } from './usage.js';
|
|
13
|
+
|
|
14
|
+
const STATUS_MARK = { open: '○', in_progress: '◐', review: '◑', closed: '●' };
|
|
15
|
+
|
|
16
|
+
/** The ALP project a task command works on: --project, or the current directory. */
|
|
17
|
+
/** alp permissions: the profile each agent runs with, from .alp/settings.json and $ALP_HOME/settings.json. */
|
|
18
|
+
|
|
19
|
+
async function taskProject(directory) {
|
|
20
|
+
const root = path.resolve(directory ?? process.cwd());
|
|
21
|
+
try { await access(path.join(root, '.alp')); }
|
|
22
|
+
catch { throw new Error(`${root} is not an ALP project (no .alp directory); run alp init, or pass --project`); }
|
|
23
|
+
return root;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function taskRow(task, tasks) {
|
|
27
|
+
const row = summarize(task, tasks);
|
|
28
|
+
const extra = [
|
|
29
|
+
row.blockedBy ? `blocked by ${row.blockedBy.join(', ')}` : '',
|
|
30
|
+
row.gates ? `waits on ${row.gates.join('; ')}` : '',
|
|
31
|
+
row.assignee ? `@${row.assignee}` : '',
|
|
32
|
+
row.labels ? row.labels.map(label => `#${label}`).join(' ') : '',
|
|
33
|
+
].filter(Boolean).join(' ');
|
|
34
|
+
return `${STATUS_MARK[task.status]} ${task.id.padEnd(10)} P${task.priority} ${task.type.padEnd(7)} ${task.status.padEnd(11)} ${task.title}${extra ? ` ${extra}` : ''}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function warnUnreadable(errors) {
|
|
38
|
+
for (const { file, error } of errors) console.error(`alp: skipped ${file}: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The project's tasks: open, in progress and in review by default; ready lists what nothing blocks. */
|
|
42
|
+
|
|
43
|
+
async function tasksCommand(args) {
|
|
44
|
+
if (args[0] === 'gates' || args[0] === 'compact') return taskMaintenance([args[0]], args.slice(1));
|
|
45
|
+
if (args[0] === 'export' || args[0] === 'import') return beads(args[0], args.slice(1));
|
|
46
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
|
|
47
|
+
all: { type: 'boolean' }, status: { type: 'string' }, label: { type: 'string' }, project: { type: 'string' }, json: { type: 'boolean' },
|
|
48
|
+
} });
|
|
49
|
+
if (positionals.length > 1 || (positionals.length && positionals[0] !== 'ready')) throw new UsageError();
|
|
50
|
+
const root = await taskProject(values.project);
|
|
51
|
+
const { tasks, errors } = await loadTasks(root);
|
|
52
|
+
warnUnreadable(errors);
|
|
53
|
+
const rows = positionals[0] === 'ready' ? readyTasks(tasks) : listTasks(tasks, { status: values.status, label: values.label, all: values.all });
|
|
54
|
+
if (values.json) { console.log(JSON.stringify(rows)); return; }
|
|
55
|
+
if (!rows.length) { console.log(positionals[0] === 'ready' ? 'No task is ready' : `No tasks in ${path.join(root, TASKS_DIR)}`); return; }
|
|
56
|
+
for (const task of rows) console.log(taskRow(task, tasks));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The GitHub CLI, for gh:pr and gh:run gates. */
|
|
60
|
+
|
|
61
|
+
const gh = (args, { cwd }) => new Promise((resolve, reject) => {
|
|
62
|
+
const bin = process.env.ALP_GH_BIN ?? 'gh';
|
|
63
|
+
// Windows cannot exec a script by its shebang (the tests' stand-in for gh); a JavaScript one runs under this Node.
|
|
64
|
+
const script = process.platform === 'win32' && /\.[cm]?js$/i.test(bin);
|
|
65
|
+
const child = spawn(script ? process.execPath : bin, script ? [bin, ...args] : args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
66
|
+
let stdout = '';
|
|
67
|
+
let stderr = '';
|
|
68
|
+
child.stdout.on('data', chunk => { stdout += chunk; });
|
|
69
|
+
child.stderr.on('data', chunk => { stderr += chunk; });
|
|
70
|
+
child.on('error', error => reject(error.code === 'ENOENT' ? new Error('gh is not installed or not on PATH') : error));
|
|
71
|
+
child.on('close', code => code === 0 ? resolve(stdout) : reject(new Error(stderr.trim() || `gh exited with ${code}`)));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/** alp tasks gates: clears GitHub gates that are done and lists the open ones. alp tasks compact: shrinks old closed tasks. */
|
|
75
|
+
|
|
76
|
+
async function taskMaintenance([command], args) {
|
|
77
|
+
const { values, positionals: rest } = parseArgs({ args, allowPositionals: true, options: {
|
|
78
|
+
project: { type: 'string' }, json: { type: 'boolean' }, days: { type: 'string' }, 'dry-run': { type: 'boolean' },
|
|
79
|
+
} });
|
|
80
|
+
if (rest.length) throw new UsageError();
|
|
81
|
+
const root = await taskProject(values.project);
|
|
82
|
+
if (command === 'compact') {
|
|
83
|
+
const days = values.days === undefined ? 30 : Number(values.days);
|
|
84
|
+
const changed = await compactTasks(root, { days, dryRun: values['dry-run'] }, 'user');
|
|
85
|
+
if (values.json) { console.log(JSON.stringify(changed)); return; }
|
|
86
|
+
if (!changed.length) { console.log(`No task closed more than ${days} days ago is left to compact`); return; }
|
|
87
|
+
for (const { id, before, after } of changed) console.log(`${id} ${before} → ${after} characters`);
|
|
88
|
+
console.log(`${values['dry-run'] ? 'Would compact' : 'Compacted'} ${changed.length} closed ${changed.length === 1 ? 'task' : 'tasks'}`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const checked = await checkGates(root, gh);
|
|
92
|
+
const { tasks } = await loadTasks(root);
|
|
93
|
+
const open = tasks.filter(task => task.status !== 'closed').flatMap(task => task.gates.filter(gate => gateOpen(gate)).map(gate => ({ task, gate })));
|
|
94
|
+
if (values.json) { console.log(JSON.stringify({ ...checked, open: open.map(({ task, gate }) => ({ task: task.id, ...gate })) })); return; }
|
|
95
|
+
for (const { task, gate, detail } of checked.cleared) console.log(`✓ ${task} ${gate} cleared: ${detail}`);
|
|
96
|
+
for (const { task, gate, error } of checked.errors) console.error(`alp: could not check ${task} ${gate}: ${error}`);
|
|
97
|
+
if (!open.length) { console.log('No open gates'); return; }
|
|
98
|
+
for (const { task, gate } of open) {
|
|
99
|
+
const state = checked.pending.find(entry => entry.task === task.id && entry.gate === gate.id)?.detail;
|
|
100
|
+
console.log(`⏸ ${task.id} ${describeGate(gate)}${state ? ` (${state})` : ''} ${task.title}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** alp tasks export / import: interchange with beads through its JSONL issue format. */
|
|
105
|
+
|
|
106
|
+
async function beads(command, args) {
|
|
107
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
|
|
108
|
+
project: { type: 'string' }, output: { type: 'string', short: 'o' }, 'dry-run': { type: 'boolean' }, json: { type: 'boolean' },
|
|
109
|
+
} });
|
|
110
|
+
const root = await taskProject(values.project);
|
|
111
|
+
if (command === 'export') {
|
|
112
|
+
if (positionals.length || values['dry-run']) throw new UsageError();
|
|
113
|
+
const { tasks, errors } = await loadTasks(root);
|
|
114
|
+
warnUnreadable(errors);
|
|
115
|
+
const text = exportBeads(tasks).map(record => JSON.stringify(record)).join('\n') + (tasks.length ? '\n' : '');
|
|
116
|
+
if (values.output) {
|
|
117
|
+
await writeFile(values.output, text);
|
|
118
|
+
console.error(`Exported ${tasks.length} ${tasks.length === 1 ? 'task' : 'tasks'} to ${values.output}`);
|
|
119
|
+
} else {
|
|
120
|
+
process.stdout.write(text);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (positionals.length > 1 || values.output) throw new UsageError();
|
|
125
|
+
const file = positionals[0] ?? path.join(root, '.beads', 'issues.jsonl');
|
|
126
|
+
const { records, errors } = parseJsonl(await readFile(file, 'utf8'));
|
|
127
|
+
const report = await importBeads(root, records, { dryRun: values['dry-run'], by: 'user' });
|
|
128
|
+
report.skipped.push(...errors);
|
|
129
|
+
if (values.json) { console.log(JSON.stringify(report)); return; }
|
|
130
|
+
const verb = values['dry-run'] ? 'Would import' : 'Imported';
|
|
131
|
+
for (const { id, from } of report.created) console.log(`+ ${id}${id !== from ? ` (from ${from})` : ''}`);
|
|
132
|
+
for (const { id, from } of report.updated) console.log(`~ ${id}${id !== from ? ` (from ${from})` : ''}`);
|
|
133
|
+
for (const { line, reason } of report.skipped.sort((a, b) => a.line - b.line)) console.error(`alp: skipped line ${line}: ${reason}`);
|
|
134
|
+
for (const warning of report.warnings) console.error(`alp: ${warning}`);
|
|
135
|
+
console.log(`${verb} ${file}: ${report.created.length} created, ${report.updated.length} updated, ${report.skipped.length} skipped`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** alp formula: workflow templates that pour into an epic with a task per step. */
|
|
139
|
+
|
|
140
|
+
async function formulaCommand([action, ...args]) {
|
|
141
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
|
|
142
|
+
project: { type: 'string' }, var: { type: 'string', multiple: true }, parent: { type: 'string' }, 'dry-run': { type: 'boolean' }, json: { type: 'boolean' },
|
|
143
|
+
} });
|
|
144
|
+
const root = await taskProject(values.project);
|
|
145
|
+
const home = alpHome();
|
|
146
|
+
if (action === 'list') {
|
|
147
|
+
if (positionals.length) throw new UsageError();
|
|
148
|
+
const found = await listFormulas(root, home, { toml });
|
|
149
|
+
if (values.json) { console.log(JSON.stringify(found)); return; }
|
|
150
|
+
if (!found.length) { console.log(`No formulas in ${formulaDirs(root, home).join(', ')}`); return; }
|
|
151
|
+
for (const entry of found) console.log(entry.error ? `✗ ${entry.name} ${entry.file}: ${entry.error}` : `${entry.name} ${entry.formula.steps.length} steps${entry.formula.description ? ` ${entry.formula.description.split('\n')[0]}` : ''}`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
155
|
+
const { formula, file } = await findFormula(root, home, positionals[0], { toml });
|
|
156
|
+
if (action === 'show') {
|
|
157
|
+
if (values.json) { console.log(JSON.stringify(formula)); return; }
|
|
158
|
+
console.log(`${formula.formula}${formula.version ? ` v${formula.version}` : ''} ${file}`);
|
|
159
|
+
if (formula.description) console.log(` ${formula.description}`);
|
|
160
|
+
for (const [name, spec] of Object.entries(formula.vars)) console.log(` --var ${name}=…${spec.required ? ' (required)' : spec.default !== undefined ? ` (default ${spec.default})` : ''}${spec.description ? ` ${spec.description}` : ''}`);
|
|
161
|
+
for (const step of formula.steps) console.log(` ${step.id}${step.type === 'human' ? ' [you]' : step.type !== 'task' ? ` [${step.type}]` : ''}: ${step.title}${step.needs.length ? ` after ${step.needs.join(', ')}` : ''}`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (action !== 'pour') throw new UsageError();
|
|
165
|
+
const given = {};
|
|
166
|
+
for (const entry of values.var ?? []) {
|
|
167
|
+
const at = entry.indexOf('=');
|
|
168
|
+
if (at < 1) throw new UsageError();
|
|
169
|
+
given[entry.slice(0, at)] = entry.slice(at + 1);
|
|
170
|
+
}
|
|
171
|
+
const { epic, tasks } = await pourFormula(root, formula, given, 'user', { dryRun: values['dry-run'], ...(values.parent ? { parent: values.parent } : {}) });
|
|
172
|
+
if (values.json) { console.log(JSON.stringify({ epic, tasks })); return; }
|
|
173
|
+
console.log(`${values['dry-run'] ? 'Would pour' : 'Poured'} ${formula.formula} as ${epic.id} ${epic.title}`);
|
|
174
|
+
const all = [epic, ...tasks];
|
|
175
|
+
for (const task of tasks) console.log(` ${taskRow(task, all)}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const repeated = { type: 'string', multiple: true };
|
|
179
|
+
|
|
180
|
+
async function taskCommand([action, ...args]) {
|
|
181
|
+
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
|
|
182
|
+
description: { type: 'string', short: 'd' }, priority: { type: 'string', short: 'p' }, type: { type: 'string', short: 't' },
|
|
183
|
+
label: { ...repeated, short: 'l' }, path: repeated, parent: { type: 'string' }, after: repeated, related: repeated, from: { type: 'string' },
|
|
184
|
+
title: { type: 'string' }, message: { type: 'string', short: 'm' }, reason: { type: 'string' }, unverified: { type: 'string' }, project: { type: 'string' }, json: { type: 'boolean' },
|
|
185
|
+
human: { type: 'string' }, timer: { type: 'string' }, pr: { type: 'string' }, run: { type: 'string' },
|
|
186
|
+
} });
|
|
187
|
+
const root = await taskProject(values.project);
|
|
188
|
+
const fields = {
|
|
189
|
+
...(values.description !== undefined ? { description: values.description } : {}),
|
|
190
|
+
...(values.priority !== undefined ? { priority: values.priority } : {}),
|
|
191
|
+
...(values.type !== undefined ? { type: values.type } : {}),
|
|
192
|
+
...(values.label ? { labels: values.label } : {}),
|
|
193
|
+
...(values.path ? { paths: values.path } : {}),
|
|
194
|
+
};
|
|
195
|
+
let task;
|
|
196
|
+
if (action === 'add') {
|
|
197
|
+
const title = positionals.join(' ').trim();
|
|
198
|
+
if (!title) throw new UsageError();
|
|
199
|
+
task = await createTask(root, { title, ...fields, parent: values.parent, blockedBy: values.after, related: values.related, discoveredFrom: values.from }, 'user');
|
|
200
|
+
} else if (action === 'show') {
|
|
201
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
202
|
+
const { tasks, errors } = await loadTasks(root);
|
|
203
|
+
warnUnreadable(errors);
|
|
204
|
+
task = tasks.find(candidate => candidate.id === positionals[0]);
|
|
205
|
+
if (!task) throw new Error(`No task ${positionals[0]} in ${path.join(root, TASKS_DIR)}`);
|
|
206
|
+
if (values.json) { console.log(JSON.stringify(task)); return; }
|
|
207
|
+
printTask(task, tasks);
|
|
208
|
+
return;
|
|
209
|
+
} else if (action === 'report') {
|
|
210
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
211
|
+
const { tasks, errors } = await loadTasks(root);
|
|
212
|
+
warnUnreadable(errors);
|
|
213
|
+
const report = epicReport(positionals[0], tasks);
|
|
214
|
+
console.log(values.json ? JSON.stringify(report) : report.text);
|
|
215
|
+
return;
|
|
216
|
+
} else if (action === 'edit') {
|
|
217
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
218
|
+
task = await updateTask(root, positionals[0], { ...fields, ...(values.title !== undefined ? { title: values.title } : {}), note: values.message }, 'user');
|
|
219
|
+
} else if (action === 'close') {
|
|
220
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
221
|
+
task = await closeTask(root, positionals[0], { reason: values.reason, summary: values.message, unverified: values.unverified }, 'user');
|
|
222
|
+
} else if (action === 'reopen') {
|
|
223
|
+
if (positionals.length !== 1) throw new UsageError();
|
|
224
|
+
task = await reopenTask(root, positionals[0], { note: values.message }, 'user');
|
|
225
|
+
} else if (action === 'dep') {
|
|
226
|
+
const [change, id, ...rest] = positionals;
|
|
227
|
+
if (!['add', 'rm'].includes(change) || !id || rest.length || !(values.after || values.parent || values.related)) throw new UsageError();
|
|
228
|
+
const links = { ...(values.after ? { blockedBy: values.after } : {}), ...(values.parent ? { parent: values.parent } : {}), ...(values.related ? { related: values.related } : {}) };
|
|
229
|
+
task = await linkTask(root, id, change === 'add' ? { add: links } : { remove: links }, 'user');
|
|
230
|
+
} else if (action === 'gate') {
|
|
231
|
+
const [change, id, gate, ...rest] = positionals;
|
|
232
|
+
const kinds = ['human', 'timer', 'pr', 'run'].filter(kind => values[kind] !== undefined);
|
|
233
|
+
if (change === 'add' && id && !gate && kinds.length === 1) {
|
|
234
|
+
const kind = kinds[0];
|
|
235
|
+
task = await addGate(root, id, kind === 'human' ? { kind, note: values.human } : kind === 'timer' ? { kind, until: values.timer } : { kind: `gh:${kind}`, ref: values[kind] }, 'user');
|
|
236
|
+
} else if ((change === 'clear' || change === 'rm') && id && gate && !rest.length && !kinds.length) {
|
|
237
|
+
task = await resolveGate(root, id, gate, { by: 'user', note: values.message, remove: change === 'rm' });
|
|
238
|
+
} else {
|
|
239
|
+
throw new UsageError();
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
throw new UsageError();
|
|
243
|
+
}
|
|
244
|
+
if (values.json) { console.log(JSON.stringify(task)); return; }
|
|
245
|
+
const { tasks } = await loadTasks(root);
|
|
246
|
+
console.log(`${{ add: 'Created', close: 'Closed', reopen: 'Reopened' }[action] ?? 'Updated'} ${TASKS_DIR}/${task.id}.json`);
|
|
247
|
+
if (action === 'gate') for (const gate of task.gates.filter(entry => gateOpen(entry))) console.log(` ⏸ ${describeGate(gate)}`);
|
|
248
|
+
console.log(taskRow(task, tasks));
|
|
249
|
+
if (action === 'close' && tasks.some(entry => entry.parent === task.id)) console.log(`\n${epicReport(task.id, tasks).text}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function printTask(task, tasks) {
|
|
253
|
+
console.log(`${STATUS_MARK[task.status]} ${task.id} ${task.title}`);
|
|
254
|
+
console.log(` ${task.type}, P${task.priority}, ${task.status}${task.assignee ? ` with ${task.assignee.agent}` : ''}; created by ${task.createdBy} ${ago(task.createdAt)} ago, rev ${task.rev}`);
|
|
255
|
+
if (task.description) console.log(`\n ${task.description.replace(/\n/g, '\n ')}\n`);
|
|
256
|
+
const blockers = task.status === 'closed' ? [] : blockersOf(task, tasks);
|
|
257
|
+
const relations = [
|
|
258
|
+
task.parent && `parent ${task.parent}`,
|
|
259
|
+
task.blockedBy.length && `after ${task.blockedBy.join(', ')}${blockers.length ? ` (open: ${blockers.join(', ')})` : ''}`,
|
|
260
|
+
task.discoveredFrom && `found during ${task.discoveredFrom}`,
|
|
261
|
+
task.related.length && `related ${task.related.join(', ')}`,
|
|
262
|
+
].filter(Boolean);
|
|
263
|
+
if (relations.length) console.log(` ${relations.join('; ')}`);
|
|
264
|
+
for (const gate of task.gates) console.log(` ${gateOpen(gate) ? '⏸' : '✓'} gate ${describeGate(gate)}${gate.resolved ? ` (cleared by ${gate.resolved.by}${gate.resolved.note ? `: ${gate.resolved.note}` : ''})` : ''}`);
|
|
265
|
+
const inherited = gatesOf(task, tasks).filter(label => label.startsWith('t-'));
|
|
266
|
+
if (task.status !== 'closed' && inherited.length) console.log(` waits on its parent's gates: ${inherited.join('; ')}`);
|
|
267
|
+
if (task.compacted) console.log(` compacted ${task.compacted.at.slice(0, 10)} from ${task.compacted.chars} characters`);
|
|
268
|
+
if (task.labels.length) console.log(` labels: ${task.labels.join(', ')}`);
|
|
269
|
+
if (task.paths.length) console.log(` paths: ${task.paths.join(', ')}`);
|
|
270
|
+
for (const child of childrenOf(task.id, tasks)) console.log(` ${taskRow(child, tasks)}`);
|
|
271
|
+
if (task.verified) console.log(` ${task.verified.skipped ? '–' : task.verified.passed ? '✓' : '✗'} ${describeVerification(task.verified)}${task.verified.where ? ` in the ${task.verified.where}` : ''}, ${ago(task.verified.at)} ago`);
|
|
272
|
+
if (task.closed) console.log(` closed ${task.closed.reason} by ${task.closed.by}${task.closed.summary ? `: ${task.closed.summary}` : ''}${task.closed.unverified ? ` (unverified: ${task.closed.unverified})` : ''}`);
|
|
273
|
+
for (const entry of task.log.slice(-10)) {
|
|
274
|
+
const { at, by, event, ...detail } = entry;
|
|
275
|
+
const text = Object.entries(detail).map(([key, value]) => `${key} ${Array.isArray(value) ? value.join(', ') : value}`).join('; ');
|
|
276
|
+
console.log(` ${at.slice(0, 16).replace('T', ' ')} ${by} ${event}${text ? `: ${text}` : ''}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Pauses and parked assignments, one line each; `always` also says when nothing is paused. */
|
|
281
|
+
|
|
282
|
+
export { STATUS_MARK, taskProject, taskRow, warnUnreadable, tasksCommand, gh, taskMaintenance, beads, formulaCommand, repeated, taskCommand, printTask };
|
package/src/usage.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const USAGE = `Usage:
|
|
5
|
+
alp <init|upgrade|update> [directory]
|
|
6
|
+
alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]
|
|
7
|
+
[--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]
|
|
8
|
+
[--claude-oracle M] [--codex-oracle M] write Phở/Cafe's agent profiles to .alp/settings.json
|
|
9
|
+
alp daemon <start|stop|restart>
|
|
10
|
+
alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready
|
|
11
|
+
alp daemon <install|uninstall> run alpd as a login service that restarts after a crash
|
|
12
|
+
alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio
|
|
13
|
+
alp web [--print] open the local web app alpd serves; --print only prints its address
|
|
14
|
+
alp web pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off
|
|
15
|
+
alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to
|
|
16
|
+
alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file
|
|
17
|
+
alp backup verify <file> [--json] | alp backup list [--json]
|
|
18
|
+
alp restore <file> [--home-only] [--dry-run] [--stop] [--replace-newer] [--json] checks the whole backup first; keeps what it replaces
|
|
19
|
+
alpd must be stopped for both; --stop stops it and starts it again after
|
|
20
|
+
alp run [--agent A] [--team pho|cafe|ID] [--model M] [--mode read-only|workspace-write|full-access] [--thinking T] [--project DIR] [--json] <prompt>
|
|
21
|
+
alp ps [--all]
|
|
22
|
+
alp top [session] [--once]
|
|
23
|
+
alp attach <session> [--json]
|
|
24
|
+
alp send <session> [--json] <text>
|
|
25
|
+
alp questions [--json]
|
|
26
|
+
alp answer <question> <text> | alp answer <question> --dismiss [--reason R]
|
|
27
|
+
alp log <session> [--json]
|
|
28
|
+
alp board [--project DIR] [--json]
|
|
29
|
+
alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries
|
|
30
|
+
alp providers [--json] ACP and Antigravity providers in your library
|
|
31
|
+
alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules
|
|
32
|
+
alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]
|
|
33
|
+
[--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]
|
|
34
|
+
alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...
|
|
35
|
+
[--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]
|
|
36
|
+
[--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]
|
|
37
|
+
alp skill new <name> [--project [DIR]] [--from S] [--file FILE]
|
|
38
|
+
alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)
|
|
39
|
+
alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]
|
|
40
|
+
alp provider add <id> --command C [--arg A]... [--env K=V]... [--label L] [-d text] [--models a,b] an ACP agent; use id antigravity for native agy
|
|
41
|
+
alp provider edit antigravity --read-only-mode instructions|reject opt into prompt-only read-only for advisory roles
|
|
42
|
+
alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]
|
|
43
|
+
alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider
|
|
44
|
+
without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed
|
|
45
|
+
alp trust [--project DIR] | --revoke [--project DIR] | --list [--json] whether the project's hooks may run
|
|
46
|
+
alp permissions [--project DIR] [--json] each agent's permission profile
|
|
47
|
+
alp permissions check <agent> "<command>" what that agent's profile says about a command
|
|
48
|
+
alp tasks [ready] [--all] [--status S] [--label L] [--project DIR] [--json]
|
|
49
|
+
alp tasks gates [--json] open gates; checks GitHub ones
|
|
50
|
+
alp tasks compact [--days 30] [--dry-run]
|
|
51
|
+
alp tasks export [-o file.jsonl] as beads JSONL
|
|
52
|
+
alp tasks import [file.jsonl] [--dry-run] beads JSONL; default .beads/issues.jsonl
|
|
53
|
+
alp formula list | show <name> | pour <name> [--var k=v]... [--parent ID] [--dry-run]
|
|
54
|
+
alp task add <title> [-d text] [-p 0-4] [-t task|bug|feature|chore|epic] [--parent ID] [--after ID]... [-l label]... [--path P]... [--from ID]
|
|
55
|
+
alp task show <id> [--json]
|
|
56
|
+
alp task report <epic> [--json] what an epic came to: tasks, time, rework, verification
|
|
57
|
+
alp task edit <id> [--title T] [-d text] [-p N] [-t type] [-l label]... [--path P]... [-m note]
|
|
58
|
+
alp task close <id> [--reason done|wontfix|duplicate|superseded] [-m summary] [--unverified "why"]
|
|
59
|
+
alp verify [--project DIR] [--task ID] [--json] run the project's verify commands; --task records the result
|
|
60
|
+
alp task reopen <id> [-m note]
|
|
61
|
+
alp task dep <add|rm> <id> [--after ID]... [--parent ID] [--related ID]...
|
|
62
|
+
alp task gate add <id> --human "question" | --timer +2h|ISO | --pr N|owner/repo#N | --run N|owner/repo#N
|
|
63
|
+
alp task gate <clear|rm> <id> <gate> [-m note]
|
|
64
|
+
alp pause [codex|claude] [--now] [-m reason] | alp pause status hold delegation; --now parks running assignments
|
|
65
|
+
alp resume [codex|claude] lift a pause; parked assignments continue
|
|
66
|
+
alp language [name | --reset] the language agents and ALP write to you in; default Vietnamese
|
|
67
|
+
alp recall <assignment|task> [--project DIR] [--json] <question> ask a finished assignment about its work
|
|
68
|
+
alp interrupt <session>`;
|
|
69
|
+
|
|
70
|
+
class UsageError extends Error {}
|
|
71
|
+
|
|
72
|
+
export { USAGE, UsageError };
|