reasonweave 0.0.0-stage → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +101 -0
- package/INSTALL.md +258 -0
- package/README.md +280 -2
- package/bin/lab.mjs +888 -0
- package/constitution.md +55 -0
- package/docs/CONSUMER-PROMPTS.md +474 -0
- package/docs/backlogs/01-forward-wait-self-detach.md +18 -0
- package/docs/backlogs/02-decouple-wait-and-daemon-for-agent-hosts.md +35 -0
- package/docs/backlogs/03-baton-wait-multi-id-lightweight-pubsub.md +34 -0
- package/docs/backlogs/04-adr-cross-repo-automated-dispatch-boundary.md +19 -0
- package/docs/backlogs/05-feat-units-worktree-isolation-engine.md +23 -0
- package/docs/backlogs/06-feat-blind-audit-automated-clean-runner.md +22 -0
- package/docs/backlogs/07-feat-attention-throttle-silent-pipe.md +23 -0
- package/docs/backlogs/08-future-units-shadow-ledger.md +22 -0
- package/docs/backlogs/09-feat-agent-baton-core-convergence-and-resilience.md +42 -0
- package/docs/backlogs/10-feat-anti-orphan-deterministic-wiring-governance.md +35 -0
- package/docs/backlogs/11-perf-orphan-index-fs-read.md +16 -0
- package/docs/backlogs/12-feat-vibe-security-anti-suppression-and-orphan-deps.md +43 -0
- package/docs/backlogs/13-feat-sdd-reppit-tiered-guardrails.md +40 -0
- package/docs/backlogs/14-feat-universal-cli-contract-and-hermetic-test-fixtures.md +48 -0
- package/docs/backlogs/15-feat-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +44 -0
- package/docs/backlogs/16-feat-micro-engineering-skills-and-sdd-baton-fusion.md +52 -0
- package/docs/codegraph-readiness-check.md +49 -0
- package/group/architecture/adr/0001-handoff-async-wait-and-reactive-wakeup.md +87 -0
- package/group/architecture/adr/0002-de-ritualize-handoff-prompt-for-intra-repo.md +53 -0
- package/group/architecture/adr/0003-attention-throttle-and-workspace-driver.md +65 -0
- package/group/architecture/adr/0004-spec-guard-and-drift-prevention.md +90 -0
- package/group/architecture/adr/0005-global-orphan-scavenger-and-read-only-invariants.md +94 -0
- package/group/architecture/adr/0006-triad-engineering-defense-and-mutation-sensitivity.md +68 -0
- package/group/architecture/adr/0007-agent-baton-state-machine-defense-and-workspace-jail-spec.md +86 -0
- package/group/architecture/adr/0008-agent-baton-core-convergence-and-heterogeneous-session-resilience.md +133 -0
- package/group/architecture/adr/0009-anti-orphan-deterministic-wiring-governance-and-federated-guardrails.md +108 -0
- package/group/architecture/adr/0010-agent-baton-identity-security-cryptographic-credentials-and-prompt-anti-confusion.md +119 -0
- package/group/architecture/adr/0011-vibe-security-anti-suppression-and-dependency-reachability.md +161 -0
- package/group/architecture/adr/0012-spec-driven-development-reppit-and-tiered-guardrails.md +130 -0
- package/group/architecture/adr/0013-universal-cli-contract-hermetic-testing-and-defensive-probes.md +110 -0
- package/group/architecture/adr/0014-reasonweave-rebranding-and-doc-code-synchronization-invariant.md +108 -0
- package/group/architecture/adr/0015-micro-engineering-skills-and-dual-core-gate-invariant.md +127 -0
- package/group/architecture/adr/INDEX.md +29 -0
- package/group/architecture/adr/templates/adr-template.md +33 -0
- package/group/architecture/dependency-graph.md +60 -0
- package/group/contracts/npm-packaging.md +69 -0
- package/group/product/intent.md +24 -0
- package/package.json +93 -4
- package/scripts/sync-all-consumers.mjs +174 -0
- package/specs/RFC-20261110-SPEC-GUARD-UNIT.md +353 -0
- package/specs/templates/01-research.md.template +23 -0
- package/specs/templates/02-proposals.md.template +22 -0
- package/specs/templates/03-spec.md.template +33 -0
- package/specs/templates/04-tasks.md.template +29 -0
- package/specs/templates/05-evidence.md.template +29 -0
- package/specs/templates/README.md +26 -0
- package/units/adr/AGENTS.md +85 -0
- package/units/adr/CHANGELOG.md +20 -0
- package/units/adr/README.md +88 -0
- package/units/adr/VERSION.md +10 -0
- package/units/adr/docs/existing-project-prompt.md +24 -0
- package/units/adr/docs/new-project-prompt.md +36 -0
- package/units/adr/scripts/adr-init.sh +101 -0
- package/units/adr/templates/INDEX.md +19 -0
- package/units/adr/templates/adr-frozen.md +33 -0
- package/units/adr/templates/adr-light.md +56 -0
- package/units/adr/templates/adr-standard.md +61 -0
- package/units/backlog/AGENTS.md +53 -0
- package/units/backlog/AUTONOMOUS-GOVERNANCE.md +98 -0
- package/units/backlog/CHANGELOG.md +37 -0
- package/units/backlog/README.md +124 -0
- package/units/backlog/VERSION.md +11 -0
- package/units/backlog/docs/existing-project-ironrules-prompt.md +31 -0
- package/units/backlog/docs/existing-project-prompt.md +24 -0
- package/units/backlog/docs/new-project-prompt.md +19 -0
- package/units/backlog/templates/entry.md +39 -0
- package/units/backlog/templates/project-ironrules.md +36 -0
- package/units/handoffs/AGENT-GUIDE.md +118 -0
- package/units/handoffs/AGENTS.md +28 -0
- package/units/handoffs/CHANGELOG.md +498 -0
- package/units/handoffs/CLAUDE.md +28 -0
- package/units/handoffs/COMMANDS.md +187 -0
- package/units/handoffs/DESIGN.md +74 -0
- package/units/handoffs/README.md +456 -0
- package/units/handoffs/RESPONSE-TEMPLATE.md +138 -0
- package/units/handoffs/VERSION.md +1 -0
- package/units/handoffs/handoff-status.mjs +1017 -0
- package/units/handoffs/handoff.mjs +5675 -0
- package/units/orphan/CHANGELOG.md +118 -0
- package/units/orphan/DESIGN.md +484 -0
- package/units/orphan/README.md +143 -0
- package/units/orphan/VERSION.md +1 -0
- package/units/orphan/adapters/android/index.mjs +140 -0
- package/units/orphan/adapters/python/index.mjs +232 -0
- package/units/orphan/adapters/web/index.mjs +280 -0
- package/units/orphan/bin/lab-orphan.mjs +298 -0
- package/units/orphan/core/blob-reader.mjs +142 -0
- package/units/orphan/core/classifier.mjs +261 -0
- package/units/orphan/core/cleaner.mjs +166 -0
- package/units/orphan/core/diff-checker.mjs +341 -0
- package/units/orphan/core/inverted-index.mjs +124 -0
- package/units/orphan/core/orphan-deps.mjs +192 -0
- package/units/orphan/core/protocol-s1-s3.mjs +194 -0
- package/units/orphan/core/solver.mjs +217 -0
- package/units/orphan/index.mjs +105 -0
- package/units/orphan/templates/ci/orphan-guard.yml +36 -0
- package/units/orphan/templates/pre-commit.d/30-orphan-guard +34 -0
- package/units/orphan/templates/wiring/README.md +51 -0
- package/units/orphan/templates/wiring/miniprogram-route-guard.js.template +80 -0
- package/units/orphan/templates/wiring/pre-commit-node.sh.template +73 -0
- package/units/orphan/templates/wiring/project-agents-gemini-templates.md +60 -0
- package/units/orphan/templates/wiring/python-parity-test.py.template +100 -0
- package/units/orphan/templates/wiring/rust-exhaustive-match.md +65 -0
- package/units/orphan/templates/wiring/swift-periphery.md +56 -0
- package/units/orphan/tests/adapters.test.mjs +243 -0
- package/units/orphan/tests/orphan-deps.test.mjs +131 -0
- package/units/orphan/tests/phase3-gates.test.mjs +135 -0
- package/units/playbook/README.md +106 -0
- package/units/playbook/ZSPEC-AGENT-GUIDE.md +99 -0
- package/units/playbook/docs/01-architecture.md +99 -0
- package/units/playbook/docs/02-bootstrap.md +126 -0
- package/units/playbook/docs/03-units.md +91 -0
- package/units/playbook/docs/04-constitution.md +113 -0
- package/units/playbook/docs/05-adr.md +33 -0
- package/units/playbook/docs/06-spec-kit.md +76 -0
- package/units/playbook/docs/07-backlog.md +30 -0
- package/units/playbook/docs/08-codegraph.md +79 -0
- package/units/playbook/docs/09-skills.md +101 -0
- package/units/playbook/docs/10-handoff.md +72 -0
- package/units/playbook/docs/11-evidence.md +163 -0
- package/units/playbook/docs/12-gates.md +124 -0
- package/units/playbook/docs/13-parallel.md +115 -0
- package/units/playbook/docs/14-dependency-graph.md +86 -0
- package/units/playbook/docs/15-memory.md +153 -0
- package/units/playbook/docs/16-change-control.md +121 -0
- package/units/playbook/docs/17-prompts.md +121 -0
- package/units/playbook/docs/18-shift-left.md +97 -0
- package/units/playbook/docs/19-anti-orphan-vertical-slicing.md +102 -0
- package/units/playbook/docs/20-vibe-security-and-anti-suppression.md +88 -0
- package/units/playbook/docs/21-spec-driven-reppit-closed-loop.md +88 -0
- package/units/playbook/examples/owisel.md +80 -0
- package/units/playbook/references/Agent-Engineering-Framework-AEF-v1.0.md +2033 -0
- package/units/playbook/references/links.md +103 -0
- package/units/playbook/templates/AGENTS.root.md +44 -0
- package/units/playbook/templates/AGENTS.unit.md +52 -0
- package/units/playbook/templates/adr/INDEX.md +17 -0
- package/units/playbook/templates/adr/NNNN-template.md +56 -0
- package/units/playbook/templates/backlogs/entry.md +30 -0
- package/units/playbook/templates/constitution.md +93 -0
- package/units/playbook/templates/evidence/README.md +36 -0
- package/units/playbook/templates/group/architecture/dependency-graph.md +48 -0
- package/units/playbook/templates/group/architecture/system.md +59 -0
- package/units/playbook/templates/group/contracts/api.md +67 -0
- package/units/playbook/templates/group/product/intent.md +30 -0
- package/units/playbook/templates/group/product/requirements.md +48 -0
- package/units/playbook/templates/unit-skeleton/README.md +35 -0
- package/units/preflight/AGENTS.md +45 -0
- package/units/preflight/CHANGELOG.md +55 -0
- package/units/preflight/INSTALL.md +65 -0
- package/units/preflight/README.md +104 -0
- package/units/preflight/VERSION.md +3 -0
- package/units/preflight/docs/audit-requirements.md +114 -0
- package/units/preflight/docs/existing-project-prompt.md +25 -0
- package/units/preflight/docs/new-project-prompt.md +25 -0
- package/units/preflight/docs/transfers/CONSUMER-INSTALL.md +40 -0
- package/units/preflight/docs/transfers/CONSUMER-SELFCHECK.md +51 -0
- package/units/preflight/docs/transfers/README.md +39 -0
- package/units/preflight/docs/transfers/prospero.md +26 -0
- package/units/preflight/templates/check.sh +43 -0
- package/units/preflight/templates/pre-commit +55 -0
- package/units/preflight/templates/pre-commit.d/20-preflight +15 -0
- package/units/preflight/templates/preflight.conf.example +21 -0
- package/units/preflight/templates/preflight.sh +189 -0
- package/units/preflight/templates/wrap-up.md +9 -0
- package/units/review-gate/AGENTS.md +42 -0
- package/units/review-gate/CHANGELOG.md +58 -0
- package/units/review-gate/README.md +118 -0
- package/units/review-gate/VERSION.md +3 -0
- package/units/review-gate/clean-runner.mjs +350 -0
- package/units/review-gate/docs/existing-project-prompt.md +28 -0
- package/units/review-gate/docs/new-project-prompt.md +38 -0
- package/units/review-gate/docs/transfers/iggle.md +34 -0
- package/units/review-gate/docs/transfers/prospero.md +35 -0
- package/units/review-gate/docs/transfers/swoop.md +36 -0
- package/units/review-gate/docs/transfers/yiqiyihuihua.md +35 -0
- package/units/review-gate/templates/.semgrepignore +37 -0
- package/units/review-gate/templates/pre-commit +130 -0
- package/units/review-gate/templates/scan.sh +158 -0
- package/units/skills/AGENTS.md +17 -0
- package/units/skills/CHANGELOG.md +18 -0
- package/units/skills/README.md +63 -0
- package/units/skills/VERSION.md +1 -0
- package/units/skills/bin/review-package.mjs +99 -0
- package/units/skills/bin/task-brief.mjs +102 -0
- package/units/skills/catalog/brainstorming/SKILL.md +75 -0
- package/units/skills/catalog/brainstorming/references/design-doc-template.md +28 -0
- package/units/skills/catalog/systematic-debugging/SKILL.md +101 -0
- package/units/skills/catalog/systematic-debugging/references/root-cause-tracing.md +23 -0
- package/units/skills/catalog/test-driven-development/SKILL.md +88 -0
- package/units/skills/catalog/test-driven-development/references/writing-good-tests.md +13 -0
- package/units/skills/catalog/verification-before-completion/SKILL.md +73 -0
- package/units/skills/skills.mjs +181 -0
- package/units/skills/tests/pipeline.test.mjs +131 -0
- package/units/skills/tests/skill-contract.test.mjs +67 -0
- package/units/skills/tests/skills-cli.test.mjs +107 -0
- package/units/spec-guard/AGENTS.md +43 -0
- package/units/spec-guard/CHANGELOG.md +88 -0
- package/units/spec-guard/README.md +148 -0
- package/units/spec-guard/VERSION.md +1 -0
- package/units/spec-guard/bin/spec-guard.mjs +431 -0
- package/units/spec-guard/core/adr-parser.mjs +540 -0
- package/units/spec-guard/core/matrix-checker.mjs +587 -0
- package/units/spec-guard/core/mutation-runner.mjs +267 -0
- package/units/spec-guard/core/scanner.mjs +333 -0
- package/units/spec-guard/core/telemetry_authenticator.mjs +484 -0
- package/units/spec-guard/core/wiring_tracer.mjs +306 -0
- package/units/spec-guard/templates/annotations/ContractOnly.kt +19 -0
- package/units/spec-guard/templates/annotations/Invariant.kt +16 -0
- package/units/spec-guard/templates/annotations/invariant.go +19 -0
- package/units/spec-guard/templates/annotations/invariant.py +38 -0
- package/units/spec-guard/templates/annotations/invariant.ts +39 -0
- package/units/spec-guard/templates/ci/spec-guard-audit.yml +23 -0
- package/units/spec-guard/templates/pre-commit.d/15-spec-guard +72 -0
- package/units/spec-guard/templates/spec-matrix.overlay.yml +70 -0
- package/units/spec-guard/tests/spec-guard.test.mjs +716 -0
- package/units/spec-guard/tests/telemetry_authenticator.test.mjs +633 -0
- package/units/worktree/AGENTS.md +22 -0
- package/units/worktree/CHANGELOG.md +14 -0
- package/units/worktree/README.md +65 -0
- package/units/worktree/VERSION.md +1 -0
- package/units/worktree/worktree.mjs +352 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.md +322 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { test, describe } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import { OrphanDepsSolver } from '../core/orphan-deps.mjs';
|
|
8
|
+
|
|
9
|
+
describe('OrphanDepsSolver & Secrets Scanner (ADR-0011 / ADR-0012)', () => {
|
|
10
|
+
test('detects orphan dependencies in Python requirements.txt', async () => {
|
|
11
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'orphan-py-'));
|
|
12
|
+
try {
|
|
13
|
+
fs.writeFileSync(
|
|
14
|
+
path.join(tmpDir, 'requirements.txt'),
|
|
15
|
+
'requests>=2.28.0\nflask==2.3.0\nnumpy\npython-dotenv>=1.0.0\n'
|
|
16
|
+
);
|
|
17
|
+
fs.writeFileSync(
|
|
18
|
+
path.join(tmpDir, 'main.py'),
|
|
19
|
+
'import requests\nfrom dotenv import load_dotenv\nload_dotenv()\n'
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// 初始化临时 git 仓库以供 getTrackedFiles 识别
|
|
23
|
+
execSync('git init && git add .', { cwd: tmpDir, stdio: 'pipe' });
|
|
24
|
+
|
|
25
|
+
const solver = new OrphanDepsSolver({ repoDir: tmpDir });
|
|
26
|
+
const results = await solver.scan();
|
|
27
|
+
|
|
28
|
+
assert.equal(results.length, 1);
|
|
29
|
+
const pyResult = results[0];
|
|
30
|
+
assert.equal(pyResult.manifest, 'requirements.txt');
|
|
31
|
+
assert.equal(pyResult.total_declared, 4);
|
|
32
|
+
// flask 与 numpy 未导入,requests 与 python-dotenv (dotenv) 应被保留
|
|
33
|
+
assert.ok(pyResult.orphans.includes('flask'));
|
|
34
|
+
assert.ok(pyResult.orphans.includes('numpy'));
|
|
35
|
+
assert.equal(pyResult.orphans.length, 2);
|
|
36
|
+
} finally {
|
|
37
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('detects orphan dependencies in Node package.json', async () => {
|
|
42
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'orphan-node-'));
|
|
43
|
+
try {
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(tmpDir, 'package.json'),
|
|
46
|
+
JSON.stringify({
|
|
47
|
+
name: 'test-app',
|
|
48
|
+
dependencies: {
|
|
49
|
+
lodash: '^4.17.21',
|
|
50
|
+
express: '^4.18.2',
|
|
51
|
+
chalk: '^5.0.0'
|
|
52
|
+
}
|
|
53
|
+
}, null, 2)
|
|
54
|
+
);
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
path.join(tmpDir, 'index.mjs'),
|
|
57
|
+
'import _ from "lodash";\nconsole.log(_);\n'
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
execSync('git init && git add .', { cwd: tmpDir, stdio: 'pipe' });
|
|
61
|
+
|
|
62
|
+
const solver = new OrphanDepsSolver({ repoDir: tmpDir });
|
|
63
|
+
const results = await solver.scan();
|
|
64
|
+
|
|
65
|
+
assert.equal(results.length, 1);
|
|
66
|
+
const nodeResult = results[0];
|
|
67
|
+
assert.equal(nodeResult.manifest, 'package.json');
|
|
68
|
+
assert.equal(nodeResult.total_declared, 3);
|
|
69
|
+
assert.ok(nodeResult.orphans.includes('express'));
|
|
70
|
+
assert.ok(nodeResult.orphans.includes('chalk'));
|
|
71
|
+
assert.ok(!nodeResult.orphans.includes('lodash'));
|
|
72
|
+
assert.equal(nodeResult.orphans.length, 2);
|
|
73
|
+
} finally {
|
|
74
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('scanSecrets detects real high-entropy tokens and ignores dummy placeholders', () => {
|
|
79
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'secrets-test-'));
|
|
80
|
+
try {
|
|
81
|
+
fs.writeFileSync(
|
|
82
|
+
path.join(tmpDir, 'config.py'),
|
|
83
|
+
'# Valid high-entropy fake token\n' +
|
|
84
|
+
'ghp_token = "ghp_1234567890abcdefghijklmnopqrstuvwxyz"\n' +
|
|
85
|
+
'# Placeholder token should be ignored\n' +
|
|
86
|
+
'dummy_token = "your-token-here"\n' +
|
|
87
|
+
'test_key = "dummy_key_placeholder"\n'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
execSync('git init && git add .', { cwd: tmpDir, stdio: 'pipe' });
|
|
91
|
+
|
|
92
|
+
const solver = new OrphanDepsSolver({ repoDir: tmpDir });
|
|
93
|
+
const findings = solver.scanSecrets();
|
|
94
|
+
|
|
95
|
+
assert.equal(findings.length, 1);
|
|
96
|
+
assert.equal(findings[0].file, 'config.py');
|
|
97
|
+
assert.match(findings[0].match, /ghp_1234567890/);
|
|
98
|
+
} finally {
|
|
99
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('CLI --strict gate exits with code 1 upon findings', () => {
|
|
104
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cli-gate-'));
|
|
105
|
+
const cliPath = path.resolve('units/orphan/bin/lab-orphan.mjs');
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
fs.writeFileSync(
|
|
109
|
+
path.join(tmpDir, 'package.json'),
|
|
110
|
+
JSON.stringify({
|
|
111
|
+
name: 'gate-test',
|
|
112
|
+
dependencies: { unused_pkg: '^1.0.0' }
|
|
113
|
+
}, null, 2)
|
|
114
|
+
);
|
|
115
|
+
fs.writeFileSync(path.join(tmpDir, 'index.js'), 'console.log("hello");\n');
|
|
116
|
+
execSync('git init && git add .', { cwd: tmpDir, stdio: 'pipe' });
|
|
117
|
+
|
|
118
|
+
// 无 --strict 时 exit 0
|
|
119
|
+
assert.doesNotThrow(() => {
|
|
120
|
+
execSync(`node "${cliPath}" check-deps`, { cwd: tmpDir, stdio: 'pipe' });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// 带 --strict 时触发门禁 exit 1
|
|
124
|
+
assert.throws(() => {
|
|
125
|
+
execSync(`node "${cliPath}" check-deps --strict`, { cwd: tmpDir, stdio: 'pipe' });
|
|
126
|
+
}, (err) => err.status === 1);
|
|
127
|
+
} finally {
|
|
128
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests for units/orphan Phase 3 Gates (DiffChecker, Cleaner, Preflight Hook)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { execFileSync } from 'node:child_process';
|
|
10
|
+
import { DiffChecker } from '../core/diff-checker.mjs';
|
|
11
|
+
import { Cleaner } from '../core/cleaner.mjs';
|
|
12
|
+
|
|
13
|
+
test('DiffChecker: parseDiff correctly extracts added lines and new files', () => {
|
|
14
|
+
const sampleDiff = `
|
|
15
|
+
diff --git a/src/new_module.py b/src/new_module.py
|
|
16
|
+
new file mode 100644
|
|
17
|
+
--- /dev/null
|
|
18
|
+
+++ b/src/new_module.py
|
|
19
|
+
@@ -0,0 +1,5 @@
|
|
20
|
+
+def brand_new_function():
|
|
21
|
+
+ pass
|
|
22
|
+
+
|
|
23
|
+
+class BrandNewClass:
|
|
24
|
+
+ pass
|
|
25
|
+
diff --git a/src/existing.ts b/src/existing.ts
|
|
26
|
+
--- a/src/existing.ts
|
|
27
|
+
+++ b/src/existing.ts
|
|
28
|
+
@@ -10,0 +11,2 @@
|
|
29
|
+
+export const NEW_EXPORT = 42;
|
|
30
|
+
+export function newHelper() {}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const parsed = DiffChecker.parseDiff(sampleDiff);
|
|
34
|
+
assert.equal(parsed.length, 2, 'Should parse 2 files from diff');
|
|
35
|
+
|
|
36
|
+
const pyFile = parsed.find(f => f.path === 'src/new_module.py');
|
|
37
|
+
assert.ok(pyFile);
|
|
38
|
+
assert.equal(pyFile.isNewFile, true);
|
|
39
|
+
assert.equal(pyFile.addedLines.length, 5);
|
|
40
|
+
|
|
41
|
+
const tsFile = parsed.find(f => f.path === 'src/existing.ts');
|
|
42
|
+
assert.ok(tsFile);
|
|
43
|
+
assert.equal(tsFile.isNewFile, false);
|
|
44
|
+
assert.equal(tsFile.addedLines.length, 2);
|
|
45
|
+
assert.equal(tsFile.addedLines[0].text, 'export const NEW_EXPORT = 42;');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('DiffChecker: extractAddedCandidates extracts Python & TS candidate declarations', () => {
|
|
49
|
+
const checker = new DiffChecker();
|
|
50
|
+
|
|
51
|
+
const pyCandidates = checker.extractAddedCandidates('src/util.py', [
|
|
52
|
+
{ lineNo: 1, text: 'def orphan_calc():' },
|
|
53
|
+
{ lineNo: 2, text: ' return 1' },
|
|
54
|
+
{ lineNo: 3, text: 'def test_something():' },
|
|
55
|
+
{ lineNo: 4, text: ' pass' },
|
|
56
|
+
], false);
|
|
57
|
+
|
|
58
|
+
const orphanCalc = pyCandidates.find(c => c.name === 'orphan_calc');
|
|
59
|
+
assert.ok(orphanCalc);
|
|
60
|
+
assert.equal(orphanCalc.isProtected, false);
|
|
61
|
+
|
|
62
|
+
const testSomething = pyCandidates.find(c => c.name === 'test_something');
|
|
63
|
+
assert.ok(testSomething);
|
|
64
|
+
assert.equal(testSomething.isProtected, true, 'pytest test_* should be protected');
|
|
65
|
+
|
|
66
|
+
const tsCandidates = checker.extractAddedCandidates('src/index.ts', [
|
|
67
|
+
{ lineNo: 10, text: 'export function activeApi() {}' },
|
|
68
|
+
{ lineNo: 11, text: 'export const STALE_TOKEN = "xyz";' },
|
|
69
|
+
], false);
|
|
70
|
+
|
|
71
|
+
assert.equal(tsCandidates.length, 2);
|
|
72
|
+
assert.equal(tsCandidates[0].name, 'activeApi');
|
|
73
|
+
assert.equal(tsCandidates[1].name, 'STALE_TOKEN');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('Cleaner: dry-run generates unified diff without modifying files', () => {
|
|
77
|
+
const tmpDir = path.join(process.cwd(), '.tmp_test_cleaner_' + Date.now());
|
|
78
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
79
|
+
|
|
80
|
+
const testFile = path.join(tmpDir, 'service.py');
|
|
81
|
+
const initialContent = [
|
|
82
|
+
'def active_function():',
|
|
83
|
+
' return "active"',
|
|
84
|
+
'',
|
|
85
|
+
'def orphan_dead_function():',
|
|
86
|
+
' return "dead"',
|
|
87
|
+
'',
|
|
88
|
+
'def another_active():',
|
|
89
|
+
' return "ok"',
|
|
90
|
+
].join('\n');
|
|
91
|
+
|
|
92
|
+
fs.writeFileSync(testFile, initialContent, 'utf8');
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const cleaner = new Cleaner({
|
|
96
|
+
repoDir: tmpDir,
|
|
97
|
+
dryRun: true,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const candidates = [
|
|
101
|
+
{
|
|
102
|
+
id: 'orphan-1',
|
|
103
|
+
name: 'orphan_dead_function',
|
|
104
|
+
type: 'function',
|
|
105
|
+
path: 'service.py',
|
|
106
|
+
line_no: 4,
|
|
107
|
+
status: 'CONFIRMED_ORPHAN',
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
const result = cleaner.clean(candidates);
|
|
112
|
+
assert.equal(result.dryRun, true);
|
|
113
|
+
assert.equal(result.cleanedCount, 1);
|
|
114
|
+
assert.ok(result.unifiedDiff.includes('-def orphan_dead_function():'));
|
|
115
|
+
assert.ok(result.unifiedDiff.includes('diff --git a/service.py b/service.py'));
|
|
116
|
+
|
|
117
|
+
// Assert that file on disk is strictly untouched
|
|
118
|
+
const currentDiskContent = fs.readFileSync(testFile, 'utf8');
|
|
119
|
+
assert.equal(currentDiskContent, initialContent, 'Dry-run must not modify file content on disk');
|
|
120
|
+
} finally {
|
|
121
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('Preflight Hook: 30-orphan-guard script executes with exit 0 on clean state', () => {
|
|
126
|
+
const hookScript = path.join(process.cwd(), 'units/orphan/templates/pre-commit.d/30-orphan-guard');
|
|
127
|
+
assert.ok(fs.existsSync(hookScript), '30-orphan-guard template must exist');
|
|
128
|
+
|
|
129
|
+
const out = execFileSync('bash', [hookScript], {
|
|
130
|
+
encoding: 'utf8',
|
|
131
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
assert.ok(out.includes('Orphan Check-Diff') || out.includes('增量防腐门禁检查'));
|
|
135
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# AEF Playbook — 执行手册
|
|
2
|
+
|
|
3
|
+
**用途**:开一个多端、多智能体协作的新项目时,照这本手册从 0 搭目录、写宪法、装工具、跑生命周期。
|
|
4
|
+
|
|
5
|
+
**性质**:这是**执行手册**,不是框架本体。框架权威是 `references/Agent-Engineering-Framework-AEF-v1.0.md`(下称 **AEF**),本手册只讲"怎么落地",并在每处标注 AEF 原文章节号。
|
|
6
|
+
|
|
7
|
+
**已验证案例**:OWSEL(iOS + Backend + MCP 三 Unit)——见 `examples/owisel.md`。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 方法论一页纸
|
|
12
|
+
|
|
13
|
+
核心公式(AEF §1):
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Intent → Spec → Context → Agent → Evidence → Convergence
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
八个构件,缺一不可:
|
|
20
|
+
|
|
21
|
+
| # | 构件 | 落地成什么 | 手册章节 |
|
|
22
|
+
|---|------|-----------|---------|
|
|
23
|
+
| 1 | Intent | `group/product/intent.md` + `constitution.md` | [04](docs/04-constitution.md) |
|
|
24
|
+
| 2 | Spec | Spec Kit 流程产物 `specs/NNN-*/` | [06](docs/06-spec-kit.md) |
|
|
25
|
+
| 3 | Context | 分层 `AGENTS.md` + Skills + CodeGraph | [03](docs/03-units.md) [08](docs/08-codegraph.md) [09](docs/09-skills.md) |
|
|
26
|
+
| 4 | Agent | Group / Unit 隔离 + 并行隔离 | [01](docs/01-architecture.md) [13](docs/13-parallel.md) |
|
|
27
|
+
| 5 | Evidence | E0–E5 分级证据 + `evidence/` | [11](docs/11-evidence.md) |
|
|
28
|
+
| 6 | Convergence | Convergence Checklist + 收尾门禁 | [12](docs/12-gates.md) |
|
|
29
|
+
| 7 | 协作契约 | `group/contracts/` + 依赖协调图 | [14](docs/14-dependency-graph.md) |
|
|
30
|
+
| 8 | 记忆 | `docs/PROGRESS.md` + 结构化交接件 | [15](docs/15-memory.md) |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 新项目启动顺序
|
|
35
|
+
|
|
36
|
+
严格按序,每步有硬门禁:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
1. git init ← 并行隔离的前提,见 13 章
|
|
40
|
+
2. 搭目录骨架 → 02-bootstrap.md
|
|
41
|
+
3. 写 Constitution → 04-constitution.md 门禁:宪法 review 通过
|
|
42
|
+
4. 写 ADR-001 起步决策 + INDEX → 05-adr.md
|
|
43
|
+
5. 建依赖协调图(哪怕只有 1 个 Unit)→ 14-dependency-graph.md
|
|
44
|
+
6. 每个 Unit 建 AGENTS.md 骨架 → 03-units.md
|
|
45
|
+
7. specify init 装 Spec Kit → 06-spec-kit.md
|
|
46
|
+
8. 建 CodeGraph 索引 → 08-codegraph.md
|
|
47
|
+
9. 定 Agent Skills(项目级) → 09-skills.md
|
|
48
|
+
10. 跨仓交接契约(如涉及) → 10-handoff.md
|
|
49
|
+
11. 跑第一个 feature 前通读 12 章门禁
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 每个 feature 收尾硬门禁
|
|
53
|
+
|
|
54
|
+
见 [12-gates.md](docs/12-gates.md)。一句话版:
|
|
55
|
+
|
|
56
|
+
> 没有 Evidence 的完成不算完成(AEF §14);不收敛到 Intent 的完成不算收敛(AEF §16)。
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 与业界的关系
|
|
61
|
+
|
|
62
|
+
本手册的每条原则都对应英文互联网上已被验证的实践,出处见 [01-architecture.md §6 与业界对照](docs/01-architecture.md) 以及 `references/links.md`。要点:
|
|
63
|
+
|
|
64
|
+
- **写操作单线程,其余 Agent 只出智能不出动作**(Cognition)
|
|
65
|
+
- **隔离靠 git worktree / 分支,不靠目录约定**(Anthropic、CAID 论文)
|
|
66
|
+
- **Agent 之间用结构化工件通信,不用自由对话**(CAID:misalignment 是头号失败原因)
|
|
67
|
+
- **指令文件分层 + 渐进披露,不做百科全书**(Anthropic 2026 context engineering)
|
|
68
|
+
- **ADR 是 Agent 的架构记忆,只注入最近 3–5 条**(arxiv 2604.03826)
|
|
69
|
+
- **"完成"必须有外部验证工具,Agent 会自欺**(Anthropic harness)
|
|
70
|
+
- **中途变更先评估影响面、spec 与代码同 commit,否则必漂移**(Spec Growth Engine、BMAD correct-course)
|
|
71
|
+
- **任务列表就是 Agent 的记忆:只增不删、单 in-progress、压缩前检查点**(tracking-tasks)
|
|
72
|
+
- **改既有代码前先出影响面清单、先钉特征化测试**(TDAD:回归 6.08%→1.82%)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 目录
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
playbook/
|
|
80
|
+
├── README.md ← 本文件
|
|
81
|
+
├── docs/
|
|
82
|
+
│ ├── 01-architecture.md AEF 七层 / Golden Loop / Group-Unit / 与业界对照
|
|
83
|
+
│ ├── 02-bootstrap.md 新项目从 0 搭建顺序
|
|
84
|
+
│ ├── 03-units.md Unit 设计与 AGENTS.md 分层
|
|
85
|
+
│ ├── 04-constitution.md 宪法怎么写
|
|
86
|
+
│ ├── 05-adr.md ADR 规范
|
|
87
|
+
│ ├── 06-spec-kit.md Spec Kit:为什么用、与 AEF 的映射
|
|
88
|
+
│ ├── 07-backlog.md backlog-capture + docs/backlogs/
|
|
89
|
+
│ ├── 08-codegraph.md 代码索引
|
|
90
|
+
│ ├── 09-skills.md Agent Skills 两级体系
|
|
91
|
+
│ ├── 10-handoff.md 跨仓交接(指针)
|
|
92
|
+
│ ├── 11-evidence.md Evidence 分级与 DoD
|
|
93
|
+
│ ├── 12-gates.md 硬门禁清单
|
|
94
|
+
│ ├── 13-parallel.md 并行执行隔离 ← 新增
|
|
95
|
+
│ ├── 14-dependency-graph.md 跨 Unit 依赖协调图 ← 新增
|
|
96
|
+
│ ├── 15-memory.md 结构化记忆与交接 ← 新增
|
|
97
|
+
│ ├── 16-change-control.md 中途需求变更 CR 流程 ← 新增
|
|
98
|
+
│ ├── 17-prompts.md 两段复制即用的提示词 ← 新增
|
|
99
|
+
│ ├── 18-shift-left.md 「收尾才暴露问题」根因+对策 ← 新增
|
|
100
|
+
│ ├── 19-anti-orphan-vertical-slicing.md 全栈反未接线与垂直切片交付法则 ← 新增
|
|
101
|
+
│ ├── 20-vibe-security-and-anti-suppression.md Vibe Coding 虚假安全感穿透防御与依赖可达性治理 ← 新增
|
|
102
|
+
│ └── 21-spec-driven-reppit-closed-loop.md SDD 规约驱动开发与 RePPIT 分级工程防线 ← 新增
|
|
103
|
+
├── templates/ 可直接改写的模板
|
|
104
|
+
├── references/ AEF 原文 + 外部链接索引
|
|
105
|
+
└── examples/owisel.md 真实案例拆解
|
|
106
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# ZSpec (AEF v1.0) Agent 实战工程规范与起步指南
|
|
2
|
+
|
|
3
|
+
> **目标受众**:面向负责新项目架构搭建、多端开发与工程维护的 **AI Coding Agent**。
|
|
4
|
+
> **核心原则**:结构化、机械可判定、职责隔离、规范不漂移。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. 架构拓扑 (Mental Model for Agents)
|
|
9
|
+
|
|
10
|
+
ZSpec 采用分层自治结构,Agent 必须严格遵守以下四层读取与修改边界:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
+-------------------------------------------------------------+
|
|
14
|
+
| Layer 0: constitution.md (最高宪法,全端不变量,Agent不得擅自降级) |
|
|
15
|
+
+-------------------------------------------------------------+
|
|
16
|
+
| Layer 1: group/ (全局事实层:产品意图 intent.md + 拓扑依赖 graph) |
|
|
17
|
+
| * 规则:跨端共享事实在此沉淀;任一端不得单方面破坏契约 |
|
|
18
|
+
+-------------------------------------------------------------+
|
|
19
|
+
| Layer 2: units/<端名>/ (各端自治上下文:iOS / Android / Web / ...) |
|
|
20
|
+
| * 规则:Agent 工作必须限定在当前 Unit,禁止跨 Unit 乱窜改码 |
|
|
21
|
+
+-------------------------------------------------------------+
|
|
22
|
+
| Layer 3: 研发纪律机件 (ADR / Backlog / Preflight / Review-Gate) |
|
|
23
|
+
| * 规则:使用 lab-agent-toolkit 统一提供,项目内只保留指针 |
|
|
24
|
+
+-------------------------------------------------------------+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Agent 上下文读取顺序 (Deterministic Reading Order)
|
|
30
|
+
|
|
31
|
+
每次 Agent 接到任务或启动新会话时,**必须按以下严格顺序读取上下文**,严禁跳步:
|
|
32
|
+
|
|
33
|
+
1. **项目根 `AGENTS.md`**:获取全局架构、门禁指令与 Unit 映射。
|
|
34
|
+
2. **目标 Unit 的 `units/<unit>/AGENTS.md`**:获取当前端的专属技术栈、构建与验证指令。
|
|
35
|
+
3. **`constitution.md`**:核验改动是否触碰项目硬原则。
|
|
36
|
+
4. **`group/contracts/`(如涉及跨端/接口改动)**:只读共享接口契约。
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 3. 新项目从 0 到 1 初始化协议 (Bootstrap Protocol)
|
|
41
|
+
|
|
42
|
+
当用户要求“按 ZSpec 模式初始化新项目”时,Agent 必须执行以下标准步骤:
|
|
43
|
+
|
|
44
|
+
### Step 1: 运行脚手架一键生成骨架
|
|
45
|
+
在项目根目录运行命令:
|
|
46
|
+
```bash
|
|
47
|
+
lab zspec init "<项目名称>"
|
|
48
|
+
```
|
|
49
|
+
*该命令会自动生成以下标准骨架,并完成 lab 纪律机件的动态接线:*
|
|
50
|
+
- `constitution.md` — 预置 P/T/A/D 四维核心原则
|
|
51
|
+
- `group/product/intent.md` — 产品意图事实源
|
|
52
|
+
- `group/architecture/dependency-graph.md` — 拓扑依赖事实源
|
|
53
|
+
- `specs/` — Spec Kit 特性规格工作区
|
|
54
|
+
- `docs/backlogs/` — 待办与越界事项跟踪区
|
|
55
|
+
- `AGENTS.md` — 根指挥官规则(<150行,动态挂载 lab 能力库)
|
|
56
|
+
|
|
57
|
+
### Step 2: 填充核心业务事实(Agent 填空阶段)
|
|
58
|
+
Agent 必须根据用户初始需求,仅填充以下特定锚点,不要破坏骨架标记:
|
|
59
|
+
1. `group/product/intent.md`:
|
|
60
|
+
- 填入本项目的核心问题定义与关键用户旅程(一句话一个旅程)。
|
|
61
|
+
2. `constitution.md`:
|
|
62
|
+
- 在 `P1-P3` 替换业务专属的产品不变量(如“隐私数据绝不上云”、“必须支持离线”等)。
|
|
63
|
+
|
|
64
|
+
### Step 3: 根据端划分建立 Unit
|
|
65
|
+
若项目涉及多端(如 `frontend`、`backend`、`ios` 等),为每个端运行:
|
|
66
|
+
```bash
|
|
67
|
+
lab zspec add-unit <端名称>
|
|
68
|
+
```
|
|
69
|
+
*这会在 `units/<端名称>/` 下生成自治的 `AGENTS.md` 与工程上下文。*
|
|
70
|
+
|
|
71
|
+
### Step 4: 挂载工程纪律门禁
|
|
72
|
+
运行 `lab doctor`,并初始化项目首条架构决策:
|
|
73
|
+
```bash
|
|
74
|
+
adr-init . standard "<项目名称>"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 4. Agent 日常维护守则 (Invariants for Agents)
|
|
80
|
+
|
|
81
|
+
| 场景 | 允许的行为 (DO) | 严禁的行为 (DON'T) |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| **改动需求/业务逻辑** | 优先更新 `group/product/intent.md` 达成一致再写代码 | ❌ 直接把需求细节硬编码进某端代码 |
|
|
84
|
+
| **跨端接口变动** | 更新 `group/contracts/api.md` 并标记影响端 | ❌ A 端悄悄改字段,B 端运行期报错 |
|
|
85
|
+
| **发现跨界/未来待办** | 按 `$(lab path backlog)/README.md` 写入 `docs/backlogs/` | ❌ 擅自顺手改掉非本任务范围的代码 |
|
|
86
|
+
| **引用工程规范** | 使用 `$(lab path <unit>)/...` 动态指针 | ❌ 把 lab 的规范大段复制到当前项目仓库 |
|
|
87
|
+
| **收尾交付** | 运行 preflight / review-gate 门禁并出示证据 | ❌ 只用文字声称“我已通过所有测试” |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 5. 机器可验证检查清单 (Verification Checklist)
|
|
92
|
+
|
|
93
|
+
Agent 在声称“ZSpec 规范初始化完成”前,必须在终端自检并全部通过:
|
|
94
|
+
- [ ] `test -f constitution.md`
|
|
95
|
+
- [ ] `test -f group/product/intent.md`
|
|
96
|
+
- [ ] `test -f group/architecture/dependency-graph.md`
|
|
97
|
+
- [ ] `test -d docs/backlogs`
|
|
98
|
+
- [ ] `test -f AGENTS.md && grep -q "lab path" AGENTS.md`
|
|
99
|
+
- [ ] `test -f adr/INDEX.md`
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# 01 — 架构:AEF 怎么组织一个项目
|
|
2
|
+
|
|
3
|
+
## 1. 七层模型(AEF §5)
|
|
4
|
+
|
|
5
|
+
任何按 AEF 组织的项目都是这七层,下层不满足则上层无效:
|
|
6
|
+
|
|
7
|
+
| Layer | 名称 | 问题 | 落地文件 |
|
|
8
|
+
|-------|------|------|---------|
|
|
9
|
+
| 1 | Intent | 人到底想要什么 | `constitution.md`、`group/product/intent.md` |
|
|
10
|
+
| 2 | Specification | 需求如何被固化、可验证 | `group/product/requirements.md`、`specs/NNN-*/spec.md` |
|
|
11
|
+
| 3 | Architecture | 技术决策是什么、为什么 | `group/architecture/system.md` + `adr/` |
|
|
12
|
+
| 4 | Context | Agent 能看到什么事实 | `AGENTS.md` 分层、Skills、CodeGraph |
|
|
13
|
+
| 5 | Execution | 谁在什么边界里干活 | Unit 目录、git 分支/worktree |
|
|
14
|
+
| 6 | Evidence | 凭什么说完成了 | build log、测试报告、截图、`evidence/` |
|
|
15
|
+
| 7 | Convergence | 结果是否回到最初意图 | Convergence Checklist、门禁 |
|
|
16
|
+
|
|
17
|
+
**顺序不可颠倒**:没有 Intent 的 Spec 是空转,没有 Evidence 的 Execution 是自欺。
|
|
18
|
+
|
|
19
|
+
## 2. Golden Loop(AEF §41)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Intent → Spec → Plan → Tasks → Implement → Verify → Evidence → Convergence
|
|
23
|
+
│
|
|
24
|
+
不一致?回写 Spec / ADR
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Spec Kit 的 `specify → plan → tasks → implement → converge` 就是这个环的实现,见 [06-spec-kit.md](06-spec-kit.md)。
|
|
28
|
+
|
|
29
|
+
## 3. Group / Unit 模型(AEF §6)
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Group(单一事实源,全项目共享)
|
|
33
|
+
├── product/ intent.md · requirements.md
|
|
34
|
+
├── architecture/ system.md · dependency-graph.md
|
|
35
|
+
└── contracts/ api.md 等跨 Unit 契约
|
|
36
|
+
|
|
37
|
+
Unit(平台隔离,各端独立工程上下文)
|
|
38
|
+
├── ios/ ← 自己的 AGENTS.md、CodeGraph 索引、Skills
|
|
39
|
+
├── backend/
|
|
40
|
+
└── mcp/
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **Group 是"共识"**:一个事实只有一个权威来源(AEF §33 Source of Truth)。
|
|
44
|
+
- **Unit 是"边界"**:不同平台的 Agent 不共享上下文,只通过 Contracts 协作——这是防止"多端互相污染"的唯一手段(AEF 设计目标 G3)。
|
|
45
|
+
|
|
46
|
+
详细切分方法见 [03-units.md](03-units.md)。
|
|
47
|
+
|
|
48
|
+
## 4. 两种隔离,别混淆
|
|
49
|
+
|
|
50
|
+
这是本手册反复强调的关键区分:
|
|
51
|
+
|
|
52
|
+
| | **Unit 隔离**(平台边界) | **执行隔离**(并行碰撞) |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| 解决什么 | iOS Agent 不会去改后端代码 | 两个 Agent 同时改同一文件 |
|
|
55
|
+
| 手段 | 目录边界 + 各自 AGENTS.md + Shared Contracts | git 分支 / worktree / 容器 |
|
|
56
|
+
| AEF 章节 | §6 Group/Unit、G3 | §24 Parallel Development |
|
|
57
|
+
| 手册章节 | [03-units.md](03-units.md) | [13-parallel.md](13-parallel.md) |
|
|
58
|
+
|
|
59
|
+
**Unit 隔离不能替代 git 隔离。** OWSEL 教训:三端目录分得很清楚,但整个仓库连 `git init` 都没有——一旦两个 Agent 并行改同一 Unit,没有任何机制能防止互相覆盖。
|
|
60
|
+
|
|
61
|
+
## 5. Agent 角色(AEF §11)
|
|
62
|
+
|
|
63
|
+
AEF 定义六种角色:Product / Architecture / Planner / Implementation / QA / Reviewer。
|
|
64
|
+
|
|
65
|
+
落地原则(与业界一致,见下):**Implementation 是唯一写者**,其余角色要么不碰代码,要么只产出评审意见。
|
|
66
|
+
|
|
67
|
+
- Planner 产出 `tasks.md`(不改代码)
|
|
68
|
+
- QA 产出 Evidence(只读 + 运行验证)
|
|
69
|
+
- Reviewer 产出评审结论(只读)
|
|
70
|
+
|
|
71
|
+
## 6. 与业界对照
|
|
72
|
+
|
|
73
|
+
本手册每条原则的英文互联网出处,供需要说服他人时引用:
|
|
74
|
+
|
|
75
|
+
| 本手册做法 | 业界说法 | 出处 |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| 单线程写 + 智能评审(§5) | "writes stay single-threaded…agents contribute intelligence rather than actions";unstructured swarm "mostly a distraction";实用形态 map-reduce-and-manage | [Cognition — Multi-Agents: What's Actually Working](https://cognition.com/blog/multi-agents-working) |
|
|
78
|
+
| git 分支/worktree 隔离(§4) | "One agent per worktree. One worktree per branch. No exceptions." | [2026 AI Coding Stack](https://gist.github.com/selcukcift/32868c0746f5fe5e14a35c1f5a89e634) |
|
|
79
|
+
| 容器级隔离 + 文件锁 | 每个 Claude 一个容器,`current_tasks/*.txt` 抢锁,pull→merge→push | [Anthropic — Building a C compiler with a team of parallel Claudes](https://www.anthropic.com/engineering/building-c-compiler) |
|
|
80
|
+
| 结构化交接工件([10](10-handoff.md)) | 用结构化 JSON 指令 + git commit 而非自由对话;misalignment 是多 Agent 首要失败模式 | [CAID, arxiv 2603.21489](https://arxiv.org/html/2603.21489v2) |
|
|
81
|
+
| 依赖协调图([14](14-dependency-graph.md)) | Repo Coordination Graph:依赖图 + 规定合并顺序,跨仓特性先查图 | [mabl — shipping code across 75+ repos](https://www.mabl.com/blog/how-we-built-a-system-for-ai-agents-to-ship-real-code-across-75-repos) |
|
|
82
|
+
| 分层 AGENTS.md + 最近优先([03](03-units.md)) | AGENTS.md 由 Linux Foundation 托管;"closest AGENTS.md to the edited file wins" | [agents.md](https://agents.md/) |
|
|
83
|
+
| 渐进披露、不做百科全书([09](09-skills.md)) | "不要把 CLAUDE.md 做成所有已知实践的中央仓库";用 skills + references 懒加载 | [Anthropic — New rules of context engineering](https://claude.com/blog/the-new-rules-of-context-engineering-for-claude-5-generation-models) |
|
|
84
|
+
| `PROGRESS.md` 当长期记忆([15](15-memory.md)) | 结构化笔记 / CHANGELOG.md 作为便携长期记忆;context reset + 结构化 handoff 工件 | [Anthropic — Effective context engineering](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)、[Harness design](https://www.anthropic.com/engineering/harness-design-long-running-apps) |
|
|
85
|
+
| ADR 只注入最近 3–5 条([05](05-adr.md)) | 750 仓实证:小窗口(3–5 条)最佳;context engineering 比模型规模更关键;仅 accepted 入索引 | [arxiv 2604.03826](https://arxiv.org/abs/2604.03826) |
|
|
86
|
+
| Evidence 必须外部工具取证([11](11-evidence.md)) | Agent 会改完代码就宣称完成,必须显式给 e2e 验证工具(浏览器+截图)才承认 | [Anthropic — Effective harnesses](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents) |
|
|
87
|
+
| 收尾自检([12](12-gates.md)) | Ralph loop:Agent 说完成了就踢回去问"真的吗" | [Anthropic — Long-running Claude](https://www.anthropic.com/research/long-running-Claude) |
|
|
88
|
+
| 编排器只能是主会话([13](13-parallel.md)) | subagent 不能 spawn subagent,orchestrator 必须是主会话 | [One Agent Per Repo](https://dev.to/just_an_electron/one-agent-per-repo-an-orchestration-pattern-for-multi-repo-ai-coding-49ba) |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 落地动作
|
|
93
|
+
|
|
94
|
+
1. 新项目 `git init`,第一次提交空骨架(见 [02-bootstrap.md](02-bootstrap.md))。
|
|
95
|
+
2. 建 `group/` 三目录,先各放一个从 `templates/group/` 拷的空文件。
|
|
96
|
+
3. 对照 §4 表格,在 `AGENTS.md` 根文件里写明本项目采用哪两种隔离。
|
|
97
|
+
4. 需要引用出处时,打开 `references/links.md`。
|
|
98
|
+
|
|
99
|
+
> AEF 原文对应章节:§4 总体架构、§5 七层模型、§6 Group/Unit、§11 Agent Roles、§24 Parallel Development、§33 Source of Truth、§41 Golden Loop。
|