@tea-agent/loop-agent 0.12.0 → 0.13.0-alpha.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/CHANGELOG.md +50 -2
- package/README.md +30 -2
- package/dist/application/dag/generate-task-dag.js +30 -0
- package/dist/cli/command-definitions.js +10 -3
- package/dist/commands/knowledge.js +129 -31
- package/dist/governance/manifest-types.js +3 -0
- package/dist/task/config-types.js +5 -1
- package/dist/worker/cli.js +96 -1
- package/dist/worker/delivery/package.js +3 -3
- package/dist/worker/feature/decision-loader.js +37 -6
- package/dist/worker/feature/next-action.js +10 -2
- package/dist/worker/feature/ready-plan-projection.js +81 -0
- package/dist/worker/feature/reducer.js +2 -1
- package/dist/worker/feature/review.js +19 -2
- package/dist/worker/feature/run.js +27 -2
- package/dist/worker/follow-up/approve.js +5 -2
- package/dist/worker/follow-up/factory.js +1 -1
- package/dist/worker/observability/read-model.js +246 -41
- package/dist/worker/observe/routes.js +158 -15
- package/dist/worker/observe/spec-evidence.js +281 -0
- package/dist/worker/observe/static/api.js +19 -0
- package/dist/worker/observe/static/app.js +2 -2
- package/dist/worker/observe/static/relations.js +17 -12
- package/dist/worker/observe/static/router.js +8 -0
- package/dist/worker/observe/static/styles.css +12 -0
- package/dist/worker/observe/static/views/batch.js +3 -2
- package/dist/worker/observe/static/views/dag-inspector.js +123 -4
- package/dist/worker/observe/static/views/dashboard.js +8 -5
- package/dist/worker/observe/static/views/feature.js +43 -4
- package/dist/worker/observe/static/views/pool.js +5 -2
- package/dist/worker/observe/static/views/run.js +1 -1
- package/dist/worker/observe/static/views/task.js +69 -15
- package/dist/worker/pool/doctor.js +165 -0
- package/dist/worker/pool/migrate-state.js +303 -0
- package/dist/worker/pool/run-store.js +205 -17
- package/dist/worker/pool/types.js +17 -1
- package/dist/worker/pool/validation.js +100 -15
- package/dist/worker/report/morning-report.js +12 -2
- package/dist/worker/runner/run-ready.js +41 -26
- package/dist/worker/task-graph/ready-planner.js +136 -0
- package/dist/workflows/dag/convergence/controller.js +16 -8
- package/dist/workflows/dag/failure-routing.js +12 -1
- package/dist/workflows/dag/init-hybrid.js +837 -8
- package/dist/workflows/dag/types.js +1 -0
- package/docs/README.md +1 -1
- package/docs/agent-dag-recovery-playbook.md +9 -0
- package/docs/architecture/evolution.md +4 -3
- package/docs/architecture/facts-and-state.md +14 -1
- package/docs/architecture/worker-and-feature.md +6 -2
- package/docs/decisions/README.md +3 -0
- package/docs/design/README.md +8 -0
- package/docs/exec-plans/active/README.md +2 -0
- package/docs/exec-plans/completed/README.md +3 -2
- package/docs/feature-workflow.md +80 -2
- package/docs/loop-agent-harness.md +15 -4
- package/docs/progress/README.md +4 -0
- package/docs/reports/README.md +6 -0
- package/docs/templates/backend-test-dag.json +12 -0
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
- package/docs/templates/knowledge-sync-dag.json +177 -0
- package/docs/templates/knowledge-sync-draft.schema.json +71 -0
- package/docs/verification-matrix.md +2 -1
- package/package.json +8 -2
- package/scripts/kb-bootstrap-init-skeleton.sh +239 -0
- package/scripts/kb-graph-incremental-prepare.mjs +372 -0
- package/scripts/kb-graph-incremental-prepare.sh +5 -0
- package/scripts/kb-graph-materialize.mjs +105 -0
- package/scripts/kb-graph-materialize.sh +4 -0
- package/scripts/kb-graph-promote.mjs +153 -0
- package/scripts/kb-graph-promote.sh +4 -0
- package/scripts/kb-query.mjs +554 -0
- package/scripts/kb-query.sh +5 -0
- package/skills/agent-worker/SKILL.md +3 -1
- package/skills/agent-worker/references/agent-worker-operator.md +18 -1
- package/skills/frontend-design-review/SKILL.md +26 -24
- package/skills/frontend-implementation/SKILL.md +29 -26
- package/skills/frontend-implementation/references/node-contracts.md +50 -19
- package/skills/frontend-review/SKILL.md +1 -1
- package/skills/loop-agent/references/command-reference.md +1 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./agent-dag.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "Knowledge-sync DAG template",
|
|
5
|
+
"objective": "After final verification, draft and apply stable testing knowledge: acceptance verdict, cases, coverage, defects, requirement delta pointers, and run audit records under features/*/testing/**.",
|
|
6
|
+
"successCriteria": [
|
|
7
|
+
"knowledge-sync-collect-pi inventories final verification evidence, ACs, cases, and defect candidates without writing files",
|
|
8
|
+
"knowledge-sync-draft-pi writes schemaVersion 1 knowledge-sync-draft.json under features/<feature-id>/testing/sync/pending/",
|
|
9
|
+
"knowledge-sync-validate-shell fails closed on missing draft, invalid schema, or non-pass finalVerification when gated",
|
|
10
|
+
"knowledge-sync-apply-pi upserts acceptance-verdict, coverage-matrix, cases, automation-map, and defects only within writeSet",
|
|
11
|
+
"knowledge-sync-pointer-pi writes runs/latest.md and sync/applied/KS-*.json audit pointers",
|
|
12
|
+
"No writes to src/**, .harness/**, or knowledge/testing/standards/**"
|
|
13
|
+
],
|
|
14
|
+
"globalConstraints": [
|
|
15
|
+
"Replace feature-id placeholders with the concrete Feature id before production runs.",
|
|
16
|
+
"Do not commit runtime traces under .harness/dag-runs/.",
|
|
17
|
+
"Use only existing executors: pi, shell. Pi writer nodes must set toolProfile=write.",
|
|
18
|
+
"Read-only nodes must not write repository files.",
|
|
19
|
+
"Exclusive writer nodes must stay within declared writeSet.",
|
|
20
|
+
"Final verification shell evidence remains completion authority; knowledge-sync stores stable facts and path pointers only.",
|
|
21
|
+
"High-risk requirement/acceptance body changes require human approval via requirement-delta; do not silently rewrite requirement.md.",
|
|
22
|
+
"Prefer structured YAML/Markdown L1 knowledge pack over vector-store-only writes."
|
|
23
|
+
],
|
|
24
|
+
"defaults": {
|
|
25
|
+
"executor": "pi",
|
|
26
|
+
"contextProfile": "slim",
|
|
27
|
+
"skills": [
|
|
28
|
+
"ai-engineering-context"
|
|
29
|
+
],
|
|
30
|
+
"writePolicy": "read-only"
|
|
31
|
+
},
|
|
32
|
+
"skillsByRole": {
|
|
33
|
+
"planner": [
|
|
34
|
+
"loop-agent"
|
|
35
|
+
],
|
|
36
|
+
"implementer": [
|
|
37
|
+
"verification-before-completion"
|
|
38
|
+
],
|
|
39
|
+
"reviewer": [
|
|
40
|
+
"requesting-code-review"
|
|
41
|
+
],
|
|
42
|
+
"verifier": [
|
|
43
|
+
"verification-before-completion",
|
|
44
|
+
"systematic-debugging"
|
|
45
|
+
],
|
|
46
|
+
"closeout": [
|
|
47
|
+
"loop-agent",
|
|
48
|
+
"verification-before-completion"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"tasks": [
|
|
52
|
+
{
|
|
53
|
+
"id": "knowledge-sync-collect-pi",
|
|
54
|
+
"depends_on": [],
|
|
55
|
+
"role": "planner",
|
|
56
|
+
"executor": "pi",
|
|
57
|
+
"complexity": "MED",
|
|
58
|
+
"writePolicy": "read-only",
|
|
59
|
+
"allowedPaths": [
|
|
60
|
+
"./**",
|
|
61
|
+
"docs/**",
|
|
62
|
+
"features/**"
|
|
63
|
+
],
|
|
64
|
+
"forbiddenPaths": [
|
|
65
|
+
".harness/**",
|
|
66
|
+
"artifacts/**"
|
|
67
|
+
],
|
|
68
|
+
"outputContract": "Plain Markdown inventory of evidence and knowledge-sync candidates; no file writes.",
|
|
69
|
+
"subtask_prompt": "Collect final-verification evidence, AC list, cases, defects, and requirement-delta candidates. Read-only."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "knowledge-sync-draft-pi",
|
|
73
|
+
"depends_on": [
|
|
74
|
+
"knowledge-sync-collect-pi"
|
|
75
|
+
],
|
|
76
|
+
"role": "implementer",
|
|
77
|
+
"executor": "pi",
|
|
78
|
+
"toolProfile": "write",
|
|
79
|
+
"complexity": "HIGH",
|
|
80
|
+
"writePolicy": "exclusive",
|
|
81
|
+
"writeSet": [
|
|
82
|
+
"features/**/testing/sync/pending/**"
|
|
83
|
+
],
|
|
84
|
+
"allowedPaths": [
|
|
85
|
+
"features/**/testing/sync/pending/**"
|
|
86
|
+
],
|
|
87
|
+
"forbiddenPaths": [
|
|
88
|
+
".harness/**",
|
|
89
|
+
"artifacts/**",
|
|
90
|
+
"src/**"
|
|
91
|
+
],
|
|
92
|
+
"outputContract": "Pending knowledge-sync-draft.json + markdown summary under features/<feature-id>/testing/sync/pending/.",
|
|
93
|
+
"subtask_prompt": "Write schemaVersion 1 draft with operations, payload, and gates. Stay within writeSet."
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "knowledge-sync-validate-shell",
|
|
97
|
+
"depends_on": [
|
|
98
|
+
"knowledge-sync-draft-pi"
|
|
99
|
+
],
|
|
100
|
+
"role": "verifier",
|
|
101
|
+
"executor": "shell",
|
|
102
|
+
"complexity": "LOW",
|
|
103
|
+
"writePolicy": "read-only",
|
|
104
|
+
"allowedPaths": [
|
|
105
|
+
"features/**"
|
|
106
|
+
],
|
|
107
|
+
"forbiddenPaths": [
|
|
108
|
+
".harness/**",
|
|
109
|
+
"artifacts/**"
|
|
110
|
+
],
|
|
111
|
+
"outputContract": "Deterministic draft schema validation; exit non-zero on invalid draft.",
|
|
112
|
+
"subtask_prompt": "Validate pending knowledge-sync-draft.json files.",
|
|
113
|
+
"shell": {
|
|
114
|
+
"commands": [
|
|
115
|
+
"node -e \"const fs=require('fs');const path=require('path');function walk(d,a=[]){if(!fs.existsSync(d))return a;for(const e of fs.readdirSync(d,{withFileTypes:true})){const p=path.join(d,e.name);if(e.isDirectory())walk(p,a);else if(e.name==='knowledge-sync-draft.json')a.push(p);}return a;}const drafts=walk('features');if(!drafts.length){console.error('no draft');process.exit(1);}for(const f of drafts){const d=JSON.parse(fs.readFileSync(f,'utf8'));if(d.schemaVersion!==1)process.exit(1);}console.log('ok');\""
|
|
116
|
+
],
|
|
117
|
+
"cwd": ".",
|
|
118
|
+
"timeoutMs": 120000
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "knowledge-sync-apply-pi",
|
|
123
|
+
"depends_on": [
|
|
124
|
+
"knowledge-sync-validate-shell"
|
|
125
|
+
],
|
|
126
|
+
"role": "implementer",
|
|
127
|
+
"executor": "pi",
|
|
128
|
+
"toolProfile": "write",
|
|
129
|
+
"complexity": "HIGH",
|
|
130
|
+
"writePolicy": "exclusive",
|
|
131
|
+
"writeSet": [
|
|
132
|
+
"features/**/testing/**",
|
|
133
|
+
"features/**/requirement-delta.md",
|
|
134
|
+
"docs/test-reports/**"
|
|
135
|
+
],
|
|
136
|
+
"allowedPaths": [
|
|
137
|
+
"features/**/testing/**",
|
|
138
|
+
"features/**/requirement-delta.md",
|
|
139
|
+
"docs/test-reports/**"
|
|
140
|
+
],
|
|
141
|
+
"forbiddenPaths": [
|
|
142
|
+
".harness/**",
|
|
143
|
+
"artifacts/**",
|
|
144
|
+
"src/**",
|
|
145
|
+
"knowledge/testing/standards/**"
|
|
146
|
+
],
|
|
147
|
+
"outputContract": "Applied L1 knowledge files: acceptance-verdict, coverage-matrix, cases, defects, optional requirement-delta.",
|
|
148
|
+
"subtask_prompt": "Apply validated draft into Feature testing knowledge paths. Do not touch standards or src."
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "knowledge-sync-pointer-pi",
|
|
152
|
+
"depends_on": [
|
|
153
|
+
"knowledge-sync-apply-pi"
|
|
154
|
+
],
|
|
155
|
+
"role": "closeout",
|
|
156
|
+
"executor": "pi",
|
|
157
|
+
"toolProfile": "write",
|
|
158
|
+
"complexity": "MED",
|
|
159
|
+
"writePolicy": "exclusive",
|
|
160
|
+
"writeSet": [
|
|
161
|
+
"features/**/testing/runs/**",
|
|
162
|
+
"features/**/testing/sync/applied/**"
|
|
163
|
+
],
|
|
164
|
+
"allowedPaths": [
|
|
165
|
+
"features/**/testing/runs/**",
|
|
166
|
+
"features/**/testing/sync/applied/**"
|
|
167
|
+
],
|
|
168
|
+
"forbiddenPaths": [
|
|
169
|
+
".harness/**",
|
|
170
|
+
"artifacts/**",
|
|
171
|
+
"src/**"
|
|
172
|
+
],
|
|
173
|
+
"outputContract": "runs/latest.md and sync/applied/KS-*.json audit pointers.",
|
|
174
|
+
"subtask_prompt": "Write run pointers and applied audit record only."
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://loop-agent.local/schemas/knowledge-sync-draft.schema.json",
|
|
4
|
+
"title": "Knowledge Sync Draft",
|
|
5
|
+
"description": "Pending package written by knowledge-sync-draft-pi before validate/apply.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schemaVersion",
|
|
10
|
+
"featureId",
|
|
11
|
+
"taskId",
|
|
12
|
+
"runId",
|
|
13
|
+
"finalVerification",
|
|
14
|
+
"operations",
|
|
15
|
+
"payload",
|
|
16
|
+
"gates"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"schemaVersion": { "const": 1 },
|
|
20
|
+
"featureId": { "type": "string", "minLength": 1 },
|
|
21
|
+
"taskId": { "type": "string", "minLength": 1 },
|
|
22
|
+
"runId": { "type": "string", "minLength": 1 },
|
|
23
|
+
"headSha": { "type": "string" },
|
|
24
|
+
"finalVerification": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["pass", "fail", "partial", "pass-with-waivers"]
|
|
27
|
+
},
|
|
28
|
+
"operations": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"minItems": 1,
|
|
31
|
+
"items": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"additionalProperties": false,
|
|
34
|
+
"required": ["op", "target", "risk", "reason"],
|
|
35
|
+
"properties": {
|
|
36
|
+
"op": { "type": "string", "enum": ["upsert", "create", "append"] },
|
|
37
|
+
"target": { "type": "string", "minLength": 1 },
|
|
38
|
+
"risk": { "type": "string", "enum": ["low", "medium", "high"] },
|
|
39
|
+
"reason": { "type": "string", "minLength": 1 }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"payload": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": true,
|
|
46
|
+
"properties": {
|
|
47
|
+
"acceptanceVerdict": { "type": ["object", "null"] },
|
|
48
|
+
"coverageMatrix": { "type": ["object", "null"] },
|
|
49
|
+
"caseIndex": { "type": ["object", "null"] },
|
|
50
|
+
"automationMap": { "type": ["object", "null"] },
|
|
51
|
+
"defects": { "type": ["object", "null"] },
|
|
52
|
+
"requirementDelta": { "type": ["object", "string", "null"] },
|
|
53
|
+
"retrospectiveRef": { "type": ["string", "null"] },
|
|
54
|
+
"evidencePointers": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"items": { "type": "string" }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"gates": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"required": ["requireHumanIfHighRisk", "blockIfFinalVerificationNotPass"],
|
|
64
|
+
"properties": {
|
|
65
|
+
"requireHumanIfHighRisk": { "type": "boolean" },
|
|
66
|
+
"blockIfFinalVerificationNotPass": { "type": "boolean" },
|
|
67
|
+
"blockIfCoverageP0Missing": { "type": "boolean" }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
| Feature run orchestration | `npx vitest run test/worker/feature test/worker/runner/run-ready.test.ts test/worker/agent-worker-cli.test.ts` | `npm test` + `node bin/agent-worker.js feature run --help` |
|
|
12
12
|
| Follow-up 分类与事务 | `npx vitest run test/worker/follow-up test/worker/feature test/worker/pool test/worker/report test/worker/agent-worker-cli.test.ts` | `npm test` + `node bin/agent-worker.js task draft-followup --help` + `node bin/agent-worker.js feature approve-followup --help` |
|
|
13
13
|
| Feature Git transaction | `npx vitest run test/worker/delivery test/worker/feature test/worker/runner test/worker/agent-worker-cli.test.ts` | `npm test` + `node bin/agent-worker.js feature run --help` + temporary Git repo smoke |
|
|
14
|
-
| Final verification / Delivery / Closeout | `npx vitest run test/worker/delivery test/worker/
|
|
14
|
+
| Final verification / Delivery / Closeout | `npx vitest run test/worker/delivery test/worker/feature test/worker/agent-worker-cli.test.ts` | `npm test` + verify-final/Delivery/Closeout CLI help + temporary Git repo evidence/hash/tamper/apply rollback smoke。Closeout 覆盖在 `test/worker/delivery/**` 与 CLI,不存在独立 `test/worker/closeout/` 目录 |
|
|
15
|
+
| Task Pool feature-scoped identity / migration | `npx vitest run test/worker/pool test/worker/runner/run-ready.test.ts test/worker/feature test/worker/follow-up test/worker/delivery test/worker/report test/worker/observability test/worker/observe test/worker/agent-worker-cli.test.ts` + `npm run typecheck` | 平台临时目录 dual-Feature smoke(同名 `QA-EXEC-001` 不串线)+ `pool doctor` / `pool migrate-state` dry-run + Observe canonical/legacy 409 |
|
|
15
16
|
| Controller identity / pinning | `npx vitest run test/worker/package-metadata.test.ts test/worker/repo-preflight.test.ts test/worker/loop-agent-client.test.ts test/worker/run-task/run-task.test.ts test/worker/runner/run-ready.test.ts test/worker/feature/run.test.ts test/worker/delivery/final-verification.test.ts test/worker/delivery/package.test.ts test/worker/agent-worker-cli.test.ts` + `npm run typecheck` | `npm test` + build + 两个 CLI `--version` + 写入型命令 help |
|
|
16
17
|
| DAG resolved skill snapshot / resume | `npx vitest run test/dag-skill-snapshot.test.ts test/dag-approve-resume.test.ts` + `npm run typecheck` | `npm test` + snapshot tamper/pause-resume/dynamic profile smoke |
|
|
17
18
|
| Versioned self-hosting candidate canary | `npx vitest run test/self-host-canary.test.ts test/package-surface.test.ts` + `npm run build` | `npm run self-host:canary -- --deterministic --output <evidence.json>` + `npm pack --dry-run` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tea-agent/loop-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"loop-agent": "bin/loop-agent.js",
|
|
@@ -18,7 +18,13 @@
|
|
|
18
18
|
"docs/exec-plans/active/README.md", "docs/exec-plans/completed/README.md",
|
|
19
19
|
"docs/init-surface.manifest.json", "docs/progress/README.md", "docs/reports/README.md",
|
|
20
20
|
"docs/skills/", "docs/templates/", "examples/", "harness.json", "skills/",
|
|
21
|
-
"scripts/check-product-line-docs.sh", "scripts/check-task-pool-root.sh",
|
|
21
|
+
"scripts/check-product-line-docs.sh", "scripts/check-task-pool-root.sh",
|
|
22
|
+
"scripts/kb-bootstrap-init-skeleton.sh",
|
|
23
|
+
"scripts/kb-query.sh", "scripts/kb-query.mjs",
|
|
24
|
+
"scripts/kb-graph-materialize.sh", "scripts/kb-graph-materialize.mjs",
|
|
25
|
+
"scripts/kb-graph-promote.sh", "scripts/kb-graph-promote.mjs",
|
|
26
|
+
"scripts/kb-graph-incremental-prepare.sh", "scripts/kb-graph-incremental-prepare.mjs",
|
|
27
|
+
"README.md", "CHANGELOG.md"
|
|
22
28
|
],
|
|
23
29
|
"publishConfig": { "access": "public" },
|
|
24
30
|
"scripts": {
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# B1 skeleton for business knowledge-graph bootstrap (no model calls).
|
|
3
|
+
# Creates knowledge/bootstrap/{scope,status}.yaml, staging dirs, and graph placeholders.
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
usage() {
|
|
7
|
+
cat <<'EOF'
|
|
8
|
+
Usage: bash scripts/kb-bootstrap-init-skeleton.sh [--root <dir>] [--force] [--product-name <name>]
|
|
9
|
+
|
|
10
|
+
Idempotent B1 bootstrap skeleton for knowledge-graph-bootstrap-dag preflight.
|
|
11
|
+
|
|
12
|
+
--root DIR Target repository root (default: cwd)
|
|
13
|
+
--force Overwrite scope.yaml / status.yaml if they already exist
|
|
14
|
+
--product-name N Product name written into scope.yaml (default: basename of root)
|
|
15
|
+
|
|
16
|
+
Does not call any LLM. Safe for greenfield and brownfield (default: never overwrite).
|
|
17
|
+
EOF
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ROOT="$(pwd)"
|
|
21
|
+
FORCE=0
|
|
22
|
+
PRODUCT_NAME=""
|
|
23
|
+
|
|
24
|
+
while [[ $# -gt 0 ]]; do
|
|
25
|
+
case "$1" in
|
|
26
|
+
--root)
|
|
27
|
+
ROOT="${2:-}"
|
|
28
|
+
shift 2
|
|
29
|
+
;;
|
|
30
|
+
--force)
|
|
31
|
+
FORCE=1
|
|
32
|
+
shift
|
|
33
|
+
;;
|
|
34
|
+
--product-name)
|
|
35
|
+
PRODUCT_NAME="${2:-}"
|
|
36
|
+
shift 2
|
|
37
|
+
;;
|
|
38
|
+
-h|--help)
|
|
39
|
+
usage
|
|
40
|
+
exit 0
|
|
41
|
+
;;
|
|
42
|
+
*)
|
|
43
|
+
echo "unknown argument: $1" >&2
|
|
44
|
+
usage >&2
|
|
45
|
+
exit 2
|
|
46
|
+
;;
|
|
47
|
+
esac
|
|
48
|
+
done
|
|
49
|
+
|
|
50
|
+
if [[ -z "${ROOT}" ]]; then
|
|
51
|
+
echo "--root requires a directory" >&2
|
|
52
|
+
exit 2
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
ROOT="$(cd "${ROOT}" && pwd)"
|
|
56
|
+
if [[ -z "${PRODUCT_NAME}" ]]; then
|
|
57
|
+
PRODUCT_NAME="$(basename "${ROOT}")"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
TS="$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
61
|
+
BOOTSTRAP_ID="BR-$(date -u +"%Y%m%d-%H%M%S" 2>/dev/null || echo "init")"
|
|
62
|
+
|
|
63
|
+
mkdir -p \
|
|
64
|
+
"${ROOT}/knowledge/bootstrap/runs" \
|
|
65
|
+
"${ROOT}/knowledge/bootstrap/staging/domains" \
|
|
66
|
+
"${ROOT}/knowledge/bootstrap/staging/services" \
|
|
67
|
+
"${ROOT}/knowledge/bootstrap/staging/modules" \
|
|
68
|
+
"${ROOT}/knowledge/bootstrap/staging/features-links.proposed" \
|
|
69
|
+
"${ROOT}/knowledge/graph" \
|
|
70
|
+
"${ROOT}/knowledge/domains" \
|
|
71
|
+
"${ROOT}/knowledge/services" \
|
|
72
|
+
"${ROOT}/knowledge/modules" \
|
|
73
|
+
"${ROOT}/knowledge/testing"
|
|
74
|
+
|
|
75
|
+
write_if_missing() {
|
|
76
|
+
local path="$1"
|
|
77
|
+
local content="$2"
|
|
78
|
+
if [[ -e "${path}" && "${FORCE}" -ne 1 ]]; then
|
|
79
|
+
echo "keep existing: ${path#"${ROOT}"/}"
|
|
80
|
+
return 0
|
|
81
|
+
fi
|
|
82
|
+
mkdir -p "$(dirname "${path}")"
|
|
83
|
+
printf '%s' "${content}" > "${path}"
|
|
84
|
+
echo "wrote ${path#"${ROOT}"/}"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
SCOPE_CONTENT=$(cat <<EOF
|
|
88
|
+
# B0/B1 scope for knowledge-graph bootstrap (edit before propose).
|
|
89
|
+
schema_version: 1
|
|
90
|
+
product_name: ${PRODUCT_NAME}
|
|
91
|
+
primary_language: zh-CN
|
|
92
|
+
repo_kind: single-service
|
|
93
|
+
include_paths:
|
|
94
|
+
- src/**
|
|
95
|
+
- services/**
|
|
96
|
+
- apps/**
|
|
97
|
+
- packages/**
|
|
98
|
+
- features/**
|
|
99
|
+
- docs/**
|
|
100
|
+
- README.md
|
|
101
|
+
exclude_paths:
|
|
102
|
+
- node_modules/**
|
|
103
|
+
- dist/**
|
|
104
|
+
- .harness/**
|
|
105
|
+
- "**/*.min.js"
|
|
106
|
+
id_namespace:
|
|
107
|
+
domain_prefix: DOM
|
|
108
|
+
service_prefix: SVC
|
|
109
|
+
api_prefix: API
|
|
110
|
+
seed_domains: []
|
|
111
|
+
seed_services: []
|
|
112
|
+
seed_features: []
|
|
113
|
+
assumptions: []
|
|
114
|
+
out_of_scope: []
|
|
115
|
+
human_owners:
|
|
116
|
+
architect: ""
|
|
117
|
+
qa: ""
|
|
118
|
+
EOF
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
STATUS_CONTENT=$(cat <<EOF
|
|
122
|
+
# Bootstrap status machine (see docs/design/knowledge-graph-ai-bootstrap.md §4)
|
|
123
|
+
schema_version: 1
|
|
124
|
+
bootstrap_id: ${BOOTSTRAP_ID}
|
|
125
|
+
repo_root: .
|
|
126
|
+
phase: B2
|
|
127
|
+
updated_at: ${TS}
|
|
128
|
+
scope_ref: knowledge/bootstrap/scope.yaml
|
|
129
|
+
inventory_ref: knowledge/bootstrap/inventory.json
|
|
130
|
+
last_run_dir: ""
|
|
131
|
+
stats:
|
|
132
|
+
entities_proposed: 0
|
|
133
|
+
entities_asserted: 0
|
|
134
|
+
edges_proposed: 0
|
|
135
|
+
edges_asserted: 0
|
|
136
|
+
features_linked: 0
|
|
137
|
+
blockers: []
|
|
138
|
+
next_actions:
|
|
139
|
+
- "Edit knowledge/bootstrap/scope.yaml (include/exclude, seeds)"
|
|
140
|
+
- "Run knowledge-graph-bootstrap DAG or inventory step (B2+)"
|
|
141
|
+
EOF
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
README_KB=$(cat <<'EOF'
|
|
145
|
+
# Knowledge base
|
|
146
|
+
|
|
147
|
+
Structured project knowledge (Git is authority).
|
|
148
|
+
|
|
149
|
+
- `bootstrap/` — AI graph init workspace (staging only until promote)
|
|
150
|
+
- `graph/` — materialize indexes (`entities-index.yaml`, `edges.yaml`)
|
|
151
|
+
- `domains|services|modules/` — formal asserted entities after promote
|
|
152
|
+
- `testing/` — shared testing standards (L0), Feature packs live under `features/<F>/testing/`
|
|
153
|
+
|
|
154
|
+
## Bootstrap (B1+)
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
bash scripts/kb-bootstrap-init-skeleton.sh --root .
|
|
158
|
+
# edit knowledge/bootstrap/scope.yaml
|
|
159
|
+
loop-agent dag run-task <id> --profile knowledge-graph-bootstrap
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Query (Phase A design)
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# when available:
|
|
166
|
+
# bash scripts/kb-query.sh --mode by_feature --feature F-2026-004 --json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
See `docs/design/knowledge-graph-and-query-spec.md` and `docs/design/knowledge-graph-ai-bootstrap.md`.
|
|
170
|
+
EOF
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
README_BOOTSTRAP=$(cat <<'EOF'
|
|
174
|
+
# Knowledge-graph bootstrap workspace
|
|
175
|
+
|
|
176
|
+
- `scope.yaml` — human scope (required for preflight)
|
|
177
|
+
- `status.yaml` — phase machine B0–B6
|
|
178
|
+
- `inventory.json` — B2 deterministic scan output
|
|
179
|
+
- `staging/**` — **only** AI write area before promote
|
|
180
|
+
- `runs/**` — per-run reports
|
|
181
|
+
|
|
182
|
+
AI must never set `confidence: asserted`. Promote merges new files into formal trees.
|
|
183
|
+
EOF
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
README_GRAPH=$(cat <<'EOF'
|
|
187
|
+
# Graph indexes
|
|
188
|
+
|
|
189
|
+
Generated by materialize (B6):
|
|
190
|
+
|
|
191
|
+
- `entities-index.yaml`
|
|
192
|
+
- `edges.yaml`
|
|
193
|
+
- `edges.manual.yaml` — human/AI-promoted edges source (optional)
|
|
194
|
+
|
|
195
|
+
Do not hand-edit generated indexes without re-running materialize.
|
|
196
|
+
EOF
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
STAGING_NOTES=$(cat <<'EOF'
|
|
200
|
+
# Staging notes
|
|
201
|
+
|
|
202
|
+
AI proposals only. Promote copies new files into `knowledge/domains|services|modules` and feature knowledge-links.
|
|
203
|
+
EOF
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
EDGES_PROPOSED=$(cat <<'EOF'
|
|
207
|
+
schema_version: 1
|
|
208
|
+
updated_at: null
|
|
209
|
+
edges: []
|
|
210
|
+
EOF
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/scope.yaml" "${SCOPE_CONTENT}"$'\n'
|
|
214
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/status.yaml" "${STATUS_CONTENT}"$'\n'
|
|
215
|
+
write_if_missing "${ROOT}/knowledge/README.md" "${README_KB}"$'\n'
|
|
216
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/README.md" "${README_BOOTSTRAP}"$'\n'
|
|
217
|
+
write_if_missing "${ROOT}/knowledge/graph/README.md" "${README_GRAPH}"$'\n'
|
|
218
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/staging/coverage-notes.md" "${STAGING_NOTES}"$'\n'
|
|
219
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/staging/edges.proposed.yaml" "${EDGES_PROPOSED}"$'\n'
|
|
220
|
+
write_if_missing "${ROOT}/knowledge/bootstrap/staging/notes.md" "# bootstrap staging"$'\n'
|
|
221
|
+
|
|
222
|
+
# Placeholders so empty trees are visible in git if desired (optional .gitkeep)
|
|
223
|
+
for d in \
|
|
224
|
+
"${ROOT}/knowledge/bootstrap/runs" \
|
|
225
|
+
"${ROOT}/knowledge/bootstrap/staging/domains" \
|
|
226
|
+
"${ROOT}/knowledge/bootstrap/staging/services" \
|
|
227
|
+
"${ROOT}/knowledge/bootstrap/staging/modules" \
|
|
228
|
+
"${ROOT}/knowledge/domains" \
|
|
229
|
+
"${ROOT}/knowledge/services" \
|
|
230
|
+
"${ROOT}/knowledge/modules"
|
|
231
|
+
do
|
|
232
|
+
write_if_missing "${d}/.gitkeep" ""
|
|
233
|
+
done
|
|
234
|
+
|
|
235
|
+
echo
|
|
236
|
+
echo "B1 skeleton ready under ${ROOT}/knowledge/"
|
|
237
|
+
echo " scope: knowledge/bootstrap/scope.yaml"
|
|
238
|
+
echo " status: knowledge/bootstrap/status.yaml (phase: B2)"
|
|
239
|
+
echo "Next: edit scope.yaml, then run knowledge-graph-bootstrap DAG."
|