acpus 0.5.2 → 0.6.0-alpha.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/README.md +19 -5
- package/dist/.tsbuildinfo +1 -0
- package/dist/agent-progress-format.d.ts +7 -0
- package/dist/agent-progress-format.d.ts.map +1 -0
- package/dist/agent-progress-format.js +102 -0
- package/dist/agent-progress-format.js.map +1 -0
- package/dist/authoring/core.d.ts +2 -0
- package/dist/authoring/core.d.ts.map +1 -0
- package/dist/authoring/core.js +2 -0
- package/dist/authoring/core.js.map +1 -0
- package/dist/authoring/expression.d.ts +2 -0
- package/dist/authoring/expression.d.ts.map +1 -0
- package/dist/authoring/expression.js +2 -0
- package/dist/authoring/expression.js.map +1 -0
- package/dist/authoring/tasks/git.d.ts +2 -0
- package/dist/authoring/tasks/git.d.ts.map +1 -0
- package/dist/authoring/tasks/git.js +2 -0
- package/dist/authoring/tasks/git.js.map +1 -0
- package/dist/catalog.d.ts +18 -24
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +164 -174
- package/dist/catalog.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/daemon.d.ts +14 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +89 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/doctor.d.ts +11 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +26 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hooks.d.ts +11 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +64 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/json.d.ts +7 -0
- package/dist/commands/json.d.ts.map +1 -0
- package/dist/commands/json.js +43 -0
- package/dist/commands/json.js.map +1 -0
- package/dist/commands/runs-picker.d.ts +21 -0
- package/dist/commands/runs-picker.d.ts.map +1 -0
- package/dist/commands/runs-picker.js +76 -0
- package/dist/commands/runs-picker.js.map +1 -0
- package/dist/commands/runs.d.ts +12 -0
- package/dist/commands/runs.d.ts.map +1 -0
- package/dist/commands/runs.js +285 -0
- package/dist/commands/runs.js.map +1 -0
- package/dist/commands/skill.d.ts +11 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +221 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/web.d.ts +24 -0
- package/dist/commands/web.d.ts.map +1 -0
- package/dist/commands/web.js +57 -0
- package/dist/commands/web.js.map +1 -0
- package/dist/commands/workflow.d.ts +11 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +324 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/daemon-entry.d.ts +3 -0
- package/dist/daemon-entry.d.ts.map +1 -0
- package/dist/daemon-entry.js +26 -0
- package/dist/daemon-entry.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -0
- package/dist/output.d.ts +91 -11
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +203 -44
- package/dist/output.js.map +1 -1
- package/dist/program.d.ts +9 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +85 -0
- package/dist/program.js.map +1 -0
- package/dist/run-status-surface.d.ts +12 -0
- package/dist/run-status-surface.d.ts.map +1 -0
- package/dist/run-status-surface.js +324 -0
- package/dist/run-status-surface.js.map +1 -0
- package/dist/workflow-preparation.d.ts +3 -0
- package/dist/workflow-preparation.d.ts.map +1 -0
- package/dist/workflow-preparation.js +34 -0
- package/dist/workflow-preparation.js.map +1 -0
- package/package.json +35 -35
- package/skills/acpus/SKILL.md +120 -0
- package/skills/acpus/eval/evaluations.md +47 -0
- package/skills/acpus/examples/hooks.example.json +17 -0
- package/skills/acpus/examples/workflows/adversarial-review/workflow.ts +248 -0
- package/skills/acpus/examples/workflows/change-approval/workflow.ts +121 -0
- package/skills/acpus/examples/workflows/issue-triage/tasks.ts +14 -0
- package/skills/acpus/examples/workflows/issue-triage/workflow.ts +146 -0
- package/skills/acpus/examples/workflows/multi-aspect-brainstorm/workflow.ts +304 -0
- package/skills/acpus/examples/workflows/worktree-tournament/workflow.ts +194 -0
- package/skills/acpus/references/authoring.md +205 -0
- package/skills/acpus/references/cli-operations.md +94 -0
- package/skills/acpus/references/hooks-json.md +81 -0
- package/skills/acpus/references/runtime-recovery.md +97 -0
- package/dist/agent-activity.d.ts +0 -3
- package/dist/agent-activity.d.ts.map +0 -1
- package/dist/agent-activity.js +0 -50
- package/dist/agent-activity.js.map +0 -1
- package/dist/agent-overrides.d.ts +0 -3
- package/dist/agent-overrides.d.ts.map +0 -1
- package/dist/agent-overrides.js +0 -39
- package/dist/agent-overrides.js.map +0 -1
- package/dist/follow.d.ts +0 -23
- package/dist/follow.d.ts.map +0 -1
- package/dist/follow.js +0 -164
- package/dist/follow.js.map +0 -1
- package/dist/hooks.d.ts +0 -4
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -159
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -592
- package/dist/index.js.map +0 -1
- package/dist/io.d.ts +0 -3
- package/dist/io.d.ts.map +0 -1
- package/dist/io.js +0 -27
- package/dist/io.js.map +0 -1
- package/dist/observations.d.ts +0 -39
- package/dist/observations.d.ts.map +0 -1
- package/dist/observations.js +0 -83
- package/dist/observations.js.map +0 -1
- package/dist/runs-show.d.ts +0 -40
- package/dist/runs-show.d.ts.map +0 -1
- package/dist/runs-show.js +0 -296
- package/dist/runs-show.js.map +0 -1
- package/dist/supervisor-client.d.ts +0 -9
- package/dist/supervisor-client.d.ts.map +0 -1
- package/dist/supervisor-client.js +0 -8
- package/dist/supervisor-client.js.map +0 -1
- package/dist/supervisor.d.ts +0 -18
- package/dist/supervisor.d.ts.map +0 -1
- package/dist/supervisor.js +0 -24
- package/dist/supervisor.js.map +0 -1
package/dist/catalog.js
CHANGED
|
@@ -1,194 +1,184 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import {} from "node:fs";
|
|
3
|
+
import { cp, mkdir, readdir, readFile, rm, stat } from "node:fs/promises";
|
|
2
4
|
import { homedir } from "node:os";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
entry.ref = undefined;
|
|
31
|
-
entry.diagnostics = [{
|
|
32
|
-
severity: "error",
|
|
33
|
-
code: "CATALOG_CONFLICT",
|
|
34
|
-
message: `Workflow name '${name}' is duplicated in ${scope} catalog.`,
|
|
35
|
-
path: "$.name"
|
|
36
|
-
}];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return entries;
|
|
5
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import { CliError, usageError } from "./errors.js";
|
|
7
|
+
const catalogNamePattern = /^[a-z0-9][a-z0-9-]*$/;
|
|
8
|
+
const catalogWorkflowEntry = "workflow.ts";
|
|
9
|
+
export async function discoverWorkflowCatalog(cwd, options = {}) {
|
|
10
|
+
const scope = selectedScope(options);
|
|
11
|
+
const allEntries = (await Promise.all(["project", "global"].map(item => discoverScope(cwd, item)))).flat();
|
|
12
|
+
const counts = new Map();
|
|
13
|
+
for (const entry of allEntries)
|
|
14
|
+
counts.set(entry.name, (counts.get(entry.name) ?? 0) + 1);
|
|
15
|
+
return allEntries
|
|
16
|
+
.filter(entry => scope === undefined || entry.scope === scope)
|
|
17
|
+
.map(entry => ({ ...entry, requiresScope: (counts.get(entry.name) ?? 0) > 1 }))
|
|
18
|
+
.sort(compareCatalogEntries);
|
|
19
|
+
}
|
|
20
|
+
export async function showWorkflowCatalogEntry(cwd, name, options = {}) {
|
|
21
|
+
assertCatalogName(name);
|
|
22
|
+
return findCatalogEntry(cwd, name, options);
|
|
23
|
+
}
|
|
24
|
+
export async function resolveWorkflowReference(cwd, workflow, options = {}) {
|
|
25
|
+
if (!hasSelectedScope(options) && await isPathLikeWorkflowReference(cwd, workflow))
|
|
26
|
+
return { workflow };
|
|
27
|
+
assertCatalogName(workflow);
|
|
28
|
+
const catalog = await findCatalogEntry(cwd, workflow, options);
|
|
29
|
+
if (catalog.scope === "project")
|
|
30
|
+
return { workflow: catalog.entryPath, catalog };
|
|
31
|
+
return { workflow: await materializeGlobalCatalogEntry(cwd, catalog), catalog };
|
|
41
32
|
}
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
function selectedScope(options) {
|
|
34
|
+
if (options.project && options.global)
|
|
35
|
+
throw usageError("--project and --global are mutually exclusive.");
|
|
36
|
+
if (options.project)
|
|
37
|
+
return "project";
|
|
38
|
+
if (options.global)
|
|
39
|
+
return "global";
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
function hasSelectedScope(options) {
|
|
43
|
+
return Boolean(options.project || options.global);
|
|
44
|
+
}
|
|
45
|
+
async function findCatalogEntry(cwd, name, options) {
|
|
46
|
+
const entries = (await discoverWorkflowCatalog(cwd, options)).filter(entry => entry.name === name);
|
|
47
|
+
if (entries.length === 0) {
|
|
48
|
+
const scope = selectedScope(options);
|
|
49
|
+
throw inspectError(scope
|
|
50
|
+
? `Workflow catalog entry '${name}' was not found in ${scope} scope.`
|
|
51
|
+
: `Workflow catalog entry '${name}' was not found.`);
|
|
46
52
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (entries.length > 1)
|
|
54
|
+
throw usageError(`Workflow catalog entry '${name}' exists in project and global scopes. Pass --project or --global.`);
|
|
55
|
+
return entries[0];
|
|
56
|
+
}
|
|
57
|
+
async function discoverScope(cwd, scope) {
|
|
58
|
+
const root = catalogRoot(cwd, scope);
|
|
59
|
+
let dirents;
|
|
60
|
+
try {
|
|
61
|
+
dirents = await readdir(root, { withFileTypes: true });
|
|
55
62
|
}
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (isMissingPath(error))
|
|
65
|
+
return [];
|
|
66
|
+
throw inspectError(`Workflow catalog ${scope} root '${root}' could not be read: ${causeMessage(error)}`);
|
|
58
67
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const entries = [];
|
|
69
|
+
for (const dirent of dirents) {
|
|
70
|
+
const name = dirent.name;
|
|
71
|
+
if (!catalogNamePattern.test(name))
|
|
72
|
+
continue;
|
|
73
|
+
const packagePath = join(root, name);
|
|
74
|
+
if (!await isDirectory(packagePath))
|
|
75
|
+
continue;
|
|
76
|
+
const entryPath = join(packagePath, catalogWorkflowEntry);
|
|
77
|
+
if (!await isFile(entryPath))
|
|
78
|
+
continue;
|
|
79
|
+
entries.push({
|
|
80
|
+
scope,
|
|
81
|
+
name,
|
|
82
|
+
packagePath,
|
|
83
|
+
entryPath,
|
|
84
|
+
status: "available",
|
|
85
|
+
requiresScope: false,
|
|
86
|
+
});
|
|
71
87
|
}
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
return entries;
|
|
89
|
+
}
|
|
90
|
+
function catalogRoot(cwd, scope) {
|
|
91
|
+
return scope === "project"
|
|
92
|
+
? join(cwd, ".acpus", "workflows")
|
|
93
|
+
: join(process.env.HOME || homedir(), ".acpus", "workflows");
|
|
94
|
+
}
|
|
95
|
+
function assertCatalogName(name) {
|
|
96
|
+
if (!catalogNamePattern.test(name))
|
|
97
|
+
throw usageError(`Workflow catalog name '${name}' must match ${catalogNamePattern.source}.`);
|
|
98
|
+
}
|
|
99
|
+
async function isPathLikeWorkflowReference(cwd, workflow) {
|
|
100
|
+
if (isAbsolute(workflow)
|
|
101
|
+
|| workflow.startsWith("./")
|
|
102
|
+
|| workflow.startsWith("../")
|
|
103
|
+
|| workflow.includes("/")
|
|
104
|
+
|| workflow.includes("\\")
|
|
105
|
+
|| workflow.endsWith(".ts")) {
|
|
106
|
+
return true;
|
|
74
107
|
}
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
function
|
|
78
|
-
return entry.ref === target || entry.name === target || (entry.name !== undefined && `${entry.scope}:${entry.name}` === target);
|
|
79
|
-
}
|
|
80
|
-
function scanScope(scope, root, sourceResolver) {
|
|
81
|
-
if (!existsSync(root))
|
|
82
|
-
return [];
|
|
83
|
-
const files = collectCandidateFiles(root);
|
|
84
|
-
return files.map((file) => entryFromFile(scope, file, sourceResolver));
|
|
85
|
-
}
|
|
86
|
-
function collectCandidateFiles(root) {
|
|
87
|
-
const out = [];
|
|
88
|
-
const visit = (dir) => {
|
|
89
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
90
|
-
const path = join(dir, entry.name);
|
|
91
|
-
if (entry.isDirectory()) {
|
|
92
|
-
visit(path);
|
|
93
|
-
}
|
|
94
|
-
else if (entry.isFile() && isWorkflowCandidate(entry.name)) {
|
|
95
|
-
out.push(path);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
visit(root);
|
|
100
|
-
return out.sort();
|
|
101
|
-
}
|
|
102
|
-
function entryFromFile(scope, path, sourceResolver) {
|
|
103
|
-
const source = readFileSync(path, "utf8");
|
|
104
|
-
const parsed = parseSpecSummary(source);
|
|
105
|
-
const lint = lintCatalogEntry(source, path, sourceResolver);
|
|
106
|
-
const name = parsed.name;
|
|
107
|
-
const status = lint.ok && name ? "ready" : "invalid";
|
|
108
|
-
return {
|
|
109
|
-
scope,
|
|
110
|
-
ref: status === "ready" ? `${scope}:${name}` : undefined,
|
|
111
|
-
name,
|
|
112
|
-
description: parsed.description,
|
|
113
|
-
input: parsed.input,
|
|
114
|
-
inputKeys: Object.keys(parsed.input ?? {}),
|
|
115
|
-
path,
|
|
116
|
-
status,
|
|
117
|
-
diagnostics: lint.ok && !name
|
|
118
|
-
? [{ severity: "error", code: "CATALOG_NAME", message: "Workflow Spec must declare a string name.", path: "$.name" }]
|
|
119
|
-
: lint.diagnostics
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function lintCatalogEntry(source, path, sourceResolver) {
|
|
108
|
+
return isFile(resolve(cwd, workflow));
|
|
109
|
+
}
|
|
110
|
+
async function materializeGlobalCatalogEntry(cwd, entry) {
|
|
123
111
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
112
|
+
const digest = await digestDirectory(entry.packagePath);
|
|
113
|
+
const target = join(cwd, ".acpus", ".local", "catalog-cache", "global", entry.name, digest);
|
|
114
|
+
const targetEntry = join(target, catalogWorkflowEntry);
|
|
115
|
+
if (await isFile(targetEntry))
|
|
116
|
+
return targetEntry;
|
|
117
|
+
await rm(target, { recursive: true, force: true });
|
|
118
|
+
await mkdir(dirname(target), { recursive: true });
|
|
119
|
+
await cp(entry.packagePath, target, { recursive: true, dereference: true });
|
|
120
|
+
if (!await isFile(targetEntry))
|
|
121
|
+
throw new Error(`materialized package is missing ${catalogWorkflowEntry}`);
|
|
122
|
+
return targetEntry;
|
|
128
123
|
}
|
|
129
124
|
catch (error) {
|
|
130
|
-
|
|
131
|
-
ok: false,
|
|
132
|
-
diagnostics: [{
|
|
133
|
-
severity: "error",
|
|
134
|
-
code: "CATALOG_LINT",
|
|
135
|
-
message: error instanceof Error ? error.message : String(error),
|
|
136
|
-
path: "$"
|
|
137
|
-
}]
|
|
138
|
-
};
|
|
125
|
+
throw inspectError(`Workflow catalog entry '${entry.name}' could not be materialized: ${causeMessage(error)}`);
|
|
139
126
|
}
|
|
140
127
|
}
|
|
141
|
-
function
|
|
128
|
+
async function digestDirectory(root) {
|
|
129
|
+
const hash = createHash("sha256");
|
|
130
|
+
await addToDigest(hash, root, "");
|
|
131
|
+
return hash.digest("hex");
|
|
132
|
+
}
|
|
133
|
+
async function addToDigest(hash, path, relativePath) {
|
|
134
|
+
const item = await stat(path);
|
|
135
|
+
const normalizedPath = relativePath.split(/[\\/]/).filter(Boolean).join("/");
|
|
136
|
+
if (item.isDirectory()) {
|
|
137
|
+
if (normalizedPath)
|
|
138
|
+
hash.update(`D ${normalizedPath}\n`);
|
|
139
|
+
const names = (await readdir(path)).sort();
|
|
140
|
+
for (const name of names)
|
|
141
|
+
await addToDigest(hash, join(path, name), join(relativePath, name));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!item.isFile())
|
|
145
|
+
return;
|
|
146
|
+
hash.update(`F ${normalizedPath}\n`);
|
|
147
|
+
hash.update(await readFile(path));
|
|
148
|
+
hash.update("\n");
|
|
149
|
+
}
|
|
150
|
+
async function isDirectory(path) {
|
|
142
151
|
try {
|
|
143
|
-
|
|
144
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
145
|
-
return {};
|
|
146
|
-
const map = parsed;
|
|
147
|
-
return {
|
|
148
|
-
name: typeof map.name === "string" ? map.name : undefined,
|
|
149
|
-
description: typeof map.description === "string" ? map.description : undefined,
|
|
150
|
-
input: typeof map.input === "object" && map.input !== null && !Array.isArray(map.input)
|
|
151
|
-
? map.input
|
|
152
|
-
: undefined
|
|
153
|
-
};
|
|
152
|
+
return (await stat(path)).isDirectory();
|
|
154
153
|
}
|
|
155
154
|
catch {
|
|
156
|
-
return
|
|
155
|
+
return false;
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
"workflow.yml",
|
|
163
|
-
"workflow.spec.yaml",
|
|
164
|
-
"workflow.spec.yml"
|
|
165
|
-
]);
|
|
166
|
-
if (exact.has(filename))
|
|
167
|
-
return true;
|
|
168
|
-
return [
|
|
169
|
-
".workflow.yaml",
|
|
170
|
-
".workflow.yml",
|
|
171
|
-
".workflow.spec.yaml",
|
|
172
|
-
".workflow.spec.yml"
|
|
173
|
-
].some((suffix) => filename.endsWith(suffix));
|
|
174
|
-
}
|
|
175
|
-
export function looksLikeWorkflowPath(target) {
|
|
176
|
-
return target.startsWith(".")
|
|
177
|
-
|| target.startsWith("/")
|
|
178
|
-
|| target.startsWith("~")
|
|
179
|
-
|| target.includes("/")
|
|
180
|
-
|| target.endsWith(".yaml")
|
|
181
|
-
|| target.endsWith(".yml");
|
|
182
|
-
}
|
|
183
|
-
export function resolveWorkflowPath(path) {
|
|
184
|
-
if (path === "~")
|
|
185
|
-
return homedir();
|
|
186
|
-
if (path.startsWith("~/"))
|
|
187
|
-
return resolve(homedir(), path.slice(2));
|
|
188
|
-
const resolved = resolve(process.cwd(), path);
|
|
189
|
-
if (!existsSync(resolved) || !statSync(resolved).isFile()) {
|
|
190
|
-
throw new Error(`Workflow Spec path not found: ${path}`);
|
|
158
|
+
async function isFile(path) {
|
|
159
|
+
try {
|
|
160
|
+
return (await stat(path)).isFile();
|
|
191
161
|
}
|
|
192
|
-
|
|
162
|
+
catch {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function compareCatalogEntries(left, right) {
|
|
167
|
+
const name = left.name.localeCompare(right.name);
|
|
168
|
+
if (name !== 0)
|
|
169
|
+
return name;
|
|
170
|
+
return scopeRank(left.scope) - scopeRank(right.scope);
|
|
171
|
+
}
|
|
172
|
+
function scopeRank(scope) {
|
|
173
|
+
return scope === "project" ? 0 : 1;
|
|
174
|
+
}
|
|
175
|
+
function inspectError(message) {
|
|
176
|
+
return new CliError(1, { ok: false, phase: "inspect", message });
|
|
177
|
+
}
|
|
178
|
+
function isMissingPath(error) {
|
|
179
|
+
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
180
|
+
}
|
|
181
|
+
function causeMessage(cause) {
|
|
182
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
193
183
|
}
|
|
194
184
|
//# sourceMappingURL=catalog.js.map
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAe,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuBnD,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAClD,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAW,EAAE,UAAuC,EAAE;IAClG,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAE,CAA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,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAAC,KAA2B;IAC5C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,IAAI,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AACnG,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { runCli } from "./program.js";
|
|
3
|
+
runCli(process.argv.slice(2), {
|
|
4
|
+
cwd: process.cwd(),
|
|
5
|
+
stdin: process.stdin,
|
|
6
|
+
stdout: process.stdout,
|
|
7
|
+
stderr: process.stderr,
|
|
8
|
+
}).then(code => {
|
|
9
|
+
process.exitCode = code;
|
|
10
|
+
}, error => {
|
|
11
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC5B,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,MAAM,EAAE,OAAO,CAAC,MAAM;CACvB,CAAC,CAAC,IAAI,CACL,IAAI,CAAC,EAAE;IACL,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,EACD,KAAK,CAAC,EAAE;IACN,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DaemonControlIntent, type DaemonErrorCode, type RunDetails, type RuntimeAdvanceResult, type RuntimeMutationResult } from "@acpus/runtime";
|
|
2
|
+
export declare class DaemonControlFailure extends Error {
|
|
3
|
+
readonly code: DaemonErrorCode;
|
|
4
|
+
readonly controlType: DaemonControlIntent["type"];
|
|
5
|
+
readonly runId: string;
|
|
6
|
+
readonly run: RunDetails | undefined;
|
|
7
|
+
constructor(code: DaemonErrorCode, controlType: DaemonControlIntent["type"], runId: string, run: RunDetails | undefined, cause: unknown);
|
|
8
|
+
}
|
|
9
|
+
export declare function ensureDaemonRunning(cwd: string): void;
|
|
10
|
+
export declare function sendDaemonControl(cwd: string, intent: DaemonControlIntent): Promise<RuntimeMutationResult>;
|
|
11
|
+
export declare function sendDaemonStartRun(cwd: string, runId: string): Promise<RunDetails>;
|
|
12
|
+
export declare function sendDaemonObserveRun(cwd: string, runId: string): Promise<RuntimeAdvanceResult>;
|
|
13
|
+
export declare function daemonControlRequestId(): string;
|
|
14
|
+
//# sourceMappingURL=daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../src/commands/daemon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoG,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE1P,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS;gBAH3B,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,UAAU,GAAG,SAAS,EACpC,KAAK,EAAE,OAAO;CAIjB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOrD;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAchH;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAcxF;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAGpG;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { DaemonRequestError, getRun, requestDaemonControl, requestDaemonObserveRun, requestDaemonStartRun } from "@acpus/runtime";
|
|
5
|
+
export class DaemonControlFailure extends Error {
|
|
6
|
+
code;
|
|
7
|
+
controlType;
|
|
8
|
+
runId;
|
|
9
|
+
run;
|
|
10
|
+
constructor(code, controlType, runId, run, cause) {
|
|
11
|
+
super(controlFailureMessage(code, controlType, runId, run, cause));
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.controlType = controlType;
|
|
14
|
+
this.runId = runId;
|
|
15
|
+
this.run = run;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function ensureDaemonRunning(cwd) {
|
|
19
|
+
const child = spawn(process.execPath, daemonEntryArgs(cwd), {
|
|
20
|
+
cwd,
|
|
21
|
+
detached: true,
|
|
22
|
+
stdio: "ignore",
|
|
23
|
+
});
|
|
24
|
+
child.unref();
|
|
25
|
+
}
|
|
26
|
+
export async function sendDaemonControl(cwd, intent) {
|
|
27
|
+
ensureDaemonRunning(cwd);
|
|
28
|
+
const deadline = Date.now() + 30_000;
|
|
29
|
+
let lastError;
|
|
30
|
+
while (Date.now() <= deadline) {
|
|
31
|
+
try {
|
|
32
|
+
return await requestDaemonControl(cwd, intent);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof DaemonRequestError && error.code !== "INTERNAL_ERROR")
|
|
36
|
+
throw await daemonControlFailure(cwd, intent, error.code, error);
|
|
37
|
+
lastError = error;
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw await daemonControlFailure(cwd, intent, "EXECUTION_UNAVAILABLE", lastError);
|
|
42
|
+
}
|
|
43
|
+
export async function sendDaemonStartRun(cwd, runId) {
|
|
44
|
+
ensureDaemonRunning(cwd);
|
|
45
|
+
const deadline = Date.now() + 30_000;
|
|
46
|
+
let lastError;
|
|
47
|
+
while (Date.now() <= deadline) {
|
|
48
|
+
try {
|
|
49
|
+
return await requestDaemonStartRun(cwd, runId);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof DaemonRequestError && error.code !== "INTERNAL_ERROR")
|
|
53
|
+
throw error;
|
|
54
|
+
lastError = error;
|
|
55
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
59
|
+
}
|
|
60
|
+
export async function sendDaemonObserveRun(cwd, runId) {
|
|
61
|
+
await sendDaemonStartRun(cwd, runId);
|
|
62
|
+
return requestDaemonObserveRun(cwd, runId);
|
|
63
|
+
}
|
|
64
|
+
export function daemonControlRequestId() {
|
|
65
|
+
return `cli:${randomUUID()}`;
|
|
66
|
+
}
|
|
67
|
+
function daemonEntryArgs(cwd) {
|
|
68
|
+
const isSourceMode = fileURLToPath(import.meta.url).endsWith(".ts");
|
|
69
|
+
const entry = fileURLToPath(new URL(`../daemon-entry.${isSourceMode ? "ts" : "js"}`, import.meta.url));
|
|
70
|
+
return isSourceMode
|
|
71
|
+
? ["--conditions=development", "--import", import.meta.resolve("tsx"), entry, cwd]
|
|
72
|
+
: [entry, cwd];
|
|
73
|
+
}
|
|
74
|
+
async function daemonControlFailure(cwd, intent, code, cause) {
|
|
75
|
+
let run;
|
|
76
|
+
try {
|
|
77
|
+
run = await getRun(cwd, intent.runId);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
run = undefined;
|
|
81
|
+
}
|
|
82
|
+
return new DaemonControlFailure(code, intent.type, intent.runId, run, cause);
|
|
83
|
+
}
|
|
84
|
+
function controlFailureMessage(code, controlType, runId, run, cause) {
|
|
85
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
86
|
+
const current = run ? ` Current run: ${run.id} ${run.name} ${run.status} updated ${run.updatedAt}.` : " Current run: unavailable.";
|
|
87
|
+
return `Control '${controlType}' for run '${runId}' failed with ${code}: ${reason}.${current}`;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=daemon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../src/commands/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,qBAAqB,EAA0H,MAAM,gBAAgB,CAAC;AAE1P,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAElC;IACA;IACA;IACA;IAJX,YACW,IAAqB,EACrB,WAAwC,EACxC,KAAa,EACb,GAA2B,EACpC,KAAc;QAEd,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAN1D,SAAI,GAAJ,IAAI,CAAiB;QACrB,gBAAW,GAAX,WAAW,CAA6B;QACxC,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAwB;IAItC,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE;QAC1D,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAA2B;IAC9E,mBAAmB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AC,KAAK,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,GAAG,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAqB,EAAE,WAAmB,EAAE,KAAa,EAAE,GAA2B,EAAE,KAAc;IACnI,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,iBAAiB,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,YAAY,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,4BAA4B,CAAC;IACnI,OAAO,YAAY,WAAW,cAAc,KAAK,iBAAiB,IAAI,KAAK,MAAM,IAAI,OAAO,EAAE,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Writable } from "node:stream";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
export type DoctorCommandContext = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
stdout: Writable;
|
|
6
|
+
stderr: Writable;
|
|
7
|
+
wantsJson: boolean;
|
|
8
|
+
setExitCode(code: number): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createDoctorCommand(ctx: DoctorCommandContext): Command;
|
|
11
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAoBtE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { getRuntimeHealth } from "@acpus/runtime";
|
|
3
|
+
import { writeResult } from "../output.js";
|
|
4
|
+
export function createDoctorCommand(ctx) {
|
|
5
|
+
return new Command("doctor")
|
|
6
|
+
.exitOverride()
|
|
7
|
+
.configureOutput({
|
|
8
|
+
writeOut: text => ctx.stdout.write(text),
|
|
9
|
+
writeErr: text => {
|
|
10
|
+
if (!ctx.wantsJson)
|
|
11
|
+
ctx.stderr.write(text);
|
|
12
|
+
},
|
|
13
|
+
outputError: (text, write) => write(text),
|
|
14
|
+
})
|
|
15
|
+
.description("Run read-only workspace health checks.")
|
|
16
|
+
.action(async () => {
|
|
17
|
+
const report = await getRuntimeHealth(ctx.cwd);
|
|
18
|
+
ctx.setExitCode(writeResult({
|
|
19
|
+
ok: report.ok,
|
|
20
|
+
phase: "doctor",
|
|
21
|
+
message: report.ok ? "Doctor checks passed." : "Doctor checks failed.",
|
|
22
|
+
checks: report.checks,
|
|
23
|
+
}, ctx.wantsJson ? "json" : "text", ctx, report.ok ? 0 : 1));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW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
|
|
3
|
+
export type HooksCommandContext = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
stdout: Writable;
|
|
6
|
+
stderr: Writable;
|
|
7
|
+
wantsJson: boolean;
|
|
8
|
+
setExitCode(code: number): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createHooksCommand(ctx: HooksCommandContext): Command;
|
|
11
|
+
//# sourceMappingURL=hooks.d.ts.map
|