@mycodemap/mycodemap 0.5.2-beta.1 → 1.9.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 +14 -0
- package/README.md +84 -10
- package/dist/cli/commands/init.d.ts +7 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +22 -34
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/publish-status.d.ts +31 -0
- package/dist/cli/commands/publish-status.d.ts.map +1 -0
- package/dist/cli/commands/publish-status.js +101 -0
- package/dist/cli/commands/publish-status.js.map +1 -0
- package/dist/cli/commands/readiness-gate.d.ts +25 -0
- package/dist/cli/commands/readiness-gate.d.ts.map +1 -0
- package/dist/cli/commands/readiness-gate.js +197 -0
- package/dist/cli/commands/readiness-gate.js.map +1 -0
- package/dist/cli/commands/ship/checker.d.ts +4 -9
- package/dist/cli/commands/ship/checker.d.ts.map +1 -1
- package/dist/cli/commands/ship/checker.js +60 -22
- package/dist/cli/commands/ship/checker.js.map +1 -1
- package/dist/cli/commands/ship/monitor.d.ts +6 -1
- package/dist/cli/commands/ship/monitor.d.ts.map +1 -1
- package/dist/cli/commands/ship/monitor.js +223 -46
- package/dist/cli/commands/ship/monitor.js.map +1 -1
- package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
- package/dist/cli/commands/ship/pipeline.js +14 -5
- package/dist/cli/commands/ship/pipeline.js.map +1 -1
- package/dist/cli/commands/ship/rules/quality-rules.d.ts +12 -8
- package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -1
- package/dist/cli/commands/ship/rules/quality-rules.js +49 -34
- package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -1
- package/dist/cli/config-loader.js +1 -1
- package/dist/cli/config-loader.js.map +1 -1
- package/dist/cli/first-run-guide.d.ts.map +1 -1
- package/dist/cli/first-run-guide.js +10 -12
- package/dist/cli/first-run-guide.js.map +1 -1
- package/dist/cli/index.js +8 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/hooks.d.ts +17 -0
- package/dist/cli/init/hooks.d.ts.map +1 -0
- package/dist/cli/init/hooks.js +220 -0
- package/dist/cli/init/hooks.js.map +1 -0
- package/dist/cli/init/receipt.d.ts +4 -0
- package/dist/cli/init/receipt.d.ts.map +1 -0
- package/dist/cli/init/receipt.js +117 -0
- package/dist/cli/init/receipt.js.map +1 -0
- package/dist/cli/init/reconciler.d.ts +44 -0
- package/dist/cli/init/reconciler.d.ts.map +1 -0
- package/dist/cli/init/reconciler.js +377 -0
- package/dist/cli/init/reconciler.js.map +1 -0
- package/dist/cli/init/rule-templates.d.ts +9 -0
- package/dist/cli/init/rule-templates.d.ts.map +1 -0
- package/dist/cli/init/rule-templates.js +105 -0
- package/dist/cli/init/rule-templates.js.map +1 -0
- package/dist/cli/init/rules.d.ts +13 -0
- package/dist/cli/init/rules.d.ts.map +1 -0
- package/dist/cli/init/rules.js +113 -0
- package/dist/cli/init/rules.js.map +1 -0
- package/dist/cli/paths.d.ts +4 -2
- package/dist/cli/paths.d.ts.map +1 -1
- package/dist/cli/paths.js +13 -5
- package/dist/cli/paths.js.map +1 -1
- package/dist/orchestrator/test-linker.d.ts.map +1 -1
- package/dist/orchestrator/test-linker.js +5 -36
- package/dist/orchestrator/test-linker.js.map +1 -1
- package/docs/AI_ASSISTANT_SETUP.md +4 -2
- package/docs/SETUP_GUIDE.md +12 -12
- package/docs/agents/domain.md +36 -0
- package/docs/agents/issue-tracker.md +22 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/ai-guide/COMMANDS.md +57 -3
- package/docs/ai-guide/INTEGRATION.md +1 -1
- package/docs/ai-guide/PATTERNS.md +3 -3
- package/docs/ai-guide/QUICKSTART.md +13 -4
- package/docs/ai-guide/README.md +7 -7
- package/docs/archive/ideation/2026-04-22-harness-rules-entry-docs-optimization-ideation.md +102 -0
- package/docs/archive/ideation/2026-04-22-rules-claude-agents-optimization-ideation.md +107 -0
- package/docs/brainstorms/2026-04-22-rules-entry-docs-phase1-structure-consolidation-requirements.md +110 -0
- package/docs/brainstorms/999.1-mycodemap-init-enhancements-requirements.md +166 -0
- package/docs/exec-plans/README.md +3 -0
- package/docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md +96 -0
- package/docs/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation.md +119 -0
- package/docs/lesson-learn/2026-04-19-prerelease-trusted-publishing-fix.md +119 -0
- package/docs/lesson-learn/image.png +0 -0
- package/docs/rules/README.md +4 -1
- package/docs/rules/deployment.md +7 -0
- package/docs/rules/engineering-with-codex-openai.md +47 -8
- package/docs/rules/pre-release-checklist.md +44 -33
- package/docs/rules/release.md +303 -0
- package/docs/rules/testing.md +19 -0
- package/docs/rules/validation.md +16 -7
- package/mycodemap.config.schema.json +1 -1
- package/package.json +3 -3
- package/scripts/hooks/templates/commit-msg +38 -0
- package/scripts/hooks/templates/pre-commit +224 -0
- package/scripts/pre-release-check.js +4 -4
- package/scripts/release.sh +1 -1
- package/scripts/validate-docs.js +283 -14
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Pre-commit hook: 运行测试和文件头检查
|
|
3
|
+
|
|
4
|
+
echo "Running pre-commit checks..."
|
|
5
|
+
|
|
6
|
+
# 1. 运行与变更相关的测试(失败即阻断)
|
|
7
|
+
echo "Running tests for changed files..."
|
|
8
|
+
if [ -f "node_modules/vitest/vitest.mjs" ]; then
|
|
9
|
+
node node_modules/vitest/vitest.mjs run --changed
|
|
10
|
+
else
|
|
11
|
+
if [ ! -e "node_modules/vitest" ]; then
|
|
12
|
+
VITEST_PACKAGE_DIR=$(find node_modules -type d -path '*/.pnpm/*/node_modules/vitest' | head -n 1)
|
|
13
|
+
if [ -n "$VITEST_PACKAGE_DIR" ]; then
|
|
14
|
+
ln -sfn "${VITEST_PACKAGE_DIR#node_modules/}" node_modules/vitest
|
|
15
|
+
fi
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if [ -f "node_modules/vitest/vitest.mjs" ]; then
|
|
19
|
+
node node_modules/vitest/vitest.mjs run --changed
|
|
20
|
+
else
|
|
21
|
+
VITEST_ENTRY=$(find node_modules -type f -path '*/.pnpm/*/node_modules/vitest/vitest.mjs' | head -n 1)
|
|
22
|
+
if [ -z "$VITEST_ENTRY" ]; then
|
|
23
|
+
VITEST_ENTRY=$(find node_modules -type f -path '*/.vitest-*/vitest.mjs' | head -n 1)
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
if [ -n "$VITEST_ENTRY" ]; then
|
|
27
|
+
node "$VITEST_ENTRY" run --changed
|
|
28
|
+
else
|
|
29
|
+
npx --yes vitest run --changed
|
|
30
|
+
fi
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
if [ $? -ne 0 ]; then
|
|
34
|
+
echo "ERROR: Tests failed, commit rejected"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
echo "Tests passed"
|
|
39
|
+
|
|
40
|
+
# 2. repo-local 规则校验(按 hard_gate.mode 决定 report-only / enforce)
|
|
41
|
+
RULE_CONFIG_PATH=".claude/rule-system.config.json"
|
|
42
|
+
RULE_HARD_GATE_MODE="report-only"
|
|
43
|
+
|
|
44
|
+
if [ -f "$RULE_CONFIG_PATH" ]; then
|
|
45
|
+
RULE_HARD_GATE_MODE=$(python3 - <<'PY'
|
|
46
|
+
import json
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
|
|
49
|
+
config_path = Path(".claude/rule-system.config.json")
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
config = json.loads(config_path.read_text(encoding="utf-8"))
|
|
53
|
+
except Exception:
|
|
54
|
+
print("report-only")
|
|
55
|
+
else:
|
|
56
|
+
print(config.get("hard_gate", {}).get("mode", "report-only"))
|
|
57
|
+
PY
|
|
58
|
+
)
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
echo "Running repo-local rule validation (mode: $RULE_HARD_GATE_MODE)..."
|
|
62
|
+
case "$RULE_HARD_GATE_MODE" in
|
|
63
|
+
enforce)
|
|
64
|
+
python3 scripts/validate-rules.py code
|
|
65
|
+
VALIDATE_EXIT=$?
|
|
66
|
+
case "$VALIDATE_EXIT" in
|
|
67
|
+
0)
|
|
68
|
+
echo "Rule validation passed"
|
|
69
|
+
;;
|
|
70
|
+
1)
|
|
71
|
+
echo "ERROR: Rule validation found blocking P0 failures, commit rejected"
|
|
72
|
+
exit 1
|
|
73
|
+
;;
|
|
74
|
+
2)
|
|
75
|
+
echo "WARNING: Rule validation reported warn-only P1 findings, continuing commit"
|
|
76
|
+
;;
|
|
77
|
+
3)
|
|
78
|
+
echo "WARNING: Rule validation reported notice-only P2 findings, continuing commit"
|
|
79
|
+
;;
|
|
80
|
+
4)
|
|
81
|
+
echo "ERROR: Rule validation dependencies unavailable, commit rejected"
|
|
82
|
+
exit 1
|
|
83
|
+
;;
|
|
84
|
+
*)
|
|
85
|
+
echo "ERROR: Rule validation returned unexpected exit code ($VALIDATE_EXIT), commit rejected"
|
|
86
|
+
exit 1
|
|
87
|
+
;;
|
|
88
|
+
esac
|
|
89
|
+
;;
|
|
90
|
+
report-only|*)
|
|
91
|
+
if [ "$RULE_HARD_GATE_MODE" != "report-only" ]; then
|
|
92
|
+
echo "WARNING: Unknown hard gate mode '$RULE_HARD_GATE_MODE', defaulting to report-only"
|
|
93
|
+
fi
|
|
94
|
+
python3 scripts/validate-rules.py code --report-only >/dev/null
|
|
95
|
+
VALIDATE_EXIT=$?
|
|
96
|
+
if [ "$VALIDATE_EXIT" -ne 0 ]; then
|
|
97
|
+
echo "WARNING: Rule validation report-only command exited with $VALIDATE_EXIT, continuing commit"
|
|
98
|
+
else
|
|
99
|
+
echo "Rule validation report-only completed"
|
|
100
|
+
fi
|
|
101
|
+
;;
|
|
102
|
+
esac
|
|
103
|
+
|
|
104
|
+
# 3. 检查 staged 文件数量(初始化 commit 除外)
|
|
105
|
+
MAX_FILES_PER_COMMIT=10
|
|
106
|
+
MAX_FILES_WITH_DOCS=20
|
|
107
|
+
|
|
108
|
+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
|
|
109
|
+
STAGED_FILE_COUNT=$(echo "$STAGED_FILES" | grep -c '^' || echo 0)
|
|
110
|
+
|
|
111
|
+
ONLY_DOT_DIRS=true
|
|
112
|
+
if [ -n "$STAGED_FILES" ]; then
|
|
113
|
+
NON_DOT_FILES=$(echo "$STAGED_FILES" | grep -v '^\.' || true)
|
|
114
|
+
if [ -n "$NON_DOT_FILES" ]; then
|
|
115
|
+
ONLY_DOT_DIRS=false
|
|
116
|
+
fi
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
IS_INITIAL_COMMIT=false
|
|
120
|
+
git rev-parse --verify HEAD >/dev/null 2>&1
|
|
121
|
+
if [ $? -ne 0 ]; then
|
|
122
|
+
IS_INITIAL_COMMIT=true
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
CONTAINS_DOC_FILES=false
|
|
126
|
+
if [ -n "$STAGED_FILES" ]; then
|
|
127
|
+
DOC_FILES=$(echo "$STAGED_FILES" | grep -E '(\.md$|^docs/|^README|^CHANGELOG|^LICENSE)' || true)
|
|
128
|
+
if [ -n "$DOC_FILES" ]; then
|
|
129
|
+
CONTAINS_DOC_FILES=true
|
|
130
|
+
fi
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
if [ "$CONTAINS_DOC_FILES" = "true" ]; then
|
|
134
|
+
CURRENT_LIMIT=$MAX_FILES_WITH_DOCS
|
|
135
|
+
else
|
|
136
|
+
CURRENT_LIMIT=$MAX_FILES_PER_COMMIT
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
if [ "$ONLY_DOT_DIRS" = "true" ]; then
|
|
140
|
+
echo "Note: Only dot-directory files staged, skipping count limit check"
|
|
141
|
+
elif [ "$STAGED_FILE_COUNT" -gt "$CURRENT_LIMIT" ] && [ "$IS_INITIAL_COMMIT" = "false" ]; then
|
|
142
|
+
echo ""
|
|
143
|
+
echo "WARNING: Staged files count ($STAGED_FILE_COUNT) exceeds limit ($CURRENT_LIMIT)"
|
|
144
|
+
echo ""
|
|
145
|
+
if [ "$CONTAINS_DOC_FILES" = "true" ]; then
|
|
146
|
+
echo "Note: This commit contains documentation files, so the limit is increased to $MAX_FILES_WITH_DOCS."
|
|
147
|
+
else
|
|
148
|
+
echo "Single commit should not contain more than $MAX_FILES_PER_COMMIT files."
|
|
149
|
+
fi
|
|
150
|
+
echo "Please consider splitting your changes into smaller, focused commits."
|
|
151
|
+
echo ""
|
|
152
|
+
echo "If you have a very good reason for this large commit, you can bypass"
|
|
153
|
+
echo "this warning with: git commit --no-verify"
|
|
154
|
+
echo ""
|
|
155
|
+
echo "Staged files:"
|
|
156
|
+
git diff --cached --name-only --diff-filter=ACM
|
|
157
|
+
echo ""
|
|
158
|
+
exit 1
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# 4. 检查文件头注释(只检查 staged 的 TS 源文件,豁免 . 开头目录)
|
|
162
|
+
echo "Checking file headers..."
|
|
163
|
+
if [ "$ONLY_DOT_DIRS" = "true" ]; then
|
|
164
|
+
echo "Note: Only dot-directory files staged, skipping header check"
|
|
165
|
+
STAGED_TS_FILES=""
|
|
166
|
+
else
|
|
167
|
+
STAGED_TS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.ts$' | grep -v '\.test\.ts$' | grep -v '\.d\.ts$')
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
if [ -n "$STAGED_TS_FILES" ]; then
|
|
171
|
+
MISSING_HEADERS=0
|
|
172
|
+
|
|
173
|
+
for file in $STAGED_TS_FILES; do
|
|
174
|
+
if [ ! -f "$file" ]; then
|
|
175
|
+
continue
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
HEAD_CONTENT=$(head -10 "$file")
|
|
179
|
+
|
|
180
|
+
if ! echo "$HEAD_CONTENT" | grep -q '\[META\]'; then
|
|
181
|
+
echo "ERROR: $file missing [META] comment"
|
|
182
|
+
MISSING_HEADERS=$((MISSING_HEADERS + 1))
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
if ! echo "$HEAD_CONTENT" | grep -q '\[WHY\]'; then
|
|
186
|
+
echo "ERROR: $file missing [WHY] comment"
|
|
187
|
+
MISSING_HEADERS=$((MISSING_HEADERS + 1))
|
|
188
|
+
fi
|
|
189
|
+
done
|
|
190
|
+
|
|
191
|
+
if [ $MISSING_HEADERS -gt 0 ]; then
|
|
192
|
+
echo ""
|
|
193
|
+
echo "Add header comments at file top:"
|
|
194
|
+
echo "// [META] since:YYYY-MM | owner:team | stable:false"
|
|
195
|
+
echo "// [WHY] Explain why this file exists"
|
|
196
|
+
exit 1
|
|
197
|
+
fi
|
|
198
|
+
fi
|
|
199
|
+
|
|
200
|
+
echo "File headers passed"
|
|
201
|
+
|
|
202
|
+
# 5. 检查文档与 CLI 护栏(仅在相关文件变更时阻断)
|
|
203
|
+
DOC_GUARDRAIL_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^(README\.md|package\.json|docs/|src/cli/index\.ts|vitest\.config\.ts|vitest\.benchmark\.config\.ts|\.github/workflows/ci-gateway\.yml)$' || true)
|
|
204
|
+
|
|
205
|
+
if [ -n "$DOC_GUARDRAIL_FILES" ]; then
|
|
206
|
+
echo "Checking documentation guardrails..."
|
|
207
|
+
npm run docs:check
|
|
208
|
+
if [ $? -ne 0 ]; then
|
|
209
|
+
echo "ERROR: Documentation guardrails failed, commit rejected"
|
|
210
|
+
exit 1
|
|
211
|
+
fi
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
echo "Documentation guardrails passed"
|
|
215
|
+
|
|
216
|
+
# 6. 生成 AI 饲料(警告级,不阻断)
|
|
217
|
+
echo "Generating AI feed..."
|
|
218
|
+
npx mycodemap generate --quiet >/dev/null 2>&1 &
|
|
219
|
+
if [ $? -ne 0 ]; then
|
|
220
|
+
echo "WARNING: Failed to start AI feed generation"
|
|
221
|
+
fi
|
|
222
|
+
|
|
223
|
+
echo "Pre-commit checks passed"
|
|
224
|
+
exit 0
|
|
@@ -710,10 +710,10 @@ async function runPreReleaseChecks() {
|
|
|
710
710
|
const pkgVersion = JSON.parse(pkg).version;
|
|
711
711
|
console.log(`\n当前版本: v${pkgVersion}`);
|
|
712
712
|
console.log('\n📋 发布步骤:');
|
|
713
|
-
console.log(' 1.
|
|
714
|
-
console.log(' 2. ./scripts/release.sh
|
|
715
|
-
console.log(' 3.
|
|
716
|
-
console.log(' 4.
|
|
713
|
+
console.log(' 1. /release vX.Y # 统一入口:readiness → closeout → 双确认门');
|
|
714
|
+
console.log(' 2. Gate #2 通过后委托 ./scripts/release.sh X.Y.0 # 机械 helper');
|
|
715
|
+
console.log(' 3. 推送 tag 后由 .github/workflows/publish.yml 自动: 构建 → 测试 → 发布 → 创建 Release');
|
|
716
|
+
console.log(' 4. 若不是 milestone-bound release,才使用人工受控的例外流程');
|
|
717
717
|
console.log('\n🔗 相关链接:');
|
|
718
718
|
console.log(` - GitHub Actions: https://github.com/mycodemap/mycodemap/actions`);
|
|
719
719
|
console.log(` - NPM 包: https://www.npmjs.com/package/@mycodemap/mycodemap`);
|
package/scripts/release.sh
CHANGED
|
@@ -109,7 +109,7 @@ echo ""
|
|
|
109
109
|
# 步骤 2: 提交版本更新
|
|
110
110
|
echo -e "${BLUE}2/5 提交版本更新...${NC}"
|
|
111
111
|
git add package.json package-lock.json
|
|
112
|
-
git commit -m "[
|
|
112
|
+
git commit -m "[CONFIG] version: bump to v$NEW_VERSION"
|
|
113
113
|
echo -e "${GREEN} ✅ 已提交版本更新${NC}"
|
|
114
114
|
echo ""
|
|
115
115
|
|