@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,41 @@
|
|
|
1
|
+
// src/domains/prompts/preload.ts
|
|
2
|
+
var FULL_PROJECT_CONTEXT_MAX_CHARS = 8e3;
|
|
3
|
+
var FULL_PROJECT_CONTEXT_MAX_LINES = 220;
|
|
4
|
+
var NEAR_LIMIT_FRACTION = 0.9;
|
|
5
|
+
function formatKb(chars) {
|
|
6
|
+
return `${(chars / 1e3).toFixed(1)}kB`;
|
|
7
|
+
}
|
|
8
|
+
function classifyProjectPreload(input) {
|
|
9
|
+
const chars = input.text.length;
|
|
10
|
+
const lines = input.text.length === 0 ? 0 : input.text.split("\n").length;
|
|
11
|
+
if (input.text.trim().length === 0) {
|
|
12
|
+
return { mode: "none", chars, lines, reason: null, nearLimit: false, label: "none (no project context)" };
|
|
13
|
+
}
|
|
14
|
+
const reason = !input.hasClioMd ? "no-clio-md" : chars > FULL_PROJECT_CONTEXT_MAX_CHARS ? "size" : lines > FULL_PROJECT_CONTEXT_MAX_LINES ? "lines" : null;
|
|
15
|
+
if (reason !== null) {
|
|
16
|
+
return {
|
|
17
|
+
mode: "synopsis",
|
|
18
|
+
chars,
|
|
19
|
+
lines,
|
|
20
|
+
reason,
|
|
21
|
+
nearLimit: false,
|
|
22
|
+
label: `synopsis (reason: ${reason})`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const nearLimit = chars > FULL_PROJECT_CONTEXT_MAX_CHARS * NEAR_LIMIT_FRACTION || lines > FULL_PROJECT_CONTEXT_MAX_LINES * NEAR_LIMIT_FRACTION;
|
|
26
|
+
return {
|
|
27
|
+
mode: "full",
|
|
28
|
+
chars,
|
|
29
|
+
lines,
|
|
30
|
+
reason: null,
|
|
31
|
+
nearLimit,
|
|
32
|
+
label: `full (${formatKb(chars)}, ${lines} lines)`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
FULL_PROJECT_CONTEXT_MAX_CHARS,
|
|
38
|
+
FULL_PROJECT_CONTEXT_MAX_LINES,
|
|
39
|
+
classifyProjectPreload
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-KBR4MZZR.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/cli/oauth-manual-input.ts
|
|
2
|
+
function createDelayedManualCodeInput(rl, prompt, options) {
|
|
3
|
+
const delayMs = Math.max(0, options?.delayMs ?? 1e4);
|
|
4
|
+
let timer = null;
|
|
5
|
+
let abortController = null;
|
|
6
|
+
let pendingReject = null;
|
|
7
|
+
let started = false;
|
|
8
|
+
let cancelled = false;
|
|
9
|
+
return {
|
|
10
|
+
onManualCodeInput: () => new Promise((resolve, reject) => {
|
|
11
|
+
pendingReject = reject;
|
|
12
|
+
const beginPrompt = () => {
|
|
13
|
+
pendingReject = null;
|
|
14
|
+
if (cancelled) {
|
|
15
|
+
reject(new Error("cancelled"));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
started = true;
|
|
19
|
+
abortController = new AbortController();
|
|
20
|
+
void rl.question(prompt, { signal: abortController.signal }).then((answer) => {
|
|
21
|
+
resolve(answer.trim());
|
|
22
|
+
}).catch((error) => {
|
|
23
|
+
const next = error instanceof Error && error.name === "AbortError" ? new Error("cancelled") : error;
|
|
24
|
+
reject(next instanceof Error ? next : new Error(String(next)));
|
|
25
|
+
}).finally(() => {
|
|
26
|
+
abortController = null;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
if (delayMs === 0) {
|
|
30
|
+
beginPrompt();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
timer = setTimeout(() => {
|
|
34
|
+
timer = null;
|
|
35
|
+
beginPrompt();
|
|
36
|
+
}, delayMs);
|
|
37
|
+
}),
|
|
38
|
+
cancel: () => {
|
|
39
|
+
if (cancelled) return;
|
|
40
|
+
cancelled = true;
|
|
41
|
+
if (timer) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
timer = null;
|
|
44
|
+
}
|
|
45
|
+
if (!started) {
|
|
46
|
+
pendingReject?.(new Error("cancelled"));
|
|
47
|
+
pendingReject = null;
|
|
48
|
+
}
|
|
49
|
+
if (started) {
|
|
50
|
+
abortController?.abort();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/cli/oauth-select.ts
|
|
57
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
58
|
+
function writeOAuthSelectOptions(prompt) {
|
|
59
|
+
const defaultId = prompt.options[0]?.id;
|
|
60
|
+
process.stdout.write(`${prompt.message}
|
|
61
|
+
`);
|
|
62
|
+
for (const [index, option] of prompt.options.entries()) {
|
|
63
|
+
const marker = option.id === defaultId ? "*" : " ";
|
|
64
|
+
process.stdout.write(` ${marker} ${String(index + 1).padStart(2)}. ${option.label} (${option.id})
|
|
65
|
+
`);
|
|
66
|
+
}
|
|
67
|
+
process.stdout.write("\n");
|
|
68
|
+
return defaultId;
|
|
69
|
+
}
|
|
70
|
+
async function promptOAuthSelection(rl, prompt) {
|
|
71
|
+
const defaultId = writeOAuthSelectOptions(prompt);
|
|
72
|
+
if (!defaultId) return void 0;
|
|
73
|
+
if (!input.isTTY || !output.isTTY) return defaultId;
|
|
74
|
+
const ids = new Set(prompt.options.map((option) => option.id));
|
|
75
|
+
for (; ; ) {
|
|
76
|
+
const answer = (await rl.question(`Selection (number or id, q to cancel) [${defaultId}]: `)).trim();
|
|
77
|
+
if (answer.length === 0) return defaultId;
|
|
78
|
+
if (answer === "q" || answer === "quit" || answer === "cancel") return void 0;
|
|
79
|
+
const numeric = Number(answer);
|
|
80
|
+
if (Number.isInteger(numeric) && numeric >= 1 && numeric <= prompt.options.length) {
|
|
81
|
+
return prompt.options[numeric - 1]?.id;
|
|
82
|
+
}
|
|
83
|
+
if (ids.has(answer)) return answer;
|
|
84
|
+
process.stderr.write(`unknown selection: ${answer}
|
|
85
|
+
`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
createDelayedManualCodeInput,
|
|
91
|
+
promptOAuthSelection
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=chunk-KKKPTZLM.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/cli/text-layout.ts
|
|
2
|
+
function terminalColumns(stream = process.stdout) {
|
|
3
|
+
const columns = stream.columns;
|
|
4
|
+
if (typeof columns !== "number" || !Number.isFinite(columns)) return 80;
|
|
5
|
+
return Math.max(20, Math.floor(columns));
|
|
6
|
+
}
|
|
7
|
+
function truncate(text, width) {
|
|
8
|
+
if (width <= 0) return "";
|
|
9
|
+
if (text.length <= width) return text;
|
|
10
|
+
if (width === 1) return "\u2026";
|
|
11
|
+
return `${text.slice(0, width - 1)}\u2026`;
|
|
12
|
+
}
|
|
13
|
+
function column(text, width) {
|
|
14
|
+
return truncate(text, width).padEnd(width);
|
|
15
|
+
}
|
|
16
|
+
function wrapPlain(text, width, hangingIndent = 0) {
|
|
17
|
+
const words = text.split(/\s+/).filter((word) => word.length > 0);
|
|
18
|
+
if (words.length === 0) return [""];
|
|
19
|
+
const indent = " ".repeat(hangingIndent);
|
|
20
|
+
const lines = [];
|
|
21
|
+
let current = "";
|
|
22
|
+
const emit = (line) => {
|
|
23
|
+
lines.push(lines.length === 0 ? line : `${indent}${line}`);
|
|
24
|
+
};
|
|
25
|
+
for (const word of words) {
|
|
26
|
+
if (current.length === 0) {
|
|
27
|
+
current = word;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (current.length + 1 + word.length <= width) {
|
|
31
|
+
current = `${current} ${word}`;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
emit(current);
|
|
35
|
+
current = word;
|
|
36
|
+
}
|
|
37
|
+
emit(current);
|
|
38
|
+
return lines;
|
|
39
|
+
}
|
|
40
|
+
function twoColumnRow(left, right, options) {
|
|
41
|
+
const { indent, leftWidth, width } = options;
|
|
42
|
+
const minRight = options.minRight ?? 24;
|
|
43
|
+
const pad = " ".repeat(indent);
|
|
44
|
+
const rightRoom = width - indent - leftWidth;
|
|
45
|
+
if (rightRoom >= minRight) {
|
|
46
|
+
const wrapped = wrapPlain(right, rightRoom, indent + leftWidth);
|
|
47
|
+
const [first = "", ...rest] = wrapped;
|
|
48
|
+
return [`${pad}${column(left, leftWidth)}${first}`, ...rest];
|
|
49
|
+
}
|
|
50
|
+
const stackIndent = indent + 2;
|
|
51
|
+
return [
|
|
52
|
+
`${pad}${left}`,
|
|
53
|
+
...wrapPlain(right, Math.max(8, width - stackIndent), stackIndent).map(
|
|
54
|
+
(line, index) => index === 0 ? `${" ".repeat(stackIndent)}${line}` : line
|
|
55
|
+
)
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
terminalColumns,
|
|
61
|
+
truncate,
|
|
62
|
+
column,
|
|
63
|
+
wrapPlain,
|
|
64
|
+
twoColumnRow
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=chunk-ME6DNWIU.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readStateInfo,
|
|
3
|
+
runDoctor
|
|
4
|
+
} from "./chunk-7RBKDI66.js";
|
|
5
|
+
import {
|
|
6
|
+
getVersionInfo
|
|
7
|
+
} from "./chunk-HMYNFFY4.js";
|
|
8
|
+
|
|
9
|
+
// src/domains/lifecycle/migrations/index.ts
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
var REGISTRY = Object.freeze([]);
|
|
13
|
+
function listMigrations() {
|
|
14
|
+
return REGISTRY;
|
|
15
|
+
}
|
|
16
|
+
function manifestPath(stateDir) {
|
|
17
|
+
return join(stateDir, "migrations.json");
|
|
18
|
+
}
|
|
19
|
+
function readManifest(path) {
|
|
20
|
+
if (!existsSync(path)) return { applied: [] };
|
|
21
|
+
try {
|
|
22
|
+
const raw = readFileSync(path, "utf8");
|
|
23
|
+
const parsed = JSON.parse(raw);
|
|
24
|
+
if (parsed && typeof parsed === "object" && Array.isArray(parsed.applied)) {
|
|
25
|
+
const ids = parsed.applied.filter((v) => typeof v === "string");
|
|
26
|
+
return { applied: ids };
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
return { applied: [] };
|
|
31
|
+
}
|
|
32
|
+
function writeManifest(path, manifest) {
|
|
33
|
+
writeFileSync(path, `${JSON.stringify(manifest, null, 2)}
|
|
34
|
+
`, { encoding: "utf8", mode: 420 });
|
|
35
|
+
}
|
|
36
|
+
async function runPending(stateDir) {
|
|
37
|
+
mkdirSync(stateDir, { recursive: true });
|
|
38
|
+
const path = manifestPath(stateDir);
|
|
39
|
+
const manifest = readManifest(path);
|
|
40
|
+
const applied = new Set(manifest.applied);
|
|
41
|
+
const newlyApplied = [];
|
|
42
|
+
for (const m of REGISTRY) {
|
|
43
|
+
if (applied.has(m.id)) continue;
|
|
44
|
+
await m.up(stateDir);
|
|
45
|
+
applied.add(m.id);
|
|
46
|
+
newlyApplied.push(m.id);
|
|
47
|
+
}
|
|
48
|
+
const allApplied = [...applied];
|
|
49
|
+
writeManifest(path, { applied: allApplied });
|
|
50
|
+
return {
|
|
51
|
+
applied: newlyApplied,
|
|
52
|
+
allApplied,
|
|
53
|
+
available: REGISTRY.map((m) => m.id)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/domains/lifecycle/extension.ts
|
|
58
|
+
function createLifecycleBundle(_context) {
|
|
59
|
+
const extension = {
|
|
60
|
+
async start() {
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const contract = {
|
|
64
|
+
version: getVersionInfo,
|
|
65
|
+
state: readStateInfo,
|
|
66
|
+
doctor: runDoctor,
|
|
67
|
+
runMigrations: (stateDir) => runPending(stateDir)
|
|
68
|
+
};
|
|
69
|
+
return { extension, contract };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/domains/lifecycle/manifest.ts
|
|
73
|
+
var LifecycleManifest = {
|
|
74
|
+
name: "lifecycle",
|
|
75
|
+
dependsOn: ["config"]
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/domains/lifecycle/index.ts
|
|
79
|
+
var LifecycleDomainModule = {
|
|
80
|
+
manifest: LifecycleManifest,
|
|
81
|
+
createExtension: createLifecycleBundle
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
listMigrations,
|
|
86
|
+
LifecycleDomainModule
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=chunk-NI4DEJMC.js.map
|