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,807 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentLock Harness v2.2 — Brownfield Repository Scanner & Zero-Friction Adopter
|
|
3
|
+
*
|
|
4
|
+
* Strictly read-only inspection phase:
|
|
5
|
+
* - Scans package manifests (package.json, pyproject.toml, CMakeLists.txt, go.mod, Cargo.toml, Makefile)
|
|
6
|
+
* - Detects package manager (pnpm/yarn/bun/npm), monorepo workspaces, CI workflows, existing AI instruction files
|
|
7
|
+
* - Extracts real build/lint/typecheck/test commands
|
|
8
|
+
* - Suggests best-fit v1 domain profile & host set
|
|
9
|
+
*
|
|
10
|
+
* Epistemic Honesty Rule (inherited from AgentLock v1):
|
|
11
|
+
* - Every auto-discovered entry written to `docs/00-context.md` is explicitly tagged `status: Unverified`
|
|
12
|
+
* and never claims execution verification until a human or CI actually runs it.
|
|
13
|
+
* - Generated `docs/00-context.md` strictly respects v1's budget (<= 80 lines, <= 2,200 chars).
|
|
14
|
+
*/
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { VALID_HOSTS } from "./catalog.mjs";
|
|
18
|
+
import { assertSafeDestination, REPO_ROOT } from "./harness-writer.mjs";
|
|
19
|
+
import { addTask, readLedger } from "./task-ledger.mjs";
|
|
20
|
+
|
|
21
|
+
export const VALID_DOCS_STRATEGIES = ["thin-route", "archive-switch"];
|
|
22
|
+
const LEGACY_ARCHIVE_PREFIX = "legacy-archive";
|
|
23
|
+
const MAX_EXISTING_DOCS = 500;
|
|
24
|
+
|
|
25
|
+
function isLegacyArchiveEntry(name) {
|
|
26
|
+
return name === LEGACY_ARCHIVE_PREFIX || name.startsWith(`${LEGACY_ARCHIVE_PREFIX}-`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function scanExistingDocs(root) {
|
|
30
|
+
const docsDir = path.join(root, "docs");
|
|
31
|
+
if (!fs.existsSync(docsDir)) return [];
|
|
32
|
+
try {
|
|
33
|
+
if (fs.lstatSync(docsDir).isSymbolicLink() || !fs.statSync(docsDir).isDirectory()) return [];
|
|
34
|
+
} catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const found = [];
|
|
38
|
+
const walk = (curDir) => {
|
|
39
|
+
if (found.length >= MAX_EXISTING_DOCS) return;
|
|
40
|
+
let entries;
|
|
41
|
+
try {
|
|
42
|
+
entries = fs.readdirSync(curDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
43
|
+
} catch {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const ent of entries) {
|
|
47
|
+
if (found.length >= MAX_EXISTING_DOCS) break;
|
|
48
|
+
if (ent.name === ".DS_Store" || ent.name === ".git" || ent.name === "node_modules") continue;
|
|
49
|
+
if (curDir === docsDir && isLegacyArchiveEntry(ent.name)) continue;
|
|
50
|
+
if (ent.isSymbolicLink()) continue;
|
|
51
|
+
const full = path.join(curDir, ent.name);
|
|
52
|
+
if (ent.isDirectory()) {
|
|
53
|
+
walk(full);
|
|
54
|
+
} else if (ent.isFile() && ent.name.toLowerCase().endsWith(".md")) {
|
|
55
|
+
found.push(path.relative(root, full).split(path.sep).join("/"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
walk(docsDir);
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getProfileDocs(profileId, locale = "zh-CN") {
|
|
64
|
+
const loc = locale === "en-US" ? "en-US" : "zh-CN";
|
|
65
|
+
const profilesPath = path.join(REPO_ROOT, "templates", loc, "profiles/profiles.json");
|
|
66
|
+
const profiles = readJsonSafe(profilesPath) || {};
|
|
67
|
+
return Array.isArray(profiles[profileId]) ? [...profiles[profileId]] : [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function readJsonSafe(filePath) {
|
|
71
|
+
if (!fs.existsSync(filePath)) return null;
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function detectNodePackageManager(root) {
|
|
80
|
+
if (fs.existsSync(path.join(root, "pnpm-lock.yaml")) || fs.existsSync(path.join(root, "pnpm-workspace.yaml"))) return "pnpm";
|
|
81
|
+
if (fs.existsSync(path.join(root, "bun.lockb")) || fs.existsSync(path.join(root, "bun.lock"))) return "bun";
|
|
82
|
+
if (fs.existsSync(path.join(root, "yarn.lock"))) return "yarn";
|
|
83
|
+
return "npm";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function runScriptCmd(pm, scriptName) {
|
|
87
|
+
if (pm === "npm") return scriptName === "test" ? "npm test" : `npm run ${scriptName}`;
|
|
88
|
+
if (pm === "pnpm") return scriptName === "test" ? "pnpm test" : `pnpm ${scriptName}`;
|
|
89
|
+
if (pm === "yarn") return `yarn ${scriptName}`;
|
|
90
|
+
return `bun run ${scriptName}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function pickFirstScript(scripts, candidates) {
|
|
94
|
+
for (const name of candidates) {
|
|
95
|
+
if (scripts && typeof scripts[name] === "string" && scripts[name].trim()) {
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
export function discoverSpecs(root) {
|
|
104
|
+
const canonicalCandidates = [
|
|
105
|
+
"docs/06-dev-guide/SPEC.md",
|
|
106
|
+
"SPEC.md",
|
|
107
|
+
"docs/SPEC.md",
|
|
108
|
+
];
|
|
109
|
+
const extraFiles = [
|
|
110
|
+
"openapi.yaml",
|
|
111
|
+
"openapi.yml",
|
|
112
|
+
"openapi.json",
|
|
113
|
+
"swagger.yaml",
|
|
114
|
+
"swagger.json",
|
|
115
|
+
"prisma/schema.prisma",
|
|
116
|
+
];
|
|
117
|
+
const specDirs = [
|
|
118
|
+
"docs/specs",
|
|
119
|
+
"docs/adr",
|
|
120
|
+
"docs/05-project/adr",
|
|
121
|
+
"proto",
|
|
122
|
+
"schemas",
|
|
123
|
+
"openspec",
|
|
124
|
+
".specify",
|
|
125
|
+
".kiro/specs",
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const found = [];
|
|
129
|
+
let canonicalSpec = null;
|
|
130
|
+
|
|
131
|
+
for (const rel of canonicalCandidates) {
|
|
132
|
+
const abs = path.join(root, rel);
|
|
133
|
+
if (fs.existsSync(abs) && fs.statSync(abs).isFile()) {
|
|
134
|
+
found.push(rel);
|
|
135
|
+
if (!canonicalSpec) canonicalSpec = rel;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const rel of extraFiles) {
|
|
139
|
+
const abs = path.join(root, rel);
|
|
140
|
+
if (fs.existsSync(abs) && fs.statSync(abs).isFile()) {
|
|
141
|
+
found.push(rel);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const dirRel of specDirs) {
|
|
145
|
+
const abs = path.join(root, dirRel);
|
|
146
|
+
if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) {
|
|
147
|
+
const entries = fs.readdirSync(abs).filter((n) => !n.startsWith(".") && n !== "README.md" && n !== "ADR-000-template.md");
|
|
148
|
+
if (entries.length > 0) {
|
|
149
|
+
found.push(`${dirRel}/`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const hasExistingSpecs = found.length > 0;
|
|
155
|
+
return {
|
|
156
|
+
hasExistingSpecs,
|
|
157
|
+
canonicalSpec,
|
|
158
|
+
specFiles: found,
|
|
159
|
+
strategy: hasExistingSpecs ? "adopt-existing" : "builtin-change-flow",
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function scanRepository(targetRoot) {
|
|
164
|
+
const root = path.resolve(targetRoot);
|
|
165
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
|
|
166
|
+
throw new Error(`Target directory does not exist: ${root}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const projectName = path.basename(root);
|
|
170
|
+
const detectedStacks = [];
|
|
171
|
+
const markerFiles = [];
|
|
172
|
+
const commands = { build: "", lint: "", typecheck: "", test: "" };
|
|
173
|
+
const notes = [];
|
|
174
|
+
let monorepo = false;
|
|
175
|
+
let suggestedProfile = "minimal";
|
|
176
|
+
|
|
177
|
+
// 1. Node.js / TypeScript
|
|
178
|
+
const pkgPath = path.join(root, "package.json");
|
|
179
|
+
const pkg = readJsonSafe(pkgPath);
|
|
180
|
+
if (fs.existsSync(pkgPath)) {
|
|
181
|
+
markerFiles.push("package.json");
|
|
182
|
+
const pm = detectNodePackageManager(root);
|
|
183
|
+
const hasTs = fs.existsSync(path.join(root, "tsconfig.json")) || Boolean(pkg?.devDependencies?.typescript || pkg?.dependencies?.typescript);
|
|
184
|
+
detectedStacks.push({ id: "node-ts", label: hasTs ? `TypeScript / Node.js (${pm})` : `Node.js (${pm})`, pm });
|
|
185
|
+
if (fs.existsSync(path.join(root, "pnpm-workspace.yaml")) || Array.isArray(pkg?.workspaces) || Array.isArray(pkg?.workspaces?.packages)) {
|
|
186
|
+
monorepo = true;
|
|
187
|
+
}
|
|
188
|
+
if (pkg?.scripts) {
|
|
189
|
+
const b = pickFirstScript(pkg.scripts, ["build", "compile", "bundle"]);
|
|
190
|
+
const l = pickFirstScript(pkg.scripts, ["lint", "check:lint", "eslint", "biome"]);
|
|
191
|
+
const tc = pickFirstScript(pkg.scripts, ["typecheck", "type-check", "check-types", "tsc"]);
|
|
192
|
+
const t = pickFirstScript(pkg.scripts, ["test", "test:unit", "check"]);
|
|
193
|
+
if (b) commands.build = runScriptCmd(pm, b);
|
|
194
|
+
if (l) commands.lint = runScriptCmd(pm, l);
|
|
195
|
+
if (tc) commands.typecheck = runScriptCmd(pm, tc);
|
|
196
|
+
if (t) commands.test = runScriptCmd(pm, t);
|
|
197
|
+
} else if (!pkg) {
|
|
198
|
+
notes.push("package.json exists but failed JSON parse; commands left empty for manual review.");
|
|
199
|
+
}
|
|
200
|
+
if (pkg?.bin) suggestedProfile = "cli-tool";
|
|
201
|
+
else if (pkg?.dependencies?.next || pkg?.dependencies?.react || pkg?.dependencies?.vue || pkg?.dependencies?.express || pkg?.dependencies?.fastify) {
|
|
202
|
+
suggestedProfile = "web-saas";
|
|
203
|
+
} else if (pkg?.exports || pkg?.main) {
|
|
204
|
+
suggestedProfile = "library-sdk";
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 2. Python
|
|
209
|
+
const pyMarkers = ["pyproject.toml", "setup.py", "pytest.ini", "requirements.txt"].filter((f) => fs.existsSync(path.join(root, f)));
|
|
210
|
+
if (pyMarkers.length > 0) {
|
|
211
|
+
markerFiles.push(...pyMarkers);
|
|
212
|
+
detectedStacks.push({ id: "python", label: "Python" });
|
|
213
|
+
const pyText = fs.existsSync(path.join(root, "pyproject.toml"))
|
|
214
|
+
? fs.readFileSync(path.join(root, "pyproject.toml"), "utf-8")
|
|
215
|
+
: "";
|
|
216
|
+
if (!commands.test) {
|
|
217
|
+
if (/pytest/i.test(pyText) || fs.existsSync(path.join(root, "pytest.ini"))) {
|
|
218
|
+
commands.test = "pytest -q";
|
|
219
|
+
} else if (fs.existsSync(path.join(root, "tests")) && fs.statSync(path.join(root, "tests")).isDirectory()) {
|
|
220
|
+
commands.test = "python3 -B -m unittest discover -s tests";
|
|
221
|
+
} else if (fs.existsSync(path.join(root, "test")) && fs.statSync(path.join(root, "test")).isDirectory()) {
|
|
222
|
+
commands.test = "python3 -B -m unittest discover -s test";
|
|
223
|
+
} else {
|
|
224
|
+
commands.test = "python3 -B -m unittest discover";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!commands.lint && /ruff/i.test(pyText)) commands.lint = "ruff check .";
|
|
228
|
+
if (!commands.typecheck && /mypy|pyright/i.test(pyText)) commands.typecheck = /pyright/i.test(pyText) ? "pyright" : "mypy .";
|
|
229
|
+
if (!commands.build) commands.build = "python3 -m compileall -q .";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 3. C/C++ / Embedded
|
|
233
|
+
const cppMarkers = ["CMakeLists.txt", "Makefile", "platformio.ini"].filter((f) => fs.existsSync(path.join(root, f)));
|
|
234
|
+
if (cppMarkers.length > 0) {
|
|
235
|
+
markerFiles.push(...cppMarkers);
|
|
236
|
+
detectedStacks.push({ id: "cpp-embedded", label: "C/C++ / Embedded" });
|
|
237
|
+
if (fs.existsSync(path.join(root, "CMakeLists.txt"))) {
|
|
238
|
+
if (!commands.build) commands.build = "cmake -B build && cmake --build build -j";
|
|
239
|
+
if (!commands.test) commands.test = "ctest --test-dir build --output-on-failure";
|
|
240
|
+
} else if (fs.existsSync(path.join(root, "Makefile"))) {
|
|
241
|
+
if (!commands.build) commands.build = "make";
|
|
242
|
+
}
|
|
243
|
+
if (suggestedProfile === "minimal") suggestedProfile = "software-automation";
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// 4. Go
|
|
247
|
+
if (fs.existsSync(path.join(root, "go.mod"))) {
|
|
248
|
+
markerFiles.push("go.mod");
|
|
249
|
+
detectedStacks.push({ id: "go", label: "Go" });
|
|
250
|
+
if (!commands.build) commands.build = "go build ./...";
|
|
251
|
+
if (!commands.typecheck) commands.typecheck = "go vet ./...";
|
|
252
|
+
if (!commands.test) commands.test = "go test ./...";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 5. Rust
|
|
256
|
+
if (fs.existsSync(path.join(root, "Cargo.toml"))) {
|
|
257
|
+
markerFiles.push("Cargo.toml");
|
|
258
|
+
detectedStacks.push({ id: "rust", label: "Rust" });
|
|
259
|
+
if (!commands.build) commands.build = "cargo build";
|
|
260
|
+
if (!commands.typecheck) commands.typecheck = "cargo check --all-targets";
|
|
261
|
+
if (!commands.lint) commands.lint = "cargo clippy --all-targets -- -D warnings";
|
|
262
|
+
if (!commands.test) commands.test = "cargo test";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 6. Existing AI / Governance Files
|
|
266
|
+
const existingAiFiles = [
|
|
267
|
+
"AGENTS.md",
|
|
268
|
+
"CLAUDE.md",
|
|
269
|
+
"GEMINI.md",
|
|
270
|
+
"SESSION.md",
|
|
271
|
+
".cursorrules",
|
|
272
|
+
".cursor/rules",
|
|
273
|
+
".claude/settings.json",
|
|
274
|
+
".claude/rules",
|
|
275
|
+
".codex/config.toml",
|
|
276
|
+
".gemini/settings.json",
|
|
277
|
+
".github/copilot-instructions.md",
|
|
278
|
+
".github/instructions",
|
|
279
|
+
".agentlock.json",
|
|
280
|
+
"agentlock-harness.json",
|
|
281
|
+
].filter((rel) => fs.existsSync(path.join(root, rel)));
|
|
282
|
+
|
|
283
|
+
// 7. Key Directories & CI Workflows
|
|
284
|
+
const candidateDirs = ["src", "lib", "app", "apps", "packages", "cmd", "include", "firmware", "tests", "test", "docs", "scripts"];
|
|
285
|
+
const entryDirs = candidateDirs.filter((d) => {
|
|
286
|
+
const p = path.join(root, d);
|
|
287
|
+
return fs.existsSync(p) && fs.statSync(p).isDirectory();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const ciWorkflows = [];
|
|
291
|
+
const wfDir = path.join(root, ".github/workflows");
|
|
292
|
+
if (fs.existsSync(wfDir) && fs.statSync(wfDir).isDirectory()) {
|
|
293
|
+
for (const f of fs.readdirSync(wfDir).sort()) {
|
|
294
|
+
if (f.endsWith(".yml") || f.endsWith(".yaml")) ciWorkflows.push(`.github/workflows/${f}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const isGitRepo = fs.existsSync(path.join(root, ".git"));
|
|
299
|
+
const primaryStack = detectedStacks[0] || { id: "custom", label: "Custom / Unknown" };
|
|
300
|
+
const specDiscovery = discoverSpecs(root);
|
|
301
|
+
const existingDocs = scanExistingDocs(root);
|
|
302
|
+
const hasV1Manifest = fs.existsSync(path.join(root, ".agentlock.json"));
|
|
303
|
+
const hasUntrackedCoreDocs =
|
|
304
|
+
!hasV1Manifest &&
|
|
305
|
+
["AGENTS.md", "SESSION.md", "docs/00-context.md", "docs/README.md"].some((f) => fs.existsSync(path.join(root, f)));
|
|
306
|
+
const hasLegacyDocs = !hasV1Manifest && (existingDocs.length > 0 || hasUntrackedCoreDocs);
|
|
307
|
+
|
|
308
|
+
const stackSuggestedProfile = suggestedProfile;
|
|
309
|
+
if (hasLegacyDocs && suggestedProfile !== "minimal") {
|
|
310
|
+
notes.push(
|
|
311
|
+
`Detected ${existingDocs.length} existing docs under docs/ (or root AGENTS/SESSION). Defaulting thin-route profile to "minimal" to prevent duplicate Draft templates.`
|
|
312
|
+
);
|
|
313
|
+
suggestedProfile = "minimal";
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return {
|
|
317
|
+
root,
|
|
318
|
+
projectName,
|
|
319
|
+
isGitRepo,
|
|
320
|
+
monorepo,
|
|
321
|
+
primaryStack,
|
|
322
|
+
detectedStacks,
|
|
323
|
+
markerFiles: [...new Set(markerFiles)],
|
|
324
|
+
commands,
|
|
325
|
+
entryDirs,
|
|
326
|
+
ciWorkflows,
|
|
327
|
+
existingAiFiles,
|
|
328
|
+
existingDocs,
|
|
329
|
+
hasV1Manifest,
|
|
330
|
+
hasUntrackedCoreDocs,
|
|
331
|
+
hasLegacyDocs,
|
|
332
|
+
recommendedDocsStrategy: "thin-route",
|
|
333
|
+
specDiscovery,
|
|
334
|
+
stackSuggestedProfile,
|
|
335
|
+
suggestedProfile,
|
|
336
|
+
suggestedHosts: [...VALID_HOSTS],
|
|
337
|
+
notes,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Generates a compact `docs/00-context.md` strictly within AgentLock v1's entry budget
|
|
343
|
+
* (<= 80 lines, <= 2,200 characters) and explicitly marked `status: Unverified`.
|
|
344
|
+
*/
|
|
345
|
+
export function renderAdoptedContextMd(scan, locale = "zh-CN", { archiveDir = null } = {}) {
|
|
346
|
+
const zh = locale !== "en-US";
|
|
347
|
+
const stackSummary = scan.detectedStacks.length
|
|
348
|
+
? scan.detectedStacks.map((s) => s.label).join(" + ")
|
|
349
|
+
: zh ? "待识别" : "Unknown";
|
|
350
|
+
const dirsSummary = scan.entryDirs.length ? scan.entryDirs.map((d) => `\`${d}/\``).join(", ") : zh ? "待核验" : "Unverified";
|
|
351
|
+
const ciSummary = scan.ciWorkflows.length ? scan.ciWorkflows.slice(0, 3).map((w) => `\`${w}\``).join(", ") : zh ? "无" : "None";
|
|
352
|
+
const aiSummary = scan.existingAiFiles.length ? scan.existingAiFiles.slice(0, 5).map((f) => `\`${f}\``).join(", ") : zh ? "无" : "None";
|
|
353
|
+
const specInfo = scan.specDiscovery || { hasExistingSpecs: false, specFiles: [] };
|
|
354
|
+
const specSummary = specInfo.hasExistingSpecs
|
|
355
|
+
? specInfo.specFiles.slice(0, 3).map((f) => `\`${f}\``).join(", ")
|
|
356
|
+
: zh
|
|
357
|
+
? "未建立(新功能/跨模块变更先跑 `alh change new <slug>`)"
|
|
358
|
+
: "None yet (run `alh change new <slug>` before feature/cross-module edits)";
|
|
359
|
+
const existingDocs = Array.isArray(scan.existingDocs) ? scan.existingDocs : [];
|
|
360
|
+
const legacyRowZh = archiveDir
|
|
361
|
+
? `| 归档旧文档参考 | \`${archiveDir}/\`(${existingDocs.length} 份已隔离) | 只读蒸馏参考,已排除检索 |`
|
|
362
|
+
: existingDocs.length > 0
|
|
363
|
+
? `| 既有项目文档 | ${existingDocs.slice(0, 3).map((d) => `\`${d}\``).join(", ")}${existingDocs.length > 3 ? ` 等 ${existingDocs.length} 份` : ""} | 薄路由保留,唯一事实源 |`
|
|
364
|
+
: null;
|
|
365
|
+
const legacyRowEn = archiveDir
|
|
366
|
+
? `| Archived Legacy Docs | \`${archiveDir}/\` (${existingDocs.length} isolated) | Read-only distillation ref |`
|
|
367
|
+
: existingDocs.length > 0
|
|
368
|
+
? `| Existing Project Docs | ${existingDocs.slice(0, 3).map((d) => `\`${d}\``).join(", ")}${existingDocs.length > 3 ? ` (+${existingDocs.length - 3} more)` : ""} | Preserved thin-route truth |`
|
|
369
|
+
: null;
|
|
370
|
+
|
|
371
|
+
if (zh) {
|
|
372
|
+
return [
|
|
373
|
+
"---",
|
|
374
|
+
"status: Unverified",
|
|
375
|
+
"owner: project-owner",
|
|
376
|
+
"---",
|
|
377
|
+
"",
|
|
378
|
+
`# ${scan.projectName} — 任务路由与工程入口`,
|
|
379
|
+
"",
|
|
380
|
+
"> 由 `alh adopt` 只读探测自动生成(所有推断项标记为未核验,请抽查真实入口与副作用后再改为 Current)。",
|
|
381
|
+
"",
|
|
382
|
+
"## 快速定位",
|
|
383
|
+
"",
|
|
384
|
+
"| 任务 / 能力 | 探测到的入口目录或清单 | 状态 / 说明 |",
|
|
385
|
+
"|---|---|---|",
|
|
386
|
+
`| 技术栈与清单 | ${stackSummary} (${scan.markerFiles.slice(0, 4).join(", ") || "无"}) | 未核验${scan.monorepo ? " · Monorepo" : ""} |`,
|
|
387
|
+
`| 主要源码与测试目录 | ${dirsSummary} | 未核验 |`,
|
|
388
|
+
`| CI 流水线 | ${ciSummary} | 只读扫描 |`,
|
|
389
|
+
`| 规范与契约 | ${specSummary} | ${specInfo.hasExistingSpecs ? "优先遵循" : "内置轻量流"} |`,
|
|
390
|
+
...(legacyRowZh ? [legacyRowZh] : []),
|
|
391
|
+
`| 既有 AI 规则/配置 | ${aiSummary} | 保留未覆盖 |`,
|
|
392
|
+
"",
|
|
393
|
+
"## 探测到的常用命令",
|
|
394
|
+
"",
|
|
395
|
+
"| 用途 | 候选命令 | 核验状态 |",
|
|
396
|
+
"|---|---|---|",
|
|
397
|
+
`| 构建 (build) | \`${scan.commands.build || "未探测到"}\` | 未核验 |`,
|
|
398
|
+
`| 静态检查 (lint) | \`${scan.commands.lint || "未探测到"}\` | 未核验 |`,
|
|
399
|
+
`| 类型检查 (typecheck) | \`${scan.commands.typecheck || "未探测到"}\` | 未核验 |`,
|
|
400
|
+
`| 自动化测试 (test) | \`${scan.commands.test || "未探测到"}\` | 未核验 |`,
|
|
401
|
+
"",
|
|
402
|
+
"## 如何扩展读取",
|
|
403
|
+
"",
|
|
404
|
+
"先用本页与 `node scripts/doc-find.mjs . --topic <关键词>` 定位,再核对活跃源码与测试。路径级局部规则源位于 `.agentlock-harness/rules/`。",
|
|
405
|
+
"",
|
|
406
|
+
].join("\n");
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return [
|
|
410
|
+
"---",
|
|
411
|
+
"status: Unverified",
|
|
412
|
+
"owner: project-owner",
|
|
413
|
+
"---",
|
|
414
|
+
"",
|
|
415
|
+
`# ${scan.projectName} — Task Routing & Engineering Entrypoints`,
|
|
416
|
+
"",
|
|
417
|
+
"> Auto-generated via read-only `alh adopt` scan. All inferred items remain Unverified until checked against live code.",
|
|
418
|
+
"",
|
|
419
|
+
"## Quick Location",
|
|
420
|
+
"",
|
|
421
|
+
"| Area | Detected Paths / Manifests | Status |",
|
|
422
|
+
"|---|---|---|",
|
|
423
|
+
`| Tech Stack | ${stackSummary} (${scan.markerFiles.slice(0, 4).join(", ") || "none"}) | Unverified${scan.monorepo ? " · Monorepo" : ""} |`,
|
|
424
|
+
`| Source & Test Dirs | ${dirsSummary} | Unverified |`,
|
|
425
|
+
`| CI Workflows | ${ciSummary} | Read-only scan |`,
|
|
426
|
+
`| Specs & Contracts | ${specSummary} | ${specInfo.hasExistingSpecs ? "Obey first" : "Built-in flow"} |`,
|
|
427
|
+
...(legacyRowEn ? [legacyRowEn] : []),
|
|
428
|
+
`| Existing AI Files | ${aiSummary} | Preserved |`,
|
|
429
|
+
"",
|
|
430
|
+
"## Discovered Commands",
|
|
431
|
+
"",
|
|
432
|
+
"| Purpose | Candidate Command | Verification |",
|
|
433
|
+
"|---|---|---|",
|
|
434
|
+
`| Build | \`${scan.commands.build || "not detected"}\` | Unverified |`,
|
|
435
|
+
`| Lint | \`${scan.commands.lint || "not detected"}\` | Unverified |`,
|
|
436
|
+
`| Typecheck | \`${scan.commands.typecheck || "not detected"}\` | Unverified |`,
|
|
437
|
+
`| Test | \`${scan.commands.test || "not detected"}\` | Unverified |`,
|
|
438
|
+
"",
|
|
439
|
+
"## Expanding Context",
|
|
440
|
+
"",
|
|
441
|
+
"Start here or run `node scripts/doc-find.mjs . --topic <keyword>`, then inspect live code and tests. Path-scoped rules live in `.agentlock-harness/rules/`.",
|
|
442
|
+
"",
|
|
443
|
+
].join("\n");
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export function renderAdoptReportMd(scan, locale = "zh-CN") {
|
|
447
|
+
const zh = locale !== "en-US";
|
|
448
|
+
if (zh) {
|
|
449
|
+
return [
|
|
450
|
+
`# ${scan.projectName} — Brownfield 存量接入探测报告`,
|
|
451
|
+
"",
|
|
452
|
+
"> 目标目录已存在未纳管的根文档(如既有 `AGENTS.md` 或 `docs/README.md`),`alh adopt` 已严格保护原文档零覆盖,并完成 v2.2 Harness 层与路径级规则编译器的安全挂载。",
|
|
453
|
+
"",
|
|
454
|
+
`- **识别技术栈**:${scan.detectedStacks.map((s) => s.label).join(", ") || "未知"}`,
|
|
455
|
+
`- **标志清单**:${scan.markerFiles.join(", ") || "无"}`,
|
|
456
|
+
`- **源码/测试目录**:${scan.entryDirs.join(", ") || "无"}`,
|
|
457
|
+
`- **规范资产探测**:${scan.specDiscovery?.hasExistingSpecs ? scan.specDiscovery.specFiles.join(", ") : "无(已启用内置 alh change 轻量契约流)"}`,
|
|
458
|
+
`- **既有 AI 配置**:${scan.existingAiFiles.join(", ") || "无"}`,
|
|
459
|
+
`- **推荐命令(待核验)**:build=\`${scan.commands.build || "-"}\` | lint=\`${scan.commands.lint || "-"}\` | typecheck=\`${scan.commands.typecheck || "-"}\` | test=\`${scan.commands.test || "-"}\``,
|
|
460
|
+
"",
|
|
461
|
+
"## 后续手工融合建议",
|
|
462
|
+
"",
|
|
463
|
+
"1. 在既有 `AGENTS.md` 中补充指向 `.agentlock-harness/rules/INDEX.md` 与 `agentlock-harness.json` 的一行导航;",
|
|
464
|
+
"2. 核验 `agentlock-harness.json` 中的 `commands` 是否准确;",
|
|
465
|
+
"3. 运行 `alh verify` 与 `alh rules check` 验证护栏与规则编译零漂移。",
|
|
466
|
+
"",
|
|
467
|
+
].join("\n");
|
|
468
|
+
}
|
|
469
|
+
return [
|
|
470
|
+
`# ${scan.projectName} — Brownfield Adoption Discovery Report`,
|
|
471
|
+
"",
|
|
472
|
+
"> Untracked root documentation already existed (e.g., existing `AGENTS.md`). `alh adopt` preserved all existing files untouched and layered the v2.2 Harness guardrails and path-scoped rules compiler safely.",
|
|
473
|
+
"",
|
|
474
|
+
`- **Detected Stacks**: ${scan.detectedStacks.map((s) => s.label).join(", ") || "Unknown"}`,
|
|
475
|
+
`- **Marker Files**: ${scan.markerFiles.join(", ") || "None"}`,
|
|
476
|
+
`- **Entry Directories**: ${scan.entryDirs.join(", ") || "None"}`,
|
|
477
|
+
`- **Spec Discovery**: ${scan.specDiscovery?.hasExistingSpecs ? scan.specDiscovery.specFiles.join(", ") : "None (built-in alh change workflow active)"}`,
|
|
478
|
+
`- **Existing AI Files**: ${scan.existingAiFiles.join(", ") || "None"}`,
|
|
479
|
+
`- **Candidate Commands (Unverified)**: build=\`${scan.commands.build || "-"}\` | lint=\`${scan.commands.lint || "-"}\` | typecheck=\`${scan.commands.typecheck || "-"}\` | test=\`${scan.commands.test || "-"}\``,
|
|
480
|
+
"",
|
|
481
|
+
"## Next Merge Steps",
|
|
482
|
+
"",
|
|
483
|
+
"1. Add a short pointer in your existing `AGENTS.md` to `.agentlock-harness/rules/INDEX.md` and `agentlock-harness.json`;",
|
|
484
|
+
"2. Verify `commands` inside `agentlock-harness.json`;",
|
|
485
|
+
"3. Run `alh verify` and `alh rules check`.",
|
|
486
|
+
"",
|
|
487
|
+
].join("\n");
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function chooseArchiveDirRel(root) {
|
|
491
|
+
const base = `docs/${LEGACY_ARCHIVE_PREFIX}`;
|
|
492
|
+
if (!fs.existsSync(path.join(root, base))) return base;
|
|
493
|
+
const stamp = new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
494
|
+
let candidate = `docs/${LEGACY_ARCHIVE_PREFIX}-${stamp}`;
|
|
495
|
+
let idx = 1;
|
|
496
|
+
while (fs.existsSync(path.join(root, candidate))) {
|
|
497
|
+
candidate = `docs/${LEGACY_ARCHIVE_PREFIX}-${stamp}-${idx++}`;
|
|
498
|
+
}
|
|
499
|
+
return candidate;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Plans non-destructive archival of untracked legacy docs into `docs/legacy-archive/`.
|
|
504
|
+
* Refuses if `.agentlock.json` already exists so AgentLock-managed docs are never archived.
|
|
505
|
+
*/
|
|
506
|
+
export function planLegacyDocsArchive(targetRoot, { profileId = "minimal", locale = "zh-CN" } = {}) {
|
|
507
|
+
const root = path.resolve(targetRoot);
|
|
508
|
+
if (fs.existsSync(path.join(root, ".agentlock.json"))) {
|
|
509
|
+
return {
|
|
510
|
+
ok: false,
|
|
511
|
+
alreadyManaged: true,
|
|
512
|
+
reason: "Repository is already managed by AgentLock (.agentlock.json exists). Use update/thin-route instead of archive-switch.",
|
|
513
|
+
archiveDir: null,
|
|
514
|
+
moves: [],
|
|
515
|
+
archivedDocFiles: [],
|
|
516
|
+
profileDocs: getProfileDocs(profileId, locale),
|
|
517
|
+
plannedTasks: [],
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Pre-flight check: refuse BEFORE moving anything if untracked v1 tooling/config files would block init-docs.mjs
|
|
522
|
+
const blockingToolFiles = [
|
|
523
|
+
"docs.config.json",
|
|
524
|
+
"scripts/doc-tools.mjs",
|
|
525
|
+
"scripts/validate-docs.mjs",
|
|
526
|
+
"scripts/doc-map.mjs",
|
|
527
|
+
"scripts/doc-find.mjs",
|
|
528
|
+
"scripts/README.md",
|
|
529
|
+
].filter((rel) => fs.existsSync(path.join(root, rel)));
|
|
530
|
+
if (blockingToolFiles.length > 0) {
|
|
531
|
+
return {
|
|
532
|
+
ok: false,
|
|
533
|
+
alreadyManaged: false,
|
|
534
|
+
reason: `Pre-flight aborted before moving files: untracked files would collide with v1 init (${blockingToolFiles.join(", ")}).`,
|
|
535
|
+
archiveDir: null,
|
|
536
|
+
moves: [],
|
|
537
|
+
archivedDocFiles: [],
|
|
538
|
+
profileDocs: getProfileDocs(profileId, locale),
|
|
539
|
+
plannedTasks: [],
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const archiveDir = chooseArchiveDirRel(root);
|
|
544
|
+
const moves = [];
|
|
545
|
+
const usedDestNames = new Set();
|
|
546
|
+
const existingDocs = scanExistingDocs(root);
|
|
547
|
+
|
|
548
|
+
const docsDirAbs = path.join(root, "docs");
|
|
549
|
+
if (fs.existsSync(docsDirAbs)) {
|
|
550
|
+
const dStat = fs.lstatSync(docsDirAbs);
|
|
551
|
+
if (dStat.isSymbolicLink()) {
|
|
552
|
+
return {
|
|
553
|
+
ok: false,
|
|
554
|
+
alreadyManaged: false,
|
|
555
|
+
reason: "Pre-flight aborted: docs/ is a symlink; refusing automated archive-switch.",
|
|
556
|
+
archiveDir: null,
|
|
557
|
+
moves: [],
|
|
558
|
+
archivedDocFiles: [],
|
|
559
|
+
profileDocs: getProfileDocs(profileId, locale),
|
|
560
|
+
plannedTasks: [],
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
if (dStat.isDirectory()) {
|
|
564
|
+
for (const ent of fs.readdirSync(docsDirAbs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
565
|
+
if (ent.name === ".DS_Store" || isLegacyArchiveEntry(ent.name)) continue;
|
|
566
|
+
if (ent.isSymbolicLink()) {
|
|
567
|
+
return {
|
|
568
|
+
ok: false,
|
|
569
|
+
alreadyManaged: false,
|
|
570
|
+
reason: `Pre-flight aborted: symlink detected at docs/${ent.name}; resolve manually before archive-switch.`,
|
|
571
|
+
archiveDir: null,
|
|
572
|
+
moves: [],
|
|
573
|
+
archivedDocFiles: [],
|
|
574
|
+
profileDocs: getProfileDocs(profileId, locale),
|
|
575
|
+
plannedTasks: [],
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
const from = `docs/${ent.name}`;
|
|
579
|
+
const to = `${archiveDir}/${ent.name}`;
|
|
580
|
+
assertSafeDestination(root, from);
|
|
581
|
+
assertSafeDestination(root, to);
|
|
582
|
+
moves.push({ from, to, isDir: ent.isDirectory() });
|
|
583
|
+
usedDestNames.add(ent.name.toLowerCase());
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const rootLegacyFiles = ["AGENTS.md", "SESSION.md", "DOCS_MAINTENANCE.md"];
|
|
589
|
+
const rootArchivedDocs = [];
|
|
590
|
+
for (const name of rootLegacyFiles) {
|
|
591
|
+
const abs = path.join(root, name);
|
|
592
|
+
if (!fs.existsSync(abs)) continue;
|
|
593
|
+
const lst = fs.lstatSync(abs);
|
|
594
|
+
if (lst.isSymbolicLink() || !lst.isFile()) continue;
|
|
595
|
+
const destName = usedDestNames.has(name.toLowerCase()) ? name.replace(/\.md$/i, ".root.md") : name;
|
|
596
|
+
const to = `${archiveDir}/${destName}`;
|
|
597
|
+
assertSafeDestination(root, name);
|
|
598
|
+
assertSafeDestination(root, to);
|
|
599
|
+
moves.push({ from: name, to, isDir: false });
|
|
600
|
+
usedDestNames.add(destName.toLowerCase());
|
|
601
|
+
rootArchivedDocs.push(name);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const profileDocs = getProfileDocs(profileId, locale);
|
|
605
|
+
const archivedDocFiles = [...rootArchivedDocs, ...existingDocs];
|
|
606
|
+
const plannedTasks = buildDistillationTaskSpecs({ archiveDir, profileDocs, locale });
|
|
607
|
+
|
|
608
|
+
return {
|
|
609
|
+
ok: true,
|
|
610
|
+
alreadyManaged: false,
|
|
611
|
+
archiveDir,
|
|
612
|
+
moves,
|
|
613
|
+
archivedDocFiles,
|
|
614
|
+
profileDocs,
|
|
615
|
+
excludePath: archiveDir,
|
|
616
|
+
plannedTasks,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export function executeLegacyDocsArchive(targetRoot, plan) {
|
|
621
|
+
const root = path.resolve(targetRoot);
|
|
622
|
+
if (!plan || !plan.ok) {
|
|
623
|
+
throw new Error(plan?.reason || "Invalid legacy archive plan.");
|
|
624
|
+
}
|
|
625
|
+
if (!plan.moves || plan.moves.length === 0) {
|
|
626
|
+
return { archiveDir: plan.archiveDir, moved: [], archivedDocFiles: [] };
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const archiveAbs = assertSafeDestination(root, plan.archiveDir);
|
|
630
|
+
fs.mkdirSync(archiveAbs, { recursive: true });
|
|
631
|
+
|
|
632
|
+
const moved = [];
|
|
633
|
+
for (const m of plan.moves) {
|
|
634
|
+
const srcAbs = assertSafeDestination(root, m.from);
|
|
635
|
+
const destAbs = assertSafeDestination(root, m.to);
|
|
636
|
+
if (!fs.existsSync(srcAbs)) continue;
|
|
637
|
+
if (fs.lstatSync(srcAbs).isSymbolicLink()) continue;
|
|
638
|
+
fs.mkdirSync(path.dirname(destAbs), { recursive: true });
|
|
639
|
+
fs.renameSync(srcAbs, destAbs);
|
|
640
|
+
moved.push(m);
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
archiveDir: plan.archiveDir,
|
|
644
|
+
moved,
|
|
645
|
+
archivedDocFiles: plan.archivedDocFiles,
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export function excludeArchiveInDocsConfig(targetRoot, archiveDirRel) {
|
|
650
|
+
const root = path.resolve(targetRoot);
|
|
651
|
+
const cfgPath = assertSafeDestination(root, "docs.config.json");
|
|
652
|
+
if (!fs.existsSync(cfgPath)) return false;
|
|
653
|
+
const cfg = JSON.parse(fs.readFileSync(cfgPath, "utf-8"));
|
|
654
|
+
const norm = String(archiveDirRel || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
655
|
+
if (!norm) return false;
|
|
656
|
+
cfg.exclude = Array.isArray(cfg.exclude) ? cfg.exclude : [];
|
|
657
|
+
if (!cfg.exclude.includes(norm)) {
|
|
658
|
+
cfg.exclude.push(norm);
|
|
659
|
+
fs.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function buildDistillationTaskSpecs({ archiveDir, profileDocs = [], locale = "zh-CN" }) {
|
|
666
|
+
const zh = locale !== "en-US";
|
|
667
|
+
const specs = [
|
|
668
|
+
{
|
|
669
|
+
key: "verify-context",
|
|
670
|
+
priority: "P0",
|
|
671
|
+
title: zh
|
|
672
|
+
? "核验 docs/00-context.md 与 agentlock-harness.json 构建测试命令(对照真实源码)"
|
|
673
|
+
: "Verify docs/00-context.md & agentlock-harness.json commands against live code",
|
|
674
|
+
},
|
|
675
|
+
];
|
|
676
|
+
for (const docPath of profileDocs) {
|
|
677
|
+
specs.push({
|
|
678
|
+
key: `distill:${docPath}`,
|
|
679
|
+
priority: "P1",
|
|
680
|
+
title: zh
|
|
681
|
+
? `双向蒸馏 ${docPath}(对照 ${archiveDir}/ × 现网源码,冲突项显式标出待人裁决)`
|
|
682
|
+
: `Cross-distill ${docPath} (${archiveDir}/ x live code; flag conflicts for human review)`,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
specs.push({
|
|
686
|
+
key: "cleanup-archive",
|
|
687
|
+
priority: "P2",
|
|
688
|
+
title: zh
|
|
689
|
+
? `全部核心规范晋升 Current 后,人工审校并决定是否移除 ${archiveDir}/`
|
|
690
|
+
: `After core specs reach Current, review and decide whether to remove ${archiveDir}/`,
|
|
691
|
+
});
|
|
692
|
+
return specs;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export function seedMigrationTasks(targetRoot, { archiveDir, profileDocs = [], locale = "zh-CN" }) {
|
|
696
|
+
const specs = buildDistillationTaskSpecs({ archiveDir, profileDocs, locale });
|
|
697
|
+
const existingLedger = readLedger(targetRoot);
|
|
698
|
+
const existingByTitle = new Map(existingLedger.tasks.map((t) => [t.title, t.id]));
|
|
699
|
+
|
|
700
|
+
const created = [];
|
|
701
|
+
let rootTaskId = existingByTitle.get(specs[0].title) || null;
|
|
702
|
+
if (!rootTaskId) {
|
|
703
|
+
const t0 = addTask(targetRoot, { title: specs[0].title, priority: specs[0].priority });
|
|
704
|
+
rootTaskId = t0.id;
|
|
705
|
+
created.push(t0);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
const topicIds = [];
|
|
709
|
+
for (const sp of specs.slice(1, -1)) {
|
|
710
|
+
let tid = existingByTitle.get(sp.title) || null;
|
|
711
|
+
if (!tid) {
|
|
712
|
+
const t = addTask(targetRoot, { title: sp.title, priority: sp.priority, dependsOn: [rootTaskId] });
|
|
713
|
+
tid = t.id;
|
|
714
|
+
created.push(t);
|
|
715
|
+
}
|
|
716
|
+
topicIds.push(tid);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const finalSpec = specs[specs.length - 1];
|
|
720
|
+
if (!existingByTitle.has(finalSpec.title)) {
|
|
721
|
+
const deps = topicIds.length > 0 ? topicIds : [rootTaskId];
|
|
722
|
+
const tf = addTask(targetRoot, { title: finalSpec.title, priority: finalSpec.priority, dependsOn: deps });
|
|
723
|
+
created.push(tf);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return created;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export function renderMigrationPlanMd({
|
|
730
|
+
projectName,
|
|
731
|
+
archiveDir,
|
|
732
|
+
archivedDocFiles = [],
|
|
733
|
+
profileId = "minimal",
|
|
734
|
+
profileDocs = [],
|
|
735
|
+
locale = "zh-CN",
|
|
736
|
+
}) {
|
|
737
|
+
const zh = locale !== "en-US";
|
|
738
|
+
const archiveList = archivedDocFiles.length
|
|
739
|
+
? archivedDocFiles.slice(0, 40).map((f) => `- \`${f}\` → \`${archiveDir}/\``).join("\n") +
|
|
740
|
+
(archivedDocFiles.length > 40 ? `\n- ... (+${archivedDocFiles.length - 40})` : "")
|
|
741
|
+
: zh ? "- (本次未移动既有文档)" : "- (No legacy docs moved)";
|
|
742
|
+
const draftList = profileDocs.length
|
|
743
|
+
? profileDocs.map((d) => `- \`${d}\` (\`status: Draft\`)`).join("\n")
|
|
744
|
+
: zh ? "- `docs/00-context.md`(`minimal` 极简核心路由)" : "- `docs/00-context.md` (`minimal` thin router)";
|
|
745
|
+
|
|
746
|
+
if (zh) {
|
|
747
|
+
return [
|
|
748
|
+
`# ${projectName} — 存量文档双向蒸馏迁移计划(Archive & Distill)`,
|
|
749
|
+
"",
|
|
750
|
+
`> 已将旧文档非破坏性归档至 \`${archiveDir}/\`,并自动加入 \`docs.config.json\` 排除列表(避免双真相源污染检索与校验)。`,
|
|
751
|
+
"> **严禁仅凭源码自动重写全部规范**:代码只反映现状(含历史 Bug 与妥协),业务意图与设计权衡藏在旧文档中。",
|
|
752
|
+
"",
|
|
753
|
+
"## 1. 已归档的旧文档(只读参考源)",
|
|
754
|
+
"",
|
|
755
|
+
archiveList,
|
|
756
|
+
"",
|
|
757
|
+
`## 2. 本次生成的新骨架(Profile: \`${profileId}\`)`,
|
|
758
|
+
"",
|
|
759
|
+
draftList,
|
|
760
|
+
"",
|
|
761
|
+
"## 3. 推荐的「旧文档 × 现网源码」双向蒸馏提示词(可直接交给本地 AI 逐模块执行)",
|
|
762
|
+
"",
|
|
763
|
+
"```text",
|
|
764
|
+
"请查看 alh task ready 认领下一项文档蒸馏任务:",
|
|
765
|
+
`1. 同时阅读 ${archiveDir}/ 下对应模块的旧文档(提取业务契约、边界条件、ADR 原因)与当前活跃源码及测试;`,
|
|
766
|
+
"2. 两者一致的事实,整理写入目标 Draft 文档并补全 code_refs 与测试证据;",
|
|
767
|
+
"3. 若旧文档与现网代码存在冲突,严禁自行把代码 Bug 洗白成规范,也严禁盲信旧文档——必须单独列出冲突清单交由我裁决;",
|
|
768
|
+
"4. 全部核验完成后再将文档状态从 Draft 晋升为 Current 并执行 alh verify。",
|
|
769
|
+
"```",
|
|
770
|
+
"",
|
|
771
|
+
"## 4. 已自动创建的 DAG 迁移任务",
|
|
772
|
+
"",
|
|
773
|
+
"运行 `alh task graph` 或在 `alh ui` 的「Spec 变更与 DAG」面板中查看并逐项推进。",
|
|
774
|
+
"",
|
|
775
|
+
].join("\n");
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
return [
|
|
779
|
+
`# ${projectName} — Legacy Documentation Cross-Distillation Plan`,
|
|
780
|
+
"",
|
|
781
|
+
`> Legacy docs were safely moved to \`${archiveDir}/\` and automatically excluded in \`docs.config.json\` to prevent dual-truth drift.`,
|
|
782
|
+
"> **Never regenerate specs from source code alone**: code reflects current reality (including bugs & workarounds), while intent and ADR rationale live in archived docs.",
|
|
783
|
+
"",
|
|
784
|
+
"## 1. Archived Legacy Docs (Read-Only Reference)",
|
|
785
|
+
"",
|
|
786
|
+
archiveList,
|
|
787
|
+
"",
|
|
788
|
+
`## 2. Newly Scaffolded Draft Skeletons (Profile: \`${profileId}\`)`,
|
|
789
|
+
"",
|
|
790
|
+
draftList,
|
|
791
|
+
"",
|
|
792
|
+
"## 3. Recommended Dual-Source Distillation Prompt (Run Module by Module)",
|
|
793
|
+
"",
|
|
794
|
+
"```text",
|
|
795
|
+
"Run 'alh task ready' and claim the next distillation task:",
|
|
796
|
+
`1. Cross-read relevant legacy docs under ${archiveDir}/ (business intent, SLA, ADR rationale) alongside live source code and tests;`,
|
|
797
|
+
"2. Write verified matching contracts into the target Draft doc with accurate code_refs and evidence;",
|
|
798
|
+
"3. Whenever legacy docs conflict with live code, DO NOT whitewash code bugs into specs and DO NOT trust stale docs blindly — list every conflict explicitly for human arbitration;",
|
|
799
|
+
"4. Promote status from Draft to Current only after verification, then run 'alh verify'.",
|
|
800
|
+
"```",
|
|
801
|
+
"",
|
|
802
|
+
"## 4. Seeded DAG Migration Tasks",
|
|
803
|
+
"",
|
|
804
|
+
"Run `alh task graph` or inspect the Spec & DAG panel in `alh ui`.",
|
|
805
|
+
"",
|
|
806
|
+
].join("\n");
|
|
807
|
+
}
|