Skip to content
This repository was archived by the owner on Jun 9, 2026. It is now read-only.
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
14 changes: 7 additions & 7 deletions .opencode/PAI/ACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Actions run in two environments with identical behavior:

## Action Structure

Each action is a flat directory under `~/.claude/PAI/ACTIONS/`:
Each action is a flat directory under `~/.opencode/PAI/ACTIONS/`:

```
A_LABEL_AND_RATE/
Expand Down Expand Up @@ -195,7 +195,7 @@ const capabilities = {
### Local Execution

```bash
cd ~/.claude/PAI/ACTIONS
cd ~/.opencode/PAI/ACTIONS

# Run a single action
bun lib/runner.v2.ts run A_LABEL_AND_RATE --input '{"content": "Your text here"}'
Expand Down Expand Up @@ -258,7 +258,7 @@ Authorization: Bearer YOUR_AUTH_TOKEN

```bash
# Personal actions go in USER/ACTIONS/
mkdir ~/.claude/PAI/USER/ACTIONS/A_YOUR_ACTION
mkdir ~/.opencode/PAI/USER/ACTIONS/A_YOUR_ACTION
```

### Step 2: Define Manifest (action.json)
Expand Down Expand Up @@ -389,10 +389,10 @@ Same input should produce same output (for LLM actions, use temperature 0).

## Related Documentation

- **Pipelines:** `~/.claude/PAI/PIPELINES.md`
- **Flows:** `~/.claude/PAI/FLOWS.md`
- **Architecture:** `~/.claude/PAI/PAISYSTEMARCHITECTURE.md`
- **Personal Actions:** `~/.claude/PAI/USER/ACTIONS/`
- **Pipelines:** `~/.opencode/PAI/PIPELINES.md`
- **Flows:** `~/.opencode/PAI/FLOWS.md`
- **Architecture:** `~/.opencode/PAI/PAISYSTEMARCHITECTURE.md`
- **Personal Actions:** `~/.opencode/PAI/USER/ACTIONS/`
- **Source code:** `~/Projects/arbol/`

---
Expand Down
12 changes: 6 additions & 6 deletions .opencode/PAI/Algorithm/v3.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ The coarse version has 3 criteria that each hide 6+ verifiable sub-requirements.

**ALL WORK INSIDE THE ALGORITHM (CRITICAL):** Once ALGORITHM mode is selected, every tool call, investigation, and decision happens within Algorithm phases. No work outside the phase structure until the Algorithm completes.

**Entry banner was already printed by CLAUDE.md** before this file was loaded. The user has already seen:
**Entry banner was already printed by AGENTS.md** before this file was loaded. The user has already seen:
```
♻︎ Entering the PAI ALGORITHM… (v3.7.0) ═════════════
🗒️ TASK: [8 word description]
Expand Down Expand Up @@ -165,7 +165,7 @@ OUTPUT:
💪🏼 EFFORT LEVEL: [EFFORT LEVEL based on the reverse engineering step above] | [8 word reasoning]`

- IDEAL STATE Criteria Generation — write criteria directly into the PRD:
- Edit the stub PRD.md (already created at Algorithm entry) to add full content — update frontmatter `effort` field with the determined effort level, and add sections (Context, Criteria, Decisions, Verification) per `~/.claude/PAI/PRDFORMAT.md`
- Edit the stub PRD.md (already created at Algorithm entry) to add full content — update frontmatter `effort` field with the determined effort level, and add sections (Context, Criteria, Decisions, Verification) per `~/.opencode/PAI/PRDFORMAT.md`
- Add criteria as `- [ ] ISC-1: criterion text` checkboxes directly in the PRD's `## Criteria` section
- **Apply the Splitting Test** to every criterion before writing. Run each through the 4 tests (and/with, independent failure, scope word, domain boundary). Split any compound criteria into atomics.
- Set frontmatter `progress: 0/N` where N = total criteria count
Expand Down Expand Up @@ -348,7 +348,7 @@ OUTPUT:
- **WRITE REFLECTION JSONL (MANDATORY for Standard+ effort):** After outputting the learning reflections above, append a structured JSONL entry to the reflections log. This feeds MineReflections, AlgorithmUpgrade, and Upgrade workflows.

```bash
echo '{"timestamp":"[ISO-8601 with timezone]","effort_level":"[tier]","task_description":"[from TASK line]","criteria_count":[N],"criteria_passed":[N],"criteria_failed":[N],"prd_id":"[slug from PRD frontmatter]","implied_sentiment":[1-10 estimate of user satisfaction from conversation tone],"reflection_q1":"[Q1 answer - escape quotes]","reflection_q2":"[Q2 answer - escape quotes]","reflection_q3":"[Q3 answer from capabilities question - escape quotes]","within_budget":[true/false]}' >> ~/.claude/MEMORY/LEARNING/REFLECTIONS/algorithm-reflections.jsonl
echo '{"timestamp":"[ISO-8601 with timezone]","effort_level":"[tier]","task_description":"[from TASK line]","criteria_count":[N],"criteria_passed":[N],"criteria_failed":[N],"prd_id":"[slug from PRD frontmatter]","implied_sentiment":[1-10 estimate of user satisfaction from conversation tone],"reflection_q1":"[Q1 answer - escape quotes]","reflection_q2":"[Q2 answer - escape quotes]","reflection_q3":"[Q3 answer from capabilities question - escape quotes]","within_budget":[true/false]}' >> ~/.opencode/MEMORY/LEARNING/REFLECTIONS/algorithm-reflections.jsonl
```

Fill in all bracketed values from the current session. `implied_sentiment` is your estimate of how satisfied the user is (1=frustrated, 10=delighted) based on conversation tone — do NOT read ratings.jsonl. Escape double quotes in reflection text with `\"`.
Expand All @@ -358,7 +358,7 @@ Fill in all bracketed values from the current session. `implied_sentiment` is yo

### Critical Rules (Zero Exceptions)

- **Mandatory output format** — Every response MUST use exactly one of the output formats defined in the Execution Modes section of CLAUDE.md (ALGORITHM, NATIVE, ITERATION, or MINIMAL). No freeform output. No exceptions. If you completed algorithm work, wrap results in the ALGORITHM format. If iterating, use ITERATION. Choose the right format and use it.
- **Mandatory output format** — Every response MUST use exactly one of the output formats defined in the Execution Modes section of AGENTS.md (ALGORITHM, NATIVE, ITERATION, or MINIMAL). No freeform output. No exceptions. If you completed algorithm work, wrap results in the ALGORITHM format. If iterating, use ITERATION. Choose the right format and use it.
- **Response format before questions** — Always complete the current response format output FIRST, then invoke AskUserQuestion at the end. Never interrupt or replace the response format to ask questions. Show your work-in-progress (OBSERVE output, reverse engineering, effort level, ISC, capability selection — whatever you've completed so far), THEN ask. The user sees your thinking AND your questions together. Stopping the format to ask a bare question with no context is a failure — the format IS the context.
- **Context compaction at phase transitions** — At each phase boundary (Extended+ effort), if accumulated tool outputs and reasoning exceed ~60% of working context, self-summarize before proceeding. Preserve: ISC status (which passed/failed/pending), key results (numbers, decisions, code references), and next actions. Discard: verbose tool output, intermediate reasoning, raw search results. Format: 1-3 paragraphs replacing prior phase content. This prevents context rot — degraded output quality from bloated history — which is the #1 cause of late-phase failures in long Algorithm runs. Inspired by RLM (Zhang/Kraska/Khattab 2025).
- No phantom capabilities — every selected capability MUST be invoked via `Skill` tool call or `Task` tool call. Text-only output is NOT invocation. Selection without a tool call is dishonest and a CRITICAL FAILURE.
Expand All @@ -374,12 +374,12 @@ If after compaction you don't know your current phase or criteria status:
1. Read the most recent PRD from `MEMORY/WORK/` (by mtime) — it has all state
2. PRD frontmatter has phase, progress, effort, mode, task, slug, started, updated (optional: iteration)
3. PRD body has criteria checkboxes, decisions, verification evidence
4. `~/.claude/MEMORY/STATE/work.json` has the registry of all sessions (populated by read-only PRDSync + PRDStateSync hooks)
4. `~/.opencode/MEMORY/STATE/work.json` has the registry of all sessions (populated by read-only PRDSync + PRDStateSync hooks)

### PRD.md Format

**Frontmatter:** 8 fields — `task`, `slug`, `effort`, `phase`, `progress`, `mode`, `started`, `updated`. Optional: `iteration` (for rework).
**Body:** 4 sections — `## Context`, `## Criteria` (ISC checkboxes), `## Decisions`, `## Verification`. Sections appear only when populated.
**Full spec:** `~/.claude/PAI/PRDFORMAT.md` (read during OBSERVE if needed for field details or continuation rules).
**Full spec:** `~/.opencode/PAI/PRDFORMAT.md` (read during OBSERVE if needed for field details or continuation rules).

---
8 changes: 4 additions & 4 deletions .opencode/PAI/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The Algorithm CLI executes the PAI Algorithm (Observe → Think → Plan → Bui
# Run the Algorithm in autonomous loop mode
bun ~/.opencode/PAI/Tools/algorithm.ts -m loop -p <PRD-path> -n 20

# Run in interactive mode (launches a claude session with PRD context)
# Run in interactive mode (launches an OpenCode session with PRD context)
bun ~/.opencode/PAI/Tools/algorithm.ts -m interactive -p <PRD-path>

# Check status of all PRDs
Expand Down Expand Up @@ -57,7 +57,7 @@ algorithm stop -p <PRD> Stop a loop
Loop mode runs the Algorithm iteratively without human interaction. Each iteration:

1. Reads the PRD and identifies failing Ideal State Criteria
2. Spawns a `claude -p` session focused on the failing criteria
2. Spawns an OpenCode session via Task tool focused on the failing criteria
3. The session makes progress, updates the PRD checkboxes
4. Re-reads the PRD to check progress
5. Repeats until all criteria pass or max iterations reached
Expand Down Expand Up @@ -88,13 +88,13 @@ bun ~/.opencode/PAI/Tools/algorithm.ts -m loop -p PRD-20260213-auth.md -n 20 -a

#### Interactive Mode

Interactive mode launches a full `claude` session with the PRD context pre-loaded. You work with Claude directly to make progress on criteria.
Interactive mode launches a full OpenCode session with the PRD context pre-loaded. You work with OpenCode directly to make progress on criteria.

```bash
bun ~/.opencode/PAI/Tools/algorithm.ts -m interactive -p PRD-20260213-feature.md
```

This opens an interactive Claude session with:
This opens an interactive OpenCode session with:
- The PRD path and title
- Current progress (passing/total)
- List of failing criteria
Expand Down
Loading
Loading