ai-engineering-init 1.11.0 → 1.12.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 (26) hide show
  1. package/.claude/agents/requirements-analyzer.md +14 -1
  2. package/.claude/{skills/openspec-apply-change/SKILL.md → commands/opsx-apply.md} +1 -19
  3. package/.claude/{skills/openspec-archive-change/SKILL.md → commands/opsx-archive.md} +1 -18
  4. package/.claude/{skills/openspec-bulk-archive-change/SKILL.md → commands/opsx-bulk-archive.md} +1 -18
  5. package/.claude/{skills/openspec-continue-change/SKILL.md → commands/opsx-continue.md} +1 -18
  6. package/.claude/{skills/openspec-explore/SKILL.md → commands/opsx-explore.md} +1 -19
  7. package/.claude/{skills/openspec-ff-change/SKILL.md → commands/opsx-ff.md} +1 -18
  8. package/.claude/{skills/openspec-new-change/SKILL.md → commands/opsx-new.md} +1 -18
  9. package/.claude/{skills/openspec-onboard/SKILL.md → commands/opsx-onboard.md} +1 -18
  10. package/.claude/{skills/openspec-sync-specs/SKILL.md → commands/opsx-sync.md} +1 -18
  11. package/.claude/{skills/openspec-verify-change/SKILL.md → commands/opsx-verify.md} +1 -18
  12. package/.claude/hooks/skill-forced-eval.js +0 -10
  13. package/.claude/skills/analyze-requirements/SKILL.md +38 -5
  14. package/.claude/skills/fix-bug/SKILL.md +103 -57
  15. package/.claude/skills/loki-log-query/SKILL.md +4 -4
  16. package/.codex/skills/analyze-requirements/SKILL.md +38 -5
  17. package/.codex/skills/fix-bug/SKILL.md +103 -57
  18. package/.codex/skills/loki-log-query/SKILL.md +4 -4
  19. package/.cursor/skills/analyze-requirements/SKILL.md +38 -5
  20. package/.cursor/skills/fix-bug/SKILL.md +103 -57
  21. package/.cursor/skills/loki-log-query/SKILL.md +4 -4
  22. package/README.md +1 -1
  23. package/package.json +1 -1
  24. package/src/platform-map.json +40 -0
  25. package/src/skills/fix-bug/SKILL.md +103 -57
  26. package/src/skills/loki-log-query/SKILL.md +4 -4
@@ -23,7 +23,20 @@ tools: Read, Bash, Grep, Glob, Agent
23
23
 
24
24
  根据用户提供的输入类型,调用对应的 Haiku 层 Agent:
25
25
 
26
- **有 Axure 原型图时**调用 `image-reader` Agent:
26
+ **有 Axure 链接时(重要)**先用 Playwright 截图,再调 `image-reader`:
27
+
28
+ > Axure 是 SPA 应用,WebFetch 必定失败(TLS/JS 渲染问题)。**禁止用 WebFetch 访问 Axure 链接。**
29
+
30
+ ```bash
31
+ # 1. 用 Playwright 截图(每个页面单独截)
32
+ Bash: npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page1" /tmp/axure-1.png
33
+ Bash: npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page2" /tmp/axure-2.png
34
+
35
+ # 2. 截图完成后,传给 image-reader 分析
36
+ Agent(subagent_type="image-reader", prompt="分析 Axure 原型截图:/tmp/axure-1.png")
37
+ ```
38
+
39
+ **有 Axure 原型截图文件时** → 直接调用 `image-reader` Agent:
27
40
  ```
28
41
  Agent(subagent_type="image-reader", prompt="分析以下 Axure 原型截图,提取页面结构、搜索条件、表格列、表单字段、操作按钮、交互流程:[图片路径]")
29
42
  ```
@@ -1,22 +1,4 @@
1
- ---
2
- name: openspec-apply-change
3
- description: |
4
- Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
5
-
6
- 触发场景:
7
- - 需要实现 OpenSpec 变更中的任务
8
- - 执行变更制品中定义的实现步骤
9
- - 将规格和设计转化为实际代码
10
- - 逐个完成 tasks.md 中的待办事项
11
-
12
- 触发词:实现任务、开始实现、opsx:apply、openspec apply、执行变更、开始编码、实现变更
13
- license: MIT
14
- compatibility: Requires openspec CLI.
15
- metadata:
16
- author: openspec
17
- version: "1.0"
18
- generatedBy: "1.1.1"
19
- ---
1
+ # /opsx-apply - 实现 OpenSpec 变更任务
20
2
 
21
3
  Implement tasks from an OpenSpec change.
22
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-archive-change
3
- description: |
4
- Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
5
-
6
- 触发场景:
7
- - 变更实现完毕,需要归档保存
8
- - 完成的变更需要移入 archive 目录
9
- - 项目决策记录需要持久化保存
10
-
11
- 触发词:归档变更、归档、opsx:archive、openspec archive、完成变更、存档、归档完成
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-archive - 归档 OpenSpec 变更
19
2
 
20
3
  Archive a completed change in the experimental workflow.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-bulk-archive-change
3
- description: |
4
- Archive multiple completed changes at once. Use when archiving several parallel changes.
5
-
6
- 触发场景:
7
- - 多个变更同时完成,需要批量归档
8
- - 清理多个已完成的并行变更
9
- - 需要处理多个变更之间的规格冲突后统一归档
10
-
11
- 触发词:批量归档、全部归档、opsx:bulk-archive、一起归档、归档所有变更、批量存档
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-bulk-archive - 批量归档 OpenSpec 变更
19
2
 
20
3
  Archive multiple completed changes in a single operation.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-continue-change
3
- description: |
4
- Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
5
-
6
- 触发场景:
7
- - 需要继续推进已有变更的下一个制品
8
- - 上次中断后恢复变更工作
9
- - 逐步创建变更的 proposal/specs/design/tasks
10
-
11
- 触发词:继续变更、继续、opsx:continue、openspec continue、下一步、推进变更、继续工作
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-continue - 继续 OpenSpec 变更
19
2
 
20
3
  Continue working on a change by creating the next artifact.
21
4
 
@@ -1,22 +1,4 @@
1
- ---
2
- name: openspec-explore
3
- description: |
4
- Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
5
-
6
- 触发场景:
7
- - 需要在实现前先探索和思考问题
8
- - 比较多种技术方案的优劣
9
- - 调查代码库中的现有架构和模式
10
- - 在变更实现过程中遇到困惑需要深入分析
11
-
12
- 触发词:探索、opsx:explore、openspec explore、想一想、分析问题、调研方案、头脑风暴
13
- license: MIT
14
- compatibility: Requires openspec CLI.
15
- metadata:
16
- author: openspec
17
- version: "1.0"
18
- generatedBy: "1.1.1"
19
- ---
1
+ # /opsx-explore - OpenSpec 探索模式
20
2
 
21
3
  Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
22
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-ff-change
3
- description: |
4
- Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
5
-
6
- 触发场景:
7
- - 需要快速一次性生成所有变更制品
8
- - 跳过逐步创建,直接生成 proposal/specs/design/tasks
9
- - 想快速启动一个变更并立即进入实现阶段
10
-
11
- 触发词:快速创建、快进、opsx:ff、openspec ff、一键生成、快速开始、fast forward
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-ff - 快速推进 OpenSpec 变更
19
2
 
20
3
  Fast-forward through artifact creation - generate everything needed to start implementation in one go.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-new-change
3
- description: |
4
- Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.
5
-
6
- 触发场景:
7
- - 需要创建一个新的 OpenSpec 变更
8
- - 开始一个新功能或修复的结构化工作流
9
- - 初始化变更目录并查看第一个制品模板
10
-
11
- 触发词:新建变更、新变更、opsx:new、openspec new、创建变更、开始新功能、新增变更
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-new - 新建 OpenSpec 变更
19
2
 
20
3
  Start a new change using the experimental artifact-driven approach.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-onboard
3
- description: |
4
- Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
5
-
6
- 触发场景:
7
- - 首次使用 OpenSpec,需要引导式教学
8
- - 想通过实际操作学习 OpenSpec 完整工作流
9
- - 需要了解 OpenSpec 的所有命令和流程
10
-
11
- 触发词:入门、onboard、opsx:onboard、openspec 教程、学习 openspec、新手引导、openspec 入门
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-onboard - OpenSpec 新手引导
19
2
 
20
3
  Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-sync-specs
3
- description: |
4
- Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
5
-
6
- 触发场景:
7
- - 需要将变更中的增量规格同步到主规格
8
- - 变更的 delta spec 需要合并到 openspec/specs 目录
9
- - 在归档前手动同步规格变更
10
-
11
- 触发词:同步规格、同步specs、opsx:sync、openspec sync、合并规格、同步变更规格
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-sync - 同步 OpenSpec 规格
19
2
 
20
3
  Sync delta specs from a change to main specs.
21
4
 
@@ -1,21 +1,4 @@
1
- ---
2
- name: openspec-verify-change
3
- description: |
4
- Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
5
-
6
- 触发场景:
7
- - 实现完成后需要验证是否与规格一致
8
- - 归档前检查任务完成度和代码正确性
9
- - 需要生成变更的完整性/正确性/一致性报告
10
-
11
- 触发词:验证变更、验证、opsx:verify、openspec verify、检查实现、校验变更、验收
12
- license: MIT
13
- compatibility: Requires openspec CLI.
14
- metadata:
15
- author: openspec
16
- version: "1.0"
17
- generatedBy: "1.1.1"
18
- ---
1
+ # /opsx-verify - 验证 OpenSpec 变更
19
2
 
20
3
  Verify that an implementation matches the change artifacts (specs, tasks, design).
21
4
 
@@ -96,16 +96,6 @@ const instructions = `## 强制技能激活流程(必须执行)
96
96
  - sms-mail: 短信/邮件/SMS/验证码/通知
97
97
  - social-login: 第三方登录/OAuth/OAuth2/社交登录/授权登录
98
98
  - tenant-management: 多租户/租户隔离/SaaS/数据隔离
99
- - openspec-new-change: 新建变更/开始新功能/opsx:new/openspec new
100
- - openspec-ff-change: 快速推进/opsx:ff/openspec ff/fast-forward
101
- - openspec-apply-change: 实现任务/opsx:apply/openspec apply
102
- - openspec-continue-change: 继续变更/opsx:continue/openspec continue
103
- - openspec-archive-change: 归档变更/opsx:archive/openspec archive
104
- - openspec-bulk-archive-change: 批量归档/opsx:bulk-archive
105
- - openspec-explore: 探索模式/opsx:explore/openspec explore
106
- - openspec-onboard: 新手引导/opsx:onboard/openspec onboard
107
- - openspec-sync-specs: 同步规格/opsx:sync/openspec sync
108
- - openspec-verify-change: 验证变更/opsx:verify/openspec verify
109
99
  - ui-pc: 前端组件/Element UI/页面开发
110
100
  - store-pc: Vuex/状态管理/store模块
111
101
  - mysql-debug: MySQL调试/查数据库/执行SQL/数据库排查
@@ -29,7 +29,7 @@ description: |
29
29
  │ - 用户已给出完整字段列表
30
30
 
31
31
  └─ 复杂需求? ──→ Agent 路径(启动 requirements-analyzer)
32
- - 提供了 Axure 原型截图
32
+ - 提供了 Axure 原型链接或截图
33
33
  - 提供了云效任务编号
34
34
  - 多页面/多模块联动
35
35
  - 业务流程复杂,需要状态流转设计
@@ -45,12 +45,34 @@ description: |
45
45
 
46
46
  ## Agent 路径(复杂需求)
47
47
 
48
+ ### Axure 链接处理(重要)
49
+
50
+ > **Axure 是 SPA 应用,WebFetch 必定失败(TLS/JS 渲染问题)。禁止用 WebFetch 访问 Axure 链接。**
51
+
52
+ 当用户提供 Axure 链接时,必须用 Playwright 截图:
53
+
54
+ ```bash
55
+ # 1. 先用 Playwright 截图(每个页面单独截)
56
+ npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page1" /tmp/axure-1.png
57
+ npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page2" /tmp/axure-2.png
58
+
59
+ # 2. 截图完成后,将文件路径传给 image-reader Agent 分析
60
+ # 3. 如果原型有多个页面,URL 通常带 #page 参数,逐页截图
61
+ ```
62
+
63
+ **判断规则**:
64
+ - URL 包含 `axure.cloud` 或 `.axshare.com` → Playwright 截图
65
+ - 用户说"Axure 链接" → Playwright 截图
66
+ - 本地截图文件(.png/.jpg) → 直接 image-reader 分析
67
+
68
+ ### 完整流程
69
+
48
70
  ```
49
71
  步骤 1:收集信息(从用户消息中提取)
50
- - Axure 原型截图路径
51
- - 云效任务编号
72
+ - Axure 原型链接 → Playwright 截图 → image-reader 分析
73
+ - Axure 原型截图文件 → 直接 image-reader 分析
74
+ - 云效任务编号 → task-fetcher 获取详情
52
75
  - 需求描述文字
53
- - 关联模块信息
54
76
 
55
77
  步骤 2:启动 requirements-analyzer Agent
56
78
  └── requirements-analyzer(Opus) 内部自动编排:
@@ -69,13 +91,23 @@ description: |
69
91
  |---------------|---------|
70
92
  | 只有文字描述 | 快速路径(不启动 Agent) |
71
93
  | 文字 + 原型截图 | requirements-analyzer → 内部调 image-reader |
94
+ | 文字 + Axure 链接 | Playwright 截图 → requirements-analyzer → image-reader |
72
95
  | 文字 + 云效任务号 | requirements-analyzer → 内部调 task-fetcher |
73
96
  | 原型截图 + 云效任务号 | requirements-analyzer → 内部并行调 image-reader + task-fetcher |
74
97
 
75
98
  ### 启动示例
76
99
 
77
100
  ```
78
- # 有原型截图
101
+ # 有 Axure 链接(先截图再分析)
102
+ Bash: npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page1" /tmp/axure-1.png
103
+ Bash: npx playwright screenshot --wait-for-timeout 3000 "https://xxx.axure.cloud/page2" /tmp/axure-2.png
104
+
105
+ Agent(subagent_type="requirements-analyzer",
106
+ prompt="分析以下 Axure 原型截图,输出需求分析报告和开发任务清单:
107
+ 截图路径:/tmp/axure-1.png, /tmp/axure-2.png
108
+ 需求描述:xxx")
109
+
110
+ # 有原型截图文件
79
111
  Agent(subagent_type="requirements-analyzer",
80
112
  prompt="分析以下 Axure 原型截图,输出需求分析报告和开发任务清单:
81
113
  截图路径:/path/to/image1.png, /path/to/image2.png
@@ -110,3 +142,4 @@ Agent(subagent_type="requirements-analyzer",
110
142
  - 与 `bug-detective` / `fix-bug` 的区别:本技能面向**新功能开发前的需求分析**,不涉及 Bug 排查
111
143
  - 数据库设计必须遵循项目规范(雪花 ID、审计字段、del_flag=2 正常)
112
144
  - 如果需求信息不完整,主动列出需要确认的点,而不是猜测
145
+ - **Axure 链接必须用 Playwright 截图,禁止 WebFetch**
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: fix-bug
3
3
  description: |
4
- Bug 修复全流程编排。强制使用并行 Agent 模式进行排查,修复后走 git-workflow 提交。
4
+ Bug 修复全流程编排。两阶段 Agent 排查 + 报告确认 + git-workflow 提交。
5
5
 
6
6
  触发场景:
7
7
  - 修复 Bug(含日志/traceId/数据库信息)
@@ -16,20 +16,20 @@ description: |
16
16
 
17
17
  ## 核心原则
18
18
 
19
- **先判断复杂度,简单 Bug 直接修,复杂 Bug 走并行 Agent。修复后必须走 git-workflow 提交。**
19
+ **先判断复杂度,简单 Bug 直接修,复杂 Bug 走两阶段 Agent 排查。搞清原因后先出报告,用户确认后再修复代码。**
20
20
 
21
21
  ## 步骤 0:复杂度判断(必须先做)
22
22
 
23
23
  ```
24
24
  用户提供 Bug 线索
25
25
 
26
- ├─ 简单 Bug? ──→ 快速路径(直接读代码修复)
26
+ ├─ 简单 Bug? ──→ 快速路径
27
27
  │ - 明显的代码错误(NPE、空判断遗漏、拼写错误)
28
28
  │ - 用户已明确指出问题和修改方案
29
29
  │ - 单文件改动,逻辑清晰
30
30
  │ - 不需要查数据库/日志验证
31
31
 
32
- └─ 复杂 Bug? ──→ Agent 路径(并行排查)
32
+ └─ 复杂 Bug? ──→ Agent 路径(两阶段排查)
33
33
  - 需要查日志确认线上行为(提供了 traceId)
34
34
  - 需要查数据库验证数据正确性(提供了 DB 信息)
35
35
  - 问题根因不明确,需要多维度分析
@@ -39,10 +39,10 @@ description: |
39
39
  ## 快速路径(简单 Bug)
40
40
 
41
41
  ```
42
- 读代码 → 定位问题 → 修复 → git-workflow 提交
42
+ 读代码 → 定位问题 → 输出排查报告 → 用户确认 → 修复 → git-workflow 提交
43
43
  ```
44
44
 
45
- 不启动 Agent,直接在主对话中完成。
45
+ 不启动 Agent,直接在主对话中完成。即使是简单 Bug,也先说明问题原因和修复方案,等用户确认再动手。
46
46
 
47
47
  ## Agent 路径(复杂 Bug)
48
48
 
@@ -53,31 +53,111 @@ description: |
53
53
  - Loki 日志环境
54
54
  - Bug 描述 / 期望行为
55
55
 
56
- 步骤 2:并行启动 Agent(必须同时启动,不串行)
57
- ├── bug-analyzer Agent: 读代码分析根因,给出修复方案
58
- ├── mysql-runner Agent: 查数据库验证数据(如提供了DB信息)
59
- └── loki-runner Agent: Loki 日志验证线上行为(如提供了traceId)
56
+ 步骤 2(阶段一):并行启动 Agent
57
+ ├── bug-analyzer: 读代码分析根因
58
+ ├── loki-runner: 查 Loki 日志(有 traceId 时)
59
+ └── mysql-runner: 查数据库验证数据(有 DB 信息时)
60
60
 
61
- 步骤 3:汇总 Agent 结果 → 确认修复方案
61
+ 步骤 3(阶段二):日志驱动二次查询
62
+ 从 loki-runner 结果中提取:
63
+ ├── 表名(INSERT/UPDATE/DELETE/FROM/JOIN 后面的表名)
64
+ ├── 数据 ID(id=xxx、orderId=xxx 等)
65
+ ├── 租户 ID(tenantId、MERCHANT-ID 请求头)
66
+ └── SQL 语句片段
67
+ 如果提取到有效的表名+ID → 自动启动 mysql-runner 二次查询
62
68
 
63
- 步骤 4:修复代码
69
+ 步骤 4:汇总所有结果 → 输出排查报告(见下方模板)
64
70
 
65
- 步骤 5:走 git-workflow 提交
71
+ 步骤 5:⏸️ 等待用户确认修复方案
72
+
73
+ 步骤 6:用户确认后 → 修复代码
74
+
75
+ 步骤 7:走 git-workflow 提交
66
76
  ```
67
77
 
78
+ ## 排查报告模板(必须输出)
79
+
80
+ 无论简单还是复杂 Bug,修复代码前**必须先输出报告**:
81
+
82
+ ```markdown
83
+ ## 🔍 Bug 排查报告
84
+
85
+ ### 问题描述
86
+ {用户报告的现象}
87
+
88
+ ### 根因分析
89
+ {代码层面的根本原因,指出具体文件和行号}
90
+
91
+ ### 数据验证(如有)
92
+ {从日志/数据库中发现的关键数据,证实根因}
93
+
94
+ ### 修复方案
95
+ - 修改文件:`xxx.java` 第 N 行
96
+ - 修改内容:{具体改动描述}
97
+ - 影响范围:{改动是否影响其他功能}
98
+
99
+ ### 风险评估
100
+ - 低/中/高
101
+ - {风险说明}
102
+
103
+ ---
104
+ 确认修复请回复"修",需要调整方案请说明。
105
+ ```
106
+
107
+ **⚠️ 禁止跳过报告直接修改代码。必须等用户明确确认后才能开始修复。**
108
+
109
+ ## 阶段二:日志驱动二次查询
110
+
111
+ 当阶段一的 loki-runner 返回日志后,主会话检查日志内容:
112
+
113
+ ```
114
+ loki-runner 返回日志
115
+
116
+ ├─ 日志中包含 SQL/表名/数据ID?
117
+ │ │
118
+ │ ├─ 阶段一已启动 mysql-runner?
119
+ │ │ → 检查是否需要追加查询(不同的表或ID)
120
+ │ │ → 需要则启动新的 mysql-runner 查询
121
+ │ │
122
+ │ └─ 阶段一未启动 mysql-runner?
123
+ │ → 从日志提取表名+ID+租户ID
124
+ │ → 自动启动 mysql-runner 二次查询
125
+
126
+ └─ 日志中无数据库相关信息?
127
+ → 跳过,直接汇总现有结果
128
+ ```
129
+
130
+ ### 日志中常见的可提取信息
131
+
132
+ | 日志模式 | 提取内容 | 查询方式 |
133
+ |---------|---------|---------|
134
+ | `INSERT INTO order_info` | 表名 order_info | `SELECT * FROM order_info WHERE id = ?` |
135
+ | `UPDATE account SET balance=` | 表名 account | `SELECT * FROM account WHERE id = ?` |
136
+ | `orderId=123456` | 数据 ID | 按 ID 查对应表 |
137
+ | `MERCHANT-ID: 100` | 租户 ID | 切换到对应租户库查询 |
138
+ | `Duplicate entry 'xxx'` | 唯一键冲突 | 查重复数据 |
139
+ | `Data truncation` | 字段溢出 | 查表结构 `DESC table_name` |
140
+
68
141
  ## Agent 启动规则
69
142
 
70
- ### 必须并行(单条消息多个 Agent tool call)
143
+ ### 阶段一:必须并行(单条消息多个 Agent tool call)
71
144
 
72
145
  ```
73
- # 正确:一条消息同时启动 3 个 Agent
146
+ # 正确:一条消息同时启动
74
147
  Agent(bug-analyzer, "分析 xxx 代码的 bug...")
75
- Agent(mysql-runner, "查询 xxx 数据库验证...")
76
148
  Agent(loki-runner, "查询 traceId xxx 的日志...")
149
+ Agent(mysql-runner, "查询 xxx 数据库验证...")
77
150
 
78
151
  # 错误:串行启动(等一个完再启动下一个)
79
152
  ```
80
153
 
154
+ ### 阶段二:按需启动(阶段一结果返回后)
155
+
156
+ ```
157
+ # 从 loki-runner 结果中发现了表名和数据ID
158
+ Agent(mysql-runner, "根据日志发现涉及 order_info 表,查询 id=xxx 的数据...")
159
+ ```
160
+
81
161
  ### 各 Agent 职责
82
162
 
83
163
  | Agent | subagent_type | 职责 | 输入 |
@@ -106,50 +186,16 @@ Agent(loki-runner, "查询 traceId xxx 的日志...")
106
186
  └─ 配置文件不存在? → 创建模板文件(占位符) → 提示用户填写 → 等确认后继续
107
187
  ```
108
188
 
109
- **创建 MySQL 模板**:
110
- ```json
111
- {
112
- "environments": {
113
- "test21": {
114
- "name": "test21 测试环境",
115
- "host": "YOUR_HOST",
116
- "port": 3306,
117
- "user": "YOUR_USER",
118
- "password": "YOUR_PASSWORD",
119
- "db_prefix": "testcore_",
120
- "aliases": ["test21", "21"]
121
- }
122
- },
123
- "default": "test21",
124
- "mysql_path": "/opt/homebrew/opt/mysql-client/bin/mysql"
125
- }
126
- ```
127
-
128
- **创建 Loki 模板**:
129
- ```json
130
- {
131
- "active": "test13",
132
- "environments": {
133
- "test13": {
134
- "name": "测试13(主测试环境)",
135
- "url": "https://test13.xnzn.net/grafana",
136
- "token": "YOUR_TOKEN",
137
- "aliases": ["test13", "13"]
138
- }
139
- }
140
- }
141
- ```
142
-
143
189
  **敏感信息由用户手动填写,禁止 AI 将对话中的密码/token 写入配置文件。**
144
190
 
145
191
  ### 按信息量决定启动哪些 Agent
146
192
 
147
- | 用户提供的信息 | 启动的 Agent |
148
- |---------------|-------------|
149
- | 只有 Bug 描述 | bug-analyzer |
150
- | Bug 描述 + traceId | bug-analyzer + loki-runner |
151
- | Bug 描述 + DB 信息 | bug-analyzer + mysql-runner |
152
- | Bug 描述 + traceId + DB 信息 | bug-analyzer + mysql-runner + loki-runner(全部) |
193
+ | 用户提供的信息 | 阶段一启动 | 阶段二(日志驱动) |
194
+ |---------------|-----------|-----------------|
195
+ | 只有 Bug 描述 | bug-analyzer | — |
196
+ | Bug 描述 + traceId | bug-analyzer + loki-runner | 日志中有表名/ID → mysql-runner |
197
+ | Bug 描述 + DB 信息 | bug-analyzer + mysql-runner | — |
198
+ | Bug 描述 + traceId + DB 信息 | 全部 | 日志中有新表/ID → mysql-runner 追加查询 |
153
199
 
154
200
  ## 提交规则
155
201
 
@@ -161,6 +207,6 @@ Agent(loki-runner, "查询 traceId xxx 的日志...")
161
207
 
162
208
  ## 注意
163
209
 
164
- - 简单 Bug 不要过度编排,直接修就行
210
+ - 简单 Bug 不要过度编排,直接修就行(但仍需先报告再修复)
165
211
  - 如果用户没提供 DB/Loki 信息但 Bug 涉及数据问题,主动询问
166
212
  - 与 `bug-detective` 技能的区别:`bug-detective` 是排查指南,`fix-bug` 是全流程编排(包含排查+修复+提交)
@@ -140,7 +140,7 @@ print('Token updated for monitor-dev')
140
140
  ```bash
141
141
  TRACE_ID="a53dd0b0cc62bf4a79a63e77444f6f3f"
142
142
  END=$(date +%s)000000000
143
- START=$(( $(date +%s) - 86400 ))000000000
143
+ START=$(( $(date +%s) - 21600 ))000000000 # 最近6小时
144
144
 
145
145
  curl -s "${API}/query_range" \
146
146
  -H "Authorization: Bearer ${TOKEN}" \
@@ -172,7 +172,7 @@ else:
172
172
  ```bash
173
173
  API_PATH="/security/summary/order/mealtime/classify/page"
174
174
  END=$(date +%s)000000000
175
- START=$(( $(date +%s) - 3600 ))000000000 # 最近1小时
175
+ START=$(( $(date +%s) - 21600 ))000000000 # 最近6小时
176
176
 
177
177
  curl -s "${API}/query_range" \
178
178
  -H "Authorization: Bearer ${TOKEN}" \
@@ -221,7 +221,7 @@ if len(all_lines) > 30:
221
221
  ```bash
222
222
  KEYWORD="LeException"
223
223
  END=$(date +%s)000000000
224
- START=$(( $(date +%s) - 3600 ))000000000
224
+ START=$(( $(date +%s) - 21600 ))000000000 # 最近6小时
225
225
 
226
226
  curl -s "${API}/query_range" \
227
227
  -H "Authorization: Bearer ${TOKEN}" \
@@ -269,7 +269,7 @@ curl -s "${API}/query_range" \
269
269
  # Step 1: 找 traceId
270
270
  API_PATH="/api/v2/web/order/list"
271
271
  END=$(date +%s)000000000
272
- START=$(( $(date +%s) - 3600 ))000000000
272
+ START=$(( $(date +%s) - 21600 ))000000000 # 最近6小时
273
273
 
274
274
  TRACE_IDS=$(curl -s "${API}/query_range" \
275
275
  -H "Authorization: Bearer ${TOKEN}" \