@tomsun28/pizza 0.1.0 → 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 -14
- package/dist/extension/index.js +0 -374
- package/dist/extension/index.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/themes/pizza.json +0 -87
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const TASK_HISTORY_EVENT_TYPES = [
|
|
2
|
+
"TASK_CREATED",
|
|
3
|
+
"TASK_ASSIGNED",
|
|
4
|
+
"TASK_STARTED",
|
|
5
|
+
"TASK_PROGRESS",
|
|
6
|
+
"TASK_COMPLETED",
|
|
7
|
+
"TASK_FAILED",
|
|
8
|
+
"TASK_REWORK_REQUESTED",
|
|
9
|
+
"TASK_ACCEPTED",
|
|
10
|
+
"TASK_CANCELLED",
|
|
11
|
+
];
|
|
12
|
+
export function buildRecentTaskHistory(projection, limit = 3) {
|
|
13
|
+
return projection
|
|
14
|
+
.listTasks()
|
|
15
|
+
.sort((a, b) => b.updated_at - a.updated_at)
|
|
16
|
+
.slice(0, Math.max(0, limit))
|
|
17
|
+
.map((task) => ({
|
|
18
|
+
task_id: task.task_id,
|
|
19
|
+
status: task.status,
|
|
20
|
+
title: cleanText(task.title),
|
|
21
|
+
summary: summarizeTask(task),
|
|
22
|
+
updated_at: task.updated_at,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export function summarizeTask(task) {
|
|
26
|
+
const title = cleanText(task.title);
|
|
27
|
+
const latestProgress = cleanText(task.progress_notes.at(-1));
|
|
28
|
+
const summary = cleanText(task.summary);
|
|
29
|
+
const failure = cleanText(task.failure_message);
|
|
30
|
+
const rework = cleanText(task.rework_reason);
|
|
31
|
+
const cancelled = cleanText(task.cancel_reason);
|
|
32
|
+
const description = cleanText(task.description);
|
|
33
|
+
switch (task.status) {
|
|
34
|
+
case "accepted":
|
|
35
|
+
return summary || title;
|
|
36
|
+
case "completed":
|
|
37
|
+
return summary || `Completed ${lowercaseFirst(title)}`;
|
|
38
|
+
case "failed":
|
|
39
|
+
return failure ? `Failed: ${failure}` : `Failed ${lowercaseFirst(title)}`;
|
|
40
|
+
case "rework":
|
|
41
|
+
return rework ? `Rework: ${rework}` : `Rework needed for ${lowercaseFirst(title)}`;
|
|
42
|
+
case "cancelled":
|
|
43
|
+
return cancelled ? `Cancelled: ${cancelled}` : `Cancelled ${lowercaseFirst(title)}`;
|
|
44
|
+
case "in_progress":
|
|
45
|
+
return latestProgress || `Working on ${lowercaseFirst(title)}`;
|
|
46
|
+
case "started":
|
|
47
|
+
return `Started ${lowercaseFirst(title)}`;
|
|
48
|
+
case "assigned":
|
|
49
|
+
return task.assigned_to ? `Assigned to ${task.assigned_to}: ${title}` : `Assigned ${lowercaseFirst(title)}`;
|
|
50
|
+
case "created":
|
|
51
|
+
return description || title;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function cleanText(value) {
|
|
55
|
+
return (value ?? "").replace(/\s+/g, " ").trim();
|
|
56
|
+
}
|
|
57
|
+
function lowercaseFirst(value) {
|
|
58
|
+
if (!value)
|
|
59
|
+
return "task";
|
|
60
|
+
return value.charAt(0).toLowerCase() + value.slice(1);
|
|
61
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline Projection
|
|
3
|
+
*
|
|
4
|
+
* Derives a chronological activity timeline from events in the EventStore.
|
|
5
|
+
* Used by UI layers to render a full activity feed (not just chat messages).
|
|
6
|
+
*
|
|
7
|
+
* The timeline includes:
|
|
8
|
+
* - User messages
|
|
9
|
+
* - Agent responses (summarized)
|
|
10
|
+
* - Tool executions (with duration)
|
|
11
|
+
* - File mutations
|
|
12
|
+
* - Goal/Task lifecycle events
|
|
13
|
+
* - Session boundaries
|
|
14
|
+
* - Compaction markers
|
|
15
|
+
*/
|
|
16
|
+
import type { EventStore } from "../event-store/store.js";
|
|
17
|
+
/** Timeline entry kind */
|
|
18
|
+
export type TimelineEntryKind = "user_message" | "agent_message" | "tool_execution" | "file_mutation" | "goal_event" | "task_event" | "session_boundary" | "compaction" | "error" | "checkpoint";
|
|
19
|
+
/** A single entry in the timeline */
|
|
20
|
+
export interface TimelineEntry {
|
|
21
|
+
/** Underlying event ID */
|
|
22
|
+
event_id: string;
|
|
23
|
+
/** Timestamp (unix ms) */
|
|
24
|
+
timestamp: number;
|
|
25
|
+
/** Entry kind for rendering */
|
|
26
|
+
kind: TimelineEntryKind;
|
|
27
|
+
/** Short human-readable summary */
|
|
28
|
+
summary: string;
|
|
29
|
+
/** Actor that produced this event */
|
|
30
|
+
actor_id: string;
|
|
31
|
+
/** Optional duration in ms (for tool executions) */
|
|
32
|
+
duration_ms?: number;
|
|
33
|
+
/** Associated metadata (tool name, file path, goal/task id, etc.) */
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
/** Causal parent event_id */
|
|
36
|
+
caused_by?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Options for querying the timeline */
|
|
39
|
+
export interface TimelineQueryOptions {
|
|
40
|
+
/** Only include entries after this timestamp */
|
|
41
|
+
after_timestamp?: number;
|
|
42
|
+
/** Only include entries before this timestamp */
|
|
43
|
+
before_timestamp?: number;
|
|
44
|
+
/** Only include specific kinds */
|
|
45
|
+
kinds?: TimelineEntryKind[];
|
|
46
|
+
/** Maximum number of entries */
|
|
47
|
+
limit?: number;
|
|
48
|
+
/** Thread filter (isolation key) */
|
|
49
|
+
thread_id?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* TimelineProjection builds a chronological activity feed from events.
|
|
53
|
+
*
|
|
54
|
+
* Usage:
|
|
55
|
+
* const timeline = new TimelineProjection(store);
|
|
56
|
+
* const entries = timeline.query({ limit: 50 });
|
|
57
|
+
*/
|
|
58
|
+
export declare class TimelineProjection {
|
|
59
|
+
private store;
|
|
60
|
+
/** In-memory cache of tool start times (for duration calculation) */
|
|
61
|
+
private toolStartTimes;
|
|
62
|
+
constructor(store: EventStore);
|
|
63
|
+
/**
|
|
64
|
+
* Query the timeline.
|
|
65
|
+
*/
|
|
66
|
+
query(options?: TimelineQueryOptions): TimelineEntry[];
|
|
67
|
+
/**
|
|
68
|
+
* Get the latest N timeline entries.
|
|
69
|
+
*/
|
|
70
|
+
latest(count: number): TimelineEntry[];
|
|
71
|
+
private _eventToEntry;
|
|
72
|
+
private _userMessage;
|
|
73
|
+
private _agentMessage;
|
|
74
|
+
private _toolExecution;
|
|
75
|
+
private _fileMutation;
|
|
76
|
+
private _goalEvent;
|
|
77
|
+
private _taskEvent;
|
|
78
|
+
private _sessionEvent;
|
|
79
|
+
private _compactionEvent;
|
|
80
|
+
private _errorEvent;
|
|
81
|
+
private _checkpointEvent;
|
|
82
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline Projection
|
|
3
|
+
*
|
|
4
|
+
* Derives a chronological activity timeline from events in the EventStore.
|
|
5
|
+
* Used by UI layers to render a full activity feed (not just chat messages).
|
|
6
|
+
*
|
|
7
|
+
* The timeline includes:
|
|
8
|
+
* - User messages
|
|
9
|
+
* - Agent responses (summarized)
|
|
10
|
+
* - Tool executions (with duration)
|
|
11
|
+
* - File mutations
|
|
12
|
+
* - Goal/Task lifecycle events
|
|
13
|
+
* - Session boundaries
|
|
14
|
+
* - Compaction markers
|
|
15
|
+
*/
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Event types we scan for the timeline
|
|
18
|
+
// ============================================================================
|
|
19
|
+
const TIMELINE_EVENT_TYPES = [
|
|
20
|
+
"USER_MESSAGE",
|
|
21
|
+
"AGENT_MESSAGE_END",
|
|
22
|
+
"TOOL_EXECUTION_START",
|
|
23
|
+
"TOOL_EXECUTION_END",
|
|
24
|
+
"FILE_MUTATION_APPLIED",
|
|
25
|
+
"GOAL_CREATED",
|
|
26
|
+
"GOAL_PLANNED",
|
|
27
|
+
"GOAL_COMPLETED",
|
|
28
|
+
"GOAL_CANCELLED",
|
|
29
|
+
"TASK_CREATED",
|
|
30
|
+
"TASK_STARTED",
|
|
31
|
+
"TASK_COMPLETED",
|
|
32
|
+
"TASK_FAILED",
|
|
33
|
+
"TASK_ACCEPTED",
|
|
34
|
+
"SESSION_CREATED",
|
|
35
|
+
"SESSION_BOUNDARY_INFERRED",
|
|
36
|
+
"SESSION_FORKED",
|
|
37
|
+
"COMPACTION_END",
|
|
38
|
+
"COMPACTION_ABORTED",
|
|
39
|
+
"AGENT_ERROR",
|
|
40
|
+
"RUNTIME_ERROR",
|
|
41
|
+
"CHECKPOINT_CREATED",
|
|
42
|
+
];
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Timeline Projection
|
|
45
|
+
// ============================================================================
|
|
46
|
+
/**
|
|
47
|
+
* TimelineProjection builds a chronological activity feed from events.
|
|
48
|
+
*
|
|
49
|
+
* Usage:
|
|
50
|
+
* const timeline = new TimelineProjection(store);
|
|
51
|
+
* const entries = timeline.query({ limit: 50 });
|
|
52
|
+
*/
|
|
53
|
+
export class TimelineProjection {
|
|
54
|
+
constructor(store) {
|
|
55
|
+
this.store = store;
|
|
56
|
+
/** In-memory cache of tool start times (for duration calculation) */
|
|
57
|
+
this.toolStartTimes = new Map();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Query the timeline.
|
|
61
|
+
*/
|
|
62
|
+
query(options) {
|
|
63
|
+
const events = this.store.query({
|
|
64
|
+
types: TIMELINE_EVENT_TYPES,
|
|
65
|
+
thread_id: options?.thread_id,
|
|
66
|
+
});
|
|
67
|
+
// Also fetch TOOL_EXECUTION_START events for duration calculation
|
|
68
|
+
const toolStartEvents = this.store.query({ types: ["TOOL_EXECUTION_START"] });
|
|
69
|
+
this.toolStartTimes.clear();
|
|
70
|
+
for (const evt of toolStartEvents) {
|
|
71
|
+
const payload = evt.payload;
|
|
72
|
+
if (payload.tool_call_id) {
|
|
73
|
+
this.toolStartTimes.set(payload.tool_call_id, evt.timestamp);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let entries = events
|
|
77
|
+
.map((event) => this._eventToEntry(event))
|
|
78
|
+
.filter((entry) => entry !== undefined);
|
|
79
|
+
// Apply filters
|
|
80
|
+
if (options?.after_timestamp) {
|
|
81
|
+
entries = entries.filter((e) => e.timestamp > options.after_timestamp);
|
|
82
|
+
}
|
|
83
|
+
if (options?.before_timestamp) {
|
|
84
|
+
entries = entries.filter((e) => e.timestamp < options.before_timestamp);
|
|
85
|
+
}
|
|
86
|
+
if (options?.kinds?.length) {
|
|
87
|
+
entries = entries.filter((e) => options.kinds.includes(e.kind));
|
|
88
|
+
}
|
|
89
|
+
if (options?.limit && entries.length > options.limit) {
|
|
90
|
+
entries = entries.slice(-options.limit);
|
|
91
|
+
}
|
|
92
|
+
return entries;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the latest N timeline entries.
|
|
96
|
+
*/
|
|
97
|
+
latest(count) {
|
|
98
|
+
return this.query({ limit: count });
|
|
99
|
+
}
|
|
100
|
+
// =========================================================================
|
|
101
|
+
// Event-to-Entry Conversion
|
|
102
|
+
// =========================================================================
|
|
103
|
+
_eventToEntry(event) {
|
|
104
|
+
switch (event.type) {
|
|
105
|
+
case "USER_MESSAGE":
|
|
106
|
+
return this._userMessage(event);
|
|
107
|
+
case "AGENT_MESSAGE_END":
|
|
108
|
+
return this._agentMessage(event);
|
|
109
|
+
case "TOOL_EXECUTION_END":
|
|
110
|
+
return this._toolExecution(event);
|
|
111
|
+
case "FILE_MUTATION_APPLIED":
|
|
112
|
+
return this._fileMutation(event);
|
|
113
|
+
case "GOAL_CREATED":
|
|
114
|
+
case "GOAL_PLANNED":
|
|
115
|
+
case "GOAL_COMPLETED":
|
|
116
|
+
case "GOAL_CANCELLED":
|
|
117
|
+
return this._goalEvent(event);
|
|
118
|
+
case "TASK_CREATED":
|
|
119
|
+
case "TASK_STARTED":
|
|
120
|
+
case "TASK_COMPLETED":
|
|
121
|
+
case "TASK_FAILED":
|
|
122
|
+
case "TASK_ACCEPTED":
|
|
123
|
+
return this._taskEvent(event);
|
|
124
|
+
case "SESSION_CREATED":
|
|
125
|
+
case "SESSION_BOUNDARY_INFERRED":
|
|
126
|
+
case "SESSION_FORKED":
|
|
127
|
+
return this._sessionEvent(event);
|
|
128
|
+
case "COMPACTION_END":
|
|
129
|
+
case "COMPACTION_ABORTED":
|
|
130
|
+
return this._compactionEvent(event);
|
|
131
|
+
case "AGENT_ERROR":
|
|
132
|
+
case "RUNTIME_ERROR":
|
|
133
|
+
return this._errorEvent(event);
|
|
134
|
+
case "CHECKPOINT_CREATED":
|
|
135
|
+
return this._checkpointEvent(event);
|
|
136
|
+
default:
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
_userMessage(event) {
|
|
141
|
+
const payload = event.payload;
|
|
142
|
+
const text = typeof payload.content === "string" ? payload.content : "";
|
|
143
|
+
return {
|
|
144
|
+
event_id: event.event_id,
|
|
145
|
+
timestamp: event.timestamp,
|
|
146
|
+
kind: "user_message",
|
|
147
|
+
summary: text.length > 100 ? text.slice(0, 100) + "…" : text,
|
|
148
|
+
actor_id: event.actor_id,
|
|
149
|
+
caused_by: event.caused_by,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
_agentMessage(event) {
|
|
153
|
+
const payload = event.payload;
|
|
154
|
+
const textBlocks = payload.content?.filter((b) => b.type === "text") ?? [];
|
|
155
|
+
const firstText = textBlocks[0]?.text ?? "";
|
|
156
|
+
const summary = firstText.length > 100 ? firstText.slice(0, 100) + "…" : firstText;
|
|
157
|
+
return {
|
|
158
|
+
event_id: event.event_id,
|
|
159
|
+
timestamp: event.timestamp,
|
|
160
|
+
kind: "agent_message",
|
|
161
|
+
summary: summary || `(${payload.stop_reason ?? "response"})`,
|
|
162
|
+
actor_id: event.actor_id,
|
|
163
|
+
caused_by: event.caused_by,
|
|
164
|
+
metadata: { stop_reason: payload.stop_reason, tokens: payload.usage?.total },
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
_toolExecution(event) {
|
|
168
|
+
const payload = event.payload;
|
|
169
|
+
const startTime = payload.tool_call_id
|
|
170
|
+
? this.toolStartTimes.get(payload.tool_call_id)
|
|
171
|
+
: undefined;
|
|
172
|
+
const duration = startTime ? event.timestamp - startTime : undefined;
|
|
173
|
+
return {
|
|
174
|
+
event_id: event.event_id,
|
|
175
|
+
timestamp: event.timestamp,
|
|
176
|
+
kind: "tool_execution",
|
|
177
|
+
summary: `${payload.tool_name ?? "tool"}${payload.is_error ? " (error)" : ""}`,
|
|
178
|
+
actor_id: event.actor_id,
|
|
179
|
+
duration_ms: duration,
|
|
180
|
+
caused_by: event.caused_by,
|
|
181
|
+
metadata: { tool_name: payload.tool_name, is_error: payload.is_error },
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
_fileMutation(event) {
|
|
185
|
+
const payload = event.payload;
|
|
186
|
+
const path = payload.path ?? payload.mutation?.path ?? "file";
|
|
187
|
+
const operation = payload.operation ?? payload.mutation?.operation ?? "modify";
|
|
188
|
+
return {
|
|
189
|
+
event_id: event.event_id,
|
|
190
|
+
timestamp: event.timestamp,
|
|
191
|
+
kind: "file_mutation",
|
|
192
|
+
summary: `${operation} ${path}`,
|
|
193
|
+
actor_id: event.actor_id,
|
|
194
|
+
caused_by: event.caused_by,
|
|
195
|
+
metadata: { ...payload.mutation, ...payload, path, operation },
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
_goalEvent(event) {
|
|
199
|
+
const payload = event.payload;
|
|
200
|
+
const action = event.type.replace("GOAL_", "").toLowerCase();
|
|
201
|
+
return {
|
|
202
|
+
event_id: event.event_id,
|
|
203
|
+
timestamp: event.timestamp,
|
|
204
|
+
kind: "goal_event",
|
|
205
|
+
summary: `Goal ${action}: ${payload.title ?? payload.goal_id ?? ""}`,
|
|
206
|
+
actor_id: event.actor_id,
|
|
207
|
+
caused_by: event.caused_by,
|
|
208
|
+
metadata: payload,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
_taskEvent(event) {
|
|
212
|
+
const payload = event.payload;
|
|
213
|
+
const action = event.type.replace("TASK_", "").toLowerCase();
|
|
214
|
+
return {
|
|
215
|
+
event_id: event.event_id,
|
|
216
|
+
timestamp: event.timestamp,
|
|
217
|
+
kind: "task_event",
|
|
218
|
+
summary: `Task ${action}: ${payload.title ?? payload.task_id ?? ""}`,
|
|
219
|
+
actor_id: event.actor_id,
|
|
220
|
+
caused_by: event.caused_by,
|
|
221
|
+
metadata: payload,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
_sessionEvent(event) {
|
|
225
|
+
const payload = event.payload;
|
|
226
|
+
const action = event.type.replace("SESSION_", "").toLowerCase();
|
|
227
|
+
return {
|
|
228
|
+
event_id: event.event_id,
|
|
229
|
+
timestamp: event.timestamp,
|
|
230
|
+
kind: "session_boundary",
|
|
231
|
+
summary: `Session ${action}${payload.reason ? `: ${payload.reason}` : ""}`,
|
|
232
|
+
actor_id: event.actor_id,
|
|
233
|
+
caused_by: event.caused_by,
|
|
234
|
+
metadata: payload,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
_compactionEvent(event) {
|
|
238
|
+
const payload = event.payload;
|
|
239
|
+
const aborted = event.type === "COMPACTION_ABORTED";
|
|
240
|
+
return {
|
|
241
|
+
event_id: event.event_id,
|
|
242
|
+
timestamp: event.timestamp,
|
|
243
|
+
kind: "compaction",
|
|
244
|
+
summary: aborted
|
|
245
|
+
? `Context compaction aborted${payload.message ? `: ${payload.message}` : ""}`
|
|
246
|
+
: `Context compacted${payload.tokens_before ? ` (${payload.tokens_before} tokens)` : ""}`,
|
|
247
|
+
actor_id: event.actor_id,
|
|
248
|
+
caused_by: event.caused_by,
|
|
249
|
+
metadata: payload,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
_errorEvent(event) {
|
|
253
|
+
const payload = event.payload;
|
|
254
|
+
return {
|
|
255
|
+
event_id: event.event_id,
|
|
256
|
+
timestamp: event.timestamp,
|
|
257
|
+
kind: "error",
|
|
258
|
+
summary: payload.error_message ?? payload.error ?? "Runtime error",
|
|
259
|
+
actor_id: event.actor_id,
|
|
260
|
+
caused_by: event.caused_by,
|
|
261
|
+
metadata: payload,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
_checkpointEvent(event) {
|
|
265
|
+
const payload = event.payload;
|
|
266
|
+
return {
|
|
267
|
+
event_id: event.event_id,
|
|
268
|
+
timestamp: event.timestamp,
|
|
269
|
+
kind: "checkpoint",
|
|
270
|
+
summary: `Checkpoint${payload.label ? `: ${payload.label}` : ""}`,
|
|
271
|
+
actor_id: event.actor_id,
|
|
272
|
+
caused_by: event.caused_by,
|
|
273
|
+
metadata: payload,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Projection Types
|
|
3
|
+
*
|
|
4
|
+
* Session is a query view over the EventStore, not a data holder.
|
|
5
|
+
*/
|
|
6
|
+
import type { EventBase } from "../event-store/types.js";
|
|
7
|
+
/** Session definition - pure reference structure */
|
|
8
|
+
export interface SessionDescriptor {
|
|
9
|
+
session_id: string;
|
|
10
|
+
thread_id: string;
|
|
11
|
+
workspace_id: string;
|
|
12
|
+
/** Event range covered by this session [start, end] (inclusive) */
|
|
13
|
+
event_range: {
|
|
14
|
+
start_event_id: string;
|
|
15
|
+
end_event_id: string;
|
|
16
|
+
};
|
|
17
|
+
/** Summary reference (compaction event_id) */
|
|
18
|
+
summary_event_id?: string;
|
|
19
|
+
/** User-defined name */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Creation method */
|
|
22
|
+
created_by: "user_explicit" | "auto_inferred" | "fork";
|
|
23
|
+
/** Boundary inference reason */
|
|
24
|
+
boundary_reason?: "intent_shift" | "file_drift" | "time_gap" | "user_explicit";
|
|
25
|
+
/** Parent session (fork source) */
|
|
26
|
+
parent_session_id?: string;
|
|
27
|
+
/** Creation timestamp */
|
|
28
|
+
created_at: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A conversation thread — the isolation unit.
|
|
32
|
+
*
|
|
33
|
+
* One thread = one `thread_id` on events. Threads are fixed once created;
|
|
34
|
+
* auto-splitting happens at session level (within a thread), never at thread level.
|
|
35
|
+
* A thread contains a tree of sessions (branches from rewind/fork).
|
|
36
|
+
*/
|
|
37
|
+
export interface ThreadDescriptor {
|
|
38
|
+
thread_id: string;
|
|
39
|
+
workspace_id: string;
|
|
40
|
+
/** User-defined name (e.g. "Q3 marketing") */
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Creation timestamp */
|
|
43
|
+
created_at: number;
|
|
44
|
+
/** Lifecycle status. active = ongoing; closed = user-ended. */
|
|
45
|
+
status: "active" | "closed";
|
|
46
|
+
}
|
|
47
|
+
/** Session index storage (threads + their session branches) */
|
|
48
|
+
export interface SessionIndex {
|
|
49
|
+
threads: ThreadDescriptor[];
|
|
50
|
+
sessions: SessionDescriptor[];
|
|
51
|
+
}
|
|
52
|
+
/** Options for building LLM context */
|
|
53
|
+
export interface BuildContextOptions {
|
|
54
|
+
/** Token budget */
|
|
55
|
+
max_tokens?: number;
|
|
56
|
+
/** Include tool execution details */
|
|
57
|
+
include_tool_details?: boolean;
|
|
58
|
+
/** Include file mutations */
|
|
59
|
+
include_file_mutations?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Built context result */
|
|
62
|
+
export interface BuiltContext {
|
|
63
|
+
/** Messages for LLM consumption */
|
|
64
|
+
messages: import("../agent/types.js").AgentMessage[];
|
|
65
|
+
/** Raw events used to build context */
|
|
66
|
+
events: EventBase[];
|
|
67
|
+
/** Session descriptor */
|
|
68
|
+
descriptor: SessionDescriptor;
|
|
69
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type SourceInfo } from "./source-info.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a prompt template loaded from a markdown file
|
|
4
|
+
*/
|
|
5
|
+
export interface PromptTemplate {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
argumentHint?: string;
|
|
9
|
+
content: string;
|
|
10
|
+
sourceInfo: SourceInfo;
|
|
11
|
+
filePath: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse command arguments respecting quoted strings (bash-style)
|
|
15
|
+
* Returns array of arguments
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseCommandArgs(argsString: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Substitute argument placeholders in template content
|
|
20
|
+
* Supports:
|
|
21
|
+
* - $1, $2, ... for positional args
|
|
22
|
+
* - $@ and $ARGUMENTS for all args
|
|
23
|
+
* - ${@:N} for args from Nth onwards (bash-style slicing)
|
|
24
|
+
* - ${@:N:L} for L args starting from Nth
|
|
25
|
+
*
|
|
26
|
+
* Note: Replacement happens on the template string only. Argument values
|
|
27
|
+
* containing patterns like $1, $@, or $ARGUMENTS are NOT recursively substituted.
|
|
28
|
+
*/
|
|
29
|
+
export declare function substituteArgs(content: string, args: string[]): string;
|
|
30
|
+
export interface LoadPromptTemplatesOptions {
|
|
31
|
+
/** Working directory for project-local templates. */
|
|
32
|
+
cwd: string;
|
|
33
|
+
/** Agent config directory for global templates. */
|
|
34
|
+
agentDir: string;
|
|
35
|
+
/** Explicit prompt template paths (files or directories). */
|
|
36
|
+
promptPaths: string[];
|
|
37
|
+
/** Include default prompt directories. */
|
|
38
|
+
includeDefaults: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load all prompt templates from:
|
|
42
|
+
* 1. Global: agentDir/prompts/
|
|
43
|
+
* 2. Project: cwd/{CONFIG_DIR_NAME}/prompts/
|
|
44
|
+
* 3. Explicit prompt paths
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadPromptTemplates(options: LoadPromptTemplatesOptions): PromptTemplate[];
|
|
47
|
+
/**
|
|
48
|
+
* Expand a prompt template if it matches a template name.
|
|
49
|
+
* Returns the expanded content or the original text if not a template.
|
|
50
|
+
*/
|
|
51
|
+
export declare function expandPromptTemplate(text: string, templates: PromptTemplate[]): string;
|