sneakoscope 7.1.0 → 7.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.
Files changed (534) hide show
  1. package/README.md +9 -1
  2. package/config/architecture-budgets.v1.json +1 -8
  3. package/crates/sks-core/Cargo.lock +225 -1
  4. package/crates/sks-core/Cargo.toml +8 -1
  5. package/crates/sks-core/src/main.rs +7 -1
  6. package/crates/sks-core/src/search/files.rs +114 -0
  7. package/crates/sks-core/src/search/mod.rs +274 -0
  8. package/crates/sks-core/src/search/text.rs +175 -0
  9. package/dist/bin/sks-dispatch.js +4 -3
  10. package/dist/cli/command-manifest-lite.js +177 -6
  11. package/dist/cli/command-registry.js +42 -8
  12. package/dist/cli/help.js +30 -0
  13. package/dist/cli/install-helpers-codex-lb-config.js +9 -6
  14. package/dist/cli/install-helpers-codex-lb-selftest-chain.js +1 -1
  15. package/dist/cli/install-helpers-install-support.js +1 -1
  16. package/dist/cli/install-helpers.js +19 -9
  17. package/dist/cli/router.js +16 -3
  18. package/dist/commands/codex-app.js +40 -5
  19. package/dist/commands/doctor-profile.js +78 -0
  20. package/dist/commands/doctor.js +29 -69
  21. package/dist/commands/search.js +4 -0
  22. package/dist/config/skills-manifest.json +53 -60
  23. package/dist/core/agent-bridge/agent-manifest.js +22 -26
  24. package/dist/core/agent-bridge/host-capability-policy.js +109 -8
  25. package/dist/core/agent-bridge/host-capability-runtime.js +178 -50
  26. package/dist/core/agent-guidance/directive-registry.js +123 -0
  27. package/dist/core/agents/agent-effort-policy.js +45 -6
  28. package/dist/core/agents/agent-worker-pipeline.js +1 -3
  29. package/dist/core/agents/native-worker-backend-router.js +43 -19
  30. package/dist/core/auto-review.js +1 -3
  31. package/dist/core/code-structure.js +282 -19
  32. package/dist/core/codex/codex-config-guard.js +14 -4
  33. package/dist/core/codex/codex-config-toml.js +1 -3
  34. package/dist/core/codex-app/codex-agent-role-sync.js +1 -3
  35. package/dist/core/codex-app/codex-app-fast-ui-repair.js +14 -1
  36. package/dist/core/codex-app/codex-app-types.js +2 -3
  37. package/dist/core/codex-app/codex-desktop-routing-ownership.js +91 -0
  38. package/dist/core/codex-app/codex-hook-approval-probe.js +1 -3
  39. package/dist/core/codex-app/codex-hook-lifecycle.js +1 -3
  40. package/dist/core/codex-app/codex-init-deep.js +22 -10
  41. package/dist/core/codex-app/codex-model-catalog.js +384 -0
  42. package/dist/core/codex-app/codex-models-cache.js +160 -0
  43. package/dist/core/codex-app/desktop-routing-snapshot.js +233 -0
  44. package/dist/core/codex-app/glm-profile-installer.js +1 -3
  45. package/dist/core/codex-app/mcp-manager.js +1 -3
  46. package/dist/core/codex-app/menubar/constants.js +3 -0
  47. package/dist/core/codex-app/menubar/installer.js +11 -1
  48. package/dist/core/codex-app/multi-provider-router-support.js +202 -0
  49. package/dist/core/codex-app/multi-provider-router.js +379 -0
  50. package/dist/core/codex-app/openrouter-activate.js +189 -26
  51. package/dist/core/codex-app/openrouter-base-instructions.js +1 -0
  52. package/dist/core/codex-app/openrouter-model-catalog.js +217 -0
  53. package/dist/core/codex-app/role-model-catalog-priority.js +61 -0
  54. package/dist/core/codex-app.js +30 -6
  55. package/dist/core/codex-compat/codex-hook-semantic-validator.js +1 -3
  56. package/dist/core/codex-control/codex-app-server-v2-client.js +39 -2
  57. package/dist/core/codex-lb/codex-lb-env.js +1 -3
  58. package/dist/core/codex-lb/codex-lb-tool-catalog.js +6 -1
  59. package/dist/core/codex-native/codex-native-feature-broker.js +2 -6
  60. package/dist/core/codex-native/codex-native-interop-policy.js +1 -3
  61. package/dist/core/codex-native/codex-native-reference-cache.js +1 -3
  62. package/dist/core/codex-native/codex-native-reference-source.js +1 -3
  63. package/dist/core/codex-native/codex-native-repair-transaction.js +1 -3
  64. package/dist/core/codex-native/core-skill-manifest.js +3 -2
  65. package/dist/core/codex-native/native-capability-repair-matrix.js +1 -3
  66. package/dist/core/codex-plugins/codex-plugin-repair.js +1 -3
  67. package/dist/core/codex-runtime/codex-desktop-config-policy.js +4 -4
  68. package/dist/core/commands/agent-bridge-command.js +24 -3
  69. package/dist/core/commands/image-ux-review-command.js +5 -11
  70. package/dist/core/commands/menubar-command.js +1 -1
  71. package/dist/core/commands/naruto-command.js +40 -13
  72. package/dist/core/commands/pipeline-command.js +5 -2
  73. package/dist/core/commands/release-command.js +63 -1
  74. package/dist/core/commands/remote-command.js +18 -0
  75. package/dist/core/commands/search-command.js +151 -0
  76. package/dist/core/commands/telegram-command.js +251 -108
  77. package/dist/core/commands/uninstall-command.js +1 -1
  78. package/dist/core/config/secret-preservation.js +1 -3
  79. package/dist/core/context7-client.js +2 -1
  80. package/dist/core/db-review.js +704 -0
  81. package/dist/core/db-safety.js +17 -23
  82. package/dist/core/doctor/browser-use-repair.js +1 -3
  83. package/dist/core/doctor/codex-startup-config-repair.js +1 -3
  84. package/dist/core/doctor/computer-use-repair.js +1 -3
  85. package/dist/core/doctor/context7-mcp-repair.js +1 -3
  86. package/dist/core/doctor/current-project-guidance.js +1 -3
  87. package/dist/core/doctor/doctor-codex-startup-repair.js +1 -3
  88. package/dist/core/doctor/doctor-dirty-planner.js +2 -2
  89. package/dist/core/doctor/doctor-native-capability-repair.js +1 -3
  90. package/dist/core/doctor/doctor-transaction.js +1 -3
  91. package/dist/core/doctor/imagegen-repair.js +1 -3
  92. package/dist/core/doctor/legacy-global-hook-cleanup.js +1 -3
  93. package/dist/core/doctor/mcp-transport-collision-repair.js +1 -3
  94. package/dist/core/doctor/retired-managed-residue-private.js +1 -3
  95. package/dist/core/doctor/supabase-mcp-repair.js +1 -3
  96. package/dist/core/engineering-sanity-review.js +186 -0
  97. package/dist/core/errors/message.js +3 -0
  98. package/dist/core/evidence/evidence-schema.js +1 -3
  99. package/dist/core/feature-fixtures.js +1 -0
  100. package/dist/core/feature-registry.js +1 -3
  101. package/dist/core/fsx.js +13 -0
  102. package/dist/core/git-hygiene/shared-memory-publish.js +1 -3
  103. package/dist/core/git-hygiene/validators.js +1 -3
  104. package/dist/core/harness-guard.js +21 -3
  105. package/dist/core/hooks-runtime/hook-context.js +2 -2
  106. package/dist/core/image-ux-review/imagegen-adapter.js +52 -56
  107. package/dist/core/image-ux-review/real-callout-extractor.js +6 -1
  108. package/dist/core/image-ux-review.js +3 -5
  109. package/dist/core/imagegen/codex-lb-imagegen-target.js +70 -0
  110. package/dist/core/imagegen/imagegen-capability.js +11 -11
  111. package/dist/core/imagegen/imagegen-evidence.js +32 -0
  112. package/dist/core/init/skills.js +9 -11
  113. package/dist/core/init.js +4 -6
  114. package/dist/core/json/records.js +9 -0
  115. package/dist/core/json-schema-validator.js +1 -3
  116. package/dist/core/lean-engineering-policy.js +54 -0
  117. package/dist/core/loops/loop-continuation-enforcer.js +1 -3
  118. package/dist/core/mad-sks/sql-plane/mcp-executor.js +2 -1
  119. package/dist/core/mad-sks/sql-plane/policy.js +2 -1
  120. package/dist/core/managed-assets/managed-assets-manifest.js +4 -3
  121. package/dist/core/mcp-config/codex-cli-adapter.js +1 -3
  122. package/dist/core/mcp-config/config-reader.js +2 -3
  123. package/dist/core/mcp-config/guarded-patch.js +1 -1
  124. package/dist/core/mcp-config/health-check.js +2 -1
  125. package/dist/core/mcp-config/mutation.js +1 -1
  126. package/dist/core/mcp-config/restore.js +1 -1
  127. package/dist/core/mcp-config/secret-policy.js +1 -3
  128. package/dist/core/migration/migration-transaction-journal.js +3 -3
  129. package/dist/core/naruto/naruto-concurrency-governor.js +2 -2
  130. package/dist/core/perf/import-graph-budget.js +91 -1
  131. package/dist/core/pipeline/pipeline-plan-writer.js +1 -1
  132. package/dist/core/pipeline-internals/runtime-core.js +121 -23
  133. package/dist/core/pipeline-internals/runtime-gates.js +193 -4
  134. package/dist/core/pipeline.js +1 -1
  135. package/dist/core/ppt-review/slide-imagegen-review.js +7 -7
  136. package/dist/core/ppt.js +3 -3
  137. package/dist/core/product-design-app-server.js +2 -1
  138. package/dist/core/proof/fake-real-proof-policy.js +1 -3
  139. package/dist/core/proof/root-cause-policy.js +1 -3
  140. package/dist/core/proof/validation.js +1 -3
  141. package/dist/core/provider/model-router.js +4 -0
  142. package/dist/core/provider/provider-context.js +1 -3
  143. package/dist/core/providers/openrouter/openrouter-account.js +1 -3
  144. package/dist/core/quality/helper-dedup.js +0 -0
  145. package/dist/core/recallpulse.js +1 -1
  146. package/dist/core/release/file-ownership.js +26 -17
  147. package/dist/core/release/macos-menubar-proof.js +59 -1
  148. package/dist/core/release/main-push-guard.js +288 -24
  149. package/dist/core/release/main-push-receipt.js +10 -45
  150. package/dist/core/release/package-size-budget.js +1 -1
  151. package/dist/core/release/release-gate-contract.js +2 -0
  152. package/dist/core/release/release-pack-receipt.js +1 -1
  153. package/dist/core/release/release-proof-io.js +33 -0
  154. package/dist/core/release/release-upgrade-baseline.js +9 -0
  155. package/dist/core/release/runtime-script-pack-closure.js +153 -4
  156. package/dist/core/release/stage-publish.js +194 -0
  157. package/dist/core/remote/index.js +2 -0
  158. package/dist/core/remote/local-worker-client.js +35 -0
  159. package/dist/core/remote/machine-registry.js +18 -13
  160. package/dist/core/remote/owner-proof.js +1 -3
  161. package/dist/core/remote/protocol.js +1 -3
  162. package/dist/core/remote/readiness.js +1 -3
  163. package/dist/core/remote/session-binding.js +153 -0
  164. package/dist/core/remote/session-index.js +1 -3
  165. package/dist/core/remote/types.js +1 -0
  166. package/dist/core/remote/worker.js +228 -14
  167. package/dist/core/responses-stream.js +151 -0
  168. package/dist/core/routes/dollar-manifest-lite.js +1 -1
  169. package/dist/core/routes.js +8 -8
  170. package/dist/core/rust-accelerator.js +12 -2
  171. package/dist/core/safety/ssot-guard.js +1 -3
  172. package/dist/core/search/benchmark.js +358 -0
  173. package/dist/core/search/cache.js +65 -0
  174. package/dist/core/search/context.js +144 -0
  175. package/dist/core/search/doctor.js +74 -0
  176. package/dist/core/search/files.js +192 -0
  177. package/dist/core/search/index.js +5 -0
  178. package/dist/core/search/ipc.js +64 -0
  179. package/dist/core/search/provider.js +142 -0
  180. package/dist/core/search/rust-bridge.js +24 -0
  181. package/dist/core/search/structure.js +230 -0
  182. package/dist/core/search/symbol.js +272 -0
  183. package/dist/core/search/text.js +146 -0
  184. package/dist/core/search/types.js +22 -0
  185. package/dist/core/search/typescript-ls.js +215 -0
  186. package/dist/core/search-visibility/discovery.js +1 -3
  187. package/dist/core/skill-forge.js +1 -1
  188. package/dist/core/stop-gate/gate-evaluator.js +3 -3
  189. package/dist/core/stop-gate/stop-gate-check.js +1 -3
  190. package/dist/core/structured-output-adapter.js +62 -2
  191. package/dist/core/subagents/agent-catalog.js +56 -43
  192. package/dist/core/subagents/model-policy.js +17 -7
  193. package/dist/core/subagents/naruto-proof-projection.js +2 -6
  194. package/dist/core/subagents/official-subagent-config.js +1 -3
  195. package/dist/core/subagents/official-subagent-preparation.js +73 -10
  196. package/dist/core/subagents/official-subagent-prompt.js +85 -18
  197. package/dist/core/subagents/official-subagent-runner.js +10 -5
  198. package/dist/core/subagents/role-model-preferences.js +202 -44
  199. package/dist/core/subagents/subagent-evidence.js +1 -3
  200. package/dist/core/subagents/thread-budget.js +1 -1
  201. package/dist/core/subagents/triwiki-attention.js +1 -5
  202. package/dist/core/telegram/config.js +29 -12
  203. package/dist/core/telegram/hub.js +8 -2
  204. package/dist/core/telegram/index.js +2 -0
  205. package/dist/core/telegram/messages.js +8 -2
  206. package/dist/core/telegram/runtime-projection.js +8 -5
  207. package/dist/core/telegram/runtime.js +19 -9
  208. package/dist/core/telegram/service.js +181 -0
  209. package/dist/core/telegram/setup.js +220 -0
  210. package/dist/core/text/regex.js +3 -0
  211. package/dist/core/text/strings.js +6 -0
  212. package/dist/core/triwiki-wrongness/image-wrongness.js +1 -3
  213. package/dist/core/triwiki-wrongness/wrongness-ledger.js +1 -3
  214. package/dist/core/triwiki-wrongness/wrongness-proof-linker.js +1 -3
  215. package/dist/core/triwiki-wrongness/wrongness-retrieval.js +1 -3
  216. package/dist/core/triwiki-wrongness/wrongness-schema.js +1 -3
  217. package/dist/core/triwiki-wrongness/wrongness-trust-policy.js +1 -3
  218. package/dist/core/trust-kernel/completion-contract.js +1 -3
  219. package/dist/core/trust-kernel/route-contract.js +1 -3
  220. package/dist/core/update/update-migration-state.js +1 -3
  221. package/dist/core/update-check.js +20 -6
  222. package/dist/core/verification/diff-quality.js +3 -4
  223. package/dist/core/verification/impact-scan.js +36 -89
  224. package/dist/core/verification/mistake-rule-compiler.js +17 -4
  225. package/dist/core/version-manager.js +3 -20
  226. package/dist/core/version.js +1 -1
  227. package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +23 -3
  228. package/dist/native/sks-menubar/Sources/ControlKit.swift +102 -0
  229. package/dist/native/sks-menubar/Sources/DiagnosticsViewController.swift +23 -11
  230. package/dist/native/sks-menubar/Sources/MCPServersViewController.swift +7 -3
  231. package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +17 -1
  232. package/dist/native/sks-menubar/Sources/OverviewViewController.swift +22 -15
  233. package/dist/native/sks-menubar/Sources/ProcessClient.swift +15 -5
  234. package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +324 -0
  235. package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +154 -214
  236. package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +252 -0
  237. package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +77 -71
  238. package/dist/native/sks-menubar/Sources/RemoteTelegramViewController.swift +167 -51
  239. package/dist/native/sks-menubar/Sources/SettingsViewController.swift +14 -5
  240. package/dist/native/sks-menubar/Sources/SidebarItem.swift +15 -1
  241. package/dist/native/sks-menubar/Sources/StatusItemController.swift +2 -2
  242. package/dist/native/sks-menubar/Sources/UpdatesViewController.swift +16 -12
  243. package/dist/scripts/agent-guidance-dedup-check.js +23 -0
  244. package/dist/scripts/agent-message-bus-reader-check.js +1 -1
  245. package/dist/scripts/all-feature-deep-completion-check.js +1 -1
  246. package/dist/scripts/appshots-thread-attachment-discovery-check.js +1 -1
  247. package/dist/scripts/architecture-guard-check.js +1 -2
  248. package/dist/scripts/certificate-sla-check.js +1 -1
  249. package/dist/scripts/cli-output-consistency-check.js +1 -1
  250. package/dist/scripts/codex-0-134-runner-truth-check.js +1 -1
  251. package/dist/scripts/codex-0138-capability-artifact-check.js +1 -1
  252. package/dist/scripts/codex-0138-capability-check.js +1 -1
  253. package/dist/scripts/codex-0138-doctor-check.js +1 -1
  254. package/dist/scripts/codex-0138-feature-probes-check.js +1 -1
  255. package/dist/scripts/codex-0144-app-server-v2-check.js +1 -1
  256. package/dist/scripts/codex-0144-binary-identity-check.js +1 -1
  257. package/dist/scripts/codex-0144-capability-check.js +1 -1
  258. package/dist/scripts/codex-0144-core-real-probes-check.js +1 -1
  259. package/dist/scripts/codex-0144-manifest-check.js +1 -1
  260. package/dist/scripts/codex-0144-policy-check.js +1 -1
  261. package/dist/scripts/codex-0144-thread-store-check.js +1 -1
  262. package/dist/scripts/codex-agent-role-rich-content-check.js +2 -2
  263. package/dist/scripts/codex-agent-role-sync-check.js +2 -2
  264. package/dist/scripts/codex-agent-type-routing-check.js +2 -2
  265. package/dist/scripts/codex-app-execution-profile-check.js +2 -2
  266. package/dist/scripts/codex-app-handoff-check.js +1 -1
  267. package/dist/scripts/codex-app-handoff-launch-check.js +1 -1
  268. package/dist/scripts/codex-control-tool-output-continuity-audit-check.js +1 -1
  269. package/dist/scripts/codex-lb-fast-ui-preservation-check.js +1 -3
  270. package/dist/scripts/codex-native-feature-broker-blackbox.js +2 -2
  271. package/dist/scripts/codex-native-feature-broker-check.js +2 -2
  272. package/dist/scripts/{sks-3-1-6-directive-check-lib.js → codex-native-gate-lib.js} +5 -5
  273. package/dist/scripts/codex-native-harness-compat-check.js +2 -2
  274. package/dist/scripts/codex-native-hook-lifecycle-proof-check.js +2 -2
  275. package/dist/scripts/codex-plugin-app-template-policy-check.js +1 -1
  276. package/dist/scripts/codex-sdk-backend-router-check.js +1 -1
  277. package/dist/scripts/codex-sdk-capability-check.js +1 -1
  278. package/dist/scripts/context7-evidence-dedupe-check.js +1 -1
  279. package/dist/scripts/core-skill-card-schema-check.js +1 -1
  280. package/dist/scripts/core-skill-deployment-snapshot-check.js +1 -1
  281. package/dist/scripts/core-skill-heldout-validation-check.js +1 -1
  282. package/dist/scripts/core-skill-no-inference-optimizer-check.js +1 -1
  283. package/dist/scripts/core-skill-patch-check.js +1 -1
  284. package/dist/scripts/core-skill-route-runtime-integration-check.js +1 -1
  285. package/dist/scripts/current-command-surface-check.js +1 -1
  286. package/dist/scripts/current-surface-update-e2e-check.js +4 -1
  287. package/dist/scripts/current-upgrade-matrix-check.js +1 -1
  288. package/dist/scripts/dfix-fixture-check.js +1 -1
  289. package/dist/scripts/dfix-patch-handoff-check.js +1 -1
  290. package/dist/scripts/dfix-verification-check.js +1 -1
  291. package/dist/scripts/dfix-verification-recommendation-check.js +1 -1
  292. package/dist/scripts/docs-truthfulness-check.js +16 -3
  293. package/dist/scripts/doctor-codex-app-harness-check.js +2 -2
  294. package/dist/scripts/evidence-flagship-coverage-check.js +1 -1
  295. package/dist/scripts/{sks-1-18-gate-lib.js → gate-lib.js} +1 -1
  296. package/dist/scripts/gate-policy-audit-check.js +4 -1
  297. package/dist/scripts/git-worktree-checkpoint-check.js +1 -1
  298. package/dist/scripts/git-worktree-cross-rebase-check.js +1 -1
  299. package/dist/scripts/git-worktree-diff-envelope-check.js +1 -1
  300. package/dist/scripts/git-worktree-dirty-lock-check.js +1 -1
  301. package/dist/scripts/git-worktree-dirty-main-detection-check.js +1 -1
  302. package/dist/scripts/git-worktree-integration-primary-check.js +1 -1
  303. package/dist/scripts/git-worktree-manifest-append-check.js +1 -1
  304. package/dist/scripts/git-worktree-untracked-diff-check.js +1 -1
  305. package/dist/scripts/harness-benchmark-check.js +1 -1
  306. package/dist/scripts/helper-dedup-check.js +62 -0
  307. package/dist/scripts/hook-latency-budget-check.js +1 -1
  308. package/dist/scripts/image-artifact-path-contract-check.js +1 -1
  309. package/dist/scripts/imagegen-real-smoke-check.js +2 -5
  310. package/dist/scripts/installed-package-smoke-check.js +1 -1
  311. package/dist/scripts/legacy-gate-inventory-check.js +1 -1
  312. package/dist/scripts/legacy-gate-purge-check.js +1 -1
  313. package/dist/scripts/legacy-strong-inventory-check.js +1 -1
  314. package/dist/scripts/lib/codex-sdk-gate-lib.js +1 -1
  315. package/dist/scripts/mad-sks-launch-sql-plane-boundary-check.js +1 -1
  316. package/dist/scripts/mad-sks-sql-plane-capability-check.js +1 -1
  317. package/dist/scripts/mad-sks-sql-plane-lifecycle-hook-decision-check.js +1 -1
  318. package/dist/scripts/mad-sks-sql-plane-result-lifecycle-check.js +1 -1
  319. package/dist/scripts/managed-config-merge-check.js +1 -1
  320. package/dist/scripts/mcp-plugin-inventory-check.js +1 -1
  321. package/dist/scripts/model-call-concurrency-check.js +1 -1
  322. package/dist/scripts/mutation-callsite-coverage-check.js +1 -1
  323. package/dist/scripts/naruto-ssot-gate-aliases-check.js +1 -1
  324. package/dist/scripts/naruto-ssot-pipeline-default-check.js +1 -1
  325. package/dist/scripts/naruto-ssot-route-normalization-check.js +1 -1
  326. package/dist/scripts/naruto-ssot-routing-check.js +1 -1
  327. package/dist/scripts/naruto-worktree-coding-blackbox.js +1 -1
  328. package/dist/scripts/native-capability-repair-matrix-check.js +1 -1
  329. package/dist/scripts/native-image-generation-repair-check.js +1 -1
  330. package/dist/scripts/official-subagent-workflow-check.js +3 -3
  331. package/dist/scripts/package-published-contract-check.js +37 -4
  332. package/dist/scripts/packlist-performance-check.js +17 -1
  333. package/dist/scripts/pipeline-codex-native-doctor-mad-routing-real-blackbox.js +1 -3
  334. package/dist/scripts/ppt-real-export-adapter-check.js +1 -1
  335. package/dist/scripts/ppt-real-imagegen-wiring-check.js +1 -1
  336. package/dist/scripts/ppt-reexport-rereview-check.js +1 -1
  337. package/dist/scripts/prepublish-fast-check.js +1 -1
  338. package/dist/scripts/probe-memoization-check.js +2 -2
  339. package/dist/scripts/prompt-placeholder-guard-check.js +1 -1
  340. package/dist/scripts/qa-loop-app-handoff-capability-check.js +1 -1
  341. package/dist/scripts/qa-loop-app-handoff-check.js +1 -1
  342. package/dist/scripts/qa-loop-app-handoff-cli-check.js +1 -1
  343. package/dist/scripts/qa-loop-app-handoff-confirmation-check.js +1 -1
  344. package/dist/scripts/qa-loop-app-handoff-gate-lifecycle-check.js +1 -1
  345. package/dist/scripts/qa-loop-app-handoff-launch-check.js +1 -1
  346. package/dist/scripts/qa-loop-app-handoff-status-lifecycle-check.js +1 -1
  347. package/dist/scripts/qa-loop-budget-policy-check.js +1 -1
  348. package/dist/scripts/qa-loop-effort-escalation-check.js +1 -1
  349. package/dist/scripts/qa-loop-execution-profile-routing-check.js +2 -2
  350. package/dist/scripts/qa-loop-image-path-exposure-check.js +1 -1
  351. package/dist/scripts/qa-loop-image-path-prompt-injection-check.js +1 -1
  352. package/dist/scripts/{sks-1-12-real-execution-check-lib.js → real-execution-check-lib.js} +1 -1
  353. package/dist/scripts/release-affected-selector-check.js +1 -1
  354. package/dist/scripts/release-aggressive-resource-governor-check.js +1 -1
  355. package/dist/scripts/release-cache-glob-hashing-check.js +1 -1
  356. package/dist/scripts/release-cache-input-classifier-check.js +1 -1
  357. package/dist/scripts/release-cache-neutralization-report-check.js +1 -1
  358. package/dist/scripts/release-cache-version-neutral-fixture-check.js +1 -1
  359. package/dist/scripts/release-dynamic-presets-check.js +2 -2
  360. package/dist/scripts/release-full-parallelism-blackbox.js +1 -1
  361. package/dist/scripts/release-gate-batch-runner-check.js +1 -1
  362. package/dist/scripts/release-gate-budget-check.js +1 -1
  363. package/dist/scripts/release-gate-dag-runner-check.js +1 -1
  364. package/dist/scripts/release-latency-slo-check.js +1 -1
  365. package/dist/scripts/release-metadata-check.js +256 -2
  366. package/dist/scripts/release-parallel-speed-budget-check.js +1 -1
  367. package/dist/scripts/release-proof-truth-check.js +1 -1
  368. package/dist/scripts/release-provenance-check.js +4 -2
  369. package/dist/scripts/release-runtime-truth-matrix-check.js +1 -1
  370. package/dist/scripts/research-blueprint-densifier-check.js +1 -1
  371. package/dist/scripts/research-claim-builder-check.js +1 -1
  372. package/dist/scripts/research-complete-package-fixture-check.js +1 -1
  373. package/dist/scripts/research-execution-profile-routing-check.js +2 -2
  374. package/dist/scripts/research-final-reviewer-blackbox.js +1 -1
  375. package/dist/scripts/{sks-3-1-4-directive-check-lib.js → runtime-domain-gate-lib.js} +2 -2
  376. package/dist/scripts/runtime-proof-summary-check.js +1 -1
  377. package/dist/scripts/runtime-script-pack-closure-check.js +7 -1
  378. package/dist/scripts/scheduler-batch-dispatch-check.js +1 -1
  379. package/dist/scripts/scheduler-parallel-proof-consistency-check.js +1 -1
  380. package/dist/scripts/scheduler-utilization-integral-check.js +1 -1
  381. package/dist/scripts/search-visibility-gate-lib.js +1 -1
  382. package/dist/scripts/secret-preservation-check.js +1 -1
  383. package/dist/scripts/seo-geo-geo-disambiguation-check.js +1 -1
  384. package/dist/scripts/seo-geo-skill-rich-content-check.js +1 -1
  385. package/dist/scripts/side-effect-runtime-report-check.js +1 -1
  386. package/dist/scripts/{sks-3-1-8-check-lib.js → skill-fixture-check-lib.js} +1 -1
  387. package/dist/scripts/skill-name-canonicalizer-check.js +1 -1
  388. package/dist/scripts/skills-manifest-continuity-check.js +1 -1
  389. package/dist/scripts/sks-uninstall-regression-check.js +1 -1
  390. package/dist/scripts/sksd-daemon-check.js +1 -1
  391. package/dist/scripts/super-search-provider-interface-check.js +1 -1
  392. package/dist/scripts/triwiki-cache-key-check.js +1 -1
  393. package/dist/scripts/triwiki-proof-bank-blackbox.js +2 -2
  394. package/dist/scripts/triwiki-proof-bank-check.js +1 -1
  395. package/dist/scripts/triwiki-proof-card-check.js +1 -1
  396. package/dist/scripts/type-surface-codex-app-check.js +2 -2
  397. package/dist/scripts/{sks-3-1-5-directive-check-lib.js → typed-routing-gate-lib.js} +2 -2
  398. package/dist/scripts/ultra-router-auto-router-check.js +1 -1
  399. package/dist/scripts/ux-review-extract-wires-real-extractor-check.js +1 -1
  400. package/dist/scripts/ux-review-patch-diff-recheck-check.js +1 -1
  401. package/dist/scripts/ux-review-run-wires-imagegen-check.js +9 -2
  402. package/package.json +5 -7
  403. package/release-gates.v2.json +66 -11
  404. package/runtime-required-scripts.json +138 -14
  405. package/config/bench-baseline.json +0 -7
  406. package/dist/core/codex-app/sks-menubar.js +0 -1
  407. package/dist/core/release/release-closure-contract.js +0 -30
  408. package/dist/core/release/release-closure-helpers.js +0 -293
  409. package/dist/core/release/release-closure-validation.js +0 -284
  410. package/dist/core/release/release-closure.js +0 -163
  411. package/dist/scripts/build-dist.js +0 -124
  412. package/dist/scripts/build-once-runner-check.js +0 -6
  413. package/dist/scripts/canonical-test-runner.js +0 -234
  414. package/dist/scripts/changelog-check.js +0 -45
  415. package/dist/scripts/check-architecture.js +0 -295
  416. package/dist/scripts/check-cli-entrypoint.js +0 -41
  417. package/dist/scripts/check-command-module-budget.js +0 -77
  418. package/dist/scripts/check-feature-quality.js +0 -51
  419. package/dist/scripts/check-legacy-free.js +0 -64
  420. package/dist/scripts/check-pipeline-budget.js +0 -49
  421. package/dist/scripts/check-pipeline-runtime.js +0 -16
  422. package/dist/scripts/check-publish-tag.js +0 -56
  423. package/dist/scripts/check-route-modularity.js +0 -72
  424. package/dist/scripts/codex-0140-capability-check.js +0 -14
  425. package/dist/scripts/codex-0140-feature-probes-check.js +0 -23
  426. package/dist/scripts/codex-permission-profiles-check.js +0 -34
  427. package/dist/scripts/codex-project-config-policy-splitter-check.js +0 -49
  428. package/dist/scripts/competitor-scorecard-check.js +0 -24
  429. package/dist/scripts/core-skill-no-drift-check.js +0 -23
  430. package/dist/scripts/db-route-materialization-check.js +0 -32
  431. package/dist/scripts/doctor-context7-mcp-repair-blackbox.js +0 -15
  432. package/dist/scripts/doctor-fastpath-check.js +0 -25
  433. package/dist/scripts/doctor-fix-production-blackbox.js +0 -35
  434. package/dist/scripts/doctor-idempotence-check.js +0 -6
  435. package/dist/scripts/doctor-ops-semantics-check.js +0 -83
  436. package/dist/scripts/doctor-startup-config-repair-blackbox.js +0 -18
  437. package/dist/scripts/doctor-supabase-mcp-repair-blackbox.js +0 -13
  438. package/dist/scripts/ensure-bin-executable.js +0 -16
  439. package/dist/scripts/fsx-hotpath-check.js +0 -9
  440. package/dist/scripts/high-risk-contracts-check.js +0 -183
  441. package/dist/scripts/hook-latency-quantum-check.js +0 -120
  442. package/dist/scripts/import-graph-budget-check.js +0 -9
  443. package/dist/scripts/mcp-tool-naming-parity-check.js +0 -14
  444. package/dist/scripts/naruto-codex-e2e-check.js +0 -105
  445. package/dist/scripts/naruto-write-e2e-check.js +0 -31
  446. package/dist/scripts/native-capability-postcheck-check.js +0 -16
  447. package/dist/scripts/ops-diagnostics-bundle-check.js +0 -11
  448. package/dist/scripts/parallel-production-smoke-check.js +0 -20
  449. package/dist/scripts/perf-budget-check.js +0 -12
  450. package/dist/scripts/project-skill-dedupe-blackbox.js +0 -62
  451. package/dist/scripts/release-dag-full-coverage-check.js +0 -98
  452. package/dist/scripts/release-dist-freshness-check.js +0 -6
  453. package/dist/scripts/release-file-ownership-check.js +0 -35
  454. package/dist/scripts/release-gate-script-parity-check.js +0 -148
  455. package/dist/scripts/release-macos-menubar-proof.js +0 -167
  456. package/dist/scripts/release-main-push-guard.js +0 -37
  457. package/dist/scripts/release-main-push-receipt.js +0 -43
  458. package/dist/scripts/release-metadata-1-19-check.js +0 -257
  459. package/dist/scripts/release-version-truth-check.js +0 -138
  460. package/dist/scripts/retention-apply-smoke-check.js +0 -19
  461. package/dist/scripts/retention-budget-check.js +0 -6
  462. package/dist/scripts/retention-dry-run-check.js +0 -8
  463. package/dist/scripts/rollback-recovery-smoke-check.js +0 -70
  464. package/dist/scripts/route-intent-regression-check.js +0 -42
  465. package/dist/scripts/runtime-current-terminal-check.js +0 -108
  466. package/dist/scripts/runtime-dist-parity-check.js +0 -76
  467. package/dist/scripts/runtime-no-src-mjs-check.js +0 -30
  468. package/dist/scripts/runtime-ts-rust-boundary-check.js +0 -58
  469. package/dist/scripts/runtime-ts-source-of-truth-check.js +0 -53
  470. package/dist/scripts/secret-preservation-guard-check.js +0 -36
  471. package/dist/scripts/seo-marketing-truthfulness-check.js +0 -98
  472. package/dist/scripts/seo-metadata-sync-check.js +0 -60
  473. package/dist/scripts/sizecheck.js +0 -148
  474. package/dist/scripts/sks-menubar-install-check.js +0 -333
  475. package/dist/scripts/supabase-secret-preservation-blackbox.js +0 -28
  476. package/dist/scripts/super-search-live-smoke-check.js +0 -115
  477. package/dist/scripts/super-search-local-http-smoke-check.js +0 -16
  478. package/dist/scripts/super-search-offline-contract-check.js +0 -43
  479. package/dist/scripts/update-fastpath-check.js +0 -28
  480. package/dist/scripts/update-preserves-supabase-keys-blackbox.js +0 -26
  481. package/dist/scripts/upgrade-migration-matrix-check.js +0 -351
  482. package/dist/scripts/write-build-manifest.js +0 -70
  483. package/dist/scripts/zellij-capability-check.js +0 -13
  484. package/dist/scripts/zellij-developer-controls-check.js +0 -16
  485. package/dist/scripts/zellij-doctor-readiness-check.js +0 -49
  486. package/dist/scripts/zellij-dynamic-pane-lifecycle-check.js +0 -19
  487. package/dist/scripts/zellij-fake-adapter-check.js +0 -31
  488. package/dist/scripts/zellij-first-slot-down-stack-check.js +0 -20
  489. package/dist/scripts/zellij-first-slot-down-stack-real-check.js +0 -348
  490. package/dist/scripts/zellij-homebrew-policy-check.js +0 -3
  491. package/dist/scripts/zellij-initial-main-only-blackbox.js +0 -21
  492. package/dist/scripts/zellij-lane-renderer-check.js +0 -78
  493. package/dist/scripts/zellij-launch-command-truth-check.js +0 -62
  494. package/dist/scripts/zellij-layout-valid-check.js +0 -120
  495. package/dist/scripts/zellij-pane-creation-lock-metrics-check.js +0 -10
  496. package/dist/scripts/zellij-pane-lock-concurrency-blackbox.js +0 -78
  497. package/dist/scripts/zellij-pane-lock-does-not-block-worker-check.js +0 -12
  498. package/dist/scripts/zellij-pane-lock-open-worker-integration-blackbox.js +0 -134
  499. package/dist/scripts/zellij-qa-app-handoff-status-check.js +0 -7
  500. package/dist/scripts/zellij-right-column-geometry-proof.js +0 -158
  501. package/dist/scripts/zellij-right-column-headless-overflow-check.js +0 -20
  502. package/dist/scripts/zellij-right-column-manager-check.js +0 -24
  503. package/dist/scripts/zellij-self-heal-check.js +0 -3
  504. package/dist/scripts/zellij-self-heal-dry-run-check.js +0 -3
  505. package/dist/scripts/zellij-self-heal-status-contract-check.js +0 -3
  506. package/dist/scripts/zellij-self-heal-typed-blackbox.js +0 -3
  507. package/dist/scripts/zellij-slot-column-anchor-check.js +0 -65
  508. package/dist/scripts/zellij-slot-column-anchor-telemetry-check.js +0 -8
  509. package/dist/scripts/zellij-slot-only-ui-check.js +0 -29
  510. package/dist/scripts/zellij-slot-pane-renderer-check.js +0 -149
  511. package/dist/scripts/zellij-slot-pane-stale-detection-check.js +0 -65
  512. package/dist/scripts/zellij-slot-pane-telemetry-renderer-check.js +0 -11
  513. package/dist/scripts/zellij-slot-renderer-proof-semantics-check.js +0 -58
  514. package/dist/scripts/zellij-slot-telemetry-check.js +0 -38
  515. package/dist/scripts/zellij-slot-telemetry-incremental-check.js +0 -46
  516. package/dist/scripts/zellij-slot-telemetry-live-flush-check.js +0 -55
  517. package/dist/scripts/zellij-slot-telemetry-performance-check.js +0 -32
  518. package/dist/scripts/zellij-slot-telemetry-real-blackbox.js +0 -19
  519. package/dist/scripts/zellij-slot-telemetry-renderer-check.js +0 -11
  520. package/dist/scripts/zellij-slot-telemetry-runtime-check.js +0 -23
  521. package/dist/scripts/zellij-spawn-on-demand-layout-check.js +0 -45
  522. package/dist/scripts/zellij-stacked-capability-routing-check.js +0 -9
  523. package/dist/scripts/zellij-stacked-fallback-integration-blackbox.js +0 -78
  524. package/dist/scripts/zellij-stacked-version-matrix-check.js +0 -29
  525. package/dist/scripts/zellij-stacked-version-parser-check.js +0 -19
  526. package/dist/scripts/zellij-ui-design-check.js +0 -92
  527. package/dist/scripts/zellij-update-missing-self-heal-check.js +0 -3
  528. package/dist/scripts/zellij-update-prompt-matrix-check.js +0 -16
  529. package/dist/scripts/zellij-update-prompt-mode-check.js +0 -18
  530. package/dist/scripts/zellij-update-prompt-safety-check.js +0 -8
  531. package/dist/scripts/zellij-worker-pane-manager-check.js +0 -108
  532. package/dist/scripts/zellij-worker-pane-manager-single-owner-check.js +0 -47
  533. package/dist/scripts/zellij-worker-pane-real-ui-blackbox.js +0 -199
  534. /package/dist/scripts/{sks-1-11-gate-lib.js → sks-cli-gate-lib.js} +0 -0
@@ -42,13 +42,13 @@ export async function writeHarnessGuardPolicy(root, opts = {}) {
42
42
  locked: !sourceException,
43
43
  engine_source_exception: sourceException,
44
44
  engine_source_detection: 'package.name=sneakoscope + src/bin/sks.ts + src/core/init.ts + src/core/hooks-runtime.ts',
45
- rule: 'LLM tool calls must not modify installed Sneakoscope harness control files. Use manual terminal maintenance or update SKS itself.',
45
+ rule: 'LLM tool calls must not modify installed Sneakoscope harness control files. Agents must never run `sks doctor --fix`; ask the user to run it in their own terminal when repair is needed.',
46
46
  protected_files: HARNESS_STATIC_FILES,
47
47
  protected_dirs: HARNESS_STATIC_DIRS,
48
48
  runtime_mutable_paths: HARNESS_RUNTIME_MUTABLE,
49
49
  blocked_maintenance_commands: [
50
50
  'sks setup/init/fix-path',
51
- 'sks doctor --fix',
51
+ 'sks doctor --fix (operator-only; agents must ask the user)',
52
52
  'sks context7 setup',
53
53
  'npm remove/uninstall sneakoscope'
54
54
  ],
@@ -103,10 +103,25 @@ export async function harnessGuardStatus(root) {
103
103
  }
104
104
  export async function checkHarnessModification(root, payload = {}, opts = {}) {
105
105
  const policy = await loadHarnessGuardPolicy(root);
106
+ const classification = classifyHarnessPayload(root, payload, policy);
107
+ if ((classification.reasons || []).includes('sks_doctor_fix_blocked')) {
108
+ const decision = {
109
+ action: 'block',
110
+ reasons: ['sks_doctor_fix_blocked'],
111
+ matches: classification.matches,
112
+ command: classification.command,
113
+ tool: classification.toolName
114
+ };
115
+ await appendJsonlBounded(path.join(root, '.sneakoscope', 'state', 'harness-guard.jsonl'), {
116
+ ts: nowIso(),
117
+ decision,
118
+ payload_keys: Object.keys(payload || {}).sort()
119
+ }).catch(() => { });
120
+ return decision;
121
+ }
106
122
  if (!policy.enabled || !policy.locked || policy.engine_source_exception || await isHarnessSourceProject(root)) {
107
123
  return { action: 'allow', reason: 'harness_source_exception_or_unlocked' };
108
124
  }
109
- const classification = classifyHarnessPayload(root, payload, policy);
110
125
  if (classification.block) {
111
126
  const decision = { action: 'block', reasons: classification.reasons, matches: classification.matches, command: classification.command, tool: classification.toolName };
112
127
  await appendJsonlBounded(path.join(root, '.sneakoscope', 'state', 'harness-guard.jsonl'), { ts: nowIso(), decision, payload_keys: Object.keys(payload || {}).sort() }).catch(() => { });
@@ -115,6 +130,9 @@ export async function checkHarnessModification(root, payload = {}, opts = {}) {
115
130
  return { action: 'allow', classification };
116
131
  }
117
132
  export function harnessGuardBlockReason(decision = {}) {
133
+ if ((decision.reasons || []).includes('sks_doctor_fix_blocked')) {
134
+ return 'SKS agents must not run `sks doctor --fix`. Ask the user to run `sks doctor --fix` in their own terminal when repair is needed, then continue after they confirm.';
135
+ }
118
136
  const matches = (decision.matches || []).slice(0, 6).join(', ');
119
137
  return `SKS harness guard blocked this tool call. Installed Sneakoscope harness files are immutable to LLM edits after setup${matches ? `: ${matches}` : ''}. Use manual terminal maintenance or update/reinstall SKS outside the agent. This repository is editable only when it is the Sneakoscope engine source repo.`;
120
138
  }
@@ -106,7 +106,7 @@ export async function authoritativeSksSkillAdmission(root, skillNames) {
106
106
  resolution: null,
107
107
  blocked: {
108
108
  decision: 'block',
109
- reason: 'SKS managed skill resolution failed. Repair the global SKS installation, then retry.',
109
+ reason: 'SKS managed skill resolution failed. Ask the user to run `sks doctor --fix` (do not run it yourself), then retry.',
110
110
  systemMessage: 'SKS: managed skill availability check blocked this turn.'
111
111
  }
112
112
  };
@@ -120,7 +120,7 @@ export async function authoritativeSksSkillAdmission(root, skillNames) {
120
120
  resolution,
121
121
  blocked: {
122
122
  decision: 'block',
123
- reason: `SKS managed skill availability check failed (${details}). Repair the global SKS installation, then retry.`,
123
+ reason: `SKS managed skill availability check failed (${details}). Ask the user to run \`sks doctor --fix\` (do not run it yourself), then retry.`,
124
124
  systemMessage: 'SKS: managed skill availability check blocked this turn.'
125
125
  }
126
126
  };
@@ -1,10 +1,12 @@
1
1
  import path from 'node:path';
2
2
  import fsp from 'node:fs/promises';
3
- import { parseShellEnvValue } from '../codex-lb/codex-lb-env.js';
4
- import { ensureDir, exists, nowIso, projectRoot, readJson, readText, writeJsonAtomic } from '../fsx.js';
3
+ import { ensureDir, exists, nowIso, projectRoot, readJson, writeJsonAtomic } from '../fsx.js';
5
4
  import { sha256File, imageDimensions } from '../wiki-image/image-hash.js';
6
5
  import { detectImagegenCapability } from '../imagegen/imagegen-capability.js';
6
+ import { resolveCodexLbImagegenTarget } from '../imagegen/codex-lb-imagegen-target.js';
7
+ import { CODEX_LB_PROVIDER_IMAGEGEN_EVIDENCE_CLASS, CODEX_LB_PROVIDER_OUTPUT_SOURCE, NON_CODEX_API_FALLBACK_EVIDENCE_CLASS } from '../imagegen/imagegen-evidence.js';
7
8
  import { validateGptImage2Request } from '../imagegen/gpt-image-2-request-validator.js';
9
+ import { parseResponsesSsePayload } from '../responses-stream.js';
8
10
  import { withResponsesRetry } from '../responses-retry-policy.js';
9
11
  import { discoverCodexAppGeneratedImage } from './codex-app-generated-image-discovery.js';
10
12
  import { writeImageArtifactPathContract } from '../image/image-artifact-path-contract.js';
@@ -312,6 +314,12 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
312
314
  const auth = await resolveImagesApiAuth({ ...opts, apiKey, codexLb });
313
315
  const useResponsesImageTool = auth.auth_source === 'CODEX_LB_API_KEY' && Boolean(auth.responses_endpoint);
314
316
  const effectiveEndpoint = useResponsesImageTool ? auth.responses_endpoint : auth.endpoint;
317
+ const responsesModel = String(auth.responses_model || '');
318
+ const codexLbProviderSelected = useResponsesImageTool && (opts.codexLbTarget?.selected === true || codexLb?.selected === true);
319
+ const responsesEvidenceClass = codexLbProviderSelected
320
+ ? CODEX_LB_PROVIDER_IMAGEGEN_EVIDENCE_CLASS
321
+ : NON_CODEX_API_FALLBACK_EVIDENCE_CLASS;
322
+ const responsesOutputSource = codexLbProviderSelected ? CODEX_LB_PROVIDER_OUTPUT_SOURCE : null;
315
323
  const validation = await validateGptImage2Request({
316
324
  provider: 'openai_images_api',
317
325
  endpoint: effectiveEndpoint,
@@ -329,7 +337,7 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
329
337
  endpoint: effectiveEndpoint,
330
338
  auth_source: auth.auth_source,
331
339
  model: 'gpt-image-2',
332
- responses_model: useResponsesImageTool ? responsesImagegenModel(opts) : null,
340
+ responses_model: useResponsesImageTool ? responsesModel : null,
333
341
  source_screen_id: input.source_screen_id,
334
342
  source_image_path: sourcePath,
335
343
  source_screenshot_sha256: sourceSha,
@@ -372,7 +380,7 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
372
380
  await writeJsonAtomic(responseArtifact, blocked);
373
381
  return { ok: false, status: 'blocked', generated_image_path: null, output_id: null, blocker: auth.blocker, provider: 'openai_images_api', request_artifact: requestArtifact, response_artifact: responseArtifact, latency_ms: Date.now() - started };
374
382
  }
375
- if (useResponsesImageTool && !responsesImagegenModel(opts)) {
383
+ if (useResponsesImageTool && !responsesModel) {
376
384
  const blocker = 'imagegen_responses_model_missing';
377
385
  await writeJsonAtomic(responseArtifact, {
378
386
  schema: 'sks.image-ux-gpt-image-2-response.v1',
@@ -396,7 +404,7 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
396
404
  method: 'POST',
397
405
  headers: { authorization: `Bearer ${auth.apiKey}`, 'content-type': 'application/json' },
398
406
  body: JSON.stringify({
399
- model: responsesImagegenModel(opts),
407
+ model: responsesModel,
400
408
  input: [{
401
409
  role: 'user',
402
410
  content: [
@@ -431,6 +439,8 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
431
439
  source_screen_id: input.source_screen_id,
432
440
  provider_surface: 'openai_responses_image_generation',
433
441
  output_id: generated.id || payload?.id || null,
442
+ evidence_class: responsesEvidenceClass,
443
+ output_source: responsesOutputSource,
434
444
  real_generated: true
435
445
  });
436
446
  const imageContract = await writeGeneratedImagePathContract(input, out, 'openai_responses_image_generation').catch(() => null);
@@ -438,16 +448,21 @@ export function createOpenAIImagesApiAdapter(opts = {}) {
438
448
  schema: 'sks.image-ux-gpt-image-2-response.v1',
439
449
  created_at: nowIso(),
440
450
  provider: 'openai_responses_image_generation',
441
- evidence_class: 'non_codex_api_fallback',
451
+ evidence_class: responsesEvidenceClass,
442
452
  model: 'gpt-image-2',
443
- responses_model: responsesImagegenModel(opts),
453
+ responses_model: responsesModel,
454
+ responses_model_source: auth.responses_model_source || null,
444
455
  auth_source: auth.auth_source,
456
+ api_key_source: auth.api_key_source || null,
457
+ codex_lb_provider_selected: codexLbProviderSelected,
445
458
  ok: true,
446
459
  status: 'generated',
447
460
  output_image_path: out,
448
461
  output_image_sha256: meta.sha256,
449
462
  output_sha256: meta.sha256,
450
463
  output_id: meta.output_id,
464
+ output_source: responsesOutputSource,
465
+ image_output_recovered_from_stream: payload?.image_output_recovered_from_stream === true,
451
466
  image_artifact_path_contract: imageContract?.artifact_path || null,
452
467
  dimensions: { width: meta.width, height: meta.height, format: meta.format },
453
468
  latency_ms: Date.now() - started,
@@ -563,15 +578,18 @@ export async function generateGptImage2CalloutReview(input, opts = {}) {
563
578
  return createFakeImagegenAdapter({ ...(opts.fakeAdapter || {}), mockContext: true }).generateCalloutReview(input);
564
579
  }
565
580
  const capability = await detectImagegenCapability(opts.capability || {}).catch(() => null);
581
+ const codexLbTarget = opts.codexLbTarget || await resolveCodexLbImagegenTarget(codexLbTargetInputs(opts.capability)).catch(() => null);
566
582
  const explicitDisableCodexLbFallback = opts.allowCodexLbApiFallback === false || process.env.SKS_IMAGEGEN_ALLOW_CODEX_LB_API_FALLBACK === '0';
567
583
  const allowCodexLbApiFallback = !explicitDisableCodexLbFallback && (opts.allowCodexLbApiFallback === true
568
- || process.env.SKS_IMAGEGEN_ALLOW_CODEX_LB_API_FALLBACK === '1');
584
+ || process.env.SKS_IMAGEGEN_ALLOW_CODEX_LB_API_FALLBACK === '1'
585
+ || codexLbTarget?.selected === true);
569
586
  const allowApiFallback = (opts.allowApiFallback === true
570
587
  || process.env.SKS_IMAGEGEN_ALLOW_API_FALLBACK === '1'
571
588
  || allowCodexLbApiFallback);
572
589
  const openaiOptions = {
573
590
  ...(opts.openai || {}),
574
591
  codexLb: allowCodexLbApiFallback ? opts.openai?.codexLb || capability?.codex_lb || null : null,
592
+ codexLbTarget,
575
593
  allowCodexLbApiFallback
576
594
  };
577
595
  const codexAdapter = createCodexAppImagegenAdapter({
@@ -583,6 +601,16 @@ export async function generateGptImage2CalloutReview(input, opts = {}) {
583
601
  return codexResult;
584
602
  return createOpenAIImagesApiAdapter(openaiOptions).generateCalloutReview(input);
585
603
  }
604
+ function codexLbTargetInputs(source = {}) {
605
+ const inputs = {};
606
+ if (source?.home)
607
+ inputs.home = source.home;
608
+ if (source?.env)
609
+ inputs.env = source.env;
610
+ if (typeof source?.configText === 'string')
611
+ inputs.configText = source.configText;
612
+ return inputs;
613
+ }
586
614
  function imagegenMockContext(opts = {}) {
587
615
  return opts.mockContext === true
588
616
  || opts.testContext === true
@@ -606,6 +634,8 @@ async function resolveImagesApiAuth(opts = {}) {
606
634
  return {
607
635
  apiKey: openAiKey,
608
636
  auth_source: 'OPENAI_API_KEY',
637
+ responses_model: responsesImagegenModel(opts),
638
+ responses_model_source: responsesImagegenModel(opts) ? 'explicit' : null,
609
639
  endpoint: imageEditsEndpoint(opts.baseUrl || 'https://api.openai.com/v1'),
610
640
  responses_endpoint: responsesEndpoint(opts.baseUrl || 'https://api.openai.com/v1'),
611
641
  blocker: null
@@ -616,21 +646,26 @@ async function resolveImagesApiAuth(opts = {}) {
616
646
  return {
617
647
  apiKey: null,
618
648
  auth_source: null,
649
+ responses_model: responsesImagegenModel(opts),
650
+ responses_model_source: null,
619
651
  endpoint: imageEditsEndpoint(opts.baseUrl || 'https://api.openai.com/v1'),
620
652
  responses_endpoint: responsesEndpoint(opts.baseUrl || 'https://api.openai.com/v1'),
621
653
  blocker: 'openai_api_key_missing'
622
654
  };
623
655
  }
624
656
  const envKey = codexLb.env_key || 'CODEX_LB_API_KEY';
625
- const envPath = codexLb.env_path || opts.codexLbEnvPath || '';
626
- const envText = envPath ? await readText(envPath, '').catch(() => '') : '';
627
- const codexLbKey = String(opts.codexLbApiKey || process.env[envKey] || parseShellEnvValue(envText, envKey) || '').trim();
657
+ const target = opts.codexLbTarget || await resolveCodexLbImagegenTarget(codexLbTargetInputs(opts)).catch(() => null);
658
+ const codexLbKey = String(opts.codexLbApiKey || target?.api_key || '').trim();
659
+ const baseUrl = target?.base_url || codexLb.base_url || opts.baseUrl || '';
628
660
  return {
629
661
  apiKey: codexLbKey || null,
630
662
  auth_source: envKey,
631
- endpoint: imageEditsEndpoint(codexLb.base_url || opts.baseUrl || ''),
632
- responses_endpoint: responsesEndpoint(codexLb.base_url || opts.baseUrl || ''),
633
- blocker: codexLbKey ? null : 'codex_lb_api_key_missing'
663
+ api_key_source: target?.api_key_source || null,
664
+ responses_model: responsesImagegenModel(opts) || target?.model || '',
665
+ responses_model_source: responsesImagegenModel(opts) ? 'explicit' : target?.model_source || null,
666
+ endpoint: imageEditsEndpoint(baseUrl),
667
+ responses_endpoint: responsesEndpoint(baseUrl),
668
+ blocker: codexLbKey ? null : target?.blocker || 'codex_lb_api_key_missing'
634
669
  };
635
670
  }
636
671
  function imageEditsEndpoint(baseUrl = '') {
@@ -666,7 +701,7 @@ async function readResponsePayload(response, timeoutMs = 90000) {
666
701
  return JSON.parse(text);
667
702
  }
668
703
  catch {
669
- const sse = parseSsePayload(text);
704
+ const sse = parseResponsesSsePayload(text);
670
705
  if (sse)
671
706
  return sse;
672
707
  return { error: { message: text.slice(0, 2000) } };
@@ -687,47 +722,6 @@ async function textWithTimeout(response, timeoutMs) {
687
722
  clearTimeout(timeout);
688
723
  }
689
724
  }
690
- function parseSsePayload(text) {
691
- const events = [];
692
- for (const line of text.split(/\r?\n/)) {
693
- if (!line.startsWith('data:'))
694
- continue;
695
- const data = line.slice('data:'.length).trim();
696
- if (!data || data === '[DONE]')
697
- continue;
698
- try {
699
- events.push(JSON.parse(data));
700
- }
701
- catch { }
702
- }
703
- const failed = events.find((event) => event?.type === 'response.failed' || event?.response?.status === 'failed');
704
- if (failed) {
705
- return {
706
- object: 'response.sse',
707
- status: 'failed',
708
- error: failed?.response?.error || failed?.error || { message: 'responses_sse_failed' },
709
- events: events.map((event) => event?.type || null)
710
- };
711
- }
712
- const completed = [...events].reverse().find((event) => event?.type === 'response.completed' && event?.response);
713
- if (completed?.response)
714
- return completed.response;
715
- const imageEvent = [...events].reverse().find((event) => /image_generation_call/.test(String(event?.type || '')) && (event?.result || event?.item?.result || event?.b64_json));
716
- if (imageEvent) {
717
- return {
718
- object: 'response.sse',
719
- status: 'completed',
720
- output: [{
721
- id: imageEvent?.item?.id || imageEvent?.id || null,
722
- type: 'image_generation_call',
723
- status: imageEvent?.status || imageEvent?.item?.status || 'completed',
724
- result: imageEvent?.result || imageEvent?.item?.result || imageEvent?.b64_json || null
725
- }],
726
- events: events.map((event) => event?.type || null)
727
- };
728
- }
729
- return events.length ? { object: 'response.sse', status: 'unknown', events: events.map((event) => event?.type || null) } : null;
730
- }
731
725
  function findResponsesImageGenerationOutput(payload) {
732
726
  for (const output of Array.isArray(payload?.output) ? payload.output : []) {
733
727
  if (String(output?.type || '') === 'image_generation_call') {
@@ -805,6 +799,8 @@ function payloadRetryCode(payload) {
805
799
  return 'ETIMEDOUT';
806
800
  if (status === 'failed' && /server|overload|unavailable|rate/.test(haystack))
807
801
  return 'server_error';
802
+ if (status === 'unknown' && String(payload?.object || '') === 'response.sse')
803
+ return 'server_error';
808
804
  return null;
809
805
  }
810
806
  function imagegenQualityParam(opts = {}) {
@@ -2,6 +2,7 @@ import path from 'node:path';
2
2
  import { codexSchemaPath, runCodexExecResumeWithOutputSchema, structuredOutputBlocker } from '../codex-exec-output-schema.js';
3
3
  import { readJson } from '../fsx.js';
4
4
  import { runOpenAIStructuredOutput } from '../structured-output-adapter.js';
5
+ import { resolveCodexLbImagegenTarget } from '../imagegen/codex-lb-imagegen-target.js';
5
6
  import { generatedImageMetadata } from './imagegen-adapter.js';
6
7
  import { buildIssueLedgerFromGeneratedCallouts } from './callout-extraction.js';
7
8
  export async function extractRealCallouts(input) {
@@ -73,11 +74,15 @@ export async function extractRealCallouts(input) {
73
74
  });
74
75
  }
75
76
  else {
77
+ const codexLb = await resolveCodexLbImagegenTarget({}).catch(() => null);
78
+ const useCodexLb = codexLb?.selected === true && codexLb.blocker === null;
76
79
  providerResult = await runOpenAIStructuredOutput({
77
80
  prompt,
78
81
  schemaName: 'image_ux_issue_ledger',
79
82
  jsonSchema,
80
- imagePath: path.resolve(input.root, input.generatedImagePath)
83
+ imagePath: path.resolve(input.root, input.generatedImagePath),
84
+ ...(useCodexLb ? { baseUrl: codexLb.base_url, apiKey: codexLb.api_key } : {}),
85
+ ...(useCodexLb && codexLb.model ? { model: codexLb.model } : {})
81
86
  });
82
87
  }
83
88
  if (!providerResult.ok || !providerResult.parsed_json) {
@@ -14,6 +14,7 @@ import { runImageUxFixLoop } from './image-ux-review/fix-loop.js';
14
14
  import { buildRecapturePlan } from './image-ux-review/recapture.js';
15
15
  import { addVisualAnchor, ingestImage } from './wiki-image/image-voxel-ledger.js';
16
16
  import { validateFinalHonestModeReport } from './artifact-schemas.js';
17
+ import { imagegenEvidenceClassBlockers, isFullImagegenOutputSource } from './imagegen/imagegen-evidence.js';
17
18
  export const IMAGE_UX_REVIEW_GATE_ARTIFACT = 'image-ux-review-gate.json';
18
19
  export const IMAGE_UX_REVIEW_POLICY_ARTIFACT = 'image-ux-review-policy.json';
19
20
  export const IMAGE_UX_REVIEW_SCREEN_INVENTORY_ARTIFACT = 'image-ux-screen-inventory.json';
@@ -869,11 +870,8 @@ function generatedImageEvidenceBlockers(image = {}, evidence = {}) {
869
870
  const evidenceClass = String(image.evidence_class || '');
870
871
  const outputSource = String(image.output_source || '');
871
872
  const outputSha = String(image.output_sha256 || image.output_image_sha256 || '');
872
- if (!evidenceClass)
873
- blockers.push('generated_review_image_evidence_class_missing');
874
- else if (evidenceClass !== 'codex_app_imagegen')
875
- blockers.push(`generated_review_image_evidence_class_not_codex_app:${evidenceClass}`);
876
- if (outputSource && !['manual_attach', 'auto_discovered_generated_images'].includes(outputSource))
873
+ blockers.push(...imagegenEvidenceClassBlockers('generated_review_image', evidenceClass));
874
+ if (outputSource && !isFullImagegenOutputSource(outputSource))
877
875
  blockers.push(`generated_review_image_output_source_invalid:${outputSource}`);
878
876
  if (!outputSha)
879
877
  blockers.push('generated_review_image_output_sha256_missing');
@@ -0,0 +1,70 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { readJson, readText } from '../fsx.js';
4
+ import { loadCodexLbEnv } from '../codex-lb/codex-lb-env.js';
5
+ export const CODEX_LB_IMAGEGEN_TARGET_SCHEMA = 'sks.codex-lb-imagegen-target.v1';
6
+ export async function resolveCodexLbImagegenTarget(opts = {}) {
7
+ const env = opts.env || process.env;
8
+ const home = opts.home || env.HOME || os.homedir();
9
+ const configText = typeof opts.configText === 'string'
10
+ ? opts.configText
11
+ : await readText(path.join(home, '.codex', 'config.toml'), '').catch(() => '');
12
+ const selected = topLevelTomlString(configText, 'model_provider') === 'codex-lb';
13
+ const loaded = await loadCodexLbEnv({ home, processEnv: env }).catch(() => null);
14
+ const catalogModels = await readCatalogModels(configText, home);
15
+ const explicit = String(opts.explicitModel || env.SKS_IMAGEGEN_RESPONSES_MODEL || env.OPENAI_MODEL || '').trim();
16
+ const configuredModel = topLevelTomlString(configText, 'model');
17
+ const { model, model_source } = explicit
18
+ ? { model: explicit, model_source: 'explicit' }
19
+ : catalogModels.includes(configuredModel)
20
+ ? { model: configuredModel, model_source: 'configured_model_in_catalog' }
21
+ : catalogModels.length
22
+ ? { model: catalogModels[0], model_source: 'catalog_default' }
23
+ : { model: null, model_source: null };
24
+ return {
25
+ schema: CODEX_LB_IMAGEGEN_TARGET_SCHEMA,
26
+ selected,
27
+ base_url: loaded?.base_url || null,
28
+ api_key: loaded?.secret_api_key || null,
29
+ api_key_source: loaded?.api_key?.source || null,
30
+ model,
31
+ model_source,
32
+ catalog_models: catalogModels,
33
+ blocker: codexLbImagegenBlocker({ selected, loaded, model })
34
+ };
35
+ }
36
+ function codexLbImagegenBlocker(state) {
37
+ if (!state.selected)
38
+ return 'codex_lb_not_selected';
39
+ if (!state.loaded?.base_url)
40
+ return 'codex_lb_base_url_missing';
41
+ if (!state.loaded?.secret_api_key)
42
+ return state.loaded?.missing?.includes('CODEX_LB_CREDENTIAL_BINDING')
43
+ ? 'codex_lb_credential_binding_invalid'
44
+ : 'codex_lb_api_key_missing';
45
+ if (!state.model)
46
+ return 'codex_lb_imagegen_model_unresolved';
47
+ return null;
48
+ }
49
+ async function readCatalogModels(configText, home) {
50
+ const configured = topLevelTomlString(configText, 'model_catalog_json');
51
+ const candidates = [
52
+ configured ? path.resolve(configured.replace(/^~(?=\/|$)/, home)) : '',
53
+ path.join(home, '.codex', 'sks-codex-lb-tool-catalog.json')
54
+ ].filter(Boolean);
55
+ for (const file of candidates) {
56
+ const payload = await readJson(file, null).catch(() => null);
57
+ const rows = Array.isArray(payload?.models) ? payload.models : Array.isArray(payload?.data) ? payload.data : [];
58
+ const slugs = rows
59
+ .map((row) => String(row?.slug || row?.id || row?.model || '').trim())
60
+ .filter(Boolean);
61
+ if (slugs.length)
62
+ return [...new Set(slugs)];
63
+ }
64
+ return [];
65
+ }
66
+ function topLevelTomlString(text, key) {
67
+ const topLevel = String(text || '').split(/\n\s*\[/)[0] || '';
68
+ const re = new RegExp(`(^|\\n)\\s*${key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*=\\s*"([^"]*)"\\s*(?:#.*)?(?=\\n|$)`);
69
+ return topLevel.match(re)?.[2] || '';
70
+ }
@@ -1,9 +1,10 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
- import { codexLbEnvPath, parseShellEnvValue } from '../codex-lb/codex-lb-env.js';
3
+ import { codexLbEnvPath, loadCodexLbEnv, parseShellEnvValue } from '../codex-lb/codex-lb-env.js';
4
4
  import { nowIso, readText, runProcess, which } from '../fsx.js';
5
5
  import { redactSecrets, redactString } from '../secret-redaction.js';
6
6
  import { evaluateImagegenAuthReadiness } from './imagegen-auth-readiness.js';
7
+ import { escapeRegExp } from '../text/regex.js';
7
8
  export async function detectImagegenCapability(opts = {}) {
8
9
  const codexBin = opts.codexBin || await which('codex').catch(() => null);
9
10
  const codexApp = await detectCodexAppImagegen(codexBin, opts);
@@ -107,13 +108,15 @@ async function detectCodexLbImagegenAuth(opts = {}, env = process.env) {
107
108
  const envKey = tomlString(block, 'env_key');
108
109
  const baseUrl = tomlString(block, 'base_url') || String(env.CODEX_LB_BASE_URL || '').trim();
109
110
  const envPath = opts.codexLbEnvPath || codexLbEnvPath(home);
110
- const envText = typeof opts.codexLbEnvText === 'string'
111
- ? opts.codexLbEnvText
112
- : await readText(envPath, '').catch(() => '');
113
- const keyFromEnv = envKey ? String(env[envKey] || '').trim() : '';
114
- const keyFromFile = envKey ? parseShellEnvValue(envText, envKey) : '';
115
- const apiKeyPresent = Boolean(opts.codexLbApiKey || keyFromEnv || keyFromFile);
116
- const apiKeySource = opts.codexLbApiKey ? 'option' : keyFromEnv ? 'process.env' : keyFromFile ? 'env-file' : null;
111
+ const injectedEnvText = typeof opts.codexLbEnvText === 'string' ? opts.codexLbEnvText : null;
112
+ const keyFromInjectedFile = injectedEnvText !== null && envKey ? parseShellEnvValue(injectedEnvText, envKey) : '';
113
+ const loaded = injectedEnvText === null
114
+ ? await loadCodexLbEnv({ home, processEnv: env, envPath }).catch(() => null)
115
+ : null;
116
+ const apiKeyPresent = Boolean(opts.codexLbApiKey || keyFromInjectedFile || loaded?.secret_api_key);
117
+ const apiKeySource = opts.codexLbApiKey
118
+ ? 'option'
119
+ : keyFromInjectedFile ? 'env-file' : loaded?.api_key?.source || null;
117
120
  const blocker = codexLbAuthBlocker({
118
121
  selected,
119
122
  providerConfigured,
@@ -276,6 +279,3 @@ function tomlBoolean(text = '', key = '') {
276
279
  return null;
277
280
  return raw.toLowerCase() === 'true';
278
281
  }
279
- function escapeRegExp(value) {
280
- return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
281
- }
@@ -0,0 +1,32 @@
1
+ export const CODEX_APP_IMAGEGEN_EVIDENCE_CLASS = 'codex_app_imagegen';
2
+ export const CODEX_LB_PROVIDER_IMAGEGEN_EVIDENCE_CLASS = 'codex_lb_provider_imagegen';
3
+ export const NON_CODEX_API_FALLBACK_EVIDENCE_CLASS = 'non_codex_api_fallback';
4
+ export const MOCK_FIXTURE_EVIDENCE_CLASS = 'mock_fixture';
5
+ export const FULL_IMAGEGEN_EVIDENCE_CLASSES = Object.freeze([
6
+ CODEX_APP_IMAGEGEN_EVIDENCE_CLASS,
7
+ CODEX_LB_PROVIDER_IMAGEGEN_EVIDENCE_CLASS
8
+ ]);
9
+ export const CODEX_LB_PROVIDER_OUTPUT_SOURCE = 'codex_lb_provider_responses';
10
+ export const FULL_IMAGEGEN_OUTPUT_SOURCES = Object.freeze([
11
+ 'manual_attach',
12
+ 'auto_discovered_generated_images',
13
+ CODEX_LB_PROVIDER_OUTPUT_SOURCE
14
+ ]);
15
+ export function isFullImagegenEvidenceClass(value) {
16
+ return FULL_IMAGEGEN_EVIDENCE_CLASSES.includes(String(value || ''));
17
+ }
18
+ export function isFullImagegenOutputSource(value) {
19
+ return FULL_IMAGEGEN_OUTPUT_SOURCES.includes(String(value || ''));
20
+ }
21
+ export function imagegenEvidenceClassBlockers(prefix, value) {
22
+ const evidenceClass = String(value || '');
23
+ if (!evidenceClass)
24
+ return [`${prefix}_evidence_class_missing`];
25
+ if (isFullImagegenEvidenceClass(evidenceClass))
26
+ return [];
27
+ return [
28
+ ...(evidenceClass === MOCK_FIXTURE_EVIDENCE_CLASS ? [`${prefix}_mock_fixture_not_full_evidence`] : []),
29
+ ...(evidenceClass === NON_CODEX_API_FALLBACK_EVIDENCE_CLASS ? [`${prefix}_non_codex_api_fallback_not_full_evidence`] : []),
30
+ `${prefix}_evidence_class_not_codex_app:${evidenceClass}`
31
+ ];
32
+ }
@@ -11,9 +11,10 @@ import { installOfficialSubagentAgentConfigs } from '../subagents/official-subag
11
11
  import { reconcileRetiredAgentRoleResidue } from '../agents/agent-role-config.js';
12
12
  import { ensureConfinedDirectory, inspectConfinedPath, moveConfinedPath, publicPathError, removeConfinedDirectoryIfEmpty, removeManagedPathVerified, uniqueConfinedPath } from '../managed-path-safety.js';
13
13
  import { collectNestedProjectRoots } from '../doctor/current-project-guidance-nested.js';
14
- import { coreEngineeringDirectiveReferenceText } from '../lean-engineering-policy.js';
14
+ import { coreEngineeringDirectiveReferenceText, engineeringSanityPolicyText } from '../lean-engineering-policy.js';
15
15
  import { AWESOME_DESIGN_MD_REFERENCE, CODEX_APP_IMAGE_GENERATION_DOC_URL, CODEX_COMPUTER_USE_ONLY_POLICY, CODEX_IMAGEGEN_EVIDENCE_SOURCE, CODEX_IMAGEGEN_REQUIRED_POLICY, CODEX_WEB_VERIFICATION_POLICY, DEFAULT_CODEX_APP_PLUGINS, DESIGN_SYSTEM_SSOT, DOLLAR_COMMANDS, DOLLAR_SKILL_NAMES, FROM_CHAT_IMG_CHECKLIST_ARTIFACT, FROM_CHAT_IMG_COVERAGE_ARTIFACT, FROM_CHAT_IMG_QA_LOOP_ARTIFACT, FROM_CHAT_IMG_TEMP_TRIWIKI_ARTIFACT, FROM_CHAT_IMG_TEMP_TRIWIKI_SESSIONS, GETDESIGN_REFERENCE, IMAGEGEN_SOCIAL_SOURCE_POLICY, LEGACY_DOLLAR_SKILL_NAMES, OPENAI_CHATGPT_IMAGES_2_DOC_URL, OPENAI_GPT_IMAGE_2_MODEL_DOC_URL, OPENAI_IMAGE_GENERATION_DOC_URL, PPT_CONDITIONAL_SKILL_ALLOWLIST, PPT_PIPELINE_MCP_ALLOWLIST, PPT_PIPELINE_SKILL_ALLOWLIST, RECOMMENDED_SKILLS, RESERVED_CODEX_PLUGIN_SKILL_NAMES, SOLUTION_SCOUT_SKILL_NAME, chatCaptureIntakeText, context7ConfigToml, getdesignReferencePolicyText, imageUxReviewPipelinePolicyText, outcomeRubricPolicyText, pptPipelineAllowlistPolicyText, productDesignPluginPolicyText, speedLanePolicyText, stackCurrentDocsPolicyText, triwikiContextTrackingText, triwikiStagePolicyText } from '../routes.js';
16
16
  import { prefixKnownSksDollarReferences, sksPrefixedSkillName } from '../routes/dollar-prefix.js';
17
+ import { escapeRegExp } from '../text/regex.js';
17
18
  const SKS_SKILL_MANIFEST_FILE = '.sks-generated.json';
18
19
  const PACKAGED_SKILLS_MANIFEST_SCHEMA = 'sks.skills-manifest.v1';
19
20
  const GENERATED_PRUNE_POLICY = 'remove_previous_sks_generated_paths_absent_from_current_manifest';
@@ -36,6 +37,8 @@ export const REMOVED_SKS_SKILL_NAMES = [
36
37
  'qaloop',
37
38
  'wiki-refresh',
38
39
  'wikirefresh',
40
+ 'research-discovery',
41
+ 'sks-research-discovery',
39
42
  'ralph',
40
43
  'ralph-supervisor',
41
44
  'ralph-resolver'
@@ -62,7 +65,6 @@ const LEGACY_SKS_SUPPORT_SKILL_NAMES = [
62
65
  'prompt-pipeline',
63
66
  'reasoning-router',
64
67
  'reflection',
65
- 'research-discovery',
66
68
  'solution-scout',
67
69
  'turbo-context-pack'
68
70
  ];
@@ -109,16 +111,16 @@ async function installOfficialSkills(root) {
109
111
  'release-review': `---\nname: release-review\ndescription: Official Codex subagent release review route for $Release-Review.\n---\n\nUse only when the user invokes $Release-Review or asks for a release-readiness review. Run it through \`sks naruto run \"$Release-Review release audit\" --agents <n> --read-only --json\` or the current Codex parent session. The parent owns decomposition, waits for every official worker/expert thread, integrates one structured outcome per thread, and records subagent-plan.json, subagent-events.jsonl, subagent-parent-summary.json, and subagent-evidence.json. No alternate Release-Review runtime is supported. Finish with release-readiness verification and Honest Mode.\n`,
110
112
  'commit': `---\nname: commit\ndescription: Simple git-only route for $Commit requests that stage current changes and create one commit without the full SKS pipeline.\n---\n\nUse only when the user invokes $Commit or explicitly asks to commit the current repository changes without pushing. Keep this route lightweight: inspect git status and the relevant diff summary, avoid Naruto/pipeline/TriWiki route work unless separately requested, stage the intended current changes, and create one git commit. The commit message must summarize the actual work and include exactly one trailer: Co-authored-by: Codex <noreply@openai.com>. Do not push. If there are no changes, report that no commit was created. Finish with a concise result and a one-line Honest Mode covering the commit hash and any unverified items.\n`,
111
113
  'commit-and-push': `---\nname: commit-and-push\ndescription: Simple git-only route for $Commit-And-Push requests that stage current changes, create one commit, and push without the full SKS pipeline.\n---\n\nUse only when the user invokes $Commit-And-Push or explicitly asks to commit and push the current repository changes. Keep this route lightweight: inspect git status and the relevant diff summary, avoid Naruto/pipeline/TriWiki route work unless separately requested, stage the intended current changes, create one git commit, then push the current branch. The commit message must summarize the actual work and include exactly one trailer: Co-authored-by: Codex <noreply@openai.com>. If there are no changes, do not create an empty commit unless the user explicitly asks for one. Finish with a concise result and a one-line Honest Mode covering the commit hash, pushed branch, and any unverified items.\n`,
112
- 'research': `---\nname: research\ndescription: Dollar-command route for $Research or $research frontier discovery workflows.\n---\n\nUse when the user invokes $Research/$research or asks for research, hypotheses, new mechanisms, falsification, or testable predictions. Prefer sks research prepare and sks research run. Research is not an implementation route: do not edit repository source, docs, package metadata, generated skills, or harness files; write only route-local mission artifacts under .sneakoscope/missions/<mission-id>/. First run layered Super Search across current papers, primary/official sources, standards, public discourse, practitioner evidence, background sources, and explicit counterevidence; only verified-content source rows may support real-run reviewer claims. Then run exactly three independent official Codex subagent threads using the project custom agent research_reviewer with GPT-5.6 Sol Max: Einstein Agent (first principles, explanation, experiments), von Neumann Agent (formal systems, algorithms, strategy, scaling), and Skeptic Agent (counterevidence, base rates, replication). These are composite persona-inspired lenses, not impersonations. Do not launch a custom debate scheduler, worker pool, or synthetic model fanout. Each reviewer must return the structured adversarial outcome, one literal "Eureka!" idea, source ids, falsifiers, cheap probes, and zero unresolved objections before approval. If any reviewer requests revision, revise the manuscript and run a fresh three-thread review cycle within the bounded cycle cap; convergence requires unanimous approval and trustworthy parent outcomes for all threads. agent-ledger.json and debate-ledger.json are compatibility projections from official reviewer outcomes, not independent runtime proof. Record research-source-skill.md, source-ledger.json, claim-evidence-matrix.json, novelty-ledger.json, falsification-ledger.json, research-report.md, the dated research paper, research-adversarial-review.json, research-revision-ledger.json, research-adversarial-convergence.json, genius-opinion-summary.md, research-honest-mode.json, and research-gate.json. Context7 is required only when the topic depends on current package/API/framework docs. Do not use --mock except for selftests; if live source execution is unavailable, record a blocker and keep the gate unpassed. Do not use for ordinary code edits.\n`,
114
+ 'research': `---\nname: research\ndescription: Dollar-command route for $Research or $research frontier discovery workflows.\n---\n\nUse when the user invokes $Research/$research or asks for research, hypotheses, new mechanisms, falsification, or testable predictions. Prefer sks research prepare and sks research run. Research is not an implementation route: do not edit repository source, docs, package metadata, generated skills, or harness files; write only route-local mission artifacts under .sneakoscope/missions/<mission-id>/. Frame the research criteria and map assumptions before retrieval. First run layered Super Search across current papers, primary/official sources, standards, public discourse, practitioner evidence, background sources, and explicit counterevidence; only verified-content source rows may support real-run reviewer claims. Then run exactly three independent official Codex subagent threads using the project custom agent research_reviewer with GPT-5.6 Sol Max: Einstein Agent (first principles, explanation, experiments), von Neumann Agent (formal systems, algorithms, strategy, scaling), and Skeptic Agent (counterevidence, base rates, replication). These are composite persona-inspired lenses, not impersonations. Do not launch a custom debate scheduler, worker pool, or synthetic model fanout. Each reviewer must return the structured adversarial outcome, one literal "Eureka!" idea, source ids, falsifiers, cheap probes, and zero unresolved objections before approval. If any reviewer requests revision, revise the manuscript and run a fresh three-thread review cycle within the bounded cycle cap; convergence requires unanimous approval and trustworthy parent outcomes for all threads. agent-ledger.json and debate-ledger.json are compatibility projections from official reviewer outcomes, not independent runtime proof. Record research-source-skill.md, source-ledger.json, claim-evidence-matrix.json, novelty-ledger.json, falsification-ledger.json, research-report.md, the dated research paper, research-adversarial-review.json, research-revision-ledger.json, research-adversarial-convergence.json, genius-opinion-summary.md, research-honest-mode.json, and research-gate.json. Context7 is required only when the topic depends on current package/API/framework docs. Do not use --mock except for selftests; if live source execution is unavailable, record a blocker and keep the gate unpassed. Do not overclaim genius, novelty, breakthrough, publication acceptance, or experimental support beyond the recorded evidence. Do not use for ordinary code edits.\n`,
113
115
  'autoresearch': `---\nname: autoresearch\ndescription: Dollar-command route for $AutoResearch or $autoresearch iterative experiment loops.\n---\n\nUse for $AutoResearch, iterative improvement, ranking, workflow, benchmark, or experiments. Define program, hypothesis, experiment, metric, keep/discard, falsification, next step, and Honest Mode. Do not become the parent identity for SEO/GEO; $SEO-GEO-OPTIMIZER may call research as a child stage for query, market, or competitor discovery while keeping the parent mission, gate, and Completion Proof on $SEO-GEO-OPTIMIZER.\n`,
114
- 'db': `---\nname: db\ndescription: Dollar-command route for $DB or $db database and Supabase safety checks.\n---\n\nUse when the user invokes $DB/$db or the task touches SQL, Supabase, Postgres, migrations, Prisma, Drizzle, Knex, MCP database tools, or production data. The $DB route automatically materializes db-safety-scan.json and db-review.json from the internal DB safety engine; inspect those artifacts and current source/docs evidence directly. Keep analysis read-only by default. Destructive database operations remain forbidden; explicitly authorized SQL-plane work uses sks mad-sks plan|sql|apply-migration under an active scoped permission mission.\n`,
116
+ 'db': `---\nname: db\ndescription: Dollar-command route for $DB or $db database and Supabase safety checks.\n---\n\nUse when the user invokes $DB/$db or the task touches SQL, Supabase, Postgres, migrations, Prisma, Drizzle, Knex, MCP database tools, or production data. The route automatically materializes db-safety-scan.json and db-review.json plus db-access-candidates.json, db-access-review.json, code-structure-report.json, and engineering-sanity-review.json; there is no public CLI database subcommand. Inspect existing DB entry points and real callers first, then bind db-access-review.json to the generated candidate scan. Reuse the canonical adapter/query helper and prove one owned pool/client lifecycle, bounded acquire/release/shutdown/reconnect behavior, N+1/repeated-I/O review, and transaction/rollback/error propagation/idempotency/post-commit invariants for sensitive, payment, ledger, or multi-step mutations. Outside MAD-SKS, never mutate a live database: if a migration is needed, finish with exactly one mission-local manual-migration.sql containing active forward SQL and a complete rollback section that stays commented out, record its SHA-256, and tell the user to apply it manually and run rollback separately only if needed. When $MAD-SKS is explicitly combined with $DB, route directly to the bound capability-v2 SQL-plane MCP instead of generating a manual file; use \`sks mad-sks plan|sql|apply-migration\` for the explicit SQL-plane lifecycle and require independent read-back, capability close, and read-only restoration.\n`,
115
117
  'mad-sks': `---\nname: mad-sks\ndescription: Explicit high-risk authorization modifier plus SQL-plane executor for $MAD-SKS.\n---\n\nUse only when the user explicitly invokes $MAD-SKS, top-level sks --mad, or \`sks mad-sks plan|run|apply|sql|apply-migration|status|close|rollback-apply\`. MAD-SKS is the single high-risk route for scoped permission widening and bound SQL-plane execution. It can be combined with another route, such as $MAD-SKS $Naruto or $DB ... $MAD-SKS; in that case the other command remains the primary workflow and MAD-SKS is the temporary permission grant or SQL-plane executor. The widened permission applies only while the active mission gate is open, must be deactivated when the task ends, and can open approved scopes such as target-project file writes, shell commands, package installs, local service control, network operations, browser/Computer Use workflows, generated assets, file permissions, migrations, Supabase MCP database writes, column/schema cleanup, direct execute SQL, and normal targeted DB writes.\n\nSQL-plane policy:\n${canonicalMadSksSqlPlanePolicy}\n\nCatastrophic SQL boundary: TRUNCATE, all-row UPDATE/DELETE, table/schema/database DROP, and equivalent reset operations are allowed only through the SQL-plane executor and only when the user's prompt or CLI SQL statement literally names that operation. Other MAD-SKS executors, including db-write, keep those catastrophic categories blocked. Whole database/schema/table removal outside SQL-plane, dangerous project/branch management, credential exfiltration, persistent security weakening, destructive delete without explicit confirmation, and unrequested fallback implementation remain blocked. Do not carry MAD-SKS permission into later prompts or routes. The permission profile source is centralized in src/core/permission-gates.ts and emitted as dist/core/permission-gates.js so skill/hook/MCP-style gates share one decision function.\n`,
116
118
  'gx': `---\nname: gx\ndescription: Dollar-command route for $GX or $gx deterministic GX visual context cartridges.\n---\n\nUse when the user invokes $GX/$gx or asks for architecture/context visualization through SKS. Prefer sks gx init, render, validate, drift, and snapshot. vgraph.json remains the source of truth.\n`,
117
119
  'help': `---\nname: help\ndescription: Dollar-command route for $Help or $help explaining installed SKS commands and workflows.\n---\n\nUse when the user invokes $Help/$help or asks what commands exist. Prefer concise output from sks commands, sks usage <topic>, sks quickstart, sks aliases, and sks codex-app.\n`,
118
- 'prompt-pipeline': `---\nname: prompt-pipeline\ndescription: Default SKS prompt routing for execution requests; Answer and DFix remain lightweight.\n---\n\nClassify only the route and the constraints that change execution. Answer handles real information requests; DFix handles tiny copy/config/docs/labels/spacing/translation/mechanical edits; general code-changing work uses Naruto with Codex official subagents. Preserve the literal user request; TriWiki may enrich it but never replace an explicit requirement. ${coreEngineeringDirectiveReferenceText()} For code work, identify the requested outcome, actual code/data flow, exact write scope, acceptance criteria, and the smallest meaningful verification. Load route-specific Design, PPT, image, browser, research, DB, release, or Context7 rules only when that route or external contract requires them. Materialize pipeline-plan.json with route, scopes, verification, and blockers, then finish the requested work instead of stopping at the plan.\n`,
120
+ 'prompt-pipeline': `---\nname: prompt-pipeline\ndescription: Default SKS prompt routing for execution requests; Answer and DFix remain lightweight.\n---\n\nClassify only the route and the constraints that change execution. Answer handles real information requests; DFix handles tiny copy/config/docs/labels/spacing/translation/mechanical edits; general code-changing work uses Naruto with Codex official subagents. Preserve the literal user request; TriWiki may enrich it but never replace an explicit requirement. ${coreEngineeringDirectiveReferenceText()} ${engineeringSanityPolicyText()} For code work, identify the requested outcome, actual code/data flow, exact write scope, acceptance criteria, and the smallest meaningful verification. Load route-specific Design, PPT, image, browser, research, DB, release, or Context7 rules only when that route or external contract requires them. Materialize pipeline-plan.json with route, scopes, verification, and blockers, then finish the requested work instead of stopping at the plan.\n`,
119
121
  [SOLUTION_SCOUT_SKILL_NAME]: `---\nname: ${SOLUTION_SCOUT_SKILL_NAME}\ndescription: Optional source scout for fixes that materially depend on external precedent.\n---\n\nUse only when the user asks for similar cases or when a package, API, platform, or externally documented behavior makes outside precedent materially useful. Search with the concrete symptom and current stack, prefer primary sources, and keep the local code path authoritative. Do not add this step to ordinary local bugfixes. If external evidence is unavailable, record that gap instead of inventing a workaround.\n`,
120
122
  'reasoning-router': `---\nname: reasoning-router\ndescription: Temporary SKS reasoning-effort routing for every command and pipeline route.\n---\n\nmedium: simple copy/color/discovery/setup/mechanical edits. high: logic, safety, architecture, DB, orchestration, refactor, multi-file work. xhigh: research, AutoResearch, falsification, benchmarks, SEO/GEO, open-ended discovery, and From-Chat-IMG image work-order analysis. Routing is temporary; return to default after the gate. Inspect with sks reasoning and sks pipeline status.\n`,
121
- 'pipeline-runner': `---\nname: pipeline-runner\ndescription: Execute SKS routes with bounded state, evidence, reflection, and Honest Mode.\n---\n\nEvery $ command selects a route. Use current.json, mission artifacts, and pipeline-plan.json as bounded execution state; load only the selected route skill. ${coreEngineeringDirectiveReferenceText()} Codex native /goal is the only persisted goal owner. Use official Codex subagents only when the route requires independent slices, keep parent-owned integration, use bounded TriWiki context, fetch current external docs only when relevant, record real blockers, refresh and validate evidence, run reflection for full routes, and finish with a completion summary plus Honest Mode.\n`,
123
+ 'pipeline-runner': `---\nname: pipeline-runner\ndescription: Execute SKS routes with bounded state, evidence, reflection, and Honest Mode.\n---\n\nEvery $ command selects a route. Use current.json, mission artifacts, and pipeline-plan.json as bounded execution state; load only the selected route skill. ${coreEngineeringDirectiveReferenceText()} ${engineeringSanityPolicyText()} Codex native /goal is the only persisted goal owner. Use official Codex subagents only when the route requires independent slices, keep parent-owned integration, use bounded TriWiki context, fetch current external docs only when relevant, record real blockers, refresh and validate evidence, run reflection for full routes, and finish with a completion summary plus Honest Mode.\n`,
122
124
  'context7-docs': `---\nname: context7-docs\ndescription: Enforce Context7 MCP documentation evidence for SKS routes that depend on external libraries, frameworks, APIs, MCPs, package managers, DB SDKs, or generated docs.\n---\n\nWhen required, resolve-library-id, then query-docs for the resolved id. Legacy get-library-docs evidence is accepted. Prefer sks context7 tools/resolve/docs/evidence and finish only after both evidence stages exist. Check setup with sks context7 check.\n`,
123
125
  'super-search': `---\nname: super-search\ndescription: Dollar-command route for $Super-Search provider-independent source intelligence.\n---\n\nUse when the user invokes $Super-Search or asks for Super-Search source intelligence, source acquisition, X-search-style collection, URL acquisition, source normalization, claim ledgers, or citation proof. Prefer \`sks super-search doctor --json\` for readiness and \`sks super-search run "<query>" --mode balanced --json\` for provider-independent source proof; use \`sks super-search x "<query>" --json\` for X-search intent and \`sks super-search fetch "<url>" --json\` for URL acquisition. Context7 is required only when the query depends on current package/API/framework/MCP/generated documentation behavior. Provider-specific credentials are optional and must not be required for route readiness. Evidence/artifacts remain under \`.sneakoscope/missions/<super-search-* or route mission>/super-search/\`: intent.json, axes.json, query-variants.json, provider-plan.json, source-ledger.json, lead-ledger.json, claim-ledger.json, attempt-ledger.json, synthesis.md, super-search-proof.json, super-search-gate.json, and super-search-result.json. Do not turn weak discovery into supported claims; finish with an Honest Mode summary of verified sources, blockers, and unverified external coverage.\n`,
124
126
  'search-visibility-core': `---\nname: search-visibility-core\ndescription: Shared kernel for seo-geo-optimizer audit, plan, explicit apply, rollback, verification, gates, and Completion Proof.\n---\n\nPurpose: keep Search Engine Optimization and Generative Engine Optimization on one typed search-visibility kernel instead of duplicate implementations. Use when $SEO-GEO-OPTIMIZER or \`sks seo-geo-optimizer\` is selected. Workflow: doctor detects package/static/Next evidence; audit writes source-backed inventory and findings; plan compiles safe mutation operations; apply requires explicit \`--apply\`; verify separates source, build, HTTP, browser, production, and measured outcome; rollback only reverses mission-owned operations. Safety: default read-only, never overwrite unmanaged robots.txt, sitemap, llms.txt, metadata, or structured data; do not hard-code customer routes; do not invent prices, reviews, availability, rankings, traffic, or AI citation outcomes. Evidence/artifacts: search-visibility/intake.json, adapter-detection.json, site-inventory.json, route-graph.json, robots-policy.json, structured-data-ledger.json, mutation-plan.json, mutation-journal.jsonl, rollback-manifest.json, verification-report.json, route gate, and completion-proof.json. Failure/recovery: unsupported frameworks stay audit/plan-only; missing production/browser/Search Console evidence remains unverified, not fabricated. CLI entrypoint: \`sks seo-geo-optimizer ... --mode seo|geo\`.\n`,
@@ -133,7 +135,6 @@ async function installOfficialSkills(root) {
133
135
  'gx-visual-read': `---\nname: gx-visual-read\ndescription: Read a Sneakoscope Codex deterministic visual sheet and produce context notes.\n---\n\nExtract nodes, edges, invariants, tests, risks, uncertainties, and RGBA anchors from source/render/snapshot. Do not infer hidden nodes.\n`,
134
136
  'gx-visual-validate': `---\nname: gx-visual-validate\ndescription: Validate render metadata against vgraph.json and beta.json.\n---\n\nRun sks gx validate and drift; fail stale or incomplete hashes, nodes, edges, invariants, or anchors.\n`,
135
137
  'turbo-context-pack': `---\nname: turbo-context-pack\ndescription: Build ultra-low-token context packet with Q4 bits, Q3 tags, top-K claims, and minimal evidence.\n---\n\nDefault to Q4/Q3 plus TriWiki RGBA anchors and attention.use_first. Add Q2/Q1 only when needed or when attention.hydrate_first says source hydration is required. Keep id, hash, path, and coordinate tuple for hydration.\n`,
136
- 'research-discovery': `---\nname: research-discovery\ndescription: Run SKS Research Mode for frontier-style research, hypotheses, novelty ledgers, falsification, and experiments.\n---\n\nFrame criteria, map assumptions, and run layered Super Search before synthesis. Use exactly three independent official research_reviewer threads on GPT-5.6 Sol Max: Einstein Agent for first-principles explanation and experiments, von Neumann Agent for formal systems/algorithms/strategy, and Skeptic Agent for counterevidence/base rates/replication. Treat them as composite persona-inspired lenses, never impersonations. Require structured source-bound outcomes, one literal "Eureka!" idea per reviewer, falsifiers, cheap probes, and unanimous zero-objection approval. Revise and rerun a fresh three-thread cycle when challenged; do not use the removed custom debate scheduler. Keep agent/debate ledgers as compatibility projections only and do not overclaim genius, novelty, breakthrough, or publication acceptance.\n`,
137
138
  'performance-evaluator': `---\nname: performance-evaluator\ndescription: Evaluate SKS performance, evidence-backed token usage, serialized-size proxies, accuracy-proxy, context-compression, or workflow improvements.\n---\n\nUse sks eval run/compare before claims. Treat serialized_size_bytes as a deterministic non-token proxy. Claim token savings only when actual baseline and candidate token counts include an evidence source; otherwise report token savings as not measured. Report accuracy_delta/proxy, required_recall, support, and meaningful_improvement without substituting proxy size for token evidence.\n`,
138
139
  'image-ux-review': imageUxReviewSkill('image-ux-review'),
139
140
  'ux-review': imageUxReviewSkill('ux-review'),
@@ -1191,7 +1192,7 @@ async function writeSkillMetadata(root, dir, name) {
1191
1192
  const policyName = String(name || '').replace(/^sks-/, '');
1192
1193
  const effort = ['computer-use-fast', 'cu'].includes(policyName)
1193
1194
  ? 'low'
1194
- : ['research', 'autoresearch', 'research-discovery', 'autoresearch-loop', 'from-chat-img'].includes(policyName)
1195
+ : ['research', 'autoresearch', 'autoresearch-loop', 'from-chat-img'].includes(policyName)
1195
1196
  ? 'xhigh'
1196
1197
  : (['dfix', 'sks', 'help'].includes(policyName) ? 'medium' : 'high');
1197
1198
  await ensureConfinedDirectory(root, path.join(dir, 'agents'));
@@ -1291,9 +1292,6 @@ function isGeneratedSksLegacySkill(text, name) {
1291
1292
  return MANAGED_SKILL_MARKER_RE.test(text)
1292
1293
  || /Sneakoscope generated|Fallback Codex App picker alias|Codex App picker alias for|Dollar-command route generated by SKS|Deprecated \$?(?:Team|MAD-DB|Swarm|ShadowClone|Kagebunshin) compatibility alias|Codex App pipeline activation:/i.test(text);
1293
1294
  }
1294
- function escapeRegExp(value) {
1295
- return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1296
- }
1297
1295
  async function removeDirIfEmpty(dir) {
1298
1296
  try {
1299
1297
  const entries = await fsp.readdir(dir);