ai-scaffold-pro 2.0.1 → 2.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-scaffold-pro",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "AI Coding Skeleton — CLI + LLM协作架构: CLI搭建骨架 → AI深度初始化",
5
5
  "bin": {
6
6
  "ai-scaffold-pro": "bin/cli.js"
@@ -27,6 +27,7 @@ description: Initialize AI coding assistance framework for this project. Scans s
27
27
 
28
28
  3. **确认CodeGraph状态**
29
29
  - 运行 `codegraph --version` (3秒超时)
30
+ - 如果未安装,执行 Phase 0.4 询问用户是否安装
30
31
  - 记录结果用于后续决策
31
32
 
32
33
  输出检测结果:
@@ -38,16 +39,96 @@ description: Initialize AI coding assistance framework for this project. Scans s
38
39
  - 初始化类型: [首次初始化/增量更新]
39
40
  ```
40
41
 
42
+ ## Phase 0.4: CodeGraph 安装提示(仅当未安装时执行)
43
+
44
+ 如果Phase 0.3检测到CodeGraph未安装,询问用户:
45
+
46
+ ```
47
+ ⚙️ 检测到 CodeGraph CLI 未安装
48
+
49
+ CodeGraph 是一个代码关系图工具,可为 AI 提供项目结构探索能力(类/方法/符号搜索)。
50
+ 安装后可减少约 90% 的 AI 工具调用,使 references/ 目录采用轻量模式。
51
+
52
+ 是否现在安装 CodeGraph?
53
+ 1. ✅ 是,安装并配置(推荐)
54
+ 2. ❌ 否,跳过(将使用完整模式)
55
+
56
+ 选择 1 → 执行 Phase 0.4.1 安装流程
57
+ 选择 2 → 设置 HAS_CODEGRAPH = false,references/ 采用完整模式
58
+ ```
59
+
60
+ ### Phase 0.4.1: CodeGraph 安装流程
61
+
62
+ 用户选择安装后,执行以下步骤:
63
+
64
+ ```
65
+ Step 1: 安装 CodeGraph CLI
66
+ 执行: npx @colbymchenry/codegraph
67
+
68
+ Step 2: 验证安装
69
+ 执行: codegraph --version
70
+ 成功 → HAS_CODEGRAPH = true
71
+ 失败 → 显示错误信息,询问用户是否继续(降级为完整模式)
72
+
73
+ Step 3: 初始化 CodeGraph(必须执行)
74
+ 说明: CodeGraph 必须在项目中建立索引才能使用
75
+ 执行: codegraph init
76
+ 等待初始化完成...
77
+
78
+ 如果初始化成功:
79
+ → CodeGraph 已就绪,使用轻量模式
80
+ → 继续后续流程
81
+
82
+ 如果初始化失败:
83
+ → 显示错误信息
84
+ → 询问用户: "CodeGraph 初始化失败,是否降级为完整模式?"
85
+ - 是 → HAS_CODEGRAPH = false,使用完整模式
86
+ - 否 → 中止初始化流程,让用户手动解决问题
87
+ ```
88
+
89
+ 安装成功后设置 `HAS_CODEGRAPH = true`,影响后续行为:
90
+ - `project_rule.md` §1 行为准则使用 CodeGraph 版本
91
+ - `{{ENTRY}}` 入口文件追加 CodeGraph 集成说明
92
+ - `gen_references.py` 使用 `--lightweight` 标志
93
+ - `references/` 采用轻量模式
94
+
95
+ 安装失败不阻塞流程,降级为完整模式继续。
96
+
41
97
  ## Phase 1: 项目深度分析
42
98
 
43
- ### 1.1 运行结构扫描器
99
+ ### 1.1 运行结构扫描器(带 CodeGraph 验证)
44
100
 
45
- 执行以下命令生成项目结构数据:
101
+ **关键步骤**: 在执行扫描前,必须验证 CodeGraph 是否真正可用
46
102
 
47
- ```bash
48
- python {{DIR}}/scripts/gen_references.py{{#if HAS_CODEGRAPH}} --lightweight{{/if}}
103
+ ```
104
+ 如果 HAS_CODEGRAPH = true:
105
+ Step A: 验证 CodeGraph 可用性
106
+ 执行: codegraph explore "test" --limit 1 2>/dev/null
107
+
108
+ 如果成功:
109
+ → CodeGraph 可用 ✅
110
+ 执行: python {{DIR}}/scripts/gen_references.py --lightweight
111
+
112
+ 如果失败:
113
+ → CodeGraph 不可用 ️
114
+ 自动降级: HAS_CODEGRAPH = false
115
+ 提示: "⚠️ CodeGraph 未正确初始化或不可用,已降级为完整模式"
116
+ 执行: python {{DIR}}/scripts/gen_references.py
117
+
118
+ 如果 HAS_CODEGRAPH = false:
119
+ 直接执行: python {{DIR}}/scripts/gen_references.py
49
120
  ```
50
121
 
122
+ **降级原因可能是**:
123
+ - 用户跳过了 `codegraph init`
124
+ - CodeGraph 索引损坏
125
+ - 项目结构发生变化需要重新索引
126
+
127
+ **降级后的行为**:
128
+ - `_scan.json` 将包含完整文件列表和目录树
129
+ - AI 可以通过文件列表直接定位源码
130
+ - 不影响初始化流程继续进行
131
+
51
132
  这将生成 `{{DIR}}/references/_scan.json`,包含:
52
133
  - 模块列表和依赖关系
53
134
  - 文件树结构(非轻量模式)
@@ -397,11 +478,29 @@ const platformVars = await getPlatformVars(detection.platform, lang);
397
478
 
398
479
  **Step 2**: AI逐模块生成文档
399
480
 
481
+ **重要**: 必须为 _scan.json 中的**所有模块**生成文档,不能遗漏!
482
+
400
483
  对于每个模块,执行:
401
484
  ```
402
485
  1. 读取 _scan.json 中该模块的结构信息
403
486
  2. 逐个读取该模块的源文件(限制每个模块最多10个关键文件)
404
487
  3. 基于源码理解生成 {module}.md
488
+ 4. 确认文件已保存到 {{DIR}}/references/{module}.md
489
+ ```
490
+
491
+ **模块列表获取**:
492
+ ```
493
+ const scanData = JSON.parse(readFile('{{DIR}}/references/_scan.json'));
494
+ const allModules = scanData.modules; // 获取所有模块
495
+
496
+ console.log(`📋 共发现 ${allModules.length} 个模块:`);
497
+ allModules.forEach((m, i) => console.log(` ${i+1}. ${m.name}`));
498
+
499
+ // 逐个生成
500
+ for (const module of allModules) {
501
+ console.log(`🔍 正在生成模块文档: ${module.name} (${i+1}/${allModules.length})`);
502
+ generateModuleDoc(module);
503
+ }
405
504
  ```
406
505
 
407
506
  **{module}.md 模板**:
@@ -590,8 +689,10 @@ Agent文件:
590
689
  - [ ] {{DIR}}/references/_scan.json 已生成
591
690
  - [ ] {{DIR}}/references/dependencies.md 已生成
592
691
  - [ ] {{DIR}}/references/conventions.md 已生成
593
- - [ ] 至少生成了 3 个核心模块的 {module}.md 文档
692
+ - [ ] **已为 _scan.json 中的所有模块生成文档**(不是只生成3个!)
693
+ - [ ] 验证: {{DIR}}/references/ 目录下的 {module}.md 文件数量 = _scan.json 中的 modules 数量
594
694
  - [ ] 所有模块文档中的"模块概述"不为空
695
+ - [ ] 所有模块文档中的"元信息"表格完整填写
595
696
 
596
697
  入口文件:
597
698
  - [ ] {{ENTRY}} 已从极简版替换为完整版