• 设计见 docs/done/system-design/28-agent-registry-unification.md。
    
    改造前 Agent 本体散在三处(system/agents/ 11 个、system/templates/ 50 个、
    data/companies/{id}/agents/ 17 个),同一个 AgentScaffold 被三个 baseDir 实例化。
    后果是同一角色在 N 家公司下有 N 份互不相干的副本,模板更新不会同步;
    org-coder / org-planner 这类走 hireFromBaseMetaAgent 造出来的本体
    legacy_path 指回自己公司目录,永远无法被第二家公司复用。
    
    本次:
    - G1 单一注册表:system/templates/ 整体并入 system/agents/,base → _base。
      7 个同名 id 逐个裁决,被丢弃的一份归档到 docs/_archive/ 而非删除。
      source_kind(template/global_agent/company_hired) → origin(builtin/created)。
    - G2 运行态下沉:CLI 的 cwd 从本体根改为 system/agents/{aid}/{cid}/{taskId}/。
      memory / conversations 落公司态 {aid}/{cid}/,按公司隔离不串。
      sessionPool 的 key 含 (companyId, taskId),两家公司调同一 agent 不复用会话。
    - G2b 产物不下沉:交付物仍落 data/companies/{cid}/,system/agents/ 只留运行痕迹。
      写入边界按链路分叉——graph 节点走节点私有目录(被 indexNodeOutputs 索引),
      chat 走公司 workspace,同一提示词里不再出现两条互斥指令。
    - G3 公司只存引用:data/companies/{id}/agents/ 删除,新增 company_agents 关联表。
      不复用 org_graph_nodes——后者是执行流图,work 层本体被雇时不写它,天生覆盖不全。
    - G4 缺则创建:本体缺失时从 _base 复制骨架进 system/agents/{id}/,
      agent-creator 填 agent.md/soul.md 后才从 draft 转 active(哨兵判据,
      骨架未填时哨兵仍在,不许被 hire)。产物即刻是全系统可复用的本体。
    
    新增 server/services/agent-locator.js 收编原先散在 6 处的寻址逻辑。
    
    边界守卫(graph-engine)的豁免从「本体根上五个文件名」放宽为整棵 system/agents/:
    新本体的骨架本来就要进 git,gitignore 挡不住 ?? system/agents/{newId}/,
    旧判据会把一个真正成功的招聘节点判成 boundary_escape fail。
    
    存量迁移见 scripts/migrate-agent-registry.js(幂等,备份到 data/_migration-backup-*)。
    
    真 Claude CLI E2E 已验证:新建公司 → orggraph-planning 自动规划 →
    自动招聘 org-planner/org-coder/org-validator 三节点流水线;
    data/companies/{cid}/agents/ 不存在,company_agents 4 行,
    system_agents 56→56(零新建私有本体,纯复用),git status 零增量。
    
    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    yibo authored
     
    Browse Dir »

  • Final P0 deliverables to make the system bootable in mock mode and
    pass `scripts/phase0-verify.js` + `scripts/phase0-test-call.js` end-to-end.
    
    ClaudeCliProtocol (mock mode):
    - LEMONBOSS_CLAUDE_MODE=mock or { mock: true } in constructor enables
      mock mode. connect() becomes a no-op; sendPrompt reads fixtures from
      fixtures/devloop-mock/{agentName}.json and emits scripted session_update
      chunks + session/result(mock=true). Falls back to default.json.
    
    Agent registry:
    - 6 entries added to system/templates/_registry.json (devloop-pm,
      devloop-architect, devloop-coder, devloop-tester, devloop-integrator,
      devloop-triager).
    - Per-agent dirs system/templates/devloop-{role}/ with:
      * prompt.md   — auto-extracted from agents-{role}.html §2.2
      * config.json — cli.toolPolicy.allowedTools + sandbox.writeAllowList
    
    Tooling:
    - scripts/extract-agent-prompts.js  — regex-extracts §2.2 system prompts
      from 6 agent HTML pages to system/templates/devloop-{role}/prompt.md.
    - server/src/tools/devloop/index.js — central export (tools Map,
      bashHooks, dispatch).
    - server/src/core/devloop/loop-controller.js (P0 skeleton) — exposes
      createProject (sandbox alloc + git init + first commit + timeline) and
      commitAfterAgent (per-agent kind-routed git commit + timeline event).
    
    Mock fixtures:
    - fixtures/devloop-mock/default.json + devloop-pm.json
    
    Acceptance scripts:
    - scripts/phase0-verify.js   — 8 static checks (35 tools loadable,
      6 agents registered, prompt+config wired, bash guard exported, services
      require, fixtures present, git-vault interface, loop-controller).
    - scripts/phase0-test-call.js — 7 end-to-end steps under mock mode
      (createProject → CLI connect → sendPrompt chunks → no-op commit returns
      null → real write commits → git log ≥2 → timeline has both events).
    
    vitest.config.js: include packages/**/*.test.js so the mock smoke test
    runs in the suite.
    
    Results:
    - 162/162 devloop + acp-core tests pass (up from 159).
    - phase0-verify: 8/8.
    - phase0-test-call: 7/7.
    
    Specs: docs/prd/newfunction/_spec/plan-migration.md · Quick-Start step 7
    
    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
    yibo authored
     
    Browse Dir »