@thaodangspace/argos 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +45 -2
- package/dist/args.d.ts +21 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +86 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/actions.d.ts +8 -0
- package/dist/commands/actions.d.ts.map +1 -0
- package/dist/commands/actions.js +89 -0
- package/dist/commands/actions.js.map +1 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +187 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/run.d.ts +5 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +65 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/runs.d.ts +7 -0
- package/dist/commands/runs.d.ts.map +1 -0
- package/dist/commands/runs.js +113 -0
- package/dist/commands/runs.js.map +1 -0
- package/dist/commands/schedule.d.ts +15 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +320 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/serve.d.ts +29 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +200 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/validate.d.ts +23 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +185 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/worktree.d.ts +11 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +92 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +5 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +61 -0
- package/dist/main.js.map +1 -0
- package/dist/output.d.ts +38 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +114 -0
- package/dist/output.js.map +1 -0
- package/dist/rpc-command.d.ts +12 -0
- package/dist/rpc-command.d.ts.map +1 -0
- package/dist/rpc-command.js +34 -0
- package/dist/rpc-command.js.map +1 -0
- package/package.json +52 -4
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `argos serve` (FR2/FR25) — the **only** process that opens `$ARGOS_HOME/argos.sqlite`.
|
|
3
|
+
*
|
|
4
|
+
* It builds the Paseo executor (or the deterministic `ARGOS_FAKE_PASEO=1` test executor), opens
|
|
5
|
+
* `ArgosHost` (pid file + SQLite + `resume()`), ensures the bearer token, starts the loopback RPC
|
|
6
|
+
* server, and waits for SIGINT/SIGTERM to close both gracefully. The host is retried once on a
|
|
7
|
+
* transient open failure; `storage_locked` is never retried because another live process owns the
|
|
8
|
+
* home.
|
|
9
|
+
*/
|
|
10
|
+
import { resolve } from "node:path";
|
|
11
|
+
import { argosHome, isArgosError } from "@thaodangspace/argos-core";
|
|
12
|
+
import { ArgosHost, createRpcServer, } from "@thaodangspace/argos-core/rpc/server";
|
|
13
|
+
import { ModelCatalog, createAgentStepExecutor, createFakeStepExecutor, createPaseoPort, fakeProviderCatalog, } from "@thaodangspace/argos-core/paseo";
|
|
14
|
+
import { flag, rejectUnknownFlags } from "../args.js";
|
|
15
|
+
import { EXIT_RUNTIME, REQUIRED_NODE_VERSION, nodeVersionOk, } from "../output.js";
|
|
16
|
+
/**
|
|
17
|
+
* The single stderr line `argos serve` prints per fire (FR10.4), including its newline.
|
|
18
|
+
*
|
|
19
|
+
* It carries the schedule id, the ISO fire time, the status, and then either the run the fire
|
|
20
|
+
* started or the error code that refused it. It never contains an input value — and the event it
|
|
21
|
+
* reads has no inputs at all.
|
|
22
|
+
*/
|
|
23
|
+
export function formatScheduleFireLine(event) {
|
|
24
|
+
const head = `[argos] schedule ${event.scheduleId} ${new Date(event.fireAt).toISOString()} ${event.status}`;
|
|
25
|
+
const tail = event.runId !== undefined
|
|
26
|
+
? ` run ${event.runId}`
|
|
27
|
+
: event.errorCode !== undefined && event.errorCode !== null
|
|
28
|
+
? ` ${event.errorCode}`
|
|
29
|
+
: event.count !== undefined
|
|
30
|
+
? ` ${event.count}`
|
|
31
|
+
: "";
|
|
32
|
+
return `${head}${tail}\n`;
|
|
33
|
+
}
|
|
34
|
+
function configuredPort(value) {
|
|
35
|
+
const raw = value ?? process.env["ARGOS_PORT"];
|
|
36
|
+
if (raw === undefined)
|
|
37
|
+
return 7676;
|
|
38
|
+
const parsed = Number.parseInt(raw, 10);
|
|
39
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : 7676;
|
|
40
|
+
}
|
|
41
|
+
function delay(ms) {
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
setTimeout(resolve, ms);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Bound startup catalog discovery so a down daemon cannot block `argos serve`. */
|
|
47
|
+
function within(promise, ms) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
reject(new Error(`no answer within ${ms} ms`));
|
|
51
|
+
}, ms);
|
|
52
|
+
timer.unref?.();
|
|
53
|
+
promise.then((value) => {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
resolve(value);
|
|
56
|
+
}, (error) => {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Open once, then once more after a short pause unless the home is owned by a live process. */
|
|
63
|
+
async function openHost(options) {
|
|
64
|
+
try {
|
|
65
|
+
return await ArgosHost.open(options);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (isArgosError(error) && error.code === "storage_locked")
|
|
69
|
+
throw error;
|
|
70
|
+
await delay(250);
|
|
71
|
+
return ArgosHost.open(options);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function buildDependencies(home, io) {
|
|
75
|
+
if (process.env["ARGOS_FAKE_PASEO"] === "1") {
|
|
76
|
+
io.stderr("[argos] ARGOS_FAKE_PASEO=1: using the deterministic test-only executor\n");
|
|
77
|
+
const catalog = ModelCatalog.fromSnapshot(fakeProviderCatalog());
|
|
78
|
+
// File-backed by default so a restarted `argos serve` adopts the fake agents it created in
|
|
79
|
+
// its previous lifetime (Phase 10 D17). `ARGOS_FAKE_PASEO_DIR` moves the state elsewhere.
|
|
80
|
+
const fakeDir = process.env["ARGOS_FAKE_PASEO_DIR"];
|
|
81
|
+
const host = await openHost({
|
|
82
|
+
home,
|
|
83
|
+
executor: createFakeStepExecutor({
|
|
84
|
+
statePath: fakeDir === undefined ? home : resolve(fakeDir),
|
|
85
|
+
}),
|
|
86
|
+
modelCatalog: catalog,
|
|
87
|
+
// FR10.4: registered before the first tick, so a catch-up fire during `open()` still prints.
|
|
88
|
+
onScheduleFire: (event) => io.stderr(formatScheduleFireLine(event)),
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
host,
|
|
92
|
+
probe: { mode: "fake", snapshot: async () => fakeProviderCatalog() },
|
|
93
|
+
close: async () => undefined,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const paseo = createPaseoPort();
|
|
97
|
+
let catalog;
|
|
98
|
+
try {
|
|
99
|
+
catalog = await within(ModelCatalog.load(paseo), 5_000);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
io.stderr(`[argos] warning: could not load the provider catalog (${error instanceof Error ? error.message : String(error)}); runs will fail until the daemon is reachable\n`);
|
|
103
|
+
}
|
|
104
|
+
const executor = createAgentStepExecutor({
|
|
105
|
+
port: paseo,
|
|
106
|
+
...(catalog === undefined ? {} : { catalog }),
|
|
107
|
+
});
|
|
108
|
+
const host = await openHost({
|
|
109
|
+
home,
|
|
110
|
+
executor,
|
|
111
|
+
...(catalog === undefined ? {} : { modelCatalog: catalog }),
|
|
112
|
+
onScheduleFire: (event) => io.stderr(formatScheduleFireLine(event)),
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
host,
|
|
116
|
+
probe: {
|
|
117
|
+
url: paseo.url,
|
|
118
|
+
mode: "live",
|
|
119
|
+
snapshot: () => paseo.providersSnapshot(),
|
|
120
|
+
},
|
|
121
|
+
close: () => paseo.close(),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export async function serveCommand(args, io) {
|
|
125
|
+
const unknown = rejectUnknownFlags(args, ["port", "home"]);
|
|
126
|
+
if (unknown !== undefined) {
|
|
127
|
+
io.stderr(`argos: ${unknown}\n`);
|
|
128
|
+
return EXIT_RUNTIME;
|
|
129
|
+
}
|
|
130
|
+
if (!nodeVersionOk()) {
|
|
131
|
+
io.stderr(`argos: Node ${process.versions.node} is too old; Argos needs ${REQUIRED_NODE_VERSION} (built-in SQLite)\n`);
|
|
132
|
+
return EXIT_RUNTIME;
|
|
133
|
+
}
|
|
134
|
+
const homeFlag = flag(args, "home");
|
|
135
|
+
const home = resolve(homeFlag ?? argosHome());
|
|
136
|
+
const portFlag = flag(args, "port");
|
|
137
|
+
if (portFlag !== undefined && !/^\d+$/.test(portFlag)) {
|
|
138
|
+
io.stderr("argos: --port must be a non-negative integer\n");
|
|
139
|
+
return EXIT_RUNTIME;
|
|
140
|
+
}
|
|
141
|
+
const port = configuredPort(portFlag);
|
|
142
|
+
let dependencies;
|
|
143
|
+
try {
|
|
144
|
+
dependencies = await buildDependencies(home, io);
|
|
145
|
+
const server = await createRpcServer({
|
|
146
|
+
host: dependencies.host,
|
|
147
|
+
home,
|
|
148
|
+
port,
|
|
149
|
+
cwd: process.cwd(),
|
|
150
|
+
paseo: dependencies.probe,
|
|
151
|
+
});
|
|
152
|
+
if (args.json) {
|
|
153
|
+
io.stdout(`${JSON.stringify({ port: server.port, home, pid: process.pid })}\n`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
io.stdout(`[argos] listening on ${server.url} (home ${home}, pid ${process.pid})\n`);
|
|
157
|
+
}
|
|
158
|
+
// FR10.4: the fire line is already wired through `ArgosHost.open` (`onScheduleFire`), so a
|
|
159
|
+
// catch-up fire that runs while the host opens is announced too. A JSON `serve` still keeps
|
|
160
|
+
// stdout to one line.
|
|
161
|
+
return await new Promise((resolve) => {
|
|
162
|
+
let stopping = false;
|
|
163
|
+
const shutdown = () => {
|
|
164
|
+
if (stopping)
|
|
165
|
+
return;
|
|
166
|
+
stopping = true;
|
|
167
|
+
void (async () => {
|
|
168
|
+
try {
|
|
169
|
+
await server.close();
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
try {
|
|
173
|
+
await dependencies?.host.close();
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
await dependencies?.close().catch(() => undefined);
|
|
177
|
+
resolve(0);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})();
|
|
181
|
+
};
|
|
182
|
+
process.once("SIGINT", shutdown);
|
|
183
|
+
process.once("SIGTERM", shutdown);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
const code = isArgosError(error) ? error.code : "internal_error";
|
|
188
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
189
|
+
await dependencies?.host.close().catch(() => undefined);
|
|
190
|
+
await dependencies?.close().catch(() => undefined);
|
|
191
|
+
if (args.json) {
|
|
192
|
+
io.stderr(`${JSON.stringify({ error: { code, message } })}\n`);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
io.stderr(`argos: ${code}: ${message}\n`);
|
|
196
|
+
}
|
|
197
|
+
return EXIT_RUNTIME;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AA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C,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,YAAY,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,MAAM,CAAC,UAAU,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `argos validate [path]` (FR25, FR12) — loader only: no server, no SQLite, no side effects.
|
|
3
|
+
*
|
|
4
|
+
* With no argument it validates every playbook discovered under the current directory (the same
|
|
5
|
+
* `.argos/playbooks` / `.paseo/plugins/playbooks` roots the engine uses) plus the global library in
|
|
6
|
+
* `$ARGOS_HOME/playbooks` (`--home`, else `ARGOS_HOME`, else `~/.argos`). A file argument is
|
|
7
|
+
* validated as that exact file, with the repository root inferred from the standard directory
|
|
8
|
+
* layout; a directory argument is treated as a repository root, unless it is itself a playbooks
|
|
9
|
+
* directory or a loose folder of YAML files. Every error keeps its file and step id, and the
|
|
10
|
+
* command exits 2 when at least one playbook is invalid.
|
|
11
|
+
*/
|
|
12
|
+
import type { ValidateReport } from "@thaodangspace/argos-core/rpc";
|
|
13
|
+
import type { ParsedArgs } from "../args.js";
|
|
14
|
+
import { type CliIo } from "../output.js";
|
|
15
|
+
interface ValidationResult {
|
|
16
|
+
readonly report: ValidateReport;
|
|
17
|
+
readonly repoDir: string;
|
|
18
|
+
}
|
|
19
|
+
/** Run the loader over every candidate and collect every failure (never stop at the first). */
|
|
20
|
+
export declare function validatePlaybooks(pathArg: string | undefined, cwd?: string, home?: string): ValidationResult;
|
|
21
|
+
export declare function validateCommand(args: ParsedArgs, io: CliIo): number;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAQtB,UAAU,gBAAgB;IACxB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAqED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,GAAG,GAAE,MAAsB,EAC3B,IAAI,GAAE,MAAoB,GACzB,gBAAgB,CAoElB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CA6CnE"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `argos validate [path]` (FR25, FR12) — loader only: no server, no SQLite, no side effects.
|
|
3
|
+
*
|
|
4
|
+
* With no argument it validates every playbook discovered under the current directory (the same
|
|
5
|
+
* `.argos/playbooks` / `.paseo/plugins/playbooks` roots the engine uses) plus the global library in
|
|
6
|
+
* `$ARGOS_HOME/playbooks` (`--home`, else `ARGOS_HOME`, else `~/.argos`). A file argument is
|
|
7
|
+
* validated as that exact file, with the repository root inferred from the standard directory
|
|
8
|
+
* layout; a directory argument is treated as a repository root, unless it is itself a playbooks
|
|
9
|
+
* directory or a loose folder of YAML files. Every error keeps its file and step id, and the
|
|
10
|
+
* command exits 2 when at least one playbook is invalid.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
13
|
+
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
14
|
+
import { argosHome, errorLocation, isArgosError } from "@thaodangspace/argos-core";
|
|
15
|
+
import { discoverPlaybooks, loadPlaybook, } from "@thaodangspace/argos-core/playbook";
|
|
16
|
+
import { flag, rejectUnknownFlags } from "../args.js";
|
|
17
|
+
import { EXIT_OK, EXIT_RUNTIME, EXIT_VALIDATION, printJson, } from "../output.js";
|
|
18
|
+
const YAML_EXTENSIONS = new Set([".yaml", ".yml"]);
|
|
19
|
+
const ROOT_MARKERS = [
|
|
20
|
+
"/.argos/playbooks",
|
|
21
|
+
"/.paseo/plugins/playbooks",
|
|
22
|
+
];
|
|
23
|
+
function toPosix(path) {
|
|
24
|
+
return path.split(sep).join("/");
|
|
25
|
+
}
|
|
26
|
+
/** The repository root a standard playbooks path belongs to. */
|
|
27
|
+
function inferRepoRoot(file) {
|
|
28
|
+
const posix = toPosix(file);
|
|
29
|
+
for (const marker of ROOT_MARKERS) {
|
|
30
|
+
const index = posix.indexOf(marker);
|
|
31
|
+
if (index > 0)
|
|
32
|
+
return posix.slice(0, index);
|
|
33
|
+
}
|
|
34
|
+
return dirname(file);
|
|
35
|
+
}
|
|
36
|
+
function yamlFiles(directory) {
|
|
37
|
+
return readdirSync(directory)
|
|
38
|
+
.filter((name) => YAML_EXTENSIONS.has(extname(name)))
|
|
39
|
+
.map((name) => join(directory, name))
|
|
40
|
+
.filter((file) => statSync(file).isFile())
|
|
41
|
+
.sort();
|
|
42
|
+
}
|
|
43
|
+
function candidatesFor(target, home) {
|
|
44
|
+
const absolute = resolve(target);
|
|
45
|
+
if (!existsSync(absolute)) {
|
|
46
|
+
throw new Error(`path not found: ${target}`);
|
|
47
|
+
}
|
|
48
|
+
const info = statSync(absolute);
|
|
49
|
+
if (info.isFile()) {
|
|
50
|
+
const id = basename(absolute, extname(absolute));
|
|
51
|
+
return {
|
|
52
|
+
repoDir: inferRepoRoot(absolute),
|
|
53
|
+
candidates: [{ entry: { id, file: absolute, root: "" }, explicit: true }],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (!info.isDirectory()) {
|
|
57
|
+
throw new Error(`not a file or directory: ${target}`);
|
|
58
|
+
}
|
|
59
|
+
const discovered = discoverPlaybooks(absolute, home);
|
|
60
|
+
if (discovered.length > 0) {
|
|
61
|
+
return {
|
|
62
|
+
repoDir: absolute,
|
|
63
|
+
candidates: discovered.map((entry) => ({ entry, explicit: false })),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const files = yamlFiles(absolute);
|
|
67
|
+
const explicit = files.map((file) => ({
|
|
68
|
+
entry: { id: basename(file, extname(file)), file, root: "" },
|
|
69
|
+
explicit: true,
|
|
70
|
+
}));
|
|
71
|
+
return { repoDir: inferRepoRoot(absolute), candidates: explicit };
|
|
72
|
+
}
|
|
73
|
+
function displayPath(repoDir, file) {
|
|
74
|
+
const path = relative(resolve(repoDir), resolve(file));
|
|
75
|
+
return path === "" || path.startsWith("..") ? resolve(file) : toPosix(path);
|
|
76
|
+
}
|
|
77
|
+
/** Run the loader over every candidate and collect every failure (never stop at the first). */
|
|
78
|
+
export function validatePlaybooks(pathArg, cwd = process.cwd(), home = argosHome()) {
|
|
79
|
+
const root = resolve(cwd);
|
|
80
|
+
const { repoDir, candidates } = pathArg === undefined
|
|
81
|
+
? {
|
|
82
|
+
repoDir: root,
|
|
83
|
+
candidates: discoverPlaybooks(root, home).map((entry) => ({
|
|
84
|
+
entry,
|
|
85
|
+
explicit: false,
|
|
86
|
+
})),
|
|
87
|
+
}
|
|
88
|
+
: candidatesFor(resolve(root, pathArg), home);
|
|
89
|
+
const playbooks = [];
|
|
90
|
+
const errors = [];
|
|
91
|
+
const warnings = [];
|
|
92
|
+
for (const candidate of candidates) {
|
|
93
|
+
try {
|
|
94
|
+
const ir = loadPlaybook(repoDir, candidate.entry.id, candidate.explicit
|
|
95
|
+
? { file: candidate.entry.file, home, warnings }
|
|
96
|
+
: { home, warnings });
|
|
97
|
+
playbooks.push({
|
|
98
|
+
id: ir.id,
|
|
99
|
+
file: displayPath(repoDir, candidate.entry.file),
|
|
100
|
+
hash: ir.hash,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const file = isArgosError(error) && error.file !== undefined ? error.file : candidate.entry.file;
|
|
105
|
+
const code = isArgosError(error) ? error.code : "playbook_invalid";
|
|
106
|
+
const errorStepId = isArgosError(error) ? (error.stepId ?? null) : null;
|
|
107
|
+
const issues = isArgosError(error) ? (error.issues ?? []) : [];
|
|
108
|
+
if (issues.length > 0) {
|
|
109
|
+
// FR1.4: one `errors[]` entry per schema issue, so every typo is named in one run.
|
|
110
|
+
for (const issue of issues) {
|
|
111
|
+
errors.push({
|
|
112
|
+
file: displayPath(repoDir, file),
|
|
113
|
+
stepId: issue.stepId ?? errorStepId,
|
|
114
|
+
code,
|
|
115
|
+
message: `${issue.path}: ${issue.message}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
const prefix = errorLocation(file, errorStepId ?? undefined);
|
|
122
|
+
errors.push({
|
|
123
|
+
file: displayPath(repoDir, file),
|
|
124
|
+
stepId: errorStepId,
|
|
125
|
+
code,
|
|
126
|
+
message: message.startsWith(prefix) ? message.slice(prefix.length) : message,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
repoDir,
|
|
132
|
+
report: {
|
|
133
|
+
valid: errors.length === 0,
|
|
134
|
+
playbooks,
|
|
135
|
+
errors,
|
|
136
|
+
warnings: warnings.map((warning) => ({ ...warning, file: displayPath(repoDir, warning.file) })),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function validateCommand(args, io) {
|
|
141
|
+
const unknown = rejectUnknownFlags(args, ["home"]);
|
|
142
|
+
if (unknown !== undefined) {
|
|
143
|
+
io.stderr(`argos: ${unknown}\n`);
|
|
144
|
+
return EXIT_RUNTIME;
|
|
145
|
+
}
|
|
146
|
+
if (args.positionals.length > 1) {
|
|
147
|
+
io.stderr("argos: validate takes at most one path\n");
|
|
148
|
+
return EXIT_RUNTIME;
|
|
149
|
+
}
|
|
150
|
+
// Same precedence as `argos serve`: `--home`, else `ARGOS_HOME`, else `~/.argos`, so a local
|
|
151
|
+
// check and a running server agree on the global playbook library.
|
|
152
|
+
const homeFlag = flag(args, "home");
|
|
153
|
+
const home = resolve(homeFlag ?? argosHome());
|
|
154
|
+
let result;
|
|
155
|
+
try {
|
|
156
|
+
result = validatePlaybooks(args.positionals[0], process.cwd(), home);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
io.stderr(`argos: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
160
|
+
return EXIT_RUNTIME;
|
|
161
|
+
}
|
|
162
|
+
if (args.json) {
|
|
163
|
+
printJson(io, result.report);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
for (const playbook of result.report.playbooks) {
|
|
167
|
+
io.stdout(`ok ${playbook.id} ${playbook.file} ${playbook.hash}\n`);
|
|
168
|
+
}
|
|
169
|
+
for (const error of result.report.errors) {
|
|
170
|
+
const location = error.stepId === null ? error.file : `${error.file}: step ${error.stepId}`;
|
|
171
|
+
io.stdout(`FAIL ${location}: ${error.code}: ${error.message}\n`);
|
|
172
|
+
}
|
|
173
|
+
// FR7.1: warnings print after the errors and never change the exit code.
|
|
174
|
+
for (const warning of result.report.warnings) {
|
|
175
|
+
const location = warning.stepId === null ? warning.file : `${warning.file}: step ${warning.stepId}`;
|
|
176
|
+
io.stdout(`WARN ${location}: ${warning.code}: ${warning.message}\n`);
|
|
177
|
+
}
|
|
178
|
+
const total = result.report.playbooks.length + result.report.errors.length;
|
|
179
|
+
io.stdout(result.report.valid
|
|
180
|
+
? `${result.report.playbooks.length} playbook(s) valid\n`
|
|
181
|
+
: `${result.report.errors.length} of ${total} playbook(s) invalid\n`);
|
|
182
|
+
}
|
|
183
|
+
return result.report.valid ? EXIT_OK : EXIT_VALIDATION;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EACL,iBAAiB,EACjB,YAAY,GAGb,MAAM,oCAAoC,CAAC;AAS5C,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,SAAS,GAEV,MAAM,cAAc,CAAC;AAatB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACnD,MAAM,YAAY,GAAG;IACnB,mBAAmB;IACnB,2BAA2B;CACnB,CAAC;AAEX,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC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AC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,UAAU,OAAO,CAAC,MAAM,EAAE,CAAC;YACpG,EAAE,CAAC,MAAM,CAAC,SAAS,QAAQ,KAAK,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACxE,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAC3E,EAAE,CAAC,MAAM,CACP,MAAM,CAAC,MAAM,CAAC,KAAK;YACjB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,sBAAsB;YACzD,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,KAAK,wBAAwB,CACvE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `argos worktree rm|gc` (FR4.6) — manual cleanup of `$ARGOS_HOME/worktrees`.
|
|
3
|
+
*
|
|
4
|
+
* The sub-command is parsed by hand (the same shape as the rest of the CLI: no dependency), and
|
|
5
|
+
* every request goes through `argos serve`: the CLI never touches a working tree or SQLite. The
|
|
6
|
+
* server derives the path and branch from the run record (FR4.4), so nothing here ever sends a path.
|
|
7
|
+
*/
|
|
8
|
+
import { type ParsedArgs } from "../args.js";
|
|
9
|
+
import { type CliIo } from "../output.js";
|
|
10
|
+
export declare function worktreeCommand(args: ParsedArgs, io: CliIo): Promise<number>;
|
|
11
|
+
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/commands/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGxD,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `argos worktree rm|gc` (FR4.6) — manual cleanup of `$ARGOS_HOME/worktrees`.
|
|
3
|
+
*
|
|
4
|
+
* The sub-command is parsed by hand (the same shape as the rest of the CLI: no dependency), and
|
|
5
|
+
* every request goes through `argos serve`: the CLI never touches a working tree or SQLite. The
|
|
6
|
+
* server derives the path and branch from the run record (FR4.4), so nothing here ever sends a path.
|
|
7
|
+
*/
|
|
8
|
+
import { flag, hasFlag, rejectUnknownFlags } from "../args.js";
|
|
9
|
+
import { EXIT_RUNTIME } from "../output.js";
|
|
10
|
+
import { withRpc } from "../rpc-command.js";
|
|
11
|
+
export async function worktreeCommand(args, io) {
|
|
12
|
+
const [sub, ...rest] = args.positionals;
|
|
13
|
+
if (sub === "rm")
|
|
14
|
+
return removeWorktreeCommand(args, io, rest);
|
|
15
|
+
if (sub === "gc")
|
|
16
|
+
return gcWorktreeCommand(args, io, rest);
|
|
17
|
+
io.stderr("argos: worktree needs a sub-command (rm <runId> | gc --older-than <dur>)\n");
|
|
18
|
+
return EXIT_RUNTIME;
|
|
19
|
+
}
|
|
20
|
+
async function removeWorktreeCommand(args, io, positionals) {
|
|
21
|
+
const unknown = rejectUnknownFlags(args, ["force", "delete-branch"]);
|
|
22
|
+
if (unknown !== undefined) {
|
|
23
|
+
io.stderr(`argos: ${unknown}\n`);
|
|
24
|
+
return EXIT_RUNTIME;
|
|
25
|
+
}
|
|
26
|
+
const runId = positionals[0];
|
|
27
|
+
if (runId === undefined) {
|
|
28
|
+
io.stderr("argos: worktree rm needs a run id\n");
|
|
29
|
+
return EXIT_RUNTIME;
|
|
30
|
+
}
|
|
31
|
+
if (positionals.length > 1) {
|
|
32
|
+
io.stderr("argos: worktree rm takes exactly one run id\n");
|
|
33
|
+
return EXIT_RUNTIME;
|
|
34
|
+
}
|
|
35
|
+
const force = hasFlag(args, "force");
|
|
36
|
+
const deleteBranch = hasFlag(args, "delete-branch");
|
|
37
|
+
return withRpc(io, args.json, async (client) => {
|
|
38
|
+
const result = await client.removeWorktree(runId, {
|
|
39
|
+
...(force ? { force: true } : {}),
|
|
40
|
+
...(deleteBranch ? { deleteBranch: true } : {}),
|
|
41
|
+
});
|
|
42
|
+
const branch = result.branchDeleted
|
|
43
|
+
? "; deleted its branch"
|
|
44
|
+
: deleteBranch
|
|
45
|
+
? "; the branch was kept (merge it first, or pass --force)"
|
|
46
|
+
: "";
|
|
47
|
+
return {
|
|
48
|
+
jsonValue: result,
|
|
49
|
+
human: result.removed
|
|
50
|
+
? `removed worktree ${result.path} of run ${result.runId}${branch}`
|
|
51
|
+
: `run ${result.runId} has no worktree to remove${branch}`,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function gcWorktreeCommand(args, io, positionals) {
|
|
56
|
+
const unknown = rejectUnknownFlags(args, ["older-than", "force", "delete-branch", "dry-run"]);
|
|
57
|
+
if (unknown !== undefined) {
|
|
58
|
+
io.stderr(`argos: ${unknown}\n`);
|
|
59
|
+
return EXIT_RUNTIME;
|
|
60
|
+
}
|
|
61
|
+
if (positionals.length > 0) {
|
|
62
|
+
io.stderr("argos: worktree gc takes no run id; it works from --older-than\n");
|
|
63
|
+
return EXIT_RUNTIME;
|
|
64
|
+
}
|
|
65
|
+
const olderThan = flag(args, "older-than");
|
|
66
|
+
if (olderThan === undefined) {
|
|
67
|
+
io.stderr("argos: worktree gc needs --older-than <n>(s|m|h|d), e.g. --older-than 24h\n");
|
|
68
|
+
return EXIT_RUNTIME;
|
|
69
|
+
}
|
|
70
|
+
const force = hasFlag(args, "force");
|
|
71
|
+
const deleteBranch = hasFlag(args, "delete-branch");
|
|
72
|
+
const dryRun = hasFlag(args, "dry-run");
|
|
73
|
+
return withRpc(io, args.json, async (client) => {
|
|
74
|
+
const result = await client.gcWorktrees({
|
|
75
|
+
olderThan,
|
|
76
|
+
...(dryRun ? { dryRun: true } : {}),
|
|
77
|
+
...(force ? { force: true } : {}),
|
|
78
|
+
...(deleteBranch ? { deleteBranch: true } : {}),
|
|
79
|
+
});
|
|
80
|
+
const verb = dryRun ? "would remove" : "removed";
|
|
81
|
+
const branches = result.removed.filter((entry) => entry.branchDeleted).length;
|
|
82
|
+
const skip = result.skipped.map((entry) => `${entry.runId} (${entry.reason})`).join(", ");
|
|
83
|
+
return {
|
|
84
|
+
jsonValue: result,
|
|
85
|
+
human: `${verb} ${result.removed.length} worktree(s)` +
|
|
86
|
+
(branches > 0 ? `, ${branches} branch(es)` : "") +
|
|
87
|
+
`; skipped ${result.skipped.length}${skip === "" ? "" : `: ${skip}`}` +
|
|
88
|
+
`; ${result.orphans.length} orphan director${result.orphans.length === 1 ? "y" : "ies"} reported`,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=worktree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../src/commands/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAmB,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,YAAY,EAAc,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,eA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F,OAAO;YACL,SAAS,EAAE,MAAM;YACjB,KAAK,EACH,GAAG,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,cAAc;gBAC9C,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE;gBACrE,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,mBAAmB,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW;SACpG,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `argos` executable entry (FR25).
|
|
4
|
+
*
|
|
5
|
+
* Executing this file runs the CLI; importing it (tests) only exposes {@link runCli}. `serve` is
|
|
6
|
+
* loaded lazily by the dispatcher so a client command never pulls the durable host into memory.
|
|
7
|
+
*/
|
|
8
|
+
export { runCli } from "./main.js";
|
|
9
|
+
/** Name of the CLI binary. */
|
|
10
|
+
export declare const CLI_NAME = "argos";
|
|
11
|
+
/** Small diagnostic used by the Phase 1 smoke test. */
|
|
12
|
+
export declare function describeEnvironment(): string;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAUH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,UAAU,CAAC;AAEhC,uDAAuD;AACvD,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `argos` executable entry (FR25).
|
|
4
|
+
*
|
|
5
|
+
* Executing this file runs the CLI; importing it (tests) only exposes {@link runCli}. `serve` is
|
|
6
|
+
* loaded lazily by the dispatcher so a client command never pulls the durable host into memory.
|
|
7
|
+
*/
|
|
8
|
+
import { realpathSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { argosHome } from "@thaodangspace/argos-core";
|
|
12
|
+
import { runCli } from "./main.js";
|
|
13
|
+
export { runCli } from "./main.js";
|
|
14
|
+
/** Name of the CLI binary. */
|
|
15
|
+
export const CLI_NAME = "argos";
|
|
16
|
+
/** Small diagnostic used by the Phase 1 smoke test. */
|
|
17
|
+
export function describeEnvironment() {
|
|
18
|
+
return `${CLI_NAME} home: ${argosHome()}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* True when this file is the process entry point. Both paths are realpath'd because a global
|
|
22
|
+
* install (`npm link`, `npm i -g`) runs a bin symlink: `process.argv[1]` keeps the symlink path
|
|
23
|
+
* while `import.meta.url` is the resolved module path, so a plain string compare never matches.
|
|
24
|
+
*/
|
|
25
|
+
function isEntryPoint() {
|
|
26
|
+
const entry = process.argv[1];
|
|
27
|
+
if (entry === undefined)
|
|
28
|
+
return false;
|
|
29
|
+
const self = fileURLToPath(import.meta.url);
|
|
30
|
+
try {
|
|
31
|
+
return realpathSync(resolve(entry)) === realpathSync(self);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// `argv[1]` can name a path that no longer exists; fall back to the plain comparison.
|
|
35
|
+
return resolve(entry) === self;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (isEntryPoint()) {
|
|
39
|
+
process.exitCode = await runCli(process.argv.slice(2));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,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The `argos` command dispatcher (FR25). No storage import anywhere on this path. */
|
|
2
|
+
import { type CliIo } from "./output.js";
|
|
3
|
+
/** Run one CLI invocation and return its exit code (0/1/2/3). */
|
|
4
|
+
export declare function runCli(argv: readonly string[], io?: CliIo): Promise<number>;
|
|
5
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAUtF,OAAO,EAOL,KAAK,KAAK,EACX,MAAM,aAAa,CAAC;AAErB,iEAAiE;AACjE,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,GAAE,KAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmD5F"}
|