pi-jar 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +288 -0
- package/docs/DESIGN.md +85 -0
- package/docs/DEVELOPMENT.md +95 -0
- package/docs/FLAME.md +54 -0
- package/docs/INTEGRATIONS.md +82 -0
- package/docs/PLAN.md +68 -0
- package/docs/SHOWCASE.md +22 -0
- package/docs/WORKFLOWS.md +141 -0
- package/extensions/index.ts +773 -0
- package/package.json +62 -0
- package/src/accent.ts +36 -0
- package/src/advisor.ts +194 -0
- package/src/animations.ts +23 -0
- package/src/ask-tool.ts +185 -0
- package/src/attachments.ts +79 -0
- package/src/changes.ts +146 -0
- package/src/commit.ts +61 -0
- package/src/compact-tools.ts +129 -0
- package/src/composer.ts +404 -0
- package/src/context-view.ts +141 -0
- package/src/delegate.ts +208 -0
- package/src/dialogs.ts +127 -0
- package/src/diff-view.ts +160 -0
- package/src/flame.ts +245 -0
- package/src/footer-settings.ts +32 -0
- package/src/footer.ts +147 -0
- package/src/goal-loop.ts +313 -0
- package/src/goals.ts +114 -0
- package/src/history-ui.ts +136 -0
- package/src/history.ts +168 -0
- package/src/info-panels.ts +75 -0
- package/src/mascot.ts +103 -0
- package/src/model-roles.ts +332 -0
- package/src/panel.ts +90 -0
- package/src/plan-utils.ts +191 -0
- package/src/plan-view.ts +149 -0
- package/src/plan.ts +460 -0
- package/src/prompt-search.ts +83 -0
- package/src/quota.ts +134 -0
- package/src/roles-ui.ts +190 -0
- package/src/roles.ts +25 -0
- package/src/session-gallery.ts +52 -0
- package/src/session-ui.ts +76 -0
- package/src/settings-ui.ts +154 -0
- package/src/settings.ts +96 -0
- package/src/shells.ts +319 -0
- package/src/side-model.ts +48 -0
- package/src/split-view.ts +74 -0
- package/src/status.ts +71 -0
- package/src/suggest.ts +89 -0
- package/src/task-tool.ts +135 -0
- package/src/tasks-ui.ts +73 -0
- package/src/tasks.ts +147 -0
- package/src/usage-view.ts +98 -0
- package/src/usage.ts +16 -0
- package/src/welcome.ts +260 -0
- package/src/working.ts +60 -0
- package/themes/pi-jar-dark-amber.json +84 -0
- package/themes/pi-jar-dark-azure.json +84 -0
- package/themes/pi-jar-dark-gray.json +84 -0
- package/themes/pi-jar-dark-pink.json +84 -0
- package/themes/pi-jar-dark-teal.json +84 -0
- package/themes/pi-jar-dark-violet.json +84 -0
- package/themes/pi-jar-dark.json +84 -0
package/docs/PLAN.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# pi-jar roadmap
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
A polished Pi package where the agent's work is visible at a glance, motion communicates useful state, and the core workflows (planning, goals, roles) are enforced rather than merely suggested.
|
|
6
|
+
|
|
7
|
+
## Principles
|
|
8
|
+
|
|
9
|
+
1. **State first.** You should always know what is running, what is waiting on you, and what is done or failed.
|
|
10
|
+
2. **Motion has meaning.** Animate only active work or important events; everything works with motion off.
|
|
11
|
+
3. **Enforce through public APIs.** Tool sets, `tool_call` guards, hidden context, `agent_before_settle` continuations and session entries. Never scrape another extension's private data.
|
|
12
|
+
4. **Responsive by default.** Narrow terminals get compact layouts, never wrapped dashboards.
|
|
13
|
+
5. **Low overhead.** Idle pi-jar does not repaint continuously; timers are unref'd and stop with the session.
|
|
14
|
+
|
|
15
|
+
## Done
|
|
16
|
+
|
|
17
|
+
### Foundation and visuals
|
|
18
|
+
|
|
19
|
+
- [x] Pi package manifest; Pi core packages as `"*"` peer dependencies; tested against the latest Pi
|
|
20
|
+
- [x] dark theme with six accent variants; generated with `npm run themes:build`
|
|
21
|
+
- [x] responsive footer (model, effort, session, cwd, context, RAM, cost, quota, goal, roles, branch)
|
|
22
|
+
- [x] pixel-fire welcome flame with embers, sparks, wind and a deterministic frozen frame for motion-off
|
|
23
|
+
- [x] welcome card with workspace, workflow and role state, plus clickable actions (fullscreen) or keyboard hints (regular)
|
|
24
|
+
- [x] persisted visual settings with Appearance, Footer and Pi tabs
|
|
25
|
+
|
|
26
|
+
### Composer
|
|
27
|
+
|
|
28
|
+
- [x] rounded frame that keeps autocomplete below it and overflow counts in the borders
|
|
29
|
+
- [x] auto-expanding input (≈60% of the terminal) and click-to-place cursor in fullscreen
|
|
30
|
+
- [x] Ember mascot with moods for idle, blink, generating, tools, dialogs, sleepy, error, goal completion and poke
|
|
31
|
+
- [x] next-prompt suggestions as dim ghost text, accepted with Tab
|
|
32
|
+
|
|
33
|
+
### Workflows
|
|
34
|
+
|
|
35
|
+
- [x] plan mode: read-only gating, plan directory write guard, `jar_plan_submit` validation, reminders, split plan view, approve/compact/refine/stop, continue-with role
|
|
36
|
+
- [x] goal mode: task gate, implementor continuation, advisor audit, evidence-based completion, round budget, pause/resume
|
|
37
|
+
- [x] model roles v2: aliases, effort suffixes, custom roles, project overrides, cycle order, split manager
|
|
38
|
+
- [x] `jar_todo` branch-aware checklist and `/jar tasks`
|
|
39
|
+
- [x] `jar_ask` structured questions
|
|
40
|
+
- [x] `/jar history` read-only timeline
|
|
41
|
+
- [x] publisher-driven teammate roles and quota windows
|
|
42
|
+
- [x] change review (`/diff`): per-file baselines, split diff view, accept/revert
|
|
43
|
+
- [x] background shells (`jar_shell`) with watch patterns that wake the agent
|
|
44
|
+
- [x] parallel subagents (`jar_delegate`) on model roles, shown as live teammates
|
|
45
|
+
- [x] composer image chips and prompt history search
|
|
46
|
+
- [x] recent-session gallery on the welcome card and `/jar resume`
|
|
47
|
+
- [x] `implement` role and automatic, manual-choice-respecting role switches
|
|
48
|
+
- [x] advisor: `jar_advisor`, `/advisor`, loop and failure gates
|
|
49
|
+
- [x] `/usage` and `/context` panel; `/jar commit` with the `commit` role
|
|
50
|
+
|
|
51
|
+
## Next
|
|
52
|
+
|
|
53
|
+
- [ ] plan view: inline notes per section fed into **Refine**; section delete with undo
|
|
54
|
+
- [ ] goal mode: optional token or time budget alongside the round budget
|
|
55
|
+
- [ ] roles: per-role fallback chains when a model is unavailable
|
|
56
|
+
- [ ] tasks: optional in-progress state, grouping and priorities
|
|
57
|
+
- [ ] presets (minimal / normal / verbose / focus) for the footer
|
|
58
|
+
- [ ] optional light theme, if it keeps the same identity
|
|
59
|
+
- [ ] terminal checks: iTerm2, Ghostty, WezTerm, VS Code, tmux
|
|
60
|
+
- [ ] changelog and release process
|
|
61
|
+
|
|
62
|
+
## Non-goals
|
|
63
|
+
|
|
64
|
+
pi-jar does not:
|
|
65
|
+
|
|
66
|
+
- become a multi-agent orchestrator or own other extensions' task execution;
|
|
67
|
+
- keep a second source of truth for another extension's state;
|
|
68
|
+
- change Pi's native transcript, keybindings or clipboard as a side effect (Pi settings change only when you toggle them in the Pi tab).
|
package/docs/SHOWCASE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Showcase and media
|
|
2
|
+
|
|
3
|
+
pi-jar's README visual should demonstrate the real TUI rather than a polished mockup that quietly invents capabilities. The canonical demo asset is:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
docs/assets/pi-jar-demo.gif
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## What the demo should show
|
|
10
|
+
|
|
11
|
+
The primary loop should make the product understandable without narration:
|
|
12
|
+
|
|
13
|
+
- the animated torch-style `π` and natural flame/ember motion;
|
|
14
|
+
- the hopeful welcome message and live workspace card;
|
|
15
|
+
- visible project, session, plan, goal, task and role state when available;
|
|
16
|
+
- the composer and Ember mascot so the welcome screen feels connected to the working UI.
|
|
17
|
+
|
|
18
|
+
## Capture guidelines
|
|
19
|
+
|
|
20
|
+
Keep the source capture in a dark terminal using a pi-jar theme. Crop dead time before the UI appears, avoid showing secrets or unrelated desktop chrome, and prefer a short loop over a full recording. The README version should be optimized for quick loading; the original recording can remain outside the repository.
|
|
21
|
+
|
|
22
|
+
The visual is supporting evidence, not the documentation itself. Every demonstrated feature should still be explained in the README or the focused docs.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Workflows
|
|
2
|
+
|
|
3
|
+
pi-jar adds four agent workflows on top of Pi. Each is enforced with Pi's public extension API — active tool sets, `tool_call` guards, hidden context messages, the `agent_before_settle` continuation boundary, and session entries — rather than by prompting alone.
|
|
4
|
+
|
|
5
|
+
## Plan mode
|
|
6
|
+
|
|
7
|
+
### Lifecycle
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
/plan ──▶ read-only tools + plan role ──▶ agent explores
|
|
11
|
+
│ │
|
|
12
|
+
│ writes $TMPDIR/pi-jar/plans/<session>/<slug>-plan.md
|
|
13
|
+
│ │
|
|
14
|
+
│ jar_plan_submit({ path }) ──▶ validate ──✗──▶ missing sections returned
|
|
15
|
+
│ │ ✓
|
|
16
|
+
▼ ▼
|
|
17
|
+
turn ended without submit plan view (after the run settles)
|
|
18
|
+
→ hidden reminder (≤ 2/prompt) approve │ compact+approve │ refine │ stop
|
|
19
|
+
▼
|
|
20
|
+
seed jar_todo, restore tools/model, optional role,
|
|
21
|
+
send <plan path="…">full text</plan> as the next prompt
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Enforcement
|
|
25
|
+
|
|
26
|
+
| Mechanism | Detail |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Active tools | Current tools ∩ `read, bash, grep, find, ls, jar_ask`, plus `write`, `edit`, `jar_plan_submit`. The previous set is restored exactly on exit. |
|
|
29
|
+
| `tool_call` guard | Unknown tools fail closed. `bash` must pass the read-only allowlist (no redirection, substitution, globbing or mutating git/find flags). `write`/`edit` must target a `.md` file whose real path (after resolving symlinks on the nearest existing ancestor and on the file itself) is inside the session's plan directory. |
|
|
30
|
+
| Hidden context | Each run gets `[PI-JAR PLAN MODE · READ ONLY]` with the plan directory, the template and the rule to end with `jar_plan_submit`. It is filtered out of context once plan mode ends. |
|
|
31
|
+
| Submission | `jar_plan_submit` reads at most 64 KB, strips control sequences, requires one `#` title and `## Context`, `## Approach` (with numbered/bulleted steps or `###` step headings), `## Critical files` and `## Verification`. Success ends the turn (`terminate`). |
|
|
32
|
+
| Reminder | `agent_before_settle` appends a hidden reminder and continues once — at most twice per user prompt — when a completed turn did not submit. Never after an interrupt or error, and never on top of another extension's continuation. |
|
|
33
|
+
|
|
34
|
+
### Plan view
|
|
35
|
+
|
|
36
|
+
`openPlanView` renders a full-height overlay using the shared split frame:
|
|
37
|
+
|
|
38
|
+
- Left: table of contents from ATX headings (fenced code ignored). A single `#` title becomes the header; content before the first heading is an **Overview** entry; `###` entries are indented. Width is `clamp(round(w × 0.26), 18, 32)`; below 64 columns the sidebar collapses into a `‹ n/m heading ›` pager.
|
|
39
|
+
- Right: the selected section and its subsections rendered with Pi's markdown renderer, scrollable independently.
|
|
40
|
+
- Bottom: actions and the **continue with** role chip (cycles through assigned roles in `cycleOrder`).
|
|
41
|
+
- The view handles clicks and wheel only; press/drag/release fall through to Pi so text selection and copy-on-select keep working.
|
|
42
|
+
|
|
43
|
+
State (`pi-jar.plan` entries, v2: `enabled`, `steps`, `text`, `path`, `title`) follows the session branch; v1 entries still restore.
|
|
44
|
+
|
|
45
|
+
## Goal mode
|
|
46
|
+
|
|
47
|
+
### States
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
/goal <text>
|
|
51
|
+
│
|
|
52
|
+
▼
|
|
53
|
+
┌──────── active ────────┐
|
|
54
|
+
│ phase: implement │◀─── auditor added tasks
|
|
55
|
+
│ │ all tasks done │
|
|
56
|
+
│ ▼ │
|
|
57
|
+
│ phase: audit ─────────┼──▶ jar_goal complete (evidence) ──▶ complete
|
|
58
|
+
└──┬──────────────────────┘
|
|
59
|
+
│ Esc / error / plan mode / jar_goal block / round budget
|
|
60
|
+
▼
|
|
61
|
+
paused ──/goal resume──▶ active
|
|
62
|
+
/goal clear ──▶ (dropped)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Rules
|
|
66
|
+
|
|
67
|
+
- **Round budget:** each automatic continuation is a round (`round n/max`, default 8). A real user message resets it. Reaching the limit pauses the goal.
|
|
68
|
+
- **Task gate:** with no open task, `write`/`edit` are blocked, and so are shell commands that are not on the read-only allowlist during the implement phase. During the audit, edits are blocked but verification commands are allowed.
|
|
69
|
+
- **Roles per round:** implement rounds run on the `implement` role and the audit round on `advisor` (each only if assigned). The previous model and effort are restored when the run settles.
|
|
70
|
+
- **Completion:** `jar_goal complete` requires the audit phase, no open tasks, and non-empty evidence. It ends the turn, records the evidence, and Ember shows `(★ᴗ★)`.
|
|
71
|
+
- **Context hygiene:** only the newest goal context and continuation messages are kept in the prompt.
|
|
72
|
+
|
|
73
|
+
Goal events (`pi-jar.goal`, v2: `set`, `status`, `round`) are append-only session entries; v1 `set`/`clear` still replay.
|
|
74
|
+
|
|
75
|
+
## Model roles
|
|
76
|
+
|
|
77
|
+
Resolution for a role name:
|
|
78
|
+
|
|
79
|
+
1. Merge global (`<agent dir>/pi-jar-roles.json`) and project (`<cwd>/.pi/pi-jar-roles.json`) roles; project wins per role.
|
|
80
|
+
2. If the spec is `@other[:effort]`, remember the effort (first one wins) and follow `other`; stop after five hops or on a cycle.
|
|
81
|
+
3. A `provider/model[:effort]` spec resolves through Pi's model registry; activation fails with a notice if the model is unknown or unauthenticated.
|
|
82
|
+
4. An unassigned role "follows the current model" (activating it only labels the footer).
|
|
83
|
+
|
|
84
|
+
`activateTemporary(role)` returns a restore function that puts back the previous model, effort and active role — used by plan mode (`plan`), approved-plan execution (`implement`), goal rounds (`implement` / `advisor`).
|
|
85
|
+
|
|
86
|
+
Manual choices win: a model or effort you select yourself (model picker, cycling, `/thinking`) while a temporary role is applied cancels that role's restore, so leaving plan mode or finishing a goal round never overrides it. pi-jar's own switches are not counted as manual.
|
|
87
|
+
|
|
88
|
+
## Advisor
|
|
89
|
+
|
|
90
|
+
- Context sent: the newest conversation (≈24k characters; tool results truncated to 1.2k each) plus `git status --short --branch` and `git diff --stat HEAD` (≤4k). No tools run on the advisor's side.
|
|
91
|
+
- `jar_advisor` returns the advice as the tool result. `/advisor [focus]` and the failure gate deliver a visible `pi-jar.advisor` message (steered into a running turn, or queued for the next one when idle).
|
|
92
|
+
- Loop gate: the same tool and input three times within the last eight calls blocks that call and returns the advice as the block reason. Failure gate: three failing tool results in a row. Both share a budget of two consultations per user prompt and are reset by your next message.
|
|
93
|
+
- The advisor model comes from the `advisor` role; unassigned, it is the current model with a fresh context.
|
|
94
|
+
|
|
95
|
+
## Commit
|
|
96
|
+
|
|
97
|
+
`/jar commit [note]` reads the staged diff (≤60k characters) and the last eight commit subjects, asks the `commit` role (or the current model) for a message in the same style, and opens it in an editor. Saving commits with `git commit -F`; an empty message cancels. With nothing staged it offers `git add -A`. It never pushes.
|
|
98
|
+
|
|
99
|
+
## Usage and context panel
|
|
100
|
+
|
|
101
|
+
- Usage totals come from the assistant messages on the active branch plus pi-jar's side calls (advisor, commit) for this session. Limit bars use the quota lookup that feeds the footer.
|
|
102
|
+
- Context parts are estimated at ~4 characters per token (images ≈1.6k tokens) and scaled to the provider-reported total when known. The autocompact buffer is Pi's compaction reserve (`compaction.reserveTokens`), or 0 when compaction is off. Context files and skills are the ones the last prompt used.
|
|
103
|
+
|
|
104
|
+
## Next-prompt suggestions
|
|
105
|
+
|
|
106
|
+
- The `jar_suggest` tool is active only while the pi-jar composer and the suggestions setting are on.
|
|
107
|
+
- Its prompt guidelines ask the agent to call it once, last, when a request is finished; the result ends the turn, so it costs no extra model round.
|
|
108
|
+
- If a completed turn did not suggest, a single hidden reminder asks for one (never while plan or goal automation owns the next step, and never after an interrupt).
|
|
109
|
+
- The suggestion is sanitized to one line (≤ 160 characters) and kept in memory only. It is cleared by your next prompt, a new run, typing, or branch navigation.
|
|
110
|
+
|
|
111
|
+
## Change review
|
|
112
|
+
|
|
113
|
+
- A `tool_call` hook records a file's content right before the agent's **first** `edit` or `write` to it (project files only, up to 200 files, 1 MB each, text only). Later edits keep that baseline, so the review always shows everything since the agent started on the file.
|
|
114
|
+
- `/diff` (or <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>D</kbd>) compares the baseline with the file on disk using a line diff with 3 lines of context. Files that are back to their baseline drop out.
|
|
115
|
+
- **Accept** forgets the baseline. **Revert** writes the baseline back (or removes a file the agent created) after a second key press to confirm. Errors are reported and the file stays listed.
|
|
116
|
+
- Baselines live in memory for the session; changes made through `bash` or by you are not tracked.
|
|
117
|
+
|
|
118
|
+
## Background shells
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
jar_shell start {command, watch: "ready|error"} → s1 running
|
|
122
|
+
↓ output (ANSI stripped, last 2000 lines)
|
|
123
|
+
watch matches or process exits → pi-jar.shell message → agent wakes (or it is queued)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- Each shell runs `/bin/sh -c` in its own process group; `kill` sends SIGTERM to the group, then SIGKILL after 3 s. At most 8 run at once; the 20 most recent are kept.
|
|
127
|
+
- A watch fires once per shell. With `notify: false` nothing wakes the agent; it can still read `output`.
|
|
128
|
+
- In goal mode, starting a shell with a non-read-only command counts as a change and needs an open task, like `bash`.
|
|
129
|
+
|
|
130
|
+
## Subagents
|
|
131
|
+
|
|
132
|
+
- `jar_delegate` takes 1–4 tasks. Each runs `pi --mode json -p --no-session --model <role model> [--thinking <effort>] [--tools read,grep,find,ls] "<task>"` in the project directory, with `PI_JAR_CHILD=1`.
|
|
133
|
+
- The model comes from the task's role (default `task`), falling back to `default` and then the current model.
|
|
134
|
+
- Progress (tools used, turns, cost) streams into the tool card; each running subagent is published as a teammate for the welcome TEAM row and footer, and cleared when it ends.
|
|
135
|
+
- Subagents time out after 20 minutes and stop when the turn is aborted. The result lists every report with its role, model and outcome. In goal mode, `write: true` needs an open task.
|
|
136
|
+
|
|
137
|
+
## Sessions and prompt history
|
|
138
|
+
|
|
139
|
+
- The welcome loads the three most recent sessions for the project (excluding the current one and empty ones) in the background, reading each file (up to 8 MB) for its latest pi-jar goal and plan title.
|
|
140
|
+
- Clicking a recent row stages `/jar resume N` in the composer (switching sessions needs a command); `/jar resume` alone opens the searchable picker.
|
|
141
|
+
- <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>H</kbd> collects every user prompt in the current session file (all branches, newest first) plus the opening prompt of up to 50 recent sessions, deduplicated, and fuzzy-filters as you type.
|