@iowarp/clio-coder 0.3.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/CHANGELOG.md +407 -0
- package/CODE_OF_CONDUCT.md +21 -0
- package/CONTRIBUTING.md +224 -0
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +798 -0
- package/SECURITY.md +72 -0
- package/assets/clio-coder-logo-128.webp +0 -0
- package/damage-control-rules.yaml +419 -0
- package/dist/acp-UMLFVA3F.js +92 -0
- package/dist/agents-Q4MYPMUW.js +91 -0
- package/dist/auth-O6HYIJ6J.js +521 -0
- package/dist/chunk-262G75JS.js +35 -0
- package/dist/chunk-26BZQOAD.js +1281 -0
- package/dist/chunk-2J63S4SF.js +508 -0
- package/dist/chunk-3DANZDGR.js +717 -0
- package/dist/chunk-4UQA7NCT.js +29 -0
- package/dist/chunk-527KG6XR.js +497 -0
- package/dist/chunk-5LDRNKX2.js +1063 -0
- package/dist/chunk-5N2FG33Q.js +25 -0
- package/dist/chunk-67MTHP2E.js +135 -0
- package/dist/chunk-6CWDTGUC.js +20 -0
- package/dist/chunk-7BHLZB3A.js +2115 -0
- package/dist/chunk-7RBKDI66.js +348 -0
- package/dist/chunk-AMFR5YA3.js +541 -0
- package/dist/chunk-BBUH4VAA.js +1224 -0
- package/dist/chunk-BYEU76JP.js +899 -0
- package/dist/chunk-CLJ5HLUD.js +458 -0
- package/dist/chunk-D5YD55AR.js +116 -0
- package/dist/chunk-DXQNI4PC.js +61 -0
- package/dist/chunk-E3NYWENM.js +1004 -0
- package/dist/chunk-GNGDQYDU.js +34688 -0
- package/dist/chunk-GOTUR54M.js +9 -0
- package/dist/chunk-HBU5MTAM.js +41 -0
- package/dist/chunk-HMYNFFY4.js +28 -0
- package/dist/chunk-JPOWPFCU.js +1010 -0
- package/dist/chunk-JWHCJDCI.js +1215 -0
- package/dist/chunk-KBR4MZZR.js +41 -0
- package/dist/chunk-KKKPTZLM.js +93 -0
- package/dist/chunk-ME6DNWIU.js +66 -0
- package/dist/chunk-NI4DEJMC.js +88 -0
- package/dist/chunk-O4EJEDHO.js +659 -0
- package/dist/chunk-PIDUD6M2.js +31 -0
- package/dist/chunk-PS4PFJQP.js +29459 -0
- package/dist/chunk-QV47YRF4.js +48 -0
- package/dist/chunk-RQDWMVRB.js +279 -0
- package/dist/chunk-TFSSEXL6.js +136 -0
- package/dist/chunk-TKHQ4DGZ.js +8290 -0
- package/dist/chunk-TPOCL34A.js +2876 -0
- package/dist/chunk-UGYAX5YI.js +565 -0
- package/dist/chunk-UHTSULZS.js +461 -0
- package/dist/chunk-UU3R62TT.js +128 -0
- package/dist/chunk-UWIJNAOB.js +3906 -0
- package/dist/chunk-VOO7NYPP.js +914 -0
- package/dist/chunk-VPAWTYLY.js +117 -0
- package/dist/chunk-WD6AJM35.js +1216 -0
- package/dist/chunk-X3BR7HWV.js +115 -0
- package/dist/chunk-X3NE4WVW.js +120 -0
- package/dist/chunk-XNISANGE.js +1395 -0
- package/dist/chunk-XV4ZJ6ZM.js +3177 -0
- package/dist/cli/index.js +236 -0
- package/dist/clio-KIQ5SNDS.js +53 -0
- package/dist/components-JVHMUBEB.js +653 -0
- package/dist/config-ZFCDBMDC.js +372 -0
- package/dist/configure-G4E3A2PG.js +27 -0
- package/dist/context-CDXTP2MP.js +293 -0
- package/dist/context-E3KIFVXI.js +185 -0
- package/dist/context-clear-3F4PLXOS.js +102 -0
- package/dist/context-index-Q7YSYTR3.js +106 -0
- package/dist/docs-YIETIWZI.js +280 -0
- package/dist/doctor-M5HJJZOL.js +61 -0
- package/dist/domains/agents/builtins/architect.md +33 -0
- package/dist/domains/agents/builtins/coder.md +31 -0
- package/dist/domains/agents/builtins/context-bootstrap.md +38 -0
- package/dist/domains/agents/builtins/debugger.md +30 -0
- package/dist/domains/agents/builtins/documenter.md +31 -0
- package/dist/domains/agents/builtins/git-master.md +30 -0
- package/dist/domains/agents/builtins/provenance.md +30 -0
- package/dist/domains/agents/builtins/researcher.md +71 -0
- package/dist/domains/agents/builtins/scout.md +42 -0
- package/dist/domains/agents/builtins/tester.md +31 -0
- package/dist/domains/agents/builtins/verifier.md +30 -0
- package/dist/domains/agents/builtins/wiki-writer.md +41 -0
- package/dist/eval-B3KZZESM.js +2674 -0
- package/dist/evidence-V67CHM35.js +233 -0
- package/dist/evolve-YDZSUQYA.js +518 -0
- package/dist/extensions-SRG7XCAH.js +207 -0
- package/dist/fleet-CA2CRTVG.js +760 -0
- package/dist/fleet-preflight-CLIAX7YR.js +21 -0
- package/dist/init-2OZDJE2D.js +227 -0
- package/dist/memory-3PIQQAKX.js +207 -0
- package/dist/models-DY35XI7Y.js +237 -0
- package/dist/paths-5OMXW7Z4.js +57 -0
- package/dist/preload-KZVHET2B.js +11 -0
- package/dist/reset-PIFYNOS3.js +216 -0
- package/dist/run-3VSPP24F.js +735 -0
- package/dist/share-D36RQCXM.js +241 -0
- package/dist/skills-F2MRLELY.js +445 -0
- package/dist/skills-eval-E2ZTW4PL.js +932 -0
- package/dist/targets-DZMEZAH4.js +977 -0
- package/dist/trace-7NYCUI2J.js +250 -0
- package/dist/uninstall-AD3JWHBB.js +322 -0
- package/dist/upgrade-WYYBKGDY.js +301 -0
- package/dist/usage-ULIDAGFF.js +755 -0
- package/dist/version-ROZ6CZKH.js +16 -0
- package/dist/wiki-generate-PKFIX6OB.js +377 -0
- package/dist/worker/entry.js +1739 -0
- package/docs/README.md +93 -0
- package/docs/acp.md +120 -0
- package/docs/alcf-provider.md +72 -0
- package/docs/architecture.md +172 -0
- package/docs/artifact-versions.md +54 -0
- package/docs/built-in-agents.md +265 -0
- package/docs/capacity-and-scheduling.md +97 -0
- package/docs/commands-and-modes.md +554 -0
- package/docs/config-knobs-audit.md +115 -0
- package/docs/configuration-and-targets.md +812 -0
- package/docs/context-engine.md +236 -0
- package/docs/dispatch-architecture-rationale.md +126 -0
- package/docs/documentation-coverage.md +46 -0
- package/docs/documentation-guide.md +166 -0
- package/docs/environment-variables.md +105 -0
- package/docs/eval-runner.md +205 -0
- package/docs/evals-internal.md +298 -0
- package/docs/evidence-and-memory.md +243 -0
- package/docs/evolution.md +143 -0
- package/docs/exit-codes-and-output.md +74 -0
- package/docs/extensions-and-sharing.md +306 -0
- package/docs/fleet-demo-runbook.md +179 -0
- package/docs/fleet-dispatch.md +591 -0
- package/docs/glossary.md +75 -0
- package/docs/html/agents_blueprint.html +936 -0
- package/docs/html/alcf_blueprint.html +324 -0
- package/docs/html/architecture_blueprint.html +850 -0
- package/docs/html/commands_blueprint.html +794 -0
- package/docs/html/config_knobs_audit_blueprint.html +178 -0
- package/docs/html/configuration_blueprint.html +1080 -0
- package/docs/html/context_blueprint.html +603 -0
- package/docs/html/documentation_blueprint.html +832 -0
- package/docs/html/environment_blueprint.html +404 -0
- package/docs/html/eval_blueprint.html +743 -0
- package/docs/html/evals_internal_blueprint.html +190 -0
- package/docs/html/evolution_blueprint.html +674 -0
- package/docs/html/extensions_blueprint.html +2065 -0
- package/docs/html/fleet_dispatch_blueprint.html +286 -0
- package/docs/html/index.html +919 -0
- package/docs/html/lifecycle_blueprint.html +723 -0
- package/docs/html/memory_blueprint.html +699 -0
- package/docs/html/middleware_blueprint.html +664 -0
- package/docs/html/models_blueprint.html +2366 -0
- package/docs/html/observability_blueprint.html +683 -0
- package/docs/html/provider_adapter_blueprint.html +245 -0
- package/docs/html/safety_blueprint.html +1386 -0
- package/docs/html/shared.css +571 -0
- package/docs/html/shared.js +143 -0
- package/docs/html/skills_blueprint.html +671 -0
- package/docs/html/soak_blueprint.html +182 -0
- package/docs/html/tool_usage_blueprint.html +350 -0
- package/docs/html/tools_blueprint.html +2249 -0
- package/docs/html/trace_blueprint.html +235 -0
- package/docs/html/tui_design_blueprint.html +314 -0
- package/docs/html/validation_blueprint.html +961 -0
- package/docs/html/worker_dispatch_blueprint.html +231 -0
- package/docs/installation-and-lifecycle.md +308 -0
- package/docs/middleware-and-components.md +148 -0
- package/docs/model-catalog.md +189 -0
- package/docs/observability.md +233 -0
- package/docs/proactive-memory.md +452 -0
- package/docs/prompt-envelope-and-tools.md +142 -0
- package/docs/provider-adapter-cookbook.md +148 -0
- package/docs/release-cut-checklist.md +138 -0
- package/docs/safety-model.md +357 -0
- package/docs/scientific-validation.md +105 -0
- package/docs/session-lifecycle.md +156 -0
- package/docs/skills-marketplace.md +46 -0
- package/docs/tool-usage.md +527 -0
- package/docs/trace-store.md +132 -0
- package/docs/troubleshooting.md +33 -0
- package/docs/tui-design.md +239 -0
- package/docs/worker-dispatch-mechanics.md +242 -0
- package/package.json +132 -0
- package/skills/README.md +408 -0
- package/skills/git/commit-crafting/SKILL.md +79 -0
- package/skills/git/commit-crafting/evals.md +92 -0
- package/skills/git/create-pr/SKILL.md +116 -0
- package/skills/git/create-pr/evals.md +114 -0
- package/skills/git/investigate-issue/SKILL.md +139 -0
- package/skills/git/investigate-issue/evals.md +94 -0
- package/skills/git/resolve-merge-conflicts/SKILL.md +96 -0
- package/skills/git/resolve-merge-conflicts/evals.md +58 -0
- package/skills/git/review-changes/SKILL.md +103 -0
- package/skills/git/review-changes/evals.md +85 -0
- package/skills/git/worktree-create/SKILL.md +92 -0
- package/skills/git/worktree-create/evals.md +97 -0
- package/skills/git/worktree-create/references/worktree-setup.md +66 -0
- package/skills/git/worktree-merge/SKILL.md +95 -0
- package/skills/git/worktree-merge/evals.md +114 -0
- package/skills/skill-marketplace.json +261 -0
- package/skills/workflow/cut-it/SKILL.md +86 -0
- package/skills/workflow/cut-it/evals.md +42 -0
- package/src/domains/agents/builtins/architect.md +33 -0
- package/src/domains/agents/builtins/coder.md +31 -0
- package/src/domains/agents/builtins/context-bootstrap.md +38 -0
- package/src/domains/agents/builtins/debugger.md +30 -0
- package/src/domains/agents/builtins/documenter.md +31 -0
- package/src/domains/agents/builtins/git-master.md +30 -0
- package/src/domains/agents/builtins/provenance.md +30 -0
- package/src/domains/agents/builtins/researcher.md +71 -0
- package/src/domains/agents/builtins/scout.md +42 -0
- package/src/domains/agents/builtins/tester.md +31 -0
- package/src/domains/agents/builtins/verifier.md +30 -0
- package/src/domains/agents/builtins/wiki-writer.md +41 -0
- package/src/domains/agents/fleets/build-review.md +34 -0
- package/src/domains/agents/fleets/build-test.md +35 -0
- package/src/domains/agents/fleets/sdlc.md +86 -0
- package/src/domains/prompts/fragments/identity/clio-worker.md +11 -0
- package/src/domains/prompts/fragments/identity/clio.md +26 -0
- package/src/domains/prompts/fragments/operating/contract.md +64 -0
- package/src/domains/prompts/fragments/safety/auto-edit.md +14 -0
- package/src/domains/prompts/fragments/safety/full-auto.md +14 -0
- package/src/domains/prompts/fragments/safety/read-only.md +13 -0
- package/src/domains/prompts/fragments/safety/suggest.md +13 -0
- package/src/domains/prompts/fragments/wiki/page.md +75 -0
- package/src/domains/prompts/fragments/wiki/plan.md +48 -0
- package/src/domains/providers/models/cloud-models/alcf.yaml +40 -0
- package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +993 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TRACE_EVENT_POLL_LIMIT,
|
|
3
|
+
TraceReader,
|
|
4
|
+
traceDatabasePath
|
|
5
|
+
} from "./chunk-E3NYWENM.js";
|
|
6
|
+
import {
|
|
7
|
+
clioStatePath
|
|
8
|
+
} from "./chunk-X3NE4WVW.js";
|
|
9
|
+
|
|
10
|
+
// src/cli/trace.ts
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { access } from "node:fs/promises";
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
+
var HELP = `Usage:
|
|
16
|
+
clio-coder trace runs [--db PATH] [--limit N]
|
|
17
|
+
clio-coder trace phases <runId> [--db PATH]
|
|
18
|
+
clio-coder trace tail <runId> [--follow] [--db PATH]
|
|
19
|
+
clio-coder trace procs <runId> [--db PATH]
|
|
20
|
+
clio-coder trace sql <SELECT query> [--db PATH]
|
|
21
|
+
clio-coder trace ui [--db PATH] [--port N] source checkout only
|
|
22
|
+
|
|
23
|
+
The viewer ships with the repository, not the npm package, so from an installed
|
|
24
|
+
Clio the subcommands above are the way in. They read the same database.
|
|
25
|
+
`;
|
|
26
|
+
function parseTraceArgs(args) {
|
|
27
|
+
const positional = [];
|
|
28
|
+
let db = traceDatabasePath(clioStatePath());
|
|
29
|
+
let dbExplicit = false;
|
|
30
|
+
let follow = false;
|
|
31
|
+
let limit = 50;
|
|
32
|
+
let port = 0;
|
|
33
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
34
|
+
const arg = args[index];
|
|
35
|
+
if (arg === "--follow") follow = true;
|
|
36
|
+
else if (arg === "--db" || arg === "--limit" || arg === "--port") {
|
|
37
|
+
const value = args[index + 1];
|
|
38
|
+
if (value === void 0) throw new Error(`${arg} requires a value`);
|
|
39
|
+
index += 1;
|
|
40
|
+
if (arg === "--db") {
|
|
41
|
+
db = resolve(value);
|
|
42
|
+
dbExplicit = true;
|
|
43
|
+
} else if (arg === "--limit") limit = parseInteger(value, "--limit", 1, 500);
|
|
44
|
+
else port = parseInteger(value, "--port", 0, 65535);
|
|
45
|
+
} else if (arg?.startsWith("--db=")) {
|
|
46
|
+
db = resolve(arg.slice(5));
|
|
47
|
+
dbExplicit = true;
|
|
48
|
+
} else if (arg?.startsWith("--limit=")) limit = parseInteger(arg.slice(8), "--limit", 1, 500);
|
|
49
|
+
else if (arg?.startsWith("--port=")) port = parseInteger(arg.slice(7), "--port", 0, 65535);
|
|
50
|
+
else if (arg?.startsWith("-")) throw new Error(`unknown trace flag: ${arg}`);
|
|
51
|
+
else if (arg !== void 0) positional.push(arg);
|
|
52
|
+
}
|
|
53
|
+
return { positional, db, dbExplicit, follow, limit, port };
|
|
54
|
+
}
|
|
55
|
+
async function runTraceCommand(args) {
|
|
56
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
57
|
+
process.stdout.write(HELP);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
let parsed;
|
|
61
|
+
try {
|
|
62
|
+
parsed = parseTraceArgs(args);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
65
|
+
${HELP}`);
|
|
66
|
+
return 2;
|
|
67
|
+
}
|
|
68
|
+
const [command, runId] = parsed.positional;
|
|
69
|
+
if (!command || command === "help") {
|
|
70
|
+
process.stdout.write(HELP);
|
|
71
|
+
return command === "help" ? 0 : 2;
|
|
72
|
+
}
|
|
73
|
+
if (command === "ui") return runTraceUi(parsed.db, parsed.port);
|
|
74
|
+
if (!existsSync(parsed.db)) return missingDatabase(parsed);
|
|
75
|
+
let reader;
|
|
76
|
+
try {
|
|
77
|
+
reader = new TraceReader(parsed.db);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
process.stderr.write(`trace database: ${error instanceof Error ? error.message : String(error)}
|
|
80
|
+
`);
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
switch (command) {
|
|
85
|
+
case "runs":
|
|
86
|
+
printRuns(reader.runs(parsed.limit));
|
|
87
|
+
return 0;
|
|
88
|
+
case "phases":
|
|
89
|
+
if (!runId) return missingRunId(command);
|
|
90
|
+
printPhases(reader.phases(runId));
|
|
91
|
+
return 0;
|
|
92
|
+
case "tail":
|
|
93
|
+
if (!runId) return missingRunId(command);
|
|
94
|
+
await tail(reader, runId, parsed.follow);
|
|
95
|
+
return 0;
|
|
96
|
+
case "procs":
|
|
97
|
+
if (!runId) return missingRunId(command);
|
|
98
|
+
printProcesses(reader.processes(runId));
|
|
99
|
+
return 0;
|
|
100
|
+
case "sql": {
|
|
101
|
+
const query = parsed.positional.slice(1).join(" ");
|
|
102
|
+
if (!query) {
|
|
103
|
+
process.stderr.write("trace sql requires a SELECT query\n");
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
process.stdout.write(`${JSON.stringify(reader.select(query), jsonBigInt, 2)}
|
|
107
|
+
`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
default:
|
|
111
|
+
process.stderr.write(`unknown trace command: ${command}
|
|
112
|
+
${HELP}`);
|
|
113
|
+
return 2;
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
117
|
+
`);
|
|
118
|
+
return 1;
|
|
119
|
+
} finally {
|
|
120
|
+
reader.close();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function tail(reader, runId, follow) {
|
|
124
|
+
let cursor = 0;
|
|
125
|
+
let idleTerminalPolls = 0;
|
|
126
|
+
for (; ; ) {
|
|
127
|
+
const rows = reader.events(runId, cursor, TRACE_EVENT_POLL_LIMIT);
|
|
128
|
+
for (const row of rows) {
|
|
129
|
+
process.stdout.write(`${formatEvent(row)}
|
|
130
|
+
`);
|
|
131
|
+
cursor = Math.max(cursor, row.rowid);
|
|
132
|
+
}
|
|
133
|
+
if (!follow) return;
|
|
134
|
+
const status = reader.run(runId)?.status;
|
|
135
|
+
idleTerminalPolls = rows.length === 0 && status !== "queued" && status !== "running" ? idleTerminalPolls + 1 : 0;
|
|
136
|
+
if (idleTerminalPolls >= 2) return;
|
|
137
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 500));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function formatEvent(row) {
|
|
141
|
+
const duration = row.ended_at === null ? "" : ` ${Math.max(0, Date.parse(row.ended_at) - Date.parse(row.started_at))}ms`;
|
|
142
|
+
return `${row.rowid.toString().padStart(6)} ${row.started_at} ${row.type.padEnd(18)} ${row.name}${duration}`;
|
|
143
|
+
}
|
|
144
|
+
function printRuns(rows) {
|
|
145
|
+
process.stdout.write("STATUS STARTED TOKENS COST RUN\n");
|
|
146
|
+
for (const row of rows) {
|
|
147
|
+
process.stdout.write(
|
|
148
|
+
`${row.status.padEnd(8)} ${row.started_at.padEnd(28)} ${formatNumber(row.total_tokens).padStart(8)} ${formatCost(row.total_cost_usd).padStart(10)} ${row.run_id}
|
|
149
|
+
`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function printPhases(rows) {
|
|
154
|
+
process.stdout.write("STATUS TRY OWNER TOKENS COST PHASE\n");
|
|
155
|
+
for (const row of rows) {
|
|
156
|
+
process.stdout.write(
|
|
157
|
+
`${row.status.padEnd(8)} ${String(row.attempt + 1).padStart(3)} ${row.owner.slice(0, 18).padEnd(18)} ${formatNumber(row.total_tokens).padStart(8)} ${formatCost(row.total_cost_usd).padStart(10)} ${row.name}
|
|
158
|
+
`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function printProcesses(rows) {
|
|
163
|
+
process.stdout.write("STATE PID KIND NAME COMMAND\n");
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
process.stdout.write(
|
|
166
|
+
`${(row.ended_at === null ? "live" : "ended").padEnd(6)} ${String(row.pid).padEnd(8)} ${row.kind.padEnd(12)} ${row.name.slice(0, 20).padEnd(20)} ${row.command}
|
|
167
|
+
`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function runTraceUi(db, port) {
|
|
172
|
+
const candidates = [
|
|
173
|
+
fileURLToPath(new URL("../apps/trace-viewer/server.mjs", import.meta.url)),
|
|
174
|
+
fileURLToPath(new URL("../../apps/trace-viewer/server.mjs", import.meta.url))
|
|
175
|
+
];
|
|
176
|
+
const entry = await firstExisting(candidates);
|
|
177
|
+
if (entry === null) {
|
|
178
|
+
process.stderr.write(
|
|
179
|
+
`trace viewer is available only from a source checkout; apps/trace-viewer/server.mjs was not found
|
|
180
|
+
the npm package does not carry the viewer, so an installed clio cannot start it
|
|
181
|
+
the same run is readable here: clio-coder trace runs --db ${db}
|
|
182
|
+
from a checkout of the repository: npm run trace:ui
|
|
183
|
+
`
|
|
184
|
+
);
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
const module = await import(pathToFileURL(entry).href);
|
|
188
|
+
const server = await module.startTraceViewer({ db, port });
|
|
189
|
+
process.stdout.write(`Trace viewer: ${server.url}
|
|
190
|
+
`);
|
|
191
|
+
await new Promise((resolveStop) => {
|
|
192
|
+
const stop = () => {
|
|
193
|
+
process.off("SIGINT", stop);
|
|
194
|
+
process.off("SIGTERM", stop);
|
|
195
|
+
void server.close().finally(resolveStop);
|
|
196
|
+
};
|
|
197
|
+
process.on("SIGINT", stop);
|
|
198
|
+
process.on("SIGTERM", stop);
|
|
199
|
+
});
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
async function firstExisting(paths) {
|
|
203
|
+
for (const path of paths) {
|
|
204
|
+
try {
|
|
205
|
+
await access(path);
|
|
206
|
+
return path;
|
|
207
|
+
} catch {
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
function parseInteger(value, flag, min, max) {
|
|
213
|
+
const parsed = Number(value);
|
|
214
|
+
if (!Number.isInteger(parsed) || parsed < min || parsed > max)
|
|
215
|
+
throw new Error(`${flag} must be an integer in [${min}, ${max}]`);
|
|
216
|
+
return parsed;
|
|
217
|
+
}
|
|
218
|
+
function missingDatabase(parsed) {
|
|
219
|
+
if (parsed.dbExplicit) {
|
|
220
|
+
process.stderr.write(
|
|
221
|
+
`trace database not found: ${parsed.db}
|
|
222
|
+
--db named this path. omit it to read the default at ${traceDatabasePath(clioStatePath())}
|
|
223
|
+
`
|
|
224
|
+
);
|
|
225
|
+
return 1;
|
|
226
|
+
}
|
|
227
|
+
process.stdout.write(
|
|
228
|
+
`no trace database yet at ${parsed.db}. rows are recorded when a dispatch executes or an interactive turn runs; run \`clio-coder run "<task>"\` or start a session to create one.
|
|
229
|
+
`
|
|
230
|
+
);
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
function missingRunId(command) {
|
|
234
|
+
process.stderr.write(`trace ${command} requires a run id
|
|
235
|
+
`);
|
|
236
|
+
return 2;
|
|
237
|
+
}
|
|
238
|
+
function formatNumber(value) {
|
|
239
|
+
return value === null ? "\u2014" : value.toLocaleString("en-US");
|
|
240
|
+
}
|
|
241
|
+
function formatCost(value) {
|
|
242
|
+
return value === null ? "\u2014" : `$${value.toFixed(value < 0.01 ? 4 : 2)}`;
|
|
243
|
+
}
|
|
244
|
+
function jsonBigInt(_key, value) {
|
|
245
|
+
return typeof value === "bigint" ? value.toString() : value;
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
runTraceCommand
|
|
249
|
+
};
|
|
250
|
+
//# sourceMappingURL=trace-7NYCUI2J.js.map
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removePath,
|
|
3
|
+
reportRemovalFailures
|
|
4
|
+
} from "./chunk-HBU5MTAM.js";
|
|
5
|
+
import "./chunk-PIDUD6M2.js";
|
|
6
|
+
import {
|
|
7
|
+
printError,
|
|
8
|
+
printHeader,
|
|
9
|
+
printOk
|
|
10
|
+
} from "./chunk-67MTHP2E.js";
|
|
11
|
+
import "./chunk-5LDRNKX2.js";
|
|
12
|
+
import "./chunk-VPAWTYLY.js";
|
|
13
|
+
import {
|
|
14
|
+
resetXdgCache,
|
|
15
|
+
resolveClioDirs
|
|
16
|
+
} from "./chunk-X3NE4WVW.js";
|
|
17
|
+
import {
|
|
18
|
+
resolvePackageRoot
|
|
19
|
+
} from "./chunk-DXQNI4PC.js";
|
|
20
|
+
|
|
21
|
+
// src/cli/uninstall.ts
|
|
22
|
+
import { spawnSync } from "node:child_process";
|
|
23
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync, realpathSync } from "node:fs";
|
|
24
|
+
import { homedir } from "node:os";
|
|
25
|
+
import { delimiter, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
26
|
+
var HELP = `clio-coder uninstall [--remove-binary] [--dry-run] [--force]
|
|
27
|
+
|
|
28
|
+
Remove all Clio Coder state: the config, data, state, and cache roots.
|
|
29
|
+
|
|
30
|
+
Per-project \`.clio-coder/\` directories are outside those roots and are never removed
|
|
31
|
+
here. Every project Clio has run in is recorded in the session metadata, so both
|
|
32
|
+
the real run and --dry-run list them and name the command that clears one,
|
|
33
|
+
before the launcher is touched.
|
|
34
|
+
|
|
35
|
+
Flags:
|
|
36
|
+
--remove-binary also remove the launcher symlink when it points at this
|
|
37
|
+
installation. A real file, or a link into a different clio-coder
|
|
38
|
+
installation, is kept and reported.
|
|
39
|
+
--dry-run print what would be removed without changing anything
|
|
40
|
+
--force required for destructive execution
|
|
41
|
+
`;
|
|
42
|
+
function parseUninstallArgs(argv) {
|
|
43
|
+
const parsed = {
|
|
44
|
+
removeBinary: false,
|
|
45
|
+
force: false,
|
|
46
|
+
dryRun: false,
|
|
47
|
+
help: false
|
|
48
|
+
};
|
|
49
|
+
for (const arg of argv) {
|
|
50
|
+
switch (arg) {
|
|
51
|
+
case "--remove-binary":
|
|
52
|
+
parsed.removeBinary = true;
|
|
53
|
+
break;
|
|
54
|
+
case "--force":
|
|
55
|
+
case "-f":
|
|
56
|
+
parsed.force = true;
|
|
57
|
+
break;
|
|
58
|
+
case "--dry-run":
|
|
59
|
+
parsed.dryRun = true;
|
|
60
|
+
break;
|
|
61
|
+
case "--help":
|
|
62
|
+
case "-h":
|
|
63
|
+
parsed.help = true;
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`unknown flag: ${arg}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
function report(label, path) {
|
|
72
|
+
process.stdout.write(` ${label.padEnd(8)} remove ${path}${existsSync(path) ? "" : " (absent)"}
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
function projectContextInventory(stateDir) {
|
|
76
|
+
const root = join(stateDir, "sessions");
|
|
77
|
+
let hashes;
|
|
78
|
+
try {
|
|
79
|
+
hashes = readdirSync(root);
|
|
80
|
+
} catch {
|
|
81
|
+
return { recorded: 0, dirs: [], storeAbsent: true };
|
|
82
|
+
}
|
|
83
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
84
|
+
let recorded = 0;
|
|
85
|
+
for (const hash of hashes.sort()) {
|
|
86
|
+
const cwd = firstRecordedCwd(join(root, hash));
|
|
87
|
+
if (cwd === null) continue;
|
|
88
|
+
recorded += 1;
|
|
89
|
+
if (existsSync(join(cwd, ".clio-coder"))) dirs.add(cwd);
|
|
90
|
+
}
|
|
91
|
+
return { recorded, dirs: [...dirs].sort(), storeAbsent: false };
|
|
92
|
+
}
|
|
93
|
+
function firstRecordedCwd(hashDir) {
|
|
94
|
+
let sessions;
|
|
95
|
+
try {
|
|
96
|
+
sessions = readdirSync(hashDir);
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
for (const session of sessions.sort()) {
|
|
101
|
+
try {
|
|
102
|
+
const meta = JSON.parse(readFileSync(join(hashDir, session, "meta.json"), "utf8"));
|
|
103
|
+
if (typeof meta.cwd === "string" && meta.cwd.length > 0) return meta.cwd;
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function reportProjectContext(inventory, removeBinary) {
|
|
110
|
+
process.stdout.write("\nPer-project context (not removed by uninstall):\n");
|
|
111
|
+
if (inventory.storeAbsent) {
|
|
112
|
+
process.stdout.write(" no session store to read; any .clio-coder/ directories must be found by hand\n");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (inventory.dirs.length === 0) {
|
|
116
|
+
process.stdout.write(
|
|
117
|
+
` none: ${inventory.recorded} project director${inventory.recorded === 1 ? "y" : "ies"} recorded, none still has a .clio-coder/
|
|
118
|
+
`
|
|
119
|
+
);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const dir of inventory.dirs) process.stdout.write(` ${join(dir, ".clio-coder")}
|
|
123
|
+
`);
|
|
124
|
+
process.stdout.write(
|
|
125
|
+
removeBinary ? "\nThis run also removes the launcher. Clear each one from inside it first, then re-run:\n" : "\nClear each one from inside it, while clio still runs:\n"
|
|
126
|
+
);
|
|
127
|
+
process.stdout.write(" clio-coder context reset --all\n\n");
|
|
128
|
+
}
|
|
129
|
+
function launcherLinkPath() {
|
|
130
|
+
const binDir = process.env.CLIO_CODER_BIN_DIR?.trim() || join(homedir(), ".local", "bin");
|
|
131
|
+
return join(binDir, "clio-coder");
|
|
132
|
+
}
|
|
133
|
+
function ownedCliEntry() {
|
|
134
|
+
const entry = join(resolvePackageRoot(), "dist", "cli", "index.js");
|
|
135
|
+
try {
|
|
136
|
+
return realpathSync(entry);
|
|
137
|
+
} catch {
|
|
138
|
+
return entry;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function classifyLauncher(linkPath) {
|
|
142
|
+
let isSymlink;
|
|
143
|
+
try {
|
|
144
|
+
isSymlink = lstatSync(linkPath).isSymbolicLink();
|
|
145
|
+
} catch {
|
|
146
|
+
return { kind: "absent" };
|
|
147
|
+
}
|
|
148
|
+
if (!isSymlink) {
|
|
149
|
+
return { kind: "keep", detail: "not a symlink; remove it via your package manager" };
|
|
150
|
+
}
|
|
151
|
+
const owned = ownedCliEntry();
|
|
152
|
+
let resolved = null;
|
|
153
|
+
try {
|
|
154
|
+
resolved = realpathSync(linkPath);
|
|
155
|
+
} catch {
|
|
156
|
+
resolved = null;
|
|
157
|
+
}
|
|
158
|
+
if (resolved !== null) {
|
|
159
|
+
if (resolved === owned) return { kind: "remove", detail: `-> ${resolved}` };
|
|
160
|
+
return {
|
|
161
|
+
kind: "keep",
|
|
162
|
+
detail: `points at ${resolved}, not this installation (${owned}); remove it with \`rm ${linkPath}\``
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const raw = readlinkSync(linkPath);
|
|
166
|
+
const danglingTarget = isAbsolute(raw) ? raw : resolve(dirname(linkPath), raw);
|
|
167
|
+
if (danglingTarget.endsWith(join(sep, "dist", "cli", "index.js"))) {
|
|
168
|
+
return { kind: "remove", detail: `-> ${danglingTarget} (dangling; that installation is already gone)` };
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
kind: "keep",
|
|
172
|
+
detail: `dangling link to ${danglingTarget}, which is not a clio entry; remove it with \`rm ${linkPath}\``
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function removeLauncher(dryRun) {
|
|
176
|
+
const linkPath = launcherLinkPath();
|
|
177
|
+
const verdict = classifyLauncher(linkPath);
|
|
178
|
+
if (verdict.kind === "absent") {
|
|
179
|
+
process.stdout.write(` binary absent ${linkPath}
|
|
180
|
+
`);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (verdict.kind === "keep") {
|
|
184
|
+
process.stdout.write(` binary keep ${linkPath} (${verdict.detail})
|
|
185
|
+
`);
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
process.stdout.write(` binary remove ${linkPath} ${verdict.detail}
|
|
189
|
+
`);
|
|
190
|
+
return removePath("binary", linkPath, dryRun);
|
|
191
|
+
}
|
|
192
|
+
function findClioOnPath() {
|
|
193
|
+
const names = process.platform === "win32" ? ["clio-coder.cmd", "clio-coder.ps1", "clio-coder.exe", "clio-coder"] : ["clio-coder"];
|
|
194
|
+
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
195
|
+
if (!dir) continue;
|
|
196
|
+
for (const name of names) {
|
|
197
|
+
const candidate = join(dir, name);
|
|
198
|
+
if (existsSync(candidate)) return candidate;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
function readNpmPrefix() {
|
|
204
|
+
try {
|
|
205
|
+
const result = spawnSync("npm", ["config", "get", "prefix"], {
|
|
206
|
+
encoding: "utf8",
|
|
207
|
+
timeout: 5e3,
|
|
208
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
209
|
+
// A read-only probe that writes. npm drops a debug log into
|
|
210
|
+
// $HOME/.npm/_logs on every invocation, so the documented
|
|
211
|
+
// side-effect-free `--dry-run` path left a file behind in the home
|
|
212
|
+
// directory it had just finished promising not to touch. `logs-max=0`
|
|
213
|
+
// keeps npm from retaining any; the notifier is off for the same reason.
|
|
214
|
+
env: { ...process.env, npm_config_logs_max: "0", npm_config_update_notifier: "false" }
|
|
215
|
+
});
|
|
216
|
+
if (result.status !== 0) return null;
|
|
217
|
+
const prefix = result.stdout.trim();
|
|
218
|
+
return prefix.length > 0 ? prefix : null;
|
|
219
|
+
} catch {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function otherClioOnPath(pathClio, localLink) {
|
|
224
|
+
if (pathClio === null) return null;
|
|
225
|
+
if (pathClio === localLink) return null;
|
|
226
|
+
const resolve2 = (path) => {
|
|
227
|
+
try {
|
|
228
|
+
return realpathSync(path);
|
|
229
|
+
} catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const resolvedPathClio = resolve2(pathClio);
|
|
234
|
+
if (resolvedPathClio !== null && resolvedPathClio === resolve2(localLink)) return null;
|
|
235
|
+
return pathClio;
|
|
236
|
+
}
|
|
237
|
+
function printRemovalGuidance(removeBinaryRequested) {
|
|
238
|
+
const pathClio = findClioOnPath();
|
|
239
|
+
const npmPrefix = readNpmPrefix();
|
|
240
|
+
const localLink = launcherLinkPath();
|
|
241
|
+
const currentLauncher = process.argv[1];
|
|
242
|
+
process.stdout.write("\nBinary removal guidance:\n");
|
|
243
|
+
if (currentLauncher) process.stdout.write(` current launcher: ${currentLauncher}
|
|
244
|
+
`);
|
|
245
|
+
process.stdout.write(` PATH lookup: ${pathClio ?? "not currently found"}
|
|
246
|
+
`);
|
|
247
|
+
if (npmPrefix) process.stdout.write(` npm prefix bin: ${join(npmPrefix, "bin")}
|
|
248
|
+
`);
|
|
249
|
+
process.stdout.write(` local source bin: ${localLink}${existsSync(localLink) ? "" : " (absent)"}
|
|
250
|
+
`);
|
|
251
|
+
const survivor = otherClioOnPath(pathClio, localLink);
|
|
252
|
+
if (survivor !== null) {
|
|
253
|
+
process.stdout.write(`
|
|
254
|
+
another clio-coder remains on your PATH at ${survivor}
|
|
255
|
+
`);
|
|
256
|
+
process.stdout.write(" it is a different installation from the one this uninstall touched\n");
|
|
257
|
+
process.stdout.write(` check it with: ${survivor} --version
|
|
258
|
+
`);
|
|
259
|
+
}
|
|
260
|
+
process.stdout.write("\nUse the removal path that matches how you installed Clio Coder:\n");
|
|
261
|
+
if (!removeBinaryRequested) {
|
|
262
|
+
process.stdout.write(" source symlink: clio-coder uninstall --remove-binary --force\n");
|
|
263
|
+
}
|
|
264
|
+
process.stdout.write(" npm global: npm uninstall -g @iowarp/clio-coder\n");
|
|
265
|
+
process.stdout.write(" npm link: npm unlink -g @iowarp/clio-coder\n");
|
|
266
|
+
process.stdout.write("\nAfter removing or replacing a clio-coder link, clear shell command caches:\n");
|
|
267
|
+
process.stdout.write(" hash -r # Bash\n");
|
|
268
|
+
process.stdout.write(" rehash # Zsh\n");
|
|
269
|
+
}
|
|
270
|
+
function runUninstallCommand(argv) {
|
|
271
|
+
let args;
|
|
272
|
+
try {
|
|
273
|
+
args = parseUninstallArgs(argv);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
276
|
+
process.stdout.write(HELP);
|
|
277
|
+
return 2;
|
|
278
|
+
}
|
|
279
|
+
if (args.help) {
|
|
280
|
+
process.stdout.write(HELP);
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
if (!args.dryRun && !args.force) {
|
|
284
|
+
printError("`clio-coder uninstall` requires --force unless you are using --dry-run");
|
|
285
|
+
process.stdout.write(HELP);
|
|
286
|
+
return 2;
|
|
287
|
+
}
|
|
288
|
+
const dirs = resolveClioDirs();
|
|
289
|
+
printHeader("Clio Coder uninstall");
|
|
290
|
+
const roots = [
|
|
291
|
+
["config", dirs.config],
|
|
292
|
+
["data", dirs.data],
|
|
293
|
+
["state", dirs.state],
|
|
294
|
+
["cache", dirs.cache]
|
|
295
|
+
];
|
|
296
|
+
for (const [label, path] of roots) report(label, path);
|
|
297
|
+
reportProjectContext(projectContextInventory(dirs.state), args.removeBinary);
|
|
298
|
+
const failures = [];
|
|
299
|
+
for (const [label, path] of roots) {
|
|
300
|
+
const failure = removePath(label, path, args.dryRun);
|
|
301
|
+
if (failure) failures.push(failure);
|
|
302
|
+
}
|
|
303
|
+
if (args.removeBinary) {
|
|
304
|
+
const failure = removeLauncher(args.dryRun);
|
|
305
|
+
if (failure) failures.push(failure);
|
|
306
|
+
}
|
|
307
|
+
resetXdgCache();
|
|
308
|
+
if (failures.length > 0) {
|
|
309
|
+
printError("uninstall did not remove everything");
|
|
310
|
+
reportRemovalFailures(`clio-coder uninstall${args.removeBinary ? " --remove-binary" : ""} --force`, failures);
|
|
311
|
+
return 1;
|
|
312
|
+
}
|
|
313
|
+
printOk(args.dryRun ? "uninstall preview complete" : "removed Clio Coder state");
|
|
314
|
+
printRemovalGuidance(args.removeBinary);
|
|
315
|
+
return 0;
|
|
316
|
+
}
|
|
317
|
+
export {
|
|
318
|
+
otherClioOnPath,
|
|
319
|
+
projectContextInventory,
|
|
320
|
+
runUninstallCommand
|
|
321
|
+
};
|
|
322
|
+
//# sourceMappingURL=uninstall-AD3JWHBB.js.map
|