@jx-grxf/patchpilot 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +17 -1
- package/README.md +69 -14
- package/SECURITY.md +7 -1
- package/dist/cli.js +59 -13
- package/dist/cli.js.map +1 -1
- package/dist/core/agent.d.ts +3 -0
- package/dist/core/agent.js +56 -12
- package/dist/core/agent.js.map +1 -1
- package/dist/core/cleanup.d.ts +3 -0
- package/dist/core/cleanup.js +29 -0
- package/dist/core/cleanup.js.map +1 -0
- package/dist/core/doctor.d.ts +4 -1
- package/dist/core/doctor.js +119 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/geminiWrapper.d.ts +51 -0
- package/dist/core/geminiWrapper.js +718 -0
- package/dist/core/geminiWrapper.js.map +1 -0
- package/dist/core/json.js +65 -1
- package/dist/core/json.js.map +1 -1
- package/dist/core/memory.d.ts +16 -0
- package/dist/core/memory.js +108 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/modelClient.js +7 -0
- package/dist/core/modelClient.js.map +1 -1
- package/dist/core/nvidia.js +1 -1
- package/dist/core/nvidia.js.map +1 -1
- package/dist/core/projectInit.d.ts +6 -0
- package/dist/core/projectInit.js +44 -0
- package/dist/core/projectInit.js.map +1 -0
- package/dist/core/reasoning.js +3 -0
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/session.d.ts +1 -0
- package/dist/core/session.js +46 -0
- package/dist/core/session.js.map +1 -1
- package/dist/core/types.d.ts +9 -4
- package/dist/core/workspace.d.ts +8 -0
- package/dist/core/workspace.js +293 -21
- package/dist/core/workspace.js.map +1 -1
- package/dist/tui/App.js +536 -69
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/commands.js +35 -6
- package/dist/tui/commands.js.map +1 -1
- package/dist/tui/components/CommandSuggestions.js +8 -3
- package/dist/tui/components/CommandSuggestions.js.map +1 -1
- package/dist/tui/components/Composer.js +1 -1
- package/dist/tui/components/Composer.js.map +1 -1
- package/dist/tui/components/ExperimentalPanel.d.ts +10 -0
- package/dist/tui/components/ExperimentalPanel.js +33 -0
- package/dist/tui/components/ExperimentalPanel.js.map +1 -0
- package/dist/tui/components/Header.js +3 -3
- package/dist/tui/components/Header.js.map +1 -1
- package/dist/tui/components/OnboardingPanel.d.ts +13 -1
- package/dist/tui/components/OnboardingPanel.js +23 -9
- package/dist/tui/components/OnboardingPanel.js.map +1 -1
- package/dist/tui/components/Sidebar.js +17 -13
- package/dist/tui/components/Sidebar.js.map +1 -1
- package/dist/tui/components/Transcript.js +2 -2
- package/dist/tui/components/Transcript.js.map +1 -1
- package/dist/tui/format.js +7 -7
- package/dist/tui/format.js.map +1 -1
- package/dist/tui/modes.d.ts +1 -1
- package/dist/tui/modes.js +8 -2
- package/dist/tui/modes.js.map +1 -1
- package/docs/gemini-wrapper.md +87 -0
- package/docs/releases/v0.1.1-beta.md +18 -0
- package/docs/releases/v0.2.1.md +1 -1
- package/docs/releases/v0.3.1-beta.md +4 -0
- package/docs/releases/v0.4.0.md +1 -1
- package/docs/releases/v1.0.0.md +28 -0
- package/docs/showcase/patchpilot-banner.png +0 -0
- package/docs/showcase/patchpilot-logo.png +0 -0
- package/package.json +5 -2
package/.env.example
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Provider options: ollama, gemini, openrouter, nvidia, codex.
|
|
1
|
+
# Provider options: ollama, gemini, gemini-wrapper, openrouter, nvidia, codex.
|
|
2
2
|
# codex uses your Codex CLI ChatGPT login. Run: codex login
|
|
3
3
|
PATCHPILOT_PROVIDER=codex
|
|
4
4
|
PATCHPILOT_MODEL=gpt-5.5
|
|
@@ -8,6 +8,22 @@ GEMINI_API_KEY=your_gemini_api_key_here
|
|
|
8
8
|
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
9
9
|
NVIDIA_API_KEY=your_nvidia_api_key_here
|
|
10
10
|
|
|
11
|
+
# Optional: Gemini-Wrapper provider.
|
|
12
|
+
# Default mode uses PatchPilot's managed Python venv for `gemini_webapi`.
|
|
13
|
+
# PatchPilot creates ~/.patchpilot/gemini-wrapper-venv automatically.
|
|
14
|
+
# Onboarding can create ~/.patchpilot/gemini-cookies.json from masked pasted values.
|
|
15
|
+
# PatchPilot never scans browser cookies or web login sessions.
|
|
16
|
+
PATCHPILOT_GEMINI_WRAPPER_MODE=python
|
|
17
|
+
PATCHPILOT_GEMINI_WRAPPER_BOOTSTRAP_PYTHON=python3
|
|
18
|
+
PATCHPILOT_GEMINI_WRAPPER_COOKIES_JSON=/Users/you/.patchpilot/gemini-cookies.json
|
|
19
|
+
PATCHPILOT_GEMINI_WRAPPER_MIN_INTERVAL_MS=1500
|
|
20
|
+
PATCHPILOT_GEMINI_WRAPPER_TIMEOUT_MS=180000
|
|
21
|
+
# Alternative HTTP mode for an explicit OpenAI-compatible wrapper endpoint.
|
|
22
|
+
PATCHPILOT_GEMINI_WRAPPER_BASE_URL=http://localhost:8787/v1
|
|
23
|
+
PATCHPILOT_GEMINI_WRAPPER_API_KEY=your_wrapper_api_key_here
|
|
24
|
+
|
|
11
25
|
# Optional tuning shared by local and API providers.
|
|
12
26
|
PATCHPILOT_NUM_PREDICT=1024
|
|
13
27
|
PATCHPILOT_TEMPERATURE=0.1
|
|
28
|
+
PATCHPILOT_THINKING_MODE=adaptive
|
|
29
|
+
PATCHPILOT_SUBAGENTS=off
|
package/README.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<img src="https://raw.githubusercontent.com/jx-grxf/PatchPilot/main/docs/showcase/patchpilot-logo.png" alt="PatchPilot logo" width="112">
|
|
4
|
+
|
|
3
5
|
# PatchPilot
|
|
4
6
|
|
|
5
7
|
**A local-first coding-agent TUI that makes repo changes visible, permissioned, and easy to review across local, remote, and cloud model routes.**
|
|
6
8
|
|
|
7
9
|
[](https://github.com/jx-grxf/PatchPilot/actions/workflows/ci.yml)
|
|
8
|
-
](https://www.npmjs.com/package/@jx-grxf/patchpilot)
|
|
11
|
+
[](https://www.npmjs.com/package/@jx-grxf/patchpilot)
|
|
12
|
+

|
|
9
13
|

|
|
10
14
|

|
|
11
15
|

|
|
@@ -13,22 +17,29 @@
|
|
|
13
17
|
[](LICENSE)
|
|
14
18
|
|
|
15
19
|
<p>
|
|
16
|
-
<strong>Visible tools.</strong> Explicit permissions. Local Ollama. Remote Ollama. Gemini. OpenRouter. NVIDIA. Codex.
|
|
20
|
+
<strong>Visible tools.</strong> Explicit permissions. Local Ollama. Remote Ollama. Gemini. Gemini-Wrapper. OpenRouter. NVIDIA. Codex.
|
|
17
21
|
</p>
|
|
18
22
|
|
|
19
23
|
</div>
|
|
20
24
|
|
|
21
25
|
---
|
|
22
26
|
|
|
23
|
-
##
|
|
27
|
+
## Product Visual
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<img src="https://raw.githubusercontent.com/jx-grxf/PatchPilot/main/docs/showcase/patchpilot-banner.png" alt="PatchPilot product visual" width="920">
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
## Current TUI Screenshot
|
|
24
34
|
|
|
25
35
|
<p align="center">
|
|
26
36
|
<img src="docs/showcase/patchpilot-showcase.svg" alt="PatchPilot terminal interface overview" width="920">
|
|
27
37
|
</p>
|
|
28
38
|
|
|
29
|
-
PatchPilot is a terminal interface for running coding-agent tasks inside a repository. It shows what the agent is doing, keeps risky actions behind explicit permissions, and supports local Ollama, remote Ollama, Google Gemini, OpenRouter, NVIDIA NIM-compatible endpoints, and Codex CLI OAuth.
|
|
39
|
+
PatchPilot is a terminal interface for running coding-agent tasks inside a repository. It shows what the agent is doing, keeps risky actions behind explicit permissions, and supports local Ollama, remote Ollama, Google Gemini, experimental Gemini Web wrapper routing, OpenRouter, NVIDIA NIM-compatible endpoints, and Codex CLI OAuth.
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
> [!IMPORTANT]
|
|
42
|
+
> PatchPilot v1.0.0 is the first stable CLI release for visible, permissioned coding-agent runs. Experimental provider and memory/file-analysis features remain opt-in.
|
|
32
43
|
|
|
33
44
|
---
|
|
34
45
|
|
|
@@ -36,6 +47,7 @@ PatchPilot is still preview software. The v0.4 line focuses on making the TUI, a
|
|
|
36
47
|
|
|
37
48
|
- [Highlights](#highlights)
|
|
38
49
|
- [Why This Exists](#why-this-exists)
|
|
50
|
+
- [Current Workflow](#current-workflow)
|
|
39
51
|
- [Requirements](#requirements)
|
|
40
52
|
- [Quick Start](#quick-start)
|
|
41
53
|
- [Usage](#usage)
|
|
@@ -55,7 +67,7 @@ PatchPilot is still preview software. The v0.4 line focuses on making the TUI, a
|
|
|
55
67
|
|---|---|
|
|
56
68
|
| Local-first by default | Uses Ollama on your own machine unless you choose another route. |
|
|
57
69
|
| Remote GPU workflow | Connect your laptop TUI to an Ollama host on a desktop, LAN, or Tailscale machine. |
|
|
58
|
-
| Cloud provider routes | Gemini, OpenRouter, NVIDIA, and Codex CLI OAuth are available from one TUI. |
|
|
70
|
+
| Cloud provider routes | Gemini, Gemini-Wrapper, OpenRouter, NVIDIA, and Codex CLI OAuth are available from one TUI. |
|
|
59
71
|
| Guided onboarding | First-run setup walks through local/remote mode, provider auth, host discovery, and model choice. |
|
|
60
72
|
| Observable agent loop | Transcript, tool calls, telemetry, token counts, provider cache hits, latency, and cost estimates are visible. |
|
|
61
73
|
| Explicit permissions | Risky tools show a sticky approval box unless trusted bypass is explicitly accepted. |
|
|
@@ -69,6 +81,8 @@ PatchPilot is still preview software. The v0.4 line focuses on making the TUI, a
|
|
|
69
81
|
|
|
70
82
|
Most local coding-agent experiments fall into one of two traps: they are either raw scripts that feel painful to use, or polished tools that hide too much of what is happening. PatchPilot aims for the middle: a practical TUI where every file read, search, proposed write, command, model route, and token/cost signal stays visible.
|
|
71
83
|
|
|
84
|
+
## Current Workflow
|
|
85
|
+
|
|
72
86
|
The core workflow is intentionally simple:
|
|
73
87
|
|
|
74
88
|
1. Open a repository.
|
|
@@ -86,7 +100,7 @@ Mode behavior is intentionally explicit: `plan` is read-only, `build` keeps writ
|
|
|
86
100
|
| Node.js 22 or newer | Required for the published CLI and source builds. |
|
|
87
101
|
| Git | Required for repository context and normal development workflows. |
|
|
88
102
|
| Ollama | Optional, only needed for local or remote Ollama inference. |
|
|
89
|
-
| Provider API key | Optional, only needed for Gemini, OpenRouter, or NVIDIA routes. |
|
|
103
|
+
| Provider API key | Optional, only needed for Gemini, Gemini-Wrapper remote URLs, OpenRouter, or NVIDIA routes. |
|
|
90
104
|
| Codex CLI login | Optional, only needed for the Codex provider route. |
|
|
91
105
|
|
|
92
106
|
## Quick Start
|
|
@@ -136,6 +150,9 @@ patchpilot "find likely test gaps in this repo"
|
|
|
136
150
|
|
|
137
151
|
Use bypass permissions only when you intentionally want PatchPilot to modify files or run commands without per-tool approval:
|
|
138
152
|
|
|
153
|
+
> [!WARNING]
|
|
154
|
+
> `--apply --allow-shell` bypasses per-tool approval. Use it only in trusted workspaces and review `/diff` before committing.
|
|
155
|
+
|
|
139
156
|
```bash
|
|
140
157
|
patchpilot "add tests for the parser" --apply --allow-shell
|
|
141
158
|
```
|
|
@@ -156,15 +173,16 @@ patchpilot resume [session-id] [--workspace <path>]
|
|
|
156
173
|
| Option | Description |
|
|
157
174
|
|---|---|
|
|
158
175
|
| `--workspace <path>` | Project root the agent may inspect. Defaults to the current directory. |
|
|
159
|
-
| `--provider <name>` | Model provider route. Supports `ollama`, `gemini`/`google`, `openrouter`/`open-router`, `nvidia`/`nim`, and `codex`/`openai`/`openai-codex`. |
|
|
176
|
+
| `--provider <name>` | Model provider route. Supports `ollama`, `gemini`/`google`, `gemini-wrapper`/`geminiwrapper`, `openrouter`/`open-router`, `nvidia`/`nim`, and `codex`/`openai`/`openai-codex`. |
|
|
160
177
|
| `--model <name>` | Model name for the selected provider. |
|
|
161
178
|
| `--ollama-url <url>` | Ollama base URL. Defaults to `http://127.0.0.1:11434`. |
|
|
162
179
|
| `--steps <count>` | Maximum agent loop steps before stopping. |
|
|
163
|
-
| `--thinking <mode>` | Step-budget mode: `fixed` or `adaptive`. |
|
|
180
|
+
| `--thinking <mode>` | Step-budget mode: `fixed` or `adaptive`. Defaults to `adaptive`. |
|
|
164
181
|
| `--reasoning <effort>` | Provider reasoning effort: `none`, `low`, `medium`, `high`, `xhigh`, or `adaptive`. Unsupported provider/model combinations fall back to provider defaults. |
|
|
165
182
|
| `--apply` | Allows file writes inside the workspace. |
|
|
166
183
|
| `--allow-shell` | Allows shell commands inside the workspace. |
|
|
167
|
-
| `--
|
|
184
|
+
| `--subagents` | Enables explorer/planner/reviewer advisor calls. Defaults to off. |
|
|
185
|
+
| `--no-subagents` | Disables explorer/planner/reviewer advisor calls. |
|
|
168
186
|
|
|
169
187
|
Useful slash commands inside the TUI:
|
|
170
188
|
|
|
@@ -180,7 +198,7 @@ Useful slash commands inside the TUI:
|
|
|
180
198
|
| `/write on\|off` | Requests trusted bypass for direct writes, or returns to approval-gated build mode. |
|
|
181
199
|
| `/shell on\|off` | Requests trusted bypass for direct shell commands, or returns to approval-gated build mode. |
|
|
182
200
|
| `/agents on\|off` | Enable or disable advisor subagents. |
|
|
183
|
-
| `/provider ollama\|gemini\|openrouter\|nvidia\|codex` | Switch inference provider. |
|
|
201
|
+
| `/provider ollama\|gemini\|gemini-wrapper\|openrouter\|nvidia\|codex` | Switch inference provider. |
|
|
184
202
|
| `/model <query>` | Search and switch the model for the current provider. |
|
|
185
203
|
| `/models [query\|number]` | Refresh, search, browse, or select provider models. |
|
|
186
204
|
| `/connect` | Scan LAN/Tailscale for reachable Ollama hosts. |
|
|
@@ -188,8 +206,13 @@ Useful slash commands inside the TUI:
|
|
|
188
206
|
| `/eject [model\|all]` | Unload Ollama model(s) from the active host. |
|
|
189
207
|
| `/hosts` | Re-scan reachable Ollama hosts. |
|
|
190
208
|
| `/doctor` | Run provider diagnostics from inside the TUI. |
|
|
209
|
+
| `/doctor fix` | Apply safe doctor repairs, such as installing the managed Gemini-API bridge. |
|
|
210
|
+
| `/cleanup cache\|sessions\|temp\|all` | Clean PatchPilot workspace state. |
|
|
211
|
+
| `/experimental` | Open the experimental checkbox menu; use Space to toggle file-analysis, memory, and subagents. |
|
|
212
|
+
| `/init` | Ask the selected model to inspect the repository and create or update `PATCHPILOT.md`. |
|
|
213
|
+
| `/new` | Start a fresh session and clear current context. |
|
|
191
214
|
| `/sessions` | List recent sessions for the current workspace. |
|
|
192
|
-
| `/resume [session-id]` |
|
|
215
|
+
| `/resume [session-id]` | Resume a previous session and inject its compact summary into the next run. |
|
|
193
216
|
| `/diff` | Show the current Git diff. |
|
|
194
217
|
| `/approve once\|session` | Approve a pending risky tool request. |
|
|
195
218
|
| `/deny` | Deny a pending risky tool request. |
|
|
@@ -198,6 +221,8 @@ Useful slash commands inside the TUI:
|
|
|
198
221
|
|
|
199
222
|
The transcript and sidebar have internal scroll areas. With an empty prompt, use left/right to choose the sidebar or transcript, then Page Up/Page Down and Home/End to navigate long sessions.
|
|
200
223
|
|
|
224
|
+
Experimental file analysis allows `inspect_document` to read supported files outside the workspace after per-path approval when the user provides an absolute path, including PNG/JPEG/WebP/GIF metadata, PDFs, DOCX, Markdown, and text/code files. Experimental memory stores durable workspace notes in `~/.patchpilot/memory.sqlite`; `memory_remember` requires write approval and `memory_search` is read-only.
|
|
225
|
+
|
|
201
226
|
## Providers
|
|
202
227
|
|
|
203
228
|
| Provider route | Accepted values | Default model | Best for | Setup |
|
|
@@ -205,6 +230,7 @@ The transcript and sidebar have internal scroll areas. With an empty prompt, use
|
|
|
205
230
|
| Ollama local | `ollama` | `qwen2.5-coder:7b` | Private local coding work and offline experiments. | Install Ollama, pull a model, run `patchpilot`. |
|
|
206
231
|
| Ollama remote | `ollama` with `--ollama-url` or `/connect` | Host model inventory | Laptop editing with a stronger desktop/server GPU. | Expose Ollama on the host, then use `/connect` or `--ollama-url`. |
|
|
207
232
|
| Google Gemini | `gemini`, `google` | `gemini-2.5-flash` | Fast cloud inference through a Gemini API key. | Store `GEMINI_API_KEY` in `~/.patchpilot/.env` or use onboarding. |
|
|
233
|
+
| Gemini-Wrapper | `gemini-wrapper`, `geminiwrapper` | `auto` | Experimental advanced bridge to the pinned `gemini_webapi` Python wrapper, with optional HTTP-wrapper mode. | Use onboarding to paste `__Secure-1PSID`, then run `/doctor fix` to approve the pinned managed bridge install. PatchPilot creates `~/.patchpilot/gemini-cookies.json`, asks the WebAPI for real available models, and never scans browser cookies. |
|
|
208
234
|
| OpenRouter | `openrouter`, `open-router` | `openrouter/auto` | Broad model routing, auto model selection, and free variants. | Store `OPENROUTER_API_KEY` in `~/.patchpilot/.env` or use onboarding. |
|
|
209
235
|
| NVIDIA | `nvidia`, `nim` | `meta/llama-3.1-70b-instruct` | NVIDIA NIM OpenAI-compatible endpoints. | Store `NVIDIA_API_KEY` in `~/.patchpilot/.env` or use onboarding. |
|
|
210
236
|
| Codex CLI | `codex`, `openai`, `openai-codex` | `gpt-5.5` | Using an existing Codex CLI OAuth login. | Run `codex login`, then `patchpilot --provider codex`. |
|
|
@@ -214,6 +240,7 @@ Examples:
|
|
|
214
240
|
```bash
|
|
215
241
|
patchpilot --provider ollama --model qwen2.5-coder:7b
|
|
216
242
|
patchpilot --provider gemini --model gemini-2.5-flash
|
|
243
|
+
patchpilot --provider gemini-wrapper --model auto
|
|
217
244
|
patchpilot --provider openrouter --model openrouter/auto
|
|
218
245
|
patchpilot --provider nvidia --model meta/llama-3.1-70b-instruct
|
|
219
246
|
patchpilot --provider codex --model gpt-5.5
|
|
@@ -227,6 +254,7 @@ Provider diagnostics:
|
|
|
227
254
|
```bash
|
|
228
255
|
patchpilot doctor --provider ollama
|
|
229
256
|
patchpilot doctor --provider gemini
|
|
257
|
+
patchpilot doctor --provider gemini-wrapper
|
|
230
258
|
patchpilot doctor --provider openrouter
|
|
231
259
|
patchpilot doctor --provider nvidia
|
|
232
260
|
patchpilot doctor --provider codex
|
|
@@ -236,7 +264,33 @@ PatchPilot caches model discovery for a short TTL inside the running TUI, so nor
|
|
|
236
264
|
|
|
237
265
|
PatchPilot reads provider cache telemetry when the provider reports it, for example Codex cached input tokens or OpenRouter `prompt_tokens_details.cached_tokens`, then displays cache hit rate as `cached / input`.
|
|
238
266
|
|
|
239
|
-
Reasoning support is provider and model dependent. Codex accepts fixed reasoning levels. OpenRouter receives `reasoning.effort` only for models whose metadata advertises reasoning support. Gemini uses Thinking configuration where the selected model exposes it; some Gemini models cannot disable thinking. Ollama only receives native `think` values for known thinking model families. NVIDIA reasoning effort is limited to supported GPT-OSS NIM routes.
|
|
267
|
+
Reasoning support is provider and model dependent. Codex accepts fixed reasoning levels. OpenRouter receives `reasoning.effort` only for models whose metadata advertises reasoning support. Gemini uses Thinking configuration where the selected model exposes it; some Gemini models cannot disable thinking. Gemini-Wrapper stays on wrapper defaults because wrapper compatibility varies. Ollama only receives native `think` values for known thinking model families. NVIDIA reasoning effort is limited to supported GPT-OSS NIM routes.
|
|
268
|
+
|
|
269
|
+
Gemini-Wrapper is intentionally explicit and unofficial. In default `python` bridge mode, PatchPilot creates a managed Python venv and installs the pinned wrapper there only after `/doctor fix` or `patchpilot doctor --fix` approval:
|
|
270
|
+
|
|
271
|
+
> [!CAUTION]
|
|
272
|
+
> `__Secure-1PSID` acts like a Google session token. Never paste it into issues, logs, chats, or commits.
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
~/.patchpilot/gemini-wrapper-venv
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
This avoids Homebrew Python's externally-managed-environment / PEP 668 block. Then PatchPilot runs the bridge command itself for model discovery and chat requests. Use `/onboarding`, choose Gemini-Wrapper, paste `__Secure-1PSID`, and optionally paste `__Secure-1PSIDTS`. PatchPilot writes `~/.patchpilot/gemini-cookies.json` with owner-only permissions and stores the file path in `~/.patchpilot/.env`.
|
|
279
|
+
|
|
280
|
+
```sh
|
|
281
|
+
PATCHPILOT_PROVIDER=gemini-wrapper
|
|
282
|
+
PATCHPILOT_MODEL=auto
|
|
283
|
+
PATCHPILOT_GEMINI_WRAPPER_MODE=python
|
|
284
|
+
PATCHPILOT_GEMINI_WRAPPER_COOKIES_JSON=/Users/you/.patchpilot/gemini-cookies.json
|
|
285
|
+
PATCHPILOT_GEMINI_WRAPPER_MIN_INTERVAL_MS=1500
|
|
286
|
+
PATCHPILOT_GEMINI_WRAPPER_TIMEOUT_MS=180000
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The cookie JSON must contain `__Secure-1PSID`; `__Secure-1PSIDTS` is optional for some accounts. If the optional timestamp expires, PatchPilot retries once without it. Transient WebAPI network timeouts are retried inside the bridge. `auto` lets Gemini Web pick its default model and avoids relying on brittle Web model headers. Env alternatives are `GEMINI_SECURE_1PSID` and `GEMINI_SECURE_1PSIDTS`. See [docs/gemini-wrapper.md](docs/gemini-wrapper.md) for the exact setup steps.
|
|
290
|
+
|
|
291
|
+
PatchPilot also sets `GEMINI_COOKIE_PATH` to `~/.patchpilot/gemini-webapi-cache` for the Python process so refreshed wrapper cookies stay in a local owner-only cache instead of a temporary directory.
|
|
292
|
+
|
|
293
|
+
PatchPilot does not inspect Chrome, Safari, Firefox, Arc, Edge, Brave, Keychain, or browser cookie stores, and it does not reuse Google web-login sessions automatically. Advanced users can still set `PATCHPILOT_GEMINI_WRAPPER_MODE=http` plus `PATCHPILOT_GEMINI_WRAPPER_BASE_URL` for an explicit OpenAI-compatible `/v1` endpoint.
|
|
240
294
|
|
|
241
295
|
OpenRouter `:free` models are rate-limited by OpenRouter. PatchPilot warns when a selected model ID ends in `:free`, and OpenRouter credit or rate-limit failures are surfaced as explicit provider errors.
|
|
242
296
|
|
|
@@ -313,7 +367,7 @@ PatchPilot now has sticky approval prompts and a Git diff command, but it still
|
|
|
313
367
|
| TUI | Ink, React, ink-text-input |
|
|
314
368
|
| Agent protocol | JSON command envelope validated with Zod |
|
|
315
369
|
| Sessions | Append-only JSONL in `.patchpilot/sessions` plus global index in `~/.patchpilot` |
|
|
316
|
-
| Providers | Ollama chat API, Gemini generateContent API, OpenRouter OpenAI-compatible API, NVIDIA OpenAI-compatible API, Codex CLI OAuth backend |
|
|
370
|
+
| Providers | Ollama chat API, Gemini generateContent API, Gemini-Wrapper OpenAI-compatible API, OpenRouter OpenAI-compatible API, NVIDIA OpenAI-compatible API, Codex CLI OAuth backend |
|
|
317
371
|
| Tests | Vitest |
|
|
318
372
|
| CI | GitHub Actions |
|
|
319
373
|
|
|
@@ -355,6 +409,7 @@ Release notes are kept in [docs/releases](docs/releases).
|
|
|
355
409
|
|
|
356
410
|
| Version | Notes |
|
|
357
411
|
|---|---|
|
|
412
|
+
| `v1.0.0` | [Release notes](docs/releases/v1.0.0.md) |
|
|
358
413
|
| `v0.4.0` | [Release notes](docs/releases/v0.4.0.md) |
|
|
359
414
|
| `v0.3.1-beta` | [Release notes](docs/releases/v0.3.1-beta.md) |
|
|
360
415
|
| `v0.3.0` | [Release notes](docs/releases/v0.3.0.md) |
|
package/SECURITY.md
CHANGED
|
@@ -6,7 +6,11 @@ PatchPilot is public preview software. Security fixes target the latest publishe
|
|
|
6
6
|
|
|
7
7
|
## Reporting a Vulnerability
|
|
8
8
|
|
|
9
|
-
Please report security issues through GitHub Security Advisories
|
|
9
|
+
Please report security issues through GitHub Security Advisories:
|
|
10
|
+
|
|
11
|
+
https://github.com/jx-grxf/PatchPilot/security/advisories/new
|
|
12
|
+
|
|
13
|
+
Include:
|
|
10
14
|
|
|
11
15
|
- affected version or commit
|
|
12
16
|
- reproduction steps
|
|
@@ -20,3 +24,5 @@ Do not open a public issue for a vulnerability before the maintainer has had tim
|
|
|
20
24
|
PatchPilot keeps file tools inside one workspace root, blocks common secret files and credential-like extensions, and requires approval or explicit trusted bypass for writes and shell commands. Package-script approvals include the resolved script body because scripts can hide publish, push, or destructive commands.
|
|
21
25
|
|
|
22
26
|
Session logs are stored in `.patchpilot/sessions/` under the workspace and summarized in `~/.patchpilot/session-index.json`. Treat those logs as local project metadata: they may contain prompts, tool names, summaries, and clipped command output. Do not use cloud providers or trusted bypass in repositories containing secrets you do not want processed by external model providers.
|
|
27
|
+
|
|
28
|
+
Gemini-Wrapper support runs either the installed `gemini_webapi` Python package with an explicit cookie source or an explicit OpenAI-compatible URL from `PATCHPILOT_GEMINI_WRAPPER_BASE_URL`. PatchPilot must not scan browser profiles, cookies, Keychain items, or Google web-login sessions for provider auth.
|
package/dist/cli.js
CHANGED
|
@@ -5,11 +5,14 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
import { render } from "ink";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { defaultCodexModel } from "./core/codex.js";
|
|
8
|
+
import { cleanupPatchPilot, readCleanupTarget } from "./core/cleanup.js";
|
|
8
9
|
import { loadPatchPilotEnv } from "./core/env.js";
|
|
9
10
|
import { defaultGeminiModel } from "./core/gemini.js";
|
|
11
|
+
import { defaultGeminiWrapperModel } from "./core/geminiWrapper.js";
|
|
10
12
|
import { normalizeModelProvider, readModelProvider } from "./core/modelClient.js";
|
|
11
13
|
import { defaultNvidiaModel } from "./core/nvidia.js";
|
|
12
14
|
import { runDoctor } from "./core/doctor.js";
|
|
15
|
+
import { ensurePatchPilotInstructions } from "./core/projectInit.js";
|
|
13
16
|
import { defaultOllamaModel, resolveOllamaBaseUrl } from "./core/ollama.js";
|
|
14
17
|
import { defaultOpenRouterModel } from "./core/openrouter.js";
|
|
15
18
|
import { listIndexedSessions, listWorkspaceSessions, loadSessionSummary } from "./core/session.js";
|
|
@@ -20,32 +23,61 @@ const defaultProvider = readModelProvider();
|
|
|
20
23
|
const defaultModel = process.env.PATCHPILOT_MODEL ??
|
|
21
24
|
(defaultProvider === "gemini"
|
|
22
25
|
? defaultGeminiModel
|
|
23
|
-
: defaultProvider === "
|
|
24
|
-
?
|
|
25
|
-
: defaultProvider === "
|
|
26
|
-
?
|
|
27
|
-
: defaultProvider === "
|
|
28
|
-
?
|
|
29
|
-
:
|
|
26
|
+
: defaultProvider === "gemini-wrapper"
|
|
27
|
+
? defaultGeminiWrapperModel
|
|
28
|
+
: defaultProvider === "openrouter"
|
|
29
|
+
? defaultOpenRouterModel
|
|
30
|
+
: defaultProvider === "nvidia"
|
|
31
|
+
? defaultNvidiaModel
|
|
32
|
+
: defaultProvider === "codex"
|
|
33
|
+
? defaultCodexModel
|
|
34
|
+
: defaultOllamaModel);
|
|
30
35
|
const program = new Command();
|
|
31
36
|
program.enablePositionalOptions();
|
|
32
37
|
program
|
|
33
38
|
.name("patchpilot")
|
|
34
39
|
.description("Local-first coding agent TUI powered by Ollama and OpenAI-compatible providers.")
|
|
35
40
|
.version(readPackageVersion());
|
|
41
|
+
program
|
|
42
|
+
.command("init")
|
|
43
|
+
.description("Create PATCHPILOT.md workspace instructions.")
|
|
44
|
+
.option("--workspace <path>", "Workspace root", process.cwd())
|
|
45
|
+
.action(async (options) => {
|
|
46
|
+
const result = await ensurePatchPilotInstructions(path.resolve(options.workspace));
|
|
47
|
+
console.log(`${result.created ? "created" : "exists"} ${result.path}`);
|
|
48
|
+
});
|
|
49
|
+
program
|
|
50
|
+
.command("cleanup")
|
|
51
|
+
.description("Clean PatchPilot workspace cache, sessions, temp files, or all.")
|
|
52
|
+
.argument("[target]", "cache, sessions, temp, or all", "cache")
|
|
53
|
+
.option("--workspace <path>", "Workspace root", process.cwd())
|
|
54
|
+
.action(async (target, options) => {
|
|
55
|
+
const cleanupTarget = readCleanupTarget(target);
|
|
56
|
+
if (!cleanupTarget) {
|
|
57
|
+
console.error("Use one of: cache, sessions, temp, all");
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const removed = await cleanupPatchPilot(path.resolve(options.workspace), cleanupTarget);
|
|
62
|
+
console.log(`cleaned ${removed.join(", ") || cleanupTarget}`);
|
|
63
|
+
});
|
|
36
64
|
program
|
|
37
65
|
.command("doctor")
|
|
38
66
|
.description("Check local PatchPilot requirements.")
|
|
39
|
-
.option("--provider <name>", "Model provider: ollama, gemini, openrouter, nvidia, or codex.", defaultProvider)
|
|
67
|
+
.option("--provider <name>", "Model provider: ollama, gemini, gemini-wrapper, openrouter, nvidia, or codex.", defaultProvider)
|
|
40
68
|
.option("--check-url <url>", "Ollama base URL to verify", defaultOllamaUrl)
|
|
41
69
|
.option("--ollama-url <url>", "Alias for --check-url.")
|
|
42
70
|
.option("--check-model <name>", "Model name to verify", defaultModel)
|
|
43
71
|
.option("--model <name>", "Alias for --check-model.")
|
|
72
|
+
.option("--fix", "Apply safe doctor fixes, such as installing the managed Gemini-API bridge.", false)
|
|
44
73
|
.action(async (options) => {
|
|
45
|
-
const results = await runDoctor(normalizeModelProvider(options.provider), options.ollamaUrl ?? options.checkUrl, options.model ?? options.checkModel
|
|
74
|
+
const results = await runDoctor(normalizeModelProvider(options.provider), options.ollamaUrl ?? options.checkUrl, options.model ?? options.checkModel, {
|
|
75
|
+
fix: Boolean(options.fix)
|
|
76
|
+
});
|
|
46
77
|
for (const result of results) {
|
|
47
78
|
const marker = result.ok ? "ok" : "fail";
|
|
48
|
-
|
|
79
|
+
const action = result.action ? ` ${result.action}` : "";
|
|
80
|
+
console.log(`${marker.padEnd(5)} ${result.name}${action}: ${result.details}`);
|
|
49
81
|
}
|
|
50
82
|
process.exitCode = results.every((result) => result.ok) ? 0 : 1;
|
|
51
83
|
});
|
|
@@ -86,19 +118,20 @@ program
|
|
|
86
118
|
program
|
|
87
119
|
.argument("[task...]", "Task for the local coding agent.")
|
|
88
120
|
.option("--workspace <path>", "Workspace root", process.cwd())
|
|
89
|
-
.option("--provider <name>", "Model provider: ollama, gemini, openrouter, nvidia, or codex.", defaultProvider)
|
|
121
|
+
.option("--provider <name>", "Model provider: ollama, gemini, gemini-wrapper, openrouter, nvidia, or codex.", defaultProvider)
|
|
90
122
|
.option("--model <name>", "Model name", defaultModel)
|
|
91
123
|
.option("--ollama-url <url>", "Ollama base URL", defaultOllamaUrl)
|
|
92
124
|
.option("--steps <count>", "Maximum agent steps", "8")
|
|
93
|
-
.option("--thinking <mode>", "Thinking budget mode: fixed or adaptive.", process.env.PATCHPILOT_THINKING_MODE ?? "
|
|
125
|
+
.option("--thinking <mode>", "Thinking budget mode: fixed or adaptive.", process.env.PATCHPILOT_THINKING_MODE ?? "adaptive")
|
|
94
126
|
.option("--reasoning <effort>", "Provider reasoning effort: none, low, medium, high, xhigh, or adaptive.", process.env.PATCHPILOT_REASONING_EFFORT ?? "medium")
|
|
95
127
|
.option("--apply", "Allow file writes inside the workspace.", false)
|
|
96
128
|
.option("--allow-shell", "Allow shell commands inside the workspace.", false)
|
|
129
|
+
.option("--subagents", "Enable planner and reviewer subagents.", readBooleanEnv(process.env.PATCHPILOT_SUBAGENTS, false))
|
|
97
130
|
.option("--no-subagents", "Disable planner and reviewer subagents for faster local runs.")
|
|
98
131
|
.action((taskParts, options) => {
|
|
99
132
|
const workspace = path.resolve(String(options.workspace));
|
|
100
133
|
const maxSteps = Number.parseInt(String(options.steps), 10);
|
|
101
|
-
render(_jsx(App, { initialTask: taskParts.join(" ").trim() || undefined, provider: readModelProvider({ PATCHPILOT_PROVIDER: String(options.provider) }), model: String(options.model), ollamaUrl: String(options.ollamaUrl), workspace: workspace, allowWrite: Boolean(options.apply), allowShell: Boolean(options.allowShell), maxSteps: Number.isFinite(maxSteps) ? maxSteps : 8, thinkingMode: String(options.thinking) === "adaptive" ? "adaptive" : "fixed", reasoningEffort: readReasoningEffort(String(options.reasoning)), subagents: options.subagents
|
|
134
|
+
render(_jsx(App, { initialTask: taskParts.join(" ").trim() || undefined, provider: readModelProvider({ PATCHPILOT_PROVIDER: String(options.provider) }), model: String(options.model), ollamaUrl: String(options.ollamaUrl), workspace: workspace, allowWrite: Boolean(options.apply), allowShell: Boolean(options.allowShell), maxSteps: Number.isFinite(maxSteps) ? maxSteps : 8, thinkingMode: String(options.thinking) === "adaptive" ? "adaptive" : "fixed", reasoningEffort: readReasoningEffort(String(options.reasoning)), subagents: Boolean(options.subagents) }));
|
|
102
135
|
});
|
|
103
136
|
await program.parseAsync(process.argv);
|
|
104
137
|
function readReasoningEffort(value) {
|
|
@@ -108,6 +141,19 @@ function readReasoningEffort(value) {
|
|
|
108
141
|
? value
|
|
109
142
|
: "medium";
|
|
110
143
|
}
|
|
144
|
+
function readBooleanEnv(value, fallback) {
|
|
145
|
+
if (!value) {
|
|
146
|
+
return fallback;
|
|
147
|
+
}
|
|
148
|
+
const normalized = value.trim().toLowerCase();
|
|
149
|
+
if (["1", "true", "yes", "on"].includes(normalized)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (["0", "false", "no", "off"].includes(normalized)) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
return fallback;
|
|
156
|
+
}
|
|
111
157
|
function readPackageVersion() {
|
|
112
158
|
try {
|
|
113
159
|
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAA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AAW,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
package/dist/core/agent.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export type AgentRunnerOptions = {
|
|
|
12
12
|
thinkingMode: "fixed" | "adaptive";
|
|
13
13
|
reasoningEffort: ProviderReasoningEffort | "adaptive";
|
|
14
14
|
subagents: boolean;
|
|
15
|
+
resumeContext?: string;
|
|
16
|
+
allowExternalFileAnalysis?: boolean;
|
|
17
|
+
memoryEnabled?: boolean;
|
|
15
18
|
signal?: AbortSignal;
|
|
16
19
|
sessionStore?: SessionStore;
|
|
17
20
|
approvalHandler?: (request: ApprovalRequest) => Promise<PermissionDecision>;
|
package/dist/core/agent.js
CHANGED
|
@@ -20,6 +20,8 @@ export class AgentRunner {
|
|
|
20
20
|
root: options.workspace,
|
|
21
21
|
allowWrite: options.allowWrite,
|
|
22
22
|
allowShell: options.allowShell,
|
|
23
|
+
allowExternalFileAnalysis: options.allowExternalFileAnalysis,
|
|
24
|
+
memoryEnabled: options.memoryEnabled,
|
|
23
25
|
signal: options.signal,
|
|
24
26
|
approvalHandler: options.approvalHandler
|
|
25
27
|
});
|
|
@@ -71,11 +73,14 @@ export class AgentRunner {
|
|
|
71
73
|
const messages = [
|
|
72
74
|
{
|
|
73
75
|
role: "system",
|
|
74
|
-
content: buildSystemPrompt(this.tools.root, subagentContext, workspaceSummary, {
|
|
76
|
+
content: buildSystemPrompt(this.tools.root, subagentContext, workspaceSummary, this.options.resumeContext ?? "", {
|
|
75
77
|
mode: this.options.mode ?? (this.options.allowWrite || this.options.allowShell ? "bypass" : "plan"),
|
|
76
78
|
allowWrite: this.options.allowWrite,
|
|
77
79
|
allowShell: this.options.allowShell,
|
|
78
80
|
hasApprovalHandler: Boolean(this.options.approvalHandler)
|
|
81
|
+
}, {
|
|
82
|
+
allowExternalFileAnalysis: Boolean(this.options.allowExternalFileAnalysis),
|
|
83
|
+
memoryEnabled: Boolean(this.options.memoryEnabled)
|
|
79
84
|
})
|
|
80
85
|
},
|
|
81
86
|
{
|
|
@@ -107,13 +112,26 @@ export class AgentRunner {
|
|
|
107
112
|
step: stepIndex + 1,
|
|
108
113
|
createdAt: new Date().toISOString()
|
|
109
114
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
let modelResponse;
|
|
116
|
+
try {
|
|
117
|
+
modelResponse = await this.client.chat({
|
|
118
|
+
model: this.options.model,
|
|
119
|
+
messages,
|
|
120
|
+
formatJson: true,
|
|
121
|
+
reasoningEffort,
|
|
122
|
+
signal: this.options.signal
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
+
await this.options.sessionStore?.append({
|
|
128
|
+
type: "run.failed",
|
|
129
|
+
runId,
|
|
130
|
+
message,
|
|
131
|
+
failedAt: new Date().toISOString()
|
|
132
|
+
});
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
117
135
|
const rawResponse = modelResponse.content;
|
|
118
136
|
yield {
|
|
119
137
|
type: "metrics",
|
|
@@ -133,7 +151,7 @@ export class AgentRunner {
|
|
|
133
151
|
};
|
|
134
152
|
messages.push({
|
|
135
153
|
role: "assistant",
|
|
136
|
-
content: rawResponse
|
|
154
|
+
content: clipPromptValue(rawResponse, 2000)
|
|
137
155
|
});
|
|
138
156
|
messages.push({
|
|
139
157
|
role: "user",
|
|
@@ -293,7 +311,7 @@ function shouldUseSubagents(task) {
|
|
|
293
311
|
}
|
|
294
312
|
return /\b(repo|repository|projekt|project|code|file|datei|test|build|fix|debug|implement|refactor|review|analyze|analyse|analysiere|prüf|pruef|bewerte|architektur|erklär|erklaer|such|find|install|commit|diff|patch|src|readme|sprache|programmiersprache|stack|framework|dependencies|abhängigkeiten|abhaengigkeiten|typescript|javascript|node|swift|python|c)\b/.test(normalizedTask);
|
|
295
313
|
}
|
|
296
|
-
function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, permissions) {
|
|
314
|
+
function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, resumeContext, permissions, experimental) {
|
|
297
315
|
const workspaceLabel = path.basename(workspaceRoot) || "workspace";
|
|
298
316
|
const writePolicy = permissions.allowWrite
|
|
299
317
|
? "write tools bypass approval for this run"
|
|
@@ -305,6 +323,9 @@ function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, per
|
|
|
305
323
|
: permissions.hasApprovalHandler && permissions.mode === "build"
|
|
306
324
|
? "shell and test tools require interactive approval"
|
|
307
325
|
: "shell and test tools are unavailable";
|
|
326
|
+
const bypassPolicy = permissions.allowWrite && permissions.allowShell
|
|
327
|
+
? "Build+bypass mode may run write, script, test, or shell tools without per-tool approval. Keep actions narrow and avoid broad destructive commands."
|
|
328
|
+
: "Only explicitly enabled permission groups bypass approval. Unavailable tool groups stay blocked.";
|
|
308
329
|
return [
|
|
309
330
|
"You are PatchPilot, a local coding agent running inside a terminal TUI.",
|
|
310
331
|
"You help inspect, edit, test, and explain code inside one workspace.",
|
|
@@ -316,7 +337,7 @@ function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, per
|
|
|
316
337
|
permissions.mode === "plan"
|
|
317
338
|
? "Plan mode is read-only: inspect files, explain findings, and return an implementation plan. Do not call write_file, apply_patch, run_script, run_tests, or run_shell."
|
|
318
339
|
: permissions.mode === "bypass"
|
|
319
|
-
?
|
|
340
|
+
? bypassPolicy
|
|
320
341
|
: "Build mode may request write, script, test, or shell tools when necessary. Prefer focused tool calls and keep risky actions easy to approve.",
|
|
321
342
|
`All tool paths are relative to the workspace root. If the workspace is named "${workspaceLabel}", do not prefix paths with "${workspaceLabel}/". Use "." for the workspace root.`,
|
|
322
343
|
"Treat short questions about this project, its language, stack, quality, architecture, dependencies, tests, or files as workspace questions.",
|
|
@@ -328,7 +349,22 @@ function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, per
|
|
|
328
349
|
"For repository summaries, inspect README.md, package.json, tests, docs, and top-level source files before answering.",
|
|
329
350
|
"For implementation tasks, first inspect the narrowest relevant files, then edit only what is needed.",
|
|
330
351
|
"When diagnosing a failure, form a concrete hypothesis, gather targeted evidence with tools, then fix the smallest cause.",
|
|
352
|
+
experimental.allowExternalFileAnalysis
|
|
353
|
+
? "Experimental file analysis is enabled: inspect_document may inspect supported absolute paths outside the workspace when the user provides them."
|
|
354
|
+
: "Experimental file analysis is disabled: inspect_document is limited to the workspace.",
|
|
355
|
+
experimental.memoryEnabled
|
|
356
|
+
? "Experimental memory is enabled: use memory_search for relevant durable context and memory_remember when the user asks you to remember something or states durable project guidance."
|
|
357
|
+
: "Experimental memory is disabled.",
|
|
331
358
|
workspaceSummary ? ["", "Workspace context:", workspaceSummary].join("\n") : "",
|
|
359
|
+
resumeContext
|
|
360
|
+
? [
|
|
361
|
+
"",
|
|
362
|
+
"Resumed session context:",
|
|
363
|
+
resumeContext,
|
|
364
|
+
"",
|
|
365
|
+
"Use this as compact historical context. Re-read files before making claims about current workspace contents."
|
|
366
|
+
].join("\n")
|
|
367
|
+
: "",
|
|
332
368
|
subagentContext
|
|
333
369
|
? [
|
|
334
370
|
"",
|
|
@@ -355,6 +391,12 @@ function buildSystemPrompt(workspaceRoot, subagentContext, workspaceSummary, per
|
|
|
355
391
|
"- file_info: {\"path\":\"src/index.ts\"}",
|
|
356
392
|
"- search_text: {\"query\":\"functionName\"}",
|
|
357
393
|
"- inspect_document: {\"path\":\"docs/spec.pdf\"} for pdf, docx, and text/code files",
|
|
394
|
+
...(experimental.memoryEnabled
|
|
395
|
+
? [
|
|
396
|
+
"- memory_search: {\"query\":\"provider setup\",\"limit\":5}",
|
|
397
|
+
"- memory_remember: {\"content\":\"durable note\",\"tags\":[\"project\"]}"
|
|
398
|
+
]
|
|
399
|
+
: []),
|
|
358
400
|
"- git_status: {} for current branch and dirty files",
|
|
359
401
|
"- git_diff: {\"path\":\"src/index.ts\"} or {} for all current changes",
|
|
360
402
|
"- list_changed_files: {}",
|
|
@@ -454,12 +496,14 @@ function createToolCallId(tool) {
|
|
|
454
496
|
return `${tool}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
455
497
|
}
|
|
456
498
|
async function buildWorkspaceSummary(workspaceRoot) {
|
|
457
|
-
const [packageJson, tsconfig, readme] = await Promise.all([
|
|
499
|
+
const [patchPilotInstructions, packageJson, tsconfig, readme] = await Promise.all([
|
|
500
|
+
readWorkspaceFile(workspaceRoot, "PATCHPILOT.md", 4000),
|
|
458
501
|
readWorkspaceFile(workspaceRoot, "package.json", 4000),
|
|
459
502
|
readWorkspaceFile(workspaceRoot, "tsconfig.json", 1600),
|
|
460
503
|
readWorkspaceFile(workspaceRoot, "README.md", 3000)
|
|
461
504
|
]);
|
|
462
505
|
return [
|
|
506
|
+
patchPilotInstructions ? `PATCHPILOT.md instructions:\n${patchPilotInstructions}` : "",
|
|
463
507
|
packageJson ? `package.json:\n${packageJson}` : "",
|
|
464
508
|
tsconfig ? `tsconfig.json:\n${tsconfig}` : "",
|
|
465
509
|
readme ? `README excerpt:\n${readme}` : ""
|