@jaguilar87/gaia 5.0.0-rc1

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 (609) hide show
  1. package/.claude-plugin/marketplace.json +33 -0
  2. package/.claude-plugin/plugin.json +26 -0
  3. package/ARCHITECTURE.md +335 -0
  4. package/CHANGELOG.md +1212 -0
  5. package/CODE_OF_CONDUCT.md +11 -0
  6. package/CONTRIBUTING.md +146 -0
  7. package/INSTALL.md +436 -0
  8. package/LICENSE +21 -0
  9. package/README.md +222 -0
  10. package/SECURITY.md +47 -0
  11. package/agents/README.md +78 -0
  12. package/agents/cloud-troubleshooter.md +73 -0
  13. package/agents/developer.md +65 -0
  14. package/agents/gaia-operator.md +64 -0
  15. package/agents/gaia-orchestrator.md +237 -0
  16. package/agents/gaia-planner.md +53 -0
  17. package/agents/gaia-system.md +70 -0
  18. package/agents/gitops-operator.md +61 -0
  19. package/agents/terraform-architect.md +63 -0
  20. package/bin/README.md +106 -0
  21. package/bin/cli/__init__.py +1 -0
  22. package/bin/cli/approvals.py +740 -0
  23. package/bin/cli/cleanup.py +562 -0
  24. package/bin/cli/context.py +283 -0
  25. package/bin/cli/doctor.py +628 -0
  26. package/bin/cli/history.py +305 -0
  27. package/bin/cli/memory.py +464 -0
  28. package/bin/cli/metrics.py +1068 -0
  29. package/bin/cli/plans.py +515 -0
  30. package/bin/cli/status.py +302 -0
  31. package/bin/cli/update.py +382 -0
  32. package/bin/gaia +112 -0
  33. package/bin/gaia-cleanup.js +531 -0
  34. package/bin/gaia-doctor.js +635 -0
  35. package/bin/gaia-evidence +126 -0
  36. package/bin/gaia-history.js +251 -0
  37. package/bin/gaia-metrics.js +1278 -0
  38. package/bin/gaia-review.js +269 -0
  39. package/bin/gaia-scan +44 -0
  40. package/bin/gaia-scan.py +589 -0
  41. package/bin/gaia-skills-diagnose.js +929 -0
  42. package/bin/gaia-status.js +278 -0
  43. package/bin/gaia-uninstall.js +111 -0
  44. package/bin/gaia-update.js +816 -0
  45. package/bin/pre-publish-validate.js +610 -0
  46. package/bin/python-detect.js +60 -0
  47. package/commands/README.md +64 -0
  48. package/commands/gaia.md +37 -0
  49. package/commands/scan-project.md +67 -0
  50. package/config/README.md +71 -0
  51. package/config/cloud/aws.json +134 -0
  52. package/config/cloud/gcp.json +139 -0
  53. package/config/context-contracts.json +158 -0
  54. package/config/crons-schema.md +81 -0
  55. package/config/git_standards.json +72 -0
  56. package/config/surface-routing.json +421 -0
  57. package/config/universal-rules.json +102 -0
  58. package/dist/gaia-ops/.claude-plugin/plugin.json +24 -0
  59. package/dist/gaia-ops/README.md +80 -0
  60. package/dist/gaia-ops/agents/cloud-troubleshooter.md +73 -0
  61. package/dist/gaia-ops/agents/developer.md +65 -0
  62. package/dist/gaia-ops/agents/gaia-operator.md +64 -0
  63. package/dist/gaia-ops/agents/gaia-orchestrator.md +237 -0
  64. package/dist/gaia-ops/agents/gaia-planner.md +53 -0
  65. package/dist/gaia-ops/agents/gaia-system.md +70 -0
  66. package/dist/gaia-ops/agents/gitops-operator.md +61 -0
  67. package/dist/gaia-ops/agents/terraform-architect.md +63 -0
  68. package/dist/gaia-ops/commands/gaia.md +37 -0
  69. package/dist/gaia-ops/config/README.md +71 -0
  70. package/dist/gaia-ops/config/cloud/aws.json +134 -0
  71. package/dist/gaia-ops/config/cloud/gcp.json +139 -0
  72. package/dist/gaia-ops/config/context-contracts.json +158 -0
  73. package/dist/gaia-ops/config/crons-schema.md +81 -0
  74. package/dist/gaia-ops/config/git_standards.json +72 -0
  75. package/dist/gaia-ops/config/surface-routing.json +421 -0
  76. package/dist/gaia-ops/config/universal-rules.json +102 -0
  77. package/dist/gaia-ops/hooks/adapters/__init__.py +52 -0
  78. package/dist/gaia-ops/hooks/adapters/base.py +219 -0
  79. package/dist/gaia-ops/hooks/adapters/channel.py +17 -0
  80. package/dist/gaia-ops/hooks/adapters/claude_code.py +1890 -0
  81. package/dist/gaia-ops/hooks/adapters/types.py +194 -0
  82. package/dist/gaia-ops/hooks/adapters/utils.py +25 -0
  83. package/dist/gaia-ops/hooks/hooks.json +163 -0
  84. package/dist/gaia-ops/hooks/modules/__init__.py +15 -0
  85. package/dist/gaia-ops/hooks/modules/agents/__init__.py +29 -0
  86. package/dist/gaia-ops/hooks/modules/agents/contract_validator.py +647 -0
  87. package/dist/gaia-ops/hooks/modules/agents/response_contract.py +496 -0
  88. package/dist/gaia-ops/hooks/modules/agents/skill_injection_verifier.py +120 -0
  89. package/dist/gaia-ops/hooks/modules/agents/state_tracker.py +267 -0
  90. package/dist/gaia-ops/hooks/modules/agents/task_info_builder.py +74 -0
  91. package/dist/gaia-ops/hooks/modules/agents/transcript_analyzer.py +458 -0
  92. package/dist/gaia-ops/hooks/modules/agents/transcript_reader.py +152 -0
  93. package/dist/gaia-ops/hooks/modules/audit/__init__.py +28 -0
  94. package/dist/gaia-ops/hooks/modules/audit/event_detector.py +168 -0
  95. package/dist/gaia-ops/hooks/modules/audit/logger.py +131 -0
  96. package/dist/gaia-ops/hooks/modules/audit/metrics.py +134 -0
  97. package/dist/gaia-ops/hooks/modules/audit/workflow_auditor.py +611 -0
  98. package/dist/gaia-ops/hooks/modules/audit/workflow_recorder.py +296 -0
  99. package/dist/gaia-ops/hooks/modules/context/__init__.py +11 -0
  100. package/dist/gaia-ops/hooks/modules/context/agentic_loop_detector.py +165 -0
  101. package/dist/gaia-ops/hooks/modules/context/anchor_tracker.py +317 -0
  102. package/dist/gaia-ops/hooks/modules/context/compact_context_builder.py +218 -0
  103. package/dist/gaia-ops/hooks/modules/context/context_freshness.py +145 -0
  104. package/dist/gaia-ops/hooks/modules/context/context_injector.py +558 -0
  105. package/dist/gaia-ops/hooks/modules/context/context_writer.py +530 -0
  106. package/dist/gaia-ops/hooks/modules/context/contracts_loader.py +161 -0
  107. package/dist/gaia-ops/hooks/modules/core/__init__.py +40 -0
  108. package/dist/gaia-ops/hooks/modules/core/hook_entry.py +78 -0
  109. package/dist/gaia-ops/hooks/modules/core/paths.py +160 -0
  110. package/dist/gaia-ops/hooks/modules/core/plugin_mode.py +149 -0
  111. package/dist/gaia-ops/hooks/modules/core/plugin_setup.py +577 -0
  112. package/dist/gaia-ops/hooks/modules/core/state.py +179 -0
  113. package/dist/gaia-ops/hooks/modules/core/stdin.py +24 -0
  114. package/dist/gaia-ops/hooks/modules/events/__init__.py +1 -0
  115. package/dist/gaia-ops/hooks/modules/events/event_writer.py +210 -0
  116. package/dist/gaia-ops/hooks/modules/memory/__init__.py +8 -0
  117. package/dist/gaia-ops/hooks/modules/memory/episode_writer.py +216 -0
  118. package/dist/gaia-ops/hooks/modules/orchestrator/__init__.py +1 -0
  119. package/dist/gaia-ops/hooks/modules/orchestrator/delegate_mode.py +122 -0
  120. package/dist/gaia-ops/hooks/modules/scanning/__init__.py +8 -0
  121. package/dist/gaia-ops/hooks/modules/scanning/scan_trigger.py +84 -0
  122. package/dist/gaia-ops/hooks/modules/security/__init__.py +120 -0
  123. package/dist/gaia-ops/hooks/modules/security/approval_cleanup.py +87 -0
  124. package/dist/gaia-ops/hooks/modules/security/approval_constants.py +23 -0
  125. package/dist/gaia-ops/hooks/modules/security/approval_grants.py +1638 -0
  126. package/dist/gaia-ops/hooks/modules/security/approval_messages.py +71 -0
  127. package/dist/gaia-ops/hooks/modules/security/approval_scopes.py +222 -0
  128. package/dist/gaia-ops/hooks/modules/security/blocked_commands.py +595 -0
  129. package/dist/gaia-ops/hooks/modules/security/blocked_message_formatter.py +87 -0
  130. package/dist/gaia-ops/hooks/modules/security/command_semantics.py +181 -0
  131. package/dist/gaia-ops/hooks/modules/security/composition_rules.py +547 -0
  132. package/dist/gaia-ops/hooks/modules/security/flag_classifiers.py +873 -0
  133. package/dist/gaia-ops/hooks/modules/security/gitops_validator.py +179 -0
  134. package/dist/gaia-ops/hooks/modules/security/mutative_verbs.py +1131 -0
  135. package/dist/gaia-ops/hooks/modules/security/network_hosts.py +481 -0
  136. package/dist/gaia-ops/hooks/modules/security/prompt_validator.py +40 -0
  137. package/dist/gaia-ops/hooks/modules/security/shell_unwrapper.py +165 -0
  138. package/dist/gaia-ops/hooks/modules/security/tiers.py +196 -0
  139. package/dist/gaia-ops/hooks/modules/session/__init__.py +10 -0
  140. package/dist/gaia-ops/hooks/modules/session/pending_scanner.py +174 -0
  141. package/dist/gaia-ops/hooks/modules/session/session_context_writer.py +100 -0
  142. package/dist/gaia-ops/hooks/modules/session/session_event_injector.py +160 -0
  143. package/dist/gaia-ops/hooks/modules/session/session_manager.py +31 -0
  144. package/dist/gaia-ops/hooks/modules/session/session_registry.py +232 -0
  145. package/dist/gaia-ops/hooks/modules/tools/__init__.py +29 -0
  146. package/dist/gaia-ops/hooks/modules/tools/bash_validator.py +1008 -0
  147. package/dist/gaia-ops/hooks/modules/tools/cloud_pipe_validator.py +231 -0
  148. package/dist/gaia-ops/hooks/modules/tools/hook_response.py +55 -0
  149. package/dist/gaia-ops/hooks/modules/tools/shell_parser.py +227 -0
  150. package/dist/gaia-ops/hooks/modules/tools/stage_decomposer.py +315 -0
  151. package/dist/gaia-ops/hooks/modules/tools/task_validator.py +294 -0
  152. package/dist/gaia-ops/hooks/modules/validation/__init__.py +23 -0
  153. package/dist/gaia-ops/hooks/modules/validation/commit_validator.py +380 -0
  154. package/dist/gaia-ops/hooks/post_compact.py +43 -0
  155. package/dist/gaia-ops/hooks/post_tool_use.py +54 -0
  156. package/dist/gaia-ops/hooks/pre_compact.py +60 -0
  157. package/dist/gaia-ops/hooks/pre_tool_use.py +413 -0
  158. package/dist/gaia-ops/hooks/session_start.py +81 -0
  159. package/dist/gaia-ops/hooks/stop_hook.py +82 -0
  160. package/dist/gaia-ops/hooks/subagent_start.py +71 -0
  161. package/dist/gaia-ops/hooks/subagent_stop.py +295 -0
  162. package/dist/gaia-ops/hooks/task_completed.py +70 -0
  163. package/dist/gaia-ops/hooks/user_prompt_submit.py +246 -0
  164. package/dist/gaia-ops/settings.json +72 -0
  165. package/dist/gaia-ops/skills/README.md +154 -0
  166. package/dist/gaia-ops/skills/agent-protocol/SKILL.md +93 -0
  167. package/dist/gaia-ops/skills/agent-protocol/examples.md +223 -0
  168. package/dist/gaia-ops/skills/agent-response/SKILL.md +69 -0
  169. package/dist/gaia-ops/skills/agentic-loop/SKILL.md +80 -0
  170. package/dist/gaia-ops/skills/agentic-loop/reference.md +378 -0
  171. package/dist/gaia-ops/skills/blog-writing/SKILL.md +98 -0
  172. package/dist/gaia-ops/skills/blog-writing/reference.md +130 -0
  173. package/dist/gaia-ops/skills/brief-spec/SKILL.md +182 -0
  174. package/dist/gaia-ops/skills/command-execution/SKILL.md +64 -0
  175. package/dist/gaia-ops/skills/command-execution/reference.md +83 -0
  176. package/dist/gaia-ops/skills/context-updater/SKILL.md +87 -0
  177. package/dist/gaia-ops/skills/context-updater/examples.md +71 -0
  178. package/dist/gaia-ops/skills/developer-patterns/SKILL.md +50 -0
  179. package/dist/gaia-ops/skills/developer-patterns/reference.md +112 -0
  180. package/dist/gaia-ops/skills/execution/SKILL.md +99 -0
  181. package/dist/gaia-ops/skills/fast-queries/SKILL.md +43 -0
  182. package/dist/gaia-ops/skills/gaia-compact/SKILL.md +74 -0
  183. package/dist/gaia-ops/skills/gaia-patterns/SKILL.md +108 -0
  184. package/dist/gaia-ops/skills/gaia-patterns/reference.md +395 -0
  185. package/dist/gaia-ops/skills/gaia-planner/SKILL.md +37 -0
  186. package/dist/gaia-ops/skills/gaia-planner/reference.md +107 -0
  187. package/dist/gaia-ops/skills/gaia-release/SKILL.md +82 -0
  188. package/dist/gaia-ops/skills/gaia-release/reference.md +102 -0
  189. package/dist/gaia-ops/skills/gaia-self-check/SKILL.md +114 -0
  190. package/dist/gaia-ops/skills/gaia-self-check/reference.md +453 -0
  191. package/dist/gaia-ops/skills/gaia-verify/SKILL.md +77 -0
  192. package/dist/gaia-ops/skills/gaia-verify/reference.md +80 -0
  193. package/dist/gaia-ops/skills/git-conventions/SKILL.md +47 -0
  194. package/dist/gaia-ops/skills/gitops-patterns/SKILL.md +60 -0
  195. package/dist/gaia-ops/skills/gitops-patterns/reference.md +183 -0
  196. package/dist/gaia-ops/skills/gmail-policy/SKILL.md +200 -0
  197. package/dist/gaia-ops/skills/gmail-policy/reference.md +150 -0
  198. package/dist/gaia-ops/skills/gmail-triage/SKILL.md +100 -0
  199. package/dist/gaia-ops/skills/gws-setup/SKILL.md +99 -0
  200. package/dist/gaia-ops/skills/gws-setup/reference.md +73 -0
  201. package/dist/gaia-ops/skills/investigation/SKILL.md +100 -0
  202. package/dist/gaia-ops/skills/memory-curation/SKILL.md +83 -0
  203. package/dist/gaia-ops/skills/memory-search/SKILL.md +88 -0
  204. package/dist/gaia-ops/skills/orchestrator-approval/SKILL.md +160 -0
  205. package/dist/gaia-ops/skills/orchestrator-approval/reference.md +174 -0
  206. package/dist/gaia-ops/skills/pending-approvals/SKILL.md +72 -0
  207. package/dist/gaia-ops/skills/pending-approvals/reference.md +214 -0
  208. package/dist/gaia-ops/skills/readme-writing/SKILL.md +71 -0
  209. package/dist/gaia-ops/skills/readme-writing/reference.md +188 -0
  210. package/dist/gaia-ops/skills/reference.md +135 -0
  211. package/dist/gaia-ops/skills/request-approval/SKILL.md +140 -0
  212. package/dist/gaia-ops/skills/request-approval/examples.md +140 -0
  213. package/dist/gaia-ops/skills/request-approval/reference.md +57 -0
  214. package/dist/gaia-ops/skills/schedule-task/SKILL.md +64 -0
  215. package/dist/gaia-ops/skills/schedule-task/reference.md +233 -0
  216. package/dist/gaia-ops/skills/security-tiers/SKILL.md +141 -0
  217. package/dist/gaia-ops/skills/security-tiers/destructive-commands-reference.md +623 -0
  218. package/dist/gaia-ops/skills/security-tiers/reference.md +39 -0
  219. package/dist/gaia-ops/skills/skill-creation/SKILL.md +92 -0
  220. package/dist/gaia-ops/skills/skill-creation/reference.md +29 -0
  221. package/dist/gaia-ops/skills/terraform-patterns/SKILL.md +89 -0
  222. package/dist/gaia-ops/skills/terraform-patterns/reference.md +93 -0
  223. package/dist/gaia-ops/tools/__init__.py +9 -0
  224. package/dist/gaia-ops/tools/agentic-loop/decide-status.py +210 -0
  225. package/dist/gaia-ops/tools/agentic-loop/parse-metric.py +106 -0
  226. package/dist/gaia-ops/tools/agentic-loop/record-iteration.py +221 -0
  227. package/dist/gaia-ops/tools/context/README.md +132 -0
  228. package/dist/gaia-ops/tools/context/__init__.py +42 -0
  229. package/dist/gaia-ops/tools/context/_paths.py +20 -0
  230. package/dist/gaia-ops/tools/context/context_provider.py +721 -0
  231. package/dist/gaia-ops/tools/context/context_section_reader.py +342 -0
  232. package/dist/gaia-ops/tools/context/deep_merge.py +159 -0
  233. package/dist/gaia-ops/tools/context/pending_updates.py +760 -0
  234. package/dist/gaia-ops/tools/context/surface_router.py +278 -0
  235. package/dist/gaia-ops/tools/fast-queries/README.md +65 -0
  236. package/dist/gaia-ops/tools/fast-queries/__init__.py +30 -0
  237. package/dist/gaia-ops/tools/fast-queries/appservices/quicktriage_devops_developer.sh +75 -0
  238. package/dist/gaia-ops/tools/fast-queries/cloud/aws/quicktriage_aws_troubleshooter.sh +32 -0
  239. package/dist/gaia-ops/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh +88 -0
  240. package/dist/gaia-ops/tools/fast-queries/gitops/quicktriage_gitops_operator.sh +48 -0
  241. package/dist/gaia-ops/tools/fast-queries/run_triage.sh +59 -0
  242. package/dist/gaia-ops/tools/fast-queries/terraform/quicktriage_terraform_architect.sh +80 -0
  243. package/dist/gaia-ops/tools/gaia_simulator/__init__.py +33 -0
  244. package/dist/gaia-ops/tools/gaia_simulator/cli.py +354 -0
  245. package/dist/gaia-ops/tools/gaia_simulator/extractor.py +457 -0
  246. package/dist/gaia-ops/tools/gaia_simulator/reporter.py +258 -0
  247. package/dist/gaia-ops/tools/gaia_simulator/routing_simulator.py +334 -0
  248. package/dist/gaia-ops/tools/gaia_simulator/runner.py +539 -0
  249. package/dist/gaia-ops/tools/gaia_simulator/skills_mapper.py +264 -0
  250. package/dist/gaia-ops/tools/memory/README.md +0 -0
  251. package/dist/gaia-ops/tools/memory/__init__.py +20 -0
  252. package/dist/gaia-ops/tools/memory/backfill_fts5.py +107 -0
  253. package/dist/gaia-ops/tools/memory/conflict_detector.py +295 -0
  254. package/dist/gaia-ops/tools/memory/episodic.py +1210 -0
  255. package/dist/gaia-ops/tools/memory/git_invalidator.py +262 -0
  256. package/dist/gaia-ops/tools/memory/paths.py +102 -0
  257. package/dist/gaia-ops/tools/memory/scoring.py +193 -0
  258. package/dist/gaia-ops/tools/memory/search_store.py +360 -0
  259. package/dist/gaia-ops/tools/persist_transcript_analysis.py +85 -0
  260. package/dist/gaia-ops/tools/review/__init__.py +1 -0
  261. package/dist/gaia-ops/tools/review/review_engine.py +157 -0
  262. package/dist/gaia-ops/tools/scan/__init__.py +35 -0
  263. package/dist/gaia-ops/tools/scan/config.py +247 -0
  264. package/dist/gaia-ops/tools/scan/merge.py +212 -0
  265. package/dist/gaia-ops/tools/scan/orchestrator.py +549 -0
  266. package/dist/gaia-ops/tools/scan/registry.py +127 -0
  267. package/dist/gaia-ops/tools/scan/scanners/__init__.py +18 -0
  268. package/dist/gaia-ops/tools/scan/scanners/base.py +137 -0
  269. package/dist/gaia-ops/tools/scan/scanners/environment.py +349 -0
  270. package/dist/gaia-ops/tools/scan/scanners/git.py +570 -0
  271. package/dist/gaia-ops/tools/scan/scanners/infrastructure.py +875 -0
  272. package/dist/gaia-ops/tools/scan/scanners/orchestration.py +600 -0
  273. package/dist/gaia-ops/tools/scan/scanners/stack.py +1085 -0
  274. package/dist/gaia-ops/tools/scan/scanners/tools.py +260 -0
  275. package/dist/gaia-ops/tools/scan/setup.py +686 -0
  276. package/dist/gaia-ops/tools/scan/tests/__init__.py +1 -0
  277. package/dist/gaia-ops/tools/scan/tests/conftest.py +796 -0
  278. package/dist/gaia-ops/tools/scan/tests/test_environment.py +323 -0
  279. package/dist/gaia-ops/tools/scan/tests/test_git.py +419 -0
  280. package/dist/gaia-ops/tools/scan/tests/test_infrastructure.py +382 -0
  281. package/dist/gaia-ops/tools/scan/tests/test_integration.py +920 -0
  282. package/dist/gaia-ops/tools/scan/tests/test_merge.py +269 -0
  283. package/dist/gaia-ops/tools/scan/tests/test_orchestration.py +304 -0
  284. package/dist/gaia-ops/tools/scan/tests/test_stack.py +604 -0
  285. package/dist/gaia-ops/tools/scan/tests/test_tools.py +349 -0
  286. package/dist/gaia-ops/tools/scan/ui.py +624 -0
  287. package/dist/gaia-ops/tools/scan/verify.py +270 -0
  288. package/dist/gaia-ops/tools/scan/walk.py +118 -0
  289. package/dist/gaia-ops/tools/scan/workspace.py +85 -0
  290. package/dist/gaia-ops/tools/validation/README.md +244 -0
  291. package/dist/gaia-ops/tools/validation/__init__.py +17 -0
  292. package/dist/gaia-ops/tools/validation/approval_gate.py +321 -0
  293. package/dist/gaia-ops/tools/validation/validate_skills.py +189 -0
  294. package/dist/gaia-security/.claude-plugin/plugin.json +24 -0
  295. package/dist/gaia-security/README.md +90 -0
  296. package/dist/gaia-security/config/universal-rules.json +102 -0
  297. package/dist/gaia-security/hooks/adapters/__init__.py +52 -0
  298. package/dist/gaia-security/hooks/adapters/base.py +219 -0
  299. package/dist/gaia-security/hooks/adapters/channel.py +17 -0
  300. package/dist/gaia-security/hooks/adapters/claude_code.py +1890 -0
  301. package/dist/gaia-security/hooks/adapters/types.py +194 -0
  302. package/dist/gaia-security/hooks/adapters/utils.py +25 -0
  303. package/dist/gaia-security/hooks/hooks.json +84 -0
  304. package/dist/gaia-security/hooks/modules/__init__.py +15 -0
  305. package/dist/gaia-security/hooks/modules/agents/__init__.py +29 -0
  306. package/dist/gaia-security/hooks/modules/agents/contract_validator.py +647 -0
  307. package/dist/gaia-security/hooks/modules/agents/response_contract.py +496 -0
  308. package/dist/gaia-security/hooks/modules/agents/skill_injection_verifier.py +120 -0
  309. package/dist/gaia-security/hooks/modules/agents/state_tracker.py +267 -0
  310. package/dist/gaia-security/hooks/modules/agents/task_info_builder.py +74 -0
  311. package/dist/gaia-security/hooks/modules/agents/transcript_analyzer.py +458 -0
  312. package/dist/gaia-security/hooks/modules/agents/transcript_reader.py +152 -0
  313. package/dist/gaia-security/hooks/modules/audit/__init__.py +28 -0
  314. package/dist/gaia-security/hooks/modules/audit/event_detector.py +168 -0
  315. package/dist/gaia-security/hooks/modules/audit/logger.py +131 -0
  316. package/dist/gaia-security/hooks/modules/audit/metrics.py +134 -0
  317. package/dist/gaia-security/hooks/modules/audit/workflow_auditor.py +611 -0
  318. package/dist/gaia-security/hooks/modules/audit/workflow_recorder.py +296 -0
  319. package/dist/gaia-security/hooks/modules/context/__init__.py +11 -0
  320. package/dist/gaia-security/hooks/modules/context/agentic_loop_detector.py +165 -0
  321. package/dist/gaia-security/hooks/modules/context/anchor_tracker.py +317 -0
  322. package/dist/gaia-security/hooks/modules/context/compact_context_builder.py +218 -0
  323. package/dist/gaia-security/hooks/modules/context/context_freshness.py +145 -0
  324. package/dist/gaia-security/hooks/modules/context/context_injector.py +558 -0
  325. package/dist/gaia-security/hooks/modules/context/context_writer.py +530 -0
  326. package/dist/gaia-security/hooks/modules/context/contracts_loader.py +161 -0
  327. package/dist/gaia-security/hooks/modules/core/__init__.py +40 -0
  328. package/dist/gaia-security/hooks/modules/core/hook_entry.py +78 -0
  329. package/dist/gaia-security/hooks/modules/core/paths.py +160 -0
  330. package/dist/gaia-security/hooks/modules/core/plugin_mode.py +149 -0
  331. package/dist/gaia-security/hooks/modules/core/plugin_setup.py +577 -0
  332. package/dist/gaia-security/hooks/modules/core/state.py +179 -0
  333. package/dist/gaia-security/hooks/modules/core/stdin.py +24 -0
  334. package/dist/gaia-security/hooks/modules/events/__init__.py +1 -0
  335. package/dist/gaia-security/hooks/modules/events/event_writer.py +210 -0
  336. package/dist/gaia-security/hooks/modules/memory/__init__.py +8 -0
  337. package/dist/gaia-security/hooks/modules/memory/episode_writer.py +216 -0
  338. package/dist/gaia-security/hooks/modules/orchestrator/__init__.py +1 -0
  339. package/dist/gaia-security/hooks/modules/orchestrator/delegate_mode.py +122 -0
  340. package/dist/gaia-security/hooks/modules/scanning/__init__.py +8 -0
  341. package/dist/gaia-security/hooks/modules/scanning/scan_trigger.py +84 -0
  342. package/dist/gaia-security/hooks/modules/security/__init__.py +120 -0
  343. package/dist/gaia-security/hooks/modules/security/approval_cleanup.py +87 -0
  344. package/dist/gaia-security/hooks/modules/security/approval_constants.py +23 -0
  345. package/dist/gaia-security/hooks/modules/security/approval_grants.py +1638 -0
  346. package/dist/gaia-security/hooks/modules/security/approval_messages.py +71 -0
  347. package/dist/gaia-security/hooks/modules/security/approval_scopes.py +222 -0
  348. package/dist/gaia-security/hooks/modules/security/blocked_commands.py +595 -0
  349. package/dist/gaia-security/hooks/modules/security/blocked_message_formatter.py +87 -0
  350. package/dist/gaia-security/hooks/modules/security/command_semantics.py +181 -0
  351. package/dist/gaia-security/hooks/modules/security/composition_rules.py +547 -0
  352. package/dist/gaia-security/hooks/modules/security/flag_classifiers.py +873 -0
  353. package/dist/gaia-security/hooks/modules/security/gitops_validator.py +179 -0
  354. package/dist/gaia-security/hooks/modules/security/mutative_verbs.py +1131 -0
  355. package/dist/gaia-security/hooks/modules/security/network_hosts.py +481 -0
  356. package/dist/gaia-security/hooks/modules/security/prompt_validator.py +40 -0
  357. package/dist/gaia-security/hooks/modules/security/shell_unwrapper.py +165 -0
  358. package/dist/gaia-security/hooks/modules/security/tiers.py +196 -0
  359. package/dist/gaia-security/hooks/modules/session/__init__.py +10 -0
  360. package/dist/gaia-security/hooks/modules/session/pending_scanner.py +174 -0
  361. package/dist/gaia-security/hooks/modules/session/session_context_writer.py +100 -0
  362. package/dist/gaia-security/hooks/modules/session/session_event_injector.py +160 -0
  363. package/dist/gaia-security/hooks/modules/session/session_manager.py +31 -0
  364. package/dist/gaia-security/hooks/modules/session/session_registry.py +232 -0
  365. package/dist/gaia-security/hooks/modules/tools/__init__.py +29 -0
  366. package/dist/gaia-security/hooks/modules/tools/bash_validator.py +1008 -0
  367. package/dist/gaia-security/hooks/modules/tools/cloud_pipe_validator.py +231 -0
  368. package/dist/gaia-security/hooks/modules/tools/hook_response.py +55 -0
  369. package/dist/gaia-security/hooks/modules/tools/shell_parser.py +227 -0
  370. package/dist/gaia-security/hooks/modules/tools/stage_decomposer.py +315 -0
  371. package/dist/gaia-security/hooks/modules/tools/task_validator.py +294 -0
  372. package/dist/gaia-security/hooks/modules/validation/__init__.py +23 -0
  373. package/dist/gaia-security/hooks/modules/validation/commit_validator.py +380 -0
  374. package/dist/gaia-security/hooks/post_tool_use.py +54 -0
  375. package/dist/gaia-security/hooks/pre_tool_use.py +413 -0
  376. package/dist/gaia-security/hooks/session_start.py +81 -0
  377. package/dist/gaia-security/hooks/stop_hook.py +82 -0
  378. package/dist/gaia-security/hooks/user_prompt_submit.py +246 -0
  379. package/dist/gaia-security/settings.json +58 -0
  380. package/git-hooks/commit-msg +41 -0
  381. package/hooks/README.md +100 -0
  382. package/hooks/adapters/__init__.py +52 -0
  383. package/hooks/adapters/base.py +219 -0
  384. package/hooks/adapters/channel.py +17 -0
  385. package/hooks/adapters/claude_code.py +1890 -0
  386. package/hooks/adapters/types.py +194 -0
  387. package/hooks/adapters/utils.py +25 -0
  388. package/hooks/elicitation_result.py +179 -0
  389. package/hooks/hooks.json +84 -0
  390. package/hooks/modules/README.md +189 -0
  391. package/hooks/modules/__init__.py +15 -0
  392. package/hooks/modules/agents/__init__.py +29 -0
  393. package/hooks/modules/agents/contract_validator.py +647 -0
  394. package/hooks/modules/agents/response_contract.py +496 -0
  395. package/hooks/modules/agents/skill_injection_verifier.py +120 -0
  396. package/hooks/modules/agents/state_tracker.py +267 -0
  397. package/hooks/modules/agents/task_info_builder.py +74 -0
  398. package/hooks/modules/agents/transcript_analyzer.py +458 -0
  399. package/hooks/modules/agents/transcript_reader.py +152 -0
  400. package/hooks/modules/audit/__init__.py +28 -0
  401. package/hooks/modules/audit/event_detector.py +168 -0
  402. package/hooks/modules/audit/logger.py +131 -0
  403. package/hooks/modules/audit/metrics.py +134 -0
  404. package/hooks/modules/audit/workflow_auditor.py +611 -0
  405. package/hooks/modules/audit/workflow_recorder.py +296 -0
  406. package/hooks/modules/context/__init__.py +11 -0
  407. package/hooks/modules/context/agentic_loop_detector.py +165 -0
  408. package/hooks/modules/context/anchor_tracker.py +317 -0
  409. package/hooks/modules/context/compact_context_builder.py +218 -0
  410. package/hooks/modules/context/context_freshness.py +145 -0
  411. package/hooks/modules/context/context_injector.py +558 -0
  412. package/hooks/modules/context/context_writer.py +530 -0
  413. package/hooks/modules/context/contracts_loader.py +161 -0
  414. package/hooks/modules/core/__init__.py +40 -0
  415. package/hooks/modules/core/hook_entry.py +78 -0
  416. package/hooks/modules/core/paths.py +160 -0
  417. package/hooks/modules/core/plugin_mode.py +149 -0
  418. package/hooks/modules/core/plugin_setup.py +577 -0
  419. package/hooks/modules/core/state.py +179 -0
  420. package/hooks/modules/core/stdin.py +24 -0
  421. package/hooks/modules/events/__init__.py +1 -0
  422. package/hooks/modules/events/event_writer.py +210 -0
  423. package/hooks/modules/evidence/__init__.py +34 -0
  424. package/hooks/modules/evidence/assertions.py +137 -0
  425. package/hooks/modules/evidence/index_writer.py +57 -0
  426. package/hooks/modules/evidence/loader.py +126 -0
  427. package/hooks/modules/evidence/runner.py +241 -0
  428. package/hooks/modules/memory/__init__.py +8 -0
  429. package/hooks/modules/memory/episode_writer.py +216 -0
  430. package/hooks/modules/orchestrator/__init__.py +1 -0
  431. package/hooks/modules/orchestrator/delegate_mode.py +122 -0
  432. package/hooks/modules/scanning/__init__.py +8 -0
  433. package/hooks/modules/scanning/scan_trigger.py +84 -0
  434. package/hooks/modules/security/__init__.py +120 -0
  435. package/hooks/modules/security/approval_cleanup.py +87 -0
  436. package/hooks/modules/security/approval_constants.py +23 -0
  437. package/hooks/modules/security/approval_grants.py +1638 -0
  438. package/hooks/modules/security/approval_messages.py +71 -0
  439. package/hooks/modules/security/approval_scopes.py +222 -0
  440. package/hooks/modules/security/blocked_commands.py +595 -0
  441. package/hooks/modules/security/blocked_message_formatter.py +87 -0
  442. package/hooks/modules/security/command_semantics.py +181 -0
  443. package/hooks/modules/security/composition_rules.py +547 -0
  444. package/hooks/modules/security/flag_classifiers.py +873 -0
  445. package/hooks/modules/security/gitops_validator.py +179 -0
  446. package/hooks/modules/security/mutative_verbs.py +1131 -0
  447. package/hooks/modules/security/network_hosts.py +481 -0
  448. package/hooks/modules/security/prompt_validator.py +40 -0
  449. package/hooks/modules/security/shell_unwrapper.py +165 -0
  450. package/hooks/modules/security/tiers.py +196 -0
  451. package/hooks/modules/session/__init__.py +10 -0
  452. package/hooks/modules/session/pending_scanner.py +174 -0
  453. package/hooks/modules/session/session_context_writer.py +100 -0
  454. package/hooks/modules/session/session_event_injector.py +160 -0
  455. package/hooks/modules/session/session_manager.py +31 -0
  456. package/hooks/modules/session/session_registry.py +232 -0
  457. package/hooks/modules/tools/__init__.py +29 -0
  458. package/hooks/modules/tools/bash_validator.py +1008 -0
  459. package/hooks/modules/tools/cloud_pipe_validator.py +231 -0
  460. package/hooks/modules/tools/hook_response.py +55 -0
  461. package/hooks/modules/tools/shell_parser.py +227 -0
  462. package/hooks/modules/tools/stage_decomposer.py +315 -0
  463. package/hooks/modules/tools/task_validator.py +294 -0
  464. package/hooks/modules/validation/__init__.py +23 -0
  465. package/hooks/modules/validation/commit_validator.py +380 -0
  466. package/hooks/post_compact.py +43 -0
  467. package/hooks/post_tool_use.py +54 -0
  468. package/hooks/pre_compact.py +60 -0
  469. package/hooks/pre_tool_use.py +413 -0
  470. package/hooks/session_start.py +81 -0
  471. package/hooks/stop_hook.py +82 -0
  472. package/hooks/subagent_start.py +71 -0
  473. package/hooks/subagent_stop.py +295 -0
  474. package/hooks/task_completed.py +70 -0
  475. package/hooks/user_prompt_submit.py +246 -0
  476. package/index.js +83 -0
  477. package/package.json +99 -0
  478. package/pyproject.toml +32 -0
  479. package/skills/README.md +154 -0
  480. package/skills/agent-protocol/SKILL.md +93 -0
  481. package/skills/agent-protocol/examples.md +223 -0
  482. package/skills/agent-response/SKILL.md +69 -0
  483. package/skills/agentic-loop/SKILL.md +80 -0
  484. package/skills/agentic-loop/reference.md +378 -0
  485. package/skills/blog-writing/SKILL.md +98 -0
  486. package/skills/blog-writing/reference.md +130 -0
  487. package/skills/brief-spec/SKILL.md +182 -0
  488. package/skills/command-execution/SKILL.md +64 -0
  489. package/skills/command-execution/reference.md +83 -0
  490. package/skills/context-updater/SKILL.md +87 -0
  491. package/skills/context-updater/examples.md +71 -0
  492. package/skills/developer-patterns/SKILL.md +50 -0
  493. package/skills/developer-patterns/reference.md +112 -0
  494. package/skills/execution/SKILL.md +99 -0
  495. package/skills/fast-queries/SKILL.md +43 -0
  496. package/skills/gaia-compact/SKILL.md +74 -0
  497. package/skills/gaia-patterns/SKILL.md +108 -0
  498. package/skills/gaia-patterns/reference.md +395 -0
  499. package/skills/gaia-planner/SKILL.md +37 -0
  500. package/skills/gaia-planner/reference.md +107 -0
  501. package/skills/gaia-release/SKILL.md +82 -0
  502. package/skills/gaia-release/reference.md +102 -0
  503. package/skills/gaia-self-check/SKILL.md +114 -0
  504. package/skills/gaia-self-check/reference.md +453 -0
  505. package/skills/gaia-verify/SKILL.md +77 -0
  506. package/skills/gaia-verify/reference.md +80 -0
  507. package/skills/git-conventions/SKILL.md +47 -0
  508. package/skills/gitops-patterns/SKILL.md +60 -0
  509. package/skills/gitops-patterns/reference.md +183 -0
  510. package/skills/gmail-policy/SKILL.md +200 -0
  511. package/skills/gmail-policy/reference.md +150 -0
  512. package/skills/gmail-triage/SKILL.md +100 -0
  513. package/skills/gws-setup/SKILL.md +99 -0
  514. package/skills/gws-setup/reference.md +73 -0
  515. package/skills/investigation/SKILL.md +100 -0
  516. package/skills/memory-curation/SKILL.md +83 -0
  517. package/skills/memory-search/SKILL.md +88 -0
  518. package/skills/orchestrator-approval/SKILL.md +160 -0
  519. package/skills/orchestrator-approval/reference.md +174 -0
  520. package/skills/pending-approvals/SKILL.md +72 -0
  521. package/skills/pending-approvals/reference.md +214 -0
  522. package/skills/readme-writing/SKILL.md +71 -0
  523. package/skills/readme-writing/reference.md +188 -0
  524. package/skills/reference.md +135 -0
  525. package/skills/request-approval/SKILL.md +140 -0
  526. package/skills/request-approval/examples.md +140 -0
  527. package/skills/request-approval/reference.md +57 -0
  528. package/skills/schedule-task/SKILL.md +64 -0
  529. package/skills/schedule-task/reference.md +233 -0
  530. package/skills/security-tiers/SKILL.md +141 -0
  531. package/skills/security-tiers/destructive-commands-reference.md +623 -0
  532. package/skills/security-tiers/reference.md +39 -0
  533. package/skills/skill-creation/SKILL.md +92 -0
  534. package/skills/skill-creation/reference.md +29 -0
  535. package/skills/terraform-patterns/SKILL.md +89 -0
  536. package/skills/terraform-patterns/reference.md +93 -0
  537. package/templates/README.md +69 -0
  538. package/templates/managed-settings.template.json +43 -0
  539. package/tools/__init__.py +9 -0
  540. package/tools/agentic-loop/decide-status.py +210 -0
  541. package/tools/agentic-loop/parse-metric.py +106 -0
  542. package/tools/agentic-loop/record-iteration.py +221 -0
  543. package/tools/context/README.md +132 -0
  544. package/tools/context/__init__.py +42 -0
  545. package/tools/context/_paths.py +20 -0
  546. package/tools/context/context_provider.py +721 -0
  547. package/tools/context/context_section_reader.py +342 -0
  548. package/tools/context/deep_merge.py +159 -0
  549. package/tools/context/pending_updates.py +760 -0
  550. package/tools/context/surface_router.py +278 -0
  551. package/tools/fast-queries/README.md +65 -0
  552. package/tools/fast-queries/__init__.py +30 -0
  553. package/tools/fast-queries/appservices/quicktriage_devops_developer.sh +75 -0
  554. package/tools/fast-queries/cloud/aws/quicktriage_aws_troubleshooter.sh +32 -0
  555. package/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh +88 -0
  556. package/tools/fast-queries/gitops/quicktriage_gitops_operator.sh +48 -0
  557. package/tools/fast-queries/run_triage.sh +59 -0
  558. package/tools/fast-queries/terraform/quicktriage_terraform_architect.sh +80 -0
  559. package/tools/gaia_simulator/__init__.py +33 -0
  560. package/tools/gaia_simulator/cli.py +354 -0
  561. package/tools/gaia_simulator/extractor.py +457 -0
  562. package/tools/gaia_simulator/reporter.py +258 -0
  563. package/tools/gaia_simulator/routing_simulator.py +334 -0
  564. package/tools/gaia_simulator/runner.py +539 -0
  565. package/tools/gaia_simulator/skills_mapper.py +264 -0
  566. package/tools/memory/README.md +0 -0
  567. package/tools/memory/__init__.py +20 -0
  568. package/tools/memory/backfill_fts5.py +107 -0
  569. package/tools/memory/conflict_detector.py +295 -0
  570. package/tools/memory/episodic.py +1210 -0
  571. package/tools/memory/git_invalidator.py +262 -0
  572. package/tools/memory/paths.py +102 -0
  573. package/tools/memory/scoring.py +193 -0
  574. package/tools/memory/search_store.py +360 -0
  575. package/tools/persist_transcript_analysis.py +85 -0
  576. package/tools/review/__init__.py +1 -0
  577. package/tools/review/review_engine.py +157 -0
  578. package/tools/scan/__init__.py +35 -0
  579. package/tools/scan/config.py +247 -0
  580. package/tools/scan/merge.py +212 -0
  581. package/tools/scan/orchestrator.py +549 -0
  582. package/tools/scan/registry.py +127 -0
  583. package/tools/scan/scanners/__init__.py +18 -0
  584. package/tools/scan/scanners/base.py +137 -0
  585. package/tools/scan/scanners/environment.py +349 -0
  586. package/tools/scan/scanners/git.py +570 -0
  587. package/tools/scan/scanners/infrastructure.py +875 -0
  588. package/tools/scan/scanners/orchestration.py +600 -0
  589. package/tools/scan/scanners/stack.py +1085 -0
  590. package/tools/scan/scanners/tools.py +260 -0
  591. package/tools/scan/setup.py +686 -0
  592. package/tools/scan/tests/__init__.py +1 -0
  593. package/tools/scan/tests/conftest.py +796 -0
  594. package/tools/scan/tests/test_environment.py +323 -0
  595. package/tools/scan/tests/test_git.py +419 -0
  596. package/tools/scan/tests/test_infrastructure.py +382 -0
  597. package/tools/scan/tests/test_integration.py +920 -0
  598. package/tools/scan/tests/test_merge.py +269 -0
  599. package/tools/scan/tests/test_orchestration.py +304 -0
  600. package/tools/scan/tests/test_stack.py +604 -0
  601. package/tools/scan/tests/test_tools.py +349 -0
  602. package/tools/scan/ui.py +624 -0
  603. package/tools/scan/verify.py +270 -0
  604. package/tools/scan/walk.py +118 -0
  605. package/tools/scan/workspace.py +85 -0
  606. package/tools/validation/README.md +244 -0
  607. package/tools/validation/__init__.py +17 -0
  608. package/tools/validation/approval_gate.py +321 -0
  609. package/tools/validation/validate_skills.py +189 -0
@@ -0,0 +1,214 @@
1
+ # Pending Approvals — Reference
2
+
3
+ Read on-demand when processing approval requests.
4
+
5
+ ## Pending JSON Schema
6
+
7
+ File: `.claude/cache/approvals/pending-{nonce}.json`
8
+
9
+ ```json
10
+ {
11
+ "nonce": "8072af8044f0da0571c348041ad2cef6",
12
+ "session_id": "abc123",
13
+ "command": "kubectl apply -f manifest.yaml",
14
+ "danger_verb": "apply",
15
+ "danger_category": "MUTATIVE",
16
+ "scope_type": "semantic_signature",
17
+ "scope_signature": {
18
+ "base_cmd": "kubectl",
19
+ "cli_family": "k8s",
20
+ "verb": "apply",
21
+ "semantic_tokens": ["kubectl", "apply", "manifest.yaml"],
22
+ "normalized_flags": ["-f"]
23
+ },
24
+ "timestamp": 1775843292.4328,
25
+ "ttl_minutes": 5,
26
+ "context": {
27
+ "scope": "k8s cluster — dev namespace",
28
+ "rollback": "kubectl delete -f manifest.yaml",
29
+ "risk": "MEDIUM"
30
+ }
31
+ }
32
+ ```
33
+
34
+ The `context` field is optional. When absent, derive scope/rollback/risk from `scope_signature` and `danger_category`.
35
+
36
+ ## Nonce Prefix Matching
37
+
38
+ User references "P-8072af8" → match against nonces starting with "8072af8".
39
+ Minimum 4 characters. If multiple nonces share the same prefix, ask user to be more specific.
40
+
41
+ ## Summary Format (SessionStart injection)
42
+
43
+ ```
44
+ Tienes N aprobaciones pendientes:
45
+
46
+ P-{nonce[0:8]} {command} [{danger_verb}] hace {age}
47
+ P-{nonce[0:8]} {command} [{danger_verb}] hace {age}
48
+
49
+ Di "ver P-XXXX" para detalles o "aprobar P-XXXX" para ejecutar.
50
+ ```
51
+
52
+ ## Detail View Format
53
+
54
+ ```
55
+ P-{nonce[0:8]} — Detalle
56
+
57
+ COMANDO: {command}
58
+ OPERACION: {danger_verb} en {base_cmd}
59
+ CATEGORIA: {danger_category}
60
+ SCOPE: {scope}
61
+ ROLLBACK: {rollback}
62
+ CREADO: {timestamp as readable datetime}
63
+ ```
64
+
65
+ ## AskUserQuestion Template
66
+
67
+ ```python
68
+ AskUserQuestion(
69
+ question=(
70
+ "APPROVAL REQUIRED\n\n"
71
+ f"OPERACION: {danger_verb} on {base_cmd}\n"
72
+ f"COMANDO: {command}\n" # verbatim, never paraphrased
73
+ f"SCOPE: {scope}\n"
74
+ f"RIESGO: {danger_category}\n"
75
+ f"ROLLBACK: {rollback}"
76
+ ),
77
+ options=[f"Approve -- {danger_verb} {base_cmd} {target} [P-{nonce[:8]}]", "Reject"]
78
+ # Option label MUST name the specific action, e.g.:
79
+ # "Approve -- kubectl apply -f manifest.yaml [P-8072af80]"
80
+ # NEVER: "Approve", "Approve -- proceed", "Approve -- aplicar cambios"
81
+ )
82
+ ```
83
+
84
+ The PostToolUse hook checks `answer.lower().startswith("approve")` to activate the grant.
85
+ "Reject" (or any non-"Approve" answer) does NOT activate the grant.
86
+
87
+ ## Post-Approval Dispatch Template
88
+
89
+ After AskUserQuestion returns "Approve", check whether the pending file belongs to the current session. Both dispatch paths use the same smart prompt structure -- the only difference is whether the nonce is included.
90
+
91
+ ### Dispatch prompt structure
92
+
93
+ The dispatch prompt tells the agent three things: what to run, where to run it, and how to handle failure. This replaces fire-and-forget dispatch, which reports failure without attempting recovery.
94
+
95
+ ```
96
+ Ejecuta este comando aprobado por el usuario. No requiere confirmacion adicional.
97
+ {Nonce: {nonce} -- only for same-session dispatch}
98
+ Comando: {command}
99
+ Directorio: {cwd}
100
+
101
+ PREFLIGHT: Before executing, verify preconditions still hold.
102
+ - For git push: fetch and check if the local branch is ahead of remote.
103
+ - For kubectl/helm apply: confirm the target resource exists and is not mid-rollout.
104
+ - For terraform apply: run a quick plan to confirm no unexpected drift.
105
+ - General: if the command depends on state that may have changed, check that state first.
106
+ If a precondition fails, report what changed and do NOT execute.
107
+
108
+ RECOVERY: If the command fails with a recoverable error, attempt ONE standard local recovery, then retry.
109
+ - git push (non-fast-forward): pull --rebase, then retry push.
110
+ - terraform apply (state conflict): refresh state, then retry apply.
111
+ - kubectl apply (conflict): re-fetch the resource, re-apply.
112
+ - General: if the error message suggests a local fix (rebase, refresh, retry), do that fix ONCE.
113
+ Do NOT attempt remote-mutating recovery (force push, remote delete, taint, import).
114
+ Do NOT retry more than once -- if recovery + retry fails, report the error.
115
+ ```
116
+
117
+ The `cwd` field may be present in the pending JSON. When present, include it in the dispatch as `Directorio:`. When absent, omit the line.
118
+
119
+ ### Dispatch `mode` for post-approval execution
120
+
121
+ The Gaia grant activates on the blocked command signature -- that covers the Gaia hook, but CC native is a separate gate. Pick `mode` based on the command target:
122
+
123
+ | Approved command targets... | mode | session | Why |
124
+ |-----------------------------|------|---------|-----|
125
+ | Normal paths (src/, infra/, /tmp/) | `default` | foreground | CC native does not protect these; no mode needed |
126
+ | `.claude/` writes only (Edit/Write on skills, agents, briefs) | `acceptEdits` | foreground | CC native prompts on `.claude/` writes; `acceptEdits` satisfies it |
127
+ | Bash mutativo sobre `.claude/` (rm, mv, mkdir) | `bypassPermissions` | foreground | CC native intercepts `.claude/` destructive ops regardless of verb; bypass satisfies it |
128
+ | Bundle: Bash on `.claude/` + Edits on `.claude/` | `bypassPermissions` | foreground | The bundle needs one mode that covers both layers; pack all steps in one dispatch turn |
129
+
130
+ The dispatch is single-turn and cannot split: if the bundle emits APPROVAL_REQUEST mid-execution, the orchestrator must re-dispatch fresh with the same mode, not SendMessage resume -- mode does not survive resume.
131
+
132
+ ### Same-session dispatch
133
+
134
+ When `pending.session_id == CLAUDE_SESSION_ID` -- pass the nonce:
135
+
136
+ 1. Build the dispatch prompt with nonce, command, and cwd (if available)
137
+ 2. Dispatch the one-shot agent
138
+ 3. The hook finds the nonce, activates the grant, and allows the T3 operation through
139
+
140
+ ### Cross-session dispatch
141
+
142
+ When `pending.session_id != CLAUDE_SESSION_ID` -- the nonce is stale:
143
+
144
+ 1. The PostToolUse hook will have already activated the grant under the current session
145
+ 2. Build the dispatch prompt with command and cwd (if available), no nonce
146
+ 3. Dispatch the one-shot agent
147
+ 4. The hook finds the pre-activated grant (by command signature) and allows the T3 operation through
148
+
149
+ ### Recovery scope guardrail
150
+
151
+ Recovery actions must only modify LOCAL state. The agent should never attempt:
152
+ - `git push --force` or `git push --force-with-lease` (remote-mutating)
153
+ - `terraform state rm` or `terraform import` (state-mutating beyond refresh)
154
+ - `kubectl delete` followed by re-create (destructive recovery)
155
+ - Any action that would require its own T3 approval
156
+
157
+ If the only path forward requires remote mutation, the agent reports the failure and lets the user decide.
158
+
159
+ ## Complete Flow Example
160
+
161
+ ### Same-session path
162
+
163
+ ```
164
+ SessionStart
165
+ → scans .claude/cache/approvals/pending-*.json
166
+ → injects summary into additionalContext
167
+
168
+ User sees:
169
+ "Tienes 1 aprobación pendiente:
170
+ P-8072af8 kubectl apply -f manifest.yaml [apply] hace 2 min"
171
+
172
+ User: "ver P-8072af8"
173
+ → orchestrator reads pending-8072af8044f0da0571c348041ad2cef6.json
174
+ → presents detail view
175
+
176
+ User: "aprobar P-8072af8"
177
+ → orchestrator calls AskUserQuestion with all 5 fields visible
178
+ → user selects "Approve -- kubectl apply -f manifest.yaml [P-8072af80]"
179
+ → PostToolUse hook extracts nonce from label, activates grant for nonce 8072af8044f0da0571c348041ad2cef6
180
+ → orchestrator dispatches one-shot agent with nonce + command
181
+ → agent runs command; hook validates nonce and allows T3 through
182
+ → agent returns COMPLETE; pending file deleted
183
+ ```
184
+
185
+ ### Cross-session path
186
+
187
+ ```
188
+ SessionStart (new session)
189
+ → scans .claude/cache/approvals/pending-*.json
190
+ → pending-8072af8044f0da0571c348041ad2cef6.json has session_id = "prior-session"
191
+ → scanner annotates entry with [session anterior]
192
+ → injects summary into additionalContext
193
+
194
+ User sees:
195
+ "Tienes 1 aprobación pendiente:
196
+ P-8072af8 kubectl apply -f manifest.yaml [apply] hace 5 min [session anterior]"
197
+
198
+ User: "aprobar P-8072af8"
199
+ → orchestrator calls AskUserQuestion with all 5 fields visible
200
+ → user selects "Approve -- kubectl apply -f manifest.yaml [P-8072af80]"
201
+ → orchestrator detects pending.session_id != CLAUDE_SESSION_ID
202
+ → calls activate_cross_session_pending(pending_data) — grant created in current session
203
+ → deletes old pending file
204
+ → dispatches one-shot agent with command only (no nonce)
205
+ → agent runs command; hook finds pre-activated grant and allows T3 through
206
+ → agent returns COMPLETE
207
+ ```
208
+
209
+ ## Pending File Location
210
+
211
+ All pending files: `.claude/cache/approvals/pending-{nonce}.json`
212
+ Index file (per-session): `.claude/cache/approvals/pending-index-{session_id}.json`
213
+
214
+ Use glob `pending-*.json` to find all pending files. Skip files starting with `pending-index-`.
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: readme-writing
3
+ description: Use when writing or updating a README for a Gaia component folder (agents/, skills/, hooks/, commands/, config/, bin/, tests/, build/, templates/, or the repo root)
4
+ metadata:
5
+ user-invocable: false
6
+ type: technique
7
+ ---
8
+
9
+ # README Writing
10
+
11
+ A folder README is not a table of contents. It is the mental model a developer or agent needs before touching anything in that folder. A README that only lists files is worse than none -- it creates the impression the folder is understood when it is not.
12
+
13
+ Gaia is event-driven. Every component has a trigger: a hook fires, a skill is injected, a command is dispatched, a config file is loaded. A README that does not explain WHEN and HOW a component activates leaves the reader guessing the most important thing.
14
+
15
+ ## Step 1: Choose your target
16
+
17
+ Write or update a README when:
18
+ - A new folder is created (agents/, skills/<name>/, hooks/, etc.)
19
+ - You add a file that changes what the folder does or when it activates
20
+ - A drift report in `cross_layer_impacts` flags a README as stale
21
+
22
+ ## Step 2: Write the 5 sections in order
23
+
24
+ Every README uses this structure. Order is not optional -- a reader skimming top-to-bottom should understand activation before they see a file tree.
25
+
26
+ **Section 1: Intro narrative** (2-4 paragraphs, no bullets, conversational)
27
+ - One sentence on what lives here
28
+ - Why this folder exists separately (the conceptual contract)
29
+ - How to think about this folder (mental model or analogy)
30
+ - Who touches it: developer, agent at runtime, CI, admin
31
+
32
+ **Section 2: When activated** (the core -- do not skip)
33
+ - The concrete trigger: what event, condition, or code path fires this
34
+ - ASCII diagram if more than 2 steps chain together
35
+ - Step-by-step list as complement when the diagram is not enough
36
+ - What happens if this folder is absent or broken
37
+
38
+ **Section 3: What's here** (annotated tree)
39
+ - One-line comment per file or subdirectory
40
+ - Mark generated files so they are not edited by hand
41
+
42
+ **Section 4: Conventions** (concrete rules, not aspirations)
43
+ - How to name new files
44
+ - What internal structure new files must follow
45
+ - What to update elsewhere when adding something here
46
+ - What validation runs against this folder
47
+
48
+ **Section 5: See also** (relative links with reason)
49
+ - Adjacent components with a one-line reason per link
50
+
51
+ ## Step 3: Write the activation section for judgment
52
+
53
+ The activation section fails when it describes intent ("skills are injected at startup") without describing mechanism ("the pre_tool_use hook reads `skills:` from agent frontmatter, then calls `skill_injection.py`, which reads each SKILL.md and prepends it to the agent context").
54
+
55
+ Concrete mechanism is the test. If the description would be true for any event-driven system, it is not concrete enough.
56
+
57
+ ## Step 4: Integration points
58
+
59
+ **With skill-creation:** When completing a new skill, update the `skills/` README to reflect the new entry. This is the last step of the skill-creation workflow, not optional cleanup.
60
+
61
+ **With gaia-patterns (Documentation Drift Awareness):** When an agent adds a file to `agents/`, `skills/`, `hooks/`, or any top-level folder, it must include the relevant README in `cross_layer_impacts` if the README no longer accurately describes the folder. The orchestrator dispatches a readme-writing task from that signal. The agent that added the file does NOT update the README itself -- it reports drift and stops.
62
+
63
+ **With test_directory_structure.py:** The system test verifies README existence for all key folders. Adding a new top-level folder without a README will cause a test failure. See `tests/system/test_directory_structure.py`.
64
+
65
+ ## Anti-Patterns
66
+
67
+ - **Activation section describes intent, not mechanism** -- "agents use skills" is intent; "pre_tool_use.py reads frontmatter and calls skill_injection.py" is mechanism.
68
+ - **File tree without comments** -- a bare tree adds no value over `ls`; every entry needs a reason.
69
+ - **Conventions that are aspirational** -- "files should be well-named" is not a convention; "skill folders use kebab-case matching the `name:` field in frontmatter" is.
70
+ - **See also without reasons** -- a link list without context shifts the burden to the reader.
71
+ - **Updating README inline during feature work** -- drift reporting exists so README updates happen as deliberate tasks, not rushed afterthoughts mid-feature.
@@ -0,0 +1,188 @@
1
+ # README Writing Reference
2
+
3
+ Extended examples for the readme-writing skill. Load this file when you need a filled-in template to work from.
4
+
5
+ ## Canonical filled example: skills/
6
+
7
+ The example below is the README for the `skills/` top-level folder. Use it as the gold standard for voice, section depth, and activation detail.
8
+
9
+ ---
10
+
11
+ ```markdown
12
+ # Skills
13
+
14
+ Las skills son conocimiento procedimental inyectado en los agentes. No son código que se ejecuta -- son texto que el agente recibe y sigue. Piénsalas como el manual de procedimientos que le das a un contractor: le dices cómo clasificar riesgos, cómo reportar resultados, cómo ejecutar comandos. El agente trae su identidad (qué es, qué puede hacer); la skill trae el proceso (cómo lo hace).
15
+
16
+ Esta carpeta existe separada de `agents/` porque el mismo procedimiento aplica a múltiples agentes. `security-tiers` la siguen seis agentes distintos. Si esa lógica viviera inline en cada `.md`, tendríamos seis copias divergiendo. Una skill es la SSOT del proceso.
17
+
18
+ Mental model: una skill es como un módulo importable, pero para texto. El agente la "importa" en startup (si está en su frontmatter) o la "requiere" en runtime (si la lee bajo demanda con el Read tool).
19
+
20
+ Las skills las toca el developer cuando crea o refina procedimientos, y el agente en runtime cuando las lee on-demand. El hook layer nunca las lee directamente.
21
+
22
+ ---
23
+
24
+ ## Cuándo se activa
25
+
26
+ Hay dos rutas de activación:
27
+
28
+ **RUTA 1 -- Startup injection (frontmatter)**
29
+
30
+ ```
31
+ Agent .md frontmatter
32
+ skills:
33
+ - agent-protocol
34
+ - security-tiers
35
+ |
36
+ v
37
+ pre_tool_use.py fires on agent start
38
+ |
39
+ v
40
+ adapters/claude_code.py -> modules/agents/skill_injection.py
41
+ |
42
+ v
43
+ Reads each SKILL.md from disk
44
+ Prepends content to agent system prompt
45
+ |
46
+ v
47
+ Agent receives process knowledge before first tool call
48
+ ```
49
+
50
+ Skills listed in frontmatter load unconditionally on every call. Keep this list short (< 5 skills, < 100 lines each) -- everything here costs tokens on every invocation.
51
+
52
+ **RUTA 2 -- On-demand (workflow skills)**
53
+
54
+ ```
55
+ Agent encounters task that needs a process
56
+ |
57
+ v
58
+ Agent reads SKILL.md directly via Read tool
59
+ |
60
+ v
61
+ Agent follows the process inline
62
+ ```
63
+
64
+ Workflow skills (approval, execution, investigation) are read on-demand because they are only needed for specific task types. Listing them in frontmatter would waste tokens on every agent call.
65
+
66
+ **What breaks if skills/ is missing or corrupted:**
67
+ - Startup-injected skills: agent proceeds without process knowledge, silently. No error. Wrong behavior.
68
+ - On-demand skills: agent gets a file-not-found error and must improvise or halt. Improvising produces inconsistent results across agents.
69
+
70
+ ---
71
+
72
+ ## Qué hay aquí
73
+
74
+ ```
75
+ skills/
76
+ ├── README.md <- este archivo
77
+ ├── reference.md <- índice de skills con tipo y descripción
78
+ ├── agent-protocol/
79
+ │ ├── SKILL.md <- protocol: response contract, state machine
80
+ │ └── examples.md <- filled json:contract examples
81
+ ├── security-tiers/
82
+ │ ├── SKILL.md <- reference: T0-T3 tier definitions
83
+ │ └── reference.md <- cloud CLI examples, conditional commands
84
+ ├── skill-creation/
85
+ │ ├── SKILL.md <- technique: how to build a skill
86
+ │ └── reference.md <- tone guide by skill type
87
+ ├── command-execution/
88
+ │ ├── SKILL.md <- discipline: no pipes, one command per step
89
+ │ └── reference.md <- cloud CLI mutation examples
90
+ └── ... (one folder per skill)
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Convenciones
96
+
97
+ - Folder name = `name:` field in SKILL.md frontmatter, kebab-case
98
+ - Every skill folder contains at minimum `SKILL.md`
99
+ - `SKILL.md` must have valid frontmatter: `name:`, `description:`, `metadata.type:`
100
+ - `description:` contains triggering conditions only -- not process summary
101
+ - `SKILL.md` < 150 lines; heavy content goes to `reference.md`
102
+ - After creating a new skill, update this README's "Qué hay aquí" section
103
+ - After creating a new skill, update `skills/reference.md` index table
104
+
105
+ Validation: `tests/system/test_directory_structure.py` verifies all skill folders have a `SKILL.md`.
106
+
107
+ ---
108
+
109
+ ## Ver también
110
+
111
+ - `agents/` -- agent definitions that consume skills via frontmatter
112
+ - `hooks/modules/agents/skill_injection.py` -- runtime that reads and injects skill content
113
+ - `skills/skill-creation/SKILL.md` -- how to build a new skill (type selection, line budget, description rules)
114
+ - `tests/system/test_directory_structure.py` -- verifies README and SKILL.md existence
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Template (blank)
120
+
121
+ Copy this when writing a README from scratch. Fill every section -- do not delete sections that seem inapplicable, as the absence of a section signals the folder was not fully analyzed.
122
+
123
+ ```markdown
124
+ # <Folder Name>
125
+
126
+ <Intro paragraph 1: one sentence on what lives here>
127
+
128
+ <Intro paragraph 2: why this folder exists separately -- the conceptual contract>
129
+
130
+ <Intro paragraph 3: how to think about this folder -- mental model or analogy>
131
+
132
+ <Intro paragraph 4: who touches it: developer / agent at runtime / CI / admin>
133
+
134
+ ---
135
+
136
+ ## Cuándo se activa
137
+
138
+ <Concrete trigger: what event, condition, or code path fires this>
139
+
140
+ ```
141
+ <ASCII diagram if > 2 steps chain>
142
+ ```
143
+
144
+ <Step-by-step list as complement>
145
+
146
+ <What breaks if this folder is absent or broken>
147
+
148
+ ---
149
+
150
+ ## Qué hay aquí
151
+
152
+ ```
153
+ <folder>/
154
+ ├── <file> <- <one-line comment>
155
+ └── <subdir>/ <- <one-line comment>
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Convenciones
161
+
162
+ - <Naming rule for new files>
163
+ - <Required internal structure>
164
+ - <What to update elsewhere when adding something here>
165
+ - <Validation that runs against this folder>
166
+
167
+ ---
168
+
169
+ ## Ver también
170
+
171
+ - `<path>` -- <one-line reason>
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Section depth guide by folder type
177
+
178
+ | Folder | Activation complexity | Typical diagram? |
179
+ |--------|----------------------|-----------------|
180
+ | `hooks/` | High -- event-driven, multi-module | Yes |
181
+ | `agents/` | Medium -- routing dispatch | Optional |
182
+ | `skills/` | Medium -- two injection paths | Yes |
183
+ | `commands/` | Low -- user-invoked slash commands | No |
184
+ | `config/` | Low -- read at startup or on-demand | No |
185
+ | `bin/` | Low -- CLI tools, user-invoked | No |
186
+ | `tests/` | Low -- run by CI or developer | No |
187
+ | `build/` | Medium -- triggered by npm run build | Optional |
188
+ | `templates/` | Low -- read by build scripts | No |
@@ -0,0 +1,135 @@
1
+ # Agent Reference
2
+
3
+ > **Legacy reference.** Current patterns and the full component inventory are in `gaia-patterns/reference.md`. This file is retained for historical context and the agent template below.
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
+ permissionMode: acceptEdits # standard for most agents; omit for orchestrator and read-only agents
14
+ skills:
15
+ - security-tiers
16
+ - agent-protocol
17
+ - context-updater
18
+ - investigation
19
+ - command-execution
20
+ ---
21
+
22
+ ## TL;DR
23
+
24
+ **Purpose:** [What this agent does]
25
+ **Input:** [What context it needs]
26
+ **Output:** [What it produces]
27
+ **Tier:** [T0-T2 or T0-T3]
28
+
29
+ For T3 approval/execution workflows, read `.claude/skills/request-approval/SKILL.md` and `.claude/skills/execution/SKILL.md`.
30
+
31
+ ---
32
+
33
+ ## Core Identity
34
+
35
+ [What makes this agent unique - 2-3 paragraphs max]
36
+
37
+ ### Code-First Protocol
38
+
39
+ 1. **Trust the Contract** - [Key contract field]
40
+ 2. **Analyze Before Generating** - Follow `investigation` skill
41
+ 3. **Pattern-Aware Generation** - [Domain-specific generation rules]
42
+ 4. **Validate** - [Domain-specific validation]
43
+ 5. **Output is a Realization Package** - [What the package contains]
44
+
45
+ ---
46
+
47
+ ## 4-Phase Workflow
48
+
49
+ ### Phase 1: Investigation
50
+ Follow `investigation` skill protocol. Then: [domain-specific steps]
51
+
52
+ ### Phase 2: Present
53
+ [What to show user]
54
+
55
+ ### Phase 3: Confirm
56
+ [Approval requirements]
57
+
58
+ ### Phase 4: Execute
59
+ [Execution steps]
60
+
61
+ ---
62
+
63
+ ## Scope
64
+
65
+ ### CAN DO
66
+ - [List capabilities]
67
+
68
+ ### CANNOT DO
69
+ - [List restrictions with delegation targets]
70
+
71
+ ### DELEGATE
72
+ [When to recommend other agents]
73
+
74
+ ---
75
+
76
+ ## Error Handling
77
+
78
+ | Error | Detection | Recovery |
79
+ |-------|-----------|----------|
80
+ | [error] | [how detected] | [how to recover] |
81
+ ```
82
+
83
+ ## Release Checklist
84
+
85
+ When publishing a new version:
86
+
87
+ 1. Read `package.json` for current version
88
+ 2. Review changes (`git log`, CHANGELOG.md)
89
+ 3. Determine version bump (patch/minor/major)
90
+ 4. Update CHANGELOG.md with changes
91
+ 5. Test symlinks work in consuming project:
92
+ ```bash
93
+ # In consuming project
94
+ ls -la .claude/ # Should point to node_modules/@jaguilar87/gaia/
95
+ ```
96
+ 6. Bump version:
97
+ ```bash
98
+ npm version [patch|minor|major]
99
+ ```
100
+ 7. Publish:
101
+ ```bash
102
+ npm publish --access public
103
+ ```
104
+ 8. Verify:
105
+ ```bash
106
+ npm info @jaguilar87/gaia version
107
+ ```
108
+
109
+ ## Documentation Template
110
+
111
+ ```markdown
112
+ # Component Name
113
+
114
+ Brief description of what this does and why it exists.
115
+ Written like you're explaining to a colleague.
116
+
117
+ ## Where This Fits
118
+
119
+ ```
120
+ User request → Orchestrator → **This Tool** → Agent receives context
121
+ ```
122
+
123
+ ## Quick Start
124
+
125
+ \`\`\`bash
126
+ python3 tool.py --help
127
+ \`\`\`
128
+
129
+ ## Examples
130
+
131
+ \`\`\`bash
132
+ python3 tool.py "example input"
133
+ # Output: example output
134
+ \`\`\`
135
+ ```