# Plan: Restructure pi-skill as a Self-Contained Pi Package

## Context

The pi-skill project currently has a messy structure with three separate skill sources:

| Source | Location |
|--------|----------|
| agent-pi skills (20+) | `.repos/agent-pi/skills/` |
| Open Design skills (80+) | `.repos/open-design/skills/` |
| pi-skill custom skills (emdash, etc.) | `skills/` |
| Copied during install | `~/.pi/agent/skills/` |

The `install.sh` tries to copy skills between these directories, which is fragile and confusing. Pi already has two ways to discover skills — auto-discovering `~/.pi/agent/skills/` AND loading from package manifests — but the current setup fights both mechanisms.

**Goal:** Make pi-skill a single, self-contained Pi package. All skills in one place. Install via `pi install .` — no install script needed.

---

## Phase 1: Centralize All Resources into pi-skill

**Why:** pi-skill already has copies of agent-pi's 43 extensions and most of its skills. We need the remaining agent-pi resources (themes, agents, commands, prompts) to make pi-skill a complete stand-in for agent-pi.

**Copy** → agent-pi resources that pi-skill is missing:

- `cp -r .repos/agent-pi/themes/ themes/` (11 themes)
- `cp -r .repos/agent-pi/agents/ agents/` (agent definitions YAML)
- `cp -r .repos/agent-pi/commands/ commands/` (slash commands)
- `cp -r .repos/agent-pi/prompts/ prompts/` (prompt templates)
- `cp -r .repos/agent-pi/tex/ tex/` (Text Tools app)
- `cp .repos/agent-pi/agent-logo.png agent-logo.png`

**Update** → `package.json` to declare ALL resources:

```json
{
  "name": "pi-skill",
  "private": true,
  "version": "2.0.0",
  "description": "pi-skill — 50+ skills, 43 extensions, 11 themes for Pi",
  "keywords": ["pi-package"],
  "pi": {
    "extensions": ["./extensions"],
    "skills": ["./skills"],
    "themes": ["./themes"],
    "agents": ["./agents"],
    "commands": ["./commands"],
    "prompts": ["./prompts"]
  }
}
```

---

## Phase 2: Resolve Skill Conflicts and Clean Up

**Why:** Some skills may now exist in both pi-skill's `skills/` and pi-agent's old skills. We need to deduplicate.

**Check for name collisions** between pi-skill `skills/` and agent-pi `skills/`:

| pi-skill has | agent-pi has | Conflict? |
|---|---|---|
| agent-browser | agent-browser | YES — pi-skill has emdash version, agent-pi has original |
| building-emdash-site | — | No (pi-skill custom) |
| creating-plugins | — | No (pi-skill custom) |
| emdash-cli | — | No (pi-skill custom) |
| ... | autoresearch, just-bash, nano-banana, etc. | pi-skill may be missing some agent-pi skills |

**Action:** Copy any agent-pi skills missing from pi-skill's `skills/` into it. Keep pi-skill's versions where conflicts exist (they're more specific/detailed).

---

## Phase 3: Register pi-skill as the Primary Package

**Why:** Pi currently loads `git:github.com/ruizrica/agent-pi` as a package. We need to replace it with pi-skill.

**Update** `~/.pi/agent/settings.json`:

```json
{
  "packages": [
    "/Users/kunthawatgreethong/gitea/pi-skill",
    "npm:@plannotator/pi-extension"
  ]
}
```

Then verify: `pi install /Users/kunthawatgreethong/gitea/pi-skill`

---

## Phase 4: Simplify install.sh → bootstrap.sh

**Why:** The current install.sh is complex and user wants it gone. Replace it with a minimal bootstrap script.

New minimal `bootstrap.sh`:
```bash
#!/bin/bash
# bootstrap.sh — One-time setup for pi-skill
# After this, just use: pi install <path-to-pi-skill>

set -e
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "Registering pi-skill with Pi..."
pi install "$SOURCE_DIR"

echo ""
echo "Done! Restart Pi agent to load all 50+ skills, 43 extensions, and 11 themes."
```

---

## Phase 5: Test & Verify

1. Run `pi install /Users/kunthawatgreethong/gitea/pi-skill`
2. Restart Pi
3. Verify emdash skills appear in AI's available skills
4. Verify extensions still work (modes, commands, themes)
5. Clean up old agent-pi package from settings if still listed

---

## Critical Files

| File | Action |
|------|--------|
| `package.json` | Modify — add themes, agents, commands, prompts |
| `themes/` | New — copy from `.repos/agent-pi/themes/` |
| `agents/` | New — copy from `.repos/agent-pi/agents/` |
| `commands/` | New — copy from `.repos/agent-pi/commands/` |
| `prompts/` | New — copy from `.repos/agent-pi/prompts/` |
| `tex/` | New — copy from `.repos/agent-pi/tex/` |
| `agent-logo.png` | New — copy from `.repos/agent-pi/` |
| `install.sh` | Replace with minimal `bootstrap.sh` |
| `~/.pi/agent/settings.json` | Update — replace agent-pi package with pi-skill |
| `~/.pi/agent/skills/` | Clean up redundant copies |

## Reusable Components (no changes needed)

- **`extensions/`** — already identical to agent-pi's 43 extensions, ready to use
- **`skills/`** — already has 51 skills including emdash ones, just need to fill missing agent-pi skills
- **`.repos/`** — keep as reference sources for future syncs

## Verification

1. `pi list` — should show pi-skill with 50+ skills, 43 extensions, 11 themes
2. Restart Pi — all modes, commands, themes should work
3. Ask about "emdash" — AI should find the building-emdash-site, creating-plugins, etc. skills
4. `/mode` — should cycle modes normally
5. No more errors about missing extensions or skills
