Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .pi/extensions/dora.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Dora Extension - Minimal lifecycle hooks for dora CLI
*
* This extension only handles session lifecycle:
* - On session start: Check if dora is initialized
* - On session shutdown: Background index update
*
* The LLM uses regular `bash` tool to run dora commands.
* See .dora/docs/SKILL.md for complete dora usage documentation.
*/

import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";

export default function (pi: ExtensionAPI) {
let doraAvailable = false;

// Check dora status on session start
pi.on("session_start", async (_event, ctx) => {
try {
const check = await pi.exec("bash", ["-c", "command -v dora"], {
timeout: 1000,
});
doraAvailable = check.code === 0;

if (doraAvailable) {
const status = await pi.exec("bash", ["-c", "dora status 2>/dev/null"], {
timeout: 2000,
});

if (status.code !== 0) {
ctx.ui.notify("dora not initialized. Run: dora init && dora index", "info");
}
}
} catch (error) {
doraAvailable = false;
}
});

// Update index in background on shutdown
pi.on("session_shutdown", async (_event, ctx) => {
if (doraAvailable) {
try {
// Fire and forget background index update
pi.exec("bash", ["-c", "(dora index > /tmp/dora-index.log 2>&1 &) || true"], {
timeout: 500,
}).catch(() => {
// Ignore errors - this is best effort
});
} catch (error) {
// Silent failure for background task
}
}
});
}
69 changes: 69 additions & 0 deletions .pi/extensions/plan-mode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Plan Mode Extension

Read-only exploration mode for safe code analysis.

## Features

- **Read-only tools**: Restricts available tools to read, bash, grep, find, ls, question
- **Bash allowlist**: Only read-only bash commands are allowed
- **Plan extraction**: Extracts numbered steps from `Plan:` sections
- **Progress tracking**: Widget shows completion status during execution
- **[DONE:n] markers**: Explicit step completion tracking
- **Session persistence**: State survives session resume

## Commands

- `/plan` - Toggle plan mode
- `/todos` - Show current plan progress
- `Ctrl+Alt+P` - Toggle plan mode (shortcut)

## Usage

1. Enable plan mode with `/plan` or `--plan` flag
2. Ask the agent to analyze code and create a plan
3. The agent should output a numbered plan under a `Plan:` header:

```
Plan:
1. First step description
2. Second step description
3. Third step description
```

4. Choose "Execute the plan" when prompted
5. During execution, the agent marks steps complete with `[DONE:n]` tags
6. Progress widget shows completion status

## How It Works

### Plan Mode (Read-Only)

- Only read-only tools available
- Bash commands filtered through allowlist
- Agent creates a plan without making changes

### Execution Mode

- Full tool access restored
- Agent executes steps in order
- `[DONE:n]` markers track completion
- Widget shows progress

### Command Allowlist

Safe commands (allowed):

- File inspection: `cat`, `head`, `tail`, `less`, `more`
- Search: `grep`, `find`, `rg`, `fd`
- Directory: `ls`, `pwd`, `tree`
- Git read: `git status`, `git log`, `git diff`, `git branch`
- Package info: `npm list`, `npm outdated`, `yarn info`
- System info: `uname`, `whoami`, `date`, `uptime`

Blocked commands:

- File modification: `rm`, `mv`, `cp`, `mkdir`, `touch`
- Git write: `git add`, `git commit`, `git push`
- Package install: `npm install`, `yarn add`, `pip install`
- System: `sudo`, `kill`, `reboot`
- Editors: `vim`, `nano`, `code`
Loading