claude-cli-advanced-starter-pack 1.1.0 → 1.8.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.
- package/OVERVIEW.md +5 -1
- package/README.md +241 -132
- package/bin/gtask.js +53 -0
- package/package.json +1 -1
- package/src/cli/menu.js +27 -0
- package/src/commands/explore-mcp/mcp-registry.js +99 -0
- package/src/commands/init.js +306 -77
- package/src/commands/install-panel-hook.js +108 -0
- package/src/commands/install-scripts.js +232 -0
- package/src/commands/install-skill.js +220 -0
- package/src/commands/panel.js +297 -0
- package/src/commands/setup-wizard.js +4 -3
- package/src/commands/test-setup.js +4 -5
- package/src/data/releases.json +164 -0
- package/src/panel/queue.js +188 -0
- package/templates/commands/ask-claude.template.md +118 -0
- package/templates/commands/ccasp-panel.template.md +72 -0
- package/templates/commands/ccasp-setup.template.md +470 -79
- package/templates/commands/create-smoke-test.template.md +186 -0
- package/templates/commands/project-impl.template.md +9 -113
- package/templates/commands/refactor-check.template.md +112 -0
- package/templates/commands/refactor-cleanup.template.md +144 -0
- package/templates/commands/refactor-prep.template.md +192 -0
- package/templates/docs/AI_ARCHITECTURE_CONSTITUTION.template.md +198 -0
- package/templates/docs/DETAILED_GOTCHAS.template.md +347 -0
- package/templates/docs/PHASE-DEV-CHECKLIST.template.md +241 -0
- package/templates/docs/PROGRESS_JSON_TEMPLATE.json +117 -0
- package/templates/docs/background-agent.template.md +264 -0
- package/templates/hooks/autonomous-decision-logger.template.js +207 -0
- package/templates/hooks/branch-merge-checker.template.js +272 -0
- package/templates/hooks/git-commit-tracker.template.js +267 -0
- package/templates/hooks/issue-completion-detector.template.js +205 -0
- package/templates/hooks/panel-queue-reader.template.js +83 -0
- package/templates/hooks/phase-validation-gates.template.js +307 -0
- package/templates/hooks/session-id-generator.template.js +236 -0
- package/templates/hooks/token-usage-monitor.template.js +193 -0
- package/templates/patterns/README.md +129 -0
- package/templates/patterns/l1-l2-orchestration.md +189 -0
- package/templates/patterns/multi-phase-orchestration.md +258 -0
- package/templates/patterns/two-tier-query-pipeline.md +192 -0
- package/templates/scripts/README.md +109 -0
- package/templates/scripts/analyze-delegation-log.js +299 -0
- package/templates/scripts/autonomous-decision-logger.js +277 -0
- package/templates/scripts/git-history-analyzer.py +269 -0
- package/templates/scripts/phase-validation-gates.js +307 -0
- package/templates/scripts/poll-deployment-status.js +260 -0
- package/templates/scripts/roadmap-scanner.js +263 -0
- package/templates/scripts/validate-deployment.js +293 -0
- package/templates/skills/agent-creator/skill.json +18 -0
- package/templates/skills/agent-creator/skill.md +335 -0
- package/templates/skills/hook-creator/skill.json +18 -0
- package/templates/skills/hook-creator/skill.md +318 -0
- package/templates/skills/panel/skill.json +18 -0
- package/templates/skills/panel/skill.md +90 -0
- package/templates/skills/rag-agent-creator/skill.json +18 -0
- package/templates/skills/rag-agent-creator/skill.md +307 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Git History Analyzer
|
|
4
|
+
|
|
5
|
+
Security audit for sensitive data in git history.
|
|
6
|
+
Scans commits for passwords, API keys, tokens, and other secrets.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
python git-history-analyzer.py
|
|
10
|
+
python git-history-analyzer.py --patterns "password|secret|api.key"
|
|
11
|
+
python git-history-analyzer.py --since "2024-01-01" --output json
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import subprocess
|
|
15
|
+
import re
|
|
16
|
+
import sys
|
|
17
|
+
import json
|
|
18
|
+
import argparse
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
# Default patterns for sensitive data
|
|
23
|
+
DEFAULT_PATTERNS = [
|
|
24
|
+
# API keys and tokens
|
|
25
|
+
r'(?i)(api[_-]?key|apikey)\s*[:=]\s*["\']?[\w-]{20,}',
|
|
26
|
+
r'(?i)(access[_-]?token|auth[_-]?token)\s*[:=]\s*["\']?[\w-]{20,}',
|
|
27
|
+
r'(?i)(secret[_-]?key|private[_-]?key)\s*[:=]\s*["\']?[\w-]{20,}',
|
|
28
|
+
|
|
29
|
+
# Passwords
|
|
30
|
+
r'(?i)password\s*[:=]\s*["\'][^"\']{4,}["\']',
|
|
31
|
+
r'(?i)passwd\s*[:=]\s*["\'][^"\']{4,}["\']',
|
|
32
|
+
|
|
33
|
+
# AWS
|
|
34
|
+
r'AKIA[0-9A-Z]{16}', # AWS Access Key
|
|
35
|
+
r'(?i)aws[_-]?secret[_-]?access[_-]?key\s*[:=]',
|
|
36
|
+
|
|
37
|
+
# GitHub
|
|
38
|
+
r'ghp_[a-zA-Z0-9]{36}', # GitHub Personal Access Token
|
|
39
|
+
r'github[_-]?token\s*[:=]',
|
|
40
|
+
|
|
41
|
+
# Generic secrets
|
|
42
|
+
r'(?i)bearer\s+[a-zA-Z0-9\-._~+/]+=*',
|
|
43
|
+
r'(?i)-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----',
|
|
44
|
+
|
|
45
|
+
# Database URLs
|
|
46
|
+
r'(?i)(postgres|mysql|mongodb|redis)://[^\s"\']+',
|
|
47
|
+
|
|
48
|
+
# Environment variables with sensitive names
|
|
49
|
+
r'(?i)(DB_PASSWORD|DATABASE_PASSWORD|MYSQL_ROOT_PASSWORD)\s*=',
|
|
50
|
+
r'(?i)(JWT_SECRET|SESSION_SECRET|ENCRYPTION_KEY)\s*=',
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class GitHistoryAnalyzer:
|
|
55
|
+
def __init__(self, patterns=None, since=None, verbose=False):
|
|
56
|
+
self.patterns = patterns or DEFAULT_PATTERNS
|
|
57
|
+
self.compiled_patterns = [re.compile(p) for p in self.patterns]
|
|
58
|
+
self.since = since
|
|
59
|
+
self.verbose = verbose
|
|
60
|
+
self.findings = []
|
|
61
|
+
|
|
62
|
+
def run(self):
|
|
63
|
+
"""Run the analysis."""
|
|
64
|
+
print("\n🔍 Git History Security Audit\n")
|
|
65
|
+
|
|
66
|
+
if not self._is_git_repo():
|
|
67
|
+
print("❌ Not a git repository")
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
print(f"Scanning {len(self.patterns)} patterns...")
|
|
71
|
+
if self.since:
|
|
72
|
+
print(f"Since: {self.since}")
|
|
73
|
+
print()
|
|
74
|
+
|
|
75
|
+
commits = self._get_commits()
|
|
76
|
+
print(f"Found {len(commits)} commits to analyze\n")
|
|
77
|
+
|
|
78
|
+
for i, commit in enumerate(commits, 1):
|
|
79
|
+
if self.verbose:
|
|
80
|
+
print(f"[{i}/{len(commits)}] {commit['hash'][:8]}", end='\r')
|
|
81
|
+
self._analyze_commit(commit)
|
|
82
|
+
|
|
83
|
+
if self.verbose:
|
|
84
|
+
print()
|
|
85
|
+
|
|
86
|
+
return self.findings
|
|
87
|
+
|
|
88
|
+
def _is_git_repo(self):
|
|
89
|
+
"""Check if current directory is a git repository."""
|
|
90
|
+
try:
|
|
91
|
+
subprocess.run(
|
|
92
|
+
['git', 'rev-parse', '--git-dir'],
|
|
93
|
+
capture_output=True,
|
|
94
|
+
check=True
|
|
95
|
+
)
|
|
96
|
+
return True
|
|
97
|
+
except subprocess.CalledProcessError:
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
def _get_commits(self):
|
|
101
|
+
"""Get list of commits to analyze."""
|
|
102
|
+
cmd = ['git', 'log', '--pretty=format:%H|%an|%ae|%ad|%s', '--date=iso']
|
|
103
|
+
|
|
104
|
+
if self.since:
|
|
105
|
+
cmd.extend(['--since', self.since])
|
|
106
|
+
|
|
107
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
108
|
+
commits = []
|
|
109
|
+
|
|
110
|
+
for line in result.stdout.strip().split('\n'):
|
|
111
|
+
if line:
|
|
112
|
+
parts = line.split('|', 4)
|
|
113
|
+
if len(parts) == 5:
|
|
114
|
+
commits.append({
|
|
115
|
+
'hash': parts[0],
|
|
116
|
+
'author': parts[1],
|
|
117
|
+
'email': parts[2],
|
|
118
|
+
'date': parts[3],
|
|
119
|
+
'message': parts[4],
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
return commits
|
|
123
|
+
|
|
124
|
+
def _analyze_commit(self, commit):
|
|
125
|
+
"""Analyze a single commit for sensitive data."""
|
|
126
|
+
# Get diff for this commit
|
|
127
|
+
cmd = ['git', 'show', '--pretty=', '--diff-filter=AM', commit['hash']]
|
|
128
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
129
|
+
|
|
130
|
+
diff = result.stdout
|
|
131
|
+
|
|
132
|
+
# Check each pattern
|
|
133
|
+
for i, pattern in enumerate(self.compiled_patterns):
|
|
134
|
+
matches = pattern.findall(diff)
|
|
135
|
+
if matches:
|
|
136
|
+
for match in matches:
|
|
137
|
+
finding = {
|
|
138
|
+
'commit': commit['hash'],
|
|
139
|
+
'author': commit['author'],
|
|
140
|
+
'date': commit['date'],
|
|
141
|
+
'message': commit['message'],
|
|
142
|
+
'pattern': self.patterns[i],
|
|
143
|
+
'match': match if isinstance(match, str) else match[0],
|
|
144
|
+
'severity': self._get_severity(self.patterns[i]),
|
|
145
|
+
}
|
|
146
|
+
self.findings.append(finding)
|
|
147
|
+
|
|
148
|
+
def _get_severity(self, pattern):
|
|
149
|
+
"""Determine severity based on pattern type."""
|
|
150
|
+
high_severity = ['password', 'private.key', 'aws', 'secret']
|
|
151
|
+
medium_severity = ['api.key', 'token', 'bearer']
|
|
152
|
+
|
|
153
|
+
pattern_lower = pattern.lower()
|
|
154
|
+
|
|
155
|
+
if any(s in pattern_lower for s in high_severity):
|
|
156
|
+
return 'HIGH'
|
|
157
|
+
elif any(s in pattern_lower for s in medium_severity):
|
|
158
|
+
return 'MEDIUM'
|
|
159
|
+
else:
|
|
160
|
+
return 'LOW'
|
|
161
|
+
|
|
162
|
+
def print_report(self):
|
|
163
|
+
"""Print human-readable report."""
|
|
164
|
+
if not self.findings:
|
|
165
|
+
print("✅ No sensitive data found in git history\n")
|
|
166
|
+
return
|
|
167
|
+
|
|
168
|
+
print(f"\n⚠️ Found {len(self.findings)} potential issues\n")
|
|
169
|
+
print("=" * 70)
|
|
170
|
+
|
|
171
|
+
# Group by severity
|
|
172
|
+
by_severity = {'HIGH': [], 'MEDIUM': [], 'LOW': []}
|
|
173
|
+
for finding in self.findings:
|
|
174
|
+
by_severity[finding['severity']].append(finding)
|
|
175
|
+
|
|
176
|
+
for severity in ['HIGH', 'MEDIUM', 'LOW']:
|
|
177
|
+
findings = by_severity[severity]
|
|
178
|
+
if findings:
|
|
179
|
+
icon = '🔴' if severity == 'HIGH' else '🟡' if severity == 'MEDIUM' else '🔵'
|
|
180
|
+
print(f"\n{icon} {severity} Severity ({len(findings)} issues)\n")
|
|
181
|
+
|
|
182
|
+
for f in findings[:10]: # Limit to 10 per severity
|
|
183
|
+
print(f" Commit: {f['commit'][:8]}")
|
|
184
|
+
print(f" Date: {f['date']}")
|
|
185
|
+
print(f" Author: {f['author']}")
|
|
186
|
+
print(f" Match: {f['match'][:50]}...")
|
|
187
|
+
print()
|
|
188
|
+
|
|
189
|
+
if len(findings) > 10:
|
|
190
|
+
print(f" ... and {len(findings) - 10} more\n")
|
|
191
|
+
|
|
192
|
+
print("=" * 70)
|
|
193
|
+
print("\n📋 Recommendations:\n")
|
|
194
|
+
|
|
195
|
+
if by_severity['HIGH']:
|
|
196
|
+
print(" 1. Immediately rotate any exposed credentials")
|
|
197
|
+
print(" 2. Consider using git-filter-repo to remove sensitive commits")
|
|
198
|
+
print(" 3. Add patterns to .gitignore and pre-commit hooks")
|
|
199
|
+
|
|
200
|
+
print(" 4. Use environment variables for secrets")
|
|
201
|
+
print(" 5. Consider using a secrets manager (Vault, AWS Secrets Manager)")
|
|
202
|
+
print()
|
|
203
|
+
|
|
204
|
+
def to_json(self):
|
|
205
|
+
"""Return findings as JSON."""
|
|
206
|
+
return json.dumps({
|
|
207
|
+
'scannedAt': datetime.now().isoformat(),
|
|
208
|
+
'totalFindings': len(self.findings),
|
|
209
|
+
'bySeverity': {
|
|
210
|
+
'HIGH': len([f for f in self.findings if f['severity'] == 'HIGH']),
|
|
211
|
+
'MEDIUM': len([f for f in self.findings if f['severity'] == 'MEDIUM']),
|
|
212
|
+
'LOW': len([f for f in self.findings if f['severity'] == 'LOW']),
|
|
213
|
+
},
|
|
214
|
+
'findings': self.findings,
|
|
215
|
+
}, indent=2)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def main():
|
|
219
|
+
parser = argparse.ArgumentParser(
|
|
220
|
+
description='Scan git history for sensitive data'
|
|
221
|
+
)
|
|
222
|
+
parser.add_argument(
|
|
223
|
+
'--patterns',
|
|
224
|
+
help='Custom regex patterns (pipe-separated)',
|
|
225
|
+
default=None
|
|
226
|
+
)
|
|
227
|
+
parser.add_argument(
|
|
228
|
+
'--since',
|
|
229
|
+
help='Only scan commits since date (e.g., "2024-01-01")',
|
|
230
|
+
default=None
|
|
231
|
+
)
|
|
232
|
+
parser.add_argument(
|
|
233
|
+
'--output',
|
|
234
|
+
choices=['text', 'json'],
|
|
235
|
+
default='text',
|
|
236
|
+
help='Output format'
|
|
237
|
+
)
|
|
238
|
+
parser.add_argument(
|
|
239
|
+
'--verbose', '-v',
|
|
240
|
+
action='store_true',
|
|
241
|
+
help='Show progress'
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
args = parser.parse_args()
|
|
245
|
+
|
|
246
|
+
patterns = None
|
|
247
|
+
if args.patterns:
|
|
248
|
+
patterns = args.patterns.split('|')
|
|
249
|
+
|
|
250
|
+
analyzer = GitHistoryAnalyzer(
|
|
251
|
+
patterns=patterns,
|
|
252
|
+
since=args.since,
|
|
253
|
+
verbose=args.verbose
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
findings = analyzer.run()
|
|
257
|
+
|
|
258
|
+
if args.output == 'json':
|
|
259
|
+
print(analyzer.to_json())
|
|
260
|
+
else:
|
|
261
|
+
analyzer.print_report()
|
|
262
|
+
|
|
263
|
+
# Exit with error code if HIGH severity findings
|
|
264
|
+
high_count = len([f for f in findings if f.get('severity') == 'HIGH'])
|
|
265
|
+
sys.exit(1 if high_count > 0 else 0)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
if __name__ == '__main__':
|
|
269
|
+
main()
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Phase Validation Gates
|
|
4
|
+
*
|
|
5
|
+
* 5-gate validation before phase transitions:
|
|
6
|
+
* 1. EXIST - Required files and artifacts exist
|
|
7
|
+
* 2. INIT - Initialization completed successfully
|
|
8
|
+
* 3. REGISTER - Components registered/configured
|
|
9
|
+
* 4. INVOKE - Functionality works when invoked
|
|
10
|
+
* 5. PROPAGATE - Changes propagated to dependent systems
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node phase-validation-gates.js --phase 1 --config ./validation.json
|
|
14
|
+
* node phase-validation-gates.js --progress ./PROGRESS.json
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { existsSync, readFileSync } from 'fs';
|
|
18
|
+
import { execSync } from 'child_process';
|
|
19
|
+
import { resolve } from 'path';
|
|
20
|
+
|
|
21
|
+
const GATES = ['EXIST', 'INIT', 'REGISTER', 'INVOKE', 'PROPAGATE'];
|
|
22
|
+
|
|
23
|
+
class PhaseValidator {
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
this.phase = options.phase;
|
|
26
|
+
this.configPath = options.configPath;
|
|
27
|
+
this.progressPath = options.progressPath || 'PROGRESS.json';
|
|
28
|
+
this.verbose = options.verbose || false;
|
|
29
|
+
this.config = null;
|
|
30
|
+
this.results = {
|
|
31
|
+
phase: this.phase,
|
|
32
|
+
gates: {},
|
|
33
|
+
passed: false,
|
|
34
|
+
timestamp: new Date().toISOString(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async validate() {
|
|
39
|
+
await this.loadConfig();
|
|
40
|
+
|
|
41
|
+
console.log(`\n🔒 Phase ${this.phase} Validation\n`);
|
|
42
|
+
console.log('Gate Status Checks');
|
|
43
|
+
console.log('-'.repeat(60));
|
|
44
|
+
|
|
45
|
+
for (const gate of GATES) {
|
|
46
|
+
const gateConfig = this.config.gates?.[gate] || {};
|
|
47
|
+
const result = await this.validateGate(gate, gateConfig);
|
|
48
|
+
this.results.gates[gate] = result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.results.passed = Object.values(this.results.gates)
|
|
52
|
+
.every(g => g.passed);
|
|
53
|
+
|
|
54
|
+
this.printSummary();
|
|
55
|
+
return this.results;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async loadConfig() {
|
|
59
|
+
if (this.configPath && existsSync(this.configPath)) {
|
|
60
|
+
this.config = JSON.parse(readFileSync(this.configPath, 'utf8'));
|
|
61
|
+
} else if (existsSync(this.progressPath)) {
|
|
62
|
+
const progress = JSON.parse(readFileSync(this.progressPath, 'utf8'));
|
|
63
|
+
this.config = progress.phases?.[this.phase - 1]?.validation || {};
|
|
64
|
+
} else {
|
|
65
|
+
this.config = this.getDefaultConfig();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getDefaultConfig() {
|
|
70
|
+
return {
|
|
71
|
+
gates: {
|
|
72
|
+
EXIST: {
|
|
73
|
+
files: ['package.json'],
|
|
74
|
+
directories: ['src/', 'node_modules/'],
|
|
75
|
+
},
|
|
76
|
+
INIT: {
|
|
77
|
+
commands: ['npm --version'],
|
|
78
|
+
},
|
|
79
|
+
REGISTER: {
|
|
80
|
+
files: ['.claude/settings.json'],
|
|
81
|
+
},
|
|
82
|
+
INVOKE: {
|
|
83
|
+
commands: ['npm run --silent test 2>/dev/null || echo "no tests"'],
|
|
84
|
+
},
|
|
85
|
+
PROPAGATE: {
|
|
86
|
+
commands: ['git status --porcelain'],
|
|
87
|
+
expectEmpty: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async validateGate(gate, config) {
|
|
94
|
+
const result = {
|
|
95
|
+
gate,
|
|
96
|
+
passed: true,
|
|
97
|
+
checks: [],
|
|
98
|
+
errors: [],
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
switch (gate) {
|
|
103
|
+
case 'EXIST':
|
|
104
|
+
await this.checkExist(config, result);
|
|
105
|
+
break;
|
|
106
|
+
case 'INIT':
|
|
107
|
+
await this.checkInit(config, result);
|
|
108
|
+
break;
|
|
109
|
+
case 'REGISTER':
|
|
110
|
+
await this.checkRegister(config, result);
|
|
111
|
+
break;
|
|
112
|
+
case 'INVOKE':
|
|
113
|
+
await this.checkInvoke(config, result);
|
|
114
|
+
break;
|
|
115
|
+
case 'PROPAGATE':
|
|
116
|
+
await this.checkPropagate(config, result);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
result.passed = false;
|
|
121
|
+
result.errors.push(error.message);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const icon = result.passed ? '✅' : '❌';
|
|
125
|
+
const checkCount = `${result.checks.filter(c => c.passed).length}/${result.checks.length}`;
|
|
126
|
+
console.log(`${gate.padEnd(12)} ${icon} ${checkCount} checks passed`);
|
|
127
|
+
|
|
128
|
+
if (this.verbose && result.errors.length > 0) {
|
|
129
|
+
for (const error of result.errors) {
|
|
130
|
+
console.log(` └─ ${error}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async checkExist(config, result) {
|
|
138
|
+
// Check files
|
|
139
|
+
for (const file of config.files || []) {
|
|
140
|
+
const exists = existsSync(resolve(process.cwd(), file));
|
|
141
|
+
result.checks.push({ type: 'file', path: file, passed: exists });
|
|
142
|
+
if (!exists) {
|
|
143
|
+
result.passed = false;
|
|
144
|
+
result.errors.push(`Missing file: ${file}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Check directories
|
|
149
|
+
for (const dir of config.directories || []) {
|
|
150
|
+
const exists = existsSync(resolve(process.cwd(), dir));
|
|
151
|
+
result.checks.push({ type: 'directory', path: dir, passed: exists });
|
|
152
|
+
if (!exists) {
|
|
153
|
+
result.passed = false;
|
|
154
|
+
result.errors.push(`Missing directory: ${dir}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async checkInit(config, result) {
|
|
160
|
+
// Run initialization check commands
|
|
161
|
+
for (const cmd of config.commands || []) {
|
|
162
|
+
try {
|
|
163
|
+
execSync(cmd, { encoding: 'utf8', stdio: 'pipe' });
|
|
164
|
+
result.checks.push({ type: 'command', command: cmd, passed: true });
|
|
165
|
+
} catch (error) {
|
|
166
|
+
result.passed = false;
|
|
167
|
+
result.checks.push({ type: 'command', command: cmd, passed: false });
|
|
168
|
+
result.errors.push(`Command failed: ${cmd}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Check environment variables
|
|
173
|
+
for (const envVar of config.envVars || []) {
|
|
174
|
+
const exists = !!process.env[envVar];
|
|
175
|
+
result.checks.push({ type: 'envVar', name: envVar, passed: exists });
|
|
176
|
+
if (!exists) {
|
|
177
|
+
result.passed = false;
|
|
178
|
+
result.errors.push(`Missing env var: ${envVar}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async checkRegister(config, result) {
|
|
184
|
+
// Check config files contain expected content
|
|
185
|
+
for (const file of config.files || []) {
|
|
186
|
+
const filePath = resolve(process.cwd(), file);
|
|
187
|
+
const exists = existsSync(filePath);
|
|
188
|
+
result.checks.push({ type: 'config', path: file, passed: exists });
|
|
189
|
+
|
|
190
|
+
if (!exists) {
|
|
191
|
+
result.passed = false;
|
|
192
|
+
result.errors.push(`Missing config: ${file}`);
|
|
193
|
+
} else if (config.contains?.[file]) {
|
|
194
|
+
const content = readFileSync(filePath, 'utf8');
|
|
195
|
+
for (const expected of config.contains[file]) {
|
|
196
|
+
const found = content.includes(expected);
|
|
197
|
+
result.checks.push({ type: 'content', file, expected, passed: found });
|
|
198
|
+
if (!found) {
|
|
199
|
+
result.passed = false;
|
|
200
|
+
result.errors.push(`Missing in ${file}: ${expected}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async checkInvoke(config, result) {
|
|
208
|
+
// Run functionality tests
|
|
209
|
+
for (const cmd of config.commands || []) {
|
|
210
|
+
try {
|
|
211
|
+
const output = execSync(cmd, { encoding: 'utf8', stdio: 'pipe' });
|
|
212
|
+
|
|
213
|
+
if (config.expectOutput?.[cmd]) {
|
|
214
|
+
const expected = config.expectOutput[cmd];
|
|
215
|
+
const matches = output.includes(expected);
|
|
216
|
+
result.checks.push({ type: 'invoke', command: cmd, passed: matches });
|
|
217
|
+
if (!matches) {
|
|
218
|
+
result.passed = false;
|
|
219
|
+
result.errors.push(`Output mismatch for: ${cmd}`);
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
result.checks.push({ type: 'invoke', command: cmd, passed: true });
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (!config.allowFailure?.includes(cmd)) {
|
|
226
|
+
result.passed = false;
|
|
227
|
+
result.checks.push({ type: 'invoke', command: cmd, passed: false });
|
|
228
|
+
result.errors.push(`Invoke failed: ${cmd}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async checkPropagate(config, result) {
|
|
235
|
+
// Check that changes are propagated (git clean, deps synced, etc.)
|
|
236
|
+
for (const cmd of config.commands || []) {
|
|
237
|
+
try {
|
|
238
|
+
const output = execSync(cmd, { encoding: 'utf8', stdio: 'pipe' });
|
|
239
|
+
|
|
240
|
+
if (config.expectEmpty) {
|
|
241
|
+
const isEmpty = output.trim() === '';
|
|
242
|
+
result.checks.push({ type: 'propagate', command: cmd, passed: isEmpty });
|
|
243
|
+
if (!isEmpty) {
|
|
244
|
+
result.passed = false;
|
|
245
|
+
result.errors.push(`Expected empty output: ${cmd}`);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
result.checks.push({ type: 'propagate', command: cmd, passed: true });
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
result.passed = false;
|
|
252
|
+
result.checks.push({ type: 'propagate', command: cmd, passed: false });
|
|
253
|
+
result.errors.push(`Propagate check failed: ${cmd}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
printSummary() {
|
|
259
|
+
console.log('\n' + '='.repeat(60));
|
|
260
|
+
console.log(`Phase ${this.phase} Validation: ${this.results.passed ? '✅ PASSED' : '❌ FAILED'}`);
|
|
261
|
+
console.log('='.repeat(60));
|
|
262
|
+
|
|
263
|
+
if (!this.results.passed) {
|
|
264
|
+
console.log('\n❌ Failed Gates:');
|
|
265
|
+
for (const [gate, result] of Object.entries(this.results.gates)) {
|
|
266
|
+
if (!result.passed) {
|
|
267
|
+
console.log(`\n ${gate}:`);
|
|
268
|
+
for (const error of result.errors) {
|
|
269
|
+
console.log(` - ${error}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
console.log('');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// CLI entry point
|
|
280
|
+
async function main() {
|
|
281
|
+
const args = process.argv.slice(2);
|
|
282
|
+
|
|
283
|
+
const getArg = (name) => {
|
|
284
|
+
const index = args.indexOf(`--${name}`);
|
|
285
|
+
return index >= 0 ? args[index + 1] : null;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const phase = parseInt(getArg('phase') || '1');
|
|
289
|
+
const configPath = getArg('config');
|
|
290
|
+
const progressPath = getArg('progress');
|
|
291
|
+
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
292
|
+
|
|
293
|
+
const validator = new PhaseValidator({
|
|
294
|
+
phase,
|
|
295
|
+
configPath,
|
|
296
|
+
progressPath,
|
|
297
|
+
verbose,
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const results = await validator.validate();
|
|
301
|
+
process.exit(results.passed ? 0 : 1);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Export for use as module
|
|
305
|
+
export { PhaseValidator, GATES };
|
|
306
|
+
|
|
307
|
+
main().catch(console.error);
|