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,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
function getSkillsVersion() {
|
|
11
|
+
try {
|
|
12
|
+
const versionPath = path.join(__dirname, 'VERSION.md');
|
|
13
|
+
if (fs.existsSync(versionPath)) {
|
|
14
|
+
const content = fs.readFileSync(versionPath, 'utf8').trim();
|
|
15
|
+
const match = content.match(/v?(\d+\.\d+\.\d+)/);
|
|
16
|
+
if (match) return match[1];
|
|
17
|
+
}
|
|
18
|
+
} catch {}
|
|
19
|
+
return '0.1.0';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const VERSION = getSkillsVersion();
|
|
23
|
+
const CATALOG_DIR = path.join(__dirname, 'catalog');
|
|
24
|
+
|
|
25
|
+
function printHelp() {
|
|
26
|
+
console.log(`
|
|
27
|
+
ReasonWeave Skills CLI · v${VERSION} (units/skills)
|
|
28
|
+
微观工程原子技能库与分发引擎
|
|
29
|
+
|
|
30
|
+
用法:
|
|
31
|
+
lab-skills --version, -v 打印当前版本
|
|
32
|
+
lab-skills --help, -h 显示帮助信息
|
|
33
|
+
lab-skills list 列出官方微观原子技能目录及状态
|
|
34
|
+
lab-skills install [选项] 安装/挂载技能至目标工作区或全局
|
|
35
|
+
lab-skills check 体检技能体积(<20KB)与元数据规范
|
|
36
|
+
lab-skills brief <plan> <id> 提取指定计划中的单任务切片 Brief
|
|
37
|
+
lab-skills review <base> <head> 生成审查用差分包文件
|
|
38
|
+
|
|
39
|
+
安装选项:
|
|
40
|
+
--project 安装到当前项目 (.agents/skills/) [默认]
|
|
41
|
+
--global 安装到用户全局 (~/.agents/skills/)
|
|
42
|
+
--copy 使用物理复制代替符号链接 (默认: 软链)
|
|
43
|
+
`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function listSkills() {
|
|
47
|
+
if (!fs.existsSync(CATALOG_DIR)) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const entries = fs.readdirSync(CATALOG_DIR, { withFileTypes: true });
|
|
52
|
+
const skills = [];
|
|
53
|
+
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
if (entry.isDirectory()) {
|
|
56
|
+
const skillFile = path.join(CATALOG_DIR, entry.name, 'SKILL.md');
|
|
57
|
+
if (fs.existsSync(skillFile)) {
|
|
58
|
+
const content = fs.readFileSync(skillFile, 'utf8');
|
|
59
|
+
const size = Buffer.byteLength(content, 'utf8');
|
|
60
|
+
const descMatch = content.match(/description:\s*(.+)/i);
|
|
61
|
+
const desc = descMatch ? descMatch[1].trim() : '无描述';
|
|
62
|
+
skills.push({
|
|
63
|
+
name: entry.name,
|
|
64
|
+
size,
|
|
65
|
+
description: desc,
|
|
66
|
+
path: skillFile,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return skills;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function checkSkills() {
|
|
76
|
+
const skills = listSkills();
|
|
77
|
+
const LIMIT = 20000;
|
|
78
|
+
let hasError = false;
|
|
79
|
+
|
|
80
|
+
console.log(`🔍 正在核验官方微观技能规范 (上限: ${LIMIT} bytes):`);
|
|
81
|
+
|
|
82
|
+
for (const s of skills) {
|
|
83
|
+
const isUnderLimit = s.size < LIMIT;
|
|
84
|
+
const status = isUnderLimit ? '✅' : '❌';
|
|
85
|
+
console.log(` ${status} ${s.name.padEnd(32)}: ${s.size} bytes`);
|
|
86
|
+
if (!isUnderLimit) {
|
|
87
|
+
console.error(` ⚠️ 超出 20KB 预算!请将详细内容移至 references/ 子目录。`);
|
|
88
|
+
hasError = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return !hasError;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function installSkills(options = {}) {
|
|
96
|
+
const targetDir = options.global
|
|
97
|
+
? path.join(os.homedir(), '.agents', 'skills')
|
|
98
|
+
: path.join(process.cwd(), '.agents', 'skills');
|
|
99
|
+
|
|
100
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
101
|
+
|
|
102
|
+
const skills = listSkills();
|
|
103
|
+
const installed = [];
|
|
104
|
+
|
|
105
|
+
for (const s of skills) {
|
|
106
|
+
const srcDir = path.dirname(s.path);
|
|
107
|
+
const destDir = path.join(targetDir, s.name);
|
|
108
|
+
|
|
109
|
+
if (fs.existsSync(destDir)) {
|
|
110
|
+
// Clean up existing link or directory
|
|
111
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (options.copy) {
|
|
115
|
+
fs.cpSync(srcDir, destDir, { recursive: true });
|
|
116
|
+
} else {
|
|
117
|
+
fs.symlinkSync(srcDir, destDir, 'junction');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
installed.push({ name: s.name, dest: destDir });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { targetDir, installed };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function run(args = process.argv.slice(2)) {
|
|
127
|
+
const cmd = args[0];
|
|
128
|
+
|
|
129
|
+
if (!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help') {
|
|
130
|
+
printHelp();
|
|
131
|
+
process.exit(0);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
|
|
135
|
+
console.log(`v${VERSION}`);
|
|
136
|
+
process.exit(0);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (cmd === 'list') {
|
|
140
|
+
const skills = listSkills();
|
|
141
|
+
console.log(`\n📦 官方微观工程原子技能库 (v${VERSION}):\n`);
|
|
142
|
+
for (const s of skills) {
|
|
143
|
+
console.log(` • \x1b[36m${s.name}\x1b[0m (${s.size} bytes)`);
|
|
144
|
+
console.log(` ${s.description}\n`);
|
|
145
|
+
}
|
|
146
|
+
process.exit(0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (cmd === 'check') {
|
|
150
|
+
const ok = checkSkills();
|
|
151
|
+
process.exit(ok ? 0 : 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (cmd === 'install') {
|
|
155
|
+
const isGlobal = args.includes('--global');
|
|
156
|
+
const isCopy = args.includes('--copy');
|
|
157
|
+
const result = installSkills({ global: isGlobal, copy: isCopy });
|
|
158
|
+
console.log(`✅ 成功安装 ${result.installed.length} 项微观技能至: ${result.targetDir}`);
|
|
159
|
+
for (const item of result.installed) {
|
|
160
|
+
console.log(` • ${item.name} -> ${item.dest}`);
|
|
161
|
+
}
|
|
162
|
+
process.exit(0);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (cmd === 'brief') {
|
|
166
|
+
import('./bin/task-brief.mjs').then((m) => m.run(args.slice(1)));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (cmd === 'review') {
|
|
171
|
+
import('./bin/review-package.mjs').then((m) => m.run(args.slice(1)));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
console.error(`未知命令: ${cmd}。运行 lab-skills --help 查看帮助。`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(new URL(import.meta.url).pathname)) {
|
|
180
|
+
run();
|
|
181
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import { extractTaskBrief } from '../bin/task-brief.mjs';
|
|
8
|
+
import { generateReviewPackage } from '../bin/review-package.mjs';
|
|
9
|
+
|
|
10
|
+
function createTestGitRepo() {
|
|
11
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'reasonweave-pipeline-test-'));
|
|
12
|
+
execFileSync('git', ['init', '-b', 'main'], { cwd: tmp, stdio: 'ignore' });
|
|
13
|
+
execFileSync('git', ['config', 'user.name', 'Tester'], { cwd: tmp, stdio: 'ignore' });
|
|
14
|
+
execFileSync('git', ['config', 'user.email', 'tester@example.com'], { cwd: tmp, stdio: 'ignore' });
|
|
15
|
+
|
|
16
|
+
// Initial commit
|
|
17
|
+
fs.writeFileSync(path.join(tmp, 'file1.txt'), 'Initial text\n');
|
|
18
|
+
execFileSync('git', ['add', '.'], { cwd: tmp, stdio: 'ignore' });
|
|
19
|
+
execFileSync('git', ['commit', '-m', 'Initial commit'], { cwd: tmp, stdio: 'ignore' });
|
|
20
|
+
const baseSha = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: tmp, encoding: 'utf8' }).trim();
|
|
21
|
+
|
|
22
|
+
// Commit 1
|
|
23
|
+
fs.writeFileSync(path.join(tmp, 'file1.txt'), 'Updated text\n');
|
|
24
|
+
fs.writeFileSync(path.join(tmp, 'file2.txt'), 'New file\n');
|
|
25
|
+
execFileSync('git', ['add', '.'], { cwd: tmp, stdio: 'ignore' });
|
|
26
|
+
execFileSync('git', ['commit', '-m', 'Task 1: Add file2 and update file1'], { cwd: tmp, stdio: 'ignore' });
|
|
27
|
+
|
|
28
|
+
// Commit 2
|
|
29
|
+
fs.writeFileSync(path.join(tmp, 'file2.txt'), 'New file with extra line\n');
|
|
30
|
+
execFileSync('git', ['add', '.'], { cwd: tmp, stdio: 'ignore' });
|
|
31
|
+
execFileSync('git', ['commit', '-m', 'Task 1: Refine file2'], { cwd: tmp, stdio: 'ignore' });
|
|
32
|
+
const headSha = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: tmp, encoding: 'utf8' }).trim();
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
dir: tmp,
|
|
36
|
+
baseSha,
|
|
37
|
+
headSha,
|
|
38
|
+
cleanup: () => {
|
|
39
|
+
try {
|
|
40
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
41
|
+
} catch {}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('units/skills: 零污染流水线切片工具测试 (ADR-0015)', () => {
|
|
47
|
+
describe('extractTaskBrief (task-brief)', () => {
|
|
48
|
+
const samplePlan = `
|
|
49
|
+
# Implementation Plan
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
Some introductory text.
|
|
53
|
+
|
|
54
|
+
## Task 1: Setup infrastructure
|
|
55
|
+
- Create directory structure
|
|
56
|
+
- Configure build tools
|
|
57
|
+
|
|
58
|
+
\`\`\`markdown
|
|
59
|
+
# Task 99 inside code fence should be ignored
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
## Task 2: Implement core algorithm
|
|
63
|
+
- Write failing tests first
|
|
64
|
+
- Implement function \`compute()\`
|
|
65
|
+
- Verify with 100 cases
|
|
66
|
+
|
|
67
|
+
### Task 2.1: Optimize memory
|
|
68
|
+
- Add cache
|
|
69
|
+
|
|
70
|
+
## Task 3: Final verification
|
|
71
|
+
- Run all tests
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
it('能精确提取指定 Task 的完整正文与子任务', () => {
|
|
75
|
+
const res = extractTaskBrief(samplePlan, '2');
|
|
76
|
+
assert.ok(res.found);
|
|
77
|
+
assert.match(res.content, /## Task 2: Implement core algorithm/);
|
|
78
|
+
assert.match(res.content, /Implement function `compute\(\)`/);
|
|
79
|
+
assert.match(res.content, /### Task 2.1: Optimize memory/);
|
|
80
|
+
assert.doesNotMatch(res.content, /## Task 3: Final verification/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('忽略代码块内伪造的 Task 标题', () => {
|
|
84
|
+
const res = extractTaskBrief(samplePlan, '1');
|
|
85
|
+
assert.ok(res.found);
|
|
86
|
+
assert.match(res.content, /## Task 1: Setup infrastructure/);
|
|
87
|
+
assert.doesNotMatch(res.content, /## Task 2/);
|
|
88
|
+
assert.ok(!res.availableTasks.includes('99'), '代码块内的 Task 99 不应被当作真实任务');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('查询不存在的 Task 时返回 found: false 并提供可用任务清单', () => {
|
|
92
|
+
const res = extractTaskBrief(samplePlan, '404');
|
|
93
|
+
assert.equal(res.found, false);
|
|
94
|
+
assert.ok(res.availableTasks.includes('1'));
|
|
95
|
+
assert.ok(res.availableTasks.includes('2'));
|
|
96
|
+
assert.ok(res.availableTasks.includes('3'));
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('generateReviewPackage (review-package)', () => {
|
|
101
|
+
it('跨多 Commit 生成完备的 Diff 审查包', () => {
|
|
102
|
+
const repo = createTestGitRepo();
|
|
103
|
+
try {
|
|
104
|
+
const pkg = generateReviewPackage(repo.baseSha, repo.headSha, { cwd: repo.dir });
|
|
105
|
+
assert.equal(pkg.commitCount, 2);
|
|
106
|
+
assert.match(pkg.content, /# Review Package:/);
|
|
107
|
+
assert.match(pkg.content, /## Commits/);
|
|
108
|
+
assert.match(pkg.content, /Task 1: Add file2/);
|
|
109
|
+
assert.match(pkg.content, /Task 1: Refine file2/);
|
|
110
|
+
assert.match(pkg.content, /## Files Changed/);
|
|
111
|
+
assert.match(pkg.content, /file1\.txt/);
|
|
112
|
+
assert.match(pkg.content, /file2\.txt/);
|
|
113
|
+
assert.match(pkg.content, /## Net Diff/);
|
|
114
|
+
} finally {
|
|
115
|
+
repo.cleanup();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('若 HEAD 不是 BASE 的后代则抛出异常阻断', () => {
|
|
120
|
+
const repo = createTestGitRepo();
|
|
121
|
+
try {
|
|
122
|
+
assert.throws(
|
|
123
|
+
() => generateReviewPackage(repo.headSha, repo.baseSha, { cwd: repo.dir }),
|
|
124
|
+
/HEAD 不是 BASE 的后代提交/
|
|
125
|
+
);
|
|
126
|
+
} finally {
|
|
127
|
+
repo.cleanup();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const CATALOG_DIR = path.resolve(__dirname, '..', 'catalog');
|
|
10
|
+
|
|
11
|
+
describe('units/skills: 技能契约与不变量门禁 (ADR-0015)', () => {
|
|
12
|
+
const entries = fs.readdirSync(CATALOG_DIR, { withFileTypes: true })
|
|
13
|
+
.filter((e) => e.isDirectory())
|
|
14
|
+
.map((e) => e.name);
|
|
15
|
+
|
|
16
|
+
it('官方技能目录包含核心 4 大微观技能', () => {
|
|
17
|
+
const required = [
|
|
18
|
+
'systematic-debugging',
|
|
19
|
+
'test-driven-development',
|
|
20
|
+
'verification-before-completion',
|
|
21
|
+
'brainstorming',
|
|
22
|
+
];
|
|
23
|
+
for (const req of required) {
|
|
24
|
+
assert.ok(entries.includes(req), `缺失必须的技能: ${req}`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
for (const skillName of entries) {
|
|
29
|
+
describe(`技能: ${skillName}`, () => {
|
|
30
|
+
const skillPath = path.join(CATALOG_DIR, skillName, 'SKILL.md');
|
|
31
|
+
const content = fs.readFileSync(skillPath, 'utf8');
|
|
32
|
+
|
|
33
|
+
it('正文字节数严格小于 20,000 bytes (Skill Size Invariant)', () => {
|
|
34
|
+
const byteSize = Buffer.byteLength(content, 'utf8');
|
|
35
|
+
assert.ok(
|
|
36
|
+
byteSize < 20000,
|
|
37
|
+
`技能 ${skillName} 体积为 ${byteSize} bytes,超出了 20,000 bytes 硬上限!`
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('包含标准 YAML Frontmatter (name 与 description)', () => {
|
|
42
|
+
assert.match(content, /^---\s*\nname:\s*[\w-]+\s*\ndescription:\s*.+\s*\n---/m);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('包含不可违背铁律 (The Iron Law)', () => {
|
|
46
|
+
const hasIronLaw = content.includes('Iron Law') || content.includes('不可违背铁律');
|
|
47
|
+
assert.ok(hasIronLaw, `技能 ${skillName} 缺失不可违背铁律小节!`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('包含防合理化阻断表 (Anti-Rationalization / Red Flags)', () => {
|
|
51
|
+
const hasAntiRationalization =
|
|
52
|
+
content.includes('Anti-Rationalization') ||
|
|
53
|
+
content.includes('防合理化') ||
|
|
54
|
+
content.includes('Red Flags');
|
|
55
|
+
assert.ok(hasAntiRationalization, `技能 ${skillName} 缺失防合理化阻断表!`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('内部 references 引用文件真实物理存在', () => {
|
|
59
|
+
const refMatches = content.matchAll(/references\/[\w-]+\.md/g);
|
|
60
|
+
for (const m of refMatches) {
|
|
61
|
+
const refFile = path.join(CATALOG_DIR, skillName, m[0]);
|
|
62
|
+
assert.ok(fs.existsSync(refFile), `引用文件不存在: ${refFile}`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
const CLI_PATH = path.resolve(__dirname, '..', 'skills.mjs');
|
|
12
|
+
const VERSION_FILE = path.resolve(__dirname, '..', 'VERSION.md');
|
|
13
|
+
|
|
14
|
+
function readVersion() {
|
|
15
|
+
const content = fs.readFileSync(VERSION_FILE, 'utf8').trim();
|
|
16
|
+
const m = content.match(/v?(\d+\.\d+\.\d+)/);
|
|
17
|
+
return m ? m[1] : '0.1.0';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createSandbox() {
|
|
21
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'reasonweave-skills-test-'));
|
|
22
|
+
return {
|
|
23
|
+
dir: tmp,
|
|
24
|
+
cleanup: () => {
|
|
25
|
+
try {
|
|
26
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
27
|
+
} catch {}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('units/skills: CLI 物理契约与沙箱安装测试 (ADR-0013 / ADR-0015)', () => {
|
|
33
|
+
const expectedVersion = readVersion();
|
|
34
|
+
|
|
35
|
+
it('支持 --version 与 -v 选项,且版本与 VERSION.md 严格一致', () => {
|
|
36
|
+
const out1 = execFileSync(process.execPath, [CLI_PATH, '--version'], { encoding: 'utf8' }).trim();
|
|
37
|
+
assert.equal(out1, `v${expectedVersion}`);
|
|
38
|
+
|
|
39
|
+
const out2 = execFileSync(process.execPath, [CLI_PATH, '-v'], { encoding: 'utf8' }).trim();
|
|
40
|
+
assert.equal(out2, `v${expectedVersion}`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('支持 --help 与 -h 选项,退出码为 0', () => {
|
|
44
|
+
const out1 = execFileSync(process.execPath, [CLI_PATH, '--help'], { encoding: 'utf8' });
|
|
45
|
+
assert.match(out1, /ReasonWeave Skills CLI/);
|
|
46
|
+
assert.match(out1, /用法:/);
|
|
47
|
+
|
|
48
|
+
const out2 = execFileSync(process.execPath, [CLI_PATH, '-h'], { encoding: 'utf8' });
|
|
49
|
+
assert.match(out2, /ReasonWeave Skills CLI/);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('在外部工作区 (cwd: /tmp) 运行 list 正常输出且退出码为 0', () => {
|
|
53
|
+
const out = execFileSync(process.execPath, [CLI_PATH, 'list'], {
|
|
54
|
+
cwd: os.tmpdir(),
|
|
55
|
+
encoding: 'utf8',
|
|
56
|
+
});
|
|
57
|
+
assert.match(out, /systematic-debugging/);
|
|
58
|
+
assert.match(out, /test-driven-development/);
|
|
59
|
+
assert.match(out, /verification-before-completion/);
|
|
60
|
+
assert.match(out, /brainstorming/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('check 子命令通过且 Exit 0', () => {
|
|
64
|
+
const out = execFileSync(process.execPath, [CLI_PATH, 'check'], { encoding: 'utf8' });
|
|
65
|
+
assert.match(out, /正在核验官方微观技能规范/);
|
|
66
|
+
assert.match(out, /✅ systematic-debugging/);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('install --project 在沙箱中正确挂载 .agents/skills/ 软链', () => {
|
|
70
|
+
const sandbox = createSandbox();
|
|
71
|
+
try {
|
|
72
|
+
execFileSync(process.execPath, [CLI_PATH, 'install', '--project'], {
|
|
73
|
+
cwd: sandbox.dir,
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const installedSkillsDir = path.join(sandbox.dir, '.agents', 'skills');
|
|
78
|
+
assert.ok(fs.existsSync(installedSkillsDir));
|
|
79
|
+
|
|
80
|
+
const installed = fs.readdirSync(installedSkillsDir);
|
|
81
|
+
assert.ok(installed.includes('systematic-debugging'));
|
|
82
|
+
assert.ok(installed.includes('test-driven-development'));
|
|
83
|
+
|
|
84
|
+
const skillFile = path.join(installedSkillsDir, 'systematic-debugging', 'SKILL.md');
|
|
85
|
+
assert.ok(fs.existsSync(skillFile));
|
|
86
|
+
} finally {
|
|
87
|
+
sandbox.cleanup();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('install --copy 在沙箱中完成物理拷贝', () => {
|
|
92
|
+
const sandbox = createSandbox();
|
|
93
|
+
try {
|
|
94
|
+
execFileSync(process.execPath, [CLI_PATH, 'install', '--project', '--copy'], {
|
|
95
|
+
cwd: sandbox.dir,
|
|
96
|
+
encoding: 'utf8',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const skillDir = path.join(sandbox.dir, '.agents', 'skills', 'brainstorming');
|
|
100
|
+
const stat = fs.lstatSync(skillDir);
|
|
101
|
+
assert.ok(!stat.isSymbolicLink(), '应当为物理目录而非软链');
|
|
102
|
+
assert.ok(fs.existsSync(path.join(skillDir, 'SKILL.md')));
|
|
103
|
+
} finally {
|
|
104
|
+
sandbox.cleanup();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# spec-guard Agent 行为守则与实操规范
|
|
2
|
+
|
|
3
|
+
> 本文件是 AI Agent 在涉及顶层规约设计(ADR)、不变量断言、算法原型及防漂移审查时的专属行为法则。
|
|
4
|
+
> 任何在项目中扮演架构师、实现方(impl lane)或审计方(audit lane)的 Agent 必须严格遵守。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. 核心行为禁令(反模式拦截)
|
|
9
|
+
|
|
10
|
+
1. **严禁“半山腰挂起”(No Spec Hang)**:
|
|
11
|
+
在底层基础设施(调度、网络、IPC、业务排他锁)尚未就绪时,**严禁将未接线的纯算法函数直接提交至生产目录(`src/main/`、`app/` 等)**。
|
|
12
|
+
- 若需提前沉淀算法原型,请使用契约沙箱:放进 `src/test/.../contract/` 或显式标注 `@ContractOnly`;
|
|
13
|
+
- 算法原型在 ADR 的 `## Implementation Status` 中必须老老实实标记为 `❌ 未实现` 或 `⚠️ 契约沙箱未接线`。
|
|
14
|
+
|
|
15
|
+
2. **严禁“装饰性空壳接线”(No Shallow / Decorative Wiring)**:
|
|
16
|
+
为了消除死代码警报或骗取调用图绿灯,在轮询循环(Watchdog/Tick)中塞入无业务判断的空调用,属于**严重违规欺骗行为**。
|
|
17
|
+
- 接线必须是**端到端有业务先决条件判断(如温控、空闲、互斥锁)的语义闭环**;
|
|
18
|
+
- 必须配有负向断言(如非工作时间/冷却中抓包数为 0)或变异测试阻断。
|
|
19
|
+
|
|
20
|
+
3. **防伪铁律:单测不等于接线(No-Cheat Rule)**:
|
|
21
|
+
`src/test/` 中的测试调用**绝不代表生产代码已接线**。不要在回执或审计报告中以“测试跑通了”自欺欺人地声称“生产已闭环”。
|
|
22
|
+
|
|
23
|
+
4. **绝不越权篡改 ADR Frozen 状态(Never Auto-Mutate ADR Status)**:
|
|
24
|
+
`🔒Frozen` 是具有法律效力的终态,必须由人类单句明确批准。Agent 只能使用 `spec-guard audit-adr <ID>` 生成客观事实对账报告呈交人类,严禁自行修改 ADR 状态行。
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. 操作工序流 (Standard Operating Procedure)
|
|
29
|
+
|
|
30
|
+
### 当你在编写或冻结 ADR 时:
|
|
31
|
+
1. 检查 ADR 是否严格包含 `## Implementation Status` 落地情况节;
|
|
32
|
+
2. 为每一个关键不变量(`H-1`, `H-2`...)设定唯一的 Invariant ID;
|
|
33
|
+
3. 运行 `spec-guard audit-adr <ID>`,确认断言覆盖率是否与当前实现状态一致;
|
|
34
|
+
4. 若存在未接线项,如实写在 `Implementation Status` 表中,不制造虚假完备性。
|
|
35
|
+
|
|
36
|
+
### 当你在编写生产代码与单测时:
|
|
37
|
+
1. 在单元测试/契约测试中,用 `@Invariant("ADR-XXX:H-Y")` 标注被测不变量;
|
|
38
|
+
2. 若编写的是仅供契约验证的原型,使用 `@ContractOnly(adr="ADR-XXX", expire="YYYY-MM-DD")`;
|
|
39
|
+
3. 提交前运行 `spec-guard check`,确保没有引入漂移或孤儿断言。
|
|
40
|
+
|
|
41
|
+
### 当你在审计回执(Audit Lane)时:
|
|
42
|
+
1. 运行 `spec-guard check --strict` 独立执行机器核验,严禁静态读码或采信自报;
|
|
43
|
+
2. 重点检查是否有通过空调用骗过门禁的 Shallow Wiring 现象。
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog - spec-guard (drift-gate)
|
|
2
|
+
|
|
3
|
+
## [2.2.1] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **CLI 版本号与帮助 Banner 动态对齐**:
|
|
7
|
+
- `spec-guard` 帮助 banner 移除硬编码 `v2.0.0`,改为动态读取 `VERSION.md` 事实源;
|
|
8
|
+
- 显式接线 `--version` / `-v` / `version` 命令行选项,避免下发 `--version` 时报错 `未知命令: --version` 且以 exit 1 退出。
|
|
9
|
+
|
|
10
|
+
## [2.2.0] - 2026-11-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **门禁增量感知与快速放行 (`templates/pre-commit.d/15-spec-guard`, `bin/spec-guard.mjs`)**:
|
|
14
|
+
- **根除无条件 `--full --strict` 的 footgun 误杀**:在预提交门禁中加入暂存区(Staged)改动感知,当提交仅包含普通业务代码、样式或非架构文档时,门禁于 `< 0.05s` 内极速放行,彻底杜绝全仓历史技术债与长耗时全景扫描阻断日常提交。
|
|
15
|
+
- **按需触发严格对账**:当且仅当暂存区涉及 ADR 架构规约、`spec-matrix.overlay.yml`、`evidence/*.json` 或包含 `@Invariant` 注解的代码时,才激活 `--full --strict` 强对账拦截。
|
|
16
|
+
- **CLI 原生增量检查**:`spec-guard check` 原生支持 `--incremental` / `--staged` 参数,自动根据暂存区差异完成轻量增量评估。
|
|
17
|
+
- **性能实测自述与架构约定阈值解耦 (`core/telemetry_authenticator.mjs`, `core/adr-parser.mjs`)**:
|
|
18
|
+
- **Overlay 规则支持**:`spec-matrix.overlay.yml` 支持配置 `telemetry_ignore_patterns`(字符串/正则)与 `telemetry_exempt_adrs`(ADR 编号列表),支持顶层或 `telemetry:` 嵌套语法。
|
|
19
|
+
- **行级内联标记**:支持在 ADR Markdown 行中通过 `<!-- telemetry: ignore -->`(或 `skip`/`convention`/`exempt`)将轮询周期上限、配置参数、超时门限等约定阈值声明为非基准指标,免除机器 JSON 信任根强制校验。
|
|
20
|
+
- **块级范围标记**:支持通过 `<!-- telemetry: ignore-start -->` 与 `<!-- telemetry: ignore-end -->` 对特定配置段落实施整体忽略。
|
|
21
|
+
- **ADR 级显式豁免**:支持在 ADR frontmatter 中声明 `telemetry: exempt`(或 `skip`/`ignore`/`convention`/`false`),或在 overlay 中配置 `telemetry_exempt_adrs`,将特定非量化 ADR 整体标记为 `SKIPPED`。
|
|
22
|
+
- 彻底解耦「**架构约定阈值(SLA/上限/轮询)**」与「**性能跑分实测自述(Benchmark/Telemetry)**」,杜绝消费方被迫为纯文本约定补写伪造基准 JSON。
|
|
23
|
+
|
|
24
|
+
## [2.1.0] - 2026-11-14
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **ADR 发现与解析规则项目侧可配置化 (`core/adr-parser.mjs`)**:
|
|
28
|
+
- `findAdrFiles` 支持通过 `spec-matrix.overlay.yml`(或 CLI/选项)配置 `adr_dirs` 与 `adr_id_pattern`。
|
|
29
|
+
- 缺省无配置时自动回退现有四候选目录 (`group/architecture/adr`, `docs/adr`, `adr`, `docs/proposals`) 及 `ADR-\d+`/`^\d{4}-`,保持 100% 零回归。
|
|
30
|
+
- `parseAdrContent` 支持提取 frontmatter `id:` 并采用同一模式解析异构决策编号(如 `DECISION-NNNN`)。
|
|
31
|
+
- 支持 frontmatter `status:` 及 `frozen_states` 状态列表映射,确保 `active|superseded` 状态不会被误判为 `🔒Frozen`。
|
|
32
|
+
- 核心章节标题(Decision, Invariants, Implementation Status)支持别名匹配(如 `## 决定`、`## 验证`)。
|
|
33
|
+
- **零覆盖假绿防卫与严格门禁拦截 (`core/matrix-checker.mjs`)**:
|
|
34
|
+
- 根除「0 规约/0 不变量 → 覆盖率 100%」的空集假绿缺陷:`totalAdrs === 0` 时严禁判定健康,强制输出 `coveragePercent: 0` 与 `ZERO_COVERAGE` 警示,`--strict` 与 `--full` 模式下一律 Exit 1 阻断。
|
|
35
|
+
- **Git 提交门禁片全面升级 (`templates/pre-commit.d/15-spec-guard`)**:
|
|
36
|
+
- 将未实现的 `check --incremental` 升级为 `check --full --strict`,杜绝非 strict 恒 Exit 0 导致的装饰性空壳门禁。
|
|
37
|
+
|
|
38
|
+
## [2.0.0] - 2026-11-14
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- **实测数据自述凭据与机器信任根对账引擎 (`core/telemetry_authenticator.mjs`)**:
|
|
42
|
+
- 静态扫描 ADR 表格与正文中声明的量化性能指标 (`ms`, `s`, `MB`, `FPS`, `%`, `Tokens`, `P95`, `P99`, `INT8` 等)。
|
|
43
|
+
- 强制对齐上位规约 ADR-064 机器信任根模型:命中量化指标的 ADR 必须显式引用 `evidence_ref: evidence/*.json` 及 `digest: sha256:...` / `signature`。
|
|
44
|
+
- 自动检验凭证文件物理存在性与 SHA-256 哈希完整性,杜绝离线篡改。
|
|
45
|
+
- 容差恒等于 $0\%$:比对 ADR 文本自述数值与 JSON 实测字段值,彻底根除 ADR-066 式的文本伪造实测数据漂移。
|
|
46
|
+
- 新增 `spec-guard verify-evidence [ADR-ID]` 子命令与 `--telemetry` 门禁选项。
|
|
47
|
+
- **物理代码接线探测与孤儿决策防卫 (`core/wiring_tracer.mjs`)**:
|
|
48
|
+
- 自动解析 ADR `## 2. Decision` 节提取核心架构实体、类名、方法与引擎编号。
|
|
49
|
+
- 严格贯彻 No-Cheat 铁律:排除测试目录 (`src/test/`, `tests/` 等),在生产源码目录反查真实符号存活性与物理接线。
|
|
50
|
+
- 预热加载生产代码内存缓存,避免海量物理 I/O,极速完成全仓反查。
|
|
51
|
+
- 精准识别 `🔒Frozen` 但生产代码零符号命中的孤儿决策 (`ORPHAN_DECISION`) 并 Exit 1 阻断。
|
|
52
|
+
- 新增 `spec-guard check-wiring [ADR-ID]` 子命令。
|
|
53
|
+
- **全景对账热力表与一键三元体检 (`check --full`)**:
|
|
54
|
+
- 覆盖「断言 (Assertion) ↔ 证据 (Evidence) ↔ 接线 (Wiring)」三元闭环。
|
|
55
|
+
- 一键输出全景对账热力表 (Triad Heatmap) 与客观综合裁决 (`VERIFIED`, `TELEMETRY_DRIFT`, `ORPHAN_DECISION`, `DRIFT_DETECTED`)。
|
|
56
|
+
- **全量测试套件保障 (`tests/telemetry_authenticator.test.mjs`)**:
|
|
57
|
+
- 包含格式伪造拦截与缺少机器签名熔断双必红守护、0% 容差比对、孤儿决策熔断以及针对 Tappy 仓 ADR-066 的真实端到端抓捕验证。
|
|
58
|
+
|
|
59
|
+
## [1.1.0] - 2026-11-10
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
- **防线 2:变异反向测试契约引擎(Mutation Sensitivity Runner)**:
|
|
63
|
+
- `core/mutation-runner.mjs`:自动化变异注入引擎(端点篡改、布尔倒置、比较取反、返回值破坏),断言测试套件在变异注入后必须爆红(Exit !== 0);若依然全绿(Exit === 0),判定为回音壁假测试并阻断(`MUTATION_SURVIVED`)。
|
|
64
|
+
- 支持 `spec-guard mutate --file <path> --cmd "<cmd>" [--mutator <type>]` 命令行调用与 cleanContext 清洗机制。
|
|
65
|
+
- **防线 3:生产拓扑可达性扫描与孤儿接线门禁 (`--check-callers`)**:
|
|
66
|
+
- 联动 `units/orphan` 的倒排索引与符号引用分类器(`countProductionCallers` / `Classifier.evaluateCallers`)。
|
|
67
|
+
- 凡是在 `spec-matrix.overlay.yml` 或源码中标记为架构 Invariant 的方法,必须在非测试生产代码中找到至少 1 处真实调用者(Production Callers >= 1)。
|
|
68
|
+
- 若只有单测调用、生产调用数为 0,门禁精准阻断并报红:`🚨 架构函数未在生产关键链路接线 (Zero Production Callers)`,强制 Exit 1。
|
|
69
|
+
- **单测全量覆盖与实测验证**:
|
|
70
|
+
- `tests/spec-guard.test.mjs`:新增孤儿接线阻断与接入复测、变异反向拦截假测试实测、`orphan` 分类器跨单元联动单测,全量纳入 `npm test`。
|
|
71
|
+
|
|
72
|
+
## [1.0.0] - 2026-11-10
|
|
73
|
+
|
|
74
|
+
### 初始发布 (Initial Release)
|
|
75
|
+
- **架构定性与落地**:正式收敛 Tappy ADR-060 “半山腰挂起”与“装饰性接线(Shallow Wiring)”事故反思,将 RFC-20261110-SPEC-GUARD-UNIT 落地为通用工程单元。
|
|
76
|
+
- **Code-as-Spec-Matrix 动态对账引擎**:
|
|
77
|
+
- 默认以代码为事实源:通过 AST/正则扫描 `@Invariant("ADR-XXX:H-Y")` 注解与 ADR 文本 `## Implementation Status`,在内存中动态构建对账矩阵。
|
|
78
|
+
- 支持 `spec-matrix.overlay.yml` 作为跨端/跨语言协议层按需覆写(Overlay)。
|
|
79
|
+
- **严格词界与分隔符锚定(防正则假阳性)**:
|
|
80
|
+
- 在 ADR 解析器与源码标签抽取器中全面实行边界锚定匹配(`(?:^|[^a-zA-Z0-9_-])`),彻底杜绝 `H-1` 误伤 `H-10` 或 `H-1-OBSOLETE`。
|
|
81
|
+
- **防伪铁律(No-Cheat Rule)**:
|
|
82
|
+
- 测试类(`src/test/` 等)中对算法原型的直接调用,一律不计入生产可达性证明。
|
|
83
|
+
- **空壳接线启发式检测(兼容副作用函数)**:
|
|
84
|
+
- 对无返回值(void/Unit)业务 Entrypoint 采取 WARN 级审计呈现,不硬阻断合法副作用逻辑。
|
|
85
|
+
- **CLI 命令行工具**:
|
|
86
|
+
- `spec-guard init`:一键初始化项目配置。
|
|
87
|
+
- `spec-guard check`:对账全仓规约覆盖率与漂移风险。
|
|
88
|
+
- `spec-guard audit-adr <ID>`:针对指定 ADR 输出只读机器审计报告(作为人类批准 Frozen 的客观依据)。
|