@wwkit/harness 1.0.9 → 1.0.11

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/agents/extract.md +2 -14
  2. package/agents/lint.md +368 -0
  3. package/agents/pyit.md +361 -0
  4. package/agents/pyut.md +347 -0
  5. package/agents/query.md +2 -14
  6. package/agents/revise.md +2 -14
  7. package/agents/work.md +631 -0
  8. package/commands/fix.md +77 -0
  9. package/commands/git-sync.md +218 -0
  10. package/commands/net-port.md +364 -0
  11. package/commands/pyit.md +6 -0
  12. package/commands/pyut.md +6 -0
  13. package/commands/resume.md +104 -0
  14. package/package.json +4 -2
  15. package/plugins/work-bootstrap.js +77 -0
  16. package/scripts/work-review-package +50 -0
  17. package/scripts/work-task-brief +27 -0
  18. package/scripts/work-workspace +31 -0
  19. package/skills/better-skill/SKILL.md +124 -0
  20. package/skills/blame-skill/SKILL.md +201 -0
  21. package/skills/lint-ai-fix/SKILL.md +141 -0
  22. package/skills/lint-config-setup/SKILL.md +106 -0
  23. package/skills/lint-config-setup/references/languages/js.md +110 -0
  24. package/skills/lint-config-setup/references/languages/py.md +89 -0
  25. package/skills/lint-env-ensure/SKILL.md +92 -0
  26. package/skills/lint-env-ensure/references/config.md +65 -0
  27. package/skills/lint-language-detect/SKILL.md +79 -0
  28. package/skills/lint-language-detect/references/detect-language.js +65 -0
  29. package/skills/lint-rules-analyze/SKILL.md +129 -0
  30. package/skills/lint-suitability-check/SKILL.md +84 -0
  31. package/skills/lint-tool-fix/SKILL.md +94 -0
  32. package/skills/new-skill/SKILL.md +227 -0
  33. package/skills/new-skill/references/template.md +53 -0
  34. package/skills/new-skill/references/workflow-patterns.md +104 -0
  35. package/skills/pytest-case-create/SKILL.md +327 -0
  36. package/skills/pytest-case-create/references/test-standards.md +244 -0
  37. package/skills/pytest-case-fix/SKILL.md +274 -0
  38. package/skills/pytest-coverage-analyze/SKILL.md +226 -0
  39. package/skills/pytest-coverage-analyze/references/scoring-rules.md +57 -0
  40. package/skills/pytest-env-ensure/SKILL.md +198 -0
  41. package/skills/pytest-env-ensure/references/config.md +145 -0
  42. package/skills/pytest-execute/SKILL.md +155 -0
  43. package/skills/pytest-sample/SKILL.md +164 -0
  44. package/skills/pytest-sample/references/src/pytest-sample/Calculator.py +67 -0
  45. package/skills/pytest-sample/references/src/pytest-sample/ConfigManager.py +68 -0
  46. package/skills/pytest-sample/references/src/pytest-sample/FileProcessor.py +53 -0
  47. package/skills/pytest-sample/references/src/pytest-sample/OrderService.py +82 -0
  48. package/skills/pytest-sample/references/src/pytest-sample/TokenGenerator.py +50 -0
  49. package/skills/pytest-sample/references/src/pytest-sample/UserService.py +45 -0
  50. package/skills/pytest-sample/references/src/pytest-sample/__init__.py +0 -0
  51. package/skills/pytest-suitability-check/SKILL.md +224 -0
  52. package/skills/read-docs/SKILL.md +134 -0
  53. package/skills/read-docs/references/opencode/agents/cases.md +206 -0
  54. package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -0
  55. package/skills/read-docs/references/opencode/agents/detail.md +191 -0
  56. package/skills/read-docs/references/opencode/agents/examples.md +100 -0
  57. package/skills/read-docs/references/opencode/agents/index.md +309 -0
  58. package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -0
  59. package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -0
  60. package/skills/read-docs/references/opencode/agents/workflow.md +161 -0
  61. package/skills/read-docs/references/opencode/cli/commands/acp.md +32 -0
  62. package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -0
  63. package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -0
  64. package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -0
  65. package/skills/read-docs/references/opencode/cli/commands/others.md +49 -0
  66. package/skills/read-docs/references/opencode/cli/commands/plugin.md +13 -0
  67. package/skills/read-docs/references/opencode/cli/commands/provider.md +44 -0
  68. package/skills/read-docs/references/opencode/cli/commands/run.md +81 -0
  69. package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -0
  70. package/skills/read-docs/references/opencode/cli/commands/session.md +38 -0
  71. package/skills/read-docs/references/opencode/cli/commands/web.md +15 -0
  72. package/skills/read-docs/references/opencode/cli/env.md +39 -0
  73. package/skills/read-docs/references/opencode/cli/index.md +19 -0
  74. package/skills/read-docs/references/opencode/cli/tui.md +35 -0
  75. package/skills/read-docs/references/opencode/commands/examples.md +42 -0
  76. package/skills/read-docs/references/opencode/commands/index.md +185 -0
  77. package/skills/read-docs/references/opencode/config/provider.md +152 -0
  78. package/skills/read-docs/references/opencode/formatter/index.md +71 -0
  79. package/skills/read-docs/references/opencode/guide/config.md +419 -0
  80. package/skills/read-docs/references/opencode/guide/formatters.md +70 -0
  81. package/skills/read-docs/references/opencode/guide/index.md +37 -0
  82. package/skills/read-docs/references/opencode/guide/providers.md +31 -0
  83. package/skills/read-docs/references/opencode/guide/rules.md +63 -0
  84. package/skills/read-docs/references/opencode/plugins/examples.md +75 -0
  85. package/skills/read-docs/references/opencode/plugins/index.md +188 -0
  86. package/skills/read-docs/references/opencode/reference/index.md +119 -0
  87. package/skills/read-docs/references/opencode/rule/index.md +78 -0
  88. package/skills/read-docs/references/opencode/skills/detail.md +113 -0
  89. package/skills/read-docs/references/opencode/skills/examples.md +141 -0
  90. package/skills/read-docs/references/opencode/skills/index.md +126 -0
  91. package/skills/read-docs/references/opencode/skills/workflow.md +146 -0
  92. package/skills/read-docs/references/opencode/tests/agent.md +10 -0
  93. package/skills/read-docs/references/opencode/tests/config.md +60 -0
  94. package/skills/read-docs/references/opencode/tests/file.md +12 -0
  95. package/skills/read-docs/references/opencode/tests/serve.md +18 -0
  96. package/skills/read-docs/references/opencode/tests/session.md +31 -0
  97. package/skills/read-docs/references/opencode/tests/web.md +17 -0
  98. package/skills/read-docs/references/opencode/tools/arguments.md +305 -0
  99. package/skills/read-docs/references/opencode/tools/context.md +18 -0
  100. package/skills/read-docs/references/opencode/tools/custom.md +111 -0
  101. package/skills/read-docs/references/opencode/tools/detail.md +104 -0
  102. package/skills/read-docs/references/opencode/tools/examples.md +71 -0
  103. package/skills/read-docs/references/opencode/tools/index.md +56 -0
  104. package/skills/read-docs/references/opencode/tools/lsp.md +26 -0
  105. package/skills/read-docs/references/opencode/tools/mcp.md +132 -0
  106. package/skills/read-docs/references/opencode/train/README.md +135 -0
  107. package/skills/read-docs/references/opencode/train/agent-basic.md +772 -0
  108. package/skills/read-docs/references/opencode/train/command-basic.md +668 -0
  109. package/skills/read-docs/references/opencode/train/config-basic.md +509 -0
  110. package/skills/read-docs/references/opencode/train/index.md +164 -0
  111. package/skills/read-docs/references/opencode/train/practice.md +873 -0
  112. package/skills/read-docs/references/opencode/train/skill-basic.md +608 -0
  113. package/skills/read-docs/references/opencode/tui/commands/config.md +32 -0
  114. package/skills/read-docs/references/opencode/tui/commands/editor.md +47 -0
  115. package/skills/read-docs/references/opencode/tui/commands/index.md +125 -0
  116. package/skills/read-docs/references/opencode/tui/commands/init.md +5 -0
  117. package/skills/read-docs/references/opencode/tui/index.md +26 -0
  118. package/skills/read-docs/references/superpowers/bootstrap.md +107 -0
  119. package/skills/read-docs/references/superpowers/comparison.md +77 -0
  120. package/skills/read-docs/references/superpowers/context.md +71 -0
  121. package/skills/read-docs/references/superpowers/index.md +58 -0
  122. package/skills/read-docs/references/superpowers/parallel.md +49 -0
  123. package/skills/read-docs/references/superpowers/sdd.md +183 -0
  124. package/skills/read-docs/references/superpowers/skills.md +68 -0
  125. package/skills/read-docs/references/superpowers/workflow.md +83 -0
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: lint-ai-fix
3
+ description: |
4
+ 对 linter 无法自动修复的违规进行 AI 语义修复。内部管理 fix→验证→复检 的 loop(max 3),
5
+ 每次修改后做语法验证,失败则 git checkout 回滚并记人工处理项。agent 只接收最终输出。
6
+ 适用:lint agent 的 AI 修复阶段,处理 lint-tool-fix 的剩余违规。
7
+ 不适用:linter --fix 可修复的违规(使用 lint-tool-fix)、规则检查(使用 lint-rules-analyze)。
8
+ ---
9
+
10
+ # Lint AI 语义修复
11
+
12
+ ## 工作流模式
13
+
14
+ 内部迭代执行(max 3 轮),4 个阶段。
15
+
16
+ ## 输入
17
+
18
+ | 参数 | 必填 | 类型 | 说明 |
19
+ |------|------|------|------|
20
+ | remaining_violations | 是 | array | lint-tool-fix 输出的剩余违规列表 |
21
+ | target_dir | 是 | string | 检查目标目录路径 |
22
+ | root_dir | 是 | string | 工程根目录路径 |
23
+ | primary_language | 是 | string | 主语言(`jsts` 或 `python`) |
24
+ | config_file_path | 是 | string | lint 配置文件路径 |
25
+
26
+ ## 输出
27
+
28
+ - `ai_fixed_count`:AI 修复的违规数
29
+ - `final_violations`:修复后剩余的违规列表(结构同输入)
30
+ - `manual_items`:无法修复的人工处理项列表,每条含 `{ ...violation, fix_attempted, reason }`
31
+
32
+ ## 内部 Loop(max 3)
33
+
34
+ ```
35
+ inner_round 1: 逐条修复 → 语法验证 → linter 复检
36
+ inner_round 2: 逐条修复 → 语法验证 → linter 复检
37
+ inner_round 3: 逐条修复 → 语法验证 → linter 复检
38
+
39
+ 退出条件:
40
+ - 0 违规 → 成功退出
41
+ - 无改进(违规数 >= 轮首) → 退出,输出 manual_items
42
+ - inner_round = 3 → 超限退出,输出 manual_items
43
+ ```
44
+
45
+ ## 阶段一:逐条分析修复
46
+
47
+ 对 `remaining_violations` 中的每条违规:
48
+
49
+ 1. 分析违规规则和上下文
50
+ 2. 修改源码文件以消除违规
51
+ 3. 记录修改的文件和修复内容
52
+
53
+ ### 修复策略
54
+
55
+ | 规则类型 | 修复策略 |
56
+ |---------|---------|
57
+ | 未使用变量/import | 删除未使用的声明 |
58
+ | 未定义变量 | 添加定义或修正引用 |
59
+ | debugger 语句 | 删除 debugger |
60
+ | 空语句块 | 添加注释或实现 |
61
+ | 比较使用 None/True/False | 改为 is/is not |
62
+ | 其他规则 | 按规则语义最小改动修复 |
63
+
64
+ ## 阶段二:语法验证
65
+
66
+ 每次修改文件后,执行语法验证:
67
+
68
+ | 主语言 | 验证命令 |
69
+ |--------|---------|
70
+ | jsts | `node --check {file}` |
71
+ | python | `python3 -m py_compile {file}` |
72
+
73
+ | 条件 | 动作 |
74
+ |------|------|
75
+ | 语法验证通过 | 继续阶段三 |
76
+ | 语法验证失败 | `git checkout {file}` 回滚,标记为 manual_item,跳过该文件 |
77
+
78
+ ## 阶段三:linter 复检
79
+
80
+ 对所有修改的文件重新执行 linter 检查(同 lint-rules-analyze 命令),获取当前违规数。
81
+
82
+ ## 阶段四:退出判断
83
+
84
+ | 条件 | 动作 |
85
+ |------|------|
86
+ | 当前违规数 = 0 | 成功退出,输出 ai_fixed_count + 空 final_violations |
87
+ | 当前违规数 >= 轮首违规数 | 无改进退出,输出 final_violations + manual_items |
88
+ | inner_round = 3 | 超限退出,输出 final_violations + manual_items |
89
+ | 否则 | inner_round++,回到阶段一 |
90
+
91
+ ## 输出格式
92
+
93
+ ```
94
+ ## AI 修复结果
95
+
96
+ - AI 修复数: X
97
+ - 最终违规数: X
98
+ - 人工处理项: X
99
+
100
+ ### 修复记录
101
+ | # | 文件 | 规则 | 修复内容 |
102
+ |---|------|------|---------|
103
+ | 1 | src/foo.js | no-unused-vars | 删除未使用变量 x |
104
+
105
+ ### 人工处理项
106
+ | # | 文件 | 行号 | 规则 | 原因 |
107
+ |---|------|------|------|------|
108
+ | 1 | src/bar.js | 20 | no-console | 需确认是否保留 console.log |
109
+ ```
110
+
111
+ ## 决策
112
+
113
+ | 条件 | 动作 |
114
+ |------|------|
115
+ | final_violations 为空 | agent 回到轮尾评分(final_count 应为 0 → 达标) |
116
+ | final_violations 非空 | agent 回到轮尾评分(独立验证) |
117
+
118
+ ## 失败处理
119
+
120
+ | 场景 | 处理方式 |
121
+ |------|---------|
122
+ | 源码修改后语法失败 | git checkout 回滚,记 manual_item |
123
+ | linter 复检失败 | 使用上一次的违规列表作为 final_violations |
124
+ | git checkout 失败 | 报错,保留当前状态,记 manual_item |
125
+ | 文件只读 | 记 manual_item,跳过 |
126
+
127
+ ## 一定要做
128
+
129
+ 1. 每次修改后必须做语法验证
130
+ 2. 语法验证失败必须 git checkout 回滚
131
+ 3. 内部 loop 退出条件清晰(0 违规/无改进/超限)
132
+ 4. 输出 manual_items 含 fix_attempted 和 reason
133
+ 5. 修复是最小改动,不做重构
134
+
135
+ ## 一定不要做
136
+
137
+ 1. 不要做大规模重构
138
+ 2. 不要修改非违规文件的代码
139
+ 3. 不要跳过语法验证
140
+ 4. 不要在语法验证失败时不回滚
141
+ 5. 不要执行网络请求
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: lint-config-setup
3
+ description: |
4
+ 生成或补全 lint 配置文件。读取语言规则清单,按初始启用规则生成 eslint.config.js 或 ruff.toml。
5
+ 已有配置文件时只追加缺失的启用规则,不覆盖用户自定义规则。
6
+ 适用:lint agent 的配置生成阶段,在规则分析前确保配置文件存在且包含初始规则集。
7
+ 不适用:非 lint 场景的配置生成、手动配置调优。
8
+ ---
9
+
10
+ # Lint 配置生成
11
+
12
+ ## 工作流模式
13
+
14
+ 顺序执行,4 个阶段。
15
+
16
+ ## 输入
17
+
18
+ | 参数 | 必填 | 类型 | 说明 |
19
+ |------|------|------|------|
20
+ | root_dir | 是 | string | 工程根目录路径 |
21
+ | primary_language | 是 | string | 主语言(`jsts` 或 `python`) |
22
+
23
+ ## 输出
24
+
25
+ - `config_file_path`:配置文件绝对路径
26
+ - `enabled_rules`:已启用的规则列表
27
+ - `total_rules`:规则清单中的全量规则数
28
+ - `config_generated`:是否新建配置(true=新建,false=已有补全)
29
+
30
+ ## 阶段一:加载规则清单
31
+
32
+ 读取 `references/languages/{primary_language}.md`,解析规则清单表格:
33
+
34
+ | 主语言 | 规则文件 | 配置文件名 |
35
+ |--------|---------|-----------|
36
+ | jsts | `references/languages/js.md` | `eslint.config.js` |
37
+ | python | `references/languages/py.md` | `ruff.toml` |
38
+
39
+ 提取所有"初始启用"标记为 ✓ 的规则。
40
+
41
+ ## 阶段二:检查已有配置
42
+
43
+ 检查 `root_dir` 下是否已有配置文件:
44
+
45
+ | 主语言 | 检查文件 |
46
+ |--------|---------|
47
+ | jsts | `eslint.config.js`、`.eslintrc.json`、`.eslintrc.js` |
48
+ | python | `ruff.toml`、`pyproject.toml`(含 `[tool.ruff]` 段) |
49
+
50
+ ## 阶段三:生成或补全
51
+
52
+ | 条件 | 动作 |
53
+ |------|------|
54
+ | 无配置文件 | 从模板生成新配置文件,写入初始启用规则,`config_generated = true` |
55
+ | 有配置文件 | 读取已有规则,追加缺失的初始启用规则(不覆盖用户自定义),`config_generated = false` |
56
+
57
+ ### 生成模板
58
+
59
+ jsts → `eslint.config.js`(flat config 格式):
60
+ ```javascript
61
+ import js from '@eslint/js';
62
+ export default [
63
+ js.configs.recommended,
64
+ { rules: { /* 初始启用规则 */ } },
65
+ ];
66
+ ```
67
+
68
+ python → `ruff.toml`:
69
+ ```toml
70
+ [lint]
71
+ select = ["F401", "F811", "F841", "E711"]
72
+ ```
73
+
74
+ ## 阶段四:输出
75
+
76
+ 输出配置文件路径、已启用规则列表、全量规则数、是否新建。
77
+
78
+ ## 决策
79
+
80
+ | 条件 | 动作 |
81
+ |------|------|
82
+ | 生成/补全成功 | 输出结果,流程结束 |
83
+ | 生成失败 | 报错,agent 退出 |
84
+ | 规则清单文件缺失 | 报错"规则清单文件不存在",agent 退出 |
85
+
86
+ ## 失败处理
87
+
88
+ | 场景 | 处理方式 |
89
+ |------|---------|
90
+ | 规则清单文件不存在 | 报错退出 |
91
+ | 配置文件写入失败 | 报错退出 |
92
+ | 已有配置解析失败 | 报错退出,提示用户检查配置文件格式 |
93
+
94
+ ## 一定要做
95
+
96
+ 1. 从规则清单文件读取初始启用规则
97
+ 2. 已有配置只追加缺失规则,不覆盖用户自定义
98
+ 3. eslint.config.js 使用 flat config 格式(ESLint 9+)
99
+ 4. 输出 config_generated 标识新建 vs 补全
100
+
101
+ ## 一定不要做
102
+
103
+ 1. 不要覆盖用户已有的自定义规则
104
+ 2. 不要修改非配置文件
105
+ 3. 不要写入初始未启用的规则
106
+ 4. 不要执行网络请求
@@ -0,0 +1,110 @@
1
+ # JS/TS ESLint 规则清单
2
+
3
+ ## 工具信息
4
+
5
+ | 项 | 值 |
6
+ |---|---|
7
+ | 工具 | ESLint |
8
+ | 安装 | `npm install -D eslint` |
9
+ | TS 扩展 | `npm install -D @typescript-eslint/parser @typescript-eslint/eslint-plugin` |
10
+ | 配置文件 | `eslint.config.js`(flat config,ESLint 9+) |
11
+ | 检查命令 | `npx eslint {target_dir} --format json` |
12
+ | 修复命令 | `npx eslint {target_dir} --fix` |
13
+ | 输出格式 | JSON 数组,每元素含 `filePath` + `messages[]` |
14
+
15
+ ## ESLint JSON 输出解析
16
+
17
+ ```json
18
+ [
19
+ {
20
+ "filePath": "/abs/path/to/file.js",
21
+ "messages": [
22
+ {
23
+ "ruleId": "no-unused-vars",
24
+ "severity": 2,
25
+ "message": "'x' is defined but never used",
26
+ "line": 10,
27
+ "column": 5,
28
+ "fix": { "range": [100, 110], "text": "" }
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ ```
34
+
35
+ - `severity`: 1 = warning, 2 = error
36
+ - `fix` 存在 = 可自动修复(`fixable = true`)
37
+
38
+ ## 规则清单
39
+
40
+ > 初始启用标记 ✓ 的规则在配置生成时写入 config 文件;✗ 的规则仅记录在清单中,后续可逐步放开。
41
+
42
+ ### Possible Errors
43
+
44
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
45
+ |------|------|---------|---------|--------|
46
+ | no-unused-vars | 禁止未使用的变量 | error | ✓ | ✗ |
47
+ | no-undef | 禁止未定义的变量 | error | ✓ | ✗ |
48
+ | no-cond-assign | 禁止条件表达式中赋值 | error | ✗ | ✓ |
49
+ | no-debugger | 禁止 debugger 语句 | error | ✓ | ✗ |
50
+ | no-dupe-keys | 禁止对象字面量重复键 | error | ✗ | ✓ |
51
+ | no-dupe-args | 禁止函数参数重复 | error | ✗ | ✓ |
52
+ | no-empty | 禁止空语句块 | error | ✓ | ✓ |
53
+ | no-extra-semi | 禁止多余分号 | error | ✗ | ✓ |
54
+ | no-irregular-whitespace | 禁止不规则的空白字符 | error | ✗ | ✗ |
55
+ | no-unreachable | 禁止 return 后的不可达代码 | error | ✗ | ✓ |
56
+
57
+ ### Best Practices
58
+
59
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
60
+ |------|------|---------|---------|--------|
61
+ | no-console | 禁止 console | warn | ✗ | ✓ |
62
+ | no-constant-condition | 禁止常量条件表达式 | error | ✗ | ✗ |
63
+ | no-dupe-else-if | 禁止重复的 else if | error | ✗ | ✓ |
64
+ | no-empty-pattern | 禁止空解构模式 | error | ✗ | ✓ |
65
+ | no-ex-assign | 禁止 catch 中重新赋值异常 | error | ✗ | ✓ |
66
+ | no-fallthrough | 禁止 switch 穿透 | error | ✗ | ✗ |
67
+ | no-redeclare | 禁止重复声明 | error | ✗ | ✓ |
68
+ | no-useless-return | 禁止无用的 return | error | ✗ | ✓ |
69
+ | eqeqeq | 要求严格相等 === | error | ✗ | ✓ |
70
+ | prefer-const | 优先使用 const | error | ✗ | ✓ |
71
+
72
+ ### Stylistic Issues
73
+
74
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
75
+ |------|------|---------|---------|--------|
76
+ | semi | 分号一致性 | warn | ✗ | ✓ |
77
+ | quotes | 引号一致性 | warn | ✗ | ✓ |
78
+ | indent | 缩进一致性 | warn | ✗ | ✓ |
79
+ | no-trailing-spaces | 禁止行尾空格 | warn | ✗ | ✓ |
80
+ | eol-last | 文件末尾换行 | warn | ✗ | ✓ |
81
+ | no-multiple-empty-lines | 禁止多个空行 | warn | ✗ | ✓ |
82
+
83
+ ### ES6+
84
+
85
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
86
+ |------|------|---------|---------|--------|
87
+ | no-const-assign | 禁止修改 const | error | ✗ | ✗ |
88
+ | no-dupe-class-members | 禁止重复类成员 | error | ✗ | ✓ |
89
+ | no-var | 禁止 var | error | ✗ | ✓ |
90
+ | prefer-arrow-callback | 优先箭头函数回调 | warn | ✗ | ✓ |
91
+
92
+ ## 配置文件模板(eslint.config.js)
93
+
94
+ ```javascript
95
+ import js from '@eslint/js';
96
+
97
+ export default [
98
+ js.configs.recommended,
99
+ {
100
+ rules: {
101
+ 'no-unused-vars': 'error',
102
+ 'no-undef': 'error',
103
+ 'no-debugger': 'error',
104
+ 'no-empty': 'error',
105
+ },
106
+ },
107
+ ];
108
+ ```
109
+
110
+ > 仅写入初始启用 ✓ 的规则。用户已有配置文件时只追加缺失规则,不覆盖。
@@ -0,0 +1,89 @@
1
+ # Python Ruff 规则清单
2
+
3
+ ## 工具信息
4
+
5
+ | 项 | 值 |
6
+ |---|---|
7
+ | 工具 | Ruff |
8
+ | 安装 | `pip install ruff` 或 `uv add --dev ruff` |
9
+ | 配置文件 | `ruff.toml` |
10
+ | 检查命令 | `ruff check {target_dir} --output-format json` |
11
+ | 修复命令 | `ruff check {target_dir} --fix` |
12
+ | 输出格式 | JSON 数组,每元素含 code/message/filename/location |
13
+
14
+ ## Ruff JSON 输出解析
15
+
16
+ ```json
17
+ [
18
+ {
19
+ "code": "F401",
20
+ "message": "'os' imported but unused",
21
+ "filename": "/abs/path/to/file.py",
22
+ "location": [10, 1],
23
+ "end_location": [10, 10],
24
+ "fix": null
25
+ }
26
+ ]
27
+ ```
28
+
29
+ - `fix` 非 null = 可自动修复(`fixable = true`)
30
+ - severity 映射:F 前缀 = error,E 前缀 = error,W 前缀 = warning,UP 前缀 = warning
31
+
32
+ ## 规则清单
33
+
34
+ > 初始启用标记 ✓ 的规则在配置生成时写入 config 文件;✗ 的规则仅记录在清单中,后续可逐步放开。
35
+
36
+ ### Pyflakes (F)
37
+
38
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
39
+ |------|------|---------|---------|--------|
40
+ | F401 | 未使用的 import | error | ✓ | ✓ |
41
+ | F811 | 重定义未使用的名称 | error | ✓ | ✓ |
42
+ | F841 | 未使用的局部变量 | error | ✓ | ✓ |
43
+ | F501 | f-string 无占位符 | error | ✗ | ✓ |
44
+ | F541 | f-string 无占位符 | error | ✗ | ✓ |
45
+ | F601 | 字典字面量重复键 | error | ✗ | ✓ |
46
+ | F621 | 参数列表解包重复 | error | ✗ | ✗ |
47
+ | F622 | 星号后重复参数 | error | ✗ | ✗ |
48
+ | F633 | 非法 __future__ import | error | ✗ | ✗ |
49
+ | F701 | break 在循环外 | error | ✗ | ✗ |
50
+ | F821 | 未定义名称 | error | ✗ | ✗ |
51
+ | F822 | __all__ 中未定义名称 | error | ✗ | ✗ |
52
+
53
+ ### Pycodestyle (E/W)
54
+
55
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
56
+ |------|------|---------|---------|--------|
57
+ | E711 | 比较使用 None 应为 is None | error | ✓ | ✓ |
58
+ | E712 | 比较使用 True/False 应为 is | error | ✗ | ✓ |
59
+ | E713 | not in 应替代 not ... in | error | ✗ | ✓ |
60
+ | E714 | is not 应替代 not ... is | error | ✗ | ✓ |
61
+ | E501 | 行过长(默认 88 字符) | warn | ✗ | ✗ |
62
+ | E302 | 预期 2 个空行 | warn | ✗ | ✓ |
63
+ | E303 | 函数间空行过多 | warn | ✗ | ✓ |
64
+ | E305 | 函数/类后 2 个空行 | warn | ✗ | ✓ |
65
+ | W291 | 行尾空格 | warn | ✗ | ✓ |
66
+ | W292 | 文件末尾无换行 | warn | ✗ | ✓ |
67
+ | W293 | 空行有空白字符 | warn | ✗ | ✓ |
68
+
69
+ ### Pyupgrade (UP)
70
+
71
+ | 规则 | 描述 | 默认级别 | 初始启用 | 可 fix |
72
+ |------|------|---------|---------|--------|
73
+ | UP001 | 过时的 __future__ import | warn | ✗ | ✓ |
74
+ | UP010 | 过时的 __future__ union types | warn | ✗ | ✓ |
75
+ | UP011 | 不必要的 lru_cache 括号 | warn | ✗ | ✓ |
76
+ | UP015 | 不必要的 open 模式 | warn | ✗ | ✓ |
77
+
78
+ ## 配置文件模板(ruff.toml)
79
+
80
+ ```toml
81
+ [lint]
82
+ # 初始启用规则
83
+ select = ["F401", "F811", "F841", "E711"]
84
+
85
+ [lint.fix]
86
+ unsafe-fixes = false
87
+ ```
88
+
89
+ > 仅写入初始启用 ✓ 的规则。用户已有配置文件时只追加缺失规则,不覆盖。
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: lint-env-ensure
3
+ description: |
4
+ 检查 lint 工具可用性,缺失时在项目内自动安装。按主语言检查对应 linter(jsts→eslint,python→ruff),
5
+ 安装失败重试 3 次。加载配置清单供后续 skill 共享。
6
+ 适用:lint agent 的环境检查阶段,在配置生成和规则分析前确保工具可用。
7
+ 不适用:非 lint 场景的环境检查、系统级工具安装。
8
+ ---
9
+
10
+ # Lint 环境检查
11
+
12
+ ## 工作流模式
13
+
14
+ 顺序执行,4 个阶段。
15
+
16
+ ## 输入
17
+
18
+ | 参数 | 必填 | 类型 | 说明 |
19
+ |------|------|------|------|
20
+ | root_dir | 是 | string | 工程根目录路径 |
21
+ | primary_language | 是 | string | 主语言(`jsts` 或 `python`) |
22
+
23
+ ## 输出
24
+
25
+ - `linter_name`:linter 名称(`eslint` 或 `ruff`)
26
+ - `linter_version`:linter 版本号
27
+ - `linter_installed`:是否已安装且可用(bool)
28
+ - `config`:从 references/config.md 加载的配置对象
29
+
30
+ ## 阶段一:检查工具可用性
31
+
32
+ 按 `primary_language` 检查对应 linter:
33
+
34
+ | 主语言 | linter | 检查命令 |
35
+ |--------|--------|---------|
36
+ | jsts | eslint | `npx eslint --version` |
37
+ | python | ruff | `ruff --version` |
38
+
39
+ ## 阶段二:自动安装(工具缺失时)
40
+
41
+ 工具不可用时,在项目内安装:
42
+
43
+ | 主语言 | 安装命令 | 备注 |
44
+ |--------|---------|------|
45
+ | jsts | `cd {root_dir} && npm install -D eslint` | TS 项目额外安装 `@typescript-eslint/parser @typescript-eslint/eslint-plugin` |
46
+ | python | `cd {root_dir} && pip install ruff` 或 `cd {root_dir} && uv add --dev ruff` | 优先用 uv,回退到 pip |
47
+
48
+ 安装失败时重试,最多 3 次(`install_retry` 来自 config)。
49
+
50
+ ## 阶段三:安装验证
51
+
52
+ 重新执行阶段一的检查命令,确认安装成功。
53
+
54
+ | 条件 | 动作 |
55
+ |------|------|
56
+ | 工具可用 | 输出 linter_name/version/installed=true,继续 |
57
+ | 工具仍不可用 | 输出 installed=false,agent 退出 |
58
+
59
+ ## 阶段四:加载配置
60
+
61
+ 读取 `references/config.md`,输出配置对象供后续 skill 使用。
62
+
63
+ ## 决策
64
+
65
+ | 条件 | 动作 |
66
+ |------|------|
67
+ | 工具已安装 | 输出结果,流程结束 |
68
+ | 工具缺失,安装成功 | 输出结果,流程结束 |
69
+ | 工具缺失,安装失败 | 输出 installed=false,agent 退出 |
70
+
71
+ ## 失败处理
72
+
73
+ | 场景 | 处理方式 |
74
+ |------|---------|
75
+ | 检查命令执行失败 | 认为工具未安装,进入安装流程 |
76
+ | npm install 失败 | 重试最多 3 次 |
77
+ | pip install 失败 | 尝试 uv add,再失败则重试 |
78
+ | 重试 3 次仍失败 | 输出 installed=false |
79
+
80
+ ## 一定要做
81
+
82
+ 1. 在项目内安装(`npm install -D`),不安装全局
83
+ 2. 安装后必须重新验证工具可用性
84
+ 3. 加载 config.md 配置供后续 skill 共享
85
+ 4. TS 项目检查是否需要 @typescript-eslint 插件
86
+
87
+ ## 一定不要做
88
+
89
+ 1. 不要全局安装工具(`npm install -g`)
90
+ 2. 不要跳过安装验证步骤
91
+ 3. 不要修改项目配置文件(package.json 等)
92
+ 4. 不要使用 webfetch 下载工具,仅通过包管理器(npm/pip/uv)安装
@@ -0,0 +1,65 @@
1
+ # lint 检查代理配置清单
2
+
3
+ > 本文件是 lint 代理的全局配置,agent 启动时首先读取,后续所有 skill 共享。
4
+
5
+ ## 依赖工具
6
+
7
+ ### JS/TS
8
+
9
+ | name | check | required | install |
10
+ |------|-------|----------|---------|
11
+ | eslint | `npx eslint --version` | true | `npm install -D eslint` |
12
+ | @typescript-eslint/parser | `npx tsc --version` 时需要 | false | `npm install -D @typescript-eslint/parser @typescript-eslint/eslint-plugin` |
13
+
14
+ ### Python
15
+
16
+ | name | check | required | install |
17
+ |------|-------|----------|---------|
18
+ | ruff | `ruff --version` | true | `pip install ruff` 或 `uv add --dev ruff` |
19
+
20
+ ## 环境检查
21
+
22
+ | 参数 | 值 | 说明 |
23
+ |------|-----|------|
24
+ | install_retry | 3 | 工具安装失败重试次数 |
25
+
26
+ ## Loop 控制
27
+
28
+ | 参数 | 值 | 说明 |
29
+ |------|-----|------|
30
+ | outer_max | 3 | 外层 loop(check→fix→recheck)最大轮次 |
31
+ | inner_max | 3 | lint-ai-fix 内部 loop 最大轮次 |
32
+
33
+ ## 评分模型
34
+
35
+ | 参数 | 值 | 说明 |
36
+ |------|-----|------|
37
+ | target_score | 100 | 二元制:0 违规=100,1+ 违规=0 |
38
+ | pass_threshold | 0 | 违规数达标线(0 = 全部通过) |
39
+
40
+ ## 命名规则
41
+
42
+ | 参数 | 值 | 说明 |
43
+ |------|-----|------|
44
+ | report_dir_pattern | `{root_dir}/.webwork/harness/lint/{YYYY-MM-DD}/` | 报告输出目录 |
45
+ | report.lint_report | `lint_report-{HHMMSS}.md` | 最终报告文件名 |
46
+
47
+ ## 语言映射
48
+
49
+ | 语言 | 标识 | 扩展名 | manifest | linter | config_file |
50
+ |------|------|--------|----------|--------|-------------|
51
+ | JS/TS/Vue | jsts | .js .jsx .ts .tsx .vue .mjs .cjs | package.json | eslint | eslint.config.js |
52
+ | Python | python | .py | pyproject.toml / setup.py | ruff | ruff.toml |
53
+
54
+ ## 排除目录
55
+
56
+ ```
57
+ node_modules/ dist/ build/ .git/ __pycache__/ .venv/ venv/ .webwork/ reports/ coverage/ .next/ .nuxt/ .output/ .eggs/ eggs/
58
+ ```
59
+
60
+ ## 语法验证命令
61
+
62
+ | 语言 | 命令 | 说明 |
63
+ |------|------|------|
64
+ | jsts | `node --check {file}` | Node.js 语法检查 |
65
+ | python | `python3 -m py_compile {file}` | Python 字节码编译检查 |
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: lint-language-detect
3
+ description: |
4
+ 探测工程主语言。优先检查 manifest 文件(package.json → jsts,pyproject.toml/setup.py → python),
5
+ 无 manifest 时按源码文件扩展名计数,多者为主语言。JS/TS 视为一种语言。
6
+ 适用:lint agent 的语言探测阶段,在环境检查和配置生成前确定主语言。
7
+ 不适用:非 lint 场景的语言检测、混合语言项目(v1 按主语言处理,不支持混合)。
8
+ ---
9
+
10
+ # 主语言探测
11
+
12
+ ## 工作流模式
13
+
14
+ 顺序执行,2 个阶段。
15
+
16
+ ## 输入
17
+
18
+ | 参数 | 必填 | 类型 | 说明 |
19
+ |------|------|------|------|
20
+ | root_dir | 是 | string | 工程根目录路径 |
21
+
22
+ ## 输出
23
+
24
+ - `primary_language`:主语言标识(`jsts` 或 `python`)
25
+ - `detection_method`:检测方式(`manifest` 或 `file_count`)
26
+ - `file_counts`:各语言源码文件计数(仅 `file_count` 方式时有值)
27
+
28
+ ## 阶段一:Manifest 检测
29
+
30
+ 检查 `root_dir` 下的 manifest 文件:
31
+
32
+ | 检查项 | 命中结果 |
33
+ |--------|---------|
34
+ | `package.json` 存在 | `primary_language = jsts`,`detection_method = manifest` |
35
+ | `pyproject.toml` 存在 | `primary_language = python`,`detection_method = manifest` |
36
+ | `setup.py` 存在 | `primary_language = python`,`detection_method = manifest` |
37
+
38
+ 若 manifest 命中,直接输出结果,跳过阶段二。
39
+
40
+ ## 阶段二:文件计数检测
41
+
42
+ 无 manifest 时,调用 `references/detect-language.js` 的 `detectLanguage(rootDir)` 函数扫描源码文件:
43
+
44
+ 1. 递归扫描 `root_dir`(最大深度 10 层)
45
+ 2. 排除目录:`node_modules/`、`dist/`、`build/`、`.git/`、`__pycache__/`、`.venv/`、`venv/`、`.webwork/`、`reports/`、`coverage/`
46
+ 3. 按扩展名分类计数:
47
+ - jsts:`.js`、`.jsx`、`.ts`、`.tsx`、`.vue`、`.mjs`、`.cjs`
48
+ - python:`.py`
49
+ 4. 文件数多者为主语言;两者都为 0 → 报错
50
+
51
+ ## 决策
52
+
53
+ | 条件 | 动作 |
54
+ |------|------|
55
+ | manifest 命中 | 输出主语言,流程结束 |
56
+ | 无 manifest,源码文件 > 0 | 输出计数多者为主语言 |
57
+ | 无 manifest,源码文件 = 0 | 报错退出 |
58
+
59
+ ## 失败处理
60
+
61
+ | 场景 | 处理方式 |
62
+ |------|---------|
63
+ | root_dir 不存在 | 报错"工程根目录不存在" |
64
+ | 无 manifest 且无源码文件 | 报错"无法检测项目主语言" |
65
+ | 扫描权限不足 | 跳过不可读目录,继续扫描 |
66
+
67
+ ## 一定要做
68
+
69
+ 1. 优先检查 manifest 文件,避免全量扫描
70
+ 2. JS/TS 统一视为 `jsts` 一种语言
71
+ 3. 排除常见的非源码目录
72
+ 4. 无 manifest 时必须扫描文件计数
73
+
74
+ ## 一定不要做
75
+
76
+ 1. 不要返回多个语言(v1 只返回主语言)
77
+ 2. 不要扫描 `node_modules/` 等依赖目录
78
+ 3. 不要修改任何文件
79
+ 4. 不要执行网络请求