@oh-my-pi/pi-coding-agent 6.9.69 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +219 -51
- package/README.md +1 -1
- package/docs/hooks.md +2 -2
- package/docs/sdk.md +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/package.json +10 -10
- package/scripts/format-prompts.ts +143 -0
- package/scripts/generate-template.ts +1 -1
- package/src/cli/args.ts +3 -3
- package/src/cli/config-cli.ts +4 -4
- package/src/cli/file-processor.ts +3 -3
- package/src/cli/list-models.ts +2 -2
- package/src/cli/plugin-cli.ts +3 -3
- package/src/cli/session-picker.ts +2 -2
- package/src/cli/setup-cli.ts +2 -2
- package/src/cli/stats-cli.ts +1 -1
- package/src/cli/update-cli.ts +2 -2
- package/src/{core → config}/keybindings.ts +1 -1
- package/src/{core → config}/model-registry.ts +8 -1
- package/src/{core → config}/model-resolver.ts +3 -3
- package/src/{core → config}/prompt-templates.ts +2 -2
- package/src/{core → config}/settings-manager.ts +6 -6
- package/src/{core/cursor/exec-bridge.ts → cursor.ts} +4 -4
- package/src/discovery/agents-md.ts +4 -4
- package/src/discovery/builtin.ts +17 -17
- package/src/discovery/claude.ts +12 -12
- package/src/discovery/cline.ts +6 -6
- package/src/discovery/codex.ts +21 -21
- package/src/discovery/cursor.ts +9 -9
- package/src/discovery/gemini.ts +9 -9
- package/src/discovery/github.ts +6 -6
- package/src/discovery/helpers.ts +4 -4
- package/src/discovery/index.ts +16 -16
- package/src/discovery/mcp-json.ts +4 -4
- package/src/discovery/ssh.ts +4 -4
- package/src/discovery/vscode.ts +4 -4
- package/src/discovery/windsurf.ts +6 -6
- package/src/{core/tools/exa → exa}/company.ts +2 -3
- package/src/{core/tools/exa → exa}/index.ts +2 -2
- package/src/{core/tools/exa → exa}/linkedin.ts +2 -3
- package/src/{core/tools/exa → exa}/mcp-client.ts +2 -2
- package/src/{core/tools/exa → exa}/render.ts +3 -3
- package/src/{core/tools/exa → exa}/researcher.ts +1 -1
- package/src/{core/tools/exa → exa}/search.ts +2 -10
- package/src/{core/tools/exa → exa}/websets.ts +1 -1
- package/src/{core → exec}/bash-executor.ts +23 -7
- package/src/{core → export}/custom-share.ts +1 -1
- package/src/{core/export-html → export/html}/index.ts +3 -3
- package/src/{core → export}/ttsr.ts +2 -2
- package/src/{core → extensibility}/custom-commands/bundled/review/index.ts +4 -4
- package/src/{core → extensibility}/custom-commands/loader.ts +3 -3
- package/src/{core → extensibility}/custom-commands/types.ts +1 -1
- package/src/{core → extensibility}/custom-tools/loader.ts +9 -9
- package/src/{core → extensibility}/custom-tools/types.ts +6 -6
- package/src/{core → extensibility}/custom-tools/wrapper.ts +1 -1
- package/src/{core → extensibility}/extensions/loader.ts +8 -8
- package/src/{core → extensibility}/extensions/runner.ts +3 -3
- package/src/{core → extensibility}/extensions/types.ts +15 -15
- package/src/{core → extensibility}/extensions/wrapper.ts +1 -1
- package/src/{core → extensibility}/hooks/index.ts +1 -1
- package/src/{core → extensibility}/hooks/loader.ts +7 -7
- package/src/{core → extensibility}/hooks/runner.ts +4 -4
- package/src/{core → extensibility}/hooks/types.ts +9 -9
- package/src/{core → extensibility}/plugins/doctor.ts +1 -1
- package/src/{core → extensibility}/plugins/installer.ts +2 -3
- package/src/{core → extensibility}/plugins/paths.ts +1 -1
- package/src/{core → extensibility}/skills.ts +8 -48
- package/src/{core → extensibility}/slash-commands.ts +6 -6
- package/src/index.ts +127 -128
- package/src/internal-urls/agent-protocol.ts +126 -0
- package/src/internal-urls/artifact-protocol.ts +93 -0
- package/src/internal-urls/index.ts +28 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/router.ts +69 -0
- package/src/internal-urls/rule-protocol.ts +56 -0
- package/src/internal-urls/skill-protocol.ts +112 -0
- package/src/internal-urls/types.ts +48 -0
- package/src/{core/python-executor.ts → ipy/executor.ts} +74 -13
- package/src/{core/python-gateway-coordinator.ts → ipy/gateway-coordinator.ts} +40 -270
- package/src/{core/python-kernel.ts → ipy/kernel.ts} +38 -10
- package/src/{core/python-prelude.py → ipy/prelude.py} +201 -8
- package/src/ipy/prelude.ts +3 -0
- package/src/{core/tools/lsp → lsp}/client.ts +7 -6
- package/src/{core/tools/lsp → lsp}/clients/biome-client.ts +1 -1
- package/src/{core/tools/lsp → lsp}/clients/index.ts +1 -1
- package/src/{core/tools/lsp → lsp}/clients/lsp-linter-client.ts +4 -4
- package/src/{core/tools/lsp → lsp}/config.ts +1 -1
- package/src/{core/tools/lsp → lsp}/index.ts +29 -17
- package/src/{core/tools/lsp → lsp}/render.ts +2 -2
- package/src/{core/tools/lsp → lsp}/types.ts +14 -16
- package/src/{core/tools/lsp → lsp}/utils.ts +1 -1
- package/src/main.ts +12 -12
- package/src/{core/mcp → mcp}/config.ts +8 -8
- package/src/{core/mcp → mcp}/loader.ts +5 -6
- package/src/{core/mcp → mcp}/manager.ts +2 -2
- package/src/{core/mcp → mcp}/tool-bridge.ts +35 -6
- package/src/{core/mcp → mcp}/tool-cache.ts +1 -1
- package/src/{core/mcp → mcp}/transports/http.ts +7 -1
- package/src/{core/mcp → mcp}/transports/stdio.ts +1 -1
- package/src/{core/mcp → mcp}/types.ts +1 -1
- package/src/migrations.ts +2 -2
- package/src/modes/{interactive/components → components}/armin.ts +1 -1
- package/src/modes/{interactive/components → components}/assistant-message.ts +1 -1
- package/src/modes/{interactive/components → components}/bash-execution.ts +37 -29
- package/src/modes/{interactive/components → components}/bordered-loader.ts +1 -1
- package/src/modes/{interactive/components → components}/branch-summary-message.ts +2 -2
- package/src/modes/{interactive/components → components}/compaction-summary-message.ts +2 -2
- package/src/modes/{interactive/components → components}/custom-message.ts +3 -3
- package/src/modes/{interactive/components → components}/diff.ts +1 -1
- package/src/modes/{interactive/components → components}/dynamic-border.ts +1 -1
- package/src/modes/{interactive/components → components}/extensions/extension-dashboard.ts +3 -3
- package/src/modes/{interactive/components → components}/extensions/extension-list.ts +2 -2
- package/src/modes/{interactive/components → components}/extensions/inspector-panel.ts +1 -1
- package/src/modes/{interactive/components → components}/extensions/state-manager.ts +11 -17
- package/src/modes/{interactive/components → components}/extensions/types.ts +1 -1
- package/src/modes/{interactive/components → components}/footer.ts +3 -3
- package/src/modes/{interactive/components → components}/history-search.ts +2 -2
- package/src/modes/{interactive/components → components}/hook-editor.ts +1 -1
- package/src/modes/{interactive/components → components}/hook-input.ts +1 -1
- package/src/modes/{interactive/components → components}/hook-message.ts +3 -3
- package/src/modes/{interactive/components → components}/hook-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/keybinding-hints.ts +2 -2
- package/src/modes/{interactive/components → components}/login-dialog.ts +1 -1
- package/src/modes/{interactive/components → components}/model-selector.ts +5 -5
- package/src/modes/{interactive/components → components}/oauth-selector.ts +2 -2
- package/src/modes/{interactive/components → components}/plugin-settings.ts +3 -3
- package/src/modes/{interactive/components → components}/python-execution.ts +35 -24
- package/src/modes/{interactive/components → components}/queue-mode-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/read-tool-group.ts +2 -2
- package/src/modes/{interactive/components → components}/session-selector.ts +3 -3
- package/src/modes/{interactive/components → components}/settings-defs.ts +2 -2
- package/src/modes/{interactive/components → components}/settings-selector.ts +2 -2
- package/src/modes/{interactive/components → components}/show-images-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/status-line/segments.ts +2 -2
- package/src/modes/{interactive/components → components}/status-line/separators.ts +1 -1
- package/src/modes/{interactive/components → components}/status-line/types.ts +2 -2
- package/src/modes/{interactive/components → components}/status-line-segment-editor.ts +2 -2
- package/src/modes/{interactive/components → components}/status-line.ts +3 -3
- package/src/modes/{interactive/components → components}/theme-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/thinking-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/todo-display.ts +3 -4
- package/src/modes/{interactive/components → components}/todo-reminder.ts +2 -2
- package/src/modes/{interactive/components → components}/tool-execution.ts +8 -8
- package/src/modes/{interactive/components → components}/tree-selector.ts +3 -3
- package/src/modes/{interactive/components → components}/ttsr-notification.ts +2 -2
- package/src/modes/{interactive/components → components}/user-message-selector.ts +1 -1
- package/src/modes/{interactive/components → components}/user-message.ts +1 -1
- package/src/modes/{interactive/components → components}/welcome.ts +2 -2
- package/src/modes/{interactive/controllers → controllers}/command-controller.ts +381 -30
- package/src/modes/{interactive/controllers → controllers}/event-controller.ts +9 -9
- package/src/modes/{interactive/controllers → controllers}/extension-ui-controller.ts +8 -8
- package/src/modes/{interactive/controllers → controllers}/input-controller.ts +61 -13
- package/src/modes/{interactive/controllers → controllers}/selector-controller.ts +16 -16
- package/src/modes/index.ts +1 -1
- package/src/modes/{interactive/interactive-mode.ts → interactive-mode.ts} +20 -15
- package/src/modes/print-mode.ts +1 -1
- package/src/modes/rpc/rpc-client.ts +3 -3
- package/src/modes/rpc/rpc-mode.ts +3 -3
- package/src/modes/rpc/rpc-types.ts +3 -3
- package/src/modes/{interactive/theme → theme}/theme.ts +1 -1
- package/src/modes/{interactive/types.ts → types.ts} +10 -10
- package/src/modes/{interactive/utils → utils}/ui-helpers.ts +20 -27
- package/src/{core/tools/patch → patch}/applicator.ts +1 -1
- package/src/{core/tools/patch → patch}/diff.ts +1 -1
- package/src/{core/tools/patch → patch}/index.ts +31 -36
- package/src/{core/tools/patch → patch}/shared.ts +9 -6
- package/src/prompts/agents/explore.md +83 -46
- package/src/prompts/agents/init.md +9 -4
- package/src/prompts/agents/plan.md +8 -7
- package/src/prompts/agents/reviewer.md +36 -18
- package/src/prompts/agents/task.md +4 -4
- package/src/prompts/compaction/branch-summary-preamble.md +0 -1
- package/src/prompts/review-request.md +0 -1
- package/src/prompts/system/custom-system-prompt.md +2 -14
- package/src/prompts/system/file-operations.md +0 -2
- package/src/prompts/system/system-prompt.md +182 -171
- package/src/prompts/system/web-search.md +26 -0
- package/src/prompts/tools/ask.md +31 -24
- package/src/prompts/tools/bash.md +20 -17
- package/src/prompts/tools/calculator.md +9 -5
- package/src/prompts/tools/fetch.md +16 -0
- package/src/prompts/tools/find.md +15 -5
- package/src/prompts/tools/gemini-image.md +21 -6
- package/src/prompts/tools/grep.md +28 -12
- package/src/prompts/tools/lsp.md +35 -14
- package/src/prompts/tools/patch.md +39 -41
- package/src/prompts/tools/python.md +59 -77
- package/src/prompts/tools/read.md +23 -22
- package/src/prompts/tools/replace.md +19 -12
- package/src/prompts/tools/ssh.md +21 -28
- package/src/prompts/tools/task.md +54 -44
- package/src/prompts/tools/todo-write.md +52 -163
- package/src/prompts/tools/web-search.md +16 -9
- package/src/prompts/tools/write.md +13 -2
- package/src/{core/sdk.ts → sdk.ts} +65 -34
- package/src/{core → session}/agent-session.ts +157 -41
- package/src/{core → session}/agent-storage.ts +2 -2
- package/src/session/artifacts.ts +110 -0
- package/src/{core → session}/auth-storage.ts +525 -203
- package/src/{core → session}/compaction/branch-summarization.ts +5 -5
- package/src/{core → session}/compaction/compaction.ts +6 -6
- package/src/{core → session}/compaction/utils.ts +3 -3
- package/src/{core → session}/history-storage.ts +1 -1
- package/src/{core → session}/messages.ts +6 -8
- package/src/{core → session}/session-manager.ts +2 -2
- package/src/{core → session}/storage-migration.ts +2 -2
- package/src/session/streaming-output.ts +177 -0
- package/src/{core/ssh → ssh}/connection-manager.ts +1 -1
- package/src/{core/ssh → ssh}/ssh-executor.ts +19 -4
- package/src/{core/ssh → ssh}/sshfs-mount.ts +1 -1
- package/src/{core/system-prompt.ts → system-prompt.ts} +8 -37
- package/src/{core/tools/task → task}/agents.ts +8 -8
- package/src/{core/tools/task → task}/commands.ts +5 -6
- package/src/{core/tools/task → task}/discovery.ts +3 -3
- package/src/{core/tools/task → task}/executor.ts +34 -44
- package/src/{core/tools/task → task}/index.ts +206 -50
- package/src/{core/tools/task → task}/render.ts +80 -23
- package/src/{core/tools/task → task}/subprocess-tool-registry.ts +1 -1
- package/src/task/template.ts +47 -0
- package/src/{core/tools/task → task}/types.ts +19 -27
- package/src/{core/tools/task → task}/worker-protocol.ts +8 -4
- package/src/{core/tools/task → task}/worker.ts +34 -29
- package/src/task/worktree.ts +166 -0
- package/src/{core/tools → tools}/ask.ts +13 -21
- package/src/{core/tools → tools}/bash-interceptor.ts +1 -1
- package/src/{core/tools → tools}/bash.ts +61 -63
- package/src/{core/tools → tools}/calculator.ts +4 -4
- package/src/{core/tools → tools}/complete.ts +1 -1
- package/src/{core/tools → tools}/context.ts +2 -2
- package/src/{core/tools/web-fetch.ts → tools/fetch.ts} +97 -76
- package/src/{core/tools → tools}/find.ts +96 -107
- package/src/{core/tools → tools}/gemini-image.ts +420 -29
- package/src/{core/tools → tools}/grep.ts +155 -164
- package/src/{core/tools → tools}/index.ts +63 -56
- package/src/tools/list-limit.ts +40 -0
- package/src/{core/tools → tools}/ls.ts +44 -35
- package/src/{core/tools → tools}/notebook.ts +3 -3
- package/src/tools/output-meta.ts +443 -0
- package/src/tools/output-utils.ts +63 -0
- package/src/{core/tools → tools}/python.ts +106 -89
- package/src/tools/read.ts +882 -0
- package/src/{core/tools → tools}/render-utils.ts +1 -1
- package/src/{core/tools → tools}/renderers.ts +8 -10
- package/src/{core/tools → tools}/review.ts +2 -2
- package/src/{core/tools → tools}/ssh.ts +56 -59
- package/src/{core/tools → tools}/todo-write.ts +12 -23
- package/src/tools/tool-errors.ts +95 -0
- package/src/tools/tool-result.ts +92 -0
- package/src/{core/tools → tools}/truncate.ts +2 -2
- package/src/{core/tools → tools}/write.ts +15 -13
- package/src/utils/changelog.ts +1 -1
- package/src/{core → utils}/file-mentions.ts +4 -4
- package/src/utils/image-convert.ts +1 -1
- package/src/utils/image-resize.ts +1 -1
- package/src/utils/shell.ts +1 -1
- package/src/{core → utils}/title-generator.ts +4 -4
- package/src/utils/tools-manager.ts +1 -1
- package/src/{core/tools/web-scrapers → web/scrapers}/choosealicense.ts +1 -1
- package/src/{core/tools/web-scrapers → web/scrapers}/twitter.ts +3 -2
- package/src/{core/tools/web-scrapers → web/scrapers}/types.ts +4 -2
- package/src/{core/tools/web-scrapers → web/scrapers}/utils.ts +1 -1
- package/src/{core/tools/web-scrapers → web/scrapers}/youtube.ts +14 -13
- package/src/{core/tools/web-search → web/search}/auth.ts +4 -4
- package/src/{core/tools/web-search → web/search}/index.ts +22 -71
- package/src/{core/tools/web-search → web/search}/providers/anthropic.ts +7 -10
- package/src/{core/tools/web-search → web/search}/providers/exa.ts +2 -2
- package/src/{core/tools/web-search → web/search}/providers/perplexity.ts +4 -16
- package/src/{core/tools/web-search → web/search}/render.ts +3 -3
- package/scripts/migrate-sessions.sh +0 -93
- package/src/core/index.ts +0 -56
- package/src/core/python-prelude.ts +0 -3
- package/src/core/ssh-executor.ts +0 -5
- package/src/core/streaming-output.ts +0 -115
- package/src/core/tools/output.ts +0 -519
- package/src/core/tools/read.ts +0 -717
- package/src/core/tools/task/template.ts +0 -37
- package/src/prompts/tools/output.md +0 -47
- package/src/prompts/tools/web-fetch.md +0 -9
- /package/src/{core/tools/exa → exa}/types.ts +0 -0
- /package/src/{core → exec}/exec.ts +0 -0
- /package/src/{core/export-html → export/html}/template.css +0 -0
- /package/src/{core/export-html → export/html}/template.generated.ts +0 -0
- /package/src/{core/export-html → export/html}/template.html +0 -0
- /package/src/{core/export-html → export/html}/template.js +0 -0
- /package/src/{core/export-html → export/html}/template.macro.ts +0 -0
- /package/src/{core/export-html → export/html}/vendor/highlight.min.js +0 -0
- /package/src/{core/export-html → export/html}/vendor/marked.min.js +0 -0
- /package/src/{core → extensibility}/custom-commands/index.ts +0 -0
- /package/src/{core → extensibility}/custom-tools/index.ts +0 -0
- /package/src/{core → extensibility}/extensions/index.ts +0 -0
- /package/src/{core → extensibility}/hooks/tool-wrapper.ts +0 -0
- /package/src/{core → extensibility}/plugins/index.ts +0 -0
- /package/src/{core → extensibility}/plugins/loader.ts +0 -0
- /package/src/{core → extensibility}/plugins/manager.ts +0 -0
- /package/src/{core → extensibility}/plugins/parser.ts +0 -0
- /package/src/{core → extensibility}/plugins/types.ts +0 -0
- /package/src/{core/python-modules.ts → ipy/modules.ts} +0 -0
- /package/src/{core/tools/lsp → lsp}/defaults.json +0 -0
- /package/src/{core/tools/lsp → lsp}/edits.ts +0 -0
- /package/src/{core/tools/lsp → lsp}/lspmux.ts +0 -0
- /package/src/{core/tools/lsp → lsp}/rust-analyzer.ts +0 -0
- /package/src/{core/mcp → mcp}/client.ts +0 -0
- /package/src/{core/mcp → mcp}/index.ts +0 -0
- /package/src/{core/mcp → mcp}/json-rpc.ts +0 -0
- /package/src/{core/mcp → mcp}/transports/index.ts +0 -0
- /package/src/modes/{interactive/components → components}/countdown-timer.ts +0 -0
- /package/src/modes/{interactive/components → components}/custom-editor.ts +0 -0
- /package/src/modes/{interactive/components → components}/extensions/index.ts +0 -0
- /package/src/modes/{interactive/components → components}/index.ts +0 -0
- /package/src/modes/{interactive/components → components}/status-line/index.ts +0 -0
- /package/src/modes/{interactive/components → components}/status-line/presets.ts +0 -0
- /package/src/modes/{interactive/components → components}/visual-truncate.ts +0 -0
- /package/src/modes/{interactive/theme → theme}/dark.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/alabaster.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/amethyst.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/anthracite.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/basalt.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/birch.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-abyss.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-arctic.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-aurora.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-catppuccin.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-cavern.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-copper.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-cosmos.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-cyberpunk.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-dracula.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-eclipse.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-ember.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-equinox.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-forest.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-github.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-gruvbox.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-lavender.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-lunar.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-midnight.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-monochrome.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-monokai.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-nebula.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-nord.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-ocean.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-one.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-rainforest.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-reef.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-retro.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-rose-pine.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-sakura.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-slate.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-solarized.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-solstice.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-starfall.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-sunset.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-swamp.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-synthwave.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-taiga.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-terminal.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-tokyo-night.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-tundra.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-twilight.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/dark-volcanic.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/graphite.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/index.ts +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-arctic.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-aurora-day.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-canyon.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-catppuccin.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-cirrus.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-coral.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-cyberpunk.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-dawn.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-dunes.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-eucalyptus.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-forest.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-frost.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-github.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-glacier.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-gruvbox.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-haze.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-honeycomb.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-lagoon.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-lavender.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-meadow.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-mint.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-monochrome.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-ocean.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-one.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-opal.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-orchard.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-paper.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-prism.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-retro.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-sand.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-savanna.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-solarized.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-soleil.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-sunset.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-synthwave.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-tokyo-night.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-wetland.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/light-zenith.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/limestone.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/mahogany.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/marble.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/obsidian.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/onyx.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/pearl.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/porcelain.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/quartz.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/sandstone.json +0 -0
- /package/src/modes/{interactive/theme → theme}/defaults/titanium.json +0 -0
- /package/src/modes/{interactive/theme → theme}/light.json +0 -0
- /package/src/modes/{interactive/theme → theme}/theme-schema.json +0 -0
- /package/src/{core/tools/patch → patch}/fuzzy.ts +0 -0
- /package/src/{core/tools/patch → patch}/normalize.ts +0 -0
- /package/src/{core/tools/patch → patch}/normative.ts +0 -0
- /package/src/{core/tools/patch → patch}/parser.ts +0 -0
- /package/src/{core/tools/patch → patch}/types.ts +0 -0
- /package/src/{core → session}/compaction/index.ts +0 -0
- /package/src/{core → session}/session-storage.ts +0 -0
- /package/src/{core/tools/task → task}/name-generator.ts +0 -0
- /package/src/{core/tools/task → task}/omp-command.ts +0 -0
- /package/src/{core/tools/task → task}/parallel.ts +0 -0
- /package/src/{core/tools → tools}/jtd-to-json-schema.ts +0 -0
- /package/src/{core/tools → tools}/path-utils.ts +0 -0
- /package/src/{core → utils}/event-bus.ts +0 -0
- /package/src/{core → utils}/frontmatter.ts +0 -0
- /package/src/{core → utils}/terminal-notify.ts +0 -0
- /package/src/{core → utils}/timings.ts +0 -0
- /package/src/{core → utils}/utils.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/artifacthub.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/arxiv.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/aur.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/biorxiv.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/bluesky.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/brew.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/cheatsh.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/chocolatey.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/cisa-kev.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/clojars.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/coingecko.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/crates-io.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/crossref.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/devto.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/discogs.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/discourse.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/dockerhub.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/fdroid.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/firefox-addons.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/flathub.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/github-gist.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/github.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/gitlab.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/go-pkg.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/hackage.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/hackernews.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/hex.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/huggingface.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/iacr.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/index.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/jetbrains-marketplace.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/lemmy.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/lobsters.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/mastodon.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/maven.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/mdn.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/metacpan.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/musicbrainz.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/npm.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/nuget.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/nvd.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/ollama.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/open-vsx.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/opencorporates.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/openlibrary.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/orcid.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/osv.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/packagist.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/pub-dev.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/pubmed.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/pypi.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/rawg.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/readthedocs.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/reddit.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/repology.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/rfc.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/rubygems.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/searchcode.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/sec-edgar.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/semantic-scholar.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/snapcraft.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/sourcegraph.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/spdx.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/spotify.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/stackoverflow.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/terraform.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/tldr.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/vimeo.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/vscode-marketplace.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/w3c.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/wikidata.ts +0 -0
- /package/src/{core/tools/web-scrapers → web/scrapers}/wikipedia.ts +0 -0
- /package/src/{core/tools/web-search → web/search}/types.ts +0 -0
|
@@ -15,26 +15,34 @@
|
|
|
15
15
|
|
|
16
16
|
import { existsSync, readFileSync } from "node:fs";
|
|
17
17
|
import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
AssistantMessage,
|
|
20
|
+
ImageContent,
|
|
21
|
+
Message,
|
|
22
|
+
Model,
|
|
23
|
+
TextContent,
|
|
24
|
+
ToolCall,
|
|
25
|
+
Usage,
|
|
26
|
+
UsageReport,
|
|
27
|
+
} from "@oh-my-pi/pi-ai";
|
|
19
28
|
import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@oh-my-pi/pi-ai";
|
|
20
29
|
import { abortableSleep, logger } from "@oh-my-pi/pi-utils";
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
30
|
+
import { YAML } from "bun";
|
|
31
|
+
import type { Rule } from "$c/capability/rule";
|
|
32
|
+
import { getAgentDbPath } from "$c/config";
|
|
33
|
+
import type { ModelRegistry } from "$c/config/model-registry";
|
|
34
|
+
import { parseModelString } from "$c/config/model-resolver";
|
|
26
35
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from "
|
|
36
|
-
import type { LoadedCustomCommand } from "
|
|
37
|
-
import { exportSessionToHtml } from "./export-html/index";
|
|
36
|
+
expandPromptTemplate,
|
|
37
|
+
type PromptTemplate,
|
|
38
|
+
parseCommandArgs,
|
|
39
|
+
renderPromptTemplate,
|
|
40
|
+
} from "$c/config/prompt-templates";
|
|
41
|
+
import type { SettingsManager, SkillsSettings } from "$c/config/settings-manager";
|
|
42
|
+
import { type BashResult, executeBash as executeBashCommand } from "$c/exec/bash-executor";
|
|
43
|
+
import { exportSessionToHtml } from "$c/export/html/index";
|
|
44
|
+
import type { TtsrManager } from "$c/export/ttsr";
|
|
45
|
+
import type { LoadedCustomCommand } from "$c/extensibility/custom-commands/index";
|
|
38
46
|
import type {
|
|
39
47
|
ExtensionCommandContext,
|
|
40
48
|
ExtensionRunner,
|
|
@@ -46,25 +54,43 @@ import type {
|
|
|
46
54
|
TreePreparation,
|
|
47
55
|
TurnEndEvent,
|
|
48
56
|
TurnStartEvent,
|
|
49
|
-
} from "
|
|
50
|
-
import type { CompactOptions, ContextUsage } from "
|
|
51
|
-
import {
|
|
52
|
-
import type {
|
|
53
|
-
import
|
|
54
|
-
import type
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import
|
|
57
|
+
} from "$c/extensibility/extensions";
|
|
58
|
+
import type { CompactOptions, ContextUsage } from "$c/extensibility/extensions/types";
|
|
59
|
+
import type { HookCommandContext } from "$c/extensibility/hooks/types";
|
|
60
|
+
import type { Skill, SkillWarning } from "$c/extensibility/skills";
|
|
61
|
+
import { expandSlashCommand, type FileSlashCommand } from "$c/extensibility/slash-commands";
|
|
62
|
+
import { executePython as executePythonCommand, type PythonResult } from "$c/ipy/executor";
|
|
63
|
+
import { theme } from "$c/modes/theme/theme";
|
|
64
|
+
import { normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "$c/patch";
|
|
65
|
+
import ttsrInterruptTemplate from "$c/prompts/system/ttsr-interrupt.md" with { type: "text" };
|
|
66
|
+
import { closeAllConnections } from "$c/ssh/connection-manager";
|
|
67
|
+
import { unmountAll } from "$c/ssh/sshfs-mount";
|
|
68
|
+
import { outputMeta } from "$c/tools/output-meta";
|
|
69
|
+
import { resolveToCwd } from "$c/tools/path-utils";
|
|
70
|
+
import type { TodoItem } from "$c/tools/todo-write";
|
|
71
|
+
import { extractFileMentions, generateFileMentionMessages } from "$c/utils/file-mentions";
|
|
72
|
+
import {
|
|
73
|
+
type CompactionResult,
|
|
74
|
+
calculateContextTokens,
|
|
75
|
+
collectEntriesForBranchSummary,
|
|
76
|
+
compact,
|
|
77
|
+
estimateTokens,
|
|
78
|
+
generateBranchSummary,
|
|
79
|
+
prepareCompaction,
|
|
80
|
+
shouldCompact,
|
|
81
|
+
} from "./compaction/index";
|
|
82
|
+
import {
|
|
83
|
+
type BashExecutionMessage,
|
|
84
|
+
type BranchSummaryMessage,
|
|
85
|
+
bashExecutionToText,
|
|
86
|
+
type CompactionSummaryMessage,
|
|
87
|
+
type CustomMessage,
|
|
88
|
+
type FileMentionMessage,
|
|
89
|
+
type HookMessage,
|
|
90
|
+
type PythonExecutionMessage,
|
|
91
|
+
pythonExecutionToText,
|
|
92
|
+
} from "./messages";
|
|
58
93
|
import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, SessionManager } from "./session-manager";
|
|
59
|
-
import type { SettingsManager, SkillsSettings } from "./settings-manager";
|
|
60
|
-
import type { Skill, SkillWarning } from "./skills";
|
|
61
|
-
import { expandSlashCommand, type FileSlashCommand } from "./slash-commands";
|
|
62
|
-
import { closeAllConnections } from "./ssh/connection-manager";
|
|
63
|
-
import { unmountAll } from "./ssh/sshfs-mount";
|
|
64
|
-
import { normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "./tools/patch";
|
|
65
|
-
import { resolveToCwd } from "./tools/path-utils";
|
|
66
|
-
import type { TodoItem } from "./tools/todo-write";
|
|
67
|
-
import type { TtsrManager } from "./ttsr";
|
|
68
94
|
|
|
69
95
|
/** Session-specific events that extend the core AgentEvent */
|
|
70
96
|
export type AgentSessionEvent =
|
|
@@ -567,7 +593,7 @@ export class AgentSession {
|
|
|
567
593
|
|
|
568
594
|
const args = toolCall.arguments;
|
|
569
595
|
if (!args || typeof args !== "object" || Array.isArray(args)) return;
|
|
570
|
-
if ("
|
|
596
|
+
if ("old_text" in args || "new_text" in args) return;
|
|
571
597
|
|
|
572
598
|
const path = typeof args.path === "string" ? args.path : undefined;
|
|
573
599
|
if (!path) return;
|
|
@@ -612,7 +638,7 @@ export class AgentSession {
|
|
|
612
638
|
|
|
613
639
|
const args = toolCall.arguments;
|
|
614
640
|
if (!args || typeof args !== "object" || Array.isArray(args)) return;
|
|
615
|
-
if ("
|
|
641
|
+
if ("old_text" in args || "new_text" in args) return;
|
|
616
642
|
|
|
617
643
|
const path = typeof args.path === "string" ? args.path : undefined;
|
|
618
644
|
const diff = typeof args.diff === "string" ? args.diff : undefined;
|
|
@@ -2577,6 +2603,7 @@ export class AgentSession {
|
|
|
2577
2603
|
* Used by executeBash and by extensions that handle bash execution themselves.
|
|
2578
2604
|
*/
|
|
2579
2605
|
recordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void {
|
|
2606
|
+
const meta = outputMeta().truncationFromSummary(result, { direction: "tail" }).get();
|
|
2580
2607
|
const bashMessage: BashExecutionMessage = {
|
|
2581
2608
|
role: "bashExecution",
|
|
2582
2609
|
command,
|
|
@@ -2584,7 +2611,7 @@ export class AgentSession {
|
|
|
2584
2611
|
exitCode: result.exitCode,
|
|
2585
2612
|
cancelled: result.cancelled,
|
|
2586
2613
|
truncated: result.truncated,
|
|
2587
|
-
|
|
2614
|
+
meta,
|
|
2588
2615
|
timestamp: Date.now(),
|
|
2589
2616
|
excludeFromContext: options?.excludeFromContext,
|
|
2590
2617
|
};
|
|
@@ -2681,6 +2708,7 @@ export class AgentSession {
|
|
|
2681
2708
|
* Record a Python execution result in session history.
|
|
2682
2709
|
*/
|
|
2683
2710
|
recordPythonResult(code: string, result: PythonResult, options?: { excludeFromContext?: boolean }): void {
|
|
2711
|
+
const meta = outputMeta().truncationFromSummary(result, { direction: "tail" }).get();
|
|
2684
2712
|
const pythonMessage: PythonExecutionMessage = {
|
|
2685
2713
|
role: "pythonExecution",
|
|
2686
2714
|
code,
|
|
@@ -2688,7 +2716,7 @@ export class AgentSession {
|
|
|
2688
2716
|
exitCode: result.exitCode,
|
|
2689
2717
|
cancelled: result.cancelled,
|
|
2690
2718
|
truncated: result.truncated,
|
|
2691
|
-
|
|
2719
|
+
meta,
|
|
2692
2720
|
timestamp: Date.now(),
|
|
2693
2721
|
excludeFromContext: options?.excludeFromContext,
|
|
2694
2722
|
};
|
|
@@ -3161,6 +3189,14 @@ export class AgentSession {
|
|
|
3161
3189
|
};
|
|
3162
3190
|
}
|
|
3163
3191
|
|
|
3192
|
+
async fetchUsageReports(): Promise<UsageReport[] | null> {
|
|
3193
|
+
const authStorage = this._modelRegistry.authStorage;
|
|
3194
|
+
if (!authStorage.fetchUsageReports) return null;
|
|
3195
|
+
return authStorage.fetchUsageReports({
|
|
3196
|
+
baseUrlResolver: (provider) => this._modelRegistry.getProviderBaseUrl?.(provider),
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3164
3200
|
/**
|
|
3165
3201
|
* Estimate context tokens from messages, using the last assistant usage when available.
|
|
3166
3202
|
*/
|
|
@@ -3265,6 +3301,36 @@ export class AgentSession {
|
|
|
3265
3301
|
formatSessionAsText(): string {
|
|
3266
3302
|
const lines: string[] = [];
|
|
3267
3303
|
|
|
3304
|
+
// Include system prompt at the beginning
|
|
3305
|
+
const systemPrompt = this.agent.state.systemPrompt;
|
|
3306
|
+
if (systemPrompt) {
|
|
3307
|
+
lines.push("## System Prompt\n");
|
|
3308
|
+
lines.push(systemPrompt);
|
|
3309
|
+
lines.push("\n");
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
// Include model and thinking level
|
|
3313
|
+
const model = this.agent.state.model;
|
|
3314
|
+
const thinkingLevel = this.agent.state.thinkingLevel;
|
|
3315
|
+
lines.push("## Configuration\n");
|
|
3316
|
+
lines.push(`Model: ${model.provider}/${model.id}`);
|
|
3317
|
+
lines.push(`Thinking Level: ${thinkingLevel}`);
|
|
3318
|
+
lines.push("\n");
|
|
3319
|
+
|
|
3320
|
+
// Include available tools
|
|
3321
|
+
const tools = this.agent.state.tools;
|
|
3322
|
+
if (tools.length > 0) {
|
|
3323
|
+
lines.push("## Available Tools\n");
|
|
3324
|
+
for (const tool of tools) {
|
|
3325
|
+
lines.push(`### ${tool.name}\n`);
|
|
3326
|
+
lines.push(tool.description);
|
|
3327
|
+
lines.push("\n```yaml");
|
|
3328
|
+
lines.push(YAML.stringify(tool.parameters, null, 2));
|
|
3329
|
+
lines.push("```\n");
|
|
3330
|
+
}
|
|
3331
|
+
lines.push("\n");
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3268
3334
|
for (const msg of this.messages) {
|
|
3269
3335
|
if (msg.role === "user") {
|
|
3270
3336
|
lines.push("## User\n");
|
|
@@ -3293,8 +3359,8 @@ export class AgentSession {
|
|
|
3293
3359
|
lines.push("</thinking>\n");
|
|
3294
3360
|
} else if (c.type === "toolCall") {
|
|
3295
3361
|
lines.push(`### Tool: ${c.name}`);
|
|
3296
|
-
lines.push("```
|
|
3297
|
-
lines.push(
|
|
3362
|
+
lines.push("```yaml");
|
|
3363
|
+
lines.push(YAML.stringify(c.arguments, null, 2));
|
|
3298
3364
|
lines.push("```\n");
|
|
3299
3365
|
}
|
|
3300
3366
|
}
|
|
@@ -3314,6 +3380,56 @@ export class AgentSession {
|
|
|
3314
3380
|
}
|
|
3315
3381
|
}
|
|
3316
3382
|
lines.push("");
|
|
3383
|
+
} else if (msg.role === "bashExecution") {
|
|
3384
|
+
const bashMsg = msg as BashExecutionMessage;
|
|
3385
|
+
if (!bashMsg.excludeFromContext) {
|
|
3386
|
+
lines.push("## Bash Execution\n");
|
|
3387
|
+
lines.push(bashExecutionToText(bashMsg));
|
|
3388
|
+
lines.push("\n");
|
|
3389
|
+
}
|
|
3390
|
+
} else if (msg.role === "pythonExecution") {
|
|
3391
|
+
const pythonMsg = msg as PythonExecutionMessage;
|
|
3392
|
+
if (!pythonMsg.excludeFromContext) {
|
|
3393
|
+
lines.push("## Python Execution\n");
|
|
3394
|
+
lines.push(pythonExecutionToText(pythonMsg));
|
|
3395
|
+
lines.push("\n");
|
|
3396
|
+
}
|
|
3397
|
+
} else if (msg.role === "custom" || msg.role === "hookMessage") {
|
|
3398
|
+
const customMsg = msg as CustomMessage | HookMessage;
|
|
3399
|
+
lines.push(`## ${customMsg.customType}\n`);
|
|
3400
|
+
if (typeof customMsg.content === "string") {
|
|
3401
|
+
lines.push(customMsg.content);
|
|
3402
|
+
} else {
|
|
3403
|
+
for (const c of customMsg.content) {
|
|
3404
|
+
if (c.type === "text") {
|
|
3405
|
+
lines.push(c.text);
|
|
3406
|
+
} else if (c.type === "image") {
|
|
3407
|
+
lines.push("[Image]");
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
lines.push("\n");
|
|
3412
|
+
} else if (msg.role === "branchSummary") {
|
|
3413
|
+
const branchMsg = msg as BranchSummaryMessage;
|
|
3414
|
+
lines.push("## Branch Summary\n");
|
|
3415
|
+
lines.push(`(from branch: ${branchMsg.fromId})\n`);
|
|
3416
|
+
lines.push(branchMsg.summary);
|
|
3417
|
+
lines.push("\n");
|
|
3418
|
+
} else if (msg.role === "compactionSummary") {
|
|
3419
|
+
const compactMsg = msg as CompactionSummaryMessage;
|
|
3420
|
+
lines.push("## Compaction Summary\n");
|
|
3421
|
+
lines.push(`(${compactMsg.tokensBefore} tokens before compaction)\n`);
|
|
3422
|
+
lines.push(compactMsg.summary);
|
|
3423
|
+
lines.push("\n");
|
|
3424
|
+
} else if (msg.role === "fileMention") {
|
|
3425
|
+
const fileMsg = msg as FileMentionMessage;
|
|
3426
|
+
lines.push("## File Mention\n");
|
|
3427
|
+
for (const file of fileMsg.files) {
|
|
3428
|
+
lines.push(`<file path="${file.path}">`);
|
|
3429
|
+
lines.push(file.content);
|
|
3430
|
+
lines.push("</file>\n");
|
|
3431
|
+
}
|
|
3432
|
+
lines.push("\n");
|
|
3317
3433
|
}
|
|
3318
3434
|
}
|
|
3319
3435
|
|
|
@@ -2,9 +2,9 @@ import { Database } from "bun:sqlite";
|
|
|
2
2
|
import { chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { logger } from "@oh-my-pi/pi-utils";
|
|
5
|
-
import { getAgentDbPath } from "
|
|
5
|
+
import { getAgentDbPath } from "$c/config";
|
|
6
|
+
import type { Settings } from "$c/config/settings-manager";
|
|
6
7
|
import type { AuthCredential } from "./auth-storage";
|
|
7
|
-
import type { Settings } from "./settings-manager";
|
|
8
8
|
|
|
9
9
|
/** Prepared SQLite statement type from bun:sqlite */
|
|
10
10
|
type Statement = ReturnType<Database["prepare"]>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped artifact storage for truncated tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Artifacts are stored in a directory alongside the session file,
|
|
5
|
+
* accessible via artifact:// URLs or the $ARTIFACTS environment variable.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { mkdir, readdir } from "node:fs/promises";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Manages artifact storage for a session.
|
|
13
|
+
*
|
|
14
|
+
* Artifacts are stored with sequential IDs in the session's artifact directory.
|
|
15
|
+
* The directory is created lazily on first write.
|
|
16
|
+
*/
|
|
17
|
+
export class ArtifactManager {
|
|
18
|
+
#nextId = 0;
|
|
19
|
+
readonly #dir: string;
|
|
20
|
+
#dirCreated = false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param sessionFile Path to the session .jsonl file
|
|
24
|
+
*/
|
|
25
|
+
constructor(sessionFile: string) {
|
|
26
|
+
// Artifact directory is session file path without .jsonl extension
|
|
27
|
+
this.#dir = sessionFile.slice(0, -6);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Artifact directory path.
|
|
32
|
+
* Directory may not exist until first artifact is saved.
|
|
33
|
+
*/
|
|
34
|
+
get dir(): string {
|
|
35
|
+
return this.#dir;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async #ensureDir(): Promise<void> {
|
|
39
|
+
if (!this.#dirCreated) {
|
|
40
|
+
await mkdir(this.#dir, { recursive: true });
|
|
41
|
+
this.#dirCreated = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Atomically allocate next artifact ID.
|
|
47
|
+
* IDs are sequential within the session.
|
|
48
|
+
*/
|
|
49
|
+
allocateId(): number {
|
|
50
|
+
return this.#nextId++;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Allocate a new artifact path and ID without writing content.
|
|
55
|
+
*
|
|
56
|
+
* @param toolType Tool name for file extension (e.g., "bash", "fetch")
|
|
57
|
+
*/
|
|
58
|
+
async allocatePath(toolType: string): Promise<{ id: string; path: string }> {
|
|
59
|
+
await this.#ensureDir();
|
|
60
|
+
const id = String(this.allocateId());
|
|
61
|
+
const filename = `${id}.${toolType}.txt`;
|
|
62
|
+
return { id, path: join(this.#dir, filename) };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Save content as an artifact and return the artifact ID.
|
|
67
|
+
*
|
|
68
|
+
* @param content Full content to save
|
|
69
|
+
* @param toolType Tool name for file extension (e.g., "bash", "fetch")
|
|
70
|
+
* @returns Artifact ID (numeric string)
|
|
71
|
+
*/
|
|
72
|
+
async save(content: string, toolType: string): Promise<string> {
|
|
73
|
+
const { id, path } = await this.allocatePath(toolType);
|
|
74
|
+
await Bun.write(path, content);
|
|
75
|
+
return id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if an artifact exists.
|
|
80
|
+
* @param id Artifact ID (numeric string)
|
|
81
|
+
*/
|
|
82
|
+
async exists(id: string): Promise<boolean> {
|
|
83
|
+
const files = await this.listFiles();
|
|
84
|
+
return files.some((f) => f.startsWith(`${id}.`));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* List all artifact files in the directory.
|
|
89
|
+
* Returns empty array if directory doesn't exist.
|
|
90
|
+
*/
|
|
91
|
+
async listFiles(): Promise<string[]> {
|
|
92
|
+
try {
|
|
93
|
+
return await readdir(this.#dir);
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get the full path to an artifact file.
|
|
101
|
+
* Returns null if artifact doesn't exist.
|
|
102
|
+
*
|
|
103
|
+
* @param id Artifact ID (numeric string)
|
|
104
|
+
*/
|
|
105
|
+
async getPath(id: string): Promise<string | null> {
|
|
106
|
+
const files = await this.listFiles();
|
|
107
|
+
const match = files.find((f) => f.startsWith(`${id}.`));
|
|
108
|
+
return match ? join(this.#dir, match) : null;
|
|
109
|
+
}
|
|
110
|
+
}
|