@tomsun28/pizza 0.0.1 → 0.0.4

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.
@@ -0,0 +1,247 @@
1
+ /**
2
+ * pi-pizza extension
3
+ *
4
+ * Replaces JSON tool calling with [CLI] tag output — the "pizza" approach.
5
+ * The LLM emits [CLI] toolName args[/CLI] text blocks instead of native tool
6
+ * calls. Results are returned as [RESULT]...[/RESULT] text. Conversation
7
+ * history is rewritten so the model always sees the [CLI]/[RESULT] format.
8
+ *
9
+ * Supports: ls, read, write, edit, grep, bash
10
+ *
11
+ * Usage in pi:
12
+ * /pizza-mode — toggle pizza mode on/off
13
+ */
14
+ import { Text } from "@mariozechner/pi-tui";
15
+ import { MAX_CALLS_PER_TURN, buildResultBlock, dispatchTool, parseCLICalls, reconstructCliText, } from "./core.js";
16
+ // ─── System prompt addon ───────────────────────────────────────────────────────
17
+ const PIZZA_SYSTEM_PROMPT = `
18
+ You interact with the user's environment by issuing commands wrapped in [CLI]...[/CLI] tags.
19
+ Any [CLI] blocks you emit are executed immediately; results come back as [RESULT]...[/RESULT] text.
20
+ You may include multiple [CLI] blocks in a single response — they all run before your next reply.
21
+ When issuing multiple [CLI] blocks, add an id attribute to each for result mapping: [CLI id=1] ... [/CLI]
22
+
23
+ ## Commands
24
+
25
+ [CLI] ls <path>[/CLI]
26
+ [CLI] read <path>[/CLI]
27
+ [CLI] read <path> --offset <n> --limit <n>[/CLI]
28
+ [CLI] write --path <path> --content <content>[/CLI]
29
+ [CLI] edit --path <path> --old <oldText> --new <newText>[/CLI]
30
+ [CLI] grep <pattern> --path <dir> --include <glob>[/CLI]
31
+ [CLI] bash <any shell command>[/CLI]
32
+
33
+ ## Examples
34
+
35
+ Example 1 — Explore the project (your response ends right after the [/CLI] tags):
36
+
37
+ [CLI id=1] ls .[/CLI]
38
+ [CLI id=2] bash node --version[/CLI]
39
+
40
+ (System will execute both commands and inject [RESULT] blocks automatically. You will see them in the next turn.)
41
+
42
+ Example 2 — After receiving results, you can issue more commands or respond normally:
43
+
44
+ The project has a \`src/\` directory and a \`package.json\`. Node is v22.3.0. Let me look at the code:
45
+
46
+ [CLI id=1] read src/app.ts[/CLI]
47
+
48
+ Example 3 — When you have enough information, respond without any [CLI] blocks:
49
+
50
+ Done — the greeting has been updated to "Hi".
51
+
52
+ ## Rules
53
+
54
+ - Emit at most ${MAX_CALLS_PER_TURN} [CLI] blocks per response
55
+ - All [CLI] blocks in your response are executed before you continue
56
+ - After emitting [CLI] blocks, STOP immediately. Do NOT write anything after the last [/CLI] tag
57
+ - NEVER generate [RESULT] blocks yourself — they are injected by the system automatically after execution
58
+ - Do NOT predict, guess, or fabricate command output
59
+ - When you have all the information you need, respond normally without any [CLI] blocks
60
+ - Do NOT use markdown code blocks for commands you want executed
61
+ `.trim();
62
+ // ─── Extension ────────────────────────────────────────────────────────────────
63
+ export default function (pi) {
64
+ let pizzaModeActive = true;
65
+ // ── /pizza-mode command ──────────────────────────────────────────────────
66
+ pi.registerCommand("cli-mode", {
67
+ description: "Toggle [CLI] tag mode on/off (active by default at startup)",
68
+ handler: async (_args, ctx) => {
69
+ pizzaModeActive = !pizzaModeActive;
70
+ const status = pizzaModeActive ? "ON" : "OFF";
71
+ ctx.ui.notify(`CLI mode: ${status}`, "info");
72
+ ctx.ui.setStatus("cli-mode", pizzaModeActive ? "🍕 [CLI] on" : "🍕 cli");
73
+ },
74
+ });
75
+ // ── Inject system prompt ─────────────────────────────────────────────────
76
+ pi.on("before_agent_start", (event, _ctx) => {
77
+ if (!pizzaModeActive)
78
+ return;
79
+ return {
80
+ systemPrompt: event.systemPrompt + "\n\n" + PIZZA_SYSTEM_PROMPT,
81
+ };
82
+ });
83
+ // ── Strip tools from provider request ────────────────────────────────────
84
+ pi.on("before_provider_request", (event, _ctx) => {
85
+ if (!pizzaModeActive)
86
+ return;
87
+ const payload = { ...event.payload };
88
+ delete payload["tools"];
89
+ delete payload["tool_choice"];
90
+ delete payload["toolConfig"];
91
+ return payload;
92
+ });
93
+ // ── Parse [CLI] tags, execute tools, inject [RESULT] ─────────────────────
94
+ pi.on("agent_end", async (event, ctx) => {
95
+ if (!pizzaModeActive)
96
+ return;
97
+ const messages = event.messages;
98
+ // Find the last assistant text
99
+ let lastAssistantText = "";
100
+ for (let i = messages.length - 1; i >= 0; i--) {
101
+ const msg = messages[i];
102
+ if (msg.role === "assistant") {
103
+ if (typeof msg.content === "string") {
104
+ lastAssistantText = msg.content;
105
+ }
106
+ else if (Array.isArray(msg.content)) {
107
+ const textParts = msg.content
108
+ .filter((c) => c.type === "text")
109
+ .map((c) => c.text ?? "");
110
+ lastAssistantText = textParts.join("\n");
111
+ }
112
+ break;
113
+ }
114
+ }
115
+ const { calls } = parseCLICalls(lastAssistantText);
116
+ if (calls.length === 0)
117
+ return;
118
+ const cwd = ctx.cwd;
119
+ const toExecute = calls.slice(0, MAX_CALLS_PER_TURN);
120
+ const skipped = calls.length - toExecute.length;
121
+ // Execute all calls in parallel
122
+ const results = await Promise.all(toExecute.map(async (call) => {
123
+ try {
124
+ return await dispatchTool(call.toolName, call.rawArgs, cwd);
125
+ }
126
+ catch (err) {
127
+ return {
128
+ output: err instanceof Error ? err.message : String(err),
129
+ isError: true,
130
+ };
131
+ }
132
+ }));
133
+ // Build combined [RESULT] block(s)
134
+ const parts = results.map((r, i) => {
135
+ const call = toExecute[i];
136
+ const cliCmd = `${call.toolName}${call.rawArgs ? " " + call.rawArgs : ""}`;
137
+ return buildResultBlock(r.output, r.isError, call.id, results.length, cliCmd);
138
+ });
139
+ if (skipped > 0) {
140
+ parts.push(`[INFO] ${skipped} [CLI] call(s) were skipped (limit: ${MAX_CALLS_PER_TURN} per turn).`);
141
+ }
142
+ const content = parts.join("\n\n");
143
+ pi.sendMessage({ customType: "pizza-result", content, display: true }, { triggerTurn: true });
144
+ });
145
+ // ── Rewrite history: custom pizza-result → plain user text ───────────────
146
+ pi.on("context", (event, _ctx) => {
147
+ if (!pizzaModeActive)
148
+ return;
149
+ let modified = false;
150
+ const messages = event.messages.map((msg) => {
151
+ const custom = msg;
152
+ if (custom.role === "custom" && custom.customType === "pizza-result") {
153
+ modified = true;
154
+ return {
155
+ role: "user",
156
+ content: [{ type: "text", text: custom.content ?? "" }],
157
+ timestamp: custom.timestamp ?? Date.now(),
158
+ };
159
+ }
160
+ // Rewrite native tool_use/tool_result messages to [CLI]/[RESULT] text
161
+ // so the model's history stays in pizza format even across sessions
162
+ if (msg.role === "assistant" && Array.isArray(msg.content)) {
163
+ const content = msg.content;
164
+ const hasToolCalls = content.some((c) => c.type === "toolCall");
165
+ if (hasToolCalls) {
166
+ modified = true;
167
+ const textParts = [];
168
+ for (const block of content) {
169
+ if (block.type === "text" && block.text) {
170
+ textParts.push(block.text);
171
+ }
172
+ else if (block.type === "toolCall") {
173
+ const tc = block;
174
+ textParts.push(reconstructCliText(tc.name, tc.arguments));
175
+ }
176
+ }
177
+ return {
178
+ ...msg,
179
+ content: [{ type: "text", text: textParts.join("\n\n") }],
180
+ };
181
+ }
182
+ }
183
+ return msg;
184
+ });
185
+ if (modified)
186
+ return { messages };
187
+ });
188
+ // ── Custom renderer for pizza-result messages ─────────────────────────────
189
+ pi.registerMessageRenderer("pizza-result", (message, options, theme) => {
190
+ const content = typeof message.content === "string" ? message.content : "";
191
+ const resultPattern = /\[RESULT((?:\s+[^\]]*)?)\]([\s\S]*?)\[\/RESULT\]/g;
192
+ const PREVIEW_LINES = 2;
193
+ const lines = [];
194
+ let hasResults = false;
195
+ let match;
196
+ while ((match = resultPattern.exec(content)) !== null) {
197
+ hasResults = true;
198
+ const attrs = match[1] || "";
199
+ const isError = attrs.includes("error=true");
200
+ const body = match[2].trim();
201
+ const idMatch = attrs.match(/id=(\d+)/);
202
+ const cliMatch = attrs.match(/cli="((?:[^"\\]|\\.)*)"/);
203
+ const id = idMatch ? idMatch[1] : null;
204
+ const cli = cliMatch ? cliMatch[1].replace(/\\"/g, '"') : null;
205
+ const headerColor = isError ? "error" : "success";
206
+ const statusLabel = isError ? "error" : "ok";
207
+ const idLabel = id ? `[${id}]` : "";
208
+ const cliLabel = cli ? ` ${cli}` : "";
209
+ const header = `▶ result ${idLabel} ${statusLabel}${cliLabel}`;
210
+ lines.push(theme.fg(headerColor, header));
211
+ if (body) {
212
+ const bodyLines = body.split("\n");
213
+ const showAll = options.expanded || bodyLines.length <= PREVIEW_LINES;
214
+ const visible = showAll ? bodyLines : bodyLines.slice(0, PREVIEW_LINES);
215
+ for (const line of visible) {
216
+ lines.push(" " + theme.fg("dim", line));
217
+ }
218
+ if (!showAll) {
219
+ const hidden = bodyLines.length - PREVIEW_LINES;
220
+ lines.push(" " + theme.fg("muted", `... +${hidden} more lines (expand to see all)`));
221
+ }
222
+ }
223
+ else {
224
+ lines.push(" " + theme.fg("muted", "(no output)"));
225
+ }
226
+ lines.push("");
227
+ }
228
+ // Show any [INFO] lines (e.g. skipped calls notice)
229
+ const infoPattern = /\[INFO\] (.+)/g;
230
+ let infoMatch;
231
+ while ((infoMatch = infoPattern.exec(content)) !== null) {
232
+ lines.push(theme.fg("muted", `ℹ ${infoMatch[1]}`));
233
+ }
234
+ if (!hasResults) {
235
+ lines.push(theme.fg("muted", "(no pizza results)"));
236
+ }
237
+ return new Text(lines.join("\n"), 0, 0);
238
+ });
239
+ // ── Pizza UI customization ────────────────────────────────────────────────
240
+ pi.on("session_start", (_event, ctx) => {
241
+ ctx.ui.setTheme("pizza");
242
+ ctx.ui.setTitle("🍕 pizza");
243
+ ctx.ui.setWorkingMessage("🍕 baking...");
244
+ ctx.ui.setStatus("pizza-mode", pizzaModeActive ? "🍕 [CLI] on" : "🍕 pizza");
245
+ });
246
+ }
247
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extension/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5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AC,CAAC,KAAK,IAAI,EAAE,CAAC;YACzD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,6EAA6E;IAE7E,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACtC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEzB,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAE5B,GAAG,CAAC,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;QAE1C,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACJ,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/main.js CHANGED
@@ -1,88 +1,112 @@
1
1
  #!/usr/bin/env node
2
- import { createInterface } from "node:readline";
3
- import { createPizzaAgent } from "./agent.js";
4
- import { createRenderer } from "./ui/render.js";
5
- // ANSI helpers
6
- const bold = (s) => `\x1b[1m${s}\x1b[0m`;
7
- const dim = (s) => `\x1b[2m${s}\x1b[0m`;
8
- const green = (s) => `\x1b[32m${s}\x1b[0m`;
9
- const cyan = (s) => `\x1b[36m${s}\x1b[0m`;
10
- // Parse CLI args
2
+ import { InteractiveMode, SessionManager, createAgentSessionRuntime, createAgentSessionServices, createAgentSessionFromServices, getAgentDir, } from "@mariozechner/pi-coding-agent";
3
+ import { getModel } from "@mariozechner/pi-ai";
4
+ import { fileURLToPath } from "node:url";
5
+ import { join, dirname } from "node:path";
6
+ import pizzaExtension from "./extension/index.js";
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const THEMES_DIR = join(__dirname, "..", "themes");
9
+ // ─── Startup banner ─────────────────────────────────────────────────────────
10
+ function printBanner() {
11
+ const r = "\x1b[0m";
12
+ const b = "\x1b[1m";
13
+ const o = "\x1b[38;5;214m";
14
+ const d = "\x1b[2m";
15
+ const y = "\x1b[33m";
16
+ console.log();
17
+ console.log(o + b + " ██████╗ ██╗███████╗███████╗ █████╗ " + r);
18
+ console.log(o + b + " ██╔══██╗██║╚════██║╚════██║██╔══██╗" + r);
19
+ console.log(o + b + " ██████╔╝██║ ███╔╝ ███╔╝ ███████║" + r);
20
+ console.log(o + b + " ██╔═══╝ ██║ ██╔╝ ██╔╝ ██╔══██║" + r);
21
+ console.log(o + b + " ██║ ██║███████╗███████╗██║ ██║" + r);
22
+ console.log(o + b + " ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝" + r);
23
+ console.log();
24
+ console.log(y + " 🍕 CLI is all you need" + r);
25
+ console.log(d + " /cli-mode /help Ctrl+P: model Ctrl+T: think Ctrl+C: stop" + r);
26
+ console.log();
27
+ }
28
+ // ─── CLI arg parsing ──────────────────────────────────────────────────────────
11
29
  function parseArgs() {
12
30
  const args = process.argv.slice(2);
13
31
  const result = {};
14
32
  for (let i = 0; i < args.length; i++) {
15
- if (args[i] === "--provider" && args[i + 1]) {
33
+ if ((args[i] === "--provider" || args[i] === "-p") && args[i + 1]) {
16
34
  result.provider = args[++i];
17
35
  }
18
- else if (args[i] === "--model" && args[i + 1]) {
36
+ else if ((args[i] === "--model" || args[i] === "-m") && args[i + 1]) {
19
37
  result.model = args[++i];
20
38
  }
21
- else if (args[i] === "--api-key" && args[i + 1]) {
22
- result.apiKey = args[++i];
23
- }
24
39
  else if (args[i] === "--help" || args[i] === "-h") {
25
- console.log(`
26
- ${bold("pizza")} - A minimal coding agent
27
-
28
- ${bold("Usage:")}
29
- pizza [options]
30
-
31
- ${bold("Options:")}
32
- --provider <name> LLM provider (default: zai)
33
- --model <id> Model ID (default: glm-4.5)
34
- --api-key <key> API key (default: from env)
35
- -h, --help Show this help
36
-
37
- ${bold("Environment:")}
38
- ZAI_API_KEY ZAI API key
39
- ANTHROPIC_API_KEY Anthropic API key
40
- OPENAI_API_KEY OpenAI API key
41
- `);
40
+ printHelp();
42
41
  process.exit(0);
43
42
  }
43
+ else if (!args[i].startsWith("-")) {
44
+ result.message = args[i];
45
+ }
44
46
  }
45
47
  return result;
46
48
  }
49
+ function printHelp() {
50
+ console.log(`
51
+ 🍕 pizza — CLI is all you need
52
+
53
+ USAGE
54
+ pizza [options] [message]
55
+
56
+ OPTIONS
57
+ -p, --provider <name> LLM provider (default: from pizza settings)
58
+ -m, --model <id> Model ID (default: from pizza settings)
59
+ -h, --help Show this help
60
+
61
+ Powered by pi coding agent. Uses pi's TUI, session management, and extension system.
62
+ [CLI] tag mode is active by default. Use /pizza-mode inside the session to toggle it.
63
+ `);
64
+ }
65
+ // ─── Main ─────────────────────────────────────────────────────────────────────
47
66
  async function main() {
48
67
  const args = parseArgs();
49
- console.log(`\n${bold(green("🍕 pizza"))} ${dim("coding agent")}`);
50
- console.log(dim(`provider: ${args.provider ?? "zai"} | model: ${args.model ?? "glm-4.7"}`));
51
- console.log(dim(`cwd: ${process.cwd()}`));
52
- console.log(dim(`Type your message, or "exit" to quit.\n`));
53
- const { agent, model } = createPizzaAgent({
54
- provider: args.provider,
55
- model: args.model,
56
- apiKey: args.apiKey,
57
- });
58
- const render = createRenderer();
59
- agent.subscribe(render);
60
- const rl = createInterface({
61
- input: process.stdin,
62
- output: process.stdout,
63
- });
64
- const prompt = () => {
65
- rl.question(`${cyan(">")} `, async (input) => {
66
- const trimmed = input.trim();
67
- if (!trimmed) {
68
- prompt();
69
- return;
70
- }
71
- if (trimmed === "exit" || trimmed === "quit" || trimmed === "/exit" || trimmed === "/quit") {
72
- console.log(dim("\nBye!"));
73
- rl.close();
74
- process.exit(0);
75
- }
76
- try {
77
- await agent.prompt(trimmed);
78
- }
79
- catch (err) {
80
- console.error(`\n\x1b[31mError: ${err.message}\x1b[0m\n`);
81
- }
82
- prompt();
68
+ const cwd = process.cwd();
69
+ const createRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent }) => {
70
+ const services = await createAgentSessionServices({
71
+ cwd,
72
+ agentDir,
73
+ resourceLoaderOptions: {
74
+ extensionFactories: [pizzaExtension],
75
+ additionalThemePaths: [join(THEMES_DIR, "pizza.json")],
76
+ },
77
+ });
78
+ const { settingsManager } = services;
79
+ settingsManager.setQuietStartup(true);
80
+ let model;
81
+ if (args.provider && args.model) {
82
+ model = getModel(args.provider, args.model);
83
+ }
84
+ else if (args.model) {
85
+ model = getModel("openai", args.model);
86
+ }
87
+ const created = await createAgentSessionFromServices({
88
+ services,
89
+ sessionManager,
90
+ sessionStartEvent,
91
+ model,
83
92
  });
93
+ return { ...created, services, diagnostics: [] };
84
94
  };
85
- prompt();
95
+ const agentDir = getAgentDir();
96
+ const sessionManager = SessionManager.create(cwd);
97
+ const runtime = await createAgentSessionRuntime(createRuntime, {
98
+ cwd,
99
+ agentDir,
100
+ sessionManager,
101
+ });
102
+ const interactive = new InteractiveMode(runtime, {
103
+ modelFallbackMessage: runtime.modelFallbackMessage,
104
+ initialMessage: args.message,
105
+ });
106
+ if (!args.message) {
107
+ printBanner();
108
+ }
109
+ await interactive.run();
86
110
  }
87
111
  main().catch((err) => {
88
112
  console.error("Fatal:", err);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA,OAAO,EACN,eAAe,EACf,c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EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAClD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAAC,aAAa,EAAE;QAC9D,GAAG;QACH,QAAQ;QACR,cAAc;KACd,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,OAAO,EAAE;QAChD,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,cAAc,EAAE,IAAI,CAAC,OAAO;KAC5B,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,WAAW,EAAE,CAAC;IACf,CAAC;IAED,MAAM,WAAW,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomsun28/pizza",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "description": "Pizza - CLI is all you need",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,10 +13,9 @@
13
13
  "start": "node dist/main.js"
14
14
  },
15
15
  "dependencies": {
16
- "@mariozechner/pi-agent-core": "^0.62.0",
17
- "@mariozechner/pi-ai": "^0.62.0",
18
- "@mariozechner/pi-tui": "^0.62.0",
19
- "@sinclair/typebox": "^0.34.41"
16
+ "@mariozechner/pi-coding-agent": "^0.66.0",
17
+ "@mariozechner/pi-ai": "^0.66.0",
18
+ "@mariozechner/pi-tui": "^0.66.0"
20
19
  },
21
20
  "devDependencies": {
22
21
  "@types/node": "^22.0.0",
@@ -29,5 +28,14 @@
29
28
  "publishConfig": {
30
29
  "access": "public"
31
30
  },
32
- "author": "tomsun28"
31
+ "author": "tomsun28",
32
+ "files": [
33
+ "dist/",
34
+ "themes/",
35
+ "README.md"
36
+ ],
37
+ "piConfig": {
38
+ "name": "pizza",
39
+ "configDir": ".pizza"
40
+ }
33
41
  }
@@ -0,0 +1,87 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/badlogic/pi-mono/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
3
+ "name": "pizza",
4
+ "vars": {
5
+ "tomato": "#e8503a",
6
+ "salami": "#c0392b",
7
+ "crust": "#d4a054",
8
+ "cheese": "#f5c842",
9
+ "olive": "#6a9153",
10
+ "basil": "#4caf7d",
11
+ "mozzarella": "#e8dcc8",
12
+ "charcoal": "#1e1a17",
13
+ "ashGray": "#4a4540",
14
+ "smokeGray": "#6b6560",
15
+ "dimSmoke": "#3a3530",
16
+ "warmBlack": "#140f0c",
17
+ "sauceDeep": "#2a1510",
18
+ "sauceMid": "#3d1e10",
19
+ "sauceLight": "#4d2a18",
20
+ "crustBg": "#2b2118"
21
+ },
22
+ "colors": {
23
+ "accent": "crust",
24
+ "border": "tomato",
25
+ "borderAccent": "cheese",
26
+ "borderMuted": "dimSmoke",
27
+ "success": "basil",
28
+ "error": "salami",
29
+ "warning": "cheese",
30
+ "muted": "smokeGray",
31
+ "dim": "ashGray",
32
+ "text": "",
33
+
34
+ "thinkingText": "smokeGray",
35
+ "userMessageText": "mozzarella",
36
+ "customMessageText": "mozzarella",
37
+ "customMessageLabel": "crust",
38
+
39
+ "selectedBg": "sauceLight",
40
+ "userMessageBg": "sauceMid",
41
+ "customMessageBg": "crustBg",
42
+ "toolPendingBg": "sauceDeep",
43
+ "toolSuccessBg": "#1a2b1a",
44
+ "toolErrorBg": "#2e1010",
45
+ "toolTitle": "mozzarella",
46
+ "toolOutput": "smokeGray",
47
+
48
+ "mdHeading": "cheese",
49
+ "mdLink": "crust",
50
+ "mdLinkUrl": "smokeGray",
51
+ "mdCode": "tomato",
52
+ "mdCodeBlock": "olive",
53
+ "mdCodeBlockBorder": "ashGray",
54
+ "mdQuote": "smokeGray",
55
+ "mdQuoteBorder": "ashGray",
56
+ "mdHr": "ashGray",
57
+ "mdListBullet": "tomato",
58
+
59
+ "toolDiffAdded": "basil",
60
+ "toolDiffRemoved": "salami",
61
+ "toolDiffContext": "smokeGray",
62
+
63
+ "syntaxComment": "#7a9060",
64
+ "syntaxKeyword": "#e8503a",
65
+ "syntaxFunction": "#f5c842",
66
+ "syntaxVariable": "#e8dcc8",
67
+ "syntaxString": "#d4a054",
68
+ "syntaxNumber": "#4caf7d",
69
+ "syntaxType": "#c0a060",
70
+ "syntaxOperator": "#d0c8be",
71
+ "syntaxPunctuation": "#d0c8be",
72
+
73
+ "thinkingOff": "dimSmoke",
74
+ "thinkingMinimal": "ashGray",
75
+ "thinkingLow": "#8a6040",
76
+ "thinkingMedium": "crust",
77
+ "thinkingHigh": "tomato",
78
+ "thinkingXhigh": "cheese",
79
+
80
+ "bashMode": "basil"
81
+ },
82
+ "export": {
83
+ "pageBg": "#140f0c",
84
+ "cardBg": "#1e1a17",
85
+ "infoBg": "#3d2510"
86
+ }
87
+ }
@@ -1,14 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Write",
5
- "Bash(npm:*)",
6
- "Bash(npx:*)",
7
- "Bash(echo:*)",
8
- "mcp__zread__get_repo_structure"
9
- ]
10
- },
11
- "enabledPlugins": {
12
- "skill-creator@claude-plugins-official": true
13
- }
14
- }
package/src/agent.ts DELETED
@@ -1,44 +0,0 @@
1
- import { Agent, type AgentEvent } from "@mariozechner/pi-agent-core";
2
- import { getModel, type Model } from "@mariozechner/pi-ai";
3
- import { createAllTools } from "./tools/index.js";
4
- import { buildSystemPrompt } from "./system-prompt.js";
5
- import { createCLIStreamFn } from "./cli-stream.js";
6
- import { convertToLlmWithCLI } from "./cli-convert.js";
7
-
8
- export interface PizzaOptions {
9
- provider?: string;
10
- model?: string;
11
- cwd?: string;
12
- apiKey?: string;
13
- }
14
-
15
- export interface PizzaAgent {
16
- agent: Agent;
17
- model: Model<any>;
18
- }
19
-
20
- export function createPizzaAgent(options: PizzaOptions = {}): PizzaAgent {
21
- const cwd = options.cwd ?? process.cwd();
22
- const provider = options.provider ?? "zai";
23
- const modelId = options.model ?? "glm-4.7";
24
-
25
- const model = getModel(provider as any, modelId as any);
26
- const tools = createAllTools(cwd);
27
- const systemPrompt = buildSystemPrompt(cwd);
28
-
29
- const agent = new Agent({
30
- initialState: {
31
- systemPrompt,
32
- model,
33
- thinkingLevel: "off",
34
- tools,
35
- },
36
- streamFn: createCLIStreamFn(),
37
- convertToLlm: convertToLlmWithCLI,
38
- getApiKey: async () => {
39
- return options.apiKey ?? process.env.ZAI_API_KEY ?? process.env.ANTHROPIC_API_KEY ?? process.env.OPENAI_API_KEY;
40
- },
41
- });
42
-
43
- return { agent, model };
44
- }