@jaguilar87/gaia-ops 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +315 -0
  2. package/CLAUDE.md +154 -0
  3. package/LICENSE +21 -0
  4. package/README.md +221 -0
  5. package/agents/aws-troubleshooter.md +50 -0
  6. package/agents/claude-architect.md +821 -0
  7. package/agents/devops-developer.md +92 -0
  8. package/agents/gcp-troubleshooter.md +50 -0
  9. package/agents/gitops-operator.md +360 -0
  10. package/agents/terraform-architect.md +289 -0
  11. package/bin/gaia-init.js +620 -0
  12. package/commands/architect.md +97 -0
  13. package/commands/restore-session.md +87 -0
  14. package/commands/save-session.md +88 -0
  15. package/commands/session-status.md +61 -0
  16. package/commands/speckit.add-task.md +144 -0
  17. package/commands/speckit.analyze-task.md +65 -0
  18. package/commands/speckit.implement.md +96 -0
  19. package/commands/speckit.init.md +237 -0
  20. package/commands/speckit.plan.md +88 -0
  21. package/commands/speckit.specify.md +161 -0
  22. package/commands/speckit.tasks.md +188 -0
  23. package/config/AGENTS.md +162 -0
  24. package/config/agent-catalog.md +604 -0
  25. package/config/context-contracts.md +682 -0
  26. package/config/git-standards.md +674 -0
  27. package/config/git_standards.json +69 -0
  28. package/config/orchestration-workflow.md +735 -0
  29. package/hooks/__pycache__/post_tool_use.cpython-312.pyc +0 -0
  30. package/hooks/__pycache__/pre_kubectl_security.cpython-312.pyc +0 -0
  31. package/hooks/__pycache__/pre_tool_use.cpython-312.pyc +0 -0
  32. package/hooks/__pycache__/session_start.cpython-312.pyc +0 -0
  33. package/hooks/__pycache__/subagent_stop.cpython-312.pyc +0 -0
  34. package/hooks/post_tool_use.py +463 -0
  35. package/hooks/pre_kubectl_security.py +205 -0
  36. package/hooks/pre_tool_use.py +530 -0
  37. package/hooks/session_start.py +315 -0
  38. package/hooks/subagent_stop.py +549 -0
  39. package/index.js +92 -0
  40. package/package.json +59 -0
  41. package/speckit/README.en.md +648 -0
  42. package/speckit/README.md +353 -0
  43. package/speckit/governance.md +169 -0
  44. package/speckit/scripts/check-prerequisites.sh +194 -0
  45. package/speckit/scripts/common.sh +126 -0
  46. package/speckit/scripts/create-new-feature.sh +131 -0
  47. package/speckit/scripts/init.sh +42 -0
  48. package/speckit/scripts/setup-plan.sh +95 -0
  49. package/speckit/scripts/update-agent-context.sh +718 -0
  50. package/speckit/templates/adr-template.md +118 -0
  51. package/speckit/templates/agent-file-template.md +23 -0
  52. package/speckit/templates/plan-template.md +233 -0
  53. package/speckit/templates/spec-template.md +116 -0
  54. package/speckit/templates/tasks-template-bkp.md +136 -0
  55. package/speckit/templates/tasks-template.md +345 -0
  56. package/templates/CLAUDE.template.md +170 -0
  57. package/templates/code-examples/approval_gate_workflow.py +141 -0
  58. package/templates/code-examples/clarification_workflow.py +94 -0
  59. package/templates/code-examples/commit_validation.py +86 -0
  60. package/templates/project-context.template.json +126 -0
  61. package/templates/settings.template.json +307 -0
  62. package/tools/__pycache__/agent_router.cpython-312.pyc +0 -0
  63. package/tools/__pycache__/approval_gate.cpython-312.pyc +0 -0
  64. package/tools/__pycache__/clarify_engine.cpython-312.pyc +0 -0
  65. package/tools/__pycache__/clarify_patterns.cpython-312.pyc +0 -0
  66. package/tools/__pycache__/commit_validator.cpython-312.pyc +0 -0
  67. package/tools/__pycache__/context_section_reader.cpython-312.pyc +0 -0
  68. package/tools/__pycache__/routing_dashboard.cpython-312.pyc +0 -0
  69. package/tools/__pycache__/routing_feedback.cpython-312.pyc +0 -0
  70. package/tools/__pycache__/semantic_matcher.cpython-312.pyc +0 -0
  71. package/tools/__pycache__/task_manager.cpython-312.pyc +0 -0
  72. package/tools/agent_capabilities.json +231 -0
  73. package/tools/agent_invoker_helper.py +239 -0
  74. package/tools/agent_router.py +730 -0
  75. package/tools/approval_gate.py +318 -0
  76. package/tools/clarify_engine.py +511 -0
  77. package/tools/clarify_patterns.py +356 -0
  78. package/tools/commit_validator.py +338 -0
  79. package/tools/context_provider.py +181 -0
  80. package/tools/context_section_reader.py +301 -0
  81. package/tools/demo_clarify.py +104 -0
  82. package/tools/generate_embeddings.py +168 -0
  83. package/tools/quicktriage_aws_troubleshooter.sh +45 -0
  84. package/tools/quicktriage_devops_developer.sh +38 -0
  85. package/tools/quicktriage_gcp_troubleshooter.sh +51 -0
  86. package/tools/quicktriage_gitops_operator.sh +47 -0
  87. package/tools/quicktriage_terraform_architect.sh +40 -0
  88. package/tools/semantic_matcher.py +222 -0
  89. package/tools/task_manager.py +547 -0
  90. package/tools/task_manager_README.md +395 -0
  91. package/tools/task_manager_example.py +215 -0
@@ -0,0 +1,231 @@
1
+ {
2
+ "schema_version": "1.0",
3
+ "last_updated": "2025-09-25",
4
+ "routing_matrix": {
5
+ "skills": {
6
+ "infrastructure_planning": {
7
+ "primary_agent": "terraform-architect",
8
+ "fallback_agent": "devops-developer",
9
+ "base_tier": "T1",
10
+ "confidence_boost": 0.4,
11
+ "keywords": ["infrastructure", "architecture", "planning", "design", "resource", "networking"],
12
+ "file_patterns": ["*.tf", "*.tfvars", "terragrunt.hcl", "infrastructure/", "terraform/"],
13
+ "priority_indicators": {
14
+ "high_impact": ["production", "critical", "security", "compliance"],
15
+ "uncertain": ["experimental", "prototype", "poc", "investigate"],
16
+ "time_sensitive": ["emergency", "hotfix", "urgent", "immediate"]
17
+ }
18
+ },
19
+ "terraform_operations": {
20
+ "primary_agent": "terraform-architect",
21
+ "fallback_agent": "devops-developer",
22
+ "base_tier": "T1",
23
+ "confidence_boost": 0.5,
24
+ "keywords": ["terraform", "terragrunt", "module", "state", "plan", "apply", "destroy"],
25
+ "file_patterns": ["*.tf", "*.tfvars", "*.hcl"],
26
+ "command_patterns": ["terraform", "terragrunt", "tflint", "checkov"],
27
+ "security_rules": {
28
+ "T0": ["show", "output", "graph", "version", "fmt", "validate"],
29
+ "T1": ["plan", "validate", "fmt", "init"],
30
+ "T2": ["plan -detailed-exitcode"],
31
+ "T3": ["apply", "destroy", "import", "taint", "untaint"]
32
+ }
33
+ },
34
+ "kubernetes_deployment": {
35
+ "primary_agent": "gitops-operator",
36
+ "fallback_agent": "devops-developer",
37
+ "base_tier": "T0",
38
+ "confidence_boost": 0.4,
39
+ "keywords": ["kubernetes", "k8s", "deployment", "service", "pod", "manifest", "yaml"],
40
+ "file_patterns": ["*.yaml", "*.yml", "manifests/", "k8s/"],
41
+ "command_patterns": ["kubectl"],
42
+ "security_rules": {
43
+ "T0": ["get", "describe", "logs", "port-forward"],
44
+ "T1": ["diff", "dry-run", "validate", "explain"],
45
+ "T2": ["apply --dry-run", "create --dry-run"],
46
+ "T3": ["apply", "create", "delete", "patch", "replace"]
47
+ }
48
+ },
49
+ "helm_management": {
50
+ "primary_agent": "gitops-operator",
51
+ "fallback_agent": "devops-developer",
52
+ "base_tier": "T1",
53
+ "confidence_boost": 0.3,
54
+ "keywords": ["helm", "chart", "values", "template", "release"],
55
+ "file_patterns": ["Chart.yaml", "values.yaml", "templates/", "charts/"],
56
+ "command_patterns": ["helm"],
57
+ "security_rules": {
58
+ "T0": ["list", "status", "get", "history"],
59
+ "T1": ["template", "lint", "test"],
60
+ "T2": ["install --dry-run", "upgrade --dry-run"],
61
+ "T3": ["install", "upgrade", "uninstall", "rollback"]
62
+ }
63
+ },
64
+ "gcp_operations": {
65
+ "primary_agent": "gcp-troubleshooter",
66
+ "fallback_agent": "devops-developer",
67
+ "base_tier": "T0",
68
+ "confidence_boost": 0.4,
69
+ "keywords": ["gcp", "gke", "gcloud", "google cloud", "cloud sql", "monitoring"],
70
+ "file_patterns": ["gcp/", "google-cloud/"],
71
+ "command_patterns": ["gcloud", "gsutil", "bq"],
72
+ "security_rules": {
73
+ "T0": ["describe", "list", "get-iam-policy", "logs"],
74
+ "T1": ["config", "auth", "info"],
75
+ "T2": ["--dry-run", "simulate"],
76
+ "T3": ["create", "delete", "update", "set-iam-policy"]
77
+ }
78
+ },
79
+ "aws_operations": {
80
+ "primary_agent": "aws-troubleshooter",
81
+ "fallback_agent": "devops-developer",
82
+ "base_tier": "T0",
83
+ "confidence_boost": 0.4,
84
+ "keywords": ["aws", "eks", "cloudformation", "cloudwatch", "ec2", "s3"],
85
+ "file_patterns": ["aws/", "cloudformation/"],
86
+ "command_patterns": ["aws", "eksctl"],
87
+ "security_rules": {
88
+ "T0": ["describe", "list", "get", "logs"],
89
+ "T1": ["validate", "estimate-cost"],
90
+ "T2": ["--dry-run", "simulate"],
91
+ "T3": ["create", "delete", "update", "deploy"]
92
+ }
93
+ },
94
+ "application_development": {
95
+ "primary_agent": "devops-developer",
96
+ "fallback_agent": "gitops-operator",
97
+ "base_tier": "T1",
98
+ "confidence_boost": 0.3,
99
+ "keywords": ["application", "code", "api", "frontend", "backend", "service"],
100
+ "file_patterns": ["src/", "app/", "*.js", "*.ts", "*.py", "package.json"],
101
+ "command_patterns": ["npm", "node", "python", "pytest"],
102
+ "security_rules": {
103
+ "T0": ["test", "lint", "format", "check"],
104
+ "T1": ["build", "compile", "validate"],
105
+ "T2": ["install --dry-run", "preview"],
106
+ "T3": ["deploy", "publish", "release"]
107
+ }
108
+ },
109
+ "testing_validation": {
110
+ "primary_agent": "devops-developer",
111
+ "fallback_agent": "gitops-operator",
112
+ "base_tier": "T1",
113
+ "confidence_boost": 0.5,
114
+ "keywords": ["test", "testing", "validation", "unit", "integration", "contract", "security"],
115
+ "file_patterns": ["tests/", "test/", "*test*", "*spec*"],
116
+ "command_patterns": ["pytest", "jest", "npm test"],
117
+ "security_rules": {
118
+ "T1": ["test", "validate", "lint", "security scan", "contract test"]
119
+ },
120
+ "priority_indicators": {
121
+ "critical": ["security", "contract", "integration"],
122
+ "high_confidence": ["unit", "validation", "lint"]
123
+ }
124
+ },
125
+ "documentation_creation": {
126
+ "primary_agent": "devops-developer",
127
+ "fallback_agent": "gitops-operator",
128
+ "base_tier": "T1",
129
+ "confidence_boost": 0.2,
130
+ "keywords": ["documentation", "docs", "guide", "readme", "manual"],
131
+ "file_patterns": ["*.md", "docs/", "README*"],
132
+ "security_rules": {
133
+ "T1": ["create", "update", "write", "document"]
134
+ }
135
+ },
136
+ "configuration_management": {
137
+ "primary_agent": "gitops-operator",
138
+ "fallback_agent": "devops-developer",
139
+ "base_tier": "T0",
140
+ "confidence_boost": 0.3,
141
+ "keywords": ["config", "configuration", "configmap", "secret", "environment"],
142
+ "file_patterns": ["config/", "*.conf", "*.ini", "*.env"],
143
+ "security_rules": {
144
+ "T0": ["create configmap", "update configuration"],
145
+ "T1": ["validate config", "lint configuration"],
146
+ "T3": ["secret", "credential", "key", "password", "token"]
147
+ }
148
+ },
149
+ "monitoring_observability": {
150
+ "primary_agent": "gcp-troubleshooter",
151
+ "fallback_agent": "aws-troubleshooter",
152
+ "base_tier": "T0",
153
+ "confidence_boost": 0.3,
154
+ "keywords": ["monitoring", "metrics", "logging", "observability", "health", "alerts"],
155
+ "file_patterns": ["monitoring/", "metrics/", "alerts/"],
156
+ "security_rules": {
157
+ "T0": ["health check", "monitoring", "metrics", "logs"],
158
+ "T1": ["configure monitoring", "setup alerts"]
159
+ }
160
+ }
161
+ },
162
+ "taxonomies": {
163
+ "service_types": {
164
+ "api": ["rest", "graphql", "grpc", "endpoint", "service"],
165
+ "web": ["frontend", "ui", "interface", "webapp", "client"],
166
+ "data": ["database", "storage", "persistence", "cache", "queue"],
167
+ "infrastructure": ["network", "compute", "storage", "security", "monitoring"]
168
+ },
169
+ "domains": {
170
+ "training": ["tcm", "compliance", "training", "certification", "course"],
171
+ "platform": ["kubernetes", "cloud", "infrastructure", "devops"],
172
+ "security": ["auth", "sso", "rbac", "encryption", "compliance"],
173
+ "integration": ["api", "webhook", "event", "message", "sync"]
174
+ },
175
+ "artifact_types": {
176
+ "code": ["implementation", "feature", "function", "class", "module"],
177
+ "config": ["manifest", "values", "environment", "settings"],
178
+ "test": ["unit", "integration", "contract", "performance", "security"],
179
+ "docs": ["readme", "guide", "manual", "specification", "architecture"]
180
+ }
181
+ },
182
+ "priority_signals": {
183
+ "thresholds": {
184
+ "high_impact": 0.8,
185
+ "medium_impact": 0.5,
186
+ "low_impact": 0.2,
187
+ "high_uncertainty": 0.7,
188
+ "medium_uncertainty": 0.4,
189
+ "low_uncertainty": 0.1,
190
+ "time_critical": 0.9,
191
+ "time_sensitive": 0.6,
192
+ "normal_priority": 0.3
193
+ },
194
+ "signal_mapping": {
195
+ "🎯": "high_confidence_critical",
196
+ "⚡": "high_impact_fast",
197
+ "❓": "uncertain_investigate",
198
+ "🚨": "critical_immediate",
199
+ "⚠️": "caution_required",
200
+ "✅": "validated_safe"
201
+ }
202
+ }
203
+ },
204
+ "fallback_rules": {
205
+ "confidence_threshold": 0.7,
206
+ "default_agent": "devops-developer",
207
+ "escalation_triggers": [
208
+ "multiple_agents_equal_score",
209
+ "confidence_below_threshold",
210
+ "security_tier_mismatch",
211
+ "critical_priority_detected"
212
+ ]
213
+ },
214
+ "integration_metadata": {
215
+ "bundle_fields": [
216
+ "suggested_agent",
217
+ "confidence_score",
218
+ "security_tier",
219
+ "priority_signal",
220
+ "routing_reasoning",
221
+ "fallback_options",
222
+ "skill_matches"
223
+ ],
224
+ "handshake_validation": {
225
+ "verify_agent_match": true,
226
+ "verify_tier_compatibility": true,
227
+ "require_approval_on_mismatch": true,
228
+ "log_routing_decisions": true
229
+ }
230
+ }
231
+ }
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Agent Invoker Helper - Context Pre-Loading Pattern
4
+
5
+ This helper demonstrates the CORRECT pattern for invoking specialized agents
6
+ with pre-loaded, filtered context from project-context.json.
7
+
8
+ Philosophy:
9
+ - Claude orchestrator (main conversation) pre-loads context BEFORE invoking agents
10
+ - Agents receive everything in the prompt - NO file reads needed
11
+ - 50-76% token savings per agent invocation
12
+
13
+ Usage:
14
+ from .claude.tools.agent_invoker_helper import AgentInvokerHelper
15
+
16
+ helper = AgentInvokerHelper()
17
+
18
+ # Get pre-loaded context for terraform-architect
19
+ context = helper.get_agent_context('terraform-architect')
20
+
21
+ # Build prompt with pre-loaded context
22
+ prompt = helper.build_prompt(
23
+ agent='terraform-architect',
24
+ task_description='Clean up legacy TCM resources',
25
+ instructions=[
26
+ 'Identify all Terraform modules...',
27
+ 'Create a plan showing...',
28
+ 'Generate instructions...'
29
+ ]
30
+ )
31
+
32
+ # Invoke agent with pre-loaded context
33
+ Task(
34
+ subagent_type='terraform-architect',
35
+ description='Clean up legacy TCM resources',
36
+ prompt=prompt
37
+ )
38
+ """
39
+
40
+ from pathlib import Path
41
+ from typing import List, Optional, Dict
42
+ import json
43
+
44
+
45
+ class AgentInvokerHelper:
46
+ """Helper for invoking agents with pre-loaded, filtered context."""
47
+
48
+ def __init__(self):
49
+ """Initialize the helper with context reader."""
50
+ from context_section_reader import ContextSectionReader
51
+ self.reader = ContextSectionReader()
52
+
53
+ def get_agent_context(self, agent_name: str) -> str:
54
+ """
55
+ Get pre-filtered context for a specific agent.
56
+
57
+ Args:
58
+ agent_name: Name of the agent (e.g., 'terraform-architect')
59
+
60
+ Returns:
61
+ Markdown string with pre-filtered context sections
62
+
63
+ Example:
64
+ context = helper.get_agent_context('terraform-architect')
65
+ # Returns ~145 lines, ~580 tokens (vs 1,312 tokens full)
66
+ """
67
+ return self.reader.get_for_agent(agent_name)
68
+
69
+ def get_token_savings(self, agent_name: str) -> Dict:
70
+ """
71
+ Get token savings estimate for context pre-loading.
72
+
73
+ Args:
74
+ agent_name: Name of the agent
75
+
76
+ Returns:
77
+ Dictionary with token counts and savings percentage
78
+ """
79
+ return self.reader.get_agent_stats(agent_name)
80
+
81
+ def build_prompt(
82
+ self,
83
+ agent: str,
84
+ task_description: str,
85
+ instructions: List[str],
86
+ additional_context: Optional[str] = None
87
+ ) -> str:
88
+ """
89
+ Build a prompt with pre-loaded context for an agent.
90
+
91
+ This is the CORRECT pattern - context comes in the prompt, not from files.
92
+
93
+ Args:
94
+ agent: Agent name (e.g., 'terraform-architect')
95
+ task_description: High-level description of the task
96
+ instructions: List of specific instructions
97
+ additional_context: Optional additional context
98
+
99
+ Returns:
100
+ Complete prompt with pre-loaded context
101
+
102
+ Example:
103
+ prompt = helper.build_prompt(
104
+ agent='terraform-architect',
105
+ task_description='Clean up TCM resources',
106
+ instructions=[
107
+ 'List modules in /terraform/tf_live/rnd/',
108
+ 'Create plan for tcm-vpc removal',
109
+ 'Do NOT execute destroy'
110
+ ]
111
+ )
112
+ """
113
+ # Get pre-filtered context for this agent
114
+ context = self.get_agent_context(agent)
115
+
116
+ # Build instruction section
117
+ instruction_text = '\n'.join([f'{i+1}. {instr}' for i, instr in enumerate(instructions)])
118
+
119
+ # Construct prompt
120
+ prompt = f"""# Project Context (Pre-Loaded for {agent})
121
+
122
+ {context}
123
+
124
+ ---
125
+
126
+ # Task Description
127
+
128
+ {task_description}
129
+
130
+ # Task Instructions
131
+
132
+ {instruction_text}
133
+ """
134
+
135
+ if additional_context:
136
+ prompt += f"""
137
+ # Additional Context
138
+
139
+ {additional_context}
140
+ """
141
+
142
+ return prompt
143
+
144
+ def invoke_agent_with_context(
145
+ self,
146
+ agent_name: str,
147
+ task_description: str,
148
+ instructions: List[str],
149
+ additional_context: Optional[str] = None
150
+ ) -> str:
151
+ """
152
+ Generate a complete Task tool invocation with pre-loaded context.
153
+
154
+ This shows how to invoke agents the CORRECT way.
155
+
156
+ Args:
157
+ agent_name: Agent to invoke
158
+ task_description: Task description
159
+ instructions: Task instructions
160
+ additional_context: Optional additional context
161
+
162
+ Returns:
163
+ Python code snippet ready for Task() invocation
164
+ """
165
+ prompt = self.build_prompt(
166
+ agent=agent_name,
167
+ task_description=task_description,
168
+ instructions=instructions,
169
+ additional_context=additional_context
170
+ )
171
+
172
+ code_snippet = f'''# CORRECT INVOCATION PATTERN
173
+ Task(
174
+ subagent_type='{agent_name}',
175
+ description='{task_description}',
176
+ prompt=f"""
177
+ {prompt}
178
+ """
179
+ )
180
+ '''
181
+ return code_snippet
182
+
183
+ def print_agent_stats(self) -> None:
184
+ """Print token savings statistics for all agents."""
185
+ print("\n📊 Token Savings by Agent (Context Pre-Loading)\n")
186
+ print("Agent | Lines | Tokens | Savings")
187
+ print("-" * 60)
188
+
189
+ for agent in self.reader.AGENT_SECTIONS.keys():
190
+ stats = self.reader.get_agent_stats(agent)
191
+ print(
192
+ f"{agent:26} | {stats['lines_loaded']:5} | "
193
+ f"{stats['tokens_estimated']:6} | {stats['savings']['percentage']:.1f}%"
194
+ )
195
+
196
+ full_stats = self.reader.get_stats()
197
+ print("\n" + "=" * 60)
198
+ print(f"Full project-context.json: {full_stats['total_lines']} lines, "
199
+ f"{full_stats['total_tokens_estimated']} tokens")
200
+ print("=" * 60)
201
+
202
+
203
+ # Example usage showing the CORRECT pattern
204
+ if __name__ == '__main__':
205
+ helper = AgentInvokerHelper()
206
+
207
+ # Show stats
208
+ helper.print_agent_stats()
209
+
210
+ print("\n\n" + "="*70)
211
+ print("EXAMPLE: Invoking terraform-architect with pre-loaded context")
212
+ print("="*70 + "\n")
213
+
214
+ # Build example prompt
215
+ example_prompt = helper.build_prompt(
216
+ agent='terraform-architect',
217
+ task_description='Clean up legacy TCM resources',
218
+ instructions=[
219
+ 'Identify all Terraform modules in /terraform/tf_live/rnd/',
220
+ 'Create a plan showing what will be destroyed',
221
+ 'Do NOT execute destroy - only plan and document'
222
+ ]
223
+ )
224
+
225
+ print(example_prompt[:500] + "...\n")
226
+
227
+ print("\n" + "="*70)
228
+ print("CORRECT INVOCATION CODE:")
229
+ print("="*70 + "\n")
230
+
231
+ print(helper.invoke_agent_with_context(
232
+ agent_name='terraform-architect',
233
+ task_description='Clean up legacy TCM resources',
234
+ instructions=[
235
+ 'Identify all Terraform modules in /terraform/tf_live/rnd/',
236
+ 'Create a plan showing what will be destroyed',
237
+ 'Do NOT execute destroy - only plan and document'
238
+ ]
239
+ ))