@tomsun28/pizza 0.0.9 → 0.1.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/README.md +20 -143
- package/README.zh-CN.md +36 -0
- package/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +6 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +3 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.js +330 -0
- package/dist/cli/config-selector.d.ts +13 -0
- package/dist/cli/config-selector.js +30 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +82 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +21 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +96 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +68 -0
- package/dist/config.d.ts +79 -0
- package/dist/config.js +223 -0
- package/dist/core/agent/index.d.ts +6 -0
- package/dist/core/agent/index.js +6 -0
- package/dist/core/agent/types.d.ts +202 -0
- package/dist/core/agent/types.js +51 -0
- package/dist/core/auth-storage.d.ts +135 -0
- package/dist/core/auth-storage.js +417 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +107 -0
- package/dist/core/compaction/branch-summarization.d.ts +87 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction-engine.d.ts +40 -0
- package/dist/core/compaction/compaction-engine.js +292 -0
- package/dist/core/compaction/compaction.d.ts +106 -0
- package/dist/core/compaction/compaction.js +295 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +152 -0
- package/dist/core/defaults.d.ts +2 -0
- package/dist/core/defaults.js +1 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +24 -0
- package/dist/core/event-store/events.d.ts +465 -0
- package/dist/core/event-store/events.js +6 -0
- package/dist/core/event-store/index.d.ts +10 -0
- package/dist/core/event-store/index.js +10 -0
- package/dist/core/event-store/sqlite-store.d.ts +27 -0
- package/dist/core/event-store/sqlite-store.js +275 -0
- package/dist/core/event-store/store.d.ts +91 -0
- package/dist/core/event-store/store.js +7 -0
- package/dist/core/event-store/thread-scoped-store.d.ts +29 -0
- package/dist/core/event-store/thread-scoped-store.js +50 -0
- package/dist/core/event-store/types.d.ts +70 -0
- package/dist/core/event-store/types.js +7 -0
- package/dist/core/event-store/workspace.d.ts +37 -0
- package/dist/core/event-store/workspace.js +71 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +74 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +248 -0
- package/dist/core/export-html/index.d.ts +29 -0
- package/dist/core/export-html/index.js +186 -0
- package/dist/core/export-html/template.css +1017 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1742 -0
- package/dist/core/export-html/tool-renderer.d.ts +39 -0
- package/dist/core/export-html/tool-renderer.js +94 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.js +492 -0
- package/dist/core/extensions/runner.d.ts +167 -0
- package/dist/core/extensions/runner.js +898 -0
- package/dist/core/extensions/session-context.d.ts +67 -0
- package/dist/core/extensions/session-context.js +272 -0
- package/dist/core/extensions/types.d.ts +1147 -0
- package/dist/core/extensions/types.js +44 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +21 -0
- package/dist/core/footer-data-provider.d.ts +47 -0
- package/dist/core/footer-data-provider.js +321 -0
- package/dist/core/goal/index.d.ts +3 -0
- package/dist/core/goal/index.js +1 -0
- package/dist/core/goal/scheduler.d.ts +83 -0
- package/dist/core/goal/scheduler.js +154 -0
- package/dist/core/goal/types.d.ts +182 -0
- package/dist/core/goal/types.js +11 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +8 -0
- package/dist/core/intent/classifier.d.ts +53 -0
- package/dist/core/intent/classifier.js +353 -0
- package/dist/core/intent/index.d.ts +8 -0
- package/dist/core/intent/index.js +8 -0
- package/dist/core/intent/tool-adapter.d.ts +31 -0
- package/dist/core/intent/tool-adapter.js +168 -0
- package/dist/core/intent/types.d.ts +71 -0
- package/dist/core/intent/types.js +6 -0
- package/dist/core/keybindings.d.ts +297 -0
- package/dist/core/keybindings.js +250 -0
- package/dist/core/messages.d.ts +30 -0
- package/dist/core/messages.js +134 -0
- package/dist/core/model-registry.d.ts +131 -0
- package/dist/core/model-registry.js +634 -0
- package/dist/core/model-resolver.d.ts +109 -0
- package/dist/core/model-resolver.js +486 -0
- package/dist/core/output-guard.d.ts +5 -0
- package/dist/core/output-guard.js +58 -0
- package/dist/core/package-manager.d.ts +196 -0
- package/dist/core/package-manager.js +1873 -0
- package/dist/core/projection/boundary-inferrer.d.ts +58 -0
- package/dist/core/projection/boundary-inferrer.js +122 -0
- package/dist/core/projection/event-to-message.d.ts +35 -0
- package/dist/core/projection/event-to-message.js +253 -0
- package/dist/core/projection/goal-projection.d.ts +67 -0
- package/dist/core/projection/goal-projection.js +339 -0
- package/dist/core/projection/index.d.ts +13 -0
- package/dist/core/projection/index.js +13 -0
- package/dist/core/projection/session-manager.d.ts +100 -0
- package/dist/core/projection/session-manager.js +331 -0
- package/dist/core/projection/session-projection.d.ts +58 -0
- package/dist/core/projection/session-projection.js +257 -0
- package/dist/core/projection/task-history.d.ts +13 -0
- package/dist/core/projection/task-history.js +61 -0
- package/dist/core/projection/timeline-projection.d.ts +82 -0
- package/dist/core/projection/timeline-projection.js +276 -0
- package/dist/core/projection/types.d.ts +69 -0
- package/dist/core/projection/types.js +6 -0
- package/dist/core/prompt-templates.d.ts +51 -0
- package/dist/core/prompt-templates.js +249 -0
- package/dist/core/resolve-config-value.d.ts +22 -0
- package/dist/core/resolve-config-value.js +125 -0
- package/dist/core/resource-loader.d.ts +193 -0
- package/dist/core/resource-loader.js +685 -0
- package/dist/core/runtime/ai-client.d.ts +12 -0
- package/dist/core/runtime/ai-client.js +153 -0
- package/dist/core/runtime/checkpoint.d.ts +12 -0
- package/dist/core/runtime/checkpoint.js +78 -0
- package/dist/core/runtime/index.d.ts +12 -0
- package/dist/core/runtime/index.js +12 -0
- package/dist/core/runtime/llm-types.d.ts +99 -0
- package/dist/core/runtime/llm-types.js +6 -0
- package/dist/core/runtime/local-runtime.d.ts +23 -0
- package/dist/core/runtime/local-runtime.js +59 -0
- package/dist/core/runtime/policies.d.ts +72 -0
- package/dist/core/runtime/policies.js +37 -0
- package/dist/core/runtime/reactor.d.ts +213 -0
- package/dist/core/runtime/reactor.js +992 -0
- package/dist/core/runtime/runtime.d.ts +191 -0
- package/dist/core/runtime/runtime.js +449 -0
- package/dist/core/runtime/types.d.ts +42 -0
- package/dist/core/runtime/types.js +1 -0
- package/dist/core/sdk.d.ts +12 -0
- package/dist/core/sdk.js +10 -0
- package/dist/core/session-context-builder.d.ts +9 -0
- package/dist/core/session-context-builder.js +87 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +36 -0
- package/dist/core/session-facade-factory.d.ts +79 -0
- package/dist/core/session-facade-factory.js +460 -0
- package/dist/core/session-facade.d.ts +57 -0
- package/dist/core/session-facade.js +91 -0
- package/dist/core/session-listing.d.ts +30 -0
- package/dist/core/session-listing.js +168 -0
- package/dist/core/session-reader.d.ts +19 -0
- package/dist/core/session-reader.js +101 -0
- package/dist/core/session-ref.d.ts +7 -0
- package/dist/core/session-ref.js +25 -0
- package/dist/core/session-services.d.ts +51 -0
- package/dist/core/session-services.js +90 -0
- package/dist/core/session-stats.d.ts +43 -0
- package/dist/core/session-stats.js +41 -0
- package/dist/core/settings-manager.d.ts +236 -0
- package/dist/core/settings-manager.js +706 -0
- package/dist/core/skill-block-parser.d.ts +12 -0
- package/dist/core/skill-block-parser.js +15 -0
- package/dist/core/skills.d.ts +59 -0
- package/dist/core/skills.js +408 -0
- package/dist/core/slash-commands.d.ts +13 -0
- package/dist/core/slash-commands.js +17 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +18 -0
- package/dist/core/system-prompt.d.ts +27 -0
- package/dist/core/system-prompt.js +179 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.js +30 -0
- package/dist/core/tools/bash.d.ts +95 -0
- package/dist/core/tools/bash.js +513 -0
- package/dist/core/tools/builtin-commands.d.ts +75 -0
- package/dist/core/tools/builtin-commands.js +503 -0
- package/dist/core/tools/compat-commands.d.ts +12 -0
- package/dist/core/tools/compat-commands.js +1280 -0
- package/dist/core/tools/edit-diff.d.ts +59 -0
- package/dist/core/tools/edit-diff.js +263 -0
- package/dist/core/tools/edit.d.ts +49 -0
- package/dist/core/tools/edit.js +340 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +36 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +459 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +422 -0
- package/dist/core/tools/index.d.ts +70 -0
- package/dist/core/tools/index.js +129 -0
- package/dist/core/tools/line-anchors.d.ts +33 -0
- package/dist/core/tools/line-anchors.js +151 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +268 -0
- package/dist/core/tools/path-utils.d.ts +7 -0
- package/dist/core/tools/path-utils.js +80 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.js +244 -0
- package/dist/core/tools/render-utils.d.ts +20 -0
- package/dist/core/tools/render-utils.js +48 -0
- package/dist/core/tools/session-split.d.ts +9 -0
- package/dist/core/tools/session-split.js +77 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +32 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +204 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +211 -0
- package/dist/core/types/session-types.d.ts +123 -0
- package/dist/core/types/session-types.js +8 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +38 -0
- package/dist/main.d.ts +11 -2
- package/dist/main.js +577 -149
- package/dist/modes/event-mapper.d.ts +115 -0
- package/dist/modes/event-mapper.js +200 -0
- package/dist/modes/gui/server.d.ts +14 -0
- package/dist/modes/gui/server.js +1032 -0
- package/dist/modes/index.d.ts +10 -0
- package/dist/modes/index.js +9 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +328 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
- package/dist/modes/interactive/components/assistant-message.js +115 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +169 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +50 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +41 -0
- package/dist/modes/interactive/components/brand-header.d.ts +33 -0
- package/dist/modes/interactive/components/brand-header.js +235 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +42 -0
- package/dist/modes/interactive/components/config-selector.d.ts +70 -0
- package/dist/modes/interactive/components/config-selector.js +469 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +27 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +27 -0
- package/dist/modes/interactive/components/custom-editor.js +94 -0
- package/dist/modes/interactive/components/custom-message.d.ts +19 -0
- package/dist/modes/interactive/components/custom-message.js +73 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +137 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +132 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +19 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +39 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +54 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +23 -0
- package/dist/modes/interactive/components/extension-selector.js +70 -0
- package/dist/modes/interactive/components/footer.d.ts +55 -0
- package/dist/modes/interactive/components/footer.js +207 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.js +32 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
- package/dist/modes/interactive/components/keybinding-hints.js +21 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +41 -0
- package/dist/modes/interactive/components/login-dialog.js +138 -0
- package/dist/modes/interactive/components/model-selector.d.ts +32 -0
- package/dist/modes/interactive/components/model-selector.js +209 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +18 -0
- package/dist/modes/interactive/components/oauth-selector.js +91 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +57 -0
- package/dist/modes/interactive/components/settings-selector.js +299 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +37 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +44 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +50 -0
- package/dist/modes/interactive/components/timeline-view.d.ts +31 -0
- package/dist/modes/interactive/components/timeline-view.js +81 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +64 -0
- package/dist/modes/interactive/components/tool-execution.js +305 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +88 -0
- package/dist/modes/interactive/components/tree-selector.js +1072 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +32 -0
- package/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/modes/interactive/interactive-mode.js +4116 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +80 -0
- package/dist/modes/interactive/theme/theme.js +973 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +102 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +48 -0
- package/dist/modes/rpc/rpc-client.d.ts +219 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +381 -0
- package/dist/modes/rpc/rpc-types.d.ts +406 -0
- package/dist/modes/rpc/rpc-types.js +7 -0
- package/dist/package-manager-cli.d.ts +3 -0
- package/dist/package-manager-cli.js +233 -0
- package/dist/utils/changelog.d.ts +20 -0
- package/dist/utils/changelog.js +86 -0
- package/dist/utils/child-process.d.ts +10 -0
- package/dist/utils/child-process.js +77 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +244 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.js +13 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +77 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +157 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +162 -0
- package/dist/utils/image-convert.d.ts +8 -0
- package/dist/utils/image-convert.js +38 -0
- package/dist/utils/image-resize.d.ts +35 -0
- package/dist/utils/image-resize.js +136 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.js +25 -0
- package/dist/utils/path-shims.d.ts +1 -0
- package/dist/utils/path-shims.js +90 -0
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.js +18 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +120 -0
- package/dist/utils/shell.d.ts +29 -0
- package/dist/utils/shell.js +189 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +16 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.js +101 -0
- package/dist/vendor/bin/darwin-arm64/fd +0 -0
- package/dist/vendor/bin/darwin-arm64/rg +0 -0
- package/dist/vendor/bin/darwin-x64/fd +0 -0
- package/dist/vendor/bin/darwin-x64/rg +0 -0
- package/dist/vendor/bin/linux-arm64/fd +0 -0
- package/dist/vendor/bin/linux-arm64/rg +0 -0
- package/dist/vendor/bin/linux-x64/fd +0 -0
- package/dist/vendor/bin/linux-x64/rg +0 -0
- package/dist/vendor/bin/win32-arm64/fd.exe +0 -0
- package/dist/vendor/bin/win32-arm64/rg.exe +0 -0
- package/dist/vendor/bin/win32-x64/fd.exe +0 -0
- package/dist/vendor/bin/win32-x64/rg.exe +0 -0
- package/package.json +90 -26
- package/dist/extension/core.d.ts +0 -69
- package/dist/extension/core.js +0 -270
- package/dist/extension/core.js.map +0 -1
- package/dist/extension/index.d.ts +0 -25
- package/dist/extension/index.js +0 -303
- package/dist/extension/index.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/themes/pizza.json +0 -87
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Goal Projection
|
|
3
|
+
*
|
|
4
|
+
* Derives goal and task state by scanning events from the EventStore.
|
|
5
|
+
* A projection is a read-only view — it can be rebuilt at any time
|
|
6
|
+
* by replaying the event log.
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Goal Projection
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* GoalProjection derives current goal and task state from the EventStore.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* const projection = new GoalProjection(store);
|
|
16
|
+
* projection.rebuild(); // scan all events
|
|
17
|
+
* const goals = projection.listGoals();
|
|
18
|
+
* const tasks = projection.getTasksForGoal(goalId);
|
|
19
|
+
*/
|
|
20
|
+
export class GoalProjection {
|
|
21
|
+
constructor(store) {
|
|
22
|
+
this.store = store;
|
|
23
|
+
this.goals = new Map();
|
|
24
|
+
this.tasks = new Map();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Rebuild the projection from scratch by scanning all events.
|
|
28
|
+
*/
|
|
29
|
+
rebuild() {
|
|
30
|
+
this.goals.clear();
|
|
31
|
+
this.tasks.clear();
|
|
32
|
+
const events = this.store.query({
|
|
33
|
+
types: [
|
|
34
|
+
"GOAL_CREATED",
|
|
35
|
+
"GOAL_CLASSIFIED",
|
|
36
|
+
"GOAL_PLANNED",
|
|
37
|
+
"GOAL_PAUSED",
|
|
38
|
+
"GOAL_RESUMED",
|
|
39
|
+
"GOAL_COMPLETED",
|
|
40
|
+
"GOAL_CANCELLED",
|
|
41
|
+
"TASK_CREATED",
|
|
42
|
+
"TASK_ASSIGNED",
|
|
43
|
+
"TASK_STARTED",
|
|
44
|
+
"TASK_PROGRESS",
|
|
45
|
+
"TASK_COMPLETED",
|
|
46
|
+
"TASK_FAILED",
|
|
47
|
+
"TASK_REWORK_REQUESTED",
|
|
48
|
+
"TASK_ACCEPTED",
|
|
49
|
+
"TASK_CANCELLED",
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
for (const event of events) {
|
|
53
|
+
this._applyEvent(event);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Start live-updating the projection by subscribing to new events.
|
|
58
|
+
*/
|
|
59
|
+
startLive() {
|
|
60
|
+
if (this.unsubscribe)
|
|
61
|
+
return;
|
|
62
|
+
this.unsubscribe = this.store.subscribe((event) => this._applyEvent(event), {
|
|
63
|
+
types: [
|
|
64
|
+
"GOAL_CREATED",
|
|
65
|
+
"GOAL_CLASSIFIED",
|
|
66
|
+
"GOAL_PLANNED",
|
|
67
|
+
"GOAL_PAUSED",
|
|
68
|
+
"GOAL_RESUMED",
|
|
69
|
+
"GOAL_COMPLETED",
|
|
70
|
+
"GOAL_CANCELLED",
|
|
71
|
+
"TASK_CREATED",
|
|
72
|
+
"TASK_ASSIGNED",
|
|
73
|
+
"TASK_STARTED",
|
|
74
|
+
"TASK_PROGRESS",
|
|
75
|
+
"TASK_COMPLETED",
|
|
76
|
+
"TASK_FAILED",
|
|
77
|
+
"TASK_REWORK_REQUESTED",
|
|
78
|
+
"TASK_ACCEPTED",
|
|
79
|
+
"TASK_CANCELLED",
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Stop live updates.
|
|
85
|
+
*/
|
|
86
|
+
stopLive() {
|
|
87
|
+
this.unsubscribe?.();
|
|
88
|
+
this.unsubscribe = undefined;
|
|
89
|
+
}
|
|
90
|
+
// =========================================================================
|
|
91
|
+
// Queries
|
|
92
|
+
// =========================================================================
|
|
93
|
+
/** Get all goals */
|
|
94
|
+
listGoals() {
|
|
95
|
+
return [...this.goals.values()];
|
|
96
|
+
}
|
|
97
|
+
/** Get active (non-terminal) goals */
|
|
98
|
+
listActiveGoals() {
|
|
99
|
+
return this.listGoals().filter((g) => g.status !== "completed" && g.status !== "cancelled");
|
|
100
|
+
}
|
|
101
|
+
/** Get a specific goal */
|
|
102
|
+
getGoal(goalId) {
|
|
103
|
+
return this.goals.get(goalId);
|
|
104
|
+
}
|
|
105
|
+
/** Get all tasks for a goal */
|
|
106
|
+
getTasksForGoal(goalId) {
|
|
107
|
+
return [...this.tasks.values()].filter((t) => t.goal_id === goalId);
|
|
108
|
+
}
|
|
109
|
+
/** Get all tasks */
|
|
110
|
+
listTasks() {
|
|
111
|
+
return [...this.tasks.values()];
|
|
112
|
+
}
|
|
113
|
+
/** Get a specific task */
|
|
114
|
+
getTask(taskId) {
|
|
115
|
+
return this.tasks.get(taskId);
|
|
116
|
+
}
|
|
117
|
+
/** Get tasks that are ready to start (all dependencies completed/accepted) */
|
|
118
|
+
getReadyTasks(goalId) {
|
|
119
|
+
const goalTasks = this.getTasksForGoal(goalId);
|
|
120
|
+
return goalTasks.filter((task) => {
|
|
121
|
+
if (task.status !== "created")
|
|
122
|
+
return false;
|
|
123
|
+
return task.depends_on.every((depId) => {
|
|
124
|
+
const dep = this.tasks.get(depId);
|
|
125
|
+
return dep && (dep.status === "completed" || dep.status === "accepted");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** Get tasks blocked by dependencies */
|
|
130
|
+
getBlockedTasks(goalId) {
|
|
131
|
+
const goalTasks = this.getTasksForGoal(goalId);
|
|
132
|
+
return goalTasks.filter((task) => {
|
|
133
|
+
if (task.status !== "created")
|
|
134
|
+
return false;
|
|
135
|
+
return task.depends_on.some((depId) => {
|
|
136
|
+
const dep = this.tasks.get(depId);
|
|
137
|
+
return !dep || (dep.status !== "completed" && dep.status !== "accepted");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// =========================================================================
|
|
142
|
+
// Event Application
|
|
143
|
+
// =========================================================================
|
|
144
|
+
_applyEvent(event) {
|
|
145
|
+
switch (event.type) {
|
|
146
|
+
case "GOAL_CREATED":
|
|
147
|
+
this._onGoalCreated(event);
|
|
148
|
+
break;
|
|
149
|
+
case "GOAL_CLASSIFIED":
|
|
150
|
+
this._onGoalClassified(event);
|
|
151
|
+
break;
|
|
152
|
+
case "GOAL_PLANNED":
|
|
153
|
+
this._onGoalPlanned(event);
|
|
154
|
+
break;
|
|
155
|
+
case "GOAL_PAUSED":
|
|
156
|
+
this._onGoalStatusChange(event, "paused");
|
|
157
|
+
break;
|
|
158
|
+
case "GOAL_RESUMED":
|
|
159
|
+
this._onGoalStatusChange(event, "running");
|
|
160
|
+
break;
|
|
161
|
+
case "GOAL_COMPLETED":
|
|
162
|
+
this._onGoalStatusChange(event, "completed");
|
|
163
|
+
break;
|
|
164
|
+
case "GOAL_CANCELLED":
|
|
165
|
+
this._onGoalStatusChange(event, "cancelled");
|
|
166
|
+
break;
|
|
167
|
+
case "TASK_CREATED":
|
|
168
|
+
this._onTaskCreated(event);
|
|
169
|
+
break;
|
|
170
|
+
case "TASK_ASSIGNED":
|
|
171
|
+
this._onTaskAssigned(event);
|
|
172
|
+
break;
|
|
173
|
+
case "TASK_STARTED":
|
|
174
|
+
this._onTaskStarted(event);
|
|
175
|
+
break;
|
|
176
|
+
case "TASK_PROGRESS":
|
|
177
|
+
this._onTaskProgress(event);
|
|
178
|
+
break;
|
|
179
|
+
case "TASK_COMPLETED":
|
|
180
|
+
this._onTaskCompleted(event);
|
|
181
|
+
break;
|
|
182
|
+
case "TASK_FAILED":
|
|
183
|
+
this._onTaskFailed(event);
|
|
184
|
+
break;
|
|
185
|
+
case "TASK_REWORK_REQUESTED":
|
|
186
|
+
this._onTaskRework(event);
|
|
187
|
+
break;
|
|
188
|
+
case "TASK_ACCEPTED":
|
|
189
|
+
this._onTaskStatusChange(event, "accepted");
|
|
190
|
+
break;
|
|
191
|
+
case "TASK_CANCELLED":
|
|
192
|
+
this._onTaskCancelled(event);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
_onGoalCreated(event) {
|
|
197
|
+
const payload = event.payload;
|
|
198
|
+
this.goals.set(payload.goal_id, {
|
|
199
|
+
goal_id: payload.goal_id,
|
|
200
|
+
workspace_id: event.workspace_id,
|
|
201
|
+
status: "created",
|
|
202
|
+
title: payload.title,
|
|
203
|
+
description: payload.description,
|
|
204
|
+
root_event_id: event.event_id,
|
|
205
|
+
task_ids: [],
|
|
206
|
+
created_at: event.timestamp,
|
|
207
|
+
updated_at: event.timestamp,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
_onGoalClassified(event) {
|
|
211
|
+
const payload = event.payload;
|
|
212
|
+
const goal = this.goals.get(payload.goal_id);
|
|
213
|
+
if (!goal)
|
|
214
|
+
return;
|
|
215
|
+
goal.status = "classified";
|
|
216
|
+
goal.classification = payload.classification;
|
|
217
|
+
goal.updated_at = event.timestamp;
|
|
218
|
+
}
|
|
219
|
+
_onGoalPlanned(event) {
|
|
220
|
+
const payload = event.payload;
|
|
221
|
+
const goal = this.goals.get(payload.goal_id);
|
|
222
|
+
if (!goal)
|
|
223
|
+
return;
|
|
224
|
+
goal.status = "planned";
|
|
225
|
+
goal.task_ids = payload.task_ids;
|
|
226
|
+
goal.acceptance_criteria = payload.acceptance_criteria;
|
|
227
|
+
goal.updated_at = event.timestamp;
|
|
228
|
+
}
|
|
229
|
+
_onGoalStatusChange(event, status) {
|
|
230
|
+
const payload = event.payload;
|
|
231
|
+
const goal = this.goals.get(payload.goal_id);
|
|
232
|
+
if (!goal)
|
|
233
|
+
return;
|
|
234
|
+
goal.status = status;
|
|
235
|
+
goal.updated_at = event.timestamp;
|
|
236
|
+
}
|
|
237
|
+
_onTaskCreated(event) {
|
|
238
|
+
const payload = event.payload;
|
|
239
|
+
this.tasks.set(payload.task_id, {
|
|
240
|
+
task_id: payload.task_id,
|
|
241
|
+
goal_id: payload.goal_id,
|
|
242
|
+
status: "created",
|
|
243
|
+
title: payload.title,
|
|
244
|
+
description: payload.description,
|
|
245
|
+
priority: payload.priority,
|
|
246
|
+
depends_on: payload.depends_on ?? [],
|
|
247
|
+
root_event_id: event.event_id,
|
|
248
|
+
acceptance_criteria: payload.acceptance_criteria,
|
|
249
|
+
progress_notes: [],
|
|
250
|
+
created_at: event.timestamp,
|
|
251
|
+
updated_at: event.timestamp,
|
|
252
|
+
});
|
|
253
|
+
// Also add to goal's task_ids if not already there
|
|
254
|
+
const goal = this.goals.get(payload.goal_id);
|
|
255
|
+
if (goal && !goal.task_ids.includes(payload.task_id)) {
|
|
256
|
+
goal.task_ids.push(payload.task_id);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
_onTaskAssigned(event) {
|
|
260
|
+
const payload = event.payload;
|
|
261
|
+
const task = this.tasks.get(payload.task_id);
|
|
262
|
+
if (!task)
|
|
263
|
+
return;
|
|
264
|
+
task.status = "assigned";
|
|
265
|
+
task.assigned_to = payload.assigned_to;
|
|
266
|
+
if (payload.session_id)
|
|
267
|
+
task.session_id = payload.session_id;
|
|
268
|
+
task.updated_at = event.timestamp;
|
|
269
|
+
}
|
|
270
|
+
_onTaskStarted(event) {
|
|
271
|
+
const payload = event.payload;
|
|
272
|
+
const task = this.tasks.get(payload.task_id);
|
|
273
|
+
if (!task)
|
|
274
|
+
return;
|
|
275
|
+
task.status = "started";
|
|
276
|
+
task.session_id = payload.session_id;
|
|
277
|
+
task.updated_at = event.timestamp;
|
|
278
|
+
// Mark goal as running if not already
|
|
279
|
+
const goal = this.goals.get(task.goal_id);
|
|
280
|
+
if (goal && (goal.status === "planned" || goal.status === "classified")) {
|
|
281
|
+
goal.status = "running";
|
|
282
|
+
goal.active_session_id = payload.session_id;
|
|
283
|
+
goal.updated_at = event.timestamp;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
_onTaskProgress(event) {
|
|
287
|
+
const payload = event.payload;
|
|
288
|
+
const task = this.tasks.get(payload.task_id);
|
|
289
|
+
if (!task)
|
|
290
|
+
return;
|
|
291
|
+
task.status = "in_progress";
|
|
292
|
+
task.progress_notes.push(payload.note);
|
|
293
|
+
task.updated_at = event.timestamp;
|
|
294
|
+
}
|
|
295
|
+
_onTaskFailed(event) {
|
|
296
|
+
const payload = event.payload;
|
|
297
|
+
const task = this.tasks.get(payload.task_id);
|
|
298
|
+
if (!task)
|
|
299
|
+
return;
|
|
300
|
+
task.status = "failed";
|
|
301
|
+
task.failure_message = payload.error_message;
|
|
302
|
+
task.updated_at = event.timestamp;
|
|
303
|
+
}
|
|
304
|
+
_onTaskRework(event) {
|
|
305
|
+
const payload = event.payload;
|
|
306
|
+
const task = this.tasks.get(payload.task_id);
|
|
307
|
+
if (!task)
|
|
308
|
+
return;
|
|
309
|
+
task.status = "rework";
|
|
310
|
+
task.rework_reason = payload.reason;
|
|
311
|
+
task.updated_at = event.timestamp;
|
|
312
|
+
}
|
|
313
|
+
_onTaskCompleted(event) {
|
|
314
|
+
const payload = event.payload;
|
|
315
|
+
const task = this.tasks.get(payload.task_id);
|
|
316
|
+
if (!task)
|
|
317
|
+
return;
|
|
318
|
+
task.status = "completed";
|
|
319
|
+
task.summary = payload.summary ?? task.summary;
|
|
320
|
+
task.updated_at = event.timestamp;
|
|
321
|
+
}
|
|
322
|
+
_onTaskCancelled(event) {
|
|
323
|
+
const payload = event.payload;
|
|
324
|
+
const task = this.tasks.get(payload.task_id);
|
|
325
|
+
if (!task)
|
|
326
|
+
return;
|
|
327
|
+
task.status = "cancelled";
|
|
328
|
+
task.cancel_reason = payload.reason;
|
|
329
|
+
task.updated_at = event.timestamp;
|
|
330
|
+
}
|
|
331
|
+
_onTaskStatusChange(event, status) {
|
|
332
|
+
const payload = event.payload;
|
|
333
|
+
const task = this.tasks.get(payload.task_id);
|
|
334
|
+
if (!task)
|
|
335
|
+
return;
|
|
336
|
+
task.status = status;
|
|
337
|
+
task.updated_at = event.timestamp;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection Module
|
|
3
|
+
*
|
|
4
|
+
* Session is a query view over EventStore.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * from "./event-to-message.js";
|
|
8
|
+
export * from "./session-projection.js";
|
|
9
|
+
export * from "./session-manager.js";
|
|
10
|
+
export * from "./boundary-inferrer.js";
|
|
11
|
+
export * from "./goal-projection.js";
|
|
12
|
+
export * from "./task-history.js";
|
|
13
|
+
export * from "./timeline-projection.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection Module
|
|
3
|
+
*
|
|
4
|
+
* Session is a query view over EventStore.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * from "./event-to-message.js";
|
|
8
|
+
export * from "./session-projection.js";
|
|
9
|
+
export * from "./session-manager.js";
|
|
10
|
+
export * from "./boundary-inferrer.js";
|
|
11
|
+
export * from "./goal-projection.js";
|
|
12
|
+
export * from "./task-history.js";
|
|
13
|
+
export * from "./timeline-projection.js";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Manager (Event-Sourced)
|
|
3
|
+
*
|
|
4
|
+
* Manages session descriptors, not session data.
|
|
5
|
+
* Data lives in EventStore. Session is just a query view.
|
|
6
|
+
*/
|
|
7
|
+
import type { EventStore } from "../event-store/store.js";
|
|
8
|
+
import type { SessionDescriptor, ThreadDescriptor } from "./types.js";
|
|
9
|
+
import { SessionProjection } from "./session-projection.js";
|
|
10
|
+
export interface CreateProjectionSessionOptions {
|
|
11
|
+
parentSessionId?: string;
|
|
12
|
+
threadId?: string;
|
|
13
|
+
startEventId?: string;
|
|
14
|
+
summaryEventId?: string;
|
|
15
|
+
closeActive?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SessionManager - manages session descriptors only.
|
|
19
|
+
*
|
|
20
|
+
* Storage: ~/.pizza/agent/workspaces/<workspace_id>/sessions.json
|
|
21
|
+
*
|
|
22
|
+
* Does NOT store messages. Tree structure emerges from EventStore's caused_by chain.
|
|
23
|
+
*/
|
|
24
|
+
export declare class SessionManager {
|
|
25
|
+
private store;
|
|
26
|
+
private threads;
|
|
27
|
+
private sessions;
|
|
28
|
+
private activeThreadId;
|
|
29
|
+
private activeSessionId;
|
|
30
|
+
private inferrer;
|
|
31
|
+
private unsubscribe;
|
|
32
|
+
private filePath;
|
|
33
|
+
constructor(store: EventStore, storagePath?: string);
|
|
34
|
+
/**
|
|
35
|
+
* Get or create the active session.
|
|
36
|
+
*/
|
|
37
|
+
getActiveSession(): SessionProjection;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new session.
|
|
40
|
+
*/
|
|
41
|
+
createSession(created_by: SessionDescriptor["created_by"], name?: string, options?: CreateProjectionSessionOptions): SessionDescriptor;
|
|
42
|
+
/**
|
|
43
|
+
* Fork the current session at a specific event.
|
|
44
|
+
*/
|
|
45
|
+
forkAt(event_id: string): SessionDescriptor;
|
|
46
|
+
/**
|
|
47
|
+
* Fork an existing session while preserving its projected history.
|
|
48
|
+
*
|
|
49
|
+
* The source session is frozen at the current head if it was tracking HEAD,
|
|
50
|
+
* and the forked descriptor reuses the source start boundary so context still
|
|
51
|
+
* includes the source conversation.
|
|
52
|
+
*/
|
|
53
|
+
forkFromSession(session_id: string): SessionDescriptor;
|
|
54
|
+
/**
|
|
55
|
+
* List all sessions.
|
|
56
|
+
*/
|
|
57
|
+
listSessions(): SessionDescriptor[];
|
|
58
|
+
/**
|
|
59
|
+
* Switch to a different session.
|
|
60
|
+
*/
|
|
61
|
+
switchTo(session_id: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Get a session by ID.
|
|
64
|
+
*/
|
|
65
|
+
getSession(session_id: string): SessionDescriptor | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Get session projection by ID.
|
|
68
|
+
*/
|
|
69
|
+
getSessionProjection(session_id: string): SessionProjection | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Update session name.
|
|
72
|
+
*/
|
|
73
|
+
renameSession(session_id: string, name: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Get the active session ID.
|
|
76
|
+
*/
|
|
77
|
+
getActiveSessionId(): string | undefined;
|
|
78
|
+
getActiveThreadId(): string | undefined;
|
|
79
|
+
getActiveThread(): ThreadDescriptor | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Create a new thread (conversation). Threads are the isolation unit —
|
|
82
|
+
* events are tagged with thread_id. Creates the first session in the thread.
|
|
83
|
+
* Threads are fixed once created; auto-splitting happens at session level.
|
|
84
|
+
*/
|
|
85
|
+
createThread(name?: string): ThreadDescriptor;
|
|
86
|
+
/**
|
|
87
|
+
* Dispose the session manager.
|
|
88
|
+
*/
|
|
89
|
+
dispose(): void;
|
|
90
|
+
private _subscribeToEvents;
|
|
91
|
+
private _evaluateBoundary;
|
|
92
|
+
private _getRecentEventsBefore;
|
|
93
|
+
private _ensureStorageDir;
|
|
94
|
+
private _loadIndex;
|
|
95
|
+
private _persistIndex;
|
|
96
|
+
private _generateSessionId;
|
|
97
|
+
/** Create a thread record (no session). Used by createThread and createSession's auto-thread fallback. */
|
|
98
|
+
private _createThreadRecord;
|
|
99
|
+
private _generateThreadId;
|
|
100
|
+
}
|