diff --git a/README.md b/README.md index 123d55a..de46495 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ rm -rf .git # Initialize git git init -# Setup (installs pnpm if missing, dependencies, and pre-commit hook) +# Setup (installs pnpm, dependencies, pre-commit hook, and Feynman configs) pnpm run setup # Remove this README (it's the template's README) rm README.md ``` -**That's it.** The setup script handles everything. +**That's it.** The setup script handles everything—including installing the Feynman skill if Feynman is detected. ## What This Is @@ -31,12 +31,26 @@ rm README.md - **Agents think out loud** in issue files, making reasoning visible - **Humans approve reasoning**, not code line-by-line - **Pre-commit hooks enforce** issue format before any commit +- **Feynman integration** for automatic workflow bootstrapping + +## Feynman Integration + +If Feynman is installed on your system, the setup script will automatically: + +1. Detect the Feynman installation +2. Install the `workflow-bootstrap` skill +3. Create `.feynman/memory.md` with workflow preferences + +This gives you a two-layer nudge system: +- **Skill** (manual trigger): Say "feynman, set up the workflow" for new projects +- **Memory** (automatic nudge): Feynman reminds you if you forget ## Requirements - **Node.js** (recommended: https://nodejs.org) - If you don't have Node.js, the setup script will install `pnpm` using `corepack` or `npm` - **Git** +- **Feynman** (optional, for automatic workflow bootstrapping) No other dependencies required for the workflow itself. diff --git a/docs/workflow/INDEX.md b/docs/workflow/INDEX.md index 8822d96..a068136 100644 --- a/docs/workflow/INDEX.md +++ b/docs/workflow/INDEX.md @@ -56,11 +56,19 @@ A workflow where: ## Before Starting a New Project -Tell your agent to set up the workflow: +If you have Feynman installed: -> "feynman, set up the workflow using the template from https://git.fbrns.co/shoko/workflow" +> "feynman, set up the workflow" -The agent will copy the structure and install the pre-commit hook automatically. +Feynman will clone the template, copy the structure, install the pre-commit hook, and set up its own skill and memory. + +If Feynman is not installed, manually: + +```bash +git clone https://git.fbrns.co/shoko/workflow.git my-new-project +cd my-new-project +pnpm run setup +``` ## For New Team Members diff --git a/feynman/README.md b/feynman/README.md new file mode 100644 index 0000000..9562171 --- /dev/null +++ b/feynman/README.md @@ -0,0 +1,76 @@ +# Feynman Configuration + +This directory contains Feynman-specific configurations that can be installed alongside the workflow. + +## What's Included + +``` +feynman/ +├── README.md ← This file +├── skills/ +│ └── workflow-bootstrap/ +│ └── SKILL.md ← Skill to bootstrap new projects +└── memory-template.md ← Memory template to load into Feynman +``` + +## Installation + +These are installed automatically by `pnpm run setup` if Feynman is detected. + +### Manual Installation + +**Skill:** +```bash +mkdir -p ~/.feynman/agent/skills +cp -r feynman/skills/* ~/.feynman/agent/skills/ +``` + +**Memory:** +```bash +# Copy as memory.md in your project's .feynman directory +cp feynman/memory-template.md /path/to/your/project/.feynman/memory.md + +# Or load into Feynman's persistent memory directly +``` + +## What the Skill Does + +The `workflow-bootstrap` skill allows Feynman to set up the issue-based workflow for any new project: + +1. Clone the workflow template from `https://git.fbrns.co/shoko/workflow` +2. Copy docs, issues structure, and hooks to the current project +3. Run the setup script +4. Summarize what was set up + +**Trigger phrases:** +- "feynman, start a new project" +- "set up the workflow" +- "apply the workflow template" +- "initialize the issue-based workflow" + +## What the Memory Does + +The memory template contains: +- `pref.new_project_workflow`: Location and structure of the workflow template +- `lesson.workflow.new_project_nudge`: A nudge rule to remind you to use the workflow + +This gives you a two-layer enforcement: +1. **Skill** (manual trigger): You say "new project" and Feynman sets it up +2. **Memory** (automatic nudge): If you forget, Feynman reminds you + +## For Fresh Feynman Installations + +If you're running Feynman on a new host: + +```bash +# 1. Clone the workflow template (it includes feynman configs) +git clone https://git.fbrns.co/shoko/workflow.git my-project +cd my-project + +# 2. Run setup (installs pnpm, hooks, and feynman configs) +pnpm run setup + +# 3. Load the memory into Feynman +# In Feynman: /memory.md to load the memory template +# Or: copy feynman/memory-template.md to your project's .feynman/memory.md +``` diff --git a/feynman/memory-template.md b/feynman/memory-template.md new file mode 100644 index 0000000..410ecce --- /dev/null +++ b/feynman/memory-template.md @@ -0,0 +1,17 @@ +# Feynman Memory Template + +Copy this file to your project's `.feynman/memory.md` or load it into Feynman's persistent memory. + +## pref.new_project_workflow +Workflow template lives at: https://git.fbrns.co/shoko/workflow +Structure: /docs/workflow/ (INDEX, ISSUE-FORMAT, WORKFLOW, AGENT-PROMPTS), /.issues/ (INDEX + examples), /.hooks/ (issue-linter.js) +Two-layer enforcement: Skill (manual trigger) + Memory (nudge if forgotten) +Prefers file-based issues over external trackers like Gitea issues +Pre-commit hook enforces issue format before commit +Agent must think out loud: Plan, Status Log, Self-Verification in issue file +Human approves reasoning, not tasks. Human does not manually test unless edge case. + +## lesson.workflow.new_project_nudge +When human mentions a new project, ALWAYS check memory for pref.new_project_workflow. +If template exists but not used, nudge: "Do you want to use the workflow template from shoko/workflow? I can set it up automatically." +Category: workflow diff --git a/feynman/skills/SKILL.md b/feynman/skills/SKILL.md new file mode 100644 index 0000000..30cfab4 --- /dev/null +++ b/feynman/skills/SKILL.md @@ -0,0 +1,136 @@ +# Workflow Bootstrap Skill + +## Description +Set up the issue-based workflow for a new project by cloning the template from `https://git.fbrns.co/shoko/workflow`. + +**This skill is automatically installed** when you run `pnpm run setup` in a project cloned from the workflow template. + +Use this skill when: +- Human asks to start a new project +- Human asks to "set up the workflow" +- Human asks to "apply the workflow template" +- Human asks to "initialize the issue-based workflow" +- Human is starting work in a new directory without the workflow structure + +## Workflow Template Location +- URL: `https://git.fbrns.co/shoko/workflow` +- Clone: `https://git.fbrns.co/shoko/workflow.git` +- Template repo contains: + - `/docs/workflow/` — INDEX.md, ISSUE-FORMAT.md, WORKFLOW.md, AGENT-PROMPTS.md + - `/.issues/` — INDEX.md, example issues + - `/.hooks/` — issue-linter.js (pre-commit validator) + - `/feynman/` — This skill + memory template + +## Steps + +### 1. Check if workflow already exists +```bash +# Check if /docs/workflow/INDEX.md exists +ls -la /docs/workflow/INDEX.md 2>/dev/null && echo "exists" || echo "not found" +``` + +If workflow already exists, tell the human and ask if they want to re-initialize or just proceed. + +### 2. Fetch template from Gitea +```bash +# Clone the template repo +git clone https://git.fbrns.co/shoko/workflow.git /tmp/workflow-template + +# Or download as archive +curl -L https://git.fbrns.co/shoko/workflow/archive/main.tar.gz | tar -xz -C /tmp/ +``` + +### 3. Copy template structure to current directory +```bash +# Copy workflow docs +cp -r /tmp/workflow-template/docs/workflow/ ./docs/ + +# Copy issue structure (but not example files unless needed) +mkdir -p ./.issues +cp /tmp/workflow-template/.issues/INDEX.md ./.issues/ + +# Copy hooks +mkdir -p ./.hooks +cp /tmp/workflow-template/.hooks/issue-linter.js ./.hooks/ + +# Copy package.json scripts if they exist and merge with existing +if [ -f /tmp/workflow-template/package.json ]; then + # Merge workflow-scripts into existing package.json + echo "Template has package.json - review scripts manually" +fi +``` + +### 4. Initialize git hooks (pre-commit) +```bash +# Make hook executable +chmod +x ./.hooks/issue-linter.js + +# Set up pre-commit hook +mkdir -p .git/hooks +cat > .git/hooks/pre-commit << 'EOF' +#!/bin/bash +node ./.hooks/issue-linter.js +EOF +chmod +x .git/hooks/pre-commit + +# Or: install via husky if project uses it +# npx husky add .husky/pre-commit "node ./.hooks/issue-linter.js" +``` + +### 5. Verify setup +```bash +# Check structure +ls -la docs/workflow/ +ls -la .issues/ +ls -la .hooks/ +ls -la .git/hooks/pre-commit + +# Test hook manually +echo "Testing pre-commit hook..." +# Create a dummy change and try to commit +``` + +### 6. Create first issue index if needed +If `/.issues/INDEX.md` exists, review it and update if needed. If not, create it. + +### 7. Summary for human +Tell the human: +- What was copied +- Where to find the docs +- How to start using it +- That the pre-commit hook is now active + +Example output: +``` +Workflow template installed. Structure: + + docs/workflow/ ← READ THIS FIRST (INDEX.md) + .issues/ ← Your issues live here + .hooks/ ← Pre-commit validator active + +Pre-commit hook is installed. Any code change without a valid issue file will be rejected. + +To start working: +1. Read docs/workflow/INDEX.md +2. Create your first issue in .issues/ +3. Follow the workflow stages defined there + +Let me know when you're ready to create your first issue. +``` + +## Error Handling + +| Error | What to do | +|---|---| +| Gitea repo not accessible | Tell human, offer to create structure manually from documentation | +| `.git/hooks/` already has pre-commit | Ask human whether to overwrite or merge | +| Not in a git repo | Tell human "This requires a git repository. Run `git init` first." | +| `node` not available for hook | Fall back to bash-based validator or skip hook with warning | + +## Human Prompts That Trigger This Skill + +- "feynman, start a new project" +- "set up the workflow" +- "apply the template" +- "initialize the issue-based workflow" +- "let's work on something new" diff --git a/scripts/setup.sh b/scripts/setup.sh index a4c5056..ae993e2 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -4,6 +4,7 @@ # - Installs pnpm if missing # - Installs dependencies # - Sets up pre-commit hook +# - Installs Feynman skill and memory (if Feynman detected) # set -e @@ -19,6 +20,33 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color +# ============================================ +# Step 0: Check for feynman directory +# ============================================ +FEYNMAN_DIR="" +FEYNMAN_SKILLS_DIR="" +FEYNMAN_DETECTED=false + +# Check common feynman locations +if [ -d "$HOME/.feynman/agent/skills" ]; then + FEYNMAN_DIR="$HOME/.feynman" + FEYNMAN_SKILLS_DIR="$HOME/.feynman/agent/skills" + FEYNMAN_DETECTED=true +elif [ -d "$HOME/.config/feynman/agent/skills" ]; then + FEYNMAN_DIR="$HOME/.config/feynman" + FEYNMAN_SKILLS_DIR="$HOME/.config/feynman/agent/skills" + FEYNMAN_DETECTED=true +fi + +# Check if skill already installed +SKILL_INSTALLED=false +if [ -d "feynman/skills/workflow-bootstrap" ]; then + if [ "$FEYNMAN_DETECTED" = true ] && [ -d "$FEYNMAN_SKILLS_DIR/workflow-bootstrap" ]; then + SKILL_INSTALLED=true + fi +fi + +# ============================================ # Step 1: Check/install pnpm echo "Checking for pnpm..." @@ -89,7 +117,66 @@ chmod +x scripts/setup.sh echo -e "${GREEN}Pre-commit hook installed.${NC}" echo "" -# Step 4: Summary +# ============================================ +# Step 4: Install Feynman configs (if feynman detected) +# ============================================ +if [ "$FEYNMAN_DETECTED" = true ] && [ "$SKILL_INSTALLED" = false ]; then + echo "==========================================" + echo "Feynman Detected" + echo "==========================================" + echo "" + echo -e "${YELLOW}Feynman installation found at: $FEYNMAN_DIR${NC}" + + # Check if feynman directory is writable + if [ -w "$FEYNMAN_SKILLS_DIR" ]; then + echo "Installing workflow-bootstrap skill..." + mkdir -p "$FEYNMAN_SKILLS_DIR/workflow-bootstrap" + cp -f feynman/skills/workflow-bootstrap/SKILL.md "$FEYNMAN_SKILLS_DIR/workflow-bootstrap/" + echo -e "${GREEN}Skill installed to: $FEYNMAN_SKILLS_DIR/workflow-bootstrap/${NC}" + + # Also create/update memory in the project if .feynman exists + if [ -d ".feynman" ]; then + if [ ! -f ".feynman/memory.md" ]; then + echo "Creating .feynman/memory.md..." + cp feynman/memory-template.md .feynman/memory.md + echo -e "${GREEN}Memory template installed to: .feynman/memory.md${NC}" + else + echo -e "${YELLOW}.feynman/memory.md already exists. Skipping.${NC}" + fi + fi + + echo "" + echo "Feynman can now bootstrap this workflow for any new project." + echo "Trigger phrases:" + echo " - 'feynman, start a new project'" + echo " - 'set up the workflow'" + echo " - 'apply the workflow template'" + echo "" + else + echo -e "${YELLOW}Warning: Feynman skills directory not writable.${NC}" + echo "To install the workflow-bootstrap skill manually:" + echo " mkdir -p $FEYNMAN_SKILLS_DIR/workflow-bootstrap" + echo " cp feynman/skills/workflow-bootstrap/SKILL.md $FEYNMAN_SKILLS_DIR/workflow-bootstrap/" + echo "" + fi +elif [ "$SKILL_INSTALLED" = true ]; then + echo -e "${GREEN}Workflow-bootstrap skill already installed.${NC}" +else + echo "==========================================" + echo "Feynman Not Detected" + echo "==========================================" + echo "" + echo -e "${YELLOW}Feynman not found. The workflow-bootstrap skill was not installed.${NC}" + echo "" + echo "To install Feynman: https://github.com/your-org/feynman" + echo "" + echo "After installing Feynman, you can manually copy the skill:" + echo " mkdir -p ~/.feynman/agent/skills" + echo " cp -r feynman/skills/* ~/.feynman/agent/skills/" + echo "" +fi + +# Step 5: Summary echo "==========================================" echo -e "${GREEN}Setup complete!${NC}" echo "=========================================="