@ashx-j/lunr 0.2.11 → 0.2.13
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 +13 -0
- package/README.md +211 -236
- package/dist/builtin-extensions/ashxj-tui.d.ts +3 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +28 -11
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +0 -2
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-cron.js +1 -1
- package/dist/builtin-extensions/lunr-cron.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts +0 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js +1 -23
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +6 -7
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +7 -14
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +12 -9
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +38 -34
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +3 -3
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +32 -47
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +7 -10
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +90 -109
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +3 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +37 -50
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +4 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js +5 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +31 -13
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +4 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +48 -20
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +90 -64
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +6 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +262 -161
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +24 -33
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +25 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +51 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js +20 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +5 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +9 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +20 -17
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +70 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +153 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +13 -8
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.js +20 -51
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +80 -20
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js +10 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +20 -32
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +23 -449
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +13 -11
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js +18 -17
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts +2 -2
- package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js +41 -17
- package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/amazon-bedrock.json +1 -1
- package/dist/catalog/providers/azure-openai-responses.json +1 -1
- package/dist/catalog/providers/cloudflare-ai-gateway.json +1 -1
- package/dist/catalog/providers/cloudflare-workers-ai.json +1 -1
- package/dist/catalog/providers/fireworks.json +1 -1
- package/dist/catalog/providers/github-copilot.json +1 -1
- package/dist/catalog/providers/huggingface.json +1 -1
- package/dist/catalog/providers/minimax-cn.json +1 -1
- package/dist/catalog/providers/minimax.json +1 -1
- package/dist/catalog/providers/mistral.json +1 -1
- package/dist/catalog/providers/nvidia.json +1 -1
- package/dist/catalog/providers/openai.json +1 -1
- package/dist/catalog/providers/opencode-go.json +1 -1
- package/dist/catalog/providers/opencode.json +1 -1
- package/dist/catalog/providers/openrouter.json +1 -1
- package/dist/catalog/providers/qwen-cloud-cn.json +1 -1
- package/dist/catalog/providers/qwen-cloud.json +1 -1
- package/dist/catalog/providers/qwen-token-plan-cn.json +1 -1
- package/dist/catalog/providers/qwen-token-plan.json +1 -1
- package/dist/catalog/providers/together.json +1 -1
- package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
- package/dist/catalog/providers/zai-coding-cn.json +1 -1
- package/dist/catalog/providers/zai.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/core/agent-session.d.ts +7 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +34 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/context-breakdown.d.ts +3 -1
- package/dist/core/context-breakdown.d.ts.map +1 -1
- package/dist/core/context-breakdown.js +5 -2
- package/dist/core/context-breakdown.js.map +1 -1
- package/dist/core/customize.d.ts +2 -0
- package/dist/core/customize.d.ts.map +1 -1
- package/dist/core/customize.js +6 -0
- package/dist/core/customize.js.map +1 -1
- package/dist/core/memory-cap.d.ts +4 -8
- package/dist/core/memory-cap.d.ts.map +1 -1
- package/dist/core/memory-cap.js +8 -8
- package/dist/core/memory-cap.js.map +1 -1
- package/dist/core/permissions.d.ts +2 -0
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +30 -14
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +1 -9
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +1 -1
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/settings-manager.d.ts +16 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +37 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/subagent-permission-inherit.d.ts +34 -22
- package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
- package/dist/core/subagent-permission-inherit.js +37 -80
- package/dist/core/subagent-permission-inherit.js.map +1 -1
- package/dist/core/swarm.d.ts.map +1 -1
- package/dist/core/swarm.js +13 -7
- package/dist/core/swarm.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +38 -48
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
- package/dist/core/usage-adapters/openai-codex.js +22 -17
- package/dist/core/usage-adapters/openai-codex.js.map +1 -1
- package/dist/core/usage-service.d.ts +10 -1
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +17 -6
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +1 -4
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +1 -4
- package/dist/gateway/cron.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +0 -5
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +2 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +21 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +122 -162
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-view.js +7 -4
- package/dist/modes/interactive/components/usage-view.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +55 -96
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/skill-tag-autocomplete.d.ts +13 -0
- package/dist/modes/interactive/skill-tag-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/skill-tag-autocomplete.js +72 -0
- package/dist/modes/interactive/skill-tag-autocomplete.js.map +1 -0
- package/docs/compaction.md +23 -23
- package/docs/containerization.md +24 -24
- package/docs/custom-provider.md +18 -18
- package/docs/development.md +16 -15
- package/docs/docs.json +6 -2
- package/docs/extensions.md +82 -80
- package/docs/features.md +102 -0
- package/docs/index.md +25 -19
- package/docs/json.md +7 -7
- package/docs/keybindings.md +4 -4
- package/docs/models.md +2 -2
- package/docs/packages.md +38 -42
- package/docs/prompt-templates.md +4 -4
- package/docs/providers.md +22 -10
- package/docs/quickstart.md +81 -46
- package/docs/rpc.md +7 -13
- package/docs/sdk.md +43 -41
- package/docs/security.md +18 -18
- package/docs/session-format.md +9 -9
- package/docs/sessions.md +13 -12
- package/docs/settings.md +63 -24
- package/docs/shell-aliases.md +2 -2
- package/docs/skills.md +21 -11
- package/docs/terminal-setup.md +5 -5
- package/docs/termux.md +7 -7
- package/docs/themes.md +12 -14
- package/docs/tmux.md +4 -4
- package/docs/tui.md +23 -23
- package/docs/usage.md +112 -87
- package/docs/windows.md +10 -2
- package/examples/README.md +3 -1
- package/examples/extensions/README.md +6 -6
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/README.md +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/plan-mode/README.md +3 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/README.md +13 -11
- package/examples/extensions/todo.ts +2 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/README.md +9 -5
- package/package.json +6 -7
- package/dist/builtin-extensions/lunr-behavior.d.ts +0 -44
- package/dist/builtin-extensions/lunr-behavior.d.ts.map +0 -1
- package/dist/builtin-extensions/lunr-behavior.js +0 -213
- package/dist/builtin-extensions/lunr-behavior.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/agents/context-builder.md +0 -46
- package/dist/builtin-extensions/pi-subagents/agents/deep-researcher.md +0 -36
- package/dist/builtin-extensions/pi-subagents/agents/delegate.md +0 -12
- package/dist/builtin-extensions/pi-subagents/agents/oracle.md +0 -73
- package/dist/builtin-extensions/pi-subagents/agents/planner.md +0 -55
- package/dist/builtin-extensions/pi-subagents/agents/research-writer.md +0 -37
- package/dist/builtin-extensions/pi-subagents/agents/researcher.md +0 -52
- package/dist/builtin-extensions/pi-subagents/agents/reviewer.md +0 -79
- package/dist/builtin-extensions/pi-subagents/agents/scout.md +0 -50
- package/dist/builtin-extensions/pi-subagents/agents/worker.md +0 -55
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts +0 -20
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +0 -1273
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts +0 -49
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js +0 -252
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts +0 -3
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js +0 -6
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts +0 -3
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js +0 -23
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts +0 -8
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js +0 -143
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts +0 -176
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.js +0 -1326
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts +0 -7
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js +0 -307
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts +0 -8
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.js +0 -30
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts +0 -35
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js +0 -151
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts +0 -131
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts.map +0 -1
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js +0 -491
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js.map +0 -1
- package/dist/core/behavior-preset.d.ts +0 -60
- package/dist/core/behavior-preset.d.ts.map +0 -1
- package/dist/core/behavior-preset.js +0 -257
- package/dist/core/behavior-preset.js.map +0 -1
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* lunR: parent-delegated children inherit an explicit permission level, not a
|
|
3
|
+
* named agent role. The parent process resolves the requested level against
|
|
4
|
+
* its own mode, then snapshots that resolved child permission into the child
|
|
5
|
+
* environment. Full maps to child runtime Auto; read-only maps to Plan.
|
|
6
6
|
*
|
|
7
7
|
* Ordinary `lunr -p`, cron, and gateway headless sessions are not children and
|
|
8
8
|
* stay fail-closed.
|
|
9
9
|
*/
|
|
10
10
|
import { type PermissionMode } from "./permissions.ts";
|
|
11
11
|
export declare const SUBAGENT_CHILD_ENV = "PI_SUBAGENT_CHILD";
|
|
12
|
+
export declare const SUBAGENT_CHILD_PERMISSION_ENV = "PI_SUBAGENT_CHILD_PERMISSION";
|
|
13
|
+
/** @deprecated Replaced by SUBAGENT_CHILD_PERMISSION_ENV. Kept so leftover env is ignored. */
|
|
12
14
|
export declare const SUBAGENT_PARENT_PERMISSION_MODE_ENV = "PI_SUBAGENT_PARENT_PERMISSION_MODE";
|
|
13
|
-
export
|
|
15
|
+
export type ChildPermission = "full" | "read-only";
|
|
16
|
+
export declare const PLAN_MODE_WRITE_SPAWN_ERROR = "Cannot launch a full-access child in plan mode. Relaunch with permissions: \"read-only\".";
|
|
14
17
|
export declare function isSubagentChildProcess(env?: NodeJS.ProcessEnv): boolean;
|
|
15
18
|
export declare function parseParentPermissionMode(value: string | undefined): PermissionMode | undefined;
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
export declare function parseChildPermission(value: string | undefined): ChildPermission | undefined;
|
|
20
|
+
/** Omitted permissions resolve to full. Unknown values are rejected by the schema/executor. */
|
|
21
|
+
export declare function resolveRequestedChildPermission(requested?: string): ChildPermission;
|
|
22
|
+
export declare function resolveChildRuntimePermissionMode(childPermission: string | undefined): PermissionMode;
|
|
18
23
|
export declare function snapshotParentPermissionMode(sessionId?: string): PermissionMode;
|
|
24
|
+
export interface ResolvedChildPermissions {
|
|
25
|
+
ok: true;
|
|
26
|
+
requested: ChildPermission;
|
|
27
|
+
effective: ChildPermission;
|
|
28
|
+
}
|
|
29
|
+
export interface RejectedChildPermissions {
|
|
30
|
+
ok: false;
|
|
31
|
+
requested: ChildPermission;
|
|
32
|
+
error: string;
|
|
33
|
+
}
|
|
19
34
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
35
|
+
* Resolve the child's permission level before spawn.
|
|
36
|
+
*
|
|
37
|
+
* Parent mode Requested Result
|
|
38
|
+
* Manual/YOLO/Auto omitted Full
|
|
39
|
+
* Manual/YOLO/Auto full Full
|
|
40
|
+
* Manual/YOLO/Auto read-only Read-only
|
|
41
|
+
* Plan read-only Read-only
|
|
42
|
+
* Plan full / omitted Reject (omission resolves to full)
|
|
22
43
|
*/
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function agentBasename(name: string): string;
|
|
44
|
+
export declare function resolveChildPermissions(parentMode: string | undefined, requested?: string): ResolvedChildPermissions | RejectedChildPermissions;
|
|
25
45
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* resolved tool list is unrestricted or contains a mutating tool. `bash` alone
|
|
29
|
-
* does not count (inspection agents keep it).
|
|
46
|
+
* Apply the resolved child permission before any tool call. No-op for non-child
|
|
47
|
+
* processes so `lunr -p` stays fail-closed.
|
|
30
48
|
*/
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function planModeWriteSpawnError(parentMode: string | undefined, agents: ReadonlyArray<{
|
|
33
|
-
name: string;
|
|
34
|
-
tools?: string[];
|
|
35
|
-
}>): string | undefined;
|
|
36
|
-
/** Drop mutating tools from a plan child's `--tools` list. Leave `bash`. */
|
|
37
|
-
export declare function filterToolsForInheritedChild(tools: string[] | undefined, parentMode: string | undefined): string[] | undefined;
|
|
49
|
+
export declare function applyInheritedSubagentPermissions(env?: NodeJS.ProcessEnv): PermissionMode | undefined;
|
|
38
50
|
//# sourceMappingURL=subagent-permission-inherit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-permission-inherit.d.ts","sourceRoot":"","sources":["../../src/core/subagent-permission-inherit.ts"],"names":[],"mappings":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AW,wBAAwB;IACxC,EAAE,EAAE,KAAK,CAAC;IACV,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,CAAC,EAAE,MAAM,GAChB,wBAAwB,GAAG,wBAAwB,CAMrD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,cAAc,GAAG,SAAS,CAKlH","sourcesContent":["/**\n * lunR: parent-delegated children inherit an explicit permission level, not a\n * named agent role. The parent process resolves the requested level against\n * its own mode, then snapshots that resolved child permission into the child\n * environment. Full maps to child runtime Auto; read-only maps to Plan.\n *\n * Ordinary `lunr -p`, cron, and gateway headless sessions are not children and\n * stay fail-closed.\n */\n\nimport { getPermissionMode, type PermissionMode, resetPermissions } from \"./permissions.ts\";\n\nexport const SUBAGENT_CHILD_ENV = \"PI_SUBAGENT_CHILD\";\nexport const SUBAGENT_CHILD_PERMISSION_ENV = \"PI_SUBAGENT_CHILD_PERMISSION\";\n/** @deprecated Replaced by SUBAGENT_CHILD_PERMISSION_ENV. Kept so leftover env is ignored. */\nexport const SUBAGENT_PARENT_PERMISSION_MODE_ENV = \"PI_SUBAGENT_PARENT_PERMISSION_MODE\";\n\nexport type ChildPermission = \"full\" | \"read-only\";\n\nexport const PLAN_MODE_WRITE_SPAWN_ERROR =\n\t'Cannot launch a full-access child in plan mode. Relaunch with permissions: \"read-only\".';\n\nexport function isSubagentChildProcess(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env[SUBAGENT_CHILD_ENV] === \"1\";\n}\n\nexport function parseParentPermissionMode(value: string | undefined): PermissionMode | undefined {\n\tif (value === \"manual\" || value === \"yolo\" || value === \"plan\" || value === \"auto\") return value;\n\treturn undefined;\n}\n\nexport function parseChildPermission(value: string | undefined): ChildPermission | undefined {\n\tif (value === \"full\" || value === \"read-only\") return value;\n\treturn undefined;\n}\n\n/** Omitted permissions resolve to full. Unknown values are rejected by the schema/executor. */\nexport function resolveRequestedChildPermission(requested?: string): ChildPermission {\n\treturn requested === \"read-only\" ? \"read-only\" : \"full\";\n}\n\nexport function resolveChildRuntimePermissionMode(childPermission: string | undefined): PermissionMode {\n\treturn parseChildPermission(childPermission) === \"read-only\" ? \"plan\" : \"auto\";\n}\n\nexport function snapshotParentPermissionMode(sessionId?: string): PermissionMode {\n\treturn getPermissionMode(sessionId);\n}\n\nexport interface ResolvedChildPermissions {\n\tok: true;\n\trequested: ChildPermission;\n\teffective: ChildPermission;\n}\n\nexport interface RejectedChildPermissions {\n\tok: false;\n\trequested: ChildPermission;\n\terror: string;\n}\n\n/**\n * Resolve the child's permission level before spawn.\n *\n * Parent mode Requested Result\n * Manual/YOLO/Auto omitted Full\n * Manual/YOLO/Auto full Full\n * Manual/YOLO/Auto read-only Read-only\n * Plan read-only Read-only\n * Plan full / omitted Reject (omission resolves to full)\n */\nexport function resolveChildPermissions(\n\tparentMode: string | undefined,\n\trequested?: string,\n): ResolvedChildPermissions | RejectedChildPermissions {\n\tconst requestedPermission = resolveRequestedChildPermission(requested);\n\tif (parseParentPermissionMode(parentMode) === \"plan\" && requestedPermission === \"full\") {\n\t\treturn { ok: false, requested: requestedPermission, error: PLAN_MODE_WRITE_SPAWN_ERROR };\n\t}\n\treturn { ok: true, requested: requestedPermission, effective: requestedPermission };\n}\n\n/**\n * Apply the resolved child permission before any tool call. No-op for non-child\n * processes so `lunr -p` stays fail-closed.\n */\nexport function applyInheritedSubagentPermissions(env: NodeJS.ProcessEnv = process.env): PermissionMode | undefined {\n\tif (!isSubagentChildProcess(env)) return undefined;\n\tconst childMode = resolveChildRuntimePermissionMode(env[SUBAGENT_CHILD_PERMISSION_ENV]);\n\tresetPermissions(childMode);\n\treturn childMode;\n}\n"]}
|
|
@@ -1,46 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* lunR: parent-delegated children inherit an explicit permission level, not a
|
|
3
|
+
* named agent role. The parent process resolves the requested level against
|
|
4
|
+
* its own mode, then snapshots that resolved child permission into the child
|
|
5
|
+
* environment. Full maps to child runtime Auto; read-only maps to Plan.
|
|
6
6
|
*
|
|
7
7
|
* Ordinary `lunr -p`, cron, and gateway headless sessions are not children and
|
|
8
8
|
* stay fail-closed.
|
|
9
9
|
*/
|
|
10
10
|
import { getPermissionMode, resetPermissions } from "./permissions.js";
|
|
11
11
|
export const SUBAGENT_CHILD_ENV = "PI_SUBAGENT_CHILD";
|
|
12
|
+
export const SUBAGENT_CHILD_PERMISSION_ENV = "PI_SUBAGENT_CHILD_PERMISSION";
|
|
13
|
+
/** @deprecated Replaced by SUBAGENT_CHILD_PERMISSION_ENV. Kept so leftover env is ignored. */
|
|
12
14
|
export const SUBAGENT_PARENT_PERMISSION_MODE_ENV = "PI_SUBAGENT_PARENT_PERMISSION_MODE";
|
|
13
|
-
export const PLAN_MODE_WRITE_SPAWN_ERROR =
|
|
14
|
-
/** Known writer basenames. Packaged names use `package.local`. */
|
|
15
|
-
const WRITE_CAPABLE_AGENT_BASENAMES = new Set(["worker", "delegate", "editor"]);
|
|
16
|
-
/**
|
|
17
|
-
* Known research/review agents. Their roster may still list `write` for
|
|
18
|
-
* scratch files; plan mode keeps those tools blocked instead of failing spawn.
|
|
19
|
-
*/
|
|
20
|
-
const READ_ONLY_AGENT_BASENAMES = new Set([
|
|
21
|
-
"scout",
|
|
22
|
-
"reviewer",
|
|
23
|
-
"researcher",
|
|
24
|
-
"research",
|
|
25
|
-
"status",
|
|
26
|
-
"oracle",
|
|
27
|
-
"planner",
|
|
28
|
-
"context-builder",
|
|
29
|
-
"deep-researcher",
|
|
30
|
-
"research-writer",
|
|
31
|
-
]);
|
|
32
|
-
/** Tools that make an unknown/custom agent write-capable at spawn time. */
|
|
33
|
-
const WRITE_CAPABLE_TOOLS = new Set([
|
|
34
|
-
"edit",
|
|
35
|
-
"write",
|
|
36
|
-
"behavior_add",
|
|
37
|
-
"behavior_remove",
|
|
38
|
-
"memory_add",
|
|
39
|
-
"memory_remove",
|
|
40
|
-
"cron",
|
|
41
|
-
"code_rewrite",
|
|
42
|
-
]);
|
|
43
|
-
const PLAN_STRIP_TOOLS = new Set(WRITE_CAPABLE_TOOLS);
|
|
15
|
+
export const PLAN_MODE_WRITE_SPAWN_ERROR = 'Cannot launch a full-access child in plan mode. Relaunch with permissions: "read-only".';
|
|
44
16
|
export function isSubagentChildProcess(env = process.env) {
|
|
45
17
|
return env[SUBAGENT_CHILD_ENV] === "1";
|
|
46
18
|
}
|
|
@@ -49,62 +21,47 @@ export function parseParentPermissionMode(value) {
|
|
|
49
21
|
return value;
|
|
50
22
|
return undefined;
|
|
51
23
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
export function parseChildPermission(value) {
|
|
25
|
+
if (value === "full" || value === "read-only")
|
|
26
|
+
return value;
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Omitted permissions resolve to full. Unknown values are rejected by the schema/executor. */
|
|
30
|
+
export function resolveRequestedChildPermission(requested) {
|
|
31
|
+
return requested === "read-only" ? "read-only" : "full";
|
|
32
|
+
}
|
|
33
|
+
export function resolveChildRuntimePermissionMode(childPermission) {
|
|
34
|
+
return parseChildPermission(childPermission) === "read-only" ? "plan" : "auto";
|
|
55
35
|
}
|
|
56
36
|
export function snapshotParentPermissionMode(sessionId) {
|
|
57
37
|
return getPermissionMode(sessionId);
|
|
58
38
|
}
|
|
59
39
|
/**
|
|
60
|
-
*
|
|
40
|
+
* Resolve the child's permission level before spawn.
|
|
41
|
+
*
|
|
42
|
+
* Parent mode Requested Result
|
|
43
|
+
* Manual/YOLO/Auto omitted Full
|
|
44
|
+
* Manual/YOLO/Auto full Full
|
|
45
|
+
* Manual/YOLO/Auto read-only Read-only
|
|
46
|
+
* Plan read-only Read-only
|
|
47
|
+
* Plan full / omitted Reject (omission resolves to full)
|
|
48
|
+
*/
|
|
49
|
+
export function resolveChildPermissions(parentMode, requested) {
|
|
50
|
+
const requestedPermission = resolveRequestedChildPermission(requested);
|
|
51
|
+
if (parseParentPermissionMode(parentMode) === "plan" && requestedPermission === "full") {
|
|
52
|
+
return { ok: false, requested: requestedPermission, error: PLAN_MODE_WRITE_SPAWN_ERROR };
|
|
53
|
+
}
|
|
54
|
+
return { ok: true, requested: requestedPermission, effective: requestedPermission };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Apply the resolved child permission before any tool call. No-op for non-child
|
|
61
58
|
* processes so `lunr -p` stays fail-closed.
|
|
62
59
|
*/
|
|
63
60
|
export function applyInheritedSubagentPermissions(env = process.env) {
|
|
64
61
|
if (!isSubagentChildProcess(env))
|
|
65
62
|
return undefined;
|
|
66
|
-
const childMode =
|
|
63
|
+
const childMode = resolveChildRuntimePermissionMode(env[SUBAGENT_CHILD_PERMISSION_ENV]);
|
|
67
64
|
resetPermissions(childMode);
|
|
68
65
|
return childMode;
|
|
69
66
|
}
|
|
70
|
-
export function agentBasename(name) {
|
|
71
|
-
const trimmed = name.trim();
|
|
72
|
-
const dot = trimmed.lastIndexOf(".");
|
|
73
|
-
return (dot >= 0 ? trimmed.slice(dot + 1) : trimmed).toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
function isWriteCapableByName(name) {
|
|
76
|
-
const base = agentBasename(name);
|
|
77
|
-
if (WRITE_CAPABLE_AGENT_BASENAMES.has(base))
|
|
78
|
-
return true;
|
|
79
|
-
return base.endsWith("-editor") || base.endsWith("_editor");
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Writer agents fail spawn in plan mode. Known read-only names are allowed
|
|
83
|
-
* even if their roster lists `write`. Unknown agents are writers when the
|
|
84
|
-
* resolved tool list is unrestricted or contains a mutating tool. `bash` alone
|
|
85
|
-
* does not count (inspection agents keep it).
|
|
86
|
-
*/
|
|
87
|
-
export function isWriteCapableSubagent(agentName, tools) {
|
|
88
|
-
if (isWriteCapableByName(agentName))
|
|
89
|
-
return true;
|
|
90
|
-
if (READ_ONLY_AGENT_BASENAMES.has(agentBasename(agentName)))
|
|
91
|
-
return false;
|
|
92
|
-
if (!tools || tools.length === 0)
|
|
93
|
-
return true;
|
|
94
|
-
return tools.some((tool) => WRITE_CAPABLE_TOOLS.has(tool));
|
|
95
|
-
}
|
|
96
|
-
export function planModeWriteSpawnError(parentMode, agents) {
|
|
97
|
-
if (parseParentPermissionMode(parentMode) !== "plan")
|
|
98
|
-
return undefined;
|
|
99
|
-
if (agents.some((agent) => isWriteCapableSubagent(agent.name, agent.tools))) {
|
|
100
|
-
return PLAN_MODE_WRITE_SPAWN_ERROR;
|
|
101
|
-
}
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
/** Drop mutating tools from a plan child's `--tools` list. Leave `bash`. */
|
|
105
|
-
export function filterToolsForInheritedChild(tools, parentMode) {
|
|
106
|
-
if (!tools || parseParentPermissionMode(parentMode) !== "plan")
|
|
107
|
-
return tools;
|
|
108
|
-
return tools.filter((tool) => !PLAN_STRIP_TOOLS.has(tool));
|
|
109
|
-
}
|
|
110
67
|
//# sourceMappingURL=subagent-permission-inherit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-permission-inherit.js","sourceRoot":"","sources":["../../src/core/subagent-permission-inherit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAuB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE5F,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"subagent-permission-inherit.js","sourceRoot":"","sources":["../../src/core/subagent-permission-inherit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAuB,gBAAgB,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AAuB,CACtC,UAA8B,EAC9B,SAAkB,EACoC;IACtD,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,SAAS,CAAC,CAAC;IACvE,IAAI,yBAAyB,CAAC,UAAU,CAAC,KAAK,MAAM,IAAI,mBAAmB,KAAK,MAAM,EAAE,CAAC;QACxF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC;IAC1F,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;AAAA,CACpF;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG,EAA8B;IACnH,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,SAAS,GAAG,iCAAiC,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACxF,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,SAAS,CAAC;AAAA,CACjB","sourcesContent":["/**\n * lunR: parent-delegated children inherit an explicit permission level, not a\n * named agent role. The parent process resolves the requested level against\n * its own mode, then snapshots that resolved child permission into the child\n * environment. Full maps to child runtime Auto; read-only maps to Plan.\n *\n * Ordinary `lunr -p`, cron, and gateway headless sessions are not children and\n * stay fail-closed.\n */\n\nimport { getPermissionMode, type PermissionMode, resetPermissions } from \"./permissions.ts\";\n\nexport const SUBAGENT_CHILD_ENV = \"PI_SUBAGENT_CHILD\";\nexport const SUBAGENT_CHILD_PERMISSION_ENV = \"PI_SUBAGENT_CHILD_PERMISSION\";\n/** @deprecated Replaced by SUBAGENT_CHILD_PERMISSION_ENV. Kept so leftover env is ignored. */\nexport const SUBAGENT_PARENT_PERMISSION_MODE_ENV = \"PI_SUBAGENT_PARENT_PERMISSION_MODE\";\n\nexport type ChildPermission = \"full\" | \"read-only\";\n\nexport const PLAN_MODE_WRITE_SPAWN_ERROR =\n\t'Cannot launch a full-access child in plan mode. Relaunch with permissions: \"read-only\".';\n\nexport function isSubagentChildProcess(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env[SUBAGENT_CHILD_ENV] === \"1\";\n}\n\nexport function parseParentPermissionMode(value: string | undefined): PermissionMode | undefined {\n\tif (value === \"manual\" || value === \"yolo\" || value === \"plan\" || value === \"auto\") return value;\n\treturn undefined;\n}\n\nexport function parseChildPermission(value: string | undefined): ChildPermission | undefined {\n\tif (value === \"full\" || value === \"read-only\") return value;\n\treturn undefined;\n}\n\n/** Omitted permissions resolve to full. Unknown values are rejected by the schema/executor. */\nexport function resolveRequestedChildPermission(requested?: string): ChildPermission {\n\treturn requested === \"read-only\" ? \"read-only\" : \"full\";\n}\n\nexport function resolveChildRuntimePermissionMode(childPermission: string | undefined): PermissionMode {\n\treturn parseChildPermission(childPermission) === \"read-only\" ? \"plan\" : \"auto\";\n}\n\nexport function snapshotParentPermissionMode(sessionId?: string): PermissionMode {\n\treturn getPermissionMode(sessionId);\n}\n\nexport interface ResolvedChildPermissions {\n\tok: true;\n\trequested: ChildPermission;\n\teffective: ChildPermission;\n}\n\nexport interface RejectedChildPermissions {\n\tok: false;\n\trequested: ChildPermission;\n\terror: string;\n}\n\n/**\n * Resolve the child's permission level before spawn.\n *\n * Parent mode Requested Result\n * Manual/YOLO/Auto omitted Full\n * Manual/YOLO/Auto full Full\n * Manual/YOLO/Auto read-only Read-only\n * Plan read-only Read-only\n * Plan full / omitted Reject (omission resolves to full)\n */\nexport function resolveChildPermissions(\n\tparentMode: string | undefined,\n\trequested?: string,\n): ResolvedChildPermissions | RejectedChildPermissions {\n\tconst requestedPermission = resolveRequestedChildPermission(requested);\n\tif (parseParentPermissionMode(parentMode) === \"plan\" && requestedPermission === \"full\") {\n\t\treturn { ok: false, requested: requestedPermission, error: PLAN_MODE_WRITE_SPAWN_ERROR };\n\t}\n\treturn { ok: true, requested: requestedPermission, effective: requestedPermission };\n}\n\n/**\n * Apply the resolved child permission before any tool call. No-op for non-child\n * processes so `lunr -p` stays fail-closed.\n */\nexport function applyInheritedSubagentPermissions(env: NodeJS.ProcessEnv = process.env): PermissionMode | undefined {\n\tif (!isSubagentChildProcess(env)) return undefined;\n\tconst childMode = resolveChildRuntimePermissionMode(env[SUBAGENT_CHILD_PERMISSION_ENV]);\n\tresetPermissions(childMode);\n\treturn childMode;\n}\n"]}
|
package/dist/core/swarm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/core/swarm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/core/swarm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUrD;AAED;;;;;;;;GAQG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAe1C;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAczE;AAaD,UAAU,oBAAoB;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC/E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,gBAAgB,CAAC,EAAE,oBAAoB,GACrC,MAAM,CAYR;AAED,UAAU,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/C;AAaD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,CAO/E","sourcesContent":["/**\n * lunR: reusable swarm prompt builder.\n *\n * Moved out of interactive-mode so the gateway can decompose tasks across\n * parallel subagents the same way the TUI does.\n */\n\nexport function buildSwarmPrompt(task: string): string {\n\treturn `[SWARM MODE] Task: ${task}\nAct as an orchestrator. 1) Decompose into 3-8 independent subtasks. 2) Launch them\nin ONE parallel subagent call (async:false) as generic children, each with task,\ndescription, and permissions (\"full\" or \"read-only\"; omit permissions for full).\nUse read-only children for inspection/review and full children only when edits\nare required. Pick a model tier per subtask. 3) Synthesize the results and report.\nRules: max 8 concurrent children; no nested fan-out; if a subtask fails, retry\nonce with the heavy tier before giving up on it; keep your final report under\n100 lines with per-subtask status.`;\n}\n\n/**\n * lunR: agent-swarm auto-activation gate helpers.\n *\n * When the model launches more than SWARM_APPROVAL_THRESHOLD parallel subagents\n * in one `subagent` `tasks`/`chain.parallel` call, or that many same-turn SINGLE\n * `subagent` calls, that counts as an auto-activated agent swarm and requires\n * user approval in every permission mode except `auto` (see core/permissions.ts).\n * An explicit /swarm turn is pre-approved because the user already asked for the swarm.\n */\n\n/** Parallel-subagent count above which the swarm approval gate engages. */\nexport const SWARM_APPROVAL_THRESHOLD = 2;\n\nfunction countEntry(item: unknown): number {\n\tconst count = item && typeof item === \"object\" ? (item as { count?: unknown }).count : undefined;\n\treturn typeof count === \"number\" && Number.isInteger(count) && count >= 1 ? count : 1;\n}\n\nfunction isManagementCall(args: Record<string, unknown>): boolean {\n\treturn typeof args.action === \"string\" && args.action.length > 0;\n}\n\nfunction isAsyncDetached(args: Record<string, unknown>): boolean {\n\treturn args.async === true && args.clarify !== true;\n}\n\n/**\n * Effective number of parallel subagents a `subagent` tool call will launch:\n * the `tasks` array (with `count` multipliers) plus any `chain` step `parallel`\n * fan-out blocks. Sequential chain steps and single-agent calls count as 0.\n * Dynamic `expand` fan-out has no static count and is not gated.\n */\nexport function effectiveSwarmCount(args: Record<string, unknown>): number {\n\tlet total = 0;\n\tif (Array.isArray(args.tasks)) {\n\t\tfor (const task of args.tasks) total += countEntry(task);\n\t}\n\tif (Array.isArray(args.chain)) {\n\t\tfor (const step of args.chain) {\n\t\t\tconst parallel = step && typeof step === \"object\" ? (step as { parallel?: unknown }).parallel : undefined;\n\t\t\tif (Array.isArray(parallel)) {\n\t\t\t\tfor (const child of parallel) total += countEntry(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn total;\n}\n\nfunction siblingSingleCount(args: Record<string, unknown>): number {\n\tif (isManagementCall(args) || isAsyncDetached(args)) return 0;\n\tif (Array.isArray(args.tasks) || Array.isArray(args.chain)) return 0;\n\treturn typeof args.task === \"string\" &&\n\t\targs.task.length > 0 &&\n\t\ttypeof args.description === \"string\" &&\n\t\targs.description.length > 0\n\t\t? 1\n\t\t: 0;\n}\n\ninterface AssistantMessageLike {\n\tcontent?: ReadonlyArray<{ type?: string; name?: string; arguments?: unknown }>;\n}\n\n/**\n * Parallel subagent count for the swarm gate. Uses this call's `tasks` / chain\n * `parallel` blocks, plus every other same-turn SINGLE `subagent` call so three\n * sibling singles still trip the >2 approval gate.\n */\nexport function effectiveSwarmCountForTurn(\n\targs: Record<string, unknown>,\n\tassistantMessage?: AssistantMessageLike,\n): number {\n\tconst own = effectiveSwarmCount(args);\n\tconst siblingSingles = (assistantMessage?.content ?? []).reduce((total, block) => {\n\t\tif (block.type !== \"toolCall\" || block.name !== \"subagent\") return total;\n\t\tconst siblingArgs =\n\t\t\tblock.arguments && typeof block.arguments === \"object\" && !Array.isArray(block.arguments)\n\t\t\t\t? (block.arguments as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tif (!siblingArgs) return total;\n\t\treturn total + siblingSingleCount(siblingArgs);\n\t}, 0);\n\treturn Math.max(own, siblingSingles);\n}\n\ninterface BranchEntryLike {\n\ttype: string;\n\tmessage?: { role?: string; content?: unknown };\n}\n\nfunction messageText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (Array.isArray(content)) {\n\t\treturn content\n\t\t\t.filter((c) => c && typeof c === \"object\" && (c as { type?: unknown }).type === \"text\")\n\t\t\t.map((c) => String((c as { text?: unknown }).text ?? \"\"))\n\t\t\t.join(\"\");\n\t}\n\treturn \"\";\n}\n\n/**\n * True when the current turn started from an explicit /swarm prompt (the most\n * recent user message carries the literal `[SWARM MODE]` prefix). Both the TUI\n * and the gateway inject the same buildSwarmPrompt text, so this works on both\n * surfaces without extra state.\n */\nexport function isExplicitSwarmTurn(branch: readonly BranchEntryLike[]): boolean {\n\tfor (let i = branch.length - 1; i >= 0; i--) {\n\t\tconst entry = branch[i];\n\t\tif (entry.type !== \"message\" || entry.message?.role !== \"user\") continue;\n\t\treturn messageText(entry.message.content).startsWith(\"[SWARM MODE]\");\n\t}\n\treturn false;\n}\n"]}
|
package/dist/core/swarm.js
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
export function buildSwarmPrompt(task) {
|
|
8
8
|
return `[SWARM MODE] Task: ${task}
|
|
9
9
|
Act as an orchestrator. 1) Decompose into 3-8 independent subtasks. 2) Launch them
|
|
10
|
-
in ONE parallel subagent call (async:false)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
in ONE parallel subagent call (async:false) as generic children, each with task,
|
|
11
|
+
description, and permissions ("full" or "read-only"; omit permissions for full).
|
|
12
|
+
Use read-only children for inspection/review and full children only when edits
|
|
13
|
+
are required. Pick a model tier per subtask. 3) Synthesize the results and report.
|
|
14
|
+
Rules: max 8 concurrent children; no nested fan-out; if a subtask fails, retry
|
|
15
|
+
once with the heavy tier before giving up on it; keep your final report under
|
|
16
|
+
100 lines with per-subtask status.`;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* lunR: agent-swarm auto-activation gate helpers.
|
|
@@ -63,7 +64,12 @@ function siblingSingleCount(args) {
|
|
|
63
64
|
return 0;
|
|
64
65
|
if (Array.isArray(args.tasks) || Array.isArray(args.chain))
|
|
65
66
|
return 0;
|
|
66
|
-
return typeof args.
|
|
67
|
+
return typeof args.task === "string" &&
|
|
68
|
+
args.task.length > 0 &&
|
|
69
|
+
typeof args.description === "string" &&
|
|
70
|
+
args.description.length > 0
|
|
71
|
+
? 1
|
|
72
|
+
: 0;
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
75
|
* Parallel subagent count for the swarm gate. Uses this call's `tasks` / chain
|
package/dist/core/swarm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../src/core/swarm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAU;IACtD,OAAO,sBAAsB,IAAI
|
|
1
|
+
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../src/core/swarm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAU;IACtD,OAAO,sBAAsB,IAAI;;;;;;;;mCAQC,CAAC;AAAA,CACnC;AAED;;;;;;;;GAQG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,SAAS,UAAU,CAAC,IAAa,EAAU;IAC1C,MAAM,KAAK,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAA4B,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC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,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO;aACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAwB,CAAC,IAAI,KAAK,MAAM,CAAC;aACtF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAE,CAAwB,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;aACxD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,EAAE,CAAC;AAAA,CACV;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAkC,EAAW;IAChF,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,KAAK,MAAM;YAAE,SAAS;QACzE,OAAO,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["/**\n * lunR: reusable swarm prompt builder.\n *\n * Moved out of interactive-mode so the gateway can decompose tasks across\n * parallel subagents the same way the TUI does.\n */\n\nexport function buildSwarmPrompt(task: string): string {\n\treturn `[SWARM MODE] Task: ${task}\nAct as an orchestrator. 1) Decompose into 3-8 independent subtasks. 2) Launch them\nin ONE parallel subagent call (async:false) as generic children, each with task,\ndescription, and permissions (\"full\" or \"read-only\"; omit permissions for full).\nUse read-only children for inspection/review and full children only when edits\nare required. Pick a model tier per subtask. 3) Synthesize the results and report.\nRules: max 8 concurrent children; no nested fan-out; if a subtask fails, retry\nonce with the heavy tier before giving up on it; keep your final report under\n100 lines with per-subtask status.`;\n}\n\n/**\n * lunR: agent-swarm auto-activation gate helpers.\n *\n * When the model launches more than SWARM_APPROVAL_THRESHOLD parallel subagents\n * in one `subagent` `tasks`/`chain.parallel` call, or that many same-turn SINGLE\n * `subagent` calls, that counts as an auto-activated agent swarm and requires\n * user approval in every permission mode except `auto` (see core/permissions.ts).\n * An explicit /swarm turn is pre-approved because the user already asked for the swarm.\n */\n\n/** Parallel-subagent count above which the swarm approval gate engages. */\nexport const SWARM_APPROVAL_THRESHOLD = 2;\n\nfunction countEntry(item: unknown): number {\n\tconst count = item && typeof item === \"object\" ? (item as { count?: unknown }).count : undefined;\n\treturn typeof count === \"number\" && Number.isInteger(count) && count >= 1 ? count : 1;\n}\n\nfunction isManagementCall(args: Record<string, unknown>): boolean {\n\treturn typeof args.action === \"string\" && args.action.length > 0;\n}\n\nfunction isAsyncDetached(args: Record<string, unknown>): boolean {\n\treturn args.async === true && args.clarify !== true;\n}\n\n/**\n * Effective number of parallel subagents a `subagent` tool call will launch:\n * the `tasks` array (with `count` multipliers) plus any `chain` step `parallel`\n * fan-out blocks. Sequential chain steps and single-agent calls count as 0.\n * Dynamic `expand` fan-out has no static count and is not gated.\n */\nexport function effectiveSwarmCount(args: Record<string, unknown>): number {\n\tlet total = 0;\n\tif (Array.isArray(args.tasks)) {\n\t\tfor (const task of args.tasks) total += countEntry(task);\n\t}\n\tif (Array.isArray(args.chain)) {\n\t\tfor (const step of args.chain) {\n\t\t\tconst parallel = step && typeof step === \"object\" ? (step as { parallel?: unknown }).parallel : undefined;\n\t\t\tif (Array.isArray(parallel)) {\n\t\t\t\tfor (const child of parallel) total += countEntry(child);\n\t\t\t}\n\t\t}\n\t}\n\treturn total;\n}\n\nfunction siblingSingleCount(args: Record<string, unknown>): number {\n\tif (isManagementCall(args) || isAsyncDetached(args)) return 0;\n\tif (Array.isArray(args.tasks) || Array.isArray(args.chain)) return 0;\n\treturn typeof args.task === \"string\" &&\n\t\targs.task.length > 0 &&\n\t\ttypeof args.description === \"string\" &&\n\t\targs.description.length > 0\n\t\t? 1\n\t\t: 0;\n}\n\ninterface AssistantMessageLike {\n\tcontent?: ReadonlyArray<{ type?: string; name?: string; arguments?: unknown }>;\n}\n\n/**\n * Parallel subagent count for the swarm gate. Uses this call's `tasks` / chain\n * `parallel` blocks, plus every other same-turn SINGLE `subagent` call so three\n * sibling singles still trip the >2 approval gate.\n */\nexport function effectiveSwarmCountForTurn(\n\targs: Record<string, unknown>,\n\tassistantMessage?: AssistantMessageLike,\n): number {\n\tconst own = effectiveSwarmCount(args);\n\tconst siblingSingles = (assistantMessage?.content ?? []).reduce((total, block) => {\n\t\tif (block.type !== \"toolCall\" || block.name !== \"subagent\") return total;\n\t\tconst siblingArgs =\n\t\t\tblock.arguments && typeof block.arguments === \"object\" && !Array.isArray(block.arguments)\n\t\t\t\t? (block.arguments as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tif (!siblingArgs) return total;\n\t\treturn total + siblingSingleCount(siblingArgs);\n\t}, 0);\n\treturn Math.max(own, siblingSingles);\n}\n\ninterface BranchEntryLike {\n\ttype: string;\n\tmessage?: { role?: string; content?: unknown };\n}\n\nfunction messageText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (Array.isArray(content)) {\n\t\treturn content\n\t\t\t.filter((c) => c && typeof c === \"object\" && (c as { type?: unknown }).type === \"text\")\n\t\t\t.map((c) => String((c as { text?: unknown }).text ?? \"\"))\n\t\t\t.join(\"\");\n\t}\n\treturn \"\";\n}\n\n/**\n * True when the current turn started from an explicit /swarm prompt (the most\n * recent user message carries the literal `[SWARM MODE]` prefix). Both the TUI\n * and the gateway inject the same buildSwarmPrompt text, so this works on both\n * surfaces without extra state.\n */\nexport function isExplicitSwarmTurn(branch: readonly BranchEntryLike[]): boolean {\n\tfor (let i = branch.length - 1; i >= 0; i--) {\n\t\tconst entry = branch[i];\n\t\tif (entry.type !== \"message\" || entry.message?.role !== \"user\") continue;\n\t\treturn messageText(entry.message.content).startsWith(\"[SWARM MODE]\");\n\t}\n\treturn false;\n}\n"]}
|
|
@@ -5,11 +5,13 @@ import { type Skill } from "./skills.ts";
|
|
|
5
5
|
export interface BuildSystemPromptOptions {
|
|
6
6
|
/** Custom system prompt (replaces default). */
|
|
7
7
|
customPrompt?: string;
|
|
8
|
-
/**
|
|
8
|
+
/** Current model in provider/id form. */
|
|
9
|
+
modelSlug?: string;
|
|
10
|
+
/** Active tools; used to decide whether read-dependent skill metadata is visible. */
|
|
9
11
|
selectedTools?: string[];
|
|
10
|
-
/**
|
|
12
|
+
/** Legacy extension metadata retained for API compatibility; tool definitions are sent separately. */
|
|
11
13
|
toolSnippets?: Record<string, string>;
|
|
12
|
-
/**
|
|
14
|
+
/** Legacy extension metadata retained for API compatibility; not appended to the default prompt. */
|
|
13
15
|
promptGuidelines?: string[];
|
|
14
16
|
/** Text to append to system prompt. */
|
|
15
17
|
appendSystemPrompt?: string;
|
|
@@ -23,6 +25,6 @@ export interface BuildSystemPromptOptions {
|
|
|
23
25
|
/** Pre-loaded skills. */
|
|
24
26
|
skills?: Skill[];
|
|
25
27
|
}
|
|
26
|
-
/** Build the system prompt
|
|
28
|
+
/** Build the base system prompt and append configured context. */
|
|
27
29
|
export declare function buildSystemPrompt(options: BuildSystemPromptOptions): string;
|
|
28
30
|
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,sGAAsG;IACtG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,oGAAoG;IACpG,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAgH3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Current model in provider/id form. */\n\tmodelSlug?: string;\n\t/** Active tools; used to decide whether read-dependent skill metadata is visible. */\n\tselectedTools?: string[];\n\t/** Legacy extension metadata retained for API compatibility; tool definitions are sent separately. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Legacy extension metadata retained for API compatibility; not appended to the default prompt. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\n/** Build the base system prompt and append configured context. */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tmodelSlug,\n\t\tselectedTools,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst promptCwd = cwd.replace(/\\\\/g, \"/\");\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t\t}\n\t\t\tprompt += \"</project_context>\\n\";\n\t\t}\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\tconst currentModel = modelSlug?.trim() || \"no model selected\";\n\tconst hasRead = !selectedTools || selectedTools.includes(\"read\");\n\n\tlet prompt = `You are an expert coding assistant currently running ''${currentModel}'', operating inside lunR, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\nCurrent working directory: ''${promptCwd}''\n\nBehavior guidelines:\n- Default to writing no comments. Only add one if the why is non-obvious: a hidden constraint, a subtle invariant, a workaround for a specific bug, something that would surprise the reader. If removing the comment wouldn't confuse a future reader, don't write it.\n- Keep comments up to date! When making changes, it's important to keep things in sync. An outdated comment is worse than no comment at all.\n- Carefully consider the reversibility and blast radius of actions. Generally you can freely take local, reversible actions like editing files or running tests. But for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding.\n- Orchestrate subagents with intent! Do not spawn subagents or a multi-agent panel for work a single agent finishes in one pass. Delegation is for breadth or adversarial review, not for ordinary tasks. Use subagents as a tool when there is genuine benefit to it or the user explicitly asks for it.\n- When several agents work in parallel, state file ownership up front so they do not collide.\n- Tests are good! Endless smoke tests, regressions tests for feature deletions, etc, much less good. Tests should be focused, not slop.\n- Prefer editing existing files to creating new ones.\n- Only use emojis if the user explicitly requests it.\n- Never exfil private data on public platforms like github or any other services under any circumstances.\n\n\nGuidelines:\n- Use bash for file operations like ls, rg, find\n- Use read to examine files instead of cat or sed.\n- Use edit for precise changes (edits[].oldText must match exactly)\n- When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls\n- Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit.\n- Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions.\n- Use write only for new files or complete rewrites.\n- Use todo for meaningful multi-step work. Every update must send the complete list, with exactly one item in progress at a time.\n- Use subagents for independent parallel work, specialist analysis, or substantial research. Subagents start with fresh sessions. Use intercom instead to coordinate with an existing lunR session.\n- Use ast_search for structural code matches.\n- Use cron only when the user asks to schedule or manage unattended prompts.\n- Memory stores established, durable facts and stable preferences. Do not store behavior instructions, transient task details, transcripts, guesses, or secrets. Change memory only with the memory tools.\n- ~/.lunr/agent/AGENTS.md contains optional global instructions written by the user. Never modify it, including through shell commands.\n- Use web search when information is current, uncertain, externally referenced, or research-heavy, and cite the sources used.\n- Use MCP only for capabilities exposed by configured MCP servers. Call native lunR tools directly.\n\n\nlunR documentation (read only when the user asks about lunR itself, or the task concerns lunR itself, its SDK, extensions, themes, skills, or TUI):\n- README: ${readmePath}\n- Documentation: ${docsPath}\n- Examples: ${examplesPath}\n- Always read lunR .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n<project_context>\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `<project_instructions path=\"${filePath}\">\\n${content}\\n</project_instructions>\\n\\n`;\n\t\t}\n\t\tprompt += \"</project_context>\\n\";\n\t}\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\treturn prompt;\n}\n"]}
|