{
  "canonical_name": "grainulation/grainulation",
  "compilation_id": "pack_cc08943b774d41e29a216caae53fc752",
  "created_at": "2026-05-19T05:18:03.828612+00:00",
  "created_by": "project-pack-compiler",
  "feedback": {
    "carrier_selection_notes": [
      "viable_asset_types=mcp_config, recipe, host_instruction, eval, preflight",
      "recommended_asset_types=mcp_config, recipe, host_instruction, eval, preflight"
    ],
    "evidence_delta": {
      "confirmed_claims": [
        "identity_anchor_present",
        "capability_and_host_targets_present",
        "install_path_declared_or_better"
      ],
      "missing_required_fields": [],
      "must_verify_forwarded": [
        "Run or inspect `npm install -g @grainulation/grainulation` in an isolated environment.",
        "Confirm the project exposes the claimed capability to at least one target host."
      ],
      "quickstart_execution_scope": "allowlisted_sandbox_smoke",
      "sandbox_command": "npm install -g @grainulation/grainulation",
      "sandbox_container_image": "node:22-slim",
      "sandbox_execution_backend": "docker",
      "sandbox_planner_decision": "deterministic_isolated_install",
      "sandbox_validation_id": "sbx_20a563c146634081b10eed5cbc634b42"
    },
    "feedback_event_type": "project_pack_compilation_feedback",
    "learning_candidate_reasons": [],
    "template_gaps": []
  },
  "identity": {
    "canonical_id": "project_573c88ef6562c2ba86d3e602a59f25f3",
    "canonical_name": "grainulation/grainulation",
    "homepage_url": null,
    "license": "unknown",
    "repo_url": "https://github.com/grainulation/grainulation",
    "slug": "grainulation",
    "source_packet_id": "phit_40ba55d02e974661a35ff776715452aa",
    "source_validation_id": "dval_5c0769632ff947e08b65a16f9a24f853"
  },
  "merchandising": {
    "best_for": "需要信息检索与知识管理能力，并使用 mcp_host的用户",
    "github_forks": 1,
    "github_stars": 6,
    "one_liner_en": "The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.",
    "one_liner_zh": "The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.",
    "primary_category": {
      "category_id": "research-knowledge",
      "confidence": "high",
      "name_en": "Research & Knowledge",
      "name_zh": "信息检索与知识管理",
      "reason": "matched_keywords:research, knowledge, search"
    },
    "target_user": "使用 mcp_host 等宿主 AI 的用户",
    "title_en": "grainulation",
    "title_zh": "grainulation 能力包",
    "visible_tags": [
      {
        "label_en": "Browser Agents",
        "label_zh": "浏览器 Agent",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "product_domain-browser-agents",
        "type": "product_domain"
      },
      {
        "label_en": "Web Task Automation",
        "label_zh": "网页任务自动化",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "user_job-web-task-automation",
        "type": "user_job"
      },
      {
        "label_en": "Browser Automation",
        "label_zh": "浏览器自动化",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "core_capability-browser-automation",
        "type": "core_capability"
      },
      {
        "label_en": "Page Observation and Action Planning",
        "label_zh": "页面观察与动作规划",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "workflow_pattern-page-observation-and-action-planning",
        "type": "workflow_pattern"
      },
      {
        "label_en": "Evaluation Suite",
        "label_zh": "评测体系",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "selection_signal-evaluation-suite",
        "type": "selection_signal"
      }
    ]
  },
  "packet_id": "phit_40ba55d02e974661a35ff776715452aa",
  "page_model": {
    "artifacts": {
      "artifact_slug": "grainulation",
      "files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json",
        "REPO_INSPECTION.md",
        "CAPABILITY_CONTRACT.json",
        "EVIDENCE_INDEX.json",
        "CLAIM_GRAPH.json"
      ],
      "required_files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json"
      ]
    },
    "detail": {
      "capability_source": "Project Hit Packet + DownstreamValidationResult",
      "commands": [
        {
          "command": "npm install -g @grainulation/grainulation",
          "label": "Node.js / npm · 官方安装入口",
          "source": "https://github.com/grainulation/grainulation#readme",
          "verified": true
        }
      ],
      "display_tags": [
        "浏览器 Agent",
        "网页任务自动化",
        "浏览器自动化",
        "页面观察与动作规划",
        "评测体系"
      ],
      "eyebrow": "信息检索与知识管理",
      "glance": [
        {
          "body": "判断自己是不是目标用户。",
          "label": "最适合谁",
          "value": "需要信息检索与知识管理能力，并使用 mcp_host的用户"
        },
        {
          "body": "先理解能力边界，再决定是否继续。",
          "label": "核心价值",
          "value": "The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents."
        },
        {
          "body": "未完成验证前保持审慎。",
          "label": "继续前",
          "value": "publish to Doramagic.ai project surfaces"
        }
      ],
      "guardrail_source": "Boundary & Risk Card",
      "guardrails": [
        {
          "body": "Prompt Preview 只展示流程，不证明项目已安装或运行。",
          "label": "Check 1",
          "value": "不要把试用当真实运行"
        },
        {
          "body": "mcp_host",
          "label": "Check 2",
          "value": "确认宿主兼容"
        },
        {
          "body": "publish to Doramagic.ai project surfaces",
          "label": "Check 3",
          "value": "先隔离验证"
        }
      ],
      "mode": "mcp_config, recipe, host_instruction, eval, preflight",
      "pitfall_log": {
        "items": [
          {
            "body": "README/documentation is current enough for a first validation pass.",
            "category": "能力坑",
            "evidence": [
              "capability.assumptions | github_repo:1184031176 | https://github.com/grainulation/grainulation | README/documentation is current enough for a first validation pass."
            ],
            "severity": "medium",
            "suggested_check": "将假设转成下游验证清单。",
            "title": "能力判断依赖假设",
            "user_impact": "假设不成立时，用户拿不到承诺的能力。"
          },
          {
            "body": "未记录 last_activity_observed。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | last_activity_observed missing"
            ],
            "severity": "medium",
            "suggested_check": "补 GitHub 最近 commit、release、issue/PR 响应信号。",
            "title": "维护活跃度未知",
            "user_impact": "新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "downstream_validation.risk_items | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "进入安全/权限治理复核队列。",
            "title": "下游验证发现风险项",
            "user_impact": "下游已经要求复核，不能在页面中弱化。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "risks.scoring_risks | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "把风险写入边界卡，并确认是否需要人工复核。",
            "title": "存在评分风险",
            "user_impact": "风险会影响是否适合普通用户安装。"
          },
          {
            "body": "GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.1.0 — Security Hardening",
            "category": "安全/权限坑",
            "evidence": [
              "community_evidence:github | cevd_5e8c2578dd024d369fd769a7c23df98a | https://github.com/grainulation/grainulation/releases/tag/v1.1.0 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。"
            ],
            "severity": "medium",
            "suggested_check": "来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。",
            "title": "来源证据：v1.1.0 — Security Hardening",
            "user_impact": "可能增加新用户试用和生产接入成本。"
          },
          {
            "body": "issue_or_pr_quality=unknown。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | issue_or_pr_quality=unknown"
            ],
            "severity": "low",
            "suggested_check": "抽样最近 issue/PR，判断是否长期无人处理。",
            "title": "issue/PR 响应质量未知",
            "user_impact": "用户无法判断遇到问题后是否有人维护。"
          },
          {
            "body": "release_recency=unknown。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | release_recency=unknown"
            ],
            "severity": "low",
            "suggested_check": "确认最近 release/tag 和 README 安装命令是否一致。",
            "title": "发布节奏不明确",
            "user_impact": "安装命令和文档可能落后于代码，用户踩坑概率升高。"
          }
        ],
        "source": "ProjectPitfallLog + ProjectHitPacket + validation + community signals",
        "summary": "发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：能力坑 - 能力判断依赖假设。",
        "title": "踩坑日志"
      },
      "snapshot": {
        "contributors": 1,
        "forks": 1,
        "license": "unknown",
        "note": "站点快照，非实时质量证明；用于开工前背景判断。",
        "stars": 6
      },
      "source_url": "https://github.com/grainulation/grainulation",
      "steps": [
        {
          "body": "不安装项目，先体验能力节奏。",
          "code": "preview",
          "title": "先试 Prompt"
        },
        {
          "body": "理解输入、输出、失败模式和边界。",
          "code": "manual",
          "title": "读说明书"
        },
        {
          "body": "把上下文交给宿主 AI 继续工作。",
          "code": "context",
          "title": "带给 AI"
        },
        {
          "body": "进入主力环境前先完成安装入口与风险边界验证。",
          "code": "verify",
          "title": "沙箱验证"
        }
      ],
      "subtitle": "The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.",
      "title": "grainulation 能力包",
      "trial_prompt": "# grainulation - Prompt Preview\n\n> Copy the prompt below into your AI host before installing anything.\n> Its purpose is to let you safely feel the project's workflow, not to claim the project has already run.\n\n## Copy this prompt\n\n```text\nYou are using an independent Doramagic capability pack for grainulation/grainulation.\n\nProject:\n- Name: grainulation\n- Repository: https://github.com/grainulation/grainulation\n- Summary: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n- Host target: mcp_host\n\nGoal:\nHelp me evaluate this project for the following task without installing it yet: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n\nBefore taking action:\n1. Restate my task, success standard, and boundary.\n2. Identify whether the next step requires tools, browser access, network access, filesystem access, credentials, package installation, or host configuration.\n3. Use only the Doramagic Project Pack, the upstream repository, and the source-linked evidence listed below.\n4. If a real command, install step, API call, file write, or host integration is required, mark it as \"requires post-install verification\" and ask for approval first.\n5. If evidence is missing, say \"evidence is missing\" instead of filling the gap.\n\nPreviewable capabilities:\n- Capability 1: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n\nCapabilities that require post-install verification:\n- Capability 1: Use the source-backed project context to guide one small, checkable workflow step.\n\nCore service flow:\n1. project-overview: Project Overview. Produce one small intermediate artifact and wait for confirmation.\n2. cli-architecture: CLI Architecture. Produce one small intermediate artifact and wait for confirmation.\n3. command-reference: Command Reference. Produce one small intermediate artifact and wait for confirmation.\n4. ecosystem-overview: Ecosystem Overview. Produce one small intermediate artifact and wait for confirmation.\n5. setup-installation: Setup and Installation. Produce one small intermediate artifact and wait for confirmation.\n\nSource-backed evidence to keep in mind:\n- https://github.com/grainulation/grainulation\n- https://github.com/grainulation/grainulation#readme\n- README.md\n- package.json\n- docs/ecosystem.md\n- bin/grainulation.js\n- lib/router.js\n- lib/server.mjs\n- lib/ecosystem.js\n- lib/doctor.js\n\nFirst response rules:\n1. Start Step 1 only.\n2. Explain the one service action you will perform first.\n3. Ask exactly three questions about my target workflow, success standard, and sandbox boundary.\n4. Stop and wait for my answers.\n\nStep 1 follow-up protocol:\n- After I answer the first three questions, stay in Step 1.\n- Produce six parts only: clarified task, success standard, boundary conditions, two or three options, tradeoffs for each option, and one recommendation.\n- End by asking whether I confirm the recommendation.\n- Do not move to Step 2 until I explicitly confirm.\n\nConversation rules:\n- Advance one step at a time and wait for confirmation after each small artifact.\n- Write outputs as recommendations or planned checks, not as completed execution.\n- Do not claim tests passed, files changed, commands ran, APIs were called, or the project was installed.\n- If the user asks for execution, first provide the sandbox setup, expected output, rollback, and approval checkpoint.\n```\n",
      "voices": [
        {
          "body": "来源平台：github。github/github_release: v1.1.0 — Security Hardening（https://github.com/grainulation/grainulation/releases/tag/v1.1.0）。这些是项目级外部声音，不作为单独质量证明。",
          "items": [
            {
              "kind": "github_release",
              "source": "github",
              "title": "v1.1.0 — Security Hardening",
              "url": "https://github.com/grainulation/grainulation/releases/tag/v1.1.0"
            }
          ],
          "status": "已收录 1 条来源",
          "title": "社区讨论"
        }
      ]
    },
    "homepage_card": {
      "category": "信息检索与知识管理",
      "desc": "The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.",
      "effort": "安装已验证",
      "forks": 1,
      "icon": "search",
      "name": "grainulation 能力包",
      "risk": "需复核",
      "slug": "grainulation",
      "stars": 6,
      "tags": [
        "浏览器 Agent",
        "网页任务自动化",
        "浏览器自动化",
        "页面观察与动作规划",
        "评测体系"
      ],
      "thumb": "blue",
      "type": "MCP 配置"
    },
    "manual": {
      "markdown": "# https://github.com/grainulation/grainulation 项目说明书\n\n生成时间：2026-05-15 12:02:35 UTC\n\n## 目录\n\n- [Project Overview](#project-overview)\n- [CLI Architecture](#cli-architecture)\n- [Command Reference](#command-reference)\n- [Ecosystem Overview](#ecosystem-overview)\n- [Tool Integration](#tool-integration)\n- [Setup and Installation](#setup-installation)\n- [Health Checks and Diagnostics](#health-checks)\n- [Package Management](#package-management)\n- [Server and Routing](#server-routing)\n- [Extensibility Guide](#extensibility-guide)\n\n<a id='project-overview'></a>\n\n## Project Overview\n\n### 相关页面\n\n相关主题：[Ecosystem Overview](#ecosystem-overview), [CLI Architecture](#cli-architecture)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n</details>\n\n# Project Overview\n\nGrainulation is an ecosystem of eight zero-dependency CLI tools that transform technical decision-making from gut-feel opinions into structured, evidence-based claims. The system enables teams to research questions, challenge findings, and compile decisions into auditable briefs backed by a full git history.\n\n## Purpose and Scope\n\nMost technical decisions fail not due to lack of data, but lack of process for converting data into evidence and evidence into conviction. Grainulation provides that missing process through a claims-based research framework.\n\nThe ecosystem serves teams who need to make consequential technical decisions—such as architecture migrations, technology choices, or infrastructure changes—and want defensible, auditable reasoning behind those choices.\n\n**Core objectives:**\n\n- Turn vague technical questions into typed, evidence-graded claims\n- Provide adversarial testing through a challenge mechanism\n- Catch contradictions and weak evidence via a deterministic compiler\n- Produce decision briefs with full git audit trails 资料来源：[README.md:18]()\n\n## Architecture\n\nThe grainulation project follows a monorepo structure with eight independent packages plus the meta-package that orchestrates them.\n\n```mermaid\ngraph TD\n    subgraph \"Meta Package\"\n        G[grainulation<br/>Unified CLI]\n    end\n    \n    subgraph \"Core Tools\"\n        W[wheat<br/>Research Engine]\n        F[farmer<br/>Permission Dashboard]\n        B[barn<br/>Tool Registry]\n        M[mill<br/>Export Engine]\n    end\n    \n    subgraph \"Analysis Tools\"\n        S[silo<br/>Claim Explorer]\n        H[harvest<br/>Analytics]\n        O[orchard<br/>Sprint Manager]\n    end\n    \n    G --> W\n    G --> F\n    G --> B\n    G --> M\n    G --> S\n    G --> H\n    G --> O\n    \n    W --> B\n    M --> S\n    H --> S\n```\n\n### Meta Package Structure\n\n| Path | Purpose |\n|------|---------|\n| `bin/grainulation.js` | CLI entrypoint — routes to individual tools |\n| `lib/router.js` | Command routing to the correct tool package |\n| `lib/ecosystem.js` | Ecosystem health checks and tool discovery |\n| `lib/doctor.js` | Diagnostic tool — validates tool installations |\n| `lib/setup.js` | First-run setup and configuration |\n| `lib/pm.js` | Package management for grainulation tools |\n| `lib/server.mjs` | Local server — unified ecosystem dashboard (ESM) |\n| `public/` | Web UI — ecosystem overview and status |\n| `site/` | Public website (grainulation.com) |\n\n资料来源：[CONTRIBUTING.md:25-36]()\n\n## The Eight Tools\n\n| Tool | Purpose | Install Command |\n|------|---------|-----------------|\n| **wheat** | Research engine. Grow structured evidence. | `npx @grainulation/wheat init` |\n| **farmer** | Permission dashboard. Approve AI agent tool calls. | `npx @grainulation/farmer start` |\n| **barn** | Tool registry. Curated, versioned, approved. | `npx @grainulation/barn status` |\n| **mill** | Export engine. Turn compiled research into PDFs, CSVs, static sites. | `npx @grainulation/mill export --format pdf` |\n| **silo** | Claim explorer. Navigate and filter claims across sprints. | `npx @grainulation/silo explore` |\n| **harvest** | Analytics. Track prediction accuracy, find systemic blind spots. | `npx @grainulation/harvest analyze ./sprints/` |\n| **orchard** | Sprint manager. Coordinate team research across sprints. | `npx @grainulation/orchard status` |\n| **grainulation** | Unified CLI. Routes to the right tool, checks ecosystem health. | `npx @grainulation/grainulation` |\n\n资料来源：[site/index.html:1-60]()\n\n## Claims System\n\nEverything in grainulation starts with a **claim** — a single typed statement with an evidence grade.\n\n### Claim Types\n\n| Type | Description |\n|------|-------------|\n| `factual` | Verifiable fact with supporting evidence |\n| `risk` | Potential problem or threat |\n| `estimate` | Quantified prediction with uncertainty |\n| `constraint` | Hard limitation or requirement |\n| `recommendation` | Suggested course of action |\n\n### Evidence Tiers\n\nEvidence tiers range from \"someone said it\" to \"measured in production,\" providing a spectrum of confidence in claims.\n\nThe compiler validates claims, catching contradictions, flagging weak evidence, and blocking output until issues are resolved. This compiler is JavaScript code, not an LLM call — same claims in, same result out every time. 资料来源：[site/index.html:75-95]()\n\n## Research Workflow\n\nThe typical workflow follows three phases:\n\n```mermaid\ngraph LR\n    A[Init Sprint<br/>wheat init] --> B[Research<br/>Gather evidence]\n    B --> C[Challenge<br/>Stress-test claims]\n    C --> D[Compile<br/>Resolve conflicts]\n    D --> E[Decision Brief<br/>Ship with audit trail]\n```\n\n### Phase 1: Initialize\n\n```bash\nnpx @grainulation/wheat init\n```\n\nCreates a claims file and config:\n\n- `claims.json` — stores all claims (0 claims initially)\n- `wheat.config.json` — sprint configuration\n\n### Phase 2: Research and Challenge\n\n- `/research \"topic\"` — Gather evidence and create claims\n- `/challenge r001` — Stress-test existing claims, finding risks and contradictions\n\nExample output:\n\n```\nr001 [factual|documented] ...\nx001 [risk|documented] ...\n```\n\n### Phase 3: Compile and Ship\n\n```bash\nwheat> /brief\n```\n\nThe compiler resolves conflicts, checks evidence, and produces a decision brief:\n\n```\nCompiled 12 claims (2 conflicts resolved)\nWritten: output/brief.html\n```\n\n资料来源：[site/index.html:55-90]()\n\n## Design Principles\n\nFour principles underpin the entire ecosystem:\n\n### 1. Evidence Over Authority\n\nGrainulation does not care who made a claim — it cares about the evidence behind it. The system validates claims based on supporting documentation, not seniority.\n\n### 2. Confrontation by Default\n\nConsensus is the enemy of good decisions. The system forces you to challenge, witness, and stress-test every claim through the adversarial challenge mechanism.\n\n### 3. Zero Dependencies\n\nNode.js built-ins only. Zero npm dependencies across all eight packages. No supply chain anxiety. No left-pad incidents. No API keys for the core tools. Every tool ships what it needs and nothing more. 资料来源：[CONTRIBUTING.md:8-10]()\n\n### 4. Local-First\n\nEverything runs locally. Everything is plain JSON and HTML. No cloud services required for core functionality.\n\n## Requirements\n\nTo use grainulation, you need:\n\n- **Claude Code** — for AI-assisted research and challenge\n- **Node.js 20+** — runtime environment\n- **npx** — package executor\n\nNo accounts, no cloud services, no API keys for the core tools. 资料来源：[site/index.html:95-100]()\n\n## Comparison with Traditional Methods\n\n| Aspect | RFC/ADR | ChatGPT | Grainulation |\n|--------|---------|---------|--------------|\n| Timing | Post-decision documentation | Instant but unvalidated | Pre-decision research |\n| Evidence | Often absent | Cannot verify | Typed and graded |\n| Challenge | Optional review | No mechanism | Built-in adversarial testing |\n| Reproducibility | Varies | Non-deterministic | Deterministic compiler |\n| Audit trail | Manual | None | Git-tracked claims history |\n\nRFCs and ADRs document a decision after it is made. Grainulation captures the research process — evidence gathering, adversarial testing, and conflict resolution — and validates it through a compiler. The output brief can serve as your ADR, with a full git audit trail showing how every claim was collected, challenged, and resolved. 资料来源：[site/index.html:130-145]()\n\n## Release Process\n\nPackages publish via GitHub Actions workflows on tag push. The workflow runs tests, verifies the tag matches `package.json.version`, and publishes with npm provenance via OIDC trusted publishing.\n\nFor coordinated releases where a consumer depends on new internal-dep features:\n\n1. Publish the dependency package first (e.g., `barn`)\n2. Wait for the package to appear on npm (~60s)\n3. Run `npm install` in consumer repos to regenerate `package-lock.json`\n4. Bump consumer versions and push tags\n\n资料来源：[RELEASE.md:1-35]()\n\n## Getting Started\n\nInstall the meta-package globally:\n\n```bash\nnpm install -g @grainulation/grainulation\n```\n\nOr start a research sprint directly:\n\n```bash\nnpx @grainulation/wheat init\n```\n\nUseful commands:\n\n| Command | Description |\n|---------|-------------|\n| `grainulation` | Ecosystem overview |\n| `grainulation doctor` | Health check: which tools, which versions |\n| `grainulation setup` | Install the right tools for your role |\n| `grainulation wheat init` | Delegate to any tool |\n| `grainulation farmer start` | Start permission dashboard |\n\n资料来源：[README.md:30-45]()\n\n---\n\n<a id='cli-architecture'></a>\n\n## CLI Architecture\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Tool Integration](#tool-integration), [Server and Routing](#server-routing)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/server.mjs](https://github.com/grainulation/grainulation/blob/main/lib/server.mjs)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js)\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n</details>\n\n# CLI Architecture\n\n## Overview\n\nThe Grainulation CLI is the unified entry point for the entire ecosystem of eight zero-dependency CLI tools. It serves as a meta-package and ecosystem router that orchestrates all grainulation tools through a single command interface. The CLI has zero npm dependencies and relies exclusively on Node.js built-in modules, running entirely locally without cloud services or API keys.\n\nThe architectural philosophy follows a modular pattern where the main CLI delegates to specialized modules responsible for routing, ecosystem health, diagnostics, configuration, and package management. This separation of concerns allows each component to be focused and testable while maintaining a cohesive user experience.\n\n## Architecture Components\n\nThe CLI system consists of several interconnected modules that work together to provide a seamless interface for tool discovery, command routing, and ecosystem management.\n\n| Component | File | Responsibility |\n|-----------|------|----------------|\n| CLI Entrypoint | `bin/grainulation.js` | Main entry point, argument parsing, command dispatch |\n| Router | `lib/router.js` | Routes commands to correct tool packages |\n| Ecosystem | `lib/ecosystem.js` | Health checks and tool discovery |\n| Doctor | `lib/doctor.js` | Diagnostic validation for tool installations |\n| Setup | `lib/setup.js` | First-run setup and configuration |\n| Package Manager | `lib/pm.js` | Package management for grainulation tools |\n| Server | `lib/server.mjs` | Local dashboard server (ESM module) |\n\n## Entry Point\n\nThe CLI entry point at `bin/grainulation.js` serves as the main entry point for the unified command-line interface. It handles initial argument parsing and dispatches commands to the appropriate handlers. Users interact with the system by running `node bin/grainulation.js --help` or directly invoking the CLI.\n\nThe entry point is designed to have zero external dependencies, leveraging only Node.js built-in modules such as `fs`, `path`, and `process`. This ensures maximum portability and minimal attack surface.\n\n## Command Routing\n\nThe router module (`lib/router.js`) is responsible for directing incoming commands to the correct tool package within the ecosystem. When a user invokes a command, the router analyzes the arguments and determines which tool should handle the request.\n\nThe routing mechanism supports multiple tool packages in the ecosystem:\n\n- **wheat** - Research and claims management\n- **farmer** - Permission dashboard\n- **barn** - Shared utilities and sprint detection\n- **mill** - Export and publishing\n- **silo** - Data management\n- **harvest** - Analytics and cross-sprint learning\n- **orchard** - Package management and status\n\n```mermaid\ngraph TD\n    A[User Input] --> B[bin/grainulation.js]\n    B --> C[lib/router.js]\n    C --> D{Command Type}\n    D -->|Tool Command| E[wheat]\n    D -->|Tool Command| F[farmer]\n    D -->|Tool Command| G[barn]\n    D -->|Tool Command| H[mill]\n    D -->|Tool Command| I[silo]\n    D -->|Tool Command| J[harvest]\n    D -->|Tool Command| K[orchard]\n    D -->|Meta Command| L[lib/ecosystem.js]\n    D -->|Diagnostic| M[lib/doctor.js]\n```\n\nThe router maintains awareness of available tools and their capabilities, enabling dynamic command resolution based on what tools are currently installed in the ecosystem.\n\n## Ecosystem Management\n\n### Health Checks and Tool Discovery\n\nThe ecosystem module (`lib/ecosystem.js`) provides two critical functions: health checks and tool discovery. Health checks verify that all installed tools are functioning correctly and meet minimum version requirements. Tool discovery scans the ecosystem to identify all installed grainulation packages and their current states.\n\nWhen invoked, the ecosystem module performs a comprehensive scan of installed tools, checking:\n\n- Package installation status\n- Version compatibility\n- Dependency integrity\n- Configuration validity\n\n### Diagnostic Validation\n\nThe doctor module (`lib/doctor.js`) acts as a diagnostic tool that validates tool installations across the ecosystem. It performs thorough checks to ensure each tool is properly installed and configured, identifying issues that might prevent tools from functioning correctly.\n\nThe diagnostic process includes validation of:\n\n- File system permissions\n- Configuration file integrity\n- Required Node.js modules availability\n- Inter-tool communication channels\n\n## Configuration and Setup\n\n### First-Run Setup\n\nThe setup module (`lib/setup.js`) handles first-run initialization for new users. When a user runs the CLI for the first time, setup creates necessary configuration files and establishes the directory structure required for the ecosystem to function properly.\n\nSetup operations include:\n\n- Creating configuration directories\n- Generating default configuration files\n- Initializing tool registry\n- Establishing user preferences\n\n### Package Management\n\nThe package manager module (`lib/pm.js`) provides package management functionality for grainulation tools. It handles installation, updates, and removal of tools within the ecosystem, ensuring consistent package states across the development environment.\n\n## Local Dashboard Server\n\nThe server module (`lib/server.mjs`) provides a local web dashboard for ecosystem management. Implemented as an ESM module, it serves a unified ecosystem dashboard that displays:\n\n- Tool status overview\n- Installation health\n- Configuration management interface\n- Real-time ecosystem metrics\n\nThe dashboard is accessible locally and provides a visual interface for monitoring and managing the grainulation ecosystem without requiring a web browser connection to external services.\n\n## Data Flow\n\nThe following diagram illustrates the complete data flow from user input through command processing to output generation:\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Ecosystem as lib/ecosystem.js\n    participant Doctor as lib/doctor.js\n    participant PM as lib/pm.js\n    participant Tool as Individual Tool\n\n    User->>CLI: Execute command\n    CLI->>CLI: Parse arguments\n    CLI->>Router: Route request\n    Router->>Router: Identify target tool/command\n    \n    alt Meta Command\n        Router->>Ecosystem: Check ecosystem health\n        Ecosystem-->>User: Status report\n    end\n    \n    alt Diagnostic Command\n        Router->>Doctor: Run diagnostics\n        Doctor-->>User: Diagnostic report\n    end\n    \n    alt Package Management\n        Router->>PM: Handle package operation\n        PM-->>User: Operation result\n    end\n    \n    alt Tool Command\n        Router->>Tool: Delegate to tool\n        Tool-->>User: Tool output\n    end\n```\n\n## Command Categories\n\nThe CLI supports four primary command categories:\n\n| Category | Handler | Purpose |\n|----------|---------|---------|\n| Tool Commands | Individual packages | Execute tool-specific operations |\n| Meta Commands | Built-in modules | Ecosystem-level operations |\n| Diagnostic Commands | `lib/doctor.js` | Validate installations |\n| Management Commands | `lib/pm.js` | Install, update, remove packages |\n\n## Quick Start\n\nUsers can get started with the grainulation CLI by cloning the repository and running the help command:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\nNo `npm install` step is required since the CLI has zero dependencies and relies solely on Node.js built-in modules.\n\n## Architecture Principles\n\nThe CLI architecture adheres to several key principles that guide its design and implementation:\n\n**Zero Dependencies** - Every module uses only Node.js built-in modules, eliminating supply chain vulnerabilities and ensuring the CLI works immediately after cloning without any installation steps.\n\n**Modular Routing** - Commands are routed through a centralized router that delegates to specialized modules, maintaining clear separation of concerns.\n\n**Local-First** - All operations run locally without requiring network connectivity or external services, ensuring data privacy and offline capability.\n\n**Tool Discovery** - The ecosystem module dynamically discovers available tools, allowing the CLI to adapt to different tool configurations without hardcoding.\n\n**Diagnostic Visibility** - Built-in diagnostic tools help users identify and resolve issues without external debugging tools.\n\n---\n\n<a id='command-reference'></a>\n\n## Command Reference\n\n### 相关页面\n\n相关主题：[Health Checks and Diagnostics](#health-checks), [Setup and Installation](#setup-installation), [Ecosystem Overview](#ecosystem-overview)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n</details>\n\n# Command Reference\n\nThis page documents the command-line interface (CLI) for the Grainulation ecosystem, covering the unified CLI entrypoint, routing mechanisms, ecosystem management, and diagnostic tools.\n\n## Overview\n\nThe Grainulation CLI provides a unified interface for managing the entire ecosystem of eight research tools. The command system is designed with zero npm dependencies, relying exclusively on Node.js built-in modules. 资料来源：[bin/grainulation.js]()\n\nThe architecture follows a router-based pattern where commands are dispatched to appropriate handlers based on the first argument passed to the CLI. 资料来源：[lib/router.js]()\n\n```mermaid\ngraph TD\n    A[User Input] --> B[bin/grainulation.js]\n    B --> C[Command Router]\n    C --> D{Command Type}\n    D -->|doctor| E[lib/doctor.js]\n    D -->|setup| F[lib/setup.js]\n    D -->|ecosystem| G[lib/ecosystem.js]\n    D -->|pm| H[lib/pm.js]\n    D -->|wheat| I[Delegate to wheat package]\n    D -->|farmer| J[Delegate to farmer package]\n    D -->|Unknown| K[Help / Error]\n```\n\n## CLI Entry Point\n\n### bin/grainulation.js\n\nThe main CLI entrypoint that handles all user input and routes commands to appropriate handlers. 资料来源：[bin/grainulation.js]()\n\n**Usage:**\n\n```bash\ngrainulation [command] [options]\n```\n\n**Global Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--help` | Display help information |\n| `--version` | Display CLI version |\n| `--json` | Output results as JSON |\n\n### Commands Summary\n\n| Command | Description | Handler |\n|---------|-------------|---------|\n| `doctor` | Validate tool installations | lib/doctor.js |\n| `setup` | First-run setup and configuration | lib/setup.js |\n| `ecosystem` | Ecosystem health checks and tool discovery | lib/ecosystem.js |\n| `pm` | Package management for grainulation tools | lib/pm.js |\n| `wheat` | Delegate to wheat package | External package |\n| `farmer` | Delegate to farmer package | External package |\n\n## Command Handlers\n\n### doctor\n\nThe diagnostic tool validates tool installations across the ecosystem. It checks which tools are installed, their versions, and reports any issues with the setup. 资料来源：[lib/doctor.js]()\n\n**Usage:**\n\n```bash\ngrainulation doctor [options]\n```\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--verbose` | Show detailed diagnostic information |\n| `--fix` | Attempt to fix detected issues automatically |\n\n**Output Example:**\n\n```\nChecking grainulation tools...\n✓ wheat v1.2.0 installed\n✓ farmer v1.1.0 installed\n✗ silo not found\n⚠ mill v1.0.0 has known compatibility issues\n\nRun 'grainulation setup' to install missing tools\n```\n\n### setup\n\nHandles first-run setup and configuration of the Grainulation ecosystem. This command ensures all required tools are installed and configured correctly. 资料来源：[lib/setup.js]()\n\n**Usage:**\n\n```bash\ngrainulation setup [options]\n```\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--install` | Install all recommended tools |\n| `--tools <list>` | Install specific tools (comma-separated) |\n| `--skip-validation` | Skip post-install validation |\n\n**Workflow:**\n\n```mermaid\ngraph LR\n    A[Run Setup] --> B{Check Node.js Version}\n    B -->|≥20| C{Check Existing Tools}\n    C -->|Missing| D[Download Tools]\n    D --> E[Validate Installation]\n    E --> F[Create Config Files]\n    F --> G[Setup Complete]\n    B -->|<20| H[Error: Node.js 20+ Required]\n```\n\n### ecosystem\n\nProvides ecosystem health checks and tool discovery functionality. This command scans for installed tools and reports their status. 资料来源：[lib/ecosystem.js]()\n\n**Usage:**\n\n```bash\ngrainulation ecosystem [command]\n```\n\n**Subcommands:**\n\n| Subcommand | Description |\n|------------|-------------|\n| `status` | Show status of all ecosystem tools |\n| `discover` | Scan for available tools |\n| `health` | Run comprehensive health check |\n\n**Status Output Format:**\n\n```json\n{\n  \"tools\": [\n    { \"name\": \"wheat\", \"status\": \"installed\", \"version\": \"1.2.0\" },\n    { \"name\": \"farmer\", \"status\": \"installed\", \"version\": \"1.1.0\" },\n    { \"name\": \"silo\", \"status\": \"not_found\", \"version\": null }\n  ],\n  \"overall\": \"degraded\"\n}\n```\n\n### pm (Package Manager)\n\nHandles package management operations for grainulation tools. Supports installation, removal, and updating of tools. 资料来源：[lib/pm.js]()\n\n**Usage:**\n\n```bash\ngrainulation pm <action> [package]\n```\n\n**Actions:**\n\n| Action | Description |\n|--------|-------------|\n| `install` | Install a package |\n| `remove` | Remove a package |\n| `update` | Update a package to latest |\n| `list` | List installed packages |\n\n**Examples:**\n\n```bash\ngrainulation pm install wheat\ngrainulation pm remove silo\ngrainulation pm update harvest\ngrainulation pm list\n```\n\n### Tool Delegation\n\nFor commands not recognized by the core CLI, the router delegates to individual tool packages. This allows direct invocation via `npx @grainulation/<tool-name>`. 资料来源：[lib/router.js]()\n\n**Delegated Tools:**\n\n| Tool | Purpose | Package |\n|------|---------|---------|\n| wheat | Research engine | @grainulation/wheat |\n| farmer | Permission dashboard | @grainulation/farmer |\n| barn | Claims backend | @grainulation/barn |\n| mill | Export and publish | @grainulation/mill |\n| silo | Evidence library | @grainulation/silo |\n| harvest | Analytics | @grainulation/harvest |\n| orchard | Orchestration | @grainulation/orchard |\n\n## Routing Architecture\n\nThe command router (`lib/router.js`) implements a priority-based matching system to determine which handler should process each command. 资料来源：[lib/router.js]()\n\n```mermaid\ngraph TD\n    A[Parse CLI Arguments] --> B{Is Built-in Command?}\n    B -->|Yes| C[Route to Handler]\n    B -->|No| D{Is Tool Command?}\n    D -->|Yes| E[Delegate to Tool Package]\n    D -->|No| F{Is Global Flag?}\n    F -->|--help| G[Display Help]\n    F -->|--version| H[Display Version]\n    F -->|Else| I[Error: Unknown Command]\n```\n\n### Route Priority\n\n1. Built-in commands (doctor, setup, ecosystem, pm)\n2. Tool delegation (wheat, farmer, barn, mill, silo, harvest, orchard)\n3. Global flags (--help, --version)\n4. Error handling for unknown commands\n\n## Error Handling\n\nThe CLI implements consistent error handling across all commands:\n\n| Error Type | Exit Code | Message Format |\n|------------|-----------|----------------|\n| Command not found | 1 | `Unknown command: <command>` |\n| Invalid arguments | 2 | `Invalid argument: <argument>` |\n| Tool not installed | 3 | `Tool not installed: <tool>` |\n| Node.js version error | 4 | `Node.js 20+ required` |\n| Network error | 5 | `Failed to reach npm registry` |\n\n## Configuration\n\nThe CLI reads configuration from `~/.grainulation/` directory:\n\n| File | Purpose |\n|------|---------|\n| `config.json` | Global settings |\n| `installed.json` | List of installed tools |\n| `cache/` | Temporary cache files |\n\n## Quick Reference\n\n```bash\n# Display help\ngrainulation --help\n\n# Check ecosystem health\ngrainulation doctor --verbose\n\n# Setup new environment\ngrainulation setup --install\n\n# View ecosystem status\ngrainulation ecosystem status\n\n# Manage packages\ngrainulation pm list\ngrainulation pm install wheat\n\n# Direct tool usage\nnpx @grainulation/wheat init\nnpx @grainulation/farmer start\n\n---\n\n<a id='ecosystem-overview'></a>\n\n## Ecosystem Overview\n\n### 相关页面\n\n相关主题：[Tool Integration](#tool-integration), [Project Overview](#project-overview), [Command Reference](#command-reference)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n</details>\n\n# Ecosystem Overview\n\n## Introduction\n\nGrainulation is a meta-package and ecosystem router that orchestrates eight independent CLI tools for structured technical research and decision-making. The ecosystem follows a \"microkernel\" architecture where the core `grainulation` package provides unified CLI access, routing, and health monitoring while each specialized tool operates as an independent package with zero npm dependencies.\n\nThe core philosophy centers on turning technical questions into typed, evidence-graded claims that can be compiled into auditable decision briefs. Each tool addresses a specific phase of the research workflow: initialization, evidence gathering, challenge, storage, export, archival, analysis, and system orchestration.\n\n## Architecture\n\n### Core Components\n\nThe grainulation ecosystem architecture consists of several interconnected layers that enable tool discovery, routing, and health management.\n\n```mermaid\ngraph TD\n    A[CLI Entry Point<br/>bin/grainulation.js] --> B[Router<br/>lib/router.js]\n    B --> C[Tool Packages<br/>wheat, farmer, barn, mill, silo, harvest, orchard]\n    A --> D[Ecosystem Health<br/>lib/ecosystem.js]\n    A --> E[Doctor<br/>lib/doctor.js]\n    A --> F[Setup<br/>lib/setup.js]\n    A --> G[Package Manager<br/>lib/pm.js]\n    D --> H[Local Server<br/>lib/server.mjs]\n    H --> I[Web UI<br/>public/]\n    C --> D\n```\n\n### Directory Structure\n\n| Path | Purpose | Description |\n|------|---------|-------------|\n| `bin/grainulation.js` | CLI entrypoint | Routes commands to individual tools |\n| `lib/router.js` | Command routing | Dispatches to correct tool package |\n| `lib/ecosystem.js` | Health checks | Tool discovery and version verification |\n| `lib/doctor.js` | Diagnostics | Validates tool installations |\n| `lib/setup.js` | Configuration | First-run setup and initialization |\n| `lib/pm.js` | Package management | Manages grainulation tool installations |\n| `lib/server.mjs` | Local server | Unified ecosystem dashboard (ESM) |\n| `public/` | Web UI | Static assets for dashboard |\n| `test/` | Test suite | Node built-in test runner |\n\n资料来源：[CONTRIBUTING.md:1-50](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## The Eight Tools\n\n### Tool Overview\n\n| Tool | Package | Function | Install Command |\n|------|---------|----------|-----------------|\n| wheat | `@grainulation/wheat` | Research engine for growing structured evidence | `npx @grainulation/wheat init` |\n| farmer | `@grainulation/farmer` | Permission dashboard for AI agent approvals | `npx @grainulation/farmer start` |\n| barn | `@grainulation/barn` | Knowledge base for shared evidence and claims | `npx @grainulation/barn sync` |\n| mill | `@grainulation/mill` | Export and publish to PDFs, CSVs, static sites | `npx @grainulation/mill export --format pdf` |\n| silo | `@grainulation/silo` | Archive and search historical sprints | `npx @grainulation/silo search` |\n| harvest | `@grainulation/harvest` | Analytics for cross-sprint learning | `npx @grainulation/harvest analyze ./sprints/` |\n| orchard | `@grainulation/orchard` | Unified CLI status and health monitoring | `npx @grainulation/orchard status` |\n| grainulation | `@grainulation/grainulation` | Meta-package orchestrating all tools | `npx @grainulation/grainulation` |\n\n### Tool Interactions\n\n```mermaid\ngraph LR\n    W[wheat] --> B[barn]\n    F[farmer] --> B\n    W --> H[harvest]\n    S[silo] --> H\n    B --> M[mill]\n    W --> S\n    O[orchard] --> All\n```\n\nEach tool follows the zero-dependency principle: built entirely on Node.js built-ins, ships what it needs, and nothing more.\n\n## Key Modules\n\n### CLI Entry Point\n\nThe `bin/grainulation.js` file serves as the unified command-line interface that delegates to individual tools based on user input.\n\n```javascript\n// Entry point routes to individual tools\n// Usage: grainulation <command> [args]\n```\n\n资料来源：[CONTRIBUTING.md:27](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n### Ecosystem Health Checks\n\nThe `lib/ecosystem.js` module performs health checks across the entire tool ecosystem, verifying tool availability and version consistency.\n\n**Key Functions:**\n\n| Function | Purpose |\n|----------|---------|\n| `checkToolHealth()` | Verifies all installed tools are operational |\n| `getVersionMatrix()` | Returns version info for all packages |\n| `validateToolchain()` | Ensures tool dependencies are satisfied |\n\n### Router\n\nThe `lib/router.js` module handles command dispatching to the appropriate tool based on subcommand parsing.\n\n```mermaid\ngraph TD\n    A[User Command] --> B[Parse Command]\n    B --> C{Is Global Command?}\n    C -->|Yes| D[Run Ecosystem Command<br/>doctor/setup/health]\n    C -->|No| E{Local Tool Command?}\n    E -->|Yes| F[Route to Tool Package]\n    E -->|No| G[Show Help]\n```\n\n### Doctor Module\n\nThe `lib/doctor.js` diagnostic tool validates tool installations and identifies issues with the local setup.\n\n资料来源：[CONTRIBUTING.md:25](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Tool Discovery\n\nThe ecosystem uses npm package discovery to find installed tools. Each tool follows the naming convention `@grainulation/<toolname>` and is installed on-demand when first accessed via npx.\n\n### Discovery Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant NPM as npm registry\n    participant Tool as @grainulation/tool\n\n    User->>CLI: grainulation wheat init\n    CLI->>Router: route(wheat, [init])\n    Router->>Tool: npx @grainulation/wheat init\n    Tool-->>User: Execute command\n```\n\n## Configuration Management\n\n### Setup Flow\n\nThe first-run setup process (`lib/setup.js`) performs initial configuration:\n\n1. Detects installed Node.js version\n2. Verifies npx availability\n3. Creates user configuration directory\n4. Initializes default settings for each tool\n\n### Configuration Files\n\n| File | Location | Purpose |\n|------|----------|---------|\n| `wheat.config.json` | Sprint directory | Research configuration |\n| `claims.json` | Sprint directory | Evidence and claims storage |\n| `.grainulationrc` | User home | Global preferences |\n\n## Publishing and Releases\n\n### Release Architecture\n\nThe entire ecosystem uses a coordinated release process documented in `RELEASE.md`.\n\n```mermaid\ngraph LR\n    A[Tag v.x.y.z] --> B[Workflow Trigger]\n    B --> C[Run Tests]\n    C --> D[Verify Version]\n    D --> E[Publish npm<br/>via OIDC]\n    E --> F[Update npmjs.com]\n```\n\n### Publishing Workflow\n\nEach package publishes via `.github/workflows/publish.yml` on tag push. The workflow:\n\n1. Runs tests\n2. Verifies tag matches `package.json.version`\n3. Publishes with npm provenance via OIDC trusted publishing\n4. No `NPM_TOKEN` secret required after initial setup\n\n资料来源：[RELEASE.md:1-30](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n### Single-Package Release\n\n```bash\ncd <repo>\nnpm version patch\ngit push origin main --follow-tags\n```\n\n### Coordinated Release\n\nFor consumer packages depending on new internal features:\n\n1. Publish the dependency package first (e.g., `barn`)\n2. Wait for npm publication (~60 seconds)\n3. Run `npm install` in each consumer repo\n4. Commit lockfile updates\n5. Publish each consumer with version bump\n\n资料来源：[RELEASE.md:15-35](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n## Web Dashboard\n\nThe `lib/server.mjs` module provides a local web server for the ecosystem dashboard, serving the web UI from the `public/` directory.\n\n### Dashboard Features\n\n- Real-time ecosystem health status\n- Tool version matrix\n- Quick action buttons for common operations\n- Configuration overview\n\n## Testing\n\nThe ecosystem uses Node's built-in test runner with tests located in `test/basic.test.js`.\n\n```bash\nnode test/basic.test.js\n```\n\nThis runs without additional dependencies, consistent with the zero-dependency philosophy.\n\n## Quick Reference Commands\n\n| Command | Description |\n|---------|-------------|\n| `grainulation` | Ecosystem overview |\n| `grainulation doctor` | Health check for all tools |\n| `grainulation setup` | Install tools for your role |\n| `grainulation wheat init` | Initialize research sprint |\n| `grainulation orchard status` | Check ecosystem status |\n\n## Design Principles\n\nThe ecosystem is built on four core principles:\n\n1. **Zero Dependencies**: Every tool ships with only Node.js built-ins, eliminating supply chain risk\n2. **Language Agnostic**: Research can cover any technology stack or domain\n3. **Local-First**: All processing occurs locally; no cloud services or API keys required for core tools\n4. **Auditable**: Every claim, challenge, and resolution maintains a git audit trail\n\n---\n\n<a id='tool-integration'></a>\n\n## Tool Integration\n\n### 相关页面\n\n相关主题：[Ecosystem Overview](#ecosystem-overview), [CLI Architecture](#cli-architecture), [Extensibility Guide](#extensibility-guide)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js) - CLI entrypoint\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js) - Command routing\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js) - Package management\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js) - Ecosystem health checks\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js) - Diagnostic tool\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js) - First-run setup\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md) - Architecture documentation\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md) - Release documentation\n</details>\n\n# Tool Integration\n\nThe Grainulation ecosystem provides a unified CLI architecture that orchestrates eight independent CLI tools through a centralized routing and package management system. This document describes how tools integrate with the ecosystem, how commands flow through the system, and how the unified entrypoint manages tool discovery and execution.\n\n## Architecture Overview\n\nGrainulation follows a meta-package pattern where the `grainulation` tool serves as an ecosystem router. It does not implement tool functionality itself but delegates to individual packages while providing unified health checks, diagnostics, and package management.\n\n```mermaid\ngraph TD\n    User[\"User\"] --> CLI[\"bin/grainulation.js<br/>CLI Entrypoint\"]\n    CLI --> Router[\"lib/router.js<br/>Command Router\"]\n    Router --> Wheat[\"@grainulation/wheat\"]\n    Router --> Farmer[\"@grainulation/farmer\"]\n    Router --> Barn[\"@grainulation/barn\"]\n    Router --> Mill[\"@grainulation/mill\"]\n    Router --> Silo[\"@grainulation/silo\"]\n    Router --> Harvest[\"@grainulation/harvest\"]\n    Router --> Orchard[\"@grainulation/orchard\"]\n    \n    CLI --> Ecosystem[\"lib/ecosystem.js<br/>Health Checks\"]\n    CLI --> Doctor[\"lib/doctor.js<br/>Diagnostics\"]\n    CLI --> PM[\"lib/pm.js<br/>Package Manager\"]\n    CLI --> Setup[\"lib/setup.js<br/>Configuration\"]\n    \n    Ecosystem -.-> Wheat\n    Ecosystem -.-> Farmer\n    Ecosystem -.-> Barn\n```\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L35)\n\n## The Eight Tools\n\nThe ecosystem consists of eight independently versioned packages, each with a specific responsibility:\n\n| Tool | Role | Primary Function |\n|------|------|------------------|\n| **wheat** | Research | Claim collection and challenge workflow |\n| **farmer** | Permissions | AI agent tool call approval dashboard |\n| **barn** | Shared utilities | Sprint detection, manifest generation, HTML templates |\n| **mill** | Export | PDF, CSV, and static site generation |\n| **silo** | Storage | Data persistence layer |\n| **harvest** | Analytics | Cross-sprint learning and prediction tracking |\n| **orchard** | Orchestration | Multi-tool coordination |\n| **grainulation** | Unified CLI | Meta-tool routing and ecosystem management |\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - Tool card descriptions\n\n## CLI Entry Point\n\nThe CLI entrypoint at `bin/grainulation.js` serves as the single entry point for all tool operations. When invoked via `npx @grainulation/grainulation` or `npx grainulation`, this script:\n\n1. Parses command-line arguments\n2. Checks for ecosystem health\n3. Routes commands to the appropriate tool\n4. Handles configuration and setup workflows\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L28)\n\n### Quick Setup\n\nNo installation step is required. The tools use zero npm dependencies and run directly:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L12-L16)\n\n## Command Routing\n\nThe routing system in `lib/router.js` maps user commands to the correct tool package. The router interprets command arguments and dispatches execution to the appropriate tool's CLI interface.\n\n### Routing Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Tool as Individual Tool\n\n    User->>CLI: npx @grainulation/grainulation <command>\n    CLI->>Router: parseAndRoute(args)\n    Router->>Router: identifyTool(command)\n    Router->>Tool: delegate(command, args)\n    Tool-->>User: Output\n```\n\nThe router maintains a registry of available tools and their command signatures, enabling dynamic routing without hard-coded dependencies on tool implementations.\n\n**资料来源：** [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js) - Routing implementation\n\n## Package Management\n\nThe `lib/pm.js` module handles package management for the grainulation ecosystem. It manages:\n\n- Installation of individual tool packages\n- Version resolution across interdependent packages\n- Dependency tracking between ecosystem tools\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L33)\n\n### Coordinated Releases\n\nWhen a tool depends on new features from another tool in the ecosystem, a coordinated release process ensures compatibility:\n\n1. **Publish dependency first** - The upstream tool (e.g., `barn`) publishes its new version\n2. **Wait for registry sync** - Allow ~60 seconds for npm to propagate the package\n3. **Update consumers** - Run `npm install` in each consumer repository to regenerate `package-lock.json`\n4. **Publish consumers** - Tag and publish each dependent package\n\n```bash\n# Example: barn new version\ncd barn\nnpm version patch\ngit push origin main --follow-tags\n\n# Wait 60s, then in each consumer\nnpm install\ngit add package-lock.json\nnpm version patch\ngit push origin main --follow-tags\n```\n\n**资料来源：** [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md#L26-L43)\n\n## Ecosystem Health Checks\n\nThe `lib/ecosystem.js` module provides health checks and tool discovery capabilities. It:\n\n- Verifies all tool packages are installed correctly\n- Checks version compatibility between tools\n- Provides status information for the entire ecosystem\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L30)\n\n## Diagnostic System\n\nThe `lib/doctor.js` module validates tool installations and provides diagnostic information:\n\n- Checks Node.js version compatibility\n- Validates package integrity\n- Reports missing or misconfigured tools\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L31)\n\n## Setup and Configuration\n\nThe `lib/setup.js` module handles first-run setup and configuration:\n\n- Creates initial configuration files\n- Sets up workspace directories\n- Initializes claim storage\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L32)\n\n## Zero Dependencies Architecture\n\nAll eight tools in the grainulation ecosystem share a critical design principle: **zero npm dependencies**. Every tool ships only Node.js built-ins and its own code.\n\n```mermaid\ngraph LR\n    subgraph \"Traditional Tool\"\n        T1[Tool Code] --> DEPS[External Dependencies]\n        DEPS --> POTENTIAL[\"Potential Issues:<br/>- Supply chain risk<br/>- Version conflicts<br/>- API changes\"]\n    end\n    \n    subgraph \"Grainulation Tool\"\n        G1[Tool Code] --> BUILTIN[\"Node.js Built-ins Only\"]\n        BUILTIN --> BENEFITS[\"Benefits:<br/>- No left-pad incidents<br/>- No supply chain anxiety<br/>- Offline capable\"]\n    end\n```\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - Feature descriptions\n\n### Benefits of Zero Dependencies\n\n| Aspect | Impact |\n|--------|--------|\n| Supply chain security | No third-party code to compromise |\n| Reproducibility | Same behavior across all environments |\n| Offline capability | Works without network access |\n| Maintenance | No dependency update churn |\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - \"Zero dependencies\" feature card\n\n## Publishing Workflow\n\nEach package publishes independently via GitHub Actions using OIDC trusted publishing:\n\n```yaml\n# .github/workflows/publish.yml pattern\non:\n  push:\n    tags:\n      - 'v*'\njobs:\n  publish:\n    steps:\n      - uses: actions/checkout@v4\n      - run: npm publish --provenance --access public\n```\n\nNo `NPM_TOKEN` secret is required after initial setup on npmjs.com. The workflow verifies that the tag matches `package.json.version` before publishing.\n\n**资料来源：** [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md#L14-L24)\n\n## Local Server Dashboard\n\nThe `lib/server.mjs` module provides a local web server (ESM) that serves as a unified ecosystem dashboard:\n\n- Real-time status of all tools\n- Health check visualization\n- Ecosystem-wide monitoring\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L35-L36)\n\n## Contributing to Tool Integration\n\nTo add a new tool to the ecosystem or modify the integration layer:\n\n1. **Report bugs** - Open an issue with expected vs actual behavior, Node version, and reproduction steps\n2. **Suggest features** - Describe the use case: \"I need X because Y\"\n3. **Submit PRs**:\n   - Fork the repo and create a branch: `git checkout -b fix/description`\n   - Make changes following the existing patterns\n   - Run tests: `node test/basic.test.js`\n   - Commit with a clear message and open a PR\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L20-L26)\n\n## File Structure Reference\n\n| File | Purpose |\n|------|---------|\n| `bin/grainulation.js` | CLI entrypoint, routes to individual tools |\n| `lib/router.js` | Command routing to the correct tool package |\n| `lib/ecosystem.js` | Ecosystem health checks and tool discovery |\n| `lib/doctor.js` | Diagnostic tool, validates tool installations |\n| `lib/setup.js` | First-run setup and configuration |\n| `lib/pm.js` | Package management for grainulation tools |\n| `lib/server.mjs` | Local server, unified ecosystem dashboard (ESM) |\n| `public/` | Web UI for ecosystem overview and status |\n| `site/` | Public website (grainulation.com) |\n| `test/` | Node built-in test runner tests |\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L36)\n\n---\n\n<a id='setup-installation'></a>\n\n## Setup and Installation\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Health Checks and Diagnostics](#health-checks), [Package Management](#package-management)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n</details>\n\n# Setup and Installation\n\nGrainulation is designed with zero external dependencies, meaning no `npm install` is required to get started. The entire ecosystem uses only Node.js built-in modules, eliminating supply chain anxiety and ensuring consistent behavior across environments.\n\n## Prerequisites\n\nBefore installing or running Grainulation tools, ensure your environment meets the following requirements:\n\n| Requirement | Version | Notes |\n|-------------|---------|-------|\n| Node.js | 20+ | Required for all core tools |\n| npx | Latest | Bundled with Node.js 20+ |\n| Git | Any recent version | For cloning repositories |\n| Claude Code | Required | Only needed for research features |\n\n资料来源：[CONTRIBUTING.md:12]()\n\n## Installation Methods\n\n### Quick Start with npx\n\nThe fastest way to run any Grainulation tool is through `npx`, which downloads and executes the package on-demand:\n\n```bash\nnpx @grainulation/wheat init\nnpx @grainulation/grainulation --help\n```\n\n### Local Development Setup\n\nFor contributing to the project or modifying the source code:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\n资料来源：[CONTRIBUTING.md:5-9]()\n\n## Project Structure\n\n```\ngrainulation/\n├── bin/\n│   └── grainulation.js    # CLI entrypoint - routes to individual tools\n├── lib/\n│   ├── router.js          # Command routing to the correct tool package\n│   ├── ecosystem.js      # Ecosystem health checks and tool discovery\n│   ├── doctor.js         # Diagnostic tool - validates tool installations\n│   ├── setup.js          # First-run setup and configuration\n│   ├── pm.js             # Package management for grainulation tools\n│   └── server.mjs        # Local server (ESM)\n├── public/               # Web UI - ecosystem overview and status\n├── site/                 # Public website (grainulation.com)\n└── test/                 # Node built-in test runner tests\n```\n\n资料来源：[CONTRIBUTING.md:28-38]()\n\n## CLI Entry Point Architecture\n\nThe unified CLI routes commands to the appropriate tool package based on the arguments provided:\n\n```mermaid\ngraph TD\n    A[CLI: node bin/grainulation.js] --> B[lib/router.js]\n    B --> C[wheat]\n    B --> D[farmer]\n    B --> E[barn]\n    B --> F[mill]\n    B --> G[silo]\n    B --> H[harvest]\n    B --> I[orchard]\n    B --> J[doctor - diagnostics]\n```\n\nThe router module determines which package should handle each command, enabling the unified CLI experience while keeping each tool independent.\n\n资料来源：[CONTRIBUTING.md:28-29]()\n\n## Tool Ecosystem Overview\n\nGrainulation consists of eight specialized packages plus a meta-package:\n\n| Package | Role | Install Command |\n|---------|------|-----------------|\n| wheat | Research and claims management | `npx @grainulation/wheat init` |\n| farmer | Permission dashboard for AI agents | `npx @grainulation/farmer start` |\n| barn | Shared utilities and sprint detection | `npx @grainulation/barn detect-sprints` |\n| mill | Export and publish compiled research | `npx @grainulation/mill export --format pdf` |\n| silo | Research storage and retrieval | `npx @grainulation/silo` |\n| harvest | Analytics and cross-sprint learning | `npx @grainulation/harvest analyze ./sprints/` |\n| orchard | Orchestration and workflow management | `npx @grainulation/orchard status` |\n| grainulation | Unified CLI meta-tool | `npx @grainulation/grainulation` |\n\n资料来源：[site/index.html:145-165]()\n\n## Zero Dependencies Architecture\n\nAll eight packages in the Grainulation ecosystem maintain zero npm dependencies:\n\n```mermaid\ngraph LR\n    A[User Environment] --> B[Node.js Built-ins Only]\n    B --> C[No npm packages]\n    B --> D[No external APIs]\n    C --> E[Zero supply chain risk]\n    D --> E\n```\n\nThis design philosophy ensures:\n- No supply chain anxiety\n- No \"left-pad\" incidents\n- No API keys required for core tools\n- Everything ships what it needs and nothing more\n\n资料来源：[site/index.html:38-40]()\n\n## First-Run Setup\n\nOn first execution, the setup module (`lib/setup.js`) handles:\n\n1. Configuration file creation in the user's home directory\n2. Ecosystem health verification\n3. Tool discovery across all installed packages\n\nRun diagnostics to verify your setup:\n\n```bash\nnode bin/grainulation.js doctor\n```\n\n资料来源：[CONTRIBUTING.md:30]()\n\n## Running Tests\n\nAfter making changes to the codebase, validate your modifications:\n\n```bash\nnode test/basic.test.js\n```\n\n资料来源：[CONTRIBUTING.md:18]()\n\n## Package Publishing Workflow\n\nFor developers releasing updates to the ecosystem, the publishing process uses GitHub Actions with OIDC trusted publishing:\n\n```mermaid\ngraph LR\n    A[npm version patch] --> B[Git push with tags]\n    B --> C[GitHub Actions trigger]\n    C --> D[Verify tag matches package.json]\n    D --> E[Run tests]\n    E --> F[Publish via OIDC]\n    F --> G[npmjs.com]\n```\n\nThe workflow handles all eight packages plus the `grainulator` plugin through coordinated releases when dependencies exist between packages.\n\n资料来源：[RELEASE.md:1-30]()\n\n## Verification Checklist\n\nAfter installation, verify your setup by running these commands:\n\n| Check | Command | Expected Output |\n|-------|---------|-----------------|\n| CLI accessible | `node bin/grainulation.js --help` | Command routing help |\n| Doctor diagnostics | `node bin/grainulation.js doctor` | Health status report |\n| Tool discovery | `node bin/grainulation.js ecosystem` | List of installed tools |\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| Command not found | Ensure Node.js 20+ is installed |\n| Tool routing fails | Run `node bin/grainulation.js doctor` to diagnose |\n| npx timeout | Use local clone: `node bin/grainulation.js <command>` |\n\n### Diagnostic Commands\n\nThe doctor module validates tool installations and provides troubleshooting guidance:\n\n```bash\nnode bin/grainulation.js doctor\n```\n\n资料来源：[CONTRIBUTING.md:30]()\n\n## Related Documentation\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md) - Development setup and architecture\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md) - Release processes and publishing\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md) - Project overview and capabilities\n\n---\n\n<a id='health-checks'></a>\n\n## Health Checks and Diagnostics\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Setup and Installation](#setup-installation), [Package Management](#package-management)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n</details>\n\n# Health Checks and Diagnostics\n\nThe **Health Checks and Diagnostics** subsystem in grainulation provides a systematic way to verify the integrity of the ecosystem, validate configurations, and diagnose issues across the eight CLI tools. The `doctor` module serves as the central diagnostic engine that ensures the research workflow operates correctly.\n\n## Overview\n\ngrainulation is an ecosystem of eight zero-dependency CLI tools for structured technical research. Given the distributed nature of this architecture—where tools like `wheat`, `silo`, `mill`, `farmer`, `harvest`, `orchard`, `barn`, and the unified `grainulation` CLI must work together—the Health Checks and Diagnostics system provides essential validation and troubleshooting capabilities.\n\nThe diagnostic subsystem answers questions like:\n\n- Are all tool configurations valid?\n- Is the Node.js environment compatible?\n- Are claims files properly formatted?\n- Are there conflicts or issues in sprint data?\n\n## Architecture\n\n```mermaid\ngraph TD\n    A[User Command] --> B[grainulation CLI]\n    B --> C{doctor.js}\n    C --> D[Config Validation]\n    C --> E[Tool Health Check]\n    C --> F[Claims Validation]\n    C --> G[Ecosystem Status]\n    D --> H[wheat.config.json]\n    E --> I[Individual Tools]\n    F --> J[claims.json]\n    G --> K[Tool Manifests]\n```\n\n### Core Components\n\n| Component | Purpose | File Location |\n|-----------|---------|---------------|\n| `doctor.js` | Main diagnostic engine | `lib/doctor.js` |\n| Config Validator | Validates JSON configurations | Part of doctor module |\n| Claims Checker | Validates claim structure | Part of doctor module |\n| Ecosystem Scanner | Checks tool availability | Part of doctor module |\n\n## Diagnostic Workflow\n\nWhen running a health check, the system follows this diagnostic sequence:\n\n```mermaid\ngraph LR\n    A[Init Check] --> B[Environment Scan]\n    B --> C[Config Load]\n    C --> D[Schema Validation]\n    D --> E{Settings Valid?}\n    E -->|Yes| F[Tool Check]\n    E -->|No| G[Report Errors]\n    F --> H{All Tools OK?}\n    H -->|Yes| I[Generate Report]\n    H -->|No| J[Flag Issues]\n```\n\n1. **Initialization Check**: Verifies the command can access necessary Node.js APIs\n2. **Environment Scan**: Checks Node.js version compatibility\n3. **Configuration Load**: Loads project-level and global configurations\n4. **Schema Validation**: Ensures configuration files match expected schemas\n5. **Tool Health Check**: Verifies each tool in the ecosystem is accessible\n6. **Report Generation**: Produces a diagnostic report with findings\n\n## Configuration Validation\n\nThe diagnostic system validates configurations stored in `wheat.config.json` and tool-specific settings.\n\n### Validated Configuration Elements\n\n| Element | Description | Validation |\n|---------|-------------|------------|\n| `question` | Research question string | Non-empty string |\n| `audience` | Target stakeholders | Array of strings |\n| `constraints` | Decision constraints | Array of strings |\n| `tools` | Enabled tool list | String array |\n| `outputFormat` | Brief output format | Enum: html, pdf, md |\n\nConfiguration validation uses strict JSON schema checking to ensure data integrity throughout the research sprint.\n\n## Claims Validation\n\nAs described in the grainulation philosophy, everything starts with a **claim**—a typed statement with an evidence grade. The diagnostic system validates claims in `claims.json`.\n\n### Claim Structure Validation\n\n```mermaid\ngraph TD\n    A[claims.json] --> B[Parse JSON]\n    B --> C[For Each Claim]\n    C --> D{ID Present?}\n    D -->|No| E[Flag: Missing ID]\n    D -->|Yes| F{Type Valid?}\n    F -->|No| G[Flag: Invalid Type]\n    F -->|Yes| H{Tier Valid?}\n    H -->|No| I[Flag: Invalid Tier]\n    H -->|Yes| J[Evidence Check]\n    J --> K{Evidence Grade OK?}\n    K -->|No| L[Flag: Weak Evidence]\n    K -->|Yes| M[Next Claim]\n```\n\n### Claim Types\n\n| Type | Description |\n|------|-------------|\n| `factual` | Verifiable fact with evidence |\n| `risk` | Identified risk or threat |\n| `estimate` | Best-effort estimation |\n| `constraint` | Hard constraint on the decision |\n| `recommendation` | Suggested action based on evidence |\n\n### Evidence Tiers\n\n| Tier | Level | Description |\n|------|-------|-------------|\n| 1 | `stated` | Someone said it |\n| 2 | `claimed` | External source states it |\n| 3 | `documented` | Written documentation exists |\n| 4 | `measured` | Measured or observed in practice |\n\n## Ecosystem Health Checks\n\nThe diagnostic system performs comprehensive checks across the grainulation ecosystem.\n\n### Tool Availability\n\nEach of the eight tools is checked for availability:\n\n```mermaid\ngraph TD\n    A[Check Tool Availability] --> B[wheat - Research Engine]\n    A --> C[silo - Reusable Knowledge]\n    A --> D[mill - Export & Publish]\n    A --> E[farmer - AI Permissions]\n    A --> F[harvest - Analytics]\n    A --> G[orchard - Orchestration]\n    A --> H[barn - Shared Utilities]\n    A --> I[grainulation - Unified CLI]\n    B --> J{Installed?}\n    J -->|Yes| K[OK]\n    J -->|No| L[Missing Warning]\n```\n\n### Zero Dependencies Verification\n\nThe diagnostic system confirms that tools maintain the zero-dependency promise by verifying no external npm packages are required.\n\n## Diagnostic Output\n\nThe health check produces structured output:\n\n```json\n{\n  \"status\": \"healthy|warning|critical\",\n  \"timestamp\": \"ISO-8601 timestamp\",\n  \"checks\": {\n    \"environment\": { \"status\": \"pass|fail\", \"details\": \"...\" },\n    \"config\": { \"status\": \"pass|fail\", \"errors\": [] },\n    \"claims\": { \"status\": \"pass|fail\", \"count\": 0, \"issues\": [] },\n    \"ecosystem\": { \"status\": \"pass|fail\", \"tools\": {} }\n  },\n  \"recommendations\": [\"suggestion1\", \"suggestion2\"]\n}\n```\n\n## Running Diagnostics\n\nHealth checks can be invoked through the unified CLI:\n\n```bash\n# Check overall ecosystem health\nnpx grainulation doctor\n\n# Check specific sprint health\nnpx @grainulation/wheat doctor\n\n# Check with verbose output\nnpx grainulation doctor --verbose\n```\n\n## Common Issues and Resolutions\n\n| Issue | Symptom | Resolution |\n|-------|---------|------------|\n| Invalid JSON config | Parser error | Validate JSON syntax in config files |\n| Missing claims | Empty claims array | Run `/research` commands to gather claims |\n| Weak evidence | Low-tier claims | Gather more evidence for critical claims |\n| Tool not found | Command not recognized | Reinstall via `npx @grainulation/[tool]` |\n| Conflict unresolved | Compiler blocks output | Use `/challenge` to resolve claim conflicts |\n\n## Integration with Compiler\n\nThe diagnostic system integrates with the compiler to ensure decision briefs are only generated when health checks pass:\n\n```mermaid\ngraph TD\n    A[/brief command] --> B[Run Health Check]\n    B --> C{All Checks Pass?}\n    C -->|No| D[Block Brief]\n    C -->|Yes| E[Compile Claims]\n    E --> F{Conflicts Exist?}\n    F -->|Yes| G[Flag Conflicts]\n    G --> D\n    F -->|No| H[Generate Brief]\n```\n\nThis ensures that decision briefs maintain the integrity guarantees promised by the grainulation philosophy—only well-researched, properly challenged, and conflict-resolved claims make it into the final output.\n\n## Summary\n\nThe Health Checks and Diagnostics system is fundamental to grainulation's promise of producing auditable, evidence-based decision briefs. By validating configurations, claims structure, evidence quality, and ecosystem integrity, the diagnostic subsystem ensures that every decision produced by the system meets the rigorous standards required for technical decision-making.\n\n---\n\n<a id='package-management'></a>\n\n## Package Management\n\n### 相关页面\n\n相关主题：[Setup and Installation](#setup-installation), [Health Checks and Diagnostics](#health-checks)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n- [package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n</details>\n\n# Package Management\n\nGrainulation implements a lightweight package management system designed to orchestrate its ecosystem of zero-dependency CLI tools. Rather than relying on external package managers for tool discovery and installation, the system provides `lib/pm.js` as a built-in mechanism for managing the eight core packages that comprise the grainulation ecosystem.\n\n## Overview\n\nThe package management module serves two primary functions within the grainulation architecture:\n\n1. **Tool Discovery** — Locates installed grainulation packages within the local environment\n2. **Package Installation** — Installs and updates the eight core tools (`wheat`, `farmer`, `barn`, `mill`, `silo`, `harvest`, `orchard`, `grainulation`) plus the `grainulator` plugin\n\nThis approach aligns with the project's fundamental philosophy: everything runs locally with minimal external dependencies. The package management layer sits above Node.js built-in modules and does not introduce additional npm packages into the runtime environment.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Ecosystem Architecture\n\nThe grainulation ecosystem consists of eight specialized tools, each responsible for a distinct phase of structured technical research. The package management module serves as the glue layer that enables these tools to work together as a unified system.\n\n```mermaid\ngraph TD\n    subgraph \"Grainulation Ecosystem\"\n        G[\"grainulation<br/>(meta-package)\"]\n        PM[\"lib/pm.js<br/>(Package Manager)\"]\n        \n        G --> PM\n    end\n    \n    subgraph \"Core Tools\"\n        W[\"wheat<br/>(Research Sprint)\"]\n        F[\"farmer<br/>(Permission Dashboard)\"]\n        B[\"barn<br/>(Validation)\"]\n        M[\"mill<br/>(Export)\"]\n        S[\"silo<br/>(Data Storage)\"]\n        H[\"harvest<br/>(Analytics)\"]\n        O[\"orchard<br/>(Status)\"]\n    end\n    \n    subgraph \"Plugins\"\n        GR[\"grainulator\"]\n    end\n    \n    PM --> W\n    PM --> F\n    PM --> B\n    PM --> M\n    PM --> S\n    PM --> H\n    PM --> O\n    PM --> GR\n    \n    W <--> B\n    W <--> M\n    B <--> S\n    H <--> S\n    O <--> S\n```\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Package Registry\n\nAll grainulation packages are published to npm under the `@grainulation` scope. The following table lists the core packages and their primary functions:\n\n| Package | Purpose | Command Prefix |\n|---------|---------|----------------|\n| `@grainulation/grainulation` | Unified CLI entry point, ecosystem router | `npx grainulation` |\n| `@grainulation/wheat` | Research sprint initialization and claims management | `npx @grainulation/wheat` |\n| `@grainulation/farmer` | Permission dashboard for AI agent tool calls | `npx @grainulation/farmer` |\n| `@grainulation/barn` | Validation engine, evidence grading | `npx @grainulation/barn` |\n| `@grainulation/mill` | Export compiled research to PDF, CSV, HTML | `npx @grainulation/mill` |\n| `@grainulation/silo` | Local data storage and persistence | `npx @grainulation/silo` |\n| `@grainulation/harvest` | Cross-sprint analytics and prediction tracking | `npx @grainulation/harvest` |\n| `@grainulation/orchard` | Ecosystem status and health monitoring | `npx @grainulation/orchard` |\n\nThe `grainulator` plugin extends the system with additional capabilities and follows the same package naming conventions.\n\n资料来源：[site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n\n## pnpm Configuration\n\nGrainulation uses [pnpm](https://pnpm.io/) as its package manager, with version 10.30.0 specified in the project's `package.json`:\n\n```json\n{\n  \"packageManager\": \"pnpm@10.30.0\"\n}\n```\n\n### Key Configuration\n\n| Setting | Value | Purpose |\n|---------|-------|---------|\n| `packageManager` | `pnpm@10.30.0` | Ensures consistent package manager version across contributors |\n| `engines.node` | `>=20` | Requires Node.js 20 or higher |\n| `publishConfig.access` | `public` | Packages are publicly accessible on npm |\n\nThe Node.js version requirement ensures compatibility with modern JavaScript features used throughout the ecosystem, including ES modules and built-in APIs like `node:fs`, `node:path`, and `node:http`.\n\n资料来源：[package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n\n## Dependency Model\n\nUnlike traditional Node.js projects that accumulate numerous npm dependencies, grainulation maintains a strict zero-dependency policy for the CLI tools themselves. However, the meta-package (`grainulation`) includes one internal dependency to enable routing and ecosystem coordination:\n\n```json\n{\n  \"dependencies\": {\n    \"@grainulation/barn\": \"^1.3.0\"\n  }\n}\n```\n\n### Dependency Philosophy\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    Dependency Philosophy                    │\n├─────────────────────────────────────────────────────────────┤\n│  CLI Tools (wheat, farmer, etc.)    →  Zero npm deps       │\n│  Meta-package (grainulation)        →  Only @grainulation  │\n│  All packages                       →  Node.js built-ins  │\n└─────────────────────────────────────────────────────────────┘\n```\n\nThis design provides several benefits:\n\n- **Supply chain security** — No third-party code dependencies reduces attack surface\n- **Installation speed** — Minimal package download footprint\n- **Reliability** — No dependency on external package availability\n- **Auditability** — Complete visibility into tool behavior\n\n资料来源：[site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n\n## Installation Workflow\n\n### Quick Setup\n\nThe recommended installation method uses npx, which downloads and executes packages on-demand without requiring a global installation:\n\n```bash\n# Clone the repository\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\n\n# Run the CLI directly\nnode bin/grainulation.js --help\n```\n\n### Installing Individual Tools\n\nEach tool can be installed independently using npx:\n\n```bash\n# Initialize a research sprint\nnpx @grainulation/wheat init\n\n# Start the permission dashboard\nnpx @grainulation/farmer start\n\n# Export compiled research\nnpx @grainulation/mill export --format pdf\n```\n\nThe package management module (`lib/pm.js`) handles tool discovery and ensures that the correct versions of inter-dependent packages are available.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Release Workflow\n\nPackages are published through GitHub Actions using OIDC trusted publishing, eliminating the need for npm access tokens after initial setup.\n\n### Release Process\n\n1. **Version bump** — Run `npm version patch` (or `minor`/`major`) in the package directory\n2. **Tag creation** — The npm version command creates a git tag (`v<x.y.z>`)\n3. **Push with tags** — `git push origin main --follow-tags` triggers the workflow\n4. **Automated publish** — GitHub Actions verifies the tag matches `package.json` version and publishes to npm\n\n### Coordinated Releases\n\nWhen a package update requires changes in dependent packages:\n\n1. Publish the base package (e.g., `barn`) first\n2. Wait for npm publication (~60 seconds)\n3. Run `npm install` in consumer repositories to update lockfiles\n4. Commit the lockfile changes\n5. Proceed with dependent package releases\n\n资料来源：[RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n## CLI Entry Point\n\nThe unified CLI is implemented in `bin/grainulation.js`, which serves as the main entry point for the ecosystem:\n\n```mermaid\ngraph LR\n    A[\"grainulation CLI\"] --> B[\"bin/grainulation.js\"]\n    B --> C[\"lib/router.js\"]\n    B --> D[\"lib/ecosystem.js\"]\n    B --> E[\"lib/doctor.js\"]\n    B --> F[\"lib/pm.js\"]\n    \n    C --> G1[\"wheat\"]\n    C --> G2[\"farmer\"]\n    C --> G3[\"barn\"]\n    C --> G4[\"mill\"]\n    \n    D --> H[\"Health Checks\"]\n    E --> I[\"Diagnostics\"]\n    F --> J[\"Package Ops\"]\n```\n\nThe router (`lib/router.js`) delegates commands to the appropriate tool package, while the ecosystem module (`lib/ecosystem.js`) provides health checks and tool discovery capabilities.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## See Also\n\n- [wheat](../wheat/research-sprint) — Research sprint initialization\n- [barn](../barn/validation) — Evidence validation and grading\n- [farmer](../farmer/permissions) — Permission dashboard for AI agents\n- [mill](../mill/export) — Export and publishing tools\n\n---\n\n<a id='server-routing'></a>\n\n## Server and Routing\n\n### 相关页面\n\n相关主题：[CLI Architecture](#cli-architecture), [Tool Integration](#tool-integration)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/server.mjs](https://github.com/grainulation/grainulation/blob/main/lib/server.mjs)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n</details>\n\n# Server and Routing\n\n## Overview\n\nThe Server and Routing system in Grainulation serves as the foundational infrastructure that handles command dispatch, local development server operations, and ecosystem health management. This system orchestrates the eight independent CLI tools within the ecosystem, providing a unified entry point and centralized coordination layer.\n\nThe routing architecture follows a delegation pattern where the main CLI entrypoint (`bin/grainulation.js`) routes incoming commands to the appropriate tool-specific handlers, while the local server (`lib/server.mjs`) provides an ESM-based dashboard for ecosystem monitoring and interaction.\n\n## Architecture\n\n```mermaid\ngraph TD\n    User[User] --> CLI[bin/grainulation.js<br/>CLI Entrypoint]\n    CLI --> Router[lib/router.js<br/>Command Router]\n    Router --> Wheat[wheat<br/>Research Engine]\n    Router --> Farmer[farmer<br/>Permission Dashboard]\n    Router --> Mill[mill<br/>Export Tools]\n    Router --> Harvest[harvest<br/>Analytics]\n    Router --> Silo[silo<br/>Shared Config]\n    Router --> Barn[barn<br/>Shared Utilities]\n    Router --> Orchard[orchard<br/>Orchestration]\n    CLI --> Server[lib/server.mjs<br/>Local Server]\n    Server --> Ecosystem[lib/ecosystem.js<br/>Health Checks]\n    Server --> Doctor[lib/doctor.js<br/>Diagnostics]\n```\n\n## Key Components\n\n### CLI Entrypoint (`bin/grainulation.js`)\n\nThe primary command-line interface entrypoint that initializes the routing system and delegates to individual tool packages. This file provides the unified CLI experience for all grainulation tools.\n\n| Aspect | Details |\n|--------|---------|\n| Type | Main executable script |\n| Format | JavaScript (CommonJS) |\n| Purpose | Routes to individual tools |\n| Dependencies | Zero npm dependencies |\n\n**Usage:**\n```bash\nnode bin/grainulation.js --help\ngrainulation doctor       # Health check\ngrainulation setup        # Install tools\ngrainulation wheat init   # Delegate to wheat\n```\n\n### Command Router (`lib/router.js`)\n\nThe router module handles command dispatching, parsing incoming arguments and determining which tool package should handle the request. It implements the core routing logic that enables the meta-package approach.\n\n| Aspect | Details |\n|--------|---------|\n| Type | Module |\n| Format | CommonJS (.js) |\n| Purpose | Routes commands to correct tool package |\n| Integration | Called by bin/grainulation.js |\n\nThe router acts as the central switchboard, ensuring commands reach their intended tool while maintaining a consistent interface across the ecosystem.\n\n### Local Server (`lib/server.mjs`)\n\nThe local development server implemented as an ESM module, providing a unified ecosystem dashboard. This server runs locally and offers real-time monitoring of the entire grainulation ecosystem.\n\n| Aspect | Details |\n|--------|---------|\n| Type | HTTP Server |\n| Format | ES Module (.mjs) |\n| Purpose | Unified ecosystem dashboard |\n| Port | Configurable |\n\n**Key Features:**\n- Real-time ecosystem health monitoring\n- SSE (Server-Sent Events) for live updates\n- Zero external dependencies\n- Plain JSON and HTML responses\n\n### Ecosystem Health (`lib/ecosystem.js`)\n\nManages ecosystem-wide health checks and tool discovery. This module maintains awareness of all installed tools and their operational status.\n\n| Function | Description |\n|----------|-------------|\n| Health checks | Validates tool installations |\n| Tool discovery | Finds and catalogs available tools |\n| Status reporting | Provides ecosystem overview |\n\n### Diagnostic Tool (`lib/doctor.js`)\n\nA diagnostic utility that validates tool installations and reports configuration issues. It performs pre-flight checks to ensure the ecosystem is properly configured.\n\n**Command:**\n```bash\ngrainulation doctor\n```\n\n**Validation Checks:**\n- Tool presence verification\n- Version compatibility checks\n- Configuration file validation\n\n## Command Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Server as lib/server.mjs\n    participant Tool as Individual Tool\n    \n    User->>CLI: grainulation wheat init\n    CLI->>Router: Parse command\n    Router->>Tool: Route to wheat\n    Tool-->>User: Execute command\n    \n    User->>CLI: grainulation server start\n    CLI->>Server: Start dashboard\n    Server->>Server: Initialize ESM server\n    Server-->>User: Dashboard available\n    \n    User->>CLI: grainulation doctor\n    CLI->>Router: Parse command\n    Router->>Server: Check ecosystem health\n    Server-->>Router: Health status\n    Router-->>User: Diagnostic report\n```\n\n## Server Implementation\n\nThe `lib/server.mjs` module follows modern ESM conventions with the following characteristics:\n\n**Module Type:** ECMAScript Modules (ESM)  \n**Dependencies:** Node.js built-ins only  \n**Transport:** Server-Sent Events (SSE) for real-time updates  \n**Response Format:** Plain JSON and HTML\n\nThe server operates without external npm dependencies, maintaining the project's zero-dependency philosophy while providing full ecosystem monitoring capabilities.\n\n## Routing Configuration\n\nThe routing system supports delegation to eight distinct tools:\n\n| Tool | Command Pattern | Purpose |\n|------|-----------------|---------|\n| wheat | `grainulation wheat <cmd>` | Research engine |\n| farmer | `grainulation farmer start` | Permission dashboard |\n| mill | `grainulation mill export` | Export and publish |\n| harvest | `grainulation harvest analyze` | Analytics |\n| silo | `grainulation silo status` | Shared configuration |\n| barn | `grainulation barn detect` | Shared utilities |\n| orchard | `grainulation orchard` | Orchestration |\n| grainulation | `grainulation <cmd>` | Meta-tool commands |\n\n## Setup and Initialization\n\nFirst-run setup is handled by `lib/setup.js`, which prepares the environment for tool usage. This includes:\n\n1. Configuration file creation\n2. Tool directory initialization\n3. Environment validation\n\n**Command:**\n```bash\ngrainulation setup\n```\n\n## Health Monitoring\n\nThe ecosystem provides continuous health monitoring through:\n\n- **Automatic checks:** Performed on tool access\n- **Manual diagnostics:** Via `grainulation doctor`\n- **Dashboard view:** Via `lib/server.mjs` dashboard\n\n## Dependencies\n\nThe Server and Routing system maintains zero external npm dependencies:\n\n| Module | Node.js Built-ins Used |\n|--------|------------------------|\n| server.mjs | http, fs, path, events |\n| router.js | fs, path, child_process |\n| ecosystem.js | fs, path |\n| doctor.js | fs, child_process |\n\n## Security\n\nThe implementation includes security headers configured in the site's HTML:\n\n```html\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'\">\n```\n\nThis CSP configuration ensures:\n- Self-hosted resources only\n- Inline scripts for functionality\n- No external connections\n- Data URIs for embedded images\n\n---\n\n<a id='extensibility-guide'></a>\n\n## Extensibility Guide\n\n### 相关页面\n\n相关主题：[Tool Integration](#tool-integration), [Ecosystem Overview](#ecosystem-overview)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n</details>\n\n# Extensibility Guide\n\n## Overview\n\nThe grainulation ecosystem is designed as a modular, extensible CLI framework for structured technical research and decision-making. Built with zero npm dependencies, the system follows a hub-and-spoke architecture where the main `grainulation` package serves as the orchestrator and unified entry point for eight specialized tools: `wheat`, `farmer`, `barn`, `mill`, `silo`, `harvest`, `orchard`, and `grainulator`.\n\nThe ecosystem architecture enables horizontal scaling of functionality through independently deployable packages while maintaining a consistent user experience through the centralized CLI router. Each tool follows a strict contract: typed claims with evidence grades, compilation logic, and output formats that integrate seamlessly with the broader research workflow.\n\n## Architecture\n\n### Hub-and-Spoke Model\n\nThe grainulation ecosystem follows a hub-and-spoke architecture where the core `grainulation` package routes commands to specialized tools. This design allows each tool to remain focused on a single responsibility while benefiting from shared infrastructure.\n\n```\ngraph TD\n    A[User: grainulation command] --> B[bin/grainulation.js]\n    B --> C[lib/router.js]\n    C --> D[Tool: wheat]\n    C --> E[Tool: farmer]\n    C --> F[Tool: barn]\n    C --> G[Tool: silo]\n    C --> H[Tool: mill]\n    C --> I[Tool: harvest]\n    C --> J[Tool: orchard]\n    \n    K[lib/ecosystem.js] -.->|health checks| C\n    L[lib/doctor.js] -.->|diagnostics| C\n    M[lib/pm.js] -.->|package management| C\n```\n\n资料来源：[CONTRIBUTING.md:31-46]()\n\n### Directory Structure\n\nThe grainulation repository maintains a clean separation between infrastructure code and tool implementations:\n\n| Directory | Purpose | Key Files |\n|-----------|---------|-----------|\n| `bin/` | CLI entry point | `grainulation.js` - Main executable |\n| `lib/` | Core infrastructure | `router.js`, `ecosystem.js`, `doctor.js`, `pm.js`, `setup.js` |\n| `public/` | Web UI assets | Ecosystem dashboard |\n| `site/` | Public website | Static site for grainulation.com |\n| `test/` | Test suite | Node built-in test runner tests |\n\n资料来源：[CONTRIBUTING.md:31-46]()\n\n## Tool Ecosystem\n\n### Available Tools\n\nThe eight tools in the grainulation ecosystem form a complete research-to-decision pipeline:\n\n| Tool | Role | Function |\n|------|------|----------|\n| `wheat` | Research engine | Initiate sprints, research topics, challenge findings |\n| `farmer` | Permission dashboard | Approve AI agent tool calls in real-time |\n| `barn` | Collaboration | Team-based claim management |\n| `mill` | Export | Generate PDFs, CSVs, static sites from compiled research |\n| `silo` | Documentation | Document and share decision briefs |\n| `harvest` | Analytics | Track prediction accuracy, detect stale claims |\n| `orchard` | Status monitoring | Ecosystem health checks and tool discovery |\n| `grainulator` | Plugin | Custom extension mechanism |\n\n资料来源：[README.md:59-75]()\n\n### Inter-Tool Communication\n\nTools communicate through a shared claims data model. Every claim follows a consistent structure with type, evidence grade, and metadata. This standardization enables seamless handoffs between tools:\n\n```\ngraph LR\n    A[wheat: research] -->|claims.json| B[farmer: challenge]\n    B -->|updated claims| C[barn: collaborate]\n    C -->|merged claims| D[mill: export]\n    D -->|compiled brief| E[silo: publish]\n    \n    F[harvest: analyze] -.->|cross-sprint insights| A\n    G[orchard: status] -.->|health reports| A\n```\n\n## Extending the Ecosystem\n\n### Adding New Tools\n\nThe architecture supports adding new tools through a consistent pattern. Each tool must:\n\n1. Follow the npm package naming convention `@grainulation/<tool-name>`\n2. Accept claims in the standardized format\n3. Produce output compatible with other tools in the pipeline\n4. Implement zero-dependency principles using Node.js built-ins\n\nTo add a new tool to the ecosystem:\n\n```bash\n# Create new package following grainulation naming conventions\nmkdir @grainulation/newtool\ncd newtool\nnpm init\n```\n\nThe router in `lib/router.js` automatically discovers and routes to new tools based on their npm package naming, enabling plug-and-play extensibility without modifying core infrastructure.\n\n资料来源：[CONTRIBUTING.md:15-30]()\n\n### Package Management Integration\n\nThe `lib/pm.js` module handles package management for grainulation tools. When a new tool is installed via npm, the system:\n\n1. Detects the `@grainulation/*` package scope\n2. Registers the tool with the local router\n3. Updates ecosystem health status\n4. Makes the tool available through the unified CLI\n\n```javascript\n// lib/pm.js handles tool discovery and registration\n// New tools automatically integrate through npm install\n```\n\n资料来源：[CONTRIBUTING.md:42]()\n\n### Health Checks and Diagnostics\n\nThe ecosystem includes built-in health monitoring through two complementary systems:\n\n| Component | Purpose | Location |\n|-----------|---------|----------|\n| `orchard` | Tool discovery and status | `orchard.grainulation.com` |\n| `doctor` | Diagnostic validation | `lib/doctor.js` |\n\nThe `doctor.js` module validates tool installations and reports configuration issues. This enables users to diagnose problems without external dependencies.\n\n资料来源：[CONTRIBUTING.md:41]()\n\n## CLI Extensibility\n\n### Unified Entry Point\n\nThe `bin/grainulation.js` file serves as the single entry point for all ecosystem commands. It delegates to specialized tools based on command arguments:\n\n```bash\n# Router dispatches to appropriate tool\nnode bin/grainulation.js <tool-name> <command> [args]\n```\n\nThe bin entry point is registered in `package.json`:\n\n```json\n{\n  \"bin\": {\n    \"grainulation\": \"bin/grainulation.js\"\n  }\n}\n```\n\n资料来源：[package.json:8-10]()\n\n### Command Routing\n\nThe `lib/router.js` module implements intelligent command routing. It:\n\n1. Parses incoming CLI arguments\n2. Maps commands to tool packages\n3. Handles cross-tool invocations\n4. Manages command aliases\n\n### Local Server Extension\n\nThe ecosystem includes an ESM server (`lib/server.mjs`) for web-based extensions. This enables:\n\n- Real-time dashboard views\n- SSE-based permission workflows\n- Browser-based collaboration interfaces\n\nThe server maintains zero dependencies, using only Node.js built-in modules for HTTP and streaming functionality.\n\n资料来源：[CONTRIBUTING.md:44]()\n\n## Configuration and Setup\n\n### First-Run Setup\n\nThe `lib/setup.js` module handles first-run configuration. When a new tool is invoked for the first time, the system:\n\n1. Creates necessary directory structures\n2. Generates default configuration files\n3. Establishes claims storage locations\n4. Initializes git hooks for audit trail\n\n### Configuration Schema\n\nEach tool follows a consistent configuration pattern. The `wheat` tool demonstrates the standard approach with `wheat.config.json`:\n\n| Setting | Purpose |\n|---------|---------|\n| `question` | Research question being investigated |\n| `audience` | Primary stakeholders for the decision |\n| `constraints` | Hard requirements that must be satisfied |\n| `claims[]` | Array of typed claims with evidence grades |\n\n## Publishing and Distribution\n\n### Package Publishing Workflow\n\nTools publish through a standardized GitHub Actions workflow defined in `.github/workflows/publish.yml`. The workflow:\n\n1. Runs tests against the package\n2. Verifies version matches git tag\n3. Publishes with npm provenance via OIDC\n4. Eliminates need for NPM_TOKEN secrets\n\n资料来源：[RELEASE.md:1-18]()\n\n### Publishing Commands\n\n```bash\n# Single-package patch release\ncd <repo>\nnpm version patch\ngit push origin main --follow-tags\n\n# Coordinated release (multiple packages)\n# 1. Publish dependency first\ncd barn && npm version patch && git push origin main --follow-tags\n# 2. Wait for npm to reflect the new version (~60s)\n# 3. Update consumers\ncd consumer && npm install && git commit -m \"Update barn dependency\"\nnpm version patch && git push origin main --follow-tags\n```\n\n资料来源：[RELEASE.md:19-32]()\n\n## Best Practices for Extensions\n\n### Zero-Dependency Principle\n\nAll grainulation tools must adhere to the zero-dependency principle:\n\n- Use only Node.js built-in modules (`fs`, `path`, `http`, `crypto`, etc.)\n- Ship required utilities within the package\n- Avoid supply chain vulnerabilities\n- Enable offline operation\n\nThis principle ensures reliability and security across the entire ecosystem.\n\n### Claim Type System\n\nExtensions should implement the standardized claim type system:\n\n| Type | Description | Example |\n|------|-------------|---------|\n| `factual` | Verified facts | Performance metrics, API specs |\n| `risk` | Potential issues | Security vulnerabilities, failure modes |\n| `estimate` | Informed estimates | Resource projections, timeline forecasts |\n| `constraint` | Hard requirements | Regulatory compliance, SLA requirements |\n| `recommendation` | Suggested actions | Architectural choices, implementation approaches |\n\nEach claim includes an evidence grade from \"someone said it\" to \"measured in production\", enabling the compiler to validate and resolve conflicts.\n\n### Audit Trail Integration\n\nAll claims should maintain git-based audit trails showing:\n\n- When claims were collected\n- How claims were challenged\n- Resolution of conflicts\n- Final compilation decisions\n\nThis enables full traceability of the research process and supports post-decision retrospectives.\n\n## Contributing Extensions\n\n### Development Workflow\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/tool-name`\n3. Implement the tool following grainulation conventions\n4. Add tests using Node built-in test runner\n5. Run existing tests: `node test/basic.test.js`\n6. Submit a pull request\n\n### Testing Requirements\n\nThe project uses Node's built-in test runner. Tests must:\n\n- Cover core functionality\n- Handle error cases gracefully\n- Maintain zero external dependencies\n- Pass on Node.js 20+\n\n```bash\n# Run all tests\nnode test/basic.test.js\nnode --test test/tarball.test.mjs\n```\n\n### Code Quality\n\nThe project uses Biome for linting and formatting:\n\n```bash\n# Check code style\nnpm run lint\n\n# Auto-format code\nnpm run format\n```\n\n资料来源：[CONTRIBUTING.md:15-30]()\n\n## Summary\n\nThe grainulation extensibility model provides a robust framework for building specialized research and decision-making tools. By adhering to the hub-and-spoke architecture, zero-dependency principle, and standardized claims format, new tools can seamlessly integrate into the ecosystem while maintaining independence and focus. The modular design enables teams to adopt only the tools they need while preserving the ability to expand functionality as requirements evolve.\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：grainulation/grainulation\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：能力坑 - 能力判断依赖假设。\n\n## 1. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1184031176 | https://github.com/grainulation/grainulation | README/documentation is current enough for a first validation pass.\n\n## 2. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | last_activity_observed missing\n\n## 3. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 4. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 来源证据：v1.1.0 — Security Hardening\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.1.0 — Security Hardening\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_5e8c2578dd024d369fd769a7c23df98a | https://github.com/grainulation/grainulation/releases/tag/v1.1.0 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | release_recency=unknown\n\n<!-- canonical_name: grainulation/grainulation; human_manual_source: deepwiki_human_wiki -->\n",
      "markdown_key": "grainulation",
      "pages": "draft",
      "source_refs": [
        {
          "evidence_id": "github_repo:1184031176",
          "kind": "repo",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/grainulation/grainulation"
        },
        {
          "evidence_id": "art_9e0ca4ebbac3479db86c749ef6b030c7",
          "kind": "docs",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/grainulation/grainulation#readme"
        }
      ],
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "grainulation 说明书",
      "toc": [
        "https://github.com/grainulation/grainulation 项目说明书",
        "目录",
        "Project Overview",
        "Purpose and Scope",
        "Architecture",
        "The Eight Tools",
        "Claims System",
        "Research Workflow",
        "Doramagic 踩坑日志"
      ]
    }
  },
  "quality_gate": {
    "blocking_gaps": [],
    "category_confidence": "medium",
    "compile_status": "ready_for_review",
    "five_assets_present": true,
    "install_sandbox_verified": true,
    "missing_evidence": [],
    "next_action": "publish to Doramagic.ai project surfaces",
    "prompt_preview_boundary_ok": true,
    "publish_status": "publishable",
    "quick_start_verified": true,
    "repo_clone_verified": true,
    "repo_commit": "e8d7f0310a86218851c9c3903eb8afbf3e6fa458",
    "repo_inspection_error": null,
    "repo_inspection_files": [
      "pnpm-lock.yaml",
      "package.json",
      "README.md",
      "docs/ecosystem.md"
    ],
    "repo_inspection_verified": true,
    "review_reasons": [
      "community_discussion_evidence_below_public_threshold"
    ],
    "tag_count_ok": true,
    "unsupported_claims": []
  },
  "schema_version": "0.1",
  "user_assets": {
    "ai_context_pack": {
      "asset_id": "ai_context_pack",
      "filename": "AI_CONTEXT_PACK.md",
      "markdown": "# @grainulation/grainulation - Doramagic AI Context Pack\n\n> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。\n\n## 充分原则\n\n- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。\n- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。\n\n## 给宿主 AI 的使用方式\n\n你正在读取 Doramagic 为 @grainulation/grainulation 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。\n\n## Claim 消费规则\n\n- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。\n- **事实最低状态**：`supported`\n- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。\n- `weak`：只能作为低置信度线索，必须要求用户继续核实。\n- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。\n- `unverified`：不得作为事实使用，应明确说证据不足。\n- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。\n\n## 它最适合谁\n\n- **想在安装前理解开源项目价值和边界的用户**：当前证据主要来自项目文档。 证据：`README.md` Claim：`clm_0002` supported 0.86\n\n## 它能做什么\n\n- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0001` supported 0.86\n\n## 怎么开始\n\n- `npm install -g @grainulation/grainulation` 证据：`README.md` Claim：`clm_0003` supported 0.86\n- `npx @grainulation/wheat init` 证据：`README.md` Claim：`clm_0004` supported 0.86\n\n## 继续前判断卡\n\n- **当前建议**：先做研究框架试用\n- **为什么**：这个项目面向研究工作流，核心风险是资料可信度和输出质量；先用 Prompt Preview 验证研究框架，再在隔离环境试装。\n\n### 30 秒判断\n\n- **现在怎么做**：先做研究框架试用\n- **最小安全下一步**：先用 Prompt Preview 验证研究框架；满意后再隔离试装\n- **先别相信**：研究结论、引用和实验结果不能在安装前相信。\n- **继续会触碰**：研究判断、命令执行、本地环境或项目文件\n\n### 现在可以相信\n\n- **适合人群线索：想在安装前理解开源项目价值和边界的用户**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86\n- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86\n- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0003` supported 0.86\n\n### 现在还不能相信\n\n- **研究结论、引用和实验结果不能在安装前相信。**（unverified）：研究 Skill 可以组织问题和路径，但不能替代真实资料检索、论文核验和实验复现。\n- **是否适合你的具体研究领域不能直接相信。**（unverified）：Skill 覆盖很多研究主题，不代表对你的领域、资料要求和可信度标准足够。\n- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。\n- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。\n- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。\n- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。\n- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。\n- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。\n\n### 继续会触碰什么\n\n- **研究判断**：问题拆解、资料路径、实验路径、结论结构和可信度判断。 原因：研究型 Skill 可能让输出看起来更专业，但不能替代真实证据核验。\n- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`\n- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`\n- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。\n\n### 最小安全下一步\n\n- **先跑 Prompt Preview**：先验证它能否正确界定研究问题和证据边界，不要先相信研究输出。（适用：任何项目都适用，尤其是输出质量未知时。）\n- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）\n- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）\n\n### 退出方式\n\n- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。\n- **保留资料和结论核验清单**：如果后续发现引用或实验路径不可靠，可以回到证据边界阶段重新校验。\n- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。\n- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。\n\n## 哪些只能预览\n\n- 解释项目适合谁和能做什么\n- 基于项目文档演示典型对话流程\n- 帮助用户判断是否值得安装或继续研究\n\n## 哪些必须安装后验证\n\n- 真实安装 Skill、插件或 CLI\n- 执行脚本、修改本地文件或访问外部服务\n- 验证真实输出质量、性能和兼容性\n\n## 边界与风险判断卡\n\n- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0005` inferred 0.45\n- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0006` supported 0.86\n- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。\n- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。\n- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。\n\n## 开工前工作上下文\n\n### 加载顺序\n\n- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。\n- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。\n- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。\n- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。\n- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。\n\n### 任务路由\n\n- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86\n\n### 上下文规模\n\n- 文件总数：41\n- 重要文件覆盖：38/41\n- 证据索引条目：37\n- 角色 / Skill 条目：7\n\n### 证据不足时的处理\n\n- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。\n- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。\n- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。\n- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。\n\n## Prompt Recipes\n\n### 适配判断\n\n- 目标：判断这个项目是否适合用户当前任务。\n- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。\n\n```text\n请基于 @grainulation/grainulation 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。\n```\n\n### 安装前体验\n\n- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。\n- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。\n\n```text\n请把 @grainulation/grainulation 当作安装前体验资产，而不是已安装工具或真实运行环境。\n\n请严格输出四段：\n1. 先问我 3 个必要问题。\n2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。\n3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。\n4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。\n\n硬性边界：\n- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。\n- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。\n- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。\n- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。\n- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。\n- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。\n\n```\n\n### 角色 / Skill 选择\n\n- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。\n- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。\n\n```text\n请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。\n```\n\n### 风险预检\n\n- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。\n- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。\n\n```text\n请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。\n```\n\n### 宿主 AI 开工指令\n\n- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。\n- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。\n\n```text\n请基于 @grainulation/grainulation 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。\n```\n\n\n## 角色 / Skill 索引\n\n- 共索引 7 个角色 / Skill / 项目文档条目。\n\n- **Install**（project_doc）：Structured research for decisions that satisfice. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`\n- **Contributing to Grainulation**（project_doc）：Thanks for considering contributing. Grainulation is the meta-package and ecosystem router -- it orchestrates all grainulation tools and provides the unified CLI entry point. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CONTRIBUTING.md`\n- **Grainulation Ecosystem Reference**（project_doc）：The grainulation CLI is the unified entry point for all eight tools in the ecosystem. Each tool has its own npm package and can be used standalone, but the grainulation package connects them into an integrated workflow. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/ecosystem.md`\n- **Changelog**（project_doc）：- Added SECURITY.md and CODE OF CONDUCT.md - Production polish: publishConfig , .env and .idea ignored 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CHANGELOG.md`\n- **Code of Conduct**（project_doc）：We are committed to providing a welcoming and productive environment for everyone. We expect participants to: 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CODE_OF_CONDUCT.md`\n- **Release playbook**（project_doc）：This file lives in the grainulation umbrella repo but covers the whole 8-package ecosystem wheat , farmer , barn , mill , silo , harvest , orchard , grainulation plus the grainulator plugin. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`RELEASE.md`\n- **Security Policy**（project_doc）：Only the latest published minor version of each package receives security fixes. Older versions may be patched at maintainer discretion. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`SECURITY.md`\n\n## 证据索引\n\n- 共索引 37 条证据。\n\n- **Install**（documentation）：Structured research for decisions that satisfice. 证据：`README.md`\n- **Package**（package_manifest）：{ \"name\": \"@grainulation/grainulation\", \"version\": \"1.1.3\", \"description\": \"Structured research for decisions that satisfice\", \"license\": \"MIT\", \"bin\": { \"grainulation\": \"bin/grainulation.js\" }, \"main\": \"./lib/ecosystem.js\", \"exports\": { \".\": \"./lib/ecosystem.js\", \"./pm\": \"./lib/pm.js\", \"./doctor\": \"./lib/doctor.js\", \"./router\": \"./lib/router.js\" }, \"files\": \"bin/\", \"lib/\", \"public/\", \"site/\", \"CHANGELOG.md\", \"LICENSE\", \"CODE OF CONDUCT.md\", \"CONTRIBUTING.md\", \"SECURITY.md\", \"README.md\" , \"type\": \"commonjs\", \"scripts\": { \"test\": \"node test/basic.test.js && node --test test/tarball.test.mjs\", \"lint\": \"npx @biomejs/biome@2.4.8 ci .\", \"format\": \"npx @biomejs/biome@2.4.8 check --write .\", \"star… 证据：`package.json`\n- **Contributing to Grainulation**（documentation）：Thanks for considering contributing. Grainulation is the meta-package and ecosystem router -- it orchestrates all grainulation tools and provides the unified CLI entry point. 证据：`CONTRIBUTING.md`\n- **License**（source_file）：Copyright c 2026 grainulation contributors 证据：`LICENSE`\n- **Grainulation Ecosystem Reference**（documentation）：The grainulation CLI is the unified entry point for all eight tools in the ecosystem. Each tool has its own npm package and can be used standalone, but the grainulation package connects them into an integrated workflow. 证据：`docs/ecosystem.md`\n- **Changelog**（documentation）：- Added SECURITY.md and CODE OF CONDUCT.md - Production polish: publishConfig , .env and .idea ignored 证据：`CHANGELOG.md`\n- **Code of Conduct**（documentation）：We are committed to providing a welcoming and productive environment for everyone. We expect participants to: 证据：`CODE_OF_CONDUCT.md`\n- **Release playbook**（documentation）：This file lives in the grainulation umbrella repo but covers the whole 8-package ecosystem wheat , farmer , barn , mill , silo , harvest , orchard , grainulation plus the grainulator plugin. 证据：`RELEASE.md`\n- **Security Policy**（documentation）：Only the latest published minor version of each package receives security fixes. Older versions may be patched at maintainer discretion. 证据：`SECURITY.md`\n- **Wiki**（structured_config）：{ \"repo notes\": { \"content\": \"grainulation is the umbrella repository and marketing site for the grainulation ecosystem. It is NOT a standalone tool — it is the landing page grainulation.app , the meta-package that lets users discover the individual packages barn, wheat, farmer, mill, silo, harvest, orchard , and the place where cross-cutting docs and demos live. The actual functionality lives in the individual packages.\", \"author\": \"grainulation-core\" }, { \"content\": \"When documenting grainulation, emphasize: 1 it is the ENTRY POINT — start here if you're new, 2 it hosts the interactive demo sprint-mode demo at grainulation.app , 3 each ecosystem package has its own wiki — link out, do not… 证据：`.devin/wiki.json`\n- **Biome**（structured_config）：{ \"$schema\": \"https://biomejs.dev/schemas/2.4.8/schema.json\", \"vcs\": { \"enabled\": true, \"clientKind\": \"git\", \"useIgnoreFile\": true }, \"formatter\": { \"enabled\": true, \"indentStyle\": \"space\", \"indentWidth\": 2, \"lineWidth\": 120 }, \"linter\": { \"enabled\": true, \"rules\": { \"recommended\": true, \"correctness\": { \"noUnusedVariables\": \"warn\", \"noUnusedImports\": \"warn\" } } }, \"javascript\": { \"formatter\": { \"quoteStyle\": \"single\", \"trailingCommas\": \"all\" } }, \"files\": { \"includes\": \" / .js\", \" / .mjs\", \" / .css\", \"!site/grainulation-print.css\", \"!site/grainulation-tokens.css\" } } 证据：`biome.json`\n- **!/bin/sh**（source_file）：Lint with Biome skip if npx is not available, but fail on lint errors if command -v npx /dev/null 2 &1; then npx --no biome check --staged --no-errors-on-unmatched fi 证据：`.githooks/pre-commit`\n- **Claude Code**（source_file）：.farmer-token .farmer-state.json .farmer.pid .farmer-audit .jsonl .farmer-config.json node modules/ coverage/ 证据：`.gitignore`\n- **!/usr/bin/env node**（source_file）：/ grainulation The unified entry point for the grainulation ecosystem. Routes to the right tool based on what you need. Usage: grainulation Show ecosystem overview grainulation doctor Check which tools are installed grainulation setup Interactive setup wizard grainulation serve Start the ecosystem control center grainulation args Delegate to a grainulation tool / 证据：`bin/grainulation.js`\n- **Doctor**（source_file）：const { execFileSync } = require 'node:child process' ; const { existsSync, readFileSync, readdirSync } = require 'node:fs' ; const path = require 'node:path' ; const { getInstallable } = require './ecosystem' ; 证据：`lib/doctor.js`\n- **Ecosystem**（source_file）：/ The grainulation ecosystem registry. Eight tools. Each grows from the same soil: question - evidence - decision. / 证据：`lib/ecosystem.js`\n- **Pm**（source_file）：/ Process Manager — start, stop, and monitor grainulation tools. Each tool runs its own HTTP server on a known port. This module spawns/kills them and probes ports for health. / 证据：`lib/pm.js`\n- **Router**（source_file）：const { execFileSync, spawn } = require 'node:child process' ; const { existsSync, readFileSync } = require 'node:fs' ; const path = require 'node:path' ; const { getByName, getInstallable } = require './ecosystem' ; 证据：`lib/router.js`\n- **!/usr/bin/env node**（source_file）：/ grainulation serve — local HTTP server for the ecosystem control center Tool catalog, doctor health checks, scaffold actions, and cross-tool navigation. SSE for live updates. Zero npm dependencies node:http only . Usage: grainulation serve --port 9098 / 证据：`lib/server.mjs`\n- **Setup**（source_file）：const readline = require 'node:readline' ; const { execFileSync } = require 'node:child process' ; const { getInstallable } = require './ecosystem' ; const { getVersion } = require './doctor' ; 证据：`lib/setup.js`\n- **0a0e1a is universal across all four UIs.**（source_file）：/ grainulation-tokens.css v1.0.0 Shared design tokens for the grainulation ecosystem. Home: barn the design-system tool Usage: Token architecture three layers : 1. Base layer -- backgrounds, foregrounds, borders, spacing, type, radii 2. Semantic layer -- accent maps to tool , status colors, feedback colors 3. Tool scales -- per-tool 5-weight accent ramp 50/200/400/600/800 Reset layer: Box model, scrollbar, font smoothing, shared components Accent activation: Set data-tool=\" \" on to load that tool's accent scale. Default accent no data-tool = barn rose-red. Extracted from working UIs: - barn/public/index.html accent: f43f5e rose — lightened from e11d48 for WCAG AA - wheat/public/index.html a… 证据：`public/grainulation-tokens.css`\n- **Index**（source_file）：Grainulation G \" / ── Tokens inline, zero deps ── / :root { --bg: 0a0e1a; --bg2: 111827; --bg3: 1e293b; --bg4: 334155; --fg: e2e8f0; --fg2: 94a3b8; --fg3: 64748b; --border: 1e293b; --border-subtle: rgba 255,255,255,0.08 ; --green: 34d399; --red: f87171; --blue: 60a5fa; --orange: fb923c; --purple: a78bfa; --cyan: 22d3ee; --accent: 9ca3af; --accent-light: d1d5db; --accent-dim: rgba 156,163,175,0.10 ; --accent-border: rgba 156,163,175,0.25 ; --radius: 8px; --radius-sm: 4px; --radius-lg: 12px; --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif; --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', monospace; --transition-fast: 0.1s ease; --transition-base: 0.15… 证据：`public/index.html`\n- **!/usr/bin/env bash**（source_file）：!/usr/bin/env bash seo-check.sh grainulation variant — Layer 1 regression guard for SEO/AI-visibility site assets. grainulation's site intentionally uses PNG favicons favicon-16.png, favicon-32.png, apple-touch-icon.png rather than the single SVG favicon used by the other 7 grainulation packages. Zero deps Bash + standard Unix . Runs in well under 30s. 证据：`scripts/seo-check.sh`\n- **7100366149211580Be04515B58B6E6D0**（source_file）：7100366149211580be04515b58b6e6d0 证据：`site/7100366149211580be04515b58b6e6d0.txt`\n- **Cname**（source_file）：grainulation.com 证据：`site/CNAME`\n- **Favicon**（source_file）：G 证据：`site/favicon.svg`\n- **Grainulation Print**（source_file）：/ grainulation-print.css v1.0.0 Shared print stylesheet for grainulation ecosystem sites. Home: barn. Vendored into each site via barn sync-assets . Usage in each site's , before : Sites that need local overrides ship a site-specific print-local.css AFTER this one; higher specificity wins. Do NOT fork this file -- contribute upstream to barn instead. Scope: applied only at print-time media=\"print\" . Has no effect on on-screen rendering; safe to ship everywhere. / 证据：`site/grainulation-print.css`\n- **0a0e1a is universal across all four UIs.**（source_file）：/ grainulation-tokens.css v0.1.0 Shared design tokens for the grainulation ecosystem. Home: barn the design-system tool Usage: Token architecture three layers : 1. Base layer -- backgrounds, foregrounds, borders, spacing, type, radii 2. Semantic layer -- accent maps to tool , status colors, feedback colors 3. Tool scales -- per-tool 5-weight accent ramp 50/200/400/600/800 Reset layer: Box model, scrollbar, font smoothing, shared components Accent activation: Set data-tool=\" \" on to load that tool's accent scale. Default accent no data-tool = barn rose-red. Extracted from working UIs: - barn/public/index.html accent: f43f5e rose — lightened from e11d48 for WCAG AA - wheat/public/index.html a… 证据：`site/grainulation-tokens.css`\n- **Index**（source_file）：Grainulation — Evidence-Based Technical Decision Tools :root { --bg: 0a0e1a; --bg-2: 111827; --surface: rgba 255,255,255,0.03 ; --surface-hover: rgba 255,255,255,0.06 ; --border: rgba 255,255,255,0.07 ; --border-light: rgba 255,255,255,0.12 ; --accent: 9ca3af; --accent-dim: rgba 156,163,175,0.12 ; --accent-glow: rgba 156,163,175,0.06 ; --green: 34d399; --green-dim: rgba 52,211,153,0.1 ; --red: f87171; --silver: 9ca3af; --blue: 60a5fa; --blue-dim: rgba 96,165,250,0.1 ; --orange: f59e0b; --pink: ec4899; --text: e8ecf1; --text-2: 9ba5b7; --text-3: 8b95a5; --mono: 'SF Mono','Fira Code','Cascadia Code','Consolas',monospace; --sans: -apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif… 证据：`site/index.html`\n- **Grainulation umbrella**（source_file）：Umbrella site for the grainulation ecosystem — research sprints, claim compilation, evidence-graded decisions. 证据：`site/llms.txt`\n- **Og Image**（source_file）：G rainulation Structured research for decisions that matter grainulation 证据：`site/og-image.svg`\n- **Robots**（source_file）：Sitemap: https://grainulation.com/sitemap.xml 证据：`site/robots.txt`\n- **Sitemap**（source_file）：https://grainulation.com/ 2026-04-19 weekly 1.0 证据：`site/sitemap.xml`\n- **Status Icons**（source_file）：<!-- status-icons.svg — SVG sprite for triple-encoded status indicators WCAG 1.4.1 Each status has a distinctive shape so meaning is independent of color perception: success = checkmark circle with check error = cross circle with X warning = triangle with exclamation info = circle with \"i\" 证据：`site/status-icons.svg`\n- **Wordmark**（source_file）：G rainulation 证据：`site/wordmark.svg`\n- **Basic.Test**（source_file）：const assert = require 'node:assert/strict' ; const { execSync } = require 'node:child process' ; const path = require 'node:path' ; 证据：`test/basic.test.js`\n- **Tarball.Test**（source_file）：// test/tarball.test.mjs — verify the published npm tarball contains everything // grainulation serve / grainulation CLI need at runtime. // Prevents the drift class that caused wheat 1.0.1–1.1.7 and harvest/orchard // 1.1.4 dashboard 404s files referenced at runtime but not in package.json files . // // .mjs because the package is type: commonjs but the wheat harness we mirror // is ESM; isolating as .mjs keeps the harness byte-identical to wheat 1.1.8. 证据：`test/tarball.test.mjs`\n\n## 宿主 AI 必须遵守的规则\n\n- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`README.md`, `package.json`, `CONTRIBUTING.md`\n- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`README.md`, `package.json`, `CONTRIBUTING.md`\n\n## 用户开工前应该回答的问题\n\n- 你准备在哪个宿主 AI 或本地环境中使用它？\n- 你只是想先体验工作流，还是准备真实安装？\n- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？\n\n## 验收标准\n\n- 所有能力声明都能回指到 evidence_refs 中的文件路径。\n- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。\n- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。\n\n---\n\n## Doramagic Context Augmentation\n\n下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。\n\n## Human Manual 骨架\n\n使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。\n\n宿主 AI 硬性规则：\n- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。\n- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。\n- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。\n\n- **Project Overview**：importance `high`\n  - source_paths: README.md, package.json, docs/ecosystem.md\n- **CLI Architecture**：importance `high`\n  - source_paths: bin/grainulation.js, lib/router.js, lib/server.mjs\n- **Command Reference**：importance `high`\n  - source_paths: bin/grainulation.js, lib/ecosystem.js, lib/doctor.js, lib/setup.js\n- **Ecosystem Overview**：importance `high`\n  - source_paths: lib/ecosystem.js, docs/ecosystem.md\n- **Tool Integration**：importance `medium`\n  - source_paths: lib/router.js, lib/pm.js\n- **Setup and Installation**：importance `high`\n  - source_paths: lib/setup.js, package.json\n- **Health Checks and Diagnostics**：importance `medium`\n  - source_paths: lib/doctor.js\n- **Package Management**：importance `medium`\n  - source_paths: lib/pm.js, package.json, pnpm-lock.yaml\n\n## Repo Inspection Evidence / 源码检查证据\n\n- repo_clone_verified: true\n- repo_inspection_verified: true\n- repo_commit: `e8d7f0310a86218851c9c3903eb8afbf3e6fa458`\n- inspected_files: `pnpm-lock.yaml`, `package.json`, `README.md`, `docs/ecosystem.md`\n\n宿主 AI 硬性规则：\n- 没有 repo_clone_verified=true 时，不得声称已经读过源码。\n- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。\n- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。\n\n## Doramagic Pitfall Constraints / 踩坑约束\n\n这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。\n\n### Constraint 1: 能力判断依赖假设\n\n- Trigger: README/documentation is current enough for a first validation pass.\n- Host AI rule: 将假设转成下游验证清单。\n- Why it matters: 假设不成立时，用户拿不到承诺的能力。\n- Evidence: capability.assumptions | github_repo:1184031176 | https://github.com/grainulation/grainulation | README/documentation is current enough for a first validation pass.\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 2: 维护活跃度未知\n\n- Trigger: 未记录 last_activity_observed。\n- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。\n- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- Evidence: evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | last_activity_observed missing\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 3: 下游验证发现风险项\n\n- Trigger: no_demo\n- Host AI rule: 进入安全/权限治理复核队列。\n- Why it matters: 下游已经要求复核，不能在页面中弱化。\n- Evidence: downstream_validation.risk_items | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 4: 存在评分风险\n\n- Trigger: no_demo\n- Host AI rule: 把风险写入边界卡，并确认是否需要人工复核。\n- Why it matters: 风险会影响是否适合普通用户安装。\n- Evidence: risks.scoring_risks | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 5: 来源证据：v1.1.0 — Security Hardening\n\n- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.1.0 — Security Hardening\n- Host AI rule: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- Why it matters: 可能增加新用户试用和生产接入成本。\n- Evidence: community_evidence:github | cevd_5e8c2578dd024d369fd769a7c23df98a | https://github.com/grainulation/grainulation/releases/tag/v1.1.0 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 6: issue/PR 响应质量未知\n\n- Trigger: issue_or_pr_quality=unknown。\n- Host AI rule: 抽样最近 issue/PR，判断是否长期无人处理。\n- Why it matters: 用户无法判断遇到问题后是否有人维护。\n- Evidence: evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | issue_or_pr_quality=unknown\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 7: 发布节奏不明确\n\n- Trigger: release_recency=unknown。\n- Host AI rule: 确认最近 release/tag 和 README 安装命令是否一致。\n- Why it matters: 安装命令和文档可能落后于代码，用户踩坑概率升高。\n- Evidence: evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | release_recency=unknown\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n",
      "summary": "给宿主 AI 的上下文和工作边界。",
      "title": "AI Context Pack / 带给我的 AI"
    },
    "boundary_risk_card": {
      "asset_id": "boundary_risk_card",
      "filename": "BOUNDARY_RISK_CARD.md",
      "markdown": "# Boundary & Risk Card / 安装前决策卡\n\n项目：grainulation/grainulation\n\n## Doramagic 试用结论\n\n当前结论：可以进入发布前推荐检查；首次使用仍应从最小权限、临时目录和可回滚配置开始。\n\n## 用户现在可以做\n\n- 可以先阅读 Human Manual，理解项目目的和主要工作流。\n- 可以复制 Prompt Preview 做安装前体验；这只验证交互感，不代表真实运行。\n- 可以把官方 Quick Start 命令放到隔离环境中验证，不要直接进主力环境。\n\n## 现在不要做\n\n- 不要把 Prompt Preview 当成项目实际运行结果。\n- 不要把 metadata-only validation 当成沙箱安装验证。\n- 不要把未验证能力写成“已支持、已跑通、可放心安装”。\n- 不要在首次试用时交出生产数据、私人文件、真实密钥或主力配置目录。\n\n## 安装前检查\n\n- 宿主 AI 是否匹配：mcp_host\n- 官方安装入口状态：已发现官方入口\n- 是否在临时目录、临时宿主或容器中验证：必须是\n- 是否能回滚配置改动：必须能\n- 是否需要 API Key、网络访问、读写文件或修改宿主配置：未确认前按高风险处理\n- 是否记录了安装命令、实际输出和失败日志：必须记录\n\n## 当前阻塞项\n\n- review_required: community_discussion_evidence_below_public_threshold\n\n## 项目专属踩坑\n\n- 能力判断依赖假设（medium）：假设不成立时，用户拿不到承诺的能力。 建议检查：将假设转成下游验证清单。\n- 维护活跃度未知（medium）：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 下游验证发现风险项（medium）：下游已经要求复核，不能在页面中弱化。 建议检查：进入安全/权限治理复核队列。\n- 存在评分风险（medium）：风险会影响是否适合普通用户安装。 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 来源证据：v1.1.0 — Security Hardening（medium）：可能增加新用户试用和生产接入成本。 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n\n## 风险与权限提示\n\n- no_demo: medium\n\n## 证据缺口\n\n- 暂未发现结构化证据缺口。\n",
      "summary": "安装、权限、验证和推荐前风险。",
      "title": "Boundary & Risk Card / 边界与风险卡"
    },
    "human_manual": {
      "asset_id": "human_manual",
      "filename": "HUMAN_MANUAL.md",
      "markdown": "# https://github.com/grainulation/grainulation 项目说明书\n\n生成时间：2026-05-15 12:02:35 UTC\n\n## 目录\n\n- [Project Overview](#project-overview)\n- [CLI Architecture](#cli-architecture)\n- [Command Reference](#command-reference)\n- [Ecosystem Overview](#ecosystem-overview)\n- [Tool Integration](#tool-integration)\n- [Setup and Installation](#setup-installation)\n- [Health Checks and Diagnostics](#health-checks)\n- [Package Management](#package-management)\n- [Server and Routing](#server-routing)\n- [Extensibility Guide](#extensibility-guide)\n\n<a id='project-overview'></a>\n\n## Project Overview\n\n### 相关页面\n\n相关主题：[Ecosystem Overview](#ecosystem-overview), [CLI Architecture](#cli-architecture)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n</details>\n\n# Project Overview\n\nGrainulation is an ecosystem of eight zero-dependency CLI tools that transform technical decision-making from gut-feel opinions into structured, evidence-based claims. The system enables teams to research questions, challenge findings, and compile decisions into auditable briefs backed by a full git history.\n\n## Purpose and Scope\n\nMost technical decisions fail not due to lack of data, but lack of process for converting data into evidence and evidence into conviction. Grainulation provides that missing process through a claims-based research framework.\n\nThe ecosystem serves teams who need to make consequential technical decisions—such as architecture migrations, technology choices, or infrastructure changes—and want defensible, auditable reasoning behind those choices.\n\n**Core objectives:**\n\n- Turn vague technical questions into typed, evidence-graded claims\n- Provide adversarial testing through a challenge mechanism\n- Catch contradictions and weak evidence via a deterministic compiler\n- Produce decision briefs with full git audit trails 资料来源：[README.md:18]()\n\n## Architecture\n\nThe grainulation project follows a monorepo structure with eight independent packages plus the meta-package that orchestrates them.\n\n```mermaid\ngraph TD\n    subgraph \"Meta Package\"\n        G[grainulation<br/>Unified CLI]\n    end\n    \n    subgraph \"Core Tools\"\n        W[wheat<br/>Research Engine]\n        F[farmer<br/>Permission Dashboard]\n        B[barn<br/>Tool Registry]\n        M[mill<br/>Export Engine]\n    end\n    \n    subgraph \"Analysis Tools\"\n        S[silo<br/>Claim Explorer]\n        H[harvest<br/>Analytics]\n        O[orchard<br/>Sprint Manager]\n    end\n    \n    G --> W\n    G --> F\n    G --> B\n    G --> M\n    G --> S\n    G --> H\n    G --> O\n    \n    W --> B\n    M --> S\n    H --> S\n```\n\n### Meta Package Structure\n\n| Path | Purpose |\n|------|---------|\n| `bin/grainulation.js` | CLI entrypoint — routes to individual tools |\n| `lib/router.js` | Command routing to the correct tool package |\n| `lib/ecosystem.js` | Ecosystem health checks and tool discovery |\n| `lib/doctor.js` | Diagnostic tool — validates tool installations |\n| `lib/setup.js` | First-run setup and configuration |\n| `lib/pm.js` | Package management for grainulation tools |\n| `lib/server.mjs` | Local server — unified ecosystem dashboard (ESM) |\n| `public/` | Web UI — ecosystem overview and status |\n| `site/` | Public website (grainulation.com) |\n\n资料来源：[CONTRIBUTING.md:25-36]()\n\n## The Eight Tools\n\n| Tool | Purpose | Install Command |\n|------|---------|-----------------|\n| **wheat** | Research engine. Grow structured evidence. | `npx @grainulation/wheat init` |\n| **farmer** | Permission dashboard. Approve AI agent tool calls. | `npx @grainulation/farmer start` |\n| **barn** | Tool registry. Curated, versioned, approved. | `npx @grainulation/barn status` |\n| **mill** | Export engine. Turn compiled research into PDFs, CSVs, static sites. | `npx @grainulation/mill export --format pdf` |\n| **silo** | Claim explorer. Navigate and filter claims across sprints. | `npx @grainulation/silo explore` |\n| **harvest** | Analytics. Track prediction accuracy, find systemic blind spots. | `npx @grainulation/harvest analyze ./sprints/` |\n| **orchard** | Sprint manager. Coordinate team research across sprints. | `npx @grainulation/orchard status` |\n| **grainulation** | Unified CLI. Routes to the right tool, checks ecosystem health. | `npx @grainulation/grainulation` |\n\n资料来源：[site/index.html:1-60]()\n\n## Claims System\n\nEverything in grainulation starts with a **claim** — a single typed statement with an evidence grade.\n\n### Claim Types\n\n| Type | Description |\n|------|-------------|\n| `factual` | Verifiable fact with supporting evidence |\n| `risk` | Potential problem or threat |\n| `estimate` | Quantified prediction with uncertainty |\n| `constraint` | Hard limitation or requirement |\n| `recommendation` | Suggested course of action |\n\n### Evidence Tiers\n\nEvidence tiers range from \"someone said it\" to \"measured in production,\" providing a spectrum of confidence in claims.\n\nThe compiler validates claims, catching contradictions, flagging weak evidence, and blocking output until issues are resolved. This compiler is JavaScript code, not an LLM call — same claims in, same result out every time. 资料来源：[site/index.html:75-95]()\n\n## Research Workflow\n\nThe typical workflow follows three phases:\n\n```mermaid\ngraph LR\n    A[Init Sprint<br/>wheat init] --> B[Research<br/>Gather evidence]\n    B --> C[Challenge<br/>Stress-test claims]\n    C --> D[Compile<br/>Resolve conflicts]\n    D --> E[Decision Brief<br/>Ship with audit trail]\n```\n\n### Phase 1: Initialize\n\n```bash\nnpx @grainulation/wheat init\n```\n\nCreates a claims file and config:\n\n- `claims.json` — stores all claims (0 claims initially)\n- `wheat.config.json` — sprint configuration\n\n### Phase 2: Research and Challenge\n\n- `/research \"topic\"` — Gather evidence and create claims\n- `/challenge r001` — Stress-test existing claims, finding risks and contradictions\n\nExample output:\n\n```\nr001 [factual|documented] ...\nx001 [risk|documented] ...\n```\n\n### Phase 3: Compile and Ship\n\n```bash\nwheat> /brief\n```\n\nThe compiler resolves conflicts, checks evidence, and produces a decision brief:\n\n```\nCompiled 12 claims (2 conflicts resolved)\nWritten: output/brief.html\n```\n\n资料来源：[site/index.html:55-90]()\n\n## Design Principles\n\nFour principles underpin the entire ecosystem:\n\n### 1. Evidence Over Authority\n\nGrainulation does not care who made a claim — it cares about the evidence behind it. The system validates claims based on supporting documentation, not seniority.\n\n### 2. Confrontation by Default\n\nConsensus is the enemy of good decisions. The system forces you to challenge, witness, and stress-test every claim through the adversarial challenge mechanism.\n\n### 3. Zero Dependencies\n\nNode.js built-ins only. Zero npm dependencies across all eight packages. No supply chain anxiety. No left-pad incidents. No API keys for the core tools. Every tool ships what it needs and nothing more. 资料来源：[CONTRIBUTING.md:8-10]()\n\n### 4. Local-First\n\nEverything runs locally. Everything is plain JSON and HTML. No cloud services required for core functionality.\n\n## Requirements\n\nTo use grainulation, you need:\n\n- **Claude Code** — for AI-assisted research and challenge\n- **Node.js 20+** — runtime environment\n- **npx** — package executor\n\nNo accounts, no cloud services, no API keys for the core tools. 资料来源：[site/index.html:95-100]()\n\n## Comparison with Traditional Methods\n\n| Aspect | RFC/ADR | ChatGPT | Grainulation |\n|--------|---------|---------|--------------|\n| Timing | Post-decision documentation | Instant but unvalidated | Pre-decision research |\n| Evidence | Often absent | Cannot verify | Typed and graded |\n| Challenge | Optional review | No mechanism | Built-in adversarial testing |\n| Reproducibility | Varies | Non-deterministic | Deterministic compiler |\n| Audit trail | Manual | None | Git-tracked claims history |\n\nRFCs and ADRs document a decision after it is made. Grainulation captures the research process — evidence gathering, adversarial testing, and conflict resolution — and validates it through a compiler. The output brief can serve as your ADR, with a full git audit trail showing how every claim was collected, challenged, and resolved. 资料来源：[site/index.html:130-145]()\n\n## Release Process\n\nPackages publish via GitHub Actions workflows on tag push. The workflow runs tests, verifies the tag matches `package.json.version`, and publishes with npm provenance via OIDC trusted publishing.\n\nFor coordinated releases where a consumer depends on new internal-dep features:\n\n1. Publish the dependency package first (e.g., `barn`)\n2. Wait for the package to appear on npm (~60s)\n3. Run `npm install` in consumer repos to regenerate `package-lock.json`\n4. Bump consumer versions and push tags\n\n资料来源：[RELEASE.md:1-35]()\n\n## Getting Started\n\nInstall the meta-package globally:\n\n```bash\nnpm install -g @grainulation/grainulation\n```\n\nOr start a research sprint directly:\n\n```bash\nnpx @grainulation/wheat init\n```\n\nUseful commands:\n\n| Command | Description |\n|---------|-------------|\n| `grainulation` | Ecosystem overview |\n| `grainulation doctor` | Health check: which tools, which versions |\n| `grainulation setup` | Install the right tools for your role |\n| `grainulation wheat init` | Delegate to any tool |\n| `grainulation farmer start` | Start permission dashboard |\n\n资料来源：[README.md:30-45]()\n\n---\n\n<a id='cli-architecture'></a>\n\n## CLI Architecture\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Tool Integration](#tool-integration), [Server and Routing](#server-routing)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/server.mjs](https://github.com/grainulation/grainulation/blob/main/lib/server.mjs)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js)\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n</details>\n\n# CLI Architecture\n\n## Overview\n\nThe Grainulation CLI is the unified entry point for the entire ecosystem of eight zero-dependency CLI tools. It serves as a meta-package and ecosystem router that orchestrates all grainulation tools through a single command interface. The CLI has zero npm dependencies and relies exclusively on Node.js built-in modules, running entirely locally without cloud services or API keys.\n\nThe architectural philosophy follows a modular pattern where the main CLI delegates to specialized modules responsible for routing, ecosystem health, diagnostics, configuration, and package management. This separation of concerns allows each component to be focused and testable while maintaining a cohesive user experience.\n\n## Architecture Components\n\nThe CLI system consists of several interconnected modules that work together to provide a seamless interface for tool discovery, command routing, and ecosystem management.\n\n| Component | File | Responsibility |\n|-----------|------|----------------|\n| CLI Entrypoint | `bin/grainulation.js` | Main entry point, argument parsing, command dispatch |\n| Router | `lib/router.js` | Routes commands to correct tool packages |\n| Ecosystem | `lib/ecosystem.js` | Health checks and tool discovery |\n| Doctor | `lib/doctor.js` | Diagnostic validation for tool installations |\n| Setup | `lib/setup.js` | First-run setup and configuration |\n| Package Manager | `lib/pm.js` | Package management for grainulation tools |\n| Server | `lib/server.mjs` | Local dashboard server (ESM module) |\n\n## Entry Point\n\nThe CLI entry point at `bin/grainulation.js` serves as the main entry point for the unified command-line interface. It handles initial argument parsing and dispatches commands to the appropriate handlers. Users interact with the system by running `node bin/grainulation.js --help` or directly invoking the CLI.\n\nThe entry point is designed to have zero external dependencies, leveraging only Node.js built-in modules such as `fs`, `path`, and `process`. This ensures maximum portability and minimal attack surface.\n\n## Command Routing\n\nThe router module (`lib/router.js`) is responsible for directing incoming commands to the correct tool package within the ecosystem. When a user invokes a command, the router analyzes the arguments and determines which tool should handle the request.\n\nThe routing mechanism supports multiple tool packages in the ecosystem:\n\n- **wheat** - Research and claims management\n- **farmer** - Permission dashboard\n- **barn** - Shared utilities and sprint detection\n- **mill** - Export and publishing\n- **silo** - Data management\n- **harvest** - Analytics and cross-sprint learning\n- **orchard** - Package management and status\n\n```mermaid\ngraph TD\n    A[User Input] --> B[bin/grainulation.js]\n    B --> C[lib/router.js]\n    C --> D{Command Type}\n    D -->|Tool Command| E[wheat]\n    D -->|Tool Command| F[farmer]\n    D -->|Tool Command| G[barn]\n    D -->|Tool Command| H[mill]\n    D -->|Tool Command| I[silo]\n    D -->|Tool Command| J[harvest]\n    D -->|Tool Command| K[orchard]\n    D -->|Meta Command| L[lib/ecosystem.js]\n    D -->|Diagnostic| M[lib/doctor.js]\n```\n\nThe router maintains awareness of available tools and their capabilities, enabling dynamic command resolution based on what tools are currently installed in the ecosystem.\n\n## Ecosystem Management\n\n### Health Checks and Tool Discovery\n\nThe ecosystem module (`lib/ecosystem.js`) provides two critical functions: health checks and tool discovery. Health checks verify that all installed tools are functioning correctly and meet minimum version requirements. Tool discovery scans the ecosystem to identify all installed grainulation packages and their current states.\n\nWhen invoked, the ecosystem module performs a comprehensive scan of installed tools, checking:\n\n- Package installation status\n- Version compatibility\n- Dependency integrity\n- Configuration validity\n\n### Diagnostic Validation\n\nThe doctor module (`lib/doctor.js`) acts as a diagnostic tool that validates tool installations across the ecosystem. It performs thorough checks to ensure each tool is properly installed and configured, identifying issues that might prevent tools from functioning correctly.\n\nThe diagnostic process includes validation of:\n\n- File system permissions\n- Configuration file integrity\n- Required Node.js modules availability\n- Inter-tool communication channels\n\n## Configuration and Setup\n\n### First-Run Setup\n\nThe setup module (`lib/setup.js`) handles first-run initialization for new users. When a user runs the CLI for the first time, setup creates necessary configuration files and establishes the directory structure required for the ecosystem to function properly.\n\nSetup operations include:\n\n- Creating configuration directories\n- Generating default configuration files\n- Initializing tool registry\n- Establishing user preferences\n\n### Package Management\n\nThe package manager module (`lib/pm.js`) provides package management functionality for grainulation tools. It handles installation, updates, and removal of tools within the ecosystem, ensuring consistent package states across the development environment.\n\n## Local Dashboard Server\n\nThe server module (`lib/server.mjs`) provides a local web dashboard for ecosystem management. Implemented as an ESM module, it serves a unified ecosystem dashboard that displays:\n\n- Tool status overview\n- Installation health\n- Configuration management interface\n- Real-time ecosystem metrics\n\nThe dashboard is accessible locally and provides a visual interface for monitoring and managing the grainulation ecosystem without requiring a web browser connection to external services.\n\n## Data Flow\n\nThe following diagram illustrates the complete data flow from user input through command processing to output generation:\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Ecosystem as lib/ecosystem.js\n    participant Doctor as lib/doctor.js\n    participant PM as lib/pm.js\n    participant Tool as Individual Tool\n\n    User->>CLI: Execute command\n    CLI->>CLI: Parse arguments\n    CLI->>Router: Route request\n    Router->>Router: Identify target tool/command\n    \n    alt Meta Command\n        Router->>Ecosystem: Check ecosystem health\n        Ecosystem-->>User: Status report\n    end\n    \n    alt Diagnostic Command\n        Router->>Doctor: Run diagnostics\n        Doctor-->>User: Diagnostic report\n    end\n    \n    alt Package Management\n        Router->>PM: Handle package operation\n        PM-->>User: Operation result\n    end\n    \n    alt Tool Command\n        Router->>Tool: Delegate to tool\n        Tool-->>User: Tool output\n    end\n```\n\n## Command Categories\n\nThe CLI supports four primary command categories:\n\n| Category | Handler | Purpose |\n|----------|---------|---------|\n| Tool Commands | Individual packages | Execute tool-specific operations |\n| Meta Commands | Built-in modules | Ecosystem-level operations |\n| Diagnostic Commands | `lib/doctor.js` | Validate installations |\n| Management Commands | `lib/pm.js` | Install, update, remove packages |\n\n## Quick Start\n\nUsers can get started with the grainulation CLI by cloning the repository and running the help command:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\nNo `npm install` step is required since the CLI has zero dependencies and relies solely on Node.js built-in modules.\n\n## Architecture Principles\n\nThe CLI architecture adheres to several key principles that guide its design and implementation:\n\n**Zero Dependencies** - Every module uses only Node.js built-in modules, eliminating supply chain vulnerabilities and ensuring the CLI works immediately after cloning without any installation steps.\n\n**Modular Routing** - Commands are routed through a centralized router that delegates to specialized modules, maintaining clear separation of concerns.\n\n**Local-First** - All operations run locally without requiring network connectivity or external services, ensuring data privacy and offline capability.\n\n**Tool Discovery** - The ecosystem module dynamically discovers available tools, allowing the CLI to adapt to different tool configurations without hardcoding.\n\n**Diagnostic Visibility** - Built-in diagnostic tools help users identify and resolve issues without external debugging tools.\n\n---\n\n<a id='command-reference'></a>\n\n## Command Reference\n\n### 相关页面\n\n相关主题：[Health Checks and Diagnostics](#health-checks), [Setup and Installation](#setup-installation), [Ecosystem Overview](#ecosystem-overview)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n</details>\n\n# Command Reference\n\nThis page documents the command-line interface (CLI) for the Grainulation ecosystem, covering the unified CLI entrypoint, routing mechanisms, ecosystem management, and diagnostic tools.\n\n## Overview\n\nThe Grainulation CLI provides a unified interface for managing the entire ecosystem of eight research tools. The command system is designed with zero npm dependencies, relying exclusively on Node.js built-in modules. 资料来源：[bin/grainulation.js]()\n\nThe architecture follows a router-based pattern where commands are dispatched to appropriate handlers based on the first argument passed to the CLI. 资料来源：[lib/router.js]()\n\n```mermaid\ngraph TD\n    A[User Input] --> B[bin/grainulation.js]\n    B --> C[Command Router]\n    C --> D{Command Type}\n    D -->|doctor| E[lib/doctor.js]\n    D -->|setup| F[lib/setup.js]\n    D -->|ecosystem| G[lib/ecosystem.js]\n    D -->|pm| H[lib/pm.js]\n    D -->|wheat| I[Delegate to wheat package]\n    D -->|farmer| J[Delegate to farmer package]\n    D -->|Unknown| K[Help / Error]\n```\n\n## CLI Entry Point\n\n### bin/grainulation.js\n\nThe main CLI entrypoint that handles all user input and routes commands to appropriate handlers. 资料来源：[bin/grainulation.js]()\n\n**Usage:**\n\n```bash\ngrainulation [command] [options]\n```\n\n**Global Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--help` | Display help information |\n| `--version` | Display CLI version |\n| `--json` | Output results as JSON |\n\n### Commands Summary\n\n| Command | Description | Handler |\n|---------|-------------|---------|\n| `doctor` | Validate tool installations | lib/doctor.js |\n| `setup` | First-run setup and configuration | lib/setup.js |\n| `ecosystem` | Ecosystem health checks and tool discovery | lib/ecosystem.js |\n| `pm` | Package management for grainulation tools | lib/pm.js |\n| `wheat` | Delegate to wheat package | External package |\n| `farmer` | Delegate to farmer package | External package |\n\n## Command Handlers\n\n### doctor\n\nThe diagnostic tool validates tool installations across the ecosystem. It checks which tools are installed, their versions, and reports any issues with the setup. 资料来源：[lib/doctor.js]()\n\n**Usage:**\n\n```bash\ngrainulation doctor [options]\n```\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--verbose` | Show detailed diagnostic information |\n| `--fix` | Attempt to fix detected issues automatically |\n\n**Output Example:**\n\n```\nChecking grainulation tools...\n✓ wheat v1.2.0 installed\n✓ farmer v1.1.0 installed\n✗ silo not found\n⚠ mill v1.0.0 has known compatibility issues\n\nRun 'grainulation setup' to install missing tools\n```\n\n### setup\n\nHandles first-run setup and configuration of the Grainulation ecosystem. This command ensures all required tools are installed and configured correctly. 资料来源：[lib/setup.js]()\n\n**Usage:**\n\n```bash\ngrainulation setup [options]\n```\n\n**Options:**\n\n| Option | Description |\n|--------|-------------|\n| `--install` | Install all recommended tools |\n| `--tools <list>` | Install specific tools (comma-separated) |\n| `--skip-validation` | Skip post-install validation |\n\n**Workflow:**\n\n```mermaid\ngraph LR\n    A[Run Setup] --> B{Check Node.js Version}\n    B -->|≥20| C{Check Existing Tools}\n    C -->|Missing| D[Download Tools]\n    D --> E[Validate Installation]\n    E --> F[Create Config Files]\n    F --> G[Setup Complete]\n    B -->|<20| H[Error: Node.js 20+ Required]\n```\n\n### ecosystem\n\nProvides ecosystem health checks and tool discovery functionality. This command scans for installed tools and reports their status. 资料来源：[lib/ecosystem.js]()\n\n**Usage:**\n\n```bash\ngrainulation ecosystem [command]\n```\n\n**Subcommands:**\n\n| Subcommand | Description |\n|------------|-------------|\n| `status` | Show status of all ecosystem tools |\n| `discover` | Scan for available tools |\n| `health` | Run comprehensive health check |\n\n**Status Output Format:**\n\n```json\n{\n  \"tools\": [\n    { \"name\": \"wheat\", \"status\": \"installed\", \"version\": \"1.2.0\" },\n    { \"name\": \"farmer\", \"status\": \"installed\", \"version\": \"1.1.0\" },\n    { \"name\": \"silo\", \"status\": \"not_found\", \"version\": null }\n  ],\n  \"overall\": \"degraded\"\n}\n```\n\n### pm (Package Manager)\n\nHandles package management operations for grainulation tools. Supports installation, removal, and updating of tools. 资料来源：[lib/pm.js]()\n\n**Usage:**\n\n```bash\ngrainulation pm <action> [package]\n```\n\n**Actions:**\n\n| Action | Description |\n|--------|-------------|\n| `install` | Install a package |\n| `remove` | Remove a package |\n| `update` | Update a package to latest |\n| `list` | List installed packages |\n\n**Examples:**\n\n```bash\ngrainulation pm install wheat\ngrainulation pm remove silo\ngrainulation pm update harvest\ngrainulation pm list\n```\n\n### Tool Delegation\n\nFor commands not recognized by the core CLI, the router delegates to individual tool packages. This allows direct invocation via `npx @grainulation/<tool-name>`. 资料来源：[lib/router.js]()\n\n**Delegated Tools:**\n\n| Tool | Purpose | Package |\n|------|---------|---------|\n| wheat | Research engine | @grainulation/wheat |\n| farmer | Permission dashboard | @grainulation/farmer |\n| barn | Claims backend | @grainulation/barn |\n| mill | Export and publish | @grainulation/mill |\n| silo | Evidence library | @grainulation/silo |\n| harvest | Analytics | @grainulation/harvest |\n| orchard | Orchestration | @grainulation/orchard |\n\n## Routing Architecture\n\nThe command router (`lib/router.js`) implements a priority-based matching system to determine which handler should process each command. 资料来源：[lib/router.js]()\n\n```mermaid\ngraph TD\n    A[Parse CLI Arguments] --> B{Is Built-in Command?}\n    B -->|Yes| C[Route to Handler]\n    B -->|No| D{Is Tool Command?}\n    D -->|Yes| E[Delegate to Tool Package]\n    D -->|No| F{Is Global Flag?}\n    F -->|--help| G[Display Help]\n    F -->|--version| H[Display Version]\n    F -->|Else| I[Error: Unknown Command]\n```\n\n### Route Priority\n\n1. Built-in commands (doctor, setup, ecosystem, pm)\n2. Tool delegation (wheat, farmer, barn, mill, silo, harvest, orchard)\n3. Global flags (--help, --version)\n4. Error handling for unknown commands\n\n## Error Handling\n\nThe CLI implements consistent error handling across all commands:\n\n| Error Type | Exit Code | Message Format |\n|------------|-----------|----------------|\n| Command not found | 1 | `Unknown command: <command>` |\n| Invalid arguments | 2 | `Invalid argument: <argument>` |\n| Tool not installed | 3 | `Tool not installed: <tool>` |\n| Node.js version error | 4 | `Node.js 20+ required` |\n| Network error | 5 | `Failed to reach npm registry` |\n\n## Configuration\n\nThe CLI reads configuration from `~/.grainulation/` directory:\n\n| File | Purpose |\n|------|---------|\n| `config.json` | Global settings |\n| `installed.json` | List of installed tools |\n| `cache/` | Temporary cache files |\n\n## Quick Reference\n\n```bash\n# Display help\ngrainulation --help\n\n# Check ecosystem health\ngrainulation doctor --verbose\n\n# Setup new environment\ngrainulation setup --install\n\n# View ecosystem status\ngrainulation ecosystem status\n\n# Manage packages\ngrainulation pm list\ngrainulation pm install wheat\n\n# Direct tool usage\nnpx @grainulation/wheat init\nnpx @grainulation/farmer start\n\n---\n\n<a id='ecosystem-overview'></a>\n\n## Ecosystem Overview\n\n### 相关页面\n\n相关主题：[Tool Integration](#tool-integration), [Project Overview](#project-overview), [Command Reference](#command-reference)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n</details>\n\n# Ecosystem Overview\n\n## Introduction\n\nGrainulation is a meta-package and ecosystem router that orchestrates eight independent CLI tools for structured technical research and decision-making. The ecosystem follows a \"microkernel\" architecture where the core `grainulation` package provides unified CLI access, routing, and health monitoring while each specialized tool operates as an independent package with zero npm dependencies.\n\nThe core philosophy centers on turning technical questions into typed, evidence-graded claims that can be compiled into auditable decision briefs. Each tool addresses a specific phase of the research workflow: initialization, evidence gathering, challenge, storage, export, archival, analysis, and system orchestration.\n\n## Architecture\n\n### Core Components\n\nThe grainulation ecosystem architecture consists of several interconnected layers that enable tool discovery, routing, and health management.\n\n```mermaid\ngraph TD\n    A[CLI Entry Point<br/>bin/grainulation.js] --> B[Router<br/>lib/router.js]\n    B --> C[Tool Packages<br/>wheat, farmer, barn, mill, silo, harvest, orchard]\n    A --> D[Ecosystem Health<br/>lib/ecosystem.js]\n    A --> E[Doctor<br/>lib/doctor.js]\n    A --> F[Setup<br/>lib/setup.js]\n    A --> G[Package Manager<br/>lib/pm.js]\n    D --> H[Local Server<br/>lib/server.mjs]\n    H --> I[Web UI<br/>public/]\n    C --> D\n```\n\n### Directory Structure\n\n| Path | Purpose | Description |\n|------|---------|-------------|\n| `bin/grainulation.js` | CLI entrypoint | Routes commands to individual tools |\n| `lib/router.js` | Command routing | Dispatches to correct tool package |\n| `lib/ecosystem.js` | Health checks | Tool discovery and version verification |\n| `lib/doctor.js` | Diagnostics | Validates tool installations |\n| `lib/setup.js` | Configuration | First-run setup and initialization |\n| `lib/pm.js` | Package management | Manages grainulation tool installations |\n| `lib/server.mjs` | Local server | Unified ecosystem dashboard (ESM) |\n| `public/` | Web UI | Static assets for dashboard |\n| `test/` | Test suite | Node built-in test runner |\n\n资料来源：[CONTRIBUTING.md:1-50](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## The Eight Tools\n\n### Tool Overview\n\n| Tool | Package | Function | Install Command |\n|------|---------|----------|-----------------|\n| wheat | `@grainulation/wheat` | Research engine for growing structured evidence | `npx @grainulation/wheat init` |\n| farmer | `@grainulation/farmer` | Permission dashboard for AI agent approvals | `npx @grainulation/farmer start` |\n| barn | `@grainulation/barn` | Knowledge base for shared evidence and claims | `npx @grainulation/barn sync` |\n| mill | `@grainulation/mill` | Export and publish to PDFs, CSVs, static sites | `npx @grainulation/mill export --format pdf` |\n| silo | `@grainulation/silo` | Archive and search historical sprints | `npx @grainulation/silo search` |\n| harvest | `@grainulation/harvest` | Analytics for cross-sprint learning | `npx @grainulation/harvest analyze ./sprints/` |\n| orchard | `@grainulation/orchard` | Unified CLI status and health monitoring | `npx @grainulation/orchard status` |\n| grainulation | `@grainulation/grainulation` | Meta-package orchestrating all tools | `npx @grainulation/grainulation` |\n\n### Tool Interactions\n\n```mermaid\ngraph LR\n    W[wheat] --> B[barn]\n    F[farmer] --> B\n    W --> H[harvest]\n    S[silo] --> H\n    B --> M[mill]\n    W --> S\n    O[orchard] --> All\n```\n\nEach tool follows the zero-dependency principle: built entirely on Node.js built-ins, ships what it needs, and nothing more.\n\n## Key Modules\n\n### CLI Entry Point\n\nThe `bin/grainulation.js` file serves as the unified command-line interface that delegates to individual tools based on user input.\n\n```javascript\n// Entry point routes to individual tools\n// Usage: grainulation <command> [args]\n```\n\n资料来源：[CONTRIBUTING.md:27](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n### Ecosystem Health Checks\n\nThe `lib/ecosystem.js` module performs health checks across the entire tool ecosystem, verifying tool availability and version consistency.\n\n**Key Functions:**\n\n| Function | Purpose |\n|----------|---------|\n| `checkToolHealth()` | Verifies all installed tools are operational |\n| `getVersionMatrix()` | Returns version info for all packages |\n| `validateToolchain()` | Ensures tool dependencies are satisfied |\n\n### Router\n\nThe `lib/router.js` module handles command dispatching to the appropriate tool based on subcommand parsing.\n\n```mermaid\ngraph TD\n    A[User Command] --> B[Parse Command]\n    B --> C{Is Global Command?}\n    C -->|Yes| D[Run Ecosystem Command<br/>doctor/setup/health]\n    C -->|No| E{Local Tool Command?}\n    E -->|Yes| F[Route to Tool Package]\n    E -->|No| G[Show Help]\n```\n\n### Doctor Module\n\nThe `lib/doctor.js` diagnostic tool validates tool installations and identifies issues with the local setup.\n\n资料来源：[CONTRIBUTING.md:25](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Tool Discovery\n\nThe ecosystem uses npm package discovery to find installed tools. Each tool follows the naming convention `@grainulation/<toolname>` and is installed on-demand when first accessed via npx.\n\n### Discovery Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant NPM as npm registry\n    participant Tool as @grainulation/tool\n\n    User->>CLI: grainulation wheat init\n    CLI->>Router: route(wheat, [init])\n    Router->>Tool: npx @grainulation/wheat init\n    Tool-->>User: Execute command\n```\n\n## Configuration Management\n\n### Setup Flow\n\nThe first-run setup process (`lib/setup.js`) performs initial configuration:\n\n1. Detects installed Node.js version\n2. Verifies npx availability\n3. Creates user configuration directory\n4. Initializes default settings for each tool\n\n### Configuration Files\n\n| File | Location | Purpose |\n|------|----------|---------|\n| `wheat.config.json` | Sprint directory | Research configuration |\n| `claims.json` | Sprint directory | Evidence and claims storage |\n| `.grainulationrc` | User home | Global preferences |\n\n## Publishing and Releases\n\n### Release Architecture\n\nThe entire ecosystem uses a coordinated release process documented in `RELEASE.md`.\n\n```mermaid\ngraph LR\n    A[Tag v.x.y.z] --> B[Workflow Trigger]\n    B --> C[Run Tests]\n    C --> D[Verify Version]\n    D --> E[Publish npm<br/>via OIDC]\n    E --> F[Update npmjs.com]\n```\n\n### Publishing Workflow\n\nEach package publishes via `.github/workflows/publish.yml` on tag push. The workflow:\n\n1. Runs tests\n2. Verifies tag matches `package.json.version`\n3. Publishes with npm provenance via OIDC trusted publishing\n4. No `NPM_TOKEN` secret required after initial setup\n\n资料来源：[RELEASE.md:1-30](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n### Single-Package Release\n\n```bash\ncd <repo>\nnpm version patch\ngit push origin main --follow-tags\n```\n\n### Coordinated Release\n\nFor consumer packages depending on new internal features:\n\n1. Publish the dependency package first (e.g., `barn`)\n2. Wait for npm publication (~60 seconds)\n3. Run `npm install` in each consumer repo\n4. Commit lockfile updates\n5. Publish each consumer with version bump\n\n资料来源：[RELEASE.md:15-35](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n## Web Dashboard\n\nThe `lib/server.mjs` module provides a local web server for the ecosystem dashboard, serving the web UI from the `public/` directory.\n\n### Dashboard Features\n\n- Real-time ecosystem health status\n- Tool version matrix\n- Quick action buttons for common operations\n- Configuration overview\n\n## Testing\n\nThe ecosystem uses Node's built-in test runner with tests located in `test/basic.test.js`.\n\n```bash\nnode test/basic.test.js\n```\n\nThis runs without additional dependencies, consistent with the zero-dependency philosophy.\n\n## Quick Reference Commands\n\n| Command | Description |\n|---------|-------------|\n| `grainulation` | Ecosystem overview |\n| `grainulation doctor` | Health check for all tools |\n| `grainulation setup` | Install tools for your role |\n| `grainulation wheat init` | Initialize research sprint |\n| `grainulation orchard status` | Check ecosystem status |\n\n## Design Principles\n\nThe ecosystem is built on four core principles:\n\n1. **Zero Dependencies**: Every tool ships with only Node.js built-ins, eliminating supply chain risk\n2. **Language Agnostic**: Research can cover any technology stack or domain\n3. **Local-First**: All processing occurs locally; no cloud services or API keys required for core tools\n4. **Auditable**: Every claim, challenge, and resolution maintains a git audit trail\n\n---\n\n<a id='tool-integration'></a>\n\n## Tool Integration\n\n### 相关页面\n\n相关主题：[Ecosystem Overview](#ecosystem-overview), [CLI Architecture](#cli-architecture), [Extensibility Guide](#extensibility-guide)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js) - CLI entrypoint\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js) - Command routing\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js) - Package management\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js) - Ecosystem health checks\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js) - Diagnostic tool\n- [lib/setup.js](https://github.com/grainulation/grainulation/blob/main/lib/setup.js) - First-run setup\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md) - Architecture documentation\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md) - Release documentation\n</details>\n\n# Tool Integration\n\nThe Grainulation ecosystem provides a unified CLI architecture that orchestrates eight independent CLI tools through a centralized routing and package management system. This document describes how tools integrate with the ecosystem, how commands flow through the system, and how the unified entrypoint manages tool discovery and execution.\n\n## Architecture Overview\n\nGrainulation follows a meta-package pattern where the `grainulation` tool serves as an ecosystem router. It does not implement tool functionality itself but delegates to individual packages while providing unified health checks, diagnostics, and package management.\n\n```mermaid\ngraph TD\n    User[\"User\"] --> CLI[\"bin/grainulation.js<br/>CLI Entrypoint\"]\n    CLI --> Router[\"lib/router.js<br/>Command Router\"]\n    Router --> Wheat[\"@grainulation/wheat\"]\n    Router --> Farmer[\"@grainulation/farmer\"]\n    Router --> Barn[\"@grainulation/barn\"]\n    Router --> Mill[\"@grainulation/mill\"]\n    Router --> Silo[\"@grainulation/silo\"]\n    Router --> Harvest[\"@grainulation/harvest\"]\n    Router --> Orchard[\"@grainulation/orchard\"]\n    \n    CLI --> Ecosystem[\"lib/ecosystem.js<br/>Health Checks\"]\n    CLI --> Doctor[\"lib/doctor.js<br/>Diagnostics\"]\n    CLI --> PM[\"lib/pm.js<br/>Package Manager\"]\n    CLI --> Setup[\"lib/setup.js<br/>Configuration\"]\n    \n    Ecosystem -.-> Wheat\n    Ecosystem -.-> Farmer\n    Ecosystem -.-> Barn\n```\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L35)\n\n## The Eight Tools\n\nThe ecosystem consists of eight independently versioned packages, each with a specific responsibility:\n\n| Tool | Role | Primary Function |\n|------|------|------------------|\n| **wheat** | Research | Claim collection and challenge workflow |\n| **farmer** | Permissions | AI agent tool call approval dashboard |\n| **barn** | Shared utilities | Sprint detection, manifest generation, HTML templates |\n| **mill** | Export | PDF, CSV, and static site generation |\n| **silo** | Storage | Data persistence layer |\n| **harvest** | Analytics | Cross-sprint learning and prediction tracking |\n| **orchard** | Orchestration | Multi-tool coordination |\n| **grainulation** | Unified CLI | Meta-tool routing and ecosystem management |\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - Tool card descriptions\n\n## CLI Entry Point\n\nThe CLI entrypoint at `bin/grainulation.js` serves as the single entry point for all tool operations. When invoked via `npx @grainulation/grainulation` or `npx grainulation`, this script:\n\n1. Parses command-line arguments\n2. Checks for ecosystem health\n3. Routes commands to the appropriate tool\n4. Handles configuration and setup workflows\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L28)\n\n### Quick Setup\n\nNo installation step is required. The tools use zero npm dependencies and run directly:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L12-L16)\n\n## Command Routing\n\nThe routing system in `lib/router.js` maps user commands to the correct tool package. The router interprets command arguments and dispatches execution to the appropriate tool's CLI interface.\n\n### Routing Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Tool as Individual Tool\n\n    User->>CLI: npx @grainulation/grainulation <command>\n    CLI->>Router: parseAndRoute(args)\n    Router->>Router: identifyTool(command)\n    Router->>Tool: delegate(command, args)\n    Tool-->>User: Output\n```\n\nThe router maintains a registry of available tools and their command signatures, enabling dynamic routing without hard-coded dependencies on tool implementations.\n\n**资料来源：** [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js) - Routing implementation\n\n## Package Management\n\nThe `lib/pm.js` module handles package management for the grainulation ecosystem. It manages:\n\n- Installation of individual tool packages\n- Version resolution across interdependent packages\n- Dependency tracking between ecosystem tools\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L33)\n\n### Coordinated Releases\n\nWhen a tool depends on new features from another tool in the ecosystem, a coordinated release process ensures compatibility:\n\n1. **Publish dependency first** - The upstream tool (e.g., `barn`) publishes its new version\n2. **Wait for registry sync** - Allow ~60 seconds for npm to propagate the package\n3. **Update consumers** - Run `npm install` in each consumer repository to regenerate `package-lock.json`\n4. **Publish consumers** - Tag and publish each dependent package\n\n```bash\n# Example: barn new version\ncd barn\nnpm version patch\ngit push origin main --follow-tags\n\n# Wait 60s, then in each consumer\nnpm install\ngit add package-lock.json\nnpm version patch\ngit push origin main --follow-tags\n```\n\n**资料来源：** [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md#L26-L43)\n\n## Ecosystem Health Checks\n\nThe `lib/ecosystem.js` module provides health checks and tool discovery capabilities. It:\n\n- Verifies all tool packages are installed correctly\n- Checks version compatibility between tools\n- Provides status information for the entire ecosystem\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L30)\n\n## Diagnostic System\n\nThe `lib/doctor.js` module validates tool installations and provides diagnostic information:\n\n- Checks Node.js version compatibility\n- Validates package integrity\n- Reports missing or misconfigured tools\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L31)\n\n## Setup and Configuration\n\nThe `lib/setup.js` module handles first-run setup and configuration:\n\n- Creates initial configuration files\n- Sets up workspace directories\n- Initializes claim storage\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L32)\n\n## Zero Dependencies Architecture\n\nAll eight tools in the grainulation ecosystem share a critical design principle: **zero npm dependencies**. Every tool ships only Node.js built-ins and its own code.\n\n```mermaid\ngraph LR\n    subgraph \"Traditional Tool\"\n        T1[Tool Code] --> DEPS[External Dependencies]\n        DEPS --> POTENTIAL[\"Potential Issues:<br/>- Supply chain risk<br/>- Version conflicts<br/>- API changes\"]\n    end\n    \n    subgraph \"Grainulation Tool\"\n        G1[Tool Code] --> BUILTIN[\"Node.js Built-ins Only\"]\n        BUILTIN --> BENEFITS[\"Benefits:<br/>- No left-pad incidents<br/>- No supply chain anxiety<br/>- Offline capable\"]\n    end\n```\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - Feature descriptions\n\n### Benefits of Zero Dependencies\n\n| Aspect | Impact |\n|--------|--------|\n| Supply chain security | No third-party code to compromise |\n| Reproducibility | Same behavior across all environments |\n| Offline capability | Works without network access |\n| Maintenance | No dependency update churn |\n\n**资料来源：** [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html) - \"Zero dependencies\" feature card\n\n## Publishing Workflow\n\nEach package publishes independently via GitHub Actions using OIDC trusted publishing:\n\n```yaml\n# .github/workflows/publish.yml pattern\non:\n  push:\n    tags:\n      - 'v*'\njobs:\n  publish:\n    steps:\n      - uses: actions/checkout@v4\n      - run: npm publish --provenance --access public\n```\n\nNo `NPM_TOKEN` secret is required after initial setup on npmjs.com. The workflow verifies that the tag matches `package.json.version` before publishing.\n\n**资料来源：** [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md#L14-L24)\n\n## Local Server Dashboard\n\nThe `lib/server.mjs` module provides a local web server (ESM) that serves as a unified ecosystem dashboard:\n\n- Real-time status of all tools\n- Health check visualization\n- Ecosystem-wide monitoring\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L35-L36)\n\n## Contributing to Tool Integration\n\nTo add a new tool to the ecosystem or modify the integration layer:\n\n1. **Report bugs** - Open an issue with expected vs actual behavior, Node version, and reproduction steps\n2. **Suggest features** - Describe the use case: \"I need X because Y\"\n3. **Submit PRs**:\n   - Fork the repo and create a branch: `git checkout -b fix/description`\n   - Make changes following the existing patterns\n   - Run tests: `node test/basic.test.js`\n   - Commit with a clear message and open a PR\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L20-L26)\n\n## File Structure Reference\n\n| File | Purpose |\n|------|---------|\n| `bin/grainulation.js` | CLI entrypoint, routes to individual tools |\n| `lib/router.js` | Command routing to the correct tool package |\n| `lib/ecosystem.js` | Ecosystem health checks and tool discovery |\n| `lib/doctor.js` | Diagnostic tool, validates tool installations |\n| `lib/setup.js` | First-run setup and configuration |\n| `lib/pm.js` | Package management for grainulation tools |\n| `lib/server.mjs` | Local server, unified ecosystem dashboard (ESM) |\n| `public/` | Web UI for ecosystem overview and status |\n| `site/` | Public website (grainulation.com) |\n| `test/` | Node built-in test runner tests |\n\n**资料来源：** [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md#L27-L36)\n\n---\n\n<a id='setup-installation'></a>\n\n## Setup and Installation\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Health Checks and Diagnostics](#health-checks), [Package Management](#package-management)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n</details>\n\n# Setup and Installation\n\nGrainulation is designed with zero external dependencies, meaning no `npm install` is required to get started. The entire ecosystem uses only Node.js built-in modules, eliminating supply chain anxiety and ensuring consistent behavior across environments.\n\n## Prerequisites\n\nBefore installing or running Grainulation tools, ensure your environment meets the following requirements:\n\n| Requirement | Version | Notes |\n|-------------|---------|-------|\n| Node.js | 20+ | Required for all core tools |\n| npx | Latest | Bundled with Node.js 20+ |\n| Git | Any recent version | For cloning repositories |\n| Claude Code | Required | Only needed for research features |\n\n资料来源：[CONTRIBUTING.md:12]()\n\n## Installation Methods\n\n### Quick Start with npx\n\nThe fastest way to run any Grainulation tool is through `npx`, which downloads and executes the package on-demand:\n\n```bash\nnpx @grainulation/wheat init\nnpx @grainulation/grainulation --help\n```\n\n### Local Development Setup\n\nFor contributing to the project or modifying the source code:\n\n```bash\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\nnode bin/grainulation.js --help\n```\n\n资料来源：[CONTRIBUTING.md:5-9]()\n\n## Project Structure\n\n```\ngrainulation/\n├── bin/\n│   └── grainulation.js    # CLI entrypoint - routes to individual tools\n├── lib/\n│   ├── router.js          # Command routing to the correct tool package\n│   ├── ecosystem.js      # Ecosystem health checks and tool discovery\n│   ├── doctor.js         # Diagnostic tool - validates tool installations\n│   ├── setup.js          # First-run setup and configuration\n│   ├── pm.js             # Package management for grainulation tools\n│   └── server.mjs        # Local server (ESM)\n├── public/               # Web UI - ecosystem overview and status\n├── site/                 # Public website (grainulation.com)\n└── test/                 # Node built-in test runner tests\n```\n\n资料来源：[CONTRIBUTING.md:28-38]()\n\n## CLI Entry Point Architecture\n\nThe unified CLI routes commands to the appropriate tool package based on the arguments provided:\n\n```mermaid\ngraph TD\n    A[CLI: node bin/grainulation.js] --> B[lib/router.js]\n    B --> C[wheat]\n    B --> D[farmer]\n    B --> E[barn]\n    B --> F[mill]\n    B --> G[silo]\n    B --> H[harvest]\n    B --> I[orchard]\n    B --> J[doctor - diagnostics]\n```\n\nThe router module determines which package should handle each command, enabling the unified CLI experience while keeping each tool independent.\n\n资料来源：[CONTRIBUTING.md:28-29]()\n\n## Tool Ecosystem Overview\n\nGrainulation consists of eight specialized packages plus a meta-package:\n\n| Package | Role | Install Command |\n|---------|------|-----------------|\n| wheat | Research and claims management | `npx @grainulation/wheat init` |\n| farmer | Permission dashboard for AI agents | `npx @grainulation/farmer start` |\n| barn | Shared utilities and sprint detection | `npx @grainulation/barn detect-sprints` |\n| mill | Export and publish compiled research | `npx @grainulation/mill export --format pdf` |\n| silo | Research storage and retrieval | `npx @grainulation/silo` |\n| harvest | Analytics and cross-sprint learning | `npx @grainulation/harvest analyze ./sprints/` |\n| orchard | Orchestration and workflow management | `npx @grainulation/orchard status` |\n| grainulation | Unified CLI meta-tool | `npx @grainulation/grainulation` |\n\n资料来源：[site/index.html:145-165]()\n\n## Zero Dependencies Architecture\n\nAll eight packages in the Grainulation ecosystem maintain zero npm dependencies:\n\n```mermaid\ngraph LR\n    A[User Environment] --> B[Node.js Built-ins Only]\n    B --> C[No npm packages]\n    B --> D[No external APIs]\n    C --> E[Zero supply chain risk]\n    D --> E\n```\n\nThis design philosophy ensures:\n- No supply chain anxiety\n- No \"left-pad\" incidents\n- No API keys required for core tools\n- Everything ships what it needs and nothing more\n\n资料来源：[site/index.html:38-40]()\n\n## First-Run Setup\n\nOn first execution, the setup module (`lib/setup.js`) handles:\n\n1. Configuration file creation in the user's home directory\n2. Ecosystem health verification\n3. Tool discovery across all installed packages\n\nRun diagnostics to verify your setup:\n\n```bash\nnode bin/grainulation.js doctor\n```\n\n资料来源：[CONTRIBUTING.md:30]()\n\n## Running Tests\n\nAfter making changes to the codebase, validate your modifications:\n\n```bash\nnode test/basic.test.js\n```\n\n资料来源：[CONTRIBUTING.md:18]()\n\n## Package Publishing Workflow\n\nFor developers releasing updates to the ecosystem, the publishing process uses GitHub Actions with OIDC trusted publishing:\n\n```mermaid\ngraph LR\n    A[npm version patch] --> B[Git push with tags]\n    B --> C[GitHub Actions trigger]\n    C --> D[Verify tag matches package.json]\n    D --> E[Run tests]\n    E --> F[Publish via OIDC]\n    F --> G[npmjs.com]\n```\n\nThe workflow handles all eight packages plus the `grainulator` plugin through coordinated releases when dependencies exist between packages.\n\n资料来源：[RELEASE.md:1-30]()\n\n## Verification Checklist\n\nAfter installation, verify your setup by running these commands:\n\n| Check | Command | Expected Output |\n|-------|---------|-----------------|\n| CLI accessible | `node bin/grainulation.js --help` | Command routing help |\n| Doctor diagnostics | `node bin/grainulation.js doctor` | Health status report |\n| Tool discovery | `node bin/grainulation.js ecosystem` | List of installed tools |\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| Command not found | Ensure Node.js 20+ is installed |\n| Tool routing fails | Run `node bin/grainulation.js doctor` to diagnose |\n| npx timeout | Use local clone: `node bin/grainulation.js <command>` |\n\n### Diagnostic Commands\n\nThe doctor module validates tool installations and provides troubleshooting guidance:\n\n```bash\nnode bin/grainulation.js doctor\n```\n\n资料来源：[CONTRIBUTING.md:30]()\n\n## Related Documentation\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md) - Development setup and architecture\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md) - Release processes and publishing\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md) - Project overview and capabilities\n\n---\n\n<a id='health-checks'></a>\n\n## Health Checks and Diagnostics\n\n### 相关页面\n\n相关主题：[Command Reference](#command-reference), [Setup and Installation](#setup-installation), [Package Management](#package-management)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n</details>\n\n# Health Checks and Diagnostics\n\nThe **Health Checks and Diagnostics** subsystem in grainulation provides a systematic way to verify the integrity of the ecosystem, validate configurations, and diagnose issues across the eight CLI tools. The `doctor` module serves as the central diagnostic engine that ensures the research workflow operates correctly.\n\n## Overview\n\ngrainulation is an ecosystem of eight zero-dependency CLI tools for structured technical research. Given the distributed nature of this architecture—where tools like `wheat`, `silo`, `mill`, `farmer`, `harvest`, `orchard`, `barn`, and the unified `grainulation` CLI must work together—the Health Checks and Diagnostics system provides essential validation and troubleshooting capabilities.\n\nThe diagnostic subsystem answers questions like:\n\n- Are all tool configurations valid?\n- Is the Node.js environment compatible?\n- Are claims files properly formatted?\n- Are there conflicts or issues in sprint data?\n\n## Architecture\n\n```mermaid\ngraph TD\n    A[User Command] --> B[grainulation CLI]\n    B --> C{doctor.js}\n    C --> D[Config Validation]\n    C --> E[Tool Health Check]\n    C --> F[Claims Validation]\n    C --> G[Ecosystem Status]\n    D --> H[wheat.config.json]\n    E --> I[Individual Tools]\n    F --> J[claims.json]\n    G --> K[Tool Manifests]\n```\n\n### Core Components\n\n| Component | Purpose | File Location |\n|-----------|---------|---------------|\n| `doctor.js` | Main diagnostic engine | `lib/doctor.js` |\n| Config Validator | Validates JSON configurations | Part of doctor module |\n| Claims Checker | Validates claim structure | Part of doctor module |\n| Ecosystem Scanner | Checks tool availability | Part of doctor module |\n\n## Diagnostic Workflow\n\nWhen running a health check, the system follows this diagnostic sequence:\n\n```mermaid\ngraph LR\n    A[Init Check] --> B[Environment Scan]\n    B --> C[Config Load]\n    C --> D[Schema Validation]\n    D --> E{Settings Valid?}\n    E -->|Yes| F[Tool Check]\n    E -->|No| G[Report Errors]\n    F --> H{All Tools OK?}\n    H -->|Yes| I[Generate Report]\n    H -->|No| J[Flag Issues]\n```\n\n1. **Initialization Check**: Verifies the command can access necessary Node.js APIs\n2. **Environment Scan**: Checks Node.js version compatibility\n3. **Configuration Load**: Loads project-level and global configurations\n4. **Schema Validation**: Ensures configuration files match expected schemas\n5. **Tool Health Check**: Verifies each tool in the ecosystem is accessible\n6. **Report Generation**: Produces a diagnostic report with findings\n\n## Configuration Validation\n\nThe diagnostic system validates configurations stored in `wheat.config.json` and tool-specific settings.\n\n### Validated Configuration Elements\n\n| Element | Description | Validation |\n|---------|-------------|------------|\n| `question` | Research question string | Non-empty string |\n| `audience` | Target stakeholders | Array of strings |\n| `constraints` | Decision constraints | Array of strings |\n| `tools` | Enabled tool list | String array |\n| `outputFormat` | Brief output format | Enum: html, pdf, md |\n\nConfiguration validation uses strict JSON schema checking to ensure data integrity throughout the research sprint.\n\n## Claims Validation\n\nAs described in the grainulation philosophy, everything starts with a **claim**—a typed statement with an evidence grade. The diagnostic system validates claims in `claims.json`.\n\n### Claim Structure Validation\n\n```mermaid\ngraph TD\n    A[claims.json] --> B[Parse JSON]\n    B --> C[For Each Claim]\n    C --> D{ID Present?}\n    D -->|No| E[Flag: Missing ID]\n    D -->|Yes| F{Type Valid?}\n    F -->|No| G[Flag: Invalid Type]\n    F -->|Yes| H{Tier Valid?}\n    H -->|No| I[Flag: Invalid Tier]\n    H -->|Yes| J[Evidence Check]\n    J --> K{Evidence Grade OK?}\n    K -->|No| L[Flag: Weak Evidence]\n    K -->|Yes| M[Next Claim]\n```\n\n### Claim Types\n\n| Type | Description |\n|------|-------------|\n| `factual` | Verifiable fact with evidence |\n| `risk` | Identified risk or threat |\n| `estimate` | Best-effort estimation |\n| `constraint` | Hard constraint on the decision |\n| `recommendation` | Suggested action based on evidence |\n\n### Evidence Tiers\n\n| Tier | Level | Description |\n|------|-------|-------------|\n| 1 | `stated` | Someone said it |\n| 2 | `claimed` | External source states it |\n| 3 | `documented` | Written documentation exists |\n| 4 | `measured` | Measured or observed in practice |\n\n## Ecosystem Health Checks\n\nThe diagnostic system performs comprehensive checks across the grainulation ecosystem.\n\n### Tool Availability\n\nEach of the eight tools is checked for availability:\n\n```mermaid\ngraph TD\n    A[Check Tool Availability] --> B[wheat - Research Engine]\n    A --> C[silo - Reusable Knowledge]\n    A --> D[mill - Export & Publish]\n    A --> E[farmer - AI Permissions]\n    A --> F[harvest - Analytics]\n    A --> G[orchard - Orchestration]\n    A --> H[barn - Shared Utilities]\n    A --> I[grainulation - Unified CLI]\n    B --> J{Installed?}\n    J -->|Yes| K[OK]\n    J -->|No| L[Missing Warning]\n```\n\n### Zero Dependencies Verification\n\nThe diagnostic system confirms that tools maintain the zero-dependency promise by verifying no external npm packages are required.\n\n## Diagnostic Output\n\nThe health check produces structured output:\n\n```json\n{\n  \"status\": \"healthy|warning|critical\",\n  \"timestamp\": \"ISO-8601 timestamp\",\n  \"checks\": {\n    \"environment\": { \"status\": \"pass|fail\", \"details\": \"...\" },\n    \"config\": { \"status\": \"pass|fail\", \"errors\": [] },\n    \"claims\": { \"status\": \"pass|fail\", \"count\": 0, \"issues\": [] },\n    \"ecosystem\": { \"status\": \"pass|fail\", \"tools\": {} }\n  },\n  \"recommendations\": [\"suggestion1\", \"suggestion2\"]\n}\n```\n\n## Running Diagnostics\n\nHealth checks can be invoked through the unified CLI:\n\n```bash\n# Check overall ecosystem health\nnpx grainulation doctor\n\n# Check specific sprint health\nnpx @grainulation/wheat doctor\n\n# Check with verbose output\nnpx grainulation doctor --verbose\n```\n\n## Common Issues and Resolutions\n\n| Issue | Symptom | Resolution |\n|-------|---------|------------|\n| Invalid JSON config | Parser error | Validate JSON syntax in config files |\n| Missing claims | Empty claims array | Run `/research` commands to gather claims |\n| Weak evidence | Low-tier claims | Gather more evidence for critical claims |\n| Tool not found | Command not recognized | Reinstall via `npx @grainulation/[tool]` |\n| Conflict unresolved | Compiler blocks output | Use `/challenge` to resolve claim conflicts |\n\n## Integration with Compiler\n\nThe diagnostic system integrates with the compiler to ensure decision briefs are only generated when health checks pass:\n\n```mermaid\ngraph TD\n    A[/brief command] --> B[Run Health Check]\n    B --> C{All Checks Pass?}\n    C -->|No| D[Block Brief]\n    C -->|Yes| E[Compile Claims]\n    E --> F{Conflicts Exist?}\n    F -->|Yes| G[Flag Conflicts]\n    G --> D\n    F -->|No| H[Generate Brief]\n```\n\nThis ensures that decision briefs maintain the integrity guarantees promised by the grainulation philosophy—only well-researched, properly challenged, and conflict-resolved claims make it into the final output.\n\n## Summary\n\nThe Health Checks and Diagnostics system is fundamental to grainulation's promise of producing auditable, evidence-based decision briefs. By validating configurations, claims structure, evidence quality, and ecosystem integrity, the diagnostic subsystem ensures that every decision produced by the system meets the rigorous standards required for technical decision-making.\n\n---\n\n<a id='package-management'></a>\n\n## Package Management\n\n### 相关页面\n\n相关主题：[Setup and Installation](#setup-installation), [Health Checks and Diagnostics](#health-checks)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/pm.js](https://github.com/grainulation/grainulation/blob/main/lib/pm.js)\n- [package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n</details>\n\n# Package Management\n\nGrainulation implements a lightweight package management system designed to orchestrate its ecosystem of zero-dependency CLI tools. Rather than relying on external package managers for tool discovery and installation, the system provides `lib/pm.js` as a built-in mechanism for managing the eight core packages that comprise the grainulation ecosystem.\n\n## Overview\n\nThe package management module serves two primary functions within the grainulation architecture:\n\n1. **Tool Discovery** — Locates installed grainulation packages within the local environment\n2. **Package Installation** — Installs and updates the eight core tools (`wheat`, `farmer`, `barn`, `mill`, `silo`, `harvest`, `orchard`, `grainulation`) plus the `grainulator` plugin\n\nThis approach aligns with the project's fundamental philosophy: everything runs locally with minimal external dependencies. The package management layer sits above Node.js built-in modules and does not introduce additional npm packages into the runtime environment.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Ecosystem Architecture\n\nThe grainulation ecosystem consists of eight specialized tools, each responsible for a distinct phase of structured technical research. The package management module serves as the glue layer that enables these tools to work together as a unified system.\n\n```mermaid\ngraph TD\n    subgraph \"Grainulation Ecosystem\"\n        G[\"grainulation<br/>(meta-package)\"]\n        PM[\"lib/pm.js<br/>(Package Manager)\"]\n        \n        G --> PM\n    end\n    \n    subgraph \"Core Tools\"\n        W[\"wheat<br/>(Research Sprint)\"]\n        F[\"farmer<br/>(Permission Dashboard)\"]\n        B[\"barn<br/>(Validation)\"]\n        M[\"mill<br/>(Export)\"]\n        S[\"silo<br/>(Data Storage)\"]\n        H[\"harvest<br/>(Analytics)\"]\n        O[\"orchard<br/>(Status)\"]\n    end\n    \n    subgraph \"Plugins\"\n        GR[\"grainulator\"]\n    end\n    \n    PM --> W\n    PM --> F\n    PM --> B\n    PM --> M\n    PM --> S\n    PM --> H\n    PM --> O\n    PM --> GR\n    \n    W <--> B\n    W <--> M\n    B <--> S\n    H <--> S\n    O <--> S\n```\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Package Registry\n\nAll grainulation packages are published to npm under the `@grainulation` scope. The following table lists the core packages and their primary functions:\n\n| Package | Purpose | Command Prefix |\n|---------|---------|----------------|\n| `@grainulation/grainulation` | Unified CLI entry point, ecosystem router | `npx grainulation` |\n| `@grainulation/wheat` | Research sprint initialization and claims management | `npx @grainulation/wheat` |\n| `@grainulation/farmer` | Permission dashboard for AI agent tool calls | `npx @grainulation/farmer` |\n| `@grainulation/barn` | Validation engine, evidence grading | `npx @grainulation/barn` |\n| `@grainulation/mill` | Export compiled research to PDF, CSV, HTML | `npx @grainulation/mill` |\n| `@grainulation/silo` | Local data storage and persistence | `npx @grainulation/silo` |\n| `@grainulation/harvest` | Cross-sprint analytics and prediction tracking | `npx @grainulation/harvest` |\n| `@grainulation/orchard` | Ecosystem status and health monitoring | `npx @grainulation/orchard` |\n\nThe `grainulator` plugin extends the system with additional capabilities and follows the same package naming conventions.\n\n资料来源：[site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n\n## pnpm Configuration\n\nGrainulation uses [pnpm](https://pnpm.io/) as its package manager, with version 10.30.0 specified in the project's `package.json`:\n\n```json\n{\n  \"packageManager\": \"pnpm@10.30.0\"\n}\n```\n\n### Key Configuration\n\n| Setting | Value | Purpose |\n|---------|-------|---------|\n| `packageManager` | `pnpm@10.30.0` | Ensures consistent package manager version across contributors |\n| `engines.node` | `>=20` | Requires Node.js 20 or higher |\n| `publishConfig.access` | `public` | Packages are publicly accessible on npm |\n\nThe Node.js version requirement ensures compatibility with modern JavaScript features used throughout the ecosystem, including ES modules and built-in APIs like `node:fs`, `node:path`, and `node:http`.\n\n资料来源：[package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n\n## Dependency Model\n\nUnlike traditional Node.js projects that accumulate numerous npm dependencies, grainulation maintains a strict zero-dependency policy for the CLI tools themselves. However, the meta-package (`grainulation`) includes one internal dependency to enable routing and ecosystem coordination:\n\n```json\n{\n  \"dependencies\": {\n    \"@grainulation/barn\": \"^1.3.0\"\n  }\n}\n```\n\n### Dependency Philosophy\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    Dependency Philosophy                    │\n├─────────────────────────────────────────────────────────────┤\n│  CLI Tools (wheat, farmer, etc.)    →  Zero npm deps       │\n│  Meta-package (grainulation)        →  Only @grainulation  │\n│  All packages                       →  Node.js built-ins  │\n└─────────────────────────────────────────────────────────────┘\n```\n\nThis design provides several benefits:\n\n- **Supply chain security** — No third-party code dependencies reduces attack surface\n- **Installation speed** — Minimal package download footprint\n- **Reliability** — No dependency on external package availability\n- **Auditability** — Complete visibility into tool behavior\n\n资料来源：[site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n\n## Installation Workflow\n\n### Quick Setup\n\nThe recommended installation method uses npx, which downloads and executes packages on-demand without requiring a global installation:\n\n```bash\n# Clone the repository\ngit clone https://github.com/grainulation/grainulation.git\ncd grainulation\n\n# Run the CLI directly\nnode bin/grainulation.js --help\n```\n\n### Installing Individual Tools\n\nEach tool can be installed independently using npx:\n\n```bash\n# Initialize a research sprint\nnpx @grainulation/wheat init\n\n# Start the permission dashboard\nnpx @grainulation/farmer start\n\n# Export compiled research\nnpx @grainulation/mill export --format pdf\n```\n\nThe package management module (`lib/pm.js`) handles tool discovery and ensures that the correct versions of inter-dependent packages are available.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## Release Workflow\n\nPackages are published through GitHub Actions using OIDC trusted publishing, eliminating the need for npm access tokens after initial setup.\n\n### Release Process\n\n1. **Version bump** — Run `npm version patch` (or `minor`/`major`) in the package directory\n2. **Tag creation** — The npm version command creates a git tag (`v<x.y.z>`)\n3. **Push with tags** — `git push origin main --follow-tags` triggers the workflow\n4. **Automated publish** — GitHub Actions verifies the tag matches `package.json` version and publishes to npm\n\n### Coordinated Releases\n\nWhen a package update requires changes in dependent packages:\n\n1. Publish the base package (e.g., `barn`) first\n2. Wait for npm publication (~60 seconds)\n3. Run `npm install` in consumer repositories to update lockfiles\n4. Commit the lockfile changes\n5. Proceed with dependent package releases\n\n资料来源：[RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n\n## CLI Entry Point\n\nThe unified CLI is implemented in `bin/grainulation.js`, which serves as the main entry point for the ecosystem:\n\n```mermaid\ngraph LR\n    A[\"grainulation CLI\"] --> B[\"bin/grainulation.js\"]\n    B --> C[\"lib/router.js\"]\n    B --> D[\"lib/ecosystem.js\"]\n    B --> E[\"lib/doctor.js\"]\n    B --> F[\"lib/pm.js\"]\n    \n    C --> G1[\"wheat\"]\n    C --> G2[\"farmer\"]\n    C --> G3[\"barn\"]\n    C --> G4[\"mill\"]\n    \n    D --> H[\"Health Checks\"]\n    E --> I[\"Diagnostics\"]\n    F --> J[\"Package Ops\"]\n```\n\nThe router (`lib/router.js`) delegates commands to the appropriate tool package, while the ecosystem module (`lib/ecosystem.js`) provides health checks and tool discovery capabilities.\n\n资料来源：[CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n\n## See Also\n\n- [wheat](../wheat/research-sprint) — Research sprint initialization\n- [barn](../barn/validation) — Evidence validation and grading\n- [farmer](../farmer/permissions) — Permission dashboard for AI agents\n- [mill](../mill/export) — Export and publishing tools\n\n---\n\n<a id='server-routing'></a>\n\n## Server and Routing\n\n### 相关页面\n\n相关主题：[CLI Architecture](#cli-architecture), [Tool Integration](#tool-integration)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [lib/server.mjs](https://github.com/grainulation/grainulation/blob/main/lib/server.mjs)\n- [lib/router.js](https://github.com/grainulation/grainulation/blob/main/lib/router.js)\n- [bin/grainulation.js](https://github.com/grainulation/grainulation/blob/main/bin/grainulation.js)\n- [lib/ecosystem.js](https://github.com/grainulation/grainulation/blob/main/lib/ecosystem.js)\n- [lib/doctor.js](https://github.com/grainulation/grainulation/blob/main/lib/doctor.js)\n</details>\n\n# Server and Routing\n\n## Overview\n\nThe Server and Routing system in Grainulation serves as the foundational infrastructure that handles command dispatch, local development server operations, and ecosystem health management. This system orchestrates the eight independent CLI tools within the ecosystem, providing a unified entry point and centralized coordination layer.\n\nThe routing architecture follows a delegation pattern where the main CLI entrypoint (`bin/grainulation.js`) routes incoming commands to the appropriate tool-specific handlers, while the local server (`lib/server.mjs`) provides an ESM-based dashboard for ecosystem monitoring and interaction.\n\n## Architecture\n\n```mermaid\ngraph TD\n    User[User] --> CLI[bin/grainulation.js<br/>CLI Entrypoint]\n    CLI --> Router[lib/router.js<br/>Command Router]\n    Router --> Wheat[wheat<br/>Research Engine]\n    Router --> Farmer[farmer<br/>Permission Dashboard]\n    Router --> Mill[mill<br/>Export Tools]\n    Router --> Harvest[harvest<br/>Analytics]\n    Router --> Silo[silo<br/>Shared Config]\n    Router --> Barn[barn<br/>Shared Utilities]\n    Router --> Orchard[orchard<br/>Orchestration]\n    CLI --> Server[lib/server.mjs<br/>Local Server]\n    Server --> Ecosystem[lib/ecosystem.js<br/>Health Checks]\n    Server --> Doctor[lib/doctor.js<br/>Diagnostics]\n```\n\n## Key Components\n\n### CLI Entrypoint (`bin/grainulation.js`)\n\nThe primary command-line interface entrypoint that initializes the routing system and delegates to individual tool packages. This file provides the unified CLI experience for all grainulation tools.\n\n| Aspect | Details |\n|--------|---------|\n| Type | Main executable script |\n| Format | JavaScript (CommonJS) |\n| Purpose | Routes to individual tools |\n| Dependencies | Zero npm dependencies |\n\n**Usage:**\n```bash\nnode bin/grainulation.js --help\ngrainulation doctor       # Health check\ngrainulation setup        # Install tools\ngrainulation wheat init   # Delegate to wheat\n```\n\n### Command Router (`lib/router.js`)\n\nThe router module handles command dispatching, parsing incoming arguments and determining which tool package should handle the request. It implements the core routing logic that enables the meta-package approach.\n\n| Aspect | Details |\n|--------|---------|\n| Type | Module |\n| Format | CommonJS (.js) |\n| Purpose | Routes commands to correct tool package |\n| Integration | Called by bin/grainulation.js |\n\nThe router acts as the central switchboard, ensuring commands reach their intended tool while maintaining a consistent interface across the ecosystem.\n\n### Local Server (`lib/server.mjs`)\n\nThe local development server implemented as an ESM module, providing a unified ecosystem dashboard. This server runs locally and offers real-time monitoring of the entire grainulation ecosystem.\n\n| Aspect | Details |\n|--------|---------|\n| Type | HTTP Server |\n| Format | ES Module (.mjs) |\n| Purpose | Unified ecosystem dashboard |\n| Port | Configurable |\n\n**Key Features:**\n- Real-time ecosystem health monitoring\n- SSE (Server-Sent Events) for live updates\n- Zero external dependencies\n- Plain JSON and HTML responses\n\n### Ecosystem Health (`lib/ecosystem.js`)\n\nManages ecosystem-wide health checks and tool discovery. This module maintains awareness of all installed tools and their operational status.\n\n| Function | Description |\n|----------|-------------|\n| Health checks | Validates tool installations |\n| Tool discovery | Finds and catalogs available tools |\n| Status reporting | Provides ecosystem overview |\n\n### Diagnostic Tool (`lib/doctor.js`)\n\nA diagnostic utility that validates tool installations and reports configuration issues. It performs pre-flight checks to ensure the ecosystem is properly configured.\n\n**Command:**\n```bash\ngrainulation doctor\n```\n\n**Validation Checks:**\n- Tool presence verification\n- Version compatibility checks\n- Configuration file validation\n\n## Command Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as bin/grainulation.js\n    participant Router as lib/router.js\n    participant Server as lib/server.mjs\n    participant Tool as Individual Tool\n    \n    User->>CLI: grainulation wheat init\n    CLI->>Router: Parse command\n    Router->>Tool: Route to wheat\n    Tool-->>User: Execute command\n    \n    User->>CLI: grainulation server start\n    CLI->>Server: Start dashboard\n    Server->>Server: Initialize ESM server\n    Server-->>User: Dashboard available\n    \n    User->>CLI: grainulation doctor\n    CLI->>Router: Parse command\n    Router->>Server: Check ecosystem health\n    Server-->>Router: Health status\n    Router-->>User: Diagnostic report\n```\n\n## Server Implementation\n\nThe `lib/server.mjs` module follows modern ESM conventions with the following characteristics:\n\n**Module Type:** ECMAScript Modules (ESM)  \n**Dependencies:** Node.js built-ins only  \n**Transport:** Server-Sent Events (SSE) for real-time updates  \n**Response Format:** Plain JSON and HTML\n\nThe server operates without external npm dependencies, maintaining the project's zero-dependency philosophy while providing full ecosystem monitoring capabilities.\n\n## Routing Configuration\n\nThe routing system supports delegation to eight distinct tools:\n\n| Tool | Command Pattern | Purpose |\n|------|-----------------|---------|\n| wheat | `grainulation wheat <cmd>` | Research engine |\n| farmer | `grainulation farmer start` | Permission dashboard |\n| mill | `grainulation mill export` | Export and publish |\n| harvest | `grainulation harvest analyze` | Analytics |\n| silo | `grainulation silo status` | Shared configuration |\n| barn | `grainulation barn detect` | Shared utilities |\n| orchard | `grainulation orchard` | Orchestration |\n| grainulation | `grainulation <cmd>` | Meta-tool commands |\n\n## Setup and Initialization\n\nFirst-run setup is handled by `lib/setup.js`, which prepares the environment for tool usage. This includes:\n\n1. Configuration file creation\n2. Tool directory initialization\n3. Environment validation\n\n**Command:**\n```bash\ngrainulation setup\n```\n\n## Health Monitoring\n\nThe ecosystem provides continuous health monitoring through:\n\n- **Automatic checks:** Performed on tool access\n- **Manual diagnostics:** Via `grainulation doctor`\n- **Dashboard view:** Via `lib/server.mjs` dashboard\n\n## Dependencies\n\nThe Server and Routing system maintains zero external npm dependencies:\n\n| Module | Node.js Built-ins Used |\n|--------|------------------------|\n| server.mjs | http, fs, path, events |\n| router.js | fs, path, child_process |\n| ecosystem.js | fs, path |\n| doctor.js | fs, child_process |\n\n## Security\n\nThe implementation includes security headers configured in the site's HTML:\n\n```html\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'\">\n```\n\nThis CSP configuration ensures:\n- Self-hosted resources only\n- Inline scripts for functionality\n- No external connections\n- Data URIs for embedded images\n\n---\n\n<a id='extensibility-guide'></a>\n\n## Extensibility Guide\n\n### 相关页面\n\n相关主题：[Tool Integration](#tool-integration), [Ecosystem Overview](#ecosystem-overview)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [CONTRIBUTING.md](https://github.com/grainulation/grainulation/blob/main/CONTRIBUTING.md)\n- [README.md](https://github.com/grainulation/grainulation/blob/main/README.md)\n- [package.json](https://github.com/grainulation/grainulation/blob/main/package.json)\n- [RELEASE.md](https://github.com/grainulation/grainulation/blob/main/RELEASE.md)\n- [site/index.html](https://github.com/grainulation/grainulation/blob/main/site/index.html)\n</details>\n\n# Extensibility Guide\n\n## Overview\n\nThe grainulation ecosystem is designed as a modular, extensible CLI framework for structured technical research and decision-making. Built with zero npm dependencies, the system follows a hub-and-spoke architecture where the main `grainulation` package serves as the orchestrator and unified entry point for eight specialized tools: `wheat`, `farmer`, `barn`, `mill`, `silo`, `harvest`, `orchard`, and `grainulator`.\n\nThe ecosystem architecture enables horizontal scaling of functionality through independently deployable packages while maintaining a consistent user experience through the centralized CLI router. Each tool follows a strict contract: typed claims with evidence grades, compilation logic, and output formats that integrate seamlessly with the broader research workflow.\n\n## Architecture\n\n### Hub-and-Spoke Model\n\nThe grainulation ecosystem follows a hub-and-spoke architecture where the core `grainulation` package routes commands to specialized tools. This design allows each tool to remain focused on a single responsibility while benefiting from shared infrastructure.\n\n```\ngraph TD\n    A[User: grainulation command] --> B[bin/grainulation.js]\n    B --> C[lib/router.js]\n    C --> D[Tool: wheat]\n    C --> E[Tool: farmer]\n    C --> F[Tool: barn]\n    C --> G[Tool: silo]\n    C --> H[Tool: mill]\n    C --> I[Tool: harvest]\n    C --> J[Tool: orchard]\n    \n    K[lib/ecosystem.js] -.->|health checks| C\n    L[lib/doctor.js] -.->|diagnostics| C\n    M[lib/pm.js] -.->|package management| C\n```\n\n资料来源：[CONTRIBUTING.md:31-46]()\n\n### Directory Structure\n\nThe grainulation repository maintains a clean separation between infrastructure code and tool implementations:\n\n| Directory | Purpose | Key Files |\n|-----------|---------|-----------|\n| `bin/` | CLI entry point | `grainulation.js` - Main executable |\n| `lib/` | Core infrastructure | `router.js`, `ecosystem.js`, `doctor.js`, `pm.js`, `setup.js` |\n| `public/` | Web UI assets | Ecosystem dashboard |\n| `site/` | Public website | Static site for grainulation.com |\n| `test/` | Test suite | Node built-in test runner tests |\n\n资料来源：[CONTRIBUTING.md:31-46]()\n\n## Tool Ecosystem\n\n### Available Tools\n\nThe eight tools in the grainulation ecosystem form a complete research-to-decision pipeline:\n\n| Tool | Role | Function |\n|------|------|----------|\n| `wheat` | Research engine | Initiate sprints, research topics, challenge findings |\n| `farmer` | Permission dashboard | Approve AI agent tool calls in real-time |\n| `barn` | Collaboration | Team-based claim management |\n| `mill` | Export | Generate PDFs, CSVs, static sites from compiled research |\n| `silo` | Documentation | Document and share decision briefs |\n| `harvest` | Analytics | Track prediction accuracy, detect stale claims |\n| `orchard` | Status monitoring | Ecosystem health checks and tool discovery |\n| `grainulator` | Plugin | Custom extension mechanism |\n\n资料来源：[README.md:59-75]()\n\n### Inter-Tool Communication\n\nTools communicate through a shared claims data model. Every claim follows a consistent structure with type, evidence grade, and metadata. This standardization enables seamless handoffs between tools:\n\n```\ngraph LR\n    A[wheat: research] -->|claims.json| B[farmer: challenge]\n    B -->|updated claims| C[barn: collaborate]\n    C -->|merged claims| D[mill: export]\n    D -->|compiled brief| E[silo: publish]\n    \n    F[harvest: analyze] -.->|cross-sprint insights| A\n    G[orchard: status] -.->|health reports| A\n```\n\n## Extending the Ecosystem\n\n### Adding New Tools\n\nThe architecture supports adding new tools through a consistent pattern. Each tool must:\n\n1. Follow the npm package naming convention `@grainulation/<tool-name>`\n2. Accept claims in the standardized format\n3. Produce output compatible with other tools in the pipeline\n4. Implement zero-dependency principles using Node.js built-ins\n\nTo add a new tool to the ecosystem:\n\n```bash\n# Create new package following grainulation naming conventions\nmkdir @grainulation/newtool\ncd newtool\nnpm init\n```\n\nThe router in `lib/router.js` automatically discovers and routes to new tools based on their npm package naming, enabling plug-and-play extensibility without modifying core infrastructure.\n\n资料来源：[CONTRIBUTING.md:15-30]()\n\n### Package Management Integration\n\nThe `lib/pm.js` module handles package management for grainulation tools. When a new tool is installed via npm, the system:\n\n1. Detects the `@grainulation/*` package scope\n2. Registers the tool with the local router\n3. Updates ecosystem health status\n4. Makes the tool available through the unified CLI\n\n```javascript\n// lib/pm.js handles tool discovery and registration\n// New tools automatically integrate through npm install\n```\n\n资料来源：[CONTRIBUTING.md:42]()\n\n### Health Checks and Diagnostics\n\nThe ecosystem includes built-in health monitoring through two complementary systems:\n\n| Component | Purpose | Location |\n|-----------|---------|----------|\n| `orchard` | Tool discovery and status | `orchard.grainulation.com` |\n| `doctor` | Diagnostic validation | `lib/doctor.js` |\n\nThe `doctor.js` module validates tool installations and reports configuration issues. This enables users to diagnose problems without external dependencies.\n\n资料来源：[CONTRIBUTING.md:41]()\n\n## CLI Extensibility\n\n### Unified Entry Point\n\nThe `bin/grainulation.js` file serves as the single entry point for all ecosystem commands. It delegates to specialized tools based on command arguments:\n\n```bash\n# Router dispatches to appropriate tool\nnode bin/grainulation.js <tool-name> <command> [args]\n```\n\nThe bin entry point is registered in `package.json`:\n\n```json\n{\n  \"bin\": {\n    \"grainulation\": \"bin/grainulation.js\"\n  }\n}\n```\n\n资料来源：[package.json:8-10]()\n\n### Command Routing\n\nThe `lib/router.js` module implements intelligent command routing. It:\n\n1. Parses incoming CLI arguments\n2. Maps commands to tool packages\n3. Handles cross-tool invocations\n4. Manages command aliases\n\n### Local Server Extension\n\nThe ecosystem includes an ESM server (`lib/server.mjs`) for web-based extensions. This enables:\n\n- Real-time dashboard views\n- SSE-based permission workflows\n- Browser-based collaboration interfaces\n\nThe server maintains zero dependencies, using only Node.js built-in modules for HTTP and streaming functionality.\n\n资料来源：[CONTRIBUTING.md:44]()\n\n## Configuration and Setup\n\n### First-Run Setup\n\nThe `lib/setup.js` module handles first-run configuration. When a new tool is invoked for the first time, the system:\n\n1. Creates necessary directory structures\n2. Generates default configuration files\n3. Establishes claims storage locations\n4. Initializes git hooks for audit trail\n\n### Configuration Schema\n\nEach tool follows a consistent configuration pattern. The `wheat` tool demonstrates the standard approach with `wheat.config.json`:\n\n| Setting | Purpose |\n|---------|---------|\n| `question` | Research question being investigated |\n| `audience` | Primary stakeholders for the decision |\n| `constraints` | Hard requirements that must be satisfied |\n| `claims[]` | Array of typed claims with evidence grades |\n\n## Publishing and Distribution\n\n### Package Publishing Workflow\n\nTools publish through a standardized GitHub Actions workflow defined in `.github/workflows/publish.yml`. The workflow:\n\n1. Runs tests against the package\n2. Verifies version matches git tag\n3. Publishes with npm provenance via OIDC\n4. Eliminates need for NPM_TOKEN secrets\n\n资料来源：[RELEASE.md:1-18]()\n\n### Publishing Commands\n\n```bash\n# Single-package patch release\ncd <repo>\nnpm version patch\ngit push origin main --follow-tags\n\n# Coordinated release (multiple packages)\n# 1. Publish dependency first\ncd barn && npm version patch && git push origin main --follow-tags\n# 2. Wait for npm to reflect the new version (~60s)\n# 3. Update consumers\ncd consumer && npm install && git commit -m \"Update barn dependency\"\nnpm version patch && git push origin main --follow-tags\n```\n\n资料来源：[RELEASE.md:19-32]()\n\n## Best Practices for Extensions\n\n### Zero-Dependency Principle\n\nAll grainulation tools must adhere to the zero-dependency principle:\n\n- Use only Node.js built-in modules (`fs`, `path`, `http`, `crypto`, etc.)\n- Ship required utilities within the package\n- Avoid supply chain vulnerabilities\n- Enable offline operation\n\nThis principle ensures reliability and security across the entire ecosystem.\n\n### Claim Type System\n\nExtensions should implement the standardized claim type system:\n\n| Type | Description | Example |\n|------|-------------|---------|\n| `factual` | Verified facts | Performance metrics, API specs |\n| `risk` | Potential issues | Security vulnerabilities, failure modes |\n| `estimate` | Informed estimates | Resource projections, timeline forecasts |\n| `constraint` | Hard requirements | Regulatory compliance, SLA requirements |\n| `recommendation` | Suggested actions | Architectural choices, implementation approaches |\n\nEach claim includes an evidence grade from \"someone said it\" to \"measured in production\", enabling the compiler to validate and resolve conflicts.\n\n### Audit Trail Integration\n\nAll claims should maintain git-based audit trails showing:\n\n- When claims were collected\n- How claims were challenged\n- Resolution of conflicts\n- Final compilation decisions\n\nThis enables full traceability of the research process and supports post-decision retrospectives.\n\n## Contributing Extensions\n\n### Development Workflow\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/tool-name`\n3. Implement the tool following grainulation conventions\n4. Add tests using Node built-in test runner\n5. Run existing tests: `node test/basic.test.js`\n6. Submit a pull request\n\n### Testing Requirements\n\nThe project uses Node's built-in test runner. Tests must:\n\n- Cover core functionality\n- Handle error cases gracefully\n- Maintain zero external dependencies\n- Pass on Node.js 20+\n\n```bash\n# Run all tests\nnode test/basic.test.js\nnode --test test/tarball.test.mjs\n```\n\n### Code Quality\n\nThe project uses Biome for linting and formatting:\n\n```bash\n# Check code style\nnpm run lint\n\n# Auto-format code\nnpm run format\n```\n\n资料来源：[CONTRIBUTING.md:15-30]()\n\n## Summary\n\nThe grainulation extensibility model provides a robust framework for building specialized research and decision-making tools. By adhering to the hub-and-spoke architecture, zero-dependency principle, and standardized claims format, new tools can seamlessly integrate into the ecosystem while maintaining independence and focus. The modular design enables teams to adopt only the tools they need while preserving the ability to expand functionality as requirements evolve.\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：grainulation/grainulation\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：能力坑 - 能力判断依赖假设。\n\n## 1. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1184031176 | https://github.com/grainulation/grainulation | README/documentation is current enough for a first validation pass.\n\n## 2. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | last_activity_observed missing\n\n## 3. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 4. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 来源证据：v1.1.0 — Security Hardening\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.1.0 — Security Hardening\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_5e8c2578dd024d369fd769a7c23df98a | https://github.com/grainulation/grainulation/releases/tag/v1.1.0 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | release_recency=unknown\n\n<!-- canonical_name: grainulation/grainulation; human_manual_source: deepwiki_human_wiki -->\n",
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "Human Manual / 人类版说明书"
    },
    "pitfall_log": {
      "asset_id": "pitfall_log",
      "filename": "PITFALL_LOG.md",
      "markdown": "# Pitfall Log / 踩坑日志\n\n项目：grainulation/grainulation\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：能力坑 - 能力判断依赖假设。\n\n## 1. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1184031176 | https://github.com/grainulation/grainulation | README/documentation is current enough for a first validation pass.\n\n## 2. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | last_activity_observed missing\n\n## 3. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 4. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1184031176 | https://github.com/grainulation/grainulation | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 来源证据：v1.1.0 — Security Hardening\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v1.1.0 — Security Hardening\n- 对用户的影响：可能增加新用户试用和生产接入成本。\n- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。\n- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。\n- 证据：community_evidence:github | cevd_5e8c2578dd024d369fd769a7c23df98a | https://github.com/grainulation/grainulation/releases/tag/v1.1.0 | 来源讨论提到 npm 相关条件，需在安装/试用前复核。\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1184031176 | https://github.com/grainulation/grainulation | release_recency=unknown\n",
      "summary": "用户实践前最可能遇到的身份、安装、配置、运行和安全坑。",
      "title": "Pitfall Log / 踩坑日志"
    },
    "prompt_preview": {
      "asset_id": "prompt_preview",
      "filename": "PROMPT_PREVIEW.md",
      "markdown": "# grainulation - Prompt Preview\n\n> Copy the prompt below into your AI host before installing anything.\n> Its purpose is to let you safely feel the project's workflow, not to claim the project has already run.\n\n## Copy this prompt\n\n```text\nYou are using an independent Doramagic capability pack for grainulation/grainulation.\n\nProject:\n- Name: grainulation\n- Repository: https://github.com/grainulation/grainulation\n- Summary: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n- Host target: mcp_host\n\nGoal:\nHelp me evaluate this project for the following task without installing it yet: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n\nBefore taking action:\n1. Restate my task, success standard, and boundary.\n2. Identify whether the next step requires tools, browser access, network access, filesystem access, credentials, package installation, or host configuration.\n3. Use only the Doramagic Project Pack, the upstream repository, and the source-linked evidence listed below.\n4. If a real command, install step, API call, file write, or host integration is required, mark it as \"requires post-install verification\" and ask for approval first.\n5. If evidence is missing, say \"evidence is missing\" instead of filling the gap.\n\nPreviewable capabilities:\n- Capability 1: The grainulation ecosystem. Structured research, decision-making, and knowledge management for AI agents.\n\nCapabilities that require post-install verification:\n- Capability 1: Use the source-backed project context to guide one small, checkable workflow step.\n\nCore service flow:\n1. project-overview: Project Overview. Produce one small intermediate artifact and wait for confirmation.\n2. cli-architecture: CLI Architecture. Produce one small intermediate artifact and wait for confirmation.\n3. command-reference: Command Reference. Produce one small intermediate artifact and wait for confirmation.\n4. ecosystem-overview: Ecosystem Overview. Produce one small intermediate artifact and wait for confirmation.\n5. setup-installation: Setup and Installation. Produce one small intermediate artifact and wait for confirmation.\n\nSource-backed evidence to keep in mind:\n- https://github.com/grainulation/grainulation\n- https://github.com/grainulation/grainulation#readme\n- README.md\n- package.json\n- docs/ecosystem.md\n- bin/grainulation.js\n- lib/router.js\n- lib/server.mjs\n- lib/ecosystem.js\n- lib/doctor.js\n\nFirst response rules:\n1. Start Step 1 only.\n2. Explain the one service action you will perform first.\n3. Ask exactly three questions about my target workflow, success standard, and sandbox boundary.\n4. Stop and wait for my answers.\n\nStep 1 follow-up protocol:\n- After I answer the first three questions, stay in Step 1.\n- Produce six parts only: clarified task, success standard, boundary conditions, two or three options, tradeoffs for each option, and one recommendation.\n- End by asking whether I confirm the recommendation.\n- Do not move to Step 2 until I explicitly confirm.\n\nConversation rules:\n- Advance one step at a time and wait for confirmation after each small artifact.\n- Write outputs as recommendations or planned checks, not as completed execution.\n- Do not claim tests passed, files changed, commands ran, APIs were called, or the project was installed.\n- If the user asks for execution, first provide the sandbox setup, expected output, rollback, and approval checkpoint.\n```\n",
      "summary": "不安装项目也能感受能力节奏的安全试用 Prompt。",
      "title": "Prompt Preview / 安装前试用 Prompt"
    },
    "quick_start": {
      "asset_id": "quick_start",
      "filename": "QUICK_START.md",
      "markdown": "# Quick Start / 官方入口\n\n项目：grainulation/grainulation\n\n## 官方安装入口\n\n### Node.js / npm · 官方安装入口\n\n```bash\nnpm install -g @grainulation/grainulation\n```\n\n来源：https://github.com/grainulation/grainulation#readme\n\n## 来源\n\n- repo: https://github.com/grainulation/grainulation\n- docs: https://github.com/grainulation/grainulation#readme\n",
      "summary": "从项目官方 README 或安装文档提取的开工入口。",
      "title": "Quick Start / 官方入口"
    }
  },
  "validation_id": "dval_5c0769632ff947e08b65a16f9a24f853"
}
