ai-project-maintainer 0.3.0

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/ai-project-maintainer/SKILL.md +62 -0
  4. package/ai-project-maintainer/agents/openai.yaml +6 -0
  5. package/ai-project-maintainer/references/ci-guardrails.md +55 -0
  6. package/ai-project-maintainer/references/database.md +60 -0
  7. package/ai-project-maintainer/references/electron-desktop.md +43 -0
  8. package/ai-project-maintainer/references/incident-response.md +52 -0
  9. package/ai-project-maintainer/references/local-gate.md +117 -0
  10. package/ai-project-maintainer/references/security.md +48 -0
  11. package/ai-project-maintainer/references/tool-router.md +53 -0
  12. package/ai-project-maintainer/scripts/audit-plan.mjs +155 -0
  13. package/ai-project-maintainer/scripts/bootstrap-local-tools.ps1 +109 -0
  14. package/ai-project-maintainer/scripts/check-syntax.mjs +41 -0
  15. package/ai-project-maintainer/scripts/ci-smoke-gate.mjs +26 -0
  16. package/ai-project-maintainer/scripts/cli.mjs +165 -0
  17. package/ai-project-maintainer/scripts/doctor.mjs +80 -0
  18. package/ai-project-maintainer/scripts/init-audit.mjs +105 -0
  19. package/ai-project-maintainer/scripts/init-project.mjs +229 -0
  20. package/ai-project-maintainer/scripts/lib/check-registry.mjs +68 -0
  21. package/ai-project-maintainer/scripts/lib/checks.mjs +337 -0
  22. package/ai-project-maintainer/scripts/lib/command-runner.mjs +130 -0
  23. package/ai-project-maintainer/scripts/lib/intake.mjs +172 -0
  24. package/ai-project-maintainer/scripts/lib/policy.mjs +150 -0
  25. package/ai-project-maintainer/scripts/lib/project-detect.mjs +111 -0
  26. package/ai-project-maintainer/scripts/lib/report.mjs +227 -0
  27. package/ai-project-maintainer/scripts/probe-project.mjs +218 -0
  28. package/ai-project-maintainer/scripts/report-summary.mjs +25 -0
  29. package/ai-project-maintainer/scripts/run-local-gate.mjs +147 -0
  30. package/docs/CI-GITHUB-ACTIONS.zh-CN.md +83 -0
  31. package/docs/DEMO.md +81 -0
  32. package/docs/DEMO.zh-CN.md +81 -0
  33. package/docs/GITHUB-LAUNCH-CHECKLIST.md +77 -0
  34. package/docs/INSTALL.zh-CN.md +112 -0
  35. package/docs/INTAKE-SCHEMA.zh-CN.md +105 -0
  36. package/docs/POLICY-AND-EXCEPTIONS.zh-CN.md +96 -0
  37. package/docs/PRODUCTION-AUDIT.zh-CN.md +89 -0
  38. package/docs/PROMOTION.md +116 -0
  39. package/docs/UPGRADE-ROADMAP.zh-CN.md +47 -0
  40. package/docs/demo-output/security-report.md +57 -0
  41. package/docs/superpowers/plans/2026-06-29-ci-dogfooding.md +200 -0
  42. package/package.json +21 -0
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { toMarkdown } from "./lib/report.mjs";
6
+
7
+ export function summarizeReport(reportPath) {
8
+ const full = path.resolve(reportPath);
9
+ const text = fs.readFileSync(full, "utf8").replace(/^\uFEFF/, "");
10
+ const report = JSON.parse(text);
11
+ return toMarkdown(report);
12
+ }
13
+
14
+ function main() {
15
+ const reportPath = process.argv.slice(2).find((arg) => !arg.startsWith("--"));
16
+ if (!reportPath) {
17
+ console.error("Usage: node report-summary.mjs <reports/security-report.json>");
18
+ process.exit(2);
19
+ }
20
+ console.log(summarizeReport(reportPath));
21
+ }
22
+
23
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
24
+ main();
25
+ }
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { buildAuditPlan } from "./audit-plan.mjs";
6
+ import { detectProject } from "./lib/project-detect.mjs";
7
+ import { getToolVersions } from "./lib/command-runner.mjs";
8
+ import { runRegisteredChecks } from "./lib/check-registry.mjs";
9
+ import { loadIntake } from "./lib/intake.mjs";
10
+ import { applyPolicy, loadPolicyBundle } from "./lib/policy.mjs";
11
+ import { buildJsonReport, toMarkdown, writeReportFiles } from "./lib/report.mjs";
12
+
13
+ const versionedTools = [
14
+ "git",
15
+ "npm",
16
+ "pnpm",
17
+ "yarn",
18
+ "bun",
19
+ "gitleaks",
20
+ "trivy",
21
+ "semgrep",
22
+ "osv-scanner",
23
+ "actionlint",
24
+ "zizmor",
25
+ "syft",
26
+ "grype",
27
+ "checkov",
28
+ "squawk",
29
+ "scorecard",
30
+ "pre-commit",
31
+ "mega-linter-runner",
32
+ ];
33
+
34
+ function resolveOutputPath(root, outputPath) {
35
+ if (!outputPath) return path.join(root, "reports", "security-report.json");
36
+ return path.isAbsolute(outputPath) ? outputPath : path.resolve(root, outputPath);
37
+ }
38
+
39
+ function productionAuditChecks(audit, intake) {
40
+ if (!audit) return [];
41
+ const productionPolicy = intake.riskPolicy?.production || {};
42
+ const blockOnCoverageGaps = Boolean(productionPolicy.block_on_coverage_gaps);
43
+ const blockOnUserDecisions = Boolean(productionPolicy.block_on_user_decisions);
44
+ return audit.plan
45
+ .filter((item) => item.status === "GAP" || item.status === "USER_DECISION")
46
+ .map((item) => ({
47
+ checkId: `production-${item.id}`,
48
+ name: `production audit: ${item.title}`,
49
+ group: "production-audit",
50
+ status: item.status,
51
+ blocking: item.status === "GAP" ? blockOnCoverageGaps : blockOnUserDecisions,
52
+ coverageGap: item.status === "GAP",
53
+ summary: item.summary,
54
+ recommendation: item.recommendation,
55
+ }));
56
+ }
57
+
58
+ export function runLocalGate(projectRoot, options = {}) {
59
+ const root = path.resolve(projectRoot || process.cwd());
60
+ const outputPath = resolveOutputPath(root, options.outputPath);
61
+ const writeReports = Boolean(options.writeReports);
62
+ const sbomOutputPath = writeReports ? path.join(path.dirname(outputPath), "sbom.cdx.json") : null;
63
+ if (writeReports) fs.mkdirSync(path.dirname(outputPath), { recursive: true });
64
+ const project = detectProject(root);
65
+ const policyBundle = loadPolicyBundle(root);
66
+ const intake = options.production ? loadIntake(root, project) : null;
67
+ const audit = options.production ? buildAuditPlan(project, intake) : null;
68
+ const checks = runRegisteredChecks(project, {
69
+ strict: Boolean(options.strict),
70
+ release: Boolean(options.release),
71
+ noTests: Boolean(options.noTests),
72
+ runnerOptions: options.runnerOptions || {},
73
+ sbomOutputPath,
74
+ policy: policyBundle.policy,
75
+ }).concat(productionAuditChecks(audit, intake));
76
+ const policyResult = applyPolicy(checks, policyBundle);
77
+ const toolVersions = getToolVersions(versionedTools, options.runnerOptions || {});
78
+ const report = buildJsonReport({
79
+ root,
80
+ mode: {
81
+ strict: Boolean(options.strict),
82
+ release: Boolean(options.release),
83
+ noTests: Boolean(options.noTests),
84
+ production: Boolean(options.production),
85
+ policy: policyBundle.policy.mode,
86
+ },
87
+ probe: project,
88
+ checks: policyResult.checks,
89
+ toolVersions,
90
+ invalidExceptions: policyResult.invalidExceptions,
91
+ audit,
92
+ });
93
+
94
+ if (writeReports) writeReportFiles(report, outputPath);
95
+ return report;
96
+ }
97
+
98
+ function parseArgs(args) {
99
+ const positional = [];
100
+ const parsed = {
101
+ strict: false,
102
+ release: false,
103
+ jsonOnly: false,
104
+ noTests: false,
105
+ production: false,
106
+ outputPath: null,
107
+ };
108
+
109
+ for (let i = 0; i < args.length; i += 1) {
110
+ const arg = args[i];
111
+ if (arg === "--strict") parsed.strict = true;
112
+ else if (arg === "--release") parsed.release = true;
113
+ else if (arg === "--json") parsed.jsonOnly = true;
114
+ else if (arg === "--no-tests") parsed.noTests = true;
115
+ else if (arg === "--production") parsed.production = true;
116
+ else if (arg === "--output") parsed.outputPath = args[++i];
117
+ else if (arg.startsWith("--output=")) parsed.outputPath = arg.slice("--output=".length);
118
+ else if (!arg.startsWith("--")) positional.push(arg);
119
+ }
120
+
121
+ parsed.projectRoot = positional[0] || process.cwd();
122
+ return parsed;
123
+ }
124
+
125
+ function main() {
126
+ const args = parseArgs(process.argv.slice(2));
127
+ const report = runLocalGate(args.projectRoot, {
128
+ strict: args.strict,
129
+ release: args.release,
130
+ noTests: args.noTests,
131
+ production: args.production,
132
+ outputPath: args.outputPath,
133
+ writeReports: true,
134
+ });
135
+
136
+ if (args.jsonOnly) {
137
+ console.log(JSON.stringify(report, null, 2));
138
+ } else {
139
+ console.log(toMarkdown(report));
140
+ }
141
+
142
+ process.exit(report.passed ? 0 : 1);
143
+ }
144
+
145
+ if (import.meta.url === pathToFileURL(fileURLToPath(import.meta.url)).href && process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
146
+ main();
147
+ }
@@ -0,0 +1,83 @@
1
+ # GitHub Actions 接入说明
2
+
3
+ ## 生成 CI
4
+
5
+ 如果已经发布到 npm,可以用:
6
+
7
+ ```powershell
8
+ npx ai-project-maintainer init "E:\我的项目" --profile oss --ci github
9
+ ```
10
+
11
+ 如果还没有 npm 账号或还没有发布 npm 包,也可以从源码运行初始化脚本:
12
+
13
+ ```powershell
14
+ git clone https://github.com/xixifusi1213-gif/ai-project-maintainer.git
15
+ cd .\ai-project-maintainer
16
+ npm install
17
+ node .\ai-project-maintainer\scripts\init-project.mjs "E:\我的项目" --profile oss --ci github
18
+ ```
19
+
20
+ 会生成:
21
+
22
+ ```text
23
+ .github/workflows/security-gate.yml
24
+ .github/dependabot.yml
25
+ ```
26
+
27
+ ## CI 如何调用工具包
28
+
29
+ 生成出来的 GitHub Actions 模板不依赖 npm 包发布,也不需要 npm 账号。
30
+
31
+ 默认 workflow 会:
32
+
33
+ - checkout 你的项目代码。
34
+ - 安装 Node。
35
+ - 根据 lockfile 安装你的项目依赖。
36
+ - 安装常用安全扫描器。
37
+ - 临时 clone `https://github.com/xixifusi1213-gif/ai-project-maintainer.git` 到 runner。
38
+ - 在 runner 里安装工具包依赖。
39
+ - 如果项目存在 `.ai-maintainer/project-profile.yml`,自动追加 `--production`。
40
+ - 运行 `node "$RUNNER_TEMP/ai-project-maintainer/ai-project-maintainer/scripts/run-local-gate.mjs" "$GITHUB_WORKSPACE" --strict --release $EXTRA_FLAGS --output reports/security-report.json`。
41
+ - 把 Markdown 报告写入 GitHub Step Summary。
42
+ - 尝试上传 SARIF 到 GitHub Code Scanning。
43
+ - 上传 `reports/` 作为 artifact。
44
+
45
+ 这意味着:只要你的工具包 GitHub 仓库是公开可 clone 的,同学的项目就能直接使用这套 CI 门禁,不需要你先发布 npm 包。
46
+
47
+ ## 阻断标准
48
+
49
+ 默认阻断:
50
+
51
+ - 测试、构建、打包失败。
52
+ - secret 扫描命中。
53
+ - 生产依赖高危或严重漏洞。
54
+ - Semgrep 阻断发现。
55
+ - Trivy 数据库在严格模式下不可用。
56
+ - Electron 危险配置。
57
+ - GitHub Actions 高风险配置。
58
+ - 过期或缺字段的例外。
59
+
60
+ 默认不阻断:
61
+
62
+ - 缺少生产监控、日志、备份、回滚、发布审批等证据,报告中标记为 `GAP`。
63
+ - `USER_DECISION` 项,例如核心业务流程尚未由项目负责人确认。
64
+
65
+ 如果希望生产证据缺口也阻断 CI,在 `.ai-maintainer/risk-policy.yml` 设置:
66
+
67
+ ```yaml
68
+ production:
69
+ block_on_coverage_gaps: true
70
+ ```
71
+
72
+ ## 报告
73
+
74
+ CI 上传的 `security-reports` artifact 通常包含:
75
+
76
+ ```text
77
+ security-report.json
78
+ security-report.md
79
+ security-report.sarif
80
+ sbom.cdx.json
81
+ ```
82
+
83
+ `security-report.md` 会包含 `Production Audit`、`Coverage Gaps` 和 `User Decisions`。
package/docs/DEMO.md ADDED
@@ -0,0 +1,81 @@
1
+ # Demo: From AI-Coded Repo to Production Audit Report
2
+
3
+ This demo shows the core workflow without requiring any paid account or external API.
4
+
5
+ ## 1. Initialize The Project
6
+
7
+ ```powershell
8
+ npx ai-project-maintainer init "E:\my-project" --profile oss --ci github
9
+ ```
10
+
11
+ This creates the local policy, exceptions file, GitHub Actions workflow, Dependabot config, and report directory.
12
+
13
+ ## 2. Create Production Audit Intake
14
+
15
+ ```powershell
16
+ npx ai-project-maintainer init-audit "E:\my-project"
17
+ ```
18
+
19
+ This creates:
20
+
21
+ ```text
22
+ .ai-maintainer/project-profile.yml
23
+ .ai-maintainer/evidence-sources.yml
24
+ .ai-maintainer/business-flows.yml
25
+ .ai-maintainer/risk-policy.yml
26
+ .ai-maintainer/threat-model.md
27
+ .ai-maintainer/release-checklist.yml
28
+ .ai-maintainer/incident-runbook.md
29
+ .ai-maintainer/db-migration-policy.yml
30
+ .ai-maintainer/observability-checklist.yml
31
+ ```
32
+
33
+ These files record project facts and evidence locations. They should not contain tokens, DSNs, passwords, or production secrets.
34
+
35
+ ## 3. Generate An Audit Plan
36
+
37
+ ```powershell
38
+ npx ai-project-maintainer audit-plan "E:\my-project" --output reports/audit-plan.json
39
+ ```
40
+
41
+ Example output:
42
+
43
+ ```text
44
+ PASS Production audit intake is present.
45
+ USER_DECISION Critical business flows must be declared.
46
+ GAP No GitHub Actions workflow evidence detected.
47
+ GAP No production release approval evidence declared.
48
+ GAP Error monitoring evidence is missing.
49
+ N/A No database surface detected or declared.
50
+ ```
51
+
52
+ The point is not to pretend the project is safe. The point is to make missing production evidence visible.
53
+
54
+ ## 4. Run The Production Gate
55
+
56
+ ```powershell
57
+ npx ai-project-maintainer gate "E:\my-project" --production --strict --release --output reports/security-report.json
58
+ ```
59
+
60
+ The report combines deterministic scanner output with production-readiness evidence:
61
+
62
+ ```text
63
+ PASS gitleaks secret scan
64
+ PASS trivy filesystem scan
65
+ PASS semgrep static scan
66
+ GAP Error monitoring evidence is missing.
67
+ GAP Production logs evidence is missing.
68
+ USER_DECISION Critical business flows must be declared.
69
+ ```
70
+
71
+ See [sample report](demo-output/security-report.md).
72
+
73
+ ## 5. Let Codex Fix Blockers
74
+
75
+ Ask Codex:
76
+
77
+ ```text
78
+ $ai-project-maintainer run the production gate for this project, fix blockers, and rerun until it passes.
79
+ ```
80
+
81
+ Codex can handle deterministic blockers. The maintainer still owns business decisions such as critical flows, accepted risks, and production evidence.
@@ -0,0 +1,81 @@
1
+ # 演示:从 AI coding 项目到生产审查报告
2
+
3
+ 这个 demo 不需要付费账号,也不需要外部 API。
4
+
5
+ ## 1. 初始化项目门禁
6
+
7
+ ```powershell
8
+ npx ai-project-maintainer init "E:\我的项目" --profile oss --ci github
9
+ ```
10
+
11
+ 这会生成本地策略、例外文件、GitHub Actions、Dependabot 配置和报告目录。
12
+
13
+ ## 2. 生成生产审查画像
14
+
15
+ ```powershell
16
+ npx ai-project-maintainer init-audit "E:\我的项目"
17
+ ```
18
+
19
+ 这会生成:
20
+
21
+ ```text
22
+ .ai-maintainer/project-profile.yml
23
+ .ai-maintainer/evidence-sources.yml
24
+ .ai-maintainer/business-flows.yml
25
+ .ai-maintainer/risk-policy.yml
26
+ .ai-maintainer/threat-model.md
27
+ .ai-maintainer/release-checklist.yml
28
+ .ai-maintainer/incident-runbook.md
29
+ .ai-maintainer/db-migration-policy.yml
30
+ .ai-maintainer/observability-checklist.yml
31
+ ```
32
+
33
+ 这些文件只记录项目事实和证据来源,不应该写 token、DSN、密码或生产 secret。
34
+
35
+ ## 3. 生成审计计划
36
+
37
+ ```powershell
38
+ npx ai-project-maintainer audit-plan "E:\我的项目" --output reports/audit-plan.json
39
+ ```
40
+
41
+ 示例输出:
42
+
43
+ ```text
44
+ PASS 生产审查画像已存在。
45
+ USER_DECISION 需要项目负责人声明核心业务流程。
46
+ GAP 没有 GitHub Actions 证据。
47
+ GAP 没有生产发布审批证据。
48
+ GAP 缺少错误监控证据。
49
+ N/A 没有检测到数据库。
50
+ ```
51
+
52
+ 重点不是假装项目安全,而是把“缺少哪些生产证据”明确写出来。
53
+
54
+ ## 4. 运行生产级门禁
55
+
56
+ ```powershell
57
+ npx ai-project-maintainer gate "E:\我的项目" --production --strict --release --output reports/security-report.json
58
+ ```
59
+
60
+ 报告会把确定性扫描结果和生产准备度证据合在一起:
61
+
62
+ ```text
63
+ PASS gitleaks secret scan
64
+ PASS trivy filesystem scan
65
+ PASS semgrep static scan
66
+ GAP 缺少错误监控证据。
67
+ GAP 缺少生产日志证据。
68
+ USER_DECISION 需要声明核心业务流程。
69
+ ```
70
+
71
+ 查看 [示例报告](demo-output/security-report.md)。
72
+
73
+ ## 5. 让 Codex 修阻断项
74
+
75
+ 对 Codex 说:
76
+
77
+ ```text
78
+ $ai-project-maintainer 对这个项目运行生产级门禁,修复阻断项,然后重新运行直到通过。
79
+ ```
80
+
81
+ Codex 可以处理确定性的阻断项。项目负责人仍然负责核心业务流程、风险接受和生产证据判断。
@@ -0,0 +1,77 @@
1
+ # GitHub Launch Checklist
2
+
3
+ These steps require GitHub UI access if `gh` is not authenticated locally.
4
+
5
+ ## Repository About
6
+
7
+ Open the repository page and click the gear icon in the About panel.
8
+
9
+ Description:
10
+
11
+ ```text
12
+ Production-readiness audit and CI gate for AI-coded projects.
13
+ ```
14
+
15
+ Topics:
16
+
17
+ ```text
18
+ ai-coding
19
+ devsecops
20
+ security
21
+ production-readiness
22
+ codex
23
+ github-actions
24
+ semgrep
25
+ trivy
26
+ gitleaks
27
+ ai-agents
28
+ ```
29
+
30
+ ## Social Preview
31
+
32
+ Upload a social preview image in repository settings.
33
+
34
+ Recommended source:
35
+
36
+ ```text
37
+ assets/social-preview.png
38
+ ```
39
+
40
+ Editable source:
41
+
42
+ ```text
43
+ assets/social-preview.svg
44
+ ```
45
+
46
+ If GitHub asks for PNG/JPG, export the SVG to PNG at `1280x640`.
47
+
48
+ ## Release
49
+
50
+ Create release:
51
+
52
+ ```text
53
+ Tag: v0.3.0
54
+ Title: v0.3.0: Production audit intake and gate for AI-coded projects
55
+ ```
56
+
57
+ Release notes:
58
+
59
+ ```text
60
+ ## Highlights
61
+
62
+ - Added `init-audit` to generate project profile and production evidence templates.
63
+ - Added `audit-plan` to produce project-specific production-readiness plans.
64
+ - Added `gate --production` to combine scanner evidence with production audit evidence.
65
+ - GitHub Actions can automatically enable production mode when `.ai-maintainer/project-profile.yml` exists.
66
+ - Reports now include `GAP`, `N/A`, and `USER_DECISION` production audit states.
67
+
68
+ ## Verification
69
+
70
+ - npm test
71
+ - npm run check
72
+ - npm pack --dry-run
73
+ ```
74
+
75
+ ## First Launch Posts
76
+
77
+ Use `docs/PROMOTION.md` for English and Chinese launch copy.
@@ -0,0 +1,112 @@
1
+ # AI Project Maintainer 使用说明
2
+
3
+ ## 这是什么
4
+
5
+ `ai-project-maintainer` 是一个面向 AI coding 和开源项目维护者的半自动维护门禁。
6
+
7
+ 它不会保证项目绝对安全,也不会替你完全自动维护生产项目。它负责把常见、专业、可重复的检查组织起来:测试、secret、依赖漏洞、静态安全扫描、CI 配置、SBOM、Electron 风险、数据库迁移风险、生产证据缺口和报告证据包。
8
+
9
+ ## 推荐用法:npx
10
+
11
+ 发布到 npm 后,可以这样使用:
12
+
13
+ ```powershell
14
+ npx ai-project-maintainer doctor
15
+ npx ai-project-maintainer init "E:\我的项目" --profile oss --ci github
16
+ npx ai-project-maintainer init-audit "E:\我的项目"
17
+ npx ai-project-maintainer audit-plan "E:\我的项目" --output reports/audit-plan.json
18
+ npx ai-project-maintainer gate "E:\我的项目" --production --strict --release --output reports/security-report.json
19
+ npx ai-project-maintainer summary "E:\我的项目\reports\security-report.json"
20
+ ```
21
+
22
+ ## 从源码运行
23
+
24
+ 如果还没有 npm 版本,也可以从 GitHub 克隆后直接运行源码脚本:
25
+
26
+ ```powershell
27
+ git clone https://github.com/xixifusi1213-gif/ai-project-maintainer.git
28
+ cd .\ai-project-maintainer
29
+ npm install
30
+ node .\ai-project-maintainer\scripts\doctor.mjs
31
+ node .\ai-project-maintainer\scripts\init-project.mjs "E:\我的项目" --profile oss --ci github
32
+ node .\ai-project-maintainer\scripts\init-audit.mjs "E:\我的项目"
33
+ node .\ai-project-maintainer\scripts\audit-plan.mjs "E:\我的项目" --output reports/audit-plan.json
34
+ node .\ai-project-maintainer\scripts\run-local-gate.mjs "E:\我的项目" --production --strict --release --output reports/security-report.json
35
+ ```
36
+
37
+ ## 安装为 Codex Skill
38
+
39
+ ```powershell
40
+ git clone https://github.com/xixifusi1213-gif/ai-project-maintainer.git
41
+ cd .\ai-project-maintainer
42
+ Copy-Item -Recurse .\ai-project-maintainer "$env:USERPROFILE\.codex\skills\ai-project-maintainer"
43
+ ```
44
+
45
+ 复制完成后重启 Codex,然后在项目线程中输入:
46
+
47
+ ```text
48
+ $ai-project-maintainer 先为这个项目生成生产审查画像,再生成审计计划,最后运行生产级门禁并修复阻断项。
49
+ ```
50
+
51
+ ## 初始化项目
52
+
53
+ ```powershell
54
+ npx ai-project-maintainer init "E:\我的项目" --profile oss --ci github --pre-commit
55
+ ```
56
+
57
+ 会生成:
58
+
59
+ ```text
60
+ .ai-maintainer/policy.yml
61
+ .ai-maintainer/exceptions.yml
62
+ .github/workflows/security-gate.yml
63
+ .github/dependabot.yml
64
+ .pre-commit-config.yaml
65
+ reports/.gitkeep
66
+ ```
67
+
68
+ 生成的 GitHub Actions workflow 不要求工具包已经发布到 npm。CI 会临时 clone `https://github.com/xixifusi1213-gif/ai-project-maintainer.git`,然后用 `node` 运行仓库里的门禁脚本。
69
+
70
+ ## 生产级审查
71
+
72
+ 正式审查前先运行:
73
+
74
+ ```powershell
75
+ npx ai-project-maintainer init-audit "E:\我的项目"
76
+ ```
77
+
78
+ 这会生成项目画像、证据来源、核心业务流程、风险策略、威胁模型、发布清单、事故手册、数据库迁移策略和观测性清单。
79
+
80
+ 用户需要填写业务判断和证据来源,例如:
81
+
82
+ - 这个项目是否有登录、权限、支付、财务、隐私数据。
83
+ - 核心业务流程是什么,哪些结果不能错。
84
+ - 是否有数据库、迁移、备份、回滚。
85
+ - 是否有 CI、发布审批、监控、日志、指标、告警。
86
+
87
+ 再运行:
88
+
89
+ ```powershell
90
+ npx ai-project-maintainer audit-plan "E:\我的项目" --output reports/audit-plan.json
91
+ npx ai-project-maintainer gate "E:\我的项目" --production --strict --release --output reports/security-report.json
92
+ ```
93
+
94
+ 默认情况下,缺少生产证据会标记为 `GAP`,不会直接失败。已经检查失败的高风险项仍然会失败,例如测试失败、secret 泄露、危险 Electron 配置、过期例外。
95
+
96
+ 如果希望缺少生产证据也阻断发布,在 `.ai-maintainer/risk-policy.yml` 设置:
97
+
98
+ ```yaml
99
+ production:
100
+ block_on_coverage_gaps: true
101
+ ```
102
+
103
+ ## 门禁状态
104
+
105
+ - `PASS`:已检查并通过。
106
+ - `FAIL`:已检查并失败。
107
+ - `WARN`:有风险但默认不阻断。
108
+ - `GAP`:缺少证据,无法判断。
109
+ - `N/A`:该项目不适用。
110
+ - `USER_DECISION`:需要项目负责人判断。
111
+
112
+ 真正决定是否失败的是阻断项;维护分和生产证据缺口用于帮助你判断项目健康度。