diff --git a/.sf/DECISIONS.md b/.sf/DECISIONS.md new file mode 100644 index 000000000..a54784d10 --- /dev/null +++ b/.sf/DECISIONS.md @@ -0,0 +1,10 @@ +# Decisions Register + + + +| # | When | Scope | Decision | Choice | Rationale | Revisable? | Made By | +|---|---|------|----------|--------|-----------|------------|--------| +| D001 | M001-3hf5k0/S01 | architecture | Recover from the most recent valid backup rather than attempting raw SQLite page repair | Copy `.sf/backups/db/sf.db.2026-05-10T02-42-23-822Z` to `.sf/sf.db`, clear WAL/SHM files | The WAL file is 0 bytes (empty), meaning all committed transactions are in the main DB file. The corruption is in the main DB pages, not the WAL. The backup at 02:42 is ~3 hours old and contains the full planning state (M001-6377a4 with 5 slices, M002-f6fabd). Recovery from backup is faster and more reliable than page-level repair. | Yes — if a newer backup becomes available or if the page-repair approach proves more complete | agent | +| D002 | M001-3hf5k0/S01 | pattern | Keep the M001-3hf5k0 directory created by the autonomous bootstrap session as the working directory for this recovery milestone | Use M001-3hf5k0/ for M001-3hf5k0 milestone files; use M001-6377a4/ for recovered milestone files | The autonomous session created the M001-3hf5k0 directory structure at 05:56. Using it avoids creating duplicate directory entries. After DB recovery, M001-6377a4 becomes the active milestone from the DB and its roadmap files can be created in M001-6377a4/. The DB is authoritative for milestone identity. | Yes — if the M001-6377a4/ directory creation conflicts with other tooling | agent | diff --git a/.sf/PROJECT.md b/.sf/PROJECT.md new file mode 100644 index 000000000..ddd97cd90 --- /dev/null +++ b/.sf/PROJECT.md @@ -0,0 +1,40 @@ +--- +generated: 2026-05-10T03:56:00Z +sf_version: 2.75.3 +--- + +# SF — Singularity Forge + +**What it does:** Autonomous repo operator built on Pi SDK. Takes bounded intent, applies PDD/TDD gates, executes milestones/slices/tasks with self-healing recovery, and produces verified software. + +**Core value:** Purpose-to-software compiler — not a generic coding assistant. Every unit must name its purpose, consumer, and falsifiable contract before implementation. + +**Current state:** BLOCKED. SQLite DB (`.sf/sf.db`) is malformed (corrupted). DB backup exists at `.sf/backups/db/sf.db.2026-05-10T02-42-23-822Z`. This milestone recovers the DB and executes the highest-value pending task from the recovered roadmap. + +**Architecture:** TypeScript monorepo (7 workspace packages), Rust N-API engine, Next.js web frontend, Pi SDK harness. Extension source at `src/resources/extensions/sf/` compiled to `dist/resources/extensions/sf/`. + +## Milestone Sequence + +- [ ] **M001-3hf5k0**: DB Recovery and S01-T01 Execution — recover corrupted DB, execute CLI/help doctrine fix +- [ ] **M001-6377a4** *(pending, recovered from backup)*: M001 Roadmap — stabilize core doctrine, sharpen execution, deepen reliability, keep surfaces coherent, prepare ACE convergence + +## Key Verification Commands + +```bash +# Run full test suite +npm run test + +# Build core +npm run build:core + +# Type check extensions +npm run typecheck:extensions + +# Lint +npm run lint + +# Rust checks +for d in "rust-engine" "rust-engine/crates/ast" "rust-engine/crates/engine" "rust-engine/crates/grep"; do + (cd "$d" && cargo check && cargo test -- --test-threads=2 && cargo clippy -- -D warnings) +done +``` diff --git a/.sf/REQUIREMENTS.md b/.sf/REQUIREMENTS.md new file mode 100644 index 000000000..e62a8cbb0 --- /dev/null +++ b/.sf/REQUIREMENTS.md @@ -0,0 +1,94 @@ +--- +generated: 2026-05-10T03:56:00Z +--- + +# Requirements + +This file captures the explicit capability and coverage contract for SF. + +## Active + +### R001 — Doctrine Alignment +- Class: core-capability +- Status: active +- Description: SF's product surfaces (CLI help, system prompt, summarization prompt) explicitly frame SF as a "purpose-driven software compiler" instead of a generic "AI coding assistant". +- Why it matters: ADR-0000 defines SF's product contract. Product surfaces that describe SF as a "coding assistant" violate the contract and confuse users and LLMs about SF's nature. +- Source: M001-6377a4/S01 planning +- Primary owning slice: M001-3hf5k0/S01 +- Supporting slices: none +- Validation: unmapped +- Notes: Target files confirmed by grep; mechanical string replacements only + +### R002 — DB State Integrity +- Class: quality-attribute +- Status: active +- Description: SF's SQLite DB (`.sf/sf.db`) must be readable and not malformed. Recovery from backup must restore the full planning state. +- Why it matters: Without a readable DB, SF blocks all milestone planning and autonomous execution. +- Source: M001-6377a4/S01 planning +- Primary owning slice: M001-3hf5k0/S01 +- Supporting slices: none +- Validation: unmapped +- Notes: Backup at `.sf/backups/db/sf.db.2026-05-10T02-42-23-822Z` contains M001-6377a4 with 5 slices and 1 task + +## Deferred + +### R003 — A2A Adoption +- Class: integration +- Status: deferred +- Description: Adopt A2A as the internal agent communication protocol, wrapping MessageBus as transport. +- Why it matters: Standardizes agent messaging semantics without replacing the SQLite-backed MessageBus infrastructure. +- Source: docs/plans/A2A_ADOPTION_PLAN.md +- Primary owning slice: none (Tier 1) +- Supporting slices: none +- Validation: unmapped +- Notes: 6-phase migration plan exists in docs/plans/A2A_ADOPTION_PLAN.md + +### R004 — Unified Dispatch Architecture +- Class: architecture +- Status: deferred +- Description: Merge parallel-orchestrator and slice-parallel-orchestrator into WorktreeOrchestrator, then extract DispatchService API. +- Why it matters: Eliminates ~80% code duplication between the two orchestrators and provides a unified dispatch surface. +- Source: docs/plans/UNIFIED_DISPATCH_V2.md +- Primary owning slice: none (Phase 1 = Week 1) +- Supporting slices: none +- Validation: unmapped +- Notes: 6-phase plan; Phase 1 is merge (highest value, lowest risk) + +### R005 — DB Schema Separation +- Class: quality-attribute +- Status: deferred +- Description: Normalize milestone/slice/task tables into spec + runtime + evidence tables per ADR-0077. +- Why it matters: Clear semantics (spec=intent, runtime=state, evidence=history), better query performance, auditability. +- Source: docs/adr/0077-spec-runtime-evidence-schema-separation.md +- Primary owning slice: none (v3.0 target) +- Supporting slices: none +- Validation: unmapped +- Notes: Proposed; implementation phased across milestone tables first + +## Out of Scope + +### R010 — MCP Server +- Class: anti-feature +- Status: out-of-scope +- Description: SF must not ship or revive an MCP server package or runtime endpoint. +- Why it matters: SF-owned tools must remain native SF/pi tools per .sf/ANTI-GOALS.md. +- Source: .sf/ANTI-GOALS.md +- Notes: SF may consume external MCP servers as a client. + +## Traceability + +| ID | Class | Status | Primary owner | Supporting | Proof | +|---|---|---|---|---|---| +| R001 | core-capability | active | M001-3hf5k0/S01 | none | unmapped | +| R002 | quality-attribute | active | M001-3hf5k0/S01 | none | unmapped | +| R003 | integration | deferred | none | none | unmapped | +| R004 | architecture | deferred | none | none | unmapped | +| R005 | quality-attribute | deferred | none | none | unmapped | +| R010 | anti-feature | out-of-scope | none | none | n/a | + +## Coverage Summary + +- Active requirements: 2 +- Mapped to slices: 2 +- Validated: 0 +- Unmapped active requirements: 0 diff --git a/.sf/backups/db/sf.db.2026-05-10T04-25-32-791Z b/.sf/backups/db/sf.db.2026-05-10T04-25-32-791Z new file mode 100644 index 000000000..cfb3d4dae Binary files /dev/null and b/.sf/backups/db/sf.db.2026-05-10T04-25-32-791Z differ diff --git a/.sf/metrics.db b/.sf/metrics.db index 46bbe21a9..18247c1ef 100644 Binary files a/.sf/metrics.db and b/.sf/metrics.db differ diff --git a/.sf/metrics.db-shm b/.sf/metrics.db-shm index 2899ede96..79e6bceaf 100644 Binary files a/.sf/metrics.db-shm and b/.sf/metrics.db-shm differ diff --git a/.sf/metrics.db-wal b/.sf/metrics.db-wal index 51dafc0eb..4cb2edaf0 100644 Binary files a/.sf/metrics.db-wal and b/.sf/metrics.db-wal differ diff --git a/docs/dev/context-and-hooks/07-the-system-prompt-anatomy.md b/docs/dev/context-and-hooks/07-the-system-prompt-anatomy.md index 34e9cb2ae..9cbaf7286 100644 --- a/docs/dev/context-and-hooks/07-the-system-prompt-anatomy.md +++ b/docs/dev/context-and-hooks/07-the-system-prompt-anatomy.md @@ -42,8 +42,7 @@ After `buildSystemPrompt()`, extensions can further modify via `before_agent_sta When no SYSTEM.md exists, pi uses its built-in base: ``` -You are an expert coding assistant operating inside pi, a coding agent harness. -You help users by reading files, executing commands, editing code, and writing new files. +You are a purpose-driven software compiler. You take bounded intent, produce a falsifiable purpose contract (the PDD/TDD gate), then write failing tests before implementation. You help users by reading files, executing commands, editing code, and writing new files. Available tools: - read: Read file contents diff --git a/packages/pi-coding-agent/src/cli/args.ts b/packages/pi-coding-agent/src/cli/args.ts index 80947d95d..88d4cfd2b 100644 --- a/packages/pi-coding-agent/src/cli/args.ts +++ b/packages/pi-coding-agent/src/cli/args.ts @@ -235,7 +235,7 @@ export function parseArgs( } export function printHelp(): void { - console.log(`${chalk.bold(APP_NAME)} - AI coding assistant with native read/search/edit/write tools + console.log(`${chalk.bold(APP_NAME)} - Purpose-driven software compiler. Takes bounded intent, produces verified software via PDD/TDD gates. ${chalk.bold("Usage:")} ${APP_NAME} [options] [@files...] [messages...] @@ -252,7 +252,7 @@ ${chalk.bold("Options:")} --provider Provider name (default: google) --model Model pattern or ID (supports "provider/id" and optional ":") --api-key API key (defaults to env vars) - --system-prompt System prompt (default: coding assistant prompt) + --system-prompt System prompt (default: purpose-driven development agent prompt) --append-system-prompt Append text or file contents to the system prompt --mode Output mode: text (default), json, or rpc --print, -p Non-interactive mode: process prompt and exit diff --git a/packages/pi-coding-agent/src/core/compaction/utils.ts b/packages/pi-coding-agent/src/core/compaction/utils.ts index 7eee1cd1a..ee09ff3b1 100644 --- a/packages/pi-coding-agent/src/core/compaction/utils.ts +++ b/packages/pi-coding-agent/src/core/compaction/utils.ts @@ -304,6 +304,6 @@ export function serializeConversation(messages: Message[]): string { // Summarization System Prompt // ============================================================================ -export const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified. +export const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and a purpose-driven software compiler, then produce a structured summary following the exact format specified. Do NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`; diff --git a/packages/pi-coding-agent/src/core/system-prompt.ts b/packages/pi-coding-agent/src/core/system-prompt.ts index 9d8ef6b61..bf14b1ad8 100644 --- a/packages/pi-coding-agent/src/core/system-prompt.ts +++ b/packages/pi-coding-agent/src/core/system-prompt.ts @@ -256,7 +256,7 @@ export function buildSystemPrompt( const guidelines = guidelinesList.map((g) => `- ${g}`).join("\n"); - let prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files. + let prompt = `You are a purpose-driven software compiler. You take bounded intent, produce a falsifiable purpose contract (the PDD/TDD gate), then write failing tests before implementation. You help users by reading files, executing commands, editing code, and writing new files. Available tools: ${toolsList}