cc-safe-setup 6.2.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.mjs +68 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  **One command to make Claude Code safe for autonomous operation.** [日本語](docs/README.ja.md)
8
8
 
9
- 8 built-in hooks + 32 installable examples. Audit, create, lint, diff, watch, and learn. [Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/cheatsheet.html) · [Web Tool](https://yurukusa.github.io/cc-safe-setup/) · [Troubleshooting](TROUBLESHOOTING.md)
9
+ 8 built-in + 51 examples = **59 hooks**. 26 CLI commands. 284 tests. [Web Tool](https://yurukusa.github.io/cc-safe-setup/) · [Cheat Sheet](https://yurukusa.github.io/cc-safe-setup/cheatsheet.html) · [Troubleshooting](TROUBLESHOOTING.md)
10
10
 
11
11
  ```bash
12
12
  npx cc-safe-setup
package/index.mjs CHANGED
@@ -87,6 +87,7 @@ const BENCHMARK = process.argv.includes('--benchmark');
87
87
  const DASHBOARD = process.argv.includes('--dashboard');
88
88
  const ISSUES = process.argv.includes('--issues');
89
89
  const MIGRATE = process.argv.includes('--migrate');
90
+ const GENERATE_CI = process.argv.includes('--generate-ci');
90
91
  const COMPARE_IDX = process.argv.findIndex(a => a === '--compare');
91
92
  const COMPARE = COMPARE_IDX !== -1 ? { a: process.argv[COMPARE_IDX + 1], b: process.argv[COMPARE_IDX + 2] } : null;
92
93
  const CREATE_IDX = process.argv.findIndex(a => a === '--create');
@@ -110,6 +111,7 @@ if (HELP) {
110
111
  npx cc-safe-setup --audit --json Machine-readable output for CI/CD
111
112
  npx cc-safe-setup --scan Detect tech stack, recommend hooks
112
113
  npx cc-safe-setup --learn Learn from your block history
114
+ npx cc-safe-setup --generate-ci Generate GitHub Actions workflow for safety checks
113
115
  npx cc-safe-setup --migrate Detect hooks from other projects, suggest replacements
114
116
  npx cc-safe-setup --compare <a> <b> Compare two hooks side-by-side
115
117
  npx cc-safe-setup --issues Show GitHub Issues each hook addresses
@@ -826,6 +828,71 @@ async function fullSetup() {
826
828
  console.log();
827
829
  }
828
830
 
831
+ function generateCI() {
832
+ const workflowDir = join(process.cwd(), '.github', 'workflows');
833
+ const workflowPath = join(workflowDir, 'claude-code-safety.yml');
834
+
835
+ const workflow = `# Claude Code Safety Audit
836
+ # Generated by: npx cc-safe-setup --generate-ci
837
+ # Checks safety score on every PR and fails if below threshold
838
+
839
+ name: Claude Code Safety
840
+ on:
841
+ pull_request:
842
+ push:
843
+ branches: [main, master]
844
+
845
+ jobs:
846
+ safety-audit:
847
+ runs-on: ubuntu-latest
848
+ steps:
849
+ - uses: actions/checkout@v4
850
+
851
+ - name: Run safety audit
852
+ uses: yurukusa/cc-safe-setup@main
853
+ with:
854
+ threshold: 70
855
+
856
+ - name: Comment PR with score
857
+ if: github.event_name == 'pull_request'
858
+ uses: actions/github-script@v7
859
+ with:
860
+ script: |
861
+ const score = '\${{ steps.audit.outputs.score }}' || '?';
862
+ const grade = '\${{ steps.audit.outputs.grade }}' || '?';
863
+ github.rest.issues.createComment({
864
+ issue_number: context.issue.number,
865
+ owner: context.repo.owner,
866
+ repo: context.repo.repo,
867
+ body: \`## Claude Code Safety: \${score}/100 (Grade \${grade})\\n\\nRun \\\`npx cc-safe-setup --audit\\\` locally for details.\`
868
+ });
869
+ `;
870
+
871
+ console.log();
872
+ console.log(c.bold + ' cc-safe-setup --generate-ci' + c.reset);
873
+ console.log();
874
+
875
+ if (existsSync(workflowPath)) {
876
+ console.log(c.yellow + ' Workflow already exists: ' + workflowPath + c.reset);
877
+ console.log(c.dim + ' Delete it first if you want to regenerate.' + c.reset);
878
+ process.exit(0);
879
+ }
880
+
881
+ mkdirSync(workflowDir, { recursive: true });
882
+ writeFileSync(workflowPath, workflow);
883
+
884
+ console.log(c.green + ' ✓ Created: ' + workflowPath + c.reset);
885
+ console.log();
886
+ console.log(c.dim + ' This workflow will:' + c.reset);
887
+ console.log(c.dim + ' 1. Run safety audit on every PR and push to main' + c.reset);
888
+ console.log(c.dim + ' 2. Fail CI if safety score < 70' + c.reset);
889
+ console.log(c.dim + ' 3. Comment PR with safety score' + c.reset);
890
+ console.log();
891
+ console.log(c.dim + ' Commit and push to activate:' + c.reset);
892
+ console.log(c.bold + ' git add .github/workflows/claude-code-safety.yml && git commit -m "ci: add safety audit" && git push' + c.reset);
893
+ console.log();
894
+ }
895
+
829
896
  async function migrate() {
830
897
  const { readdirSync } = await import('fs');
831
898
 
@@ -2508,6 +2575,7 @@ async function main() {
2508
2575
  if (FULL) return fullSetup();
2509
2576
  if (DOCTOR) return doctor();
2510
2577
  if (WATCH) return watch();
2578
+ if (GENERATE_CI) return generateCI();
2511
2579
  if (MIGRATE) return migrate();
2512
2580
  if (COMPARE) return compare(COMPARE.a, COMPARE.b);
2513
2581
  if (ISSUES) return issues();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "6.2.0",
4
- "description": "One command to make Claude Code safe for autonomous operation. 8 built-in + 39 examples. 23 commands including dashboard, issues, create, audit, lint, diff. 260 tests. 2,500+ daily npm downloads.",
3
+ "version": "6.3.1",
4
+ "description": "One command to make Claude Code safe. 59 hooks (8 built-in + 51 examples). 26 CLI commands: dashboard, create, audit, lint, diff, migrate, compare, generate-ci. 284 tests.",
5
5
  "main": "index.mjs",
6
6
  "bin": {
7
7
  "cc-safe-setup": "index.mjs"