4.4 KiB
4.4 KiB
AGENTS.md
Project conventions for agent-assisted development.
Project Overview
This repository provides Pi coding agent skills and extensions. The primary component is goal-driven-loop — a skill + extension pair that keeps a session focused on a user-defined goal with explicit acceptance criteria.
Repository Structure
extensions/goal-driven-loop/ # TypeScript extension (Pi Extension API)
.agents/skills/goal-driven-loop/ # Skill instructions (Markdown)
.pi/skills/ → symlink # Pi skill discovery
.pi/extensions/ → symlink # Pi extension discovery
docs/superpowers/ # Design specs and implementation plans
openspec/ # OpenSpec change archive
Agent directories (.claude/, .agents/, .pi/) are gitignored. Only the symlinks and source files at top-level directories are committed.
Tech Stack
- Skills: Markdown (Agent Skills standard), no build step
- Extensions: TypeScript, loaded via jiti (no compilation needed), depends on
@earendil-works/pi-coding-agentExtension API - Testing: Manual behavioral tests via
pi -p/pi -e; unit tests run withnpx jitiagainst individual modules - Workflow: OpenSpec → comet lifecycle for change tracking
Development Commands
# Verify skill loads
pi -p "/skill:goal-driven-loop"
# Verify extension loads
pi -e extensions/goal-driven-loop/index.ts -p "test"
# Run unit tests for trigger-detector
npx jiti /tmp/test-trigger-detector.mjs
# Run unit tests for state-injector
npx jiti /tmp/test-state-injector.mjs
# End-to-end test (create a temp project first)
mkdir -p /tmp/test && cd /tmp/test && git init
pi -e /path/to/pi-setup/extensions/goal-driven-loop/index.ts \
-p "当前目标是实现 reverseString(s) 函数"
Key Design Decisions
- Skill + Extension dual layer: Skill = instructions (agent reads). Extension = mechanics (event handlers). Do not mix concerns.
- File-based state (
.agents/goal/GOAL.md): Survives context compaction. Deleted on goal completion. - Extension never blocks user: All confirms use timed auto-defaults (10s timeout). Fallbacks are safe (continue existing goal).
- Anti-triggers are mechanical: Code blocks, quote blocks, reported speech, trivial keywords — all checked programmatically, not by agent judgment.
- Per-iteration retry: Exponential backoff counter resets each iteration. 10 retries / ~37min coverage.
- Comet delegation: Coarse-grained goals auto-delegate to
comet-open. Fallback to multi-stage mode if comet unavailable.
When Modifying This Project
Adding a new skill
- Create directory at
.agents/skills/<name>/SKILL.md - Follow the Agent Skills standard: YAML frontmatter with
nameanddescription(start with "Use when...") - Keep SKILL.md ≤ 500 words; move detailed reference to
references/subdirectory - Create symlink:
ln -s ../../.agents/skills/<name> .pi/skills/<name> - Test with
pi -p "/skill:<name>"
Adding a new extension
- Create directory at
extensions/<name>/ - Write
index.tsthat exports a default function receivingExtensionAPI - Add
package.jsonwith{ "pi": { "extensions": ["./index.ts"] } } - Create symlink:
ln -s ../../extensions/<name> .pi/extensions/<name> - Test with
pi -e extensions/<name>/index.ts -p "test"
Modifying goal-driven-loop
- Skill layer (
.agents/skills/goal-driven-loop/): Changes to instructions, acceptance criteria rules, error handling reference - Extension layer (
extensions/goal-driven-loop/):trigger-detector.ts— trigger phrase patterns and anti-trigger logicstate-injector.ts— GOAL.md parsing and injection text generationui-prompts.ts— timed confirms and notification helpersindex.ts— event wiring (input, before_agent_start)
After any change, re-run unit tests and E2E verification.
Commit Conventions
feat(skill):/feat(ext):— new featuresfix(skill):/fix(ext):— bug fixesdocs:— documentation changeschore:— maintenance (gitignore, archive, etc.)
Known Limitations (v1)
- Mid-loop granularity upgrade needs skill-side signal (
status: needs-upgradein GOAL.md) — extension cannot auto-detect goal complexity increase - Agent "estimates < 5 min" anti-trigger is instruction-level only, not mechanical
- Stagnation dual-signal precise detection needs skill-side passing count history in GOAL.md — extension relies on skill's own stagnation detection