@psnext/slingcli 2.4.20260507-3 → 2.4.20260509-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/sling.js +39 -16
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/agent-loop.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/agent.js +4 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +526 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +243 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +616 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +348 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.js +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/factory.js +9 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +102 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +194 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.js +92 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.js +42 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.js +31 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +196 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.js +170 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.js +90 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +258 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +30 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +16 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +97 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js +26 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/proxy.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/package.json +7 -5
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/cli.js +6 -6
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +307 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.js +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +22 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.js +14 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/index.js +4 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/models.generated.js +427 -122
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +129 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +34 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-codex-responses.js +1 -1
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-completions.js +150 -122
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-responses-shared.js +14 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/openai-codex.js +25 -14
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/overflow.js +3 -0
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/package.json +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/bun/register-bedrock.js +4 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/args.js +1 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/config-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/list-models.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/session-picker.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/config.js +52 -30
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/auth-storage.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/branch-summarization.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/compaction.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js +153 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.css +45 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.js +68 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/loader.js +26 -12
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/keybindings.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/model-registry.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/model-resolver.js +2 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/package-manager.js +22 -5
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/provider-display-names.js +1 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/sdk.js +3 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/bash.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/edit.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/find.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/grep.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/ls.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/read.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/render-utils.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +205 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/write.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/main.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/migrations.js +3 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/config-selector.js +25 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/custom-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/earendil-announcement.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-input.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/footer.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +4 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/model-selector.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/session-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +4 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/user-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/interactive-mode.js +47 -32
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/dark.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/light.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/theme.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/package-manager-cli.js +42 -39
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard.js +9 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/paths.js +16 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/version-check.js +9 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/package.json +9 -8
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/image.js +14 -7
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/markdown.js +24 -84
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/terminal-image.js +10 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/tui.js +73 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/utils.js +33 -7
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/package.json +3 -3
- package/node_modules/@mariozechner/clipboard/README.md +58 -0
- package/node_modules/@mariozechner/clipboard/index.d.ts +23 -0
- package/node_modules/@mariozechner/clipboard-linux-x64-gnu/README.md +3 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/http2.d.ts +4 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/stream/web.d.ts +4 -0
- package/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/fast-xml-builder/CHANGELOG.md +4 -0
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +91 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -1
- package/node_modules/fast-xml-builder/package.json +3 -2
- package/node_modules/fast-xml-builder/src/fxb.d.ts +92 -3
- package/node_modules/fast-xml-builder/src/fxb.js +92 -31
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +87 -33
- package/node_modules/get-east-asian-width/lookup-data.js +15 -12
- package/node_modules/get-east-asian-width/lookup.js +25 -22
- package/node_modules/get-east-asian-width/package.json +1 -1
- package/node_modules/jiti/README.md +258 -0
- package/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/jiti/package.json +146 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +5 -3
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/protobuf.js +5 -3
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +1 -1
- package/node_modules/protobufjs/src/namespace.js +3 -1
- package/node_modules/semver/README.md +19 -4
- package/node_modules/semver/bin/semver.js +14 -10
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/index.js +2 -0
- package/node_modules/semver/internal/re.js +1 -1
- package/node_modules/semver/package.json +3 -3
- package/node_modules/semver/range.bnf +5 -4
- package/node_modules/socks/package.json +2 -2
- package/node_modules/xml-naming/README.md +189 -0
- package/node_modules/xml-naming/package.json +54 -0
- package/node_modules/xml-naming/src/index.d.ts +74 -0
- package/node_modules/xml-naming/src/index.js +270 -0
- package/package.json +6 -6
- package/sling-default-packages.json +2 -1
- package/slingshot/index.js +442 -23
- package/node_modules/@mariozechner/jiti/dist/babel.cjs +0 -246
- package/node_modules/@mariozechner/jiti/dist/jiti.cjs +0 -1
- package/node_modules/@mariozechner/jiti/package.json +0 -96
- package/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/cli.js +0 -116
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/env-api-keys.js +0 -166
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/index.js +0 -15
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/models.generated.js +0 -16568
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/amazon-bedrock.js +0 -753
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-codex-responses.js +0 -909
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses-shared.js +0 -479
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/utils/oauth/openai-codex.js +0 -374
- package/node_modules/@mariozechner/pi-ai/dist/api-registry.js +0 -44
- package/node_modules/@mariozechner/pi-ai/dist/bedrock-provider.js +0 -6
- package/node_modules/@mariozechner/pi-ai/dist/models.js +0 -71
- package/node_modules/@mariozechner/pi-ai/dist/oauth.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +0 -951
- package/node_modules/@mariozechner/pi-ai/dist/providers/azure-openai-responses.js +0 -208
- package/node_modules/@mariozechner/pi-ai/dist/providers/cloudflare.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/providers/faux.js +0 -368
- package/node_modules/@mariozechner/pi-ai/dist/providers/github-copilot-headers.js +0 -29
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-shared.js +0 -329
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +0 -442
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +0 -400
- package/node_modules/@mariozechner/pi-ai/dist/providers/mistral.js +0 -535
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +0 -908
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses.js +0 -220
- package/node_modules/@mariozechner/pi-ai/dist/providers/register-builtins.js +0 -243
- package/node_modules/@mariozechner/pi-ai/dist/providers/simple-options.js +0 -39
- package/node_modules/@mariozechner/pi-ai/dist/providers/transform-messages.js +0 -184
- package/node_modules/@mariozechner/pi-ai/dist/stream.js +0 -27
- package/node_modules/@mariozechner/pi-ai/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/event-stream.js +0 -81
- package/node_modules/@mariozechner/pi-ai/dist/utils/hash.js +0 -14
- package/node_modules/@mariozechner/pi-ai/dist/utils/headers.js +0 -8
- package/node_modules/@mariozechner/pi-ai/dist/utils/json-parse.js +0 -113
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +0 -335
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/github-copilot.js +0 -292
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/index.js +0 -121
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/oauth-page.js +0 -105
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/pkce.js +0 -31
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/overflow.js +0 -146
- package/node_modules/@mariozechner/pi-ai/dist/utils/sanitize-unicode.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/utils/typebox-helpers.js +0 -21
- package/node_modules/@mariozechner/pi-ai/dist/utils/validation.js +0 -281
- package/node_modules/@mariozechner/pi-ai/package.json +0 -108
- package/node_modules/@mariozechner/pi-coding-agent/dist/bun/register-bedrock.js +0 -4
- package/node_modules/@mariozechner/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +0 -22
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent-loop.js +0 -458
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent.js +0 -398
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/proxy.js +0 -278
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/package.json +0 -45
- package/node_modules/socks/.claude/settings.local.json +0 -26
- package/node_modules/std-env/LICENCE +0 -22
- package/node_modules/std-env/README.md +0 -118
- package/node_modules/std-env/dist/index.cjs +0 -1
- package/node_modules/std-env/dist/index.d.cts +0 -92
- package/node_modules/std-env/dist/index.d.mts +0 -92
- package/node_modules/std-env/dist/index.d.ts +0 -92
- package/node_modules/std-env/dist/index.mjs +0 -1
- package/node_modules/std-env/package.json +0 -46
- package/node_modules/yoctocolors/base.d.ts +0 -47
- package/node_modules/yoctocolors/base.js +0 -94
- package/node_modules/yoctocolors/index.d.ts +0 -2
- package/node_modules/yoctocolors/index.js +0 -2
- package/node_modules/yoctocolors/license +0 -9
- package/node_modules/yoctocolors/package.json +0 -69
- package/node_modules/yoctocolors/readme.md +0 -138
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core → @earendil-works/pi-agent-core/dist/harness}/compaction/utils.js +0 -0
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core/tools → @earendil-works/pi-agent-core/dist/harness/utils}/truncate.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/api-registry.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/bedrock-provider.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/models.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/oauth.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/amazon-bedrock.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/azure-openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/cloudflare.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/faux.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/github-copilot-headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-shared.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-vertex.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/mistral.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/register-builtins.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/simple-options.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/transform-messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/session-resources.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/utils/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/event-stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/hash.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/json-parse.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/github-copilot.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/index.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/oauth-page.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/pkce.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/sanitize-unicode.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/typebox-helpers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/validation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/restore-sandbox-env.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/file-processor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/initial-message.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-runtime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-services.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/auth-guidance.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/bash-executor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/defaults.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/event-bus.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/exec.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/ansi-to-html.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.html +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/tool-renderer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/highlight.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/marked.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/runner.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/footer-data-provider.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/output-guard.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/prompt-templates.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resolve-config-value.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resource-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-cwd.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/settings-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/skills.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/slash-commands.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/source-info.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/system-prompt.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/telemetry.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/timings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/edit-diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/file-mutation-queue.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/output-accumulator.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/path-utils.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/tool-definition-wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/assets/clankolas.png +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/armin.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/print-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/jsonl.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-client.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/changelog.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/child-process.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-image.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-native.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/exif-orientation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/frontmatter.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/fs-watch.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/git.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-convert.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-resize.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/mime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/photon.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/pi-user-agent.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/shell.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/sleep.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/tools-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/autocomplete.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/box.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/cancellable-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/editor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/input.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/select-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/settings-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/spacer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/truncated-text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/editor-component.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/fuzzy.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keybindings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keys.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/kill-ring.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/stdin-buffer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/terminal.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/undo-stack.js +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/LICENSE +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-cli.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-hooks.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-native.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.d.mts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti/lib/jiti.mjs → jiti/lib/jiti-static.mjs} +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.cjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.cts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.mts +0 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { constants } from "node:fs";
|
|
4
|
+
import { access, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
7
|
+
import { FileError } from "../types.js";
|
|
8
|
+
function resolvePath(cwd, path) {
|
|
9
|
+
return isAbsolute(path) ? path : resolve(cwd, path);
|
|
10
|
+
}
|
|
11
|
+
function fileKindFromStats(stats) {
|
|
12
|
+
if (stats.isFile())
|
|
13
|
+
return "file";
|
|
14
|
+
if (stats.isDirectory())
|
|
15
|
+
return "directory";
|
|
16
|
+
if (stats.isSymbolicLink())
|
|
17
|
+
return "symlink";
|
|
18
|
+
throw new FileError("invalid", "Unsupported file type");
|
|
19
|
+
}
|
|
20
|
+
function fileInfoFromStats(path, stats) {
|
|
21
|
+
return {
|
|
22
|
+
name: path.replace(/\/+$/, "").split("/").pop() ?? path,
|
|
23
|
+
path,
|
|
24
|
+
kind: fileKindFromStats(stats),
|
|
25
|
+
size: stats.size,
|
|
26
|
+
mtimeMs: stats.mtimeMs,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function isNodeError(error) {
|
|
30
|
+
return error instanceof Error && "code" in error;
|
|
31
|
+
}
|
|
32
|
+
function toFileError(error, path) {
|
|
33
|
+
if (error instanceof FileError)
|
|
34
|
+
return error;
|
|
35
|
+
if (isNodeError(error)) {
|
|
36
|
+
const message = error.message;
|
|
37
|
+
switch (error.code) {
|
|
38
|
+
case "ENOENT":
|
|
39
|
+
return new FileError("not_found", message, path, { cause: error });
|
|
40
|
+
case "EACCES":
|
|
41
|
+
case "EPERM":
|
|
42
|
+
return new FileError("permission_denied", message, path, { cause: error });
|
|
43
|
+
case "ENOTDIR":
|
|
44
|
+
return new FileError("not_directory", message, path, { cause: error });
|
|
45
|
+
case "EISDIR":
|
|
46
|
+
return new FileError("is_directory", message, path, { cause: error });
|
|
47
|
+
case "EINVAL":
|
|
48
|
+
return new FileError("invalid", message, path, { cause: error });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return new FileError("unknown", error instanceof Error ? error.message : String(error), path, { cause: error });
|
|
52
|
+
}
|
|
53
|
+
async function pathExists(path) {
|
|
54
|
+
try {
|
|
55
|
+
await access(path, constants.F_OK);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function runCommand(command, args, timeoutMs) {
|
|
63
|
+
return await new Promise((resolve) => {
|
|
64
|
+
let stdout = "";
|
|
65
|
+
const child = spawn(command, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
66
|
+
const timeout = setTimeout(() => {
|
|
67
|
+
if (child.pid)
|
|
68
|
+
killProcessTree(child.pid);
|
|
69
|
+
}, timeoutMs);
|
|
70
|
+
child.stdout?.setEncoding("utf8");
|
|
71
|
+
child.stdout?.on("data", (chunk) => {
|
|
72
|
+
stdout += chunk;
|
|
73
|
+
});
|
|
74
|
+
child.on("error", () => {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
resolve({ stdout: "", status: null });
|
|
77
|
+
});
|
|
78
|
+
child.on("close", (status) => {
|
|
79
|
+
clearTimeout(timeout);
|
|
80
|
+
resolve({ stdout, status });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async function findBashOnPath() {
|
|
85
|
+
const result = process.platform === "win32"
|
|
86
|
+
? await runCommand("where", ["bash.exe"], 5000)
|
|
87
|
+
: await runCommand("which", ["bash"], 5000);
|
|
88
|
+
if (result.status !== 0 || !result.stdout)
|
|
89
|
+
return null;
|
|
90
|
+
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
91
|
+
return firstMatch && (await pathExists(firstMatch)) ? firstMatch : null;
|
|
92
|
+
}
|
|
93
|
+
async function getShellConfig(customShellPath) {
|
|
94
|
+
if (customShellPath) {
|
|
95
|
+
if (await pathExists(customShellPath)) {
|
|
96
|
+
return { shell: customShellPath, args: ["-c"] };
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Custom shell path not found: ${customShellPath}`);
|
|
99
|
+
}
|
|
100
|
+
if (process.platform === "win32") {
|
|
101
|
+
const candidates = [];
|
|
102
|
+
const programFiles = process.env.ProgramFiles;
|
|
103
|
+
if (programFiles)
|
|
104
|
+
candidates.push(`${programFiles}\\Git\\bin\\bash.exe`);
|
|
105
|
+
const programFilesX86 = process.env["ProgramFiles(x86)"];
|
|
106
|
+
if (programFilesX86)
|
|
107
|
+
candidates.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
|
|
108
|
+
for (const candidate of candidates) {
|
|
109
|
+
if (await pathExists(candidate)) {
|
|
110
|
+
return { shell: candidate, args: ["-c"] };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const bashOnPath = await findBashOnPath();
|
|
114
|
+
if (bashOnPath) {
|
|
115
|
+
return { shell: bashOnPath, args: ["-c"] };
|
|
116
|
+
}
|
|
117
|
+
throw new Error("No bash shell found");
|
|
118
|
+
}
|
|
119
|
+
if (await pathExists("/bin/bash")) {
|
|
120
|
+
return { shell: "/bin/bash", args: ["-c"] };
|
|
121
|
+
}
|
|
122
|
+
const bashOnPath = await findBashOnPath();
|
|
123
|
+
if (bashOnPath) {
|
|
124
|
+
return { shell: bashOnPath, args: ["-c"] };
|
|
125
|
+
}
|
|
126
|
+
return { shell: "sh", args: ["-c"] };
|
|
127
|
+
}
|
|
128
|
+
function getShellEnv(baseEnv, extraEnv) {
|
|
129
|
+
return {
|
|
130
|
+
...process.env,
|
|
131
|
+
...baseEnv,
|
|
132
|
+
...extraEnv,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function killProcessTree(pid) {
|
|
136
|
+
if (process.platform === "win32") {
|
|
137
|
+
try {
|
|
138
|
+
spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
|
|
139
|
+
stdio: "ignore",
|
|
140
|
+
detached: true,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// Ignore errors.
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
process.kill(-pid, "SIGKILL");
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
try {
|
|
153
|
+
process.kill(pid, "SIGKILL");
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Process already dead.
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export class NodeExecutionEnv {
|
|
161
|
+
cwd;
|
|
162
|
+
shellPath;
|
|
163
|
+
shellEnv;
|
|
164
|
+
constructor(options) {
|
|
165
|
+
this.cwd = options.cwd;
|
|
166
|
+
this.shellPath = options.shellPath;
|
|
167
|
+
this.shellEnv = options.shellEnv;
|
|
168
|
+
}
|
|
169
|
+
async exec(command, options) {
|
|
170
|
+
const cwd = options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd;
|
|
171
|
+
const { shell, args } = await getShellConfig(this.shellPath);
|
|
172
|
+
return await new Promise((resolvePromise, reject) => {
|
|
173
|
+
let stdout = "";
|
|
174
|
+
let stderr = "";
|
|
175
|
+
let settled = false;
|
|
176
|
+
let timedOut = false;
|
|
177
|
+
const child = spawn(shell, [...args, command], {
|
|
178
|
+
cwd,
|
|
179
|
+
detached: process.platform !== "win32",
|
|
180
|
+
env: getShellEnv(this.shellEnv, options?.env),
|
|
181
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
182
|
+
});
|
|
183
|
+
const timeoutId = typeof options?.timeout === "number"
|
|
184
|
+
? setTimeout(() => {
|
|
185
|
+
timedOut = true;
|
|
186
|
+
if (child.pid) {
|
|
187
|
+
killProcessTree(child.pid);
|
|
188
|
+
}
|
|
189
|
+
}, options.timeout * 1000)
|
|
190
|
+
: undefined;
|
|
191
|
+
const onAbort = () => {
|
|
192
|
+
if (child.pid) {
|
|
193
|
+
killProcessTree(child.pid);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
if (options?.signal) {
|
|
197
|
+
if (options.signal.aborted) {
|
|
198
|
+
onAbort();
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
child.stdout?.setEncoding("utf8");
|
|
205
|
+
child.stderr?.setEncoding("utf8");
|
|
206
|
+
child.stdout?.on("data", (chunk) => {
|
|
207
|
+
stdout += chunk;
|
|
208
|
+
options?.onStdout?.(chunk);
|
|
209
|
+
});
|
|
210
|
+
child.stderr?.on("data", (chunk) => {
|
|
211
|
+
stderr += chunk;
|
|
212
|
+
options?.onStderr?.(chunk);
|
|
213
|
+
});
|
|
214
|
+
child.on("error", (error) => {
|
|
215
|
+
if (timeoutId)
|
|
216
|
+
clearTimeout(timeoutId);
|
|
217
|
+
if (options?.signal)
|
|
218
|
+
options.signal.removeEventListener("abort", onAbort);
|
|
219
|
+
if (settled)
|
|
220
|
+
return;
|
|
221
|
+
settled = true;
|
|
222
|
+
reject(error);
|
|
223
|
+
});
|
|
224
|
+
child.on("close", (code) => {
|
|
225
|
+
if (timeoutId)
|
|
226
|
+
clearTimeout(timeoutId);
|
|
227
|
+
if (options?.signal)
|
|
228
|
+
options.signal.removeEventListener("abort", onAbort);
|
|
229
|
+
if (settled)
|
|
230
|
+
return;
|
|
231
|
+
settled = true;
|
|
232
|
+
if (options?.signal?.aborted) {
|
|
233
|
+
reject(new Error("aborted"));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (timedOut) {
|
|
237
|
+
reject(new Error(`timeout:${options?.timeout}`));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
resolvePromise({ stdout, stderr, exitCode: code ?? 0 });
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
async readTextFile(path) {
|
|
245
|
+
const resolved = resolvePath(this.cwd, path);
|
|
246
|
+
try {
|
|
247
|
+
return await readFile(resolved, "utf8");
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
throw toFileError(error, resolved);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async readBinaryFile(path) {
|
|
254
|
+
const resolved = resolvePath(this.cwd, path);
|
|
255
|
+
try {
|
|
256
|
+
return await readFile(resolved);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
throw toFileError(error, resolved);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async writeFile(path, content) {
|
|
263
|
+
const resolved = resolvePath(this.cwd, path);
|
|
264
|
+
try {
|
|
265
|
+
await mkdir(resolve(resolved, ".."), { recursive: true });
|
|
266
|
+
await writeFile(resolved, content);
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
throw toFileError(error, resolved);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async fileInfo(path) {
|
|
273
|
+
const resolved = resolvePath(this.cwd, path);
|
|
274
|
+
try {
|
|
275
|
+
return fileInfoFromStats(resolved, await lstat(resolved));
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
throw toFileError(error, resolved);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async listDir(path) {
|
|
282
|
+
const resolved = resolvePath(this.cwd, path);
|
|
283
|
+
try {
|
|
284
|
+
const entries = await readdir(resolved, { withFileTypes: true });
|
|
285
|
+
const infos = [];
|
|
286
|
+
for (const entry of entries) {
|
|
287
|
+
const entryPath = resolve(resolved, entry.name);
|
|
288
|
+
try {
|
|
289
|
+
infos.push(fileInfoFromStats(entryPath, await lstat(entryPath)));
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (error instanceof FileError && error.code === "invalid")
|
|
293
|
+
continue;
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return infos;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
throw toFileError(error, resolved);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async realPath(path) {
|
|
304
|
+
const resolved = resolvePath(this.cwd, path);
|
|
305
|
+
try {
|
|
306
|
+
return await realpath(resolved);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
throw toFileError(error, resolved);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async exists(path) {
|
|
313
|
+
try {
|
|
314
|
+
await this.fileInfo(path);
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error instanceof FileError && error.code === "not_found")
|
|
319
|
+
return false;
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
async createDir(path, options) {
|
|
324
|
+
await mkdir(resolvePath(this.cwd, path), { recursive: options?.recursive });
|
|
325
|
+
}
|
|
326
|
+
async remove(path, options) {
|
|
327
|
+
const resolved = resolvePath(this.cwd, path);
|
|
328
|
+
try {
|
|
329
|
+
await rm(resolved, { recursive: options?.recursive ?? false, force: options?.force ?? false });
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
throw toFileError(error, resolved);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async createTempDir(prefix = "tmp-") {
|
|
336
|
+
return await mkdtemp(join(tmpdir(), prefix));
|
|
337
|
+
}
|
|
338
|
+
async createTempFile(options) {
|
|
339
|
+
const dir = await this.createTempDir("tmp-");
|
|
340
|
+
const filePath = join(dir, `${options?.prefix ?? ""}${randomUUID()}${options?.suffix ?? ""}`);
|
|
341
|
+
await writeFile(filePath, "");
|
|
342
|
+
return filePath;
|
|
343
|
+
}
|
|
344
|
+
async cleanup() {
|
|
345
|
+
// nothing to clean up for the local node implementation
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=nodejs.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AgentHarness } from "./agent-harness.js";
|
|
2
|
+
import { Session } from "./session/session.js";
|
|
3
|
+
export function createSession(storage) {
|
|
4
|
+
return new Session(storage);
|
|
5
|
+
}
|
|
6
|
+
export function createAgentHarness(options) {
|
|
7
|
+
return new AgentHarness(options);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:
|
|
2
|
+
|
|
3
|
+
<summary>
|
|
4
|
+
`;
|
|
5
|
+
export const COMPACTION_SUMMARY_SUFFIX = `
|
|
6
|
+
</summary>`;
|
|
7
|
+
export const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:
|
|
8
|
+
|
|
9
|
+
<summary>
|
|
10
|
+
`;
|
|
11
|
+
export const BRANCH_SUMMARY_SUFFIX = `</summary>`;
|
|
12
|
+
export function bashExecutionToText(msg) {
|
|
13
|
+
let text = `Ran \`${msg.command}\`\n`;
|
|
14
|
+
if (msg.output) {
|
|
15
|
+
text += `\`\`\`\n${msg.output}\n\`\`\``;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
text += "(no output)";
|
|
19
|
+
}
|
|
20
|
+
if (msg.cancelled) {
|
|
21
|
+
text += "\n\n(command cancelled)";
|
|
22
|
+
}
|
|
23
|
+
else if (msg.exitCode !== null && msg.exitCode !== undefined && msg.exitCode !== 0) {
|
|
24
|
+
text += `\n\nCommand exited with code ${msg.exitCode}`;
|
|
25
|
+
}
|
|
26
|
+
if (msg.truncated && msg.fullOutputPath) {
|
|
27
|
+
text += `\n\n[Output truncated. Full output: ${msg.fullOutputPath}]`;
|
|
28
|
+
}
|
|
29
|
+
return text;
|
|
30
|
+
}
|
|
31
|
+
export function createBranchSummaryMessage(summary, fromId, timestamp) {
|
|
32
|
+
return {
|
|
33
|
+
role: "branchSummary",
|
|
34
|
+
summary,
|
|
35
|
+
fromId,
|
|
36
|
+
timestamp: new Date(timestamp).getTime(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function createCompactionSummaryMessage(summary, tokensBefore, timestamp) {
|
|
40
|
+
return {
|
|
41
|
+
role: "compactionSummary",
|
|
42
|
+
summary,
|
|
43
|
+
tokensBefore,
|
|
44
|
+
timestamp: new Date(timestamp).getTime(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function createCustomMessage(customType, content, display, details, timestamp) {
|
|
48
|
+
return {
|
|
49
|
+
role: "custom",
|
|
50
|
+
customType,
|
|
51
|
+
content,
|
|
52
|
+
display,
|
|
53
|
+
details,
|
|
54
|
+
timestamp: new Date(timestamp).getTime(),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function convertToLlm(messages) {
|
|
58
|
+
return messages
|
|
59
|
+
.map((m) => {
|
|
60
|
+
switch (m.role) {
|
|
61
|
+
case "bashExecution":
|
|
62
|
+
if (m.excludeFromContext) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
role: "user",
|
|
67
|
+
content: [{ type: "text", text: bashExecutionToText(m) }],
|
|
68
|
+
timestamp: m.timestamp,
|
|
69
|
+
};
|
|
70
|
+
case "custom": {
|
|
71
|
+
const content = typeof m.content === "string" ? [{ type: "text", text: m.content }] : m.content;
|
|
72
|
+
return {
|
|
73
|
+
role: "user",
|
|
74
|
+
content,
|
|
75
|
+
timestamp: m.timestamp,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
case "branchSummary":
|
|
79
|
+
return {
|
|
80
|
+
role: "user",
|
|
81
|
+
content: [{ type: "text", text: BRANCH_SUMMARY_PREFIX + m.summary + BRANCH_SUMMARY_SUFFIX }],
|
|
82
|
+
timestamp: m.timestamp,
|
|
83
|
+
};
|
|
84
|
+
case "compactionSummary":
|
|
85
|
+
return {
|
|
86
|
+
role: "user",
|
|
87
|
+
content: [
|
|
88
|
+
{ type: "text", text: COMPACTION_SUMMARY_PREFIX + m.summary + COMPACTION_SUMMARY_SUFFIX },
|
|
89
|
+
],
|
|
90
|
+
timestamp: m.timestamp,
|
|
91
|
+
};
|
|
92
|
+
case "user":
|
|
93
|
+
case "assistant":
|
|
94
|
+
case "toolResult":
|
|
95
|
+
return m;
|
|
96
|
+
default:
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.filter((m) => m !== undefined);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { parse } from "yaml";
|
|
2
|
+
/**
|
|
3
|
+
* Load prompt templates from one or more paths.
|
|
4
|
+
*
|
|
5
|
+
* Directory inputs load direct `.md` children non-recursively. File inputs load explicit `.md` files. Missing paths and
|
|
6
|
+
* non-markdown files are skipped. Read and parse failures are returned as diagnostics.
|
|
7
|
+
*/
|
|
8
|
+
export async function loadPromptTemplates(env, paths) {
|
|
9
|
+
const promptTemplates = [];
|
|
10
|
+
const diagnostics = [];
|
|
11
|
+
for (const path of Array.isArray(paths) ? paths : [paths]) {
|
|
12
|
+
const info = await safeFileInfo(env, path);
|
|
13
|
+
if (!info)
|
|
14
|
+
continue;
|
|
15
|
+
const kind = await resolveKind(env, info);
|
|
16
|
+
if (kind === "directory") {
|
|
17
|
+
const result = await loadTemplatesFromDir(env, info.path);
|
|
18
|
+
promptTemplates.push(...result.promptTemplates);
|
|
19
|
+
diagnostics.push(...result.diagnostics);
|
|
20
|
+
}
|
|
21
|
+
else if (kind === "file" && info.name.endsWith(".md")) {
|
|
22
|
+
const result = await loadTemplateFromFile(env, info.path);
|
|
23
|
+
if (result.promptTemplate)
|
|
24
|
+
promptTemplates.push(result.promptTemplate);
|
|
25
|
+
diagnostics.push(...result.diagnostics);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { promptTemplates, diagnostics };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load prompt templates from source-tagged paths.
|
|
32
|
+
*
|
|
33
|
+
* Source values are preserved exactly and attached to every loaded prompt template and diagnostic. The agent package does
|
|
34
|
+
* not interpret source values; applications define their own provenance shape.
|
|
35
|
+
*/
|
|
36
|
+
export async function loadSourcedPromptTemplates(env, inputs) {
|
|
37
|
+
const promptTemplates = [];
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
for (const input of inputs) {
|
|
40
|
+
const result = await loadPromptTemplates(env, input.path);
|
|
41
|
+
for (const promptTemplate of result.promptTemplates)
|
|
42
|
+
promptTemplates.push({ promptTemplate, source: input.source });
|
|
43
|
+
for (const diagnostic of result.diagnostics)
|
|
44
|
+
diagnostics.push({ ...diagnostic, source: input.source });
|
|
45
|
+
}
|
|
46
|
+
return { promptTemplates, diagnostics };
|
|
47
|
+
}
|
|
48
|
+
async function loadTemplatesFromDir(env, dir) {
|
|
49
|
+
const promptTemplates = [];
|
|
50
|
+
const diagnostics = [];
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = await env.listDir(dir);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
diagnostics.push({
|
|
57
|
+
type: "warning",
|
|
58
|
+
message: errorMessage(error, "failed to list prompt template directory"),
|
|
59
|
+
path: dir,
|
|
60
|
+
});
|
|
61
|
+
return { promptTemplates, diagnostics };
|
|
62
|
+
}
|
|
63
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
64
|
+
const kind = await resolveKind(env, entry);
|
|
65
|
+
if (kind !== "file" || !entry.name.endsWith(".md"))
|
|
66
|
+
continue;
|
|
67
|
+
const result = await loadTemplateFromFile(env, entry.path);
|
|
68
|
+
if (result.promptTemplate)
|
|
69
|
+
promptTemplates.push(result.promptTemplate);
|
|
70
|
+
diagnostics.push(...result.diagnostics);
|
|
71
|
+
}
|
|
72
|
+
return { promptTemplates, diagnostics };
|
|
73
|
+
}
|
|
74
|
+
async function loadTemplateFromFile(env, filePath) {
|
|
75
|
+
const diagnostics = [];
|
|
76
|
+
try {
|
|
77
|
+
const rawContent = await env.readTextFile(filePath);
|
|
78
|
+
const { frontmatter, body } = parseFrontmatter(rawContent);
|
|
79
|
+
const firstLine = body.split("\n").find((line) => line.trim());
|
|
80
|
+
let description = typeof frontmatter.description === "string" ? frontmatter.description : "";
|
|
81
|
+
if (!description && firstLine) {
|
|
82
|
+
description = firstLine.slice(0, 60);
|
|
83
|
+
if (firstLine.length > 60)
|
|
84
|
+
description += "...";
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
promptTemplate: {
|
|
88
|
+
name: basenameEnvPath(filePath).replace(/\.md$/i, ""),
|
|
89
|
+
description,
|
|
90
|
+
content: body,
|
|
91
|
+
},
|
|
92
|
+
diagnostics,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
type: "warning",
|
|
98
|
+
message: errorMessage(error, "failed to load prompt template"),
|
|
99
|
+
path: filePath,
|
|
100
|
+
});
|
|
101
|
+
return { promptTemplate: null, diagnostics };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function safeFileInfo(env, path) {
|
|
105
|
+
try {
|
|
106
|
+
return await env.fileInfo(path);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function resolveKind(env, info) {
|
|
113
|
+
if (info.kind === "file" || info.kind === "directory")
|
|
114
|
+
return info.kind;
|
|
115
|
+
try {
|
|
116
|
+
const realPath = await env.realPath(info.path);
|
|
117
|
+
const target = await env.fileInfo(realPath);
|
|
118
|
+
return target.kind === "file" || target.kind === "directory" ? target.kind : undefined;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function parseFrontmatter(content) {
|
|
125
|
+
const normalized = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
126
|
+
if (!normalized.startsWith("---"))
|
|
127
|
+
return { frontmatter: {}, body: normalized };
|
|
128
|
+
const endIndex = normalized.indexOf("\n---", 3);
|
|
129
|
+
if (endIndex === -1)
|
|
130
|
+
return { frontmatter: {}, body: normalized };
|
|
131
|
+
const yamlString = normalized.slice(4, endIndex);
|
|
132
|
+
const body = normalized.slice(endIndex + 4).trim();
|
|
133
|
+
return { frontmatter: (parse(yamlString) ?? {}), body };
|
|
134
|
+
}
|
|
135
|
+
function basenameEnvPath(path) {
|
|
136
|
+
const normalized = path.replace(/\/+$/, "");
|
|
137
|
+
const slashIndex = normalized.lastIndexOf("/");
|
|
138
|
+
return slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);
|
|
139
|
+
}
|
|
140
|
+
function errorMessage(error, fallback) {
|
|
141
|
+
return error instanceof Error ? error.message : fallback;
|
|
142
|
+
}
|
|
143
|
+
/** Parse slash-command arguments using simple shell-style single and double quotes. */
|
|
144
|
+
export function parseCommandArgs(argsString) {
|
|
145
|
+
const args = [];
|
|
146
|
+
let current = "";
|
|
147
|
+
let inQuote = null;
|
|
148
|
+
for (let i = 0; i < argsString.length; i++) {
|
|
149
|
+
const char = argsString[i];
|
|
150
|
+
if (inQuote) {
|
|
151
|
+
if (char === inQuote)
|
|
152
|
+
inQuote = null;
|
|
153
|
+
else
|
|
154
|
+
current += char;
|
|
155
|
+
}
|
|
156
|
+
else if (char === '"' || char === "'") {
|
|
157
|
+
inQuote = char;
|
|
158
|
+
}
|
|
159
|
+
else if (char === " " || char === "\t") {
|
|
160
|
+
if (current) {
|
|
161
|
+
args.push(current);
|
|
162
|
+
current = "";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
current += char;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (current)
|
|
170
|
+
args.push(current);
|
|
171
|
+
return args;
|
|
172
|
+
}
|
|
173
|
+
/** Substitute prompt template placeholders (`$1`, `$@`, `$ARGUMENTS`, `${@:N}`, `${@:N:L}`) with command arguments. */
|
|
174
|
+
export function substituteArgs(content, args) {
|
|
175
|
+
let result = content;
|
|
176
|
+
result = result.replace(/\$(\d+)/g, (_, num) => args[parseInt(num, 10) - 1] ?? "");
|
|
177
|
+
result = result.replace(/\$\{@:(\d+)(?::(\d+))?\}/g, (_, startStr, lengthStr) => {
|
|
178
|
+
let start = parseInt(startStr, 10) - 1;
|
|
179
|
+
if (start < 0)
|
|
180
|
+
start = 0;
|
|
181
|
+
if (lengthStr)
|
|
182
|
+
return args.slice(start, start + parseInt(lengthStr, 10)).join(" ");
|
|
183
|
+
return args.slice(start).join(" ");
|
|
184
|
+
});
|
|
185
|
+
const allArgs = args.join(" ");
|
|
186
|
+
result = result.replace(/\$ARGUMENTS/g, allArgs);
|
|
187
|
+
result = result.replace(/\$@/g, allArgs);
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
/** Expand a prompt template with positional command arguments. */
|
|
191
|
+
export function expandPromptTemplate(template, args = []) {
|
|
192
|
+
return substituteArgs(template.content, args);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=prompt-templates.js.map
|