@neilurk12/pi-agent-modes 0.1.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/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +301 -0
- package/dist/index.js.map +1 -0
- package/dist/mode-catalog.d.ts +51 -0
- package/dist/mode-catalog.d.ts.map +1 -0
- package/dist/mode-catalog.js +175 -0
- package/dist/mode-catalog.js.map +1 -0
- package/dist/mode-runtime.d.ts +92 -0
- package/dist/mode-runtime.d.ts.map +1 -0
- package/dist/mode-runtime.js +197 -0
- package/dist/mode-runtime.js.map +1 -0
- package/dist/mode-tool-policy.d.ts +13 -0
- package/dist/mode-tool-policy.d.ts.map +1 -0
- package/dist/mode-tool-policy.js +163 -0
- package/dist/mode-tool-policy.js.map +1 -0
- package/dist/payload-injection.d.ts +2 -0
- package/dist/payload-injection.d.ts.map +1 -0
- package/dist/payload-injection.js +25 -0
- package/dist/payload-injection.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/modes/ask.md +27 -0
- package/modes/code.md +17 -0
- package/modes/orchestrator.md +18 -0
- package/modes/plan.md +24 -0
- package/modes/yolo.md +10 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# pi-agent-modes
|
|
2
|
+
|
|
3
|
+
Multi-mode extension for the pi coding agent: **YOLO**, **PLAN**, **CODE**, **ASK**, and **ORCHESTRATOR**.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @neilurk12/pi-agent-modes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or link for local development:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm link
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### As a pi extension
|
|
20
|
+
|
|
21
|
+
Place the extension in pi's extensions directory:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# After npm install, pi will auto-discover from node_modules
|
|
25
|
+
# Or symlink/copy to ~/.pi/agent/extensions/
|
|
26
|
+
ln -s $(npm root)/@neilurk12/pi-agent-modes/dist/index.js ~/.pi/agent/extensions/modes.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or load directly:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pi --extension node_modules/@neilurk12/pi-agent-modes/dist/index.js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Switching modes
|
|
36
|
+
|
|
37
|
+
- `/mode` — interactive mode picker
|
|
38
|
+
- `/mode status` — show current active tools and config
|
|
39
|
+
- `/mode yolo|plan|code|ask|orchestrator` — switch immediately
|
|
40
|
+
- `/modes` — alias for `/mode`
|
|
41
|
+
- `Ctrl+Shift+M` — cycle modes (yolo → plan → code → ask → orchestrator)
|
|
42
|
+
|
|
43
|
+
### CLI flag
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pi --mode plan # start in plan mode
|
|
47
|
+
pi --mode orchestrator # start in orchestrator mode
|
|
48
|
+
pi --mode yolo # start in yolo mode (default)
|
|
49
|
+
pi --mode ask # start in ask mode
|
|
50
|
+
pi --mode code # start in code mode
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Modes
|
|
54
|
+
|
|
55
|
+
### YOLO (default)
|
|
56
|
+
Full unrestricted access. All tools available. No additional restrictions.
|
|
57
|
+
|
|
58
|
+
### PLAN (read-only)
|
|
59
|
+
Safe exploration mode. Only read-only tools enabled:
|
|
60
|
+
- Allowed tools: `read`, `bash`, `grep`, `find`, `ls`, `questionnaire`
|
|
61
|
+
- Bash policy: `strict_readonly` (read-only command safelist)
|
|
62
|
+
- edit/write/apply_patch are disabled by the harness
|
|
63
|
+
|
|
64
|
+
Useful for exploring codebases, understanding structure, and planning changes without risk.
|
|
65
|
+
|
|
66
|
+
### CODE
|
|
67
|
+
Full editing and development tools with non-destructive command protection. All tools available like YOLO, but bash commands are filtered:
|
|
68
|
+
- Bash policy: `non_destructive` (blocks rm -rf, git push, sudo, npm install, redirects, etc.)
|
|
69
|
+
- Differences from YOLO: bash protection, safety-focused prompt
|
|
70
|
+
|
|
71
|
+
Useful for active development with safety net against accidental data loss.
|
|
72
|
+
|
|
73
|
+
### ORCHESTRATOR
|
|
74
|
+
Coordination mode. Full tool access, but system prompt encourages:
|
|
75
|
+
- Breaking tasks into subtasks
|
|
76
|
+
- Delegating to subagents using the `subagent` tool
|
|
77
|
+
- Tracking progress and synthesizing results
|
|
78
|
+
|
|
79
|
+
Requires the subagent extension to be loaded for full delegation capability.
|
|
80
|
+
|
|
81
|
+
### ASK
|
|
82
|
+
Clarification-first mode. Enabled tools: `read`, `bash`, `grep`, `find`, `ls`, `questionnaire`. Bash policy is `strict_readonly`. Gather requirements before any implementation — no code changes.
|
|
83
|
+
|
|
84
|
+
## State persistence
|
|
85
|
+
|
|
86
|
+
Mode selection persists across sessions. The current mode is stored in session history and restored on startup.
|
|
87
|
+
|
|
88
|
+
## Configuration and Customization
|
|
89
|
+
Modes are defined by markdown files in `modes/` with YAML frontmatter:
|
|
90
|
+
```yaml
|
|
91
|
+
mode: yolo|plan|code|ask|orchestrator
|
|
92
|
+
enabled_tools: [] # empty = all tools; omitted/empty = baseline tools; non-empty = exact list
|
|
93
|
+
bash_policy: strict_readonly|non_destructive|off
|
|
94
|
+
border_label: " LABEL "
|
|
95
|
+
border_style: accent|warning|success|muted
|
|
96
|
+
prompt_suffix: | # system prompt injected before each request
|
|
97
|
+
[MODE: ...]
|
|
98
|
+
instructions...
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### User Overrides
|
|
102
|
+
You can override any mode configuration locally by creating a YAML file at `~/.pi/modes/config.yaml`:
|
|
103
|
+
```yaml
|
|
104
|
+
plan:
|
|
105
|
+
border_label: " MY PLAN "
|
|
106
|
+
enabled_tools:
|
|
107
|
+
- read
|
|
108
|
+
- bash
|
|
109
|
+
bash_policy: strict_readonly
|
|
110
|
+
```
|
|
111
|
+
This configuration is merged over the built-in markdown definitions.
|
|
112
|
+
|
|
113
|
+
### Dynamic Reload
|
|
114
|
+
- Run `/mode reload` to immediately reload the mode definitions and your overrides.
|
|
115
|
+
- The `modes/` directory and your `config.yaml` are auto-watched. Edits trigger an automatic hot-reload when your turn ends.
|
|
116
|
+
|
|
117
|
+
v0.1.0 (current): markdown-driven config with mode-specific `bash_policy`, enforced via `mode-tool-policy`.
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Install dependencies
|
|
122
|
+
npm install
|
|
123
|
+
|
|
124
|
+
# Build
|
|
125
|
+
npm run build
|
|
126
|
+
|
|
127
|
+
# Watch mode
|
|
128
|
+
npm run watch
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Then symlink/dist to `~/.pi/agent/extensions/` for testing.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,iCAAiC,CAAC;AAuBtF,yBAA+B,EAAE,EAAE,YAAY,iBAkS9C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { CustomEditor } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Key } from "@earendil-works/pi-tui";
|
|
3
|
+
import { loadAllModes, notifyModeCatalogDiagnostics } from "./mode-catalog.js";
|
|
4
|
+
import { ModeRuntimeController } from "./mode-runtime.js";
|
|
5
|
+
import { injectIntoPayload } from "./payload-injection.js";
|
|
6
|
+
import { evaluateToolCall } from "./mode-tool-policy.js";
|
|
7
|
+
async function loadInitialModeCatalog(ctx) {
|
|
8
|
+
const result = await loadAllModes();
|
|
9
|
+
if (result.ok) {
|
|
10
|
+
if (ctx)
|
|
11
|
+
notifyModeCatalogDiagnostics(ctx, result.diagnostics);
|
|
12
|
+
return result.catalog;
|
|
13
|
+
}
|
|
14
|
+
if (ctx)
|
|
15
|
+
notifyModeCatalogDiagnostics(ctx, result.diagnostics);
|
|
16
|
+
console.error("[pi-agent-modes] Failed to load required mode definitions", result.diagnostics);
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export default async function (pi) {
|
|
20
|
+
let initialCatalog = await loadInitialModeCatalog();
|
|
21
|
+
let runtime = initialCatalog ? new ModeRuntimeController(initialCatalog) : undefined;
|
|
22
|
+
let currentCtx;
|
|
23
|
+
let reloadPending = false;
|
|
24
|
+
// CLI flag: --mode <mode>
|
|
25
|
+
pi.registerFlag("mode", {
|
|
26
|
+
description: "Start in tool mode (e.g. yolo, plan, code, ask, orchestrator)",
|
|
27
|
+
type: "string",
|
|
28
|
+
});
|
|
29
|
+
function currentMode() {
|
|
30
|
+
return runtime?.snapshot().currentMode ?? "yolo";
|
|
31
|
+
}
|
|
32
|
+
function currentModes() {
|
|
33
|
+
return runtime?.modes() ?? [];
|
|
34
|
+
}
|
|
35
|
+
function applyDecision(decision, ctx) {
|
|
36
|
+
if (!decision)
|
|
37
|
+
return;
|
|
38
|
+
pi.setActiveTools(decision.activeTools);
|
|
39
|
+
if (decision.persistModeState)
|
|
40
|
+
persistMode();
|
|
41
|
+
if (ctx && decision.notifications.length > 0) {
|
|
42
|
+
for (const item of decision.notifications) {
|
|
43
|
+
ctx.ui.notify(item.message, item.level);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function reloadAll(ctx) {
|
|
48
|
+
const result = await loadAllModes();
|
|
49
|
+
if (result.ok) {
|
|
50
|
+
if (!runtime)
|
|
51
|
+
runtime = new ModeRuntimeController(result.catalog);
|
|
52
|
+
const decision = runtime.transition({ type: "mode_reload_result", catalog: result.catalog });
|
|
53
|
+
notifyModeCatalogDiagnostics(ctx, result.diagnostics);
|
|
54
|
+
applyDecision(decision, ctx);
|
|
55
|
+
updateStatus(ctx);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
runtime?.keepCatalog();
|
|
59
|
+
notifyModeCatalogDiagnostics(ctx, result.diagnostics);
|
|
60
|
+
ctx.ui.notify(runtime ? "Mode reload failed; keeping previous known-good catalog" : "Mode reload failed; no known-good catalog loaded", runtime ? "warning" : "error");
|
|
61
|
+
}
|
|
62
|
+
async function checkAndReload(ctx) {
|
|
63
|
+
if (reloadPending || !runtime)
|
|
64
|
+
return;
|
|
65
|
+
reloadPending = true;
|
|
66
|
+
try {
|
|
67
|
+
const fs = (await import("fs")).promises;
|
|
68
|
+
const path = await import("path");
|
|
69
|
+
const os = await import("os");
|
|
70
|
+
const baseDir = path.dirname(new URL(import.meta.url).pathname);
|
|
71
|
+
const modesDir = path.join(baseDir, "..", "modes");
|
|
72
|
+
const configPath = path.join(os.homedir(), ".pi", "modes", "config.yaml");
|
|
73
|
+
const lastLoadTime = runtime.lastLoadTime();
|
|
74
|
+
let shouldReload = false;
|
|
75
|
+
try {
|
|
76
|
+
const st = await fs.stat(configPath);
|
|
77
|
+
if (st.mtimeMs > lastLoadTime)
|
|
78
|
+
shouldReload = true;
|
|
79
|
+
}
|
|
80
|
+
catch (e) { }
|
|
81
|
+
if (!shouldReload) {
|
|
82
|
+
try {
|
|
83
|
+
const files = await fs.readdir(modesDir);
|
|
84
|
+
for (const file of files) {
|
|
85
|
+
if (file.endsWith(".md")) {
|
|
86
|
+
const st = await fs.stat(path.join(modesDir, file));
|
|
87
|
+
if (st.mtimeMs > lastLoadTime) {
|
|
88
|
+
shouldReload = true;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e) { }
|
|
95
|
+
}
|
|
96
|
+
if (shouldReload)
|
|
97
|
+
await reloadAll(ctx);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
reloadPending = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function handleModeCommand(args, ctx) {
|
|
104
|
+
currentCtx = ctx;
|
|
105
|
+
if (!runtime) {
|
|
106
|
+
ctx.ui.notify("Mode catalog not initialized", "error");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const command = args?.trim().toLowerCase();
|
|
110
|
+
if (command === "reload") {
|
|
111
|
+
await reloadAll(ctx);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (command === "status") {
|
|
115
|
+
await showModeStatus(ctx);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (command) {
|
|
119
|
+
const decision = runtime.transition({ type: "mode_select", requestedMode: command });
|
|
120
|
+
if (decision.error) {
|
|
121
|
+
ctx.ui.notify(decision.error, "error");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
applyDecision(decision, ctx);
|
|
125
|
+
updateStatus(ctx);
|
|
126
|
+
if (decision.modeChanged)
|
|
127
|
+
ctx.ui.notify(`Mode: ${command.toUpperCase()}`, "info");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const modes = currentModes();
|
|
131
|
+
const options = modes.map(m => {
|
|
132
|
+
const def = runtime?.definition(m);
|
|
133
|
+
const name = m.toUpperCase();
|
|
134
|
+
return def?.description ? `${name} — ${def.description}` : name;
|
|
135
|
+
});
|
|
136
|
+
const choice = await ctx.ui.select("Select mode:", options);
|
|
137
|
+
if (choice) {
|
|
138
|
+
const selectedName = choice.split(" — ")[0].toLowerCase();
|
|
139
|
+
const mode = modes.find(m => m.toLowerCase() === selectedName) || "yolo";
|
|
140
|
+
const decision = runtime.transition({ type: "mode_select", requestedMode: mode });
|
|
141
|
+
if (!decision.error) {
|
|
142
|
+
applyDecision(decision, ctx);
|
|
143
|
+
updateStatus(ctx);
|
|
144
|
+
if (decision.modeChanged)
|
|
145
|
+
ctx.ui.notify(`Mode: ${mode.toUpperCase()}`, "info");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
pi.registerCommand("mode", {
|
|
150
|
+
description: "Switch tool mode (yolo, plan, code, ask, orchestrator)",
|
|
151
|
+
handler: async (args, ctx) => {
|
|
152
|
+
await handleModeCommand(args, ctx);
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
pi.registerCommand("modes", {
|
|
156
|
+
description: "Alias for /mode",
|
|
157
|
+
handler: async (args, ctx) => {
|
|
158
|
+
await handleModeCommand(args, ctx);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
// Shortcut: cycle mode
|
|
162
|
+
pi.registerShortcut(Key.ctrlShift("m"), {
|
|
163
|
+
description: "Cycle modes (yolo → plan → code → ask → orchestrator)",
|
|
164
|
+
handler: async (ctx) => {
|
|
165
|
+
if (!runtime)
|
|
166
|
+
return;
|
|
167
|
+
const decision = runtime.transition({ type: "mode_cycle" });
|
|
168
|
+
applyDecision(decision, ctx);
|
|
169
|
+
updateStatus(ctx);
|
|
170
|
+
if (decision.modeChanged)
|
|
171
|
+
ctx.ui.notify(`Mode: ${currentMode().toUpperCase()}`, "info");
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
function modePromptInjection() {
|
|
175
|
+
const mode = currentMode();
|
|
176
|
+
const promptSuffix = runtime?.currentPromptSuffix();
|
|
177
|
+
if (!promptSuffix)
|
|
178
|
+
return undefined;
|
|
179
|
+
return `\n\n[MODE: ${mode.toUpperCase()}]\n${promptSuffix}`;
|
|
180
|
+
}
|
|
181
|
+
// Inject mode prompt on every provider request (compaction-safe).
|
|
182
|
+
pi.on("before_provider_request", async (event) => {
|
|
183
|
+
const injection = modePromptInjection();
|
|
184
|
+
if (!injection)
|
|
185
|
+
return;
|
|
186
|
+
return injectIntoPayload(event.payload, injection);
|
|
187
|
+
});
|
|
188
|
+
// Gate tool access based on mode policy module
|
|
189
|
+
pi.on("tool_call", async (event, _ctx) => {
|
|
190
|
+
runtime?.transition({ type: "tool_call", toolName: event.toolName });
|
|
191
|
+
const mode = currentMode();
|
|
192
|
+
const policyDecision = evaluateToolCall({
|
|
193
|
+
mode,
|
|
194
|
+
definition: runtime?.definition(),
|
|
195
|
+
toolName: event.toolName,
|
|
196
|
+
input: event.input,
|
|
197
|
+
});
|
|
198
|
+
if (policyDecision.block) {
|
|
199
|
+
return {
|
|
200
|
+
block: true,
|
|
201
|
+
reason: policyDecision.reason,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
function captureBaselineTools() {
|
|
206
|
+
runtime?.captureBaselineTools(pi.getAllTools().map((t) => t.name));
|
|
207
|
+
}
|
|
208
|
+
function updateStatus(ctx) {
|
|
209
|
+
const mode = currentMode();
|
|
210
|
+
const def = runtime?.definition();
|
|
211
|
+
const style = def?.border_style || "muted";
|
|
212
|
+
let display = mode.toUpperCase();
|
|
213
|
+
// Keep legacy emojis for standard modes
|
|
214
|
+
if (mode === "plan")
|
|
215
|
+
display = "📋PLAN";
|
|
216
|
+
else if (mode === "orchestrator")
|
|
217
|
+
display = "🤝ORCH";
|
|
218
|
+
else if (mode === "ask")
|
|
219
|
+
display = "❓ASK";
|
|
220
|
+
ctx.ui.setStatus("mode", ctx.ui.theme.fg(style, display));
|
|
221
|
+
}
|
|
222
|
+
function persistMode() {
|
|
223
|
+
pi.appendEntry("mode-state", { mode: currentMode() });
|
|
224
|
+
}
|
|
225
|
+
// Initialize on session start or resume
|
|
226
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
227
|
+
currentCtx = ctx;
|
|
228
|
+
initialCatalog = await loadInitialModeCatalog(ctx) ?? initialCatalog;
|
|
229
|
+
if (initialCatalog) {
|
|
230
|
+
if (!runtime)
|
|
231
|
+
runtime = new ModeRuntimeController(initialCatalog);
|
|
232
|
+
else
|
|
233
|
+
runtime.acceptCatalog(initialCatalog);
|
|
234
|
+
}
|
|
235
|
+
captureBaselineTools();
|
|
236
|
+
const flag = pi.getFlag("mode");
|
|
237
|
+
const decision = runtime?.transition({
|
|
238
|
+
type: "session_start",
|
|
239
|
+
cliMode: typeof flag === "string" ? flag : undefined,
|
|
240
|
+
sessionMode: lastSessionMode(ctx),
|
|
241
|
+
});
|
|
242
|
+
applyDecision(decision, ctx);
|
|
243
|
+
updateStatus(ctx);
|
|
244
|
+
// Set custom editor to display current mode in chat border
|
|
245
|
+
ctx.ui.setEditorComponent((tui, theme, keybindings) => {
|
|
246
|
+
class ModeEditor extends CustomEditor {
|
|
247
|
+
render(width) {
|
|
248
|
+
const lines = super.render(width);
|
|
249
|
+
if (lines.length === 0)
|
|
250
|
+
return lines;
|
|
251
|
+
const mode = currentMode();
|
|
252
|
+
const def = runtime?.definition();
|
|
253
|
+
let label = def?.border_label || ` ${mode.toUpperCase()} `;
|
|
254
|
+
const style = def?.border_style;
|
|
255
|
+
if (label && lines.length > 0) {
|
|
256
|
+
const labelWidth = label.length;
|
|
257
|
+
const dashes = "─".repeat(Math.max(0, width - labelWidth));
|
|
258
|
+
const borderText = label + dashes;
|
|
259
|
+
// Apply custom theme color if specified
|
|
260
|
+
if (style && style !== "muted" && typeof ctx.ui.theme.fg === "function") {
|
|
261
|
+
// Use fg color mapped from style, or fallback to borderColor
|
|
262
|
+
lines[lines.length - 1] = ctx.ui.theme.fg(style, borderText);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
lines[lines.length - 1] = theme.borderColor(borderText);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return lines;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return new ModeEditor(tui, theme, keybindings);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
// Persist after each turn to keep latest
|
|
275
|
+
pi.on("turn_end", async (_event, ctx) => {
|
|
276
|
+
currentCtx = ctx || currentCtx;
|
|
277
|
+
const decision = runtime?.transition({ type: "turn_end" });
|
|
278
|
+
applyDecision(decision, currentCtx);
|
|
279
|
+
if (currentCtx)
|
|
280
|
+
await checkAndReload(currentCtx);
|
|
281
|
+
});
|
|
282
|
+
async function showModeStatus(ctx) {
|
|
283
|
+
const mode = currentMode();
|
|
284
|
+
const def = runtime?.definition();
|
|
285
|
+
const allTools = pi.getAllTools().map(t => t.name);
|
|
286
|
+
const activeTools = runtime?.activeTools() ?? allTools;
|
|
287
|
+
const suffixPreview = (def?.prompt_suffix || "").slice(0, 120) + (def?.prompt_suffix && def.prompt_suffix.length > 120 ? "..." : "");
|
|
288
|
+
const status = `Mode: ${mode}\nDescription: ${def?.description || "—"}\nActive tools (${activeTools.length}): ${activeTools.join(", ")}\nPrompt suffix: ${suffixPreview || "(none)"}\nBorder: ${def?.border_label || ""} (style: ${def?.border_style || "—"})`;
|
|
289
|
+
ctx.ui.notify(status, "info");
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function lastSessionMode(ctx) {
|
|
293
|
+
const last = ctx.sessionManager.getEntries()
|
|
294
|
+
.filter((e) => e.type === "custom" && e.customType === "mode-state")
|
|
295
|
+
.pop();
|
|
296
|
+
if (last && "data" in last && last.data && typeof last.data === "object" && "mode" in last.data) {
|
|
297
|
+
return last.data.mode;
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,4BAA4B,EAAoB,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAA4B,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD,KAAK,UAAU,sBAAsB,CAAC,GAAsB;IAC1D,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACd,IAAI,GAAG;YAAE,4BAA4B,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/D,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED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,IAAI,GAAG,GAAG,CAAC;QAE/P,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,GAAqB;IAC5C,MAAM,IAAI,GAAG,GAAG,CAAC,cAAc,CAAC,UAAU,EAAE;SACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,KAAK,YAAY,CAAC;SACnE,GAAG,EAAE,CAAC;IACT,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAChG,OAAQ,IAAI,CAAC,IAAyB,CAAC,IAAI,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ModeDefinition } from "./types.js";
|
|
3
|
+
export declare const REQUIRED_BUILT_IN_MODES: readonly ["yolo", "plan", "code", "ask", "orchestrator"];
|
|
4
|
+
export type DiagnosticLevel = "warning" | "error";
|
|
5
|
+
export interface ModeCatalogDiagnostic {
|
|
6
|
+
level: DiagnosticLevel;
|
|
7
|
+
message: string;
|
|
8
|
+
mode?: string;
|
|
9
|
+
file?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ModeCatalog {
|
|
12
|
+
definitions: Map<string, ModeDefinition>;
|
|
13
|
+
loadedAt: number;
|
|
14
|
+
}
|
|
15
|
+
export type ModeCatalogResult = {
|
|
16
|
+
ok: true;
|
|
17
|
+
catalog: ModeCatalog;
|
|
18
|
+
diagnostics: ModeCatalogDiagnostic[];
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
diagnostics: ModeCatalogDiagnostic[];
|
|
22
|
+
};
|
|
23
|
+
export interface LoadModeCatalogOptions {
|
|
24
|
+
modesDir?: string;
|
|
25
|
+
userConfigPath?: string;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
}
|
|
28
|
+
export interface ParsedModeDocument {
|
|
29
|
+
mode: string;
|
|
30
|
+
file: string;
|
|
31
|
+
parsed?: unknown;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ParsedUserOverrides {
|
|
35
|
+
file: string;
|
|
36
|
+
parsed?: unknown;
|
|
37
|
+
readError?: string;
|
|
38
|
+
parseError?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BuildModeCatalogInput {
|
|
41
|
+
modeDocuments: readonly ParsedModeDocument[];
|
|
42
|
+
userOverrides?: ParsedUserOverrides;
|
|
43
|
+
diagnostics?: readonly ModeCatalogDiagnostic[];
|
|
44
|
+
fileForMode?: (mode: string) => string;
|
|
45
|
+
now?: () => number;
|
|
46
|
+
}
|
|
47
|
+
export declare function loadModeFromMarkdown(filePath: string, mode: string): Promise<ModeDefinition>;
|
|
48
|
+
export declare function buildModeCatalog(input: BuildModeCatalogInput): ModeCatalogResult;
|
|
49
|
+
export declare function loadAllModes(options?: LoadModeCatalogOptions): Promise<ModeCatalogResult>;
|
|
50
|
+
export declare function notifyModeCatalogDiagnostics(ctx: ExtensionContext, diagnostics: ModeCatalogDiagnostic[]): void;
|
|
51
|
+
//# sourceMappingURL=mode-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-catalog.d.ts","sourceRoot":"","sources":["../src/mode-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,uBAAuB,0DAA2D,CAAC;AAEhG,MAAM,MAAM,eAAe,GAAG,SAAS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