zoe-agent 0.3.1

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 (267) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/LICENSE +96 -0
  3. package/README.md +568 -0
  4. package/dist/adapters/cli/agent.d.ts +59 -0
  5. package/dist/adapters/cli/agent.js +232 -0
  6. package/dist/adapters/cli/bootstrap.d.ts +25 -0
  7. package/dist/adapters/cli/bootstrap.js +204 -0
  8. package/dist/adapters/cli/commands/build-registry.d.ts +14 -0
  9. package/dist/adapters/cli/commands/build-registry.js +88 -0
  10. package/dist/adapters/cli/commands/clear.d.ts +7 -0
  11. package/dist/adapters/cli/commands/clear.js +10 -0
  12. package/dist/adapters/cli/commands/compact.d.ts +13 -0
  13. package/dist/adapters/cli/commands/compact.js +96 -0
  14. package/dist/adapters/cli/commands/exit.d.ts +7 -0
  15. package/dist/adapters/cli/commands/exit.js +9 -0
  16. package/dist/adapters/cli/commands/gateway.d.ts +7 -0
  17. package/dist/adapters/cli/commands/gateway.js +152 -0
  18. package/dist/adapters/cli/commands/help.d.ts +9 -0
  19. package/dist/adapters/cli/commands/help.js +12 -0
  20. package/dist/adapters/cli/commands/models.d.ts +10 -0
  21. package/dist/adapters/cli/commands/models.js +32 -0
  22. package/dist/adapters/cli/commands/registry.d.ts +70 -0
  23. package/dist/adapters/cli/commands/registry.js +111 -0
  24. package/dist/adapters/cli/commands/settings-utils.d.ts +38 -0
  25. package/dist/adapters/cli/commands/settings-utils.js +182 -0
  26. package/dist/adapters/cli/commands/settings.d.ts +9 -0
  27. package/dist/adapters/cli/commands/settings.js +395 -0
  28. package/dist/adapters/cli/commands/skills.d.ts +7 -0
  29. package/dist/adapters/cli/commands/skills.js +21 -0
  30. package/dist/adapters/cli/config-loader.d.ts +27 -0
  31. package/dist/adapters/cli/config-loader.js +48 -0
  32. package/dist/adapters/cli/docker-utils.d.ts +37 -0
  33. package/dist/adapters/cli/docker-utils.js +90 -0
  34. package/dist/adapters/cli/index.d.ts +2 -0
  35. package/dist/adapters/cli/index.js +88 -0
  36. package/dist/adapters/cli/repl.d.ts +22 -0
  37. package/dist/adapters/cli/repl.js +256 -0
  38. package/dist/adapters/cli/setup.d.ts +19 -0
  39. package/dist/adapters/cli/setup.js +613 -0
  40. package/dist/adapters/cli/system-prompts.d.ts +56 -0
  41. package/dist/adapters/cli/system-prompts.js +131 -0
  42. package/dist/adapters/cli/tui/app.d.ts +58 -0
  43. package/dist/adapters/cli/tui/app.js +314 -0
  44. package/dist/adapters/cli/tui/components/assistant-message.d.ts +5 -0
  45. package/dist/adapters/cli/tui/components/assistant-message.js +9 -0
  46. package/dist/adapters/cli/tui/components/autocomplete.d.ts +19 -0
  47. package/dist/adapters/cli/tui/components/autocomplete.js +75 -0
  48. package/dist/adapters/cli/tui/components/command-palette.d.ts +15 -0
  49. package/dist/adapters/cli/tui/components/command-palette.js +50 -0
  50. package/dist/adapters/cli/tui/components/diff-viewer.d.ts +5 -0
  51. package/dist/adapters/cli/tui/components/diff-viewer.js +109 -0
  52. package/dist/adapters/cli/tui/components/error-message.d.ts +5 -0
  53. package/dist/adapters/cli/tui/components/error-message.js +8 -0
  54. package/dist/adapters/cli/tui/components/footer.d.ts +20 -0
  55. package/dist/adapters/cli/tui/components/footer.js +19 -0
  56. package/dist/adapters/cli/tui/components/goal-status.d.ts +12 -0
  57. package/dist/adapters/cli/tui/components/goal-status.js +22 -0
  58. package/dist/adapters/cli/tui/components/info-message.d.ts +5 -0
  59. package/dist/adapters/cli/tui/components/info-message.js +8 -0
  60. package/dist/adapters/cli/tui/components/logo-banner.d.ts +7 -0
  61. package/dist/adapters/cli/tui/components/logo-banner.js +33 -0
  62. package/dist/adapters/cli/tui/components/markdown.d.ts +9 -0
  63. package/dist/adapters/cli/tui/components/markdown.js +92 -0
  64. package/dist/adapters/cli/tui/components/message-area.d.ts +19 -0
  65. package/dist/adapters/cli/tui/components/message-area.js +55 -0
  66. package/dist/adapters/cli/tui/components/permission-prompt.d.ts +13 -0
  67. package/dist/adapters/cli/tui/components/permission-prompt.js +32 -0
  68. package/dist/adapters/cli/tui/components/prompt-area.d.ts +22 -0
  69. package/dist/adapters/cli/tui/components/prompt-area.js +68 -0
  70. package/dist/adapters/cli/tui/components/text-input.d.ts +27 -0
  71. package/dist/adapters/cli/tui/components/text-input.js +142 -0
  72. package/dist/adapters/cli/tui/components/tool-call-block.d.ts +11 -0
  73. package/dist/adapters/cli/tui/components/tool-call-block.js +68 -0
  74. package/dist/adapters/cli/tui/components/user-message.d.ts +5 -0
  75. package/dist/adapters/cli/tui/components/user-message.js +8 -0
  76. package/dist/adapters/cli/tui/diff/file-write-meta.d.ts +11 -0
  77. package/dist/adapters/cli/tui/diff/file-write-meta.js +11 -0
  78. package/dist/adapters/cli/tui/diff/line-diff.d.ts +17 -0
  79. package/dist/adapters/cli/tui/diff/line-diff.js +44 -0
  80. package/dist/adapters/cli/tui/feed-serializer.d.ts +29 -0
  81. package/dist/adapters/cli/tui/feed-serializer.js +70 -0
  82. package/dist/adapters/cli/tui/file-index.d.ts +8 -0
  83. package/dist/adapters/cli/tui/file-index.js +41 -0
  84. package/dist/adapters/cli/tui/hooks/use-agent.d.ts +54 -0
  85. package/dist/adapters/cli/tui/hooks/use-agent.js +177 -0
  86. package/dist/adapters/cli/tui/hooks/use-feed.d.ts +16 -0
  87. package/dist/adapters/cli/tui/hooks/use-feed.js +25 -0
  88. package/dist/adapters/cli/tui/hooks/use-file-watcher.d.ts +10 -0
  89. package/dist/adapters/cli/tui/hooks/use-file-watcher.js +43 -0
  90. package/dist/adapters/cli/tui/hooks/use-keybindings.d.ts +16 -0
  91. package/dist/adapters/cli/tui/hooks/use-keybindings.js +25 -0
  92. package/dist/adapters/cli/tui/hooks/use-theme.d.ts +8 -0
  93. package/dist/adapters/cli/tui/hooks/use-theme.js +12 -0
  94. package/dist/adapters/cli/tui/index.d.ts +19 -0
  95. package/dist/adapters/cli/tui/index.js +206 -0
  96. package/dist/adapters/cli/tui/ink-reset.d.ts +29 -0
  97. package/dist/adapters/cli/tui/ink-reset.js +57 -0
  98. package/dist/adapters/cli/tui/layout.d.ts +15 -0
  99. package/dist/adapters/cli/tui/layout.js +15 -0
  100. package/dist/adapters/cli/tui/logo/gradient.d.ts +11 -0
  101. package/dist/adapters/cli/tui/logo/gradient.js +31 -0
  102. package/dist/adapters/cli/tui/overlays/help-dialog.d.ts +4 -0
  103. package/dist/adapters/cli/tui/overlays/help-dialog.js +26 -0
  104. package/dist/adapters/cli/tui/overlays/model-selector.d.ts +14 -0
  105. package/dist/adapters/cli/tui/overlays/model-selector.js +43 -0
  106. package/dist/adapters/cli/tui/overlays/session-selector.d.ts +35 -0
  107. package/dist/adapters/cli/tui/overlays/session-selector.js +162 -0
  108. package/dist/adapters/cli/tui/overlays/settings-overlay.d.ts +24 -0
  109. package/dist/adapters/cli/tui/overlays/settings-overlay.js +126 -0
  110. package/dist/adapters/cli/tui/session-export.d.ts +21 -0
  111. package/dist/adapters/cli/tui/session-export.js +63 -0
  112. package/dist/adapters/cli/tui/theme.d.ts +23 -0
  113. package/dist/adapters/cli/tui/theme.js +22 -0
  114. package/dist/adapters/cli/tui/types.d.ts +52 -0
  115. package/dist/adapters/cli/tui/types.js +12 -0
  116. package/dist/adapters/sdk/agent.d.ts +20 -0
  117. package/dist/adapters/sdk/agent.js +356 -0
  118. package/dist/adapters/sdk/http.d.ts +43 -0
  119. package/dist/adapters/sdk/http.js +61 -0
  120. package/dist/adapters/sdk/index.d.ts +58 -0
  121. package/dist/adapters/sdk/index.js +209 -0
  122. package/dist/adapters/sdk/settings.d.ts +18 -0
  123. package/dist/adapters/sdk/settings.js +57 -0
  124. package/dist/adapters/sdk/tools.d.ts +7 -0
  125. package/dist/adapters/sdk/tools.js +13 -0
  126. package/dist/adapters/server/auth.d.ts +53 -0
  127. package/dist/adapters/server/auth.js +168 -0
  128. package/dist/adapters/server/index.d.ts +40 -0
  129. package/dist/adapters/server/index.js +255 -0
  130. package/dist/adapters/server/rest-gateway.d.ts +13 -0
  131. package/dist/adapters/server/rest-gateway.js +218 -0
  132. package/dist/adapters/server/rest.d.ts +37 -0
  133. package/dist/adapters/server/rest.js +341 -0
  134. package/dist/adapters/server/server-core.d.ts +55 -0
  135. package/dist/adapters/server/server-core.js +121 -0
  136. package/dist/adapters/server/session-store.d.ts +81 -0
  137. package/dist/adapters/server/session-store.js +272 -0
  138. package/dist/adapters/server/settings-handlers.d.ts +24 -0
  139. package/dist/adapters/server/settings-handlers.js +360 -0
  140. package/dist/adapters/server/standalone.d.ts +19 -0
  141. package/dist/adapters/server/standalone.js +113 -0
  142. package/dist/adapters/server/websocket.d.ts +26 -0
  143. package/dist/adapters/server/websocket.js +68 -0
  144. package/dist/adapters/server/ws-handlers.d.ts +32 -0
  145. package/dist/adapters/server/ws-handlers.js +523 -0
  146. package/dist/adapters/server/ws-types.d.ts +304 -0
  147. package/dist/adapters/server/ws-types.js +7 -0
  148. package/dist/core/agent-loop.d.ts +68 -0
  149. package/dist/core/agent-loop.js +423 -0
  150. package/dist/core/config.d.ts +115 -0
  151. package/dist/core/config.js +189 -0
  152. package/dist/core/errors.d.ts +58 -0
  153. package/dist/core/errors.js +88 -0
  154. package/dist/core/hooks.d.ts +35 -0
  155. package/dist/core/hooks.js +49 -0
  156. package/dist/core/index.d.ts +23 -0
  157. package/dist/core/index.js +29 -0
  158. package/dist/core/message-convert.d.ts +41 -0
  159. package/dist/core/message-convert.js +94 -0
  160. package/dist/core/middleware/auth.d.ts +24 -0
  161. package/dist/core/middleware/auth.js +28 -0
  162. package/dist/core/middleware/logging.d.ts +23 -0
  163. package/dist/core/middleware/logging.js +28 -0
  164. package/dist/core/middleware/rate-limit.d.ts +27 -0
  165. package/dist/core/middleware/rate-limit.js +38 -0
  166. package/dist/core/middleware/semantic-tools.d.ts +10 -0
  167. package/dist/core/middleware/semantic-tools.js +43 -0
  168. package/dist/core/middleware.d.ts +48 -0
  169. package/dist/core/middleware.js +38 -0
  170. package/dist/core/permission.d.ts +25 -0
  171. package/dist/core/permission.js +50 -0
  172. package/dist/core/provider-config.d.ts +129 -0
  173. package/dist/core/provider-config.js +273 -0
  174. package/dist/core/provider-env.d.ts +39 -0
  175. package/dist/core/provider-env.js +142 -0
  176. package/dist/core/provider-resolver.d.ts +12 -0
  177. package/dist/core/provider-resolver.js +12 -0
  178. package/dist/core/session-store.d.ts +75 -0
  179. package/dist/core/session-store.js +245 -0
  180. package/dist/core/settings-manager.d.ts +57 -0
  181. package/dist/core/settings-manager.js +359 -0
  182. package/dist/core/settings-schema.d.ts +38 -0
  183. package/dist/core/settings-schema.js +171 -0
  184. package/dist/core/skill-catalog.d.ts +6 -0
  185. package/dist/core/skill-catalog.js +17 -0
  186. package/dist/core/skill-invoker.d.ts +127 -0
  187. package/dist/core/skill-invoker.js +182 -0
  188. package/dist/core/stream-accumulator.d.ts +21 -0
  189. package/dist/core/stream-accumulator.js +51 -0
  190. package/dist/core/stream-manager.d.ts +58 -0
  191. package/dist/core/stream-manager.js +212 -0
  192. package/dist/core/tool-executor.d.ts +84 -0
  193. package/dist/core/tool-executor.js +256 -0
  194. package/dist/core/types.d.ts +259 -0
  195. package/dist/core/types.js +11 -0
  196. package/dist/gateway/gateway.d.ts +52 -0
  197. package/dist/gateway/gateway.js +537 -0
  198. package/dist/gateway/index.d.ts +21 -0
  199. package/dist/gateway/index.js +31 -0
  200. package/dist/gateway/openapi-importer.d.ts +15 -0
  201. package/dist/gateway/openapi-importer.js +66 -0
  202. package/dist/gateway/semantic-scorer.d.ts +7 -0
  203. package/dist/gateway/semantic-scorer.js +24 -0
  204. package/dist/gateway/settings-adapter.d.ts +49 -0
  205. package/dist/gateway/settings-adapter.js +137 -0
  206. package/dist/gateway/tool-factory.d.ts +9 -0
  207. package/dist/gateway/tool-factory.js +414 -0
  208. package/dist/gateway/types.d.ts +68 -0
  209. package/dist/gateway/types.js +7 -0
  210. package/dist/models-catalog.js +46 -0
  211. package/dist/providers/anthropic.d.ts +22 -0
  212. package/dist/providers/anthropic.js +148 -0
  213. package/dist/providers/factory.d.ts +10 -0
  214. package/dist/providers/factory.js +25 -0
  215. package/dist/providers/openai.d.ts +15 -0
  216. package/dist/providers/openai.js +71 -0
  217. package/dist/providers/types.d.ts +48 -0
  218. package/dist/providers/types.js +1 -0
  219. package/dist/skills/args.d.ts +37 -0
  220. package/dist/skills/args.js +99 -0
  221. package/dist/skills/index.d.ts +11 -0
  222. package/dist/skills/index.js +23 -0
  223. package/dist/skills/loader.d.ts +3 -0
  224. package/dist/skills/loader.js +59 -0
  225. package/dist/skills/parser.d.ts +7 -0
  226. package/dist/skills/parser.js +152 -0
  227. package/dist/skills/registry.d.ts +13 -0
  228. package/dist/skills/registry.js +74 -0
  229. package/dist/skills/resolver.d.ts +19 -0
  230. package/dist/skills/resolver.js +116 -0
  231. package/dist/skills/types.d.ts +74 -0
  232. package/dist/skills/types.js +50 -0
  233. package/dist/tools/browser.d.ts +2 -0
  234. package/dist/tools/browser.js +68 -0
  235. package/dist/tools/core.d.ts +20 -0
  236. package/dist/tools/core.js +244 -0
  237. package/dist/tools/email.d.ts +2 -0
  238. package/dist/tools/email.js +61 -0
  239. package/dist/tools/image.d.ts +2 -0
  240. package/dist/tools/image.js +257 -0
  241. package/dist/tools/index.d.ts +2 -0
  242. package/dist/tools/index.js +88 -0
  243. package/dist/tools/interface.d.ts +22 -0
  244. package/dist/tools/interface.js +1 -0
  245. package/dist/tools/notify.d.ts +2 -0
  246. package/dist/tools/notify.js +100 -0
  247. package/dist/tools/prompt-optimizer.d.ts +2 -0
  248. package/dist/tools/prompt-optimizer.js +65 -0
  249. package/dist/tools/screenshot.d.ts +2 -0
  250. package/dist/tools/screenshot.js +184 -0
  251. package/dist/tools/search.d.ts +2 -0
  252. package/dist/tools/search.js +78 -0
  253. package/dist/tools/todos.d.ts +10 -0
  254. package/dist/tools/todos.js +50 -0
  255. package/package.json +119 -0
  256. package/skills/docker-ops/SKILL.md +329 -0
  257. package/skills/k8s-deploy/SKILL.md +397 -0
  258. package/skills/log-analyzer/SKILL.md +331 -0
  259. package/skills/speckit-analyze/SKILL.md +260 -0
  260. package/skills/speckit-checklist/SKILL.md +374 -0
  261. package/skills/speckit-clarify/SKILL.md +286 -0
  262. package/skills/speckit-constitution/SKILL.md +157 -0
  263. package/skills/speckit-implement/SKILL.md +224 -0
  264. package/skills/speckit-plan/SKILL.md +171 -0
  265. package/skills/speckit-specify/SKILL.md +346 -0
  266. package/skills/speckit-tasks/SKILL.md +215 -0
  267. package/skills/speckit-taskstoissues/SKILL.md +107 -0
@@ -0,0 +1,331 @@
1
+ ---
2
+ name: log-analyzer
3
+ description: >
4
+ Analyzing application and system logs to identify patterns, diagnose errors,
5
+ and suggest fixes. Activates when the user asks to check logs, analyze errors,
6
+ find patterns in log files, diagnose crashes, investigate failures, search for
7
+ specific events in logs, parse structured or unstructured log output, identify
8
+ anomalies or spikes in error rates, trace request flows across services, extract
9
+ stack traces, correlate timestamps across multiple log sources, review application
10
+ logs from Docker containers or Kubernetes pods, analyze syslog or journalctl output,
11
+ inspect web server access logs or error logs (nginx, apache), review database
12
+ query logs, check CI/CD pipeline logs, or summarize log data for incident reports.
13
+ Triggers on phrases like "check the logs", "what went wrong", "why is it failing",
14
+ "find the error", "grep the logs", "log analysis", "trace the issue", or
15
+ "investigate the crash".
16
+ version: 1.0.0
17
+ tags:
18
+ - logs
19
+ - debugging
20
+ - analysis
21
+ - monitoring
22
+ - troubleshooting
23
+ - errors
24
+ - patterns
25
+ - diagnosis
26
+ allowedTools:
27
+ - execute_shell_command
28
+ - read_file
29
+ ---
30
+
31
+ # Log Analyzer Skill
32
+
33
+ This skill provides procedures for systematically analyzing application and system
34
+ logs. It covers log retrieval, pattern extraction, error diagnosis, and structured
35
+ reporting. The agent works with logs from Docker containers, Kubernetes pods, flat
36
+ files, journalctl, and piped command output.
37
+
38
+ ## Constraints
39
+
40
+ - **Never expose secrets found in logs** -- mask tokens, passwords, API keys, and
41
+ connection strings in any output. Replace with `***REDACTED***`.
42
+ - **Never assume a single error is the root cause** -- correlate across log sources
43
+ and time windows before drawing conclusions.
44
+ - **Never modify production log files** -- read only.
45
+ - **Always report timestamps in the original timezone** -- do not convert or assume.
46
+ - **Always note the time range analyzed** -- this gives the user context for what
47
+ was and was not covered.
48
+ - **Stop and ask if log volume exceeds 10,000 lines** -- propose a narrower filter
49
+ rather than processing everything.
50
+
51
+ ## Log Retrieval Patterns
52
+
53
+ ### Docker Container Logs
54
+
55
+ ```bash
56
+ # Recent logs (last 100 lines)
57
+ docker logs --tail 100 myapp
58
+
59
+ # Follow live logs with timestamps
60
+ docker logs -f --timestamps myapp
61
+
62
+ # Logs from a specific time window
63
+ docker logs --since "2024-01-15T10:00:00" --until "2024-01-15T11:00:00" myapp
64
+
65
+ # Logs from a crashed container (previous instance)
66
+ docker logs --previous myapp
67
+
68
+ # Logs for a docker-compose service
69
+ docker compose logs --tail 200 app
70
+ ```
71
+
72
+ ### Kubernetes Pod Logs
73
+
74
+ ```bash
75
+ # Logs from a specific pod
76
+ kubectl logs myapp-7d4f8b6x9k -n production
77
+
78
+ # Logs from all pods matching a label
79
+ kubectl logs -l app=myapp -n production --all-containers
80
+
81
+ # Previous crashed container
82
+ kubectl logs myapp-7d4f8b6x9k -n production --previous
83
+
84
+ # Logs from a specific container in a multi-container pod
85
+ kubectl logs myapp-7d4f8b6x9k -c sidecar -n production
86
+
87
+ # Logs with timestamps and time filter
88
+ kubectl logs myapp-7d4f8b6x9k -n production --since=1h --timestamps
89
+
90
+ # Stream logs from multiple pods
91
+ kubectl logs -l app=myapp -n production -f --max-log-requests=10
92
+ ```
93
+
94
+ ### System Logs
95
+
96
+ ```bash
97
+ # journalctl for systemd services
98
+ journalctl -u myapp.service --since "1 hour ago" --no-pager
99
+
100
+ # Syslog filtering
101
+ tail -n 5000 /var/log/syslog | grep -i "myapp"
102
+
103
+ # Nginx access logs -- count status codes
104
+ awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
105
+
106
+ # Nginx error logs
107
+ tail -n 1000 /var/log/nginx/error.log
108
+
109
+ # Application-specific log files
110
+ tail -n 2000 /var/log/myapp/application.log
111
+ ```
112
+
113
+ ## Analysis Workflow
114
+
115
+ ### Step 1: Scope the Investigation
116
+
117
+ Before diving into logs, determine:
118
+
119
+ 1. **Time window** -- when did the issue start? When did it last occur?
120
+ 2. **Affected component** -- which service, container, or node?
121
+ 3. **Symptom** -- error message, slow response, crash, or data inconsistency?
122
+ 4. **Log source(s)** -- application logs, access logs, system logs, or all of them?
123
+
124
+ ### Step 2: Retrieve and Filter
125
+
126
+ ```bash
127
+ # Count total lines to gauge volume
128
+ wc -l /var/log/myapp/application.log
129
+
130
+ # If too large, narrow the time window
131
+ grep "2024-01-15T10:" /var/log/myapp/application.log | wc -l
132
+
133
+ # Filter by log level
134
+ grep -E "\[ERROR\]|\[FATAL\]|\[CRITICAL\]" /var/log/myapp/application.log | tail -100
135
+
136
+ # Filter by request or trace ID
137
+ grep "req-abc-123" /var/log/myapp/application.log
138
+
139
+ # Filter by specific error pattern
140
+ grep -i "ECONNREFUSED\|ETIMEDOUT\|ENOTFOUND" /var/log/myapp/application.log
141
+ ```
142
+
143
+ ### Step 3: Identify Patterns
144
+
145
+ ```bash
146
+ # Count errors by type
147
+ grep "\[ERROR\]" /var/log/myapp/application.log | \
148
+ awk '{for(i=1;i<=NF;i++) if($i ~ /ERR_/) print $i}' | \
149
+ sort | uniq -c | sort -rn | head -20
150
+
151
+ # Find error spikes (errors per minute)
152
+ grep "\[ERROR\]" /var/log/myapp/application.log | \
153
+ awk '{print substr($1,1,16)}' | \
154
+ uniq -c
155
+
156
+ # Extract and count HTTP status codes from access logs
157
+ awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
158
+
159
+ # Find the most common error messages
160
+ grep "\[ERROR\]" /var/log/myapp/application.log | \
161
+ sed 's/\[ERROR\].*-- //' | \
162
+ sort | uniq -c | sort -rn | head -20
163
+
164
+ # Find slow requests (response time > 1s)
165
+ awk '$NF > 1000 {print $0}' /var/log/nginx/access.log
166
+ ```
167
+
168
+ ### Step 4: Extract Stack Traces
169
+
170
+ ```bash
171
+ # Extract Java-style stack traces (multiline)
172
+ grep -A 20 "Exception\|Error" /var/log/myapp/application.log | head -200
173
+
174
+ # Extract Node.js stack traces
175
+ grep -A 10 "at " /var/log/myapp/application.log | head -200
176
+
177
+ # Extract Python tracebacks
178
+ grep -A 20 "Traceback" /var/log/myapp/application.log | head -200
179
+ ```
180
+
181
+ ### Step 5: Correlate Across Sources
182
+
183
+ When multiple services are involved:
184
+
185
+ 1. Extract timestamps from each log source for the same time window.
186
+ 2. Align by timestamp to see the causal chain.
187
+ 3. Look for request IDs or correlation IDs that span services.
188
+
189
+ ```bash
190
+ # Extract all events for a specific request ID across multiple files
191
+ for f in /var/log/myapp/*.log; do
192
+ matches=$(grep "req-abc-123" "$f" | head -5)
193
+ if [ -n "$matches" ]; then
194
+ echo "=== $f ==="
195
+ echo "$matches"
196
+ fi
197
+ done
198
+ ```
199
+
200
+ ## Common Error Patterns and Diagnosis
201
+
202
+ ### Connection Errors
203
+
204
+ | Pattern | Likely Cause | Action |
205
+ |---------|-------------|--------|
206
+ | `ECONNREFUSED` | Target service not listening | Check if service is running and port is correct |
207
+ | `ETIMEDOUT` | Network unreachable or firewall | Check network routes and security groups |
208
+ | `ECONNRESET` | Remote side closed connection | Check remote service health and load |
209
+ | `ENOTFOUND` | DNS resolution failure | Check DNS config and service discovery |
210
+ | `EPIPE` / `Broken pipe` | Client disconnected | Often benign, check if widespread |
211
+
212
+ ### Out of Memory
213
+
214
+ ```
215
+ # Java
216
+ java.lang.OutOfMemoryError: Java heap space
217
+
218
+ # Node.js
219
+ FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
220
+
221
+ # System
222
+ Out of memory: Kill process 1234 (node) score 900 or sacrifice child
223
+ ```
224
+
225
+ Diagnosis: Check memory limits (Docker/K8s), look for memory leaks in heap dumps,
226
+ increase limits if workload legitimately needs more memory.
227
+
228
+ ### Disk Issues
229
+
230
+ ```
231
+ No space left on device
232
+ Cannot write to log file: No space left on device
233
+ ```
234
+
235
+ ```bash
236
+ # Check disk usage
237
+ df -h
238
+
239
+ # Find large files
240
+ du -sh /var/log/* | sort -rh | head -10
241
+
242
+ # Check inode usage
243
+ df -i
244
+ ```
245
+
246
+ ### Certificate / TLS Errors
247
+
248
+ ```
249
+ SSL: CERTIFICATE_VERIFY_FAILED
250
+ unable to verify the first certificate
251
+ certificate has expired
252
+ self-signed certificate in certificate chain
253
+ ```
254
+
255
+ Diagnosis: Check certificate expiry dates, verify CA chain, check system clock
256
+ for time drift.
257
+
258
+ ## Log Format Handling
259
+
260
+ ### JSON Logs
261
+
262
+ ```bash
263
+ # Pretty-print JSON logs
264
+ tail -n 100 /var/log/myapp/application.log | jq .
265
+
266
+ # Filter by level
267
+ cat /var/log/myapp/application.log | jq 'select(.level == "error")'
268
+
269
+ # Extract specific fields
270
+ cat /var/log/myapp/application.log | jq '{timestamp, level, message, requestId}'
271
+
272
+ # Count by error type
273
+ cat /var/log/myapp/application.log | \
274
+ jq -r 'select(.level == "error") | .message' | \
275
+ sort | uniq -c | sort -rn | head -20
276
+ ```
277
+
278
+ ### Structured Text Logs (key=value)
279
+
280
+ ```bash
281
+ # Filter by level
282
+ grep "level=error" /var/log/myapp/application.log
283
+
284
+ # Extract specific key
285
+ grep -oP 'request_id=\K[^ ]+' /var/log/myapp/application.log | sort -u
286
+ ```
287
+
288
+ ### Unstructured Logs
289
+
290
+ For logs without consistent formatting:
291
+
292
+ 1. Identify the timestamp format by examining the first few lines.
293
+ 2. Identify the log level indicator (varies widely).
294
+ 3. Use `grep` with appropriate regex to filter.
295
+ 4. Fall back to line-by-line analysis for small extracts.
296
+
297
+ ## Reporting Format
298
+
299
+ When presenting log analysis results, use this structure:
300
+
301
+ ```
302
+ ## Log Analysis Report
303
+
304
+ **Time Range**: <start> to <end>
305
+ **Log Source(s)**: <files or containers>
306
+ **Total Lines Analyzed**: <number>
307
+
308
+ ### Summary
309
+ <2-3 sentence overview of findings>
310
+
311
+ ### Key Errors
312
+ 1. [<timestamp>] <error message>
313
+ - Occurrence count: <N>
314
+ - Likely cause: <explanation>
315
+ - Suggested fix: <action>
316
+
317
+ ### Patterns Detected
318
+ - <pattern description with frequency>
319
+
320
+ ### Recommendations
321
+ 1. <actionable recommendation>
322
+ 2. <actionable recommendation>
323
+ ```
324
+
325
+ ## Performance Considerations
326
+
327
+ - Use `tail` with line counts instead of `cat` for large files.
328
+ - Pipe through `grep` before `awk` or `jq` to reduce processing volume.
329
+ - Use `--since` flags on Docker and Kubernetes log commands to limit output.
330
+ - For very large log files, use `ripgrep` (`rg`) instead of `grep` for speed.
331
+ - Avoid sorting entire files -- use `head` and `tail` to sample first.
@@ -0,0 +1,260 @@
1
+ ---
2
+ name: "speckit-analyze"
3
+ description: "Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation."
4
+ argument-hint: "Optional focus areas for analysis"
5
+ compatibility: "Requires spec-kit project structure with .specify/ directory"
6
+ metadata:
7
+ author: "github-spec-kit"
8
+ source: "templates/commands/analyze.md"
9
+ user-invocable: true
10
+ disable-model-invocation: false
11
+ ---
12
+
13
+
14
+ ## User Input
15
+
16
+ ```text
17
+ $ARGUMENTS
18
+ ```
19
+
20
+ You **MUST** consider the user input before proceeding (if not empty).
21
+
22
+ ## Pre-Execution Checks
23
+
24
+ **Check for extension hooks (before analysis)**:
25
+ - Check if `.specify/extensions.yml` exists in the project root.
26
+ - If it exists, read it and look for entries under the `hooks.before_analyze` key
27
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
28
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
29
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
30
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
31
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
32
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
33
+ - For each executable hook, output the following based on its `optional` flag:
34
+ - **Optional hook** (`optional: true`):
35
+ ```
36
+ ## Extension Hooks
37
+
38
+ **Optional Pre-Hook**: {extension}
39
+ Command: `/{command}`
40
+ Description: {description}
41
+
42
+ Prompt: {prompt}
43
+ To execute: `/{command}`
44
+ ```
45
+ - **Mandatory hook** (`optional: false`):
46
+ ```
47
+ ## Extension Hooks
48
+
49
+ **Automatic Pre-Hook**: {extension}
50
+ Executing: `/{command}`
51
+ EXECUTE_COMMAND: {command}
52
+
53
+ Wait for the result of the hook command before proceeding to the Goal.
54
+ ```
55
+ - If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
56
+
57
+ ## Goal
58
+
59
+ Identify inconsistencies, duplications, ambiguities, and underspecified items across the three core artifacts (`spec.md`, `plan.md`, `tasks.md`) before implementation. This command MUST run only after `/speckit-tasks` has successfully produced a complete `tasks.md`.
60
+
61
+ ## Operating Constraints
62
+
63
+ **STRICTLY READ-ONLY**: Do **not** modify any files. Output a structured analysis report. Offer an optional remediation plan (user must explicitly approve before any follow-up editing commands would be invoked manually).
64
+
65
+ **Constitution Authority**: The project constitution (`.specify/memory/constitution.md`) is **non-negotiable** within this analysis scope. Constitution conflicts are automatically CRITICAL and require adjustment of the spec, plan, or tasks—not dilution, reinterpretation, or silent ignoring of the principle. If a principle itself needs to change, that must occur in a separate, explicit constitution update outside `/speckit-analyze`.
66
+
67
+ ## Execution Steps
68
+
69
+ ### 1. Initialize Analysis Context
70
+
71
+ Run `.specify/scripts/bash/check-prerequisites.sh --json --require-tasks --include-tasks` once from repo root and parse JSON for FEATURE_DIR and AVAILABLE_DOCS. Derive absolute paths:
72
+
73
+ - SPEC = FEATURE_DIR/spec.md
74
+ - PLAN = FEATURE_DIR/plan.md
75
+ - TASKS = FEATURE_DIR/tasks.md
76
+
77
+ Abort with an error message if any required file is missing (instruct the user to run missing prerequisite command).
78
+ For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
79
+
80
+ ### 2. Load Artifacts (Progressive Disclosure)
81
+
82
+ Load only the minimal necessary context from each artifact:
83
+
84
+ **From spec.md:**
85
+
86
+ - Overview/Context
87
+ - Functional Requirements
88
+ - Success Criteria (measurable outcomes — e.g., performance, security, availability, user success, business impact)
89
+ - User Stories
90
+ - Edge Cases (if present)
91
+
92
+ **From plan.md:**
93
+
94
+ - Architecture/stack choices
95
+ - Data Model references
96
+ - Phases
97
+ - Technical constraints
98
+
99
+ **From tasks.md:**
100
+
101
+ - Task IDs
102
+ - Descriptions
103
+ - Phase grouping
104
+ - Parallel markers [P]
105
+ - Referenced file paths
106
+
107
+ **From constitution:**
108
+
109
+ - Load `.specify/memory/constitution.md` for principle validation
110
+
111
+ ### 3. Build Semantic Models
112
+
113
+ Create internal representations (do not include raw artifacts in output):
114
+
115
+ - **Requirements inventory**: For each Functional Requirement (FR-###) and Success Criterion (SC-###), record a stable key. Use the explicit FR-/SC- identifier as the primary key when present, and optionally also derive an imperative-phrase slug for readability (e.g., "User can upload file" → `user-can-upload-file`). Include only Success Criteria items that require buildable work (e.g., load-testing infrastructure, security audit tooling), and exclude post-launch outcome metrics and business KPIs (e.g., "Reduce support tickets by 50%").
116
+ - **User story/action inventory**: Discrete user actions with acceptance criteria
117
+ - **Task coverage mapping**: Map each task to one or more requirements or stories (inference by keyword / explicit reference patterns like IDs or key phrases)
118
+ - **Constitution rule set**: Extract principle names and MUST/SHOULD normative statements
119
+
120
+ ### 4. Detection Passes (Token-Efficient Analysis)
121
+
122
+ Focus on high-signal findings. Limit to 50 findings total; aggregate remainder in overflow summary.
123
+
124
+ #### A. Duplication Detection
125
+
126
+ - Identify near-duplicate requirements
127
+ - Mark lower-quality phrasing for consolidation
128
+
129
+ #### B. Ambiguity Detection
130
+
131
+ - Flag vague adjectives (fast, scalable, secure, intuitive, robust) lacking measurable criteria
132
+ - Flag unresolved placeholders (TODO, TKTK, ???, `<placeholder>`, etc.)
133
+
134
+ #### C. Underspecification
135
+
136
+ - Requirements with verbs but missing object or measurable outcome
137
+ - User stories missing acceptance criteria alignment
138
+ - Tasks referencing files or components not defined in spec/plan
139
+
140
+ #### D. Constitution Alignment
141
+
142
+ - Any requirement or plan element conflicting with a MUST principle
143
+ - Missing mandated sections or quality gates from constitution
144
+
145
+ #### E. Coverage Gaps
146
+
147
+ - Requirements with zero associated tasks
148
+ - Tasks with no mapped requirement/story
149
+ - Success Criteria requiring buildable work (performance, security, availability) not reflected in tasks
150
+
151
+ #### F. Inconsistency
152
+
153
+ - Terminology drift (same concept named differently across files)
154
+ - Data entities referenced in plan but absent in spec (or vice versa)
155
+ - Task ordering contradictions (e.g., integration tasks before foundational setup tasks without dependency note)
156
+ - Conflicting requirements (e.g., one requires Next.js while other specifies Vue)
157
+
158
+ ### 5. Severity Assignment
159
+
160
+ Use this heuristic to prioritize findings:
161
+
162
+ - **CRITICAL**: Violates constitution MUST, missing core spec artifact, or requirement with zero coverage that blocks baseline functionality
163
+ - **HIGH**: Duplicate or conflicting requirement, ambiguous security/performance attribute, untestable acceptance criterion
164
+ - **MEDIUM**: Terminology drift, missing non-functional task coverage, underspecified edge case
165
+ - **LOW**: Style/wording improvements, minor redundancy not affecting execution order
166
+
167
+ ### 6. Produce Compact Analysis Report
168
+
169
+ Output a Markdown report (no file writes) with the following structure:
170
+
171
+ ## Specification Analysis Report
172
+
173
+ | ID | Category | Severity | Location(s) | Summary | Recommendation |
174
+ |----|----------|----------|-------------|---------|----------------|
175
+ | A1 | Duplication | HIGH | spec.md:L120-134 | Two similar requirements ... | Merge phrasing; keep clearer version |
176
+
177
+ (Add one row per finding; generate stable IDs prefixed by category initial.)
178
+
179
+ **Coverage Summary Table:**
180
+
181
+ | Requirement Key | Has Task? | Task IDs | Notes |
182
+ |-----------------|-----------|----------|-------|
183
+
184
+ **Constitution Alignment Issues:** (if any)
185
+
186
+ **Unmapped Tasks:** (if any)
187
+
188
+ **Metrics:**
189
+
190
+ - Total Requirements
191
+ - Total Tasks
192
+ - Coverage % (requirements with >=1 task)
193
+ - Ambiguity Count
194
+ - Duplication Count
195
+ - Critical Issues Count
196
+
197
+ ### 7. Provide Next Actions
198
+
199
+ At end of report, output a concise Next Actions block:
200
+
201
+ - If CRITICAL issues exist: Recommend resolving before `/speckit-implement`
202
+ - If only LOW/MEDIUM: User may proceed, but provide improvement suggestions
203
+ - Provide explicit command suggestions: e.g., "Run /speckit-specify with refinement", "Run /speckit-plan to adjust architecture", "Manually edit tasks.md to add coverage for 'performance-metrics'"
204
+
205
+ ### 8. Offer Remediation
206
+
207
+ Ask the user: "Would you like me to suggest concrete remediation edits for the top N issues?" (Do NOT apply them automatically.)
208
+
209
+ ### 9. Check for extension hooks
210
+
211
+ After reporting, check if `.specify/extensions.yml` exists in the project root.
212
+ - If it exists, read it and look for entries under the `hooks.after_analyze` key
213
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
214
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
215
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
216
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
217
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
218
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `speckit.git.commit` → `/speckit-git-commit`.
219
+ - For each executable hook, output the following based on its `optional` flag:
220
+ - **Optional hook** (`optional: true`):
221
+ ```
222
+ ## Extension Hooks
223
+
224
+ **Optional Hook**: {extension}
225
+ Command: `/{command}`
226
+ Description: {description}
227
+
228
+ Prompt: {prompt}
229
+ To execute: `/{command}`
230
+ ```
231
+ - **Mandatory hook** (`optional: false`):
232
+ ```
233
+ ## Extension Hooks
234
+
235
+ **Automatic Hook**: {extension}
236
+ Executing: `/{command}`
237
+ EXECUTE_COMMAND: {command}
238
+ ```
239
+ - If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
240
+
241
+ ## Operating Principles
242
+
243
+ ### Context Efficiency
244
+
245
+ - **Minimal high-signal tokens**: Focus on actionable findings, not exhaustive documentation
246
+ - **Progressive disclosure**: Load artifacts incrementally; don't dump all content into analysis
247
+ - **Token-efficient output**: Limit findings table to 50 rows; summarize overflow
248
+ - **Deterministic results**: Rerunning without changes should produce consistent IDs and counts
249
+
250
+ ### Analysis Guidelines
251
+
252
+ - **NEVER modify files** (this is read-only analysis)
253
+ - **NEVER hallucinate missing sections** (if absent, report them accurately)
254
+ - **Prioritize constitution violations** (these are always CRITICAL)
255
+ - **Use examples over exhaustive rules** (cite specific instances, not generic patterns)
256
+ - **Report zero issues gracefully** (emit success report with coverage statistics)
257
+
258
+ ## Context
259
+
260
+ $ARGUMENTS