@boyingliu01/xp-gate 0.12.12 → 0.12.13

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/adapters/iac.sh CHANGED
@@ -20,8 +20,12 @@ detect_iac_files() {
20
20
  tf_files="$tf_files $file"
21
21
  ;;
22
22
  *.yaml|*.yml)
23
+ # Check if it's inside .github/workflows/ (GitHub Actions)
24
+ if echo "$file" | grep -q "\.github/workflows/"; then
25
+ # Pass directly to checkov as a GitHub Actions file
26
+ yaml_files="$yaml_files $file"
23
27
  # Check if it's a K8s manifest (has apiVersion and kind)
24
- if grep -qE "^(apiVersion|kind):" "$file" 2>/dev/null; then
28
+ elif grep -qE "^(apiVersion|kind):" "$file" 2>/dev/null; then
25
29
  yaml_files="$yaml_files $file"
26
30
  fi
27
31
  ;;
@@ -59,52 +63,75 @@ run_static_analysis() {
59
63
  # Try checkov first (recommended - supports multiple platforms)
60
64
  if command -v checkov >/dev/null 2>&1; then
61
65
  echo "Running checkov IaC security scan..."
62
-
66
+
67
+ # checkov 3.x always exits 0 even on failures. We capture output to a
68
+ # temp file and parse it for "FAILED for resource" lines instead.
69
+ local checkov_log=$(mktemp)
70
+ local checkov_args="--compact"
71
+
63
72
  # Run checkov on all detected IaC files
64
73
  local tf_files=$(echo "$iac_files" | grep "TERRAFORM:" | sed 's/TERRAFORM://')
65
74
  local k8s_files=$(echo "$iac_files" | grep "KUBERNETES:" | sed 's/KUBERNETES://')
66
75
  local docker_files=$(echo "$iac_files" | grep "DOCKER:" | sed 's/DOCKER://')
67
-
76
+
68
77
  if [ -n "$tf_files" ]; then
69
78
  echo "Scanning Terraform files..."
70
79
  for file in $tf_files; do
71
80
  if [ -f "$file" ]; then
72
- checkov --file "$file" --compact 2>&1 | tail -20
73
- local tf_exit=${PIPESTATUS[0]}
74
- if [ $tf_exit -ne 0 ]; then
75
- exit_code=$tf_exit
76
- fi
81
+ checkov --file "$file" $checkov_args >> "$checkov_log" 2>&1
77
82
  fi
78
83
  done
79
84
  fi
80
-
85
+
81
86
  if [ -n "$k8s_files" ]; then
82
- echo "Scanning Kubernetes manifests..."
87
+ local gh_files=""
88
+ local k8s_only=""
83
89
  for file in $k8s_files; do
84
- if [ -f "$file" ]; then
85
- checkov --file "$file" --compact 2>&1 | tail -20
86
- local k8s_exit=${PIPESTATUS[0]}
87
- if [ $k8s_exit -ne 0 ]; then
88
- exit_code=$k8s_exit
89
- fi
90
+ if echo "$file" | grep -q "\.github/workflows/"; then
91
+ gh_files="$gh_files $file"
92
+ else
93
+ k8s_only="$k8s_only $file"
90
94
  fi
91
95
  done
96
+
97
+ if [ -n "$k8s_only" ]; then
98
+ echo "Scanning Kubernetes manifests..."
99
+ for file in $k8s_only; do
100
+ if [ -f "$file" ]; then
101
+ checkov --file "$file" $checkov_args --framework kubernetes >> "$checkov_log" 2>&1
102
+ fi
103
+ done
104
+ fi
105
+
106
+ if [ -n "$gh_files" ]; then
107
+ echo "Scanning GitHub Actions workflows..."
108
+ for file in $gh_files; do
109
+ if [ -f "$file" ]; then
110
+ checkov --file "$file" $checkov_args --framework github_actions >> "$checkov_log" 2>&1
111
+ fi
112
+ done
113
+ fi
92
114
  fi
93
-
115
+
94
116
  if [ -n "$docker_files" ]; then
95
117
  echo "Scanning Dockerfiles..."
96
118
  for file in $docker_files; do
97
119
  if [ -f "$file" ]; then
98
- checkov --file "$file" --compact 2>&1 | tail -20
99
- local docker_exit=${PIPESTATUS[0]}
100
- if [ $docker_exit -ne 0 ]; then
101
- exit_code=$docker_exit
102
- fi
120
+ checkov --file "$file" $checkov_args >> "$checkov_log" 2>&1
103
121
  fi
104
122
  done
105
123
  fi
106
-
107
- echo "checkov scan completed with exit code: $exit_code"
124
+
125
+ # Print captured output then check for failures
126
+ cat "$checkov_log"
127
+ local failed_count=$(grep -c "FAILED for resource" "$checkov_log" 2>/dev/null || echo 0)
128
+ rm -f "$checkov_log"
129
+
130
+ if [ "$failed_count" -gt 0 ]; then
131
+ echo "❌ $failed_count security issue(s) found by checkov. Blocking commit."
132
+ exit_code=1
133
+ fi
134
+ echo "checkov scan completed."
108
135
  return $exit_code
109
136
  fi
110
137
 
package/bin/xp-gate.js CHANGED
@@ -30,7 +30,7 @@ const COMMANDS = {
30
30
  'init': {
31
31
  description: 'Initialize xp-gate (use --global for all projects)',
32
32
  run: subargs => init(subargs).then(code => process.exit(code)),
33
- usage: 'xp-gate init [--global]'
33
+ usage: 'xp-gate init [--global] [--yes]'
34
34
  },
35
35
  'setup-global': {
36
36
  description: 'Set up xp-gate globally for all git projects',
@@ -125,7 +125,7 @@ const COMMANDS = {
125
125
  usage: 'xp-gate upgrade [--preview] [--apply]'
126
126
  },
127
127
  'bootstrap': {
128
- description: 'Install CLI tools required by quality gates (jscpd, lizard, checkov, gitleaks, semgrep)',
128
+ description: 'Install CLI tools required by quality gates. Also invoked by "xp-gate init --yes"',
129
129
  run: subargs => process.exit(bootstrap(subargs)),
130
130
  usage: 'xp-gate bootstrap [--dry-run] [--verbose]'
131
131
  },
package/lib/init.js CHANGED
@@ -279,13 +279,75 @@ function printCliToolStatus() {
279
279
  console.log(`CLI tools: ${available.length}/${GATE_CLI_TOOLS.length} available`);
280
280
  if (missing.length > 0) {
281
281
  console.log(` Missing: ${missing.join(', ')}`);
282
- console.log(' Quality gates using these tools will silently SKIP until they are installed.');
283
- console.log(` Run 'xp-gate bootstrap' to install all missing tools, or 'xp-gate doctor' for details.\n`);
282
+ console.log(' Quality gates using these tools will silently SKIP until they are installed.\n');
284
283
  } else {
285
284
  console.log('');
286
285
  }
287
286
  }
288
287
 
288
+ /**
289
+ * Ask the user for confirmation via stdin.
290
+ * @param {string} question - The yes/no question to display
291
+ * @returns {Promise<boolean>} true if user answered yes
292
+ */
293
+ function askYesNo(question) {
294
+ return new Promise((resolve) => {
295
+ const rl = require('readline').createInterface({
296
+ input: process.stdin,
297
+ output: process.stdout,
298
+ });
299
+ rl.question(`${question} (Y/n) `, (answer) => {
300
+ rl.close();
301
+ const normalized = answer.trim().toLowerCase();
302
+ // Empty (just Enter) or y/yes → yes; anything else → no
303
+ resolve(normalized === '' || normalized === 'y' || normalized === 'yes');
304
+ });
305
+ });
306
+ }
307
+
308
+ /**
309
+ * Prompt the user to auto-install missing CLI quality-gate tools.
310
+ * Called after installation completes. Interactive only when TTY is available.
311
+ * Skips silently when no tools are missing.
312
+ *
313
+ * @param {boolean} autoYes - If true, skip prompt and auto-install
314
+ * @returns {Promise<number>} 0 on success or skipped, 1 on failure
315
+ */
316
+ async function promptBootstrap(autoYes) {
317
+ const { bootstrap } = require('./bootstrap.js');
318
+
319
+ // Check what's missing without printing a full header
320
+ const missing = [];
321
+ for (const entry of GATE_CLI_TOOLS) {
322
+ const result = checkCliTool(entry.tool);
323
+ if (!result.available) {
324
+ missing.push(entry.tool);
325
+ }
326
+ }
327
+
328
+ if (missing.length === 0) return 0;
329
+
330
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
331
+ console.log(' Quality Gate CLI Tools');
332
+ console.log('');
333
+ console.log(` ${missing.length} tool(s) required by quality gates are not installed:`);
334
+ for (const tool of missing) {
335
+ console.log(` ✗ ${tool}`);
336
+ }
337
+ console.log('');
338
+ console.log(' Without these tools, the corresponding quality gates will');
339
+ console.log(' silently SKIP during git commits — you may miss issues.');
340
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
341
+
342
+ if (autoYes || (process.stdin.isTTY && await askYesNo('\nInstall missing tools now?'))) {
343
+ console.log('');
344
+ return bootstrap([]);
345
+ }
346
+
347
+ console.log('\n Skipped. Run "xp-gate bootstrap" later to install them.');
348
+ return 0;
349
+ }
350
+
289
351
  async function init(args) {
290
352
  console.log('XP-Gate Initialization');
291
353
  console.log('====================\n');
@@ -384,7 +446,10 @@ async function installLocal(args) {
384
446
 
385
447
  console.log('\nInstallation complete!');
386
448
  console.log('Run git commit to trigger quality gates');
387
- console.log('');
449
+
450
+ // Auto-install missing CLI tools (prompt user)
451
+ const autoYes = args.includes('--yes') || args.includes('--auto-install');
452
+ await promptBootstrap(autoYes);
388
453
  console.log('━━━ FIRST-CLASS TEST QUALITY ━━━');
389
454
  console.log('XP-Gate treats test code as a first-class citizen:');
390
455
  console.log(' • TypeScript: test files are type-checked, not excluded from tsconfig.json');
@@ -455,6 +520,11 @@ async function setupGlobal(args) {
455
520
  console.log('\nGlobal setup complete!');
456
521
  console.log('All git repositories will now use xp-gate quality gates.');
457
522
  console.log('Per-project adapters can still override by creating <repo>/githooks/');
523
+
524
+ // Auto-install missing CLI tools (prompt user)
525
+ const autoYes = args.includes('--yes') || args.includes('--auto-install');
526
+ await promptBootstrap(autoYes);
527
+
458
528
  console.log('');
459
529
  console.log('━━━ FIRST-CLASS TEST QUALITY ━━━');
460
530
  console.log('XP-Gate treats test code as a first-class citizen:');
@@ -556,4 +626,4 @@ function injectKarpathyPrinciples(projectRoot) {
556
626
  }
557
627
  }
558
628
 
559
- module.exports = { init };
629
+ module.exports = { init, promptBootstrap };
@@ -1,9 +1,9 @@
1
1
  # SRC/MOCK-POLICY KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Mock layering policy enforcement — Gate M3 of pre-push hook. Ensures integration tests use real implementations for internal dependencies, mock external dependencies, and annotate pending mocks with removal plans. Combines project scope scanning, mock decision engine, and per-file validation into a single pipeline.
@@ -1,9 +1,9 @@
1
1
  # SRC/MUTATION KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "./bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 10 quality gates (Gate 0-9), Sprint Flow (11 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills + Sprint Flow TUI sidebar for OpenCode",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Qoder. Includes 10 quality gates (Gate 0-9), Sprint Flow (11 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,9 +1,9 @@
1
1
  # PRINCIPLES CHECKER MODULE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-06
4
- **Commit:** 132a12e
3
+ **Generated:** 2026-07-07
4
+ **Commit:** 897f8eb
5
5
  **Branch:** main
6
- **Version:** 0.12.12.0
6
+ **Version:** 0.12.13.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.