@vaclav-synacek/pi-coding-agent-termux 0.46.0 → 0.48.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/README.md +1 -327
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +10 -1
  5. package/dist/config.js.map +1 -1
  6. package/dist/core/agent-session.d.ts +16 -3
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +125 -22
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/compaction/branch-summarization.d.ts +2 -0
  11. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  12. package/dist/core/compaction/branch-summarization.js +11 -4
  13. package/dist/core/compaction/branch-summarization.js.map +1 -1
  14. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  15. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  16. package/dist/core/export-html/ansi-to-html.js +249 -0
  17. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  18. package/dist/core/export-html/index.d.ts +17 -0
  19. package/dist/core/export-html/index.d.ts.map +1 -1
  20. package/dist/core/export-html/index.js +52 -23
  21. package/dist/core/export-html/index.js.map +1 -1
  22. package/dist/core/export-html/template.css +0 -33
  23. package/dist/core/export-html/template.js +171 -18
  24. package/dist/core/export-html/tool-renderer.d.ts +35 -0
  25. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  26. package/dist/core/export-html/tool-renderer.js +57 -0
  27. package/dist/core/export-html/tool-renderer.js.map +1 -0
  28. package/dist/core/extensions/index.d.ts +1 -1
  29. package/dist/core/extensions/index.d.ts.map +1 -1
  30. package/dist/core/extensions/index.js.map +1 -1
  31. package/dist/core/extensions/loader.d.ts.map +1 -1
  32. package/dist/core/extensions/loader.js.map +1 -1
  33. package/dist/core/extensions/runner.d.ts +8 -1
  34. package/dist/core/extensions/runner.d.ts.map +1 -1
  35. package/dist/core/extensions/runner.js +41 -0
  36. package/dist/core/extensions/runner.js.map +1 -1
  37. package/dist/core/extensions/types.d.ts +45 -6
  38. package/dist/core/extensions/types.d.ts.map +1 -1
  39. package/dist/core/extensions/types.js.map +1 -1
  40. package/dist/core/prompt-templates.d.ts +5 -1
  41. package/dist/core/prompt-templates.d.ts.map +1 -1
  42. package/dist/core/prompt-templates.js +22 -28
  43. package/dist/core/prompt-templates.js.map +1 -1
  44. package/dist/core/sdk.d.ts.map +1 -1
  45. package/dist/core/sdk.js +5 -1
  46. package/dist/core/sdk.js.map +1 -1
  47. package/dist/core/session-manager.d.ts +8 -0
  48. package/dist/core/session-manager.d.ts.map +1 -1
  49. package/dist/core/session-manager.js +43 -0
  50. package/dist/core/session-manager.js.map +1 -1
  51. package/dist/core/settings-manager.d.ts +9 -0
  52. package/dist/core/settings-manager.d.ts.map +1 -1
  53. package/dist/core/settings-manager.js +21 -0
  54. package/dist/core/settings-manager.js.map +1 -1
  55. package/dist/core/skills.d.ts.map +1 -1
  56. package/dist/core/skills.js +6 -37
  57. package/dist/core/skills.js.map +1 -1
  58. package/dist/core/system-prompt.d.ts.map +1 -1
  59. package/dist/core/system-prompt.js +19 -14
  60. package/dist/core/system-prompt.js.map +1 -1
  61. package/dist/core/tools/bash.d.ts +2 -0
  62. package/dist/core/tools/bash.d.ts.map +1 -1
  63. package/dist/core/tools/bash.js +4 -1
  64. package/dist/core/tools/bash.js.map +1 -1
  65. package/dist/core/tools/index.d.ts +4 -1
  66. package/dist/core/tools/index.d.ts.map +1 -1
  67. package/dist/core/tools/index.js +8 -3
  68. package/dist/core/tools/index.js.map +1 -1
  69. package/dist/core/tools/path-utils.d.ts +1 -0
  70. package/dist/core/tools/path-utils.d.ts.map +1 -1
  71. package/dist/core/tools/path-utils.js +7 -0
  72. package/dist/core/tools/path-utils.js.map +1 -1
  73. package/dist/core/tools/read.d.ts.map +1 -1
  74. package/dist/core/tools/read.js +13 -2
  75. package/dist/core/tools/read.js.map +1 -1
  76. package/dist/index.d.ts +3 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +3 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/main.d.ts.map +1 -1
  81. package/dist/main.js +84 -14
  82. package/dist/main.js.map +1 -1
  83. package/dist/modes/interactive/components/custom-editor.d.ts +2 -2
  84. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/custom-editor.js +2 -2
  86. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  87. package/dist/modes/interactive/components/extension-editor.d.ts +2 -2
  88. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  89. package/dist/modes/interactive/components/extension-editor.js +3 -3
  90. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  91. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  92. package/dist/modes/interactive/components/session-selector.js +5 -3
  93. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  94. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  95. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  96. package/dist/modes/interactive/components/settings-selector.js +12 -0
  97. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  98. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/tool-execution.js +3 -1
  100. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  101. package/dist/modes/interactive/components/tree-selector.d.ts +7 -0
  102. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/tree-selector.js +140 -4
  104. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  105. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  106. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  107. package/dist/modes/interactive/interactive-mode.js +123 -106
  108. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  109. package/dist/modes/interactive/theme/theme-schema.json +23 -3
  110. package/dist/modes/print-mode.d.ts.map +1 -1
  111. package/dist/modes/print-mode.js +7 -2
  112. package/dist/modes/print-mode.js.map +1 -1
  113. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  114. package/dist/modes/rpc/rpc-mode.js +7 -1
  115. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  116. package/dist/utils/frontmatter.d.ts +8 -0
  117. package/dist/utils/frontmatter.d.ts.map +1 -0
  118. package/dist/utils/frontmatter.js +26 -0
  119. package/dist/utils/frontmatter.js.map +1 -0
  120. package/dist/utils/image-convert.d.ts.map +1 -1
  121. package/dist/utils/image-convert.js +6 -1
  122. package/dist/utils/image-convert.js.map +1 -1
  123. package/dist/utils/image-resize.d.ts.map +1 -1
  124. package/dist/utils/image-resize.js +14 -1
  125. package/dist/utils/image-resize.js.map +1 -1
  126. package/dist/utils/photon.d.ts +28 -0
  127. package/dist/utils/photon.d.ts.map +1 -0
  128. package/dist/utils/photon.js +51 -0
  129. package/dist/utils/photon.js.map +1 -0
  130. package/docs/extensions.md +83 -4
  131. package/docs/rpc.md +17 -15
  132. package/docs/sdk.md +1 -1
  133. package/docs/tree.md +20 -2
  134. package/docs/tui.md +26 -0
  135. package/examples/extensions/input-transform.ts +43 -0
  136. package/examples/extensions/modal-editor.ts +1 -1
  137. package/examples/extensions/overlay-test.ts +8 -3
  138. package/examples/extensions/question.ts +1 -1
  139. package/examples/extensions/questionnaire.ts +1 -1
  140. package/examples/extensions/rainbow-editor.ts +1 -8
  141. package/examples/extensions/subagent/agents.ts +3 -32
  142. package/examples/extensions/with-deps/package-lock.json +2 -2
  143. package/examples/extensions/with-deps/package.json +1 -1
  144. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.48.0] - 2026-01-16
4
+
5
+ ### Added
6
+
7
+ - Added `quietStartup` setting to silence startup output (version header, loaded context info, model scope line). Changelog notifications are still shown. ([#777](https://github.com/badlogic/pi-mono/pull/777) by [@ribelo](https://github.com/ribelo))
8
+ - Added `editorPaddingX` setting for horizontal padding in input editor (0-3, default: 0)
9
+ - Added `shellCommandPrefix` setting to prepend commands to every bash execution, enabling alias expansion in non-interactive shells (e.g., `"shellCommandPrefix": "shopt -s expand_aliases"`) ([#790](https://github.com/badlogic/pi-mono/pull/790) by [@richardgill](https://github.com/richardgill))
10
+ - Added bash-style argument slicing for prompt templates ([#770](https://github.com/badlogic/pi-mono/pull/770) by [@airtonix](https://github.com/airtonix))
11
+ - Extension commands can provide argument auto-completions via `getArgumentCompletions` in `pi.registerCommand()` ([#775](https://github.com/badlogic/pi-mono/pull/775) by [@ribelo](https://github.com/ribelo))
12
+ - Bash tool now displays the timeout value in the UI when a timeout is set ([#780](https://github.com/badlogic/pi-mono/pull/780) by [@dannote](https://github.com/dannote))
13
+ - Export `getShellConfig` for extensions to detect user's shell environment ([#766](https://github.com/badlogic/pi-mono/pull/766) by [@dannote](https://github.com/dannote))
14
+ - Added `thinkingText` and `selectedBg` to theme schema ([#763](https://github.com/badlogic/pi-mono/pull/763) by [@scutifer](https://github.com/scutifer))
15
+ - `navigateTree()` now supports `replaceInstructions` option to replace the default summarization prompt entirely, and `label` option to attach a label to the branch summary entry ([#787](https://github.com/badlogic/pi-mono/pull/787) by [@mitsuhiko](https://github.com/mitsuhiko))
16
+
17
+ ### Fixed
18
+
19
+ - Fixed crash during auto-compaction when summarization fails (e.g., quota exceeded). Now displays error message instead of crashing ([#792](https://github.com/badlogic/pi-mono/issues/792))
20
+ - Fixed `--session <UUID>` to search globally across projects if not found locally, with option to fork sessions from other projects ([#785](https://github.com/badlogic/pi-mono/pull/785) by [@ribelo](https://github.com/ribelo))
21
+ - Fixed standalone binary WASM loading on Linux ([#784](https://github.com/badlogic/pi-mono/issues/784))
22
+ - Fixed string numbers in tool arguments not being coerced to numbers during validation ([#786](https://github.com/badlogic/pi-mono/pull/786) by [@dannote](https://github.com/dannote))
23
+ - Fixed `--no-extensions` flag not preventing extension discovery ([#776](https://github.com/badlogic/pi-mono/issues/776))
24
+ - Fixed extension messages rendering twice on startup when `pi.sendMessage({ display: true })` is called during `session_start` ([#765](https://github.com/badlogic/pi-mono/pull/765) by [@dannote](https://github.com/dannote))
25
+ - Fixed `PI_CODING_AGENT_DIR` env var not expanding tilde (`~`) to home directory ([#778](https://github.com/badlogic/pi-mono/pull/778) by [@aliou](https://github.com/aliou))
26
+ - Fixed session picker hint text overflow ([#764](https://github.com/badlogic/pi-mono/issues/764))
27
+ - Fixed Kitty keyboard protocol shifted symbol keys (e.g., `@`, `?`) not working in editor ([#779](https://github.com/badlogic/pi-mono/pull/779) by [@iamd3vil](https://github.com/iamd3vil))
28
+ - Fixed Bedrock tool call IDs causing API errors from invalid characters ([#781](https://github.com/badlogic/pi-mono/pull/781) by [@pjtf93](https://github.com/pjtf93))
29
+
30
+ ### Changed
31
+
32
+ - Hardware cursor is now disabled by default for better terminal compatibility. Set `PI_HARDWARE_CURSOR=1` to enable (replaces `PI_NO_HARDWARE_CURSOR=1` which disabled it).
33
+
34
+ ## [0.47.0] - 2026-01-16
35
+
36
+ ### Breaking Changes
37
+
38
+ - Extensions using `Editor` directly must now pass `TUI` as the first constructor argument: `new Editor(tui, theme)`. The `tui` parameter is available in extension factory functions. ([#732](https://github.com/badlogic/pi-mono/issues/732))
39
+
40
+ ### Added
41
+
42
+ - **OpenAI Codex official support**: Full compatibility with OpenAI's Codex CLI models (`gpt-5.1`, `gpt-5.2`, `gpt-5.1-codex-mini`, `gpt-5.2-codex`). Features include static system prompt for OpenAI allowlisting, prompt caching via session ID, and reasoning signature retention across turns. Set `OPENAI_API_KEY` and use `--provider openai-codex` or select a Codex model. ([#737](https://github.com/badlogic/pi-mono/pull/737))
43
+ - `pi-internal://` URL scheme in read tool for accessing internal documentation. The model can read files from the coding-agent package (README, docs, examples) to learn about extending pi.
44
+ - New `input` event in extension system for intercepting, transforming, or handling user input before the agent processes it. Supports three result types: `continue` (pass through), `transform` (modify text/images), `handled` (respond without LLM). Handlers chain transforms and short-circuit on handled. ([#761](https://github.com/badlogic/pi-mono/pull/761) by [@nicobailon](https://github.com/nicobailon))
45
+ - Extension example: `input-transform.ts` demonstrating input interception patterns (quick mode, instant commands, source routing) ([#761](https://github.com/badlogic/pi-mono/pull/761) by [@nicobailon](https://github.com/nicobailon))
46
+ - Custom tool HTML export: extensions with `renderCall`/`renderResult` now render in `/share` and `/export` output with ANSI-to-HTML color conversion ([#702](https://github.com/badlogic/pi-mono/pull/702) by [@aliou](https://github.com/aliou))
47
+ - Direct filter shortcuts in Tree mode: Ctrl+D (default), Ctrl+T (no-tools), Ctrl+U (user-only), Ctrl+L (labeled-only), Ctrl+A (all) ([#747](https://github.com/badlogic/pi-mono/pull/747) by [@kaofelix](https://github.com/kaofelix))
48
+
49
+ ### Changed
50
+
51
+ - Skill commands (`/skill:name`) are now expanded in AgentSession instead of interactive mode. This enables skill commands in RPC and print modes, and allows the `input` event to intercept `/skill:name` before expansion.
52
+
53
+ ### Fixed
54
+
55
+ - Editor no longer corrupts terminal display when loading large prompts via `setEditorText`. Content now scrolls vertically with indicators showing lines above/below the viewport. ([#732](https://github.com/badlogic/pi-mono/issues/732))
56
+ - Piped stdin now works correctly: `echo foo | pi` is equivalent to `pi -p foo`. When stdin is piped, print mode is automatically enabled since interactive mode requires a TTY ([#708](https://github.com/badlogic/pi-mono/issues/708))
57
+ - Session tree now preserves branch connectors and indentation when filters hide intermediate entries so descendants attach to the nearest visible ancestor and sibling branches align. Fixed in both TUI and HTML export ([#739](https://github.com/badlogic/pi-mono/pull/739) by [@w-winter](https://github.com/w-winter))
58
+ - Added `upstream connect`, `connection refused`, and `reset before headers` patterns to auto-retry error detection ([#733](https://github.com/badlogic/pi-mono/issues/733))
59
+ - Multi-line YAML frontmatter in skills and prompt templates now parses correctly. Centralized frontmatter parsing using the `yaml` library. ([#728](https://github.com/badlogic/pi-mono/pull/728) by [@richardgill](https://github.com/richardgill))
60
+ - `ctx.shutdown()` now waits for pending UI renders to complete before exiting, ensuring notifications and final output are visible ([#756](https://github.com/badlogic/pi-mono/issues/756))
61
+ - OpenAI Codex provider now retries on transient errors (429, 5xx, connection failures) with exponential backoff ([#733](https://github.com/badlogic/pi-mono/issues/733))
62
+
3
63
  ## [0.46.0] - 2026-01-15
4
64
 
5
65
  ### Fixed
@@ -820,7 +880,7 @@ The hooks API has been restructured with more granular events and better session
820
880
 
821
881
  - `ctx.waitForIdle()` - wait for agent to finish streaming
822
882
  - `ctx.newSession(options?)` - create new sessions with optional setup callback
823
- - `ctx.branch(entryId)` - branch from a specific entry
883
+ - `ctx.fork(entryId) - fork from a specific entry, creating a new session file
824
884
  - `ctx.navigateTree(targetId, options?)` - navigate the session tree
825
885
 
826
886
  These methods are only on `HookCommandContext` (not `HookContext`) because they can deadlock if called from event handlers that run inside the agent loop.
package/README.md CHANGED
@@ -12,330 +12,4 @@ This repository maintains a Termux-compatible fork of pi-coding-agent. The port
12
12
  npm install -g @vaclav-synacek/pi-coding-agent-termux
13
13
  ```
14
14
 
15
- Or build from source (on a development machine):
16
-
17
- ```bash
18
- git clone https://github.com/VaclavSynacek/pi-coding-agent-termux.git
19
- cd pi-coding-agent-termux
20
- npm install
21
- npm run build
22
- cd packages/coding-agent
23
- npm pack
24
- # Transfer the .tgz file to Termux and install it
25
- ```
26
-
27
- On Termux:
28
- ```bash
29
- npm install -g /path/to/vaclav-synacek-pi-coding-agent-termux-0.45.7.tgz
30
- ```
31
-
32
- **Note**: Building on Termux is not supported because the build tool (`tsgo`) doesn't have ARM64 binaries. Build on a regular machine and transfer the package, or install directly from npm.
33
-
34
- For clipboard support, install Termux:API:
35
-
36
- ```bash
37
- pkg install termux-api
38
- ```
39
-
40
- ## Functional Changes in this Port
41
-
42
- This port modifies the upstream pi-coding-agent to work on Termux by:
43
-
44
- ### 1. Clipboard Integration
45
- - **Changed**: `@mariozechner/clipboard` made optional (native bindings incompatible with Termux)
46
- - **Added**: Termux clipboard support via `termux-clipboard-set` and `termux-clipboard-get` commands
47
- - **Behavior**: Text clipboard works via Termux:API; image clipboard operations are disabled on Termux
48
- - **Files modified**:
49
- - `packages/coding-agent/src/utils/clipboard.ts`
50
- - `packages/coding-agent/src/utils/clipboard-image.ts`
51
- - `packages/coding-agent/package.json` (clipboard moved to optionalDependencies)
52
-
53
- ### 2. Image Processing
54
- - **Changed**: Uses `wasm-vips` for image processing
55
- - **Note**: Upstream v0.45.7+ migrated from `photon-node` to `wasm-vips` which is WebAssembly-based
56
- - **Behavior**: Image resizing and conversion work correctly (wasm-vips is platform-independent)
57
- - **Files modified**: None required - wasm-vips works on all platforms including Termux
58
-
59
- ### 3. Update Notification
60
- - **Changed**: Version check and update notification system
61
- - **Behavior**: Checks for updates against `@vaclav-synacek/pi-coding-agent-termux` on npm (instead of upstream package)
62
- - **Display**: Shows correct command: `npm install -g @vaclav-synacek/pi-coding-agent-termux`
63
- - **Files modified**:
64
- - `packages/coding-agent/src/modes/interactive/interactive-mode.ts` (npm registry URL and install command)
65
-
66
- ### 4. Optional Dependencies
67
- - **Changed**: `canvas` moved to optionalDependencies in `packages/ai/package.json`
68
- - **Reason**: Canvas cannot build on Termux (requires pixman-1), but is only used for ai tests
69
- - **Behavior**: npm install succeeds on Termux even if canvas build fails
70
- - **Files modified**: `packages/ai/package.json`
71
-
72
- ### 5. TypeScript Target
73
- - **Changed**: `tsconfig.base.json` target set to ES2024
74
- - **Reason**: Support for regex `v` flag (required by some dependencies)
75
- - **Files modified**: `tsconfig.base.json`
76
-
77
- ## Repository Structure & Maintenance
78
-
79
- This repository follows a structured branching strategy to track upstream releases while maintaining Termux-specific patches:
80
-
81
- ### Branches
82
-
83
- - **`master`** - The main Termux port branch
84
- - Contains Termux-specific modifications applied on top of upstream
85
- - Rebased onto new upstream versions when they are released
86
- - Force-pushed after each rebase (history is rewritten)
87
-
88
- - **`upstream`** - Clean upstream tracking branch
89
- - Mirrors `https://github.com/badlogic/pi-mono.git` main branch
90
- - Used as the base for rebasing master
91
- - Never contains Termux-specific changes
92
- - Helps maintain transparency about what's changed in the port
93
-
94
- ### Tags
95
-
96
- Tags follow the naming convention: `v{UPSTREAM_VERSION}-{PORT_REVISION}`
97
-
98
- Examples:
99
- - `v0.45.7-0` - First Termux port of upstream v0.45.7
100
- - `v0.45.7-1` - Second Termux port of upstream v0.45.7 (port bugfix)
101
- - `v0.46.0-0` - First Termux port of upstream v0.46.0
102
-
103
- **Tags are immutable** - once published to npm, a tag is never changed or deleted. This preserves the complete version history.
104
-
105
- ### Remotes
106
-
107
- - `origin` - This repository (`VaclavSynacek/pi-coding-agent-termux`)
108
- - `upstream` - Upstream repository (`badlogic/pi-mono`)
109
-
110
- ## Maintenance Workflow
111
-
112
- ### When a New Upstream Version is Released
113
-
114
- Example: Upstream releases `v0.46.0`
115
-
116
- 1. **Update upstream branch**
117
- ```bash
118
- git checkout upstream
119
- git fetch upstream
120
- git merge upstream/main # or git reset --hard upstream/main
121
- git push origin upstream
122
- ```
123
-
124
- 2. **Rebase master onto new upstream version**
125
- ```bash
126
- git checkout master
127
- git rebase v0.46.0 # rebase onto the upstream tag
128
- ```
129
-
130
- 3. **Resolve conflicts**
131
- - Fix any rebase conflicts in Termux-specific patches
132
- - Pay special attention to files listed in "Functional Changes" section above
133
- - Ensure patches still apply cleanly and make sense
134
-
135
- 4. **Test thoroughly**
136
- - Build the project: `npm install && npm run build`
137
- - Test on actual Termux device
138
- - Verify clipboard operations (with Termux:API installed)
139
- - Test that image operations degrade gracefully
140
- - Check that all core features work
141
-
142
- 5. **Update package.json version**
143
- ```bash
144
- cd packages/coding-agent
145
- # Update version to match upstream (e.g., "0.46.0")
146
- ```
147
-
148
- 6. **Create immutable release tag**
149
- ```bash
150
- git tag -a v0.46.0-0 -m "Termux port of upstream v0.46.0"
151
- git push origin v0.46.0-0
152
- ```
153
-
154
- 7. **Publish to npm**
155
- ```bash
156
- cd packages/coding-agent
157
- npm publish
158
- ```
159
-
160
- 8. **Push rebased master**
161
- ```bash
162
- git push origin master --force-with-lease
163
- ```
164
-
165
- ### When Port Needs a Bugfix (Without Upstream Change)
166
-
167
- Example: Fix a bug in the Termux port of v0.46.0
168
-
169
- 1. **Make fixes on master branch**
170
- ```bash
171
- git checkout master
172
- # Make your fixes
173
- git commit -m "fix: describe the port-specific fix"
174
- ```
175
-
176
- 2. **Update package.json version** (increment port revision)
177
- ```bash
178
- cd packages/coding-agent
179
- # Version stays "0.46.0" (or use "0.46.0-termux.1" if needed)
180
- ```
181
-
182
- 3. **Create new port revision tag**
183
- ```bash
184
- git tag -a v0.46.0-1 -m "Termux port of upstream v0.46.0 (bugfix)"
185
- git push origin v0.46.0-1
186
- ```
187
-
188
- 4. **Publish to npm**
189
- ```bash
190
- cd packages/coding-agent
191
- npm publish
192
- ```
193
-
194
- 5. **Push master**
195
- ```bash
196
- git push origin master
197
- ```
198
-
199
- ### Initial Setup (Already Done)
200
-
201
- This was the initial setup of this repository:
202
-
203
- 1. Created new repository
204
- 2. Added upstream remote: `git remote add upstream https://github.com/badlogic/pi-mono.git`
205
- 3. Fetched upstream: `git fetch upstream --tags`
206
- 4. Created `upstream` branch: `git checkout -b upstream upstream/main`
207
- 5. Created `master` branch from upstream v0.45.7: `git checkout -b master v0.45.7`
208
- 6. Applied Termux patches as focused commits
209
- 7. Tagged first release: `v0.45.7-0`
210
-
211
- ## Termux Port Commits
212
-
213
- The Termux port consists of these focused commits (applied on top of upstream):
214
-
215
- 1. **docs: Add comprehensive Termux port README** - Complete documentation and maintenance instructions
216
- 2. **feat: Update TypeScript target to ES2024** - Enable modern JavaScript features
217
- 3. **feat: Make @mariozechner/clipboard optional for Termux compatibility** - Optional require() for clipboard
218
- 4. **feat: Add Termux clipboard support** - Integration with termux-clipboard-set/get
219
- 5. **feat: Make @mariozechner/clipboard optional dependency** - Move to optionalDependencies in package.json
220
- 6. **feat: Update version check to use Termux port package** - Point to @vaclav-synacek/pi-coding-agent-termux
221
- 7. **feat: Update package.json for Termux port** - Package name and metadata
222
- 8. **feat: Make canvas optional dependency in ai package** - Allow clean build on Termux
223
- 9. **chore: Remove package-lock.json** - Platform-independent dependency resolution
224
-
225
- ## Commit Strategy for Rebasing
226
-
227
- To make rebasing easier, Termux-specific changes are organized as **minimal, focused commits**:
228
-
229
- - One commit per logical change
230
- - Clear commit messages explaining why the change is needed for Termux
231
- - Avoid mixing unrelated changes
232
- - Keep patches as small as possible while maintaining functionality
233
-
234
- This approach ensures that when rebasing onto new upstream versions, conflicts are:
235
- - Easier to understand and resolve
236
- - Less likely to occur
237
- - Clearly attributable to specific Termux requirements
238
-
239
- ## Development Notes
240
-
241
- ### Building (Development Machine Required)
242
-
243
- **Important**: Building requires `tsgo` which doesn't have Android ARM64 binaries. Build on a regular development machine (Linux/macOS/Windows).
244
-
245
- This is a monorepo. To build all packages:
246
-
247
- ```bash
248
- # From repository root (on development machine)
249
- npm install
250
- npm run build
251
- ```
252
-
253
- To build only the coding-agent package:
254
-
255
- ```bash
256
- cd packages/coding-agent
257
- npm run build
258
- ```
259
-
260
- **For Termux deployment**: Build on a development machine, then either:
261
- 1. Publish to npm and install from there
262
- 2. Use `npm pack` to create a .tgz file and transfer it to Termux
263
-
264
- **Note**: The optional dependency `canvas` (in packages/ai) may fail to build due to missing native libraries (pixman-1). This is expected and harmless - npm will skip it and continue. Canvas is only used for ai package tests.
265
-
266
- ### Testing on Termux
267
-
268
- 1. Install Termux from F-Droid
269
- 2. Install dependencies:
270
- ```bash
271
- pkg update && pkg install git nodejs-lts
272
- pkg install termux-api # For clipboard support
273
- ```
274
- 3. Install the package:
275
- ```bash
276
- npm install -g @vaclav-synacek/pi-coding-agent-termux
277
- ```
278
- 4. Run: `pi`
279
-
280
- **For development/testing unreleased changes**: Build on a development machine, create a tarball with `npm pack`, transfer to Termux, and install with `npm install -g /path/to/package.tgz`.
281
-
282
- ### Comparison with Upstream
283
-
284
- To see all Termux-specific changes:
285
-
286
- ```bash
287
- git diff upstream master
288
- ```
289
-
290
- To see changes in a specific file:
291
-
292
- ```bash
293
- git diff upstream master packages/coding-agent/src/utils/clipboard.ts
294
- ```
295
-
296
- ## Publishing to npm
297
-
298
- The package is published as `@vaclav-synacek/pi-coding-agent-termux` on npm.
299
-
300
- **Publishing steps:**
301
-
302
- ```bash
303
- cd packages/coding-agent
304
- npm publish
305
- ```
306
-
307
- **Key package.json fields:**
308
- - `name`: `@vaclav-synacek/pi-coding-agent-termux` (different from upstream to avoid conflicts)
309
- - `version`: Matches upstream version (e.g., `0.46.0`)
310
- - `description`: "Termux port of pi-coding-agent - Coding agent CLI with read, bash, edit, write tools and session management"
311
- - `repository`: Points to this repository (`VaclavSynacek/pi-coding-agent-termux`)
312
- - `homepage`: https://github.com/VaclavSynacek/pi-coding-agent-termux#readme
313
-
314
- ## Why This Approach?
315
-
316
- This maintenance strategy provides:
317
-
318
- 1. **Clean separation** - Clear distinction between upstream code and Termux patches
319
- 2. **Easy updates** - Rebasing makes it straightforward to adopt new upstream features
320
- 3. **Version history** - Immutable tags preserve every published version
321
- 4. **Transparency** - Easy to see exactly what's different from upstream
322
- 5. **Maintainability** - Future maintainers can understand the port structure
323
- 6. **No upstream dependency** - Port can continue indefinitely without upstream acceptance
324
-
325
- ## Contributing
326
-
327
- When contributing Termux-specific changes:
328
-
329
- 1. Fork this repository
330
- 2. Create a feature branch from `master`
331
- 3. Make focused commits with clear messages
332
- 4. Test on actual Termux device
333
- 5. Submit pull request
334
-
335
- For general pi-coding-agent features/bugs, contribute to the [upstream repository](https://github.com/badlogic/pi-mono) instead.
336
-
337
- ## License
338
-
339
- Same as upstream: MIT License
340
-
341
- See [LICENSE](LICENSE) file for details.
15
+ **For full documentation, maintenance workflow, and technical details, see the [main repository README](https://github.com/VaclavSynacek/pi-coding-agent-termux#readme).**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAMnD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAetC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4BAA4B;AAC5B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iCAAiC;AACjC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,qCAAqC;AACrC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,+BAA+B;AAC/B,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAQD,eAAO,MAAM,QAAQ,EAAE,MAAmC,CAAC;AAC3D,eAAO,MAAM,eAAe,EAAE,MAAyC,CAAC;AACxE,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAG3C,eAAO,MAAM,aAAa,QAA+C,CAAC;AAM1E,0DAA0D;AAC1D,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\treturn process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAMnD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAetC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4BAA4B;AAC5B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iCAAiC;AACjC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,qCAAqC;AACrC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,+BAA+B;AAC/B,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAQD,eAAO,MAAM,QAAQ,EAAE,MAAmC,CAAC;AAC3D,eAAO,MAAM,eAAe,EAAE,MAAyC,CAAC;AACxE,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAG3C,eAAO,MAAM,aAAa,QAA+C,CAAC;AAM1E,0DAA0D;AAC1D,wBAAgB,WAAW,IAAI,MAAM,CASpC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
package/dist/config.js CHANGED
@@ -102,7 +102,16 @@ export const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;
102
102
  // =============================================================================
103
103
  /** Get the agent config directory (e.g., ~/.pi/agent/) */
104
104
  export function getAgentDir() {
105
- return process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, "agent");
105
+ const envDir = process.env[ENV_AGENT_DIR];
106
+ if (envDir) {
107
+ // Expand tilde to home directory
108
+ if (envDir === "~")
109
+ return homedir();
110
+ if (envDir.startsWith("~/"))
111
+ return homedir() + envDir.slice(1);
112
+ return envDir;
113
+ }
114
+ return join(homedir(), CONFIG_DIR_NAME, "agent");
106
115
  }
107
116
  /** Get path to user's custom themes directory */
108
117
  export function getCustomThemesDir() {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACvB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,O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EAAE,KAAK,CAAC,CAAC;AAAA,CAClC;AAED,6CAA6C;AAC7C,MAAM,UAAU,aAAa,GAAW;IACvC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AAAA,CACtC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,CACvC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAAA,CACpD","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\treturn process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAA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,iDAAiD;AACjD,MAAM,UAAU,kBAAkB,GAAW;IAC5C,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;AAAA,CACrC;AAED,8BAA8B;AAC9B,MAAM,UAAU,aAAa,GAAW;IACvC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AAAA,CAC1C;AAED,4BAA4B;AAC5B,MAAM,UAAU,WAAW,GAAW;IACrC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC;AAAA,CACxC;AAED,gCAAgC;AAChC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,CAAC;AAAA,CAC5C;AAED,kCAAkC;AAClC,MAAM,UAAU,WAAW,GAAW;IACrC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;AAAA,CACpC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS,GAAW;IACnC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AAAA,CAClC;AAED,6CAA6C;AAC7C,MAAM,UAAU,aAAa,GAAW;IACvC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AAAA,CACtC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc,GAAW;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AAAA,CACvC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAAA,CACpD","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(dirname(process.execPath), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n// =============================================================================\n// App Config (from package.json piConfig)\n// =============================================================================\n\nconst pkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\"));\n\nexport const APP_NAME: string = pkg.piConfig?.name || \"pi\";\nexport const CONFIG_DIR_NAME: string = pkg.piConfig?.configDir || \".pi\";\nexport const VERSION: string = pkg.version;\n\n// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\t// Expand tilde to home directory\n\t\tif (envDir === \"~\") return homedir();\n\t\tif (envDir.startsWith(\"~/\")) return homedir() + envDir.slice(1);\n\t\treturn envDir;\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
@@ -16,7 +16,7 @@ import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLe
16
16
  import type { ImageContent, Model, TextContent } from "@mariozechner/pi-ai";
17
17
  import { type BashResult } from "./bash-executor.js";
18
18
  import { type CompactionResult } from "./compaction/index.js";
19
- import type { ExtensionRunner } from "./extensions/index.js";
19
+ import type { ExtensionRunner, InputSource } from "./extensions/index.js";
20
20
  import type { CustomMessage } from "./messages.js";
21
21
  import type { ModelRegistry } from "./model-registry.js";
22
22
  import { type PromptTemplate } from "./prompt-templates.js";
@@ -33,6 +33,7 @@ export type AgentSessionEvent = AgentEvent | {
33
33
  result: CompactionResult | undefined;
34
34
  aborted: boolean;
35
35
  willRetry: boolean;
36
+ errorMessage?: string;
36
37
  } | {
37
38
  type: "auto_retry_start";
38
39
  attempt: number;
@@ -80,6 +81,8 @@ export interface PromptOptions {
80
81
  images?: ImageContent[];
81
82
  /** When streaming, how to queue the message: "steer" (interrupt) or "followUp" (wait). Required if streaming. */
82
83
  streamingBehavior?: "steer" | "followUp";
84
+ /** Source of input for extension input event handlers. Defaults to "interactive". */
85
+ source?: InputSource;
83
86
  }
84
87
  /** Result from cycleModel() */
85
88
  export interface ModelCycleResult {
@@ -239,17 +242,23 @@ export declare class AgentSession {
239
242
  */
240
243
  prompt(text: string, options?: PromptOptions): Promise<void>;
241
244
  private _tryExecuteExtensionCommand;
245
+ /**
246
+ * Expand skill commands (/skill:name args) to their full content.
247
+ * Returns the expanded text, or the original text if not a skill command or skill not found.
248
+ * Emits errors via extension runner if file read fails.
249
+ */
250
+ private _expandSkillCommand;
242
251
  /**
243
252
  * Queue a steering message to interrupt the agent mid-run.
244
253
  * Delivered after current tool execution, skips remaining tools.
245
- * Expands file-based prompt templates. Errors on extension commands.
254
+ * Expands skill commands and prompt templates. Errors on extension commands.
246
255
  * @throws Error if text is an extension command
247
256
  */
248
257
  steer(text: string): Promise<void>;
249
258
  /**
250
259
  * Queue a follow-up message to be processed after the agent finishes.
251
260
  * Delivered only when agent has no more tool calls or steering messages.
252
- * Expands file-based prompt templates. Errors on extension commands.
261
+ * Expands skill commands and prompt templates. Errors on extension commands.
253
262
  * @throws Error if text is an extension command
254
263
  */
255
264
  followUp(text: string): Promise<void>;
@@ -476,11 +485,15 @@ export declare class AgentSession {
476
485
  * @param targetId The entry ID to navigate to
477
486
  * @param options.summarize Whether user wants to summarize abandoned branch
478
487
  * @param options.customInstructions Custom instructions for summarizer
488
+ * @param options.replaceInstructions If true, customInstructions replaces the default prompt
489
+ * @param options.label Label to attach to the branch summary entry
479
490
  * @returns Result with editorText (if user message) and cancelled status
480
491
  */
481
492
  navigateTree(targetId: string, options?: {
482
493
  summarize?: boolean;
483
494
  customInstructions?: string;
495
+ replaceInstructions?: boolean;
496
+ label?: string;
484
497
  }): Promise<{
485
498
  editorText?: string;
486
499
  cancelled: boolean;