agentlock-harness 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +211 -2
- package/README.zh-CN.md +211 -0
- package/RELEASE_NOTES.md +35 -0
- package/bin/agentlock-harness.mjs +249 -0
- package/harness-templates/en-US/common/CLAUDE.md.tmpl +7 -0
- package/harness-templates/en-US/common/GEMINI.md.tmpl +7 -0
- package/harness-templates/en-US/common/agentlock-harness.json.tmpl +45 -0
- package/harness-templates/en-US/common/claude-settings.json +36 -0
- package/harness-templates/en-US/common/codex-config.toml.tmpl +11 -0
- package/harness-templates/en-US/common/copilot-instructions.md.tmpl +3 -0
- package/harness-templates/en-US/common/gemini-settings.json +42 -0
- package/harness-templates/en-US/common/git-hooks/pre-commit +24 -0
- package/harness-templates/en-US/common/git-hooks/pre-push +11 -0
- package/harness-templates/en-US/common/harness-gitignore +3 -0
- package/harness-templates/en-US/common/hooks/post-edit-check.mjs +57 -0
- package/harness-templates/en-US/common/hooks/pre-tool-guard.mjs +122 -0
- package/harness-templates/en-US/common/hooks/rules-drift-check.mjs +69 -0
- package/harness-templates/en-US/common/hooks/staged-guard.mjs +197 -0
- package/harness-templates/en-US/common/hooks/stop-gate.mjs +164 -0
- package/harness-templates/en-US/common/rules/00-testing-integrity.md +11 -0
- package/harness-templates/en-US/common/rules/01-security-boundaries.md +11 -0
- package/harness-templates/en-US/common/skills/atomic-tdd/SKILL.md +21 -0
- package/harness-templates/en-US/common/skills/brainstorming/SKILL.md +24 -0
- package/harness-templates/en-US/common/skills/code-grounding/SKILL.md +20 -0
- package/harness-templates/en-US/common/skills/cross-model-review/SKILL.md +22 -0
- package/harness-templates/en-US/common/skills/worktree-isolation/SKILL.md +19 -0
- package/harness-templates/en-US/dual-core/HARNESS_GUIDE.md +19 -0
- package/harness-templates/en-US/dual-core/scripts/cross-review.mjs +141 -0
- package/harness-templates/en-US/enterprise-platform/ci/agentlock-harness-gate.yml +32 -0
- package/harness-templates/en-US/enterprise-platform/governance/mcp-gateway.template.json +18 -0
- package/harness-templates/en-US/enterprise-platform/governance/policy.json +26 -0
- package/harness-templates/en-US/ralph-factory/PROMPT.loop.md.tmpl +12 -0
- package/harness-templates/en-US/ralph-factory/SPRINT_CONTRACT.md.tmpl +25 -0
- package/harness-templates/en-US/ralph-factory/sandbox/Dockerfile.sandbox +13 -0
- package/harness-templates/en-US/ralph-factory/sandbox/docker-compose.sandbox.yml +22 -0
- package/harness-templates/en-US/ralph-factory/sandbox/run-sandbox-loop.sh +8 -0
- package/harness-templates/zh-CN/common/CLAUDE.md.tmpl +7 -0
- package/harness-templates/zh-CN/common/GEMINI.md.tmpl +7 -0
- package/harness-templates/zh-CN/common/agentlock-harness.json.tmpl +45 -0
- package/harness-templates/zh-CN/common/claude-settings.json +36 -0
- package/harness-templates/zh-CN/common/codex-config.toml.tmpl +11 -0
- package/harness-templates/zh-CN/common/copilot-instructions.md.tmpl +3 -0
- package/harness-templates/zh-CN/common/gemini-settings.json +42 -0
- package/harness-templates/zh-CN/common/git-hooks/pre-commit +24 -0
- package/harness-templates/zh-CN/common/git-hooks/pre-push +11 -0
- package/harness-templates/zh-CN/common/harness-gitignore +3 -0
- package/harness-templates/zh-CN/common/hooks/post-edit-check.mjs +57 -0
- package/harness-templates/zh-CN/common/hooks/pre-tool-guard.mjs +122 -0
- package/harness-templates/zh-CN/common/hooks/rules-drift-check.mjs +69 -0
- package/harness-templates/zh-CN/common/hooks/staged-guard.mjs +197 -0
- package/harness-templates/zh-CN/common/hooks/stop-gate.mjs +164 -0
- package/harness-templates/zh-CN/common/rules/00-testing-integrity.md +11 -0
- package/harness-templates/zh-CN/common/rules/01-security-boundaries.md +11 -0
- package/harness-templates/zh-CN/common/skills/atomic-tdd/SKILL.md +21 -0
- package/harness-templates/zh-CN/common/skills/brainstorming/SKILL.md +24 -0
- package/harness-templates/zh-CN/common/skills/code-grounding/SKILL.md +20 -0
- package/harness-templates/zh-CN/common/skills/cross-model-review/SKILL.md +22 -0
- package/harness-templates/zh-CN/common/skills/worktree-isolation/SKILL.md +19 -0
- package/harness-templates/zh-CN/dual-core/HARNESS_GUIDE.md +19 -0
- package/harness-templates/zh-CN/dual-core/scripts/cross-review.mjs +141 -0
- package/harness-templates/zh-CN/enterprise-platform/ci/agentlock-harness-gate.yml +32 -0
- package/harness-templates/zh-CN/enterprise-platform/governance/mcp-gateway.template.json +18 -0
- package/harness-templates/zh-CN/enterprise-platform/governance/policy.json +26 -0
- package/harness-templates/zh-CN/ralph-factory/PROMPT.loop.md.tmpl +12 -0
- package/harness-templates/zh-CN/ralph-factory/SPRINT_CONTRACT.md.tmpl +25 -0
- package/harness-templates/zh-CN/ralph-factory/sandbox/Dockerfile.sandbox +13 -0
- package/harness-templates/zh-CN/ralph-factory/sandbox/docker-compose.sandbox.yml +22 -0
- package/harness-templates/zh-CN/ralph-factory/sandbox/run-sandbox-loop.sh +8 -0
- package/package.json +64 -4
- package/scripts/bootstrap.ps1 +13 -0
- package/scripts/bootstrap.sh +23 -0
- package/src/cli/colors.mjs +42 -0
- package/src/cli/commands/adopt.mjs +378 -0
- package/src/cli/commands/change.mjs +92 -0
- package/src/cli/commands/doctor.mjs +56 -0
- package/src/cli/commands/eval.mjs +193 -0
- package/src/cli/commands/hooks.mjs +97 -0
- package/src/cli/commands/init.mjs +231 -0
- package/src/cli/commands/passthrough.mjs +27 -0
- package/src/cli/commands/ralph.mjs +208 -0
- package/src/cli/commands/rules.mjs +73 -0
- package/src/cli/commands/stats.mjs +71 -0
- package/src/cli/commands/task.mjs +123 -0
- package/src/cli/commands/ui.mjs +84 -0
- package/src/cli/commands/verify.mjs +267 -0
- package/src/cli/prompt.mjs +55 -0
- package/src/core/adopt.mjs +807 -0
- package/src/core/agent-runner.mjs +118 -0
- package/src/core/audit.mjs +181 -0
- package/src/core/catalog.mjs +160 -0
- package/src/core/change-flow.mjs +344 -0
- package/src/core/detector.mjs +141 -0
- package/src/core/doc-drift.mjs +94 -0
- package/src/core/eval-fixtures.mjs +676 -0
- package/src/core/eval-frontier-fixtures.mjs +657 -0
- package/src/core/eval-hard-fixtures.mjs +923 -0
- package/src/core/eval-runner.mjs +754 -0
- package/src/core/eval-telemetry.mjs +338 -0
- package/src/core/harness-writer.mjs +286 -0
- package/src/core/installer.mjs +42 -0
- package/src/core/rules-compiler.mjs +356 -0
- package/src/core/task-ledger.mjs +327 -0
- package/src/core/version.mjs +10 -0
- package/src/ui/public/app.mjs +2199 -0
- package/src/ui/public/index.html +203 -0
- package/src/ui/public/styles.css +1200 -0
- package/src/ui/server.mjs +457 -0
- package/src/ui/service.mjs +860 -0
- package/templates/en-US/AGENTS.md +38 -0
- package/templates/en-US/DOCS_MAINTENANCE.md +65 -0
- package/templates/en-US/MIGRATION.md +46 -0
- package/templates/en-US/NEW_PROJECT_CHECKLIST.md +46 -0
- package/templates/en-US/README.md +41 -0
- package/templates/en-US/SESSION.md +29 -0
- package/templates/en-US/docs/00-context.md +38 -0
- package/templates/en-US/docs/01-vision/README.md +36 -0
- package/templates/en-US/docs/02-requirements/PRD.md +24 -0
- package/templates/en-US/docs/02-requirements/glossary.md +20 -0
- package/templates/en-US/docs/02-requirements/use-cases.md +36 -0
- package/templates/en-US/docs/03-architecture/composite-ai-framework.md +36 -0
- package/templates/en-US/docs/03-architecture/integration-architecture.md +36 -0
- package/templates/en-US/docs/03-architecture/system-architecture.md +16 -0
- package/templates/en-US/docs/04-design/README.md +21 -0
- package/templates/en-US/docs/04-design/a2a-integration-spec.md +36 -0
- package/templates/en-US/docs/04-design/agent-specs.md +36 -0
- package/templates/en-US/docs/04-design/data-model.md +18 -0
- package/templates/en-US/docs/04-design/external-api-spec.md +26 -0
- package/templates/en-US/docs/04-design/mcp-interface-spec.md +36 -0
- package/templates/en-US/docs/04-design/phase1-minimal-implementation-interfaces.md +36 -0
- package/templates/en-US/docs/04-design/responsibility-model.md +36 -0
- package/templates/en-US/docs/04-design/runtime-control-plane-spec.md +36 -0
- package/templates/en-US/docs/04-design/safety-governance.md +18 -0
- package/templates/en-US/docs/04-design/sample-scenarios-architecture-refinement.md +20 -0
- package/templates/en-US/docs/04-design/skill-syntax-spec.md +36 -0
- package/templates/en-US/docs/04-design/storage-schema.md +18 -0
- package/templates/en-US/docs/04-design/task-capability-architecture-and-evolution.md +36 -0
- package/templates/en-US/docs/05-project/adr/ADR-000-template.md +32 -0
- package/templates/en-US/docs/05-project/adr/README.md +15 -0
- package/templates/en-US/docs/05-project/doc-code-map.md +17 -0
- package/templates/en-US/docs/05-project/evolution-backlog.md +14 -0
- package/templates/en-US/docs/05-project/feature-registry.md +16 -0
- package/templates/en-US/docs/05-project/master-delivery-tracker.md +14 -0
- package/templates/en-US/docs/05-project/risk-register.md +36 -0
- package/templates/en-US/docs/05-project/roadmap.md +36 -0
- package/templates/en-US/docs/05-project/stage-view.md +14 -0
- package/templates/en-US/docs/05-project/tech-stack.md +36 -0
- package/templates/en-US/docs/06-dev-guide/SPEC.md +18 -0
- package/templates/en-US/docs/06-dev-guide/coding-standards.md +36 -0
- package/templates/en-US/docs/06-dev-guide/deployment-architecture.md +20 -0
- package/templates/en-US/docs/06-dev-guide/project-scaffold.md +16 -0
- package/templates/en-US/docs/06-dev-guide/testing-strategy.md +42 -0
- package/templates/en-US/docs/07-frontend/README.md +36 -0
- package/templates/en-US/docs/07-frontend/user-personas.md +36 -0
- package/templates/en-US/docs/08-process/README.md +27 -0
- package/templates/en-US/docs/08-process/ai-collaboration-protocol.md +28 -0
- package/templates/en-US/docs/08-process/autopilot.md +18 -0
- package/templates/en-US/docs/08-process/code-grounding.md +32 -0
- package/templates/en-US/docs/08-process/context-loading-strategy.md +35 -0
- package/templates/en-US/docs/08-process/conventions.md +75 -0
- package/templates/en-US/docs/08-process/debugging.md +25 -0
- package/templates/en-US/docs/08-process/design-gate.md +22 -0
- package/templates/en-US/docs/08-process/git-protocol.md +20 -0
- package/templates/en-US/docs/08-process/multi-agent-orchestration.md +27 -0
- package/templates/en-US/docs/08-process/planning.md +18 -0
- package/templates/en-US/docs/08-process/project-intake.md +47 -0
- package/templates/en-US/docs/08-process/reflection.md +18 -0
- package/templates/en-US/docs/08-process/review.md +30 -0
- package/templates/en-US/docs/08-process/session-handoff.md +27 -0
- package/templates/en-US/docs/08-process/tdd.md +24 -0
- package/templates/en-US/docs/08-process/tool-execution.md +32 -0
- package/templates/en-US/docs/08-process/workflow-contract.md +46 -0
- package/templates/en-US/docs/08-process/workflow.md +23 -0
- package/templates/en-US/docs/README.md +58 -0
- package/templates/en-US/docs/design-checklist.md +36 -0
- package/templates/en-US/docs/discussions/README.md +13 -0
- package/templates/en-US/docs/plans/README.md +13 -0
- package/templates/en-US/docs/proposed-design/README.md +13 -0
- package/templates/en-US/docs/temp-reference/README.md +11 -0
- package/templates/en-US/docs.config.json +46 -0
- package/templates/en-US/profiles/README.md +23 -0
- package/templates/en-US/profiles/agent-platform/README.md +23 -0
- package/templates/en-US/profiles/cli-tool/README.md +23 -0
- package/templates/en-US/profiles/library-sdk/README.md +23 -0
- package/templates/en-US/profiles/multi-agent/README.md +23 -0
- package/templates/en-US/profiles/profiles.json +31 -0
- package/templates/en-US/profiles/software-automation/README.md +23 -0
- package/templates/en-US/profiles/web-saas/README.md +23 -0
- package/templates/en-US/scripts/README.md +89 -0
- package/templates/en-US/scripts/doc-find.mjs +156 -0
- package/templates/en-US/scripts/doc-map.mjs +50 -0
- package/templates/en-US/scripts/doc-tools.mjs +311 -0
- package/templates/en-US/scripts/init-docs.mjs +214 -0
- package/templates/en-US/scripts/validate-docs.mjs +141 -0
- package/templates/zh-CN/AGENTS.md +38 -0
- package/templates/zh-CN/DOCS_MAINTENANCE.md +77 -0
- package/templates/zh-CN/MIGRATION.md +45 -0
- package/templates/zh-CN/NEW_PROJECT_CHECKLIST.md +54 -0
- package/templates/zh-CN/README.md +55 -0
- package/templates/zh-CN/SESSION.md +29 -0
- package/templates/zh-CN/docs/00-context.md +42 -0
- package/templates/zh-CN/docs/01-vision/README.md +33 -0
- package/templates/zh-CN/docs/02-requirements/PRD.md +26 -0
- package/templates/zh-CN/docs/02-requirements/glossary.md +35 -0
- package/templates/zh-CN/docs/02-requirements/use-cases.md +31 -0
- package/templates/zh-CN/docs/03-architecture/composite-ai-framework.md +27 -0
- package/templates/zh-CN/docs/03-architecture/integration-architecture.md +30 -0
- package/templates/zh-CN/docs/03-architecture/system-architecture.md +26 -0
- package/templates/zh-CN/docs/04-design/README.md +21 -0
- package/templates/zh-CN/docs/04-design/a2a-integration-spec.md +45 -0
- package/templates/zh-CN/docs/04-design/agent-specs.md +46 -0
- package/templates/zh-CN/docs/04-design/data-model.md +18 -0
- package/templates/zh-CN/docs/04-design/external-api-spec.md +34 -0
- package/templates/zh-CN/docs/04-design/mcp-interface-spec.md +44 -0
- package/templates/zh-CN/docs/04-design/phase1-minimal-implementation-interfaces.md +38 -0
- package/templates/zh-CN/docs/04-design/responsibility-model.md +37 -0
- package/templates/zh-CN/docs/04-design/runtime-control-plane-spec.md +47 -0
- package/templates/zh-CN/docs/04-design/safety-governance.md +18 -0
- package/templates/zh-CN/docs/04-design/sample-scenarios-architecture-refinement.md +38 -0
- package/templates/zh-CN/docs/04-design/skill-syntax-spec.md +43 -0
- package/templates/zh-CN/docs/04-design/storage-schema.md +18 -0
- package/templates/zh-CN/docs/04-design/task-capability-architecture-and-evolution.md +46 -0
- package/templates/zh-CN/docs/05-project/adr/ADR-000-template.md +34 -0
- package/templates/zh-CN/docs/05-project/adr/README.md +35 -0
- package/templates/zh-CN/docs/05-project/doc-code-map.md +19 -0
- package/templates/zh-CN/docs/05-project/evolution-backlog.md +14 -0
- package/templates/zh-CN/docs/05-project/feature-registry.md +16 -0
- package/templates/zh-CN/docs/05-project/master-delivery-tracker.md +14 -0
- package/templates/zh-CN/docs/05-project/risk-register.md +21 -0
- package/templates/zh-CN/docs/05-project/roadmap.md +31 -0
- package/templates/zh-CN/docs/05-project/stage-view.md +14 -0
- package/templates/zh-CN/docs/05-project/tech-stack.md +36 -0
- package/templates/zh-CN/docs/06-dev-guide/SPEC.md +24 -0
- package/templates/zh-CN/docs/06-dev-guide/coding-standards.md +29 -0
- package/templates/zh-CN/docs/06-dev-guide/deployment-architecture.md +22 -0
- package/templates/zh-CN/docs/06-dev-guide/project-scaffold.md +16 -0
- package/templates/zh-CN/docs/06-dev-guide/testing-strategy.md +46 -0
- package/templates/zh-CN/docs/07-frontend/README.md +29 -0
- package/templates/zh-CN/docs/07-frontend/user-personas.md +27 -0
- package/templates/zh-CN/docs/08-process/README.md +29 -0
- package/templates/zh-CN/docs/08-process/ai-collaboration-protocol.md +30 -0
- package/templates/zh-CN/docs/08-process/autopilot.md +18 -0
- package/templates/zh-CN/docs/08-process/code-grounding.md +40 -0
- package/templates/zh-CN/docs/08-process/context-loading-strategy.md +35 -0
- package/templates/zh-CN/docs/08-process/conventions.md +77 -0
- package/templates/zh-CN/docs/08-process/debugging.md +27 -0
- package/templates/zh-CN/docs/08-process/design-gate.md +22 -0
- package/templates/zh-CN/docs/08-process/git-protocol.md +20 -0
- package/templates/zh-CN/docs/08-process/multi-agent-orchestration.md +27 -0
- package/templates/zh-CN/docs/08-process/planning.md +18 -0
- package/templates/zh-CN/docs/08-process/project-intake.md +53 -0
- package/templates/zh-CN/docs/08-process/reflection.md +18 -0
- package/templates/zh-CN/docs/08-process/review.md +30 -0
- package/templates/zh-CN/docs/08-process/session-handoff.md +29 -0
- package/templates/zh-CN/docs/08-process/tdd.md +24 -0
- package/templates/zh-CN/docs/08-process/tool-execution.md +34 -0
- package/templates/zh-CN/docs/08-process/workflow-contract.md +48 -0
- package/templates/zh-CN/docs/08-process/workflow.md +23 -0
- package/templates/zh-CN/docs/README.md +62 -0
- package/templates/zh-CN/docs/design-checklist.md +18 -0
- package/templates/zh-CN/docs/discussions/README.md +36 -0
- package/templates/zh-CN/docs/plans/README.md +15 -0
- package/templates/zh-CN/docs/proposed-design/README.md +41 -0
- package/templates/zh-CN/docs/temp-reference/README.md +13 -0
- package/templates/zh-CN/docs.config.json +46 -0
- package/templates/zh-CN/profiles/README.md +23 -0
- package/templates/zh-CN/profiles/agent-platform/README.md +23 -0
- package/templates/zh-CN/profiles/cli-tool/README.md +23 -0
- package/templates/zh-CN/profiles/library-sdk/README.md +23 -0
- package/templates/zh-CN/profiles/multi-agent/README.md +23 -0
- package/templates/zh-CN/profiles/profiles.json +31 -0
- package/templates/zh-CN/profiles/software-automation/README.md +23 -0
- package/templates/zh-CN/profiles/web-saas/README.md +23 -0
- package/templates/zh-CN/scripts/README.md +97 -0
- package/templates/zh-CN/scripts/doc-find.mjs +156 -0
- package/templates/zh-CN/scripts/doc-map.mjs +50 -0
- package/templates/zh-CN/scripts/doc-tools.mjs +311 -0
- package/templates/zh-CN/scripts/init-docs.mjs +214 -0
- package/templates/zh-CN/scripts/validate-docs.mjs +141 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-05-04
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 讨论文档目录
|
|
8
|
+
|
|
9
|
+
本目录用于存放讨论稿、比较稿、探索稿、吸收评估稿等非正式文档。
|
|
10
|
+
|
|
11
|
+
> 命名、front-matter、状态、转正流程统一见 [`../08-process/conventions.md`](../08-process/conventions.md)。
|
|
12
|
+
|
|
13
|
+
## 使用规则
|
|
14
|
+
|
|
15
|
+
- 讨论稿可以推动正式文档演进,但不能长期替代正式文档
|
|
16
|
+
- 讨论结论稳定后,应转入对应正式文档,并按通用约定处理原稿
|
|
17
|
+
- 转正后,原稿 front-matter 应改为 `status: Superseded` 并回填仓库根相对路径 `superseded_by`
|
|
18
|
+
|
|
19
|
+
## 命名
|
|
20
|
+
|
|
21
|
+
- `YYYY-MM-DD-<主题>.md`(例如 `2026-05-04-routing-strategy.md`)
|
|
22
|
+
|
|
23
|
+
## front-matter 模板
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
---
|
|
27
|
+
status: Draft
|
|
28
|
+
owner: engineering
|
|
29
|
+
kind: discussion
|
|
30
|
+
created: YYYY-MM-DD
|
|
31
|
+
topic: <主题简述>
|
|
32
|
+
feature_ref: []
|
|
33
|
+
superseded_by: "" # 仅在被替代后填写仓库根相对路径
|
|
34
|
+
---
|
|
35
|
+
```
|
|
36
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 计划与任务材料
|
|
8
|
+
|
|
9
|
+
已有 Issue、OpenSpec 或其他计划系统时继续使用。本目录只用于确需保留且没有合适载体的计划,不要求一个切片一个文件。
|
|
10
|
+
|
|
11
|
+
任务应能找到目标、依据、范围、验收和验证;参考 [轻量任务记录](../08-process/workflow-contract.md)。复杂任务可在同一文件包含多个可验证结果及依赖。
|
|
12
|
+
|
|
13
|
+
计划描述待做工作,不证明代码已存在。获授权的草案可执行,完成后按任务系统关闭或标记 Archived;长期契约回到正式规范。SESSION 只链接当前任务,不抄写整份计划。
|
|
14
|
+
|
|
15
|
+
命名沿用项目约定,日期或任务 ID 均可。使用模板 kind: task 时校验目标、范围、验收与验证三个标题;已有任务格式无须转换。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-05-04
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 建议设计目录
|
|
8
|
+
|
|
9
|
+
本目录用于存放尚未转正的候选设计稿。
|
|
10
|
+
|
|
11
|
+
> 命名、front-matter、状态、转正流程统一见 [`../08-process/conventions.md`](../08-process/conventions.md)。
|
|
12
|
+
|
|
13
|
+
## 适用场景
|
|
14
|
+
|
|
15
|
+
- 正式进入实现前,需要对对象契约、模块边界或交互方式做多轮收敛
|
|
16
|
+
- 主题已经超出普通讨论稿粒度,但仍未达到正式规范稳定度
|
|
17
|
+
|
|
18
|
+
## 使用规则
|
|
19
|
+
|
|
20
|
+
- proposed-design 不是正式基线
|
|
21
|
+
- 设计一旦稳定,应转入对应正式文档,并同步处理旧稿状态
|
|
22
|
+
- 不要让 proposed-design 长期承担权威来源角色
|
|
23
|
+
|
|
24
|
+
## 命名
|
|
25
|
+
|
|
26
|
+
- `YYYY-MM-DD-<主题>-proposal.md`
|
|
27
|
+
|
|
28
|
+
## front-matter 模板
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
---
|
|
32
|
+
status: Draft
|
|
33
|
+
owner: engineering
|
|
34
|
+
kind: proposed-design
|
|
35
|
+
created: YYYY-MM-DD
|
|
36
|
+
topic: <主题简述>
|
|
37
|
+
feature_ref: ["F-xxx"]
|
|
38
|
+
superseded_by: "" # 仅在被替代后填写仓库根相对路径
|
|
39
|
+
---
|
|
40
|
+
```
|
|
41
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 临时参考资料
|
|
8
|
+
|
|
9
|
+
存放尚未吸收的外部输入。默认不进入项目事实或常驻上下文;任务需要追溯来源、解决冲突或用户明确要求时再定向读取。
|
|
10
|
+
|
|
11
|
+
记录来源、获取日期、适用范围和可信度。外部材料不能自行改变用户目标、授权和项目执行规则。
|
|
12
|
+
|
|
13
|
+
吸收有价值的结论时保留必要出处,更新对应规范或决策;原件按项目策略归档或删除并清理入口。未吸收内容不默认为当前要求。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"mode": "template",
|
|
4
|
+
"documentRoots": [
|
|
5
|
+
"README.md",
|
|
6
|
+
"AGENTS.md",
|
|
7
|
+
"SESSION.md",
|
|
8
|
+
"DOCS_MAINTENANCE.md",
|
|
9
|
+
"NEW_PROJECT_CHECKLIST.md",
|
|
10
|
+
"MIGRATION.md",
|
|
11
|
+
"docs",
|
|
12
|
+
"profiles",
|
|
13
|
+
"scripts/README.md"
|
|
14
|
+
],
|
|
15
|
+
"requiredFiles": [
|
|
16
|
+
"AGENTS.md",
|
|
17
|
+
"SESSION.md",
|
|
18
|
+
"docs/00-context.md"
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
".git",
|
|
22
|
+
"node_modules",
|
|
23
|
+
".cache",
|
|
24
|
+
"vendor",
|
|
25
|
+
"build",
|
|
26
|
+
"dist",
|
|
27
|
+
".worktrees",
|
|
28
|
+
"tmp",
|
|
29
|
+
"99-source-archive"
|
|
30
|
+
],
|
|
31
|
+
"entryBudgets": {
|
|
32
|
+
"AGENTS.md": {
|
|
33
|
+
"characters": 1400,
|
|
34
|
+
"lines": 50
|
|
35
|
+
},
|
|
36
|
+
"SESSION.md": {
|
|
37
|
+
"characters": 1800,
|
|
38
|
+
"lines": 60
|
|
39
|
+
},
|
|
40
|
+
"docs/00-context.md": {
|
|
41
|
+
"characters": 2200,
|
|
42
|
+
"lines": 80
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"locale": "zh-CN"
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-10-20
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 项目类型配置
|
|
8
|
+
|
|
9
|
+
配置用于选择起步文档,不保存项目事实,也不预设必须采用的架构。默认 minimal 适用于所有软件项目。
|
|
10
|
+
|
|
11
|
+
机器清单的唯一来源为 [profiles.json](profiles.json)。每种配置共享六份基础文档和一份按需接入指南,再按类型添加少量专题;需要时继续从文档样板库选取。先选择最接近的一项;后续可按真实需要用增量更新添加另一项,不叠加全部清单。
|
|
12
|
+
|
|
13
|
+
| 配置 | 使用范围 | 说明 |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| minimal | 任意软件、脚本、数据、移动端、桌面或固件项目 | 基础入口与按需接入指南 |
|
|
16
|
+
| cli-tool | 命令行工具 | [参考](cli-tool/README.md) |
|
|
17
|
+
| web-saas | Web 应用和服务 | [参考](web-saas/README.md) |
|
|
18
|
+
| library-sdk | 库与 SDK | [参考](library-sdk/README.md) |
|
|
19
|
+
| agent-platform | 产品本身包含智能体 | [参考](agent-platform/README.md) |
|
|
20
|
+
| software-automation | 软件或工作流自动化产品 | [参考](software-automation/README.md) |
|
|
21
|
+
| multi-agent | 多执行者开发协作 | [参考](multi-agent/README.md) |
|
|
22
|
+
|
|
23
|
+
使用方式与覆盖保护见 [初始化清单](../NEW_PROJECT_CHECKLIST.md)。已有项目按 [迁移指南](../MIGRATION.md) 逐步接入,不直接复制样板替换已确认内容。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 智能体产品
|
|
8
|
+
|
|
9
|
+
仅适用于产品本身具备智能体、工具调用或任务执行机制;使用 AI 开发普通软件不需要启用。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile agent-platform
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
根据实际实现说明执行入口、状态、工具权限、取消与恢复,区分规划输出和已执行结果。MCP、A2A、技能与记忆仅在产品确有这些能力时增加。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 命令行工具
|
|
8
|
+
|
|
9
|
+
适用于 CLI、离线脚本及开发工具。优先明确命令、参数、退出码、输入输出和配置优先级。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile cli-tool
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
沿真实命令注册路径核对实现;关注错误输入、兼容参数和分发后的运行环境。简单工具可把契约合并进已有 README。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 库与 SDK
|
|
8
|
+
|
|
9
|
+
适用于被其他项目集成的库、SDK 和插件。重点说明公共 API、兼容承诺、错误模型和版本策略。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile library-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
沿导出入口检查消费者与示例,避免只实现内部函数而未公开可用。关注兼容测试和包分发结果,内部重构不应无意改变公共行为。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 并行开发协作
|
|
8
|
+
|
|
9
|
+
适用于多个开发者或智能体并行工作,不依赖具体智能体产品。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile multi-agent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
优先使用已有任务系统和工作区隔离;认领需要原子性,Markdown 不是锁。任务证据独立记录,集成者核验合并结果并维护共享快照。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"minimal": [],
|
|
3
|
+
"cli-tool": [
|
|
4
|
+
"docs/04-design/external-api-spec.md",
|
|
5
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
6
|
+
],
|
|
7
|
+
"web-saas": [
|
|
8
|
+
"docs/04-design/external-api-spec.md",
|
|
9
|
+
"docs/04-design/data-model.md",
|
|
10
|
+
"docs/04-design/safety-governance.md",
|
|
11
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
12
|
+
],
|
|
13
|
+
"library-sdk": [
|
|
14
|
+
"docs/04-design/external-api-spec.md",
|
|
15
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
16
|
+
],
|
|
17
|
+
"agent-platform": [
|
|
18
|
+
"docs/04-design/agent-specs.md",
|
|
19
|
+
"docs/04-design/safety-governance.md",
|
|
20
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
21
|
+
],
|
|
22
|
+
"software-automation": [
|
|
23
|
+
"docs/04-design/sample-scenarios-architecture-refinement.md",
|
|
24
|
+
"docs/04-design/safety-governance.md",
|
|
25
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
26
|
+
],
|
|
27
|
+
"multi-agent": [
|
|
28
|
+
"docs/08-process/multi-agent-orchestration.md",
|
|
29
|
+
"docs/06-dev-guide/testing-strategy.md"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 软件自动化
|
|
8
|
+
|
|
9
|
+
适用于软件操作、工作流执行、浏览器 / 桌面自动化或本地执行器。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile software-automation
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
从代表任务检查动作前提、实际反馈、失败恢复、幂等与撤销边界。区分模拟成功和外部系统实际完成,重试前核对未知副作用。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-09-29
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Web 与服务
|
|
8
|
+
|
|
9
|
+
适用于 Web 应用、服务及 SaaS。按实际产品明确请求、身份、权限和数据边界,不默认引入多租户或微服务。
|
|
10
|
+
|
|
11
|
+
## 初始化
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node scripts/init-docs.mjs ../my-project --profile web-saas
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
默认预览;显式 --write 才创建且不覆盖已有文件。基础与增量文件以 [机器清单](../profiles.json) 和 [通用说明](../README.md) 为准,不重复维护最小文件列表。
|
|
18
|
+
|
|
19
|
+
## 核验重点
|
|
20
|
+
|
|
21
|
+
核对真实路由、前后端调用与数据访问路径;检查租户或权限要求时以实际产品范围为准。持久化、交互和部署文档按需要增加。
|
|
22
|
+
|
|
23
|
+
已有契约、任务或测试工具直接复用,专题内容可合并到真实项目来源;空白样板不能视为已启用能力。
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: Current
|
|
3
|
+
owner: docs-template
|
|
4
|
+
last_verified: 2026-10-20
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 文档工具
|
|
8
|
+
|
|
9
|
+
Node.js 18 或以上,无第三方依赖。所有路径参数以项目根为基准,Markdown 链接按所在文件解析。工具不会执行文档中的命令。
|
|
10
|
+
|
|
11
|
+
CLI 可从符号链接或系统路径别名启动;文档扫描与写入目标仍保持原有符号链接保护。
|
|
12
|
+
|
|
13
|
+
## 结构校验
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
node scripts/validate-docs.mjs . --mode project
|
|
17
|
+
node scripts/validate-docs.mjs . --mode template --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
默认使用 docs.config.json 的模式与范围;无配置时仅扫描基础入口和 docs,不遍历整仓库。exclude 支持目录名或仓库根相对路径,显式扫描入口也遵守排除规则;符号链接不递归扫描。未知配置字段会报错,不静默回退。两套分发的工具诊断统一使用英文。
|
|
21
|
+
|
|
22
|
+
- 两种模式均检查入口存在、元数据、链接目标、入口预算提示和必读依赖环。
|
|
23
|
+
- template 允许样板占位;project 拒绝 Current 正文的占位内容,提示 Draft / Unverified 的核验状态。
|
|
24
|
+
- Current 日期必须有效;不要求日期等于今天,不按日期距今天数判定过期,也不自动刷新日期。日期含义见 [通用约定](../docs/08-process/conventions.md),真实时效要求仍按项目规则核验。
|
|
25
|
+
- kind: task 检查目标、范围、验收与验证标题;已有任务格式不强制转换。
|
|
26
|
+
- 普通代码路径与 glob 的固定目录前缀不存在时提示;不声称检查了完整匹配集合或语义一致性。
|
|
27
|
+
- 相对链接须位于项目内且目标存在;不联网、不检查页内锚点,不把代码块示例当作真实链接;这是有限的 Markdown 扫描器,不是完整 CommonMark 解析器。
|
|
28
|
+
|
|
29
|
+
退出码 0 表示未发现结构错误;1 表示结构、配置或命令错误。预算默认提示,--strict 可将所有提示用于门禁。即使通过,仍可能存在未初始化文档、错误实现或未完成验收。
|
|
30
|
+
|
|
31
|
+
校验器只读,不改正文、元数据或文件修改时间;重复检查不应产生文档差异。检查输出的运行时间若需留存,放入 CI 或任务回执,不回填所有被检查文件。
|
|
32
|
+
|
|
33
|
+
## 代码影响提示
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
node scripts/doc-map.mjs . --changed src/query.js --changed tests/query.test.js
|
|
37
|
+
node scripts/doc-map.mjs . --json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
从启用文档的 code_refs 或兼容字段 code_owns 读取映射;支持仓库根相对路径、*、**、?。Superseded / Archived 不作为当前提示;其他结果显示状态。多个文档匹配正常,无匹配也不证明无需同步。
|
|
41
|
+
|
|
42
|
+
只输出查询结果,不维护第二份手工映射表,不执行代码或修改项目。
|
|
43
|
+
|
|
44
|
+
## 轻量检索
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
node scripts/doc-find.mjs . --topic "CLI 参数" --changed src/cli/run.js
|
|
48
|
+
node scripts/doc-find.mjs . --topic API --limit 5 --max-chars 2400 --json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
显式指定主题或代码路径;只返回文档路径、状态、匹配理由和小节行号,不输出正文,不创建索引数据库。先根据提示选取必要原文;无命中不证明没有约束。Draft 仍需核验,命中 Current 也不是实现证据。
|
|
52
|
+
|
|
53
|
+
默认最多 5 条、完整标准输出最多 2,400 个 Unicode 字符,含 JSON 包装和换行;可显式调整为 1–20 条、512–12,000 字符。超出移除末尾结果并计入 omitted,JSON 保持可解析。两种输出相同输入具有相同顺序,不含时间戳。
|
|
54
|
+
|
|
55
|
+
沿配置范围列举文件,最多读取前 1,000 份文档,每份最多 16 KiB;仅匹配路径、标题、小节和 trigger / scope / code_refs。正文深处可能不被检索。总 glob 匹配工作量有上限;scan.partial 表示读取截断、候选过多、元数据问题或匹配预算耗尽,应缩小 documentRoots 或直接检查目标来源。这里只限制内容读取,目录列举仍按配置范围进行,不适合将整仓库设为检索根。
|
|
56
|
+
|
|
57
|
+
此命令不调用模型、不执行文档命令、不改文件。输出字符数不是 token 数,也不证明缓存命中。
|
|
58
|
+
|
|
59
|
+
## 元数据格式
|
|
60
|
+
|
|
61
|
+
为保持无依赖,解析器只支持顶层字段、普通或引号字符串、JSON 字符串数组、缩进的字符串列表;支持 UTF-8 BOM、LF / CRLF 与行尾注释。复杂嵌套、多行块和 YAML 锚点会报错,应放进独立证据文件或换用项目已有完整 YAML 工具。
|
|
62
|
+
|
|
63
|
+
## 初始化(在模板库中执行)
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
node scripts/init-docs.mjs ../my-project --profile minimal
|
|
67
|
+
node scripts/init-docs.mjs ../my-project --profile minimal --write
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
首次初始化默认预览;写入前检查全部目标,已有文件或符号链接会拒绝写入。实际创建使用独占模式;并发或磁盘错误可能留下部分文件,按失败回执检查实际结果。
|
|
71
|
+
|
|
72
|
+
同一模板与配置生成相同文件内容,不注入当前时间或目标机器路径,也不为沿用模板而刷新其核验日期。已有项目按实际变化维护,不通过重复初始化刷新文档。
|
|
73
|
+
|
|
74
|
+
所有配置除六份基础文档外,均附带按需项目接入指南,以保证 AGENTS 的条件路由可用;不复制整套过程库,也不将该指南列为默认必读。
|
|
75
|
+
|
|
76
|
+
初始化器仅随模板库分发;生成项目只带校验、反查、检索与共享解析工具。类型清单位于模板 profiles/profiles.json。项目只需调整 docs.config.json 的扫描范围、必需入口及预算。
|
|
77
|
+
|
|
78
|
+
## 增量更新(在模板库中执行)
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
node scripts/init-docs.mjs ../my-project --update --profile web-saas --json
|
|
82
|
+
node scripts/init-docs.mjs ../my-project --update --profile web-saas --write --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
初始化记录 `.agentlock.json`:语言、已启用配置、来源指纹、文件归属和内容哈希,不含时间戳。更新合并配置并增加缺少的专题。AGENTS、SESSION、工程入口、项目文档和配置只播种一次;即使仍与样板相同也不替换,不删除文件,不自动重排项目索引。新增专题依据命令回执按需接入原路由。
|
|
86
|
+
|
|
87
|
+
仅固定清单中的工具资产受管理。未修改资产可升级;已修改或归属未知的工具产生 conflict,写入前停止。预览仍会返回各项状态,应查看 changes;内容不变则不写回,重复执行保持 mtime。没有清单的旧项目按迁移指南手工合并,不扫描认领,也没有 force 覆盖选项。
|
|
88
|
+
|
|
89
|
+
执行前及每份写入前重新检查目标;拒绝项目内外的符号链接。单个工具替换使用临时文件及 rename;这不能消除外部编辑器的全部竞态,也不提供跨文件事务。失败时 JSON 的 writtenFiles 记录已完成文件,attemptedFiles 与 failedFile 指明已尝试及失败位置;失败位置可能已有部分内容。先检查现场,必要时恢复本次工具至原基线后重试,不能自动认领新的哈希。真实项目文档始终留在其原来源。
|
|
90
|
+
|
|
91
|
+
## 工具回归(在 AgentLock 仓库根目录执行)
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npm test
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
测试覆盖裁剪后初始化、覆盖保护、两种校验模式、换行与编码、路径边界、代码块、依赖环和映射。业务验证继续使用项目自己的测试与验收流程。
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { readConfig, documents, parseDocument, withoutCode, codeReferences, globMatcher, relative, localPath, normalize, isMain } from './doc-tools.mjs';
|
|
5
|
+
|
|
6
|
+
const MAX_BYTES = 16384, MAX_FILES = 1000, MAX_MAPPING_WORK = 5_000_000;
|
|
7
|
+
const notice = 'Discovery hints only; no match does not prove that constraints are absent. Check sources and active code.';
|
|
8
|
+
const shorten = (text, length) => Array.from(text).slice(0, length).join('');
|
|
9
|
+
const order = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
10
|
+
const fold = text => text.normalize('NFKC').toLowerCase();
|
|
11
|
+
|
|
12
|
+
function integer(value, fallback, min, max, name) {
|
|
13
|
+
const result = value === undefined ? fallback : Number(value);
|
|
14
|
+
if (!Number.isInteger(result) || result < min || result > max) throw new Error(name + ' must be an integer from ' + min + ' to ' + max);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function prefix(file) {
|
|
19
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
|
|
20
|
+
try {
|
|
21
|
+
const stat = fs.fstatSync(fd);
|
|
22
|
+
if (!stat.isFile()) throw new Error('Not a regular document');
|
|
23
|
+
const buffer = Buffer.alloc(Math.min(stat.size, MAX_BYTES));
|
|
24
|
+
const bytes = fs.readSync(fd, buffer, 0, buffer.length, 0);
|
|
25
|
+
return { text: normalize(buffer.subarray(0, bytes).toString('utf8')), bytes, truncated: stat.size > bytes };
|
|
26
|
+
} finally { fs.closeSync(fd); }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function findDocuments(root, options = {}) {
|
|
30
|
+
root = path.resolve(root);
|
|
31
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) throw new Error('Project directory does not exist');
|
|
32
|
+
const topic = options.topic ?? '', changed = options.changed ?? [];
|
|
33
|
+
if (typeof topic !== 'string' || topic.length > 256) throw new Error('Topic must be at most 256 characters');
|
|
34
|
+
if (!Array.isArray(changed) || changed.length > 16 || changed.some(value => typeof value !== 'string' || !value || value.length > 512)) {
|
|
35
|
+
throw new Error('Use at most 16 changed paths, each at most 512 characters');
|
|
36
|
+
}
|
|
37
|
+
if (!topic.trim() && !changed.length) throw new Error('Provide --topic or --changed; there is no load-all mode');
|
|
38
|
+
const terms = [...new Set(fold(topic).trim().split(/\s+/).filter(Boolean))];
|
|
39
|
+
if (terms.length > 16) throw new Error('Use at most 16 topic terms');
|
|
40
|
+
const paths = [...new Set(changed.map(name => relative(root, localPath(root, name))))];
|
|
41
|
+
const limit = integer(options.limit, 5, 1, 20, 'limit');
|
|
42
|
+
const files = documents(root, readConfig(root));
|
|
43
|
+
const scan = { candidates: files.length, read: 0, bytes: 0, truncated: 0, invalid: 0, mappingLimited: false, partial: files.length > MAX_FILES };
|
|
44
|
+
const rows = [];
|
|
45
|
+
let mappingWork = 0;
|
|
46
|
+
for (const file of files.slice(0, MAX_FILES)) {
|
|
47
|
+
const name = relative(root, file);
|
|
48
|
+
let sample, parsed, headings, patterns;
|
|
49
|
+
try {
|
|
50
|
+
sample = prefix(localPath(root, name));
|
|
51
|
+
scan.read++; scan.bytes += sample.bytes;
|
|
52
|
+
if (sample.truncated) scan.truncated++;
|
|
53
|
+
parsed = parseDocument(sample.text);
|
|
54
|
+
if (parsed.errors.length) throw new Error('Unsupported metadata');
|
|
55
|
+
if (['Archived', 'Superseded'].includes(parsed.meta?.status)) continue;
|
|
56
|
+
patterns = codeReferences(parsed.meta);
|
|
57
|
+
const offset = sample.text.slice(0, sample.text.length - parsed.body.length).split('\n').length - 1;
|
|
58
|
+
headings = [];
|
|
59
|
+
for (const [index, line] of withoutCode(parsed.body).split('\n').entries()) {
|
|
60
|
+
const match = line.match(/^ {0,3}(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
61
|
+
if (match) headings.push({ title: match[2], line: offset + index + 1, level: match[1].length });
|
|
62
|
+
}
|
|
63
|
+
} catch { scan.invalid++; continue; }
|
|
64
|
+
const title = headings.find(row => row.level === 1)?.title ?? name;
|
|
65
|
+
const meta = parsed.meta ?? {};
|
|
66
|
+
const values = [title, name, typeof meta.trigger === 'string' ? meta.trigger : '',
|
|
67
|
+
typeof meta.scope === 'string' ? meta.scope : Array.isArray(meta.scope) ? meta.scope.join(' ') : ''].map(fold);
|
|
68
|
+
const headingText = headings.map(row => fold(row.title));
|
|
69
|
+
let score = 0;
|
|
70
|
+
const reasons = [];
|
|
71
|
+
const hits = terms.filter(term => values.some(value => value.includes(term)) || headingText.some(value => value.includes(term)));
|
|
72
|
+
if (hits.length) {
|
|
73
|
+
score += hits.length * 4;
|
|
74
|
+
if (hits.some(term => values[0].includes(term))) score += 3;
|
|
75
|
+
reasons.push('topic: ' + shorten(hits.join(', '), 64));
|
|
76
|
+
}
|
|
77
|
+
if (paths.includes(name)) { score += 20; reasons.push('document path'); }
|
|
78
|
+
for (const pattern of patterns) {
|
|
79
|
+
if (!paths.length) break;
|
|
80
|
+
// Bound the existing DP glob matcher's total work even for adversarial metadata.
|
|
81
|
+
const work = (pattern.length + 1) * paths.reduce((sum, value) => sum + value.length + 1, 0);
|
|
82
|
+
if (mappingWork + work > MAX_MAPPING_WORK) { scan.mappingLimited = true; continue; }
|
|
83
|
+
mappingWork += work;
|
|
84
|
+
try {
|
|
85
|
+
const matcher = globMatcher(pattern);
|
|
86
|
+
if (paths.some(value => matcher.test(value))) { score += 20; reasons.push('code_refs/code_owns'); break; }
|
|
87
|
+
} catch { scan.invalid++; break; }
|
|
88
|
+
}
|
|
89
|
+
if (!score) continue;
|
|
90
|
+
const section = headings.find((row, index) => row.level > 1 && terms.some(term => headingText[index].includes(term))) ??
|
|
91
|
+
headings.find(row => row.level === 1);
|
|
92
|
+
rows.push({ document: name, title: shorten(title, 100), status: ['Current', 'Draft', 'Unverified'].includes(meta.status) ? meta.status : 'Unverified',
|
|
93
|
+
reason: reasons.join('; '), ...(section ? { section: { title: shorten(section.title, 100), line: section.line } } : {}), score });
|
|
94
|
+
}
|
|
95
|
+
scan.partial ||= scan.truncated > 0 || scan.invalid > 0 || scan.mappingLimited;
|
|
96
|
+
rows.sort((a, b) => b.score - a.score || order(a.document, b.document));
|
|
97
|
+
return { matches: rows.slice(0, limit).map(({ score, ...row }) => row), omitted: Math.max(0, rows.length - limit), scan, notice };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function formatFindResult(result, options = {}) {
|
|
101
|
+
const maxChars = integer(options.maxChars, 2400, 512, 12000, 'max-chars');
|
|
102
|
+
const bounded = { ...result, matches: [...result.matches] };
|
|
103
|
+
function render() {
|
|
104
|
+
if (options.json) return JSON.stringify(bounded) + '\n';
|
|
105
|
+
return [
|
|
106
|
+
...bounded.matches.map(row => row.document + (row.section ? ':' + row.section.line : '') + ' [' + row.status + '] ' + row.title + '\n ' + row.reason),
|
|
107
|
+
'omitted: ' + bounded.omitted + '; scanned: ' + bounded.scan.read + '/' + bounded.scan.candidates + '; partial: ' + bounded.scan.partial,
|
|
108
|
+
bounded.notice,
|
|
109
|
+
].join('\n') + '\n';
|
|
110
|
+
}
|
|
111
|
+
let output = render();
|
|
112
|
+
while (Array.from(output).length > maxChars && bounded.matches.length) {
|
|
113
|
+
bounded.matches.pop(); bounded.omitted++;
|
|
114
|
+
output = render();
|
|
115
|
+
}
|
|
116
|
+
return output;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function main() {
|
|
120
|
+
const args = process.argv.slice(2), options = { changed: [] };
|
|
121
|
+
let root = '.', hasRoot = false;
|
|
122
|
+
for (let i = 0; i < args.length; i++) {
|
|
123
|
+
const arg = args[i];
|
|
124
|
+
if (arg === '--help') {
|
|
125
|
+
console.log('node scripts/doc-find.mjs [root] (--topic text | --changed path)... [--limit 1..20] [--max-chars 512..12000] [--json]');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (arg === '--json') options.json = true;
|
|
129
|
+
else if (['--topic', '--changed', '--limit', '--max-chars'].includes(arg)) {
|
|
130
|
+
const value = args[++i];
|
|
131
|
+
if (!value || value.startsWith('--')) throw new Error(arg + ' requires a value');
|
|
132
|
+
if (arg === '--changed') options.changed.push(value);
|
|
133
|
+
else options[{ '--topic': 'topic', '--limit': 'limit', '--max-chars': 'maxChars' }[arg]] = value;
|
|
134
|
+
} else if (!arg.startsWith('-') && !hasRoot) { root = arg; hasRoot = true; }
|
|
135
|
+
else throw new Error('Unknown argument: ' + shorten(arg, 100));
|
|
136
|
+
}
|
|
137
|
+
integer(options.maxChars, 2400, 512, 12000, 'max-chars');
|
|
138
|
+
process.stdout.write(formatFindResult(findDocuments(root, options), options));
|
|
139
|
+
}
|
|
140
|
+
if (isMain(import.meta.url)) {
|
|
141
|
+
try { main(); } catch (error) {
|
|
142
|
+
const index = process.argv.lastIndexOf('--max-chars');
|
|
143
|
+
const requested = index < 0 ? 2400 : Number(process.argv[index + 1]);
|
|
144
|
+
const maxChars = Number.isInteger(requested) && requested >= 512 && requested <= 12000 ? requested : 2400;
|
|
145
|
+
let message = shorten(error.message, 300);
|
|
146
|
+
const json = process.argv.includes('--json');
|
|
147
|
+
let output = json ? JSON.stringify({ error: message }) + '\n' : message + '\n';
|
|
148
|
+
while (Array.from(output).length > maxChars) {
|
|
149
|
+
message = shorten(message, Array.from(message).length - 1);
|
|
150
|
+
output = json ? JSON.stringify({ error: message }) + '\n' : message + '\n';
|
|
151
|
+
}
|
|
152
|
+
if (json) process.stdout.write(output);
|
|
153
|
+
else process.stderr.write(output);
|
|
154
|
+
process.exitCode = 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { readConfig, documents, parseDocument, codeReferences, globMatcher, relative, localPath, isMain } from './doc-tools.mjs';
|
|
5
|
+
|
|
6
|
+
export function documentMap(root, changed = []) {
|
|
7
|
+
root = path.resolve(root);
|
|
8
|
+
if (!fs.existsSync(root)) throw new Error('Project directory does not exist: ' + root);
|
|
9
|
+
const normalized = changed.map(file => relative(root, localPath(root, file)));
|
|
10
|
+
const rows = [];
|
|
11
|
+
for (const file of documents(root, readConfig(root))) {
|
|
12
|
+
const parsed = parseDocument(fs.readFileSync(file, 'utf8'));
|
|
13
|
+
if (parsed.errors.length) throw new Error(relative(root, file) + ': ' + parsed.errors.join('; '));
|
|
14
|
+
if (!parsed.meta || ['Superseded', 'Archived'].includes(parsed.meta.status)) continue;
|
|
15
|
+
for (const pattern of codeReferences(parsed.meta)) {
|
|
16
|
+
const matcher = globMatcher(pattern);
|
|
17
|
+
const matches = normalized.filter(file => matcher.test(file));
|
|
18
|
+
if (!changed.length || matches.length) {
|
|
19
|
+
rows.push({ document: relative(root, file), status: parsed.meta.status, pattern, matches });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return rows;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function main() {
|
|
27
|
+
const args = process.argv.slice(2);
|
|
28
|
+
let root = '.', json = false, hasRoot = false;
|
|
29
|
+
const changed = [];
|
|
30
|
+
for (let i = 0; i < args.length; i++) {
|
|
31
|
+
if (args[i] === '--help') {
|
|
32
|
+
console.log('node scripts/doc-map.mjs [root] [--changed path]... [--json]');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (args[i] === '--changed') {
|
|
36
|
+
const value = args[++i];
|
|
37
|
+
if (!value || value.startsWith('--')) throw new Error('--changed requires a path');
|
|
38
|
+
changed.push(value);
|
|
39
|
+
} else if (args[i] === '--json') json = true;
|
|
40
|
+
else if (!args[i].startsWith('-') && !hasRoot) { root = args[i]; hasRoot = true; }
|
|
41
|
+
else throw new Error('Unknown argument: ' + args[i]);
|
|
42
|
+
}
|
|
43
|
+
const rows = documentMap(root, changed);
|
|
44
|
+
if (json) console.log(JSON.stringify(rows, null, 2));
|
|
45
|
+
else if (!rows.length) console.log('No mapping hints; this does not prove documentation is unaffected.');
|
|
46
|
+
else for (const row of rows) console.log(row.document + ' [' + row.status + '] <- ' + row.pattern);
|
|
47
|
+
}
|
|
48
|
+
if (isMain(import.meta.url)) {
|
|
49
|
+
try { main(); } catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
50
|
+
}
|