talkops-opscloud 0.3.0b1__py3-none-any.whl

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 (309) hide show
  1. opscloud/__init__.py +5 -0
  2. opscloud/__main__.py +6 -0
  3. opscloud/_constants.py +53 -0
  4. opscloud/_debug.py +145 -0
  5. opscloud/_debug_buffer.py +250 -0
  6. opscloud/_textual_patches.py +367 -0
  7. opscloud/_version.py +15 -0
  8. opscloud/agent/__init__.py +27 -0
  9. opscloud/agent/config.py +168 -0
  10. opscloud/agent/factory.py +1103 -0
  11. opscloud/approval_mode.py +44 -0
  12. opscloud/backend/__init__.py +49 -0
  13. opscloud/backend/composite.py +89 -0
  14. opscloud/backend/local.py +183 -0
  15. opscloud/backend/registry.py +79 -0
  16. opscloud/backend/sandbox_config.py +107 -0
  17. opscloud/backend/sandbox_factory.py +432 -0
  18. opscloud/built_in_skills/remember/SKILL.md +124 -0
  19. opscloud/built_in_skills/skill-creator/SKILL.md +348 -0
  20. opscloud/built_in_skills/skill-creator/scripts/init_skill.py +371 -0
  21. opscloud/built_in_skills/skill-creator/scripts/quick_validate.py +165 -0
  22. opscloud/cli/__init__.py +1 -0
  23. opscloud/cli/commands/__init__.py +15 -0
  24. opscloud/cli/commands/auth.py +45 -0
  25. opscloud/cli/commands/doctor.py +100 -0
  26. opscloud/cli/commands/mcp.py +137 -0
  27. opscloud/cli/commands/threads.py +51 -0
  28. opscloud/cli/interactive.py +154 -0
  29. opscloud/cli/main.py +903 -0
  30. opscloud/cli/non_interactive.py +425 -0
  31. opscloud/cli/server_manager.py +58 -0
  32. opscloud/commands/__init__.py +19 -0
  33. opscloud/commands/_base.py +110 -0
  34. opscloud/commands/_guards.py +52 -0
  35. opscloud/commands/_router.py +146 -0
  36. opscloud/commands/_types.py +36 -0
  37. opscloud/commands/core/__init__.py +47 -0
  38. opscloud/commands/core/auth.py +94 -0
  39. opscloud/commands/core/bug.py +46 -0
  40. opscloud/commands/core/clear.py +106 -0
  41. opscloud/commands/core/cloud.py +185 -0
  42. opscloud/commands/core/compact.py +128 -0
  43. opscloud/commands/core/config_cmd.py +120 -0
  44. opscloud/commands/core/context.py +220 -0
  45. opscloud/commands/core/cost.py +44 -0
  46. opscloud/commands/core/doctor.py +535 -0
  47. opscloud/commands/core/effort.py +108 -0
  48. opscloud/commands/core/exit_cmd.py +41 -0
  49. opscloud/commands/core/fast.py +148 -0
  50. opscloud/commands/core/help_cmd.py +94 -0
  51. opscloud/commands/core/mcp.py +134 -0
  52. opscloud/commands/core/model.py +109 -0
  53. opscloud/commands/core/permissions.py +196 -0
  54. opscloud/commands/core/plugins.py +92 -0
  55. opscloud/commands/core/pool.py +108 -0
  56. opscloud/commands/core/resume.py +97 -0
  57. opscloud/commands/core/skills.py +178 -0
  58. opscloud/commands/power/__init__.py +51 -0
  59. opscloud/commands/power/agents.py +98 -0
  60. opscloud/commands/power/btw.py +85 -0
  61. opscloud/commands/power/copy.py +97 -0
  62. opscloud/commands/power/goal.py +548 -0
  63. opscloud/commands/power/loop.py +295 -0
  64. opscloud/commands/power/memory.py +287 -0
  65. opscloud/commands/power/review.py +152 -0
  66. opscloud/commands/power/rubric.py +287 -0
  67. opscloud/commands/power/runtime.py +321 -0
  68. opscloud/commands/power/skill_creator.py +70 -0
  69. opscloud/commands/power/skill_invoke.py +165 -0
  70. opscloud/commands/power/tasks.py +209 -0
  71. opscloud/commands/power/trace.py +117 -0
  72. opscloud/commands/power/ui_toggles.py +135 -0
  73. opscloud/commands/power/version.py +52 -0
  74. opscloud/commands/registry.py +176 -0
  75. opscloud/config/__init__.py +114 -0
  76. opscloud/config/adapters/__init__.py +5 -0
  77. opscloud/config/adapters/postgres.py +776 -0
  78. opscloud/config/adapters/sqlite.py +769 -0
  79. opscloud/config/aws.py +248 -0
  80. opscloud/config/cloud_profiles.py +437 -0
  81. opscloud/config/env_vars.py +81 -0
  82. opscloud/config/langsmith.py +319 -0
  83. opscloud/config/manifest.py +817 -0
  84. opscloud/config/metadata.py +205 -0
  85. opscloud/config/paths.py +604 -0
  86. opscloud/config/plugins.py +130 -0
  87. opscloud/config/settings.py +834 -0
  88. opscloud/config/store.py +453 -0
  89. opscloud/config/store_factory.py +97 -0
  90. opscloud/config/toml_config.py +562 -0
  91. opscloud/editor.py +173 -0
  92. opscloud/exceptions.py +65 -0
  93. opscloud/file_ops.py +217 -0
  94. opscloud/hooks/__init__.py +139 -0
  95. opscloud/hooks/env.py +44 -0
  96. opscloud/hooks/interrupt.py +121 -0
  97. opscloud/hooks/models/__init__.py +109 -0
  98. opscloud/hooks/models/adapters.py +19 -0
  99. opscloud/hooks/models/config.py +79 -0
  100. opscloud/hooks/models/domain.py +434 -0
  101. opscloud/hooks/models/transport.py +37 -0
  102. opscloud/hooks/tools.py +231 -0
  103. opscloud/input.py +48 -0
  104. opscloud/integrations/__init__.py +80 -0
  105. opscloud/integrations/base.py +153 -0
  106. opscloud/integrations/content_filter.py +119 -0
  107. opscloud/integrations/event_bus.py +480 -0
  108. opscloud/integrations/hooks.py +238 -0
  109. opscloud/integrations/identity.py +181 -0
  110. opscloud/integrations/notifications.py +134 -0
  111. opscloud/integrations/stream_bridge.py +397 -0
  112. opscloud/integrations/thread_store.py +81 -0
  113. opscloud/json_types.py +20 -0
  114. opscloud/mcp/__init__.py +57 -0
  115. opscloud/mcp/config.py +203 -0
  116. opscloud/mcp/discovery.py +229 -0
  117. opscloud/mcp/mcp_info.py +109 -0
  118. opscloud/mcp/middleware.py +102 -0
  119. opscloud/mcp/preload.py +505 -0
  120. opscloud/mcp/raw_config.py +149 -0
  121. opscloud/mcp/semantic_profiler.py +305 -0
  122. opscloud/mcp/session_manager.py +727 -0
  123. opscloud/mcp/trust.py +105 -0
  124. opscloud/memory/__init__.py +27 -0
  125. opscloud/memory/branch.py +61 -0
  126. opscloud/memory/guard.py +19 -0
  127. opscloud/memory/onboarding.py +120 -0
  128. opscloud/memory/registry.py +134 -0
  129. opscloud/memory/store.py +223 -0
  130. opscloud/middleware/__init__.py +106 -0
  131. opscloud/middleware/_repository_bounds.py +459 -0
  132. opscloud/middleware/ask_user.py +152 -0
  133. opscloud/middleware/auto_mode.py +60 -0
  134. opscloud/middleware/auto_mode_hitl.py +2434 -0
  135. opscloud/middleware/compaction.py +566 -0
  136. opscloud/middleware/configurable_model.py +233 -0
  137. opscloud/middleware/cost_tracking.py +1021 -0
  138. opscloud/middleware/glm_stall_recovery.py +109 -0
  139. opscloud/middleware/goal_criteria.py +1234 -0
  140. opscloud/middleware/goal_state_notice.py +712 -0
  141. opscloud/middleware/goal_tools.py +407 -0
  142. opscloud/middleware/headless_mcp_guard.py +88 -0
  143. opscloud/middleware/jev_model_router.py +1018 -0
  144. opscloud/middleware/local_context.py +460 -0
  145. opscloud/middleware/mcp_context.py +151 -0
  146. opscloud/middleware/mcp_middleware.py +146 -0
  147. opscloud/middleware/memory_guard.py +393 -0
  148. opscloud/middleware/model_retry.py +205 -0
  149. opscloud/middleware/registry.py +137 -0
  150. opscloud/middleware/reliable_rubric.py +709 -0
  151. opscloud/middleware/resume_state.py +91 -0
  152. opscloud/middleware/server_hooks.py +1189 -0
  153. opscloud/middleware/shell_allow_list.py +90 -0
  154. opscloud/middleware/skills.py +382 -0
  155. opscloud/middleware/subagent_artifacts.py +84 -0
  156. opscloud/middleware/subagent_telemetry.py +261 -0
  157. opscloud/middleware/subagents.py +243 -0
  158. opscloud/middleware/tool_filter.py +384 -0
  159. opscloud/middleware/unified_system_message.py +62 -0
  160. opscloud/model/__init__.py +37 -0
  161. opscloud/model/config.py +2992 -0
  162. opscloud/model/factory.py +477 -0
  163. opscloud/model/pool.py +459 -0
  164. opscloud/model/reasoning.py +282 -0
  165. opscloud/offload.py +173 -0
  166. opscloud/output.py +64 -0
  167. opscloud/plugins/__init__.py +189 -0
  168. opscloud/plugins/_json.py +22 -0
  169. opscloud/plugins/adapters/__init__.py +13 -0
  170. opscloud/plugins/adapters/agents.py +112 -0
  171. opscloud/plugins/adapters/commands.py +190 -0
  172. opscloud/plugins/adapters/mcp.py +363 -0
  173. opscloud/plugins/adapters/skills.py +132 -0
  174. opscloud/plugins/commands_cli.py +541 -0
  175. opscloud/plugins/discovery.py +512 -0
  176. opscloud/plugins/manifest.py +335 -0
  177. opscloud/plugins/marketplace.py +893 -0
  178. opscloud/plugins/models.py +334 -0
  179. opscloud/plugins/project_plugins.py +317 -0
  180. opscloud/plugins/protocol.py +31 -0
  181. opscloud/plugins/store.py +905 -0
  182. opscloud/plugins/substitution.py +122 -0
  183. opscloud/project_utils.py +145 -0
  184. opscloud/prompts/__init__.py +37 -0
  185. opscloud/prompts/system.py +483 -0
  186. opscloud/prompts/templates/system_prompt.md +166 -0
  187. opscloud/prompts/types.py +54 -0
  188. opscloud/rubrics/__init__.py +42 -0
  189. opscloud/rubrics/evaluator.py +404 -0
  190. opscloud/rubrics/evidence_extractor.py +229 -0
  191. opscloud/rubrics/generator.py +239 -0
  192. opscloud/rubrics/jev_compiler.py +175 -0
  193. opscloud/rubrics/jev_grader.py +297 -0
  194. opscloud/rubrics/middleware.py +8 -0
  195. opscloud/schema/__init__.py +107 -0
  196. opscloud/schema/interrupts.py +981 -0
  197. opscloud/security/__init__.py +91 -0
  198. opscloud/security/approval_mode.py +528 -0
  199. opscloud/security/approval_mode_source.py +230 -0
  200. opscloud/security/cli_ast_evaluator.py +552 -0
  201. opscloud/security/jev_classifier.py +651 -0
  202. opscloud/security/shell_safety.py +340 -0
  203. opscloud/security/unicode_security.py +439 -0
  204. opscloud/security/url_validation.py +160 -0
  205. opscloud/server/__init__.py +13 -0
  206. opscloud/server/_server_config.py +158 -0
  207. opscloud/server/server.py +242 -0
  208. opscloud/server/server_graph.py +93 -0
  209. opscloud/skills/__init__.py +91 -0
  210. opscloud/skills/commands.py +1099 -0
  211. opscloud/skills/invocation.py +200 -0
  212. opscloud/skills/load.py +388 -0
  213. opscloud/skills/loader.py +23 -0
  214. opscloud/skills/merge.py +65 -0
  215. opscloud/skills/registry.py +263 -0
  216. opscloud/skills/sources.py +174 -0
  217. opscloud/skills/trust.py +417 -0
  218. opscloud/state/__init__.py +142 -0
  219. opscloud/state/base.py +154 -0
  220. opscloud/state/cloud_context.py +262 -0
  221. opscloud/state/goal_channels.py +124 -0
  222. opscloud/state/goal_state_limits.py +175 -0
  223. opscloud/state/resume_state.py +58 -0
  224. opscloud/state/service_context.py +281 -0
  225. opscloud/state/session.py +957 -0
  226. opscloud/state/state_migration.py +86 -0
  227. opscloud/subagents/__init__.py +30 -0
  228. opscloud/subagents/loader.py +331 -0
  229. opscloud/subagents/subagents_parser.py +117 -0
  230. opscloud/subagents/types.py +25 -0
  231. opscloud/tools/__init__.py +36 -0
  232. opscloud/tools/catalog.py +37 -0
  233. opscloud/tools/display.py +24 -0
  234. opscloud/tools/fetch_url.py +176 -0
  235. opscloud/tools/goal_tools.py +423 -0
  236. opscloud/tools/registry.py +105 -0
  237. opscloud/tools/thread.py +32 -0
  238. opscloud/tools/web_search.py +215 -0
  239. opscloud/ui/__init__.py +119 -0
  240. opscloud/ui/app.py +5400 -0
  241. opscloud/ui/app.tcss +479 -0
  242. opscloud/ui/clipboard.py +147 -0
  243. opscloud/ui/command_registry.py +482 -0
  244. opscloud/ui/message_store.py +152 -0
  245. opscloud/ui/permission_store.py +360 -0
  246. opscloud/ui/preferences.py +113 -0
  247. opscloud/ui/prompt_manager.py +96 -0
  248. opscloud/ui/remote_client.py +505 -0
  249. opscloud/ui/textual_adapter.py +1269 -0
  250. opscloud/ui/theme.py +728 -0
  251. opscloud/ui/ui_help.py +415 -0
  252. opscloud/ui/widgets/__init__.py +383 -0
  253. opscloud/ui/widgets/_ask_user_types.py +81 -0
  254. opscloud/ui/widgets/_copy_spans.py +52 -0
  255. opscloud/ui/widgets/_inline_prompt.py +290 -0
  256. opscloud/ui/widgets/_js_eval_display.py +139 -0
  257. opscloud/ui/widgets/_links.py +175 -0
  258. opscloud/ui/widgets/_tool_stream.py +308 -0
  259. opscloud/ui/widgets/agent_selector.py +297 -0
  260. opscloud/ui/widgets/approval.py +741 -0
  261. opscloud/ui/widgets/ask_user.py +539 -0
  262. opscloud/ui/widgets/auth.py +695 -0
  263. opscloud/ui/widgets/auth_manager.py +214 -0
  264. opscloud/ui/widgets/auto_mode_notice.py +146 -0
  265. opscloud/ui/widgets/autocomplete.py +709 -0
  266. opscloud/ui/widgets/chat_input.py +805 -0
  267. opscloud/ui/widgets/cloud_selector.py +528 -0
  268. opscloud/ui/widgets/config_manager.py +652 -0
  269. opscloud/ui/widgets/debug_console.py +1269 -0
  270. opscloud/ui/widgets/devops_renderers.py +184 -0
  271. opscloud/ui/widgets/diff.py +237 -0
  272. opscloud/ui/widgets/effort_selector.py +166 -0
  273. opscloud/ui/widgets/goal_review.py +612 -0
  274. opscloud/ui/widgets/goal_status.py +57 -0
  275. opscloud/ui/widgets/infra_panel.py +141 -0
  276. opscloud/ui/widgets/install_confirm.py +114 -0
  277. opscloud/ui/widgets/loading.py +170 -0
  278. opscloud/ui/widgets/mcp_viewer.py +1204 -0
  279. opscloud/ui/widgets/messages.py +4461 -0
  280. opscloud/ui/widgets/model_selector.py +863 -0
  281. opscloud/ui/widgets/notification_center.py +108 -0
  282. opscloud/ui/widgets/notification_settings.py +119 -0
  283. opscloud/ui/widgets/operation_card.py +106 -0
  284. opscloud/ui/widgets/permissions_manager.py +667 -0
  285. opscloud/ui/widgets/plugin_manager.py +1212 -0
  286. opscloud/ui/widgets/pool_selector.py +376 -0
  287. opscloud/ui/widgets/preamble.py +53 -0
  288. opscloud/ui/widgets/skills_viewer.py +432 -0
  289. opscloud/ui/widgets/status.py +1037 -0
  290. opscloud/ui/widgets/subagent_panel.py +927 -0
  291. opscloud/ui/widgets/theme_selector.py +232 -0
  292. opscloud/ui/widgets/thread_selector.py +358 -0
  293. opscloud/ui/widgets/toast.py +31 -0
  294. opscloud/ui/widgets/tool_display.py +325 -0
  295. opscloud/ui/widgets/tool_renderers.py +234 -0
  296. opscloud/ui/widgets/tool_widgets.py +278 -0
  297. opscloud/ui/widgets/welcome.py +421 -0
  298. opscloud/ui/widgets/welcome_popup.py +102 -0
  299. opscloud/utils/__init__.py +24 -0
  300. opscloud/utils/cost_estimation.py +169 -0
  301. opscloud/utils/git.py +390 -0
  302. opscloud/utils/logger.py +571 -0
  303. opscloud/utils/session_stats.py +115 -0
  304. opscloud/utils/startup_error.py +37 -0
  305. talkops_opscloud-0.3.0b1.dist-info/METADATA +449 -0
  306. talkops_opscloud-0.3.0b1.dist-info/RECORD +309 -0
  307. talkops_opscloud-0.3.0b1.dist-info/WHEEL +4 -0
  308. talkops_opscloud-0.3.0b1.dist-info/entry_points.txt +2 -0
  309. talkops_opscloud-0.3.0b1.dist-info/licenses/LICENSE +175 -0
@@ -0,0 +1,371 @@
1
+ #!/usr/bin/env python3
2
+ """Skill Initializer - Creates a new skill from template.
3
+
4
+ Usage:
5
+ init_skill.py <skill-name> --path <path>
6
+
7
+ Examples:
8
+ init_skill.py my-new-skill --path skills/public
9
+ init_skill.py my-api-helper --path skills/private
10
+ init_skill.py custom-skill --path /custom/location
11
+
12
+ For opscloud CLI:
13
+ init_skill.py my-skill --path "${OPSCLOUD_HOME:-$HOME/.opscloud}/skills"
14
+ init_skill.py my-skill --path .opscloud/skills
15
+ """
16
+
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ MAX_SKILL_NAME_LENGTH = 64
21
+
22
+ SKILL_TEMPLATE = """---
23
+ name: {skill_name}
24
+ description: "[TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.]"
25
+ ---
26
+
27
+ # {skill_title}
28
+
29
+ ## Overview
30
+
31
+ [TODO: 1-2 sentences explaining what this skill enables]
32
+
33
+ ## Structuring This Skill
34
+
35
+ [TODO: Choose the structure that best fits this skill's purpose. Common patterns:
36
+
37
+ **1. Workflow-Based** (best for sequential processes)
38
+ - Works well when there are clear step-by-step procedures
39
+ - Example: Cloud deployment with "Pre-flight Checks" → "Terraform Plan" → "Apply" → "Verification"
40
+ - Structure: ## Overview → ## Workflow Decision Tree → ## Step 1 → ## Step 2...
41
+
42
+ **2. Task-Based** (best for tool collections)
43
+ - Works well when the skill offers different operations/capabilities
44
+ - Example: Kubernetes skill with "Cluster Health" → "Pod Logs" → "Rollout Restart" → "Config Inspection"
45
+ - Structure: ## Overview → ## Quick Start → ## Task Category 1 → ## Task Category 2...
46
+
47
+ **3. Reference/Guidelines** (best for standards or specifications)
48
+ - Works well for security baselines, coding standards, or compliance
49
+ - Example: IAM governance with "Least Privilege Baselines" → "Tagging Standards" → "Audit Remediation"
50
+ - Structure: ## Overview → ## Guidelines → ## Specifications → ## Usage...
51
+
52
+ **4. Capabilities-Based** (best for integrated systems)
53
+ - Works well when the skill provides multiple interrelated features
54
+ - Example: FinOps with "Cost Anomaly Detection" → "Resource Rightsizing" → "Reserved Instance Analysis"
55
+ - Structure: ## Overview → ## Core Capabilities → ### 1. Feature → ### 2. Feature...
56
+
57
+ Patterns can be mixed and matched as needed. Most skills combine patterns (e.g., start with task-based, add workflow for complex operations).
58
+
59
+ Delete this entire "Structuring This Skill" section when done - it's just guidance.]
60
+
61
+ ## [TODO: Replace with the first main section based on chosen structure]
62
+
63
+ [TODO: Add content here. See examples in existing skills:
64
+ - Code samples for technical skills
65
+ - Decision trees for complex workflows
66
+ - Concrete examples with realistic user requests
67
+ - References to scripts/templates/references as needed]
68
+
69
+ ## Resources
70
+
71
+ This skill includes example resource directories that demonstrate how to organize different types of bundled resources:
72
+
73
+ ### scripts/
74
+ Executable code (Python/Bash/etc.) that can be run directly to perform specific operations.
75
+
76
+ **Examples from other skills:**
77
+ - Cost optimization: `find_idle_resources.py`, `cleanup_unattached_ebs.py` - automation utilities
78
+ - Terraform: `generate_state_backup.py`, `check_drift.py` - Python modules for infrastructure inspection
79
+
80
+ **Appropriate for:** Python scripts, shell scripts, or any executable code that performs automation, data processing, or specific operations.
81
+
82
+ **Note:** Scripts may be executed without loading into context, but can still be read by the agent for patching or environment adjustments.
83
+
84
+ ### references/
85
+ Documentation and reference material intended to be loaded into context to inform the agent's process and thinking.
86
+
87
+ **Examples from other skills:**
88
+ - AWS Architecture: `well_architected_framework.md`, `tagging_guidelines.md` - detailed policy guides
89
+ - Infrastructure schemas: API reference documentation and query examples
90
+ - Compliance: Security baselines, audit standards
91
+
92
+ **Appropriate for:** In-depth documentation, API references, database schemas, comprehensive guides, or any detailed information that the agent should reference while working.
93
+
94
+ ### assets/
95
+ Files not intended to be loaded into context, but rather used within the output the agent produces.
96
+
97
+ **Examples from other skills:**
98
+ - Infrastructure: Terraform templates (.tf), Dockerfiles, Kubernetes manifests (.yaml)
99
+ - Configuration: Helm values templates, CI/CD pipeline definitions (.github/workflows)
100
+ - Boilerplate code: Project starter directories
101
+
102
+ **Appropriate for:** Templates, boilerplate code, document templates, configuration samples, or any files meant to be copied or used in the final output.
103
+
104
+ ---
105
+
106
+ **Any unneeded directories can be deleted.** Not every skill requires all three types of resources.
107
+ """
108
+
109
+ EXAMPLE_SCRIPT = '''#!/usr/bin/env python3
110
+ """
111
+ Example helper script for {skill_name}
112
+
113
+ This is a placeholder script that can be executed directly.
114
+ Replace with actual implementation or delete if not needed.
115
+
116
+ Example real scripts from other skills:
117
+ - aws/scripts/find_unattached_volumes.py - Discovers orphaned EBS volumes
118
+ - k8s/scripts/check_pod_restarts.py - Analyzes crash loops
119
+ """
120
+
121
+ def main():
122
+ print("This is an example script for {skill_name}")
123
+ # TODO: Add actual script logic here
124
+ # This could be cloud API calls, data processing, validation, etc.
125
+
126
+ if __name__ == "__main__":
127
+ main()
128
+ '''
129
+
130
+ EXAMPLE_REFERENCE = """# Reference Documentation for {skill_title}
131
+
132
+ This is a placeholder for detailed reference documentation.
133
+ Replace with actual reference content or delete if not needed.
134
+
135
+ Example real reference docs from other skills:
136
+ - aws/references/iam_policies.md - Comprehensive guide for least privilege IAM policies
137
+ - finops/references/pricing_models.md - Deep-dive on savings plans and spot pricing
138
+ - terraform/references/state_locking.md - Guide for DynamoDB backend lock management
139
+
140
+ ## When Reference Docs Are Useful
141
+
142
+ Reference docs are ideal for:
143
+ - Comprehensive API documentation
144
+ - Detailed workflow guides
145
+ - Complex multi-step processes
146
+ - Information too lengthy for main SKILL.md
147
+ - Content that's only needed for specific use cases
148
+
149
+ ## Structure Suggestions
150
+
151
+ ### API Reference Example
152
+ - Overview
153
+ - Authentication
154
+ - Endpoints with examples
155
+ - Error codes
156
+ - Rate limits
157
+
158
+ ### Workflow Guide Example
159
+ - Prerequisites
160
+ - Step-by-step instructions
161
+ - Common patterns
162
+ - Troubleshooting
163
+ - Best practices
164
+ """
165
+
166
+ EXAMPLE_ASSET = """# Example Asset File
167
+
168
+ This placeholder represents where asset files would be stored.
169
+ Replace with actual asset files (templates, manifests, boilerplates, etc.) or delete if not needed.
170
+
171
+ Asset files are NOT intended to be loaded into context, but rather used within
172
+ the output the agent produces.
173
+
174
+ Example asset files from other skills:
175
+ - Terraform modules: main.tf, variables.tf, outputs.tf
176
+ - Kubernetes: deployment-template.yaml, ingress-template.yaml
177
+ - Docker: Dockerfile.base, docker-compose.prod.yml
178
+ - CI/CD: github-action-deploy.yml
179
+
180
+ ## Common Asset Types
181
+
182
+ - Templates: .tf, .yaml, .json, boilerplate directories
183
+ - Configuration: .env.example, config.toml
184
+ - Scripts/Manifests: helm chart starters
185
+ - Boilerplate code: Project directories, starter files
186
+
187
+ Note: This is a text placeholder. Actual assets can be any file type.
188
+ """
189
+
190
+
191
+ def _validate_name(name: str) -> tuple[bool, str]:
192
+ """Validate skill name per Agent Skills spec.
193
+
194
+ Requirements (https://agentskills.io/specification):
195
+ - 1-64 characters
196
+ - Unicode lowercase alphanumeric and hyphens only
197
+ - Cannot start or end with hyphen
198
+ - No consecutive hyphens
199
+
200
+ Unicode lowercase alphanumeric means any character where
201
+ `c.isalpha() and c.islower()` or `c.isdigit()` returns `True`.
202
+
203
+ Args:
204
+ name: The skill name to validate.
205
+
206
+ Returns:
207
+ Tuple of (is_valid, error_message). If valid, error_message is empty.
208
+ """
209
+ if not name or not name.strip():
210
+ return False, "cannot be empty"
211
+ if len(name) > MAX_SKILL_NAME_LENGTH:
212
+ return False, "cannot exceed 64 characters"
213
+ if name.startswith("-") or name.endswith("-") or "--" in name:
214
+ return False, "must be lowercase alphanumeric with single hyphens only"
215
+ for c in name:
216
+ if c == "-":
217
+ continue
218
+ if (c.isalpha() and c.islower()) or c.isdigit():
219
+ continue
220
+ return False, "must be lowercase alphanumeric with single hyphens only"
221
+ return True, ""
222
+
223
+
224
+ def title_case_skill_name(skill_name: str) -> str:
225
+ """Convert hyphenated skill name to Title Case for display.
226
+
227
+ Returns:
228
+ Skill name with each word capitalized.
229
+ """
230
+ return " ".join(word.capitalize() for word in skill_name.split("-"))
231
+
232
+
233
+ def init_skill(skill_name: str, path: str | Path) -> Path | None:
234
+ """Initialize a new skill directory with template SKILL.md.
235
+
236
+ Args:
237
+ skill_name: Name of the skill
238
+ path: Path where the skill directory should be created
239
+
240
+ Returns:
241
+ Path to created skill directory, or None if error
242
+ """
243
+ is_valid, error_msg = _validate_name(skill_name)
244
+ if not is_valid:
245
+ print(f"Error: Invalid skill name: {error_msg}")
246
+ print(
247
+ "Skill names must be lowercase alphanumeric with hyphens only.\n"
248
+ "Examples: ecs-deploy, terraform-fix, cost-optimizer"
249
+ )
250
+ return None
251
+
252
+ # Determine skill directory path
253
+ skill_dir = Path(path).resolve() / skill_name
254
+
255
+ # Check if directory already exists
256
+ if skill_dir.exists():
257
+ print(f"Error: Skill directory already exists: {skill_dir}")
258
+ return None
259
+
260
+ # Create skill directory
261
+ try:
262
+ skill_dir.mkdir(parents=True, exist_ok=False)
263
+ print(f"Created skill directory: {skill_dir}")
264
+ except Exception as e:
265
+ print(f"Error creating directory: {e}")
266
+ return None
267
+
268
+ # Create SKILL.md from template
269
+ skill_title = title_case_skill_name(skill_name)
270
+ skill_content = SKILL_TEMPLATE.format(
271
+ skill_name=skill_name, skill_title=skill_title
272
+ )
273
+
274
+ skill_md_path = skill_dir / "SKILL.md"
275
+ try:
276
+ skill_md_path.write_text(skill_content, encoding="utf-8")
277
+ print("Created SKILL.md")
278
+ except Exception as e:
279
+ print(f"Error creating SKILL.md: {e}")
280
+ return None
281
+
282
+ # Create resource directories with example files
283
+ try:
284
+ # Create scripts/ directory with example script
285
+ scripts_dir = skill_dir / "scripts"
286
+ scripts_dir.mkdir(exist_ok=True)
287
+ example_script = scripts_dir / "example.py"
288
+ example_script.write_text(
289
+ EXAMPLE_SCRIPT.format(skill_name=skill_name), encoding="utf-8"
290
+ )
291
+ example_script.chmod(0o755)
292
+ print("Created scripts/example.py")
293
+
294
+ # Create references/ directory with example reference doc
295
+ references_dir = skill_dir / "references"
296
+ references_dir.mkdir(exist_ok=True)
297
+ example_reference = references_dir / "api_reference.md"
298
+ example_reference.write_text(
299
+ EXAMPLE_REFERENCE.format(skill_title=skill_title), encoding="utf-8"
300
+ )
301
+ print("Created references/api_reference.md")
302
+
303
+ # Create assets/ directory with example asset placeholder
304
+ assets_dir = skill_dir / "assets"
305
+ assets_dir.mkdir(exist_ok=True)
306
+ example_asset = assets_dir / "example_asset.txt"
307
+ example_asset.write_text(EXAMPLE_ASSET, encoding="utf-8")
308
+ print("Created assets/example_asset.txt")
309
+ except Exception as e:
310
+ print(f"Error creating resource directories: {e}")
311
+ return None
312
+
313
+ # Print next steps
314
+ print(f"\nSkill '{skill_name}' initialized successfully at {skill_dir}")
315
+ print("\nNext steps:")
316
+ print("1. Edit SKILL.md to complete the TODO items and update the description")
317
+ print(
318
+ "2. Customize or delete the example files in scripts/, references/, and assets/"
319
+ )
320
+ print("3. Run the validator when ready to check the skill structure")
321
+
322
+ return skill_dir
323
+
324
+
325
+ def main() -> None:
326
+ """Main entry point for the skill initialization script."""
327
+ if len(sys.argv) < 4 or sys.argv[2] != "--path":
328
+ print("Usage: init_skill.py <skill-name> --path <path>")
329
+ print("\nSkill name requirements:")
330
+ print(" - Hyphen-case identifier (e.g., 'ecs-deploy')")
331
+ print(" - Lowercase letters, digits, and hyphens only")
332
+ print(" - Max 64 characters")
333
+ print(" - Must match directory name exactly")
334
+ print("\nExamples:")
335
+ print(" init_skill.py my-new-skill --path skills/public")
336
+ print(" init_skill.py my-api-helper --path skills/private")
337
+ print(" init_skill.py custom-skill --path /custom/location")
338
+ print("\nFor opscloud CLI:")
339
+ skills_dir = "${OPSCLOUD_HOME:-$HOME/.opscloud}/skills"
340
+ print(f' init_skill.py my-skill --path "{skills_dir}"')
341
+ print(' init_skill.py my-skill --path .opscloud/skills')
342
+ sys.exit(1)
343
+
344
+ skill_name = sys.argv[1]
345
+ path = sys.argv[3]
346
+
347
+ # Early validation for fast feedback
348
+ is_valid, error_msg = _validate_name(skill_name)
349
+ if not is_valid:
350
+ print(f"Error: Invalid skill name '{skill_name}': {error_msg}")
351
+ print("\nSkill name requirements:")
352
+ print(" - Lowercase letters, digits, and hyphens only")
353
+ print(" - Cannot start or end with hyphen")
354
+ print(" - No consecutive hyphens")
355
+ print(" - Max 64 characters")
356
+ sys.exit(1)
357
+
358
+ print(f"Initializing skill: {skill_name}")
359
+ print(f" Location: {path}")
360
+ print()
361
+
362
+ result = init_skill(skill_name, path)
363
+
364
+ if result:
365
+ sys.exit(0)
366
+ else:
367
+ sys.exit(1)
368
+
369
+
370
+ if __name__ == "__main__":
371
+ main()
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env python3
2
+ """Quick validation script for skills.
3
+
4
+ For opscloud CLI, skills are located at:
5
+ - $OPSCLOUD_HOME/skills/<skill-name>/ (~/.opscloud/skills/<skill-name>/)
6
+ - .opscloud/skills/<skill-name>/
7
+ - ~/.agents/skills/<skill-name>/
8
+
9
+ Example:
10
+ ```bash
11
+ python quick_validate.py "${OPSCLOUD_HOME:-$HOME/.opscloud}/skills/my-skill"
12
+ python quick_validate.py .opscloud/skills/my-skill
13
+ ```
14
+ """
15
+
16
+ import re
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ import yaml
21
+
22
+
23
+ def validate_skill(skill_path: str | Path) -> tuple[bool, str]:
24
+ """Basic validation of a skill.
25
+
26
+ Returns:
27
+ Tuple of (is_valid, message) where is_valid is bool and message
28
+ describes result.
29
+ """
30
+ skill_path = Path(skill_path)
31
+
32
+ # Check SKILL.md exists
33
+ skill_md = skill_path / "SKILL.md"
34
+ if not skill_md.exists():
35
+ return False, "SKILL.md not found"
36
+
37
+ # Read and validate frontmatter
38
+ try:
39
+ content = skill_md.read_text(encoding="utf-8")
40
+ except Exception as exc:
41
+ return False, f"Could not read SKILL.md: {exc}"
42
+
43
+ if not content.startswith("---"):
44
+ return False, "No YAML frontmatter found"
45
+
46
+ # Extract frontmatter
47
+ match = re.match(r"^---\n(.*?)\n---", content, re.DOTALL)
48
+ if not match:
49
+ return False, "Invalid frontmatter format"
50
+
51
+ frontmatter_text = match.group(1)
52
+
53
+ # Parse YAML frontmatter
54
+ try:
55
+ frontmatter = yaml.safe_load(frontmatter_text)
56
+ if not isinstance(frontmatter, dict):
57
+ return False, "Frontmatter must be a YAML dictionary"
58
+ except yaml.YAMLError as e:
59
+ return False, f"Invalid YAML in frontmatter: {e}"
60
+
61
+ # Define allowed properties per Agent Skills spec
62
+ ALLOWED_PROPERTIES = {
63
+ "name",
64
+ "description",
65
+ "license",
66
+ "compatibility",
67
+ "allowed-tools",
68
+ "metadata",
69
+ }
70
+
71
+ # Check for unexpected properties
72
+ unexpected_keys = {str(key) for key in frontmatter if key not in ALLOWED_PROPERTIES}
73
+ if unexpected_keys:
74
+ unexpected_str = ", ".join(sorted(unexpected_keys))
75
+ allowed_str = ", ".join(sorted(ALLOWED_PROPERTIES))
76
+ return False, (
77
+ f"Unexpected key(s) in SKILL.md frontmatter: {unexpected_str}. "
78
+ f"Allowed properties are: {allowed_str}"
79
+ )
80
+
81
+ # Check required fields
82
+ if "name" not in frontmatter:
83
+ return False, "Missing 'name' in frontmatter"
84
+ if "description" not in frontmatter:
85
+ return False, "Missing 'description' in frontmatter"
86
+
87
+ # Extract name for validation
88
+ name = frontmatter.get("name", "")
89
+ if not isinstance(name, str):
90
+ return False, f"Name must be a string, got {type(name).__name__}"
91
+ name = name.strip()
92
+ if name:
93
+ # Structural hyphen checks
94
+ if name.startswith("-") or name.endswith("-") or "--" in name:
95
+ return (
96
+ False,
97
+ (
98
+ f"Name '{name}' cannot start/end with hyphen "
99
+ "or contain consecutive hyphens"
100
+ ),
101
+ )
102
+ # Character-by-character check:
103
+ # Unicode lowercase alphanumeric and hyphens only
104
+ for c in name:
105
+ if c == "-":
106
+ continue
107
+ if (c.isalpha() and c.islower()) or c.isdigit():
108
+ continue
109
+ return (
110
+ False,
111
+ (
112
+ f"Name '{name}' should be hyphen-case "
113
+ "(lowercase letters, digits, and hyphens only)"
114
+ ),
115
+ )
116
+ # Check name length (max 64 characters per spec)
117
+ if len(name) > 64:
118
+ return (
119
+ False,
120
+ f"Name is too long ({len(name)} characters). Maximum is 64 characters.",
121
+ )
122
+
123
+ # Extract and validate description
124
+ description = frontmatter.get("description", "")
125
+ if not isinstance(description, str):
126
+ return False, f"Description must be a string, got {type(description).__name__}"
127
+ description = description.strip()
128
+ if description:
129
+ # Check for angle brackets
130
+ if "<" in description or ">" in description:
131
+ return False, "Description cannot contain angle brackets (< or >)"
132
+ # Check description length (max 1024 characters per spec)
133
+ if len(description) > 1024:
134
+ return (
135
+ False,
136
+ (
137
+ f"Description is too long ({len(description)} characters). "
138
+ "Maximum is 1024 characters."
139
+ ),
140
+ )
141
+
142
+ # Extract and validate compatibility (max 500 characters per spec)
143
+ compatibility = frontmatter.get("compatibility", "")
144
+ if isinstance(compatibility, str):
145
+ compatibility = compatibility.strip()
146
+ if len(compatibility) > 500:
147
+ return (
148
+ False,
149
+ (
150
+ f"Compatibility is too long ({len(compatibility)} characters). "
151
+ "Maximum is 500 characters."
152
+ ),
153
+ )
154
+
155
+ return True, "Skill is valid!"
156
+
157
+
158
+ if __name__ == "__main__":
159
+ if len(sys.argv) != 2:
160
+ print("Usage: python quick_validate.py <skill_directory>")
161
+ sys.exit(1)
162
+
163
+ valid, message = validate_skill(sys.argv[1])
164
+ print(message)
165
+ sys.exit(0 if valid else 1)
@@ -0,0 +1 @@
1
+ """CLI package for opscloud."""
@@ -0,0 +1,15 @@
1
+ """CLI subcommands."""
2
+
3
+ from opscloud.cli.commands.auth import run_auth_command
4
+ from opscloud.cli.commands.doctor import run_doctor_command
5
+ from opscloud.cli.commands.mcp import run_mcp_command, setup_mcp_parser
6
+ from opscloud.cli.commands.threads import run_threads_command
7
+
8
+ __all__ = [
9
+ "run_auth_command",
10
+ "run_doctor_command",
11
+ "run_mcp_command",
12
+ "run_threads_command",
13
+ "setup_mcp_parser",
14
+ ]
15
+
@@ -0,0 +1,45 @@
1
+ """Auth management CLI command."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from rich.console import Console
6
+
7
+ from opscloud.config.aws import get_aws_context
8
+ from opscloud.output import OutputFormat, write_json
9
+
10
+
11
+ def run_auth_command(output_format: OutputFormat = "text") -> int:
12
+ ctx = get_aws_context()
13
+
14
+ if output_format == "json":
15
+ write_json(
16
+ "auth",
17
+ {
18
+ "authenticated": ctx.is_authenticated,
19
+ "account_id": ctx.account_id,
20
+ "arn": ctx.arn,
21
+ "user_id": ctx.user_id,
22
+ "region": ctx.region,
23
+ "profile": ctx.profile,
24
+ "error": ctx.error,
25
+ },
26
+ )
27
+ return 0 if ctx.is_authenticated else 1
28
+
29
+ console = Console()
30
+ console.print("\n[bold yellow]AWS STS Authentication Status[/bold yellow]\n")
31
+ if ctx.is_authenticated:
32
+ console.print("[bold green]Authenticated Successfully[/bold green]")
33
+ console.print(f" Account ID: {ctx.account_id}")
34
+ console.print(f" Identity ARN: {ctx.arn}")
35
+ console.print(f" User ID: {ctx.user_id}")
36
+ console.print(f" Region: {ctx.region}")
37
+ console.print(f" Profile: {ctx.profile}\n")
38
+ return 0
39
+ else:
40
+ console.print("[bold red]Not Authenticated[/bold red]")
41
+ console.print(f" Error: {ctx.error or 'No credentials found'}")
42
+ console.print(
43
+ " Tip: Configure AWS credentials via `aws configure` or export AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY\n"
44
+ )
45
+ return 1