@ashx-j/lunr 0.2.8 → 0.2.9
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/dist/builtin-extensions/ashxj-spinners.d.ts +7 -0
- package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-spinners.js +40 -3
- package/dist/builtin-extensions/ashxj-spinners.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +4 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +44 -0
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-behavior.d.ts +2 -1
- package/dist/builtin-extensions/lunr-behavior.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-behavior.js +26 -14
- package/dist/builtin-extensions/lunr-behavior.js.map +1 -1
- package/dist/builtin-extensions/lunr-todos.d.ts +4 -7
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-todos.js +18 -10
- package/dist/builtin-extensions/lunr-todos.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +2 -2
- 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 +2 -2
- 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 +3 -4
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- 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 +6 -18
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +13 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts +21 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js +22 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js.map +1 -0
- 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 +2 -1
- 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.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +10 -18
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.js +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/openrouter.json +1 -1
- package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/cli/update-cli.d.ts +16 -0
- package/dist/cli/update-cli.d.ts.map +1 -0
- package/dist/cli/update-cli.js +83 -0
- package/dist/cli/update-cli.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/behavior-preset.d.ts +60 -0
- package/dist/core/behavior-preset.d.ts.map +1 -0
- package/dist/core/behavior-preset.js +257 -0
- package/dist/core/behavior-preset.js.map +1 -0
- package/dist/core/customize.d.ts +3 -0
- package/dist/core/customize.d.ts.map +1 -1
- package/dist/core/customize.js +9 -0
- package/dist/core/customize.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +12 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +70 -5
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-tiers.d.ts +9 -0
- package/dist/core/model-tiers.d.ts.map +1 -1
- package/dist/core/model-tiers.js +16 -0
- package/dist/core/model-tiers.js.map +1 -1
- package/dist/core/settings-manager.d.ts +23 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +66 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/update-check.d.ts +32 -0
- package/dist/core/update-check.d.ts.map +1 -0
- package/dist/core/update-check.js +112 -0
- package/dist/core/update-check.js.map +1 -0
- package/dist/core/usage-service.d.ts +24 -1
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +91 -14
- 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 +5 -1
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +5 -1
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +68 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +13 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +157 -10
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +82 -3
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/keybindings.md +1 -1
- 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/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-description.js","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/extension/tool-description.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,4BAA4B,GAAG,8BAA8B,CAAC;AACpE,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AAW,GAAG,8BAA8B,CAAC;IAC9C,CAAC;IACD,gGAAgG;IAChG,IAAI,sBAAsB,EAAE;QAAE,OAAO,GAAG,WAAW,OAAO,mBAAmB,EAAE,CAAC;IAChF,OAAO,WAAW,CAAC;AAAA,CACnB;AAED,4FAA4F;AAC5F,MAAM,mBAAmB,GAAG,qRAAqR,CAAC;AAElT,qHAAqH;AACrH,SAAS,sBAAsB,GAAY;IAC1C,IAAI,CAAC;QACJ,MAAM,MAAM,GAAI,UAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAE1E,CAAC;QACb,OAAO,OAAO,MAAM,EAAE,iBAAiB,KAAK,UAAU,IAAI,MAAM,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAC/F,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AAAA,CACD","sourcesContent":["// @ts-nocheck\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ExtensionConfig, ToolDescriptionMode } from \"../shared/types.ts\";\nimport { getAgentDir, getProjectConfigDir } from \"../shared/utils.ts\";\n\nconst CUSTOM_TOOL_DESCRIPTION_FILE = \"subagent-tool-description.md\";\nconst CUSTOM_TOOL_DESCRIPTION_MAX_BYTES = 50 * 1024;\n\nexport const SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:\n• Use { action: \"list\" } before execution and only run executable/non-disabled agents or chains.\n• Keep execution and management separate: omit action for SINGLE/PARALLEL/CHAIN execution; use action only for list/get/models/create/update/delete/status/interrupt/stop/resume/append-step/doctor.\n• Async/background runs: launch with async:true only when work can proceed independently. Do not sleep or poll status just to wait. In an interactive session, normally return control and let Pi wake you; use subagent_wait when this request must run to completion in the current turn or skill. Headless sessions auto-drain current-session work.\n• Child-safety boundary: ordinary child subagents are not orchestrators and must not run subagents. Only explicitly configured fanout children may use the child-safe subagent tool, still bounded by depth/session limits.\n• Writing/review safety: keep one writer for the same cwd/worktree. Use fresh-context read-only reviewers/validators for independent review, then have the parent synthesize and apply fixes as the sole writer unless an isolated worktree was intentionally requested.\n• Artifacts/status essentials: chain outputs live under {chain_dir}; async runs expose asyncId/asyncDir with status.json, events.jsonl, output logs, and status via { action: \"status\", id }. Include output paths and residual risks when reporting results.`;\n\nexport const FULL_SUBAGENT_TOOL_DESCRIPTION = `Delegate to subagents or manage agent definitions.\n\nEXECUTION (use exactly ONE mode):\n• Before executing, use { action: \"list\" } to inspect configured agents/chains. Only execute agents listed as executable/non-disabled.\n• SINGLE: { agent, task? } - one task; omit task for self-contained agents\n• CHAIN: { chain: [{agent:\"agent-a\"}, {parallel:[{agent:\"agent-b\",count:3}]}] } - sequential pipeline with optional parallel fan-out\n• PARALLEL: { tasks: [{agent,task,count?,output?,reads?,progress?}, ...], concurrency?: number, worktree?: true } - concurrent execution (worktree: isolate each task in a git worktree)\n• Optional context: { context: \"fresh\" | \"fork\" } (explicit value overrides every child; when omitted, each requested agent uses its own defaultContext, otherwise \"fresh\"; inspect agent defaults via { action: \"list\" })\n• Fork thinking: model strings accept a thinking suffix (provider/model:off|minimal|low|medium|high|xhigh|max). Forking over a parent transcript that carries signed Anthropic thinking blocks forces thinking off only when a child's effective primary or fallback model resolves to the Anthropic provider or anthropic-messages API; unresolved models are treated conservatively. The result notes affected children, including on failures. Use fresh context when an Anthropic child needs thinking.\n• Optional timeout: { timeoutMs } or { maxRuntimeMs } sets a run-level max runtime for foreground and async/background runs\n• If { action: \"list\" } shows proactive skill subagent suggestions, consider a small fresh-context fanout for broad tasks where one of those skills would materially help\n\nCHAIN TEMPLATE VARIABLES (use in task strings):\n• {task} - The original task/request from the user\n• {previous} - Text response from the previous step (empty for first step)\n• {chain_dir} - Shared directory for chain files (e.g., <tmpdir>/pi-subagents-<scope>/chain-runs/abc123/)\n\nCHAIN EXAMPLES (quick reference for the nested schema):\n• Sequential: { chain: [{agent:\"agent-a\", task:\"Analyze {task}\"}, {agent:\"agent-b\", task:\"Plan based on {previous}\"}] }\n• Parallel fan-out: { chain: [{parallel: [{agent:\"agent-a\", task:\"Check part of {task}\", count: 3}]}] }\n• Mixed: { chain: [{agent:\"agent-a\", task:\"Research {task}\"}, {parallel: [{agent:\"agent-b\", task:\"Review {previous}\", count: 2}]}, {agent:\"agent-c\", task:\"Summarize {previous}\"}] }\n\nMANAGEMENT (use action field, omit agent/task/chain/tasks):\n• { action: \"list\" } - discover executable agents/chains\n• { action: \"get\", agent: \"name\" } - full detail; packaged agents use dotted runtime names like \"package.agent\"\n• { action: \"models\", agent?: \"name\" } - show the runtime-loaded builtin subagent model mapping, optionally filtered to one builtin\n• { action: \"watchdog.status\" | \"watchdog.check\" | \"watchdog.recommend-model\" } - inspect the opt-in subagent watchdog and its strong complementary model recommendation\n• { action: \"watchdog.configure\", model: \"recommended\" | \"inherit\" | \"provider/model[:thinking]\", scope?: \"session\" | \"user\" | \"project\", target?: \"main\" | \"children\" | \"child\", agent?: \"name\", thinking?: \"inherit\" | \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\" } - configure watchdog model selection; default scope is session, use persistent scopes only when the user asks\n• { action: \"create\", config: { name: \"custom-agent\", package: \"code-analysis\", systemPrompt, systemPromptMode, inheritProjectContext, inheritSkills, defaultContext, acceptance, acceptanceRole: \"read-only\" | \"writer\", ... } }\n• acceptanceRole affects inferred acceptance only, never tool access. Explicit task mutation/no-edit intent wins; omission preserves name heuristics. Update with false or an empty string to clear it.\n• { action: \"update\", agent: \"code-analysis.custom-agent\", config: { package: \"analysis\", ... } } - merge\n• { action: \"delete\", agent: \"code-analysis.custom-agent\" }\n• { action: \"eject\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - copy a bundled/package agent to user/project scope as an editable custom file that shadows the original (default scope: user)\n• { action: \"disable\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - hide any agent from runtime discovery via a reversible settings override (default scope: user)\n• { action: \"enable\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - remove a disabled override and restore discovery\n• { action: \"reset\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - delete the scope's custom agent file and/or settings override, restoring the bundled default\n• Use chainName for chain operations; packaged chains also use dotted runtime names\n\nCONTROL:\n• { action: \"status\", id: \"...\" } - inspect an async/background run by id or prefix\n• { action: \"status\", view: \"fleet\" } - read-only active foreground/async fleet view with transcript commands\n• { action: \"status\", id: \"...\", view: \"transcript\", index?: 0, lines?: 80 } - tail a run or child output/session transcript\n• { action: \"interrupt\", id?: \"...\" } - soft-interrupt the current child turn and leave the run paused\n• { action: \"stop\", id: \"...\" } - stop a current-session top-level async run; stopped runs finish with state \"stopped\"\n• { action: \"resume\", id: \"...\", message: \"...\", index?: 0 } - interrupt then follow up with a live async child, or revive a completed async/foreground child from its session\n• { action: \"steer\", id: \"...\", message: \"...\", index?: 0 } - await correlated child-Pi input acceptance for up to 3 seconds; returns delivered, scheduled, pending, partial, recovered, or failed with a request id. Only top-level single runs may recover after a further 15-second pause/revival bound; chain, parallel, and nested runs never auto-interrupt.\n• { action: \"append-step\", id: \"...\", chain: [{agent:\"agent-c\", task:\"Use {previous}\"}] } - append one step to the tail of a running async chain\n\nSCHEDULE (opt-in; requires { \"scheduledRuns\": { \"enabled\": true } } in config.json):\n• { action: \"schedule\", agent, task?, schedule: \"+10m\" | \"2030-01-01T09:00:00Z\", scheduleName? } - defer a subagent launch until a future time. Also accepts tasks[] or chain[]. Scheduled runs always launch async with fresh context; they become normal tracked async runs once they fire. Only schedule explicit delayed runs the user asked for.\n• { action: \"schedule-list\" } - list scheduled runs for this session\n• { action: \"schedule-status\", id: \"...\" } - inspect one scheduled run\n• { action: \"schedule-cancel\", id: \"...\" } - cancel a scheduled run before it fires\n\nDIAGNOSTICS:\n• { action: \"doctor\" } - read-only report for runtime paths, discovery, sessions, and intercom\n\n${SUBAGENT_SAFETY_GUIDANCE}`;\n\nexport const COMPACT_SUBAGENT_TOOL_DESCRIPTION = `Delegate to subagents or manage definitions. Use exactly one mode per call.\n\nEXECUTE:\n• Before execution, call { action: \"list\" }; run only executable/non-disabled configured agents/chains.\n• SINGLE {agent, task?}; PARALLEL {tasks:[{agent,task,count?,output?,reads?,progress?}], concurrency?, worktree?}; CHAIN {chain:[{agent,task?},{parallel:[...]}]}.\n• context can be \"fresh\" or \"fork\"; omitted uses each agent defaultContext, otherwise fresh. timeoutMs/maxRuntimeMs apply to foreground and async/background runs.\n• Chain templates may use {task}, {previous}, {chain_dir}, and named outputs. Parallel worktree isolation requires a clean git repo.\n• Chain example: { chain: [{agent:\"agent-a\", task:\"Analyze {task}\"}, {parallel: [{agent:\"agent-b\", task:\"Check {previous}\", count: 3}]}] }\n• If list shows proactive skill subagent suggestions, use a small fresh-context fanout only when the task is broad enough.\n\nMANAGE / CONTROL:\n• Use action without execution fields: list, get, models, create, update, delete, eject, disable, enable, reset, doctor, watchdog.status, watchdog.check, watchdog.recommend-model, watchdog.configure.\n• Agent acceptanceRole (read-only or writer) affects inferred acceptance only, never tools. Explicit task intent wins; omission keeps name heuristics. Update with false or an empty string to clear it.\n• Async control actions: status, interrupt, stop, resume, steer, append-step. Use stop with an id for current-session top-level async runs. Use status view:\"fleet\" for active-run overview, view:\"transcript\" to tail child output, and steer for acknowledged live guidance. Steering delivery means Pi accepted the correlated user input, not model compliance; use index for a specific child.\n• Opt-in schedule actions: schedule, schedule-list, schedule-status, schedule-cancel. Schedule only explicit delayed runs the user asked for.\n\nASYNC / WAIT:\n• async:true detaches background work. Do not sleep or poll just to wait. Interactive sessions normally yield for completion notifications; use subagent_wait for run-to-completion turns or skills. Headless sessions auto-drain current-session work.\n• Status and artifacts live under asyncId/asyncDir with status.json, events.jsonl, output logs, session files, and { action:\"status\", id:\"...\" }.\n\nSAFETY:\n• Ordinary child subagents are not orchestrators and must not run subagents. Only explicit fanout children may use child-safe subagent, still bounded by depth/session limits.\n• Keep one writer per cwd/worktree. Use fresh read-only review/validation fanout, then synthesize and apply fixes from the parent unless isolated worktrees were intentionally requested.`;\n\nfunction isToolDescriptionMode(value: unknown): value is ToolDescriptionMode {\n\treturn value === \"full\" || value === \"compact\" || value === \"custom\";\n}\n\nfunction warn(options: ToolDescriptionOptions | undefined, message: string): void {\n\t(options?.warn ?? console.warn)(`[pi-subagents] ${message}`);\n}\n\nexport interface ToolDescriptionOptions {\n\tcwd?: string;\n\tagentDir?: string;\n\twarn?: (message: string) => void;\n}\n\nexport function resolveToolDescriptionMode(config: Pick<ExtensionConfig, \"toolDescriptionMode\">, options?: ToolDescriptionOptions): ToolDescriptionMode {\n\tconst mode = config.toolDescriptionMode;\n\tif (mode === undefined) return \"full\";\n\tif (isToolDescriptionMode(mode)) return mode;\n\twarn(options, `Ignoring invalid toolDescriptionMode ${JSON.stringify(mode)}; expected \"full\", \"compact\", or \"custom\".`);\n\treturn \"full\";\n}\n\nfunction customDescriptionPaths(options?: ToolDescriptionOptions): string[] {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst agentDir = options?.agentDir ?? getAgentDir();\n\treturn [\n\t\tpath.join(getProjectConfigDir(cwd), CUSTOM_TOOL_DESCRIPTION_FILE),\n\t\tpath.join(agentDir, CUSTOM_TOOL_DESCRIPTION_FILE),\n\t];\n}\n\nfunction renderCustomTemplate(template: string, options?: ToolDescriptionOptions): string {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst agentDir = options?.agentDir ?? getAgentDir();\n\tconst projectConfigDir = getProjectConfigDir(cwd);\n\tconst variables: Record<string, () => string> = {\n\t\tfullDescription: () => FULL_SUBAGENT_TOOL_DESCRIPTION,\n\t\tfull: () => FULL_SUBAGENT_TOOL_DESCRIPTION,\n\t\tcompactDescription: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,\n\t\tcompact: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,\n\t\tsafetyGuidance: () => SUBAGENT_SAFETY_GUIDANCE,\n\t\tsafety: () => SUBAGENT_SAFETY_GUIDANCE,\n\t\tagentDir: () => agentDir,\n\t\tprojectConfigDir: () => projectConfigDir,\n\t};\n\treturn template.replace(/\\{\\{(\\w+)\\}\\}/g, (raw, name: string) => {\n\t\tconst replacement = variables[name];\n\t\tif (replacement) return replacement();\n\t\twarn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE}: unknown placeholder ${raw} left unchanged.`);\n\t\treturn raw;\n\t});\n}\n\nfunction loadCustomToolDescription(options?: ToolDescriptionOptions): string | undefined {\n\tfor (const filePath of customDescriptionPaths(options)) {\n\t\tlet stat: fs.Stats;\n\t\ttry {\n\t\t\tstat = fs.statSync(filePath);\n\t\t} catch (error) {\n\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && (error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n\t\t\twarn(options, `Failed to inspect custom tool description '${filePath}': ${error instanceof Error ? error.message : String(error)}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) {\n\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it is not a file.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (stat.size > CUSTOM_TOOL_DESCRIPTION_MAX_BYTES) {\n\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it is larger than ${CUSTOM_TOOL_DESCRIPTION_MAX_BYTES} bytes.`);\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst template = fs.readFileSync(filePath, \"utf-8\").trim();\n\t\t\tif (!template) {\n\t\t\t\twarn(options, `Ignoring empty custom tool description '${filePath}'.`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst rendered = renderCustomTemplate(template, options).trim();\n\t\t\tif (!rendered) {\n\t\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it rendered empty.`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn rendered;\n\t\t} catch (error) {\n\t\t\twarn(options, `Failed to read custom tool description '${filePath}': ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction withMandatorySafetyGuidance(description: string): string {\n\tconst customDescription = description\n\t\t.split(SUBAGENT_SAFETY_GUIDANCE)\n\t\t.map((part) => part.trim())\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\\n\");\n\treturn customDescription\n\t\t? `${customDescription}\\n\\n${SUBAGENT_SAFETY_GUIDANCE}`\n\t\t: SUBAGENT_SAFETY_GUIDANCE;\n}\n\nexport function buildSubagentToolDescription(config: Pick<ExtensionConfig, \"toolDescriptionMode\"> = {}, options?: ToolDescriptionOptions): string {\n\tconst mode = resolveToolDescriptionMode(config, options);\n\tlet description: string;\n\tif (mode === \"compact\") {\n\t\tdescription = COMPACT_SUBAGENT_TOOL_DESCRIPTION;\n\t} else if (mode === \"custom\") {\n\t\tconst custom = loadCustomToolDescription(options);\n\t\tif (custom) {\n\t\t\tdescription = withMandatorySafetyGuidance(custom);\n\t\t} else {\n\t\t\twarn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE} was not found or valid for toolDescriptionMode \"custom\"; using full description.`);\n\t\t\tdescription = FULL_SUBAGENT_TOOL_DESCRIPTION;\n\t\t}\n\t} else {\n\t\tdescription = FULL_SUBAGENT_TOOL_DESCRIPTION;\n\t}\n\t// lunr: append model-tier guidance only when lunR core's tier bridge is registered and enabled.\n\tif (isModelTierModeEnabled()) return `${description}\\n\\n${MODEL_TIER_GUIDANCE}`;\n\treturn description;\n}\n\n// lunr: model tier guidance appended to the subagent tool description when tier mode is on.\nconst MODEL_TIER_GUIDANCE = `MODEL TIERS: Model tiers are enabled. For each subagent choose \\`tier\\`: 'light' for simple lookups/formatting, 'standard' for typical coding tasks, 'heavy' for deep reasoning/complex debugging. An explicit \\`model\\` overrides the tier. Omit both to inherit the parent model.`;\n\n// lunr: check lunR core's model-tier bridge (Symbol.for(\"@lunr/model-tiers\")); absent bridge means tier mode is off.\nfunction isModelTierModeEnabled(): boolean {\n\ttry {\n\t\tconst bridge = (globalThis as Record<symbol, unknown>)[Symbol.for(\"@lunr/model-tiers\")] as\n\t\t\t| { isTierModeEnabled?: () => unknown }\n\t\t\t| undefined;\n\t\treturn typeof bridge?.isTierModeEnabled === \"function\" && bridge.isTierModeEnabled() === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-description.js","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/extension/tool-description.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,4BAA4B,GAAG,8BAA8B,CAAC;AACpE,MAAM,iCAAiC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpD,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;gQAMsN,CAAC;AAE/P,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwD5C,wBAAwB,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,iCAAiC,GAAG;;;;;;;;;;;;;;;;;;;;;;4LAsByI,CAAC;AAE3L,SAAS,qBAAqB,CAAC,KAAc,EAAgC;IAC5E,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,QAAQ,CAAC;AAAA,CACrE;AAED,SAAS,IAAI,CAAC,OAA2C,EAAE,OAAe,EAAQ;IACjF,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAAA,CAC7D;AAQD,MAAM,UAAU,0BAA0B,CAAC,MAAoD,EAAE,OAAgC,EAAuB;IACvJ,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CAAC;IACxC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACtC,IAAI,q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;IACxB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,WAAW,GAAG,iCAAiC,CAAC;IACjD,CAAC;SAAM,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACZ,WAAW,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,EAAE,GAAG,4BAA4B,mFAAmF,CAAC,CAAC;YAClI,WAAW,GAAG,8BAA8B,CAAC;QAC9C,CAAC;IACF,CAAC;SAAM,CAAC;QACP,WAAW,GAAG,8BAA8B,CAAC;IAC9C,CAAC;IACD,gGAAgG;IAChG,IAAI,sBAAsB,EAAE;QAAE,OAAO,GAAG,WAAW,OAAO,mBAAmB,EAAE,CAAC;IAChF,OAAO,WAAW,CAAC;AAAA,CACnB;AAED,4FAA4F;AAC5F,MAAM,mBAAmB,GAAG,qRAAqR,CAAC;AAElT,qHAAqH;AACrH,SAAS,sBAAsB,GAAY;IAC1C,IAAI,CAAC;QACJ,MAAM,MAAM,GAAI,UAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAE1E,CAAC;QACb,OAAO,OAAO,MAAM,EAAE,iBAAiB,KAAK,UAAU,IAAI,MAAM,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAC/F,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AAAA,CACD","sourcesContent":["// @ts-nocheck\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ExtensionConfig, ToolDescriptionMode } from \"../shared/types.ts\";\nimport { getAgentDir, getProjectConfigDir } from \"../shared/utils.ts\";\n\nconst CUSTOM_TOOL_DESCRIPTION_FILE = \"subagent-tool-description.md\";\nconst CUSTOM_TOOL_DESCRIPTION_MAX_BYTES = 50 * 1024;\n\nexport const SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:\n• Use { action: \"list\" } before execution and only run executable/non-disabled agents or chains.\n• Keep execution and management separate: omit action for SINGLE/PARALLEL/CHAIN execution; use action only for list/get/models/create/update/delete/status/interrupt/stop/resume/append-step/doctor.\n• Async/background runs: launch with async:true only when work can proceed independently. Do not sleep or poll status just to wait. In an interactive session, normally return control and let Pi wake you; use subagent_wait when this request must run to completion in the current turn or skill. Headless sessions auto-drain current-session work.\n• Child-safety boundary: ordinary child subagents are not orchestrators and must not run subagents. Only explicitly configured fanout children may use the child-safe subagent tool, still bounded by depth/session limits.\n• Writing/review safety: keep one writer for the same cwd/worktree. Use fresh-context read-only reviewers/validators for independent review, then have the parent synthesize and apply fixes as the sole writer unless an isolated worktree was intentionally requested.\n• Artifacts/status essentials: chain outputs live under {chain_dir}; async runs expose asyncId/asyncDir with status.json, events.jsonl, output logs, and status via { action: \"status\", id }. Include output paths and residual risks when reporting results.`;\n\nexport const FULL_SUBAGENT_TOOL_DESCRIPTION = `Delegate to subagents or manage agent definitions.\n\nEXECUTION (use exactly ONE mode):\n• Before executing, use { action: \"list\" } to inspect configured agents/chains. Only execute agents listed as executable/non-disabled.\n• SINGLE: { agent, task? } - one task; omit task for self-contained agents\n• CHAIN: { chain: [{agent:\"agent-a\"}, {parallel:[{agent:\"agent-b\",count:3}]}] } - sequential pipeline with optional parallel fan-out\n• PARALLEL: { tasks: [{agent,task,count?,output?,reads?,progress?}, ...], concurrency?: number, worktree?: true } - concurrent execution (worktree: isolate each task in a git worktree)\n• Children always start with a fresh session (no inherited parent transcript). Model strings accept a thinking suffix (provider/model:off|minimal|low|medium|high|xhigh|max).\n• Optional timeout: { timeoutMs } or { maxRuntimeMs } sets a run-level max runtime for foreground and async/background runs\n• If { action: \"list\" } shows proactive skill subagent suggestions, consider a small fresh-context fanout for broad tasks where one of those skills would materially help\n\nCHAIN TEMPLATE VARIABLES (use in task strings):\n• {task} - The original task/request from the user\n• {previous} - Text response from the previous step (empty for first step)\n• {chain_dir} - Shared directory for chain files (e.g., <tmpdir>/pi-subagents-<scope>/chain-runs/abc123/)\n\nCHAIN EXAMPLES (quick reference for the nested schema):\n• Sequential: { chain: [{agent:\"agent-a\", task:\"Analyze {task}\"}, {agent:\"agent-b\", task:\"Plan based on {previous}\"}] }\n• Parallel fan-out: { chain: [{parallel: [{agent:\"agent-a\", task:\"Check part of {task}\", count: 3}]}] }\n• Mixed: { chain: [{agent:\"agent-a\", task:\"Research {task}\"}, {parallel: [{agent:\"agent-b\", task:\"Review {previous}\", count: 2}]}, {agent:\"agent-c\", task:\"Summarize {previous}\"}] }\n\nMANAGEMENT (use action field, omit agent/task/chain/tasks):\n• { action: \"list\" } - discover executable agents/chains\n• { action: \"get\", agent: \"name\" } - full detail; packaged agents use dotted runtime names like \"package.agent\"\n• { action: \"models\", agent?: \"name\" } - show the runtime-loaded builtin subagent model mapping, optionally filtered to one builtin\n• { action: \"watchdog.status\" | \"watchdog.check\" | \"watchdog.recommend-model\" } - inspect the opt-in subagent watchdog and its strong complementary model recommendation\n• { action: \"watchdog.configure\", model: \"recommended\" | \"inherit\" | \"provider/model[:thinking]\", scope?: \"session\" | \"user\" | \"project\", target?: \"main\" | \"children\" | \"child\", agent?: \"name\", thinking?: \"inherit\" | \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\" } - configure watchdog model selection; default scope is session, use persistent scopes only when the user asks\n• { action: \"create\", config: { name: \"custom-agent\", package: \"code-analysis\", systemPrompt, systemPromptMode, inheritProjectContext, inheritSkills, acceptance, acceptanceRole: \"read-only\" | \"writer\", ... } }\n• acceptanceRole affects inferred acceptance only, never tool access. Explicit task mutation/no-edit intent wins; omission preserves name heuristics. Update with false or an empty string to clear it.\n• { action: \"update\", agent: \"code-analysis.custom-agent\", config: { package: \"analysis\", ... } } - merge\n• { action: \"delete\", agent: \"code-analysis.custom-agent\" }\n• { action: \"eject\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - copy a bundled/package agent to user/project scope as an editable custom file that shadows the original (default scope: user)\n• { action: \"disable\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - hide any agent from runtime discovery via a reversible settings override (default scope: user)\n• { action: \"enable\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - remove a disabled override and restore discovery\n• { action: \"reset\", agent: \"reviewer\", agentScope?: \"user\" | \"project\" } - delete the scope's custom agent file and/or settings override, restoring the bundled default\n• Use chainName for chain operations; packaged chains also use dotted runtime names\n\nCONTROL:\n• { action: \"status\", id: \"...\" } - inspect an async/background run by id or prefix\n• { action: \"status\", view: \"fleet\" } - read-only active foreground/async fleet view with transcript commands\n• { action: \"status\", id: \"...\", view: \"transcript\", index?: 0, lines?: 80 } - tail a run or child output/session transcript\n• { action: \"interrupt\", id?: \"...\" } - soft-interrupt the current child turn and leave the run paused\n• { action: \"stop\", id: \"...\" } - stop a current-session top-level async run; stopped runs finish with state \"stopped\"\n• { action: \"resume\", id: \"...\", message: \"...\", index?: 0 } - interrupt then follow up with a live async child, or revive a completed async/foreground child from its session\n• { action: \"steer\", id: \"...\", message: \"...\", index?: 0 } - await correlated child-Pi input acceptance for up to 3 seconds; returns delivered, scheduled, pending, partial, recovered, or failed with a request id. Only top-level single runs may recover after a further 15-second pause/revival bound; chain, parallel, and nested runs never auto-interrupt.\n• { action: \"append-step\", id: \"...\", chain: [{agent:\"agent-c\", task:\"Use {previous}\"}] } - append one step to the tail of a running async chain\n\nSCHEDULE (opt-in; requires { \"scheduledRuns\": { \"enabled\": true } } in config.json):\n• { action: \"schedule\", agent, task?, schedule: \"+10m\" | \"2030-01-01T09:00:00Z\", scheduleName? } - defer a subagent launch until a future time. Also accepts tasks[] or chain[]. Scheduled runs always launch async with fresh context; they become normal tracked async runs once they fire. Only schedule explicit delayed runs the user asked for.\n• { action: \"schedule-list\" } - list scheduled runs for this session\n• { action: \"schedule-status\", id: \"...\" } - inspect one scheduled run\n• { action: \"schedule-cancel\", id: \"...\" } - cancel a scheduled run before it fires\n\nDIAGNOSTICS:\n• { action: \"doctor\" } - read-only report for runtime paths, discovery, sessions, and intercom\n\n${SUBAGENT_SAFETY_GUIDANCE}`;\n\nexport const COMPACT_SUBAGENT_TOOL_DESCRIPTION = `Delegate to subagents or manage definitions. Use exactly one mode per call.\n\nEXECUTE:\n• Before execution, call { action: \"list\" }; run only executable/non-disabled configured agents/chains.\n• SINGLE {agent, task?}; PARALLEL {tasks:[{agent,task,count?,output?,reads?,progress?}], concurrency?, worktree?}; CHAIN {chain:[{agent,task?},{parallel:[...]}]}.\n• Children always start with a fresh session. timeoutMs/maxRuntimeMs apply to foreground and async/background runs.\n• Chain templates may use {task}, {previous}, {chain_dir}, and named outputs. Parallel worktree isolation requires a clean git repo.\n• Chain example: { chain: [{agent:\"agent-a\", task:\"Analyze {task}\"}, {parallel: [{agent:\"agent-b\", task:\"Check {previous}\", count: 3}]}] }\n• If list shows proactive skill subagent suggestions, use a small fresh-context fanout only when the task is broad enough.\n\nMANAGE / CONTROL:\n• Use action without execution fields: list, get, models, create, update, delete, eject, disable, enable, reset, doctor, watchdog.status, watchdog.check, watchdog.recommend-model, watchdog.configure.\n• Agent acceptanceRole (read-only or writer) affects inferred acceptance only, never tools. Explicit task intent wins; omission keeps name heuristics. Update with false or an empty string to clear it.\n• Async control actions: status, interrupt, stop, resume, steer, append-step. Use stop with an id for current-session top-level async runs. Use status view:\"fleet\" for active-run overview, view:\"transcript\" to tail child output, and steer for acknowledged live guidance. Steering delivery means Pi accepted the correlated user input, not model compliance; use index for a specific child.\n• Opt-in schedule actions: schedule, schedule-list, schedule-status, schedule-cancel. Schedule only explicit delayed runs the user asked for.\n\nASYNC / WAIT:\n• async:true detaches background work. Do not sleep or poll just to wait. Interactive sessions normally yield for completion notifications; use subagent_wait for run-to-completion turns or skills. Headless sessions auto-drain current-session work.\n• Status and artifacts live under asyncId/asyncDir with status.json, events.jsonl, output logs, session files, and { action:\"status\", id:\"...\" }.\n\nSAFETY:\n• Ordinary child subagents are not orchestrators and must not run subagents. Only explicit fanout children may use child-safe subagent, still bounded by depth/session limits.\n• Keep one writer per cwd/worktree. Use fresh read-only review/validation fanout, then synthesize and apply fixes from the parent unless isolated worktrees were intentionally requested.`;\n\nfunction isToolDescriptionMode(value: unknown): value is ToolDescriptionMode {\n\treturn value === \"full\" || value === \"compact\" || value === \"custom\";\n}\n\nfunction warn(options: ToolDescriptionOptions | undefined, message: string): void {\n\t(options?.warn ?? console.warn)(`[pi-subagents] ${message}`);\n}\n\nexport interface ToolDescriptionOptions {\n\tcwd?: string;\n\tagentDir?: string;\n\twarn?: (message: string) => void;\n}\n\nexport function resolveToolDescriptionMode(config: Pick<ExtensionConfig, \"toolDescriptionMode\">, options?: ToolDescriptionOptions): ToolDescriptionMode {\n\tconst mode = config.toolDescriptionMode;\n\tif (mode === undefined) return \"full\";\n\tif (isToolDescriptionMode(mode)) return mode;\n\twarn(options, `Ignoring invalid toolDescriptionMode ${JSON.stringify(mode)}; expected \"full\", \"compact\", or \"custom\".`);\n\treturn \"full\";\n}\n\nfunction customDescriptionPaths(options?: ToolDescriptionOptions): string[] {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst agentDir = options?.agentDir ?? getAgentDir();\n\treturn [\n\t\tpath.join(getProjectConfigDir(cwd), CUSTOM_TOOL_DESCRIPTION_FILE),\n\t\tpath.join(agentDir, CUSTOM_TOOL_DESCRIPTION_FILE),\n\t];\n}\n\nfunction renderCustomTemplate(template: string, options?: ToolDescriptionOptions): string {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst agentDir = options?.agentDir ?? getAgentDir();\n\tconst projectConfigDir = getProjectConfigDir(cwd);\n\tconst variables: Record<string, () => string> = {\n\t\tfullDescription: () => FULL_SUBAGENT_TOOL_DESCRIPTION,\n\t\tfull: () => FULL_SUBAGENT_TOOL_DESCRIPTION,\n\t\tcompactDescription: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,\n\t\tcompact: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,\n\t\tsafetyGuidance: () => SUBAGENT_SAFETY_GUIDANCE,\n\t\tsafety: () => SUBAGENT_SAFETY_GUIDANCE,\n\t\tagentDir: () => agentDir,\n\t\tprojectConfigDir: () => projectConfigDir,\n\t};\n\treturn template.replace(/\\{\\{(\\w+)\\}\\}/g, (raw, name: string) => {\n\t\tconst replacement = variables[name];\n\t\tif (replacement) return replacement();\n\t\twarn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE}: unknown placeholder ${raw} left unchanged.`);\n\t\treturn raw;\n\t});\n}\n\nfunction loadCustomToolDescription(options?: ToolDescriptionOptions): string | undefined {\n\tfor (const filePath of customDescriptionPaths(options)) {\n\t\tlet stat: fs.Stats;\n\t\ttry {\n\t\t\tstat = fs.statSync(filePath);\n\t\t} catch (error) {\n\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && (error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n\t\t\twarn(options, `Failed to inspect custom tool description '${filePath}': ${error instanceof Error ? error.message : String(error)}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) {\n\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it is not a file.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (stat.size > CUSTOM_TOOL_DESCRIPTION_MAX_BYTES) {\n\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it is larger than ${CUSTOM_TOOL_DESCRIPTION_MAX_BYTES} bytes.`);\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst template = fs.readFileSync(filePath, \"utf-8\").trim();\n\t\t\tif (!template) {\n\t\t\t\twarn(options, `Ignoring empty custom tool description '${filePath}'.`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst rendered = renderCustomTemplate(template, options).trim();\n\t\t\tif (!rendered) {\n\t\t\t\twarn(options, `Ignoring custom tool description '${filePath}' because it rendered empty.`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn rendered;\n\t\t} catch (error) {\n\t\t\twarn(options, `Failed to read custom tool description '${filePath}': ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction withMandatorySafetyGuidance(description: string): string {\n\tconst customDescription = description\n\t\t.split(SUBAGENT_SAFETY_GUIDANCE)\n\t\t.map((part) => part.trim())\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\\n\");\n\treturn customDescription\n\t\t? `${customDescription}\\n\\n${SUBAGENT_SAFETY_GUIDANCE}`\n\t\t: SUBAGENT_SAFETY_GUIDANCE;\n}\n\nexport function buildSubagentToolDescription(config: Pick<ExtensionConfig, \"toolDescriptionMode\"> = {}, options?: ToolDescriptionOptions): string {\n\tconst mode = resolveToolDescriptionMode(config, options);\n\tlet description: string;\n\tif (mode === \"compact\") {\n\t\tdescription = COMPACT_SUBAGENT_TOOL_DESCRIPTION;\n\t} else if (mode === \"custom\") {\n\t\tconst custom = loadCustomToolDescription(options);\n\t\tif (custom) {\n\t\t\tdescription = withMandatorySafetyGuidance(custom);\n\t\t} else {\n\t\t\twarn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE} was not found or valid for toolDescriptionMode \"custom\"; using full description.`);\n\t\t\tdescription = FULL_SUBAGENT_TOOL_DESCRIPTION;\n\t\t}\n\t} else {\n\t\tdescription = FULL_SUBAGENT_TOOL_DESCRIPTION;\n\t}\n\t// lunr: append model-tier guidance only when lunR core's tier bridge is registered and enabled.\n\tif (isModelTierModeEnabled()) return `${description}\\n\\n${MODEL_TIER_GUIDANCE}`;\n\treturn description;\n}\n\n// lunr: model tier guidance appended to the subagent tool description when tier mode is on.\nconst MODEL_TIER_GUIDANCE = `MODEL TIERS: Model tiers are enabled. For each subagent choose \\`tier\\`: 'light' for simple lookups/formatting, 'standard' for typical coding tasks, 'heavy' for deep reasoning/complex debugging. An explicit \\`model\\` overrides the tier. Omit both to inherit the parent model.`;\n\n// lunr: check lunR core's model-tier bridge (Symbol.for(\"@lunr/model-tiers\")); absent bridge means tier mode is off.\nfunction isModelTierModeEnabled(): boolean {\n\ttry {\n\t\tconst bridge = (globalThis as Record<symbol, unknown>)[Symbol.for(\"@lunr/model-tiers\")] as\n\t\t\t| { isTierModeEnabled?: () => unknown }\n\t\t\t| undefined;\n\t\treturn typeof bridge?.isTierModeEnabled === \"function\" && bridge.isTierModeEnabled() === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
|