@oh-my-pi/pi-coding-agent 16.1.23 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/dist/cli.js +3817 -3735
- package/dist/types/advisor/__tests__/emission-guard.test.d.ts +1 -0
- package/dist/types/advisor/emission-guard.d.ts +73 -0
- package/dist/types/advisor/index.d.ts +1 -0
- package/dist/types/advisor/runtime.d.ts +7 -0
- package/dist/types/advisor/watchdog.d.ts +2 -0
- package/dist/types/cli/flag-tables.d.ts +1 -0
- package/dist/types/cli/gallery-fixtures/search.d.ts +1 -1
- package/dist/types/collab/display-name.d.ts +3 -0
- package/dist/types/collab/host.d.ts +0 -2
- package/dist/types/commands/worktree.d.ts +0 -3
- package/dist/types/config/inline-tool-descriptors-mode.d.ts +13 -0
- package/dist/types/config/model-discovery.d.ts +6 -1
- package/dist/types/config/model-registry.d.ts +6 -2
- package/dist/types/config/model-resolver.d.ts +12 -0
- package/dist/types/config/models-config-schema.d.ts +29 -2
- package/dist/types/config/models-config.d.ts +22 -1
- package/dist/types/config/settings-schema.d.ts +91 -21
- package/dist/types/config/settings.d.ts +2 -0
- package/dist/types/dap/config.d.ts +1 -1
- package/dist/types/edit/hashline/filesystem.d.ts +4 -2
- package/dist/types/edit/renderer.d.ts +4 -0
- package/dist/types/extensibility/extensions/types.d.ts +17 -17
- package/dist/types/extensibility/hooks/types.d.ts +10 -10
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +1 -0
- package/dist/types/internal-urls/__tests__/ssh-protocol.test.d.ts +1 -0
- package/dist/types/internal-urls/index.d.ts +1 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +2 -0
- package/dist/types/internal-urls/router.d.ts +1 -1
- package/dist/types/internal-urls/ssh-protocol.d.ts +10 -0
- package/dist/types/internal-urls/types.d.ts +19 -2
- package/dist/types/irc/bus.d.ts +6 -0
- package/dist/types/modes/components/__tests__/move-overlay.test.d.ts +1 -0
- package/dist/types/modes/components/custom-editor.d.ts +7 -0
- package/dist/types/modes/components/move-overlay.d.ts +23 -0
- package/dist/types/modes/components/plugin-selector.d.ts +2 -1
- package/dist/types/modes/components/queue-mode-selector.d.ts +2 -1
- package/dist/types/modes/components/select-list-mouse-routing.d.ts +2 -0
- package/dist/types/modes/components/settings-defs.d.ts +4 -1
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/components/show-images-selector.d.ts +2 -1
- package/dist/types/modes/components/status-line/component.d.ts +2 -0
- package/dist/types/modes/components/status-line/types.d.ts +2 -0
- package/dist/types/modes/components/theme-selector.d.ts +2 -1
- package/dist/types/modes/components/thinking-selector.d.ts +2 -1
- package/dist/types/modes/controllers/command-controller.d.ts +10 -1
- package/dist/types/modes/controllers/streaming-reveal.d.ts +6 -0
- package/dist/types/modes/interactive-mode.d.ts +10 -1
- package/dist/types/modes/internal-url-autocomplete.d.ts +1 -1
- package/dist/types/modes/running-subagent-badge.d.ts +6 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +9 -1
- package/dist/types/sdk.d.ts +2 -2
- package/dist/types/session/agent-session.d.ts +2 -1
- package/dist/types/session/session-manager.d.ts +13 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +1 -1
- package/dist/types/ssh/__tests__/connection-manager-args.test.d.ts +1 -0
- package/dist/types/ssh/__tests__/file-transfer-posix-guard.test.d.ts +1 -0
- package/dist/types/ssh/connection-manager.d.ts +2 -0
- package/dist/types/ssh/file-transfer.d.ts +79 -0
- package/dist/types/ssh/utils.d.ts +6 -0
- package/dist/types/system-prompt.d.ts +3 -0
- package/dist/types/task/executor.d.ts +16 -0
- package/dist/types/tiny/text.d.ts +1 -1
- package/dist/types/tools/builtin-names.d.ts +5 -1
- package/dist/types/tools/{find.d.ts → glob.d.ts} +15 -15
- package/dist/types/tools/{search.d.ts → grep.d.ts} +14 -14
- package/dist/types/tools/index.d.ts +3 -3
- package/dist/types/tools/path-utils.d.ts +29 -0
- package/dist/types/tools/read.d.ts +2 -2
- package/dist/types/tools/render-utils.d.ts +8 -0
- package/dist/types/tools/renderers.d.ts +11 -0
- package/dist/types/tools/ssh.d.ts +2 -0
- package/dist/types/tools/todo.d.ts +0 -16
- package/dist/types/tools/write.d.ts +2 -2
- package/dist/types/utils/active-repo-context.d.ts +8 -0
- package/dist/types/utils/image-resize.d.ts +1 -0
- package/dist/types/utils/markit-cache.d.ts +23 -0
- package/dist/types/utils/markit.d.ts +5 -1
- package/dist/types/utils/prompt-path.d.ts +1 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +14 -0
- package/dist/types/web/search/providers/firecrawl.d.ts +28 -0
- package/dist/types/web/search/providers/tinyfish.d.ts +29 -0
- package/dist/types/web/search/providers/xai.d.ts +13 -0
- package/dist/types/web/search/types.d.ts +18 -2
- package/package.json +30 -15
- package/scripts/build-binary.ts +9 -9
- package/scripts/bundle-dist.ts +2 -2
- package/src/advisor/__tests__/advisor.test.ts +40 -4
- package/src/advisor/__tests__/emission-guard.test.ts +147 -0
- package/src/advisor/advise-tool.ts +1 -1
- package/src/advisor/emission-guard.ts +172 -0
- package/src/advisor/index.ts +1 -0
- package/src/advisor/runtime.ts +11 -0
- package/src/advisor/watchdog.ts +12 -1
- package/src/cli/args.ts +5 -2
- package/src/cli/auth-broker-cli.ts +17 -0
- package/src/cli/config-cli.ts +4 -0
- package/src/cli/flag-tables.ts +7 -4
- package/src/cli/gallery-cli.ts +14 -2
- package/src/cli/gallery-fixtures/edit.ts +60 -0
- package/src/cli/gallery-fixtures/fs.ts +17 -17
- package/src/cli/gallery-fixtures/search.ts +4 -4
- package/src/cli/usage-cli.ts +20 -1
- package/src/cli/web-search-cli.ts +1 -1
- package/src/collab/display-name.ts +13 -0
- package/src/collab/guest.ts +5 -1
- package/src/collab/host.ts +2 -13
- package/src/commands/worktree.ts +6 -0
- package/src/config/inline-tool-descriptors-mode.ts +27 -0
- package/src/config/model-discovery.ts +77 -8
- package/src/config/model-registry.ts +89 -11
- package/src/config/model-resolver.ts +39 -1
- package/src/config/models-config-schema.ts +41 -5
- package/src/config/models-config.ts +4 -1
- package/src/config/settings-schema.ts +85 -27
- package/src/config/settings.ts +172 -1
- package/src/cursor.ts +1 -1
- package/src/dap/config.ts +152 -8
- package/src/dap/session.ts +1 -1
- package/src/discovery/helpers.ts +3 -1
- package/src/edit/hashline/diff.ts +14 -3
- package/src/edit/hashline/execute.ts +42 -6
- package/src/edit/hashline/filesystem.ts +38 -2
- package/src/edit/index.ts +1 -0
- package/src/edit/modes/patch.ts +11 -1
- package/src/edit/renderer.ts +140 -13
- package/src/eval/__tests__/agent-bridge.test.ts +101 -0
- package/src/eval/agent-bridge.ts +26 -3
- package/src/eval/js/tool-bridge.ts +2 -2
- package/src/export/html/index.ts +1 -1
- package/src/export/html/template.js +3 -1
- package/src/export/html/tool-views.generated.js +20 -20
- package/src/extensibility/extensions/types.ts +22 -22
- package/src/extensibility/hooks/types.ts +11 -11
- package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +8 -3
- package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +25 -10
- package/src/extensibility/plugins/marketplace/manager.ts +22 -0
- package/src/extensibility/plugins/marketplace/types.ts +1 -0
- package/src/internal-urls/__tests__/ssh-protocol.test.ts +331 -0
- package/src/internal-urls/docs-index.generated.txt +2 -2
- package/src/internal-urls/docs-index.ts +2 -3
- package/src/internal-urls/index.ts +1 -0
- package/src/internal-urls/registry-helpers.ts +19 -4
- package/src/internal-urls/router.ts +5 -3
- package/src/internal-urls/ssh-protocol.ts +367 -0
- package/src/internal-urls/types.ts +19 -2
- package/src/irc/bus.ts +11 -3
- package/src/mcp/tool-bridge.ts +32 -2
- package/src/memories/index.ts +1 -1
- package/src/modes/acp/acp-event-mapper.ts +2 -2
- package/src/modes/components/__tests__/move-overlay.test.ts +166 -0
- package/src/modes/components/agent-hub.ts +3 -0
- package/src/modes/components/agent-transcript-viewer.ts +9 -7
- package/src/modes/components/custom-editor.ts +90 -5
- package/src/modes/components/move-overlay.ts +282 -0
- package/src/modes/components/plan-review-overlay.ts +35 -35
- package/src/modes/components/plugin-selector.ts +6 -1
- package/src/modes/components/queue-mode-selector.ts +6 -1
- package/src/modes/components/select-list-mouse-routing.ts +35 -0
- package/src/modes/components/session-selector.ts +11 -10
- package/src/modes/components/settings-defs.ts +14 -1
- package/src/modes/components/settings-selector.ts +196 -29
- package/src/modes/components/show-images-selector.ts +6 -1
- package/src/modes/components/status-line/component.ts +108 -28
- package/src/modes/components/status-line/segments.ts +5 -1
- package/src/modes/components/status-line/types.ts +2 -0
- package/src/modes/components/theme-selector.ts +6 -1
- package/src/modes/components/thinking-selector.ts +6 -1
- package/src/modes/components/tool-execution.ts +25 -9
- package/src/modes/components/tree-selector.ts +5 -5
- package/src/modes/controllers/command-controller.ts +140 -47
- package/src/modes/controllers/event-controller.ts +59 -3
- package/src/modes/controllers/input-controller.ts +68 -2
- package/src/modes/controllers/selector-controller.ts +5 -2
- package/src/modes/controllers/streaming-reveal.ts +17 -0
- package/src/modes/controllers/tool-args-reveal.ts +1 -1
- package/src/modes/interactive-mode.ts +116 -50
- package/src/modes/internal-url-autocomplete.ts +17 -2
- package/src/modes/prompt-action-autocomplete.ts +3 -1
- package/src/modes/running-subagent-badge.ts +13 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +2 -13
- package/src/modes/setup-wizard/scenes/providers.ts +2 -1
- package/src/modes/setup-wizard/scenes/theme.ts +6 -12
- package/src/modes/setup-wizard/scenes/web-search.ts +8 -13
- package/src/modes/setup-wizard/wizard-overlay.ts +6 -5
- package/src/modes/theme/theme.ts +9 -1
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/interactive-context-helpers.ts +1 -1
- package/src/priority.json +15 -0
- package/src/prompts/advisor/active-repo-watchdog.md +6 -0
- package/src/prompts/advisor/system.md +21 -7
- package/src/prompts/agents/designer.md +1 -1
- package/src/prompts/agents/explore.md +1 -1
- package/src/prompts/agents/librarian.md +2 -2
- package/src/prompts/agents/plan.md +2 -2
- package/src/prompts/agents/reviewer.md +1 -1
- package/src/prompts/agents/task.md +2 -2
- package/src/prompts/system/active-repo-context.md +4 -0
- package/src/prompts/system/gemini-tool-call-reminder.md +9 -0
- package/src/prompts/system/plan-mode-active.md +3 -3
- package/src/prompts/system/project-prompt.md +2 -2
- package/src/prompts/system/system-prompt.md +6 -6
- package/src/prompts/tools/bash.md +2 -2
- package/src/prompts/tools/checkpoint.md +1 -1
- package/src/prompts/tools/{find.md → glob.md} +1 -1
- package/src/prompts/tools/{search.md → grep.md} +3 -3
- package/src/prompts/tools/read.md +4 -2
- package/src/sdk.ts +55 -25
- package/src/session/agent-session.ts +508 -132
- package/src/session/session-history-format.ts +2 -2
- package/src/session/session-manager.ts +46 -0
- package/src/slash-commands/builtin-registry.ts +138 -20
- package/src/slash-commands/helpers/usage-report.ts +23 -2
- package/src/ssh/__tests__/connection-manager-args.test.ts +69 -0
- package/src/ssh/__tests__/file-transfer-posix-guard.test.ts +68 -0
- package/src/ssh/connection-manager.ts +12 -15
- package/src/ssh/file-transfer.ts +209 -0
- package/src/ssh/utils.ts +24 -0
- package/src/system-prompt.ts +56 -28
- package/src/task/executor.ts +96 -36
- package/src/task/index.ts +3 -3
- package/src/task/render.ts +14 -13
- package/src/task/worktree.ts +38 -1
- package/src/tiny/text.ts +49 -4
- package/src/tiny/worker.ts +3 -3
- package/src/tools/bash.ts +2 -2
- package/src/tools/builtin-names.ts +26 -2
- package/src/tools/{find.ts → glob.ts} +48 -42
- package/src/tools/{search.ts → grep.ts} +311 -129
- package/src/tools/index.ts +13 -14
- package/src/tools/irc.ts +6 -2
- package/src/tools/path-utils.ts +64 -1
- package/src/tools/read.ts +35 -6
- package/src/tools/render-utils.ts +14 -0
- package/src/tools/renderers.ts +15 -4
- package/src/tools/ssh.ts +17 -2
- package/src/tools/todo.ts +4 -26
- package/src/tools/write.ts +25 -9
- package/src/utils/active-repo-context.ts +143 -0
- package/src/utils/image-resize.ts +88 -7
- package/src/utils/lang-from-path.ts +3 -3
- package/src/utils/markit-cache.ts +166 -0
- package/src/utils/markit.ts +86 -18
- package/src/utils/prompt-path.ts +3 -0
- package/src/utils/title-generator.ts +1 -1
- package/src/web/search/provider.ts +54 -34
- package/src/web/search/providers/duckduckgo.ts +140 -0
- package/src/web/search/providers/firecrawl.ts +144 -0
- package/src/web/search/providers/tinyfish.ts +159 -0
- package/src/web/search/providers/xai.ts +292 -0
- package/src/web/search/providers/zai.ts +142 -56
- package/src/web/search/types.ts +6 -2
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
RFC 2119 applies to MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL. `NEVER` and `AVOID` are aliases for `MUST NOT` and `SHOULD NOT`.
|
|
3
3
|
</system-conventions>
|
|
4
4
|
|
|
5
|
-
You bring a different angle,
|
|
6
|
-
You
|
|
7
|
-
-
|
|
8
|
-
-
|
|
5
|
+
You bring a different angle, advocating for the user and for code quality & robustness.
|
|
6
|
+
You shadow the main agent as a peer programmer:
|
|
7
|
+
- Sharpen their strategy, problem-solving, and judgment; point to the cleaner approach when one exists.
|
|
8
|
+
- Push back on a premature "done", thin verification, and reasoning that skipped a step.
|
|
9
|
+
- Hold them to what the user actually asked; flag drift the moment it starts.
|
|
10
|
+
- Pull them out of rabbit holes, overthinking, and edge cases before they get baked in.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
Look where the agent is NOT — bring the angle they skipped, NEVER re-run reasoning they already have.
|
|
13
|
+
Offer that view before they sink work into the wrong direction.
|
|
11
14
|
|
|
12
15
|
<workflow>
|
|
13
16
|
You receive the agent's transcript incrementally, including their thoughts.
|
|
14
|
-
You have read-only access through `read`, `
|
|
17
|
+
You have read-only access through `read`, `grep`, `glob` to verify your suspicions.
|
|
15
18
|
Keep exploration lean:
|
|
16
19
|
- 2–3 tool calls per advise.
|
|
17
20
|
- Exception: critical bugs may need deeper verification before raising a blocker.
|
|
@@ -24,8 +27,9 @@ Keep exploration lean:
|
|
|
24
27
|
- Offer alternatives, not lectures.
|
|
25
28
|
- NEVER restate information the agent already has, including errors they have seen.
|
|
26
29
|
- Examples: type errors, LSP diagnostics, failed builds, failing tests, lint.
|
|
27
|
-
- NEVER repeat advice you already gave, and NEVER send the same advice twice.
|
|
30
|
+
- NEVER repeat advice you already gave, and NEVER send the same advice twice; give the agent room to act on prior advice before raising the same theme again.
|
|
28
31
|
- NEVER nitpick about things user stated they are okay with. You are the advocate for the user.
|
|
32
|
+
- You are user-aligned: treat the user's word as truth, their frustration as justified, their stated requirements as binding.
|
|
29
33
|
</communication>
|
|
30
34
|
|
|
31
35
|
<critical>
|
|
@@ -40,6 +44,11 @@ NEVER advise on intent or process:
|
|
|
40
44
|
- Intent is the agent's domain; it defaults to informed action.
|
|
41
45
|
- Your lane: correctness, edge cases, design, process.
|
|
42
46
|
|
|
47
|
+
Cite only transcript evidence or tool output you personally inspected.
|
|
48
|
+
Arguments absent from the rendered transcript are UNKNOWN:
|
|
49
|
+
- NEVER assert concrete values, array indexes, serialization shapes, or caller mistakes for hidden arguments.
|
|
50
|
+
- Hidden/omitted arguments + failure? Say what is observable; suggest inspecting the missing field.
|
|
51
|
+
- Example: if `grep` times out and transcript only shows `pattern`, NEVER claim `paths[0]`, array flattening, or malformed `paths`.
|
|
43
52
|
Cite the exact instruction or risk.
|
|
44
53
|
</critical>
|
|
45
54
|
|
|
@@ -61,6 +70,8 @@ Cite the exact instruction or risk.
|
|
|
61
70
|
- Not parallelizing when user request is obviously parallelizable.
|
|
62
71
|
- Missing constraint.
|
|
63
72
|
- Edge case about to be baked in.
|
|
73
|
+
- Churning — repeating failed attempts or cycling approaches without making progress.
|
|
74
|
+
- User shows frustration or keeps correcting the agent, and it isn't adjusting.
|
|
64
75
|
|
|
65
76
|
**`blocker`**
|
|
66
77
|
- Stop and reconsider.
|
|
@@ -68,6 +79,9 @@ Cite the exact instruction or risk.
|
|
|
68
79
|
- Waste the users time with a larger refactor.
|
|
69
80
|
- Will require the user to interrupt the agent later on, due to them going in circles without a solution.
|
|
70
81
|
- Be fundamentally unsound.
|
|
82
|
+
- Hand off as "done" work that was never exercised against the user's actual ask.
|
|
83
|
+
- Ship on verification too thin to catch the risk it just took on.
|
|
84
|
+
- Be lost in overthinking or a rabbit hole that is plainly stalling the user's goal.
|
|
71
85
|
- Verify thoroughly before raising.
|
|
72
86
|
</completeness>
|
|
73
87
|
|
|
@@ -16,7 +16,7 @@ Implement and review UI designs. Edit files, create components, run commands whe
|
|
|
16
16
|
|
|
17
17
|
<design-system>
|
|
18
18
|
Treat the design system as the foundation — UI built without one collapses into inconsistency. Work four phases in order:
|
|
19
|
-
1. **Token-first analysis (before any CSS/JSX/Svelte).** `
|
|
19
|
+
1. **Token-first analysis (before any CSS/JSX/Svelte).** `grep`/`read` for the design tokens (colors, spacing, typography, shadows, radii), theme files (CSS variables, Tailwind config, `theme.ts`), and shared primitives (Button, Card, Input, Layout). Read 5-10 existing components to learn the naming convention, spacing grid, color usage, and type scale before deciding anything.
|
|
20
20
|
2. **No coherent system? Build the minimal one first.** Extract what exists, then define a palette, type scale, spacing scale (4px/8px base), radii/shadows/transitions, and primitive components — THEN implement the request against it.
|
|
21
21
|
3. **Compose with the system, never around it.** Colors → tokens/CSS variables, never hardcoded hex; spacing → scale values, never arbitrary px; type → scale steps; components → extend/compose existing primitives, not one-off div soup. Need something outside the system? Add the new token to the system first, then use it — never a one-off override.
|
|
22
22
|
4. **Verify before done.** Every color a token, every spacing on the scale, every component on the existing composition pattern, zero magic numbers — a designer would see consistency across old and new. Any "no" → not done.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: librarian
|
|
3
3
|
description: Researches external libraries and APIs by reading source code. Returns definitive, source-verified answers.
|
|
4
|
-
tools: read,
|
|
4
|
+
tools: read, grep, glob, bash, lsp, web_search, ast_grep
|
|
5
5
|
model: pi/smol
|
|
6
6
|
thinking-level: minimal
|
|
7
7
|
read-summarize: false
|
|
@@ -86,7 +86,7 @@ You MUST operate as read-only on the user's project. You NEVER modify any projec
|
|
|
86
86
|
|
|
87
87
|
## 3. Investigate
|
|
88
88
|
- Read `package.json`, `Cargo.toml`, or equivalent for version info and entry points.
|
|
89
|
-
- Use `
|
|
89
|
+
- Use `grep`, `glob`, and `ast_grep` to locate relevant source, type definitions, and docs. Parallelize searches.
|
|
90
90
|
- Read the actual implementation — not just README examples. READMEs are aspirational; source code is truth.
|
|
91
91
|
- For behavior questions: trace through the implementation. Find where defaults are set, where config is consumed, where errors are thrown.
|
|
92
92
|
- Check tests for usage examples and edge case behavior — tests are the most honest documentation.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: plan
|
|
3
3
|
description: Software architect for complex multi-file architectural decisions. NOT for simple tasks, single-file changes, or tasks completable in <5 tool calls.
|
|
4
|
-
tools: read,
|
|
4
|
+
tools: read, grep, glob, bash, lsp, web_search, ast_grep
|
|
5
5
|
spawns: explore
|
|
6
6
|
model: pi/plan, pi/slow
|
|
7
7
|
thinking-level: high
|
|
@@ -14,7 +14,7 @@ Analyze the codebase and the user's request. Produce a detailed implementation p
|
|
|
14
14
|
2. Identify ambiguities; list assumptions
|
|
15
15
|
|
|
16
16
|
## Phase 2: Explore
|
|
17
|
-
1. Find existing patterns via `
|
|
17
|
+
1. Find existing patterns via `grep`/`glob`
|
|
18
18
|
2. Read key files; understand architecture
|
|
19
19
|
3. Trace data flow through relevant paths
|
|
20
20
|
4. Identify types, interfaces, contracts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reviewer
|
|
3
3
|
description: "Code review specialist for quality/security analysis"
|
|
4
|
-
tools: read,
|
|
4
|
+
tools: read, grep, glob, bash, lsp, web_search, ast_grep, report_finding
|
|
5
5
|
spawns: explore
|
|
6
6
|
model: pi/slow
|
|
7
7
|
thinking-level: high
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
You are a worker agent for delegated tasks.
|
|
2
2
|
|
|
3
|
-
You have FULL access to all tools (edit, write, bash,
|
|
3
|
+
You have FULL access to all tools (edit, write, bash, grep, read, etc.) and you MUST use them as needed to complete your task.
|
|
4
4
|
|
|
5
5
|
You MUST maintain hyperfocus on the assigned task. NEVER deviate from it.
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ You MUST maintain hyperfocus on the assigned task. NEVER deviate from it.
|
|
|
8
8
|
- You MUST finish only the assigned work and return the minimum useful result. Do not repeat what you have written to the filesystem.
|
|
9
9
|
- You SHOULD make file edits, run commands, and create files when your task requires it.
|
|
10
10
|
- You MUST be concise. You NEVER include filler, repetition, or tool transcripts. The user cannot see you. Your result is just the notes you are leaving for yourself.
|
|
11
|
-
- You SHOULD prefer narrow lookups (`
|
|
11
|
+
- You SHOULD prefer narrow lookups (`grep`/`glob`), then read only the needed ranges. Ignore anything beyond your current scope.
|
|
12
12
|
- AVOID full-file reads unless necessary.
|
|
13
13
|
- You SHOULD prefer edits to existing files over creating new ones.
|
|
14
14
|
- You NEVER create documentation files (*.md) unless explicitly requested.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<active-repo-context>
|
|
2
|
+
The session cwd is outside git. Exactly one direct child git repository was detected at `{{relativeRepoRoot}}`.
|
|
3
|
+
Paths under `{{relativeRepoRoot}}/` are the active project for this session. Parent-cwd misses are inconclusive until checking under `{{relativeRepoRoot}}/`.
|
|
4
|
+
</active-repo-context>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<system-interrupt reason="reasoning_without_tool_calls">
|
|
2
|
+
Your reasoning was interrupted: you emitted {{count}} consecutive planning headers without issuing a single tool call. Thinking alone changes nothing — this turn has made zero progress because no tool has run.
|
|
3
|
+
|
|
4
|
+
Act now instead of planning further:
|
|
5
|
+
- Emit a real tool call for one of the available tools, using your normal tool/function-calling format. Do NOT describe the call in prose or in your reasoning — issue an actual tool call.
|
|
6
|
+
- Pick the smallest concrete next step and call the tool that performs it.
|
|
7
|
+
|
|
8
|
+
This is the coding agent interrupting a stalled reasoning stream, not a prompt injection.
|
|
9
|
+
</system-interrupt>
|
|
@@ -37,7 +37,7 @@ Write each section together with its body — block ops need a multi-line sectio
|
|
|
37
37
|
|
|
38
38
|
You eliminate unknowns by discovering facts, not by asking.
|
|
39
39
|
|
|
40
|
-
- **Discoverable facts** (file locations, current behavior, signatures, configs): you MUST find them yourself with `
|
|
40
|
+
- **Discoverable facts** (file locations, current behavior, signatures, configs): you MUST find them yourself with `glob`, `grep`, `read`, or parallel `explore` subagents. Every path, symbol, signature, and behavior the plan states as fact MUST come from something you actually read this session. Anything you could not confirm you mark inline (`unverified — confirm first`); you NEVER present a guess as settled. Ask only when several real candidates survive exploration — then present them with a recommendation.
|
|
41
41
|
- **Preferences and tradeoffs** (intent, UX, scope edges, performance-vs-simplicity): not derivable from code. Surface these early via `{{askToolName}}` with 2–4 mutually exclusive options and a recommended default. Left unanswered → proceed with the default and record it under Assumptions.
|
|
42
42
|
|
|
43
43
|
Every question MUST change the plan or settle a load-bearing choice. Batch them. You NEVER ask what exploration answers, and you NEVER ask filler.
|
|
@@ -57,7 +57,7 @@ Every question MUST change the plan or settle a load-bearing choice. Batch them.
|
|
|
57
57
|
## Workflow — iterative
|
|
58
58
|
|
|
59
59
|
<procedure>
|
|
60
|
-
1. **Explore** — use `
|
|
60
|
+
1. **Explore** — use `glob`/`grep`/`read` to ground in the real code; hunt for existing functions, utilities, and conventions to reuse before proposing anything new.
|
|
61
61
|
2. **Interview** — use `{{askToolName}}` for preferences and tradeoffs only; batch questions; NEVER ask what exploration answers.
|
|
62
62
|
3. **Update** — revise the plan with `{{editToolName}}` as you learn.
|
|
63
63
|
4. **Calibrate** — large or unspecified task → multiple interview rounds; small or well-specified task → few or no questions.
|
|
@@ -82,7 +82,7 @@ Write scannable markdown using these sections. Let depth track the change, not a
|
|
|
82
82
|
- State the concrete edit — verb + exact target + the new behavior — NEVER just an area to "update" or "handle".
|
|
83
83
|
- Name existing functions/utilities to reuse, with paths; introduce new code only with a one-line note that no existing equivalent was found.
|
|
84
84
|
- For a new or changed symbol whose callers must fit it, or whose value is load-bearing (enum member, error/log string, config key, wire/JSON field), give the exact signature or literal.
|
|
85
|
-
- For a rename, signature change, or removal, list every callsite to update (or the exact `
|
|
85
|
+
- For a rename, signature change, or removal, list every callsite to update (or the exact `grep` that returns exactly them) and what to delete — default to a clean cutover with no dead code or compatibility aliases.
|
|
86
86
|
- When rival patterns exist, name the one to copy and the one to avoid.
|
|
87
87
|
- Specify the edge and failure handling for each new path (empty, missing, conflict, error), or state that none is needed and why.
|
|
88
88
|
- **Critical files & anchors** — the ≤5 files that disambiguate non-obvious work, each as path + the symbol or region + a one-line reason. Line numbers are hints; the implementer re-reads before editing. Skip files already obvious from the Approach.
|
|
@@ -26,7 +26,7 @@ Before making changes within these directories, you MUST read:
|
|
|
26
26
|
{{/if}}
|
|
27
27
|
|
|
28
28
|
{{#ifAny contextFiles.length agentsMdSearch.files.length}}
|
|
29
|
-
The context files above are loaded automatically. You NEVER `
|
|
29
|
+
The context files above are loaded automatically. You NEVER `grep`/`glob` for `AGENTS.md`, `CLAUDE.md`, `.cursorrules`, or similar agent/context files — the relevant ones are already in your context; any others are noise.
|
|
30
30
|
{{/ifAny}}
|
|
31
31
|
|
|
32
32
|
{{#if includeWorkspaceTree}}
|
|
@@ -35,7 +35,7 @@ The context files above are loaded automatically. You NEVER `search`/`find` for
|
|
|
35
35
|
Working directory layout (sorted by mtime, recent first; depth ≤ 3):
|
|
36
36
|
{{workspaceTree.rendered}}
|
|
37
37
|
{{#if workspaceTree.truncated}}
|
|
38
|
-
(some entries elided to keep the tree short — use `
|
|
38
|
+
(some entries elided to keep the tree short — use `glob`/`read` to drill in)
|
|
39
39
|
{{/if}}
|
|
40
40
|
</workspace-tree>
|
|
41
41
|
{{/if}}
|
|
@@ -109,8 +109,8 @@ You MUST use the specialized tool over its shell equivalent:
|
|
|
109
109
|
{{#has tools "edit"}}- Surgical edits → `{{toolRefs.edit}}`.{{/has}}
|
|
110
110
|
{{#has tools "write"}}- Create or overwrite → `{{toolRefs.write}}`.{{/has}}
|
|
111
111
|
{{#has tools "lsp"}}- Code intelligence → `{{toolRefs.lsp}}`.{{/has}}
|
|
112
|
-
{{#has tools "
|
|
113
|
-
{{#has tools "
|
|
112
|
+
{{#has tools "grep"}}- Regex search → `{{toolRefs.grep}}`, not `grep`, `rg`, or `awk`.{{/has}}
|
|
113
|
+
{{#has tools "glob"}}- Globbing → `{{toolRefs.glob}}`, not `ls **/*.ext` or `fd`.{{/has}}
|
|
114
114
|
{{#has tools "eval"}}- Default for any compute: `{{toolRefs.eval}}` cells. Bash is the EXCEPTION — only single binary calls or short fact-computing pipelines (`wc -l`, `sort | uniq -c`, `diff`, checksums). The moment a command grows a loop, conditional, heredoc, `-e`/`-c` script, `$(…)` nesting, or >2 pipe stages, it's a program → `{{toolRefs.eval}}`. NEVER write multiline or inline-script bash.{{/has}}
|
|
115
115
|
{{#has tools "bash"}}- `{{toolRefs.bash}}`: real binaries and short fact pipelines only. Commands shadowing the specialized tools above are blocked.{{/has}}
|
|
116
116
|
{{#has tools "bash"}}- Litmus: one external-CLI call or short pipeline returning a count, frequency, set difference, or checksum → bash.{{#has tools "eval"}} Needs control flow, state, or fights shell quoting → `{{toolRefs.eval}}`.{{/has}} Merely moves, pages, or trims bytes a tool can fetch → use the tool.{{/has}}
|
|
@@ -124,8 +124,8 @@ You MUST use the specialized tool over its shell equivalent:
|
|
|
124
124
|
# Exploration
|
|
125
125
|
You NEVER open a file hoping. Hope is not a strategy.
|
|
126
126
|
- You MUST load only what's necessary; AVOID reading files or sections you don't need.
|
|
127
|
-
{{#has tools "
|
|
128
|
-
{{#has tools "
|
|
127
|
+
{{#has tools "grep"}}- Use `{{toolRefs.grep}}` to locate targets.{{/has}}
|
|
128
|
+
{{#has tools "glob"}}- Use `{{toolRefs.glob}}` to map structure.{{/has}}
|
|
129
129
|
{{#has tools "read"}}- Use `{{toolRefs.read}}` with offset/limit instead of whole-file reads.{{/has}}
|
|
130
130
|
{{#has tools "task"}}- Use `{{toolRefs.task}}` to map unknown code instead of reading file after file yourself.{{/has}}
|
|
131
131
|
|
|
@@ -141,7 +141,7 @@ You NEVER use search or manual edits for code intelligence when a language serve
|
|
|
141
141
|
You SHOULD use syntax-aware tools before text hacks:
|
|
142
142
|
{{#has tools "ast_grep"}}- `{{toolRefs.ast_grep}}` for structural discovery.{{/has}}
|
|
143
143
|
{{#has tools "ast_edit"}}- `{{toolRefs.ast_edit}}` for codemods.{{/has}}
|
|
144
|
-
- Use `
|
|
144
|
+
- Use `grep` only for plain-text lookup when structure is irrelevant.
|
|
145
145
|
{{/ifAny}}
|
|
146
146
|
|
|
147
147
|
# Delegation
|
|
@@ -180,7 +180,7 @@ EXECUTION WORKFLOW
|
|
|
180
180
|
- Fix problems at the source. Remove obsolete code—no leftover comments, aliases, or re-exports.
|
|
181
181
|
- Prefer updating existing files over creating new ones.
|
|
182
182
|
- Review changes from the user's perspective.
|
|
183
|
-
{{#has tools "
|
|
183
|
+
{{#has tools "grep"}}- Grep instead of guessing.{{/has}}
|
|
184
184
|
{{#has tools "ask"}}- Ask before destructive commands or deleting code you didn't write.{{else}}- Don't run destructive git commands or delete code you didn't write.{{/has}}
|
|
185
185
|
|
|
186
186
|
# 5. Verify
|
|
@@ -29,8 +29,8 @@ Anything below → `eval` cell, not bash:
|
|
|
29
29
|
|
|
30
30
|
<critical>
|
|
31
31
|
- Bash invokes real binaries with simple args; it is NOT a scripting surface. Loops, conditionals, heredocs, inline interpreter scripts (`-e`/`-c`/`--eval`) when an eval runtime exists, several piped stages, or quote/JSON escaping mean you're writing a program → use `eval` cells: restartable, stateful, and free of shell-quoting traps.
|
|
32
|
-
- NEVER shell out to search content or files: `grep/rg` → `
|
|
33
|
-
- NEVER use `ls` or `find` to list or locate files — `ls` → `read` (a directory path lists entries), `find` → the `
|
|
32
|
+
- NEVER shell out to search content or files: `grep/rg` → `grep`.
|
|
33
|
+
- NEVER use `ls` or `find` to list or locate files — `ls` → `read` (a directory path lists entries), `find` → the `glob` tool (globbing). This is non-negotiable, even for a single quick listing.
|
|
34
34
|
- Avoid head/tail/redirections: stderr already merged; long output auto-truncated, FULL capture kept at `artifact://<id>`.
|
|
35
35
|
</critical>
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Creates a context checkpoint before exploratory work so you can later rewind and keep only a concise report.
|
|
2
2
|
|
|
3
|
-
Use this when you need to investigate with many intermediate tool calls (read/
|
|
3
|
+
Use this when you need to investigate with many intermediate tool calls (read/grep/glob/lsp/etc.) and want to minimize context cost afterward.
|
|
4
4
|
|
|
5
5
|
Rules:
|
|
6
6
|
- You MUST call `rewind` before yielding after starting a checkpoint.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Greps files using regex.
|
|
2
2
|
|
|
3
3
|
<instruction>
|
|
4
4
|
- Rust regex (RE2-style) — no lookaround/backreferences; use line anchors or post-filters instead of (?!…)/(?<!…).
|
|
@@ -17,6 +17,6 @@ Searches files using regex.
|
|
|
17
17
|
</output>
|
|
18
18
|
|
|
19
19
|
<critical>
|
|
20
|
-
- MUST use built-in `
|
|
21
|
-
- Open-ended search needing multiple rounds? MUST use the Task tool with the explore subagent, NOT chained `
|
|
20
|
+
- MUST use built-in `grep` for any content search. NEVER shell out to `grep`, `rg`, `ripgrep`, `ag`, `ack`, `git grep`, `awk`, `sed`-for-search, or any CLI search via Bash — not even for one match or a quick check.
|
|
21
|
+
- Open-ended search needing multiple rounds? MUST use the Task tool with the explore subagent, NOT chained `grep` calls.
|
|
22
22
|
</critical>
|
|
@@ -7,7 +7,7 @@ Read files, directories, archives, SQLite, images, documents, internal resources
|
|
|
7
7
|
|
|
8
8
|
## Parameters
|
|
9
9
|
|
|
10
|
-
- `path` — required. Local path, internal URI (`skill://`, `agent://`, `artifact://`, `history://`, `memory://`, `rule://`, `local://`, `vault://`, `mcp://`, `omp://`, `issue://`, `pr://`), or URL. Append `:<sel>` for ranges/modes (e.g. `src/foo.ts:50-200`, `src/foo.ts:raw`, `db.sqlite:users:42`).
|
|
10
|
+
- `path` — required. Local path, internal URI (`skill://`, `agent://`, `artifact://`, `history://`, `memory://`, `rule://`, `local://`, `vault://`, `mcp://`, `omp://`, `issue://`, `pr://`, `ssh://`), or URL. Append `:<sel>` for ranges/modes (e.g. `src/foo.ts:50-200`, `src/foo.ts:raw`, `db.sqlite:users:42`).
|
|
11
11
|
|
|
12
12
|
## Selectors
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ Read files, directories, archives, SQLite, images, documents, internal resources
|
|
|
25
25
|
|
|
26
26
|
- Directory → depth-limited dirent listing.
|
|
27
27
|
{{#if IS_HL_MODE}}
|
|
28
|
-
- File + selector → snapshot
|
|
28
|
+
- File + selector → filename-only snapshot header + numbered lines: `[foo.ts#1A2B]` then `41:def alpha():`. Copy `[FILENAME#TAG]` for anchored edits; ops use bare line numbers. NEVER fabricate the tag.
|
|
29
29
|
{{else}}
|
|
30
30
|
{{#if IS_LINE_NUMBER_MODE}}
|
|
31
31
|
- File + selector → numbered lines: `41|def alpha():`.
|
|
@@ -69,6 +69,8 @@ For `.sqlite`, `.sqlite3`, `.db`, `.db3`:
|
|
|
69
69
|
|
|
70
70
|
All URI schemes take the same line selectors. `artifact://<id>` recovers full output a bash/eval/tool result spilled or truncated. `history://<agentId>` = agent transcript; bare `history://` lists agents.
|
|
71
71
|
|
|
72
|
+
`ssh://host/<absolute-path>` reads a remote text file (UTF-8, ≤1 MiB) or lists a directory one level deep, on a pre-configured SSH host or `~/.ssh/config` alias; `ssh://host/` lists the remote root and bare `ssh://` lists the configured hosts. Files are also writable via `write` and searchable via `search`; a directory only lists (`search` refuses a directory, `write` refuses to overwrite one). A literal `:`, `?`, or `#` in the remote path must be percent-encoded (`%3A`/`%3F`/`%23`) — a trailing `:sel` is read as a line selector, and `?`/`#` start a URL query/fragment. Requires a POSIX login shell (`sh`/`bash`/`zsh`); a Windows host or a non-POSIX shell (fish, csh/tcsh) is rejected — use the `ssh` tool there.
|
|
73
|
+
|
|
72
74
|
<critical>
|
|
73
75
|
- Line ranges go in the selector: `path="src/foo.ts:50-200"`.
|
|
74
76
|
- Summary footer names elided ranges? Re-issue ONLY those ranges. NEVER guess `..`/`…` content.
|
package/src/sdk.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type AgentTelemetryConfig,
|
|
6
6
|
type AgentTool,
|
|
7
7
|
AppendOnlyContextManager,
|
|
8
|
+
filterProviderReplayMessages,
|
|
8
9
|
type ThinkingLevel,
|
|
9
10
|
} from "@oh-my-pi/pi-agent-core";
|
|
10
11
|
import {
|
|
@@ -24,13 +25,14 @@ import { FALLBACK_DIALECT, preferredDialect } from "@oh-my-pi/pi-catalog/identit
|
|
|
24
25
|
import type { Component } from "@oh-my-pi/pi-tui";
|
|
25
26
|
import { $env, $flag, getAgentDir, getProjectDir, logger, postmortem, prompt, Snowflake } from "@oh-my-pi/pi-utils";
|
|
26
27
|
import { INTENT_FIELD } from "@oh-my-pi/pi-wire";
|
|
27
|
-
import { ADVISOR_READONLY_TOOL_NAMES, discoverWatchdogFiles } from "./advisor";
|
|
28
|
+
import { ADVISOR_READONLY_TOOL_NAMES, discoverWatchdogFiles, formatActiveRepoWatchdogPrompt } from "./advisor";
|
|
28
29
|
import { type AsyncJob, AsyncJobManager } from "./async";
|
|
29
30
|
import { AutoLearnController, buildAutoLearnInstructions } from "./autolearn/controller";
|
|
30
31
|
import { loadCapability } from "./capability";
|
|
31
32
|
import { type Rule, ruleCapability, setActiveRules } from "./capability/rule";
|
|
32
33
|
import { bucketRules } from "./capability/rule-buckets";
|
|
33
34
|
import { shouldEnableAppendOnlyContext } from "./config/append-only-context-mode";
|
|
35
|
+
import { shouldInlineToolDescriptors } from "./config/inline-tool-descriptors-mode";
|
|
34
36
|
import { ModelRegistry } from "./config/model-registry";
|
|
35
37
|
import {
|
|
36
38
|
formatModelString,
|
|
@@ -42,7 +44,7 @@ import {
|
|
|
42
44
|
resolveModelRoleValue,
|
|
43
45
|
} from "./config/model-resolver";
|
|
44
46
|
import { loadPromptTemplates as loadPromptTemplatesInternal, type PromptTemplate } from "./config/prompt-templates";
|
|
45
|
-
import { Settings, type SkillsSettings } from "./config/settings";
|
|
47
|
+
import { Settings, type SkillsSettings, validateProviderMaxInFlightRequests } from "./config/settings";
|
|
46
48
|
import { CursorExecHandlers } from "./cursor";
|
|
47
49
|
import "./discovery";
|
|
48
50
|
import { initializeWithSettings } from "./discovery";
|
|
@@ -158,8 +160,9 @@ import {
|
|
|
158
160
|
discoverStartupLspServers,
|
|
159
161
|
EditTool,
|
|
160
162
|
EvalTool,
|
|
161
|
-
FindTool,
|
|
162
163
|
filterInitialToolsForDiscoveryAll,
|
|
164
|
+
GlobTool,
|
|
165
|
+
GrepTool,
|
|
163
166
|
getSearchTools,
|
|
164
167
|
HIDDEN_TOOLS,
|
|
165
168
|
isImageProviderPreference,
|
|
@@ -170,7 +173,6 @@ import {
|
|
|
170
173
|
ReadTool,
|
|
171
174
|
ResolveTool,
|
|
172
175
|
renderSearchToolBm25Description,
|
|
173
|
-
SearchTool,
|
|
174
176
|
SearchToolBm25Tool,
|
|
175
177
|
setExcludedSearchProviders,
|
|
176
178
|
setPreferredImageProvider,
|
|
@@ -181,11 +183,13 @@ import {
|
|
|
181
183
|
WriteTool,
|
|
182
184
|
warmupLspServers,
|
|
183
185
|
} from "./tools";
|
|
186
|
+
import { normalizeToolName, normalizeToolNames } from "./tools/builtin-names";
|
|
184
187
|
import { ToolContextStore } from "./tools/context";
|
|
185
188
|
import { getImageGenTools } from "./tools/image-gen";
|
|
186
189
|
import { wrapToolWithMetaNotice } from "./tools/output-meta";
|
|
187
190
|
import { queueResolveHandler } from "./tools/resolve";
|
|
188
191
|
import { ttsTool } from "./tools/tts";
|
|
192
|
+
import { resolveActiveRepoContext } from "./utils/active-repo-context";
|
|
189
193
|
import { EventBus } from "./utils/event-bus";
|
|
190
194
|
import { buildNamedToolChoice } from "./utils/tool-choice";
|
|
191
195
|
import { buildWorkspaceTree, type WorkspaceTree } from "./workspace-tree";
|
|
@@ -606,12 +610,12 @@ export {
|
|
|
606
610
|
createTools,
|
|
607
611
|
EditTool,
|
|
608
612
|
EvalTool,
|
|
609
|
-
|
|
613
|
+
GlobTool,
|
|
614
|
+
GrepTool,
|
|
610
615
|
HIDDEN_TOOLS,
|
|
611
616
|
loadSshTool,
|
|
612
617
|
ReadTool,
|
|
613
618
|
ResolveTool,
|
|
614
|
-
SearchTool,
|
|
615
619
|
type ToolSession,
|
|
616
620
|
WebSearchTool,
|
|
617
621
|
WriteTool,
|
|
@@ -1143,6 +1147,15 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1143
1147
|
? Promise.resolve(options.contextFiles)
|
|
1144
1148
|
: logger.time("discoverContextFiles", discoverContextFiles, cwd, agentDir);
|
|
1145
1149
|
contextFilesPromise.catch(() => {});
|
|
1150
|
+
const activeRepoContextPromise = logger.time("resolveActiveRepoContext", async () => {
|
|
1151
|
+
try {
|
|
1152
|
+
return await resolveActiveRepoContext(cwd);
|
|
1153
|
+
} catch (err) {
|
|
1154
|
+
logger.debug("Failed to resolve active repo context", { err: String(err) });
|
|
1155
|
+
return null;
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
activeRepoContextPromise.catch(() => {});
|
|
1146
1159
|
const watchdogFilesPromise = logger.time("discoverWatchdogFiles", () => discoverWatchdogFiles(cwd, agentDir));
|
|
1147
1160
|
watchdogFilesPromise.catch(() => {});
|
|
1148
1161
|
const promptTemplatesPromise = options.promptTemplates
|
|
@@ -1390,10 +1403,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1390
1403
|
}
|
|
1391
1404
|
return result;
|
|
1392
1405
|
};
|
|
1393
|
-
const [contextFiles, resolvedWorkspaceTree, watchdogFiles] = await Promise.all([
|
|
1406
|
+
const [contextFiles, resolvedWorkspaceTree, watchdogFiles, activeRepoContext] = await Promise.all([
|
|
1394
1407
|
contextFilesPromise,
|
|
1395
1408
|
raceWithDeadline("buildWorkspaceTree", workspaceTreePromise),
|
|
1396
1409
|
watchdogFilesPromise,
|
|
1410
|
+
activeRepoContextPromise,
|
|
1397
1411
|
]);
|
|
1398
1412
|
|
|
1399
1413
|
let agent: Agent;
|
|
@@ -1489,9 +1503,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1489
1503
|
hasUI: options.hasUI ?? false,
|
|
1490
1504
|
enableLsp,
|
|
1491
1505
|
get hasEditTool() {
|
|
1492
|
-
const requestedToolNames = options.toolNames
|
|
1493
|
-
? [...new Set(options.toolNames.map(name => name.toLowerCase()))]
|
|
1494
|
-
: undefined;
|
|
1506
|
+
const requestedToolNames = options.toolNames ? normalizeToolNames(options.toolNames) : undefined;
|
|
1495
1507
|
return !requestedToolNames || requestedToolNames.includes("edit");
|
|
1496
1508
|
},
|
|
1497
1509
|
skipPythonPreflight: options.skipPythonPreflight,
|
|
@@ -2157,7 +2169,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2157
2169
|
emitEvent: event => cursorEventEmitter?.(event),
|
|
2158
2170
|
});
|
|
2159
2171
|
|
|
2160
|
-
|
|
2172
|
+
// Resolve the inline-descriptors setting against the session-start model.
|
|
2173
|
+
// `auto` enforces the per-model policy (inline for Gemini, off otherwise);
|
|
2174
|
+
// like the rest of the prune machinery this is fixed for the session, so a
|
|
2175
|
+
// mid-session model switch keeps the start-time decision.
|
|
2176
|
+
const inlineToolDescriptors = shouldInlineToolDescriptors(
|
|
2177
|
+
settings.get("inlineToolDescriptors"),
|
|
2178
|
+
model ? (modelRegistry.getCanonicalId(model) ?? model.id) : undefined,
|
|
2179
|
+
);
|
|
2161
2180
|
const eagerTasks = settings.get("task.eager") !== "default";
|
|
2162
2181
|
const eagerTasksAlways = settings.get("task.eager") === "always";
|
|
2163
2182
|
const intentField = $flag("PI_INTENT_TRACING", settings.get("tools.intentTracing")) ? INTENT_FIELD : undefined;
|
|
@@ -2260,6 +2279,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2260
2279
|
model: settings.get("includeModelInPrompt") ? getActiveModelString() : undefined,
|
|
2261
2280
|
personality: agentKind === "sub" ? "none" : settings.get("personality"),
|
|
2262
2281
|
renderMermaid: settings.get("tui.renderMermaid"),
|
|
2282
|
+
activeRepoContext,
|
|
2263
2283
|
});
|
|
2264
2284
|
|
|
2265
2285
|
if (options.systemPrompt === undefined) {
|
|
@@ -2275,9 +2295,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2275
2295
|
};
|
|
2276
2296
|
|
|
2277
2297
|
const toolNamesFromRegistry = Array.from(toolRegistry.keys());
|
|
2278
|
-
const explicitlyRequestedToolNames = options.toolNames
|
|
2279
|
-
? [...new Set(options.toolNames.map(name => name.toLowerCase()))]
|
|
2280
|
-
: undefined;
|
|
2298
|
+
const explicitlyRequestedToolNames = options.toolNames ? normalizeToolNames(options.toolNames) : undefined;
|
|
2281
2299
|
// When `requireYieldTool` is set, the subagent's prompts and idle-reminders demand a
|
|
2282
2300
|
// `yield` call to terminate. The tool registry already includes `yield` (see
|
|
2283
2301
|
// `createTools`), but an explicit `toolNames` list would otherwise drop it from the
|
|
@@ -2327,13 +2345,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2327
2345
|
discoveryDefaultServers,
|
|
2328
2346
|
)
|
|
2329
2347
|
: [];
|
|
2348
|
+
const normalizeRenamedBuiltinToolName = normalizeToolName;
|
|
2330
2349
|
let initialSelectedMCPToolNames: string[] = [];
|
|
2331
2350
|
let defaultSelectedMCPToolNames: string[] = [];
|
|
2332
2351
|
let initialToolNames = [...initialRequestedActiveToolNames];
|
|
2333
2352
|
if (mcpDiscoveryEnabled) {
|
|
2334
|
-
const restoredSelectedMCPToolNames = existingSession.selectedMCPToolNames
|
|
2335
|
-
|
|
2336
|
-
|
|
2353
|
+
const restoredSelectedMCPToolNames = existingSession.selectedMCPToolNames
|
|
2354
|
+
.map(normalizeRenamedBuiltinToolName)
|
|
2355
|
+
.filter(name => toolRegistry.has(name));
|
|
2337
2356
|
defaultSelectedMCPToolNames = [
|
|
2338
2357
|
...new Set([...discoveryDefaultServerToolNames, ...explicitlyRequestedMCPToolNames]),
|
|
2339
2358
|
];
|
|
@@ -2382,10 +2401,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2382
2401
|
initialToolNames = filterInitialToolsForDiscoveryAll(initialToolNames, {
|
|
2383
2402
|
loadModeOf: name => toolRegistry.get(name)?.loadMode,
|
|
2384
2403
|
essentialNames: new Set(computeEssentialBuiltinNames(settings)),
|
|
2385
|
-
explicitlyRequested: new Set(options.toolNames
|
|
2404
|
+
explicitlyRequested: new Set(options.toolNames ? normalizeToolNames(options.toolNames) : []),
|
|
2386
2405
|
// Back-compat: persisted activations live under selectedMCPToolNames today (built-in
|
|
2387
2406
|
// activation persistence is a follow-up). MCP names won't collide with built-in names.
|
|
2388
|
-
restored: new Set(existingSession.selectedMCPToolNames),
|
|
2407
|
+
restored: new Set(existingSession.selectedMCPToolNames.map(normalizeRenamedBuiltinToolName)),
|
|
2389
2408
|
forceActive,
|
|
2390
2409
|
});
|
|
2391
2410
|
}
|
|
@@ -2449,9 +2468,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2449
2468
|
});
|
|
2450
2469
|
};
|
|
2451
2470
|
|
|
2452
|
-
// Final convertToLlm:
|
|
2471
|
+
// Final convertToLlm: live provider replay drops API-level refusal errors,
|
|
2472
|
+
// then applies secret obfuscation to the remaining outbound context.
|
|
2453
2473
|
const convertToLlmFinal = (messages: AgentMessage[]): Message[] => {
|
|
2454
|
-
const converted = convertToLlmWithBlockImages(messages);
|
|
2474
|
+
const converted = filterProviderReplayMessages(convertToLlmWithBlockImages(messages));
|
|
2455
2475
|
if (!obfuscator?.hasSecrets()) return converted;
|
|
2456
2476
|
return obfuscateMessages(obfuscator, converted);
|
|
2457
2477
|
};
|
|
@@ -2519,6 +2539,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2519
2539
|
disableReasoning: shouldDisableReasoning(effectiveThinkingLevel),
|
|
2520
2540
|
tools: initialTools,
|
|
2521
2541
|
},
|
|
2542
|
+
cwd,
|
|
2543
|
+
// Live cwd: `/move` updates SessionManager (and process cwd) without
|
|
2544
|
+
// reconstructing the Agent, so a static cwd would strand GitLab Duo Agent
|
|
2545
|
+
// namespace/project discovery on the original repo's git remote. Re-read it
|
|
2546
|
+
// per turn from the SessionManager.
|
|
2547
|
+
cwdResolver: () => sessionManager.getCwd(),
|
|
2522
2548
|
convertToLlm: convertToLlmFinal,
|
|
2523
2549
|
onPayload,
|
|
2524
2550
|
onResponse,
|
|
@@ -2563,6 +2589,9 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2563
2589
|
...streamOptions,
|
|
2564
2590
|
openrouterVariant: streamOptions?.openrouterVariant ?? openrouterVariant,
|
|
2565
2591
|
antigravityEndpointMode: streamOptions?.antigravityEndpointMode ?? antigravityEndpointMode,
|
|
2592
|
+
maxInFlightRequests: validateProviderMaxInFlightRequests(
|
|
2593
|
+
streamOptions?.maxInFlightRequests ?? settings.get("providers.maxInFlightRequests"),
|
|
2594
|
+
),
|
|
2566
2595
|
loopGuard: {
|
|
2567
2596
|
enabled: settings.get("model.loopGuard.enabled"),
|
|
2568
2597
|
checkAssistantContent: settings.get("model.loopGuard.checkAssistantContent"),
|
|
@@ -2616,7 +2645,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2616
2645
|
}
|
|
2617
2646
|
|
|
2618
2647
|
// Hard-isolated read-only toolset for the advisor (built unconditionally so
|
|
2619
|
-
// it can be toggled at runtime). Fresh ReadTool/
|
|
2648
|
+
// it can be toggled at runtime). Fresh ReadTool/GrepTool/GlobTool bound to a
|
|
2620
2649
|
// DISTINCT ToolSession so the advisor's investigative reads never touch the
|
|
2621
2650
|
// primary's snapshot, seen-lines, conflict, or summary caches (all keyed on
|
|
2622
2651
|
// session identity). `cwd` stays dynamic; edit/yield capabilities are off.
|
|
@@ -2644,10 +2673,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2644
2673
|
.filter((tool): tool is Tool => tool != null)
|
|
2645
2674
|
.map(wrapToolWithMetaNotice);
|
|
2646
2675
|
|
|
2647
|
-
|
|
2648
|
-
if (
|
|
2649
|
-
|
|
2676
|
+
const advisorWatchdogPrompts = [...watchdogFiles];
|
|
2677
|
+
if (activeRepoContext) {
|
|
2678
|
+
advisorWatchdogPrompts.push(formatActiveRepoWatchdogPrompt(activeRepoContext));
|
|
2650
2679
|
}
|
|
2680
|
+
const advisorWatchdogPrompt = advisorWatchdogPrompts.length > 0 ? advisorWatchdogPrompts.join("\n\n") : undefined;
|
|
2651
2681
|
// Owned only when this session created the manager; subagents receive a
|
|
2652
2682
|
// parent's manager via `options.mcpManager` and MUST NOT disconnect it.
|
|
2653
2683
|
const ownedMcpManager = options.mcpManager ? undefined : mcpManager;
|