@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,48 @@
|
|
|
1
|
+
// src/core/tool-names.ts
|
|
2
|
+
var ToolNames = {
|
|
3
|
+
// OBSERVE
|
|
4
|
+
Read: "read",
|
|
5
|
+
Grep: "grep",
|
|
6
|
+
Find: "find",
|
|
7
|
+
Ls: "ls",
|
|
8
|
+
CodeNav: "code_nav",
|
|
9
|
+
Context: "context",
|
|
10
|
+
CredentialPresent: "credential_present",
|
|
11
|
+
// MUTATE
|
|
12
|
+
Write: "write",
|
|
13
|
+
Edit: "edit",
|
|
14
|
+
// EXECUTE
|
|
15
|
+
Bash: "bash",
|
|
16
|
+
Git: "git",
|
|
17
|
+
Verify: "verify",
|
|
18
|
+
// ORCHESTRATE
|
|
19
|
+
Dispatch: "dispatch",
|
|
20
|
+
Monitor: "monitor",
|
|
21
|
+
Steer: "steer",
|
|
22
|
+
Tasks: "tasks",
|
|
23
|
+
Ledger: "ledger",
|
|
24
|
+
// RETRIEVE
|
|
25
|
+
WebFetch: "web_fetch",
|
|
26
|
+
// INTERACT
|
|
27
|
+
AskUser: "ask_user",
|
|
28
|
+
// ARTIFACT
|
|
29
|
+
Artifact: "artifact"
|
|
30
|
+
// DESIGN-RESERVED, not implemented: gateway, the MCP/DB proxy. One fixed
|
|
31
|
+
// schema; external capabilities are surfaced through find/describe/call
|
|
32
|
+
// RESULTS, never as per-capability schemas in the prompt prefix. Contract
|
|
33
|
+
// sketch: gateway(op: "find" | "describe" | "call", capability?, args?)
|
|
34
|
+
// -> JSON capability listings / schemas / call results, network action
|
|
35
|
+
// class, sequential. Reserving the name here keeps classifiers and
|
|
36
|
+
// profiles from ever assigning "gateway" to a dynamic tool.
|
|
37
|
+
// Gateway: "gateway",
|
|
38
|
+
};
|
|
39
|
+
var ALL_TOOL_NAMES = Object.values(ToolNames);
|
|
40
|
+
function isBuiltinToolName(name) {
|
|
41
|
+
return ALL_TOOL_NAMES.includes(name);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
ToolNames,
|
|
46
|
+
isBuiltinToolName
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-QV47YRF4.js.map
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WORKSPACE_EXCLUDED_DIRS,
|
|
3
|
+
createSlicer,
|
|
4
|
+
enumerateWorkspaceFiles,
|
|
5
|
+
enumerateWorkspaceFilesAsync,
|
|
6
|
+
isIndexablePath,
|
|
7
|
+
readCodewiki,
|
|
8
|
+
readCodewikiAsync
|
|
9
|
+
} from "./chunk-TPOCL34A.js";
|
|
10
|
+
import {
|
|
11
|
+
safeResourceWrite
|
|
12
|
+
} from "./chunk-VPAWTYLY.js";
|
|
13
|
+
|
|
14
|
+
// src/domains/context/fingerprint.ts
|
|
15
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { readFileSync, statSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { promisify } from "node:util";
|
|
20
|
+
var execFileAsync = promisify(execFile);
|
|
21
|
+
var DEFAULT_FINGERPRINT_CACHE_TTL_MS = 5e3;
|
|
22
|
+
var cachedFingerprints = /* @__PURE__ */ new Map();
|
|
23
|
+
var LOC_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
24
|
+
".ts",
|
|
25
|
+
".tsx",
|
|
26
|
+
".js",
|
|
27
|
+
".mjs",
|
|
28
|
+
".cjs",
|
|
29
|
+
".py",
|
|
30
|
+
".rs",
|
|
31
|
+
".go",
|
|
32
|
+
".cc",
|
|
33
|
+
".cpp",
|
|
34
|
+
".cxx",
|
|
35
|
+
".hpp",
|
|
36
|
+
".hh",
|
|
37
|
+
".hxx",
|
|
38
|
+
".c",
|
|
39
|
+
".h",
|
|
40
|
+
".cu",
|
|
41
|
+
".cuh",
|
|
42
|
+
".java",
|
|
43
|
+
".kt"
|
|
44
|
+
]);
|
|
45
|
+
function extensionOf(name) {
|
|
46
|
+
const index = name.lastIndexOf(".");
|
|
47
|
+
return index === -1 ? "" : name.slice(index);
|
|
48
|
+
}
|
|
49
|
+
function currentGitHead(cwd) {
|
|
50
|
+
try {
|
|
51
|
+
return execFileSync("git", ["rev-parse", "--verify", "HEAD"], {
|
|
52
|
+
cwd,
|
|
53
|
+
encoding: "utf8",
|
|
54
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
55
|
+
}).trim();
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function currentGitHeadAsync(cwd) {
|
|
61
|
+
try {
|
|
62
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "--verify", "HEAD"], { cwd, encoding: "utf8" });
|
|
63
|
+
return stdout.trim();
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function countLines(filePath) {
|
|
69
|
+
try {
|
|
70
|
+
const text = readFileSync(filePath, "utf8");
|
|
71
|
+
if (text.length === 0) return 0;
|
|
72
|
+
let lines = 1;
|
|
73
|
+
for (const ch of text) {
|
|
74
|
+
if (ch === "\n") lines += 1;
|
|
75
|
+
}
|
|
76
|
+
return lines;
|
|
77
|
+
} catch {
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function locFromCodewiki(codewiki) {
|
|
82
|
+
if (!codewiki) return null;
|
|
83
|
+
return codewiki.files.reduce((sum, file) => file.lang === "config" ? sum : sum + file.loc, 0);
|
|
84
|
+
}
|
|
85
|
+
function accumulateFile(cwd, relPath, hash, artifactLoc) {
|
|
86
|
+
const absPath = join(cwd, relPath);
|
|
87
|
+
let stat;
|
|
88
|
+
try {
|
|
89
|
+
stat = statSync(absPath);
|
|
90
|
+
} catch {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
hash.update(`${relPath}:${stat.size}:${Math.floor(stat.mtimeMs)}
|
|
94
|
+
`);
|
|
95
|
+
if (artifactLoc === null && LOC_EXTENSIONS.has(extensionOf(relPath))) return countLines(absPath);
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
function computeFingerprint(cwd, codewiki = readCodewiki(cwd)) {
|
|
99
|
+
const files = enumerateWorkspaceFiles(cwd, WORKSPACE_EXCLUDED_DIRS).filter(isIndexablePath);
|
|
100
|
+
const hash = createHash("sha256");
|
|
101
|
+
const artifactLoc = locFromCodewiki(codewiki);
|
|
102
|
+
let loc = 0;
|
|
103
|
+
for (const relPath of files) loc += accumulateFile(cwd, relPath, hash, artifactLoc);
|
|
104
|
+
return {
|
|
105
|
+
treeHash: hash.digest("hex"),
|
|
106
|
+
gitHead: currentGitHead(cwd),
|
|
107
|
+
loc: artifactLoc ?? loc
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function computeFingerprintAsync(cwd, codewiki = void 0, options = {}) {
|
|
111
|
+
const slicer = options.slicer ?? createSlicer();
|
|
112
|
+
const artifact = codewiki === void 0 ? await readCodewikiAsync(cwd) : codewiki;
|
|
113
|
+
await slicer.tick();
|
|
114
|
+
const files = (await enumerateWorkspaceFilesAsync(cwd, WORKSPACE_EXCLUDED_DIRS, void 0, slicer)).filter(isIndexablePath);
|
|
115
|
+
const hash = createHash("sha256");
|
|
116
|
+
const artifactLoc = locFromCodewiki(artifact);
|
|
117
|
+
let loc = 0;
|
|
118
|
+
for (const relPath of files) {
|
|
119
|
+
await slicer.tick();
|
|
120
|
+
loc += accumulateFile(cwd, relPath, hash, artifactLoc);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
treeHash: hash.digest("hex"),
|
|
124
|
+
gitHead: await currentGitHeadAsync(cwd),
|
|
125
|
+
loc: artifactLoc ?? loc
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function computeFingerprintCached(cwd, codewiki = readCodewiki(cwd), options = {}) {
|
|
129
|
+
const now = Date.now();
|
|
130
|
+
const cached = cachedFingerprints.get(cwd);
|
|
131
|
+
if (cached && cached.expiresAtMs > now) return cached.fingerprint;
|
|
132
|
+
const fingerprint = computeFingerprint(cwd, codewiki);
|
|
133
|
+
const ttlMs = options.ttlMs ?? DEFAULT_FINGERPRINT_CACHE_TTL_MS;
|
|
134
|
+
cachedFingerprints.set(cwd, {
|
|
135
|
+
fingerprint,
|
|
136
|
+
expiresAtMs: Date.now() + Math.max(0, ttlMs)
|
|
137
|
+
});
|
|
138
|
+
return fingerprint;
|
|
139
|
+
}
|
|
140
|
+
function isStale(prev, curr) {
|
|
141
|
+
return prev.treeHash !== curr.treeHash;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/domains/context/state.ts
|
|
145
|
+
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
146
|
+
import { join as join2 } from "node:path";
|
|
147
|
+
var LEGACY_BOOTSTRAP_GENERATION_MODE = "scout";
|
|
148
|
+
var STATE_RELATIVE_PATH = ".clio-coder/state.json";
|
|
149
|
+
var BOOTSTRAP_GENERATION_MODES = /* @__PURE__ */ new Set(["model", "heuristic", "existing"]);
|
|
150
|
+
var BOOTSTRAP_PARSER_OUTCOMES = /* @__PURE__ */ new Set(["parsed", "rejected", "not-run"]);
|
|
151
|
+
var BOOTSTRAP_FALLBACK_REASON_MAX_LENGTH = 4096;
|
|
152
|
+
var BOOTSTRAP_GENERATION_KEYS = /* @__PURE__ */ new Set([
|
|
153
|
+
"mode",
|
|
154
|
+
"parserOutcome",
|
|
155
|
+
"fallbackReason",
|
|
156
|
+
"structuredOutputMode",
|
|
157
|
+
"runId",
|
|
158
|
+
"targetId",
|
|
159
|
+
"wireModelId",
|
|
160
|
+
"runtimeId",
|
|
161
|
+
"runtimeKind",
|
|
162
|
+
"thinkingLevel",
|
|
163
|
+
"tokenCount",
|
|
164
|
+
"toolCalls",
|
|
165
|
+
"durationMs",
|
|
166
|
+
"promptBytes",
|
|
167
|
+
"outputBytes"
|
|
168
|
+
]);
|
|
169
|
+
var BOOTSTRAP_ID_KEYS = ["runId", "targetId", "wireModelId", "runtimeId", "runtimeKind", "thinkingLevel"];
|
|
170
|
+
var BOOTSTRAP_COUNTER_KEYS = ["tokenCount", "toolCalls", "durationMs", "promptBytes", "outputBytes"];
|
|
171
|
+
function isBoundedNonemptyString(value, maxLength) {
|
|
172
|
+
return typeof value === "string" && value.trim().length > 0 && value.length <= maxLength;
|
|
173
|
+
}
|
|
174
|
+
function isNonemptyString(value) {
|
|
175
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
176
|
+
}
|
|
177
|
+
function isBootstrapGenerationState(value) {
|
|
178
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
179
|
+
const obj = value;
|
|
180
|
+
if (!Object.keys(obj).every((key) => BOOTSTRAP_GENERATION_KEYS.has(key))) return false;
|
|
181
|
+
if (typeof obj.mode !== "string" || !BOOTSTRAP_GENERATION_MODES.has(obj.mode)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
if (typeof obj.parserOutcome !== "string" || !BOOTSTRAP_PARSER_OUTCOMES.has(obj.parserOutcome)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
if (obj.fallbackReason !== void 0 && !isBoundedNonemptyString(obj.fallbackReason, BOOTSTRAP_FALLBACK_REASON_MAX_LENGTH)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (obj.structuredOutputMode !== void 0 && obj.structuredOutputMode !== "native-schema" && obj.structuredOutputMode !== "prompt-parser") {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
for (const key of BOOTSTRAP_ID_KEYS) {
|
|
194
|
+
if (obj[key] !== void 0 && !isNonemptyString(obj[key])) return false;
|
|
195
|
+
}
|
|
196
|
+
for (const key of BOOTSTRAP_COUNTER_KEYS) {
|
|
197
|
+
if (obj[key] !== void 0 && (!Number.isSafeInteger(obj[key]) || obj[key] < 0)) return false;
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
function isFingerprint(value) {
|
|
202
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
203
|
+
const obj = value;
|
|
204
|
+
return typeof obj.treeHash === "string" && /^[0-9a-f]{64}$/.test(obj.treeHash) && (typeof obj.gitHead === "string" || obj.gitHead === null) && typeof obj.loc === "number" && Number.isInteger(obj.loc) && obj.loc >= 0;
|
|
205
|
+
}
|
|
206
|
+
var ADOPTION_SCOPES = /* @__PURE__ */ new Set(["project", "global"]);
|
|
207
|
+
var ADOPTION_PROVIDERS = /* @__PURE__ */ new Set([
|
|
208
|
+
"claude-code",
|
|
209
|
+
"agents",
|
|
210
|
+
"codex",
|
|
211
|
+
"gemini",
|
|
212
|
+
"cursor",
|
|
213
|
+
"copilot",
|
|
214
|
+
"opencode"
|
|
215
|
+
]);
|
|
216
|
+
var ADOPTION_KINDS = /* @__PURE__ */ new Set(["instructions", "settings", "command", "agent", "skill", "rule"]);
|
|
217
|
+
function isContextSourceSnapshot(value) {
|
|
218
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
219
|
+
const obj = value;
|
|
220
|
+
return typeof obj.path === "string" && obj.path.length > 0 && typeof obj.scope === "string" && ADOPTION_SCOPES.has(obj.scope) && typeof obj.provider === "string" && ADOPTION_PROVIDERS.has(obj.provider) && typeof obj.kind === "string" && ADOPTION_KINDS.has(obj.kind) && (obj.directoryScope === void 0 || typeof obj.directoryScope === "string" && obj.directoryScope.trim().length > 0 && obj.directoryScope.length <= 512) && typeof obj.sha256 === "string" && /^[0-9a-f]{64}$/.test(obj.sha256) && (obj.status === void 0 || obj.status === "accepted" || obj.status === "rejected") && (obj.reason === void 0 || isBoundedNonemptyString(obj.reason, 256)) && (obj.status !== "rejected" || typeof obj.reason === "string");
|
|
221
|
+
}
|
|
222
|
+
function isProjectState(value) {
|
|
223
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
224
|
+
const obj = value;
|
|
225
|
+
if (obj.version !== 1 || !isFingerprint(obj.fingerprint)) return false;
|
|
226
|
+
if ("bootstrapFingerprint" in obj && obj.bootstrapFingerprint !== void 0 && !isFingerprint(obj.bootstrapFingerprint)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if ("lastBootstrap" in obj && obj.lastBootstrap !== void 0 && !isBootstrapGenerationState(obj.lastBootstrap)) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
if ("codewikiVersion" in obj && obj.codewikiVersion !== void 0 && (typeof obj.codewikiVersion !== "number" || !Number.isInteger(obj.codewikiVersion) || obj.codewikiVersion < 1)) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
if ("contextSources" in obj && obj.contextSources !== void 0) {
|
|
236
|
+
if (!Array.isArray(obj.contextSources) || !obj.contextSources.every(isContextSourceSnapshot)) return false;
|
|
237
|
+
}
|
|
238
|
+
if ("contextSourceHash" in obj && obj.contextSourceHash !== void 0 && (typeof obj.contextSourceHash !== "string" || !/^[0-9a-f]{64}$/.test(obj.contextSourceHash))) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
function statePath(cwd) {
|
|
244
|
+
return join2(cwd, STATE_RELATIVE_PATH);
|
|
245
|
+
}
|
|
246
|
+
function migrateLegacyGenerationMode(parsed) {
|
|
247
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return;
|
|
248
|
+
const last = parsed.lastBootstrap;
|
|
249
|
+
if (typeof last !== "object" || last === null || Array.isArray(last)) return;
|
|
250
|
+
const record = last;
|
|
251
|
+
if (record.mode === LEGACY_BOOTSTRAP_GENERATION_MODE) record.mode = "model";
|
|
252
|
+
}
|
|
253
|
+
function readClioState(cwd) {
|
|
254
|
+
const filePath = statePath(cwd);
|
|
255
|
+
if (!existsSync(filePath)) return null;
|
|
256
|
+
let parsed;
|
|
257
|
+
try {
|
|
258
|
+
parsed = JSON.parse(readFileSync2(filePath, "utf8"));
|
|
259
|
+
} catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
migrateLegacyGenerationMode(parsed);
|
|
263
|
+
return isProjectState(parsed) ? parsed : null;
|
|
264
|
+
}
|
|
265
|
+
function writeClioState(cwd, state) {
|
|
266
|
+
safeResourceWrite(statePath(cwd), `${JSON.stringify(state, null, 2)}
|
|
267
|
+
`, { encoding: "utf8" });
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export {
|
|
271
|
+
computeFingerprint,
|
|
272
|
+
computeFingerprintAsync,
|
|
273
|
+
computeFingerprintCached,
|
|
274
|
+
isStale,
|
|
275
|
+
statePath,
|
|
276
|
+
readClioState,
|
|
277
|
+
writeClioState
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=chunk-RQDWMVRB.js.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SETTINGS_YAML
|
|
3
|
+
} from "./chunk-UHTSULZS.js";
|
|
4
|
+
import {
|
|
5
|
+
clioCacheDir,
|
|
6
|
+
clioConfigDir,
|
|
7
|
+
clioDataDir,
|
|
8
|
+
clioStateDir,
|
|
9
|
+
resolveClioDirs
|
|
10
|
+
} from "./chunk-X3NE4WVW.js";
|
|
11
|
+
import {
|
|
12
|
+
readClioVersion
|
|
13
|
+
} from "./chunk-DXQNI4PC.js";
|
|
14
|
+
|
|
15
|
+
// src/core/init.ts
|
|
16
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
var CONFIG_SUBDIRS = ["agents"];
|
|
19
|
+
var DATA_SUBDIRS = ["memory", "evidence", "evals"];
|
|
20
|
+
var STATE_SUBDIRS = ["sessions", "audit", "receipts", "interviews", "scratch"];
|
|
21
|
+
function initializeClioHome() {
|
|
22
|
+
enforceHomePrefixGuard();
|
|
23
|
+
const resolved = resolveClioDirs();
|
|
24
|
+
const preexistingHome = existsSync(resolved.state) || existsSync(resolved.config) || existsSync(resolved.data);
|
|
25
|
+
const configDir = clioConfigDir();
|
|
26
|
+
const dataDir = clioDataDir();
|
|
27
|
+
const stateDir = clioStateDir();
|
|
28
|
+
const cacheDir = clioCacheDir();
|
|
29
|
+
const created = [];
|
|
30
|
+
for (const dir of [configDir, dataDir, stateDir, cacheDir]) {
|
|
31
|
+
if (!existsSync(dir)) {
|
|
32
|
+
mkdirSync(dir, { recursive: true });
|
|
33
|
+
created.push(dir);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const subdirSets = [
|
|
37
|
+
[configDir, CONFIG_SUBDIRS],
|
|
38
|
+
[dataDir, DATA_SUBDIRS],
|
|
39
|
+
[stateDir, STATE_SUBDIRS]
|
|
40
|
+
];
|
|
41
|
+
for (const [root, subs] of subdirSets) {
|
|
42
|
+
for (const sub of subs) {
|
|
43
|
+
const full = join(root, sub);
|
|
44
|
+
if (!existsSync(full)) {
|
|
45
|
+
mkdirSync(full, { recursive: true });
|
|
46
|
+
created.push(full);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const settingsPath = join(configDir, "settings.yaml");
|
|
51
|
+
let touched = false;
|
|
52
|
+
if (!existsSync(settingsPath)) {
|
|
53
|
+
writeFileSync(settingsPath, DEFAULT_SETTINGS_YAML, { encoding: "utf8", mode: 420 });
|
|
54
|
+
created.push(settingsPath);
|
|
55
|
+
touched = true;
|
|
56
|
+
}
|
|
57
|
+
const credentialsPath = join(configDir, "credentials.yaml");
|
|
58
|
+
if (!existsSync(credentialsPath)) {
|
|
59
|
+
writeFileSync(
|
|
60
|
+
credentialsPath,
|
|
61
|
+
"# Managed via `clio-coder auth`. Do not edit manually unless you know what you are doing.\n{}\n",
|
|
62
|
+
{
|
|
63
|
+
encoding: "utf8",
|
|
64
|
+
mode: 384
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
chmodSync(credentialsPath, 384);
|
|
68
|
+
created.push(credentialsPath);
|
|
69
|
+
}
|
|
70
|
+
const installPath = join(stateDir, "install.json");
|
|
71
|
+
const installMetadata = readInstallMetadata(installPath);
|
|
72
|
+
const currentVersion = readClioVersion();
|
|
73
|
+
if (!installMetadata) {
|
|
74
|
+
const payload = {
|
|
75
|
+
version: currentVersion,
|
|
76
|
+
// A first install knows when it happened. A repair does not, and saying
|
|
77
|
+
// `installedAt: now` there is a fact this process invented.
|
|
78
|
+
...preexistingHome ? { repairedAt: (/* @__PURE__ */ new Date()).toISOString() } : { installedAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
79
|
+
platform: process.platform,
|
|
80
|
+
nodeVersion: process.version
|
|
81
|
+
};
|
|
82
|
+
writeFileSync(installPath, `${JSON.stringify(payload, null, 2)}
|
|
83
|
+
`, "utf8");
|
|
84
|
+
created.push(installPath);
|
|
85
|
+
} else if (installMetadata.version !== currentVersion || installMetadata.platform !== process.platform || installMetadata.nodeVersion !== process.version) {
|
|
86
|
+
const payload = {
|
|
87
|
+
version: currentVersion,
|
|
88
|
+
...installMetadata.installedAt !== void 0 ? { installedAt: installMetadata.installedAt } : {},
|
|
89
|
+
...installMetadata.repairedAt !== void 0 ? { repairedAt: installMetadata.repairedAt } : {},
|
|
90
|
+
upgradedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
91
|
+
platform: process.platform,
|
|
92
|
+
nodeVersion: process.version
|
|
93
|
+
};
|
|
94
|
+
writeFileSync(installPath, `${JSON.stringify(payload, null, 2)}
|
|
95
|
+
`, "utf8");
|
|
96
|
+
}
|
|
97
|
+
return { configDir, dataDir, stateDir, cacheDir, createdPaths: created, touchedSettings: touched };
|
|
98
|
+
}
|
|
99
|
+
function readInstallMetadata(path) {
|
|
100
|
+
if (!existsSync(path)) return null;
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
103
|
+
if (typeof parsed.version === "string" && (typeof parsed.installedAt === "string" || typeof parsed.repairedAt === "string") && typeof parsed.platform === "string" && typeof parsed.nodeVersion === "string") {
|
|
104
|
+
return {
|
|
105
|
+
version: parsed.version,
|
|
106
|
+
...typeof parsed.installedAt === "string" ? { installedAt: parsed.installedAt } : {},
|
|
107
|
+
...typeof parsed.upgradedAt === "string" ? { upgradedAt: parsed.upgradedAt } : {},
|
|
108
|
+
...typeof parsed.repairedAt === "string" ? { repairedAt: parsed.repairedAt } : {},
|
|
109
|
+
platform: parsed.platform,
|
|
110
|
+
nodeVersion: parsed.nodeVersion
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function enforceHomePrefixGuard() {
|
|
118
|
+
if (process.env.CLIO_CODER_REQUIRE_HOME_PREFIX !== "1") return;
|
|
119
|
+
const home = process.env.CLIO_CODER_HOME?.trim();
|
|
120
|
+
if (!home) return;
|
|
121
|
+
const dirs = resolveClioDirs();
|
|
122
|
+
const offenders = [];
|
|
123
|
+
if (!dirs.config.startsWith(home)) offenders.push(`configDir=${dirs.config}`);
|
|
124
|
+
if (!dirs.data.startsWith(home)) offenders.push(`dataDir=${dirs.data}`);
|
|
125
|
+
if (!dirs.state.startsWith(home)) offenders.push(`stateDir=${dirs.state}`);
|
|
126
|
+
if (!dirs.cache.startsWith(home)) offenders.push(`cacheDir=${dirs.cache}`);
|
|
127
|
+
if (offenders.length === 0) return;
|
|
128
|
+
throw new Error(
|
|
129
|
+
`CLIO_CODER_REQUIRE_HOME_PREFIX guardrail tripped: resolved Clio directories escape CLIO_CODER_HOME=${home}. Offending paths: ${offenders.join(", ")}. Individual overrides CLIO_CODER_CONFIG_DIR, CLIO_CODER_DATA_DIR, CLIO_CODER_STATE_DIR, and CLIO_CODER_CACHE_DIR take precedence over CLIO_CODER_HOME, so a test that sets only CLIO_CODER_HOME inherits whatever the parent process configured. Override all five env vars in lockstep to scratch subdirs (CLIO_CODER_HOME plus CLIO_CODER_CONFIG_DIR, CLIO_CODER_DATA_DIR, CLIO_CODER_STATE_DIR, CLIO_CODER_CACHE_DIR pointing under it), then call resetXdgCache().`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
initializeClioHome
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=chunk-TFSSEXL6.js.map
|