@wooojin/forgen 0.6.8 → 0.6.10
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +27 -0
- package/README.ja.md +15 -10
- package/README.ko.md +15 -10
- package/README.md +19 -14
- package/README.zh.md +13 -8
- package/dist/checks/dangerous-response-pattern.d.ts +2 -1
- package/dist/checks/dangerous-response-pattern.js +27 -3
- package/dist/cli.js +133 -17
- package/dist/core/auto-compound-runner.js +502 -397
- package/dist/core/block-cli.js +7 -3
- package/dist/core/compound-consent.d.ts +18 -0
- package/dist/core/compound-consent.js +101 -6
- package/dist/core/compound-sweep-cli.d.ts +16 -0
- package/dist/core/compound-sweep-cli.js +67 -5
- package/dist/core/config-hooks.js +28 -10
- package/dist/core/correction-signals.d.ts +9 -0
- package/dist/core/correction-signals.js +37 -0
- package/dist/core/dev-cli.d.ts +1 -2
- package/dist/core/dev-cli.js +9 -28
- package/dist/core/doctor-verify.d.ts +35 -0
- package/dist/core/doctor-verify.js +502 -0
- package/dist/core/doctor.d.ts +4 -6
- package/dist/core/doctor.js +103 -184
- package/dist/core/explain-cli.js +8 -0
- package/dist/core/extraction-haiku.d.ts +64 -0
- package/dist/core/extraction-haiku.js +208 -0
- package/dist/core/extraction-queue.d.ts +68 -0
- package/dist/core/extraction-queue.js +300 -0
- package/dist/core/flow-status.d.ts +93 -0
- package/dist/core/flow-status.js +368 -0
- package/dist/core/harness.js +14 -42
- package/dist/core/inspect-cli.js +37 -13
- package/dist/core/lifecycle-classifier.d.ts +5 -1
- package/dist/core/lifecycle-classifier.js +13 -2
- package/dist/core/migrate-cli.d.ts +1 -1
- package/dist/core/migrate-cli.js +11 -11
- package/dist/core/migrate-tenetx.d.ts +1 -1
- package/dist/core/migrate-tenetx.js +2 -2
- package/dist/core/node-engine.d.ts +3 -0
- package/dist/core/node-engine.js +8 -0
- package/dist/core/observability-store.d.ts +15 -0
- package/dist/core/observability-store.js +73 -0
- package/dist/core/paths.d.ts +2 -0
- package/dist/core/paths.js +2 -0
- package/dist/core/rendered-rules-manifest.d.ts +7 -1
- package/dist/core/rendered-rules-manifest.js +45 -1
- package/dist/core/session-store.d.ts +13 -11
- package/dist/core/session-store.js +103 -119
- package/dist/core/settings-injector.d.ts +5 -2
- package/dist/core/settings-injector.js +21 -88
- package/dist/core/spawn.d.ts +9 -1
- package/dist/core/spawn.js +33 -33
- package/dist/core/stats-cli.d.ts +7 -0
- package/dist/core/stats-cli.js +66 -93
- package/dist/core/status-cli.d.ts +1 -1
- package/dist/core/status-cli.js +23 -4
- package/dist/core/statusline-cli.js +5 -0
- package/dist/core/statusline-install.d.ts +10 -2
- package/dist/core/statusline-install.js +27 -4
- package/dist/core/transcript-summary.d.ts +84 -9
- package/dist/core/transcript-summary.js +283 -49
- package/dist/core/uninstall.d.ts +4 -0
- package/dist/core/uninstall.js +68 -36
- package/dist/core/v1-bootstrap.d.ts +1 -1
- package/dist/core/v1-bootstrap.js +38 -9
- package/dist/engine/acted-on-evidence.d.ts +8 -0
- package/dist/engine/acted-on-evidence.js +38 -0
- package/dist/engine/block-judge.d.ts +3 -1
- package/dist/engine/block-judge.js +4 -3
- package/dist/engine/compound-cli.d.ts +26 -2
- package/dist/engine/compound-cli.js +143 -19
- package/dist/engine/compound-lifecycle.d.ts +36 -2
- package/dist/engine/compound-lifecycle.js +131 -11
- package/dist/engine/compound-loop.d.ts +4 -0
- package/dist/engine/compound-loop.js +93 -18
- package/dist/engine/correction-cluster-runner.d.ts +11 -1
- package/dist/engine/correction-cluster-runner.js +39 -15
- package/dist/engine/correction-clustering.d.ts +11 -0
- package/dist/engine/correction-clustering.js +20 -3
- package/dist/engine/lifecycle/lifecycle-cli.js +10 -3
- package/dist/engine/lifecycle/meta-reclassifier.d.ts +9 -0
- package/dist/engine/lifecycle/meta-reclassifier.js +15 -3
- package/dist/engine/lifecycle/orchestrator.js +3 -2
- package/dist/engine/lifecycle/signals.d.ts +19 -1
- package/dist/engine/lifecycle/signals.js +61 -2
- package/dist/engine/lifecycle/trigger-t1-correction.d.ts +1 -1
- package/dist/engine/lifecycle/trigger-t1-correction.js +9 -28
- package/dist/engine/lifecycle/trigger-t5-conflict.d.ts +8 -0
- package/dist/engine/lifecycle/trigger-t5-conflict.js +60 -2
- package/dist/engine/roi-demotion.d.ts +11 -0
- package/dist/engine/roi-demotion.js +50 -8
- package/dist/engine/rule-detectability.d.ts +39 -0
- package/dist/engine/rule-detectability.js +66 -0
- package/dist/engine/rule-project-cli.d.ts +25 -0
- package/dist/engine/rule-project-cli.js +148 -0
- package/dist/engine/rule-recovery-cli.d.ts +21 -0
- package/dist/engine/rule-recovery-cli.js +265 -0
- package/dist/engine/rule-toggle-cli.d.ts +14 -2
- package/dist/engine/rule-toggle-cli.js +94 -6
- package/dist/engine/skill-promoter.d.ts +14 -8
- package/dist/engine/skill-promoter.js +57 -85
- package/dist/engine/solution-format.d.ts +26 -1
- package/dist/engine/solution-format.js +65 -3
- package/dist/engine/solution-habit.d.ts +1 -0
- package/dist/engine/solution-habit.js +22 -0
- package/dist/engine/solution-index.d.ts +5 -0
- package/dist/engine/solution-index.js +32 -0
- package/dist/engine/solution-matcher-eval.js +4 -4
- package/dist/engine/solution-matcher.js +15 -13
- package/dist/engine/solution-scope.d.ts +11 -0
- package/dist/engine/solution-scope.js +19 -0
- package/dist/engine/solution-writer.d.ts +3 -1
- package/dist/engine/solution-writer.js +3 -2
- package/dist/engine/term-normalizer.js +49 -0
- package/dist/fgx.js +1 -1
- package/dist/forge/cli.js +51 -8
- package/dist/forge/evidence-processor.js +6 -0
- package/dist/hooks/context-guard.d.ts +0 -22
- package/dist/hooks/context-guard.js +22 -55
- package/dist/hooks/context-usage.d.ts +21 -0
- package/dist/hooks/context-usage.js +103 -0
- package/dist/hooks/dangerous-patterns.json +1 -16
- package/dist/hooks/db-guard.d.ts +1 -1
- package/dist/hooks/db-guard.js +21 -30
- package/dist/hooks/hook-config.d.ts +2 -0
- package/dist/hooks/hook-config.js +5 -1
- package/dist/hooks/hooks-generator.d.ts +4 -0
- package/dist/hooks/hooks-generator.js +10 -4
- package/dist/hooks/permission-handler.js +23 -3
- package/dist/hooks/post-tool-use.js +14 -10
- package/dist/hooks/pre-tool-use.d.ts +17 -3
- package/dist/hooks/pre-tool-use.js +145 -30
- package/dist/hooks/rate-limiter.js +12 -7
- package/dist/hooks/secret-filter.js +15 -4
- package/dist/hooks/session-end.d.ts +2 -2
- package/dist/hooks/session-end.js +13 -7
- package/dist/hooks/session-recovery.js +79 -50
- package/dist/hooks/shared/command-analyzer.d.ts +45 -0
- package/dist/hooks/shared/command-analyzer.js +972 -0
- package/dist/hooks/shared/command-parser.d.ts +5 -29
- package/dist/hooks/shared/command-parser.js +65 -35
- package/dist/hooks/shared/commit-guard.d.ts +15 -0
- package/dist/hooks/shared/commit-guard.js +177 -0
- package/dist/hooks/shared/hook-response.d.ts +12 -2
- package/dist/hooks/shared/hook-response.js +19 -3
- package/dist/hooks/shared/hook-timing.js +9 -3
- package/dist/hooks/shared/injection-caps.d.ts +32 -2
- package/dist/hooks/shared/injection-caps.js +73 -2
- package/dist/hooks/shared/is-main.d.ts +8 -0
- package/dist/hooks/shared/is-main.js +20 -0
- package/dist/hooks/shared/tool-response.d.ts +6 -0
- package/dist/hooks/shared/tool-response.js +30 -0
- package/dist/hooks/slop-detector.js +6 -3
- package/dist/hooks/solution-injector.d.ts +23 -0
- package/dist/hooks/solution-injector.js +102 -101
- package/dist/hooks/stop-guard.d.ts +11 -1
- package/dist/hooks/stop-guard.js +28 -11
- package/dist/hooks/subagent-stop-guard.js +2 -1
- package/dist/hooks/subagent-tracker.js +2 -1
- package/dist/host/capabilities-codex.js +1 -0
- package/dist/host/claude-shim.d.ts +24 -0
- package/dist/host/claude-shim.js +68 -0
- package/dist/host/codex-hook-shim.d.ts +3 -1
- package/dist/host/codex-hook-shim.js +7 -5
- package/dist/host/codex-notify.js +1 -1
- package/dist/host/codex-rules-context.d.ts +6 -4
- package/dist/host/codex-rules-context.js +11 -24
- package/dist/host/exec-host.d.ts +5 -1
- package/dist/host/exec-host.js +15 -4
- package/dist/host/install-claude.d.ts +47 -14
- package/dist/host/install-claude.js +302 -155
- package/dist/host/install-codex.d.ts +20 -0
- package/dist/host/install-codex.js +32 -1
- package/dist/host/install-opencode.d.ts +3 -1
- package/dist/host/install-opencode.js +6 -3
- package/dist/host/install-orchestrator.js +14 -1
- package/dist/host/opencode/translate.d.ts +1 -1
- package/dist/host/opencode/translate.js +5 -3
- package/dist/host/projection.d.ts +9 -1
- package/dist/host/projection.js +19 -2
- package/dist/mcp/server.js +5 -0
- package/dist/mcp/solution-reader.d.ts +5 -5
- package/dist/mcp/solution-reader.js +13 -35
- package/dist/mcp/tools.js +18 -1
- package/dist/renderer/inspect-renderer.js +4 -2
- package/dist/renderer/render-report.d.ts +22 -0
- package/dist/renderer/render-report.js +29 -0
- package/dist/renderer/rule-renderer.d.ts +28 -2
- package/dist/renderer/rule-renderer.js +91 -76
- package/dist/store/evidence-store.js +34 -6
- package/dist/store/rule-lifecycle.d.ts +3 -1
- package/dist/store/rule-lifecycle.js +10 -0
- package/dist/store/rule-scope.d.ts +7 -0
- package/dist/store/rule-scope.js +54 -0
- package/dist/store/rule-store.d.ts +29 -3
- package/dist/store/rule-store.js +110 -26
- package/dist/store/types.d.ts +22 -2
- package/dist/way/cli.d.ts +1 -0
- package/dist/way/cli.js +313 -0
- package/dist/way/compile.d.ts +22 -0
- package/dist/way/compile.js +408 -0
- package/dist/way/conflict.d.ts +2 -0
- package/dist/way/conflict.js +18 -0
- package/dist/way/draft.d.ts +43 -0
- package/dist/way/draft.js +335 -0
- package/dist/way/extract.d.ts +17 -0
- package/dist/way/extract.js +172 -0
- package/dist/way/io.d.ts +79 -0
- package/dist/way/io.js +425 -0
- package/dist/way/similar.d.ts +2 -0
- package/dist/way/similar.js +30 -0
- package/dist/way/types.d.ts +98 -0
- package/dist/way/types.js +2 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/postinstall.js +76 -899
- package/dist/core/health-cli.d.ts +0 -25
- package/dist/core/health-cli.js +0 -90
- package/dist/host/parity-harness.d.ts +0 -70
- package/dist/host/parity-harness.js +0 -287
|
@@ -15,7 +15,7 @@ const log = createLogger('session-recovery');
|
|
|
15
15
|
import { atomicWriteJSON } from './shared/atomic-write.js';
|
|
16
16
|
import { sanitizeId } from './shared/sanitize-id.js';
|
|
17
17
|
import { isHookEnabled } from './hook-config.js';
|
|
18
|
-
import { approve, approveWithContext, failOpenWithTracking } from './shared/hook-response.js';
|
|
18
|
+
import { approve, approveWithContext, approveWithWarning, failOpenWithTracking } from './shared/hook-response.js';
|
|
19
19
|
import { HANDOFFS_DIR, STATE_DIR } from '../core/paths.js';
|
|
20
20
|
import { recordHookTiming } from './shared/hook-timing.js';
|
|
21
21
|
/** 체크포인트 저장 */
|
|
@@ -153,25 +153,28 @@ async function main() {
|
|
|
153
153
|
// 이전엔 prepareHarness (fgx/forgen wrapper) 만 호출 → 직접 claude/codex 호출 시
|
|
154
154
|
// ~/.forgen/state/sessions/<id>.json 미생성. SessionStart hook 에서도 호출하여
|
|
155
155
|
// 양쪽 진입 경로 모두에서 session state 박제.
|
|
156
|
+
// doctor 프로브(FORGEN_DOCTOR_PROBE=1): 세션 상태 기록·백그라운드 스폰 등 부작용 경로를 건너뛴다.
|
|
157
|
+
const doctorProbe = process.env.FORGEN_DOCTOR_PROBE === '1';
|
|
156
158
|
let v1RenderedRules = null;
|
|
157
159
|
try {
|
|
160
|
+
if (doctorProbe)
|
|
161
|
+
throw new Error('doctor probe — 세션 상태 기록 생략');
|
|
158
162
|
const { bootstrapV1Session } = await import('../core/v1-bootstrap.js');
|
|
159
|
-
v1RenderedRules = bootstrapV1Session().renderedRules;
|
|
163
|
+
v1RenderedRules = bootstrapV1Session(sessionContext.cwd).renderedRules;
|
|
160
164
|
}
|
|
161
165
|
catch (e) {
|
|
162
166
|
log.debug('v1-bootstrap SessionStart 호출 실패 (fail-open)', e);
|
|
163
167
|
}
|
|
164
|
-
// ADR-014 D1
|
|
165
|
-
|
|
166
|
-
const codexRulesBlock = await (async () => {
|
|
168
|
+
// 모든 호스트가 같은 경로로 룰을 받는다(ADR-014 D1 확장). 래퍼 없이 실행해도 매 세션 최신 룰이 들어간다.
|
|
169
|
+
const rulesBlock = await (async () => {
|
|
167
170
|
try {
|
|
168
|
-
const { isCodexRuntime,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return await
|
|
171
|
+
const { isCodexRuntime, buildRulesContext } = await import('../host/codex-rules-context.js');
|
|
172
|
+
const { reclaimRenderedRuleFiles } = await import('../core/rendered-rules-manifest.js');
|
|
173
|
+
reclaimRenderedRuleFiles(sessionContext.cwd);
|
|
174
|
+
return await buildRulesContext(sessionContext.cwd, v1RenderedRules, isCodexRuntime() ? 'codex' : 'claude');
|
|
172
175
|
}
|
|
173
176
|
catch (e) {
|
|
174
|
-
log.debug('
|
|
177
|
+
log.debug('rules block 생성 실패 (fail-open)', e);
|
|
175
178
|
return null;
|
|
176
179
|
}
|
|
177
180
|
})();
|
|
@@ -194,6 +197,13 @@ async function main() {
|
|
|
194
197
|
const state = parsed;
|
|
195
198
|
if (!state.active)
|
|
196
199
|
continue;
|
|
200
|
+
// H6: 키워드로 켜진 모드 상태는 그 세션의 것이다. 다른 세션(새 세션)에 "이전 세션에서 복구됨"으로 주입하면
|
|
201
|
+
// 오너가 요청하지 않은 autopilot/ralph 지시가 새 세션을 지배한다. resume/compact 는 같은 session_id 를 쓰므로
|
|
202
|
+
// 같은 세션일 때만 복구하고, sessionId 가 없거나 다르면 건너뛴다.
|
|
203
|
+
if (!state.sessionId || state.sessionId !== sessionContext.sessionId) {
|
|
204
|
+
log.debug(`${mode} 상태는 다른 세션(${state.sessionId ?? 'unknown'}) 소유 — 복구 주입 생략`);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
197
207
|
// 24시간 이상 경과한 상태는 만료
|
|
198
208
|
const startedAt = new Date(state.startedAt).getTime();
|
|
199
209
|
const elapsed = Date.now() - startedAt;
|
|
@@ -369,42 +379,48 @@ async function main() {
|
|
|
369
379
|
.filter(f => f.endsWith('.jsonl') && f !== `${sessionId}.jsonl`) // 현재 세션 제외
|
|
370
380
|
.map(f => ({ name: f, mtime: fs.statSync(path.join(projectDir, f)).mtimeMs }))
|
|
371
381
|
.sort((a, b) => b.mtime - a.mtime);
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
382
|
+
// D9: 직전 1개만 보던 단일 슬롯 판정 대신, 최근 7일 안의 미처리/자란 transcript 를 최대 3개까지 전수 확인한다.
|
|
383
|
+
// 처리 여부는 세션별 러너 기록(sessionNeedsRun: 마지막 실행 이후 transcript 크기)으로 판정 — 길이 게이트 없음.
|
|
384
|
+
// 러너는 승급·인덱싱이 멱등이고 Haiku 는 새 구간만 읽으므로 중복 비용이 없다.
|
|
385
|
+
const { sessionNeedsRun, transcriptSignature } = await import('../core/extraction-queue.js');
|
|
386
|
+
const WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
387
|
+
let spawned = 0;
|
|
388
|
+
for (const t of transcripts) {
|
|
389
|
+
if (spawned >= 3 || doctorProbe)
|
|
390
|
+
break;
|
|
391
|
+
if (Date.now() - t.mtime > WEEK_MS)
|
|
392
|
+
break; // mtime 내림차순 — 이후는 더 오래됨
|
|
393
|
+
const prevTranscript = path.join(projectDir, t.name);
|
|
394
|
+
const prevSessionId = t.name.replace('.jsonl', '');
|
|
395
|
+
let size = 0;
|
|
376
396
|
try {
|
|
377
|
-
|
|
397
|
+
size = fs.statSync(prevTranscript).size;
|
|
378
398
|
}
|
|
379
|
-
catch {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
], { detached: true, stdio: 'ignore' });
|
|
405
|
-
autoCompound.unref();
|
|
406
|
-
log.debug(`이전 세션 auto-compound 시작: ${prevSessionId} (${userMsgCount} messages)`);
|
|
407
|
-
}
|
|
399
|
+
catch {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (size === 0 || !sessionNeedsRun(prevSessionId, size, { sig: transcriptSignature(prevTranscript) }))
|
|
403
|
+
continue;
|
|
404
|
+
const { spawn: spawnProcess } = await import('node:child_process');
|
|
405
|
+
const autoCompound = spawnProcess(process.execPath, [
|
|
406
|
+
path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'core', 'auto-compound-runner.js'),
|
|
407
|
+
cwd, prevTranscript, prevSessionId, '0', 'final',
|
|
408
|
+
], { detached: true, stdio: 'ignore' });
|
|
409
|
+
autoCompound.unref();
|
|
410
|
+
spawned++;
|
|
411
|
+
log.debug(`이전 세션 auto-compound 시작: ${prevSessionId}`);
|
|
412
|
+
}
|
|
413
|
+
// D4: 새로 처리할 세션이 없어도 대기열(타임아웃·실패로 밀린 추출)에 기한이 된 항목이 있으면 재시도 러너를 띄운다.
|
|
414
|
+
if (spawned === 0 && !doctorProbe) {
|
|
415
|
+
const { readQueue } = await import('../core/extraction-queue.js');
|
|
416
|
+
const now = Date.now();
|
|
417
|
+
if (readQueue().some((e) => e.nextAt <= now && (e.claimedUntil ?? 0) <= now)) {
|
|
418
|
+
const { spawn: spawnProcess } = await import('node:child_process');
|
|
419
|
+
const q = spawnProcess(process.execPath, [
|
|
420
|
+
path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'core', 'auto-compound-runner.js'),
|
|
421
|
+
cwd, '-', 'queue-retry',
|
|
422
|
+
], { detached: true, stdio: 'ignore' });
|
|
423
|
+
q.unref();
|
|
408
424
|
}
|
|
409
425
|
}
|
|
410
426
|
}
|
|
@@ -425,7 +441,7 @@ async function main() {
|
|
|
425
441
|
}
|
|
426
442
|
}
|
|
427
443
|
catch { /* last-lifecycle.json parse failure — run lifecycle check anyway */ }
|
|
428
|
-
if (shouldRun) {
|
|
444
|
+
if (shouldRun && !doctorProbe) {
|
|
429
445
|
// B-4: detached background spawn — hook timeout 초과 방지.
|
|
430
446
|
//
|
|
431
447
|
// Audit fix #5 (2026-04-21): prior invocation interpolated
|
|
@@ -438,7 +454,7 @@ async function main() {
|
|
|
438
454
|
// no shell, no eval, no interpolation.
|
|
439
455
|
const runnerPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'internal', 'run-lifecycle-check.js');
|
|
440
456
|
const { spawn: spawnLifecycle } = await import('node:child_process');
|
|
441
|
-
const lifecycleRunner = spawnLifecycle(
|
|
457
|
+
const lifecycleRunner = spawnLifecycle(process.execPath, [runnerPath, sessionId], {
|
|
442
458
|
detached: true,
|
|
443
459
|
stdio: 'ignore',
|
|
444
460
|
});
|
|
@@ -450,10 +466,23 @@ async function main() {
|
|
|
450
466
|
catch (e) {
|
|
451
467
|
log.debug('lifecycle check 실패', e);
|
|
452
468
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
if (
|
|
456
|
-
|
|
469
|
+
// D2: 최초 1회 Haiku 전송 안내 / 호출 불가 사유 — 사용자 화면(systemMessage)에 보인다.
|
|
470
|
+
let haikuNotice = null;
|
|
471
|
+
if (!doctorProbe) {
|
|
472
|
+
try {
|
|
473
|
+
const { takeSessionStartNotice } = await import('../core/compound-consent.js');
|
|
474
|
+
haikuNotice = await takeSessionStartNotice();
|
|
475
|
+
}
|
|
476
|
+
catch (e) {
|
|
477
|
+
log.debug('Haiku 안내 생성 실패', e);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (rulesBlock || recoveryMessages.length > 0) {
|
|
481
|
+
const { fitSessionContext } = await import('./shared/injection-caps.js');
|
|
482
|
+
console.log(approveWithContext(fitSessionContext(rulesBlock, recoveryMessages), 'SessionStart', haikuNotice ?? undefined));
|
|
483
|
+
}
|
|
484
|
+
else if (haikuNotice) {
|
|
485
|
+
console.log(approveWithWarning(haikuNotice));
|
|
457
486
|
}
|
|
458
487
|
else {
|
|
459
488
|
console.log(approve());
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type FindingAction = 'block' | 'deny' | 'ask' | 'warn';
|
|
2
|
+
export interface CommandFinding {
|
|
3
|
+
id: string;
|
|
4
|
+
action: FindingAction;
|
|
5
|
+
description: string;
|
|
6
|
+
targets?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface GitOp {
|
|
9
|
+
sub: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
/** `git -C <dir>` 값 (있으면). */
|
|
12
|
+
dir?: string;
|
|
13
|
+
/** 문장 시점의 cwd (같은 명령 안 `cd` 반영). */
|
|
14
|
+
cwd: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AnalysisResult {
|
|
17
|
+
findings: CommandFinding[];
|
|
18
|
+
/** git add/commit/push 호출 — commit-guard 가 실제 staged 내용을 확인하는 데 쓴다. */
|
|
19
|
+
gitOps: GitOp[];
|
|
20
|
+
/** SQL 로 실행될 수 있는 텍스트(DB CLI 인자·heredoc·파이프 입력, python/node -c 코드). */
|
|
21
|
+
sqlTexts: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface AnalyzeOptions {
|
|
24
|
+
cwd?: string;
|
|
25
|
+
home?: string;
|
|
26
|
+
}
|
|
27
|
+
interface Word {
|
|
28
|
+
text: string;
|
|
29
|
+
quoted: boolean;
|
|
30
|
+
dynamic: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** 입력 길이 상한 — 초과는 분석하지 않고 ask (fail-open 금지). pre-tool-use 의 정규식 경로도 같은 상한을 쓴다. */
|
|
33
|
+
export declare const MAX_COMMAND_LENGTH = 50000;
|
|
34
|
+
interface Stmt {
|
|
35
|
+
words: Word[];
|
|
36
|
+
sepBefore: string;
|
|
37
|
+
heredocs: string[];
|
|
38
|
+
subs: string[];
|
|
39
|
+
procSubs: string[];
|
|
40
|
+
hereStrings: Word[];
|
|
41
|
+
}
|
|
42
|
+
export declare function tokenize(src: string): Stmt[];
|
|
43
|
+
export declare function analyzeCommand(cmd: string, opts?: AnalyzeOptions): AnalysisResult;
|
|
44
|
+
export declare function worstFinding(findings: CommandFinding[]): CommandFinding | undefined;
|
|
45
|
+
export {};
|