@hupan56/wlkj 2.6.0 → 2.7.1

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.
Files changed (125) hide show
  1. package/bin/cli.js +269 -11
  2. package/package.json +1 -1
  3. package/templates/qoder/agents/insight-planning.md +67 -0
  4. package/templates/qoder/agents/insight-research.md +61 -0
  5. package/templates/qoder/agents/prd-reference.md +8 -2
  6. package/templates/qoder/commands/optional/wl-insight.md +275 -0
  7. package/templates/qoder/commands/{wl-report.md → optional/wl-report.md} +13 -5
  8. package/templates/qoder/commands/{wl-spec.md → optional/wl-spec.md} +1 -1
  9. package/templates/qoder/commands/{wl-status.md → optional/wl-status.md} +28 -2
  10. package/templates/qoder/commands/wl-code.md +10 -2
  11. package/templates/qoder/commands/wl-commit.md +1 -1
  12. package/templates/qoder/commands/wl-design-draw.md +78 -0
  13. package/templates/qoder/commands/wl-design-scan.md +108 -0
  14. package/templates/qoder/commands/wl-design-spec.md +154 -0
  15. package/templates/qoder/commands/wl-design.md +32 -0
  16. package/templates/qoder/commands/wl-init.md +24 -3
  17. package/templates/qoder/commands/wl-prd-full.md +226 -0
  18. package/templates/qoder/commands/wl-prd-quick.md +134 -0
  19. package/templates/qoder/commands/wl-prd-review.md +104 -0
  20. package/templates/qoder/commands/wl-prd.md +17 -311
  21. package/templates/qoder/commands/wl-search.md +66 -30
  22. package/templates/qoder/commands/wl-task.md +290 -59
  23. package/templates/qoder/commands/wl-test.md +92 -24
  24. package/templates/qoder/config.yaml +51 -15
  25. package/templates/qoder/hooks/inject-workflow-state.py +2 -2
  26. package/templates/qoder/hooks/session-start.py +82 -51
  27. package/templates/qoder/rules/wl-pipeline.md +216 -105
  28. package/templates/qoder/scripts/__pycache__/search_index.cpython-39.pyc +0 -0
  29. package/templates/qoder/scripts/archive_prd.py +377 -0
  30. package/templates/qoder/scripts/autotest.py +1715 -0
  31. package/templates/qoder/scripts/autotest_batch.py +224 -0
  32. package/templates/qoder/scripts/autotest_run.py +297 -0
  33. package/templates/qoder/scripts/benchmark.py +210 -209
  34. package/templates/qoder/scripts/build_style_index.py +444 -4
  35. package/templates/qoder/scripts/check_carriers.py +238 -0
  36. package/templates/qoder/scripts/check_mcp.py +298 -0
  37. package/templates/qoder/scripts/check_qoderwork_consistency.py +166 -0
  38. package/templates/qoder/scripts/common/events.py +46 -0
  39. package/templates/qoder/scripts/common/extract.py +419 -0
  40. package/templates/qoder/scripts/common/graph_traverse.py +533 -0
  41. package/templates/qoder/scripts/common/paths.py +89 -0
  42. package/templates/qoder/scripts/common/pip_install.py +144 -0
  43. package/templates/qoder/scripts/common/platform_guard.py +61 -0
  44. package/templates/qoder/scripts/common/search_engine.py +205 -205
  45. package/templates/qoder/scripts/common/terms.py +57 -0
  46. package/templates/qoder/scripts/common/ts_extract.py +536 -0
  47. package/templates/qoder/scripts/context_pack.py +73 -13
  48. package/templates/qoder/scripts/enrich_prompt.py +226 -0
  49. package/templates/qoder/scripts/eval_prd.py +318 -231
  50. package/templates/qoder/scripts/export.py +487 -487
  51. package/templates/qoder/scripts/extract_api_params.py +246 -0
  52. package/templates/qoder/scripts/extract_routes.py +54 -0
  53. package/templates/qoder/scripts/extract_routes_tree.py +78 -0
  54. package/templates/qoder/scripts/fill_prototype.py +707 -0
  55. package/templates/qoder/scripts/gen_design_doc.py +394 -0
  56. package/templates/qoder/scripts/git_sync.py +27 -15
  57. package/templates/qoder/scripts/init_doctor.py +292 -40
  58. package/templates/qoder/scripts/install_qoderwork.py +366 -9
  59. package/templates/qoder/scripts/kg.py +708 -0
  60. package/templates/qoder/scripts/kg_auto_login.py +196 -0
  61. package/templates/qoder/scripts/kg_build.py +612 -0
  62. package/templates/qoder/scripts/kg_build_db.py +327 -0
  63. package/templates/qoder/scripts/kg_duckdb.py +549 -0
  64. package/templates/qoder/scripts/kg_incremental.py +393 -0
  65. package/templates/qoder/scripts/kg_link_db.py +224 -0
  66. package/templates/qoder/scripts/kg_mcp_server.py +801 -0
  67. package/templates/qoder/scripts/kg_semantic.py +150 -0
  68. package/templates/qoder/scripts/kg_test_runner.py +241 -0
  69. package/templates/qoder/scripts/lanhu_stdio_wrapper.py +119 -0
  70. package/templates/qoder/scripts/learn.py +118 -39
  71. package/templates/qoder/scripts/learn_aggregate.py +201 -0
  72. package/templates/qoder/scripts/mcp_launcher.py +359 -0
  73. package/templates/qoder/scripts/mysql_mcp_server.py +396 -0
  74. package/templates/qoder/scripts/repo_root.py +106 -0
  75. package/templates/qoder/scripts/role.py +12 -0
  76. package/templates/qoder/scripts/run_weekly_update.bat +5 -0
  77. package/templates/qoder/scripts/run_weekly_update.sh +5 -0
  78. package/templates/qoder/scripts/search_index.py +307 -60
  79. package/templates/qoder/scripts/secure-ls.js +5640 -0
  80. package/templates/qoder/scripts/setup.py +706 -641
  81. package/templates/qoder/scripts/setup_lanhu.py +963 -0
  82. package/templates/qoder/scripts/status.py +250 -11
  83. package/templates/qoder/scripts/sync_carriers.py +259 -0
  84. package/templates/qoder/scripts/syncgate.py +2 -2
  85. package/templates/qoder/scripts/task.py +75 -0
  86. package/templates/qoder/scripts/team_sync.py +60 -4
  87. package/templates/qoder/scripts/workspace_init.py +1 -1
  88. package/templates/qoder/skills/design-import/SKILL.md +226 -0
  89. package/templates/qoder/skills/design-import/figma-workflow.md +81 -0
  90. package/templates/qoder/skills/design-review/SKILL.md +82 -25
  91. package/templates/qoder/skills/prd-generator/SKILL.md +184 -60
  92. package/templates/qoder/skills/prd-review/SKILL.md +18 -1
  93. package/templates/qoder/skills/prompt-enrich/SKILL.md +90 -0
  94. package/templates/qoder/skills/prototype-generator/SKILL.md +256 -141
  95. package/templates/qoder/skills/prototype-generator/SKILL.md.zcode-79180-2af4721f-f9a6-412c-88db-c0af680d211b.tmp +0 -0
  96. package/templates/qoder/skills/spec-coder/SKILL.md +18 -1
  97. package/templates/qoder/skills/spec-generator/SKILL.md +18 -1
  98. package/templates/qoder/skills/test-generator/SKILL.md +15 -2
  99. package/templates/qoder/skills/wl-code/SKILL.md +55 -36
  100. package/templates/qoder/skills/wl-commit/SKILL.md +89 -76
  101. package/templates/qoder/skills/wl-design/SKILL.md +55 -0
  102. package/templates/qoder/skills/wl-init/SKILL.md +76 -67
  103. package/templates/qoder/skills/wl-insight/SKILL.md +201 -81
  104. package/templates/qoder/skills/wl-prd-full/SKILL.md +69 -0
  105. package/templates/qoder/skills/wl-prd-quick/SKILL.md +49 -0
  106. package/templates/qoder/skills/wl-prd-review/SKILL.md +34 -0
  107. package/templates/qoder/skills/wl-report/SKILL.md +131 -107
  108. package/templates/qoder/skills/wl-search/SKILL.md +141 -75
  109. package/templates/qoder/skills/wl-spec/SKILL.md +49 -39
  110. package/templates/qoder/skills/wl-status/SKILL.md +83 -61
  111. package/templates/qoder/skills/wl-task/SKILL.md +132 -58
  112. package/templates/qoder/skills/wl-test/SKILL.md +406 -40
  113. package/templates/qoder/templates/prototype-app.html +13 -8
  114. package/templates/qoder/templates/prototype-web.html +376 -93
  115. package/templates/root/AGENTS.md +89 -34
  116. package/templates/root/requirements.txt +21 -0
  117. package/templates/root//344/275/277/347/224/250/350/257/264/346/230/216.md +259 -259
  118. package/templates/root//346/226/260/346/211/213/346/214/207/345/215/227.md +186 -186
  119. package/templates/qoder/agents/prd-planning.md +0 -57
  120. package/templates/qoder/agents/prd-research.md +0 -34
  121. package/templates/qoder/commands/wl-insight.md +0 -51
  122. package/templates/qoder/scripts/__pycache__/init_doctor.cpython-39.pyc +0 -0
  123. package/templates/qoder/scripts/__pycache__/setup.cpython-39.pyc +0 -0
  124. package/templates/qoder/scripts/common/__pycache__/developer.cpython-39.pyc +0 -0
  125. package/templates/qoder/skills/wl-prd/SKILL.md +0 -92
@@ -65,7 +65,7 @@ def _recent_hook_errors(hours=24, limit=3):
65
65
  # Injected as REAL OUTPUT below (a comment here would never reach the AI)
66
66
  CRITICAL_RULE = NL.join([
67
67
  '## CRITICAL RULE',
68
- 'When user asks for /wl-prd, ALWAYS ask platform FIRST:',
68
+ 'When user asks for /wl-prd-full, ALWAYS ask platform FIRST:',
69
69
  '"这个需求是针对哪个平台?',
70
70
  ' 1. Web 管理端 (fywl-ui) - Ant Design Vue + VxeGrid 风格',
71
71
  ' 2. APP 移动端 (Carmg-H5) - Vant 风格',
@@ -142,63 +142,94 @@ def get_index_info():
142
142
  except OSError:
143
143
  pass
144
144
 
145
- lines.append('## Knowledge Index')
146
- lines.append('Use search script (DO NOT read large JSON files directly):')
145
+ lines.append('## Knowledge Graph')
146
+ lines.append('MCP工具 (QoderWork自动调用): search_code / get_impact / coverage_matrix / get_workflow 等11个')
147
147
  lines.append(' python .qoder/scripts/search_index.py <keyword> [--platform web|app]')
148
- lines.append(' python .qoder/scripts/search_index.py --prd <keyword> # search PRDs')
149
- lines.append(' python .qoder/scripts/search_index.py --style <table|form> [--platform p]')
150
- lines.append(' python .qoder/scripts/search_index.py --field <name> # field usage')
151
- lines.append(' python .qoder/scripts/search_index.py --api <keyword> # API endpoints')
152
- lines.append(' python .qoder/scripts/search_index.py --components # UI components')
153
- lines.append(' python .qoder/scripts/search_index.py --modules # project overview')
154
- lines.append(' python .qoder/scripts/search_index.py --list # top keywords')
155
-
156
- meta = load_json_safe(os.path.join(BASE, 'data', 'index', '.index-meta.json'))
157
- if meta:
158
- projects = meta.get('projects', {})
159
- if isinstance(projects, dict):
160
- for proj, info in projects.items():
161
- if isinstance(info, dict):
162
- files = info.get('files', 0)
163
- else:
164
- files = info # new meta format: {project: file_count}
165
- lines.append(' ' + str(proj) + ': ' + str(files) + ' files')
166
- elif isinstance(projects, list):
167
- for proj in projects:
168
- lines.append(' ' + str(proj))
169
- lines.append('Last sync: ' + str(meta.get('last_sync', 'unknown')))
170
- # Staleness warning (审计发现: cron 从未注册, 索引可能静默过期)
171
- last_sync = meta.get('last_sync')
172
- if last_sync:
173
- try:
174
- from datetime import datetime
175
- # 兼容多种格式: "2026-06-12 16:49" / ISO
176
- ts = str(last_sync).replace('T', ' ').split('.')[0].strip()
177
- for fmt in ('%Y-%m-%d %H:%M', '%Y-%m-%d %H:%M:%S', '%Y-%m-%dT%H:%M:%S'):
178
- try:
179
- sync_dt = datetime.strptime(ts, fmt)
180
- break
181
- except ValueError:
182
- continue
183
- else:
184
- sync_dt = None
185
- if sync_dt:
186
- age_days = (datetime.now() - sync_dt).days
187
- if age_days > 30:
188
- lines.append('[CRITICAL] 索引已 {} 天未更新! 搜索结果严重过期. 跑: python .qoder/scripts/git_sync.py'.format(age_days))
189
- elif age_days > 7:
190
- lines.append('[WARN] 索引已 {} 天未更新, 建议刷新: python .qoder/scripts/git_sync.py'.format(age_days))
191
- except Exception:
192
- pass # 日期解析失败不阻塞
193
- if meta.get('failures'):
194
- lines.append('WARNING: last sync had errors - see data/index/.index-meta.json')
148
+ lines.append(' python .qoder/scripts/context_pack.py <keyword> # 一次打包全部上下文')
149
+
150
+ # DuckDB 知识图谱状态检查
151
+ # Read role from .developer file
152
+ role = 'pm'
153
+ try:
154
+ dev_file = os.path.join(BASE, '.qoder', '.developer')
155
+ if os.path.isfile(dev_file):
156
+ for _line in open(dev_file, encoding='utf-8'):
157
+ if _line.strip().startswith('role='):
158
+ role = _line.split('=', 1)[1].strip()
159
+ except Exception:
160
+ pass
161
+ db_path = os.path.join(BASE, 'data', 'index', 'kg.duckdb')
162
+
163
+ if os.path.isfile(db_path):
164
+ import time as _time
165
+ db_mtime = os.path.getmtime(db_path)
166
+ db_age_hours = (_time.time() - db_mtime) / 3600
167
+
168
+ # 检查代码是否比 DuckDB 新 (采样几个文件)
169
+ code_dir = os.path.join(BASE, 'data', 'code')
170
+ code_newer = False
171
+ if os.path.isdir(code_dir):
172
+ for root, dirs, files in os.walk(code_dir):
173
+ dirs[:] = [d for d in dirs if d not in ('node_modules', '.git', 'dist', '__pycache__')]
174
+ depth = root[len(code_dir):].count(os.sep)
175
+ if depth >= 3:
176
+ dirs[:] = []
177
+ continue
178
+ for fn in files:
179
+ if fn.endswith(('.vue', '.java', '.ts')):
180
+ try:
181
+ if os.path.getmtime(os.path.join(root, fn)) > db_mtime:
182
+ code_newer = True
183
+ break
184
+ except OSError:
185
+ pass
186
+ if code_newer:
187
+ break
188
+
189
+ lines.append(' kg.duckdb: %.0f小时前构建' % db_age_hours)
190
+
191
+ if role in ('admin', 'dev'):
192
+ # 管理员/开发: 能构建
193
+ if code_newer or db_age_hours > 168: # 7天 = 168小时
194
+ lines.append(' [WARN] 知识图谱过期! 代码有新变更.')
195
+ lines.append(' → 管理员请运行: python .qoder/scripts/kg_build.py')
196
+ lines.append(' → 完成后: python .qoder/scripts/team_sync.py push (共享给团队)')
197
+ else:
198
+ lines.append(' ✓ 知识图谱最新')
199
+ else:
200
+ # 非管理员: 只拉取
201
+ if code_newer or db_age_hours > 168:
202
+ lines.append(' [WARN] 知识图谱可能过期.')
203
+ lines.append(' → 运行: python .qoder/scripts/team_sync.py pull (获取管理员最新构建)')
204
+ else:
205
+ lines.append(' ✓ 知识图谱最新')
206
+
207
+ # 检查是否有未标注的模块 (提示AI做语义标注)
208
+ try:
209
+ import subprocess as _sp
210
+ r = _sp.run([sys.executable, os.path.join(BASE, '.qoder', 'scripts', 'kg_semantic.py'), '--check'],
211
+ capture_output=True, text=True, encoding='utf-8', timeout=5)
212
+ if r.stdout and 'semantic_labeling_needed' in r.stdout:
213
+ import json as _json
214
+ data = _json.loads(r.stdout)
215
+ unlabeled = len(data.get('modules', []))
216
+ if unlabeled > 0:
217
+ lines.append(' [提示] %d个模块未标注中文名, 运行 kg_semantic.py --check 查看' % unlabeled)
218
+ except Exception:
219
+ pass
220
+ else:
221
+ lines.append(' [MISSING] kg.duckdb 不存在!')
222
+ if role in ('admin', 'dev'):
223
+ lines.append(' → 运行: python .qoder/scripts/kg_build.py')
224
+ else:
225
+ lines.append(' → 运行: python .qoder/scripts/team_sync.py pull')
195
226
 
196
227
  return NL.join(lines)
197
228
 
198
229
 
199
230
  def get_style_info():
200
231
  """Read style metadata for quick reference"""
201
- meta = load_json_safe(os.path.join(BASE, 'data', 'index', 'style-meta.json'))
232
+ meta = load_json_safe(os.path.join(BASE, 'data', 'index', 'ui-style-meta.json'))
202
233
  if not meta:
203
234
  return None
204
235
 
@@ -1,105 +1,216 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
- # QODER Pipeline 工作流规则(全模式生效)
6
-
7
- > 本规则是 wl-pipeline 的核心约束,通过 .qoder/rules/ 在 Qoder IDE 对话、
8
- > Quest 模式中始终生效。Qoder CLI 读根目录 AGENTS.md(内容一致)。
9
- > 完整命令定义在 .qoder/commands/wl-*.md,技能在 .qoder/skills/。
10
-
11
- ## 规则 0:自然语言 → 技能 路由表(全端通用)
12
-
13
- 所有 Qoder 产品(IDE 编辑器 / Quest 模式 / QoderWork 桌面端 / CLI)都支持两种触发方式:
14
- 1. **斜杠命令**:输入 `/wl-prd` `/wl-search` 等(commands 和 skills 都可用 `/` 触发)
15
- 2. **自然语言**:直接说"写个需求""查一下代码",AI 按下表自动映射到对应 skill
16
-
17
- > 注意:Quest/QoderWork `/` 会同时列出 commands(如 `/wl-prd`)和 skills(如 `/prd-generator`)。
18
- > 两者功能等价,优先用 `/wl-*` 命令(更稳定,参数提示更全)。
19
-
20
- | 用户说什么 | 触发的 skill/command |
21
- |------------|---------------------|
22
- | "写个需求""生成PRD""做个原型""保单这块加个功能" | `/wl-prd` 或 prd-generator + prototype-generator |
23
- | "查一下""代码在哪""搜保险""考勤的API""字段含义" | `/wl-search` 或 wl-search |
24
- | "建任务""排优先级""这个任务做完了""开始做这个" | `/wl-task` 或 wl-task |
25
- | "项目怎么样""进度""健康度""路线图" | `/wl-status` 或 wl-status |
26
- | "写日报""周报""我这周干了啥""今天做了什么" | `/wl-report` wl-report |
27
- | "用户反馈""数据怎么样""转化漏斗""留存" | `/wl-insight` 或 wl-insight |
28
- | "生成规格""写spec""技术方案" | `/wl-spec` 或 spec-generator |
29
- | "开始写代码""按规格实现""实现这个接口" | `/wl-code` 或 spec-coder |
30
- | "写单元测试""补测试""覆盖一下" | `/wl-test` 或 test-generator |
31
- | "评审PRD""PRD质量怎么样" | prd-review |
32
- | "提交代码""commit""推上去""保存代码" | `/wl-commit` 或 wl-commit |
33
- | "初始化""换开发者""环境检查""我是谁" | `/wl-init` 或 wl-init |
34
-
35
- **找不到明确匹配时:先问用户意图,不要乱跑**("你是想写 PRD、查代码、还是建任务?")。
36
- 注意:用户说"同步/保存产出"通常指 team_sync(push),不是 git commit;
37
- 用户说"提交/commit 代码"才是 wl-commit。
38
-
39
- ## 规则 1:PRD/原型需求必须先问平台
40
-
41
- 用户提出 PRD、原型、需求分析类请求时,第一步永远是问(绝不自动判断):
42
-
43
- ```
44
- 这个需求是针对哪个平台?
45
- 1. **Web 管理端** (fywl-ui) - Ant Design Vue + VxeGrid 风格
46
- 2. **APP 移动端** (Carmg-H5) - Vant 风格
47
- 3. **两端都要
48
- 请选择 (1/2/3):
49
- ```
50
-
51
- ## 规则 2:查代码只用索引,不全库 grep
52
-
53
- ```bash
54
- python .qoder/scripts/context_pack.py <业务关键词> --platform <web|app> # 一次取全(首选)
55
- python .qoder/scripts/search_index.py <关键词> --platform <web|app> # 单项搜索
56
- ```
57
- context_pack 一条命令返回:相关代码文件 + 同类页面示例 + 字段规格 +
58
- 相关 PRD + 设计 Token + 图标参考 + 模板路径。禁止对 data/code/ 全库 grep。
59
-
60
- ## 规则 3:原型风格必须来自真源(含图标)
61
-
62
- - 起点永远是平台模板:.qoder/templates/prototype-web.html / prototype-app.html
63
- - 颜色只用真源:data/index/vben-style-reference.json(Web HSL token)、
64
- chart-style-reference.json(看板/大屏两种系统内风格)、Vant 变量(APP)
65
- - **图标绝对禁止 emoji**:Web data/index/icon-reference.json 里的
66
- Ant Design 真实 SVG(内联,fill=currentColor);APP Vant 字体图标
67
- (CDN: https://cdn.jsdelivr.net/npm/vant@4/lib/index.css + van-icon 类名)
68
- - 新功能(无现有页面)也必须锚定系统内最近似的真实页面:
69
- 大屏/全国地图类 → dashboard/monitor 先例;工作台卡片类 → dashboard/workbench
70
- - 原型头部注释必须写明风格来自哪些真实文件,写不出来源 = 风格提取没做
71
-
72
- ## 规则 4:PRD 必须套团队模板 + 过 EVA 门禁
73
-
74
- - 完整需求用 .qoder/templates/prd-full-template.md,零星需求用 prd-quick-template.md
75
- - 发布前:`python .qoder/scripts/eval_prd.py <prd> [原型]` 必须 PASS (≥80%)
76
- - 发现确认采用批量方式(一个编号列表一轮确认),不要逐条问
77
-
78
- ## 规则 5:用户永不接触 git
79
-
80
- - 产出保存/发布后自动执行 `python .qoder/scripts/team_sync.py push`
81
- - 拉取团队最新:`python .qoder/scripts/team_sync.py pull`
82
- - 出现 SYNC_CONFLICT 由 AI 按提示自行解决,绝不让用户跑 git 命令
83
-
84
- ## 规则 6:环境问题找 doctor
85
-
86
- 任何"索引不对/搜不到/环境坏了"类问题:
87
- `python .qoder/scripts/init_doctor.py`(加 --fix 自动修复,幂等增量,不会重头构建)
88
-
89
- ## 规则 7:Repo Wiki 是补充知识源
90
-
91
- 若存在 .qoder/repowiki/(Qoder IDE 生成的仓库 Wiki),写 PRD 前先查其中
92
- 相关模块页面(架构、模块说明比索引更全面);data/code/ 下各源码仓库若有
93
- 自己的 repowiki 同样优先参考。索引负责"定位文件",Wiki 负责"理解模块"。
94
-
95
- ## 用户侧命令一览(用户只需要知道这些)
96
-
97
- | 命令 | 作用 |
98
- |------|------|
99
- | /wl-init [名字] [角色] | 初始化/切换开发者 + 环境体检 |
100
- | /wl-prd <需求描述> | 生成 PRD + 原型(最核心) |
101
- | /wl-search <关键词> | 查代码/PRD/字段/API |
102
- | /wl-task, /wl-status, /wl-report | 任务/状态/日报周报 |
103
- | /wl-spec, /wl-code, /wl-test, /wl-commit | 规格/编码/测试/提交(后三个需确认) |
104
-
105
- 用户用自然语言表达即可,AI 负责映射到命令和脚本。
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # QODER Pipeline 工作流规则(全模式生效)
6
+
7
+ > 本规则是 wl-pipeline 的核心约束,通过 .qoder/rules/ 在 Qoder IDE 对话、
8
+ > Quest 模式中始终生效。Qoder CLI 读根目录 AGENTS.md(内容一致)。
9
+ > 完整命令定义在 .qoder/commands/wl-*.md,技能在 .qoder/skills/。
10
+
11
+ ## 规则 -1:首次使用须知(全端通用,最高优先级)
12
+
13
+ **任何命令/自然语言请求执行前,AI 必须先检查工作流是否已初始化。**
14
+
15
+ 检查方法(一次即可,幂等):
16
+ ```bash
17
+ # .qoder/.developer 是否存在
18
+ test -f .qoder/.developer && echo "已初始化" || echo "未初始化"
19
+ ```
20
+
21
+ **若未初始化**(`.qoder/.developer` 不存在),无论用户说什么("写需求""查代码""建任务"…),
22
+ 都**先停下,引导初始化**,不要直接跑命令(会失败):
23
+
24
+ > 还没初始化工作流。先完成一次初始化(约 1 分钟):
25
+ > - **Qoder IDE / Quest / QoderWork**:说"初始化"或跑 `/wl-init`,按提示填名字和角色
26
+ > - **命令行**:`npx @hupan56/wlkj init <名字> <角色>`
27
+ >
28
+ > 角色:产品(pm)/设计(design)/开发(dev)/测试(test)/管理(admin)
29
+ > 初始化完就能正常用了。
30
+
31
+ **若已初始化**,正常路由到下面的规则 0。
32
+
33
+ > 为什么这条最高优先级:Quest 模式没有 `/wl-init` 的强制入口,用户可能直接说
34
+ > "写个需求",但身份没初始化会导致命令静默失败。50 人团队里新成员第一句话
35
+ > 就撞这个的概率很高,必须在规则层兜住。
36
+
37
+ ## 规则 0:自然语言 → 技能 路由表(全端通用)
38
+
39
+ 所有 Qoder 产品(IDE 编辑器 / Quest 模式 / QoderWork 桌面端 / CLI)都支持两种触发方式:
40
+ 1. **斜杠命令**:输入 `/wl-prd-full` `/wl-search` 等(commands 和 skills 都可用 `/` 触发)
41
+ 2. **自然语言**:直接说"写个需求""查一下代码",AI 按下表自动映射到对应 skill
42
+
43
+ > 注意:Quest/QoderWork 里 `/` 会同时列出 commands(如 `/wl-prd-full`)和 skills(如 `/prd-generator`)。
44
+ > 两者功能等价,优先用 `/wl-*` 命令(更稳定,参数提示更全)。
45
+
46
+ | 用户说什么 | 触发的 skill/command |
47
+ |------------|---------------------|
48
+ | "写个需求""生成PRD""做个原型""新模块""保单这块加个功能" | `/wl-prd-full` 或 prd-generator + prototype-generator |
49
+ | "加个字段""加个导出按钮""改下文案""小改动" | `/wl-prd-quick`(快档,零星需求)|
50
+ | "查一下""代码在哪""搜保险""考勤的API""字段含义" | `/wl-search` 或 wl-search |
51
+ | "建任务""排优先级""这个任务做完了""开始做这个" | `/wl-task` 或 wl-task |
52
+ | "项目怎么样""进度""健康度""路线图" | `/wl-status` 或 wl-status |
53
+ | "写日报""周报""我这周干了啥""今天做了什么" | `/wl-report` 或 wl-report |
54
+ | "调研""竞品""对标""规划""路线图""接下来做什么""发现个机会""探讨需求" | `/wl-insight` wl-insight(探索站:发现/调研/规划)|
55
+ | "生成规格""写spec""技术方案" | `/wl-spec` 或 spec-generator |
56
+ | "开始写代码""按规格实现""实现这个接口" | `/wl-code` 或 spec-coder |
57
+ | "跑测试用例""执行测试任务""回归测试任务" | `/wl-test`(测试工作流)或 wl-test |
58
+ | "写单元测试""补单测""生成test" | `/wl-test unit` test-generator |
59
+ | "评审PRD""PRD质量怎么样""检查需求文档" | `/wl-prd-review`(评审 PRD 质量)|
60
+ | "提交代码""commit""推上去""保存代码" | `/wl-commit` 或 wl-commit |
61
+ | "初始化""换开发者""环境检查""我是谁" | `/wl-init` 或 wl-init |
62
+ | **"出个原型""画个界面""做个 mockup""改个页面"** | **`/wl-design-draw`(画界面)** |
63
+ | **"XX 有哪些页面""XX 操作流程""系统什么风格""改XX影响什么"** | **`/wl-design-scan`(审视现状)** |
64
+ | **"录入设计稿""评审原型""检查原型""Figma 稿""蓝湖稿""蓝湖链接""lanhu"** | **`/wl-design-spec`(设计交付,蓝湖链接优先用 `mcp__lanhu__*` 直读)** |
65
+ | "测试覆盖""哪些功能有测试""哪些没测试""回归盲区" | `/wl-design-scan` MCP `coverage_matrix()` |
66
+ | "这个功能完整吗""XX功能画像" | `/wl-design-scan` MCP `feature_overview(feature='XX')` |
67
+ | "改XX会影响什么""改这个接口影响哪些页面" | `/wl-design-scan` 或 MCP `get_impact(endpoint='XX')` |
68
+ | "XX函数谁调用了""XX的调用链" | MCP `context_360(symbol='XX')` |
69
+
70
+ > 知识图谱 13 个能力(`kg.py`)**全系列通用**:QoderWork 环境 AI 也可直接调
71
+ > MCP 工具(`mcp__qoder-knowledge-graph__*`),非 MCP 环境跑 kg.py,数据一致。
72
+ > 能力清单见 `/wl-search`。
73
+
74
+ **找不到明确匹配时:先问用户意图,不要乱跑**("你是想写 PRD、查代码、还是建任务?")。
75
+ 注意:用户说"同步/保存产出"通常指 team_sync(push),不是 git commit;
76
+ 用户说"提交/commit 代码"才是 wl-commit。
77
+
78
+ **🧩 提问润色(可选增强,纯 Qoder IDE/CLI 用,QoderWork 有 MCP 不需要)**:
79
+ 非 MCP 环境下,用户输入含业务词时,可先跑 `python .qoder/scripts/enrich_prompt.py "<用户输入>"`
80
+ <10ms 的极速关键词扩展,让用户确认后再走实际命令。MCP 环境下跳过(AI 直接调 MCP 工具已含扩展)。
81
+
82
+ ## 规则 1:PRD/原型需求必须先问平台(问了就停,不许边问边干)
83
+
84
+ 用户提出 PRD、原型、需求分析类请求时,第一步永远是问(绝不自动判断):
85
+
86
+ ```
87
+ 这个需求是针对哪个平台?
88
+ 1. **Web 管理端** (fywl-ui) - Ant Design Vue + VxeGrid 风格
89
+ 2. **APP 移动端** (Carmg-H5) - Vant 风格
90
+ 3. **两端都要
91
+ 请选择 (1/2/3):
92
+ ```
93
+
94
+ **⚠️ 铁律:问完平台必须停下,整条回复到此结束。不许在同一回合里并行做别的**
95
+ (不许搜代码、不许读文件、不许分析、不许出方案)。等用户回答平台后再开始下一步。
96
+ 原因:平台不同,搜索范围、原型模板、设计 Token 全都不同——平台没定就开干,
97
+ 方向必然错,白白浪费一轮工具调用。"边问边干"是这条规则最常见的违规形态。
98
+
99
+ ## 规则 2:查代码索引优先,索引找不到才准 grep(又快又准的取数顺序)
100
+
101
+ ```bash
102
+ python .qoder/scripts/kg.py context <业务关键词> --platform <web|app> [--role pm|design|dev|test] # 一次取全(首选, 秒级)
103
+ python .qoder/scripts/search_index.py <关键词> --platform <web|app> # 单项搜索
104
+ ```
105
+ kg.py context(= context_pack)一条命令返回:相关代码文件 + 同类页面示例 + 字段规格 +
106
+ 相关 PRD + 设计 Token + 图标参考 + 模板路径。kg.py 还有 12 个兄弟能力
107
+ (impact/coverage/feature/workflow/hop/...),统一入口见 `/wl-search`。
108
+
109
+ **取数顺序(强制,违反 = 慢 + 凭空写 PRD):**
110
+ 1. **先用索引**:任何 /wl-* 命令查代码,**第一步永远是 kg.py context**(查预建图谱,秒级,不碰文件系统)。绝大多数需求一次就够。
111
+ 2. **索引够用就停**:context 列出了相关文件/字段/API → 只用 Read 读那 1-2 个 .vue,**不要再用 Grep/Glob 去文件系统扫**。
112
+ 3. **索引真找不到才 grep 兜底**:只有当 kg.py/search_index 明确返回"无匹配"或缺了某个具体点时,才回退到 Grep/Glob 直搜 —— 且**只搜 context 指向的范围**,不准对 data/code/(8973+ 文件)或整个 qoderAll 仓全库扫。
113
+
114
+ **为什么这条是红线**:QoderWork 自带 Agent 默认会用 Grep/Glob 直搜文件系统,它不懂"业务源码在 data/code/ 镜像里",会搜整个 qoderAll 仓然后报"无匹配",被迫凭空编字段/API。**Agent 只准用来**:①读 context 列出的具体文件(Read)②**在 /wl-insight 里**做 web 调研(对标/竞品)和多视角探索脑暴。**绝不用 Agent 去"发现/搜索"代码——那是 kg.py 的活。** 注意:探索类 Agent 调研已集中到 `/wl-insight`,`/wl-prd-full` 不再派 Agent 做 web 搜索/脑暴。
115
+
116
+ ## 规则 3:原型风格必须来自真源(含图标)
117
+
118
+ - 起点永远是平台模板:.qoder/templates/prototype-web.html / prototype-app.html
119
+ - 颜色只用真源:data/index/vben-style-reference.json(Web HSL token)、
120
+ chart-style-reference.json(看板/大屏两种系统内风格)、Vant 变量(APP)
121
+ - **图标绝对禁止 emoji**:Web 用 data/index/icon-reference.json 里的
122
+ Ant Design 真实 SVG(内联,fill=currentColor);APP 用 Vant 字体图标
123
+ (CDN: https://cdn.jsdelivr.net/npm/vant@4/lib/index.css + van-icon 类名)
124
+ - 新功能(无现有页面)也必须锚定系统内最近似的真实页面:
125
+ 大屏/全国地图类 → dashboard/monitor 先例;工作台卡片类 → dashboard/workbench
126
+ - 原型头部注释必须写明风格来自哪些真实文件,写不出来源 = 风格提取没做
127
+
128
+ ## 规则 3.5:UI 设计师协作(设计师 ≠ AI 对立面)
129
+
130
+ 设计师用 Figma/Axure 出图,但成果必须回流工作流,不能跟 AI 原型各干各的。
131
+
132
+ **设计师的 3 种接入方式(QoderWork 自然语言触发):**
133
+
134
+ | 设计师说什么 | 触发 | 做什么 |
135
+ |-------------|------|--------|
136
+ | "录入设计稿""把这个 Figma 稿录入" | design-import | 设计稿→spec.json→存 data/style/→进知识图谱,下次 AI 优先用它 |
137
+ | "评审原型""设计稿看一下" | design-review | 检查 AI 原型是否跟系统风格/设计师规范一致 |
138
+ | "按这个规格出原型" | prototype-generator | 设计师只出规格(布局/配色/组件),AI 按规格生成 HTML |
139
+
140
+ **铁律:设计师的 spec 优先级 > 代码风格 > PDF 规范**
141
+ - `data/style/{需求名}-design-spec.json` 一旦存在,同需求的 prototype 必须锚定它
142
+ - 设计师录入了 spec 后,AI 出原型前先检查有没有对应 spec,有就用
143
+ - 这解决"AI 原型和 Figma 稿打架"——设计师的 spec 成了单一风格真源
144
+
145
+ **典型协作流程:**
146
+ ```
147
+ PM /wl-prd-full → AI 出初稿 PRD + 原型
148
+ → 设计师 QoderWork 说"录入设计稿" (design-import): Figma 稿→spec.json
149
+ → PM 说"按设计师规范修订原型" → AI 用 spec 重生成原型
150
+ → 设计师说"评审原型" (design-review) → 通过
151
+ → /wl-commit → 前端拿到 PRD + 匹配设计师规范的原型
152
+ ```
153
+
154
+ ## 规则 4:PRD 必须套团队模板 + 过 EVA 门禁
155
+
156
+ - 完整需求用 .qoder/templates/prd-full-template.md,零星需求用 prd-quick-template.md
157
+ - 发布前:`python .qoder/scripts/eval_prd.py <prd> [原型]` 必须 PASS (≥80%)
158
+ - 发现确认采用批量方式(一个编号列表一轮确认),不要逐条问
159
+
160
+ ## 规则 5:用户永不接触 git
161
+
162
+ - 产出保存/发布后自动执行 `python .qoder/scripts/team_sync.py push`
163
+ - 拉取团队最新:`python .qoder/scripts/team_sync.py pull`
164
+ - 出现 SYNC_CONFLICT 由 AI 按提示自行解决,绝不让用户跑 git 命令
165
+
166
+ ## 规则 6:环境问题找 doctor
167
+
168
+ 任何"索引不对/搜不到/环境坏了"类问题:
169
+ `python .qoder/scripts/init_doctor.py`(加 --fix 自动修复,幂等增量,不会重头构建)
170
+
171
+ ## 规则 7:Repo Wiki 是补充知识源
172
+
173
+ 若存在 .qoder/repowiki/(Qoder IDE 生成的仓库 Wiki),写 PRD 前先查其中
174
+ 相关模块页面(架构、模块说明比索引更全面);data/code/ 下各源码仓库若有
175
+ 自己的 repowiki 同样优先参考。索引负责"定位文件",Wiki 负责"理解模块"。
176
+
177
+ ## 规则 8:QoderWork 只做可选增强(渐进增强,绝不强依赖)
178
+
179
+ 🔒 **核心约束:团队里有人用 Qoder IDE、有人用 Qoder CLI、有人用 QoderWork —— 流水线
180
+ 必须在纯 Qoder(IDE/CLI)下开箱即用、功能完整。** QoderWork 的连接器 / 专家套件 /
181
+ 定时任务只是「有则锦上添花、无则静默回退」的可选层,绝不能成为依赖。
182
+
183
+ 落实方式:
184
+ 1. **本地是唯一事实源**:task.json / git log / drafts / index 是真相,连接器只是它的投影
185
+ 2. **增强段统一标 `🧩 QoderWork 增强(可选)`**:wl-report(读日历补日报)、
186
+ wl-task(待办双向同步)、wl-status(日历校准健康度)、wl-test(浏览器自动执行测试)
187
+ 四处已接入,每段都写明回退保证
188
+ 3. **探测而非假设**:只在运行环境真正提供「日历/待办/邮件」工具可读时才启用;
189
+ 看不到就跳过,补一句 `[xx 未启用:非 QoderWork 或未授权连接器]`,不报错不阻塞
190
+ 4. **新增任何 QoderWork 增强都必须先保证纯 Qoder 可跑,再叠加可选层**
191
+
192
+ ## 用户侧命令一览(用户只需要知道这些)
193
+
194
+ **7 个核心命令**(每道工序一个,带模式参数路由):
195
+
196
+ | 命令 | 工序站 | 模式参数 |
197
+ |------|--------|---------|
198
+ | /wl-init [名字] [角色] | 身份 | (无) |
199
+ | /wl-prd-full <需求> | 需求落地(完整档) | 支持 `参考:<报告>` 衔接 insight |
200
+ | /wl-prd-quick <需求> | 需求落地(小改动) | (无) |
201
+ | /wl-design <模式> | 设计 | import/generate/review 或默认(import) |
202
+ | /wl-task <子命令> | 任务 | create/list/start/finish |
203
+ | /wl-code | 编码 | (按 spec 实现,需确认) |
204
+ | /wl-test <模式> | 测试 | quick/browser/unit 或默认(quick,需确认) |
205
+ | /wl-commit | 提交 | (需确认) |
206
+
207
+ **可选命令**(按需启用):/wl-search(代码搜索,全员工具)、/wl-spec(技术规格)、
208
+ /wl-status(项目健康度)、/wl-report(日报周报)、
209
+ /wl-insight(探索站:discover/research/plan,**位于 /wl-prd-full 之前**)。
210
+
211
+ > 模块契约(输入/输出/校验):见 `.qoder/contracts/`。
212
+ > `/wl-test` 默认浏览器自动化测试(据任务 PRD 生成用例 → QoderWork 浏览器执行,
213
+ > 纯 Qoder 降级人工核对);说"单元测试/单测"走 `/wl-test unit`(Java 单测)。
214
+ > 环境/域名在 config.yaml `autotest:` 配,`--url` 可临时覆盖。
215
+
216
+ 用户用自然语言表达即可,AI 负责映射到命令和脚本。