@jaguilar87/gaia-ops 4.4.0 → 4.7.2

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 (371) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +12 -3
  3. package/ARCHITECTURE.md +9 -8
  4. package/CHANGELOG.md +34 -0
  5. package/README.md +43 -11
  6. package/agents/terraform-architect.md +1 -1
  7. package/bin/README.md +2 -2
  8. package/bin/gaia-doctor.js +18 -5
  9. package/bin/gaia-history.js +0 -1
  10. package/bin/gaia-metrics.js +2 -2
  11. package/bin/gaia-scan.py +23 -1
  12. package/bin/gaia-update.js +346 -54
  13. package/bin/pre-publish-validate.js +33 -10
  14. package/commands/gaia.md +37 -0
  15. package/config/README.md +3 -9
  16. package/config/context-contracts.json +47 -15
  17. package/config/surface-routing.json +9 -1
  18. package/dist/gaia-ops/.claude-plugin/plugin.json +22 -0
  19. package/dist/gaia-ops/agents/cloud-troubleshooter.md +73 -0
  20. package/dist/gaia-ops/agents/devops-developer.md +57 -0
  21. package/dist/gaia-ops/agents/gaia-system.md +58 -0
  22. package/dist/gaia-ops/agents/gitops-operator.md +60 -0
  23. package/dist/gaia-ops/agents/speckit-planner.md +71 -0
  24. package/dist/gaia-ops/agents/terraform-architect.md +60 -0
  25. package/dist/gaia-ops/commands/gaia.md +37 -0
  26. package/dist/gaia-ops/config/README.md +58 -0
  27. package/dist/gaia-ops/config/cloud/aws.json +140 -0
  28. package/dist/gaia-ops/config/cloud/gcp.json +145 -0
  29. package/dist/gaia-ops/config/context-contracts.json +131 -0
  30. package/dist/gaia-ops/config/git_standards.json +72 -0
  31. package/dist/gaia-ops/config/surface-routing.json +197 -0
  32. package/dist/gaia-ops/config/universal-rules.json +10 -0
  33. package/dist/gaia-ops/hooks/adapters/__init__.py +52 -0
  34. package/dist/gaia-ops/hooks/adapters/base.py +219 -0
  35. package/dist/gaia-ops/hooks/adapters/channel.py +17 -0
  36. package/dist/gaia-ops/hooks/adapters/claude_code.py +1477 -0
  37. package/dist/gaia-ops/hooks/adapters/types.py +194 -0
  38. package/dist/gaia-ops/hooks/adapters/utils.py +25 -0
  39. package/dist/gaia-ops/hooks/hooks.json +126 -0
  40. package/dist/gaia-ops/hooks/modules/__init__.py +15 -0
  41. package/dist/gaia-ops/hooks/modules/agents/__init__.py +29 -0
  42. package/dist/gaia-ops/hooks/modules/agents/contract_validator.py +647 -0
  43. package/dist/gaia-ops/hooks/modules/agents/response_contract.py +496 -0
  44. package/dist/gaia-ops/hooks/modules/agents/skill_injection_verifier.py +124 -0
  45. package/dist/gaia-ops/hooks/modules/agents/task_info_builder.py +74 -0
  46. package/dist/gaia-ops/hooks/modules/agents/transcript_analyzer.py +458 -0
  47. package/dist/gaia-ops/hooks/modules/agents/transcript_reader.py +152 -0
  48. package/dist/gaia-ops/hooks/modules/audit/__init__.py +28 -0
  49. package/dist/gaia-ops/hooks/modules/audit/event_detector.py +168 -0
  50. package/dist/gaia-ops/hooks/modules/audit/logger.py +131 -0
  51. package/dist/gaia-ops/hooks/modules/audit/metrics.py +134 -0
  52. package/dist/gaia-ops/hooks/modules/audit/workflow_auditor.py +576 -0
  53. package/dist/gaia-ops/hooks/modules/audit/workflow_recorder.py +296 -0
  54. package/dist/gaia-ops/hooks/modules/context/__init__.py +11 -0
  55. package/dist/gaia-ops/hooks/modules/context/anchor_tracker.py +317 -0
  56. package/dist/gaia-ops/hooks/modules/context/compact_context_builder.py +215 -0
  57. package/dist/gaia-ops/hooks/modules/context/context_cache.py +129 -0
  58. package/dist/gaia-ops/hooks/modules/context/context_freshness.py +145 -0
  59. package/dist/gaia-ops/hooks/modules/context/context_injector.py +427 -0
  60. package/dist/gaia-ops/hooks/modules/context/context_writer.py +518 -0
  61. package/dist/gaia-ops/hooks/modules/context/contracts_loader.py +161 -0
  62. package/dist/gaia-ops/hooks/modules/core/__init__.py +40 -0
  63. package/dist/gaia-ops/hooks/modules/core/hook_entry.py +78 -0
  64. package/dist/gaia-ops/hooks/modules/core/paths.py +160 -0
  65. package/dist/gaia-ops/hooks/modules/core/plugin_mode.py +149 -0
  66. package/dist/gaia-ops/hooks/modules/core/plugin_setup.py +558 -0
  67. package/dist/gaia-ops/hooks/modules/core/state.py +179 -0
  68. package/dist/gaia-ops/hooks/modules/core/stdin.py +24 -0
  69. package/dist/gaia-ops/hooks/modules/events/__init__.py +1 -0
  70. package/dist/gaia-ops/hooks/modules/events/event_writer.py +210 -0
  71. package/dist/gaia-ops/hooks/modules/identity/__init__.py +0 -0
  72. package/dist/gaia-ops/hooks/modules/identity/identity_provider.py +21 -0
  73. package/dist/gaia-ops/hooks/modules/identity/ops_identity.py +34 -0
  74. package/dist/gaia-ops/hooks/modules/identity/security_identity.py +10 -0
  75. package/dist/gaia-ops/hooks/modules/memory/__init__.py +8 -0
  76. package/dist/gaia-ops/hooks/modules/memory/episode_writer.py +227 -0
  77. package/dist/gaia-ops/hooks/modules/orchestrator/__init__.py +1 -0
  78. package/dist/gaia-ops/hooks/modules/orchestrator/delegate_mode.py +128 -0
  79. package/dist/gaia-ops/hooks/modules/scanning/__init__.py +8 -0
  80. package/dist/gaia-ops/hooks/modules/scanning/scan_trigger.py +84 -0
  81. package/dist/gaia-ops/hooks/modules/security/__init__.py +89 -0
  82. package/dist/gaia-ops/hooks/modules/security/approval_cleanup.py +87 -0
  83. package/dist/gaia-ops/hooks/modules/security/approval_constants.py +23 -0
  84. package/dist/gaia-ops/hooks/modules/security/approval_grants.py +912 -0
  85. package/dist/gaia-ops/hooks/modules/security/approval_messages.py +71 -0
  86. package/dist/gaia-ops/hooks/modules/security/approval_scopes.py +153 -0
  87. package/dist/gaia-ops/hooks/modules/security/blocked_commands.py +584 -0
  88. package/dist/gaia-ops/hooks/modules/security/blocked_message_formatter.py +86 -0
  89. package/dist/gaia-ops/hooks/modules/security/command_semantics.py +130 -0
  90. package/dist/gaia-ops/hooks/modules/security/gitops_validator.py +179 -0
  91. package/dist/gaia-ops/hooks/modules/security/mutative_verbs.py +850 -0
  92. package/dist/gaia-ops/hooks/modules/security/prompt_validator.py +40 -0
  93. package/dist/gaia-ops/hooks/modules/security/tiers.py +196 -0
  94. package/dist/gaia-ops/hooks/modules/session/__init__.py +10 -0
  95. package/dist/gaia-ops/hooks/modules/session/session_context_writer.py +100 -0
  96. package/dist/gaia-ops/hooks/modules/session/session_event_injector.py +158 -0
  97. package/dist/gaia-ops/hooks/modules/session/session_manager.py +31 -0
  98. package/dist/gaia-ops/hooks/modules/tools/__init__.py +25 -0
  99. package/dist/gaia-ops/hooks/modules/tools/bash_validator.py +708 -0
  100. package/dist/gaia-ops/hooks/modules/tools/cloud_pipe_validator.py +181 -0
  101. package/dist/gaia-ops/hooks/modules/tools/hook_response.py +55 -0
  102. package/dist/gaia-ops/hooks/modules/tools/shell_parser.py +227 -0
  103. package/dist/gaia-ops/hooks/modules/tools/task_validator.py +283 -0
  104. package/dist/gaia-ops/hooks/modules/validation/__init__.py +23 -0
  105. package/dist/gaia-ops/hooks/modules/validation/commit_validator.py +380 -0
  106. package/dist/gaia-ops/hooks/post_compact.py +43 -0
  107. package/dist/gaia-ops/hooks/post_tool_use.py +54 -0
  108. package/dist/gaia-ops/hooks/pre_tool_use.py +383 -0
  109. package/dist/gaia-ops/hooks/session_start.py +69 -0
  110. package/dist/gaia-ops/hooks/stop_hook.py +69 -0
  111. package/dist/gaia-ops/hooks/subagent_start.py +71 -0
  112. package/dist/gaia-ops/hooks/subagent_stop.py +288 -0
  113. package/dist/gaia-ops/hooks/task_completed.py +70 -0
  114. package/dist/gaia-ops/hooks/user_prompt_submit.py +177 -0
  115. package/dist/gaia-ops/settings.json +72 -0
  116. package/dist/gaia-ops/skills/README.md +109 -0
  117. package/dist/gaia-ops/skills/agent-protocol/SKILL.md +105 -0
  118. package/dist/gaia-ops/skills/agent-protocol/examples.md +170 -0
  119. package/dist/gaia-ops/skills/agent-response/SKILL.md +53 -0
  120. package/dist/gaia-ops/skills/approval/SKILL.md +85 -0
  121. package/dist/gaia-ops/skills/approval/examples.md +140 -0
  122. package/dist/gaia-ops/skills/approval/reference.md +57 -0
  123. package/dist/gaia-ops/skills/command-execution/SKILL.md +64 -0
  124. package/dist/gaia-ops/skills/command-execution/reference.md +83 -0
  125. package/dist/gaia-ops/skills/context-updater/SKILL.md +76 -0
  126. package/dist/gaia-ops/skills/context-updater/examples.md +71 -0
  127. package/dist/gaia-ops/skills/developer-patterns/SKILL.md +93 -0
  128. package/dist/gaia-ops/skills/developer-patterns/reference.md +112 -0
  129. package/dist/gaia-ops/skills/execution/SKILL.md +66 -0
  130. package/dist/gaia-ops/skills/fast-queries/SKILL.md +47 -0
  131. package/dist/gaia-ops/skills/gaia-patterns/SKILL.md +92 -0
  132. package/dist/gaia-ops/skills/gaia-patterns/reference.md +22 -0
  133. package/dist/gaia-ops/skills/git-conventions/SKILL.md +48 -0
  134. package/dist/gaia-ops/skills/gitops-patterns/SKILL.md +73 -0
  135. package/dist/gaia-ops/skills/gitops-patterns/reference.md +183 -0
  136. package/dist/gaia-ops/skills/investigation/SKILL.md +77 -0
  137. package/dist/gaia-ops/skills/orchestrator-approval/SKILL.md +64 -0
  138. package/dist/gaia-ops/skills/reference.md +134 -0
  139. package/dist/gaia-ops/skills/security-tiers/SKILL.md +61 -0
  140. package/dist/gaia-ops/skills/security-tiers/destructive-commands-reference.md +623 -0
  141. package/dist/gaia-ops/skills/security-tiers/reference.md +39 -0
  142. package/dist/gaia-ops/skills/skill-creation/SKILL.md +119 -0
  143. package/dist/gaia-ops/skills/specification/SKILL.md +186 -0
  144. package/dist/gaia-ops/skills/speckit-workflow/SKILL.md +165 -0
  145. package/dist/gaia-ops/skills/speckit-workflow/reference.md +117 -0
  146. package/dist/gaia-ops/skills/terraform-patterns/SKILL.md +63 -0
  147. package/dist/gaia-ops/skills/terraform-patterns/reference.md +93 -0
  148. package/dist/gaia-ops/speckit/README.md +516 -0
  149. package/dist/gaia-ops/speckit/scripts/.gitkeep +0 -0
  150. package/dist/gaia-ops/speckit/templates/adr-template.md +118 -0
  151. package/dist/gaia-ops/speckit/templates/agent-file-template.md +23 -0
  152. package/dist/gaia-ops/speckit/templates/plan-template.md +227 -0
  153. package/dist/gaia-ops/speckit/templates/spec-template.md +140 -0
  154. package/dist/gaia-ops/speckit/templates/tasks-template.md +257 -0
  155. package/dist/gaia-ops/tools/context/README.md +132 -0
  156. package/dist/gaia-ops/tools/context/__init__.py +42 -0
  157. package/dist/gaia-ops/tools/context/_paths.py +20 -0
  158. package/dist/gaia-ops/tools/context/context_provider.py +476 -0
  159. package/dist/gaia-ops/tools/context/context_section_reader.py +330 -0
  160. package/dist/gaia-ops/tools/context/deep_merge.py +159 -0
  161. package/dist/gaia-ops/tools/context/pending_updates.py +760 -0
  162. package/dist/gaia-ops/tools/context/surface_router.py +278 -0
  163. package/dist/gaia-ops/tools/fast-queries/README.md +65 -0
  164. package/dist/gaia-ops/tools/fast-queries/__init__.py +30 -0
  165. package/dist/gaia-ops/tools/fast-queries/appservices/quicktriage_devops_developer.sh +75 -0
  166. package/dist/gaia-ops/tools/fast-queries/cloud/aws/quicktriage_aws_troubleshooter.sh +32 -0
  167. package/dist/gaia-ops/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh +88 -0
  168. package/dist/gaia-ops/tools/fast-queries/gitops/quicktriage_gitops_operator.sh +48 -0
  169. package/dist/gaia-ops/tools/fast-queries/run_triage.sh +59 -0
  170. package/dist/gaia-ops/tools/fast-queries/terraform/quicktriage_terraform_architect.sh +80 -0
  171. package/dist/gaia-ops/tools/gaia_simulator/__init__.py +33 -0
  172. package/dist/gaia-ops/tools/gaia_simulator/cli.py +354 -0
  173. package/dist/gaia-ops/tools/gaia_simulator/extractor.py +457 -0
  174. package/dist/gaia-ops/tools/gaia_simulator/reporter.py +258 -0
  175. package/dist/gaia-ops/tools/gaia_simulator/routing_simulator.py +334 -0
  176. package/dist/gaia-ops/tools/gaia_simulator/runner.py +539 -0
  177. package/dist/gaia-ops/tools/gaia_simulator/skills_mapper.py +262 -0
  178. package/dist/gaia-ops/tools/memory/README.md +0 -0
  179. package/dist/gaia-ops/tools/memory/__init__.py +20 -0
  180. package/dist/gaia-ops/tools/memory/episodic.py +1196 -0
  181. package/dist/gaia-ops/tools/persist_transcript_analysis.py +85 -0
  182. package/dist/gaia-ops/tools/review/__init__.py +1 -0
  183. package/dist/gaia-ops/tools/review/review_engine.py +157 -0
  184. package/dist/gaia-ops/tools/scan/__init__.py +35 -0
  185. package/dist/gaia-ops/tools/scan/config.py +247 -0
  186. package/dist/gaia-ops/tools/scan/merge.py +212 -0
  187. package/dist/gaia-ops/tools/scan/orchestrator.py +549 -0
  188. package/dist/gaia-ops/tools/scan/registry.py +127 -0
  189. package/dist/gaia-ops/tools/scan/scanners/__init__.py +18 -0
  190. package/dist/gaia-ops/tools/scan/scanners/base.py +137 -0
  191. package/dist/gaia-ops/tools/scan/scanners/environment.py +324 -0
  192. package/dist/gaia-ops/tools/scan/scanners/git.py +570 -0
  193. package/dist/gaia-ops/tools/scan/scanners/infrastructure.py +875 -0
  194. package/dist/gaia-ops/tools/scan/scanners/orchestration.py +600 -0
  195. package/dist/gaia-ops/tools/scan/scanners/stack.py +1085 -0
  196. package/dist/gaia-ops/tools/scan/scanners/tools.py +260 -0
  197. package/dist/gaia-ops/tools/scan/setup.py +753 -0
  198. package/dist/gaia-ops/tools/scan/tests/__init__.py +1 -0
  199. package/dist/gaia-ops/tools/scan/tests/conftest.py +796 -0
  200. package/dist/gaia-ops/tools/scan/tests/test_environment.py +323 -0
  201. package/dist/gaia-ops/tools/scan/tests/test_git.py +419 -0
  202. package/dist/gaia-ops/tools/scan/tests/test_infrastructure.py +382 -0
  203. package/dist/gaia-ops/tools/scan/tests/test_integration.py +920 -0
  204. package/dist/gaia-ops/tools/scan/tests/test_merge.py +269 -0
  205. package/dist/gaia-ops/tools/scan/tests/test_orchestration.py +304 -0
  206. package/dist/gaia-ops/tools/scan/tests/test_stack.py +604 -0
  207. package/dist/gaia-ops/tools/scan/tests/test_tools.py +349 -0
  208. package/dist/gaia-ops/tools/scan/ui.py +624 -0
  209. package/dist/gaia-ops/tools/scan/verify.py +266 -0
  210. package/dist/gaia-ops/tools/scan/walk.py +118 -0
  211. package/dist/gaia-ops/tools/scan/workspace.py +85 -0
  212. package/dist/gaia-ops/tools/validation/README.md +244 -0
  213. package/dist/gaia-ops/tools/validation/__init__.py +17 -0
  214. package/dist/gaia-ops/tools/validation/approval_gate.py +321 -0
  215. package/dist/gaia-ops/tools/validation/validate_skills.py +189 -0
  216. package/dist/gaia-security/.claude-plugin/plugin.json +22 -0
  217. package/dist/gaia-security/config/universal-rules.json +10 -0
  218. package/dist/gaia-security/hooks/adapters/__init__.py +52 -0
  219. package/dist/gaia-security/hooks/adapters/base.py +219 -0
  220. package/dist/gaia-security/hooks/adapters/channel.py +17 -0
  221. package/dist/gaia-security/hooks/adapters/claude_code.py +1477 -0
  222. package/dist/gaia-security/hooks/adapters/types.py +194 -0
  223. package/dist/gaia-security/hooks/adapters/utils.py +25 -0
  224. package/dist/gaia-security/hooks/hooks.json +57 -0
  225. package/dist/gaia-security/hooks/modules/__init__.py +15 -0
  226. package/dist/gaia-security/hooks/modules/agents/__init__.py +29 -0
  227. package/dist/gaia-security/hooks/modules/agents/contract_validator.py +647 -0
  228. package/dist/gaia-security/hooks/modules/agents/response_contract.py +496 -0
  229. package/dist/gaia-security/hooks/modules/agents/skill_injection_verifier.py +124 -0
  230. package/dist/gaia-security/hooks/modules/agents/task_info_builder.py +74 -0
  231. package/dist/gaia-security/hooks/modules/agents/transcript_analyzer.py +458 -0
  232. package/dist/gaia-security/hooks/modules/agents/transcript_reader.py +152 -0
  233. package/dist/gaia-security/hooks/modules/audit/__init__.py +28 -0
  234. package/dist/gaia-security/hooks/modules/audit/event_detector.py +168 -0
  235. package/dist/gaia-security/hooks/modules/audit/logger.py +131 -0
  236. package/dist/gaia-security/hooks/modules/audit/metrics.py +134 -0
  237. package/dist/gaia-security/hooks/modules/audit/workflow_auditor.py +576 -0
  238. package/dist/gaia-security/hooks/modules/audit/workflow_recorder.py +296 -0
  239. package/dist/gaia-security/hooks/modules/context/__init__.py +11 -0
  240. package/dist/gaia-security/hooks/modules/context/anchor_tracker.py +317 -0
  241. package/dist/gaia-security/hooks/modules/context/compact_context_builder.py +215 -0
  242. package/dist/gaia-security/hooks/modules/context/context_cache.py +129 -0
  243. package/dist/gaia-security/hooks/modules/context/context_freshness.py +145 -0
  244. package/dist/gaia-security/hooks/modules/context/context_injector.py +427 -0
  245. package/dist/gaia-security/hooks/modules/context/context_writer.py +518 -0
  246. package/dist/gaia-security/hooks/modules/context/contracts_loader.py +161 -0
  247. package/dist/gaia-security/hooks/modules/core/__init__.py +40 -0
  248. package/dist/gaia-security/hooks/modules/core/hook_entry.py +78 -0
  249. package/dist/gaia-security/hooks/modules/core/paths.py +160 -0
  250. package/dist/gaia-security/hooks/modules/core/plugin_mode.py +149 -0
  251. package/dist/gaia-security/hooks/modules/core/plugin_setup.py +558 -0
  252. package/dist/gaia-security/hooks/modules/core/state.py +179 -0
  253. package/dist/gaia-security/hooks/modules/core/stdin.py +24 -0
  254. package/dist/gaia-security/hooks/modules/events/__init__.py +1 -0
  255. package/dist/gaia-security/hooks/modules/events/event_writer.py +210 -0
  256. package/dist/gaia-security/hooks/modules/identity/__init__.py +0 -0
  257. package/dist/gaia-security/hooks/modules/identity/identity_provider.py +21 -0
  258. package/dist/gaia-security/hooks/modules/identity/ops_identity.py +34 -0
  259. package/dist/gaia-security/hooks/modules/identity/security_identity.py +10 -0
  260. package/dist/gaia-security/hooks/modules/memory/__init__.py +8 -0
  261. package/dist/gaia-security/hooks/modules/memory/episode_writer.py +227 -0
  262. package/dist/gaia-security/hooks/modules/orchestrator/__init__.py +1 -0
  263. package/dist/gaia-security/hooks/modules/orchestrator/delegate_mode.py +128 -0
  264. package/dist/gaia-security/hooks/modules/scanning/__init__.py +8 -0
  265. package/dist/gaia-security/hooks/modules/scanning/scan_trigger.py +84 -0
  266. package/dist/gaia-security/hooks/modules/security/__init__.py +89 -0
  267. package/dist/gaia-security/hooks/modules/security/approval_cleanup.py +87 -0
  268. package/dist/gaia-security/hooks/modules/security/approval_constants.py +23 -0
  269. package/dist/gaia-security/hooks/modules/security/approval_grants.py +912 -0
  270. package/dist/gaia-security/hooks/modules/security/approval_messages.py +71 -0
  271. package/dist/gaia-security/hooks/modules/security/approval_scopes.py +153 -0
  272. package/dist/gaia-security/hooks/modules/security/blocked_commands.py +584 -0
  273. package/dist/gaia-security/hooks/modules/security/blocked_message_formatter.py +86 -0
  274. package/dist/gaia-security/hooks/modules/security/command_semantics.py +130 -0
  275. package/dist/gaia-security/hooks/modules/security/gitops_validator.py +179 -0
  276. package/dist/gaia-security/hooks/modules/security/mutative_verbs.py +850 -0
  277. package/dist/gaia-security/hooks/modules/security/prompt_validator.py +40 -0
  278. package/dist/gaia-security/hooks/modules/security/tiers.py +196 -0
  279. package/dist/gaia-security/hooks/modules/session/__init__.py +10 -0
  280. package/dist/gaia-security/hooks/modules/session/session_context_writer.py +100 -0
  281. package/dist/gaia-security/hooks/modules/session/session_event_injector.py +158 -0
  282. package/dist/gaia-security/hooks/modules/session/session_manager.py +31 -0
  283. package/dist/gaia-security/hooks/modules/tools/__init__.py +25 -0
  284. package/dist/gaia-security/hooks/modules/tools/bash_validator.py +708 -0
  285. package/dist/gaia-security/hooks/modules/tools/cloud_pipe_validator.py +181 -0
  286. package/dist/gaia-security/hooks/modules/tools/hook_response.py +55 -0
  287. package/dist/gaia-security/hooks/modules/tools/shell_parser.py +227 -0
  288. package/dist/gaia-security/hooks/modules/tools/task_validator.py +283 -0
  289. package/dist/gaia-security/hooks/modules/validation/__init__.py +23 -0
  290. package/dist/gaia-security/hooks/modules/validation/commit_validator.py +380 -0
  291. package/dist/gaia-security/hooks/post_tool_use.py +54 -0
  292. package/dist/gaia-security/hooks/pre_tool_use.py +383 -0
  293. package/dist/gaia-security/hooks/session_start.py +69 -0
  294. package/dist/gaia-security/hooks/stop_hook.py +69 -0
  295. package/dist/gaia-security/hooks/user_prompt_submit.py +177 -0
  296. package/dist/gaia-security/settings.json +58 -0
  297. package/git-hooks/commit-msg +41 -0
  298. package/hooks/README.md +8 -6
  299. package/hooks/adapters/channel.py +0 -25
  300. package/hooks/adapters/claude_code.py +364 -125
  301. package/hooks/elicitation_result.py +132 -0
  302. package/hooks/hooks.json +10 -1
  303. package/hooks/modules/README.md +3 -2
  304. package/hooks/modules/agents/contract_validator.py +3 -51
  305. package/hooks/modules/agents/response_contract.py +4 -8
  306. package/hooks/modules/agents/transcript_reader.py +4 -5
  307. package/hooks/modules/audit/__init__.py +4 -6
  308. package/hooks/modules/audit/event_detector.py +0 -2
  309. package/hooks/modules/audit/metrics.py +108 -187
  310. package/hooks/modules/audit/workflow_auditor.py +0 -4
  311. package/hooks/modules/audit/workflow_recorder.py +0 -5
  312. package/hooks/modules/context/compact_context_builder.py +1 -0
  313. package/hooks/modules/context/context_cache.py +129 -0
  314. package/hooks/modules/context/context_injector.py +18 -40
  315. package/hooks/modules/context/context_writer.py +1 -25
  316. package/hooks/modules/context/contracts_loader.py +7 -10
  317. package/hooks/modules/core/hook_entry.py +1 -0
  318. package/hooks/modules/core/paths.py +12 -13
  319. package/hooks/modules/core/plugin_mode.py +74 -4
  320. package/hooks/modules/core/plugin_setup.py +395 -23
  321. package/hooks/modules/events/__init__.py +1 -0
  322. package/hooks/modules/events/event_writer.py +210 -0
  323. package/hooks/modules/identity/ops_identity.py +18 -27
  324. package/hooks/modules/memory/episode_writer.py +1 -6
  325. package/hooks/modules/orchestrator/__init__.py +1 -0
  326. package/hooks/modules/orchestrator/delegate_mode.py +128 -0
  327. package/hooks/modules/security/__init__.py +2 -4
  328. package/hooks/modules/security/approval_constants.py +5 -1
  329. package/hooks/modules/security/approval_grants.py +189 -6
  330. package/hooks/modules/security/approval_messages.py +9 -21
  331. package/hooks/modules/security/blocked_commands.py +98 -34
  332. package/hooks/modules/security/command_semantics.py +0 -4
  333. package/hooks/modules/security/gitops_validator.py +1 -11
  334. package/hooks/modules/security/mutative_verbs.py +179 -38
  335. package/hooks/modules/security/tiers.py +1 -19
  336. package/hooks/modules/session/session_event_injector.py +1 -25
  337. package/hooks/modules/tools/bash_validator.py +310 -94
  338. package/hooks/modules/tools/shell_parser.py +0 -1
  339. package/hooks/modules/tools/task_validator.py +9 -29
  340. package/hooks/post_tool_use.py +0 -72
  341. package/hooks/pre_tool_use.py +42 -102
  342. package/hooks/session_start.py +4 -2
  343. package/hooks/subagent_start.py +6 -2
  344. package/hooks/subagent_stop.py +1 -13
  345. package/hooks/user_prompt_submit.py +119 -37
  346. package/index.js +1 -1
  347. package/package.json +5 -3
  348. package/skills/README.md +3 -5
  349. package/skills/agent-protocol/SKILL.md +17 -16
  350. package/skills/agent-protocol/examples.md +6 -6
  351. package/skills/agent-response/SKILL.md +11 -14
  352. package/skills/approval/SKILL.md +28 -13
  353. package/skills/approval/reference.md +2 -2
  354. package/skills/execution/SKILL.md +1 -1
  355. package/skills/gaia-patterns/SKILL.md +2 -3
  356. package/skills/orchestrator-approval/SKILL.md +22 -50
  357. package/skills/security-tiers/SKILL.md +1 -1
  358. package/templates/README.md +9 -9
  359. package/templates/managed-settings.template.json +43 -0
  360. package/tools/gaia_simulator/runner.py +34 -1
  361. package/tools/scan/orchestrator.py +13 -0
  362. package/tools/scan/scanners/base.py +8 -0
  363. package/tools/scan/scanners/git.py +78 -0
  364. package/tools/scan/scanners/infrastructure.py +65 -0
  365. package/tools/scan/scanners/stack.py +110 -0
  366. package/tools/scan/setup.py +120 -13
  367. package/tools/scan/workspace.py +85 -0
  368. package/config/context-contracts.aws.json +0 -42
  369. package/config/context-contracts.gcp.json +0 -39
  370. package/skills/project-dispatch/SKILL.md +0 -34
  371. package/templates/settings.template.json +0 -226
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: gaia-patterns
3
+ description: Use when analyzing, designing, or modifying the gaia-ops orchestration system architecture
4
+ metadata:
5
+ user-invocable: false
6
+ type: domain
7
+ ---
8
+
9
+ # Gaia-Ops Patterns
10
+
11
+ Domain knowledge for the gaia-ops meta-system. For the Component Map details, see `reference.md`.
12
+
13
+ ## Prompt → Result Flow
14
+
15
+ ```
16
+ 1. User sends prompt
17
+
18
+ 2. Orchestrator (identity injected by submit hook) — routes to the correct agent
19
+
20
+ 3. Pre-Tool Hook (pre_tool_use.py)
21
+ ├─ Inject project-context.json (relevant sections per agent)
22
+ ├─ Load skills from frontmatter
23
+ └─ Validate permissions
24
+
25
+ 4. Agent Executes — uses tools, follows skills, returns `json:contract` block
26
+
27
+ 5. Post-Tool Hook — audit + metrics
28
+
29
+ 6. Orchestrator processes `json:contract` block (plan_status)
30
+ ├─ REVIEW → present plan, get feedback → resume (with approval_id if hook-blocked)
31
+ ├─ NEEDS_INPUT → ask user → resume
32
+ └─ COMPLETE → respond to user
33
+ ```
34
+
35
+ ## Key Concepts
36
+
37
+ - **Binary Delegation:** The orchestrator always delegates. Its only tools are Agent and AskUserQuestion.
38
+ - **Agent Instantiation:** identity (.md) + skills (injected) + project-context (contracts) + orchestrator request.
39
+ - **Security Tiers:** T0 (read) → T1 (validate) → T2 (simulate) → T3 (realize, requires approval).
40
+ - **T3 Flow:** IN_PROGRESS → REVIEW → IN_PROGRESS → COMPLETE (plan-first or hook-blocked with approval_id).
41
+ - **Consolidation Loop:** for multi-surface work, Gaia may dispatch more than one round of agents, but only while gaps are actionable and evidence is still improving.
42
+ - **Principle:** Skills teach process. Agents teach identity and domain knowledge. Runtime enforces deterministic contracts. Never duplicate.
43
+
44
+ ## Multi-Agent Consolidation
45
+
46
+ The orchestrator owns the consolidation loop. Agents return `json:contract` blocks with `consolidation` objects; the orchestrator merges, decides whether to dispatch another round, and stops when gaps are no longer actionable.
47
+
48
+ ## Workflow Design Philosophy
49
+
50
+ 1. **Flow naturally** — each step leads to the next without friction
51
+ 2. **Be positive** — describe what to do, not what to avoid
52
+ 3. **Allow discovery** — agent reaches conclusions empirically
53
+ 4. **Be concise** — leave room for growth
54
+ 5. **Be measurable** — goals with numbers, not subjective terms
55
+
56
+ ## Line Budget
57
+
58
+ | Document | Target | Max |
59
+ |----------|--------|-----|
60
+ | Agent `.md` | 80 lines | 120 |
61
+ | `CLAUDE.md` | 60 lines | 100 |
62
+ | Skill (injected) | < 100 lines | 100 |
63
+
64
+ ## Agent Creation Standards
65
+
66
+ 1. **YAML Frontmatter** — `name`, `description` (routing label), `tools`, `model`, `skills` (canonical order)
67
+ 2. **Identity** — 1-2 paragraphs: what domain, what output format
68
+ 3. **Scope** — CAN DO / CANNOT DO → DELEGATE table with agent names
69
+ 4. **Domain Errors** — domain-specific errors only
70
+
71
+ **Canonical injected skills order:** `agent-protocol` → `security-tiers` → `investigation` → `command-execution` → domain skill → `context-updater` → `fast-queries`
72
+
73
+ **On-demand workflow skills:** `approval`, `execution`, `git-conventions`
74
+
75
+ ## Documentation Standards
76
+
77
+ **Required sections (in order):** What it does, Where it fits, How it works, Components, Usage, References.
78
+
79
+ **The zoom lens rule:** every README shows the complete system flow and bolds where this module participates.
80
+
81
+ **Writing rules:** every line earns its place — no duplication, discoverable over documented.
82
+
83
+ ## Release Management
84
+
85
+ - **Package:** `@jaguilar87/gaia-ops` (npm public registry)
86
+ - **Symlinks:** `.claude/` symlinks to `node_modules/@jaguilar87/gaia-ops/`
87
+
88
+ | Change | Version |
89
+ |--------|---------|
90
+ | Bug fix in agent or skill | PATCH |
91
+ | New agent or skill | MINOR |
92
+ | Breaking change to `json:contract` format | MAJOR |
@@ -0,0 +1,22 @@
1
+ # Gaia-Ops Patterns — Reference
2
+
3
+ ## Component Map
4
+
5
+ | Component | Location | Purpose |
6
+ |-----------|----------|---------|
7
+ | **Orchestrator** | `CLAUDE.md` | Routes requests, manages workflow |
8
+ | **Agents** | `agents/*.md` | Domain identity + scope |
9
+ | **Hooks** | `hooks/*.py` | Context injection, validation, audit |
10
+ | **Skills** | `skills/*/SKILL.md` | Injected procedural knowledge |
11
+ | **Tools** | `tools/` | Python utilities |
12
+ | **Config** | `config/` | System configuration |
13
+
14
+ ## Documentation Template
15
+
16
+ ```
17
+ 1. User sends prompt
18
+ 2. Orchestrator routes
19
+ 3. **→ [THIS MODULE] ← acts here**
20
+ 4. Agent executes
21
+ 5. Orchestrator responds
22
+ ```
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: git-conventions
3
+ description: Use when creating a git commit or preparing changes for a pull request
4
+ metadata:
5
+ user-invocable: false
6
+ type: reference
7
+ ---
8
+
9
+ # Git Conventions
10
+
11
+ ## Commit Format
12
+
13
+ All commits MUST follow Conventional Commits: `type(scope): description`
14
+
15
+ | Element | Rule |
16
+ |---------|------|
17
+ | Format | `type(scope): short description` |
18
+ | Types | feat, fix, refactor, docs, test, chore, ci, perf, style, build |
19
+ | Scope | Optional, reflects module/area changed |
20
+ | Subject | Max 72 chars, lowercase start, imperative mood, no period, no emoji |
21
+ | Body | Optional, blank line after subject, 72 char line wrap (warning) |
22
+ | Footers | `BREAKING CHANGE:`, `Refs:`, `Closes:`, `Fixes:` allowed |
23
+
24
+ ## Examples
25
+
26
+ ```
27
+ feat(helmrelease): add Phase 3.3 services
28
+ fix(pg-non-prod): correct API key environment variable mappings
29
+ refactor: simplify context provider logic
30
+ chore(deps): update terraform to v1.6.0
31
+ ```
32
+
33
+ ## Rules
34
+
35
+ - Use `git commit -m "type(scope): description"` format
36
+ - Do NOT add `Co-Authored-By` or `Generated with Claude Code` footers (hooks auto-strip these)
37
+ - Description starts lowercase, imperative mood
38
+ - **Never use git path flags** -- do not use `git -C <path>`, `git --git-dir=<path>`, or `git --work-tree=<path>`. The permission system matches command prefixes; these flags break all `git <subcommand>:*` allow/deny rules. Per `command-execution` Rule 2, run `cd` as a separate Bash call before running git commands.
39
+ - **Push to the feature branch by default.** Only push directly to `main` if explicitly instructed or the plan is already on main. Never force-push (`git push --force`).
40
+
41
+ ## Hook Enforcement (Automatic)
42
+
43
+ The `commit_validator.py` hook validates against `config/git_standards.json`:
44
+
45
+ - **Forbidden footers** (error): `Co-Authored-By: Claude`, `Generated with Claude Code`, emoji-prefixed footers
46
+ - **Conventional Commits format** (error): must match `type(scope): description` with allowed types
47
+ - **Subject rules** (error): max 72 chars, no trailing period, no emoji
48
+ - **Body rules** (warning): blank line after subject, 72 char line wrap
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: gitops-patterns
3
+ description: Use when creating, modifying, or reviewing Kubernetes manifests, HelmReleases, or Flux configuration
4
+ metadata:
5
+ user-invocable: false
6
+ type: domain
7
+ ---
8
+
9
+ # GitOps Patterns
10
+
11
+ Project-specific conventions. For YAML examples, read `reference.md` in this directory.
12
+ Use values from your injected project-context — never hardcode cluster names, registry URLs, or namespaces.
13
+
14
+ ## Repository Structure
15
+
16
+ ```
17
+ {gitops_repo_path}/
18
+ ├── clusters/
19
+ │ └── {cluster-name}/ # from project-context cluster_name
20
+ │ ├── flux-system/ # Flux controllers + sync
21
+ │ ├── apps.yaml # Kustomization → apps overlay
22
+ │ └── infrastructure.yaml # Kustomization → infra overlay
23
+ ├── infrastructure/
24
+ │ ├── base/ # Shared: namespaces, sources, components
25
+ │ └── overlays/{env}/ # Per-environment patches
26
+ └── apps/
27
+ ├── base/{service}/ # Per-service Kustomize base
28
+ └── overlays/{env}/ # Per-environment patches
29
+ ```
30
+
31
+ ## Flux Configuration
32
+
33
+ - **Reconciliation interval:** 1 minute (Kustomization), 5 minutes (HelmRelease)
34
+ - **Source:** Git via SSH, branch `main`
35
+ - **Image automation:** semver `>=1.0.0` — Flux updates tags automatically
36
+ - **Pruning:** `prune: true` — resources removed from Git are deleted from cluster
37
+
38
+ ## Naming Conventions
39
+
40
+ | Resource | Pattern | Example |
41
+ |----------|---------|---------|
42
+ | Namespace | `kebab-case` | `common`, `mobile-backend` |
43
+ | Service / HelmRelease | `kebab-case` | `products-service` |
44
+ | ConfigMap | `{service}-config` | `products-service-config` |
45
+ | Secret | `{service}-secret` | `products-service-secret` |
46
+ | Kustomization | `{scope}-{env}` | `apps-oci-dev` |
47
+
48
+ ## Image Versioning (CRITICAL)
49
+
50
+ - **Pattern:** semantic versioning `v1.0.xxx`
51
+ - **NEVER:** `latest`, `main`, `master`, `dev`, `staging`
52
+ - Flux ImagePolicy uses `semver.range: '>=1.0.0'`
53
+
54
+ For resource limit defaults and secrets management strategy, see `reference.md`.
55
+
56
+ ## Per-Namespace Structure
57
+
58
+ Each namespace directory contains:
59
+ - `namespace.yaml` — Namespace definition with standard labels
60
+ - `{service}.yaml` — HelmRelease
61
+ - `{service}-config.yaml` — ConfigMap (if needed)
62
+ - `{service}-secret.yaml` — SealedSecret (if needed)
63
+
64
+ ## Key Rules
65
+
66
+ 1. **Git-first** — NEVER `kubectl apply` directly. All changes via git commit + push
67
+ 2. **Semver tags** — Never `latest`, always `v1.0.xxx`
68
+ 3. **Secrets via SealedSecrets** — Never plain secrets in Git
69
+ 4. **Flux reconciles** — Auto in ~1m, or force: `flux reconcile kustomization {name}`
70
+ 5. **Always set resource limits** — Both requests and limits required
71
+ 6. **Verify cluster context** — `kubectl config current-context` before any operation
72
+ 7. **Use project-context** — cluster_name, gitops_repo_path, environment from injected context
73
+ 8. **Post-push verification (T3 MANDATORY)** — After pushing manifests, verify Flux reconciled successfully. See `reference.md` "Post-Push Verification" for the exact command sequence
@@ -0,0 +1,183 @@
1
+ # GitOps Patterns — YAML Reference
2
+
3
+ Structural patterns for Kubernetes and Flux. Use placeholders — replace with values from project-context.
4
+
5
+ For cloud-specific resource examples, discover patterns from the existing codebase using the `investigation` skill.
6
+
7
+ ---
8
+
9
+ ## HelmRelease
10
+
11
+ ```yaml
12
+ apiVersion: helm.toolkit.fluxcd.io/v2beta1
13
+ kind: HelmRelease
14
+ metadata:
15
+ name: {service-name}
16
+ namespace: {namespace}
17
+ spec:
18
+ interval: 5m
19
+ chart:
20
+ spec:
21
+ chart: {chart-name}
22
+ version: '>=1.0.0'
23
+ sourceRef:
24
+ kind: GitRepository
25
+ name: helm-charts
26
+ namespace: flux-system
27
+ interval: 1m
28
+ values:
29
+ image:
30
+ repository: {registry}/{service-name}
31
+ tag: v1.0.0
32
+ resources:
33
+ requests:
34
+ memory: "256Mi"
35
+ cpu: "100m"
36
+ limits:
37
+ memory: "512Mi"
38
+ cpu: "500m"
39
+ ```
40
+
41
+ ## Namespace
42
+
43
+ ```yaml
44
+ apiVersion: v1
45
+ kind: Namespace
46
+ metadata:
47
+ name: {namespace}
48
+ labels:
49
+ name: {namespace}
50
+ environment: {env}
51
+ ```
52
+
53
+ ## ConfigMap
54
+
55
+ ```yaml
56
+ apiVersion: v1
57
+ kind: ConfigMap
58
+ metadata:
59
+ name: {service-name}-config
60
+ namespace: {namespace}
61
+ data:
62
+ KEY: "value"
63
+ ```
64
+
65
+ ## SealedSecret
66
+
67
+ ```yaml
68
+ apiVersion: bitnami.com/v1alpha1
69
+ kind: SealedSecret
70
+ metadata:
71
+ name: {service-name}-secret
72
+ namespace: {namespace}
73
+ spec:
74
+ encryptedData:
75
+ SECRET_KEY: AgB... # Encrypted with kubeseal
76
+ ```
77
+
78
+ ## Kustomization
79
+
80
+ ```yaml
81
+ apiVersion: kustomize.toolkit.fluxcd.io/v1
82
+ kind: Kustomization
83
+ metadata:
84
+ name: {scope}-{env}
85
+ namespace: flux-system
86
+ spec:
87
+ interval: 1m
88
+ path: ./clusters/{cluster-name}
89
+ prune: true
90
+ sourceRef:
91
+ kind: GitRepository
92
+ name: flux-system
93
+ ```
94
+
95
+ ## ImagePolicy
96
+
97
+ ```yaml
98
+ apiVersion: image.toolkit.fluxcd.io/v1beta1
99
+ kind: ImagePolicy
100
+ metadata:
101
+ name: {service-name}
102
+ spec:
103
+ imageRepositoryRef:
104
+ name: {service-name}
105
+ policy:
106
+ semver:
107
+ range: '>=1.0.0'
108
+ ```
109
+
110
+ ## Health Probes
111
+
112
+ ```yaml
113
+ livenessProbe:
114
+ httpGet:
115
+ path: /health
116
+ port: {port}
117
+ initialDelaySeconds: 30
118
+ periodSeconds: 10
119
+ timeoutSeconds: 5
120
+ failureThreshold: 3
121
+ readinessProbe:
122
+ httpGet:
123
+ path: /ready
124
+ port: {port}
125
+ initialDelaySeconds: 5
126
+ periodSeconds: 5
127
+ timeoutSeconds: 3
128
+ failureThreshold: 3
129
+ ```
130
+
131
+ ## Troubleshooting
132
+
133
+ | Issue | Check | Solution |
134
+ |-------|-------|----------|
135
+ | Pod not starting | `kubectl describe pod {name} -n {ns}` | Check events, resource limits, image pull |
136
+ | HelmRelease failed | `flux get helmrelease {name} -n {ns}` | Check chart version, values syntax |
137
+ | Image not found | `kubectl describe pod {name} -n {ns}` | Verify image exists in registry, check tag |
138
+ | Service pending | `kubectl get svc -n {ns}` | Check cloud quotas, subnet/network config |
139
+ | Flux not reconciling | `flux get kustomizations` | Check source sync, path exists |
140
+
141
+ ## Post-Push Verification
142
+
143
+ After pushing manifests to Git (T3), verify Flux reconciled successfully. Run each command separately:
144
+
145
+ ```bash
146
+ flux reconcile helmrelease {name} -n {namespace} --timeout=30s
147
+ ```
148
+
149
+ ```bash
150
+ kubectl wait --for=condition=Ready helmrelease/{name} -n {namespace} --timeout=120s
151
+ ```
152
+
153
+ ```bash
154
+ kubectl get helmrelease {name} -n {namespace} -o jsonpath='{.status.conditions[?(@.type=="Ready")]}'
155
+ ```
156
+
157
+ ## Debug Commands
158
+
159
+ ```bash
160
+ flux get helmrelease {service-name} -n {namespace} --verbose
161
+ kubectl logs -n {namespace} deployment/{service-name} --tail=100
162
+ kubectl get events -n {namespace} --sort-by='.lastTimestamp'
163
+ kubectl top pods -n {namespace}
164
+ ```
165
+
166
+ ## Resource Limits
167
+
168
+ Always set both requests AND limits:
169
+
170
+ | Size | CPU Req | CPU Lim | Mem Req | Mem Lim |
171
+ |------|---------|---------|---------|---------|
172
+ | Small | 100m | 500m | 256Mi | 512Mi |
173
+ | Medium | 250m | 1000m | 512Mi | 1Gi |
174
+ | Large | 500m | 2000m | 1Gi | 2Gi |
175
+
176
+ ## Secrets Management
177
+
178
+ ```
179
+ Preference order:
180
+ 1. SealedSecrets (Bitnami) — encrypted in Git, decrypted in cluster
181
+ 2. External Secrets — from cloud secret store (Secret Manager, Vault)
182
+ 3. NEVER plain Kubernetes Secrets in Git
183
+ ```
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: investigation
3
+ description: Use when starting an investigation, analyzing existing code or infrastructure, or building findings before proposing changes
4
+ metadata:
5
+ user-invocable: false
6
+ type: technique
7
+ ---
8
+
9
+ # Investigation
10
+
11
+ Investigation is about understanding a problem well enough to propose
12
+ a correct solution. For the `json:contract` response format, see `agent-protocol`.
13
+
14
+ ## Phase 1: Start From Injected Context
15
+
16
+ Before your first tool call, extract anchors from your injected
17
+ Project Context: paths, service names, resource IDs. These are
18
+ your starting point — go directly to them.
19
+
20
+ Define what you need to know that the context does NOT answer.
21
+ Those are your unknowns.
22
+
23
+ ## Phase 2: Explore Known Paths
24
+
25
+ For each path or name from context:
26
+ - Read the file or directory directly — no Glob needed
27
+ - Read 2-3 similar existing resources to understand conventions
28
+ - Extract: naming patterns, directory structure, dependencies
29
+
30
+ If context includes an `investigation_brief`, use it to prioritize
31
+ your surface, adjacent surfaces, and required checks.
32
+
33
+ ## Phase 3: Discover Unknowns
34
+
35
+ Search only for things NOT covered by context. Use Glob and Grep.
36
+
37
+ After initial evidence, check adjacency:
38
+ - **Neighbors:** Files next to your target often explain constraints
39
+ - **References:** What references this resource? What does it reference?
40
+ - **Breadth:** Find 2-3 instances of the same pattern. One example is
41
+ anecdote; three are convention.
42
+
43
+ Stop when new files confirm what you already know.
44
+
45
+ ## Phase 4: Live State
46
+
47
+ Only if drift is suspected or the task requires runtime data.
48
+ If you have the `fast-queries` skill, run triage first.
49
+
50
+ ## Phase 5: Pattern Hierarchy
51
+
52
+ Apply in order — do not skip levels:
53
+
54
+ 1. **Codebase first** — Find 2-3 existing resources of the same type.
55
+ If found, follow them. Consistency beats preference.
56
+ 2. **Domain skill** — If no codebase pattern, use your domain skill
57
+ (terraform-patterns, gitops-patterns, etc.)
58
+ 3. **Training knowledge** — Last resort. Mark explicitly:
59
+ *"No existing pattern found — applying best practices."*
60
+
61
+ When following patterns: **COPY** names/paths exactly.
62
+ When a pattern is problematic: **ALERT** as DEVIATION, propose alternative.
63
+
64
+ ## Phase 6: Validate Before Proposing
65
+
66
+ - Does code agree with project-context? If not → investigate drift
67
+ - Uncertain about correctness? → one more read-only validation
68
+ - Multiple valid approaches? → list options, set status `NEEDS_INPUT`
69
+
70
+ Separate what is **confirmed** (seen in code, validated) from what
71
+ is **assumed** (inferred). Never propose on assumptions.
72
+
73
+ ## Anti-Patterns
74
+
75
+ - Searching before checking if context already has the path
76
+ - Planning before resolving critical unknowns
77
+ - Treating your training preference as codebase convention
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: orchestrator-approval
3
+ description: Use when processing REVIEW with approval_id from a subagent -- enforces showing values before asking for user consent
4
+ metadata:
5
+ user-invocable: false
6
+ type: discipline
7
+ ---
8
+
9
+ # Orchestrator Approval
10
+
11
+ ```
12
+ THIS SKILL HANDLES REVIEW WITH approval_id (hook-blocked T3).
13
+ Plain REVIEW (plan-first, no approval_id) is handled directly by the orchestrator.
14
+ NEVER PRESENT AN APPROVAL WITHOUT SHOWING THE USER
15
+ (1) WHAT WILL HAPPEN, (2) EXACT CONTENT/COMMAND, (3) WHAT IT MODIFIES.
16
+ ```
17
+
18
+ ## Mental Model
19
+
20
+ The orchestrator sits between the subagent and the user. The subagent presents a plan; the user decides. But the user cannot decide on information they have not seen. Every approval prompt must contain enough detail for informed consent -- not a summary, not a reference to "the plan above", not an offer to show details on request. The values go in the prompt, every time, before the question is asked.
21
+
22
+ When a hook blocks a T3 command, it writes a pending approval and returns an `approval_id` in the deny response. The subagent includes this `approval_id` in its `approval_request`. The orchestrator presents the plan via AskUserQuestion with structured options (Approve / Modify / Reject). When the user selects "Approve", the PostToolUse hook for AskUserQuestion fires and activates the pending grant. No nonce or approval_id is relayed through SendMessage -- grant activation is handled entirely by the hook.
23
+
24
+ **Scope:** This skill applies ONLY when a subagent emits `REVIEW` with an `approval_id` in its `approval_request`. Without `approval_id`, the orchestrator handles REVIEW directly.
25
+
26
+ ## Mandatory Presentation Block
27
+
28
+ Every hook-blocked `REVIEW` presented to the user MUST include these 5 fields.
29
+ Read them from the `approval_request` object in the agent's `json:contract` block:
30
+
31
+ | Field | Source in `approval_request` | Content |
32
+ |-------|------------------------------|---------|
33
+ | **OPERATION** | `approval_request.operation` | What will happen (verb + target) |
34
+ | **EXACT_CONTENT** | `approval_request.exact_content` | The literal command, file content, or config values |
35
+ | **SCOPE** | `approval_request.scope` | What gets modified (files, resources, environments) |
36
+ | **RISK_LEVEL** | `approval_request.risk_level` | LOW / MEDIUM / HIGH / CRITICAL |
37
+ | **ROLLBACK** | `approval_request.rollback` | How to undo if wrong |
38
+
39
+ ## Rules
40
+
41
+ **1. Grant activates through the PostToolUse hook for AskUserQuestion -- not SendMessage.**
42
+ Resume the subagent via SendMessage with natural language only (e.g., "Proceed with the approved operation"). Never include any nonce, approval_id, or APPROVE: token.
43
+
44
+ **2. Scope guard.**
45
+ Compare the blocked command's scope to what the user originally approved. If the command expands scope, changes operation, or targets something materially different -- present the new scope and ask again.
46
+
47
+ **3. Fresh presentation every time.**
48
+ Each hook-blocked REVIEW requires its own presentation with all mandatory fields. Prior approvals do not carry forward.
49
+
50
+ ## Approval Procedure
51
+
52
+ 1. Extract the 5 mandatory fields from `approval_request` in the subagent's `json:contract` block.
53
+ 2. Present to the user via AskUserQuestion with all mandatory fields populated. Use exactly these options: **Approve / Modify / Reject**. Never include the approval_id in user-facing text.
54
+ 3. On "Approve": resume the subagent via SendMessage with natural language describing the approved direction.
55
+ 4. On scope change: present the new scope with all mandatory fields and ask again.
56
+
57
+ ## Anti-Patterns
58
+
59
+ - **Summary-only approval** -- presenting "Deploy to dev?" without the exact command, files, or rollback.
60
+ - **Token relay in SendMessage** -- including approval_id or nonce in the resume message.
61
+ - **Implicit carry-forward** -- treating a prior approval as valid for a new hook-blocked REVIEW.
62
+ - **Details on demand** -- offering to show the plan instead of showing it upfront.
63
+ - **"It's just a small change"** -- size does not change the contract. Show exact content regardless.
64
+ - **"The subagent already showed it"** -- show it again in the approval prompt.
@@ -0,0 +1,134 @@
1
+ # Agent Reference
2
+
3
+ Reference material for the gaia meta-agent. Load from disk when needed.
4
+
5
+ ## Agent Template
6
+
7
+ ```markdown
8
+ ---
9
+ name: agent-name
10
+ description: One-line description of what this agent does
11
+ tools: Tool1, Tool2, Tool3
12
+ model: inherit
13
+ skills:
14
+ - security-tiers
15
+ - agent-protocol
16
+ - context-updater
17
+ - investigation
18
+ - command-execution
19
+ ---
20
+
21
+ ## TL;DR
22
+
23
+ **Purpose:** [What this agent does]
24
+ **Input:** [What context it needs]
25
+ **Output:** [What it produces]
26
+ **Tier:** [T0-T2 or T0-T3]
27
+
28
+ For T3 approval/execution workflows, read `.claude/skills/approval/SKILL.md` and `.claude/skills/execution/SKILL.md`.
29
+
30
+ ---
31
+
32
+ ## Core Identity
33
+
34
+ [What makes this agent unique - 2-3 paragraphs max]
35
+
36
+ ### Code-First Protocol
37
+
38
+ 1. **Trust the Contract** - [Key contract field]
39
+ 2. **Analyze Before Generating** - Follow `investigation` skill
40
+ 3. **Pattern-Aware Generation** - [Domain-specific generation rules]
41
+ 4. **Validate** - [Domain-specific validation]
42
+ 5. **Output is a Realization Package** - [What the package contains]
43
+
44
+ ---
45
+
46
+ ## 4-Phase Workflow
47
+
48
+ ### Phase 1: Investigation
49
+ Follow `investigation` skill protocol. Then: [domain-specific steps]
50
+
51
+ ### Phase 2: Present
52
+ [What to show user]
53
+
54
+ ### Phase 3: Confirm
55
+ [Approval requirements]
56
+
57
+ ### Phase 4: Execute
58
+ [Execution steps]
59
+
60
+ ---
61
+
62
+ ## Scope
63
+
64
+ ### CAN DO
65
+ - [List capabilities]
66
+
67
+ ### CANNOT DO
68
+ - [List restrictions with delegation targets]
69
+
70
+ ### DELEGATE
71
+ [When to recommend other agents]
72
+
73
+ ---
74
+
75
+ ## Error Handling
76
+
77
+ | Error | Detection | Recovery |
78
+ |-------|-----------|----------|
79
+ | [error] | [how detected] | [how to recover] |
80
+ ```
81
+
82
+ ## Release Checklist
83
+
84
+ When publishing a new version:
85
+
86
+ 1. Read `package.json` for current version
87
+ 2. Review changes (`git log`, CHANGELOG.md)
88
+ 3. Determine version bump (patch/minor/major)
89
+ 4. Update CHANGELOG.md with changes
90
+ 5. Test symlinks work in consuming project:
91
+ ```bash
92
+ # In consuming project
93
+ ls -la .claude/ # Should point to node_modules/@jaguilar87/gaia-ops/
94
+ ```
95
+ 6. Bump version:
96
+ ```bash
97
+ npm version [patch|minor|major]
98
+ ```
99
+ 7. Publish:
100
+ ```bash
101
+ npm publish --access public
102
+ ```
103
+ 8. Verify:
104
+ ```bash
105
+ npm info @jaguilar87/gaia-ops version
106
+ ```
107
+
108
+ ## Documentation Template
109
+
110
+ ```markdown
111
+ # Component Name
112
+
113
+ Brief description of what this does and why it exists.
114
+ Written like you're explaining to a colleague.
115
+
116
+ ## Where This Fits
117
+
118
+ ```
119
+ User request → Orchestrator → **This Tool** → Agent receives context
120
+ ```
121
+
122
+ ## Quick Start
123
+
124
+ \`\`\`bash
125
+ python3 tool.py --help
126
+ \`\`\`
127
+
128
+ ## Examples
129
+
130
+ \`\`\`bash
131
+ python3 tool.py "example input"
132
+ # Output: example output
133
+ \`\`\`
134
+ ```