diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..fc0a0ae3 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ilovepixelart diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index e459a8f6..60dc9838 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ blank_issues_enabled: false contact_links: - - name: Security vulnerability + - name: Report a security vulnerability url: https://github.com/ilovepixelart/pi-code/security/advisories/new - about: Report security issues privately, never as a public issue. + about: Report security issues privately, never as a public issue. See SECURITY.md. - name: pi documentation url: https://pi.dev about: Docs for the pi coding agent that pi-code extends. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 57d69066..0e9e3f3d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -- [ ] `npm run check` passes (Biome, strict tsc, Vitest) +- [ ] `npm run check` passes (Biome, strict tsc, knip, Vitest) - [ ] Tests cover the change diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ba042b24..c6ac0faa 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,77 +1,85 @@ -# Contributor Covenant Code of Conduct -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our community include: - -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -- Focusing on what is best not just for us as individuals, but for the overall community +# Contributor Covenant 3.0 Code of Conduct -Examples of unacceptable behavior include: - -- The use of sexualized language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email address, without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -## Enforcement Responsibilities +## Our Pledge -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. +We pledge to make our community welcoming, safe, and equitable for all. -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. +We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant. -## Scope +## Encouraged Behaviors -This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. +While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language. -## Enforcement +With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including: -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement privately through a [GitHub Security Advisory](https://github.com/ilovepixelart/pi-code/security/advisories/new) or by contacting the maintainer, [@ilovepixelart](https://github.com/ilovepixelart). All complaints will be reviewed and investigated promptly and fairly. +1. Respecting the **purpose of our community**, our activities, and our ways of gathering. +2. Engaging **kindly and honestly** with others. +3. Respecting **different viewpoints** and experiences. +4. **Taking responsibility** for our actions and contributions. +5. Gracefully giving and accepting **constructive feedback**. +6. Committing to **repairing harm** when it occurs. +7. Behaving in other ways that promote and sustain the **well-being of our community**. -All community leaders are obligated to respect the privacy and security of the reporter of any incident. +## Restricted Behaviors -## Enforcement Guidelines +We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct. -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: +1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop. +2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people. +3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits. +4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community. +5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission. +6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group. +7. Behaving in other ways that **threaten the well-being** of our community. -### 1. Correction +### Other Restrictions -**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. +1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions. +2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. +3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community. +4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors. -**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. +## Reporting an Issue -### 2. Warning +Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. -**Community Impact**: A violation through a single incident or series of actions. +When an incident does occur, it is important to report it promptly. To report a possible violation, contact the maintainer, [@ilovepixelart](https://github.com/ilovepixelart), privately through the repository's private vulnerability reporting form: open the **Security** tab and choose **Report a vulnerability**. Only the reporter and the maintainer can see a report filed there. -**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. +Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. -### 3. Temporary Ban +## Addressing and Repairing Harm -**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. +If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. +1) Warning + 1) Event: A violation involving a single incident or series of incidents. + 2) Consequence: A private, written warning from the Community Moderators. + 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations. +2) Temporarily Limited Activities + 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation. + 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members. + 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over. +3) Temporary Suspension + 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation. + 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions. + 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted. +4) Permanent Ban + 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member. + 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior. + 3) Repair: There is no possible repair in cases of this severity. -### 4. Permanent Ban +This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community. -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. +## Scope -**Consequence**: A permanent ban from any sort of public interaction within the community. +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html). +This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/). + +Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/) -Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). +For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion). -For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). diff --git a/README.md b/README.md index b7e26aa0..fd238233 100644 --- a/README.md +++ b/README.md @@ -41,22 +41,22 @@ One `pi install` and everything below loads on the next start. `pi list` shows w Each topic links to its own doc with the full contract and any divergences from Claude Code. -- **[Hooks](docs/hooks.md)** — your `.claude/settings.json` hooks on every lifecycle event, with Claude's tool vocabulary, decision fields, and background hooks. -- **[MCP servers](docs/mcp.md)** — every Claude config scope, all four transports, OAuth, managed policy, timeouts, prompts, and resources. On pi 0.99 and later the servers are handed to pi's own MCP support. -- **[Custom slash commands](docs/commands.md)** — `.claude/commands` with arguments, bash spans, `@file` inlining, frontmatter, and model invocation. -- **[Skills](docs/skills.md)** — `.claude/skills` discovery plus the same dynamic content commands get. -- **[Subagents](docs/subagents.md)** — built-in and custom agents, background runs, per-agent memory, worktree isolation. -- **[CLAUDE.md, @imports, and rules](docs/claude-md.md)** — the context files and path-scoped rules pi does not load natively. -- **[Settings `env` and flags](docs/settings-env.md)** — env blocks from every settings scope, exported with Claude's precedence, plus Claude's `--settings` and `--setting-sources` flags. -- **[Output styles](docs/output-styles.md)** — replace semantics, bundled built-ins, `/output-style`. -- **[Persistent memory](docs/memory.md)** — a per-repository store with a session-injected index. -- **[Statusline](docs/statusline.md)** — your Claude `statusLine` command with the documented stdin JSON. -- **[WebSearch / WebFetch](docs/web.md)** — key-free search and SSRF-guarded fetch. -- **[Claude plugins](docs/plugins.md)** — installed marketplace plugins: commands, agents, hooks, MCP servers, styles, skills. -- **[Background Bash](docs/background-bash.md)** — `run_in_background`, commands that move to the background at their timeout instead of stopping, completion messages, and `task_stop`. +- **[Hooks](docs/hooks.md)**: your `.claude/settings.json` hooks on every lifecycle event, with Claude's tool vocabulary, decision fields, and background hooks. +- **[MCP servers](docs/mcp.md)**: every Claude config scope, all four transports, OAuth, managed policy, timeouts, prompts, and resources. On pi 0.99 and later the servers are handed to pi's own MCP support. +- **[Custom slash commands](docs/commands.md)**: `.claude/commands` with arguments, bash spans, `@file` inlining, frontmatter, and model invocation. +- **[Skills](docs/skills.md)**: `.claude/skills` discovery plus the same dynamic content commands get. +- **[Subagents](docs/subagents.md)**: built-in and custom agents, background runs, per-agent memory, worktree isolation. +- **[CLAUDE.md, @imports, and rules](docs/claude-md.md)**: the context files and path-scoped rules pi does not load natively. +- **[Settings `env` and flags](docs/settings-env.md)**: env blocks from every settings scope, exported with Claude's precedence, plus Claude's `--settings` and `--setting-sources` flags. +- **[Output styles](docs/output-styles.md)**: replace semantics, bundled built-ins, `/output-style`. +- **[Persistent memory](docs/memory.md)**: a per-repository store with a session-injected index. +- **[Statusline](docs/statusline.md)**: your Claude `statusLine` command with the documented stdin JSON. +- **[WebSearch / WebFetch](docs/web.md)**: key-free search and SSRF-guarded fetch. +- **[Claude plugins](docs/plugins.md)**: installed marketplace plugins: commands, agents, hooks, MCP servers, styles, skills. +- **[Background Bash](docs/background-bash.md)**: `run_in_background`, commands that move to the background at their timeout instead of stopping, completion messages, and `task_stop`. - **[Monitor](docs/monitor.md)**: watch a background command and receive its stdout lines as they arrive, batched, with Claude's deadline and a stop for monitors that flood; stopped with `task_stop`. - **[Goal](docs/goal.md)**: `/goal ` keeps the session working until a separate model check confirms the condition holds, with status, clear, block cap, background-work deferral, and resume. -- **[Session extras](docs/session-extras.md)** — project trust, plan mode, todos, checkpoints/rewind, AskUserQuestion, notifications, think keywords, session titles, `/context`, `/init`. +- **[Session extras](docs/session-extras.md)**: project trust, plan mode, todos, checkpoints/rewind, AskUserQuestion, notifications, think keywords, session titles, `/context`, `/init`. Slash commands: `/init`, `/context`, `/goal`, `/memory`, `/todos`, `/rewind`, `/tasks`, `/agents`, `/plan`, `/plan-todos`, `/mcp`, `/hooks`, `/claude-plugins`, and `/output-style`, alongside your own `/dir:name` commands, `/skill:name` skills, `/plugin:name` plugin commands, and each connected server's `/mcp__server__prompt` prompts. Where a name matches a Claude command, these differ: `/init` creates `AGENTS.md` where Claude creates `CLAUDE.md`; `/memory edit` opens a memory file in your editor (pi's `externalEditor` setting, `VISUAL` or `EDITOR`); `/tasks` lists background subagent runs, shell commands and monitors but cannot stop them. `/todos`, `/plan-todos` and `/claude-plugins` have no Claude counterpart. `/claude-plugins` turns installed Claude plugins on or off for pi only; a plugin's state comes from the first of managed settings, the `--settings` flag, pi's `piCode.enabledPlugins`, the Claude user settings file, and the plugin's default that has an entry for it. diff --git a/SECURITY.md b/SECURITY.md index 97b1395e..afb0c600 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,22 @@ pi-code bridges a project's `.claude/` configuration into pi. That configuration can come from an untrusted cloned repository, so extensions that read project-controlled input act on it only once the project is approved: pi has marked it trusted (`ctx.isProjectTrusted()`) and, for a repository pi did not ask about, the user has answered pi-code's own prompt (`internal/project-approval.ts`, see Trust model). User-scoped config (`~/.claude`, `~/.pi`) is the user's own and always loaded. +## Supported versions + +Security fixes are released only for the latest `1.x` version. Releases before `1.0.0` are no longer maintained; upgrade to the latest `1.x` release to receive a fix. + +| Version | Supported | +| ------- | ------------------ | +| 1.x | :white_check_mark: | +| 0.x | :x: | + ## Reporting a vulnerability -Report privately via [GitHub Security Advisories](https://github.com/ilovepixelart/pi-code/security/advisories/new). Please do not open a public issue for a security report. +Report privately via [GitHub Security Advisories](https://github.com/ilovepixelart/pi-code/security/advisories/new). Please do not open a public issue for a security report. Include the affected pi-code and pi versions, a minimal reproduction, and the impact you believe the issue has. + +- **Acknowledgement:** within 7 days of the report. +- **Triage and fix window:** targeted within 30 days for confirmed issues, depending on severity and complexity. +- **Disclosure:** coordinated via the GitHub advisory. A CVE is requested where applicable, and a patched release is published to npm before the advisory is made public. ## Trust model diff --git a/docs/mcp.md b/docs/mcp.md index 466fd85f..d4574080 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -29,7 +29,7 @@ Everything below describes pi-code's own client. - **Divergence:** `CLAUDE_CODE_MCP_ALLOWLIST_ENV` has no effect here. pi-code always passes the SDK's baseline environment to a stdio server, with no opt-out. - A stdio server also gets `CLAUDE_CODE_SESSION_ID`, captured once at connect time ("an MCP server subprocess retains the ID it was spawned with") rather than re-read per call. - `MCP_OAUTH_CALLBACK_PORT` is a fallback default for any server naming no per-server `oauth.callbackPort`. Claude documents it as "an alternative to `--callback-port` when adding an MCP server with pre-configured credentials"; pi-code has no `mcp add` command, so the fallback applies more broadly. -- Managed: a `managed-mcp.json` beside `managed-settings.json` takes exclusive control — only its servers load, every other scope and the approval flow suppressed; an empty file disables MCP. +- Managed: a `managed-mcp.json` beside `managed-settings.json` takes exclusive control: only its servers load, every other scope and the approval flow suppressed; an empty file disables MCP. - Command line: `pi --mcp-config ` adds the `mcpServers` of a JSON file (relative to the working directory) or an inline JSON object for this session, read once at startup. Repeat the flag for more values, a later value winning a shared name; Claude's space-separated form (`--mcp-config a.json b.json`) does not reach pi, whose parser takes the second path as the prompt. A flag server outranks every other scope on a shared name, needs no project approval, and passes the allow/deny lists. An entry with a `url` and no `type` is skipped with Claude's message and the rest load. A missing file, invalid JSON, or a config without an `mcpServers` object is refused with Claude's message and the session ends, as Claude exits 1. - `pi --strict-mcp-config`: only the `--mcp-config` servers load; user, local, project and plugin servers do not, and alone it loads none. Put it before another flag or write `--strict-mcp-config=true`: pi's parser takes the token after a bare flag as its value. Either flag is refused while a readable, parseable `managed-mcp.json` is deployed (Claude: "You cannot dynamically configure MCP servers when an enterprise MCP config is present"). Subagent children receive both flags, `--mcp-config` as a private copy of the merged servers. - **Limit:** under pi's native MCP, pi still reads its own `~/.pi/agent/mcp.json` and `.pi/mcp.json` with `--strict-mcp-config`; pi-code only stops handing pi the other Claude scopes. diff --git a/docs/session-extras.md b/docs/session-extras.md index ce345bc4..8a102371 100644 --- a/docs/session-extras.md +++ b/docs/session-extras.md @@ -6,7 +6,7 @@ The smaller conveniences, each its own extension. - **Plan mode** ([`extensions/plan-mode/`](../extensions/plan-mode)): `plan_mode_complete` tool, tool snapshot/restore that survives `/reload`. `/plan [description]` enters plan mode and sends the description as the first prompt; it never leaves plan mode. `pi --plan` starts a session in plan mode, as Claude's `--permission-mode plan` does. Leave by choosing "Execute the plan" after `plan_mode_complete`, or with `Ctrl+Alt+P`, which toggles plan mode; Claude's `Shift+Tab` mode cycle has no equivalent, since pi binds `Shift+Tab` to cycling the thinking level. - **Todo list** ([`extensions/todo.ts`](../extensions/todo.ts)): compaction-safe task tracking with the full list above the editor, as Claude Code shows its task list whenever a task is created or updated. `/todos-widget off|compact|full` hides the widget, shows counts and the active task on one line, or restores the full panel; it needs the terminal UI, since RPC mode draws no widgets. Empty lists stay hidden in every mode; `/todos` always opens the complete list. Display mode stays in effect across tree navigation and compaction; `/reload`, a new session, resume and fork reset it to `full`. **Divergence:** Claude Code collapses the list with `Ctrl+T` and saves that choice across sessions, and its collapsed form is the active task in the spinner line with the next one below it; `/todos-widget` and its one-line form are pi-code's own. - **Checkpoints / rewind** ([`extensions/git-checkpoint.ts`](../extensions/git-checkpoint.ts)): shadow-repo snapshots scoped to the files the session's edit tools touched, so checkpoint size tracks the edits rather than the size of the working directory; ignored files stay out even when edited. Restore overwrites checkpointed files, puts back a file the session first edited after the checkpoint as it was before that edit, and keeps files created later; 100 per session, repos pruned after 30 days. `CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING` skips the pre-run snapshot entirely. -- **AskUserQuestion** ([`extensions/question.ts`](../extensions/question.ts)): 1-4 questions per call, each with `header` and 2-4 options, single- or `multiSelect`, plus free-text. Multiple questions share a TUI form: Left/Right or Tab/Shift+Tab move between the questions and a final Submit review, stopping at either end as in Claude Code. Navigation preserves answers, checkbox selections and text drafts; it does not select a highlighted option. Entering a question, answered or not, focuses its first row, as in Claude Code. A confirmed single-select answer shows a ✔ in the success colour: after the option's label, which also turns that colour, even with the focus on it, or after the text in the free-text row, as in Claude Code. The free-text row keeps its ✔ while its text is edited or deleted without Enter, deleted text showing the placeholder with the ✔, as Claude Code does, although the confirmed text stays the answer in the review and the result. Text typed in the free-text row stays there when an option is confirmed instead, and is not sent, as in Claude Code; a remote responder's option answer keeps it too. Checkboxes read `[✔]` in the success colour when checked and `[ ]` when not, as in Claude Code. **Divergence:** Claude Code draws every row number in grey; pi-code gives the number the colour of its label, and the success colour on a confirmed free-text row. The free-text option is an inline field: moving the highlight onto it starts typing, Left/Right move the cursor, Up/Down leave the row and keep the draft, and no key switches questions until typing stops. Enter confirms an answer and advances. A `multiSelect` question uses Space to toggle and Enter to confirm. **Divergence:** Claude Code toggles with Enter or Space and confirms on a separate Next/Submit row below the options. On the TUI overlay it also has the inline free-text row, whose checkbox is checked exactly while it has text; Space types there and never toggles it, and the typed text is sent after the checked labels as a separate `User wrote:` line. Enter with nothing checked and no text leaves it unanswered, as in Claude Code, clearing any earlier answer, and on a lone question it does nothing. The tab bar marks each question answered (☒) or not (☐). The Submit review lists the answered questions, warns when any are unanswered, and offers Submit answers or Cancel (Up/Down, Enter); Cancel is the same whole-call cancel as Esc. Once a `multiSelect` question is confirmed, every toggle and every edit of its text updates its answer, as in Claude Code, so what is shown is what is submitted. A confirmed single-select text answer changes only when Enter confirms the edited text, as in Claude Code. A confirmed single-select answer wins over a text draft left on the same question. Submitting marks unanswered questions explicitly as skipped while preserving confirmed answers and, for an unconfirmed `multiSelect` question, its checked options and typed text. Single-select text that Enter did not confirm is not an answer, as in Claude Code. Claude Code keeps the given answers on a partial submit too. **Divergence:** it leaves the unanswered questions out of the result, and reports that the user did not answer only when nothing was answered; pi-code names each unanswered question as skipped. The keys match Claude Code's [tab keybindings](https://code.claude.com/docs/en/keybindings#tabs-actions). Enter on a blank single-select field cancels the whole call, as Esc does, as in Claude Code. Esc cancels the whole call, from the field too, and discards every answer; the model gets a single cancellation. On the TUI overlay, Chat about this, below the options on every question, ends the call and sends the model Claude Code's clarify text with each question and the answer Submit would send: a `multiSelect` question's checks and text count as they stand, a single-select question's text only once Enter confirms it. **Divergence:** Claude Code returns that text as a rejected tool call, behind its rejection preamble "…To tell you how to proceed, the user said:", which credits its own template to the user; pi-code sends the clarify text alone. The RPC fallback has no Chat row, asks questions in sequence, and a cancel there also cancels the whole call. Honors `askUserQuestionTimeout` (`60s`/`5m`/`10m`, scope "User or managed" — a project's own settings.json cannot set it), read from managed settings then `~/.claude/settings.json`. On the TUI overlay only: a visible countdown for the last 20 seconds, any keypress restarting the timer, and on firing, confirmed answers are reported as on a normal submit, each unconfirmed question submits only its checked options, including a filled-in `multiSelect` text row, which the model gets apart from the checked labels (an unconfirmed highlight or single-select text draft is not sent), and the model is told once per call that the user may be away, even when every question was answered, so it proceeds on its own judgment rather than reading it as a cancel. **Not implemented:** restarting the timer on terminal focus-in, since pi's TUI input stream is not confirmed to carry that escape sequence; and the timeout on the RPC dialog-primitive fallback (no terminal, so no keypress or countdown to drive it); there a `multiSelect` question takes one option, since the dialog's select returns a single choice. +- **AskUserQuestion** ([`extensions/question.ts`](../extensions/question.ts)): 1-4 questions per call, each with `header` and 2-4 options, single- or `multiSelect`, plus free-text. Multiple questions share a TUI form: Left/Right or Tab/Shift+Tab move between the questions and a final Submit review, stopping at either end as in Claude Code. Navigation preserves answers, checkbox selections and text drafts; it does not select a highlighted option. Entering a question, answered or not, focuses its first row, as in Claude Code. A confirmed single-select answer shows a ✔ in the success colour: after the option's label, which also turns that colour, even with the focus on it, or after the text in the free-text row, as in Claude Code. The free-text row keeps its ✔ while its text is edited or deleted without Enter, deleted text showing the placeholder with the ✔, as Claude Code does, although the confirmed text stays the answer in the review and the result. Text typed in the free-text row stays there when an option is confirmed instead, and is not sent, as in Claude Code; a remote responder's option answer keeps it too. Checkboxes read `[✔]` in the success colour when checked and `[ ]` when not, as in Claude Code. **Divergence:** Claude Code draws every row number in grey; pi-code gives the number the colour of its label, and the success colour on a confirmed free-text row. The free-text option is an inline field: moving the highlight onto it starts typing, Left/Right move the cursor, Up/Down leave the row and keep the draft, and no key switches questions until typing stops. Enter confirms an answer and advances. A `multiSelect` question uses Space to toggle and Enter to confirm. **Divergence:** Claude Code toggles with Enter or Space and confirms on a separate Next/Submit row below the options. On the TUI overlay it also has the inline free-text row, whose checkbox is checked exactly while it has text; Space types there and never toggles it, and the typed text is sent after the checked labels as a separate `User wrote:` line. Enter with nothing checked and no text leaves it unanswered, as in Claude Code, clearing any earlier answer, and on a lone question it does nothing. The tab bar marks each question answered (☒) or not (☐). The Submit review lists the answered questions, warns when any are unanswered, and offers Submit answers or Cancel (Up/Down, Enter); Cancel is the same whole-call cancel as Esc. Once a `multiSelect` question is confirmed, every toggle and every edit of its text updates its answer, as in Claude Code, so what is shown is what is submitted. A confirmed single-select text answer changes only when Enter confirms the edited text, as in Claude Code. A confirmed single-select answer wins over a text draft left on the same question. Submitting marks unanswered questions explicitly as skipped while preserving confirmed answers and, for an unconfirmed `multiSelect` question, its checked options and typed text. Single-select text that Enter did not confirm is not an answer, as in Claude Code. Claude Code keeps the given answers on a partial submit too. **Divergence:** it leaves the unanswered questions out of the result, and reports that the user did not answer only when nothing was answered; pi-code names each unanswered question as skipped. The keys match Claude Code's [tab keybindings](https://code.claude.com/docs/en/keybindings#tabs-actions). Enter on a blank single-select field cancels the whole call, as Esc does, as in Claude Code. Esc cancels the whole call, from the field too, and discards every answer; the model gets a single cancellation. On the TUI overlay, Chat about this, below the options on every question, ends the call and sends the model Claude Code's clarify text with each question and the answer Submit would send: a `multiSelect` question's checks and text count as they stand, a single-select question's text only once Enter confirms it. **Divergence:** Claude Code returns that text as a rejected tool call, behind its rejection preamble "…To tell you how to proceed, the user said:", which credits its own template to the user; pi-code sends the clarify text alone. The RPC fallback has no Chat row, asks questions in sequence, and a cancel there also cancels the whole call. Honors `askUserQuestionTimeout` (`60s`/`5m`/`10m`, scope "User or managed"; a project's own settings.json cannot set it), read from managed settings then `~/.claude/settings.json`. On the TUI overlay only: a visible countdown for the last 20 seconds, any keypress restarting the timer, and on firing, confirmed answers are reported as on a normal submit, each unconfirmed question submits only its checked options, including a filled-in `multiSelect` text row, which the model gets apart from the checked labels (an unconfirmed highlight or single-select text draft is not sent), and the model is told once per call that the user may be away, even when every question was answered, so it proceeds on its own judgment rather than reading it as a cancel. **Not implemented:** restarting the timer on terminal focus-in, since pi's TUI input stream is not confirmed to carry that escape sequence; and the timeout on the RPC dialog-primitive fallback (no terminal, so no keypress or countdown to drive it); there a `multiSelect` question takes one option, since the dialog's select returns a single choice. Remote responders (a chat bridge, for example): on the TUI each question is first emitted on `pi.events` as `pi-code:question:v1`, typed as `RemoteQuestionOffer` in the same file. A listener that calls `claim()` synchronously during emission receives the only settle handle. The overlay opens either way and the first answer, local or remote, wins. Answers are 1-based option indices, free text only when `allowFreeText`, or `cancel`; `pass` or an invalid reply withdraws the remote side and leaves the overlay open. `touch()` restarts the overlay idle timer, and the offer's `signal` aborts once the question is settled, after which replies are rejected. A call with several questions differs from a single one. Every question is offered when the form opens, so up to four offers are live at once; each carries `batch` (`id` shared by the call's offers, 1-based `index`, `total`), which a single question's offer omits. An offer stays live while its question is unanswered, whichever question has focus; a remote answer to another question saves there without moving focus. The settle handle returning `true` means the answer was accepted, not that it is final: the local user can still change it until the form is submitted. A remote `cancel` on any offer cancels the whole call. Every open offer aborts when the form closes. A remote answer that leaves every question answered submits the form without a terminal review, whether the other answers were local or remote; while the highlight is on another question's field holding text that Enter has not confirmed, the form stays open instead. A remote answer to the question being typed in answers it, and the typed text is not sent. - **Notifications** ([`extensions/notify.ts`](../extensions/notify.ts)): terminal notification when a turn ends (OSC 777 / Kitty OSC 99 / Windows toast); honors `preferredNotifChannel` (`terminal_bell`, `notifications_disabled`, `iterm2_with_bell`, else desktop) from user settings or the `--settings` flag; fires only when you appear to be away, approximated by turn duration since pi exposes no terminal-focus signal. - **Think keyword** ([`extensions/thinking.ts`](../extensions/thinking.ts)): `ultrathink` raises reasoning to the max for one turn, matched on a word boundary, only ever raising, restored once the turn settles. It is the only keyword, as in Claude: `think`, `think hard`, `think more` and similar phrases pass through as ordinary prompt text. **Divergence:** Claude adds an in-context instruction and leaves the API effort level unchanged; pi has no separate in-context channel for this and its thinking level is how deeper reasoning is requested, so the keyword moves the level and restores it after.