Skip to content
Open
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
51 changes: 51 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ set -euo pipefail
INSTALL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLAUDE_DIR="$HOME/.claude"
SETTINGS_FILE="$CLAUDE_DIR/settings.json"
OPENCODE_DIR="$HOME/.config/opencode"
OPENCODE_COMMANDS_DIR="$OPENCODE_DIR/commands"
OPENCODE_USER_STATE_DIR="$HOME/.opencode"
LOCAL_BIN_DIR="$HOME/.local/bin"
BIN_DIR="/usr/local/bin"
MARKETPLACE_NAME="cavekit-local"
MARKETPLACE_DIR="$CLAUDE_DIR/plugins/local/cavekit-marketplace"
Expand Down Expand Up @@ -152,6 +156,38 @@ info "Configuring Codex bundle..."
chmod +x "$INSTALL_DIR/scripts/sync-codex-plugin.sh"
"$INSTALL_DIR/scripts/sync-codex-plugin.sh"

# ─── Sync OpenCode commands ─────────────────────────────────────────────────

if [[ -d "$OPENCODE_DIR" || -d "$OPENCODE_USER_STATE_DIR" ]] || command -v opencode &>/dev/null; then
info "Configuring OpenCode commands..."
mkdir -p "$OPENCODE_COMMANDS_DIR"

for command_file in "$INSTALL_DIR"/opencode/commands/*.md; do
command_name="$(basename "$command_file")"
ln -sfn "$command_file" "$OPENCODE_COMMANDS_DIR/$command_name"
done

for command_path in "$OPENCODE_COMMANDS_DIR"/ck-*.md; do
[[ -L "$command_path" ]] || continue
target_path="$(readlink "$command_path" || true)"
[[ "$target_path" == "$INSTALL_DIR/opencode/commands/"* ]] || continue
[[ -e "$target_path" ]] || rm -f "$command_path"
done

if [[ -f "$INSTALL_DIR/opencode/AGENTS.md" ]]; then
if [[ ! -e "$OPENCODE_DIR/AGENTS.md" ]]; then
cp "$INSTALL_DIR/opencode/AGENTS.md" "$OPENCODE_DIR/AGENTS.md"
ok "Copied OpenCode AGENTS template to $OPENCODE_DIR/AGENTS.md"
else
warn "Leaving existing OpenCode AGENTS.md unchanged at $OPENCODE_DIR/AGENTS.md"
fi
fi

ok "Linked OpenCode commands at $OPENCODE_COMMANDS_DIR"
else
warn "OpenCode not detected. Skipping OpenCode command install."
fi

# ─── Install cavekit CLI ─────────────────────────────────────────────────

info "Installing cavekit command..."
Expand Down Expand Up @@ -182,6 +218,12 @@ fi
if [[ -w "$BIN_DIR" ]]; then
ln -sf "$INSTALL_DIR/scripts/cavekit" "$BIN_DIR/cavekit"
ok "Installed cavekit to $BIN_DIR/cavekit"
elif mkdir -p "$LOCAL_BIN_DIR" && [[ -w "$LOCAL_BIN_DIR" ]]; then
ln -sf "$INSTALL_DIR/scripts/cavekit" "$LOCAL_BIN_DIR/cavekit"
ok "Installed cavekit to $LOCAL_BIN_DIR/cavekit"
if [[ ":$PATH:" != *":$LOCAL_BIN_DIR:"* ]]; then
warn "$LOCAL_BIN_DIR is not on PATH. Add it to use 'cavekit' directly."
fi
else
info "Need sudo to install cavekit to $BIN_DIR"
sudo ln -sf "$INSTALL_DIR/scripts/cavekit" "$BIN_DIR/cavekit"
Expand Down Expand Up @@ -213,4 +255,13 @@ printf " ${B}Codex:${R}\n"
printf " Linked local bundle via ~/plugins/ck and ~/.agents/plugins/marketplace.json\n"
printf " Linked prompts into ~/.codex/prompts (for /prompts:ck-... commands)\n"
printf "\n"
printf " ${B}OpenCode:${R}\n"
printf " /ck-help Show portable-phase guide\n"
printf " /ck-init Bootstrap context/ for OpenCode\n"
printf " /ck-sketch Draft kits with approval gate\n"
printf " /ck-map Generate build-site.md\n"
printf " /ck-make <target> Sequential scoped implementation\n"
printf " /ck-check Read-only verification\n"
printf " /ck-status Snapshot progress report\n"
printf "\n"
printf " Restart Claude Code and Codex to load the plugin changes.\n\n"
9 changes: 9 additions & 0 deletions opencode/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Cavekit OpenCode Port

Use the OpenCode Cavekit commands from `~/.config/opencode/commands/` when the repo follows the Cavekit workflow.

Hard rules:
- This is the **Portable Phase 1 OpenCode port**, not upstream Claude/Codex runtime parity.
- Do not claim autonomous loops, stop hooks, worktree fan-out, team mode, or hidden background orchestration.
- Prefer the normal workflow: kits → build-site → scoped implementation → read-only verification.
- Keep requirements implementation-agnostic in kits. Track execution in plans and impl docs.
95 changes: 95 additions & 0 deletions opencode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Cavekit for OpenCode — Portable Phase 1

This directory contains the **OpenCode-native Cavekit port** for the portable phases only:

- `/ck-init`
- `/ck-sketch`
- `/ck-map`
- `/ck-make`
- `/ck-check`
- `/ck-status`
- `/ck-help`

## What this port is

- Real OpenCode command files, stored in-repo and installable via `install.sh`
- Truthful adaptation of Cavekit's **spec → plan → build → verify** workflow
- Sequential, tool-driven execution using OpenCode's normal file and shell tools

## What this port is not

- Not the Claude Code plugin runtime
- Not the Codex prompt/runtime bundle
- No autonomous stop-hook loop
- No `Agent()` fan-out or worktree orchestration
- No `.cavekit/tasks.json` task registry
- No `make-parallel`, team mode, visual companion, or auto-backprop runtime

## Install into OpenCode

Run:

```bash
~/.cavekit/install.sh
```

If OpenCode is detected, the installer symlinks `opencode/commands/*.md` into:

```text
~/.config/opencode/commands/
```

It also links `opencode/AGENTS.md` **only when** `~/.config/opencode/AGENTS.md` does not already exist.

## Command contract

### `/ck-init`
- Bootstraps `context/` directories and minimal CLAUDE docs
- Optional `--tools-only` capability summary
- Does **not** create the upstream `.cavekit/` runtime

### `/ck-sketch`
- Design-first kit drafting
- Requires explicit approval before writing kit files
- Supports interactive and `--from-code` brownfield drafting

### `/ck-map`
- Reads kits and writes `context/plans/build-site.md`
- Produces tier tables, a coverage matrix, and a Mermaid dependency graph
- Does **not** initialize `.cavekit/tasks.json`

### `/ck-make`
- Sequential, scoped implementation for one task or requirement at a time
- Runs tests/builds with OpenCode's normal shell tool
- Does **not** auto-commit, auto-loop, or spawn subagents

### `/ck-check`
- Read-only verification against kits and code
- Reports gaps and prioritized review findings
- Does **not** auto-fix or auto-revise kits

### `/ck-status`
- Single-snapshot status report from kits, plan, impl docs, and git
- `--watch` is intentionally unsupported in this port

## Verification

Automated check:

```bash
node tests/run-tests.cjs
```

Manual smoke test in a target repo:

1. `/ck-init`
2. `/ck-sketch --from-code`
3. Approve domain proposal and write kits
4. `/ck-map`
5. `/ck-status`
6. `/ck-make T-001` or similar target
7. `/ck-check`

## Port honesty rule

Do not claim parity with upstream Cavekit runtime. Describe this as an **OpenCode portable port**.
55 changes: 55 additions & 0 deletions opencode/commands/ck-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: Read-only verification against kits and code for the OpenCode Cavekit portable workflow
argument-hint: [--filter PATTERN]
---

You are running **/ck-check** for the OpenCode Cavekit portable port.

Hard rules:
- Read-only analysis only.
- Do not edit kits, plans, code, or impl docs.
- Do not claim upstream inspection/runtime parity.
- Inspect files directly. Do not guess from summaries alone.

Interpret `$ARGUMENTS` as an optional filter for kits, domains, or task ranges.

## Inspect
Use Read/Glob/Grep and, when useful, Bash for git/test commands. Inspect:
- `AGENTS.md` if present
- relevant `context/kits/cavekit-*.md`
- `context/kits/cavekit-overview.md` if present
- `context/plans/build-site.md` if present
- `context/impl/` artifacts if present
- relevant source files
- relevant tests
- `git status`
- recent diff or recent commits when useful

## Pass 1: Gap analysis
For each relevant requirement and acceptance criterion, classify:
- COMPLETE
- PARTIAL
- MISSING
- OVER-BUILT

Ground each finding in actual code or tests with file references.

## Pass 2: Code review
Look for:
- logic bugs
- edge-case misses
- poor error handling
- security issues
- performance issues
- maintainability problems
- drift from repo rules in `AGENTS.md`

## Output
Return a concise report with:
- coverage summary
- top requirement gaps
- prioritized findings (P0/P1/P2/P3)
- verdict: APPROVE / REVISE / REJECT
- exact next step, usually `/ck-make <target>` or `/ck-sketch`

Do not auto-fix anything. Recommend fixes only.
45 changes: 45 additions & 0 deletions opencode/commands/ck-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
description: Show the OpenCode Cavekit portable workflow and recommend the next command
---

You are serving the **Cavekit OpenCode portable port**.

Hard rules:
- Be explicit that this is **not** the upstream Claude/Codex Cavekit runtime.
- No autonomous loop, no hook-driven re-entry, no subagent fan-out, no worktree orchestration, no hidden runtime state.
- Use OpenCode's normal tools only.

First inspect the current repo with read-only tools:
- project root
- `README.md` if present
- `AGENTS.md` if present
- `context/kits/`, `context/plans/`, `context/impl/` if present

Then return a concise guide with these sections:

## Workflow
- `/ck-init` → bootstrap `context/`
- `/ck-sketch` → write or refine kits after explicit approval
- `/ck-map` → generate `context/plans/build-site.md`
- `/ck-make <target>` → implement one bounded task or requirement at a time
- `/ck-check` → read-only verification against kits and code
- `/ck-status` → snapshot of kit/plan/impl/git state

## Supported in OpenCode port
- Sequential file-based workflow
- Kit drafting and refinement
- Build-site generation with tier tables + coverage matrix
- Scoped implementation with normal test/build commands
- Read-only verification and status reporting

## Not supported in OpenCode port
- parallel build orchestration
- hook-driven autonomous loop
- subagent dispatch APIs
- `.cavekit/tasks.json` runtime registry
- team mode, visual companion, auto-backprop, live dashboards

## Recommended next step
- Recommend exactly one command for the current repo: `/ck-init`, `/ck-sketch`, `/ck-map`, `/ck-make <target>`, or `/ck-check`.

Keep it short and operational.
107 changes: 107 additions & 0 deletions opencode/commands/ck-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
description: Bootstrap context directories for the OpenCode Cavekit portable workflow
argument-hint: [--tools-only]
---

You are running **/ck-init** for the OpenCode Cavekit portable port.

Hard rules:
- Do not claim this initializes the upstream `.cavekit/` runtime.
- Do not call upstream runtime scripts, router scripts, hook scripts, tmux helpers, or subagent APIs.
- Idempotent only. Create missing files. Do not overwrite existing project docs.

Interpret `$ARGUMENTS`:
- `--tools-only` → capability summary only, no file edits
- empty → bootstrap `context/` and minimal CLAUDE docs

## If `--tools-only`
Use the Bash tool to check common tools with `command -v` and summarize availability for:
- git
- gh
- node
- npm
- python3
- docker
- opencode
- codex

Return a short table and a brief note that capability discovery is advisory only.

## Default mode

1. Inspect repo root first with Read/Glob:
- existing `context/`
- `README.md`
- `AGENTS.md`
- `.gitignore`

2. Create these directories if missing:
- `context/`
- `context/refs/`
- `context/kits/`
- `context/designs/`
- `context/plans/`
- `context/impl/`
- `context/impl/archive/`

3. Create these files only if missing:

### `context/CLAUDE.md`
```markdown
# Context Hierarchy

This repo uses the Cavekit OpenCode portable workflow.

- refs/ — source material and external references
- kits/ — implementation-agnostic requirements
- designs/ — visual system and design references
- plans/ — build-site and task graphs
- impl/ — execution notes, progress, dead ends
```

### `context/refs/CLAUDE.md`
```markdown
# References

Source material used to derive kits. Read-only inputs.
```

### `context/kits/CLAUDE.md`
```markdown
# Kits

Kits describe what must be true, not how to implement it.
Use `cavekit-overview.md` as the entry point.
```

### `context/plans/CLAUDE.md`
```markdown
# Plans

Plans translate kits into tasks, tiers, and dependencies.
Use `build-site.md` as the primary execution plan.
```

### `context/impl/CLAUDE.md`
```markdown
# Implementation Tracking

Record what was changed, what passed, what failed, and what remains.
```

### `context/designs/CLAUDE.md`
```markdown
# Design System

Store design references here or point to a root DESIGN.md.
```

4. If source directories like `src/`, `app/`, `lib/`, `tests/`, or `scripts/` exist and already contain no `CLAUDE.md`, you may add a minimal local `CLAUDE.md` only when it helps navigation. Keep it tiny.

5. Report:
- directories created
- files created
- files left untouched
- exact next step: usually `/ck-sketch`

Keep the bootstrap minimal and honest.
Loading