@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,278 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Surface routing and investigation brief generation.
4
+
5
+ Provides deterministic surface classification for Gaia tasks using generic
6
+ cross-repo surfaces instead of repo-specific routing tables.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ from dataclasses import asdict, dataclass
13
+ from pathlib import Path
14
+ from typing import Any, Dict, List, Optional
15
+
16
+ try:
17
+ from ._paths import resolve_config_dir
18
+ except ImportError:
19
+ from _paths import resolve_config_dir
20
+
21
+
22
+ DEFAULT_SURFACE_ROUTING_FILE = "surface-routing.json"
23
+ EVIDENCE_REPORT_FIELDS = [
24
+ "PATTERNS_CHECKED",
25
+ "FILES_CHECKED",
26
+ "COMMANDS_RUN",
27
+ "KEY_OUTPUTS",
28
+ "VERBATIM_OUTPUTS",
29
+ "CROSS_LAYER_IMPACTS",
30
+ "OPEN_GAPS",
31
+ ]
32
+ # All fields including OWNERSHIP_ASSESSMENT (for investigation brief injection).
33
+ # The runtime validator in response_contract.py separates OWNERSHIP_ASSESSMENT
34
+ # for enum validation; its CONSOLIDATION_FIELDS list excludes it.
35
+ CONSOLIDATION_REPORT_FIELDS = [
36
+ "OWNERSHIP_ASSESSMENT",
37
+ "CONFIRMED_FINDINGS",
38
+ "SUSPECTED_FINDINGS",
39
+ "CONFLICTS",
40
+ "OPEN_GAPS",
41
+ "NEXT_BEST_AGENT",
42
+ ]
43
+
44
+
45
+ def _get_config_dir() -> Path:
46
+ """Resolve config directory from installed project or package checkout."""
47
+ return resolve_config_dir()
48
+
49
+
50
+ def load_surface_routing_config(config_file: Optional[Path] = None) -> Dict[str, Any]:
51
+ """Load surface routing config. Returns empty config if missing or invalid."""
52
+ if config_file is None:
53
+ config_file = _get_config_dir() / DEFAULT_SURFACE_ROUTING_FILE
54
+
55
+ if not config_file.is_file():
56
+ return {"version": "missing", "reconnaissance_agent": "devops-developer", "surfaces": {}}
57
+
58
+ try:
59
+ return json.loads(config_file.read_text())
60
+ except Exception:
61
+ return {"version": "invalid", "reconnaissance_agent": "devops-developer", "surfaces": {}}
62
+
63
+
64
+ @dataclass(frozen=True)
65
+ class SurfaceMatch:
66
+ surface: str
67
+ score: float
68
+ matched_signals: List[str]
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ return asdict(self)
72
+
73
+
74
+ def _normalize_text(text: str) -> str:
75
+ return " ".join((text or "").lower().split())
76
+
77
+
78
+ def _score_surface(task_text: str, surface_name: str, surface_cfg: Dict[str, Any]) -> SurfaceMatch:
79
+ signals = surface_cfg.get("signals", {})
80
+ matched: List[str] = []
81
+ score = 0.0
82
+
83
+ for keyword in signals.get("keywords", []):
84
+ if keyword.lower() in task_text:
85
+ matched.append(keyword)
86
+ score += 1.0
87
+
88
+ for command in signals.get("commands", []):
89
+ if command.lower() in task_text:
90
+ matched.append(command)
91
+ score += 1.5
92
+
93
+ for artifact in signals.get("artifacts", []):
94
+ if artifact.lower() in task_text:
95
+ matched.append(artifact)
96
+ score += 1.0
97
+
98
+ # Small boost for explicit surface names.
99
+ if surface_name.lower() in task_text:
100
+ matched.append(surface_name)
101
+ score += 1.0
102
+
103
+ return SurfaceMatch(surface=surface_name, score=score, matched_signals=matched)
104
+
105
+
106
+ def classify_surfaces(
107
+ task: str,
108
+ *,
109
+ current_agent: str = "",
110
+ routing_config: Optional[Dict[str, Any]] = None,
111
+ ) -> Dict[str, Any]:
112
+ """
113
+ Deterministically classify active surfaces for a task.
114
+
115
+ The classifier uses generic surface signals, not repo-specific topology.
116
+ """
117
+ config = routing_config or load_surface_routing_config()
118
+ surfaces_cfg = config.get("surfaces", {})
119
+ reconnaissance_agent = config.get("reconnaissance_agent", "devops-developer")
120
+ task_text = _normalize_text(task)
121
+
122
+ matches: List[SurfaceMatch] = []
123
+ for surface_name, surface_cfg in surfaces_cfg.items():
124
+ match = _score_surface(task_text, surface_name, surface_cfg)
125
+ if match.score > 0:
126
+ matches.append(match)
127
+
128
+ matches.sort(key=lambda item: item.score, reverse=True)
129
+
130
+ if matches:
131
+ top_score = matches[0].score
132
+ active_matches = [
133
+ match for match in matches
134
+ if match.score >= 1.0 and (match.score == top_score or match.score >= (top_score * 0.55))
135
+ ]
136
+ else:
137
+ active_matches = []
138
+
139
+ agent_to_surface = {
140
+ cfg.get("primary_agent", ""): surface_name
141
+ for surface_name, cfg in surfaces_cfg.items()
142
+ }
143
+ fallback_surface = agent_to_surface.get(current_agent, "")
144
+
145
+ if not active_matches and fallback_surface:
146
+ active_matches = [SurfaceMatch(surface=fallback_surface, score=0.2, matched_signals=["agent-fallback"])]
147
+
148
+ active_surfaces = [match.surface for match in active_matches]
149
+ match_map = {match.surface: match for match in active_matches}
150
+
151
+ if not active_surfaces:
152
+ return {
153
+ "active_surfaces": [],
154
+ "primary_surface": "",
155
+ "multi_surface": False,
156
+ "dispatch_mode": "reconnaissance",
157
+ "confidence": 0.0,
158
+ "recommended_agents": [reconnaissance_agent],
159
+ "matched_signals": {},
160
+ "reconnaissance_agent": reconnaissance_agent,
161
+ }
162
+
163
+ if current_agent in agent_to_surface and agent_to_surface[current_agent] in active_surfaces:
164
+ primary_surface = agent_to_surface[current_agent]
165
+ else:
166
+ primary_surface = active_surfaces[0]
167
+
168
+ recommended_agents = []
169
+ for surface_name in active_surfaces:
170
+ agent = surfaces_cfg.get(surface_name, {}).get("primary_agent", "")
171
+ if agent and agent not in recommended_agents:
172
+ recommended_agents.append(agent)
173
+
174
+ if len(active_surfaces) == 1:
175
+ dispatch_mode = "single_surface"
176
+ elif "planning_specs" in active_surfaces:
177
+ dispatch_mode = "sequential"
178
+ else:
179
+ dispatch_mode = "parallel"
180
+
181
+ confidence = round(min(1.0, sum(match.score for match in active_matches) / max(len(active_matches) * 3.0, 1.0)), 2)
182
+
183
+ return {
184
+ "active_surfaces": active_surfaces,
185
+ "primary_surface": primary_surface,
186
+ "multi_surface": len(active_surfaces) > 1,
187
+ "dispatch_mode": dispatch_mode,
188
+ "confidence": confidence,
189
+ "recommended_agents": recommended_agents or [reconnaissance_agent],
190
+ "matched_signals": {surface: match_map[surface].matched_signals for surface in active_surfaces},
191
+ "reconnaissance_agent": reconnaissance_agent,
192
+ }
193
+
194
+
195
+ def build_investigation_brief(
196
+ task: str,
197
+ agent_name: str,
198
+ contract_context: Dict[str, Any],
199
+ *,
200
+ routing_config: Optional[Dict[str, Any]] = None,
201
+ routing: Optional[Dict[str, Any]] = None,
202
+ ) -> Dict[str, Any]:
203
+ """
204
+ Build a deterministic investigation brief for the current agent.
205
+ """
206
+ config = routing_config or load_surface_routing_config()
207
+ surfaces_cfg = config.get("surfaces", {})
208
+ if routing is None:
209
+ routing = classify_surfaces(task, current_agent=agent_name, routing_config=config)
210
+
211
+ primary_surface = routing.get("primary_surface", "")
212
+ primary_cfg = surfaces_cfg.get(primary_surface, {})
213
+ active_surfaces = routing.get("active_surfaces", [])
214
+ adjacent_surfaces = []
215
+ for surface_name in active_surfaces:
216
+ if surface_name != primary_surface and surface_name not in adjacent_surfaces:
217
+ adjacent_surfaces.append(surface_name)
218
+ for surface_name in primary_cfg.get("adjacent_surfaces", []):
219
+ if surface_name != primary_surface and surface_name not in adjacent_surfaces:
220
+ adjacent_surfaces.append(surface_name)
221
+
222
+ recommended_agents = routing.get("recommended_agents", [])
223
+ peer_agents = [agent for agent in recommended_agents if agent != agent_name]
224
+
225
+ agent_surface = ""
226
+ for surface_name, cfg in surfaces_cfg.items():
227
+ if cfg.get("primary_agent") == agent_name:
228
+ agent_surface = surface_name
229
+ break
230
+
231
+ if not active_surfaces:
232
+ role = "reconnaissance"
233
+ elif agent_surface == primary_surface:
234
+ role = "primary"
235
+ elif agent_surface in active_surfaces:
236
+ role = "cross_check"
237
+ else:
238
+ role = "adjacent"
239
+
240
+ cross_check_required = len(active_surfaces) > 1 or (agent_surface and agent_surface != primary_surface)
241
+
242
+ search_anchors = sorted(contract_context.keys())
243
+ required_checks = list(primary_cfg.get("required_checks", []))
244
+ for surface_name in adjacent_surfaces:
245
+ for check in surfaces_cfg.get(surface_name, {}).get("required_checks", []):
246
+ if check not in required_checks:
247
+ required_checks.append(check)
248
+
249
+ return {
250
+ "goal": task,
251
+ "agent_role": role,
252
+ "primary_surface": primary_surface,
253
+ "active_surfaces": active_surfaces,
254
+ "adjacent_surfaces": adjacent_surfaces,
255
+ "dispatch_mode": routing.get("dispatch_mode", "single_surface"),
256
+ "cross_check_required": cross_check_required,
257
+ "patterns_required": True,
258
+ "contract_sections_to_anchor": search_anchors,
259
+ "required_checks": required_checks,
260
+ "evidence_required": EVIDENCE_REPORT_FIELDS,
261
+ "consolidation_required": cross_check_required,
262
+ "consolidation_fields": CONSOLIDATION_REPORT_FIELDS if cross_check_required else [],
263
+ "recommended_peer_agents": peer_agents,
264
+ "stop_conditions": [
265
+ "Stop when additional files or commands only confirm the same conclusion without changing the decision.",
266
+ "Do not declare cross-surface work complete without filling CROSS_LAYER_IMPACTS and OPEN_GAPS.",
267
+ "If another surface owns the fix, name the next agent instead of guessing across domains.",
268
+ ],
269
+ }
270
+
271
+
272
+ __all__ = [
273
+ "EVIDENCE_REPORT_FIELDS",
274
+ "CONSOLIDATION_REPORT_FIELDS",
275
+ "build_investigation_brief",
276
+ "classify_surfaces",
277
+ "load_surface_routing_config",
278
+ ]
@@ -0,0 +1,65 @@
1
+ # Fast-Queries: Quick Health Checks
2
+
3
+ Optimized diagnostic scripts that provide instant health status in <5 seconds.
4
+ Only shows problems, not everything.
5
+
6
+ ## Quick Usage
7
+
8
+ ```bash
9
+ # Run all health checks
10
+ .claude/tools/fast-queries/run_triage.sh
11
+
12
+ # Run specific checks
13
+ .claude/tools/fast-queries/run_triage.sh gitops # Kubernetes/pods
14
+ .claude/tools/fast-queries/run_triage.sh terraform # Terraform validation
15
+ .claude/tools/fast-queries/run_triage.sh gcp # GCP resources
16
+ ```
17
+
18
+ ## Available Scripts
19
+
20
+ ### 1. GitOps Health Check
21
+ ```bash
22
+ .claude/tools/fast-queries/gitops/quicktriage_gitops_operator.sh [namespace]
23
+ ```
24
+ **Output:** Only shows problematic pods, deployments not ready, and recent warnings.
25
+
26
+ ### 2. Terraform Validation
27
+ ```bash
28
+ .claude/tools/fast-queries/terraform/quicktriage_terraform_architect.sh [directory]
29
+ ```
30
+ **Output:** ✅/❌ for format, validation, and drift detection.
31
+
32
+ ### 3. GCP Resources Check
33
+ ```bash
34
+ .claude/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh [project]
35
+ ```
36
+ **Output:** Status of GKE clusters, Cloud SQL, recent errors, and quota warnings.
37
+
38
+ ## For Agents
39
+
40
+ Add this to agent prompts for quick diagnostics:
41
+
42
+ ```bash
43
+ # Instead of multiple kubectl/terraform/gcloud commands:
44
+ bash .claude/tools/fast-queries/gitops/quicktriage_gitops_operator.sh namespace
45
+ ```
46
+
47
+ ## Output Format
48
+
49
+ All scripts follow the same pattern:
50
+ - ✅ = Healthy/OK
51
+ - ❌ = Problem detected
52
+ - ⚠️ = Warning/non-critical issue
53
+
54
+ Exit codes:
55
+ - 0 = All healthy
56
+ - 1 = Issues found
57
+ - 2 = Script error (missing tools)
58
+
59
+ ## Performance
60
+
61
+ | Script | Duration | Focus |
62
+ |--------|----------|-------|
63
+ | GitOps | 2-3 sec | Pod/deployment health |
64
+ | Terraform | 3-4 sec | Validation & drift |
65
+ | GCP | 4-5 sec | Resource availability |
@@ -0,0 +1,30 @@
1
+ """
2
+ Fast-Queries Module: Agent diagnostic scripts
3
+
4
+ This module provides quick diagnostic and health-check scripts for each Gaia-Ops agent.
5
+ Scripts provide instant snapshots of system state without invoking the full orchestration workflow.
6
+
7
+ Typical usage:
8
+ # Run all diagnostics via CLI
9
+ $ .claude/tools/fast-queries/run_triage.sh all
10
+
11
+ # Run specific agent
12
+ $ .claude/tools/fast-queries/run_triage.sh terraform
13
+
14
+ Available agents:
15
+ - terraform: Terraform/Terragrunt validation
16
+ - gitops: Kubernetes/Flux/Helm snapshots
17
+ - gcp: GCP GKE/SQL/IAM diagnostics
18
+ - aws: AWS EKS/VPC/CloudWatch diagnostics
19
+ - devops: Application health & hygiene checks
20
+
21
+ See README.md for detailed documentation.
22
+ """
23
+
24
+ __version__ = "1.0.0"
25
+ __all__ = [
26
+ "terraform",
27
+ "gitops",
28
+ "cloud",
29
+ "appservices",
30
+ ]
@@ -0,0 +1,75 @@
1
+ #!/bin/bash
2
+ # QuickTriage script for DevOps Developer
3
+ # Description: Quick health check for application services and development environment
4
+
5
+ # Usage: quicktriage_devops_developer.sh [repo_path]
6
+
7
+ set -euo pipefail
8
+
9
+ REPO_PATH="${1:-.}"
10
+
11
+ echo "=========================================="
12
+ echo "DevOps Developer QuickTriage"
13
+ echo "=========================================="
14
+ echo "Repository: $REPO_PATH"
15
+ echo "=========================================="
16
+ echo ""
17
+
18
+ # Change to repo directory
19
+ cd "$REPO_PATH"
20
+
21
+ # Check for common configuration files
22
+ echo "### Configuration Files ###"
23
+ for file in package.json docker-compose.yml Dockerfile .env.example Makefile; do
24
+ if [ -f "$file" ]; then
25
+ echo "[OK] $file exists"
26
+ else
27
+ echo "[--] $file not found"
28
+ fi
29
+ done
30
+ echo ""
31
+
32
+ # Check git status
33
+ echo "### Git Status ###"
34
+ if [ -d ".git" ]; then
35
+ git status --short 2>/dev/null || echo "Git status failed"
36
+ echo ""
37
+ echo "Branch: $(git branch --show-current 2>/dev/null || echo 'unknown')"
38
+ else
39
+ echo "Not a git repository"
40
+ fi
41
+ echo ""
42
+
43
+ # Check for node modules (if package.json exists)
44
+ if [ -f "package.json" ]; then
45
+ echo "### Node.js Project ###"
46
+ if [ -d "node_modules" ]; then
47
+ echo "[OK] node_modules present"
48
+ else
49
+ echo "[WARN] node_modules missing - run npm install"
50
+ fi
51
+
52
+ # Check for common scripts
53
+ echo ""
54
+ echo "Available scripts:"
55
+ if command -v jq &> /dev/null; then
56
+ jq -r '.scripts | keys[]' package.json 2>/dev/null | head -10 || echo "Could not parse scripts"
57
+ else
58
+ grep -A20 '"scripts"' package.json 2>/dev/null | head -10 || echo "Could not read scripts"
59
+ fi
60
+ echo ""
61
+ fi
62
+
63
+ # Check Docker
64
+ echo "### Docker Status ###"
65
+ if command -v docker &> /dev/null; then
66
+ echo "[OK] Docker available"
67
+ docker info --format '{{.ContainersRunning}} containers running' 2>/dev/null || echo "Docker not accessible"
68
+ else
69
+ echo "[--] Docker not installed"
70
+ fi
71
+ echo ""
72
+
73
+ echo "=========================================="
74
+ echo "QuickTriage Complete"
75
+ echo "=========================================="
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ # QuickTriage script for AWS Troubleshooter
3
+ # Status: STANDBY - AWS agent not yet active
4
+
5
+ # Description: Quick health check for AWS infrastructure
6
+ # Usage: quicktriage_aws_troubleshooter.sh [profile] [region]
7
+ # Note: This agent is currently in standby mode
8
+
9
+ set -euo pipefail
10
+
11
+ PROFILE="${1:-default}"
12
+ REGION="${2:-us-east-1}"
13
+
14
+ echo "=========================================="
15
+ echo "AWS QuickTriage - Troubleshooter"
16
+ echo "=========================================="
17
+ echo "Profile: $PROFILE"
18
+ echo "Region: $REGION"
19
+ echo "Status: STANDBY"
20
+ echo "=========================================="
21
+ echo ""
22
+ echo "AWS Troubleshooter is in standby mode."
23
+ echo "Use GCP Troubleshooter for cloud diagnostics."
24
+ echo ""
25
+ echo "When activated, this script will check:"
26
+ echo " - EC2 instance status"
27
+ echo " - RDS database health"
28
+ echo " - EKS cluster status"
29
+ echo " - IAM role configurations"
30
+ echo " - CloudWatch alarms"
31
+ echo ""
32
+ echo "=========================================="
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # QuickTriage for GCP - Optimized version
3
+ # Only shows critical resource status
4
+
5
+ set -euo pipefail
6
+
7
+ PROJECT="${GCP_PROJECT:-${1:-}}"
8
+ CLUSTER="${GKE_CLUSTER:-${2:-}}"
9
+ REGION="${GKE_REGION:-${3:-us-central1}}"
10
+
11
+ # Get current project if not specified
12
+ if [ -z "$PROJECT" ]; then
13
+ PROJECT=$(gcloud config get-value project 2>/dev/null || echo "")
14
+ fi
15
+
16
+ echo "=== GCP HEALTH CHECK: ${PROJECT:-no-project} ==="
17
+
18
+ if ! command -v gcloud >/dev/null 2>&1; then
19
+ echo "❌ gcloud CLI not installed"
20
+ exit 2
21
+ fi
22
+
23
+ if [ -z "$PROJECT" ]; then
24
+ echo "❌ No GCP project configured"
25
+ echo " Run: gcloud config set project PROJECT_ID"
26
+ exit 1
27
+ fi
28
+
29
+ # 1. GKE Clusters status (only if unhealthy)
30
+ echo -n "GKE Clusters: "
31
+ CLUSTERS=$(gcloud container clusters list --project="$PROJECT" --format="value(name,status)" 2>/dev/null || echo "")
32
+ if [ -z "$CLUSTERS" ]; then
33
+ echo "⚠️ No clusters found"
34
+ else
35
+ UNHEALTHY=$(echo "$CLUSTERS" | grep -v "RUNNING" || echo "")
36
+ if [ -n "$UNHEALTHY" ]; then
37
+ echo "❌ Issues detected"
38
+ echo "$UNHEALTHY" | awk '{printf " - %s: %s\n", $1, $2}'
39
+ else
40
+ CLUSTER_COUNT=$(echo "$CLUSTERS" | wc -l)
41
+ echo "✅ $CLUSTER_COUNT cluster(s) running"
42
+ fi
43
+ fi
44
+
45
+ # 2. Cloud SQL status (only if issues)
46
+ echo -n "Cloud SQL: "
47
+ SQL_INSTANCES=$(gcloud sql instances list --project="$PROJECT" --format="value(name,state)" 2>/dev/null || echo "")
48
+ if [ -z "$SQL_INSTANCES" ]; then
49
+ echo "⚠️ No instances found"
50
+ else
51
+ SQL_DOWN=$(echo "$SQL_INSTANCES" | grep -v "RUNNABLE" || echo "")
52
+ if [ -n "$SQL_DOWN" ]; then
53
+ echo "❌ Issues detected"
54
+ echo "$SQL_DOWN" | awk '{printf " - %s: %s\n", $1, $2}'
55
+ else
56
+ SQL_COUNT=$(echo "$SQL_INSTANCES" | wc -l)
57
+ echo "✅ $SQL_COUNT instance(s) running"
58
+ fi
59
+ fi
60
+
61
+ # 3. Recent errors (only critical)
62
+ echo -n "Recent errors: "
63
+ ERROR_COUNT=$(gcloud logging read "severity>=ERROR AND timestamp>=\"$(date -u -d '1 hour ago' '+%Y-%m-%dT%H:%M:%S')\"" \
64
+ --limit=10 --project="$PROJECT" --format="value(textPayload)" 2>/dev/null | wc -l || echo "0")
65
+
66
+ if [ "$ERROR_COUNT" -gt 0 ]; then
67
+ echo "⚠️ $ERROR_COUNT errors in last hour"
68
+ # Show top 3 error sources
69
+ gcloud logging read "severity>=ERROR AND timestamp>=\"$(date -u -d '1 hour ago' '+%Y-%m-%dT%H:%M:%S')\"" \
70
+ --limit=10 --project="$PROJECT" --format="value(resource.labels.cluster_name,textPayload)" 2>/dev/null | \
71
+ head -3 | sed 's/^/ - /' || true
72
+ else
73
+ echo "✅ No recent errors"
74
+ fi
75
+
76
+ # 4. Quota warnings (only if near limits)
77
+ echo -n "Quota status: "
78
+ QUOTA_ISSUES=$(gcloud compute project-info describe --project="$PROJECT" --format="value(quotas[].usage,quotas[].limit)" 2>/dev/null | \
79
+ awk '{if ($1/$2 > 0.8) print "High usage"}' | head -1 || echo "")
80
+
81
+ if [ -n "$QUOTA_ISSUES" ]; then
82
+ echo "⚠️ Some quotas >80% used"
83
+ else
84
+ echo "✅ All quotas healthy"
85
+ fi
86
+
87
+ # Exit code based on critical issues
88
+ [ -n "$UNHEALTHY" ] || [ -n "$SQL_DOWN" ] && exit 1 || exit 0
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ # QuickTriage for GitOps - Optimized version
3
+ # Only shows problems, not everything
4
+
5
+ set -euo pipefail
6
+
7
+ NAMESPACE="${1:-tcm-non-prod}"
8
+
9
+ echo "=== HEALTH CHECK: $NAMESPACE ==="
10
+
11
+ # 1. Only problematic pods (not all pods)
12
+ PROBLEM_PODS=$(kubectl get pods -n "$NAMESPACE" --no-headers 2>/dev/null | grep -v "Running\|Completed" || echo "")
13
+ if [ -n "$PROBLEM_PODS" ]; then
14
+ echo "❌ PODS WITH ISSUES:"
15
+ echo "$PROBLEM_PODS" | awk '{printf " - %s: %s (restarts: %s)\n", $1, $3, $4}'
16
+ else
17
+ echo "✅ All pods healthy"
18
+ fi
19
+
20
+ # 2. Only deployments with missing replicas
21
+ DEPLOY_ISSUES=$(kubectl get deploy -n "$NAMESPACE" --no-headers 2>/dev/null | awk '$2!=$3 {print $1, $2"/"$3}' || echo "")
22
+ if [ -n "$DEPLOY_ISSUES" ]; then
23
+ echo "❌ DEPLOYMENTS NOT READY:"
24
+ echo "$DEPLOY_ISSUES" | awk '{printf " - %s: %s replicas\n", $1, $2}'
25
+ else
26
+ echo "✅ All deployments ready"
27
+ fi
28
+
29
+ # 3. HelmRelease summary (1 line)
30
+ if command -v kubectl >/dev/null 2>&1 && kubectl api-resources | grep -q helmrelease 2>/dev/null; then
31
+ HR_COUNT=$(kubectl get helmrelease -n "$NAMESPACE" --no-headers 2>/dev/null | wc -l || echo "0")
32
+ HR_FAILED=$(kubectl get helmrelease -n "$NAMESPACE" --no-headers 2>/dev/null | grep -c False || echo "0")
33
+ if [ "$HR_FAILED" -gt 0 ]; then
34
+ echo "❌ HelmReleases: $HR_FAILED/$HR_COUNT failed"
35
+ elif [ "$HR_COUNT" -gt 0 ]; then
36
+ echo "✅ HelmReleases: $HR_COUNT healthy"
37
+ fi
38
+ fi
39
+
40
+ # 4. Recent warnings only (last 5)
41
+ WARNINGS=$(kubectl get events -n "$NAMESPACE" --field-selector type=Warning --no-headers 2>/dev/null | tail -5 || echo "")
42
+ if [ -n "$WARNINGS" ]; then
43
+ echo "⚠️ Recent warnings:"
44
+ echo "$WARNINGS" | awk '{print " - " $5 ": " substr($0, index($0,$6))}'
45
+ fi
46
+
47
+ # Exit code based on issues
48
+ [ -n "$PROBLEM_PODS" ] || [ -n "$DEPLOY_ISSUES" ] || [ "$HR_FAILED" -gt 0 ] && exit 1 || exit 0
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env bash
2
+ # Fast-Queries Runner - Simplified version
3
+ # Only runs the 3 essential triages
4
+
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ SELECTED="${1:-all}"
9
+
10
+ # Colors for output
11
+ GREEN='\033[0;32m'
12
+ RED='\033[0;31m'
13
+ YELLOW='\033[0;33m'
14
+ NC='\033[0m' # No Color
15
+
16
+ run_script() {
17
+ local script="$1"
18
+ local name="$2"
19
+
20
+ echo -e "\n${YELLOW}Running $name...${NC}"
21
+
22
+ if [ ! -f "$script" ]; then
23
+ echo -e "${RED}✗ Script not found: $script${NC}"
24
+ return 1
25
+ fi
26
+
27
+ if bash "$script"; then
28
+ echo -e "${GREEN}✓ $name completed${NC}"
29
+ return 0
30
+ else
31
+ echo -e "${RED}✗ $name found issues${NC}"
32
+ return 1
33
+ fi
34
+ }
35
+
36
+ echo "=== FAST HEALTH CHECK ==="
37
+
38
+ case "$SELECTED" in
39
+ all)
40
+ run_script "$SCRIPT_DIR/gitops/quicktriage_gitops_operator.sh" "GitOps"
41
+ run_script "$SCRIPT_DIR/terraform/quicktriage_terraform_architect.sh" "Terraform"
42
+ run_script "$SCRIPT_DIR/cloud/gcp/quicktriage_gcp_troubleshooter.sh" "GCP"
43
+ ;;
44
+ gitops|k8s|kubernetes)
45
+ run_script "$SCRIPT_DIR/gitops/quicktriage_gitops_operator.sh" "GitOps"
46
+ ;;
47
+ terraform|tf)
48
+ run_script "$SCRIPT_DIR/terraform/quicktriage_terraform_architect.sh" "Terraform"
49
+ ;;
50
+ gcp|cloud)
51
+ run_script "$SCRIPT_DIR/cloud/gcp/quicktriage_gcp_troubleshooter.sh" "GCP"
52
+ ;;
53
+ *)
54
+ echo "Usage: $0 [all|gitops|terraform|gcp]"
55
+ exit 1
56
+ ;;
57
+ esac
58
+
59
+ echo -e "\n${GREEN}Health check complete${NC}"