repo-audit-tool 1.2.0 → 1.2.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/PUBLISHING.md CHANGED
@@ -1,17 +1,24 @@
1
- # 发布记录:@ninjasln-labs/repo-audit
1
+ # 发布记录:repo-audit-tool
2
2
 
3
3
  ## 发布状态(2026-09-06 更新)
4
4
 
5
5
  | 项 | 状态 |
6
6
  |---|---|
7
- | npm | `@ninjasln-labs/repo-audit` v1.2.0(未发布,待首次发布) |
7
+ | npm | `repo-audit-tool` v1.2.3(latest,CI 自动发布) |
8
8
  | GitHub | `NinjaSln-labs/repo-audit` master;发版 tag `v*` |
9
9
  | 本地验证 | 自审计 100/A,验证链 4/4,测试 3/3,CI 全绿 |
10
10
 
11
11
  ## 版本历史
12
12
 
13
+ - **1.2.3** — package.json 补充 `repository` 字段,修复 npm provenance E422;
14
+ 首次 Trusted Publisher(OIDC)tag 触发自动发布(2026-09-06)
15
+ - **1.2.2** — publish CI 修复:node 20→22 + npm 条件升级,修复 EBADENGINE;
16
+ tag 发布因 npm 已存在 1.2.1 未出包(OIDC 鉴权链路已验证通过)(2026-09-06)
17
+ - **1.2.1** — README 链接改为绝对 URL(修复 npm 页面 404);手动发布(2026-09-06)
13
18
  - **1.2.0** — 开源就绪:补充 AGENTS.md、CI/publish workflow 适配、json_field monorepo 感知、
14
19
  fallback_field 数组格式修复、英文 README、参数类型校验、占位符残留扫描(2026-09-06)
20
+ - 首次发布:`npm publish --access public`(手动 bootstrap)
21
+ - 后续发布:Trusted Publisher(OIDC)由 CI 自动发布
15
22
 
16
23
  ## 发布通道(npm OIDC Trusted Publishing)
17
24
 
@@ -23,7 +30,7 @@
23
30
  ```sh
24
31
  npm version patch --no-git-tag-version
25
32
  V="$(node -p "require('./package.json').version")"
26
- git commit -am "chore: release @ninjasln-labs/repo-audit v$V — <一句话主旨>"
33
+ git commit -am "chore: release repo-audit-tool v$V — <一句话主旨>"
27
34
  git tag v$V
28
35
  git push && git push --tags
29
36
  # CI 接手:审计 → 验证链 → 测试 → 版本守卫 → npm publish
@@ -34,29 +41,25 @@ git push && git push --tags
34
41
  ```sh
35
42
  npm version prerelease --preid=next --no-git-tag-version
36
43
  V="$(node -p "require('./package.json').version")"
37
- git commit -am "chore: canary @ninjasln-labs/repo-audit v$V" && git tag v$V
44
+ git commit -am "chore: canary repo-audit-tool v$V" && git tag v$V
38
45
  git push && git push --tags
39
- # 实测通过 → 晋级 latest:npm dist-tag add @ninjasln-labs/repo-audit@x.y.z latest
46
+ # 实测通过 → 晋级 latest:npm dist-tag add repo-audit-tool@x.y.z latest
40
47
  ```
41
48
 
42
- ## 首次发布前置(一次性)
49
+ ## 首次发布(已完成)
43
50
 
44
- 1. **npm 包创建**:npmjs.com Create Package → `@ninjasln-labs/repo-audit`(需先创建 `ninjasln-labs` org
45
- 2. **Trusted Publisher 配置**:包设置 → Trusted Publisher → 填 GitHub repo `NinjaSln-labs/repo-audit`
46
- + workflow `publish.yml` + branch `master`(逐字段一致)
47
- 3. **首次 bootstrap**:首版可手动发布:
48
- ```sh
49
- npm login # 交互登录 + 2FA
50
- npm publish --access public
51
- ```
52
- 随后立即切 Trusted Publishing 由 CI 发布
53
- 4. **验证发布成功**:`npm view @ninjasln-labs/repo-audit dist-tags` + npm 页 provenance 徽章
51
+ 1. **npm 包创建**:`npm publish --access public`(v1.2.0,2026-09-06
52
+ 2. **Trusted Publisher 配置**:npmjs.com包设置 → Trusted Publisher →
53
+ - Repository: `NinjaSln-labs/repo-audit`
54
+ - Workflow: `publish.yml`
55
+ - Branch: `master`(注:tag 触发场景 npm 亦放行,v1.2.2 实测通过)
56
+ 3. **验证**:`npm view repo-audit-tool dist-tags` → latest 已更新 ✓
54
57
 
55
58
  ## 发布后验证
56
59
 
57
- - 确认 latest 已更新(`npm view @ninjasln-labs/repo-audit dist-tags`)
60
+ - 确认 latest 已更新(`npm view repo-audit-tool dist-tags`)
58
61
  - provenance 徽章(npm 包页面)
59
- - 实机安装路径实测:`npm install -g @ninjasln-labs/repo-audit` → `repo-audit --repo .`
62
+ - 实机安装路径实测:`npm install -g repo-audit-tool` → `repo-audit --repo .`
60
63
 
61
64
  ## 维护要点
62
65
 
package/README.en.md CHANGED
@@ -55,10 +55,11 @@ repo-audit/
55
55
 
56
56
  ## 📚 Documentation
57
57
 
58
- - [Human Guide](docs/repo-audit/HUMAN-GUIDE.md) — Full usage documentation
59
- - [Agent Guide](docs/repo-audit/AGENT-GUIDE.md) — Machine-readable operation protocol
60
- - [Audit Methodology](AUDIT.md)
61
- - [Best Practices](BEST-PRACTICES.md)
58
+ - [Human Guide](https://github.com/NinjaSln-labs/repo-audit/blob/master/docs/repo-audit/HUMAN-GUIDE.md) — Full usage documentation
59
+ - [Agent Guide](https://github.com/NinjaSln-labs/repo-audit/blob/master/docs/repo-audit/AGENT-GUIDE.md) — Machine-readable operation protocol
60
+ - [Audit Methodology](https://github.com/NinjaSln-labs/repo-audit/blob/master/AUDIT.md)
61
+ - [Best Practices](https://github.com/NinjaSln-labs/repo-audit/blob/master/BEST-PRACTICES.md)
62
+ - [GitHub Pages](https://ninjasln-labs.github.io/repo-audit/) — Online documentation
62
63
 
63
64
  ## 🛠️ Development
64
65
 
package/README.md CHANGED
@@ -55,10 +55,11 @@ repo-audit/
55
55
 
56
56
  ## 📚 文档
57
57
 
58
- - [人类手册](docs/repo-audit/HUMAN-GUIDE.md) — 完整使用说明
59
- - [Agent 手册](docs/repo-audit/AGENT-GUIDE.md) — 机器可读的操作协议
60
- - [审计方法论](AUDIT.md)
61
- - [最佳实践标准](BEST-PRACTICES.md)
58
+ - [人类手册](https://github.com/NinjaSln-labs/repo-audit/blob/master/docs/repo-audit/HUMAN-GUIDE.md) — 完整使用说明
59
+ - [Agent 手册](https://github.com/NinjaSln-labs/repo-audit/blob/master/docs/repo-audit/AGENT-GUIDE.md) — 机器可读的操作协议
60
+ - [审计方法论](https://github.com/NinjaSln-labs/repo-audit/blob/master/AUDIT.md)
61
+ - [最佳实践标准](https://github.com/NinjaSln-labs/repo-audit/blob/master/BEST-PRACTICES.md)
62
+ - [GitHub Pages](https://ninjasln-labs.github.io/repo-audit/) — 在线文档
62
63
 
63
64
  ## 🛠️ 开发
64
65
 
@@ -0,0 +1,239 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "repo-audit 文档索引",
4
+ "description": "AI Agent 可读的文档索引 — 包含所有文档的元数据、结构、和调用协议",
5
+ "version": "1.2.3",
6
+ "updated": "2026-09-06",
7
+ "repo": "NinjaSln-labs/repo-audit",
8
+ "npm": "repo-audit-tool",
9
+ "pages": "https://ninjasln-labs.github.io/repo-audit/",
10
+
11
+ "entry_points": {
12
+ "json_index": "/AGENT-INDEX.json",
13
+ "schema": "/SCHEMA.json",
14
+ "protocol": "/AGENT-PROTOCOL.md",
15
+ "human_guide": "/repo-audit/HUMAN-GUIDE.md",
16
+ "agent_guide": "/repo-audit/AGENT-GUIDE.md"
17
+ },
18
+
19
+ "tool": {
20
+ "name": "repo-audit",
21
+ "description": "仓库标准化审计工具 + 工程脚手架生成器(零依赖)",
22
+ "bin": "repo-audit",
23
+ "version": "1.2.3",
24
+ "language": "JavaScript (ESM)",
25
+ "runtime": "Node.js >= 18",
26
+ "dependencies": [],
27
+ "license": "MIT",
28
+
29
+ "invocation": {
30
+ "command": "repo-audit [options]",
31
+ "options": {
32
+ "--repo": { "type": "string", "default": ".", "description": "目标仓库路径" },
33
+ "--type": { "type": "string", "description": "强制指定分类(跳过自动检测)" },
34
+ "--format": { "type": "string", "enum": ["md", "json", "both"], "default": "both", "description": "输出格式" },
35
+ "--output": { "type": "string", "default": "<repo>/audit-report/", "description": "输出目录" },
36
+ "--llm-provider": { "type": "string", "description": "LLM 协议:openai/anthropic 或厂商别名" },
37
+ "--llm-model": { "type": "string", "description": "模型名称" },
38
+ "--strict": { "type": "boolean", "default": false, "description": "严格模式:Critical/Major 即 exit 1" },
39
+ "--rules": { "type": "string", "description": "自定义规则 YAML(可多次)" },
40
+ "--dim": { "type": "string", "description": "只审计指定维度(可多次)" },
41
+ "--feedback": { "type": "string", "description": "提交反馈(创建 GitHub Issue)" },
42
+ "--help": { "type": "boolean", "description": "显示帮助" }
43
+ },
44
+
45
+ "exit_codes": {
46
+ "0": "审计通过(无 Critical/Major 或 --strict 未启用)",
47
+ "1": "有 Critical/Major 发现且 --strict 启用",
48
+ "2": "参数错误",
49
+ "3": "目标不是 git 仓库"
50
+ }
51
+ },
52
+
53
+ "environment_variables": {
54
+ "LLM_PROVIDER": "LLM 协议(openai/anthropic/none),也可用厂商别名如 deepseek/qwen/glm",
55
+ "LLM_API_KEY": "API Key(必须手动指定)",
56
+ "LLM_MODEL": "模型名称",
57
+ "LLM_BASE_URL": "自定义 API 端点(OpenAI 兼容厂商必填)",
58
+ "REPO_AUDIT_TYPES": "自定义分类列表(JSON 数组)"
59
+ }
60
+ },
61
+
62
+ "audit": {
63
+ "dimensions": [
64
+ {
65
+ "id": "docs",
66
+ "label": "文档",
67
+ "rules": ["DOC-001", "DOC-002", "DOC-003", "DOC-003b", "DOC-004", "DOC-005", "DOC-006", "DOC-007"],
68
+ "description": "README/LICENSE/CONTRIBUTING/SECURITY 等文档完整性"
69
+ },
70
+ {
71
+ "id": "git",
72
+ "label": "Git",
73
+ "rules": ["GIT-001", "GIT-002", "GIT-003", "GIT-004"],
74
+ "description": "commit 规范、分支策略、scaffold 管理"
75
+ },
76
+ {
77
+ "id": "quality",
78
+ "label": "质量",
79
+ "rules": ["QUA-001", "QUA-002", "QUA-003", "QUA-004", "QUA-005"],
80
+ "description": "构建配置、测试、lint、typecheck"
81
+ },
82
+ {
83
+ "id": "security",
84
+ "label": "安全",
85
+ "rules": ["SEC-001", "SEC-002", "SEC-003", "SEC-004"],
86
+ "description": "密钥泄露、依赖漏洞、权限配置"
87
+ }
88
+ ],
89
+
90
+ "scoring": {
91
+ "formula": "score = 100 - (critical × 25) - (major × 10) - (minor × 3)",
92
+ "grades": {
93
+ "A": ">= 90",
94
+ "B": ">= 80",
95
+ "C": ">= 70",
96
+ "D": ">= 60",
97
+ "F": "< 60"
98
+ },
99
+ "note": "score 和 grade 不在 JSON 输出中,Agent 需根据 summary 字段自行计算"
100
+ },
101
+
102
+ "categories": [
103
+ "dsh-plugin", "python-app", "go-service", "content", "sandbox",
104
+ "archive", "product-oss", "javascript", "typescript", "java",
105
+ "python", "rust", "cpp", "dotnet", "php", "ruby", "unknown"
106
+ ]
107
+ },
108
+
109
+ "documents": [
110
+ {
111
+ "id": "human-guide",
112
+ "title": "人类使用手册",
113
+ "path": "/repo-audit/HUMAN-GUIDE.md",
114
+ "url": "https://ninjasln-labs.github.io/repo-audit/repo-audit/HUMAN-GUIDE.md",
115
+ "audience": "human",
116
+ "sections": [
117
+ "一、安装",
118
+ "二、快速开始",
119
+ "三、命令行参数",
120
+ "四、环境变量",
121
+ "五、输出说明",
122
+ "六、退出码",
123
+ "七、审计维度说明",
124
+ "八、扩展指南",
125
+ "九、故障排查",
126
+ "十、与 scaffold 的配合",
127
+ "十一、操作授权与完成路径",
128
+ "十二、新特性说明"
129
+ ]
130
+ },
131
+ {
132
+ "id": "agent-guide",
133
+ "title": "Agent 操作手册",
134
+ "path": "/repo-audit/AGENT-GUIDE.md",
135
+ "url": "https://ninjasln-labs.github.io/repo-audit/repo-audit/AGENT-GUIDE.md",
136
+ "audience": "agent",
137
+ "sections": [
138
+ "一、工具定位",
139
+ "二、调用协议",
140
+ "三、输出解析",
141
+ "四、标准操作流程",
142
+ "五、错误处理协议",
143
+ "六、性能参考",
144
+ "七、Agent 决策树",
145
+ "八、操作授权与完成路径",
146
+ "九、快速参考卡",
147
+ "十、反馈通道"
148
+ ]
149
+ },
150
+ {
151
+ "id": "audit-methodology",
152
+ "title": "审计方法论",
153
+ "path": "/AUDIT.md",
154
+ "url": "https://github.com/NinjaSln-labs/repo-audit/blob/master/AUDIT.md",
155
+ "audience": "both",
156
+ "description": "评分体系、规则设计、维度划分"
157
+ },
158
+ {
159
+ "id": "best-practices",
160
+ "title": "最佳实践标准",
161
+ "path": "/BEST-PRACTICES.md",
162
+ "url": "https://github.com/NinjaSln-labs/repo-audit/blob/master/BEST-PRACTICES.md",
163
+ "audience": "both",
164
+ "description": "工程仓库应满足的标准化检查项"
165
+ },
166
+ {
167
+ "id": "classification",
168
+ "title": "分类检测说明",
169
+ "path": "/REPO-CLASSIFICATION.md",
170
+ "url": "https://github.com/NinjaSln-labs/repo-audit/blob/master/REPO-CLASSIFICATION.md",
171
+ "audience": "both",
172
+ "description": "18 种仓库类型识别逻辑,置信度评分"
173
+ },
174
+ {
175
+ "id": "templates",
176
+ "title": "脚手架模板",
177
+ "path": "/templates/README.md",
178
+ "url": "https://github.com/NinjaSln-labs/repo-audit/blob/master/templates/README.md",
179
+ "audience": "both",
180
+ "description": "从零生成符合规范的工程脚手架"
181
+ },
182
+ {
183
+ "id": "schema",
184
+ "title": "审计报告 JSON Schema",
185
+ "path": "/SCHEMA.json",
186
+ "url": "https://ninjasln-labs.github.io/repo-audit/SCHEMA.json",
187
+ "audience": "agent",
188
+ "format": "json-schema",
189
+ "description": "JSON Schema 定义,用于验证审计报告输出"
190
+ }
191
+ ],
192
+
193
+ "feedback": {
194
+ "description": "反馈通道 — Agent 可通过 GitHub Issues API 检测和处理用户反馈",
195
+ "label": "audit-feedback",
196
+ "repo": "NinjaSln-labs/repo-audit",
197
+
198
+ "detect": {
199
+ "command": "gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open --json number,title,createdAt,body",
200
+ "description": "列出未处理的反馈"
201
+ },
202
+ "view": {
203
+ "command": "gh issue view <NUMBER> --repo NinjaSln-labs/repo-audit --json title,body,labels,createdAt",
204
+ "description": "获取单条反馈详情"
205
+ },
206
+ "close": {
207
+ "command": "gh issue close <NUMBER> --repo NinjaSln-labs/repo-audit --comment '已处理:[处理说明]'",
208
+ "description": "反馈已处理,关闭 Issue"
209
+ },
210
+ "create": {
211
+ "command": "node repo-audit.mjs --feedback '<反馈内容>'",
212
+ "description": "通过 CLI 创建反馈 Issue(自动预填环境信息)"
213
+ },
214
+
215
+ "priorities": [
216
+ { "level": "critical", "sla": "24h", "description": "工具崩溃/数据损坏" },
217
+ { "level": "major", "sla": "72h", "description": "功能严重受损" },
218
+ { "level": "minor", "sla": "1周", "description": "功能部分受损" },
219
+ { "level": "info", "sla": "排期", "description": "建议改进" }
220
+ ]
221
+ },
222
+
223
+ "quick_start": {
224
+ "install": "npm install -g repo-audit-tool",
225
+ "audit": "repo-audit --repo /path/to/repo",
226
+ "json_output": "repo-audit --repo /path/to/repo --format json",
227
+ "scaffold": "node templates/scaffold.mjs --type dsh-plugin --name my-plugin",
228
+ "strict_mode": "repo-audit --repo /path/to/repo --strict",
229
+ "custom_rules": "repo-audit --repo /path/to/repo --rules my-rules.yaml",
230
+ "llm_enhanced": "LLM_API_KEY=sk-xxx repo-audit --repo . --llm-provider deepseek"
231
+ },
232
+
233
+ "changelog": {
234
+ "1.2.3": "package.json 补充 repository 字段,修复 npm provenance E422;完成 Trusted Publisher tag 自动发布",
235
+ "1.2.2": "publish CI 改用 node 22 + 条件升级 npm,修复 EBADENGINE(tag 发布因 1.2.1 已存在未出包)",
236
+ "1.2.1": "README 链接改为绝对 URL(修复 npm 页面 404)",
237
+ "1.2.0": "开源就绪:AGENTS.md、CI/publish workflow、json_field monorepo、fallback_field 数组、英文 README、参数类型校验、占位符扫描"
238
+ }
239
+ }
@@ -0,0 +1,295 @@
1
+ ---
2
+ title: repo-audit Agent Protocol
3
+ version: "1.2.1"
4
+ audience: agent
5
+ format: markdown+metadata
6
+ schema: /SCHEMA.json
7
+ index: /AGENT-INDEX.json
8
+ ---
9
+
10
+ # repo-audit Agent Protocol
11
+
12
+ > 机器可读的操作协议。Agent 直接执行,无需人类解释。
13
+
14
+ ## 1. 工具身份
15
+
16
+ ```json
17
+ {
18
+ "name": "repo-audit",
19
+ "npm": "repo-audit-tool",
20
+ "version": "1.2.1",
21
+ "bin": "repo-audit",
22
+ "language": "JavaScript ESM",
23
+ "runtime": "Node.js >= 18",
24
+ "dependencies": [],
25
+ "license": "MIT",
26
+ "readonly": true
27
+ }
28
+ ```
29
+
30
+ ## 2. 调用协议
31
+
32
+ ### 2.1 基本调用
33
+
34
+ ```
35
+ repo-audit [--repo <path>] [--type <type>] [--format <fmt>] [--output <path>]
36
+ [--llm-provider <p>] [--llm-model <m>] [--strict]
37
+ [--rules <file>] [--dim <domain>] [--feedback <msg>]
38
+ ```
39
+
40
+ ### 2.2 参数
41
+
42
+ | 参数 | 类型 | 必填 | 默认值 | 说明 |
43
+ |---|---|---|---|---|
44
+ | `--repo` | string | 否 | `.` | 目标仓库路径 |
45
+ | `--type` | string | 否 | 自动检测 | 强制指定分类 |
46
+ | `--format` | enum | 否 | `both` | `md` / `json` / `both` |
47
+ | `--output` | string | 否 | `<repo>/audit-report/` | 输出目录 |
48
+ | `--llm-provider` | string | 否 | 环境变量 | LLM 协议 |
49
+ | `--llm-model` | string | 否 | 自动 | 模型名称 |
50
+ | `--strict` | bool | 否 | `false` | Critical/Major 即 exit 1 |
51
+ | `--rules` | string[] | 否 | — | 自定义规则 YAML |
52
+ | `--dim` | string[] | 否 | 全部 | 只审计指定维度 |
53
+ | `--feedback` | string | 否 | — | 提交反馈 |
54
+
55
+ ### 2.3 退出码
56
+
57
+ | 码 | 含义 | Agent 应执行 |
58
+ |---|---|---|
59
+ | 0 | 审计通过 | 正常继续 |
60
+ | 1 | Critical/Major 发现 + --strict | 读取 findings 并报告 |
61
+ | 2 | 参数错误 | 修正参数后重试 |
62
+ | 3 | 目标不是 git 仓库 | 提示用户切换到 git 仓库 |
63
+
64
+ ## 3. 输出格式
65
+
66
+ ### 3.1 JSON 报告结构
67
+
68
+ ```json
69
+ {
70
+ "generated_at": "2026-09-06T12:00:00.000Z",
71
+ "audit_type": "dsh-plugin",
72
+ "llm_used": false,
73
+ "metadata": {
74
+ "remote": "https://github.com/org/repo.git",
75
+ "branch": "master",
76
+ "commitCount": 42,
77
+ "fileCount": 117,
78
+ "lastCommit": "2026-09-06 12:00:00 +0800",
79
+ "path": "/path/to/repo"
80
+ },
81
+ "summary": {
82
+ "critical": 0,
83
+ "major": 0,
84
+ "minor": 0,
85
+ "info": 0,
86
+ "pass": 19,
87
+ "total": 19,
88
+ "waived": 0,
89
+ "llmUsed": false
90
+ },
91
+ "findings": [
92
+ {
93
+ "id": "DOC-001",
94
+ "title": "README.md 存在",
95
+ "severity": "critical",
96
+ "domain": "docs",
97
+ "applies_to": ["*"],
98
+ "status": "pass",
99
+ "message": "符合",
100
+ "evidence": "✓ README.md (3.1kB)",
101
+ "hint": null,
102
+ "template_ref": null
103
+ }
104
+ ]
105
+ }
106
+ ```
107
+
108
+ ### 3.2 评分公式
109
+
110
+ ```
111
+ score = 100 - (critical × 25) - (major × 10) - (minor × 3)
112
+ ```
113
+
114
+ | 等级 | 分数 |
115
+ |---|---|
116
+ | A | ≥ 90 |
117
+ | B | ≥ 80 |
118
+ | C | ≥ 70 |
119
+ | D | ≥ 60 |
120
+ | F | < 60 |
121
+
122
+ ### 3.3 发现状态
123
+
124
+ | 状态 | 含义 | Agent 处理 |
125
+ |---|---|---|
126
+ | `pass` | 检查通过 | 忽略 |
127
+ | `fail` | 检查失败 | 读取 `message` + `evidence` + `hint` |
128
+ | `waived` | 已豁免 | 读取 `waived_reason` + `waived_since` |
129
+
130
+ ### 3.4 严重级别
131
+
132
+ | 级别 | 扣分 | Agent 优先级 |
133
+ |---|---|---|
134
+ | `critical` | -25 | P0 — 立即处理 |
135
+ | `major` | -10 | P1 — 优先处理 |
136
+ | `minor` | -3 | P2 — 正常处理 |
137
+ | `info` | 0 | P3 — 参考信息 |
138
+
139
+ ## 4. 标准操作流程
140
+
141
+ ### 4.1 新建仓库后验证
142
+
143
+ ```bash
144
+ repo-audit --repo /path/to/new-repo --format json
145
+ ```
146
+
147
+ Agent 读取 JSON,检查 `summary.grade`:
148
+ - `A` → 通过,报告成功
149
+ - `B/C` → 报告需改进项(列出 fail findings)
150
+ - `D/F` → 警告,建议修复 critical/major 问题
151
+
152
+ ### 4.2 CI 门禁集成
153
+
154
+ ```yaml
155
+ # GitHub Actions 示例
156
+ - name: Audit
157
+ run: repo-audit --repo . --format json --strict
158
+ ```
159
+
160
+ `--strict` 使 Critical/Major 发现返回 exit 1,自动阻断 CI。
161
+
162
+ ### 4.3 自定义规则
163
+
164
+ ```yaml
165
+ # my-rules.yaml
166
+ rules:
167
+ - id: COM-001
168
+ title: "提交信息规范"
169
+ severity: major
170
+ domain: git
171
+ applies_to: ["*"]
172
+ check: commit_message
173
+ params:
174
+ pattern: "^(feat|fix|docs|chore|refactor|test):"
175
+ ```
176
+
177
+ ```bash
178
+ repo-audit --repo . --rules my-rules.yaml
179
+ ```
180
+
181
+ ### 4.4 反馈处理
182
+
183
+ ```bash
184
+ # 检测新反馈
185
+ gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open --json number,title,createdAt,body
186
+
187
+ # 获取详情
188
+ gh issue view 42 --repo NinjaSln-labs/repo-audit --json title,body,labels
189
+
190
+ # 处理完成
191
+ gh issue close 42 --repo NinjaSln-labs/repo-audit --comment "已处理:修复了 X 问题"
192
+ ```
193
+
194
+ ## 5. 错误处理协议
195
+
196
+ | 错误 | 原因 | Agent 处理 |
197
+ |---|---|---|
198
+ | `目标不是 git 仓库` | 目录无 `.git/` | 提示 `git init` 或切换到正确路径 |
199
+ | `未知参数` | 参数拼写错误 | 检查 `--help` |
200
+ | `LLM 增强失败` | API Key 无效/网络问题 | 降级为非 LLM 模式 |
201
+ | `规则加载失败` | YAML 语法错误 | 报告错误行,不阻断审计 |
202
+ | `分类检测不准` | 文件结构特殊 | 使用 `--type` 强制指定 |
203
+
204
+ ## 6. Agent 决策树
205
+
206
+ ```
207
+ 收到审计请求
208
+ ├─ 有 --repo 参数?
209
+ │ ├─ 否 → 默认当前目录
210
+ │ └─ 是 → 使用指定路径
211
+ ├─ 有 --format 参数?
212
+ │ ├─ json → 只输出 JSON
213
+ │ ├─ md → 只输出 Markdown
214
+ │ └─ both/默认 → 同时输出
215
+ ├─ 有 LLM 配置?
216
+ │ ├─ 是 → 启用 LLM 增强
217
+ │ └─ 否 → 纯规则审计
218
+ ├─ 执行审计
219
+ ├─ 解析 summary
220
+ │ ├─ grade A → 报告通过
221
+ │ ├─ grade B/C → 报告改进项
222
+ │ └─ grade D/F → 警告严重问题
223
+ └─ 输出结果
224
+ ```
225
+
226
+ ## 7. 反馈通道
227
+
228
+ ### 7.1 检测协议
229
+
230
+ ```bash
231
+ # 列出未处理反馈
232
+ gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open --json number,title,createdAt,body
233
+
234
+ # 获取详情
235
+ gh issue view <NUMBER> --repo NinjaSln-labs/repo-audit --json title,body,labels,createdAt
236
+
237
+ # 关闭已处理
238
+ gh issue close <NUMBER> --repo NinjaSln-labs/repo-audit --comment "已处理:[说明]"
239
+ ```
240
+
241
+ ### 7.2 创建反馈
242
+
243
+ ```bash
244
+ # CLI 方式
245
+ node repo-audit.mjs --feedback "在 xxx 场景下出现 yyy 问题"
246
+
247
+ # API 方式
248
+ gh issue create --repo NinjaSln-labs/repo-audit \
249
+ --title "Feedback: <标题>" \
250
+ --body "<正文>" \
251
+ --label "feedback,audit-feedback"
252
+ ```
253
+
254
+ ### 7.3 处理优先级
255
+
256
+ | 级别 | SLA | 描述 |
257
+ |---|---|---|
258
+ | critical | 24h | 工具崩溃/数据损坏 |
259
+ | major | 72h | 功能严重受损 |
260
+ | minor | 1周 | 功能部分受损 |
261
+ | info | 排期 | 建议改进 |
262
+
263
+ ## 8. 快速参考卡
264
+
265
+ ```bash
266
+ # 安装
267
+ npm install -g repo-audit-tool
268
+
269
+ # 基本审计
270
+ repo-audit --repo /path/to/repo
271
+
272
+ # JSON 输出
273
+ repo-audit --repo /path/to/repo --format json
274
+
275
+ # 严格模式(CI 用)
276
+ repo-audit --repo . --format json --strict
277
+
278
+ # LLM 增强
279
+ LLM_API_KEY=sk-xxx repo-audit --repo . --llm-provider deepseek
280
+
281
+ # 自定义规则
282
+ repo-audit --repo . --rules my-rules.yaml
283
+
284
+ # 指定维度
285
+ repo-audit --repo . --dim security --dim docs
286
+
287
+ # 生成脚手架
288
+ node templates/scaffold.mjs --type dsh-plugin --name my-plugin
289
+
290
+ # 提交反馈
291
+ repo-audit --feedback "问题描述"
292
+
293
+ # 检测反馈
294
+ gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open
295
+ ```
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ninjasln-labs.github.io/repo-audit/SCHEMA.json",
4
+ "title": "repo-audit 审计报告 Schema",
5
+ "description": "repo-audit 工具输出的 JSON 报告格式定义",
6
+ "type": "object",
7
+ "required": ["generated_at", "audit_type", "llm_used", "metadata", "summary", "findings"],
8
+ "properties": {
9
+ "generated_at": {
10
+ "type": "string",
11
+ "format": "date-time",
12
+ "description": "报告生成时间 (ISO 8601)"
13
+ },
14
+ "audit_type": {
15
+ "type": "string",
16
+ "description": "检测到的仓库分类",
17
+ "enum": [
18
+ "dsh-plugin", "python-app", "go-service", "content", "sandbox",
19
+ "archive", "product-oss", "javascript", "typescript", "java",
20
+ "python", "rust", "cpp", "dotnet", "php", "ruby", "unknown"
21
+ ]
22
+ },
23
+ "llm_used": {
24
+ "type": "boolean",
25
+ "description": "是否使用了 LLM 增强"
26
+ },
27
+ "metadata": {
28
+ "type": "object",
29
+ "required": ["remote", "branch", "commitCount", "fileCount", "lastCommit", "path"],
30
+ "properties": {
31
+ "remote": { "type": ["string", "null"], "description": "git remote URL" },
32
+ "branch": { "type": "string", "description": "当前分支" },
33
+ "commitCount": { "type": "number", "description": "commit 总数" },
34
+ "fileCount": { "type": "number", "description": "文件总数" },
35
+ "lastCommit": { "type": "string", "description": "最近 commit 时间" },
36
+ "path": { "type": "string", "description": "仓库路径" }
37
+ }
38
+ },
39
+ "summary": {
40
+ "type": "object",
41
+ "required": ["critical", "major", "minor", "info", "pass", "total", "waived", "llmUsed"],
42
+ "properties": {
43
+ "critical": { "type": "number", "minimum": 0, "description": "Critical 级发现数" },
44
+ "major": { "type": "number", "minimum": 0, "description": "Major 级发现数" },
45
+ "minor": { "type": "number", "minimum": 0, "description": "Minor 级发现数" },
46
+ "info": { "type": "number", "minimum": 0, "description": "Info 级发现数" },
47
+ "pass": { "type": "number", "minimum": 0, "description": "通过的检查数" },
48
+ "total": { "type": "number", "minimum": 1, "description": "总检查数" },
49
+ "waived": { "type": "number", "minimum": 0, "description": "已豁免的检查数" },
50
+ "llmUsed": { "type": "boolean" }
51
+ },
52
+ "description": "汇总统计。评分公式:score = 100 - (critical×25) - (major×10) - (minor×3)。等级:A≥90, B≥80, C≥70, D≥60, F<60"
53
+ },
54
+ "findings": {
55
+ "type": "array",
56
+ "description": "审计发现列表",
57
+ "items": {
58
+ "type": "object",
59
+ "required": ["id", "title", "severity", "domain", "status", "message", "evidence"],
60
+ "properties": {
61
+ "id": {
62
+ "type": "string",
63
+ "description": "规则 ID",
64
+ "pattern": "^(DOC|GIT|QUA|SEC|COM|DEP)-\\d{3}[a-z]?$"
65
+ },
66
+ "title": { "type": "string", "description": "规则标题" },
67
+ "severity": {
68
+ "type": "string",
69
+ "enum": ["critical", "major", "minor", "info"]
70
+ },
71
+ "domain": {
72
+ "type": "string",
73
+ "enum": ["docs", "git", "quality", "security", "compliance", "dependencies"]
74
+ },
75
+ "applies_to": {
76
+ "type": "array",
77
+ "items": { "type": "string" },
78
+ "description": "适用的仓库分类列表,* 表示全部"
79
+ },
80
+ "status": {
81
+ "type": "string",
82
+ "enum": ["pass", "fail", "waived"]
83
+ },
84
+ "message": { "type": "string", "description": "通过: '符合'; 失败: 规则描述" },
85
+ "evidence": { "type": "string", "description": "证据文本" },
86
+ "hint": { "type": ["string", "null"], "description": "修复建议" },
87
+ "template_ref": { "type": ["string", "null"], "description": "模板引用" },
88
+ "waived_reason": { "type": ["string", "null"], "description": "豁免原因" },
89
+ "waived_since": { "type": ["string", "null"], "description": "豁免起始日期" }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,213 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>repo-audit 文档</title>
7
+
8
+ <!-- JSON-LD 结构化数据 — AI Agent 可读 -->
9
+ <script type="application/ld+json">
10
+ {
11
+ "@context": "https://schema.org",
12
+ "①type": "SoftwareApplication",
13
+ "name": "repo-audit",
14
+ "url": "https://github.com/NinjaSln-labs/repo-audit",
15
+ "downloadUrl": "https://www.npmjs.com/package/repo-audit-tool",
16
+ "softwareVersion": "1.2.1",
17
+ "applicationCategory": "DeveloperApplication",
18
+ "operatingSystem": "Node.js >= 18",
19
+ "license": "MIT",
20
+ "description": "仓库标准化审计工具 + 工程脚手架生成器(零依赖)",
21
+ "programmingLanguage": "JavaScript ESM",
22
+ "offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
23
+ "documentation": [
24
+ { "name": "AGENT-INDEX.json", "url": "https://ninjasln-labs.github.io/repo-audit/AGENT-INDEX.json", "format": "json" },
25
+ { "name": "SCHEMA.json", "url": "https://ninjasln-labs.github.io/repo-audit/SCHEMA.json", "format": "json-schema" },
26
+ { "name": "AGENT-PROTOCOL.md", "url": "https://ninjasln-labs.github.io/repo-audit/AGENT-PROTOCOL.md", "format": "markdown" },
27
+ { "name": "HUMAN-GUIDE.md", "url": "https://ninjasln-labs.github.io/repo-audit/repo-audit/HUMAN-GUIDE.md", "format": "markdown" },
28
+ { "name": "AGENT-GUIDE.md", "url": "https://ninjasln-labs.github.io/repo-audit/repo-audit/AGENT-GUIDE.md", "format": "markdown" }
29
+ ]
30
+ }
31
+ </script>
32
+ <style>
33
+ :root { --bg: #0d1117; --card: #161b22; --border: #30363d; --text: #e6edf3; --muted: #8b949e; --accent: #58a6ff; --accent-hover: #79c0ff; --green: #3fb950; }
34
+ * { margin: 0; padding: 0; box-sizing: border-box; }
35
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
36
+ .container { max-width: 960px; margin: 0 auto; padding: 2rem 1rem; }
37
+ header { text-align: center; padding: 3rem 0 2rem; }
38
+ h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
39
+ h1 a { color: var(--text); text-decoration: none; }
40
+ .subtitle { color: var(--muted); font-size: 1.1rem; margin-bottom: 1.5rem; }
41
+ .badges { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
42
+ .badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
43
+ .badge-npm { background: #f70a45; color: white; }
44
+ .badge-ci { background: var(--accent); color: white; }
45
+ .badge-node { background: #339933; color: white; }
46
+ .badge-license { background: #555; color: white; }
47
+ .badge-zero { background: var(--green); color: white; }
48
+ .badge-count { background: var(--muted); color: white; }
49
+
50
+ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
51
+ .card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; transition: border-color 0.2s; }
52
+ .card:hover { border-color: var(--accent); }
53
+ .card h2 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--accent); }
54
+ .card p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
55
+ .card a { display: inline-block; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
56
+ .card a:hover { color: var(--accent-hover); text-decoration: underline; }
57
+
58
+ .quickstart { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; margin: 2rem 0; }
59
+ .quickstart h2 { font-size: 1.3rem; margin-bottom: 1rem; color: var(--accent); }
60
+ pre { background: #0d1117; border: 1px solid var(--border); border-radius: 6px; padding: 1rem; overflow-x: auto; font-size: 0.9rem; }
61
+ code { font-family: 'SF Mono', Monaco, Inconsolata, monospace; }
62
+ code:not(pre code) { background: #21262d; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.85em; }
63
+
64
+ .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 2rem 0; }
65
+ .stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; text-align: center; }
66
+ .stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
67
+ .stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
68
+
69
+ .feedback { background: #1a1a2e; border: 1px solid #4c4c8a; border-radius: 8px; padding: 1.5rem; margin: 2rem 0; }
70
+ .feedback h2 { color: #a78bfa; }
71
+ .feedback p { color: var(--muted); }
72
+
73
+ footer { text-align: center; padding: 2rem 0; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); margin-top: 2rem; }
74
+ footer a { color: var(--accent); text-decoration: none; }
75
+ footer a:hover { text-decoration: underline; }
76
+
77
+ .nav-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
78
+ .nav-links { display: flex; gap: 1rem; }
79
+ .nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
80
+ .nav-links a:hover { color: var(--accent); }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <div class="container">
85
+
86
+ <div class="nav-bar">
87
+ <a href="https://github.com/NinjaSln-labs/repo-audit" style="font-weight:700;color:var(--text);text-decoration:none;">repo-audit</a>
88
+ <div class="nav-links">
89
+ <a href="AGENT-INDEX.json">🤖 Agent 索引</a>
90
+ <a href="SCHEMA.json">📐 Schema</a>
91
+ <a href="AGENT-PROTOCOL.md">📖 协议</a>
92
+ <a href="repo-audit/HUMAN-GUIDE.md">使用手册</a>
93
+ <a href="repo-audit/AGENT-GUIDE.md">Agent 手册</a>
94
+ <a href="../AUDIT.md">审计方法论</a>
95
+ <a href="../BEST-PRACTICES.md">最佳实践</a>
96
+ </div>
97
+ </div>
98
+
99
+ <header>
100
+ <h1><a href="https://github.com/NinjaSln-labs/repo-audit">repo-audit</a></h1>
101
+ <p class="subtitle">仓库标准化审计工具 + 工程脚手架生成器(零依赖)</p>
102
+ <div class="badges">
103
+ <span class="badge badge-npm">npm repo-audit-tool</span>
104
+ <span class="badge badge-ci">CI 全绿</span>
105
+ <span class="badge badge-node">Node ≥18</span>
106
+ <span class="badge badge-zero">零依赖</span>
107
+ <span class="badge badge-license">MIT</span>
108
+ <span class="badge badge-count">19 条规则 · 18 种分类</span>
109
+ </div>
110
+ </header>
111
+
112
+ <div class="stats">
113
+ <div class="stat"><div class="stat-value">100/A</div><div class="stat-label">自审计评分</div></div>
114
+ <div class="stat"><div class="stat-value">18</div><div class="stat-label">仓库分类</div></div>
115
+ <div class="stat"><div class="stat-value">15+</div><div class="stat-label">LLM 提供商</div></div>
116
+ <div class="stat"><div class="stat-value">0</div><div class="stat-label">npm 依赖</div></div>
117
+ </div>
118
+
119
+ <!-- Agent 入口 -->
120
+ <div class="agent-entry" style="background:#0d2137;border:1px solid #1f6feb;border-radius:8px;padding:1.5rem;margin:2rem 0;">
121
+ <h2 style="color:#58a6ff;font-size:1.3rem;margin-bottom:1rem;">🤖 AI Agent 入口</h2>
122
+ <p style="color:#8b949e;margin-bottom:1rem;">Agent 可读取以下结构化文档,自动理解工具协议、输出格式和调用方式:</p>
123
+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:1rem;">
124
+ <div style="background:#161b22;border:1px solid #30363d;border-radius:6px;padding:1rem;">
125
+ <a href="AGENT-INDEX.json" style="color:#58a6ff;text-decoration:none;font-weight:600;">📋 AGENT-INDEX.json</a>
126
+ <p style="color:#8b949e;font-size:0.85rem;margin-top:0.3rem;">机器可读文档索引<br>包含工具参数、退出码、环境变量、文档结构</p>
127
+ </div>
128
+ <div style="background:#161b22;border:1px solid #30363d;border-radius:6px;padding:1rem;">
129
+ <a href="SCHEMA.json" style="color:#58a6ff;text-decoration:none;font-weight:600;">📐 SCHEMA.json</a>
130
+ <p style="color:#8b949e;font-size:0.85rem;margin-top:0.3rem;">JSON Schema 定义<br>用于验证审计报告输出格式</p>
131
+ </div>
132
+ <div style="background:#161b22;border:1px solid #30363d;border-radius:6px;padding:1rem;">
133
+ <a href="AGENT-PROTOCOL.md" style="color:#58a6ff;text-decoration:none;font-weight:600;">📖 AGENT-PROTOCOL.md</a>
134
+ <p style="color:#8b949e;font-size:0.85rem;margin-top:0.3rem;">Agent 操作协议<br>调用方式、输出解析、决策树、错误处理</p>
135
+ </div>
136
+ </div>
137
+ <pre style="margin-top:1rem;background:#0d1117;border:1px solid #30363d;border-radius:6px;padding:1rem;font-size:0.85rem;"><code># Agent 一键获取文档索引
138
+ curl -s https://ninjasln-labs.github.io/repo-audit/AGENT-INDEX.json | jq '.tool.invocation'
139
+
140
+ # 验证审计报告
141
+ jq --argfile schema https://ninjasln-labs.github.io/repo-audit/SCHEMA.json \
142
+ 'empty as $_ | ., (input)' audit-report.json &gt; /dev/null</code></pre>
143
+ </div>
144
+
145
+ <div class="cards">
146
+ <div class="card">
147
+ <h2>📖 人类使用手册</h2>
148
+ <p>安装、快速开始、参数说明、环境变量、审计维度、故障排查、与 scaffold 配合</p>
149
+ <a href="repo-audit/HUMAN-GUIDE.md">→ HUMAN-GUIDE.md</a>
150
+ </div>
151
+ <div class="card">
152
+ <h2>🤖 Agent 操作手册</h2>
153
+ <p>调用协议、输出解析、标准操作流程、错误处理、决策树、授权路径</p>
154
+ <a href="repo-audit/AGENT-GUIDE.md">→ AGENT-GUIDE.md</a>
155
+ </div>
156
+ <div class="card">
157
+ <h2>🔍 审计方法论</h2>
158
+ <p>评分体系、规则设计、维度划分、分类检测逻辑</p>
159
+ <a href="../AUDIT.md">→ AUDIT.md</a>
160
+ </div>
161
+ <div class="card">
162
+ <h2>📏 最佳实践</h2>
163
+ <p>工程仓库应满足的标准化检查项,按维度分类</p>
164
+ <a href="../BEST-PRACTICES.md">→ BEST-PRACTICES.md</a>
165
+ </div>
166
+ <div class="card">
167
+ <h2>🏷️ 分类检测</h2>
168
+ <p>18 种仓库类型识别逻辑,置信度评分,自动检测规则</p>
169
+ <a href="../REPO-CLASSIFICATION.md">→ REPO-CLASSIFICATION.md</a>
170
+ </div>
171
+ <div class="card">
172
+ <h2>🚀 脚手架生成</h2>
173
+ <p>从零生成符合规范的工程脚手架,支持 6 种分类</p>
174
+ <a href="../templates/README.md">→ templates/README.md</a>
175
+ </div>
176
+ </div>
177
+
178
+ <div class="quickstart">
179
+ <h2>⚡ 快速开始</h2>
180
+ <pre><code># 全局安装
181
+ npm install -g repo-audit-tool
182
+
183
+ # 审计仓库
184
+ repo-audit --repo /path/to/repo
185
+
186
+ # JSON 输出
187
+ repo-audit --repo /path/to/repo --format json
188
+
189
+ # 生成脚手架
190
+ node templates/scaffold.mjs --type dsh-plugin --name my-plugin</code></pre>
191
+ </div>
192
+
193
+ <div class="feedback">
194
+ <h2>💬 反馈通道</h2>
195
+ <p>工具内置 <code>--feedback</code> 命令,一键创建 GitHub Issue(自动预填上下文)。也可通过以下方式反馈:</p>
196
+ <pre><code># 工具内反馈(自动预填审计结果)
197
+ repo-audit --feedback "问题描述"
198
+
199
+ # GitHub Issues
200
+ https://github.com/NinjaSln-labs/repo-audit/issues
201
+
202
+ # Bug 报告(预填模板)
203
+ https://github.com/NinjaSln-labs/repo-audit/issues/new?template=bug_report.yml</code></pre>
204
+ </div>
205
+
206
+ <footer>
207
+ <p>Made with ❤️ by <a href="https://github.com/NinjaSln-labs">NinjaSln-labs</a> · MIT License · 2026</p>
208
+ <p><a href="https://github.com/NinjaSln-labs/repo-audit">GitHub</a> · <a href="https://www.npmjs.com/package/repo-audit-tool">npm</a></p>
209
+ </footer>
210
+
211
+ </div>
212
+ </body>
213
+ </html>
@@ -471,4 +471,57 @@ node repo-audit.mjs --repo <path> --format json \
471
471
 
472
472
  ---
473
473
 
474
- *Agent 操作手册 v1.2 · 2026-09-06(新增 monorepo 感知 P6 + .auditrc.yaml 豁免)
474
+ ## 十、反馈通道
475
+
476
+ ### 10.1 Agent 检测协议
477
+
478
+ Agent 可通过 GitHub Issues API 检测用户反馈:
479
+
480
+ ```bash
481
+ # 列出未处理的反馈(label: audit-feedback + state: open)
482
+ gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open --json number,title,createdAt,body
483
+
484
+ # 获取单条反馈详情
485
+ gh issue view <NUMBER> --repo NinjaSln-labs/repo-audit --json title,body,labels,createdAt
486
+
487
+ # 反馈已处理,关闭 Issue
488
+ gh issue close <NUMBER> --repo NinjaSln-labs/repo-audit --comment "已处理:[处理说明]"
489
+ ```
490
+
491
+ **标签语义**:
492
+ - `audit-feedback` — 所有工具反馈(Agent 过滤条件)
493
+ - `feedback` — 通用反馈(与 audit-feedback 同时存在)
494
+ - `bug` — Bug 报告
495
+ - `enhancement` — 功能建议
496
+ - `documentation` — 文档问题
497
+
498
+ ### 10.2 Agent 创建反馈
499
+
500
+ Agent 可通过 CLI 或 API 创建反馈 Issue:
501
+
502
+ ```bash
503
+ # CLI 方式(自动预填环境信息)
504
+ node repo-audit.mjs --feedback "在 xxx 场景下出现 yyy 问题"
505
+
506
+ # API 方式(更灵活)
507
+ gh issue create --repo NinjaSln-labs/repo-audit \
508
+ --title "Feedback: <简要标题>" \
509
+ --body "<Markdown 正文>" \
510
+ --label "feedback,audit-feedback"
511
+ ```
512
+
513
+ ### 10.3 反馈处理流程
514
+
515
+ ```
516
+ 用户反馈 → audit-feedback label → Agent 检测 → 分类处理 → 关闭 Issue
517
+ ↓ ↓
518
+ GitHub Issues 修复 / 文档 / 不采纳
519
+ ```
520
+
521
+ **处理优先级**:
522
+ 1. `critical` — 工具崩溃/数据损坏(24h 内响应)
523
+ 2. `major` — 功能严重受损(72h 内响应)
524
+ 3. `minor` — 功能部分受损(1 周内响应)
525
+ 4. `info` — 建议改进(排期处理)
526
+
527
+ *Agent 操作手册 v1.3 · 2026-09-06(新增反馈通道 §10)
@@ -746,4 +746,34 @@ grep -rE '<commit-SHA>|dsh-demo|demo-v' .github/workflows/ && echo "✗ 有残
746
746
  `npm ci`(无 lockfile)、`scripts/verify.mjs`(路径错误)、`main` 分支(实际 master)、
747
747
  `<commit-SHA>`(占位符未替换)四项同时失败,workflow 不触发。
748
748
 
749
+ ### 12.8 反馈通道
750
+
751
+ **工具内反馈**(推荐,自动预填环境信息):
752
+ ```bash
753
+ repo-audit --feedback "在 monorepo 项目中 DOC-003b 规则误报"
754
+ ```
755
+ 效果:自动创建 GitHub Issue,包含反馈内容 + 工具版本 + Node.js 版本 + 平台信息。
756
+ Agent 可通过 `gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback` 检测反馈。
757
+
758
+ **GitHub Issues**:
759
+ - [Bug 报告](https://github.com/NinjaSln-labs/repo-audit/issues/new?template=bug_report.yml) — 预填复现步骤/实际输出/期望输出
760
+ - [功能反馈](https://github.com/NinjaSln-labs/repo-audit/issues/new?template=feedback.yml) — 建议/文档问题/性能问题
761
+ - [全部 Issues](https://github.com/NinjaSln-labs/repo-audit/issues)
762
+
763
+ **其他渠道**:
764
+ - Discord/Slack:见 GitHub Discussions
765
+ - 邮件:info@ninjasln-labs.com(仅安全问题)
766
+
767
+ **Agent 反馈检测协议**:
768
+ ```bash
769
+ # 检测新反馈
770
+ gh issue list --repo NinjaSln-labs/repo-audit --label audit-feedback --state open --json number,title,createdAt
771
+
772
+ # 获取反馈详情
773
+ gh issue view <NUMBER> --repo NinjaSln-labs/repo-audit
774
+
775
+ # 反馈已处理
776
+ gh issue close <NUMBER> --repo NinjaSln-labs/repo-audit --comment "已处理,感谢反馈"
777
+ ```
778
+
749
779
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-audit-tool",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "description": "仓库标准化审计工具 + 工程脚手架生成器(零依赖)",
5
5
  "type": "module",
6
6
  "main": "repo-audit.mjs",
@@ -20,6 +20,10 @@
20
20
  "best-practices",
21
21
  "repository"
22
22
  ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/NinjaSln-labs/repo-audit"
26
+ },
23
27
  "engines": {
24
28
  "node": ">=18"
25
29
  },
package/repo-audit.mjs CHANGED
@@ -37,11 +37,11 @@ const DEFAULT_OUTPUT_DIR = 'audit-report'
37
37
  const KNOWN_FLAGS = new Set([
38
38
  '--repo', '--type', '--format', '--output',
39
39
  '--llm-provider', '--llm-model', '--llm-base-url', '--strict',
40
- '--rules', '--dim', '--help', '-h'
40
+ '--rules', '--dim', '--help', '-h', '--feedback'
41
41
  ])
42
42
  const VALUE_FLAGS = new Set([
43
43
  '--repo', '--type', '--format', '--output',
44
- '--llm-provider', '--llm-model', '--llm-base-url', '--rules', '--dim'
44
+ '--llm-provider', '--llm-model', '--llm-base-url', '--rules', '--dim', '--feedback'
45
45
  ])
46
46
 
47
47
  function parseArgs(argv) {
@@ -106,6 +106,7 @@ function usage() {
106
106
  --strict 严格模式:Critical/Major 发现即 exit 1
107
107
  --rules <file> 自定义规则文件(可多次)
108
108
  --dim <domain> 只审计指定维度(可多次,如 --dim security --dim docs)
109
+ --feedback <msg> 提交反馈(创建 GitHub Issue,自动预填环境信息)
109
110
  --help, -h 显示此帮助
110
111
 
111
112
  环境变量:
@@ -1406,6 +1407,43 @@ async function main() {
1406
1407
  process.exit(0)
1407
1408
  }
1408
1409
 
1410
+ // Feedback 通道:创建 GitHub Issue(Agent 可检测)
1411
+ if (args.flags['--feedback']) {
1412
+ const message = args.flags['--feedback'] || '(未提供反馈内容)'
1413
+ const label = 'feedback'
1414
+ const body = `## 反馈内容
1415
+
1416
+ ${message}
1417
+
1418
+ ---
1419
+
1420
+ ## 环境信息
1421
+
1422
+ - **工具版本**: ${readFileSync('package.json', 'utf-8').match(/"version":\s*"([^"]+)"/)?.[1] || 'unknown'}
1423
+ - **Node.js**: ${process.version}
1424
+ - **平台**: ${process.platform} ${process.arch}
1425
+ - **时间**: ${new Date().toISOString()}
1426
+
1427
+ ## 标签
1428
+
1429
+ - ${label}
1430
+ - audit-feedback
1431
+ `
1432
+ // 尝试通过 gh CLI 创建 Issue
1433
+ const { execSync } = await import('node:child_process')
1434
+ try {
1435
+ const result = execSync(
1436
+ `gh issue create --repo NinjaSln-labs/repo-audit --title "Feedback: ${message.slice(0, 60)}" --body "${body.replace(/"/g, '\\"').replace(/\n/g, '\\n')}" --label "${label},audit-feedback"`,
1437
+ { encoding: 'utf-8', timeout: 30000 }
1438
+ )
1439
+ console.error(`✓ 反馈已提交: ${result.trim()}`)
1440
+ } catch (e) {
1441
+ console.error(`✗ gh CLI 不可用,请手动提交反馈:`)
1442
+ console.error(` https://github.com/NinjaSln-labs/repo-audit/issues/new?labels=${label},audit-feedback&body=${encodeURIComponent(body)}`)
1443
+ }
1444
+ process.exit(0)
1445
+ }
1446
+
1409
1447
  const repoPath = resolve(args.flags['--repo'] || '.')
1410
1448
  const forceType = args.flags['--type']
1411
1449
  const format = args.flags['--format'] || 'both'
package/HANDOFF.md DELETED
@@ -1,124 +0,0 @@
1
- # HANDOFF — repo-audit 工具(工程交接)
2
-
3
- ## 1. 交接元信息
4
-
5
- - **日期**:2026-09-06
6
- - **交接方**:repo-audit 维护 agent
7
- - **接收方**:继续维护 repo-audit 的 agent / 新 session
8
- - **原因**:里程碑达成(开源发布完成)· 开发仓废弃,转入本开源仓
9
- - **项目一句话**:零依赖 Node.js ESM 仓库标准化审计工具 + 工程脚手架生成器
10
- - **主战场变更**:**本仓 `ninjasin-labs/repo-audit/` 现在是唯一开发与发布位置**;原开发仓 `dsh-ecosystem/research/scaffold-templates/` **已废弃**(历史快照,勿再改)
11
- - **文档入口链**(本仓内):
12
- - 会话记录:`ninjasin-labs/.agents/session.md`(进度权威)
13
- - 人类手册:`docs/repo-audit/HUMAN-GUIDE.md`
14
- - Agent 手册:`docs/repo-audit/AGENT-GUIDE.md`
15
- - 自审报告:`docs/repo-audit/SELF-AUDIT.md`
16
- - 影子回归:`docs/repo-audit/SHADOW-AUDIT-20260906-v3.md`
17
- - **接收方建议动作**:
18
- 1. 读 `ninjasin-labs/.agents/session.md` 了解反馈闭环全貌
19
- 2. 读 `docs/repo-audit/AGENT-GUIDE.md` 了解操作协议
20
- 3. 所有后续开发、迭代、审计验收都在**本仓**完成
21
-
22
- ## 2. 当前状态快照
23
-
24
- ### 版本控制状态
25
-
26
- | 项 | 值 |
27
- |---|---|
28
- | 主仓(本仓) | `ninjasin-labs/repo-audit/`(独立 git 仓) |
29
- | 分支 | master |
30
- | commits | 6(`11eaf65` → `bca65ff` → `cbb7e40` → `de44f20` → `abea615` → `43e9245`) |
31
- | 远端 | **已建** — `https://github.com/NinjaSln-labs/repo-audit`(公开) |
32
- | 废弃仓 | `dsh-ecosystem/research/scaffold-templates/`(历史快照,勿改) |
33
-
34
- ### 最近完成(一行式)
35
-
36
- - `43e9245` fix(ci): 适配 repo-audit — 移除 dsh-demo 模板残留(CI 首次跑通)
37
- - `abea615` fix(engine): json_field monorepo 感知 + fallback_field 数组格式修复
38
- - `de44f20` fix(docs): 补充 AGENTS.md — 修复 CLAUDE.md 悬空引用 + 多文档断链
39
- - `bca65ff` 开源就绪 — 补充工程规范 + 验证链 + 测试(自审计 100/A)
40
- - `11eaf65` repo-audit 开源初始提交
41
- - (开发仓历史,已废弃,仅参考)`e99b504` P6 monorepo / `bcf21d3` E5 豁免 / `053c524` E6 序列化 / `ca01f00` fuyao 假阳性修复
42
-
43
- ### 构建环境状态
44
-
45
- - **零 npm 依赖**,无需 install
46
- - 自审计 **100/A**(19/19 pass)
47
- - 测试:`node --test` 3 用例通过;`node verify.mjs` 4 项通过
48
- - Node ≥18
49
-
50
- ### 占位/未完成边界
51
-
52
- - **json_field 检查器**:仅读仓库根 `package.json`,不递归 workspace(neonforge DOC-003b 残留 minor,非阻塞)
53
- - **GitHub 远端发布未执行**:本地 git 就绪,`gh repo create` / 首次 push 待用户
54
-
55
- ## 3. 下一步与验证点
56
-
57
- ### 立即待办(按优先级)
58
-
59
- 1. ~~**发布到 GitHub 远端**~~ ✅ `NinjaSln-labs/repo-audit` 已公开(2026-09-06)
60
- 2. ~~**json_field workspace 支持**~~ ✅ `abea615` 修复(含 fallback_field 数组格式预存 bug)
61
- 3. ~~**验证 CI**~~ ✅ `43e9245` 修复 dsh-demo 模板残留,CI 首次跑通
62
- 4. **可选**:npm 发布(需 npm 端配置 OIDC trusted publisher)
63
-
64
- ### 外部依赖来源
65
-
66
- - 无 API Key / 凭据依赖(工具可选 LLM 增强,Key 由用户运行时提供,不落仓)
67
- - GitHub 远端发布需用户账号权限
68
-
69
- ### 风险提醒
70
-
71
- - 本仓此前无 .git 时自审计 GIT-001 会 fail;已 commit 后正常
72
- - json_field workspace 盲区影响 monorepo license 一致性检查(minor)
73
-
74
- ## 4. 即时操作
75
-
76
- ```bash
77
- # 本仓自审计
78
- cd ninjasin-labs/repo-audit
79
- node repo-audit.mjs --repo . --format json
80
-
81
- # 验证链
82
- node verify.mjs
83
- node --test
84
-
85
- # 全仓影子回归(ninjasin-labs 下其他仓,可选)
86
- for repo in $(find /home/shadow/ninjasin-labs -maxdepth 3 -name .git -type d | sed 's|/.git$||'); do
87
- node repo-audit.mjs --repo "$repo" --format json 2>/dev/null | grep -o '评分: [0-9]*'
88
- done
89
- ```
90
-
91
- ### 已知坑
92
-
93
- - 引擎对**非 git 仓**输出到 stderr(`✗ 目标不是 git 仓库`),不产生 JSON——verify.mjs 需用 git 仓
94
- - `glob_count` 无法遍历隐藏目录(`.github/`)——CI 检查用 `regex`+`command` 方案而非 glob_count
95
- - `.auditrc.yaml` 解析是简单行解析,`reason` 只取单行且去引号,长 reason 需保持单行
96
-
97
- ## 5. 引用索引
98
-
99
- | 主题 | 权威文档 |
100
- |---|---|
101
- | 会话/进度权威 | `ninjasin-labs/.agents/session.md` |
102
- | 人类使用手册 | `docs/repo-audit/HUMAN-GUIDE.md` |
103
- | Agent 操作协议 | `docs/repo-audit/AGENT-GUIDE.md` |
104
- | AI 协作纪律 | `AGENTS.md` |
105
- | 工具自审 | `docs/repo-audit/SELF-AUDIT.md` |
106
- | 全仓影子回归 | `docs/repo-audit/SHADOW-AUDIT-20260906-v3.md` |
107
- | 反馈闭环(fuyao) | `docs/repo-audit/FEEDBACK-fuyao-nomad.md` |
108
- | 反馈闭环(neonforge) | `docs/repo-audit/FEEDBACK-neonforge.md` |
109
- | 审计方法论 | `AUDIT.md` |
110
- | 最佳实践标准 | `BEST-PRACTICES.md` |
111
- | 分类检测 | `REPO-CLASSIFICATION.md` |
112
- | 核心引擎 | `repo-audit.mjs` |
113
- | 审计规则 | `rules/`(domains + categories) |
114
- | 脚手架生成器 | `templates/scaffold.mjs` |
115
- | 废弃开发仓(仅历史参考) | `dsh-ecosystem/research/scaffold-templates/` |
116
-
117
- ## 6. 维护规则
118
-
119
- - **更新时机**:跨 session / 里程碑 / 用户要求交接时
120
- - **防双源**:本文件只记 delta,文档与 commit 已有内容引用不复制
121
- - **滚动归档**:已确认修复的坑 → `HANDOFF-ARCHIVE/pits.md`,已完成待办 → `HANDOFF-ARCHIVE/done.md`
122
- - **回填约定**:改动规则/引擎后,同步更新 `docs/repo-audit/HUMAN-GUIDE.md` 和 `AGENT-GUIDE.md`
123
- - **脱敏**:不含 API Key/密码/PII(本交接含 `ninjasin-labs` 内部路径,若 push 公开前需注意;或建 .gitignore 排除 HANDOFF.md)
124
- - **主战场**:所有开发在本仓完成,废弃仓不再同步