@tea-agent/loop-agent 0.51.0 → 0.52.0-next.2
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 +91 -5
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +1 -75
- package/dist/cli/help.js +1 -1
- package/dist/cli/program.js +1 -28
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -1
- package/dist/worker/console/chat/api-workbench-core.js +17 -6
- package/dist/worker/console/chat/api-workbench.js +2 -0
- package/dist/worker/console/chat/chat-event-projection.js +2 -0
- package/dist/worker/console/chat/chat-event-store.js +32 -2
- package/dist/worker/console/chat/chat-references.js +4 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +238 -89
- package/dist/worker/console/chat/repo-browser.js +5 -2
- package/dist/worker/console/chat/repo-preview-kind.js +16 -6
- package/dist/worker/console/chat/routes.js +295 -25
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +27 -2
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +52 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +137 -0
- package/dist/worker/console/console-update-runtime.js +5 -1
- package/dist/worker/console/operator-actions.js +7 -6
- package/dist/worker/console/operator-user-error.js +5 -1
- package/dist/worker/console/routes.js +1 -1
- package/dist/worker/console/server.js +89 -5
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-BJkTFDSU.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-BJoqB-FK.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-Dnks_tKL.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-CYfXZ-MS.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-C8QUVTzH.js} +1 -1
- package/dist/worker/console/static/assets/channel-gvXtLBqv.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-BeQTq_mP.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-Cz8TULTz.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-DTGsDFfs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-D3xtdDtx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-CFcH1dmG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-D1oWTPzh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-DQ1784gP.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-BUa9gwx1.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-u-ANrNSL.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-Daj0bhib.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DQ5hdEfB.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DQ5hdEfB.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-Bk1oZEJ1.js +1 -0
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-C4Ev_fka.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-D0n24UDZ.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-C1FlRrys.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-CWpeId5Y.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-CeEU1CTn.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-DgpFxfNH.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3--9JrEf2p.js +41 -0
- package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
- package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-D7E9C_OC.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-OYp4ZJQC.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-Cyf8gGYJ.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-B7gUfjoR.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-mirrpSLp.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-gRb5KI0B.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-v3JGPZ1t.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-jJLc06Q0.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-BJ7qkdrx.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-B8iMATOq.js} +1 -1
- package/dist/worker/console/static/assets/main-BA6TGEgV.js +644 -0
- package/dist/worker/console/static/assets/main-BWBC5cML.css +1 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-C-6iih3_.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-kUxtuaLJ.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CWscAnG2.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-B4P97R-G.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-TK_kx3AZ.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-BvoUgYhv.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-DD-OVcGf.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-C_d-co8f.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-DEDF0c92.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-BI2AD1uG.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-C9N-yQxX.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-BXgVo9RE.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-CPyYpg4o.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DsJnGMMG.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BECT1jaq.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-BHQjX5sj.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-Cq_lSjge.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-BEX8BDY-.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-BTyfZdAf.js} +1 -1
- package/dist/worker/console/static/docx-preview.html +25 -0
- package/dist/worker/console/static/index.html +3 -2
- package/dist/worker/console/static/vcp/fonts/README.md +28 -0
- package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
- package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
- package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
- package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
- package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
- package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
- package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
- package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
- package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
- package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
- package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
- package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
- package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
- package/dist/worker/console/vite.config.js +5 -1
- package/dist/worker/console/workspace-registry.js +62 -19
- package/dist/worker/observe/static/operator-chrome.js +0 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
- package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
- package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
- package/dist/workflows/script/windows/guest.js +13 -2
- package/dist/workflows/script/windows/native.js +21 -3
- package/docs/architecture/dag-execution.md +2 -13
- package/docs/architecture/facts-and-state.md +2 -3
- package/docs/architecture/runtime-boundaries.md +2 -2
- package/package.json +5 -3
- package/resource-catalog.v1.json +6 -6
- package/skills/loop-agent/references/command-reference.md +2 -41
- package/skills/loop-agent/references/harness-policy.md +3 -30
- package/skills/loop-agent/references/long-running-loop.md +6 -54
- package/dist/application/loop/run-action.js +0 -19
- package/dist/commands/dag-workflow-compile.js +0 -93
- package/dist/commands/dag-workflow-plan.js +0 -132
- package/dist/commands/dag-workflow-validate.js +0 -68
- package/dist/commands/loop-benchmark.js +0 -74
- package/dist/commands/loop.js +0 -251
- package/dist/commands/workflow.js +0 -259
- package/dist/infrastructure/harness/loop-store.js +0 -41
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
- package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
- package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
- package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
- package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
- package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
- package/dist/workflows/dynamic/compile.js +0 -371
- package/dist/workflows/dynamic/compileTypes.js +0 -1
- package/dist/workflows/dynamic/errors.js +0 -5
- package/dist/workflows/dynamic/profiles.js +0 -156
- package/dist/workflows/dynamic/spec.js +0 -115
- package/dist/workflows/dynamic/validate.js +0 -275
- package/dist/workflows/loop/actions/dag-action.js +0 -129
- package/dist/workflows/loop/actions/pi-review.js +0 -267
- package/dist/workflows/loop/actions/shared.js +0 -157
- package/dist/workflows/loop/actions/shell-verify.js +0 -82
- package/dist/workflows/loop/actions/types.js +0 -1
- package/dist/workflows/loop/actions/workflow-action.js +0 -255
- package/dist/workflows/loop/actions.js +0 -160
- package/dist/workflows/loop/benchmark.js +0 -513
- package/dist/workflows/loop/closeout.js +0 -135
- package/dist/workflows/loop/context.js +0 -47
- package/dist/workflows/loop/events.js +0 -26
- package/dist/workflows/loop/hash.js +0 -32
- package/dist/workflows/loop/index.js +0 -8
- package/dist/workflows/loop/paths.js +0 -17
- package/dist/workflows/loop/policy/auto-policy.js +0 -112
- package/dist/workflows/loop/policy/path-patterns.js +0 -13
- package/dist/workflows/loop/rounds.js +0 -81
- package/dist/workflows/loop/signals.js +0 -52
- package/dist/workflows/loop/state.js +0 -116
- package/dist/workflows/loop/templates.js +0 -54
- package/dist/workflows/loop/types.js +0 -28
- /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { writeLoopContext } from "../../infrastructure/harness/loop-store.js";
|
|
2
|
-
import { readLoopRounds } from "./rounds.js";
|
|
3
|
-
import { refreshLoopState } from "./state.js";
|
|
4
|
-
import { appendLoopEvent } from "./events.js";
|
|
5
|
-
export async function rewriteLoopContext(repoRoot, taskId) {
|
|
6
|
-
const rounds = await readLoopRounds(repoRoot, taskId);
|
|
7
|
-
const latest = rounds.at(-1);
|
|
8
|
-
if (!latest)
|
|
9
|
-
return "";
|
|
10
|
-
const content = [
|
|
11
|
-
"# Loop Context",
|
|
12
|
-
"",
|
|
13
|
-
"## Current State",
|
|
14
|
-
`- Completed: ${latest.completedCriteria.length > 0 ? latest.completedCriteria.join("; ") : "none newly completed"}.`,
|
|
15
|
-
`- Open frontier: ${latest.next || "choose the next bounded action"}.`,
|
|
16
|
-
`- Current hypothesis: ${latest.decision === "continue" ? latest.next : `loop decision is ${latest.decision}`}.`,
|
|
17
|
-
"",
|
|
18
|
-
"## Verified Facts",
|
|
19
|
-
`- Latest action: ${latest.action}.`,
|
|
20
|
-
`- Latest result: ${latest.result}.`,
|
|
21
|
-
`- Verification: ${latest.verification || "not recorded"}.`,
|
|
22
|
-
`- Evidence refs: ${latest.refs.length > 0 ? latest.refs.join(", ") : "none"}.`,
|
|
23
|
-
"",
|
|
24
|
-
"## Last Round Lessons",
|
|
25
|
-
`- What worked: ${latest.result}.`,
|
|
26
|
-
`- What failed: ${latest.failureCategory || "not classified"}.`,
|
|
27
|
-
`- Avoid next round: ${latest.lesson}.`,
|
|
28
|
-
"",
|
|
29
|
-
"## Next Suggested Action",
|
|
30
|
-
`- Action: ${latest.next}.`,
|
|
31
|
-
`- Why: ${latest.lesson}.`,
|
|
32
|
-
"- Expected evidence: a new rounds.jsonl entry and deterministic verification when claiming completion.",
|
|
33
|
-
"",
|
|
34
|
-
"## Risk Notes",
|
|
35
|
-
`- Last decision: ${latest.decision}.`,
|
|
36
|
-
"",
|
|
37
|
-
].join("\n");
|
|
38
|
-
await writeLoopContext(repoRoot, taskId, content);
|
|
39
|
-
await refreshLoopState(repoRoot, taskId);
|
|
40
|
-
await appendLoopEvent(repoRoot, taskId, {
|
|
41
|
-
type: "context_rewrite",
|
|
42
|
-
round: latest.round,
|
|
43
|
-
message: `context rewritten from round ${latest.round}`,
|
|
44
|
-
refs: latest.refs,
|
|
45
|
-
});
|
|
46
|
-
return content;
|
|
47
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { appendLoopEventLine } from "../../infrastructure/harness/loop-store.js";
|
|
3
|
-
import { getLoopPaths } from "./paths.js";
|
|
4
|
-
export async function appendLoopEvent(repoRoot, taskId, input) {
|
|
5
|
-
const now = new Date().toISOString();
|
|
6
|
-
const entry = {
|
|
7
|
-
schemaVersion: 1,
|
|
8
|
-
id: `${now}-${input.type}`,
|
|
9
|
-
type: input.type,
|
|
10
|
-
taskId,
|
|
11
|
-
round: input.round ?? 0,
|
|
12
|
-
message: input.message,
|
|
13
|
-
refs: input.refs ?? [],
|
|
14
|
-
recordedAt: now,
|
|
15
|
-
};
|
|
16
|
-
await appendLoopEventLine(repoRoot, taskId, entry);
|
|
17
|
-
return entry;
|
|
18
|
-
}
|
|
19
|
-
export async function readLoopEvents(repoRoot, taskId) {
|
|
20
|
-
const raw = await readFile(getLoopPaths(repoRoot, taskId).eventsPath, "utf-8").catch(() => "");
|
|
21
|
-
return raw
|
|
22
|
-
.split("\n")
|
|
23
|
-
.map((line) => line.trim())
|
|
24
|
-
.filter(Boolean)
|
|
25
|
-
.map((line) => JSON.parse(line));
|
|
26
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { listTaskSourceFiles } from "../../task/runtime.js";
|
|
5
|
-
export function sha256Text(text) {
|
|
6
|
-
return createHash("sha256").update(text).digest("hex");
|
|
7
|
-
}
|
|
8
|
-
export async function hashFileIfPresent(filePath) {
|
|
9
|
-
try {
|
|
10
|
-
return sha256Text(await readFile(filePath, "utf-8"));
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
if (typeof error === "object" &&
|
|
14
|
-
error !== null &&
|
|
15
|
-
"code" in error &&
|
|
16
|
-
error.code === "ENOENT") {
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export async function hashTaskSource(repoRoot, taskId) {
|
|
23
|
-
const files = await listTaskSourceFiles(repoRoot, taskId);
|
|
24
|
-
const sourceDir = path.join(repoRoot, ".harness", "tasks", taskId, "source");
|
|
25
|
-
const chunks = [];
|
|
26
|
-
for (const file of files.sort()) {
|
|
27
|
-
const abs = path.isAbsolute(file) ? file : path.join(sourceDir, file);
|
|
28
|
-
const relative = path.relative(sourceDir, abs);
|
|
29
|
-
chunks.push(`${relative}\n${await readFile(abs, "utf-8")}`);
|
|
30
|
-
}
|
|
31
|
-
return sha256Text(chunks.join("\n--- source file ---\n"));
|
|
32
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { getLoopPaths } from "./paths.js";
|
|
2
|
-
export { initializeLoop, loadLoopState, refreshLoopState, saveLoopState, } from "./state.js";
|
|
3
|
-
export { appendLoopRound, readLoopRounds } from "./rounds.js";
|
|
4
|
-
export { rewriteLoopContext } from "./context.js";
|
|
5
|
-
export { appendLoopSignal, drainLoopSignals, parseLoopSignalType, pendingLoopSignals, readLoopSignals, } from "./signals.js";
|
|
6
|
-
export { appendLoopEvent, readLoopEvents } from "./events.js";
|
|
7
|
-
export { generateLoopCloseout } from "./closeout.js";
|
|
8
|
-
export { buildLoopPiReviewPrompt, decideNextLoopAutoAction, resolveLoopShellVerifyCommands, runLoopAuto, runLoopDagAction, runLoopPiReview, runLoopShellVerification, runLoopWorkflowGateSignalAction, runLoopWorkflowAction, } from "./actions.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { getTaskDir } from "../../task/runtime.js";
|
|
3
|
-
export function getLoopPaths(repoRoot, taskId) {
|
|
4
|
-
const loopDir = path.join(getTaskDir(repoRoot, taskId), "loop");
|
|
5
|
-
return {
|
|
6
|
-
loopDir,
|
|
7
|
-
objectivePath: path.join(loopDir, "objective.md"),
|
|
8
|
-
contextPath: path.join(loopDir, "context.md"),
|
|
9
|
-
statePath: path.join(loopDir, "state.json"),
|
|
10
|
-
roundsPath: path.join(loopDir, "rounds.jsonl"),
|
|
11
|
-
signalsPath: path.join(loopDir, "signals.jsonl"),
|
|
12
|
-
closeoutPath: path.join(loopDir, "closeout.md"),
|
|
13
|
-
eventsPath: path.join(loopDir, "events.jsonl"),
|
|
14
|
-
verificationDir: path.join(loopDir, "verification"),
|
|
15
|
-
reviewDir: path.join(loopDir, "reviews"),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { pendingLoopSignals } from "../signals.js";
|
|
2
|
-
export function decideNextLoopAutoAction(state, signals = [], options = {}) {
|
|
3
|
-
const pendingSignals = pendingLoopSignals(signals);
|
|
4
|
-
const urgent = pendingSignals.find((signal) => signal.urgent);
|
|
5
|
-
if (urgent) {
|
|
6
|
-
return {
|
|
7
|
-
action: "pause",
|
|
8
|
-
reason: `urgent ${urgent.type} signal: ${urgent.message}`,
|
|
9
|
-
decision: "pause",
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
const scopeChanged = pendingSignals.find((signal) => signal.type === "scope_changed");
|
|
13
|
-
if (scopeChanged) {
|
|
14
|
-
return {
|
|
15
|
-
action: "pause",
|
|
16
|
-
reason: `scope changed signal requires objective/context review: ${scopeChanged.message}`,
|
|
17
|
-
decision: "pause",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const reviewSignal = pendingSignals.find((signal) => signal.type === "review_feedback" || signal.type === "human_followup");
|
|
21
|
-
if (reviewSignal) {
|
|
22
|
-
return {
|
|
23
|
-
action: "pi-review",
|
|
24
|
-
reason: `${reviewSignal.type} signal requires read-only review: ${reviewSignal.message}`,
|
|
25
|
-
decision: "continue",
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (state.round >= state.maxRounds) {
|
|
29
|
-
return {
|
|
30
|
-
action: "blocked",
|
|
31
|
-
reason: `loop maxRounds reached (${state.round}/${state.maxRounds})`,
|
|
32
|
-
decision: "blocked",
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (state.failureStreak.category && state.failureStreak.count >= 2) {
|
|
36
|
-
return {
|
|
37
|
-
action: "blocked",
|
|
38
|
-
reason: `repeated failure category ${state.failureStreak.category} x${state.failureStreak.count}`,
|
|
39
|
-
decision: "blocked",
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (state.freshness.sourceStale) {
|
|
43
|
-
return {
|
|
44
|
-
action: "pause",
|
|
45
|
-
reason: "task source changed; rebuild or review action prompt before continuing",
|
|
46
|
-
decision: "pause",
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (state.lastAction === "shell-verify") {
|
|
50
|
-
return {
|
|
51
|
-
action: "pi-review",
|
|
52
|
-
reason: "shell verification already ran; request read-only review before next implementation decision",
|
|
53
|
-
decision: "continue",
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (state.lastAction === "pi-review") {
|
|
57
|
-
if (options.latestPiReview?.recommendedAction === "implement_fix") {
|
|
58
|
-
const policy = options.loopAutoExecutionPolicy ?? "off";
|
|
59
|
-
const approvalSignal = pendingSignals.find((signal) => signal.type === "approval");
|
|
60
|
-
const approved = Boolean(options.approvalGranted) || Boolean(approvalSignal);
|
|
61
|
-
if (policy === "off") {
|
|
62
|
-
return {
|
|
63
|
-
action: "dag",
|
|
64
|
-
dagMode: "review",
|
|
65
|
-
reason: `pi-review recommended implement_fix; loopAutoExecutionPolicy=off (DAG review only)`,
|
|
66
|
-
decision: "continue",
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (policy === "approval-required" && !approved) {
|
|
70
|
-
return {
|
|
71
|
-
action: "pause",
|
|
72
|
-
reason: `pi-review recommended implement_fix; loopAutoExecutionPolicy=approval-required without approval`,
|
|
73
|
-
decision: "pause",
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
action: "dag",
|
|
78
|
-
dagMode: "execute",
|
|
79
|
-
reason: `pi-review recommended implement_fix; loopAutoExecutionPolicy=${policy}`,
|
|
80
|
-
decision: "continue",
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
action: "dag",
|
|
85
|
-
dagMode: "review",
|
|
86
|
-
reason: "read-only review produced next action; generate a governed DAG review packet",
|
|
87
|
-
decision: "continue",
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const approvalSignal = pendingSignals.find((signal) => signal.type === "approval");
|
|
91
|
-
if (approvalSignal) {
|
|
92
|
-
return {
|
|
93
|
-
action: "dag",
|
|
94
|
-
dagMode: "review",
|
|
95
|
-
reason: `approval signal received; generate next governed DAG packet: ${approvalSignal.message}`,
|
|
96
|
-
decision: "continue",
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
if (state.lastAction === "dag") {
|
|
100
|
-
return {
|
|
101
|
-
action: "shell-verify",
|
|
102
|
-
reason: "dag round must be followed by deterministic shell verification",
|
|
103
|
-
decision: "continue",
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
action: "dag",
|
|
108
|
-
dagMode: "review",
|
|
109
|
-
reason: "default to DAG governed review packet for the next bounded round",
|
|
110
|
-
decision: "continue",
|
|
111
|
-
};
|
|
112
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { pathMatchesPattern } from "../../../shared/git-progress.js";
|
|
2
|
-
export function normalizePattern(pattern) {
|
|
3
|
-
return pattern.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/\*\*$/, "");
|
|
4
|
-
}
|
|
5
|
-
export function patternsOverlap(allowed, forbidden) {
|
|
6
|
-
const a = normalizePattern(allowed);
|
|
7
|
-
const f = normalizePattern(forbidden);
|
|
8
|
-
return (a === f ||
|
|
9
|
-
a.startsWith(`${f}/`) ||
|
|
10
|
-
f.startsWith(`${a}/`) ||
|
|
11
|
-
pathMatchesPattern(a, forbidden) ||
|
|
12
|
-
pathMatchesPattern(f, allowed));
|
|
13
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { writeLoopRounds } from "../../infrastructure/harness/loop-store.js";
|
|
3
|
-
import { getLoopPaths } from "./paths.js";
|
|
4
|
-
import { refreshLoopState } from "./state.js";
|
|
5
|
-
import { appendLoopEvent } from "./events.js";
|
|
6
|
-
function statusForDecision(decision) {
|
|
7
|
-
if (decision === "continue")
|
|
8
|
-
return "running";
|
|
9
|
-
if (decision === "pause")
|
|
10
|
-
return "paused";
|
|
11
|
-
return decision;
|
|
12
|
-
}
|
|
13
|
-
export async function readLoopRounds(repoRoot, taskId) {
|
|
14
|
-
const raw = await readFile(getLoopPaths(repoRoot, taskId).roundsPath, "utf-8");
|
|
15
|
-
return raw
|
|
16
|
-
.split("\n")
|
|
17
|
-
.map((line) => line.trim())
|
|
18
|
-
.filter(Boolean)
|
|
19
|
-
.map((line) => JSON.parse(line));
|
|
20
|
-
}
|
|
21
|
-
export async function appendLoopRound(repoRoot, taskId, input) {
|
|
22
|
-
const rounds = await readLoopRounds(repoRoot, taskId);
|
|
23
|
-
const entry = {
|
|
24
|
-
schemaVersion: 1,
|
|
25
|
-
round: rounds.length + 1,
|
|
26
|
-
recordedAt: new Date().toISOString(),
|
|
27
|
-
action: input.action,
|
|
28
|
-
refs: input.refs ?? [],
|
|
29
|
-
result: input.result,
|
|
30
|
-
verification: input.verification ?? "",
|
|
31
|
-
lesson: input.lesson,
|
|
32
|
-
next: input.next,
|
|
33
|
-
decision: input.decision,
|
|
34
|
-
failureCategory: input.failureCategory ?? "",
|
|
35
|
-
completedCriteria: input.completedCriteria ?? [],
|
|
36
|
-
};
|
|
37
|
-
await appendLoopEvent(repoRoot, taskId, {
|
|
38
|
-
type: "round_start",
|
|
39
|
-
round: entry.round,
|
|
40
|
-
message: `recording round ${entry.round} action ${entry.action}`,
|
|
41
|
-
refs: entry.refs,
|
|
42
|
-
});
|
|
43
|
-
await writeLoopRounds(repoRoot, taskId, [...rounds, entry]);
|
|
44
|
-
const previousState = await refreshLoopState(repoRoot, taskId, {
|
|
45
|
-
status: statusForDecision(entry.decision),
|
|
46
|
-
round: entry.round,
|
|
47
|
-
lastDecision: entry.decision,
|
|
48
|
-
lastAction: entry.action,
|
|
49
|
-
lastExecutorRef: entry.refs[0] ?? "",
|
|
50
|
-
openFrontier: entry.next ? [entry.next] : [],
|
|
51
|
-
completedCriteria: entry.completedCriteria,
|
|
52
|
-
});
|
|
53
|
-
if (entry.failureCategory) {
|
|
54
|
-
await refreshLoopState(repoRoot, taskId, {
|
|
55
|
-
failureStreak: {
|
|
56
|
-
category: entry.failureCategory,
|
|
57
|
-
count: previousState.failureStreak.category === entry.failureCategory
|
|
58
|
-
? previousState.failureStreak.count + 1
|
|
59
|
-
: 1,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
else if (previousState.failureStreak.category) {
|
|
64
|
-
await refreshLoopState(repoRoot, taskId, {
|
|
65
|
-
failureStreak: { category: "", count: 0 },
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
await appendLoopEvent(repoRoot, taskId, {
|
|
69
|
-
type: "action_finish",
|
|
70
|
-
round: entry.round,
|
|
71
|
-
message: `${entry.action}: ${entry.result}`,
|
|
72
|
-
refs: entry.refs,
|
|
73
|
-
});
|
|
74
|
-
await appendLoopEvent(repoRoot, taskId, {
|
|
75
|
-
type: "decision",
|
|
76
|
-
round: entry.round,
|
|
77
|
-
message: `decision=${entry.decision}; next=${entry.next}`,
|
|
78
|
-
refs: entry.refs,
|
|
79
|
-
});
|
|
80
|
-
return entry;
|
|
81
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { writeLoopSignals as persistLoopSignals } from "../../infrastructure/harness/loop-store.js";
|
|
3
|
-
import { getLoopPaths } from "./paths.js";
|
|
4
|
-
import { LOOP_SIGNAL_TYPES, } from "./types.js";
|
|
5
|
-
export function parseLoopSignalType(value) {
|
|
6
|
-
if (LOOP_SIGNAL_TYPES.includes(value)) {
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
throw new Error(`invalid loop signal type: ${value} (expected ${LOOP_SIGNAL_TYPES.join("|")})`);
|
|
10
|
-
}
|
|
11
|
-
export async function readLoopSignals(repoRoot, taskId) {
|
|
12
|
-
const raw = await readFile(getLoopPaths(repoRoot, taskId).signalsPath, "utf-8").catch(() => "");
|
|
13
|
-
return raw
|
|
14
|
-
.split("\n")
|
|
15
|
-
.map((line) => line.trim())
|
|
16
|
-
.filter(Boolean)
|
|
17
|
-
.map((line) => JSON.parse(line));
|
|
18
|
-
}
|
|
19
|
-
export async function appendLoopSignal(repoRoot, taskId, input) {
|
|
20
|
-
const signals = await readLoopSignals(repoRoot, taskId);
|
|
21
|
-
const now = new Date().toISOString();
|
|
22
|
-
const entry = {
|
|
23
|
-
schemaVersion: 1,
|
|
24
|
-
id: `${now}-${signals.length + 1}`,
|
|
25
|
-
type: input.type,
|
|
26
|
-
message: input.message.trim(),
|
|
27
|
-
urgent: input.urgent ?? false,
|
|
28
|
-
refs: input.refs ?? [],
|
|
29
|
-
createdAt: now,
|
|
30
|
-
drainedAt: "",
|
|
31
|
-
};
|
|
32
|
-
if (!entry.message) {
|
|
33
|
-
throw new Error("loop signal message cannot be empty");
|
|
34
|
-
}
|
|
35
|
-
await persistLoopSignals(repoRoot, taskId, [...signals, entry]);
|
|
36
|
-
return entry;
|
|
37
|
-
}
|
|
38
|
-
export function pendingLoopSignals(signals) {
|
|
39
|
-
return signals.filter((signal) => !signal.drainedAt);
|
|
40
|
-
}
|
|
41
|
-
export async function drainLoopSignals(repoRoot, taskId, ids) {
|
|
42
|
-
if (ids.length === 0)
|
|
43
|
-
return readLoopSignals(repoRoot, taskId);
|
|
44
|
-
const idSet = new Set(ids);
|
|
45
|
-
const now = new Date().toISOString();
|
|
46
|
-
const signals = await readLoopSignals(repoRoot, taskId);
|
|
47
|
-
const drained = signals.map((signal) => idSet.has(signal.id) && !signal.drainedAt
|
|
48
|
-
? { ...signal, drainedAt: now }
|
|
49
|
-
: signal);
|
|
50
|
-
await persistLoopSignals(repoRoot, taskId, drained);
|
|
51
|
-
return drained;
|
|
52
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { access, readFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { ensureLoopDir, writeLoopContext, writeLoopObjective, writeLoopRounds, writeLoopSignals, writeLoopEvents, writeLoopState, } from "../../infrastructure/harness/loop-store.js";
|
|
4
|
-
import { getTaskDir } from "../../task/runtime.js";
|
|
5
|
-
import { hashFileIfPresent, hashTaskSource } from "./hash.js";
|
|
6
|
-
import { getLoopPaths } from "./paths.js";
|
|
7
|
-
import { defaultContext, defaultObjective } from "./templates.js";
|
|
8
|
-
import { appendLoopEvent } from "./events.js";
|
|
9
|
-
async function exists(filePath) {
|
|
10
|
-
try {
|
|
11
|
-
await access(filePath);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
if (typeof error === "object" &&
|
|
16
|
-
error !== null &&
|
|
17
|
-
"code" in error &&
|
|
18
|
-
error.code === "ENOENT") {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function rel(repoRoot, filePath) {
|
|
25
|
-
return path.relative(repoRoot, filePath);
|
|
26
|
-
}
|
|
27
|
-
export async function buildLoopState(repoRoot, taskId, paths = getLoopPaths(repoRoot, taskId), previous) {
|
|
28
|
-
const now = new Date().toISOString();
|
|
29
|
-
const objectiveHash = await hashFileIfPresent(paths.objectivePath);
|
|
30
|
-
const contextHash = await hashFileIfPresent(paths.contextPath);
|
|
31
|
-
const sourceHash = await hashTaskSource(repoRoot, taskId);
|
|
32
|
-
const previousSourceHash = previous?.sourceHash ?? sourceHash;
|
|
33
|
-
return {
|
|
34
|
-
schemaVersion: 1,
|
|
35
|
-
taskId,
|
|
36
|
-
status: previous?.status ?? "draft",
|
|
37
|
-
round: previous?.round ?? 0,
|
|
38
|
-
maxRounds: previous?.maxRounds ?? 8,
|
|
39
|
-
objectivePath: rel(repoRoot, paths.objectivePath),
|
|
40
|
-
contextPath: rel(repoRoot, paths.contextPath),
|
|
41
|
-
roundsPath: rel(repoRoot, paths.roundsPath),
|
|
42
|
-
objectiveHash,
|
|
43
|
-
contextHash,
|
|
44
|
-
sourceHash,
|
|
45
|
-
freshness: {
|
|
46
|
-
objectiveHash,
|
|
47
|
-
contextHash,
|
|
48
|
-
sourceHash,
|
|
49
|
-
sourceStale: sourceHash !== previousSourceHash,
|
|
50
|
-
lastCheckedAt: now,
|
|
51
|
-
},
|
|
52
|
-
lastDecision: previous?.lastDecision ?? "init",
|
|
53
|
-
lastAction: previous?.lastAction ?? "init",
|
|
54
|
-
lastExecutorRef: previous?.lastExecutorRef ?? "",
|
|
55
|
-
openFrontier: previous?.openFrontier ?? ["choose the next bounded action"],
|
|
56
|
-
completedCriteria: previous?.completedCriteria ?? [],
|
|
57
|
-
failureStreak: previous?.failureStreak ?? { category: "", count: 0 },
|
|
58
|
-
createdAt: previous?.createdAt ?? now,
|
|
59
|
-
updatedAt: now,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export async function saveLoopState(repoRoot, taskId, state) {
|
|
63
|
-
await writeLoopState(repoRoot, taskId, state);
|
|
64
|
-
}
|
|
65
|
-
export async function loadLoopState(repoRoot, taskId) {
|
|
66
|
-
const paths = getLoopPaths(repoRoot, taskId);
|
|
67
|
-
const raw = await readFile(paths.statePath, "utf-8");
|
|
68
|
-
return JSON.parse(raw);
|
|
69
|
-
}
|
|
70
|
-
export async function refreshLoopState(repoRoot, taskId, patch = {}) {
|
|
71
|
-
const previous = await loadLoopState(repoRoot, taskId);
|
|
72
|
-
const state = await buildLoopState(repoRoot, taskId, undefined, {
|
|
73
|
-
...previous,
|
|
74
|
-
...patch,
|
|
75
|
-
});
|
|
76
|
-
await saveLoopState(repoRoot, taskId, state);
|
|
77
|
-
return state;
|
|
78
|
-
}
|
|
79
|
-
export async function initializeLoop(repoRoot, taskId, options = {}) {
|
|
80
|
-
const taskDir = getTaskDir(repoRoot, taskId);
|
|
81
|
-
if (!(await exists(taskDir))) {
|
|
82
|
-
throw new Error(`task does not exist: ${taskId}`);
|
|
83
|
-
}
|
|
84
|
-
const paths = getLoopPaths(repoRoot, taskId);
|
|
85
|
-
const stateExists = await exists(paths.statePath);
|
|
86
|
-
if (stateExists && !options.recover) {
|
|
87
|
-
throw new Error(`loop already initialized for task: ${taskId}`);
|
|
88
|
-
}
|
|
89
|
-
await ensureLoopDir(repoRoot, taskId);
|
|
90
|
-
if (!(await exists(paths.objectivePath))) {
|
|
91
|
-
await writeLoopObjective(repoRoot, taskId, defaultObjective(taskId));
|
|
92
|
-
}
|
|
93
|
-
if (!(await exists(paths.contextPath))) {
|
|
94
|
-
await writeLoopContext(repoRoot, taskId, defaultContext());
|
|
95
|
-
}
|
|
96
|
-
if (!(await exists(paths.roundsPath))) {
|
|
97
|
-
await writeLoopRounds(repoRoot, taskId, []);
|
|
98
|
-
}
|
|
99
|
-
if (!(await exists(paths.signalsPath))) {
|
|
100
|
-
await writeLoopSignals(repoRoot, taskId, []);
|
|
101
|
-
}
|
|
102
|
-
if (!(await exists(paths.eventsPath))) {
|
|
103
|
-
await writeLoopEvents(repoRoot, taskId, []);
|
|
104
|
-
}
|
|
105
|
-
const previous = stateExists ? await loadLoopState(repoRoot, taskId) : undefined;
|
|
106
|
-
const state = await buildLoopState(repoRoot, taskId, paths, {
|
|
107
|
-
...previous,
|
|
108
|
-
maxRounds: options.maxRounds ?? previous?.maxRounds ?? 8,
|
|
109
|
-
});
|
|
110
|
-
await saveLoopState(repoRoot, taskId, state);
|
|
111
|
-
await appendLoopEvent(repoRoot, taskId, {
|
|
112
|
-
type: "loop_start",
|
|
113
|
-
message: stateExists ? "loop recovered" : "loop initialized",
|
|
114
|
-
});
|
|
115
|
-
return { created: !stateExists, paths, state };
|
|
116
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export function defaultObjective(taskId) {
|
|
2
|
-
return [
|
|
3
|
-
"# Objective",
|
|
4
|
-
"",
|
|
5
|
-
"## Goal",
|
|
6
|
-
`- Complete the long-running task ${taskId}.`,
|
|
7
|
-
"",
|
|
8
|
-
"## Success Criteria",
|
|
9
|
-
"- Loop success criteria are copied or summarized from source/需求.md.",
|
|
10
|
-
"- Completion requires current shell verification evidence.",
|
|
11
|
-
"",
|
|
12
|
-
"## Scope",
|
|
13
|
-
"- In: work described by the task source materials.",
|
|
14
|
-
"- Out: unrelated repository changes.",
|
|
15
|
-
"",
|
|
16
|
-
"## Constraints",
|
|
17
|
-
"- Allowed paths: see source/执行约束.md.",
|
|
18
|
-
"- Forbidden paths: see source/执行约束.md.",
|
|
19
|
-
"- Verification: see source/执行约束.md.",
|
|
20
|
-
"",
|
|
21
|
-
"## Completion Policy",
|
|
22
|
-
"- Required evidence: shell verification output and referenced executor facts.",
|
|
23
|
-
"- Required review: as specified by the task source or DAG gates.",
|
|
24
|
-
"- Stop conditions: complete, paused, blocked, or max rounds reached.",
|
|
25
|
-
"",
|
|
26
|
-
].join("\n");
|
|
27
|
-
}
|
|
28
|
-
export function defaultContext() {
|
|
29
|
-
return [
|
|
30
|
-
"# Loop Context",
|
|
31
|
-
"",
|
|
32
|
-
"## Current State",
|
|
33
|
-
"- Completed: none recorded yet.",
|
|
34
|
-
"- Open frontier: initialize loop and choose the next bounded action.",
|
|
35
|
-
"- Current hypothesis: storage state must be established before executor integration.",
|
|
36
|
-
"",
|
|
37
|
-
"## Verified Facts",
|
|
38
|
-
"- No loop rounds have been recorded yet.",
|
|
39
|
-
"",
|
|
40
|
-
"## Last Round Lessons",
|
|
41
|
-
"- What worked: none yet.",
|
|
42
|
-
"- What failed: none yet.",
|
|
43
|
-
"- Avoid next round: do not treat chat history as durable state.",
|
|
44
|
-
"",
|
|
45
|
-
"## Next Suggested Action",
|
|
46
|
-
"- Action: record a bounded round with canonical evidence refs.",
|
|
47
|
-
"- Why: loop context should be derived from durable facts.",
|
|
48
|
-
"- Expected evidence: rounds.jsonl entry and rewritten context.md.",
|
|
49
|
-
"",
|
|
50
|
-
"## Risk Notes",
|
|
51
|
-
"- Completion still requires deterministic verification.",
|
|
52
|
-
"",
|
|
53
|
-
].join("\n");
|
|
54
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const LOOP_STATUSES = [
|
|
2
|
-
"draft",
|
|
3
|
-
"running",
|
|
4
|
-
"paused",
|
|
5
|
-
"blocked",
|
|
6
|
-
"complete",
|
|
7
|
-
];
|
|
8
|
-
export const LOOP_DECISIONS = [
|
|
9
|
-
"continue",
|
|
10
|
-
"pause",
|
|
11
|
-
"blocked",
|
|
12
|
-
"complete",
|
|
13
|
-
];
|
|
14
|
-
export const LOOP_EVENT_TYPES = [
|
|
15
|
-
"loop_start",
|
|
16
|
-
"round_start",
|
|
17
|
-
"action_start",
|
|
18
|
-
"action_finish",
|
|
19
|
-
"context_rewrite",
|
|
20
|
-
"decision",
|
|
21
|
-
"loop_finish",
|
|
22
|
-
];
|
|
23
|
-
export const LOOP_SIGNAL_TYPES = [
|
|
24
|
-
"human_followup",
|
|
25
|
-
"approval",
|
|
26
|
-
"scope_changed",
|
|
27
|
-
"review_feedback",
|
|
28
|
-
];
|
|
File without changes
|