@wrongstack/core 0.313.0 → 0.316.1
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/dist/chronicle/index.js +84 -6391
- package/dist/chronicle/legacy-journal-import.d.ts +0 -6
- package/dist/chronicle/metrics-ingest.d.ts +14 -0
- package/dist/chronicle/metrics-schema.d.ts +10 -1
- package/dist/chronicle/metrics-store.d.ts +20 -2
- package/dist/chronicle/project-server.js +98 -4874
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/chunk-25LSLC3G.js +334 -0
- package/dist/chunk-27QIURLN.js +1073 -0
- package/dist/chunk-2FK4WTFF.js +207 -0
- package/dist/chunk-2YU4WVBW.js +134 -0
- package/dist/chunk-3AGWVSS7.js +4608 -0
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/chunk-3ECENVHL.js +325 -0
- package/dist/chunk-3XPVB7BA.js +135 -0
- package/dist/chunk-45WI72ZB.js +16884 -0
- package/dist/chunk-4BMVPOHO.js +3748 -0
- package/dist/chunk-4I7HGVVA.js +363 -0
- package/dist/chunk-4LCZVJVF.js +317 -0
- package/dist/chunk-4SJNS7OB.js +217 -0
- package/dist/chunk-4VWO3ZXL.js +342 -0
- package/dist/chunk-57GEWK5X.js +26 -0
- package/dist/chunk-5BMIE7QG.js +46 -0
- package/dist/chunk-5S437PRC.js +50 -0
- package/dist/chunk-5XDUGTKN.js +511 -0
- package/dist/chunk-5YPSXQXM.js +1443 -0
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/chunk-6H5GEOET.js +2406 -0
- package/dist/chunk-6NWEVFEL.js +151 -0
- package/dist/chunk-AYW5YINX.js +58 -0
- package/dist/chunk-B4AMLZPB.js +9 -0
- package/dist/chunk-B7F4WVP4.js +65 -0
- package/dist/chunk-BJHVULHO.js +55 -0
- package/dist/chunk-BPBKKBUK.js +2085 -0
- package/dist/chunk-BYD345OX.js +589 -0
- package/dist/chunk-C27KDLOX.js +279 -0
- package/dist/chunk-CU546ESW.js +597 -0
- package/dist/chunk-DLHHXUAM.js +172 -0
- package/dist/chunk-DOTHQSJ2.js +429 -0
- package/dist/chunk-DYLPMV4Q.js +711 -0
- package/dist/chunk-EODDVJBM.js +82 -0
- package/dist/chunk-F3JWNST7.js +361 -0
- package/dist/chunk-FC2ZGRF3.js +140 -0
- package/dist/chunk-FCBTO76Z.js +5786 -0
- package/dist/chunk-FHZVFYSL.js +396 -0
- package/dist/chunk-FNXVT7HF.js +52 -0
- package/dist/chunk-FWNLEZYG.js +259 -0
- package/dist/chunk-FXQLIX3K.js +211 -0
- package/dist/chunk-G5S3S5ZN.js +38 -0
- package/dist/chunk-GDQ7CZRQ.js +116 -0
- package/dist/chunk-GJJGJB2R.js +1374 -0
- package/dist/chunk-GTCU6DZ3.js +1 -0
- package/dist/chunk-HA4ZYA6T.js +178 -0
- package/dist/chunk-HI3JGZR2.js +188 -0
- package/dist/chunk-HMLIGAU7.js +395 -0
- package/dist/chunk-HXKZ7OBQ.js +303 -0
- package/dist/chunk-I7DALG7J.js +292 -0
- package/dist/chunk-IRUTEHCE.js +960 -0
- package/dist/chunk-IYFBFX34.js +86 -0
- package/dist/chunk-J2WRWR37.js +1104 -0
- package/dist/chunk-JFPJ6LLQ.js +129 -0
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/chunk-JO4MGB6Z.js +1264 -0
- package/dist/chunk-JVKB2TBL.js +48 -0
- package/dist/chunk-JX7VBZDK.js +31 -0
- package/dist/chunk-K6BXGITA.js +931 -0
- package/dist/chunk-KDQJCT2J.js +45 -0
- package/dist/chunk-KJ2ZTQSL.js +47 -0
- package/dist/chunk-KZMSZV32.js +187 -0
- package/dist/chunk-LA7CLDRW.js +129 -0
- package/dist/chunk-LHOA5DWA.js +28 -0
- package/dist/chunk-LSMMOS2Z.js +119 -0
- package/dist/chunk-LX5QWLBL.js +27 -0
- package/dist/chunk-LXWCMQNJ.js +789 -0
- package/dist/chunk-M27LIEKV.js +2829 -0
- package/dist/chunk-MJPHJRAL.js +663 -0
- package/dist/chunk-MTL4O5YR.js +228 -0
- package/dist/chunk-NDBIPFNY.js +102 -0
- package/dist/chunk-NEMIWEXC.js +1199 -0
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/chunk-NIOAGFPB.js +1510 -0
- package/dist/chunk-NS52ISWS.js +355 -0
- package/dist/chunk-NSOFPKGT.js +5352 -0
- package/dist/chunk-NVIZG63R.js +757 -0
- package/dist/chunk-O37BQ65S.js +21 -0
- package/dist/chunk-OOYZPOXM.js +308 -0
- package/dist/chunk-OSGLYW5J.js +28 -0
- package/dist/chunk-PFCMSSUF.js +1640 -0
- package/dist/chunk-PFZO3C6H.js +14 -0
- package/dist/chunk-PGRVXIMY.js +158 -0
- package/dist/chunk-PHH7LD45.js +113 -0
- package/dist/chunk-PISBFBJN.js +109 -0
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/chunk-PQNS3U7Z.js +1240 -0
- package/dist/chunk-QSTSJOCK.js +402 -0
- package/dist/chunk-RFQMOKWK.js +282 -0
- package/dist/chunk-RJIZEJ42.js +30 -0
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/chunk-RXKSDUAU.js +1172 -0
- package/dist/chunk-S45JPKQN.js +3317 -0
- package/dist/chunk-SAFHACFA.js +152 -0
- package/dist/chunk-SQJVFEBV.js +41 -0
- package/dist/chunk-SVT4RNTR.js +49 -0
- package/dist/chunk-SWUFN7XM.js +43 -0
- package/dist/chunk-SXMVYC5H.js +174 -0
- package/dist/chunk-SZ6AYUIZ.js +23 -0
- package/dist/chunk-TBRL2RCC.js +9 -0
- package/dist/chunk-TCCHINEF.js +655 -0
- package/dist/chunk-THEGTRAG.js +316 -0
- package/dist/chunk-TR4LQE7L.js +2256 -0
- package/dist/chunk-TRT2HRWZ.js +18 -0
- package/dist/chunk-TWJMGXCI.js +900 -0
- package/dist/chunk-U45AXT5D.js +1023 -0
- package/dist/chunk-U4FWBSO3.js +509 -0
- package/dist/chunk-UBGDX6FI.js +147 -0
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/chunk-ULMAQV3T.js +234 -0
- package/dist/chunk-VVBP6KGT.js +9 -0
- package/dist/chunk-W5VITDM2.js +168 -0
- package/dist/chunk-WAHQVNWT.js +194 -0
- package/dist/chunk-WBPVKEEE.js +227 -0
- package/dist/chunk-WGGYRBXH.js +5434 -0
- package/dist/chunk-WLYKU45P.js +5770 -0
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/chunk-WQQON3SV.js +473 -0
- package/dist/chunk-WQTOVMGV.js +119 -0
- package/dist/chunk-XBDP4QPW.js +7 -0
- package/dist/chunk-XEBHSJLT.js +103 -0
- package/dist/chunk-XF4VUMKW.js +231 -0
- package/dist/chunk-XQ2ECNK3.js +1 -0
- package/dist/chunk-Y5YXDM7D.js +74 -0
- package/dist/chunk-YOPAUVU4.js +2588 -0
- package/dist/chunk-YPT4A46F.js +362 -0
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/chunk-YY6APYUM.js +49 -0
- package/dist/chunk-Z2IJUO45.js +691 -0
- package/dist/chunk-ZHZ2Y2DH.js +1643 -0
- package/dist/chunk-ZT7JNIGX.js +152 -0
- package/dist/coordination/agent-monitor.d.ts +9 -1
- package/dist/coordination/agent-subagent-runner.d.ts +1 -1
- package/dist/coordination/agents/agent-prompts.d.ts +8 -0
- package/dist/coordination/agents/index.d.ts +33 -1
- package/dist/coordination/agents/index.js +184 -6269
- package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
- package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
- package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
- package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
- package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
- package/dist/coordination/agents/types.d.ts +13 -2
- package/dist/coordination/brain-monitor.d.ts +30 -7
- package/dist/coordination/collab-debug.d.ts +1 -1
- package/dist/coordination/collab-pause.d.ts +1 -1
- package/dist/coordination/delegate-tool.d.ts +7 -5
- package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
- package/dist/coordination/director-options.d.ts +7 -0
- package/dist/coordination/director-spawn-model.d.ts +17 -0
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/director.d.ts +12 -0
- package/dist/coordination/dispatcher.d.ts +8 -0
- package/dist/coordination/fleet-bus.d.ts +35 -4
- package/dist/coordination/fleet-supervisor.d.ts +10 -2
- package/dist/coordination/fleet.d.ts +16 -7
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +402 -34324
- package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
- package/dist/coordination/mailbox-http-router.d.ts +4 -3
- package/dist/coordination/mailbox-http-validation.d.ts +1 -1
- package/dist/coordination/mailbox-project-server.js +48 -3276
- package/dist/coordination/mailbox-types.d.ts +24 -6
- package/dist/coordination/model-tier-leader.d.ts +122 -0
- package/dist/coordination/model-tier.d.ts +122 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
- package/dist/coordination/origin-session.d.ts +16 -0
- package/dist/coordination/provider-status-tracker.d.ts +41 -5
- package/dist/coordination/session-note-hub.d.ts +44 -0
- package/dist/coordination/session-note-tool.d.ts +10 -0
- package/dist/core/agent.d.ts +15 -2
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +239 -12360
- package/dist/core/model-ref.js +5 -23
- package/dist/core/provider-runner.d.ts +36 -1
- package/dist/core/request-conversation-binding.d.ts +37 -0
- package/dist/core/session-notes.d.ts +25 -0
- package/dist/core/system-prompt-builder.d.ts +11 -2
- package/dist/core/system-prompt-variants.d.ts +78 -0
- package/dist/design/index.js +50 -1087
- package/dist/execution/auto-compaction-middleware.d.ts +11 -0
- package/dist/execution/autonomy-brain.d.ts +2 -1
- package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
- package/dist/execution/compaction-core.d.ts +4 -4
- package/dist/execution/eternal-autonomy.d.ts +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +1615 -21895
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/execution/prompt-enhancer.js +16 -535
- package/dist/execution/retry-policy.d.ts +31 -1
- package/dist/extension/index.js +7 -311
- package/dist/goal/index.js +33 -3435
- package/dist/hooks/index.js +14 -1138
- package/dist/hq/index.js +114 -5139
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/protocol.js +21 -668
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +1502 -92655
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +504 -5230
- package/dist/infrastructure/token-counter.d.ts +9 -0
- package/dist/kernel/events/agent-events.d.ts +77 -3
- package/dist/kernel/events/brain-events.d.ts +12 -0
- package/dist/kernel/events/provider-events.d.ts +22 -1
- package/dist/kernel/events/session-events.d.ts +14 -0
- package/dist/kernel/events/tool-events.d.ts +13 -0
- package/dist/kernel/index.js +14 -992
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +41 -1117
- package/dist/notifications/index.js +3 -108
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +477 -631
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +600 -14835
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/plugins/review-finding-store.js +22 -0
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/plugins/review-report-store.js +20 -0
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +14 -948
- package/dist/registry/index.js +9 -822
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/registry-7N4O3E7W.js +14 -0
- package/dist/replay/index.js +6 -84
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +161 -2235
- package/dist/security/permission-policy.d.ts +12 -1
- package/dist/security/secret-scrubber.d.ts +15 -0
- package/dist/session-catalog/index.d.ts +1 -0
- package/dist/session-catalog/index.js +41 -2103
- package/dist/session-catalog/project-server.js +59 -1435
- package/dist/session-catalog/protocol.d.ts +32 -1
- package/dist/session-catalog/registry.d.ts +17 -1
- package/dist/session-catalog/session-agents.d.ts +56 -0
- package/dist/session-catalog/store-rebuild.d.ts +14 -0
- package/dist/session-catalog/store-schema.d.ts +26 -0
- package/dist/session-catalog/store.d.ts +27 -1
- package/dist/session-note-attach.d.ts +9 -0
- package/dist/skills/index.js +35 -1578
- package/dist/statusline/index.d.ts +43 -0
- package/dist/statusline/index.js +102 -0
- package/dist/storage/board-store-port.d.ts +2 -2
- package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
- package/dist/storage/config-loader.d.ts +3 -2
- package/dist/storage/file-session-writer.d.ts +4 -2
- package/dist/storage/goal-coordination.d.ts +6 -1
- package/dist/storage/goal-kanban.d.ts +4 -1
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +198 -15601
- package/dist/storage/input-history-store.d.ts +2 -4
- package/dist/storage/memory-curator.d.ts +133 -0
- package/dist/storage/session-agent-attribution.d.ts +39 -0
- package/dist/storage/session-doctor.d.ts +109 -0
- package/dist/storage/session-event-bridge.d.ts +5 -7
- package/dist/storage/session-outcome.d.ts +42 -0
- package/dist/storage/session-recovery.d.ts +55 -0
- package/dist/storage/session-store/load-session-data.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +1 -1
- package/dist/storage/session-store/resume-session.d.ts +0 -2
- package/dist/storage/session-store/types.d.ts +8 -0
- package/dist/storage/session-store.d.ts +3 -3
- package/dist/storage/session-summary-tracker.d.ts +8 -1
- package/dist/storage/session-write-buffer.d.ts +18 -0
- package/dist/storage/session-writer-truncate.d.ts +2 -0
- package/dist/tasking/index.js +10 -676
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +52 -9590
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- package/dist/types/config/autonomy.d.ts +5 -0
- package/dist/types/config/mcp-features.d.ts +7 -0
- package/dist/types/config/model-tiers.d.ts +148 -0
- package/dist/types/config/root.d.ts +9 -0
- package/dist/types/config/tools.d.ts +73 -0
- package/dist/types/config/ui.d.ts +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/default-config.d.ts +6 -0
- package/dist/types/errors.d.ts +20 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +131 -1342
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/provider-runner.d.ts +8 -0
- package/dist/types/provider.d.ts +15 -0
- package/dist/types/runtime-capability-manifest.d.ts +1 -1
- package/dist/types/secret-scrubber.d.ts +15 -0
- package/dist/types/session-markers.d.ts +37 -10
- package/dist/types/session-markers.js +8 -144
- package/dist/types/session-timeline.d.ts +197 -0
- package/dist/types/session-timeline.js +12 -0
- package/dist/types/session.d.ts +172 -11
- package/dist/types/system-prompt.d.ts +27 -0
- package/dist/utils/config-backup.d.ts +9 -1
- package/dist/utils/error.js +3 -4
- package/dist/utils/expect-defined.js +3 -9
- package/dist/utils/heap-watchdog.js +6 -706
- package/dist/utils/index.js +271 -5685
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- package/dist/utils/sage-output-block.js +5 -42
- package/dist/utils/socket-path.d.ts +1 -1
- package/dist/utils/token-estimate.d.ts +6 -2
- package/dist/utils/wstack-paths.d.ts +2 -0
- package/dist/wiring/proxy-rewrite.d.ts +46 -0
- package/dist/wiring/proxy-rewrite.js +24 -121
- package/dist/worktree/index.js +6 -887
- package/instructions/agents/explore-companion.md +45 -18
- package/instructions/agents/memory-curator.md +34 -22
- package/instructions/coordination/director-preamble.md +12 -7
- package/instructions/coordination/subagent-baseline.md +26 -5
- package/instructions/leader-after-task.md +4 -1
- package/instructions/llm/chimera-review.md +30 -9
- package/instructions/llm/memory-curator.md +31 -0
- package/instructions/sections/tool/delegation-compact.md +2 -0
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/sections/tool/mailbox-compact.md +5 -1
- package/instructions/sections/tool/mailbox-full.md +3 -0
- package/instructions/sections/tool/session-note-compact.md +3 -0
- package/instructions/sections/tool/session-note-full.md +15 -0
- package/instructions/system-lite.md +9 -4
- package/instructions/system-pro.md +66 -143
- package/instructions/system.md +73 -175
- package/package.json +32 -4
- package/dist/coordination/agents.d.ts +0 -8
- package/dist/coordination/transport.d.ts +0 -2
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expectDefined
|
|
3
|
+
} from "./chunk-PFZO3C6H.js";
|
|
4
|
+
|
|
5
|
+
// src/types/context-window.ts
|
|
6
|
+
var DEFAULT_CONTEXT_WINDOW_MODE_ID = "balanced";
|
|
7
|
+
var LARGE_WINDOW_DEEP_MODE_THRESHOLD = 1e6;
|
|
8
|
+
var CONTEXT_WINDOW_MODE_PINNED_META_KEY = "contextWindowModePinned";
|
|
9
|
+
var DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES = Object.freeze({
|
|
10
|
+
archival: "balanced"
|
|
11
|
+
});
|
|
12
|
+
var CONTEXT_WINDOW_MODES = Object.freeze([
|
|
13
|
+
{
|
|
14
|
+
id: "balanced",
|
|
15
|
+
name: "Balanced",
|
|
16
|
+
description: "Default rolling compaction: recent work stays verbatim, old tool output is trimmed. Windows of 1M+ tokens default to Deep.",
|
|
17
|
+
thresholds: { warn: 0.55, soft: 0.7, hard: 0.85 },
|
|
18
|
+
aggressiveOn: "soft",
|
|
19
|
+
preserveK: 8,
|
|
20
|
+
eliseThreshold: 1200,
|
|
21
|
+
targetLoad: 0.65
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "frugal",
|
|
25
|
+
name: "Frugal",
|
|
26
|
+
description: "Token-saver mode: compacts early and keeps a tight verbatim tail.",
|
|
27
|
+
thresholds: { warn: 0.4, soft: 0.55, hard: 0.7 },
|
|
28
|
+
aggressiveOn: "warn",
|
|
29
|
+
preserveK: 4,
|
|
30
|
+
eliseThreshold: 500,
|
|
31
|
+
targetLoad: 0.45
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "deep",
|
|
35
|
+
name: "Deep",
|
|
36
|
+
description: "Long-reasoning mode: delays compaction and keeps more recent turns intact.",
|
|
37
|
+
thresholds: { warn: 0.72, soft: 0.86, hard: 0.96 },
|
|
38
|
+
aggressiveOn: "hard",
|
|
39
|
+
preserveK: 18,
|
|
40
|
+
eliseThreshold: 5e3,
|
|
41
|
+
targetLoad: 0.82
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
function listContextWindowModes() {
|
|
45
|
+
return CONTEXT_WINDOW_MODES.map((m) => ({ ...m, thresholds: { ...m.thresholds } }));
|
|
46
|
+
}
|
|
47
|
+
function normalizeContextWindowModeId(id) {
|
|
48
|
+
if (!id) return null;
|
|
49
|
+
if (isContextWindowModeId(id)) return id;
|
|
50
|
+
return DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES[id] ?? null;
|
|
51
|
+
}
|
|
52
|
+
function isDeprecatedContextWindowModeId(id) {
|
|
53
|
+
return Object.hasOwn(DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES, id);
|
|
54
|
+
}
|
|
55
|
+
function isContextWindowModeSelectionId(id) {
|
|
56
|
+
return isContextWindowModeId(id) || isDeprecatedContextWindowModeId(id);
|
|
57
|
+
}
|
|
58
|
+
function getContextWindowMode(id) {
|
|
59
|
+
const normalized = normalizeContextWindowModeId(id);
|
|
60
|
+
if (!normalized) return null;
|
|
61
|
+
const mode = CONTEXT_WINDOW_MODES.find((m) => m.id === normalized);
|
|
62
|
+
return mode ? { ...mode, thresholds: { ...mode.thresholds } } : null;
|
|
63
|
+
}
|
|
64
|
+
function isContextWindowModeId(id) {
|
|
65
|
+
return CONTEXT_WINDOW_MODES.some((m) => m.id === id);
|
|
66
|
+
}
|
|
67
|
+
function resolveContextWindowPolicy(config = {}, overrideMode, maxContext) {
|
|
68
|
+
const requested = overrideMode ?? config.mode ?? DEFAULT_CONTEXT_WINDOW_MODE_ID;
|
|
69
|
+
const normalized = normalizeContextWindowModeId(requested) ?? DEFAULT_CONTEXT_WINDOW_MODE_ID;
|
|
70
|
+
const baseId = normalized === DEFAULT_CONTEXT_WINDOW_MODE_ID && typeof maxContext === "number" && maxContext >= LARGE_WINDOW_DEEP_MODE_THRESHOLD ? "deep" : normalized;
|
|
71
|
+
const mode = expectDefined(getContextWindowMode(baseId));
|
|
72
|
+
return {
|
|
73
|
+
...mode,
|
|
74
|
+
thresholds: {
|
|
75
|
+
warn: config.warnThreshold ?? mode.thresholds.warn,
|
|
76
|
+
soft: config.softThreshold ?? mode.thresholds.soft,
|
|
77
|
+
hard: config.hardThreshold ?? mode.thresholds.hard
|
|
78
|
+
},
|
|
79
|
+
preserveK: config.preserveK ?? mode.preserveK,
|
|
80
|
+
eliseThreshold: config.eliseThreshold ?? mode.eliseThreshold,
|
|
81
|
+
targetLoad: config.targetLoad ?? mode.targetLoad
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function formatContextWindowModeList(activeId) {
|
|
85
|
+
const active = normalizeContextWindowModeId(activeId);
|
|
86
|
+
return CONTEXT_WINDOW_MODES.map((m) => {
|
|
87
|
+
const marker = m.id === active ? "*" : " ";
|
|
88
|
+
return `${marker} ${m.id.padEnd(9)} ${m.name} - ${m.description}`;
|
|
89
|
+
}).join("\n");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/types/default-config.ts
|
|
93
|
+
var DEFAULT_TOOLS_CONFIG = Object.freeze({
|
|
94
|
+
defaultExecutionStrategy: "smart",
|
|
95
|
+
maxIterations: 100,
|
|
96
|
+
iterationTimeoutMs: 3e5,
|
|
97
|
+
maxToolTimeoutMs: 3e5,
|
|
98
|
+
sessionTimeoutMs: 18e5,
|
|
99
|
+
perIterationOutputCapBytes: 1e5,
|
|
100
|
+
descriptionMode: Object.freeze({}),
|
|
101
|
+
disabledTools: Object.freeze([]),
|
|
102
|
+
// Extension requires an explicit host/user policy. Without that boundary a
|
|
103
|
+
// nominal maxIterations cap can grow forever in autonomous sessions.
|
|
104
|
+
autoExtendLimit: false,
|
|
105
|
+
restrictToProjectRoot: true,
|
|
106
|
+
// Off by default: the board is a record of the work, not a permit for it.
|
|
107
|
+
// See ToolsConfig.kanbanGovernance for what turning it on costs and gates.
|
|
108
|
+
kanbanGovernance: false,
|
|
109
|
+
loopDetection: Object.freeze({
|
|
110
|
+
mode: "steer-then-cut",
|
|
111
|
+
steerThreshold: 3,
|
|
112
|
+
cutThreshold: 5,
|
|
113
|
+
windowSize: 12,
|
|
114
|
+
callRepeatThreshold: 4
|
|
115
|
+
}),
|
|
116
|
+
// Off by default — the user opts in via `/settings autothin on`. The
|
|
117
|
+
// `disabledToolMeta` field starts empty; the pipeline writes it on the
|
|
118
|
+
// first successful `apply` and clears it on `undo`.
|
|
119
|
+
autoThin: Object.freeze({
|
|
120
|
+
enabled: false,
|
|
121
|
+
idleDays: 30,
|
|
122
|
+
minInvocations: 3,
|
|
123
|
+
applyOnBoot: false
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
var DEFAULT_CONTEXT_CONFIG = Object.freeze({
|
|
127
|
+
warnThreshold: 0.55,
|
|
128
|
+
softThreshold: 0.7,
|
|
129
|
+
hardThreshold: 0.85,
|
|
130
|
+
targetLoad: 0.65,
|
|
131
|
+
preserveK: 8,
|
|
132
|
+
eliseThreshold: 1200
|
|
133
|
+
});
|
|
134
|
+
var DEFAULT_AUTONOMY_CONFIG = Object.freeze({
|
|
135
|
+
autoProceedDelayMs: 45e3
|
|
136
|
+
});
|
|
137
|
+
var DEFAULT_CIRCUIT_BREAKER_CONFIG = Object.freeze({
|
|
138
|
+
enabled: false,
|
|
139
|
+
autoKillResetMs: 6e4
|
|
140
|
+
});
|
|
141
|
+
var DEFAULT_SESSION_LOGGING_CONFIG = Object.freeze({
|
|
142
|
+
auditLevel: "standard",
|
|
143
|
+
sampling: {
|
|
144
|
+
toolProgress: {
|
|
145
|
+
sampleRate: 8
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
var DEFAULT_SESSION_PRUNE_DAYS = 30;
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
DEFAULT_CONTEXT_WINDOW_MODE_ID,
|
|
153
|
+
LARGE_WINDOW_DEEP_MODE_THRESHOLD,
|
|
154
|
+
CONTEXT_WINDOW_MODE_PINNED_META_KEY,
|
|
155
|
+
DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES,
|
|
156
|
+
CONTEXT_WINDOW_MODES,
|
|
157
|
+
listContextWindowModes,
|
|
158
|
+
normalizeContextWindowModeId,
|
|
159
|
+
isDeprecatedContextWindowModeId,
|
|
160
|
+
isContextWindowModeSelectionId,
|
|
161
|
+
getContextWindowMode,
|
|
162
|
+
isContextWindowModeId,
|
|
163
|
+
resolveContextWindowPolicy,
|
|
164
|
+
formatContextWindowModeList,
|
|
165
|
+
DEFAULT_TOOLS_CONFIG,
|
|
166
|
+
DEFAULT_CONTEXT_CONFIG,
|
|
167
|
+
DEFAULT_AUTONOMY_CONFIG,
|
|
168
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
169
|
+
DEFAULT_SESSION_LOGGING_CONFIG,
|
|
170
|
+
DEFAULT_SESSION_PRUNE_DAYS
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=chunk-DLHHXUAM.js.map
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendJournal,
|
|
3
|
+
loadGoal,
|
|
4
|
+
recordProgress,
|
|
5
|
+
saveGoal
|
|
6
|
+
} from "./chunk-C27KDLOX.js";
|
|
7
|
+
import {
|
|
8
|
+
color
|
|
9
|
+
} from "./chunk-4VWO3ZXL.js";
|
|
10
|
+
|
|
11
|
+
// src/storage/board-store-port.ts
|
|
12
|
+
var notWired = () => {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"Kanban BoardStorePort is not wired \u2014 register the implementation at the CLI composition root (see setBoardStorePort)."
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
var port;
|
|
18
|
+
function setBoardStorePort(impl) {
|
|
19
|
+
port = impl;
|
|
20
|
+
}
|
|
21
|
+
function boardStore() {
|
|
22
|
+
return port ?? notWired();
|
|
23
|
+
}
|
|
24
|
+
function tryBoardStore() {
|
|
25
|
+
return port ?? null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/storage/goal-kanban.ts
|
|
29
|
+
var GOAL_BOARD_TAG_PREFIX = "goal:";
|
|
30
|
+
async function createGoalKanbanBoard(projectRoot, goalFile, sessionId) {
|
|
31
|
+
if (!projectRoot) return null;
|
|
32
|
+
const store = tryBoardStore();
|
|
33
|
+
if (!store) return null;
|
|
34
|
+
const existingId = goalFile.kanbanBoardId;
|
|
35
|
+
if (existingId) {
|
|
36
|
+
const existing = await store.getBoard(projectRoot, existingId).catch(() => null);
|
|
37
|
+
if (existing) return existingId;
|
|
38
|
+
}
|
|
39
|
+
const displayGoal = (goalFile.refinedGoal || goalFile.goal).replace(/\s+/g, " ").trim();
|
|
40
|
+
const titleSuffix = displayGoal.length > 80 ? displayGoal.slice(0, 77) + "\u2026" : displayGoal;
|
|
41
|
+
const board = await store.createBoard(projectRoot, {
|
|
42
|
+
title: `\u{1F3AF} ${titleSuffix}`,
|
|
43
|
+
description: `Kanban board auto-created for goal: ${displayGoal}`,
|
|
44
|
+
tags: [goalTag(goalFile)],
|
|
45
|
+
// Goal boards mirror an engine-driven run; the goal coordinator owns
|
|
46
|
+
// completion semantics, so the kanban completion gate stays out of the way.
|
|
47
|
+
completionGate: { enforcement: "off" }
|
|
48
|
+
});
|
|
49
|
+
const targetColumnId = board.columns[0]?.id ?? "backlog";
|
|
50
|
+
if (goalFile.deliverables && goalFile.deliverables.length > 0) {
|
|
51
|
+
for (let index = 0; index < goalFile.deliverables.length; index++) {
|
|
52
|
+
const d = goalFile.deliverables[index];
|
|
53
|
+
const cleaned = d.replace(/^\[[x✓]\]|✅|\(done\)\s*/i, "").trim();
|
|
54
|
+
if (cleaned) {
|
|
55
|
+
await store.addTask(
|
|
56
|
+
projectRoot,
|
|
57
|
+
board.id,
|
|
58
|
+
{
|
|
59
|
+
title: cleaned,
|
|
60
|
+
columnId: targetColumnId,
|
|
61
|
+
description: `Deliverable for goal: ${displayGoal}`,
|
|
62
|
+
priority: "medium",
|
|
63
|
+
origin: {
|
|
64
|
+
system: "goal",
|
|
65
|
+
taskId: `deliverable:${index}`
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{ sessionId, actor: "goal" }
|
|
69
|
+
).catch(() => {
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
goalFile.kanbanBoardId = board.id;
|
|
75
|
+
return board.id;
|
|
76
|
+
}
|
|
77
|
+
async function findGoalKanbanBoard(projectRoot, boardId) {
|
|
78
|
+
if (!projectRoot || !boardId) return null;
|
|
79
|
+
try {
|
|
80
|
+
return await boardStore().getBoard(projectRoot, boardId);
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function deleteGoalKanbanBoard(projectRoot, boardId) {
|
|
86
|
+
if (!projectRoot || !boardId) return;
|
|
87
|
+
const store = tryBoardStore();
|
|
88
|
+
if (!store) return;
|
|
89
|
+
await store.removeBoard(projectRoot, boardId).catch(() => {
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async function findGoalBoardByTag(projectRoot, goalFile) {
|
|
93
|
+
if (!projectRoot) return null;
|
|
94
|
+
const store = tryBoardStore();
|
|
95
|
+
if (!store) return null;
|
|
96
|
+
const tag = goalTag(goalFile);
|
|
97
|
+
const boards = await store.listBoards(projectRoot);
|
|
98
|
+
const matched = boards.find((b) => b.tags?.includes(tag));
|
|
99
|
+
if (!matched) return null;
|
|
100
|
+
return store.getBoard(projectRoot, matched.id).catch(() => null);
|
|
101
|
+
}
|
|
102
|
+
function formatGoalKanbanPreview(goalFile, boardId, taskCount) {
|
|
103
|
+
const lines = [];
|
|
104
|
+
const displayGoal = (goalFile.refinedGoal || goalFile.goal).replace(/\s+/g, " ").trim();
|
|
105
|
+
lines.push("");
|
|
106
|
+
lines.push(color.bold(color.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
|
|
107
|
+
lines.push(color.bold(color.cyan(" \u{1F3AF} GOAL KANBAN \u2014 Mission Board")));
|
|
108
|
+
lines.push(color.bold(color.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
|
|
109
|
+
lines.push("");
|
|
110
|
+
lines.push(` ${color.bold("Mission:")} ${color.bold(displayGoal)}`);
|
|
111
|
+
if (boardId) {
|
|
112
|
+
lines.push(` ${color.dim(`Board: ${boardId.slice(0, 12)}\u2026`)}`);
|
|
113
|
+
}
|
|
114
|
+
if (typeof taskCount === "number") {
|
|
115
|
+
lines.push(` ${color.dim(`${taskCount} task(s)`)}`);
|
|
116
|
+
}
|
|
117
|
+
lines.push("");
|
|
118
|
+
const deliverables = goalFile.deliverables ?? [];
|
|
119
|
+
const doneDeliverables = deliverables.filter((d) => /^\[[x✓]\]|✅|\(done\)/i.test(d)).length;
|
|
120
|
+
const totalDeliverables = deliverables.length;
|
|
121
|
+
if (totalDeliverables > 0) {
|
|
122
|
+
const backlog = deliverables.filter((d) => !/^\[[x✓]\]|✅|\(done\)|🔄|in.progress/i.test(d));
|
|
123
|
+
const inProgress = deliverables.filter((d) => /🔄|in.progress/i.test(d));
|
|
124
|
+
const done = deliverables.filter((d) => /^\[[x✓]\]|✅|\(done\)/i.test(d));
|
|
125
|
+
const renderColumn = (title, items, icon, accent) => {
|
|
126
|
+
if (items.length === 0) {
|
|
127
|
+
lines.push(` ${accent(color.bold(`${icon} ${title}`))} ${color.dim("(empty)")}`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
lines.push(` ${accent(color.bold(`${icon} ${title} (${items.length})`))}`);
|
|
131
|
+
for (const item of items) {
|
|
132
|
+
const cleaned = item.replace(/^\[[x✓]\]|✅|\(done\)|🔄|in.progress\s*/gi, "").trim();
|
|
133
|
+
lines.push(` \u25CB ${cleaned}`);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
renderColumn("Backlog", backlog, "\u{1F4CB}", (s) => color.dim(s));
|
|
137
|
+
renderColumn("In Progress", inProgress, "\u{1F504}", (s) => color.cyan(s));
|
|
138
|
+
renderColumn("Done", done, "\u2705", (s) => color.green(s));
|
|
139
|
+
lines.push("");
|
|
140
|
+
lines.push(
|
|
141
|
+
` ${color.dim(`Progress: ${doneDeliverables}/${totalDeliverables} deliverables complete`)}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (typeof goalFile.progress === "number") {
|
|
145
|
+
const pct = Math.min(100, Math.max(0, Math.round(goalFile.progress)));
|
|
146
|
+
const filled = Math.round(pct / 5);
|
|
147
|
+
const empty = 20 - filled;
|
|
148
|
+
const bar = color.green("\u2588".repeat(filled)) + color.dim("\u2591".repeat(empty));
|
|
149
|
+
lines.push(` ${color.dim("Overall:")} ${bar} ${color.bold(`${pct}%`)}`);
|
|
150
|
+
if (goalFile.progressNote) {
|
|
151
|
+
lines.push(` ${color.dim(goalFile.progressNote)}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (typeof goalFile.progress === "undefined" && totalDeliverables > 0) {
|
|
155
|
+
const pct = Math.round(doneDeliverables / totalDeliverables * 100);
|
|
156
|
+
const filled = Math.round(pct / 5);
|
|
157
|
+
const empty = 20 - filled;
|
|
158
|
+
const bar = (pct > 0 ? color.green("\u2588".repeat(filled)) : "") + color.dim("\u2591".repeat(empty));
|
|
159
|
+
lines.push(` ${color.dim("Overall:")} ${bar} ${color.bold(`${pct}%`)}`);
|
|
160
|
+
}
|
|
161
|
+
lines.push("");
|
|
162
|
+
lines.push(color.bold(color.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
|
|
163
|
+
return lines.join("\n");
|
|
164
|
+
}
|
|
165
|
+
function formatGoalEvent(goalFile, boardId) {
|
|
166
|
+
const lines = [];
|
|
167
|
+
lines.push("");
|
|
168
|
+
lines.push(color.bold(color.green("\u250C\u2500\u2500\u2500 Goal Event \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510")));
|
|
169
|
+
lines.push(color.bold(color.green("\u2502")) + " \u{1F3AF} Mission locked and ready");
|
|
170
|
+
if (boardId) {
|
|
171
|
+
lines.push(
|
|
172
|
+
color.bold(color.green("\u2502")) + ` \u{1F4CB} Kanban board created: ${color.cyan(boardId.slice(0, 12) + "\u2026")}`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
const deliverables = goalFile.deliverables ?? [];
|
|
176
|
+
lines.push(
|
|
177
|
+
color.bold(color.green("\u2502")) + ` \u{1F4E6} ${deliverables.length} deliverable${deliverables.length !== 1 ? "s" : ""} extracted`
|
|
178
|
+
);
|
|
179
|
+
if (typeof goalFile.progress === "number") {
|
|
180
|
+
lines.push(color.bold(color.green("\u2502")) + ` \u{1F4CA} Progress: ${goalFile.progress}%`);
|
|
181
|
+
}
|
|
182
|
+
lines.push(color.bold(color.green("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")));
|
|
183
|
+
return lines.join("\n");
|
|
184
|
+
}
|
|
185
|
+
function formatGoalAutonomyChoice() {
|
|
186
|
+
const lines = [];
|
|
187
|
+
lines.push("");
|
|
188
|
+
lines.push(color.bold(color.magenta("\u2550\u2550\u2550 Choose Autonomy Mode \u2550\u2550\u2550")));
|
|
189
|
+
lines.push("");
|
|
190
|
+
lines.push(
|
|
191
|
+
` ${color.bold("1")}. ${color.red("Autonomy Eternal")} ${color.dim("\u2014 Single-agent sense/decide/execute/reflect loop")}`
|
|
192
|
+
);
|
|
193
|
+
lines.push(
|
|
194
|
+
` ${color.bold("2")}. ${color.magenta("Eternal Parallel")} ${color.dim("\u2014 Multi-agent fan-out (4-8 subagents per tick)")}`
|
|
195
|
+
);
|
|
196
|
+
lines.push("");
|
|
197
|
+
lines.push(` ${color.dim("Enter 1 or 2 (or press Enter to skip):")}`);
|
|
198
|
+
return lines.join("\n");
|
|
199
|
+
}
|
|
200
|
+
function parseAutonomyChoice(input) {
|
|
201
|
+
const trimmed = input.trim().toLowerCase();
|
|
202
|
+
if (trimmed === "1" || trimmed === "eternal" || trimmed === "e") return "eternal";
|
|
203
|
+
if (trimmed === "2" || trimmed === "parallel" || trimmed === "p") return "eternal-parallel";
|
|
204
|
+
if (trimmed === "" || trimmed === "skip" || trimmed === "s" || trimmed === "0") return null;
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
function goalTag(goalFile) {
|
|
208
|
+
const goal = (goalFile.refinedGoal || goalFile.goal).replace(/\s+/g, "-").slice(0, 24).toLowerCase();
|
|
209
|
+
return `${GOAL_BOARD_TAG_PREFIX}${goal}`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/storage/goal-coordination.ts
|
|
213
|
+
var DONE_MARKER = /\[done:\s*([^\]]+)\]/gi;
|
|
214
|
+
var DONE_PREFIX = /^\s*(?:✅|\[[x✓]\]|\(done\))\s*/i;
|
|
215
|
+
function parseCompletedGoalDeliverables(finalText, deliverables) {
|
|
216
|
+
if (!finalText || deliverables.length === 0) return [];
|
|
217
|
+
const seen = /* @__PURE__ */ new Set();
|
|
218
|
+
const completed = [];
|
|
219
|
+
for (const match of finalText.matchAll(DONE_MARKER)) {
|
|
220
|
+
const raw = match[1]?.trim();
|
|
221
|
+
if (!raw) continue;
|
|
222
|
+
const numeric = /^\d+$/.test(raw) ? Number.parseInt(raw, 10) : void 0;
|
|
223
|
+
let index = numeric === void 0 ? -1 : numeric === 0 ? 0 : numeric - 1;
|
|
224
|
+
if (index < 0 || index >= deliverables.length) {
|
|
225
|
+
const prefix = raw.toLowerCase();
|
|
226
|
+
index = deliverables.findIndex(
|
|
227
|
+
(item) => stripGoalDeliverableMarker(item).toLowerCase().startsWith(prefix)
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
if (index < 0 || index >= deliverables.length || seen.has(index)) continue;
|
|
231
|
+
const source = deliverables[index] ?? "";
|
|
232
|
+
if (isGoalDeliverableComplete(source)) continue;
|
|
233
|
+
seen.add(index);
|
|
234
|
+
completed.push({ index, text: stripGoalDeliverableMarker(source) });
|
|
235
|
+
}
|
|
236
|
+
return completed;
|
|
237
|
+
}
|
|
238
|
+
function isGoalDeliverableComplete(value) {
|
|
239
|
+
return DONE_PREFIX.test(value);
|
|
240
|
+
}
|
|
241
|
+
function stripGoalDeliverableMarker(value) {
|
|
242
|
+
return value.replace(DONE_PREFIX, "").trim();
|
|
243
|
+
}
|
|
244
|
+
function applyGoalDeliverableCompletions(goal, completed) {
|
|
245
|
+
if (completed.length === 0) return recomputeGoalProgress(goal);
|
|
246
|
+
const completedIndices = new Set(completed.map((item) => item.index));
|
|
247
|
+
let next = {
|
|
248
|
+
...goal,
|
|
249
|
+
deliverables: (goal.deliverables ?? []).map(
|
|
250
|
+
(item, index) => completedIndices.has(index) && !isGoalDeliverableComplete(item) ? `\u2705 ${item}` : item
|
|
251
|
+
)
|
|
252
|
+
};
|
|
253
|
+
next = appendGoalDeliverableJournals(next, completed);
|
|
254
|
+
return recomputeGoalProgress(next);
|
|
255
|
+
}
|
|
256
|
+
function appendGoalDeliverableJournals(goal, completed) {
|
|
257
|
+
let next = goal;
|
|
258
|
+
for (const item of completed) {
|
|
259
|
+
next = appendJournal(next, {
|
|
260
|
+
source: "deliverable",
|
|
261
|
+
task: `Deliverable completed: ${item.text}`.slice(0, 240),
|
|
262
|
+
status: "success",
|
|
263
|
+
note: `[DONE: ${item.index + 1}]`
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return next;
|
|
267
|
+
}
|
|
268
|
+
function recomputeGoalProgress(goal) {
|
|
269
|
+
const deliverables = goal.deliverables ?? [];
|
|
270
|
+
if (deliverables.length === 0) return goal;
|
|
271
|
+
const done = deliverables.filter(isGoalDeliverableComplete).length;
|
|
272
|
+
const progress = Math.round(done / deliverables.length * 100);
|
|
273
|
+
return recordProgress(goal, progress, `${done}/${deliverables.length} deliverables complete`);
|
|
274
|
+
}
|
|
275
|
+
async function coordinateGoalIteration(options) {
|
|
276
|
+
const current = await loadGoal(options.goalPath, options.events);
|
|
277
|
+
if (!current) return null;
|
|
278
|
+
const completed = parseCompletedGoalDeliverables(options.finalText, current.deliverables ?? []);
|
|
279
|
+
const board = await resolveGoalBoard(options.projectRoot, current);
|
|
280
|
+
let kanbanUpdatedTaskIds = [];
|
|
281
|
+
let goal;
|
|
282
|
+
if (board) {
|
|
283
|
+
kanbanUpdatedTaskIds = await refreshGoalKanban(
|
|
284
|
+
options.projectRoot,
|
|
285
|
+
current,
|
|
286
|
+
completed,
|
|
287
|
+
options.sessionId,
|
|
288
|
+
board
|
|
289
|
+
);
|
|
290
|
+
goal = await recomputeGoalProgressFromKanban(options.projectRoot, current);
|
|
291
|
+
const confirmed = completed.filter(
|
|
292
|
+
(item) => !isGoalDeliverableComplete(current.deliverables?.[item.index] ?? "") && isGoalDeliverableComplete(goal.deliverables?.[item.index] ?? "")
|
|
293
|
+
);
|
|
294
|
+
goal = appendGoalDeliverableJournals(goal, confirmed);
|
|
295
|
+
} else {
|
|
296
|
+
goal = applyGoalDeliverableCompletions(current, completed);
|
|
297
|
+
}
|
|
298
|
+
let reached = false;
|
|
299
|
+
const allComplete = (goal.deliverables?.length ?? 0) > 0 && goal.deliverables?.every(isGoalDeliverableComplete) === true;
|
|
300
|
+
if (allComplete && options.brain) {
|
|
301
|
+
const decision = await options.brain.decide({
|
|
302
|
+
id: `goal-reached-${goal.iterations}`,
|
|
303
|
+
sessionId: options.sessionId,
|
|
304
|
+
source: "system",
|
|
305
|
+
question: "Have all goal deliverables been reached and verified?",
|
|
306
|
+
context: [
|
|
307
|
+
`Goal: ${goal.refinedGoal ?? goal.goal}`,
|
|
308
|
+
`Progress: ${goal.progress ?? 0}%`,
|
|
309
|
+
"Completed deliverables:",
|
|
310
|
+
...(goal.deliverables ?? []).map(
|
|
311
|
+
(item, index) => `${index + 1}. ${stripGoalDeliverableMarker(item)}`
|
|
312
|
+
)
|
|
313
|
+
].join("\n"),
|
|
314
|
+
risk: "high",
|
|
315
|
+
fallback: "continue",
|
|
316
|
+
options: [
|
|
317
|
+
{
|
|
318
|
+
id: "goal_reached",
|
|
319
|
+
label: "Goal reached",
|
|
320
|
+
consequence: "Persist the completed goal and stop the eternal loop."
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "keep_working",
|
|
324
|
+
label: "Keep working",
|
|
325
|
+
consequence: "Leave the goal active for another iteration."
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
});
|
|
329
|
+
reached = decision.type === "answer" && decision.optionId === "goal_reached";
|
|
330
|
+
}
|
|
331
|
+
if (reached) {
|
|
332
|
+
const reachedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
333
|
+
goal = appendJournal(
|
|
334
|
+
{
|
|
335
|
+
...goal,
|
|
336
|
+
goalState: "completed",
|
|
337
|
+
engineState: "stopped",
|
|
338
|
+
progress: 100,
|
|
339
|
+
progressNote: "goal reached",
|
|
340
|
+
reachedAt,
|
|
341
|
+
reachedNote: "goal reached"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
source: "deliverable",
|
|
345
|
+
task: "GOAL REACHED",
|
|
346
|
+
status: "success",
|
|
347
|
+
note: "goal reached"
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
await saveGoal(options.goalPath, goal, options.events);
|
|
352
|
+
return { goal, completed, kanbanUpdatedTaskIds, reached };
|
|
353
|
+
}
|
|
354
|
+
async function resolveGoalBoard(projectRoot, goal) {
|
|
355
|
+
const boardId = goal.kanbanBoardId;
|
|
356
|
+
if (boardId) {
|
|
357
|
+
const board = await findGoalKanbanBoard(projectRoot, boardId);
|
|
358
|
+
if (board) return board;
|
|
359
|
+
}
|
|
360
|
+
return findGoalBoardByTag(projectRoot, goal);
|
|
361
|
+
}
|
|
362
|
+
async function refreshGoalKanban(projectRoot, goal, completed, sessionId, resolvedBoard) {
|
|
363
|
+
if (completed.length === 0) return [];
|
|
364
|
+
const board = resolvedBoard ?? await resolveGoalBoard(projectRoot, goal);
|
|
365
|
+
if (!board) return [];
|
|
366
|
+
const doneColumn = board.columns.find((column) => column.title.toLowerCase() === "done");
|
|
367
|
+
if (!doneColumn) return [];
|
|
368
|
+
const originKeys = new Set(completed.map((item) => `deliverable:${item.index}`));
|
|
369
|
+
const completedTitles = new Set(completed.map((item) => normalizeTitle(item.text)));
|
|
370
|
+
const updated = [];
|
|
371
|
+
for (const task of board.tasks) {
|
|
372
|
+
const originMatch = task.origin?.system === "goal" && task.origin?.taskId ? originKeys.has(task.origin.taskId) : false;
|
|
373
|
+
const titleMatch = !task.origin?.taskId && completedTitles.has(normalizeTitle(task.title));
|
|
374
|
+
if (!originMatch && !titleMatch) continue;
|
|
375
|
+
const result = await boardStore().updateTask(
|
|
376
|
+
projectRoot,
|
|
377
|
+
board.id,
|
|
378
|
+
task.id,
|
|
379
|
+
{ columnId: doneColumn.id, status: "completed" },
|
|
380
|
+
{
|
|
381
|
+
sessionId,
|
|
382
|
+
actor: "goal-coordinator",
|
|
383
|
+
note: originMatch ? `deliverable-completed: Matched by origin ${task.origin.taskId}.` : "deliverable-completed: Updated from [DONE:] marker (title fallback)."
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
if (result) updated.push(task.id);
|
|
387
|
+
}
|
|
388
|
+
return updated;
|
|
389
|
+
}
|
|
390
|
+
async function recomputeGoalProgressFromKanban(projectRoot, goal) {
|
|
391
|
+
const board = await resolveGoalBoard(projectRoot, goal);
|
|
392
|
+
if (!board || !goal.deliverables?.length) return recomputeGoalProgress(goal);
|
|
393
|
+
const tasksByOrigin = new Map(
|
|
394
|
+
board.tasks.filter((task) => task.origin?.system === "goal" && task.origin.taskId).map((task) => [task.origin.taskId, task])
|
|
395
|
+
);
|
|
396
|
+
const completedLegacyTitles = new Set(
|
|
397
|
+
board.tasks.filter((task) => !task.origin?.taskId && task.status === "completed").map((task) => normalizeTitle(task.title))
|
|
398
|
+
);
|
|
399
|
+
const deliverables = goal.deliverables.map((item, index) => {
|
|
400
|
+
const text = stripGoalDeliverableMarker(item);
|
|
401
|
+
const originTask = tasksByOrigin.get(`deliverable:${index}`);
|
|
402
|
+
const complete = originTask ? originTask.status === "completed" : completedLegacyTitles.has(normalizeTitle(text)) || isGoalDeliverableComplete(item);
|
|
403
|
+
return complete ? `\u2705 ${text}` : text;
|
|
404
|
+
});
|
|
405
|
+
return recomputeGoalProgress({ ...goal, deliverables });
|
|
406
|
+
}
|
|
407
|
+
function normalizeTitle(value) {
|
|
408
|
+
return stripGoalDeliverableMarker(value).replace(/\s+/g, " ").trim().toLowerCase();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export {
|
|
412
|
+
setBoardStorePort,
|
|
413
|
+
boardStore,
|
|
414
|
+
createGoalKanbanBoard,
|
|
415
|
+
findGoalKanbanBoard,
|
|
416
|
+
deleteGoalKanbanBoard,
|
|
417
|
+
findGoalBoardByTag,
|
|
418
|
+
formatGoalKanbanPreview,
|
|
419
|
+
formatGoalEvent,
|
|
420
|
+
formatGoalAutonomyChoice,
|
|
421
|
+
parseAutonomyChoice,
|
|
422
|
+
parseCompletedGoalDeliverables,
|
|
423
|
+
isGoalDeliverableComplete,
|
|
424
|
+
stripGoalDeliverableMarker,
|
|
425
|
+
applyGoalDeliverableCompletions,
|
|
426
|
+
recomputeGoalProgress,
|
|
427
|
+
coordinateGoalIteration
|
|
428
|
+
};
|
|
429
|
+
//# sourceMappingURL=chunk-DOTHQSJ2.js.map
|