@tomsun28/pizza 0.0.7 → 0.0.9

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 CHANGED
@@ -1,15 +1,14 @@
1
1
  # 🍕 Pizza
2
2
 
3
- > **CLI is all you need**
3
+ > **CLI display for pi**
4
4
 
5
- Pizza is a command-line AI assistant that replaces traditional JSON tool calls with a unique `[CLI]` tag format. Built on top of [pi-coding-agent](https://github.com/badlogic/pi-coding-agent), it provides developers with an efficient terminal interaction experience.
5
+ Pizza is a command-line AI assistant that displays pi's native tool calls in a clean `[CLI]` tag format. Built on top of [pi-coding-agent](https://github.com/badlogic/pi-coding-agent), it provides developers with an efficient terminal interaction experience.
6
6
 
7
7
  ---
8
8
 
9
9
  ## Features
10
10
 
11
- - **[CLI] Tag Format** — Invoke tools using natural text tags, no complex JSON structures needed
12
- - **Multi-Tool Support** — Built-in commands: `ls`, `read`, `write`, `edit`, `grep`, `bash`
11
+ - **[CLI] Display Format** — Tool calls are displayed in clean [CLI] tag format instead of raw JSON
13
12
  - **Interactive TUI** — Beautiful terminal interface based on pi-tui with keyboard shortcuts
14
13
  - **Multi-Model Support** — Compatible with OpenAI, Anthropic, and other LLM providers
15
14
  - **Session Management** — Automatic saving and management of conversation history
@@ -42,8 +41,9 @@ pizza "analyze the current project structure"
42
41
  pizza [options] [message]
43
42
 
44
43
  OPTIONS:
45
- -p, --provider <name> LLM provider (reads from config by default)
44
+ --provider <name> LLM provider (reads from config by default)
46
45
  -m, --model <id> Model ID
46
+ -p, --print Print mode (non-interactive, single-shot)
47
47
  -h, --help Show help information
48
48
  ```
49
49
 
@@ -62,37 +62,42 @@ OPTIONS:
62
62
 
63
63
  ---
64
64
 
65
- ## [CLI] Tag Format
65
+ ## [CLI] Display Format
66
66
 
67
- Pizza's core innovation replaces traditional JSON tool calls with `[CLI]` tags:
67
+ Pizza displays pi's native tool calls in a clean `[CLI]` tag format for better readability:
68
68
 
69
- ### Format
69
+ ### Display Format
70
+
71
+ When the model calls tools, they are displayed as:
70
72
 
71
73
  ```
72
- [CLI id=1] ls src[/CLI]
73
- [CLI id=2] read package.json[/CLI]
74
+ [CLI] read package.json[/CLI]
75
+ [CLI] bash node --version[/CLI]
74
76
  ```
75
77
 
76
- ### Result Return
78
+ ### Result Display
79
+
80
+ Tool results are displayed as:
77
81
 
78
82
  ```
79
- [RESULT id=1]
80
- file 1.2KB index.ts
81
- file 2.5KB utils.ts
82
- dir - components
83
+ [RESULT]
84
+ {
85
+ "name": "pizza",
86
+ "version": "0.0.9"
87
+ }
83
88
  [/RESULT]
84
89
  ```
85
90
 
86
- ### Supported Commands
91
+ ### Supported Tools
92
+
93
+ Pizza uses pi's built-in tools:
87
94
 
88
- | Command | Usage | Description |
89
- |---------|-------|-------------|
90
- | `ls` | `[CLI]ls <path>[/CLI]` | List directory contents |
91
- | `read` | `[CLI]read <path> [--offset N] [--limit N][/CLI]` | Read file |
92
- | `write` | `[CLI]write --path <path> --content <content>[/CLI]` | Write file |
93
- | `edit` | `[CLI]edit --path <path> --old <text> --new <text>[/CLI]` | Edit file |
94
- | `grep` | `[CLI]grep <pattern> --path <dir> --include <glob>[/CLI]` | Search files |
95
- | `bash` | `[CLI]bash <command>[/CLI]` | Execute shell command |
95
+ | Tool | Description |
96
+ |------|-------------|
97
+ | `read` | Read file contents |
98
+ | `write` | Write to a file |
99
+ | `edit` | Edit a file by replacing text |
100
+ | `bash` | Execute shell commands |
96
101
 
97
102
  ---
98
103
 
@@ -105,8 +110,7 @@ dir - components
105
110
  ├── src/
106
111
  │ ├── main.ts # Entry file
107
112
  │ └── extension/
108
- ├── index.ts # Extension main logic
109
- │ └── core.ts # Core tool implementations
113
+ └── index.ts # Extension main logic (CLI display formatting)
110
114
  ├── themes/
111
115
  │ └── pizza.json # Theme configuration
112
116
  ├── package.json
@@ -1,53 +1,69 @@
1
1
  /**
2
- * Core logic for pizza-mode: [CLI] tag parsing, tool execution helpers,
3
- * and conversation history rewriting.
2
+ * Core logic for pizza-mode.
3
+ *
4
+ * Protocol:
5
+ * [CLI id=N] <shell command>[/CLI]
6
+ * — execute an arbitrary shell command; the full unix toolbelt is available
7
+ * (ls, cat, rg, fd, find, grep, sed, awk, jq, git, gh, curl, node, python, …).
8
+ *
9
+ * [WRITE id=N path=<path>]
10
+ * <full file contents>
11
+ * [/WRITE]
12
+ * — overwrite a file with the exact body between the tags.
13
+ *
14
+ * [EDIT id=N path=<path>]
15
+ * <<<<<<< SEARCH
16
+ * <exact existing text>
17
+ * =======
18
+ * <replacement text>
19
+ * >>>>>>> REPLACE
20
+ * [/EDIT]
21
+ * — targeted replacement; SEARCH text must match exactly and appear exactly once.
22
+ *
23
+ * Results are always returned as [RESULT id=N kind=<bash|write|edit> …]…[/RESULT].
4
24
  */
5
- export declare const MAX_CALLS_PER_TURN = 5;
25
+ export declare const MAX_CALLS_PER_TURN = 10;
6
26
  export declare const MAX_OUTPUT_BYTES: number;
7
27
  export declare const MAX_OUTPUT_LINES = 1000;
8
- export declare const MAX_FILE_BYTES: number;
9
- export declare const MAX_FILE_LINES = 2000;
10
- export declare const MAX_GREP_RESULTS = 200;
11
- export declare const MAX_GREP_FILE_SIZE: number;
12
- export interface ParsedCLICall {
28
+ export type BlockKind = "bash" | "write" | "edit";
29
+ export interface ParsedBashCall {
30
+ kind: "bash";
13
31
  id: number;
14
- toolName: string;
15
- rawArgs: string;
32
+ command: string;
16
33
  }
34
+ export interface ParsedWriteBlock {
35
+ kind: "write";
36
+ id: number;
37
+ path: string;
38
+ content: string;
39
+ }
40
+ export interface ParsedEditBlock {
41
+ kind: "edit";
42
+ id: number;
43
+ path: string;
44
+ search: string;
45
+ replace: string;
46
+ }
47
+ export type ParsedBlock = ParsedBashCall | ParsedWriteBlock | ParsedEditBlock;
17
48
  export interface CLIToolResult {
18
49
  output: string;
19
50
  isError: boolean;
20
51
  }
21
52
  /**
22
- * Parse [CLI] toolName args[/CLI] blocks from model text output.
23
- * Returns all calls found and the text before the first call.
24
- */
25
- export declare function parseCLICalls(text: string): {
26
- calls: ParsedCLICall[];
27
- textBeforeCalls: string;
28
- };
29
- /**
30
- * Parse a shell-style args string into a Record.
31
- * Handles: --key "value", --key value, --flag, positional args.
32
- */
33
- export declare function parseCliArgs(raw: string): Record<string, any>;
34
- /**
35
- * Map parsed args to tool-specific argument schema.
36
- */
37
- export declare function mapArgsToTool(toolName: string, rawArgs: string): Record<string, any>;
38
- /**
39
- * Convert tool call arguments back to CLI flag string for history reconstruction.
53
+ * Parse all [CLI], [WRITE], [EDIT] blocks from assistant text, preserving order.
54
+ * Auto-assigns ids when not explicit. Ids are independent per kind so that
55
+ * result rendering can reference them back without collision.
40
56
  */
41
- export declare function argsToCliString(toolName: string, arguments_: Record<string, any>): string;
42
- export declare function execLs(cwd: string, args: Record<string, any>): Promise<CLIToolResult>;
43
- export declare function execRead(cwd: string, args: Record<string, any>): Promise<CLIToolResult>;
44
- export declare function execWrite(cwd: string, args: Record<string, any>): Promise<CLIToolResult>;
45
- export declare function execEdit(cwd: string, args: Record<string, any>): Promise<CLIToolResult>;
46
- export declare function execGrep(cwd: string, args: Record<string, any>): Promise<CLIToolResult>;
47
- export declare function execBash(cwd: string, args: Record<string, any>, signal?: AbortSignal): Promise<CLIToolResult>;
48
- export declare function dispatchTool(toolName: string, rawArgs: string, cwd: string, signal?: AbortSignal): Promise<CLIToolResult>;
49
- export declare function buildResultBlock(output: string, isError: boolean, id?: number, total?: number, cliCommand?: string): string;
57
+ export declare function parseBlocks(text: string): ParsedBlock[];
58
+ export declare function execBash(cwd: string, command: string, signal?: AbortSignal): Promise<CLIToolResult>;
59
+ export declare function execWrite(cwd: string, path: string, content: string): Promise<CLIToolResult>;
60
+ export declare function execEdit(cwd: string, path: string, search: string, replace: string): Promise<CLIToolResult>;
61
+ export declare function dispatchBlock(block: ParsedBlock, cwd: string, signal?: AbortSignal): Promise<CLIToolResult>;
62
+ export declare function buildResultBlock(output: string, isError: boolean, id: number, kind: BlockKind, label?: string): string;
63
+ export declare function labelForBlock(block: ParsedBlock): string;
50
64
  /**
51
- * Reconstruct the [CLI] text that the model originally emitted for a tool call.
65
+ * Reconstruct assistant-visible text for a native tool_use call of one of our
66
+ * built-in operations (used only if an older session recorded them as native
67
+ * tool calls). For bash we render [CLI]; for write/edit we render fenced blocks.
52
68
  */
53
- export declare function reconstructCliText(toolName: string, arguments_: Record<string, any>): string;
69
+ export declare function reconstructBlockText(toolName: string, args: Record<string, any>): string | null;