sneakoscope 4.8.7 → 5.3.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/README.md +51 -726
- package/config/bench-baseline.json +7 -0
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/crates/sks-core/src/main.rs +1 -1
- package/dist/bin/install.js +35 -0
- package/dist/bin/sks.js +1 -1
- package/dist/cli/cli-theme.js +51 -0
- package/dist/cli/command-registry.js +15 -4
- package/dist/cli/help-fast.js +18 -8
- package/dist/cli/insane-search-command.js +36 -8
- package/dist/cli/install-helpers.js +32 -0
- package/dist/commands/codex-lb.js +2 -0
- package/dist/commands/doctor.js +94 -9
- package/dist/commands/proof.js +6 -3
- package/dist/config/skills-manifest.json +82 -54
- package/dist/core/agents/agent-conflict-graph.js +5 -0
- package/dist/core/agents/agent-lease.js +5 -0
- package/dist/core/agents/agent-ledger-schemas.js +1 -0
- package/dist/core/agents/agent-lifecycle.js +5 -3
- package/dist/core/agents/agent-orchestrator.js +268 -62
- package/dist/core/agents/agent-output-validator.js +14 -3
- package/dist/core/agents/agent-patch-queue-store.js +95 -2
- package/dist/core/agents/agent-patch-queue.js +6 -3
- package/dist/core/agents/agent-patch-schema.js +13 -0
- package/dist/core/agents/agent-proof-evidence.js +6 -1
- package/dist/core/agents/agent-runner-fake.js +40 -0
- package/dist/core/agents/agent-worker-pipeline.js +36 -2
- package/dist/core/agents/codex-exec-worker-adapter.js +2 -0
- package/dist/core/agents/native-cli-worker.js +0 -1
- package/dist/core/agents/native-worker-backend-router.js +58 -1
- package/dist/core/codex-app/sks-menubar.js +477 -132
- package/dist/core/codex-app.js +1 -0
- package/dist/core/codex-control/codex-sdk-config-policy.js +2 -1
- package/dist/core/codex-control/codex-sdk-env-policy.js +1 -1
- package/dist/core/codex-control/schemas/agent-worker-result.schema.js +12 -3
- package/dist/core/codex-hooks/codex-hook-managed-install.js +5 -0
- package/dist/core/codex-hooks/codex-hook-state-writer.js +70 -11
- package/dist/core/codex-hooks/codex-hook-trust-doctor.js +2 -2
- package/dist/core/codex-lb/codex-lb-env.js +20 -1
- package/dist/core/commands/basic-cli.js +18 -1
- package/dist/core/commands/check-command.js +37 -5
- package/dist/core/commands/computer-use-command.js +62 -7
- package/dist/core/commands/db-command.js +31 -5
- package/dist/core/commands/fast-mode-command.js +3 -0
- package/dist/core/commands/gate-result-contract.js +43 -0
- package/dist/core/commands/gates-command.js +6 -1
- package/dist/core/commands/gc-command.js +29 -2
- package/dist/core/commands/goal-command.js +9 -2
- package/dist/core/commands/gx-command.js +79 -7
- package/dist/core/commands/image-ux-review-command.js +188 -13
- package/dist/core/commands/mad-db-command.js +85 -176
- package/dist/core/commands/mad-sks-command.js +230 -29
- package/dist/core/commands/menubar-command.js +24 -2
- package/dist/core/commands/naruto-command.js +64 -10
- package/dist/core/commands/plan-command.js +76 -0
- package/dist/core/commands/ppt-command.js +159 -24
- package/dist/core/commands/qa-loop-command.js +6 -2
- package/dist/core/commands/release-command.js +55 -2
- package/dist/core/commands/research-command.js +1 -1
- package/dist/core/commands/review-command.js +217 -0
- package/dist/core/commands/route-success-helpers.js +59 -0
- package/dist/core/commands/run-command.js +19 -7
- package/dist/core/commands/seo-command.js +49 -1
- package/dist/core/commands/ui-command.js +161 -0
- package/dist/core/commands/uninstall-command.js +15 -1
- package/dist/core/db-safety.js +2 -2
- package/dist/core/doctor/doctor-dirty-planner.js +51 -7
- package/dist/core/doctor/doctor-transaction.js +8 -0
- package/dist/core/doctor/doctor-zellij-repair.js +1 -0
- package/dist/core/doctor/imagegen-repair.js +161 -0
- package/dist/core/feature-fixture-runner.js +2 -2
- package/dist/core/feature-fixtures.js +58 -37
- package/dist/core/feature-registry.js +102 -2
- package/dist/core/fsx.js +39 -6
- package/dist/core/image-ux-review/imagegen-adapter.js +48 -11
- package/dist/core/image-ux-review.js +16 -0
- package/dist/core/imagegen/imagegen-capability.js +11 -5
- package/dist/core/imagegen/require-imagegen.js +57 -0
- package/dist/core/init/skills.js +10 -5
- package/dist/core/mad-db/mad-db-coordinator.js +94 -18
- package/dist/core/mad-db/mad-db-policy.js +12 -10
- package/dist/core/mad-sks/executors/executor-base.js +8 -2
- package/dist/core/mad-sks/executors/index.js +4 -0
- package/dist/core/mad-sks/executors/sql-plane-executor.js +194 -0
- package/dist/core/naruto/naruto-active-pool.js +15 -4
- package/dist/core/naruto/naruto-real-worker-child.js +11 -1
- package/dist/core/naruto/naruto-role-policy.js +3 -0
- package/dist/core/naruto/naruto-task-hints.js +10 -0
- package/dist/core/naruto/naruto-work-graph.js +8 -2
- package/dist/core/naruto/naruto-work-item.js +6 -0
- package/dist/core/naruto/solution-tournament.js +101 -0
- package/dist/core/permission-gates.js +30 -0
- package/dist/core/pipeline-internals/runtime-core.js +11 -3
- package/dist/core/pipeline-internals/runtime-gates.js +27 -0
- package/dist/core/ppt-review/index.js +6 -1
- package/dist/core/ppt-review/slide-imagegen-review.js +75 -10
- package/dist/core/ppt.js +70 -2
- package/dist/core/proof/auto-finalize.js +70 -11
- package/dist/core/proof/proof-schema.js +2 -0
- package/dist/core/proof/route-adapter.js +5 -1
- package/dist/core/proof/route-finalizer.js +8 -5
- package/dist/core/proof/selftest-proof-fixtures.js +18 -5
- package/dist/core/proof/validation.js +2 -0
- package/dist/core/provider/model-router.js +53 -0
- package/dist/core/release/release-gate-node.js +3 -0
- package/dist/core/release/release-gate-resource-governor.js +1 -0
- package/dist/core/routes/constants.js +1 -1
- package/dist/core/routes.js +65 -18
- package/dist/core/safety/mutation-guard.js +5 -1
- package/dist/core/stop-gate/gate-evaluator.js +102 -0
- package/dist/core/stop-gate/stop-gate-check.js +16 -1
- package/dist/core/stop-gate/stop-gate-writer.js +4 -0
- package/dist/core/triwiki/agents-md-projector.js +184 -0
- package/dist/core/triwiki-wrongness/wrongness-schema.js +3 -1
- package/dist/core/trust-kernel/trust-kernel-schema.js +1 -0
- package/dist/core/trust-kernel/trust-report.js +1 -1
- package/dist/core/trust-kernel/trust-status.js +2 -0
- package/dist/core/ui/dashboard-html.js +111 -0
- package/dist/core/update/update-migration-state.js +386 -15
- package/dist/core/update-check.js +178 -81
- package/dist/core/verification/diff-quality.js +100 -0
- package/dist/core/verification/impact-scan.js +164 -0
- package/dist/core/verification/machine-feedback.js +146 -0
- package/dist/core/verification/mistake-rule-compiler.js +195 -0
- package/dist/core/version.js +1 -1
- package/dist/core/zellij/zellij-self-heal.js +9 -6
- package/dist/core/zellij/zellij-slot-telemetry.js +1 -1
- package/dist/scripts/check-feature-quality.js +2 -2
- package/dist/scripts/cli-output-consistency-check.js +57 -0
- package/dist/scripts/coding-bench-check.js +136 -0
- package/dist/scripts/doctor-imagegen-repair-check.js +62 -0
- package/dist/scripts/ensure-bin-executable.js +11 -3
- package/dist/scripts/harness-benchmark-check.js +104 -0
- package/dist/scripts/legacy-update-e2e-check.js +228 -0
- package/dist/scripts/mad-db-command-check.js +11 -8
- package/dist/scripts/mad-db-route-identity-check.js +8 -6
- package/dist/scripts/mad-db-safety-conflict-matrix-check.js +31 -8
- package/dist/scripts/mad-db-skill-policy-snapshot-check.js +4 -5
- package/dist/scripts/naruto-real-active-pool-runtime-check.js +26 -1
- package/dist/scripts/ppt-real-imagegen-wiring-check.js +5 -1
- package/dist/scripts/proof-root-cause-policy-check.js +2 -0
- package/dist/scripts/release-dag-full-coverage-check.js +13 -4
- package/dist/scripts/release-gate-dag-runner.js +14 -0
- package/dist/scripts/release-gate-existence-audit.js +2 -1
- package/dist/scripts/release-gate-planner.js +2 -1
- package/dist/scripts/release-gate-script-parity-check.js +45 -17
- package/dist/scripts/release-metadata-1-19-check.js +2 -1
- package/dist/scripts/seo-geo-feature-fixture-quality-check.js +1 -1
- package/dist/scripts/sks-1-11-gate-lib.js +8 -6
- package/dist/scripts/sks-menubar-install-check.js +57 -20
- package/dist/scripts/ux-review-real-loop-fixture-check.js +9 -4
- package/dist/scripts/ux-review-run-wires-imagegen-check.js +4 -0
- package/dist/scripts/zellij-slot-telemetry-runtime-check.js +1 -0
- package/docs/assets/sneakoscope-architecture-pipeline.jpg +0 -0
- package/docs/demo.tape +28 -0
- package/package.json +31 -24
- package/schemas/codex/completion-proof.schema.json +3 -2
- package/schemas/release/release-gate-node.schema.json +2 -1
- package/dist/scripts/agent-backfill-route-blackbox.js +0 -5
- package/dist/scripts/agent-dynamic-pool-route-blackbox.js +0 -5
- package/dist/scripts/agent-parallel-write-blackbox.js +0 -56
- package/dist/scripts/agent-patch-swarm-route-blackbox.js +0 -10
- package/dist/scripts/agent-route-blackbox-lib.js +0 -132
- package/dist/scripts/blackbox-command-import-smoke.js +0 -143
- package/dist/scripts/blackbox-global-shim.js +0 -77
- package/dist/scripts/blackbox-matrix.js +0 -70
- package/dist/scripts/blackbox-npx-one-shot.js +0 -69
- package/dist/scripts/blackbox-pack-install.js +0 -174
- package/dist/scripts/brand-neutrality-zero-leakage-blackbox.js +0 -4
- package/dist/scripts/build-once-runner-blackbox.js +0 -34
- package/dist/scripts/codex-0140-integration-blackbox.js +0 -13
- package/dist/scripts/codex-agent-type-blackbox.js +0 -4
- package/dist/scripts/codex-app-harness-blackbox.js +0 -4
- package/dist/scripts/codex-app-skill-agent-blackbox.js +0 -4
- package/dist/scripts/codex-hook-approval-blackbox.js +0 -4
- package/dist/scripts/codex-init-deep-directory-local-blackbox.js +0 -4
- package/dist/scripts/codex-native-feature-broker-blackbox.js +0 -4
- package/dist/scripts/codex-native-pattern-analysis-blackbox.js +0 -4
- package/dist/scripts/codex-native-read-repair-split-blackbox.js +0 -55
- package/dist/scripts/codex-native-reference-cache-blackbox.js +0 -41
- package/dist/scripts/core-skill-integrity-blackbox.js +0 -32
- package/dist/scripts/dfix-fast-blackbox-check.js +0 -37
- package/dist/scripts/dfix-parallel-write-blackbox.js +0 -48
- package/dist/scripts/dfix-patch-swarm-route-blackbox.js +0 -10
- package/dist/scripts/doctor-dirty-repair-blackbox.js +0 -22
- package/dist/scripts/doctor-dirty-semantic-blackbox.js +0 -8
- package/dist/scripts/doctor-native-capability-repair-blackbox.js +0 -39
- package/dist/scripts/doctor-transaction-engine-blackbox.js +0 -28
- package/dist/scripts/doctor-zellij-fix-blackbox.js +0 -4
- package/dist/scripts/doctor-zellij-no-homebrew-blackbox.js +0 -4
- package/dist/scripts/doctor-zellij-upgrade-blackbox.js +0 -4
- package/dist/scripts/gate-pack-runner-blackbox.js +0 -27
- package/dist/scripts/gate-pack-v2-blackbox.js +0 -18
- package/dist/scripts/geo-cli-blackbox-check.js +0 -18
- package/dist/scripts/loop-collision-blackbox.js +0 -3
- package/dist/scripts/loop-concurrency-oversubscription-blackbox.js +0 -3
- package/dist/scripts/loop-fixture-production-misuse-blackbox.js +0 -3
- package/dist/scripts/loop-kill-interrupt-real-blackbox.js +0 -3
- package/dist/scripts/loop-merge-strategy-blackbox.js +0 -3
- package/dist/scripts/loop-mesh-production-e2e-blackbox.js +0 -3
- package/dist/scripts/loop-side-effect-blackbox.js +0 -3
- package/dist/scripts/mad-db-operation-lifecycle-blackbox.js +0 -29
- package/dist/scripts/mad-sks-actual-executor-blackbox.js +0 -5
- package/dist/scripts/mad-zellij-headless-fallback-blackbox.js +0 -4
- package/dist/scripts/mad-zellij-self-heal-blackbox.js +0 -4
- package/dist/scripts/naruto-loop-mesh-blackbox.js +0 -3
- package/dist/scripts/naruto-real-parallelism-blackbox.js +0 -307
- package/dist/scripts/naruto-worktree-coding-blackbox.js +0 -29
- package/dist/scripts/parallel-runtime-real-blackbox.js +0 -44
- package/dist/scripts/pipeline-codex-native-doctor-mad-routing-real-blackbox.js +0 -77
- package/dist/scripts/pipeline-codex-native-e2e-blackbox.js +0 -13
- package/dist/scripts/pipeline-codex-native-image-routing-real-blackbox.js +0 -50
- package/dist/scripts/pipeline-codex-native-loop-routing-real-blackbox.js +0 -74
- package/dist/scripts/pipeline-codex-native-qa-routing-real-blackbox.js +0 -51
- package/dist/scripts/pipeline-codex-native-research-routing-real-blackbox.js +0 -45
- package/dist/scripts/pipeline-execution-profile-routing-blackbox.js +0 -4
- package/dist/scripts/postinstall-global-doctor-blackbox.js +0 -12
- package/dist/scripts/ppt-full-e2e-blackbox-check.js +0 -109
- package/dist/scripts/ppt-imagegen-blackbox-check.js +0 -46
- package/dist/scripts/qa-backfill-route-blackbox.js +0 -5
- package/dist/scripts/qa-patch-swarm-route-blackbox.js +0 -10
- package/dist/scripts/release-full-parallelism-blackbox.js +0 -41
- package/dist/scripts/release-triwiki-first-runner-blackbox.js +0 -48
- package/dist/scripts/release-wiring-3110-blackbox.js +0 -27
- package/dist/scripts/release-wiring-3112-blackbox.js +0 -17
- package/dist/scripts/release-wiring-3113-blackbox.js +0 -17
- package/dist/scripts/research-backfill-route-blackbox.js +0 -5
- package/dist/scripts/research-final-reviewer-blackbox.js +0 -70
- package/dist/scripts/research-stage-cycle-runtime-blackbox.js +0 -40
- package/dist/scripts/research-synthesis-writer-blackbox.js +0 -24
- package/dist/scripts/route-blackbox-realism-check.js +0 -21
- package/dist/scripts/scheduler-resource-claim-blackbox.js +0 -24
- package/dist/scripts/seo-cli-blackbox-check.js +0 -18
- package/dist/scripts/sks-3110-all-feature-regression-blackbox.js +0 -116
- package/dist/scripts/sks-3112-all-feature-regression-blackbox.js +0 -29
- package/dist/scripts/sks-3113-all-feature-regression-blackbox.js +0 -17
- package/dist/scripts/sks-400-all-feature-regression-blackbox.js +0 -21
- package/dist/scripts/sks-400-extreme-parallel-blackbox.js +0 -8
- package/dist/scripts/sks-400-five-minute-blackbox.js +0 -9
- package/dist/scripts/sks-400-legacy-purge-blackbox.js +0 -8
- package/dist/scripts/sks-401-all-feature-regression-blackbox.js +0 -46
- package/dist/scripts/sks-401-five-minute-actual-blackbox.js +0 -23
- package/dist/scripts/sks-402-all-feature-regression-blackbox.js +0 -9
- package/dist/scripts/sks-402-five-minute-real-blackbox.js +0 -22
- package/dist/scripts/sksd-warm-cache-blackbox.js +0 -12
- package/dist/scripts/team-backfill-route-blackbox.js +0 -5
- package/dist/scripts/team-parallel-write-blackbox.js +0 -55
- package/dist/scripts/team-patch-swarm-route-blackbox.js +0 -10
- package/dist/scripts/triwiki-affected-graph-blackbox.js +0 -28
- package/dist/scripts/triwiki-proof-bank-blackbox.js +0 -30
- package/dist/scripts/triwiki-proof-bank-lock-blackbox.js +0 -7
- package/dist/scripts/ux-patch-swarm-route-blackbox.js +0 -10
- package/dist/scripts/ux-review-imagegen-blackbox-check.js +0 -67
- package/dist/scripts/zellij-initial-main-only-blackbox.js +0 -28
- package/dist/scripts/zellij-pane-lock-concurrency-blackbox.js +0 -80
- package/dist/scripts/zellij-pane-lock-open-worker-integration-blackbox.js +0 -137
- package/dist/scripts/zellij-self-heal-typed-blackbox.js +0 -4
- package/dist/scripts/zellij-slot-telemetry-real-blackbox.js +0 -20
- package/dist/scripts/zellij-stacked-fallback-integration-blackbox.js +0 -81
- package/dist/scripts/zellij-worker-pane-real-ui-blackbox.js +0 -202
|
@@ -1,180 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { initProject } from '../init.js';
|
|
3
|
-
import { findLatestMission, setCurrent } from '../mission.js';
|
|
4
|
-
import { exists, readText, sksRoot } from '../fsx.js';
|
|
5
|
-
import { closeMadDbCycle, isMadDbCapabilityActive, MAD_DB_ACK, readMadDbCapability, resolveMadDbMissionId, revokeMadDbCapability } from '../mad-db/mad-db-capability.js';
|
|
6
|
-
import { closeMadDbRuntimeProfile, verifyReadOnlyRestored } from '../mad-db/mad-db-runtime-profile.js';
|
|
7
|
-
import { runMadDbCycle } from '../mad-db/mad-db-coordinator.js';
|
|
8
|
-
import { resolveMadDbTarget } from '../mad-db/mad-db-target.js';
|
|
9
|
-
import { quarantineStaleMadDbRuntimeProfiles } from '../mad-db/mad-db-recovery.js';
|
|
10
|
-
import { sha256 } from '../fsx.js';
|
|
1
|
+
import { madHighCommand } from './mad-sks-command.js';
|
|
11
2
|
export async function madDbCommand(args = []) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
if (!
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (action === 'apply-migration')
|
|
22
|
-
return applyMigrationMadDb(root, rest);
|
|
23
|
-
if (action === 'doctor')
|
|
24
|
-
return doctorMadDb(root, rest);
|
|
25
|
-
if (action === 'close')
|
|
26
|
-
return closeMadDb(root, rest);
|
|
27
|
-
if (action === 'enable')
|
|
28
|
-
return enableMadDb(root, rest);
|
|
29
|
-
if (action === 'revoke')
|
|
30
|
-
return revokeMadDb(root, rest);
|
|
31
|
-
if (action === 'status')
|
|
32
|
-
return statusMadDb(root, rest);
|
|
33
|
-
console.error('Usage: sks mad-db run "<task-or-sql>" | exec --sql "<SQL>" | apply-migration --name <name> --file <sql-file> | doctor|status|close|revoke [--json]');
|
|
34
|
-
process.exitCode = 1;
|
|
35
|
-
}
|
|
36
|
-
async function runMadDb(root, args) {
|
|
37
|
-
const task = positionalText(args) || readOption(args, '--task', '');
|
|
38
|
-
const sql = readOption(args, '--sql', '');
|
|
39
|
-
const result = await runMadDbCycle({
|
|
40
|
-
root,
|
|
41
|
-
action: 'run',
|
|
42
|
-
task,
|
|
43
|
-
sql: sql || null,
|
|
44
|
-
verifySql: readOption(args, '--verify-sql', '') || null,
|
|
45
|
-
args
|
|
46
|
-
});
|
|
47
|
-
return printResult(result, args);
|
|
48
|
-
}
|
|
49
|
-
async function execMadDb(root, args) {
|
|
50
|
-
const sql = readOption(args, '--sql', '') || positionalText(args);
|
|
51
|
-
const result = await runMadDbCycle({
|
|
52
|
-
root,
|
|
53
|
-
action: 'exec',
|
|
54
|
-
task: sql || 'sks mad-db exec',
|
|
55
|
-
sql: sql || null,
|
|
56
|
-
verifySql: readOption(args, '--verify-sql', '') || null,
|
|
57
|
-
args
|
|
58
|
-
});
|
|
59
|
-
return printResult(result, args);
|
|
60
|
-
}
|
|
61
|
-
async function applyMigrationMadDb(root, args) {
|
|
62
|
-
const file = readOption(args, '--file', '');
|
|
63
|
-
const sql = readOption(args, '--sql', '') || (file ? await readText(path.resolve(file), '') : '');
|
|
64
|
-
const result = await runMadDbCycle({
|
|
65
|
-
root,
|
|
66
|
-
action: 'apply-migration',
|
|
67
|
-
task: `apply migration ${readOption(args, '--name', 'mad_db_migration')}`,
|
|
68
|
-
sql: sql || null,
|
|
69
|
-
migrationName: readOption(args, '--name', `mad_db_${Date.now()}`),
|
|
70
|
-
migrationFile: file || null,
|
|
71
|
-
verifySql: readOption(args, '--verify-sql', '') || null,
|
|
72
|
-
args
|
|
73
|
-
});
|
|
74
|
-
return printResult(result, args);
|
|
75
|
-
}
|
|
76
|
-
async function doctorMadDb(root, args) {
|
|
77
|
-
const target = await resolveMadDbTarget(root, { args });
|
|
78
|
-
const recovery = await quarantineStaleMadDbRuntimeProfiles(root);
|
|
79
|
-
const restoration = await verifyReadOnlyRestored(root, null);
|
|
80
|
-
const result = {
|
|
81
|
-
schema: 'sks.mad-db-doctor.v1',
|
|
82
|
-
ok: target.blockers.length === 0 && restoration.persistent_supabase_read_only,
|
|
83
|
-
target: { ...target, project_ref: target.project_ref ? `<hash:${target.project_ref_hash}>` : null },
|
|
84
|
-
stale_recovery: recovery,
|
|
85
|
-
read_only_restoration: restoration,
|
|
86
|
-
execute_sql_apply_migration_inventory_checked: false,
|
|
87
|
-
note: 'doctor does not open write transport; run/exec/apply-migration verifies tool inventory inside a bound cycle'
|
|
3
|
+
const translated = translateMadDbArgs(args);
|
|
4
|
+
const json = args.includes('--json');
|
|
5
|
+
process.stderr.write("mad-db is deprecated; use 'sks mad-sks sql ...' or 'sks mad-sks apply-migration ...'.\n");
|
|
6
|
+
if (!json)
|
|
7
|
+
return madHighCommand(['--mad-sks', ...translated]);
|
|
8
|
+
const originalLog = console.log;
|
|
9
|
+
const chunks = [];
|
|
10
|
+
console.log = (...values) => {
|
|
11
|
+
chunks.push(values.map((value) => typeof value === 'string' ? value : JSON.stringify(value)).join(' '));
|
|
88
12
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
console.error(`MadDB enable is deprecated and does not create a capability. Use sks mad-db run|exec|apply-migration for an executable cycle. Legacy ack was ${JSON.stringify(MAD_DB_ACK)}.`);
|
|
99
|
-
process.exitCode = 2;
|
|
100
|
-
return result;
|
|
13
|
+
try {
|
|
14
|
+
const result = await madHighCommand(['--mad-sks', ...translated]);
|
|
15
|
+
const parsed = parseCapturedJson(chunks.join('\n'));
|
|
16
|
+
const output = {
|
|
17
|
+
...(parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : result && typeof result === 'object' ? result : {}),
|
|
18
|
+
deprecated_alias: 'mad-db'
|
|
19
|
+
};
|
|
20
|
+
originalLog(JSON.stringify(output, null, 2));
|
|
21
|
+
return output;
|
|
101
22
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
ok: false,
|
|
105
|
-
action: 'enable',
|
|
106
|
-
reason: 'deprecated_enable_no_capability',
|
|
107
|
-
token_only: true,
|
|
108
|
-
executable_commands: ['sks mad-db run', 'sks mad-db exec', 'sks mad-db apply-migration']
|
|
109
|
-
};
|
|
110
|
-
if (json)
|
|
111
|
-
return console.log(JSON.stringify(result, null, 2));
|
|
112
|
-
console.error('MadDB enable no longer creates a capability. Use sks mad-db run|exec|apply-migration to create the bound mission/profile/capability and execute SQL.');
|
|
113
|
-
process.exitCode = 2;
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
async function statusMadDb(root, args) {
|
|
117
|
-
const missionId = await resolveMadDbMissionId(root, {}, readOption(args, '--mission', 'latest'));
|
|
118
|
-
const capability = missionId ? await readMadDbCapability(root, missionId) : null;
|
|
119
|
-
const result = {
|
|
120
|
-
schema: 'sks.mad-db-status.v2',
|
|
121
|
-
ok: true,
|
|
122
|
-
action: 'status',
|
|
123
|
-
mission_id: missionId,
|
|
124
|
-
active: isMadDbCapabilityActive(capability),
|
|
125
|
-
capability: capability ? redactCapability(capability) : null
|
|
126
|
-
};
|
|
127
|
-
return printJsonOrText(result, args, !missionId || !capability ? 'MadDB: no capability found.' : `MadDB: ${result.active ? 'active' : 'inactive'} for ${missionId}; status=${capability.status}; expires=${capability.expires_at}.`);
|
|
128
|
-
}
|
|
129
|
-
async function closeMadDb(root, args) {
|
|
130
|
-
const missionId = await resolveMadDbMissionId(root, {}, readOption(args, '--mission', 'latest')) || await findLatestMission(root);
|
|
131
|
-
const capability = missionId ? await readMadDbCapability(root, missionId) : null;
|
|
132
|
-
const restoration = missionId ? await closeMadDbRuntimeProfile({ root, missionId, reason: 'operator_close' }) : null;
|
|
133
|
-
const closed = missionId && capability ? await closeMadDbCycle(root, missionId, capability.cycle_id, 'operator_close') : null;
|
|
134
|
-
if (missionId)
|
|
135
|
-
await setCurrent(root, { mad_db_active: false, phase: 'MADDB_CLOSED' });
|
|
136
|
-
const result = { schema: 'sks.mad-db-close.v2', ok: Boolean(closed), action: 'close', mission_id: missionId, capability: closed ? redactCapability(closed) : null, read_only_restoration: restoration };
|
|
137
|
-
return printJsonOrText(result, args, closed ? `MadDB cycle closed for ${missionId}.` : 'MadDB: no capability to close.');
|
|
138
|
-
}
|
|
139
|
-
async function revokeMadDb(root, args) {
|
|
140
|
-
const missionId = await resolveMadDbMissionId(root, {}, readOption(args, '--mission', 'latest')) || await findLatestMission(root);
|
|
141
|
-
const revoked = missionId ? await revokeMadDbCapability(root, missionId, readOption(args, '--reason', 'operator_revoked')) : null;
|
|
142
|
-
const restoration = missionId ? await closeMadDbRuntimeProfile({ root, missionId, reason: 'operator_revoke' }) : null;
|
|
143
|
-
await setCurrent(root, { mad_db_active: false, phase: 'MADDB_REVOKED' });
|
|
144
|
-
const result = { schema: 'sks.mad-db-command.v2', ok: Boolean(revoked), action: 'revoke', mission_id: missionId, capability: revoked ? redactCapability(revoked) : null, read_only_restoration: restoration };
|
|
145
|
-
return printJsonOrText(result, args, revoked ? `MadDB capability revoked for ${missionId}.` : 'MadDB: no capability to revoke.');
|
|
146
|
-
}
|
|
147
|
-
function printResult(result, args) {
|
|
148
|
-
if (hasFlag(args, '--json')) {
|
|
149
|
-
console.log(JSON.stringify(result, null, 2));
|
|
23
|
+
finally {
|
|
24
|
+
console.log = originalLog;
|
|
150
25
|
}
|
|
151
|
-
|
|
152
|
-
|
|
26
|
+
}
|
|
27
|
+
function translateMadDbArgs(args = []) {
|
|
28
|
+
const list = args.map(String);
|
|
29
|
+
const action = list[0] && !list[0].startsWith('--') ? list[0] : 'status';
|
|
30
|
+
const rest = action === list[0] ? list.slice(1) : list;
|
|
31
|
+
if (action === 'run' || action === 'exec') {
|
|
32
|
+
const sql = readOption(rest, '--sql', '') || positionalText(rest);
|
|
33
|
+
return ['sql', ...(sql ? [sql] : []), ...preservedOptions(rest)];
|
|
153
34
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
35
|
+
if (action === 'apply-migration') {
|
|
36
|
+
const file = readOption(rest, '--file', '') || positionalText(rest);
|
|
37
|
+
return ['apply-migration', ...(file ? [file] : []), ...preservedOptions(rest, new Set(['--file']))];
|
|
157
38
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (result.ok === false)
|
|
166
|
-
process.exitCode = process.exitCode || 1;
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
function redactCapability(capability) {
|
|
170
|
-
return {
|
|
171
|
-
...capability,
|
|
172
|
-
project_ref: capability.project_ref ? `<hash:${sha256(capability.project_ref).slice(0, 16)}>` : null,
|
|
173
|
-
transport: capability.transport ? { ...capability.transport, server_url_redacted: capability.transport.server_url_redacted || '<redacted>' } : null
|
|
174
|
-
};
|
|
39
|
+
if (action === 'doctor')
|
|
40
|
+
return ['status', ...rest];
|
|
41
|
+
if (['status', 'close', 'revoke'].includes(action))
|
|
42
|
+
return [action, ...rest];
|
|
43
|
+
if (action === 'enable')
|
|
44
|
+
return ['permissions', ...rest];
|
|
45
|
+
return [action, ...rest];
|
|
175
46
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
47
|
+
function preservedOptions(args = [], omit = new Set()) {
|
|
48
|
+
const valueFlags = new Set(['--verify-sql', '--rollback-sql', '--ttl', '--target-root', '--intent', '--name', '--file']);
|
|
49
|
+
const out = [];
|
|
50
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
51
|
+
const arg = String(args[index] || '');
|
|
52
|
+
if (!arg.startsWith('--'))
|
|
53
|
+
continue;
|
|
54
|
+
if (omit.has(arg)) {
|
|
55
|
+
if (valueFlags.has(arg) && args[index + 1] && !String(args[index + 1]).startsWith('--'))
|
|
56
|
+
index += 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
out.push(arg);
|
|
60
|
+
if (valueFlags.has(arg) && args[index + 1] && !String(args[index + 1]).startsWith('--')) {
|
|
61
|
+
out.push(String(args[index + 1]));
|
|
62
|
+
index += 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
178
66
|
}
|
|
179
67
|
function readOption(args, name, fallback) {
|
|
180
68
|
const index = args.indexOf(name);
|
|
@@ -183,19 +71,40 @@ function readOption(args, name, fallback) {
|
|
|
183
71
|
const prefixed = args.find((arg) => String(arg).startsWith(`${name}=`));
|
|
184
72
|
return prefixed ? prefixed.slice(name.length + 1) : fallback;
|
|
185
73
|
}
|
|
186
|
-
function positionalText(args) {
|
|
74
|
+
function positionalText(args = []) {
|
|
75
|
+
const valueFlags = new Set(['--sql', '--verify-sql', '--rollback-sql', '--ttl', '--target-root', '--intent', '--name', '--file']);
|
|
187
76
|
const out = [];
|
|
188
77
|
for (let index = 0; index < args.length; index += 1) {
|
|
189
|
-
const arg = args[index];
|
|
190
|
-
if (!arg)
|
|
78
|
+
const arg = String(args[index] || '');
|
|
79
|
+
if (!arg || arg === '--json' || arg === '--yes' || arg === '-y')
|
|
191
80
|
continue;
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
index += 1;
|
|
81
|
+
if (valueFlags.has(arg)) {
|
|
82
|
+
index += 1;
|
|
195
83
|
continue;
|
|
196
84
|
}
|
|
85
|
+
if (arg.startsWith('--'))
|
|
86
|
+
continue;
|
|
197
87
|
out.push(arg);
|
|
198
88
|
}
|
|
199
89
|
return out.join(' ').trim();
|
|
200
90
|
}
|
|
91
|
+
function parseCapturedJson(text) {
|
|
92
|
+
const trimmed = String(text || '').trim();
|
|
93
|
+
if (!trimmed)
|
|
94
|
+
return null;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(trimmed);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
const start = trimmed.indexOf('{');
|
|
100
|
+
const end = trimmed.lastIndexOf('}');
|
|
101
|
+
if (start >= 0 && end > start) {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(trimmed.slice(start, end + 1));
|
|
104
|
+
}
|
|
105
|
+
catch { }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
201
110
|
//# sourceMappingURL=mad-db-command.js.map
|