@delegance/claude-autopilot 1.2.5 → 1.2.7

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/README.md CHANGED
@@ -10,6 +10,17 @@ npm install @delegance/claude-autopilot
10
10
 
11
11
  **Prerequisites:** Node 22+, [`gh` CLI](https://cli.github.com/) authenticated, [`claude` CLI](https://claude.ai/claude-code) (Claude Code).
12
12
 
13
+ ## Claude Code Skill
14
+
15
+ The package ships a ready-made Claude Code skill. After installing, copy it into your project:
16
+
17
+ ```bash
18
+ mkdir -p .claude/skills
19
+ cp node_modules/@delegance/claude-autopilot/skills/autopilot.md .claude/skills/
20
+ ```
21
+
22
+ Claude will then know when and how to invoke `autopilot run`, interpret findings, and wire it into your dev pipeline automatically.
23
+
13
24
  ## Quick Start
14
25
 
15
26
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delegance/claude-autopilot",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "type": "module",
5
5
  "description": "Claude Code automation pipeline: spec \u2192 plan \u2192 implement \u2192 validate \u2192 PR",
6
6
  "keywords": [
@@ -32,6 +32,7 @@
32
32
  "bin/",
33
33
  "src/",
34
34
  "presets/",
35
+ "skills/",
35
36
  "scripts/test-runner.mjs",
36
37
  "scripts/autoregress.ts",
37
38
  "tests/snapshots/",
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: autopilot
3
+ description: Run the @delegance/claude-autopilot code review pipeline — static rules, LLM review, snapshot regression. Use before any PR or after completing a feature.
4
+ ---
5
+
6
+ # autopilot — Code Review Pipeline
7
+
8
+ Runs static rules, optional LLM review (Codex), and impact-aware snapshot regression tests on git-changed files. Outputs findings inline and optionally as SARIF for GitHub Code Scanning.
9
+
10
+ ## When to Use
11
+
12
+ - Before creating a PR (catch issues before review)
13
+ - After completing a feature branch (validate the full changeset)
14
+ - Inside a CI pipeline step (use `--format sarif --output results.sarif`)
15
+ - Anytime `validate` is called in a dev pipeline
16
+
17
+ ## Prerequisites
18
+
19
+ Run `npx autopilot doctor` once per project setup to verify:
20
+ - Node 22+, tsx, gh CLI authenticated, claude CLI, OPENAI_API_KEY, git user config
21
+
22
+ ## Commands
23
+
24
+ ### Run pipeline on changed files
25
+
26
+ ```bash
27
+ # Diff against HEAD~1 (default — last commit)
28
+ npx autopilot run
29
+
30
+ # Diff against a branch (typical pre-PR use)
31
+ npx autopilot run --base main
32
+
33
+ # Explicit file list (skip git detection)
34
+ npx autopilot run --files src/foo.ts,src/bar.ts
35
+
36
+ # Dry run — show what would run, no execution
37
+ npx autopilot run --dry-run
38
+
39
+ # SARIF output for GitHub Code Scanning
40
+ npx autopilot run --format sarif --output autopilot.sarif
41
+ ```
42
+
43
+ ### Zero-prompt setup (new project)
44
+
45
+ ```bash
46
+ npx autopilot setup
47
+ ```
48
+
49
+ Auto-detects project type (Go, Rails, FastAPI, T3, Next.js+Supabase), writes `autopilot.config.yaml`, installs pre-push hook, runs doctor.
50
+
51
+ ### Check prerequisites
52
+
53
+ ```bash
54
+ npx autopilot doctor
55
+ ```
56
+
57
+ Exits 1 if blockers found. Safe to re-run anytime.
58
+
59
+ ### Watch mode (dev loop)
60
+
61
+ ```bash
62
+ npx autopilot watch # re-run on every file save
63
+ npx autopilot watch --debounce 500
64
+ ```
65
+
66
+ ### Snapshot regression testing
67
+
68
+ ```bash
69
+ # Generate baselines for changed files (requires OPENAI_API_KEY)
70
+ npx autopilot autoregress generate
71
+
72
+ # Run only impact-selected snapshots (default — fast)
73
+ npx autopilot autoregress run
74
+
75
+ # Run all snapshots
76
+ npx autopilot autoregress run --all
77
+
78
+ # Show diffs vs baselines
79
+ npx autopilot autoregress diff
80
+
81
+ # Overwrite baselines after intentional behavior change
82
+ npx autopilot autoregress update
83
+ ```
84
+
85
+ ### Pre-push git hook
86
+
87
+ ```bash
88
+ npx autopilot hook install # write .git/hooks/pre-push
89
+ npx autopilot hook uninstall
90
+ npx autopilot hook status
91
+ ```
92
+
93
+ ## Interpreting Results
94
+
95
+ **Exit code 0** — no findings, or only warnings. Safe to proceed.
96
+
97
+ **Exit code 1** — one or more blocking findings. Fix before merging.
98
+
99
+ **Finding severities:**
100
+ - `error` — blocks merge (hardcoded secrets, npm audit Critical/High, failed tests)
101
+ - `warning` — should fix, won't block
102
+ - `info` — informational
103
+
104
+ **SARIF output** — upload to GitHub Code Scanning with `github/codeql-action/upload-sarif@v3` for inline PR annotations.
105
+
106
+ ## Config (`autopilot.config.yaml`)
107
+
108
+ ```yaml
109
+ configVersion: 1
110
+ reviewEngine:
111
+ adapter: codex # LLM review via OpenAI (requires OPENAI_API_KEY)
112
+ testCommand: npm test
113
+ protectedPaths:
114
+ - src/core/**
115
+ staticRules:
116
+ - hardcoded-secrets
117
+ - npm-audit
118
+ ```
119
+
120
+ Full schema and preset defaults: `node_modules/@delegance/claude-autopilot/presets/<name>/autopilot.config.yaml`
121
+
122
+ ## Integration with Development Pipeline
123
+
124
+ In a full spec→PR pipeline, `autopilot run` replaces the validate step:
125
+
126
+ ```bash
127
+ # After implementing feature on branch
128
+ npx autopilot run --base main
129
+
130
+ # If findings → fix → re-run (max 3 iterations)
131
+ # If clean → push → create PR
132
+ ```
133
+
134
+ ## GitHub Actions
135
+
136
+ ```yaml
137
+ - uses: axledbetter/claude-autopilot/.github/actions/ci@main
138
+ with:
139
+ openai-api-key: ${{ secrets.OPENAI_API_KEY }}
140
+ ```
141
+
142
+ Runs the pipeline, uploads SARIF, annotates the PR diff inline.
package/src/cli/run.ts CHANGED
@@ -1,6 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  import * as path from 'node:path';
3
3
  import * as fs from 'node:fs';
4
+
5
+ // Load .env.local / .env so OPENAI_API_KEY etc. are available without shell export
6
+ const ENV_FILES = ['.env.local', '.env.dev', '.env.development', '.env'];
7
+ for (const f of ENV_FILES) {
8
+ const p = path.join(process.cwd(), f);
9
+ if (!fs.existsSync(p)) continue;
10
+ for (const line of fs.readFileSync(p, 'utf8').split('\n')) {
11
+ const t = line.trim();
12
+ if (!t || t.startsWith('#')) continue;
13
+ const eq = t.indexOf('=');
14
+ if (eq < 0) continue;
15
+ const key = t.slice(0, eq).trim();
16
+ if (!process.env[key]) {
17
+ process.env[key] = t.slice(eq + 1).trim().replace(/^['"]|['"]$/g, '');
18
+ }
19
+ }
20
+ break;
21
+ }
22
+
4
23
  import { loadConfig } from '../core/config/loader.ts';
5
24
  import { resolvePreset } from '../core/config/preset-resolver.ts';
6
25
  import { mergeConfigs } from '../core/config/preset-resolver.ts';