project-knowledge 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/CHANGELOG.md +34 -0
- package/INDEX.md +53 -0
- package/README.md +79 -0
- package/_site/README.md +63 -0
- package/_site/_test/ai-profile-test.js +199 -0
- package/_site/_test/baseline-schema-test.js +132 -0
- package/_site/_test/commit-analysis-test.js +184 -0
- package/_site/_test/context-pack-test.js +199 -0
- package/_site/_test/draft-apply-test.js +363 -0
- package/_site/_test/git-validation-test.js +171 -0
- package/_site/_test/hook-trigger-test.js +257 -0
- package/_site/_test/initial-analysis-test.js +228 -0
- package/_site/_test/job-orchestrator-test.js +297 -0
- package/_site/_test/kb-v2-templates-test.js +189 -0
- package/_site/_test/pr-consumer-contract-test.js +236 -0
- package/_site/_test/run-all-tests.js +135 -0
- package/_site/_test/scanner-test.js +206 -0
- package/_site/_test/ui-smoke-test.js +237 -0
- package/_site/_test/ui-test.js +237 -0
- package/_site/index.html +1166 -0
- package/_site/lib/ai-adapter.js +287 -0
- package/_site/lib/analysis-orchestrator.js +433 -0
- package/_site/lib/context-pack-builder.js +290 -0
- package/_site/lib/draft-apply.js +219 -0
- package/_site/lib/git-runner.js +26 -0
- package/_site/lib/hook-manager.js +148 -0
- package/_site/lib/job-orchestrator.js +231 -0
- package/_site/lib/kb-validator.js +224 -0
- package/_site/lib/llm-client.js +126 -0
- package/_site/lib/scanner.js +94 -0
- package/_site/scripts/hook-trigger.js +133 -0
- package/_site/scripts/safe-runner.js +151 -0
- package/_site/server.js +1058 -0
- package/_site/start.bat +26 -0
- package/_site/stop.bat +11 -0
- package/ai-profiles.json +18 -0
- package/docs/ai-knowledge-base-system-design.md +395 -0
- package/docs/pr-consumer-contract.md +198 -0
- package/docs/project-goal.md +72 -0
- package/docs/project-registry-schema.md +46 -0
- package/docs/testing-strategy.md +169 -0
- package/iterations.json +23 -0
- package/package.json +47 -0
- package/scripts/gen-commit-doc.ps1 +178 -0
- package/scripts/gen-commit-doc.sh +197 -0
- package/scripts/list-features.ps1 +41 -0
- package/scripts/register-scheduled-task.bat +5 -0
- package/templates/change.md +59 -0
- package/templates/commit-feature.md +56 -0
- package/templates/feature.md +44 -0
- package/templates/framework.md +80 -0
- package/templates/index-header.md +3 -0
- package/templates/kb-manifest.json +38 -0
- package/templates/module.md +58 -0
- package/templates/project-analysis.md +48 -0
- package/templates/project-goal.md +55 -0
- package/templates/project-readme.md +60 -0
- package/templates/quality-review-rules.md +37 -0
- package/templates/update-entry.md +7 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# gen-commit-doc.sh — Bash 版
|
|
3
|
+
# 用法:
|
|
4
|
+
# ./gen-commit-doc.sh claude-devsprite
|
|
5
|
+
# ./gen-commit-doc.sh ALL
|
|
6
|
+
#
|
|
7
|
+
# 与 PowerShell 版行为完全一致:在 kb/projects/<slug>/commits/ 下为每个
|
|
8
|
+
# feat/fix/refactor/perf 类型的 commit 生成一个 feature 文件,
|
|
9
|
+
# 同 feature-slug 的多次提交追加到同一文件。
|
|
10
|
+
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
|
|
13
|
+
SLUG="${1:-}"
|
|
14
|
+
if [[ -z "$SLUG" ]]; then
|
|
15
|
+
echo "usage: $0 <project-slug|ALL>" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
KB_ROOT="${KB_ROOT:-D:/SanQian.Xu/project-knowledge-base}"
|
|
20
|
+
PROJECTS_JSON="$KB_ROOT/projects.json"
|
|
21
|
+
MAX_COMMITS="${MAX_COMMITS:-0}"
|
|
22
|
+
|
|
23
|
+
if [[ ! -f "$PROJECTS_JSON" ]]; then
|
|
24
|
+
echo "找不到 $PROJECTS_JSON" >&2
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# 用 jq 解析
|
|
29
|
+
slug_to_git() {
|
|
30
|
+
local slug="$1"
|
|
31
|
+
jq -r ".${slug}.gitPath" "$PROJECTS_JSON"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# 把 commit subject 转 feature-slug
|
|
35
|
+
to_slug() {
|
|
36
|
+
local s="$1"
|
|
37
|
+
# 去 type 前缀
|
|
38
|
+
s=$(echo "$s" | sed -E 's/^(feat|fix|refactor|perf|docs|chore|test|style|build|ci)(\([^)]+\))?:[[:space:]]*//')
|
|
39
|
+
# 转 ASCII + kebab
|
|
40
|
+
s=$(echo "$s" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/-+/-/g' | sed -E 's/^-+|-+$//g')
|
|
41
|
+
if [[ -z "$s" ]]; then s="untitled"; fi
|
|
42
|
+
if [[ ${#s} -gt 50 ]]; then s="${s:0:50}"; s="${s%-}"; fi
|
|
43
|
+
echo "$s"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# 取 commit type
|
|
47
|
+
commit_type() {
|
|
48
|
+
local s="$1"
|
|
49
|
+
if [[ "$s" =~ ^(feat|fix|refactor|perf|docs|chore|test|style|build|ci)(\([^)]+\))?:\ ]]; then
|
|
50
|
+
echo "${BASH_REMATCH[1]}"
|
|
51
|
+
else
|
|
52
|
+
echo "other"
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
is_writable() {
|
|
57
|
+
local t="$1"
|
|
58
|
+
case "$t" in
|
|
59
|
+
feat|fix|refactor|perf) return 0 ;;
|
|
60
|
+
*) return 1 ;;
|
|
61
|
+
esac
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
process_project() {
|
|
65
|
+
local slug="$1"
|
|
66
|
+
local git_path
|
|
67
|
+
git_path=$(slug_to_git "$slug")
|
|
68
|
+
local commits_dir="$KB_ROOT/projects/$slug/commits"
|
|
69
|
+
mkdir -p "$commits_dir"
|
|
70
|
+
|
|
71
|
+
echo ""
|
|
72
|
+
echo "=== $slug ==="
|
|
73
|
+
echo " git: $git_path"
|
|
74
|
+
|
|
75
|
+
local log_args=("log" "--no-merges" "--pretty=format:%h|%ad|%an|%s" "--date=short")
|
|
76
|
+
if [[ "$MAX_COMMITS" -gt 0 ]]; then
|
|
77
|
+
log_args+=("-n" "$MAX_COMMITS")
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
local log_out
|
|
81
|
+
log_out=$(git -C "$git_path" "${log_args[@]}" 2>&1) || {
|
|
82
|
+
echo "git log 失败: $log_out" >&2
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if [[ -z "$log_out" ]]; then
|
|
87
|
+
echo " (无 commit)"
|
|
88
|
+
return
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
local new=0 updated=0 skipped=0
|
|
92
|
+
|
|
93
|
+
# 已有文件 → slug map
|
|
94
|
+
declare -A existing
|
|
95
|
+
while IFS= read -r f; do
|
|
96
|
+
[[ -z "$f" ]] && continue
|
|
97
|
+
local base="${f##*/}"
|
|
98
|
+
base="${base%.md}"
|
|
99
|
+
if [[ "$base" =~ _(.+)$ ]]; then
|
|
100
|
+
existing["${BASH_REMATCH[1]}"]="$f"
|
|
101
|
+
else
|
|
102
|
+
existing["$base"]="$f"
|
|
103
|
+
fi
|
|
104
|
+
done < <(find "$commits_dir" -maxdepth 1 -name "*.md" ! -name "00-index.md")
|
|
105
|
+
|
|
106
|
+
while IFS= read -r line; do
|
|
107
|
+
[[ -z "$line" ]] && continue
|
|
108
|
+
[[ "$line" != *"|"* ]] && continue
|
|
109
|
+
|
|
110
|
+
IFS='|' read -r hash date author subject <<< "$line"
|
|
111
|
+
local type
|
|
112
|
+
type=$(commit_type "$subject")
|
|
113
|
+
if ! is_writable "$type"; then
|
|
114
|
+
skipped=$((skipped+1))
|
|
115
|
+
continue
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
local slug_key
|
|
119
|
+
slug_key=$(to_slug "$subject")
|
|
120
|
+
local short_hash="${hash:0:7}"
|
|
121
|
+
local filename="${date}_${short_hash}_${slug_key}.md"
|
|
122
|
+
local filepath="$commits_dir/$filename"
|
|
123
|
+
|
|
124
|
+
if [[ -f "$filepath" ]]; then
|
|
125
|
+
existing["$slug_key"]="$filepath"
|
|
126
|
+
continue
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
if [[ -n "${existing[$slug_key]:-}" ]]; then
|
|
130
|
+
# 追加
|
|
131
|
+
cat >> "${existing[$slug_key]}" <<EOF
|
|
132
|
+
|
|
133
|
+
### ${date} \`${short_hash}\`: ${subject}
|
|
134
|
+
|
|
135
|
+
- **类型**: $type
|
|
136
|
+
- **作者**: $author
|
|
137
|
+
- **变更说明**: 由 gen-commit-doc.sh 自动生成 — $type 类型的提交,触及同一 feature。
|
|
138
|
+
EOF
|
|
139
|
+
updated=$((updated+1))
|
|
140
|
+
else
|
|
141
|
+
# 新建
|
|
142
|
+
cat > "$filepath" <<EOF
|
|
143
|
+
---
|
|
144
|
+
feature: ${slug_key}
|
|
145
|
+
project: ${slug}
|
|
146
|
+
firstCommit: ${short_hash} (${date}, ${author})
|
|
147
|
+
lastUpdate: ${short_hash} (${date}, ${author})
|
|
148
|
+
status: active
|
|
149
|
+
commitType: ${type}
|
|
150
|
+
relatedModule: null
|
|
151
|
+
generatedAt: $(date -Iseconds)
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
# ${subject}
|
|
155
|
+
|
|
156
|
+
> 由 gen-commit-doc.sh 自动生成于 $(date +%Y-%m-%d)。
|
|
157
|
+
|
|
158
|
+
## 概述
|
|
159
|
+
|
|
160
|
+
待人工补充:${type} 类型的提交 — ${subject}。
|
|
161
|
+
|
|
162
|
+
## 初始实现
|
|
163
|
+
|
|
164
|
+
- **Commit**: \`${short_hash}\` (${date}, ${author}): ${subject}
|
|
165
|
+
- **类型**: ${type}
|
|
166
|
+
- **变更说明**: 由 gen-commit-doc.sh 自动生成。
|
|
167
|
+
- **业务影响**: 待人工补充。
|
|
168
|
+
|
|
169
|
+
## 后续更新记录(倒序)
|
|
170
|
+
|
|
171
|
+
## 关联模块
|
|
172
|
+
|
|
173
|
+
- [框架说明](../framework.md)
|
|
174
|
+
|
|
175
|
+
## 关联 commit
|
|
176
|
+
|
|
177
|
+
- \`${short_hash}\` ${subject}
|
|
178
|
+
EOF
|
|
179
|
+
new=$((new+1))
|
|
180
|
+
existing["$slug_key"]="$filepath"
|
|
181
|
+
fi
|
|
182
|
+
done <<< "$log_out"
|
|
183
|
+
|
|
184
|
+
echo " 新建: $new, 追加: $updated, 跳过: $skipped"
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# 入口
|
|
188
|
+
if [[ "$SLUG" == "ALL" ]]; then
|
|
189
|
+
for slug in $(jq -r 'keys[]' "$PROJECTS_JSON"); do
|
|
190
|
+
process_project "$slug"
|
|
191
|
+
done
|
|
192
|
+
else
|
|
193
|
+
process_project "$SLUG"
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
echo ""
|
|
197
|
+
echo "完成。"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# list-features.ps1 — 列出某项目所有 feature 文档
|
|
2
|
+
# 用法: .\list-features.ps1 -ProjectSlug claude-devsprite [-SortBy time|count]
|
|
3
|
+
|
|
4
|
+
[CmdletBinding()]
|
|
5
|
+
param(
|
|
6
|
+
[Parameter(Mandatory = $true)]
|
|
7
|
+
[string] $ProjectSlug,
|
|
8
|
+
[ValidateSet("time", "count")]
|
|
9
|
+
[string] $SortBy = "time",
|
|
10
|
+
[string] $KbRoot = "D:\SanQian.Xu\project-knowledge-base"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
$commitsDir = Join-Path $KbRoot "projects\$ProjectSlug\commits"
|
|
14
|
+
if (-not (Test-Path $commitsDir)) {
|
|
15
|
+
Write-Error "找不到 $commitsDir"
|
|
16
|
+
exit 1
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$files = Get-ChildItem -Path $commitsDir -Filter "*.md" |
|
|
20
|
+
Where-Object { $_.Name -ne "00-index.md" }
|
|
21
|
+
|
|
22
|
+
if ($SortBy -eq "count") {
|
|
23
|
+
$files = $files | Sort-Object { $_.Length } -Descending
|
|
24
|
+
} else {
|
|
25
|
+
$files = $files | Sort-Object Name -Descending
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Write-Host "=== $ProjectSlug · 所有 feature 文档(按 $SortBy 排序)===" -ForegroundColor Cyan
|
|
29
|
+
Write-Host ""
|
|
30
|
+
foreach ($f in $files) {
|
|
31
|
+
$name = $f.BaseName
|
|
32
|
+
$updateCount = 0
|
|
33
|
+
if (Select-String -Path $f.FullName -Pattern "^### " -Quiet) {
|
|
34
|
+
$updateCount = ([regex]::Matches((Get-Content $f.FullName -Raw), "(?m)^### ")).Count
|
|
35
|
+
}
|
|
36
|
+
$relPath = "./$($f.Name)"
|
|
37
|
+
Write-Host ("- [{0}]({1})" -f $name, $relPath) -NoNewline
|
|
38
|
+
Write-Host " ($updateCount 次更新)" -ForegroundColor Gray
|
|
39
|
+
}
|
|
40
|
+
Write-Host ""
|
|
41
|
+
Write-Host "共 $($files.Count) 个 feature"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: change/v1
|
|
3
|
+
project: __PROJECT__
|
|
4
|
+
commit: __COMMIT__
|
|
5
|
+
shortCommit: __SHORTCOMMIT__
|
|
6
|
+
date: __DATE__
|
|
7
|
+
author: __AUTHOR__
|
|
8
|
+
subject: __SUBJECT__
|
|
9
|
+
type: __TYPE__
|
|
10
|
+
classification: __CLASSIFICATION__ # new-feature | existing-feature-update | bug-fix | refactor | infrastructure | test-only | docs-only
|
|
11
|
+
status: draft
|
|
12
|
+
generatedAt: __DATE__
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Change — __SHORTCOMMIT__
|
|
16
|
+
|
|
17
|
+
## What Changed
|
|
18
|
+
|
|
19
|
+
TODO
|
|
20
|
+
|
|
21
|
+
## Files Changed
|
|
22
|
+
|
|
23
|
+
- TODO — `path/to/file.ts`
|
|
24
|
+
|
|
25
|
+
## Affected Features / Modules
|
|
26
|
+
|
|
27
|
+
- TODO — `feature-slug` (new / updated)
|
|
28
|
+
- TODO — `module-slug`
|
|
29
|
+
|
|
30
|
+
## Classification
|
|
31
|
+
|
|
32
|
+
- **Type**: __TYPE__
|
|
33
|
+
- **Bucket**: __CLASSIFICATION__
|
|
34
|
+
- **Confidence**: TODO
|
|
35
|
+
|
|
36
|
+
## Project-Goal Impact
|
|
37
|
+
|
|
38
|
+
TODO — which project-goal scenario does this advance, harm, or leave untouched?
|
|
39
|
+
|
|
40
|
+
## Evidence
|
|
41
|
+
|
|
42
|
+
- TODO — git diff path or commit hash
|
|
43
|
+
- TODO — quoted source line
|
|
44
|
+
|
|
45
|
+
## Apply Operations
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
operations:
|
|
49
|
+
# - op: create-file
|
|
50
|
+
# path: features/__SLUG__.md
|
|
51
|
+
# - op: update-file
|
|
52
|
+
# path: features/__SLUG__.md
|
|
53
|
+
# appendSection: Update History
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Reviewer Notes
|
|
57
|
+
|
|
58
|
+
- TODO — question 1
|
|
59
|
+
- TODO — risk 1
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
feature: <feature-slug>
|
|
3
|
+
project: <slug>
|
|
4
|
+
firstCommit: <hash> (<date>, <author>)
|
|
5
|
+
lastUpdate: <hash> (<date>, <author>)
|
|
6
|
+
status: active | deprecated | superseded
|
|
7
|
+
commitType: feat | fix | refactor | perf
|
|
8
|
+
relatedModule: [<模块名>](../modules/<module>.md)
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# <功能名>
|
|
12
|
+
|
|
13
|
+
> <一段话:这个功能做什么、解决什么问题>
|
|
14
|
+
|
|
15
|
+
## 概述
|
|
16
|
+
|
|
17
|
+
<详细描述:动机、设计决策、用户能感知到的变化>
|
|
18
|
+
|
|
19
|
+
## 初始实现
|
|
20
|
+
|
|
21
|
+
- **Commit**:`<hash>` (<date>, <author>): <subject>
|
|
22
|
+
- **涉及文件**:
|
|
23
|
+
- `path/to/file1`
|
|
24
|
+
- `path/to/file2`
|
|
25
|
+
- **关键代码**:
|
|
26
|
+
|
|
27
|
+
```<lang>
|
|
28
|
+
// 10-50 行
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- **业务影响**:<一段话,用户能感知到的变化>
|
|
32
|
+
|
|
33
|
+
## 后续更新记录(倒序)
|
|
34
|
+
|
|
35
|
+
### <YYYY-MM-DD> `<hash>`: <subject>
|
|
36
|
+
|
|
37
|
+
- **类型**:fix | refactor | perf
|
|
38
|
+
- **作者**:<author>
|
|
39
|
+
- **涉及文件**:`path/to/file`
|
|
40
|
+
- **变更说明**:<一段话>
|
|
41
|
+
- **业务影响**:<一段话>
|
|
42
|
+
|
|
43
|
+
### <YYYY-MM-DD> `<hash>`: <subject>
|
|
44
|
+
|
|
45
|
+
- **类型**:fix
|
|
46
|
+
- **变更说明**:<一段话>
|
|
47
|
+
|
|
48
|
+
## 关联模块
|
|
49
|
+
|
|
50
|
+
- [<模块名>](../modules/<module>.md)
|
|
51
|
+
- [框架说明](../framework.md)
|
|
52
|
+
|
|
53
|
+
## 关联 commit
|
|
54
|
+
|
|
55
|
+
- `<hash>` <subject>
|
|
56
|
+
- `<hash>` <subject>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: feature/v1
|
|
3
|
+
project: __PROJECT__
|
|
4
|
+
featureSlug: __SLUG__
|
|
5
|
+
status: active
|
|
6
|
+
firstCommit: null
|
|
7
|
+
lastUpdate: null
|
|
8
|
+
lastUpdatedAt: __DATE__
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Feature — __SLUG__
|
|
12
|
+
|
|
13
|
+
> Long-lived knowledge about a single user-visible feature. Created on the first commit that introduces it; updated by later commits.
|
|
14
|
+
|
|
15
|
+
## What the Feature Does
|
|
16
|
+
|
|
17
|
+
TODO
|
|
18
|
+
|
|
19
|
+
## Why It Exists
|
|
20
|
+
|
|
21
|
+
TODO — which project-goal scenario this feature supports.
|
|
22
|
+
|
|
23
|
+
## User / System Behavior
|
|
24
|
+
|
|
25
|
+
TODO
|
|
26
|
+
|
|
27
|
+
## Source Files and Modules Involved
|
|
28
|
+
|
|
29
|
+
- TODO — `path/to/file.ts` — role
|
|
30
|
+
- TODO — `path/to/module` — role
|
|
31
|
+
|
|
32
|
+
## Important Commits
|
|
33
|
+
|
|
34
|
+
- TODO — `abc1234` — first commit
|
|
35
|
+
- TODO — `def5678` — significant follow-up
|
|
36
|
+
|
|
37
|
+
## Known Limitations
|
|
38
|
+
|
|
39
|
+
- TODO
|
|
40
|
+
|
|
41
|
+
## Tests / Verification Points
|
|
42
|
+
|
|
43
|
+
- TODO — `tests/foo.test.ts` — verifies X
|
|
44
|
+
- TODO — manual: run Y, expect Z
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: <slug>
|
|
3
|
+
updatedAt: <YYYY-MM-DD>
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# <项目名> · 框架说明
|
|
7
|
+
|
|
8
|
+
## 1. 技术栈
|
|
9
|
+
|
|
10
|
+
| 维度 | 选型 | 版本 | 选择理由 |
|
|
11
|
+
|------|------|------|---------|
|
|
12
|
+
| 语言 | <...> | <...> | <...> |
|
|
13
|
+
| 框架 | <...> | <...> | <...> |
|
|
14
|
+
| 存储 | <...> | <...> | <...> |
|
|
15
|
+
| 构建 | <...> | <...> | <...> |
|
|
16
|
+
| 测试 | <...> | <...> | <...> |
|
|
17
|
+
| 部署 | <...> | <...> | <...> |
|
|
18
|
+
|
|
19
|
+
## 2. 顶层目录结构
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
<project>/
|
|
23
|
+
├── src/ # 主代码
|
|
24
|
+
├── tests/ # 测试
|
|
25
|
+
├── docs/ # 项目内文档
|
|
26
|
+
├── config/ # 配置文件
|
|
27
|
+
├── scripts/ # 工具脚本
|
|
28
|
+
├── package.json # 依赖清单
|
|
29
|
+
├── README.md # 项目说明
|
|
30
|
+
└── ...
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 3. 启动方式
|
|
34
|
+
|
|
35
|
+
### 开发模式
|
|
36
|
+
```bash
|
|
37
|
+
<...>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 构建
|
|
41
|
+
```bash
|
|
42
|
+
<...>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 测试
|
|
46
|
+
```bash
|
|
47
|
+
<...>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 4. 环境变量
|
|
51
|
+
|
|
52
|
+
| 变量名 | 必填 | 默认值 | 说明 |
|
|
53
|
+
|--------|------|--------|------|
|
|
54
|
+
| `<ENV_VAR>` | 是/否 | `<default>` | <...> |
|
|
55
|
+
|
|
56
|
+
## 5. 关键配置文件
|
|
57
|
+
|
|
58
|
+
| 文件 | 用途 |
|
|
59
|
+
|------|------|
|
|
60
|
+
| `<path>` | <...> |
|
|
61
|
+
|
|
62
|
+
## 6. 架构图
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
graph TD
|
|
66
|
+
A[用户] --> B[前端]
|
|
67
|
+
B --> C[后端]
|
|
68
|
+
C --> D[存储]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 7. 核心依赖
|
|
72
|
+
|
|
73
|
+
- `<package>@<version>` — 用途
|
|
74
|
+
- `<package>@<version>` — 用途
|
|
75
|
+
|
|
76
|
+
## 8. 变更历史
|
|
77
|
+
|
|
78
|
+
| 日期 | 变更 | 链接 |
|
|
79
|
+
|------|------|------|
|
|
80
|
+
| <YYYY-MM-DD> | <...> | [commits/...](./commits/...) |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "kb-manifest/v1",
|
|
3
|
+
"project": "__PROJECT__",
|
|
4
|
+
"kbRoot": "projects/__SLUG__",
|
|
5
|
+
"generatedAt": "__DATE__",
|
|
6
|
+
"goal": {
|
|
7
|
+
"path": "project-goal.md",
|
|
8
|
+
"status": "not-created",
|
|
9
|
+
"updatedAt": null
|
|
10
|
+
},
|
|
11
|
+
"analysis": {
|
|
12
|
+
"path": "project-analysis.md",
|
|
13
|
+
"lastAnalyzedCommit": null,
|
|
14
|
+
"updatedAt": null
|
|
15
|
+
},
|
|
16
|
+
"indexes": {
|
|
17
|
+
"features": "features/00-index.md",
|
|
18
|
+
"modules": "modules/00-index.md",
|
|
19
|
+
"changes": "changes/00-index.md",
|
|
20
|
+
"sourceMap": "references/source-map.md"
|
|
21
|
+
},
|
|
22
|
+
"trustedKnowledge": [
|
|
23
|
+
"README.md",
|
|
24
|
+
"framework.md",
|
|
25
|
+
"architecture/",
|
|
26
|
+
"modules/",
|
|
27
|
+
"features/",
|
|
28
|
+
"references/"
|
|
29
|
+
],
|
|
30
|
+
"draftAreas": [
|
|
31
|
+
"_ai/drafts/",
|
|
32
|
+
"_ai/runs/",
|
|
33
|
+
"_ai/context-packs/"
|
|
34
|
+
],
|
|
35
|
+
"backCompat": {
|
|
36
|
+
"commits": "commits/ is preserved for compatibility with the legacy commit-doc generator."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: <模块名>
|
|
3
|
+
category: module
|
|
4
|
+
project: <slug>
|
|
5
|
+
sourcePath: <源码路径,如 src/auth/oauth.ts>
|
|
6
|
+
createdAt: <YYYY-MM-DD>
|
|
7
|
+
updatedAt: <YYYY-MM-DD>
|
|
8
|
+
status: active | deprecated | planned
|
|
9
|
+
relations: [<其他模块的 slug>]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# <模块名>
|
|
13
|
+
|
|
14
|
+
> <一段话:这个模块做什么、解决什么问题>
|
|
15
|
+
|
|
16
|
+
## 源码位置
|
|
17
|
+
|
|
18
|
+
- 主文件:`<sourcePath>`
|
|
19
|
+
- 测试:`<testPath>`
|
|
20
|
+
- 配置文件:`<configPath>`
|
|
21
|
+
|
|
22
|
+
## 职责
|
|
23
|
+
|
|
24
|
+
1. <职责 1>
|
|
25
|
+
2. <职责 2>
|
|
26
|
+
3. <职责 3>
|
|
27
|
+
|
|
28
|
+
## 入口 / 出口
|
|
29
|
+
|
|
30
|
+
### 入口
|
|
31
|
+
|
|
32
|
+
- `<exported function/class name>`:<签名与用途>
|
|
33
|
+
- HTTP `<METHOD> <path>`:<用途>
|
|
34
|
+
|
|
35
|
+
### 出口
|
|
36
|
+
|
|
37
|
+
- 写入文件:`<path>`
|
|
38
|
+
- HTTP 请求:`<target>`
|
|
39
|
+
- 事件:`<eventName>`
|
|
40
|
+
|
|
41
|
+
## 依赖
|
|
42
|
+
|
|
43
|
+
- [<其他模块>](../modules/<other>.md) — 用途
|
|
44
|
+
- 外部包:`<package>`
|
|
45
|
+
|
|
46
|
+
## 关键代码片段
|
|
47
|
+
|
|
48
|
+
```<lang>
|
|
49
|
+
// 10-50 行的关键代码
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 最近一次重要变更
|
|
53
|
+
|
|
54
|
+
- <日期>:<简述> — 详见 [commits/...](../commits/00-index.md)
|
|
55
|
+
|
|
56
|
+
## 关联 commit / 功能文档
|
|
57
|
+
|
|
58
|
+
- [功能: <feature-slug>](../commits/<file>.md)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: project-analysis/v1
|
|
3
|
+
project: __PROJECT__
|
|
4
|
+
lastAnalyzedCommit: null
|
|
5
|
+
updatedAt: __DATE__
|
|
6
|
+
generatedBy: human-template
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Project Analysis — __PROJECT__
|
|
10
|
+
|
|
11
|
+
> AI-generated description of the current implementation. This is evidence, not intent. For intent see `project-goal.md`.
|
|
12
|
+
|
|
13
|
+
## AI-Inferred Project Purpose
|
|
14
|
+
|
|
15
|
+
TODO — generated by initial analysis.
|
|
16
|
+
|
|
17
|
+
## Current Implemented Capabilities
|
|
18
|
+
|
|
19
|
+
- TODO — capability 1
|
|
20
|
+
- TODO — capability 2
|
|
21
|
+
|
|
22
|
+
## Current Architecture
|
|
23
|
+
|
|
24
|
+
TODO — entry points, main modules, layering.
|
|
25
|
+
|
|
26
|
+
## Important Modules
|
|
27
|
+
|
|
28
|
+
- TODO — module 1: role
|
|
29
|
+
- TODO — module 2: role
|
|
30
|
+
|
|
31
|
+
## Data / Control Flow
|
|
32
|
+
|
|
33
|
+
TODO — high-level flow description.
|
|
34
|
+
|
|
35
|
+
## How Current Implementation Supports the Project Goal
|
|
36
|
+
|
|
37
|
+
TODO — link each implemented capability to a project-goal scenario.
|
|
38
|
+
|
|
39
|
+
## Gaps Between Implementation and Project Goal
|
|
40
|
+
|
|
41
|
+
- TODO — gap 1
|
|
42
|
+
- TODO — gap 2
|
|
43
|
+
|
|
44
|
+
## Evidence List
|
|
45
|
+
|
|
46
|
+
| File / Commit | Why it is cited |
|
|
47
|
+
|---------------|-----------------|
|
|
48
|
+
| (none yet) | (run initial analysis to populate) |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: project-goal/v1
|
|
3
|
+
project: __PROJECT__
|
|
4
|
+
status: draft
|
|
5
|
+
source: human-reviewed
|
|
6
|
+
updatedAt: __DATE__
|
|
7
|
+
lastReviewedBy: __AUTHOR__
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Project Goal — __PROJECT__
|
|
11
|
+
|
|
12
|
+
> Highest-priority human-controlled truth. AI may propose edits, but must not overwrite this file automatically.
|
|
13
|
+
|
|
14
|
+
## One-Sentence Goal
|
|
15
|
+
|
|
16
|
+
TODO — describe the project in a single sentence.
|
|
17
|
+
|
|
18
|
+
## Target Users
|
|
19
|
+
|
|
20
|
+
TODO — who benefits from this project and in what way.
|
|
21
|
+
|
|
22
|
+
## Core Scenarios
|
|
23
|
+
|
|
24
|
+
- TODO — scenario 1
|
|
25
|
+
- TODO — scenario 2
|
|
26
|
+
|
|
27
|
+
## Success Criteria
|
|
28
|
+
|
|
29
|
+
- TODO — measurable outcome 1
|
|
30
|
+
- TODO — measurable outcome 2
|
|
31
|
+
|
|
32
|
+
## Non-Goals
|
|
33
|
+
|
|
34
|
+
- TODO — out of scope 1
|
|
35
|
+
- TODO — out of scope 2
|
|
36
|
+
|
|
37
|
+
## Priority Principles
|
|
38
|
+
|
|
39
|
+
When requirements conflict, prefer:
|
|
40
|
+
|
|
41
|
+
1. TODO — first principle
|
|
42
|
+
2. TODO — second principle
|
|
43
|
+
|
|
44
|
+
## PR Review Principles
|
|
45
|
+
|
|
46
|
+
The future PR-review project will use this goal to evaluate incoming changes. List the rules it should enforce:
|
|
47
|
+
|
|
48
|
+
- TODO — rule 1
|
|
49
|
+
- TODO — rule 2
|
|
50
|
+
|
|
51
|
+
## Human Revision History
|
|
52
|
+
|
|
53
|
+
| Date | Reviewer | Change |
|
|
54
|
+
|------------|-----------|------------------------------------|
|
|
55
|
+
| __DATE__ | __AUTHOR__ | Initial draft (pending acceptance) |
|