my-pi 0.3.6 → 0.4.1
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/README.md +32 -252
- package/dist/extensions.d.ts +11 -0
- package/dist/extensions.js +148 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +40 -519
- package/dist/index.js.map +1 -1
- package/dist/manager.d.ts +3 -0
- package/dist/manager.js +71 -0
- package/dist/manager.js.map +1 -0
- package/dist/settings.d.ts +3 -0
- package/dist/settings.js +16 -0
- package/dist/settings.js.map +1 -0
- package/package.json +31 -76
- package/dist/api.d.ts +0 -472
- package/dist/api.js +0 -525
- package/dist/api.js.map +0 -1
- package/dist/builtin-registry-C0CQdd45.js +0 -562
- package/dist/builtin-registry-C0CQdd45.js.map +0 -1
- package/dist/footer-BAZIMVSb.js +0 -1
- package/dist/handoff-B2wpybTf.js +0 -27
- package/dist/handoff-B2wpybTf.js.map +0 -1
- package/dist/hooks-resolution-kzoVsQAX.js +0 -478
- package/dist/hooks-resolution-kzoVsQAX.js.map +0 -1
- package/dist/openrouter-fusion-config-CPXLfmCA.js +0 -64
- package/dist/openrouter-fusion-config-CPXLfmCA.js.map +0 -1
- package/dist/prompt-presets-DOn1oZFJ.js +0 -1392
- package/dist/prompt-presets-DOn1oZFJ.js.map +0 -1
- package/dist/session-name-qyrX-OES.js +0 -157
- package/dist/session-name-qyrX-OES.js.map +0 -1
- package/dist/settings-UYlhEo3S.js +0 -172
- package/dist/settings-UYlhEo3S.js.map +0 -1
- package/dist/startup-screen-D5YGuwge.js +0 -217
- package/dist/startup-screen-D5YGuwge.js.map +0 -1
- package/dist/turn-timer-mowT6nwv.js +0 -63
- package/dist/turn-timer-mowT6nwv.js.map +0 -1
- package/dist/umans-provider-DIupQTRK.js +0 -306
- package/dist/umans-provider-DIupQTRK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,523 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { main, } from '@earendil-works/pi-coding-agent';
|
|
3
|
+
import { EXTENSIONS, themes_dir } from './extensions.js';
|
|
4
|
+
import extensions_manager from './manager.js';
|
|
5
|
+
import { is_enabled } from './settings.js';
|
|
6
|
+
process.title = 'my-pi';
|
|
7
|
+
process.env.PI_CODING_AGENT = 'true';
|
|
8
|
+
process.env.AI_AGENT = 'pi';
|
|
9
|
+
// my-pi pins its Pi version, so upstream's update notice does not apply.
|
|
10
|
+
process.env.PI_SKIP_VERSION_CHECK ??= '1';
|
|
11
|
+
// Same as upstream's CLI: hides node:sqlite's ExperimentalWarning.
|
|
12
|
+
process.emitWarning = () => { };
|
|
13
|
+
// Each factory checks the saved setting when Pi (re)loads extensions,
|
|
14
|
+
// so /extensions changes apply on /reload without a restart.
|
|
15
|
+
const extensions = [
|
|
16
|
+
{ name: 'extensions', factory: extensions_manager },
|
|
17
|
+
...EXTENSIONS.map((extension) => ({
|
|
18
|
+
name: extension.key,
|
|
19
|
+
factory: async (pi) => {
|
|
20
|
+
if (!is_enabled(extension.key))
|
|
21
|
+
return;
|
|
22
|
+
await (await extension.load())(pi);
|
|
23
|
+
},
|
|
24
|
+
})),
|
|
25
|
+
];
|
|
26
|
+
// Pi reads these subcommands from the first argument.
|
|
27
|
+
const subcommands = new Set([
|
|
28
|
+
'auth',
|
|
29
|
+
'config',
|
|
30
|
+
'install',
|
|
31
|
+
'list',
|
|
32
|
+
'mcp',
|
|
33
|
+
'remove',
|
|
34
|
+
'uninstall',
|
|
35
|
+
'update',
|
|
15
36
|
]);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
function is_citty_no_flag_set(args, cli_arg) {
|
|
24
|
-
if (args[cli_arg]) return true;
|
|
25
|
-
const positive_kebab = cli_arg.replace(/^no-/, "");
|
|
26
|
-
const positive_camel = positive_kebab.replace(/-([a-z])/g, (_, char) => String(char).toUpperCase());
|
|
27
|
-
return args[positive_kebab] === false || args[positive_camel] === false;
|
|
28
|
-
}
|
|
29
|
-
function resolve_builtin_extension_options(args) {
|
|
30
|
-
const no_builtin = is_citty_no_flag_set(args, "no-builtin");
|
|
31
|
-
return Object.fromEntries(BUILTIN_EXTENSIONS.map((extension) => [extension.option_name, !no_builtin && !is_citty_no_flag_set(args, extension.cli_arg) && extension.default_enabled]));
|
|
32
|
-
}
|
|
33
|
-
function parse_extension_cli_args(argv, known_args) {
|
|
34
|
-
const known_flags = /* @__PURE__ */ new Map();
|
|
35
|
-
for (const [name, definition] of Object.entries(known_args)) {
|
|
36
|
-
known_flags.set(`--${name}`, definition.type);
|
|
37
|
-
const camel_name = name.replace(/-([a-z])/g, (_, char) => String(char).toUpperCase());
|
|
38
|
-
known_flags.set(`--${camel_name}`, definition.type);
|
|
39
|
-
if (definition.type === "boolean") known_flags.set(`--no-${name}`, definition.type);
|
|
40
|
-
const aliases = Array.isArray(definition.alias) ? definition.alias : definition.alias ? [definition.alias] : [];
|
|
41
|
-
for (const alias of aliases) known_flags.set(`-${alias}`, definition.type);
|
|
42
|
-
}
|
|
43
|
-
const extension_flag_values = /* @__PURE__ */ new Map();
|
|
44
|
-
const positionals = [];
|
|
45
|
-
const diagnostics = [];
|
|
46
|
-
for (let i = 0; i < argv.length; i++) {
|
|
47
|
-
const arg = argv[i];
|
|
48
|
-
if (!arg) continue;
|
|
49
|
-
if (arg === "--") {
|
|
50
|
-
positionals.push(...argv.slice(i + 1));
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
const equals_index = arg.indexOf("=");
|
|
54
|
-
const flag_token = equals_index === -1 ? arg : arg.slice(0, equals_index);
|
|
55
|
-
const known_type = known_flags.get(flag_token);
|
|
56
|
-
if (known_type) {
|
|
57
|
-
if (equals_index === -1 && (known_type === "string" || known_type === "enum") && i + 1 < argv.length && argv[i + 1] !== "--") i += 1;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (arg.startsWith("--")) {
|
|
61
|
-
if (equals_index !== -1) {
|
|
62
|
-
extension_flag_values.set(arg.slice(2, equals_index), arg.slice(equals_index + 1));
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const name = arg.slice(2);
|
|
66
|
-
const next = argv[i + 1];
|
|
67
|
-
if (next !== void 0 && !next.startsWith("-") && !next.startsWith("@")) {
|
|
68
|
-
extension_flag_values.set(name, next);
|
|
69
|
-
i += 1;
|
|
70
|
-
} else extension_flag_values.set(name, true);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (arg.startsWith("-")) {
|
|
74
|
-
diagnostics.push(`Unknown option: ${arg}`);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
positionals.push(arg);
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
extension_flag_values,
|
|
81
|
-
positionals,
|
|
82
|
-
diagnostics
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function collect_flag_values(argv, flags) {
|
|
86
|
-
const values = [];
|
|
87
|
-
const flag_set = new Set(flags);
|
|
88
|
-
for (let i = 0; i < argv.length; i++) {
|
|
89
|
-
const arg = argv[i];
|
|
90
|
-
if (arg === "--") break;
|
|
91
|
-
if (!arg) continue;
|
|
92
|
-
const equals_index = arg.indexOf("=");
|
|
93
|
-
if (equals_index !== -1) {
|
|
94
|
-
const name = arg.slice(0, equals_index);
|
|
95
|
-
if (flag_set.has(name)) values.push(arg.slice(equals_index + 1));
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (flag_set.has(arg) && i + 1 < argv.length) {
|
|
99
|
-
const next = argv[i + 1];
|
|
100
|
-
if (next !== void 0 && next !== "--") {
|
|
101
|
-
values.push(next);
|
|
102
|
-
i += 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return values;
|
|
107
|
-
}
|
|
108
|
-
function parse_extension_paths(argv, cwd = process.cwd()) {
|
|
109
|
-
return collect_flag_values(argv, ["-e", "--extension"]).map((path) => path.trim()).filter(Boolean).map((path) => resolve(cwd, path));
|
|
110
|
-
}
|
|
111
|
-
function parse_comma_list_flags(argv, flags) {
|
|
112
|
-
const values = collect_flag_values(argv, flags).flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean);
|
|
113
|
-
return values.length ? [...new Set(values)] : void 0;
|
|
114
|
-
}
|
|
115
|
-
function parse_tool_allowlist(argv) {
|
|
116
|
-
return parse_comma_list_flags(argv, ["--tools", "-t"]);
|
|
117
|
-
}
|
|
118
|
-
function parse_tool_excludelist(argv) {
|
|
119
|
-
return parse_comma_list_flags(argv, ["--exclude-tools", "-xt"]);
|
|
120
|
-
}
|
|
121
|
-
function parse_skill_allowlist(argv) {
|
|
122
|
-
return parse_comma_list_flags(argv, ["--skill"]);
|
|
123
|
-
}
|
|
124
|
-
function parse_thinking_level(value) {
|
|
125
|
-
const normalized = value?.trim().toLowerCase();
|
|
126
|
-
if (!normalized) return void 0;
|
|
127
|
-
if (!THINKING_LEVELS.has(normalized)) throw new Error("--thinking must be one of: off, minimal, low, medium, high, xhigh.");
|
|
128
|
-
return normalized;
|
|
129
|
-
}
|
|
130
|
-
// src/runtime-preflight.ts
|
|
131
|
-
const MINIMUM_NODE_VERSION = "24.15.0";
|
|
132
|
-
function parse_node_version(version) {
|
|
133
|
-
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version);
|
|
134
|
-
if (!match) return void 0;
|
|
135
|
-
return [
|
|
136
|
-
Number(match[1]),
|
|
137
|
-
Number(match[2]),
|
|
138
|
-
Number(match[3])
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
function is_supported_node_version(version) {
|
|
142
|
-
const current = parse_node_version(version);
|
|
143
|
-
const minimum = parse_node_version(MINIMUM_NODE_VERSION);
|
|
144
|
-
if (!current || !minimum) return false;
|
|
145
|
-
for (let index = 0; index < current.length; index++) {
|
|
146
|
-
if (current[index] > minimum[index]) return true;
|
|
147
|
-
if (current[index] < minimum[index]) return false;
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
function get_node_preflight_error(current_version = process.versions.node) {
|
|
152
|
-
if (is_supported_node_version(current_version)) return void 0;
|
|
153
|
-
return `my-pi requires Node >=${MINIMUM_NODE_VERSION}; current version is ${current_version}. Upgrade Node and retry.`;
|
|
154
|
-
}
|
|
155
|
-
// src/warnings.ts
|
|
156
|
-
const SQLITE_EXPERIMENTAL_WARNING = "SQLite is an experimental feature";
|
|
157
|
-
const FILTER_INSTALLED = Symbol.for("my-pi.sqlite-warning-filter-installed");
|
|
158
|
-
const ORIGINAL_EMIT_WARNING = Symbol.for("my-pi.original-emit-warning");
|
|
159
|
-
function should_suppress_warning(warning) {
|
|
160
|
-
return warning.name === "ExperimentalWarning" && warning.message.includes(SQLITE_EXPERIMENTAL_WARNING);
|
|
161
|
-
}
|
|
162
|
-
function should_suppress_emit_warning_args(args) {
|
|
163
|
-
const [warning, options_or_type] = args;
|
|
164
|
-
if (warning instanceof Error) return should_suppress_warning(warning);
|
|
165
|
-
return (typeof options_or_type === "string" ? options_or_type : options_or_type && typeof options_or_type === "object" ? options_or_type.type : void 0) === "ExperimentalWarning" && String(warning).includes(SQLITE_EXPERIMENTAL_WARNING);
|
|
166
|
-
}
|
|
167
|
-
function install_sqlite_warning_filter(process_like = process) {
|
|
168
|
-
if (process_like[FILTER_INSTALLED]) return;
|
|
169
|
-
process_like[FILTER_INSTALLED] = true;
|
|
170
|
-
const original_emit_warning = process_like[ORIGINAL_EMIT_WARNING] ?? process_like.emitWarning;
|
|
171
|
-
process_like[ORIGINAL_EMIT_WARNING] = original_emit_warning;
|
|
172
|
-
process_like.emitWarning = function emit_filtered_warning(...args) {
|
|
173
|
-
if (should_suppress_emit_warning_args(args)) return;
|
|
174
|
-
return original_emit_warning.apply(this, args);
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
// src/index.ts
|
|
178
|
-
const node_preflight_error = get_node_preflight_error();
|
|
179
|
-
if (node_preflight_error) {
|
|
180
|
-
console.error(node_preflight_error);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
install_sqlite_warning_filter();
|
|
184
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
185
|
-
const package_root = join(__dirname, "..");
|
|
186
|
-
const pkg = JSON.parse(readFileSync(join(package_root, "package.json"), "utf-8"));
|
|
187
|
-
if (!existsSync(join(package_root, ".git"))) process.env.PI_SKIP_VERSION_CHECK ??= "1";
|
|
188
|
-
async function read_stdin() {
|
|
189
|
-
const chunks = [];
|
|
190
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
191
|
-
return Buffer.concat(chunks).toString("utf-8").trim();
|
|
192
|
-
}
|
|
193
|
-
async function run_interactive_mode(runtime, InteractiveModeClass) {
|
|
194
|
-
const original_write = process.stdout.write.bind(process.stdout);
|
|
195
|
-
process.stdout.write = ((chunk, ...args) => {
|
|
196
|
-
if (typeof chunk === "string") {
|
|
197
|
-
const styled_hint = new RegExp(`(To resume this session:${String.fromCharCode(27)}\\[[\\d;]*m )pi( --session )`, "g");
|
|
198
|
-
chunk = chunk.replace(styled_hint, "$1my-pi$2");
|
|
199
|
-
chunk = chunk.replace(/(To resume this session: )pi( --session )/g, "$1my-pi$2");
|
|
200
|
-
}
|
|
201
|
-
return Reflect.apply(original_write, process.stdout, [chunk, ...args]);
|
|
202
|
-
});
|
|
203
|
-
try {
|
|
204
|
-
await new InteractiveModeClass(runtime, {
|
|
205
|
-
migratedProviders: [],
|
|
206
|
-
modelFallbackMessage: void 0,
|
|
207
|
-
initialMessage: void 0,
|
|
208
|
-
initialImages: [],
|
|
209
|
-
initialMessages: []
|
|
210
|
-
}).run();
|
|
211
|
-
} finally {
|
|
212
|
-
process.stdout.write = original_write;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const HELP_APPENDIX = `
|
|
216
|
-
MODES
|
|
217
|
-
|
|
218
|
-
my-pi
|
|
219
|
-
Interactive TUI with slash commands, editor, and session UI.
|
|
220
|
-
|
|
221
|
-
my-pi "prompt"
|
|
222
|
-
my-pi -P "prompt"
|
|
223
|
-
One-shot print mode with plain text output.
|
|
224
|
-
|
|
225
|
-
my-pi --json "prompt"
|
|
226
|
-
Non-interactive NDJSON mode for scripts, evals, and other agents.
|
|
227
|
-
|
|
228
|
-
my-pi --mode rpc
|
|
229
|
-
RPC mode over stdin/stdout JSONL for orchestrators and teammate sessions.
|
|
230
|
-
|
|
231
|
-
NOTES
|
|
232
|
-
|
|
233
|
-
- In non-interactive modes, my-pi keeps headless-capable built-ins like
|
|
234
|
-
MCP, LSP, prompt presets, recall, nopeek, Omnisearch, SQLite tools, hooks, and secret redaction.
|
|
235
|
-
- UI-only built-ins like session auto-naming are skipped.
|
|
236
|
-
- Repeat -e / --extension to compose multiple extensions.
|
|
237
|
-
- Positional prompt arguments are joined with a single space.
|
|
238
|
-
- Everything after -- is prompt text, not options.
|
|
239
|
-
- --prompt takes precedence over positional prompt text and stdin.
|
|
240
|
-
|
|
241
|
-
NESTED RUNS
|
|
242
|
-
|
|
243
|
-
- Child runs inherit cwd and environment unless you isolate them explicitly.
|
|
244
|
-
- Use --agent-dir to isolate auth, config, sessions, and telemetry state.
|
|
245
|
-
- For safer evals or unknown repos, use --untrusted plus an explicit
|
|
246
|
-
--system-prompt.
|
|
247
|
-
|
|
248
|
-
EXAMPLES
|
|
249
|
-
|
|
250
|
-
my-pi
|
|
251
|
-
my-pi "fix the failing test"
|
|
252
|
-
my-pi -P "summarize this repo"
|
|
253
|
-
my-pi --json "list all TODO comments"
|
|
254
|
-
echo "plan a login page" | my-pi --json
|
|
255
|
-
my-pi --telemetry --json "run eval case"
|
|
256
|
-
my-pi --telemetry --telemetry-db ./tmp/evals.db --json "run case"
|
|
257
|
-
my-pi observability
|
|
258
|
-
my-pi --untrusted --agent-dir /tmp/pi-agent --json "run case"
|
|
259
|
-
my-pi -e ./my-ext.ts -e ./other-ext.ts "hello"
|
|
260
|
-
my-pi -m claude-haiku-4-5-20241022 "explain this file"
|
|
261
|
-
XIAOMI_API_KEY=... my-pi -m xiaomi/mimo-v2.5-pro "summarize this repo"
|
|
262
|
-
my-pi -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast "explain this file"
|
|
263
|
-
my-pi --preset terse,no-purple-prose "summarize this repo"
|
|
264
|
-
my-pi --system-prompt "You are a JSON classifier. Return only JSON." --json "classify this"
|
|
265
|
-
|
|
266
|
-
PROMPT PRESETS
|
|
267
|
-
|
|
268
|
-
Interactive commands:
|
|
269
|
-
/prompt-preset help
|
|
270
|
-
/prompt-preset export-defaults
|
|
271
|
-
/prompt-preset edit-global terse
|
|
272
|
-
/prompt-preset base detailed
|
|
273
|
-
/prompt-preset enable bullets
|
|
274
|
-
|
|
275
|
-
Short alias: /preset
|
|
276
|
-
|
|
277
|
-
Editable preset files:
|
|
278
|
-
~/.pi/agent/presets/*.md
|
|
279
|
-
.pi/presets/*.md
|
|
280
|
-
`;
|
|
281
|
-
async function render_rich_usage(cmd, parent) {
|
|
282
|
-
return `${await renderUsage(cmd, parent)}\n${HELP_APPENDIX}`;
|
|
283
|
-
}
|
|
284
|
-
async function print_usage(cmd, parent) {
|
|
285
|
-
console.log(await render_rich_usage(cmd, parent));
|
|
286
|
-
}
|
|
287
|
-
const main = defineCommand({
|
|
288
|
-
meta: {
|
|
289
|
-
name: "my-pi",
|
|
290
|
-
version: pkg.version,
|
|
291
|
-
description: "Composable pi coding agent with MCP, LSP, presets, and local eval telemetry"
|
|
292
|
-
},
|
|
293
|
-
args: {
|
|
294
|
-
print: {
|
|
295
|
-
type: "boolean",
|
|
296
|
-
alias: "P",
|
|
297
|
-
description: "Print mode (non-interactive, one-shot)",
|
|
298
|
-
default: false
|
|
299
|
-
},
|
|
300
|
-
"agent-dir": {
|
|
301
|
-
type: "string",
|
|
302
|
-
description: "Override Pi auth/config/session directory for this process",
|
|
303
|
-
required: false
|
|
304
|
-
},
|
|
305
|
-
"session-dir": {
|
|
306
|
-
type: "string",
|
|
307
|
-
description: "Override Pi session storage directory for this process",
|
|
308
|
-
required: false
|
|
309
|
-
},
|
|
310
|
-
json: {
|
|
311
|
-
type: "boolean",
|
|
312
|
-
alias: "j",
|
|
313
|
-
description: "Output NDJSON events (for agent consumption)",
|
|
314
|
-
default: false
|
|
315
|
-
},
|
|
316
|
-
mode: {
|
|
317
|
-
type: "string",
|
|
318
|
-
description: "Runtime mode: interactive, print, json, or rpc",
|
|
319
|
-
required: false
|
|
320
|
-
},
|
|
321
|
-
extension: {
|
|
322
|
-
type: "string",
|
|
323
|
-
alias: "e",
|
|
324
|
-
description: "Extension path to load; repeatable via argv parsing",
|
|
325
|
-
required: false
|
|
326
|
-
},
|
|
327
|
-
"no-builtin": {
|
|
328
|
-
type: "boolean",
|
|
329
|
-
description: "Disable all built-in extensions",
|
|
330
|
-
default: false
|
|
331
|
-
},
|
|
332
|
-
untrusted: {
|
|
333
|
-
type: "boolean",
|
|
334
|
-
description: "Safe mode for unknown repos: skip project MCP, hooks, project prompt presets, project skills, and project LSP binaries unless explicitly re-enabled",
|
|
335
|
-
default: false
|
|
336
|
-
},
|
|
337
|
-
...create_builtin_disable_cli_args(),
|
|
338
|
-
telemetry: {
|
|
339
|
-
type: "boolean",
|
|
340
|
-
description: "Enable local SQLite telemetry for this process",
|
|
341
|
-
default: false
|
|
342
|
-
},
|
|
343
|
-
"no-telemetry": {
|
|
344
|
-
type: "boolean",
|
|
345
|
-
description: "Disable local SQLite telemetry for this process",
|
|
346
|
-
default: false
|
|
347
|
-
},
|
|
348
|
-
"telemetry-db": {
|
|
349
|
-
type: "string",
|
|
350
|
-
description: "Override telemetry database path for this process",
|
|
351
|
-
required: false
|
|
352
|
-
},
|
|
353
|
-
model: {
|
|
354
|
-
type: "string",
|
|
355
|
-
alias: "m",
|
|
356
|
-
description: "Model to use (e.g. claude-sonnet-4-5-20241022, gpt-5.4, cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast)"
|
|
357
|
-
},
|
|
358
|
-
thinking: {
|
|
359
|
-
type: "string",
|
|
360
|
-
description: "Thinking level: off, minimal, low, medium, high, or xhigh",
|
|
361
|
-
required: false
|
|
362
|
-
},
|
|
363
|
-
tools: {
|
|
364
|
-
type: "string",
|
|
365
|
-
alias: "t",
|
|
366
|
-
description: "Comma-separated allowlist of tool names to enable",
|
|
367
|
-
required: false
|
|
368
|
-
},
|
|
369
|
-
"exclude-tools": {
|
|
370
|
-
type: "string",
|
|
371
|
-
alias: "xt",
|
|
372
|
-
description: "Comma-separated list of tool names to disable",
|
|
373
|
-
required: false
|
|
374
|
-
},
|
|
375
|
-
session: {
|
|
376
|
-
type: "string",
|
|
377
|
-
description: "Resume a specific session file or session ID",
|
|
378
|
-
required: false
|
|
379
|
-
},
|
|
380
|
-
"session-id": {
|
|
381
|
-
type: "string",
|
|
382
|
-
description: "Create or resume an exact project-local session ID",
|
|
383
|
-
required: false
|
|
384
|
-
},
|
|
385
|
-
name: {
|
|
386
|
-
type: "string",
|
|
387
|
-
alias: "n",
|
|
388
|
-
description: "Set the session display name at startup",
|
|
389
|
-
required: false
|
|
390
|
-
},
|
|
391
|
-
skill: {
|
|
392
|
-
type: "string",
|
|
393
|
-
description: "Skill name to allow; repeatable in argv parsing",
|
|
394
|
-
required: false
|
|
395
|
-
},
|
|
396
|
-
"system-prompt": {
|
|
397
|
-
type: "string",
|
|
398
|
-
description: "Replace the base system prompt",
|
|
399
|
-
required: false
|
|
400
|
-
},
|
|
401
|
-
"append-system-prompt": {
|
|
402
|
-
type: "string",
|
|
403
|
-
description: "Append one-off instructions to the system prompt",
|
|
404
|
-
required: false
|
|
405
|
-
},
|
|
406
|
-
prompt: {
|
|
407
|
-
type: "string",
|
|
408
|
-
alias: "p",
|
|
409
|
-
description: "Prompt text (alternative to positional argument)",
|
|
410
|
-
required: false
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
async run({ args }) {
|
|
414
|
-
const cwd = process.cwd();
|
|
415
|
-
const cli_argv = process.argv.slice(2);
|
|
416
|
-
const parsed_extension_cli = parse_extension_cli_args(cli_argv, main.args);
|
|
417
|
-
if (parsed_extension_cli.diagnostics.length) {
|
|
418
|
-
for (const message of parsed_extension_cli.diagnostics) console.error(`Error: ${message}`);
|
|
419
|
-
process.exit(1);
|
|
420
|
-
}
|
|
421
|
-
const extension_paths = parse_extension_paths(cli_argv, cwd);
|
|
422
|
-
const selected_tools = parse_tool_allowlist(cli_argv);
|
|
423
|
-
const excluded_tools = parse_tool_excludelist(cli_argv);
|
|
424
|
-
const selected_skills = parse_skill_allowlist(cli_argv);
|
|
425
|
-
let selected_thinking;
|
|
426
|
-
try {
|
|
427
|
-
selected_thinking = parse_thinking_level(args.thinking);
|
|
428
|
-
} catch (error) {
|
|
429
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
430
|
-
process.exit(1);
|
|
431
|
-
}
|
|
432
|
-
let runtime_mode = "interactive";
|
|
433
|
-
if (args.mode) {
|
|
434
|
-
const requested = String(args.mode).trim().toLowerCase();
|
|
435
|
-
if (![
|
|
436
|
-
"interactive",
|
|
437
|
-
"print",
|
|
438
|
-
"json",
|
|
439
|
-
"rpc"
|
|
440
|
-
].includes(requested)) {
|
|
441
|
-
console.error("Error: --mode must be one of interactive, print, json, rpc.");
|
|
442
|
-
process.exit(1);
|
|
443
|
-
}
|
|
444
|
-
runtime_mode = requested;
|
|
445
|
-
}
|
|
446
|
-
if (args.json) runtime_mode = "json";
|
|
447
|
-
else if (args.print) runtime_mode = "print";
|
|
448
|
-
const positionals = parsed_extension_cli.positionals;
|
|
449
|
-
if (positionals?.[0] === "observability") {
|
|
450
|
-
const { start_observability_server } = await import("@spences10/pi-observability/server");
|
|
451
|
-
start_observability_server();
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
let prompt = args.prompt;
|
|
455
|
-
if (!prompt && positionals && positionals.length > 0) prompt = positionals.join(" ");
|
|
456
|
-
if (!prompt && !process.stdin.isTTY && runtime_mode !== "rpc") prompt = await read_stdin();
|
|
457
|
-
if (prompt && runtime_mode === "interactive") runtime_mode = "print";
|
|
458
|
-
if (runtime_mode === "interactive" && !prompt && !process.stdout.isTTY) {
|
|
459
|
-
await print_usage(main);
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
if (runtime_mode !== "interactive") process.stderr.write(`my-pi: connecting to ${args.model || "default model"}...\n`);
|
|
463
|
-
if (args.telemetry && args["no-telemetry"]) {
|
|
464
|
-
console.error("Error: --telemetry and --no-telemetry cannot be used together.");
|
|
465
|
-
process.exit(1);
|
|
466
|
-
}
|
|
467
|
-
if (args.session && args["session-id"]) {
|
|
468
|
-
console.error("Error: --session and --session-id cannot be used together.");
|
|
469
|
-
process.exit(1);
|
|
470
|
-
}
|
|
471
|
-
let telemetry_override;
|
|
472
|
-
if (args.telemetry) telemetry_override = true;
|
|
473
|
-
else if (args["no-telemetry"]) telemetry_override = false;
|
|
474
|
-
const [{ create_my_pi }, { InteractiveMode, runPrintMode, runRpcMode }] = await Promise.all([import("./api.js"), import("@earendil-works/pi-coding-agent")]);
|
|
475
|
-
const runtime = await create_my_pi({
|
|
476
|
-
cwd,
|
|
477
|
-
agent_dir: args["agent-dir"],
|
|
478
|
-
session_dir: args["session-dir"],
|
|
479
|
-
extensions: extension_paths,
|
|
480
|
-
extension_flag_values: parsed_extension_cli.extension_flag_values,
|
|
481
|
-
runtime_mode,
|
|
482
|
-
...resolve_builtin_extension_options(args),
|
|
483
|
-
telemetry: telemetry_override,
|
|
484
|
-
telemetry_db_path: args["telemetry-db"],
|
|
485
|
-
model: args.model,
|
|
486
|
-
thinking: selected_thinking,
|
|
487
|
-
selected_tools,
|
|
488
|
-
excluded_tools,
|
|
489
|
-
selected_skills,
|
|
490
|
-
session: args.session,
|
|
491
|
-
session_id: args["session-id"],
|
|
492
|
-
startup_session_name: args.name,
|
|
493
|
-
system_prompt: args["system-prompt"],
|
|
494
|
-
append_system_prompt: args["append-system-prompt"],
|
|
495
|
-
untrusted_repo: args.untrusted
|
|
496
|
-
});
|
|
497
|
-
for (const diagnostic of runtime.diagnostics) {
|
|
498
|
-
const prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
|
|
499
|
-
console.error(`${prefix}${diagnostic.message}`);
|
|
500
|
-
}
|
|
501
|
-
if (runtime.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
502
|
-
await runtime.dispose();
|
|
503
|
-
process.exit(1);
|
|
504
|
-
}
|
|
505
|
-
if (runtime_mode === "rpc") await runRpcMode(runtime);
|
|
506
|
-
else if (runtime_mode === "print" || runtime_mode === "json") {
|
|
507
|
-
const code = await runPrintMode(runtime, {
|
|
508
|
-
mode: runtime_mode === "json" ? "json" : "text",
|
|
509
|
-
initialMessage: prompt || "",
|
|
510
|
-
initialImages: [],
|
|
511
|
-
messages: []
|
|
512
|
-
});
|
|
513
|
-
process.exit(code);
|
|
514
|
-
} else if (!process.stdout.isTTY) await print_usage(main);
|
|
515
|
-
else await run_interactive_mode(runtime, InteractiveMode);
|
|
516
|
-
}
|
|
37
|
+
const args = process.argv.slice(2);
|
|
38
|
+
const theme_args = is_enabled('themes') && !subcommands.has(args[0])
|
|
39
|
+
? ['--theme', themes_dir()]
|
|
40
|
+
: [];
|
|
41
|
+
await main([...theme_args, ...args], {
|
|
42
|
+
extensionFactories: extensions,
|
|
517
43
|
});
|
|
518
|
-
runMain(main, { showUsage: async (cmd, parent) => {
|
|
519
|
-
await print_usage(cmd, parent);
|
|
520
|
-
} });
|
|
521
|
-
export {};
|
|
522
|
-
|
|
523
44
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cli-args.ts","../src/runtime-preflight.ts","../src/warnings.ts","../src/index.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionOptionName,\n} from './extensions/builtin-registry.js';\n\nconst THINKING_LEVELS = new Set([\n\t'off',\n\t'minimal',\n\t'low',\n\t'medium',\n\t'high',\n\t'xhigh',\n]);\n\nexport type CliThinkingLevel =\n\t| 'off'\n\t| 'minimal'\n\t| 'low'\n\t| 'medium'\n\t| 'high'\n\t| 'xhigh';\n\nexport type BuiltinDisableCliArgs = Record<\n\tstring,\n\t{\n\t\ttype: 'boolean';\n\t\tdescription: string;\n\t\tdefault: false;\n\t}\n>;\n\nexport interface CliArgDefinition {\n\ttype: 'boolean' | 'string' | 'enum' | 'positional';\n\talias?: string | readonly string[];\n}\n\nexport type CliArgDefinitions = Record<string, CliArgDefinition>;\n\nexport interface ParsedExtensionCliArgs {\n\textension_flag_values: Map<string, boolean | string>;\n\tpositionals: string[];\n\tdiagnostics: string[];\n}\n\nexport function create_builtin_disable_cli_args(): BuiltinDisableCliArgs {\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.cli_arg,\n\t\t\t{\n\t\t\t\ttype: 'boolean' as const,\n\t\t\t\tdescription: extension.cli_description,\n\t\t\t\tdefault: false as const,\n\t\t\t},\n\t\t]),\n\t);\n}\n\nfunction is_citty_no_flag_set(\n\targs: Record<string, unknown>,\n\tcli_arg: string,\n): boolean {\n\tif (args[cli_arg]) return true;\n\n\tconst positive_kebab = cli_arg.replace(/^no-/, '');\n\tconst positive_camel = positive_kebab.replace(\n\t\t/-([a-z])/g,\n\t\t(_, char) => String(char).toUpperCase(),\n\t);\n\treturn (\n\t\targs[positive_kebab] === false || args[positive_camel] === false\n\t);\n}\n\nexport function resolve_builtin_extension_options(\n\targs: Record<string, unknown>,\n): Partial<Record<BuiltinExtensionOptionName, boolean>> {\n\tconst no_builtin = is_citty_no_flag_set(args, 'no-builtin');\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.option_name,\n\t\t\t!no_builtin &&\n\t\t\t\t!is_citty_no_flag_set(args, extension.cli_arg) &&\n\t\t\t\textension.default_enabled,\n\t\t]),\n\t) as Partial<Record<BuiltinExtensionOptionName, boolean>>;\n}\n\nexport function parse_extension_cli_args(\n\targv: string[],\n\tknown_args: CliArgDefinitions,\n): ParsedExtensionCliArgs {\n\tconst known_flags = new Map<string, CliArgDefinition['type']>();\n\tfor (const [name, definition] of Object.entries(known_args)) {\n\t\tknown_flags.set(`--${name}`, definition.type);\n\t\tconst camel_name = name.replace(/-([a-z])/g, (_, char) =>\n\t\t\tString(char).toUpperCase(),\n\t\t);\n\t\tknown_flags.set(`--${camel_name}`, definition.type);\n\t\tif (definition.type === 'boolean')\n\t\t\tknown_flags.set(`--no-${name}`, definition.type);\n\t\tconst aliases = Array.isArray(definition.alias)\n\t\t\t? definition.alias\n\t\t\t: definition.alias\n\t\t\t\t? [definition.alias]\n\t\t\t\t: [];\n\t\tfor (const alias of aliases)\n\t\t\tknown_flags.set(`-${alias}`, definition.type);\n\t}\n\n\tconst extension_flag_values = new Map<string, boolean | string>();\n\tconst positionals: string[] = [];\n\tconst diagnostics: string[] = [];\n\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i];\n\t\tif (!arg) continue;\n\t\tif (arg === '--') {\n\t\t\tpositionals.push(...argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tconst equals_index = arg.indexOf('=');\n\t\tconst flag_token =\n\t\t\tequals_index === -1 ? arg : arg.slice(0, equals_index);\n\t\tconst known_type = known_flags.get(flag_token);\n\t\tif (known_type) {\n\t\t\tif (\n\t\t\t\tequals_index === -1 &&\n\t\t\t\t(known_type === 'string' || known_type === 'enum') &&\n\t\t\t\ti + 1 < argv.length &&\n\t\t\t\targv[i + 1] !== '--'\n\t\t\t) {\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith('--')) {\n\t\t\tif (equals_index !== -1) {\n\t\t\t\textension_flag_values.set(\n\t\t\t\t\targ.slice(2, equals_index),\n\t\t\t\t\targ.slice(equals_index + 1),\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst name = arg.slice(2);\n\t\t\tconst next = argv[i + 1];\n\t\t\tif (\n\t\t\t\tnext !== undefined &&\n\t\t\t\t!next.startsWith('-') &&\n\t\t\t\t!next.startsWith('@')\n\t\t\t) {\n\t\t\t\textension_flag_values.set(name, next);\n\t\t\t\ti += 1;\n\t\t\t} else {\n\t\t\t\textension_flag_values.set(name, true);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith('-')) {\n\t\t\tdiagnostics.push(`Unknown option: ${arg}`);\n\t\t\tcontinue;\n\t\t}\n\t\tpositionals.push(arg);\n\t}\n\n\treturn { extension_flag_values, positionals, diagnostics };\n}\n\nexport function collect_flag_values(\n\targv: string[],\n\tflags: readonly string[],\n): string[] {\n\tconst values: string[] = [];\n\tconst flag_set = new Set(flags);\n\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i];\n\t\tif (arg === '--') break;\n\t\tif (!arg) continue;\n\n\t\tconst equals_index = arg.indexOf('=');\n\t\tif (equals_index !== -1) {\n\t\t\tconst name = arg.slice(0, equals_index);\n\t\t\tif (flag_set.has(name)) {\n\t\t\t\tvalues.push(arg.slice(equals_index + 1));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (flag_set.has(arg) && i + 1 < argv.length) {\n\t\t\tconst next = argv[i + 1];\n\t\t\tif (next !== undefined && next !== '--') {\n\t\t\t\tvalues.push(next);\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn values;\n}\n\nexport function parse_extension_paths(\n\targv: string[],\n\tcwd = process.cwd(),\n): string[] {\n\treturn collect_flag_values(argv, ['-e', '--extension'])\n\t\t.map((path) => path.trim())\n\t\t.filter(Boolean)\n\t\t.map((path) => resolve(cwd, path));\n}\n\nfunction parse_comma_list_flags(\n\targv: string[],\n\tflags: readonly string[],\n): string[] | undefined {\n\tconst values = collect_flag_values(argv, flags)\n\t\t.flatMap((value) => value.split(','))\n\t\t.map((value) => value.trim())\n\t\t.filter(Boolean);\n\treturn values.length ? [...new Set(values)] : undefined;\n}\n\nexport function parse_tool_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--tools', '-t']);\n}\n\nexport function parse_tool_excludelist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--exclude-tools', '-xt']);\n}\n\nexport function parse_skill_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--skill']);\n}\n\nexport function parse_thinking_level(\n\tvalue: string | undefined,\n): CliThinkingLevel | undefined {\n\tconst normalized = value?.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\tif (!THINKING_LEVELS.has(normalized)) {\n\t\tthrow new Error(\n\t\t\t'--thinking must be one of: off, minimal, low, medium, high, xhigh.',\n\t\t);\n\t}\n\treturn normalized as CliThinkingLevel;\n}\n","export const MINIMUM_NODE_VERSION = '24.15.0';\n\nfunction parse_node_version(\n\tversion: string,\n): [number, number, number] | undefined {\n\tconst match = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:[-+].*)?$/.exec(version);\n\tif (!match) return undefined;\n\treturn [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\nexport function is_supported_node_version(version: string): boolean {\n\tconst current = parse_node_version(version);\n\tconst minimum = parse_node_version(MINIMUM_NODE_VERSION);\n\tif (!current || !minimum) return false;\n\n\tfor (let index = 0; index < current.length; index++) {\n\t\tif (current[index] > minimum[index]) return true;\n\t\tif (current[index] < minimum[index]) return false;\n\t}\n\treturn true;\n}\n\nexport function get_node_preflight_error(\n\tcurrent_version = process.versions.node,\n): string | undefined {\n\tif (is_supported_node_version(current_version)) return undefined;\n\treturn `my-pi requires Node >=${MINIMUM_NODE_VERSION}; current version is ${current_version}. Upgrade Node and retry.`;\n}\n","const SQLITE_EXPERIMENTAL_WARNING =\n\t'SQLite is an experimental feature';\nconst FILTER_INSTALLED = Symbol.for(\n\t'my-pi.sqlite-warning-filter-installed',\n);\nconst ORIGINAL_EMIT_WARNING = Symbol.for(\n\t'my-pi.original-emit-warning',\n);\n\ntype WarningEmitter = Pick<typeof process, 'emitWarning'> & {\n\t[FILTER_INSTALLED]?: boolean;\n\t[ORIGINAL_EMIT_WARNING]?: typeof process.emitWarning;\n};\n\nexport function should_suppress_warning(warning: Error): boolean {\n\treturn (\n\t\twarning.name === 'ExperimentalWarning' &&\n\t\twarning.message.includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nfunction should_suppress_emit_warning_args(args: unknown[]): boolean {\n\tconst [warning, options_or_type] = args;\n\tif (warning instanceof Error)\n\t\treturn should_suppress_warning(warning);\n\tconst warning_type =\n\t\ttypeof options_or_type === 'string'\n\t\t\t? options_or_type\n\t\t\t: options_or_type && typeof options_or_type === 'object'\n\t\t\t\t? (options_or_type as { type?: unknown }).type\n\t\t\t\t: undefined;\n\treturn (\n\t\twarning_type === 'ExperimentalWarning' &&\n\t\tString(warning).includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nexport function install_sqlite_warning_filter(\n\tprocess_like: WarningEmitter = process,\n): void {\n\tif (process_like[FILTER_INSTALLED]) return;\n\tprocess_like[FILTER_INSTALLED] = true;\n\n\tconst original_emit_warning =\n\t\tprocess_like[ORIGINAL_EMIT_WARNING] ?? process_like.emitWarning;\n\tprocess_like[ORIGINAL_EMIT_WARNING] = original_emit_warning;\n\n\tprocess_like.emitWarning = function emit_filtered_warning(\n\t\tthis: WarningEmitter,\n\t\t...args: unknown[]\n\t) {\n\t\tif (should_suppress_emit_warning_args(args)) return;\n\t\treturn (\n\t\t\toriginal_emit_warning as (...args: unknown[]) => void\n\t\t).apply(this, args);\n\t} as typeof process.emitWarning;\n}\n","#!/usr/bin/env node\n\nimport {\n\tdefineCommand,\n\trenderUsage,\n\trunMain,\n\ttype ArgsDef,\n\ttype CommandDef,\n} from 'citty';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n\tcreate_builtin_disable_cli_args,\n\tparse_extension_cli_args,\n\tparse_extension_paths,\n\tparse_skill_allowlist,\n\tparse_thinking_level,\n\tparse_tool_allowlist,\n\tparse_tool_excludelist,\n\tresolve_builtin_extension_options,\n\ttype CliArgDefinitions,\n} from './cli-args.js';\nimport { get_node_preflight_error } from './runtime-preflight.js';\nimport { install_sqlite_warning_filter } from './warnings.js';\n\nconst node_preflight_error = get_node_preflight_error();\nif (node_preflight_error) {\n\tconsole.error(node_preflight_error);\n\tprocess.exit(1);\n}\n\ninstall_sqlite_warning_filter();\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst package_root = join(__dirname, '..');\nconst pkg = JSON.parse(\n\treadFileSync(join(package_root, 'package.json'), 'utf-8'),\n);\n\n// my-pi is a wrapper around Pi; upstream Pi update banners are useful in\n// this repo, but confusing for installed wrapper users.\nif (!existsSync(join(package_root, '.git'))) {\n\tprocess.env.PI_SKIP_VERSION_CHECK ??= '1';\n}\n\nasync function read_stdin(): Promise<string> {\n\tconst chunks: Buffer[] = [];\n\tfor await (const chunk of process.stdin) {\n\t\tchunks.push(chunk as Buffer);\n\t}\n\treturn Buffer.concat(chunks).toString('utf-8').trim();\n}\n\ntype MyPiRuntime = Awaited<\n\tReturnType<(typeof import('./api.js'))['create_my_pi']>\n>;\ntype InteractiveModeConstructor =\n\t(typeof import('@earendil-works/pi-coding-agent'))['InteractiveMode'];\n\nasync function run_interactive_mode(\n\truntime: MyPiRuntime,\n\tInteractiveModeClass: InteractiveModeConstructor,\n): Promise<void> {\n\tconst original_write = process.stdout.write.bind(process.stdout);\n\tprocess.stdout.write = ((\n\t\tchunk: string | Uint8Array,\n\t\t...args: Parameters<typeof original_write>\n\t) => {\n\t\tif (typeof chunk === 'string') {\n\t\t\tconst escape = String.fromCharCode(27);\n\t\t\tconst styled_hint = new RegExp(\n\t\t\t\t`(To resume this session:${escape}\\\\[[\\\\d;]*m )pi( --session )`,\n\t\t\t\t'g',\n\t\t\t);\n\t\t\tchunk = chunk.replace(styled_hint, '$1my-pi$2');\n\t\t\tchunk = chunk.replace(\n\t\t\t\t/(To resume this session: )pi( --session )/g,\n\t\t\t\t'$1my-pi$2',\n\t\t\t);\n\t\t}\n\t\treturn Reflect.apply(original_write, process.stdout, [\n\t\t\tchunk,\n\t\t\t...args,\n\t\t]);\n\t}) as typeof process.stdout.write;\n\ttry {\n\t\tconst mode = new InteractiveModeClass(runtime, {\n\t\t\tmigratedProviders: [],\n\t\t\tmodelFallbackMessage: undefined,\n\t\t\tinitialMessage: undefined,\n\t\t\tinitialImages: [],\n\t\t\tinitialMessages: [],\n\t\t});\n\t\tawait mode.run();\n\t} finally {\n\t\tprocess.stdout.write =\n\t\t\toriginal_write as typeof process.stdout.write;\n\t}\n}\n\nconst HELP_APPENDIX = `\nMODES\n\n my-pi\n Interactive TUI with slash commands, editor, and session UI.\n\n my-pi \"prompt\"\n my-pi -P \"prompt\"\n One-shot print mode with plain text output.\n\n my-pi --json \"prompt\"\n Non-interactive NDJSON mode for scripts, evals, and other agents.\n\n my-pi --mode rpc\n RPC mode over stdin/stdout JSONL for orchestrators and teammate sessions.\n\nNOTES\n\n - In non-interactive modes, my-pi keeps headless-capable built-ins like\n MCP, LSP, prompt presets, recall, nopeek, Omnisearch, SQLite tools, hooks, and secret redaction.\n - UI-only built-ins like session auto-naming are skipped.\n - Repeat -e / --extension to compose multiple extensions.\n - Positional prompt arguments are joined with a single space.\n - Everything after -- is prompt text, not options.\n - --prompt takes precedence over positional prompt text and stdin.\n\nNESTED RUNS\n\n - Child runs inherit cwd and environment unless you isolate them explicitly.\n - Use --agent-dir to isolate auth, config, sessions, and telemetry state.\n - For safer evals or unknown repos, use --untrusted plus an explicit\n --system-prompt.\n\nEXAMPLES\n\n my-pi\n my-pi \"fix the failing test\"\n my-pi -P \"summarize this repo\"\n my-pi --json \"list all TODO comments\"\n echo \"plan a login page\" | my-pi --json\n my-pi --telemetry --json \"run eval case\"\n my-pi --telemetry --telemetry-db ./tmp/evals.db --json \"run case\"\n my-pi observability\n my-pi --untrusted --agent-dir /tmp/pi-agent --json \"run case\"\n my-pi -e ./my-ext.ts -e ./other-ext.ts \"hello\"\n my-pi -m claude-haiku-4-5-20241022 \"explain this file\"\n XIAOMI_API_KEY=... my-pi -m xiaomi/mimo-v2.5-pro \"summarize this repo\"\n my-pi -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast \"explain this file\"\n my-pi --preset terse,no-purple-prose \"summarize this repo\"\n my-pi --system-prompt \"You are a JSON classifier. Return only JSON.\" --json \"classify this\"\n\nPROMPT PRESETS\n\n Interactive commands:\n /prompt-preset help\n /prompt-preset export-defaults\n /prompt-preset edit-global terse\n /prompt-preset base detailed\n /prompt-preset enable bullets\n\n Short alias: /preset\n\n Editable preset files:\n ~/.pi/agent/presets/*.md\n .pi/presets/*.md\n`;\n\nasync function render_rich_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<string> {\n\treturn `${await renderUsage(cmd, parent)}\\n${HELP_APPENDIX}`;\n}\n\nasync function print_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<void> {\n\tconsole.log(await render_rich_usage(cmd, parent));\n}\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'my-pi',\n\t\tversion: pkg.version,\n\t\tdescription:\n\t\t\t'Composable pi coding agent with MCP, LSP, presets, and local eval telemetry',\n\t},\n\targs: {\n\t\tprint: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'P',\n\t\t\tdescription: 'Print mode (non-interactive, one-shot)',\n\t\t\tdefault: false,\n\t\t},\n\t\t'agent-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi auth/config/session directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi session storage directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'j',\n\t\t\tdescription: 'Output NDJSON events (for agent consumption)',\n\t\t\tdefault: false,\n\t\t},\n\t\tmode: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Runtime mode: interactive, print, json, or rpc',\n\t\t\trequired: false,\n\t\t},\n\t\textension: {\n\t\t\ttype: 'string',\n\t\t\talias: 'e',\n\t\t\tdescription:\n\t\t\t\t'Extension path to load; repeatable via argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'no-builtin': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable all built-in extensions',\n\t\t\tdefault: false,\n\t\t},\n\t\tuntrusted: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription:\n\t\t\t\t'Safe mode for unknown repos: skip project MCP, hooks, project prompt presets, project skills, and project LSP binaries unless explicitly re-enabled',\n\t\t\tdefault: false,\n\t\t},\n\t\t...create_builtin_disable_cli_args(),\n\t\ttelemetry: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Enable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'no-telemetry': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'telemetry-db': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override telemetry database path for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tmodel: {\n\t\t\ttype: 'string',\n\t\t\talias: 'm',\n\t\t\tdescription:\n\t\t\t\t'Model to use (e.g. claude-sonnet-4-5-20241022, gpt-5.4, cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast)',\n\t\t},\n\t\tthinking: {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Thinking level: off, minimal, low, medium, high, or xhigh',\n\t\t\trequired: false,\n\t\t},\n\t\ttools: {\n\t\t\ttype: 'string',\n\t\t\talias: 't',\n\t\t\tdescription:\n\t\t\t\t'Comma-separated allowlist of tool names to enable',\n\t\t\trequired: false,\n\t\t},\n\t\t'exclude-tools': {\n\t\t\ttype: 'string',\n\t\t\talias: 'xt',\n\t\t\tdescription: 'Comma-separated list of tool names to disable',\n\t\t\trequired: false,\n\t\t},\n\t\tsession: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Resume a specific session file or session ID',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-id': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Create or resume an exact project-local session ID',\n\t\t\trequired: false,\n\t\t},\n\t\tname: {\n\t\t\ttype: 'string',\n\t\t\talias: 'n',\n\t\t\tdescription: 'Set the session display name at startup',\n\t\t\trequired: false,\n\t\t},\n\t\tskill: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Skill name to allow; repeatable in argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Replace the base system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\t'append-system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Append one-off instructions to the system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: 'string',\n\t\t\talias: 'p',\n\t\t\tdescription: 'Prompt text (alternative to positional argument)',\n\t\t\trequired: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst cwd = process.cwd();\n\t\tconst cli_argv = process.argv.slice(2);\n\t\tconst parsed_extension_cli = parse_extension_cli_args(\n\t\t\tcli_argv,\n\t\t\tmain.args as CliArgDefinitions,\n\t\t);\n\t\tif (parsed_extension_cli.diagnostics.length) {\n\t\t\tfor (const message of parsed_extension_cli.diagnostics)\n\t\t\t\tconsole.error(`Error: ${message}`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconst extension_paths = parse_extension_paths(cli_argv, cwd);\n\t\tconst selected_tools = parse_tool_allowlist(cli_argv);\n\t\tconst excluded_tools = parse_tool_excludelist(cli_argv);\n\t\tconst selected_skills = parse_skill_allowlist(cli_argv);\n\t\tlet selected_thinking;\n\t\ttry {\n\t\t\tselected_thinking = parse_thinking_level(args.thinking);\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet runtime_mode: 'interactive' | 'print' | 'json' | 'rpc' =\n\t\t\t'interactive';\n\t\tif (args.mode) {\n\t\t\tconst requested = String(args.mode).trim().toLowerCase();\n\t\t\tif (\n\t\t\t\t!['interactive', 'print', 'json', 'rpc'].includes(requested)\n\t\t\t) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Error: --mode must be one of interactive, print, json, rpc.',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\truntime_mode = requested as\n\t\t\t\t| 'interactive'\n\t\t\t\t| 'print'\n\t\t\t\t| 'json'\n\t\t\t\t| 'rpc';\n\t\t}\n\t\tif (args.json) runtime_mode = 'json';\n\t\telse if (args.print) runtime_mode = 'print';\n\n\t\tconst positionals = parsed_extension_cli.positionals;\n\t\tif (positionals?.[0] === 'observability') {\n\t\t\tconst { start_observability_server } =\n\t\t\t\tawait import('@spences10/pi-observability/server');\n\t\t\tstart_observability_server();\n\t\t\treturn;\n\t\t}\n\n\t\t// Resolve prompt: named --prompt flag > positional > stdin\n\t\tlet prompt = args.prompt;\n\t\tif (!prompt && positionals && positionals.length > 0) {\n\t\t\tprompt = positionals.join(' ');\n\t\t}\n\t\tif (!prompt && !process.stdin.isTTY && runtime_mode !== 'rpc') {\n\t\t\tprompt = await read_stdin();\n\t\t}\n\t\tif (prompt && runtime_mode === 'interactive')\n\t\t\truntime_mode = 'print';\n\n\t\tif (\n\t\t\truntime_mode === 'interactive' &&\n\t\t\t!prompt &&\n\t\t\t!process.stdout.isTTY\n\t\t) {\n\t\t\tawait print_usage(main);\n\t\t\treturn;\n\t\t}\n\n\t\t// Startup feedback so silence = broken (issue #3)\n\t\tif (runtime_mode !== 'interactive') {\n\t\t\tprocess.stderr.write(\n\t\t\t\t`my-pi: connecting to ${args.model || 'default model'}...\\n`,\n\t\t\t);\n\t\t}\n\n\t\tif (args.telemetry && args['no-telemetry']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --telemetry and --no-telemetry cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (args.session && args['session-id']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --session and --session-id cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet telemetry_override: boolean | undefined;\n\t\tif (args.telemetry) {\n\t\t\ttelemetry_override = true;\n\t\t} else if (args['no-telemetry']) {\n\t\t\ttelemetry_override = false;\n\t\t}\n\n\t\tconst [\n\t\t\t{ create_my_pi },\n\t\t\t{ InteractiveMode, runPrintMode, runRpcMode },\n\t\t] = await Promise.all([\n\t\t\timport('./api.js'),\n\t\t\timport('@earendil-works/pi-coding-agent'),\n\t\t]);\n\n\t\tconst runtime = await create_my_pi({\n\t\t\tcwd,\n\t\t\tagent_dir: args['agent-dir'],\n\t\t\tsession_dir: args['session-dir'],\n\t\t\textensions: extension_paths,\n\t\t\textension_flag_values:\n\t\t\t\tparsed_extension_cli.extension_flag_values,\n\t\t\truntime_mode,\n\t\t\t...resolve_builtin_extension_options(args),\n\t\t\ttelemetry: telemetry_override,\n\t\t\ttelemetry_db_path: args['telemetry-db'],\n\t\t\tmodel: args.model,\n\t\t\tthinking: selected_thinking,\n\t\t\tselected_tools,\n\t\t\texcluded_tools,\n\t\t\tselected_skills,\n\t\t\tsession: args.session,\n\t\t\tsession_id: args['session-id'],\n\t\t\tstartup_session_name: args.name,\n\t\t\tsystem_prompt: args['system-prompt'],\n\t\t\tappend_system_prompt: args['append-system-prompt'],\n\t\t\tuntrusted_repo: args.untrusted,\n\t\t});\n\n\t\tfor (const diagnostic of runtime.diagnostics) {\n\t\t\tconst prefix =\n\t\t\t\tdiagnostic.type === 'error'\n\t\t\t\t\t? 'Error: '\n\t\t\t\t\t: diagnostic.type === 'warning'\n\t\t\t\t\t\t? 'Warning: '\n\t\t\t\t\t\t: '';\n\t\t\tconsole.error(`${prefix}${diagnostic.message}`);\n\t\t}\n\t\tif (\n\t\t\truntime.diagnostics.some(\n\t\t\t\t(diagnostic) => diagnostic.type === 'error',\n\t\t\t)\n\t\t) {\n\t\t\tawait runtime.dispose();\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tif (runtime_mode === 'rpc') {\n\t\t\tawait runRpcMode(runtime);\n\t\t} else if (runtime_mode === 'print' || runtime_mode === 'json') {\n\t\t\tconst code = await runPrintMode(runtime, {\n\t\t\t\tmode: runtime_mode === 'json' ? 'json' : 'text',\n\t\t\t\tinitialMessage: prompt || '',\n\t\t\t\tinitialImages: [],\n\t\t\t\tmessages: [],\n\t\t\t});\n\t\t\tprocess.exit(code);\n\t\t} else if (!process.stdout.isTTY) {\n\t\t\tawait print_usage(main);\n\t\t} else {\n\t\t\tawait run_interactive_mode(runtime, InteractiveMode);\n\t\t}\n\t},\n});\n\nvoid runMain(main, {\n\tshowUsage: async (cmd, parent) => {\n\t\tawait print_usage(cmd, parent);\n\t},\n});\n"],"mappings":";;;;;;;AAMA,MAAM,kCAAkB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAgCD,SAAgB,kCAAy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;GACtB,gBAAgB,KAAA;GAChB,eAAe,CAAC;GAChB,iBAAiB,CAAC;EACnB,CACS,CAAC,CAAC,IAAI;CAChB,UAAU;EACT,QAAQ,OAAO,QACd;CACF;AACD;AAEA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEtB,eAAe,kBACd,KACA,QACkB;CAClB,OAAO,GAAG,MAAM,YAAY,KAAK,MAAM,EAAE,IAAI;AAC9C;AAEA,eAAe,YACd,KACA,QACgB;CAChB,QAAQ,IAAI,MAAM,kBAAkB,KAAK,MAAM,CAAC;AACjD;AAEA,MAAM,OAAO,cAAc;CAC1B,MAAM;EACL,MAAM;EACN,SAAS,IAAI;EACb,aACC;CACF;CACA,MAAM;EACL,OAAO;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,aAAa;GACZ,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,eAAe;GACd,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,MAAM;GACL,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,MAAM;GACL,MAAM;GACN,aAAa;GACb,UAAU;EACX;EACA,WAAW;GACV,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EACX;EACA,cAAc;GACb,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,WAAW;GACV,MAAM;GACN,aACC;GACD,SAAS;EACV;EACA,GAAG,gCAAgC;EACnC,WAAW;GACV,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;EACF;EACA,UAAU;GACT,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EAC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