javi-forge 1.0.0 → 1.2.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.
@@ -1,162 +1,17 @@
1
1
  #!/bin/bash
2
2
  # =============================================================================
3
- # PRE-COMMIT: Universal quick checks before commit
3
+ # PRE-COMMIT: Quick CI check via javi-forge
4
4
  # =============================================================================
5
- # Detecta el stack y ejecuta lint + compile rapido
6
- # Tiempo: ~30-60 segundos
5
+ # Requires: npm install -g javi-forge
6
+ # To skip: git commit --no-verify
7
7
  # =============================================================================
8
8
 
9
9
  set -e
10
10
 
11
- # Encontrar directorio .ci-local
12
- HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
13
- if [[ -d "$HOOK_DIR/../.ci-local" ]]; then
14
- CI_LOCAL_DIR="$HOOK_DIR/../.ci-local"
15
- elif [[ -d "$(git rev-parse --show-toplevel)/.ci-local" ]]; then
16
- CI_LOCAL_DIR="$(git rev-parse --show-toplevel)/.ci-local"
17
- else
18
- echo "Warning: .ci-local not found, skipping pre-commit checks"
19
- exit 0
20
- fi
21
-
22
- PROJECT_DIR="$(dirname "$CI_LOCAL_DIR")"
23
-
24
- # Source shared library for colors and detect_stack
25
- source "$CI_LOCAL_DIR/../lib/common.sh"
26
-
27
- echo -e "${YELLOW}[pre-commit] Running quick checks...${NC}"
28
-
29
- # =============================================================================
30
- # CHECK: No AI attribution in staged files
31
- # =============================================================================
32
- echo -e "${YELLOW}[1/3] Checking for AI attribution...${NC}"
33
-
34
- # Patrones prohibidos (case insensitive)
35
- AI_PATTERNS=(
36
- "co-authored-by:.*claude"
37
- "co-authored-by:.*anthropic"
38
- "co-authored-by:.*gpt"
39
- "co-authored-by:.*openai"
40
- "co-authored-by:.*copilot"
41
- "co-authored-by:.*gemini"
42
- "co-authored-by:.*\bai\b"
43
- "made by claude"
44
- "made by gpt"
45
- "made by ai"
46
- "generated by claude"
47
- "generated by gpt"
48
- "generated by ai"
49
- "generated with claude"
50
- "generated with ai"
51
- "written by claude"
52
- "written by ai"
53
- "created by claude"
54
- "created by ai"
55
- "assisted by claude"
56
- "assisted by ai"
57
- "with help from claude"
58
- "claude code"
59
- "made by anthropic"
60
- "powered by anthropic"
61
- "created by anthropic"
62
- "made by openai"
63
- "powered by openai"
64
- "created by openai"
65
- "@anthropic.com"
66
- "@openai.com"
67
- )
68
-
69
- # Check actual staged content using git show :0:file
70
- STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -vE '\.(png|jpg|jpeg|gif|ico|woff|ttf|eot|svg|lock)$' || true)
71
-
72
- if [[ -n "$STAGED_FILES" ]]; then
73
- for pattern in "${AI_PATTERNS[@]}"; do
74
- while IFS= read -r file; do
75
- [[ -z "$file" ]] && continue
76
- if git show ":0:$file" 2>/dev/null | grep -iqE "$pattern"; then
77
- echo -e "${RED}[BLOCKED] AI attribution found in staged content: $file${NC}"
78
- echo -e "${RED} Pattern matched: $pattern${NC}"
79
- git show ":0:$file" | grep -inE "$pattern" | head -3 | while IFS= read -r line; do
80
- echo -e "${RED} $line${NC}"
81
- done
82
- echo ""
83
- echo -e "${YELLOW}Remove AI attribution before committing.${NC}"
84
- exit 1
85
- fi
86
- done <<< "$STAGED_FILES"
87
- done
88
- echo -e "${GREEN} No AI attribution found${NC}"
89
- fi
90
-
91
- # Semgrep security scan - native or Docker fallback
92
- SEMGREP_CMD=""
93
- SEMGREP_MODE=""
94
- if command -v semgrep &> /dev/null; then
95
- SEMGREP_CMD="native"
96
- SEMGREP_MODE="native"
97
- elif command -v docker &> /dev/null && docker info &> /dev/null 2>&1; then
98
- SEMGREP_CMD="docker"
99
- SEMGREP_MODE="Docker"
100
- fi
101
-
102
- if [[ -n "$SEMGREP_CMD" ]]; then
103
- echo -e "${YELLOW}[2/3] Security scan (Semgrep via $SEMGREP_MODE)...${NC}"
104
- STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(java|kt|js|ts|py|go|rs)$' || true)
105
- if [[ -n "$STAGED_FILES" ]]; then
106
- if [[ "$SEMGREP_CMD" == "native" ]]; then
107
- echo "$STAGED_FILES" | tr '\n' '\0' | xargs -0 semgrep --config=.ci-local/semgrep.yml --severity=ERROR --quiet 2>/dev/null || {
108
- echo -e "${RED}Semgrep found issues${NC}"
109
- exit 1
110
- }
111
- else
112
- # Pipe file list via stdin into the container where xargs feeds it to semgrep
113
- echo "$STAGED_FILES" | docker run --rm -i -v "${PROJECT_DIR}:/src" -w /src returntocorp/semgrep \
114
- sh -c 'xargs semgrep --config=/src/.ci-local/semgrep.yml --severity=ERROR --quiet' 2>/dev/null || {
115
- echo -e "${RED}Semgrep found issues${NC}"
116
- exit 1
117
- }
118
- fi
119
- echo -e "${GREEN}Security OK${NC}"
120
- else
121
- echo -e "${GREEN}No files to scan${NC}"
122
- fi
123
- else
124
- echo -e "${YELLOW}[2/3] Semgrep not available, skipping (install semgrep or use Docker)${NC}"
125
- fi
126
-
127
- # Quick compile/lint basado en el stack
128
- echo -e "${YELLOW}[3/3] Quick compile check...${NC}"
129
- cd "$PROJECT_DIR"
130
-
131
- # Use shared stack detection from lib/common.sh
132
- detect_stack
133
-
134
- case "$STACK_TYPE" in
135
- java-gradle)
136
- ./gradlew spotlessCheck classes --no-daemon -q 2>/dev/null || {
137
- echo -e "${RED}Gradle check failed. Run: ./gradlew spotlessApply${NC}"
138
- exit 1
139
- }
140
- ;;
141
- java-maven)
142
- ./mvnw compile -q 2>/dev/null || exit 1
143
- ;;
144
- node)
145
- if [[ "$BUILD_TOOL" == "pnpm" ]]; then
146
- pnpm lint --silent 2>/dev/null || exit 1
147
- elif [[ "$BUILD_TOOL" == "yarn" ]]; then
148
- yarn lint --silent 2>/dev/null || exit 1
149
- else
150
- npm run lint --silent 2>/dev/null || exit 1
151
- fi
152
- ;;
153
- rust)
154
- cargo check --quiet 2>/dev/null || exit 1
155
- ;;
156
- go)
157
- go build ./... 2>/dev/null || exit 1
158
- ;;
159
- esac
160
-
161
- echo -e "${GREEN}Compile OK${NC}"
162
- echo -e "${GREEN}[pre-commit] All checks passed!${NC}"
11
+ echo "PRE-COMMIT: Running quick check..."
12
+ javi-forge ci --quick --no-security --no-ghagga || {
13
+ echo ""
14
+ echo "Quick check FAILED — Fix the issues above before committing."
15
+ echo "To skip: git commit --no-verify"
16
+ exit 1
17
+ }
@@ -1,41 +1,24 @@
1
1
  #!/bin/bash
2
2
  # =============================================================================
3
- # PRE-PUSH: Full CI simulation before push
3
+ # PRE-PUSH: Full CI simulation via javi-forge
4
4
  # =============================================================================
5
- # Corre tests en Docker identico al CI
6
- # Si pasa aca -> pasa en GitHub Actions / GitLab CI
5
+ # Requires: npm install -g javi-forge
6
+ # To skip: git push --no-verify
7
7
  # =============================================================================
8
8
 
9
9
  set -e
10
10
 
11
- # Encontrar directorio .ci-local
12
- if [[ -d "$(git rev-parse --show-toplevel)/.ci-local" ]]; then
13
- CI_LOCAL_DIR="$(git rev-parse --show-toplevel)/.ci-local"
14
- else
15
- echo "Warning: .ci-local not found, skipping pre-push CI simulation"
16
- exit 0
17
- fi
18
-
19
- # Source shared library for colors
20
- source "$CI_LOCAL_DIR/../lib/common.sh"
21
-
22
- echo -e "${BLUE}PRE-PUSH: CI Simulation${NC}"
23
-
24
- # Verificar Docker
25
- if ! docker info &> /dev/null; then
26
- echo -e "${RED}Docker is not running.${NC}"
27
- echo -e "${YELLOW} Start Docker or use: git push --no-verify${NC}"
11
+ # Verify Docker is running
12
+ if ! docker info &>/dev/null; then
13
+ echo "PRE-PUSH: Docker is not running."
14
+ echo " Start Docker or use: git push --no-verify"
28
15
  exit 1
29
16
  fi
30
17
 
31
- # Ejecutar CI local
32
- "$CI_LOCAL_DIR/ci-local.sh" full || {
33
- echo -e ""
34
- echo -e "${RED}CI SIMULATION FAILED - Push aborted${NC}"
35
- echo -e "${RED}Fix the issues above before pushing.${NC}"
36
- echo -e "${RED}To skip: git push --no-verify${NC}"
18
+ echo "PRE-PUSH: Running CI simulation..."
19
+ javi-forge ci || {
20
+ echo ""
21
+ echo "CI FAILED Push aborted. Fix the issues above before pushing."
22
+ echo "To skip: git push --no-verify"
37
23
  exit 1
38
24
  }
39
-
40
- echo -e ""
41
- echo -e "${GREEN}CI Simulation PASSED - Safe to push!${NC}"
File without changes
@@ -0,0 +1,33 @@
1
+ import type { Stack } from '../types/index.js';
2
+ export type CIMode = 'full' | 'quick' | 'shell' | 'detect';
3
+ export interface CIOptions {
4
+ projectDir?: string;
5
+ mode?: CIMode;
6
+ /** Skip Docker entirely — run commands natively */
7
+ noDocker?: boolean;
8
+ /** Skip GHAGGA review step */
9
+ noGhagga?: boolean;
10
+ /** Skip Semgrep security scan */
11
+ noSecurity?: boolean;
12
+ /** Timeout in seconds for each Docker step (default: 600) */
13
+ timeout?: number;
14
+ }
15
+ export type CIStepStatus = 'pending' | 'running' | 'done' | 'error' | 'skipped';
16
+ export interface CIStep {
17
+ id: string;
18
+ label: string;
19
+ status: CIStepStatus;
20
+ detail?: string;
21
+ }
22
+ export type CIStepCallback = (step: CIStep) => void;
23
+ export interface CIStackInfo {
24
+ stackType: Stack;
25
+ buildTool: string;
26
+ javaVersion: string;
27
+ lintCmd: string | null;
28
+ compileCmd: string | null;
29
+ testCmd: string | null;
30
+ }
31
+ export declare function detectCIStack(projectDir: string): Promise<CIStackInfo>;
32
+ export declare function runCI(options: CIOptions, onStep: CIStepCallback): Promise<void>;
33
+ //# sourceMappingURL=ci.d.ts.map
@@ -0,0 +1,341 @@
1
+ import { execFile, spawn } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import { isDockerAvailable, ensureImage, runInContainer, openShell } from '../lib/docker.js';
6
+ const execFileAsync = promisify(execFile);
7
+ // =============================================================================
8
+ // Stack detection
9
+ // =============================================================================
10
+ export async function detectCIStack(projectDir) {
11
+ let stackType = 'node';
12
+ let buildTool = 'npm';
13
+ let javaVersion = '21';
14
+ // Java Gradle
15
+ if (await fs.pathExists(path.join(projectDir, 'build.gradle.kts')) ||
16
+ await fs.pathExists(path.join(projectDir, 'build.gradle'))) {
17
+ stackType = 'java-gradle';
18
+ buildTool = 'gradle';
19
+ // Try to read java version from build files
20
+ const ktsPath = path.join(projectDir, 'build.gradle.kts');
21
+ const gradlePath = path.join(projectDir, 'build.gradle');
22
+ if (await fs.pathExists(ktsPath)) {
23
+ const content = await fs.readFile(ktsPath, 'utf-8');
24
+ const match = content.match(/JavaLanguageVersion\.of\((\d+)\)/);
25
+ if (match?.[1])
26
+ javaVersion = match[1];
27
+ }
28
+ else if (await fs.pathExists(gradlePath)) {
29
+ const content = await fs.readFile(gradlePath, 'utf-8');
30
+ const match = content.match(/sourceCompatibility\s*=\s*['"]*(\d+)/);
31
+ if (match?.[1])
32
+ javaVersion = match[1];
33
+ }
34
+ }
35
+ // Java Maven
36
+ else if (await fs.pathExists(path.join(projectDir, 'pom.xml'))) {
37
+ stackType = 'java-maven';
38
+ buildTool = 'mvn';
39
+ }
40
+ // Node
41
+ else if (await fs.pathExists(path.join(projectDir, 'package.json'))) {
42
+ stackType = 'node';
43
+ if (await fs.pathExists(path.join(projectDir, 'pnpm-lock.yaml')))
44
+ buildTool = 'pnpm';
45
+ else if (await fs.pathExists(path.join(projectDir, 'yarn.lock')))
46
+ buildTool = 'yarn';
47
+ else
48
+ buildTool = 'npm';
49
+ }
50
+ // Go
51
+ else if (await fs.pathExists(path.join(projectDir, 'go.mod'))) {
52
+ stackType = 'go';
53
+ buildTool = 'go';
54
+ }
55
+ // Rust
56
+ else if (await fs.pathExists(path.join(projectDir, 'Cargo.toml'))) {
57
+ stackType = 'rust';
58
+ buildTool = 'cargo';
59
+ }
60
+ // Python
61
+ else if (await fs.pathExists(path.join(projectDir, 'pyproject.toml')) ||
62
+ await fs.pathExists(path.join(projectDir, 'requirements.txt')) ||
63
+ await fs.pathExists(path.join(projectDir, 'setup.py'))) {
64
+ stackType = 'python';
65
+ if (await fs.pathExists(path.join(projectDir, 'uv.lock')))
66
+ buildTool = 'uv';
67
+ else if (await fs.pathExists(path.join(projectDir, 'poetry.lock')))
68
+ buildTool = 'poetry';
69
+ else
70
+ buildTool = 'pip';
71
+ }
72
+ // Build CI commands per stack
73
+ const { lintCmd, compileCmd, testCmd } = await buildCICommands(stackType, buildTool, projectDir);
74
+ return { stackType, buildTool, javaVersion, lintCmd, compileCmd, testCmd };
75
+ }
76
+ async function buildCICommands(stack, buildTool, projectDir) {
77
+ switch (stack) {
78
+ case 'java-gradle':
79
+ return {
80
+ lintCmd: './gradlew spotlessCheck --no-daemon',
81
+ compileCmd: './gradlew classes testClasses --no-daemon',
82
+ testCmd: './gradlew test --no-daemon',
83
+ };
84
+ case 'java-maven':
85
+ return {
86
+ lintCmd: './mvnw spotless:check',
87
+ compileCmd: './mvnw compile test-compile',
88
+ testCmd: './mvnw test',
89
+ };
90
+ case 'node': {
91
+ const pkgPath = path.join(projectDir, 'package.json');
92
+ let pkgContent = '';
93
+ try {
94
+ pkgContent = await fs.readFile(pkgPath, 'utf-8');
95
+ }
96
+ catch { /* no package.json */ }
97
+ // Clean dist/ before build to avoid permission issues from prior Docker builds
98
+ const buildPrefix = 'rm -rf dist/ && ';
99
+ return {
100
+ lintCmd: pkgContent.includes('"lint"') ? `${buildTool} run lint` : null,
101
+ compileCmd: pkgContent.includes('"build"') ? `${buildPrefix}${buildTool} run build` : null,
102
+ testCmd: pkgContent.includes('"test"') ? `${buildTool} ${buildTool === 'npm' ? 'test' : 'run test'}` : null,
103
+ };
104
+ }
105
+ case 'python':
106
+ return {
107
+ lintCmd: 'ruff check . && { pylint **/*.py 2>/dev/null || true; }',
108
+ compileCmd: null,
109
+ testCmd: 'pytest',
110
+ };
111
+ case 'go':
112
+ return {
113
+ lintCmd: 'golangci-lint run',
114
+ compileCmd: 'go build ./...',
115
+ testCmd: 'go test ./...',
116
+ };
117
+ case 'rust':
118
+ return {
119
+ lintCmd: 'cargo clippy -- -D warnings',
120
+ compileCmd: 'cargo build',
121
+ testCmd: 'cargo test',
122
+ };
123
+ default:
124
+ return { lintCmd: null, compileCmd: null, testCmd: null };
125
+ }
126
+ }
127
+ // =============================================================================
128
+ // GHAGGA check
129
+ // =============================================================================
130
+ async function isGhaggaAvailable() {
131
+ try {
132
+ await execFileAsync('ghagga', ['--version'], { timeout: 3000 });
133
+ return true;
134
+ }
135
+ catch {
136
+ return false;
137
+ }
138
+ }
139
+ // =============================================================================
140
+ // Main CI runner
141
+ // =============================================================================
142
+ function report(onStep, id, label, status, detail) {
143
+ onStep({ id, label, status, detail });
144
+ }
145
+ export async function runCI(options, onStep) {
146
+ const { projectDir = process.cwd(), mode = 'full', noDocker = false, noGhagga = false, noSecurity = false, timeout = 600, } = options;
147
+ // ── Detect stack ────────────────────────────────────────────────────────────
148
+ const stepDetect = 'detect';
149
+ report(onStep, stepDetect, 'Detecting stack', 'running');
150
+ let stackInfo;
151
+ try {
152
+ stackInfo = await detectCIStack(projectDir);
153
+ report(onStep, stepDetect, `Stack: ${stackInfo.stackType} (${stackInfo.buildTool})`, 'done');
154
+ }
155
+ catch (e) {
156
+ report(onStep, stepDetect, 'Detecting stack', 'error', String(e));
157
+ throw e;
158
+ }
159
+ // ── Detect mode ─────────────────────────────────────────────────────────────
160
+ if (mode === 'detect')
161
+ return;
162
+ // ── Shell mode ──────────────────────────────────────────────────────────────
163
+ if (mode === 'shell') {
164
+ if (noDocker) {
165
+ report(onStep, 'shell', 'Shell', 'error', '--shell requires Docker');
166
+ throw new Error('--shell requires Docker');
167
+ }
168
+ report(onStep, 'docker-image', 'Building Docker image', 'running');
169
+ try {
170
+ await ensureImage({ stack: stackInfo.stackType, javaVersion: stackInfo.javaVersion });
171
+ report(onStep, 'docker-image', 'Docker image ready', 'done');
172
+ }
173
+ catch (e) {
174
+ report(onStep, 'docker-image', 'Building Docker image', 'error', String(e));
175
+ throw e;
176
+ }
177
+ await openShell(projectDir);
178
+ return;
179
+ }
180
+ // ── Check Docker ─────────────────────────────────────────────────────────────
181
+ if (!noDocker) {
182
+ const stepDocker = 'docker-check';
183
+ report(onStep, stepDocker, 'Checking Docker', 'running');
184
+ const dockerOk = await isDockerAvailable();
185
+ if (!dockerOk) {
186
+ report(onStep, stepDocker, 'Docker not available', 'error', 'Start Docker or use --no-docker');
187
+ throw new Error('Docker is not available');
188
+ }
189
+ report(onStep, stepDocker, 'Docker available', 'done');
190
+ // Build image
191
+ const stepImage = 'docker-image';
192
+ report(onStep, stepImage, `Building image for ${stackInfo.stackType}`, 'running');
193
+ try {
194
+ await ensureImage({ stack: stackInfo.stackType, javaVersion: stackInfo.javaVersion });
195
+ report(onStep, stepImage, 'Docker image ready', 'done');
196
+ }
197
+ catch (e) {
198
+ report(onStep, stepImage, 'Building Docker image', 'error', String(e));
199
+ throw e;
200
+ }
201
+ }
202
+ // ── Lint ─────────────────────────────────────────────────────────────────────
203
+ if (stackInfo.lintCmd) {
204
+ const stepLint = 'lint';
205
+ report(onStep, stepLint, `Lint: ${stackInfo.lintCmd}`, 'running');
206
+ try {
207
+ await runStep(stackInfo.lintCmd, projectDir, noDocker, timeout);
208
+ report(onStep, stepLint, 'Lint passed', 'done');
209
+ }
210
+ catch (e) {
211
+ report(onStep, stepLint, 'Lint failed', 'error', String(e));
212
+ throw e;
213
+ }
214
+ }
215
+ // ── Compile ──────────────────────────────────────────────────────────────────
216
+ if (stackInfo.compileCmd) {
217
+ const stepCompile = 'compile';
218
+ report(onStep, stepCompile, `Compile: ${stackInfo.compileCmd}`, 'running');
219
+ try {
220
+ await runStep(stackInfo.compileCmd, projectDir, noDocker, timeout);
221
+ report(onStep, stepCompile, 'Compile passed', 'done');
222
+ }
223
+ catch (e) {
224
+ report(onStep, stepCompile, 'Compile failed', 'error', String(e));
225
+ throw e;
226
+ }
227
+ }
228
+ // ── Test (full mode only) ────────────────────────────────────────────────────
229
+ if (mode === 'full' && stackInfo.testCmd) {
230
+ const stepTest = 'test';
231
+ report(onStep, stepTest, `Test: ${stackInfo.testCmd}`, 'running');
232
+ try {
233
+ await runStep(stackInfo.testCmd, projectDir, noDocker, timeout);
234
+ report(onStep, stepTest, 'Tests passed', 'done');
235
+ }
236
+ catch (e) {
237
+ report(onStep, stepTest, 'Tests failed', 'error', String(e));
238
+ throw e;
239
+ }
240
+ }
241
+ // ── Security scan (full mode only) ──────────────────────────────────────────
242
+ if (mode === 'full' && !noSecurity) {
243
+ const stepSecurity = 'security';
244
+ const semgrepAvailable = await isSemgrepAvailable();
245
+ if (semgrepAvailable) {
246
+ report(onStep, stepSecurity, 'Security scan (Semgrep)', 'running');
247
+ try {
248
+ await runSemgrep(projectDir);
249
+ report(onStep, stepSecurity, 'Security scan passed', 'done');
250
+ }
251
+ catch (e) {
252
+ report(onStep, stepSecurity, 'Security scan failed', 'error', String(e));
253
+ throw e;
254
+ }
255
+ }
256
+ else {
257
+ report(onStep, stepSecurity, 'Security scan', 'skipped', 'Semgrep not available — install semgrep or Docker');
258
+ }
259
+ }
260
+ // ── GHAGGA review (full mode only) ──────────────────────────────────────────
261
+ if (mode === 'full' && !noGhagga) {
262
+ const stepGhagga = 'ghagga';
263
+ const ghagga = await isGhaggaAvailable();
264
+ if (ghagga) {
265
+ report(onStep, stepGhagga, 'GHAGGA review', 'running');
266
+ try {
267
+ await runGhagga(projectDir);
268
+ report(onStep, stepGhagga, 'GHAGGA review passed', 'done');
269
+ }
270
+ catch (e) {
271
+ report(onStep, stepGhagga, 'GHAGGA review failed', 'error', String(e));
272
+ throw e;
273
+ }
274
+ }
275
+ else {
276
+ report(onStep, stepGhagga, 'GHAGGA review', 'skipped', 'ghagga not installed');
277
+ }
278
+ }
279
+ }
280
+ // =============================================================================
281
+ // Step runners
282
+ // =============================================================================
283
+ async function runStep(command, projectDir, noDocker, timeout) {
284
+ if (noDocker) {
285
+ // Run natively
286
+ await new Promise((resolve, reject) => {
287
+ const proc = spawn('bash', ['-c', command], {
288
+ cwd: projectDir,
289
+ stdio: 'inherit',
290
+ env: { ...process.env, CI: 'true' },
291
+ });
292
+ proc.on('close', code => code === 0 ? resolve() : reject(new Error(`Command failed with code ${code}`)));
293
+ proc.on('error', reject);
294
+ });
295
+ }
296
+ else {
297
+ const result = await runInContainer({
298
+ projectDir,
299
+ command: `cd /home/runner/work && ${command}`,
300
+ timeout,
301
+ stream: true,
302
+ });
303
+ if (result.exitCode !== 0) {
304
+ throw new Error(`Command failed with exit code ${result.exitCode}`);
305
+ }
306
+ }
307
+ }
308
+ async function isSemgrepAvailable() {
309
+ try {
310
+ await execFileAsync('semgrep', ['--version'], { timeout: 3000 });
311
+ return true;
312
+ }
313
+ catch {
314
+ return false;
315
+ }
316
+ }
317
+ async function runSemgrep(projectDir) {
318
+ // Look for semgrep config in project or use auto
319
+ const semgrepConfig = await fs.pathExists(path.join(projectDir, '.semgrep.yml'))
320
+ ? path.join(projectDir, '.semgrep.yml')
321
+ : 'auto';
322
+ await new Promise((resolve, reject) => {
323
+ const proc = spawn('semgrep', ['--config', semgrepConfig, '--severity', 'ERROR', '--quiet', '.'], {
324
+ cwd: projectDir,
325
+ stdio: 'inherit',
326
+ });
327
+ proc.on('close', code => code === 0 ? resolve() : reject(new Error(`Semgrep found issues (exit ${code})`)));
328
+ proc.on('error', reject);
329
+ });
330
+ }
331
+ async function runGhagga(projectDir) {
332
+ await new Promise((resolve, reject) => {
333
+ const proc = spawn('ghagga', ['review', '--plain', '--exit-on-issues'], {
334
+ cwd: projectDir,
335
+ stdio: 'inherit',
336
+ });
337
+ proc.on('close', code => code === 0 ? resolve() : reject(new Error(`GHAGGA review found issues (exit ${code})`)));
338
+ proc.on('error', reject);
339
+ });
340
+ }
341
+ //# sourceMappingURL=ci.js.map
@@ -49,6 +49,11 @@ export async function initProject(options, onStep) {
49
49
  // Set core.hooksPath to ci-local/hooks
50
50
  const hooksDir = path.join(ciLocalDest, 'hooks');
51
51
  if (await fs.pathExists(hooksDir)) {
52
+ // Ensure hooks are executable
53
+ const hookFiles = await fs.readdir(hooksDir);
54
+ for (const hook of hookFiles) {
55
+ await fs.chmod(path.join(hooksDir, hook), 0o755);
56
+ }
52
57
  await execFileAsync('git', ['config', 'core.hooksPath', 'ci-local/hooks'], { cwd: projectDir });
53
58
  }
54
59
  }