# 🏭 GooseFactory **AI Agent Factory Command Center** β€” A human-in-the-loop pipeline management system built on top of [Goose](https://github.com/block/goose), designed to orchestrate MCP server production at scale. GooseFactory gives you a decision queue, approval gates, and a learning system that gets smarter with every review. --- ## Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ GooseFactory Monorepo β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ @gf/desktop β”‚ β”‚ @gf/api β”‚ β”‚ @gf/mcp-server β”‚ β”‚ β”‚ β”‚ (Goose Fork) │◄──│ (Hono:4000) │◄──│ (11 tools) β”‚ β”‚ β”‚ β”‚ Electron+Reactβ”‚ β”‚ REST + WS β”‚ β”‚ 6 resources β”‚ β”‚ β”‚ β”‚ Decision UI β”‚ β”‚ PostgreSQL β”‚ β”‚ 4 prompts β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Redis Events β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ @gf/modals β”‚ β”‚ @gf/learning β”‚ β”‚ @gf/shared β”‚ β”‚ β”‚ β”‚ 25 HITL │──▢│ Feedback β”‚ β”‚ Types β”‚ β”‚ β”‚ β”‚ Modal UIs β”‚ β”‚ Pipeline β”‚ β”‚ Constants β”‚ β”‚ β”‚ β”‚ (HTML/CSS/JS)β”‚ β”‚ Calibration β”‚ β”‚ Zod Schemas β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Memory Files β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚PostgreSQLβ”‚ β”‚ Redis β”‚ β”‚ :5432 β”‚ β”‚ :6379 β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## Pipeline Stages Every MCP server flows through 8 stages. Stages marked β˜… are **human gates** requiring approval: ``` πŸ“₯ Intake β†’ πŸ—οΈ Scaffolding β†’ πŸ”¨ Building β†’ πŸ§ͺ Testing β†’ πŸ‘οΈ Review β˜… β†’ πŸš€ Staging β˜… β†’ 🌍 Production β˜… β†’ βœ… Published ``` ## Packages | Package | Description | Port | |---------|-------------|------| | `@goosefactory/shared` | Shared TypeScript types, constants, Zod schemas | β€” | | `@goosefactory/api` | Hono REST API + WebSocket server | 4000 | | `@goosefactory/mcp-server` | MCP server with 11 tools, 6 resources, 4 prompts | stdio | | `@goosefactory/modals` | 25 HITL modal UIs (self-contained HTML) | 3334 | | `@goosefactory/learning` | Feedback processing, calibration, memory files | β€” | | `packages/desktop` | Forked Goose desktop app (Electron + React + Rust) | β€” | --- ## Prerequisites - **Node.js** β‰₯ 20 + **npm** β‰₯ 10 - **Docker** + **Docker Compose** (for PostgreSQL and Redis) - **Rust** (only needed for the desktop app) ## Quick Start ### 1. Clone and bootstrap ```bash cd goosefactory ./scripts/first-boot.sh ``` This will: 1. βœ… Check prerequisites 2. βœ… Copy `.env.example` β†’ `.env` 3. βœ… `npm install` all workspaces 4. βœ… Build `@goosefactory/shared` 5. βœ… Start PostgreSQL + Redis via Docker 6. βœ… Initialize database schema 7. βœ… Seed data from MCP command center (if available) ### 2. Start development ```bash # Start everything (API + MCP + Learning) npm run dev # Or start individual services npm run dev:api # API server on port 4000 npm run dev:mcp # MCP server (stdio) npm run dev:learning # Learning pipeline npm run dev:modals # Modal preview on port 3334 ``` ### 3. Verify ```bash # Health check curl http://localhost:4000/health # View API info curl http://localhost:4000/ ``` --- ## Development Workflow ### Day-to-day ```bash # Start infrastructure npm run dev:infra # Start all services npm run dev # Type-check across all packages npm run typecheck # Build everything npm run build ``` ### Working with the shared package ```bash # After modifying shared types: npm run build:shared # Other packages auto-import from @goosefactory/shared: import type { Pipeline, Task } from "@goosefactory/shared"; import { KANBAN_STAGES, DEFAULT_SLA } from "@goosefactory/shared"; import { FeedbackEventSchema } from "@goosefactory/shared/schemas"; ``` ### Database ```bash # Start/stop infrastructure npm run dev:infra npm run dev:infra:stop # Re-seed from factory state npm run db:seed # Access PostgreSQL directly docker exec -it goosefactory-postgres psql -U goosefactory -d goosefactory ``` ### Testing ```bash # Run all tests npm test # Run integration tests npx tsx tests/integration/modal-to-learning.test.ts ``` --- ## Environment Variables Copy `.env.example` to `.env` and configure: | Variable | Default | Description | |----------|---------|-------------| | `DATABASE_URL` | `postgresql://goosefactory:goosefactory_dev@localhost:5432/goosefactory` | PostgreSQL connection | | `REDIS_URL` | `redis://localhost:6379` | Redis connection | | `FACTORY_API_PORT` | `4000` | API server port | | `JWT_SECRET` | β€” | JWT signing secret (set in production!) | | `FACTORY_MCP_TRANSPORT` | `stdio` | MCP transport (`stdio` or `sse`) | | `FACTORY_API_URL` | `http://localhost:4000/v1` | API URL for MCP server | | `FEEDBACK_STORAGE_PATH` | `~/.config/goose/factory/feedback` | Feedback JSONL storage | | `MEMORY_FILES_PATH` | `~/.config/goose/factory/memory` | Learning memory files | --- ## MCP Tools The MCP server exposes 11 tools for operating the factory: | Tool | Description | |------|-------------| | `factory_get_pending_tasks` | Decision inbox β€” what needs attention | | `factory_approve_task` | Approve a task, advance pipeline | | `factory_reject_task` | Reject with feedback, trigger rework | | `factory_get_pipeline_status` | Pipeline state and progress | | `factory_advance_stage` | Manually advance a pipeline stage | | `factory_assign_priority` | Change priority, recalculate SLA | | `factory_get_blockers` | What's stuck and why | | `factory_run_tests` | Trigger test suite | | `factory_deploy` | Deploy to staging/production | | `factory_search` | Search across all entities | | `factory_create_pipeline` | Create a new MCP server pipeline | --- ## HITL Modals 25 interactive modals for collecting human feedback: | Category | Modals | |----------|--------| | **Binary Decision** | Traffic Light, Decision Tree, Hot Take | | **Batch Review** | Tinder Swipe, Speed Round | | **Multi-Dimensional** | Report Card, Judge's Scorecard | | **Comparison** | Side-by-Side, Before/After, Ranking Arena | | **Subjective** | Thermometer, Quick Pulse, Emoji Scale, Mood Ring | | **Estimation** | Priority Poker, Crystal Ball | | **High Stakes** | Mission Briefing | | **Verification** | Checklist Ceremony | | **Triage** | War Room | | **Retrospective** | Retrospective | Each modal is a self-contained HTML file that communicates via `postMessage`, and feeds into the learning pipeline. --- ## Contracts All inter-package contracts are defined in [`CONTRACTS.md`](./CONTRACTS.md). This is the single source of truth. If implementation differs from CONTRACTS.md, the implementation is wrong. --- ## Project Structure ``` goosefactory/ β”œβ”€β”€ CONTRACTS.md # Canonical interface contracts β”œβ”€β”€ README.md # This file β”œβ”€β”€ package.json # Monorepo root (npm workspaces) β”œβ”€β”€ .env.example # Environment template β”œβ”€β”€ packages/ β”‚ β”œβ”€β”€ shared/ # Types, constants, schemas β”‚ β”œβ”€β”€ api/ # REST API + WebSocket (Hono) β”‚ β”œβ”€β”€ mcp-server/ # MCP server (11 tools) β”‚ β”œβ”€β”€ modals/ # 25 HITL modal UIs β”‚ β”œβ”€β”€ learning/ # Feedback processing pipeline β”‚ └── desktop/ # Forked Goose (Electron + React) β”œβ”€β”€ infra/ β”‚ └── docker/ # Docker Compose + init SQL β”œβ”€β”€ scripts/ β”‚ β”œβ”€β”€ first-boot.sh # First-time setup β”‚ └── seed-from-factory.ts # Import from MCP command center └── tests/ └── integration/ # Cross-package integration tests ```