@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,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getVersionInfo
|
|
3
|
+
} from "./chunk-HMYNFFY4.js";
|
|
4
|
+
import "./chunk-DXQNI4PC.js";
|
|
5
|
+
|
|
6
|
+
// src/cli/version.ts
|
|
7
|
+
function runVersionCommand() {
|
|
8
|
+
const v = getVersionInfo();
|
|
9
|
+
process.stdout.write(`Clio Coder ${v.clio}
|
|
10
|
+
`);
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
runVersionCommand
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=version-ROZ6CZKH.js.map
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import {
|
|
2
|
+
armInternalDispatchDeadline
|
|
3
|
+
} from "./chunk-4UQA7NCT.js";
|
|
4
|
+
import {
|
|
5
|
+
SchedulingDomainModule,
|
|
6
|
+
createPromptsDomainModule
|
|
7
|
+
} from "./chunk-3DANZDGR.js";
|
|
8
|
+
import {
|
|
9
|
+
AgentsDomainModule,
|
|
10
|
+
SafetyDomainModule
|
|
11
|
+
} from "./chunk-JPOWPFCU.js";
|
|
12
|
+
import {
|
|
13
|
+
ConfigDomainModule,
|
|
14
|
+
loadDomains
|
|
15
|
+
} from "./chunk-527KG6XR.js";
|
|
16
|
+
import "./chunk-UU3R62TT.js";
|
|
17
|
+
import {
|
|
18
|
+
ContextDomainModule,
|
|
19
|
+
buildWikiPagePrompt,
|
|
20
|
+
buildWikiPlanPrompt
|
|
21
|
+
} from "./chunk-UWIJNAOB.js";
|
|
22
|
+
import "./chunk-X3BR7HWV.js";
|
|
23
|
+
import "./chunk-VOO7NYPP.js";
|
|
24
|
+
import {
|
|
25
|
+
DispatchDomainModule,
|
|
26
|
+
MAX_PAGE_ATTEMPTS,
|
|
27
|
+
MiddlewareDomainModule,
|
|
28
|
+
SessionDomainModule,
|
|
29
|
+
createObservabilityDomainModule,
|
|
30
|
+
pendingPages,
|
|
31
|
+
readAuthoredWikiPlan,
|
|
32
|
+
writeWikiPlanFile
|
|
33
|
+
} from "./chunk-GNGDQYDU.js";
|
|
34
|
+
import {
|
|
35
|
+
ResourcesDomainModule
|
|
36
|
+
} from "./chunk-2J63S4SF.js";
|
|
37
|
+
import "./chunk-RQDWMVRB.js";
|
|
38
|
+
import "./chunk-7BHLZB3A.js";
|
|
39
|
+
import "./chunk-TPOCL34A.js";
|
|
40
|
+
import "./chunk-E3NYWENM.js";
|
|
41
|
+
import "./chunk-XV4ZJ6ZM.js";
|
|
42
|
+
import "./chunk-26BZQOAD.js";
|
|
43
|
+
import "./chunk-WD6AJM35.js";
|
|
44
|
+
import {
|
|
45
|
+
ToolNames
|
|
46
|
+
} from "./chunk-QV47YRF4.js";
|
|
47
|
+
import "./chunk-CLJ5HLUD.js";
|
|
48
|
+
import "./chunk-BBUH4VAA.js";
|
|
49
|
+
import "./chunk-GOTUR54M.js";
|
|
50
|
+
import "./chunk-KBR4MZZR.js";
|
|
51
|
+
import {
|
|
52
|
+
ProvidersDomainModule,
|
|
53
|
+
canonicalizeWireModelId
|
|
54
|
+
} from "./chunk-TKHQ4DGZ.js";
|
|
55
|
+
import "./chunk-D5YD55AR.js";
|
|
56
|
+
import "./chunk-JWHCJDCI.js";
|
|
57
|
+
import "./chunk-UHTSULZS.js";
|
|
58
|
+
import "./chunk-5LDRNKX2.js";
|
|
59
|
+
import "./chunk-UGYAX5YI.js";
|
|
60
|
+
import "./chunk-5N2FG33Q.js";
|
|
61
|
+
import "./chunk-VPAWTYLY.js";
|
|
62
|
+
import "./chunk-X3NE4WVW.js";
|
|
63
|
+
import "./chunk-DXQNI4PC.js";
|
|
64
|
+
|
|
65
|
+
// src/cli/wiki-generate.ts
|
|
66
|
+
import { existsSync } from "node:fs";
|
|
67
|
+
import { join } from "node:path";
|
|
68
|
+
var UNRESOLVED_DOCUMENTER_MODEL = "unresolved-documenter-target";
|
|
69
|
+
var WIKI_AGENT_ID = "wiki-writer";
|
|
70
|
+
var PAGE_DEADLINE_MS = 6 * 60 * 1e3;
|
|
71
|
+
var PLAN_DEADLINE_MS = 8 * 60 * 1e3;
|
|
72
|
+
var RUN_BUDGET_MS = 60 * 60 * 1e3;
|
|
73
|
+
function isRecord(value) {
|
|
74
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75
|
+
}
|
|
76
|
+
function routeFields(route) {
|
|
77
|
+
return {
|
|
78
|
+
...route.target !== void 0 ? { target: route.target } : {},
|
|
79
|
+
...route.model !== void 0 ? { model: route.model } : {},
|
|
80
|
+
...route.thinkingLevel !== void 0 ? { thinkingLevel: route.thinkingLevel } : {}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function eventPayloadString(event, key) {
|
|
84
|
+
if (!isRecord(event) || !isRecord(event.payload)) return null;
|
|
85
|
+
const value = event.payload[key];
|
|
86
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
87
|
+
}
|
|
88
|
+
function formatElapsed(ms) {
|
|
89
|
+
if (!Number.isFinite(ms) || ms < 0) return "elapsed unknown";
|
|
90
|
+
if (ms < 1e3) return `elapsed ${Math.round(ms)}ms`;
|
|
91
|
+
return `elapsed ${Math.round(ms / 1e3)}s`;
|
|
92
|
+
}
|
|
93
|
+
var BLOCK_REASON_MAX_CHARS = 80;
|
|
94
|
+
function summarizeBlockReason(reason) {
|
|
95
|
+
const firstSentence = reason.split(/(?<=[.;])\s/, 1)[0]?.trim() ?? reason.trim();
|
|
96
|
+
const collapsed = firstSentence.replace(/\s+/g, " ");
|
|
97
|
+
return collapsed.length <= BLOCK_REASON_MAX_CHARS ? collapsed : `${collapsed.slice(0, BLOCK_REASON_MAX_CHARS - 1).trimEnd()}\u2026`;
|
|
98
|
+
}
|
|
99
|
+
var HEARTBEAT_MS = 3e4;
|
|
100
|
+
async function drainDispatchEvents(events, onActivity) {
|
|
101
|
+
const tools = /* @__PURE__ */ new Map();
|
|
102
|
+
let completed = 0;
|
|
103
|
+
let errors = 0;
|
|
104
|
+
let blocked = 0;
|
|
105
|
+
let firstBlockReason = null;
|
|
106
|
+
for await (const event of events) {
|
|
107
|
+
if (!isRecord(event) || event.type !== "clio_tool_finish") continue;
|
|
108
|
+
const tool = eventPayloadString(event, "tool");
|
|
109
|
+
if (!tool) continue;
|
|
110
|
+
const outcome = eventPayloadString(event, "outcome") ?? "done";
|
|
111
|
+
completed += 1;
|
|
112
|
+
tools.set(tool, (tools.get(tool) ?? 0) + 1);
|
|
113
|
+
if (outcome === "error") errors += 1;
|
|
114
|
+
if (outcome === "blocked") {
|
|
115
|
+
blocked += 1;
|
|
116
|
+
firstBlockReason ??= eventPayloadString(event, "reason");
|
|
117
|
+
}
|
|
118
|
+
onActivity?.(completed);
|
|
119
|
+
}
|
|
120
|
+
const mix = [...tools.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([tool, count]) => `${tool}=${count}`).join(", ");
|
|
121
|
+
return { tools: completed, errors, blocked, firstBlockReason, mix };
|
|
122
|
+
}
|
|
123
|
+
function summaryDetail(summary, startedAt) {
|
|
124
|
+
const blockedDetail = summary.blocked > 0 ? `; blocked=${summary.blocked}${summary.firstBlockReason ? ` (${summarizeBlockReason(summary.firstBlockReason)})` : ""}` : "";
|
|
125
|
+
return `${formatElapsed(Date.now() - startedAt)}; ${summary.mix || "no tools completed"}${summary.errors > 0 ? `; errors=${summary.errors}` : ""}${blockedDetail}`;
|
|
126
|
+
}
|
|
127
|
+
async function runWikiDispatch(input) {
|
|
128
|
+
const startedAt = Date.now();
|
|
129
|
+
let handle;
|
|
130
|
+
try {
|
|
131
|
+
handle = await input.dispatch.dispatch({
|
|
132
|
+
agentId: WIKI_AGENT_ID,
|
|
133
|
+
executionRole: "builder",
|
|
134
|
+
task: input.task,
|
|
135
|
+
cwd: input.cwd,
|
|
136
|
+
requestOrigin: "internal",
|
|
137
|
+
noSkills: true,
|
|
138
|
+
...routeFields(input.route),
|
|
139
|
+
// `git` cannot answer anything for this dispatch. The prompt already
|
|
140
|
+
// embeds `git status` and `git log` verbatim, and the staging dir is
|
|
141
|
+
// under the gitignored `.clio-coder/`, so `op=diff` cannot see the pages this
|
|
142
|
+
// run is writing.
|
|
143
|
+
denyTools: [ToolNames.Git],
|
|
144
|
+
// Containment: the worker safety seam blocks any write-class tool call
|
|
145
|
+
// whose target escapes the staging dir.
|
|
146
|
+
writeRoots: [input.outputDir],
|
|
147
|
+
// Admission patience must match execution patience. Without this the
|
|
148
|
+
// queue applies its 60s default while `deadlineMs` below allows six
|
|
149
|
+
// minutes to run, so a page waiting behind two in-flight writers was
|
|
150
|
+
// dropped before it ever started. Observed live: a 33-page plan lost
|
|
151
|
+
// `core.md` to `dispatch: admission timed_out` at 10/33 while every
|
|
152
|
+
// page ahead of it was taking 110 to 125 seconds. A page the caller is
|
|
153
|
+
// willing to wait six minutes for is a page it should be willing to
|
|
154
|
+
// queue for six minutes.
|
|
155
|
+
assignmentDeadlineAt: startedAt + input.deadlineMs
|
|
156
|
+
});
|
|
157
|
+
} catch (err) {
|
|
158
|
+
return { ok: false, detail: err instanceof Error ? err.message : String(err) };
|
|
159
|
+
}
|
|
160
|
+
const deadline = armInternalDispatchDeadline(input.dispatch, handle.runId, input.label, process.env, input.deadlineMs);
|
|
161
|
+
let lastHeartbeatAt = startedAt;
|
|
162
|
+
try {
|
|
163
|
+
const summary = await drainDispatchEvents(handle.events, (tools) => {
|
|
164
|
+
const nowMs = Date.now();
|
|
165
|
+
if (!input.onHeartbeat || nowMs - lastHeartbeatAt < HEARTBEAT_MS) return;
|
|
166
|
+
lastHeartbeatAt = nowMs;
|
|
167
|
+
input.onHeartbeat({ elapsedMs: nowMs - startedAt, tools });
|
|
168
|
+
});
|
|
169
|
+
const receipt = await handle.finalPromise;
|
|
170
|
+
if (deadline.timedOut()) return { ok: false, detail: `timed out; ${summaryDetail(summary, startedAt)}` };
|
|
171
|
+
if (receipt.exitCode !== 0) {
|
|
172
|
+
input.dispatch.abort(handle.runId);
|
|
173
|
+
return { ok: false, detail: `${receiptFailure(receipt)}; ${summaryDetail(summary, startedAt)}` };
|
|
174
|
+
}
|
|
175
|
+
return { ok: true, detail: summaryDetail(summary, startedAt) };
|
|
176
|
+
} catch (err) {
|
|
177
|
+
if (!deadline.timedOut()) input.dispatch.abort(handle.runId);
|
|
178
|
+
await handle.finalPromise.catch(() => void 0);
|
|
179
|
+
const reason = deadline.timedOut() ? "timed out" : err instanceof Error ? err.message : String(err);
|
|
180
|
+
return { ok: false, detail: `${reason}; ${formatElapsed(Date.now() - startedAt)}` };
|
|
181
|
+
} finally {
|
|
182
|
+
deadline.clear();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function receiptFailure(receipt) {
|
|
186
|
+
const code = receipt.outcomeCode ? ` (${receipt.outcomeCode})` : "";
|
|
187
|
+
return `exit ${receipt.exitCode}${code}`;
|
|
188
|
+
}
|
|
189
|
+
async function runPlanPhase(dispatch, input, route) {
|
|
190
|
+
input.progress?.({ phase: "generate", status: "running", message: "planning wiki pages" });
|
|
191
|
+
const outcome = await runWikiDispatch({
|
|
192
|
+
dispatch,
|
|
193
|
+
cwd: input.cwd,
|
|
194
|
+
outputDir: input.outputDir,
|
|
195
|
+
task: buildWikiPlanPrompt({
|
|
196
|
+
cwd: input.cwd,
|
|
197
|
+
mode: input.mode,
|
|
198
|
+
codewiki: input.codewiki,
|
|
199
|
+
generation: input.generation,
|
|
200
|
+
plan: input.plan,
|
|
201
|
+
unclaimedAreas: input.unclaimedAreas,
|
|
202
|
+
outputDir: input.outputDir,
|
|
203
|
+
gitHead: input.gitHead ?? null
|
|
204
|
+
}),
|
|
205
|
+
route,
|
|
206
|
+
deadlineMs: PLAN_DEADLINE_MS,
|
|
207
|
+
label: "wiki planner",
|
|
208
|
+
onHeartbeat: ({ elapsedMs, tools }) => input.progress?.({
|
|
209
|
+
phase: "generate",
|
|
210
|
+
status: "running",
|
|
211
|
+
message: `still planning (${formatElapsed(elapsedMs)}, ${tools} tool calls)`,
|
|
212
|
+
detail: `planner deadline ${Math.round(PLAN_DEADLINE_MS / 6e4)}m`
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
const revised = readAuthoredWikiPlan(input.outputDir, input.plan);
|
|
216
|
+
const plan = revised ?? input.plan;
|
|
217
|
+
input.progress?.({
|
|
218
|
+
phase: "generate",
|
|
219
|
+
status: "running",
|
|
220
|
+
message: outcome.ok ? `plan has ${plan.pages.length} page${plan.pages.length === 1 ? "" : "s"}` : "planner did not finish; using the indexed candidate plan",
|
|
221
|
+
detail: outcome.detail
|
|
222
|
+
});
|
|
223
|
+
return plan;
|
|
224
|
+
}
|
|
225
|
+
async function runPagePhase(dispatch, input, plan, page, route, position) {
|
|
226
|
+
const seeded = existsSync(join(input.outputDir, page.path));
|
|
227
|
+
const outcome = await runWikiDispatch({
|
|
228
|
+
dispatch,
|
|
229
|
+
cwd: input.cwd,
|
|
230
|
+
outputDir: input.outputDir,
|
|
231
|
+
task: buildWikiPagePrompt({
|
|
232
|
+
cwd: input.cwd,
|
|
233
|
+
mode: input.mode,
|
|
234
|
+
codewiki: input.codewiki,
|
|
235
|
+
page,
|
|
236
|
+
siblings: plan.pages,
|
|
237
|
+
outputDir: input.outputDir,
|
|
238
|
+
seeded
|
|
239
|
+
}),
|
|
240
|
+
route,
|
|
241
|
+
deadlineMs: PAGE_DEADLINE_MS,
|
|
242
|
+
label: `wiki page ${page.path}`,
|
|
243
|
+
onHeartbeat: ({ elapsedMs, tools }) => input.progress?.({
|
|
244
|
+
phase: "generate",
|
|
245
|
+
status: "running",
|
|
246
|
+
message: `still writing ${page.path} (${position.index}/${position.total}, ${formatElapsed(elapsedMs)}, ${tools} tool calls)`,
|
|
247
|
+
detail: `page deadline ${Math.round(PAGE_DEADLINE_MS / 6e4)}m`
|
|
248
|
+
})
|
|
249
|
+
});
|
|
250
|
+
const written = existsSync(join(input.outputDir, page.path));
|
|
251
|
+
const next = {
|
|
252
|
+
...plan,
|
|
253
|
+
pages: plan.pages.map(
|
|
254
|
+
(entry) => entry.path === page.path ? { ...entry, status: written ? "written" : "pending", attempts: entry.attempts + 1 } : entry
|
|
255
|
+
)
|
|
256
|
+
};
|
|
257
|
+
writeWikiPlanFile(input.outputDir, next);
|
|
258
|
+
input.progress?.({
|
|
259
|
+
phase: "generate",
|
|
260
|
+
status: "running",
|
|
261
|
+
message: `${written ? "wrote" : "could not write"} ${page.path} (${position.index}/${position.total})`,
|
|
262
|
+
detail: outcome.detail
|
|
263
|
+
});
|
|
264
|
+
return next;
|
|
265
|
+
}
|
|
266
|
+
async function generateWikiWithDocumenter(dispatch, input, route = {}, runBudgetMs = RUN_BUDGET_MS) {
|
|
267
|
+
const startedAt = Date.now();
|
|
268
|
+
const routeDetail = [route.target, route.model, route.thinkingLevel ? `thinking=${route.thinkingLevel}` : void 0].filter((value) => value !== void 0).join("/");
|
|
269
|
+
input.progress?.({
|
|
270
|
+
phase: "generate",
|
|
271
|
+
status: "running",
|
|
272
|
+
message: "dispatching wiki writers",
|
|
273
|
+
detail: `one page per dispatch${routeDetail ? `; ${routeDetail}` : ""}`
|
|
274
|
+
});
|
|
275
|
+
let plan = input.resumed ? input.plan : await runPlanPhase(dispatch, input, route);
|
|
276
|
+
if (!input.resumed) writeWikiPlanFile(input.outputDir, plan);
|
|
277
|
+
const queue = pendingPages(plan);
|
|
278
|
+
if (queue.length === 0) {
|
|
279
|
+
input.progress?.({ phase: "generate", status: "running", message: "every planned page is already current" });
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
{
|
|
283
|
+
const worstCaseMs = Math.min(runBudgetMs, queue.length * PAGE_DEADLINE_MS);
|
|
284
|
+
input.progress?.({
|
|
285
|
+
phase: "generate",
|
|
286
|
+
status: "running",
|
|
287
|
+
message: `${queue.length} page${queue.length === 1 ? "" : "s"} to write, one model run each`,
|
|
288
|
+
detail: `up to ${Math.round(worstCaseMs / 6e4)}m; progress is reported at least every ${Math.round(HEARTBEAT_MS / 1e3)}s and finished pages are kept if the run stops early`
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
for (const [index, page] of queue.entries()) {
|
|
292
|
+
if (Date.now() - startedAt >= runBudgetMs) {
|
|
293
|
+
const left = queue.length - index;
|
|
294
|
+
input.progress?.({
|
|
295
|
+
phase: "generate",
|
|
296
|
+
status: "running",
|
|
297
|
+
message: `run budget reached with ${left} page${left === 1 ? "" : "s"} unwritten`,
|
|
298
|
+
detail: `${formatElapsed(Date.now() - startedAt)}; staged pages are kept and promoted`
|
|
299
|
+
});
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const current = plan.pages.find((entry) => entry.path === page.path) ?? page;
|
|
303
|
+
if (current.status === "written" || current.attempts >= MAX_PAGE_ATTEMPTS) continue;
|
|
304
|
+
plan = await runPagePhase(dispatch, input, plan, current, route, {
|
|
305
|
+
index: index + 1,
|
|
306
|
+
total: queue.length
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function loadWikiDispatch() {
|
|
311
|
+
const loaded = await loadDomains([
|
|
312
|
+
ConfigDomainModule,
|
|
313
|
+
ResourcesDomainModule,
|
|
314
|
+
ContextDomainModule,
|
|
315
|
+
ProvidersDomainModule,
|
|
316
|
+
SafetyDomainModule,
|
|
317
|
+
createPromptsDomainModule({ noContextFiles: true }),
|
|
318
|
+
AgentsDomainModule,
|
|
319
|
+
MiddlewareDomainModule,
|
|
320
|
+
SessionDomainModule,
|
|
321
|
+
createObservabilityDomainModule({ dispatchTrace: false }),
|
|
322
|
+
SchedulingDomainModule,
|
|
323
|
+
DispatchDomainModule
|
|
324
|
+
]);
|
|
325
|
+
const dispatch = loaded.getContract("dispatch");
|
|
326
|
+
if (!dispatch) {
|
|
327
|
+
await loaded.stop();
|
|
328
|
+
throw new Error("wiki writer dispatch unavailable");
|
|
329
|
+
}
|
|
330
|
+
return { dispatch, loaded };
|
|
331
|
+
}
|
|
332
|
+
async function resolveDocumenterModelId(route = {}) {
|
|
333
|
+
const loaded = await loadDomains([ConfigDomainModule, ResourcesDomainModule, ProvidersDomainModule]);
|
|
334
|
+
try {
|
|
335
|
+
const config = loaded.getContract("config");
|
|
336
|
+
const providers = loaded.getContract("providers");
|
|
337
|
+
if (!config || !providers) return UNRESOLVED_DOCUMENTER_MODEL;
|
|
338
|
+
const settings = config.get();
|
|
339
|
+
const workers = settings.workers;
|
|
340
|
+
const bindingProfileName = workers?.agentBindings?.[WIKI_AGENT_ID];
|
|
341
|
+
const profile = bindingProfileName ? workers?.profiles?.[bindingProfileName] : void 0;
|
|
342
|
+
const targetId = route.target ?? profile?.target ?? workers?.default?.target ?? settings.targets?.[0]?.id ?? null;
|
|
343
|
+
if (!targetId) return UNRESOLVED_DOCUMENTER_MODEL;
|
|
344
|
+
const target = providers.getTarget(targetId);
|
|
345
|
+
const requestedModel = route.model ?? profile?.model ?? workers?.default?.model ?? target?.defaultModel ?? null;
|
|
346
|
+
if (!requestedModel) return UNRESOLVED_DOCUMENTER_MODEL;
|
|
347
|
+
const status = providers.list().find((entry) => entry.target.id === targetId);
|
|
348
|
+
return status ? canonicalizeWireModelId(status, requestedModel) : requestedModel;
|
|
349
|
+
} catch {
|
|
350
|
+
return UNRESOLVED_DOCUMENTER_MODEL;
|
|
351
|
+
} finally {
|
|
352
|
+
await loaded.stop();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function modelWikiGenerate(options = {}) {
|
|
356
|
+
return async (input) => {
|
|
357
|
+
let loaded = null;
|
|
358
|
+
try {
|
|
359
|
+
if (options.dispatch) {
|
|
360
|
+
await generateWikiWithDocumenter(options.dispatch, input, options.route, options.runBudgetMs);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const lazy = await loadWikiDispatch();
|
|
364
|
+
loaded = lazy.loaded;
|
|
365
|
+
await generateWikiWithDocumenter(lazy.dispatch, input, options.route, options.runBudgetMs);
|
|
366
|
+
} finally {
|
|
367
|
+
if (loaded) await loaded.stop();
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
export {
|
|
372
|
+
generateWikiWithDocumenter,
|
|
373
|
+
modelWikiGenerate,
|
|
374
|
+
resolveDocumenterModelId,
|
|
375
|
+
runWikiDispatch
|
|
376
|
+
};
|
|
377
|
+
//# sourceMappingURL=wiki-generate-PKFIX6OB.js.map
|