@trac3er/oh-my-god 2.0.3 → 2.0.5

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 (259) hide show
  1. package/.agents/skills/omg/AGENTS.fragment.md +5 -0
  2. package/.agents/skills/omg/algorithms/SKILL.md +11 -0
  3. package/.agents/skills/omg/algorithms/openai.yaml +11 -0
  4. package/.agents/skills/omg/api-twin/SKILL.md +11 -0
  5. package/.agents/skills/omg/api-twin/openai.yaml +12 -0
  6. package/.agents/skills/omg/codex-mcp.toml +4 -0
  7. package/.agents/skills/omg/control-plane/SKILL.md +11 -0
  8. package/.agents/skills/omg/control-plane/openai.yaml +14 -0
  9. package/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  10. package/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  11. package/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  12. package/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  13. package/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  14. package/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  15. package/.agents/skills/omg/health/SKILL.md +11 -0
  16. package/.agents/skills/omg/health/openai.yaml +11 -0
  17. package/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  18. package/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  19. package/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  20. package/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  21. package/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  22. package/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  23. package/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  24. package/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  25. package/.agents/skills/omg/preflight/SKILL.md +11 -0
  26. package/.agents/skills/omg/preflight/openai.yaml +12 -0
  27. package/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  28. package/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  29. package/.agents/skills/omg/robotics/SKILL.md +11 -0
  30. package/.agents/skills/omg/robotics/openai.yaml +11 -0
  31. package/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  32. package/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  33. package/.agents/skills/omg/security-check/SKILL.md +11 -0
  34. package/.agents/skills/omg/security-check/openai.yaml +13 -0
  35. package/.agents/skills/omg/tracebank/SKILL.md +11 -0
  36. package/.agents/skills/omg/tracebank/openai.yaml +12 -0
  37. package/.agents/skills/omg/vision/SKILL.md +11 -0
  38. package/.agents/skills/omg/vision/openai.yaml +11 -0
  39. package/.claude-plugin/marketplace.json +3 -3
  40. package/.claude-plugin/plugin.json +1 -1
  41. package/.claude-plugin/scripts/uninstall.sh +2 -2
  42. package/.mcp.json +20 -4
  43. package/CHANGELOG.md +10 -0
  44. package/OMG-setup.sh +9 -3
  45. package/OMG_COMPAT_CONTRACT.md +92 -0
  46. package/README.md +24 -4
  47. package/SECURITY.md +6 -0
  48. package/commands/OMG:api-twin.md +22 -0
  49. package/commands/OMG:preflight.md +26 -0
  50. package/commands/OMG:security-check.md +28 -0
  51. package/commands/__init__.py +1 -0
  52. package/control_plane/__init__.py +2 -0
  53. package/control_plane/openapi.yaml +228 -0
  54. package/control_plane/server.py +123 -0
  55. package/control_plane/service.py +185 -0
  56. package/dist/enterprise/bundle/.agents/skills/omg/AGENTS.fragment.md +5 -0
  57. package/dist/enterprise/bundle/.agents/skills/omg/algorithms/SKILL.md +11 -0
  58. package/dist/enterprise/bundle/.agents/skills/omg/algorithms/openai.yaml +11 -0
  59. package/dist/enterprise/bundle/.agents/skills/omg/api-twin/SKILL.md +11 -0
  60. package/dist/enterprise/bundle/.agents/skills/omg/api-twin/openai.yaml +12 -0
  61. package/dist/enterprise/bundle/.agents/skills/omg/codex-mcp.toml +4 -0
  62. package/dist/enterprise/bundle/.agents/skills/omg/control-plane/SKILL.md +11 -0
  63. package/dist/enterprise/bundle/.agents/skills/omg/control-plane/openai.yaml +14 -0
  64. package/dist/enterprise/bundle/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  65. package/dist/enterprise/bundle/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  66. package/dist/enterprise/bundle/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  67. package/dist/enterprise/bundle/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  68. package/dist/enterprise/bundle/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  69. package/dist/enterprise/bundle/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  70. package/dist/enterprise/bundle/.agents/skills/omg/health/SKILL.md +11 -0
  71. package/dist/enterprise/bundle/.agents/skills/omg/health/openai.yaml +11 -0
  72. package/dist/enterprise/bundle/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  73. package/dist/enterprise/bundle/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  74. package/dist/enterprise/bundle/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  75. package/dist/enterprise/bundle/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  76. package/dist/enterprise/bundle/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  77. package/dist/enterprise/bundle/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  78. package/dist/enterprise/bundle/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  79. package/dist/enterprise/bundle/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  80. package/dist/enterprise/bundle/.agents/skills/omg/preflight/SKILL.md +11 -0
  81. package/dist/enterprise/bundle/.agents/skills/omg/preflight/openai.yaml +12 -0
  82. package/dist/enterprise/bundle/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  83. package/dist/enterprise/bundle/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  84. package/dist/enterprise/bundle/.agents/skills/omg/robotics/SKILL.md +11 -0
  85. package/dist/enterprise/bundle/.agents/skills/omg/robotics/openai.yaml +11 -0
  86. package/dist/enterprise/bundle/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  87. package/dist/enterprise/bundle/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  88. package/dist/enterprise/bundle/.agents/skills/omg/security-check/SKILL.md +11 -0
  89. package/dist/enterprise/bundle/.agents/skills/omg/security-check/openai.yaml +13 -0
  90. package/dist/enterprise/bundle/.agents/skills/omg/tracebank/SKILL.md +11 -0
  91. package/dist/enterprise/bundle/.agents/skills/omg/tracebank/openai.yaml +12 -0
  92. package/dist/enterprise/bundle/.agents/skills/omg/vision/SKILL.md +11 -0
  93. package/dist/enterprise/bundle/.agents/skills/omg/vision/openai.yaml +11 -0
  94. package/dist/enterprise/bundle/.claude-plugin/marketplace.json +36 -0
  95. package/dist/enterprise/bundle/.claude-plugin/plugin.json +23 -0
  96. package/dist/enterprise/bundle/.mcp.json +40 -0
  97. package/dist/enterprise/bundle/OMG_COMPAT_CONTRACT.md +92 -0
  98. package/dist/enterprise/bundle/registry/bundles/algorithms.yaml +45 -0
  99. package/dist/enterprise/bundle/registry/bundles/api-twin.yaml +48 -0
  100. package/dist/enterprise/bundle/registry/bundles/control-plane.yaml +61 -0
  101. package/dist/enterprise/bundle/registry/bundles/data-lineage.yaml +47 -0
  102. package/dist/enterprise/bundle/registry/bundles/delta-classifier.yaml +47 -0
  103. package/dist/enterprise/bundle/registry/bundles/eval-gate.yaml +47 -0
  104. package/dist/enterprise/bundle/registry/bundles/health.yaml +45 -0
  105. package/dist/enterprise/bundle/registry/bundles/hook-governor.yaml +97 -0
  106. package/dist/enterprise/bundle/registry/bundles/incident-replay.yaml +47 -0
  107. package/dist/enterprise/bundle/registry/bundles/lsp-pack.yaml +48 -0
  108. package/dist/enterprise/bundle/registry/bundles/mcp-fabric.yaml +53 -0
  109. package/dist/enterprise/bundle/registry/bundles/preflight.yaml +48 -0
  110. package/dist/enterprise/bundle/registry/bundles/remote-supervisor.yaml +49 -0
  111. package/dist/enterprise/bundle/registry/bundles/robotics.yaml +45 -0
  112. package/dist/enterprise/bundle/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  113. package/dist/enterprise/bundle/registry/bundles/security-check.yaml +50 -0
  114. package/dist/enterprise/bundle/registry/bundles/tracebank.yaml +47 -0
  115. package/dist/enterprise/bundle/registry/bundles/vision.yaml +45 -0
  116. package/dist/enterprise/bundle/registry/omg-capability.schema.json +80 -0
  117. package/dist/enterprise/bundle/settings.json +381 -0
  118. package/dist/enterprise/manifest.json +255 -0
  119. package/dist/public/bundle/.agents/skills/omg/AGENTS.fragment.md +5 -0
  120. package/dist/public/bundle/.agents/skills/omg/algorithms/SKILL.md +11 -0
  121. package/dist/public/bundle/.agents/skills/omg/algorithms/openai.yaml +11 -0
  122. package/dist/public/bundle/.agents/skills/omg/api-twin/SKILL.md +11 -0
  123. package/dist/public/bundle/.agents/skills/omg/api-twin/openai.yaml +12 -0
  124. package/dist/public/bundle/.agents/skills/omg/codex-mcp.toml +4 -0
  125. package/dist/public/bundle/.agents/skills/omg/control-plane/SKILL.md +11 -0
  126. package/dist/public/bundle/.agents/skills/omg/control-plane/openai.yaml +14 -0
  127. package/dist/public/bundle/.agents/skills/omg/data-lineage/SKILL.md +11 -0
  128. package/dist/public/bundle/.agents/skills/omg/data-lineage/openai.yaml +12 -0
  129. package/dist/public/bundle/.agents/skills/omg/delta-classifier/SKILL.md +11 -0
  130. package/dist/public/bundle/.agents/skills/omg/delta-classifier/openai.yaml +12 -0
  131. package/dist/public/bundle/.agents/skills/omg/eval-gate/SKILL.md +11 -0
  132. package/dist/public/bundle/.agents/skills/omg/eval-gate/openai.yaml +12 -0
  133. package/dist/public/bundle/.agents/skills/omg/health/SKILL.md +11 -0
  134. package/dist/public/bundle/.agents/skills/omg/health/openai.yaml +11 -0
  135. package/dist/public/bundle/.agents/skills/omg/hook-governor/SKILL.md +11 -0
  136. package/dist/public/bundle/.agents/skills/omg/hook-governor/openai.yaml +11 -0
  137. package/dist/public/bundle/.agents/skills/omg/incident-replay/SKILL.md +11 -0
  138. package/dist/public/bundle/.agents/skills/omg/incident-replay/openai.yaml +12 -0
  139. package/dist/public/bundle/.agents/skills/omg/lsp-pack/SKILL.md +11 -0
  140. package/dist/public/bundle/.agents/skills/omg/lsp-pack/openai.yaml +11 -0
  141. package/dist/public/bundle/.agents/skills/omg/mcp-fabric/SKILL.md +11 -0
  142. package/dist/public/bundle/.agents/skills/omg/mcp-fabric/openai.yaml +13 -0
  143. package/dist/public/bundle/.agents/skills/omg/preflight/SKILL.md +11 -0
  144. package/dist/public/bundle/.agents/skills/omg/preflight/openai.yaml +12 -0
  145. package/dist/public/bundle/.agents/skills/omg/remote-supervisor/SKILL.md +11 -0
  146. package/dist/public/bundle/.agents/skills/omg/remote-supervisor/openai.yaml +12 -0
  147. package/dist/public/bundle/.agents/skills/omg/robotics/SKILL.md +11 -0
  148. package/dist/public/bundle/.agents/skills/omg/robotics/openai.yaml +11 -0
  149. package/dist/public/bundle/.agents/skills/omg/secure-worktree-pipeline/SKILL.md +11 -0
  150. package/dist/public/bundle/.agents/skills/omg/secure-worktree-pipeline/openai.yaml +12 -0
  151. package/dist/public/bundle/.agents/skills/omg/security-check/SKILL.md +11 -0
  152. package/dist/public/bundle/.agents/skills/omg/security-check/openai.yaml +13 -0
  153. package/dist/public/bundle/.agents/skills/omg/tracebank/SKILL.md +11 -0
  154. package/dist/public/bundle/.agents/skills/omg/tracebank/openai.yaml +12 -0
  155. package/dist/public/bundle/.agents/skills/omg/vision/SKILL.md +11 -0
  156. package/dist/public/bundle/.agents/skills/omg/vision/openai.yaml +11 -0
  157. package/dist/public/bundle/.claude-plugin/marketplace.json +36 -0
  158. package/dist/public/bundle/.claude-plugin/plugin.json +23 -0
  159. package/dist/public/bundle/.mcp.json +40 -0
  160. package/dist/public/bundle/OMG_COMPAT_CONTRACT.md +92 -0
  161. package/dist/public/bundle/registry/bundles/algorithms.yaml +45 -0
  162. package/dist/public/bundle/registry/bundles/api-twin.yaml +48 -0
  163. package/dist/public/bundle/registry/bundles/control-plane.yaml +61 -0
  164. package/dist/public/bundle/registry/bundles/data-lineage.yaml +47 -0
  165. package/dist/public/bundle/registry/bundles/delta-classifier.yaml +47 -0
  166. package/dist/public/bundle/registry/bundles/eval-gate.yaml +47 -0
  167. package/dist/public/bundle/registry/bundles/health.yaml +45 -0
  168. package/dist/public/bundle/registry/bundles/hook-governor.yaml +97 -0
  169. package/dist/public/bundle/registry/bundles/incident-replay.yaml +47 -0
  170. package/dist/public/bundle/registry/bundles/lsp-pack.yaml +48 -0
  171. package/dist/public/bundle/registry/bundles/mcp-fabric.yaml +53 -0
  172. package/dist/public/bundle/registry/bundles/preflight.yaml +48 -0
  173. package/dist/public/bundle/registry/bundles/remote-supervisor.yaml +49 -0
  174. package/dist/public/bundle/registry/bundles/robotics.yaml +45 -0
  175. package/dist/public/bundle/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  176. package/dist/public/bundle/registry/bundles/security-check.yaml +50 -0
  177. package/dist/public/bundle/registry/bundles/tracebank.yaml +47 -0
  178. package/dist/public/bundle/registry/bundles/vision.yaml +45 -0
  179. package/dist/public/bundle/registry/omg-capability.schema.json +80 -0
  180. package/dist/public/bundle/settings.json +379 -0
  181. package/dist/public/manifest.json +255 -0
  182. package/docs/assets/omg-hud.svg +32 -0
  183. package/docs/install/claude-code.md +31 -0
  184. package/docs/install/codex.md +29 -0
  185. package/docs/migration/native-adoption.md +57 -0
  186. package/docs/proof.md +55 -0
  187. package/docs/release-checklist.md +38 -0
  188. package/docs/transcripts/crazy.md +17 -0
  189. package/docs/transcripts/setup.md +25 -0
  190. package/hooks/policy_engine.py +38 -7
  191. package/hooks/post-write.py +1 -1
  192. package/hooks/prompt-enhancer.py +1 -1
  193. package/hooks/security_validators.py +75 -0
  194. package/hooks/setup_wizard.py +43 -8
  195. package/hooks/shadow_manager.py +28 -2
  196. package/package.json +1 -1
  197. package/plugins/README.md +3 -1
  198. package/plugins/__init__.py +1 -0
  199. package/plugins/advanced/commands/OMG:deep-plan.md +1 -1
  200. package/plugins/advanced/commands/OMG:security-review.md +10 -113
  201. package/plugins/advanced/commands/OMG:ship.md +1 -1
  202. package/plugins/advanced/plugin.json +1 -10
  203. package/plugins/core/plugin.json +25 -2
  204. package/pyproject.toml +38 -2
  205. package/registry/__init__.py +1 -0
  206. package/registry/bundles/algorithms.yaml +45 -0
  207. package/registry/bundles/api-twin.yaml +48 -0
  208. package/registry/bundles/control-plane.yaml +61 -0
  209. package/registry/bundles/data-lineage.yaml +47 -0
  210. package/registry/bundles/delta-classifier.yaml +47 -0
  211. package/registry/bundles/eval-gate.yaml +47 -0
  212. package/registry/bundles/health.yaml +45 -0
  213. package/registry/bundles/hook-governor.yaml +97 -0
  214. package/registry/bundles/incident-replay.yaml +47 -0
  215. package/registry/bundles/lsp-pack.yaml +48 -0
  216. package/registry/bundles/mcp-fabric.yaml +53 -0
  217. package/registry/bundles/preflight.yaml +48 -0
  218. package/registry/bundles/remote-supervisor.yaml +49 -0
  219. package/registry/bundles/robotics.yaml +45 -0
  220. package/registry/bundles/secure-worktree-pipeline.yaml +54 -0
  221. package/registry/bundles/security-check.yaml +50 -0
  222. package/registry/bundles/tracebank.yaml +47 -0
  223. package/registry/bundles/vision.yaml +45 -0
  224. package/registry/omg-capability.schema.json +80 -0
  225. package/registry/verify_artifact.py +90 -0
  226. package/runtime/adapters/claude.py +3 -0
  227. package/runtime/adapters/gpt.py +3 -0
  228. package/runtime/adapters/local.py +3 -0
  229. package/runtime/adoption.py +1 -1
  230. package/runtime/api_twin.py +179 -0
  231. package/runtime/asset_loader.py +62 -0
  232. package/runtime/compat.py +24 -3
  233. package/runtime/contract_compiler.py +847 -0
  234. package/runtime/data_lineage.py +73 -0
  235. package/runtime/delta_classifier.py +81 -0
  236. package/runtime/domain_packs.py +46 -0
  237. package/runtime/ecosystem.py +1 -1
  238. package/runtime/eval_gate.py +50 -0
  239. package/runtime/guide_assert.py +45 -0
  240. package/runtime/incident_replay.py +47 -0
  241. package/runtime/mcp_config_writers.py +147 -30
  242. package/runtime/mcp_memory_server.py +1 -1
  243. package/runtime/omg_compat_contract_snapshot.json +9 -8
  244. package/runtime/omg_contract_snapshot.json +9 -8
  245. package/runtime/omg_mcp_server.py +207 -0
  246. package/runtime/preflight.py +73 -0
  247. package/runtime/providers/codex_provider.py +2 -12
  248. package/runtime/providers/gemini_provider.py +2 -21
  249. package/runtime/providers/kimi_provider.py +2 -21
  250. package/runtime/remote_supervisor.py +64 -0
  251. package/runtime/runtime_profile.py +61 -0
  252. package/runtime/security_check.py +464 -0
  253. package/runtime/subagent_dispatcher.py +117 -10
  254. package/runtime/team_router.py +3 -1
  255. package/runtime/tracebank.py +53 -0
  256. package/runtime/untrusted_content.py +102 -0
  257. package/scripts/omg.py +360 -2
  258. package/settings.json +81 -18
  259. package/tools/python_repl.py +33 -3
@@ -0,0 +1,207 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from collections.abc import AsyncIterator
5
+ from contextlib import asynccontextmanager
6
+ from dataclasses import dataclass
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ from runtime.asset_loader import resolve_asset
11
+
12
+ _MCP_IMPORT_ERROR: ModuleNotFoundError | None = None
13
+
14
+ try:
15
+ from fastmcp import FastMCP
16
+ except ModuleNotFoundError as exc:
17
+ _MCP_IMPORT_ERROR = exc
18
+
19
+ def _passthrough_decorator(*_args: Any, **_kwargs: Any):
20
+ def decorator(func: Any) -> Any:
21
+ return func
22
+
23
+ return decorator
24
+
25
+ @dataclass
26
+ class _StubPrompt:
27
+ name: str
28
+ description: str
29
+ handler: Any
30
+
31
+ @dataclass
32
+ class _StubResource:
33
+ uri: str
34
+ name: str
35
+ description: str
36
+ mime_type: str
37
+ handler: Any
38
+
39
+ class FastMCP: # type: ignore[override]
40
+ def __init__(self, *_args: Any, **_kwargs: Any) -> None:
41
+ self._import_error = _MCP_IMPORT_ERROR
42
+ self.instructions = str(_kwargs.get("instructions", ""))
43
+ self._prompts: list[_StubPrompt] = []
44
+ self._resources: dict[str, _StubResource] = {}
45
+
46
+ def tool(self, *_args: Any, **_kwargs: Any):
47
+ return _passthrough_decorator(*_args, **_kwargs)
48
+
49
+ def prompt(self, *, name: str, description: str = ""):
50
+ def decorator(func: Any) -> Any:
51
+ self._prompts.append(_StubPrompt(name=name, description=description, handler=func))
52
+ return func
53
+
54
+ return decorator
55
+
56
+ def resource(
57
+ self,
58
+ uri: str,
59
+ *,
60
+ name: str = "",
61
+ description: str = "",
62
+ mime_type: str = "text/plain",
63
+ ):
64
+ def decorator(func: Any) -> Any:
65
+ self._resources[uri] = _StubResource(
66
+ uri=uri,
67
+ name=name,
68
+ description=description,
69
+ mime_type=mime_type,
70
+ handler=func,
71
+ )
72
+ return func
73
+
74
+ return decorator
75
+
76
+ async def list_prompts(self) -> list[_StubPrompt]:
77
+ return list(self._prompts)
78
+
79
+ async def list_resources(self) -> list[_StubResource]:
80
+ return list(self._resources.values())
81
+
82
+ async def read_resource(self, uri: str) -> Any:
83
+ resource = self._resources[str(uri)]
84
+ return resource.handler()
85
+
86
+ def run(self, *_args: Any, **_kwargs: Any) -> None:
87
+ raise RuntimeError("fastmcp is required to run the OMG MCP server") from self._import_error
88
+
89
+ FastMCP.__module__ = "fastmcp"
90
+
91
+ from control_plane.service import ControlPlaneService
92
+
93
+
94
+ MCP_INSTRUCTIONS = (
95
+ "OMG production control plane MCP. Prefer omg-control prompts and resources for "
96
+ "contract, release-readiness, and governance context before using direct tools."
97
+ )
98
+
99
+
100
+ def _root_dir() -> Path:
101
+ return Path(__file__).resolve().parents[1]
102
+
103
+
104
+ @asynccontextmanager
105
+ async def lifespan(_: object) -> AsyncIterator[None]:
106
+ yield
107
+
108
+
109
+ mcp = FastMCP("OMG Control MCP", lifespan=lifespan, instructions=MCP_INSTRUCTIONS)
110
+
111
+
112
+ def _service() -> ControlPlaneService:
113
+ return ControlPlaneService(project_dir=os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd()))
114
+
115
+
116
+ def _read_repo_text(rel_path: str) -> str:
117
+ return resolve_asset(rel_path).read_text(encoding="utf-8")
118
+
119
+
120
+ @mcp.tool()
121
+ def omg_policy_evaluate(tool: str, input: dict[str, Any]) -> dict[str, Any]:
122
+ _status, payload = _service().policy_evaluate({"tool": tool, "input": input})
123
+ return payload
124
+
125
+
126
+ @mcp.tool()
127
+ def omg_trust_review(file_path: str, old_config: dict[str, Any], new_config: dict[str, Any]) -> dict[str, Any]:
128
+ _status, payload = _service().trust_review({"file_path": file_path, "old_config": old_config, "new_config": new_config})
129
+ return payload
130
+
131
+
132
+ @mcp.tool()
133
+ def omg_evidence_ingest(
134
+ run_id: str,
135
+ tests: list[dict[str, Any]],
136
+ security_scans: list[dict[str, Any]],
137
+ diff_summary: dict[str, Any],
138
+ reproducibility: dict[str, Any],
139
+ unresolved_risks: list[str],
140
+ provenance: list[dict[str, Any]] | None = None,
141
+ trust_scores: dict[str, Any] | None = None,
142
+ api_twin: dict[str, Any] | None = None,
143
+ ) -> dict[str, Any]:
144
+ _status, payload = _service().evidence_ingest(
145
+ {
146
+ "run_id": run_id,
147
+ "tests": tests,
148
+ "security_scans": security_scans,
149
+ "diff_summary": diff_summary,
150
+ "reproducibility": reproducibility,
151
+ "unresolved_risks": unresolved_risks,
152
+ "provenance": provenance or [],
153
+ "trust_scores": trust_scores or {},
154
+ "api_twin": api_twin or {},
155
+ }
156
+ )
157
+ return payload
158
+
159
+
160
+ @mcp.tool()
161
+ def omg_runtime_dispatch(runtime: str, idea: dict[str, Any]) -> dict[str, Any]:
162
+ _status, payload = _service().runtime_dispatch({"runtime": runtime, "idea": idea})
163
+ return payload
164
+
165
+
166
+ @mcp.tool()
167
+ def omg_security_check(scope: str = ".", include_live_enrichment: bool = False) -> dict[str, Any]:
168
+ _status, payload = _service().security_check({"scope": scope, "include_live_enrichment": include_live_enrichment})
169
+ return payload
170
+
171
+
172
+ @mcp.tool()
173
+ def omg_guide_assert(candidate: str, rules: dict[str, Any]) -> dict[str, Any]:
174
+ _status, payload = _service().guide_assert({"candidate": candidate, "rules": rules})
175
+ return payload
176
+
177
+
178
+ @mcp.prompt(name="omg_contract_summary", description="Summarize the OMG production contract and generated host outputs")
179
+ def omg_contract_summary(channel: str = "public") -> str:
180
+ return (
181
+ "Summarize the OMG production control plane contract for channel "
182
+ f"`{channel}`. Include execution_contract, host_compilation_rules, "
183
+ "MCP resources, prompts, and release-readiness expectations."
184
+ )
185
+
186
+
187
+ @mcp.resource("resource://omg/contract", name="omg_contract", description="Canonical OMG production contract document", mime_type="text/markdown")
188
+ def omg_contract_resource() -> str:
189
+ return _read_repo_text("OMG_COMPAT_CONTRACT.md")
190
+
191
+
192
+ @mcp.resource(
193
+ "resource://omg/release-checklist",
194
+ name="omg_release_checklist",
195
+ description="Public release checklist for OMG",
196
+ mime_type="text/markdown",
197
+ )
198
+ def omg_release_checklist_resource() -> str:
199
+ return _read_repo_text("docs/release-checklist.md")
200
+
201
+
202
+ def run_server() -> None:
203
+ mcp.run(transport="stdio")
204
+
205
+
206
+ if __name__ == "__main__":
207
+ run_server()
@@ -0,0 +1,73 @@
1
+ """Structured preflight routing for OMG."""
2
+ from __future__ import annotations
3
+
4
+ from runtime.delta_classifier import classify_project_changes
5
+ from runtime.tracebank import record_trace
6
+ from typing import Any
7
+
8
+
9
+ def run_preflight(project_dir: str, *, goal: str) -> dict[str, Any]:
10
+ lowered = goal.lower()
11
+ task_class = "implementation"
12
+ risk_class = "medium"
13
+ route = "teams"
14
+ delta = classify_project_changes(project_dir, goal=goal)
15
+ categories = set(delta["categories"])
16
+ domain_packs = [category for category in delta["categories"] if category in {"robotics", "vision", "algorithms", "health"}]
17
+
18
+ if categories & {"auth", "payment", "health", "compliance"}:
19
+ task_class = "security"
20
+ risk_class = "high"
21
+ route = "security-check"
22
+ elif categories & {"api"} or any(token in lowered for token in ("openapi", "swagger", "postman", "contract", "fixture", "replay")):
23
+ task_class = "contract"
24
+ route = "api-twin"
25
+ elif any(token in lowered for token in ("auth", "secret", "security", "token", "injection")):
26
+ task_class = "security"
27
+ risk_class = "high"
28
+ route = "security-check"
29
+ elif any(token in lowered for token in ("full stack", "frontend and backend", "dashboard", "orchestrate")):
30
+ task_class = "orchestration"
31
+ risk_class = "high"
32
+ route = "crazy"
33
+
34
+ trace = record_trace(
35
+ project_dir,
36
+ trace_type="preflight",
37
+ route=route,
38
+ status="ok",
39
+ plan={"goal": goal, "delta_categories": delta["categories"]},
40
+ verify={"risk_class": risk_class},
41
+ )
42
+
43
+ return {
44
+ "schema": "PreflightResult",
45
+ "project_dir": project_dir,
46
+ "goal": goal,
47
+ "task_class": task_class,
48
+ "risk_class": risk_class,
49
+ "route": route,
50
+ "required_tools": _required_tools(route),
51
+ "required_mcps": ["omg-control"] if route in {"security-check", "api-twin", "crazy"} else [],
52
+ "missing_constraints": [],
53
+ "evidence_plan": _evidence_plan(route),
54
+ "delta_classification": delta,
55
+ "domain_packs": domain_packs,
56
+ "trace": {"trace_id": trace["trace_id"], "path": trace["path"]},
57
+ }
58
+
59
+
60
+ def _required_tools(route: str) -> list[str]:
61
+ return {
62
+ "security-check": ["security"],
63
+ "api-twin": ["api-twin"],
64
+ "crazy": ["teams", "ccg"],
65
+ }.get(route, ["teams"])
66
+
67
+
68
+ def _evidence_plan(route: str) -> list[str]:
69
+ return {
70
+ "security-check": ["security findings", "provenance"],
71
+ "api-twin": ["fixture fidelity", "live verification"],
72
+ "crazy": ["verification output", "evidence pack"],
73
+ }.get(route, ["verification output"])
@@ -11,6 +11,7 @@ import uuid
11
11
  from typing import Any
12
12
 
13
13
  from runtime.cli_provider import CLIProvider, register_provider
14
+ from runtime.mcp_config_writers import write_codex_mcp_config
14
15
  from runtime.tmux_session_manager import TmuxSessionManager
15
16
 
16
17
  _logger = logging.getLogger(__name__)
@@ -94,18 +95,7 @@ class CodexProvider(CLIProvider):
94
95
 
95
96
  def write_mcp_config(self, server_url: str, server_name: str = "memory-server") -> None:
96
97
  """Write an MCP server entry to ``~/.codex/config.toml``."""
97
- config_path = self.get_config_path()
98
- os.makedirs(os.path.dirname(config_path), exist_ok=True)
99
-
100
- entry = (
101
- f'[mcp_servers."{server_name}"]\n'
102
- f'url = "{server_url}"\n'
103
- )
104
-
105
- # Append or create
106
- mode = "a" if os.path.exists(config_path) else "w"
107
- with open(config_path, mode) as fh:
108
- fh.write(entry)
98
+ write_codex_mcp_config(server_url, server_name, config_path=self.get_config_path())
109
99
 
110
100
 
111
101
  # -- auto-register on import -----------------------------------------------
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import json
6
5
  import logging
7
6
  import os
8
7
  import shlex
@@ -12,6 +11,7 @@ import uuid
12
11
  from typing import Any
13
12
 
14
13
  from runtime.cli_provider import CLIProvider, register_provider
14
+ from runtime.mcp_config_writers import write_gemini_mcp_config
15
15
  from runtime.tmux_session_manager import TmuxSessionManager
16
16
 
17
17
  _logger = logging.getLogger(__name__)
@@ -102,26 +102,7 @@ class GeminiProvider(CLIProvider):
102
102
  Uses JSON format with ``mcpServers`` key and ``httpUrl`` field,
103
103
  merging into any existing configuration.
104
104
  """
105
- config_path = self.get_config_path()
106
- os.makedirs(os.path.dirname(config_path), exist_ok=True)
107
-
108
- # Load existing config or start fresh
109
- existing: dict[str, Any] = {} # pyright: ignore[reportExplicitAny]
110
- if os.path.exists(config_path):
111
- with open(config_path) as fh:
112
- try:
113
- existing = json.load(fh)
114
- except (json.JSONDecodeError, ValueError):
115
- existing = {}
116
-
117
- # Ensure mcpServers dict exists
118
- if "mcpServers" not in existing:
119
- existing["mcpServers"] = {}
120
-
121
- existing["mcpServers"][server_name] = {"httpUrl": server_url}
122
-
123
- with open(config_path, "w") as fh:
124
- json.dump(existing, fh, indent=2)
105
+ write_gemini_mcp_config(server_url, server_name, config_path=self.get_config_path())
125
106
 
126
107
 
127
108
  # -- auto-register on import -----------------------------------------------
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import json
6
5
  import logging
7
6
  import os
8
7
  import shlex
@@ -12,6 +11,7 @@ import uuid
12
11
  from typing import Any
13
12
 
14
13
  from runtime.cli_provider import CLIProvider, register_provider
14
+ from runtime.mcp_config_writers import write_kimi_mcp_config
15
15
  from runtime.tmux_session_manager import TmuxSessionManager
16
16
 
17
17
  _logger = logging.getLogger(__name__)
@@ -125,26 +125,7 @@ class KimiCodeProvider(CLIProvider):
125
125
  Uses standard ``mcpServers`` JSON format with ``type: "http"`` and ``url`` field,
126
126
  merging into any existing configuration.
127
127
  """
128
- config_path = self.get_config_path()
129
- os.makedirs(os.path.dirname(config_path), exist_ok=True)
130
-
131
- # Load existing config or start fresh
132
- existing: dict[str, Any] = {} # pyright: ignore[reportExplicitAny]
133
- if os.path.exists(config_path):
134
- with open(config_path) as fh:
135
- try:
136
- existing = json.load(fh)
137
- except (json.JSONDecodeError, ValueError):
138
- existing = {}
139
-
140
- # Ensure mcpServers dict exists
141
- if "mcpServers" not in existing:
142
- existing["mcpServers"] = {}
143
-
144
- existing["mcpServers"][server_name] = {"type": "http", "url": server_url}
145
-
146
- with open(config_path, "w") as fh:
147
- json.dump(existing, fh, indent=2)
128
+ write_kimi_mcp_config(server_url, server_name, config_path=self.get_config_path())
148
129
 
149
130
 
150
131
  # -- auto-register on import -----------------------------------------------
@@ -0,0 +1,64 @@
1
+ """Local-only authenticated supervisor sessions."""
2
+ from __future__ import annotations
3
+
4
+ import base64
5
+ from datetime import datetime, timezone
6
+ import hashlib
7
+ import hmac
8
+ import json
9
+ from pathlib import Path
10
+ from typing import Any
11
+ from uuid import uuid4
12
+
13
+
14
+ def _now() -> str:
15
+ return datetime.now(timezone.utc).isoformat()
16
+
17
+
18
+ def issue_local_supervisor_session(project_dir: str, *, worker_id: str, shared_secret: str) -> dict[str, Any]:
19
+ session_id = f"session-{uuid4().hex}"
20
+ issued_at = _now()
21
+ token_payload = {
22
+ "session_id": session_id,
23
+ "worker_id": worker_id,
24
+ "issued_at": issued_at,
25
+ }
26
+ payload_json = json.dumps(token_payload, sort_keys=True, separators=(",", ":"))
27
+ signature = hmac.new(shared_secret.encode("utf-8"), payload_json.encode("utf-8"), hashlib.sha256).hexdigest()
28
+ token = base64.urlsafe_b64encode(
29
+ json.dumps({"payload": token_payload, "signature": signature}, sort_keys=True, separators=(",", ":")).encode("utf-8")
30
+ ).decode("ascii")
31
+
32
+ result = {
33
+ "schema": "RemoteSupervisorSession",
34
+ "status": "ok",
35
+ "session_id": session_id,
36
+ "worker_id": worker_id,
37
+ "issued_at": issued_at,
38
+ "local_only": True,
39
+ "token": token,
40
+ }
41
+
42
+ rel_path = Path(".omg") / "supervisor" / "sessions" / f"{session_id}.json"
43
+ path = Path(project_dir) / rel_path
44
+ path.parent.mkdir(parents=True, exist_ok=True)
45
+ path.write_text(json.dumps({k: v for k, v in result.items() if k != "token"}, indent=2, ensure_ascii=True) + "\n", encoding="utf-8")
46
+ result["path"] = rel_path.as_posix()
47
+ return result
48
+
49
+
50
+ def verify_local_supervisor_token(token: str, *, shared_secret: str) -> dict[str, Any]:
51
+ decoded = json.loads(base64.urlsafe_b64decode(token.encode("ascii")).decode("utf-8"))
52
+ payload = decoded["payload"]
53
+ payload_json = json.dumps(payload, sort_keys=True, separators=(",", ":"))
54
+ signature = str(decoded["signature"])
55
+ expected = hmac.new(shared_secret.encode("utf-8"), payload_json.encode("utf-8"), hashlib.sha256).hexdigest()
56
+ status = "ok" if hmac.compare_digest(signature, expected) else "error"
57
+ return {
58
+ "schema": "RemoteSupervisorTokenVerification",
59
+ "status": status,
60
+ "session_id": str(payload["session_id"]),
61
+ "worker_id": str(payload["worker_id"]),
62
+ "issued_at": str(payload["issued_at"]),
63
+ "local_only": True,
64
+ }
@@ -0,0 +1,61 @@
1
+ """Runtime profile loading and parallelism budgets."""
2
+ from __future__ import annotations
3
+
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ import yaml
8
+
9
+
10
+ PROFILE_PRESETS: dict[str, dict[str, Any]] = {
11
+ "eco": {"profile": "eco", "max_workers": 2, "background_polling": False},
12
+ "balanced": {"profile": "balanced", "max_workers": 3, "background_polling": False},
13
+ "turbo": {"profile": "turbo", "max_workers": 5, "background_polling": True},
14
+ }
15
+
16
+
17
+ def load_runtime_profile(project_dir: str) -> dict[str, Any]:
18
+ runtime_path = Path(project_dir) / ".omg" / "runtime.yaml"
19
+ profile_name = "balanced"
20
+ if runtime_path.exists():
21
+ try:
22
+ payload = yaml.safe_load(runtime_path.read_text(encoding="utf-8")) or {}
23
+ except Exception:
24
+ payload = {}
25
+ if isinstance(payload, dict):
26
+ candidate = str(payload.get("profile", profile_name)).strip()
27
+ if candidate in PROFILE_PRESETS:
28
+ profile_name = candidate
29
+ return dict(PROFILE_PRESETS[profile_name])
30
+
31
+
32
+ def resolve_parallel_workers(project_dir: str, *, requested_workers: int) -> int:
33
+ profile = load_runtime_profile(project_dir)
34
+ max_workers = int(profile["max_workers"])
35
+ cli_cap = _load_cli_parallel_cap(project_dir)
36
+ if cli_cap is not None:
37
+ max_workers = min(max_workers, cli_cap)
38
+ return max(1, min(requested_workers, max_workers))
39
+
40
+
41
+ def _load_cli_parallel_cap(project_dir: str) -> int | None:
42
+ config_path = Path(project_dir) / ".omg" / "state" / "cli-config.yaml"
43
+ if not config_path.exists():
44
+ return None
45
+ try:
46
+ payload = yaml.safe_load(config_path.read_text(encoding="utf-8")) or {}
47
+ except Exception:
48
+ return None
49
+ if not isinstance(payload, dict):
50
+ return None
51
+ cli_configs = payload.get("cli_configs", {})
52
+ if not isinstance(cli_configs, dict):
53
+ return None
54
+ caps = []
55
+ for config in cli_configs.values():
56
+ if not isinstance(config, dict):
57
+ continue
58
+ value = config.get("max_parallel_agents")
59
+ if isinstance(value, int) and value > 0:
60
+ caps.append(value)
61
+ return min(caps) if caps else None