@arthai/agents 1.0.4 → 1.0.6

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 (131) hide show
  1. package/README.md +55 -3
  2. package/VERSION +1 -1
  3. package/agents/troubleshooter.md +132 -0
  4. package/bin/cli.js +366 -0
  5. package/bundles/canvas.json +1 -1
  6. package/bundles/compass.json +1 -1
  7. package/bundles/counsel.json +1 -0
  8. package/bundles/cruise.json +1 -1
  9. package/bundles/forge.json +12 -1
  10. package/bundles/prism.json +1 -0
  11. package/bundles/scalpel.json +5 -2
  12. package/bundles/sentinel.json +8 -2
  13. package/bundles/shield.json +1 -0
  14. package/bundles/spark.json +1 -0
  15. package/compiler.sh +14 -0
  16. package/dist/plugins/canvas/.claude-plugin/plugin.json +1 -1
  17. package/dist/plugins/canvas/VERSION +1 -0
  18. package/dist/plugins/canvas/commands/planning.md +100 -11
  19. package/dist/plugins/canvas/hooks/hooks.json +16 -0
  20. package/dist/plugins/canvas/hooks/project-setup.sh +109 -0
  21. package/dist/plugins/canvas/templates/CLAUDE.md.managed-block +123 -0
  22. package/dist/plugins/canvas/templates/CLAUDE.md.template +111 -0
  23. package/dist/plugins/compass/.claude-plugin/plugin.json +1 -1
  24. package/dist/plugins/compass/VERSION +1 -0
  25. package/dist/plugins/compass/commands/planning.md +100 -11
  26. package/dist/plugins/compass/hooks/hooks.json +16 -0
  27. package/dist/plugins/compass/hooks/project-setup.sh +109 -0
  28. package/dist/plugins/compass/templates/CLAUDE.md.managed-block +123 -0
  29. package/dist/plugins/compass/templates/CLAUDE.md.template +111 -0
  30. package/dist/plugins/counsel/.claude-plugin/plugin.json +1 -1
  31. package/dist/plugins/counsel/VERSION +1 -0
  32. package/dist/plugins/counsel/hooks/hooks.json +10 -0
  33. package/dist/plugins/counsel/hooks/project-setup.sh +109 -0
  34. package/dist/plugins/counsel/templates/CLAUDE.md.managed-block +123 -0
  35. package/dist/plugins/counsel/templates/CLAUDE.md.template +111 -0
  36. package/dist/plugins/cruise/.claude-plugin/plugin.json +1 -1
  37. package/dist/plugins/cruise/VERSION +1 -0
  38. package/dist/plugins/cruise/hooks/hooks.json +16 -0
  39. package/dist/plugins/cruise/hooks/project-setup.sh +109 -0
  40. package/dist/plugins/cruise/templates/CLAUDE.md.managed-block +123 -0
  41. package/dist/plugins/cruise/templates/CLAUDE.md.template +111 -0
  42. package/dist/plugins/forge/.claude-plugin/plugin.json +1 -1
  43. package/dist/plugins/forge/VERSION +1 -0
  44. package/dist/plugins/forge/agents/troubleshooter.md +132 -0
  45. package/dist/plugins/forge/commands/implement.md +99 -1
  46. package/dist/plugins/forge/commands/planning.md +100 -11
  47. package/dist/plugins/forge/hooks/escalation-guard.sh +177 -0
  48. package/dist/plugins/forge/hooks/hooks.json +22 -0
  49. package/dist/plugins/forge/hooks/project-setup.sh +109 -0
  50. package/dist/plugins/forge/templates/CLAUDE.md.managed-block +123 -0
  51. package/dist/plugins/forge/templates/CLAUDE.md.template +111 -0
  52. package/dist/plugins/prime/.claude-plugin/plugin.json +1 -1
  53. package/dist/plugins/prime/VERSION +1 -0
  54. package/dist/plugins/prime/agents/troubleshooter.md +132 -0
  55. package/dist/plugins/prime/commands/calibrate.md +20 -0
  56. package/dist/plugins/prime/commands/ci-fix.md +36 -0
  57. package/dist/plugins/prime/commands/fix.md +23 -0
  58. package/dist/plugins/prime/commands/implement.md +99 -1
  59. package/dist/plugins/prime/commands/planning.md +100 -11
  60. package/dist/plugins/prime/commands/qa-incident.md +54 -0
  61. package/dist/plugins/prime/commands/restart.md +186 -30
  62. package/dist/plugins/prime/hooks/escalation-guard.sh +177 -0
  63. package/dist/plugins/prime/hooks/hooks.json +60 -0
  64. package/dist/plugins/prime/hooks/post-config-change-restart-reminder.sh +86 -0
  65. package/dist/plugins/prime/hooks/post-server-crash-watch.sh +120 -0
  66. package/dist/plugins/prime/hooks/pre-server-port-guard.sh +110 -0
  67. package/dist/plugins/prime/hooks/project-setup.sh +109 -0
  68. package/dist/plugins/prime/hooks/sync-agents.sh +99 -12
  69. package/dist/plugins/prime/templates/CLAUDE.md.managed-block +123 -0
  70. package/dist/plugins/prime/templates/CLAUDE.md.template +111 -0
  71. package/dist/plugins/prism/.claude-plugin/plugin.json +1 -1
  72. package/dist/plugins/prism/VERSION +1 -0
  73. package/dist/plugins/prism/commands/qa-incident.md +54 -0
  74. package/dist/plugins/prism/hooks/hooks.json +12 -0
  75. package/dist/plugins/prism/hooks/project-setup.sh +109 -0
  76. package/dist/plugins/prism/templates/CLAUDE.md.managed-block +123 -0
  77. package/dist/plugins/prism/templates/CLAUDE.md.template +111 -0
  78. package/dist/plugins/scalpel/.claude-plugin/plugin.json +1 -1
  79. package/dist/plugins/scalpel/VERSION +1 -0
  80. package/dist/plugins/scalpel/agents/troubleshooter.md +132 -0
  81. package/dist/plugins/scalpel/commands/ci-fix.md +36 -0
  82. package/dist/plugins/scalpel/commands/fix.md +23 -0
  83. package/dist/plugins/scalpel/hooks/escalation-guard.sh +177 -0
  84. package/dist/plugins/scalpel/hooks/hooks.json +24 -0
  85. package/dist/plugins/scalpel/hooks/project-setup.sh +109 -0
  86. package/dist/plugins/scalpel/templates/CLAUDE.md.managed-block +123 -0
  87. package/dist/plugins/scalpel/templates/CLAUDE.md.template +111 -0
  88. package/dist/plugins/sentinel/.claude-plugin/plugin.json +1 -1
  89. package/dist/plugins/sentinel/VERSION +1 -0
  90. package/dist/plugins/sentinel/agents/troubleshooter.md +132 -0
  91. package/dist/plugins/sentinel/commands/restart.md +186 -30
  92. package/dist/plugins/sentinel/hooks/escalation-guard.sh +177 -0
  93. package/dist/plugins/sentinel/hooks/hooks.json +64 -0
  94. package/dist/plugins/sentinel/hooks/post-config-change-restart-reminder.sh +86 -0
  95. package/dist/plugins/sentinel/hooks/post-server-crash-watch.sh +120 -0
  96. package/dist/plugins/sentinel/hooks/pre-server-port-guard.sh +110 -0
  97. package/dist/plugins/sentinel/hooks/project-setup.sh +109 -0
  98. package/dist/plugins/sentinel/templates/CLAUDE.md.managed-block +123 -0
  99. package/dist/plugins/sentinel/templates/CLAUDE.md.template +111 -0
  100. package/dist/plugins/shield/.claude-plugin/plugin.json +1 -1
  101. package/dist/plugins/shield/VERSION +1 -0
  102. package/dist/plugins/shield/hooks/hooks.json +22 -12
  103. package/dist/plugins/shield/hooks/project-setup.sh +109 -0
  104. package/dist/plugins/shield/templates/CLAUDE.md.managed-block +123 -0
  105. package/dist/plugins/shield/templates/CLAUDE.md.template +111 -0
  106. package/dist/plugins/spark/.claude-plugin/plugin.json +1 -1
  107. package/dist/plugins/spark/VERSION +1 -0
  108. package/dist/plugins/spark/commands/calibrate.md +20 -0
  109. package/dist/plugins/spark/hooks/hooks.json +10 -0
  110. package/dist/plugins/spark/hooks/project-setup.sh +109 -0
  111. package/dist/plugins/spark/templates/CLAUDE.md.managed-block +123 -0
  112. package/dist/plugins/spark/templates/CLAUDE.md.template +111 -0
  113. package/hook-defs.json +31 -0
  114. package/hooks/escalation-guard.sh +177 -0
  115. package/hooks/post-config-change-restart-reminder.sh +86 -0
  116. package/hooks/post-server-crash-watch.sh +120 -0
  117. package/hooks/pre-server-port-guard.sh +110 -0
  118. package/hooks/project-setup.sh +109 -0
  119. package/hooks/sync-agents.sh +99 -12
  120. package/install.sh +2 -2
  121. package/package.json +1 -1
  122. package/portable.manifest +7 -1
  123. package/skills/calibrate/SKILL.md +20 -0
  124. package/skills/ci-fix/SKILL.md +36 -0
  125. package/skills/fix/SKILL.md +23 -0
  126. package/skills/implement/SKILL.md +99 -1
  127. package/skills/license/SKILL.md +159 -0
  128. package/skills/planning/SKILL.md +100 -11
  129. package/skills/publish/SKILL.md +3 -0
  130. package/skills/qa-incident/SKILL.md +54 -0
  131. package/skills/restart/SKILL.md +187 -31
@@ -1,70 +1,226 @@
1
1
  ---
2
2
  name: restart
3
- description: "Kill and restart local dev servers. Reads service config from CLAUDE.md. Usage: /restart [service]"
3
+ description: "Discover, restart, and validate local dev servers. Auto-detects Docker vs native, checks health, catches crash loops. Usage: /restart <service> <--preflight>"
4
4
  user-invocable: true
5
- arguments: "<service>"
5
+ arguments: "<service> <--preflight>"
6
6
  ---
7
7
 
8
8
  # Restart Servers Skill
9
9
 
10
- Kill and restart local dev servers using the configuration from CLAUDE.md.
10
+ Discover how services run, restart them safely, and verify they stay healthy.
11
11
 
12
- ## Instructions
12
+ ## Phase 1: Discover Services
13
13
 
14
- 1. **Read CLAUDE.md** in the project root. Look for the **Local Dev Services** table:
14
+ **First, check CLAUDE.md** for a `Local Dev Services` table:
15
15
 
16
16
  ```markdown
17
17
  ## Local Dev Services
18
18
 
19
- | Service | Port | Directory | Start Command |
20
- |----------|------|-----------|---------------|
21
- | Frontend | 3000 | frontend/ | npm run dev |
22
- | Backend | 8000 | backend/ | uvicorn app.main:app --reload --port 8000 |
19
+ | Service | Type | Port | Directory | Start Command | Health Check | Depends On |
20
+ |----------|--------|------|-----------|---------------------------------------|-----------------|------------|
21
+ | Postgres | docker | 5432 | — | docker compose up -d postgres | pg_isready | Docker |
22
+ | Backend | native | 8000 | backend/ | uvicorn app.main:app --reload | /api/health | Postgres |
23
+ | Frontend | native | 3000 | frontend/ | npm run dev | /health | Backend |
23
24
  ```
24
25
 
25
- If CLAUDE.md doesn't have this section, scan the project:
26
- - `package.json` scripts → find dev/start commands
27
- - `requirements.txt` / `pyproject.toml` look for uvicorn/gunicorn/flask
28
- - `docker-compose.yml` → extract service ports
29
- - Common ports: frontend 3000, backend 8000
26
+ **If the table is missing or incomplete, auto-discover** by scanning the repo. Check these files in order:
27
+
28
+ | File | What to extract |
29
+ |------|-----------------|
30
+ | `docker-compose.yml` / `docker-compose.*.yml` | Service names, ports, images, healthcheck configs, volume mounts. These are **docker** type services. |
31
+ | `Dockerfile` / `Dockerfile.*` | What gets containerized — cross-reference with compose to understand which services are Docker-managed. |
32
+ | `package.json` (root + subdirs) | `scripts.dev`, `scripts.start`, `scripts.serve` → these are **native** Node services. Check `proxy` field for backend port. |
33
+ | `Makefile` / `Procfile` / `Justfile` | Process definitions, often with ports and dependency ordering. |
34
+ | `pyproject.toml` / `requirements.txt` | Python services — look for uvicorn/gunicorn/flask/django in deps. |
35
+ | `.env` / `.env.local` / `.env.example` | Port assignments (`PORT=`, `DATABASE_URL=`, `REDIS_URL=`), required env vars. |
36
+ | `turbo.json` / `nx.json` / `pnpm-workspace.yaml` | Monorepo structure — maps workspace packages to services. |
37
+
38
+ For each discovered service, determine:
39
+ - **Name**: human-readable (e.g., "Backend API", "Postgres")
40
+ - **Type**: `docker` (managed by docker compose) or `native` (runs directly on host)
41
+ - **Port**: what port it listens on
42
+ - **Directory**: where to `cd` before running the start command
43
+ - **Start command**: exact command to launch it
44
+ - **Health check**: endpoint or command to verify it's running (look for `/health`, `/api/health`, `pg_isready`, `redis-cli ping`, etc.)
45
+ - **Depends on**: other services that must be running first (DB before backend, backend before frontend)
46
+
47
+ **If discovery is ambiguous, ASK the user.** Specifically ask when:
48
+ - Multiple compose files exist and it's unclear which to use (dev vs prod vs test)
49
+ - A service could be Docker OR native (e.g., Postgres has both a compose entry and a local install)
50
+ - No health check endpoint is obvious — ask what URL or command confirms the service is healthy
51
+ - Port conflicts or unusual port assignments are detected
52
+ - You find services but can't determine the dependency order
53
+
54
+ Present what you found and ask for confirmation:
55
+ ```
56
+ Found 3 services:
57
+ 1. Postgres (docker, port 5432) — via docker-compose.yml
58
+ 2. Backend (native, port 8000) — via backend/pyproject.toml
59
+ 3. Frontend (native, port 3000) — via frontend/package.json
60
+
61
+ Dependencies: Frontend → Backend → Postgres
62
+
63
+ Health checks:
64
+ - Postgres: pg_isready -h localhost -p 5432
65
+ - Backend: curl localhost:8000/api/health
66
+ - Frontend: curl localhost:3000
67
+
68
+ Does this look right? Any corrections?
69
+ ```
70
+
71
+ After confirmation (or if CLAUDE.md table already exists), proceed to Phase 2.
72
+
73
+ **Update CLAUDE.md**: If services were auto-discovered and the user confirmed, write/update the `Local Dev Services` table in CLAUDE.md so future runs skip discovery.
30
74
 
31
- 2. **Kill existing processes** for the target service(s):
75
+ ## Phase 2: Pre-flight Validation
32
76
 
77
+ Before touching any running processes, validate the environment is ready:
78
+
79
+ ### 2a. Docker check (if any service type is `docker`)
80
+ ```bash
81
+ # Is Docker daemon running?
82
+ docker info > /dev/null 2>&1 && echo "Docker: OK" || echo "Docker: NOT RUNNING"
83
+ ```
84
+ If Docker is not running, **stop and tell the user**. Don't proceed.
85
+
86
+ ### 2b. Dependency check (for native services)
33
87
  ```bash
34
- # Kill by port
88
+ # Node services — are node_modules installed?
89
+ [ -d "<directory>/node_modules" ] && echo "node_modules: OK" || echo "node_modules: MISSING — run npm install"
90
+
91
+ # Python services — is the venv active / deps installed?
92
+ [ -f "<directory>/.venv/bin/python" ] && echo "venv: OK" || echo "venv: MISSING"
93
+ ```
94
+
95
+ ### 2c. Environment variables
96
+ ```bash
97
+ # Check critical env vars exist (read from .env.example or known requirements)
98
+ [ -f "<directory>/.env" ] || [ -f "<directory>/.env.local" ] && echo "env file: OK" || echo "env file: MISSING"
99
+ ```
100
+
101
+ ### 2d. Port availability
102
+ ```bash
103
+ # Check if port is already in use by a DIFFERENT process than expected
104
+ lsof -ti:<port> 2>/dev/null
105
+ ```
106
+ If a port is occupied by an unexpected process, warn the user before killing it.
107
+
108
+ ### 2e. Pre-flight only mode
109
+ If the user ran `/restart --preflight`, **stop here** and report results. Don't restart anything.
110
+
111
+ ## Phase 3: Restart Services (dependency order)
112
+
113
+ Restart in dependency order — infrastructure first, then backends, then frontends.
114
+
115
+ ### 3a. Stop services (reverse dependency order)
116
+ ```bash
117
+ # For native services — kill by port
35
118
  lsof -ti:<port> | xargs kill -9 2>/dev/null
36
119
 
120
+ # For docker services — stop the specific service
121
+ docker compose stop <service_name>
122
+
37
123
  # Wait for ports to free
38
124
  sleep 2
39
- ```
40
125
 
41
- 3. **Start each server** in background using the configured start command:
126
+ # Verify port is actually free
127
+ lsof -ti:<port> 2>/dev/null && echo "WARNING: port <port> still occupied" || echo "Port <port>: free"
128
+ ```
42
129
 
130
+ ### 3b. Start services (dependency order)
43
131
  ```bash
44
- # Run in background
45
- <start_command> &
132
+ # Docker services first
133
+ docker compose up -d <service_name>
134
+
135
+ # Then native services — run in background
136
+ cd <directory> && <start_command>
46
137
  ```
47
138
 
48
- Use `run_in_background: true` on the Bash tool.
139
+ Use `run_in_background: true` on the Bash tool for native services.
140
+
141
+ **Wait between dependency layers** — don't start the backend until the DB health check passes. Don't start the frontend until the backend health check passes.
142
+
143
+ ## Phase 4: Post-restart Health Validation
144
+
145
+ This is the critical phase. A single health check is not enough — services can start and then crash seconds later.
49
146
 
50
- 4. **Health check** after startup:
147
+ ### 4a. Initial health check (per service, in dependency order)
51
148
 
52
149
  ```bash
53
- # Check each service
54
- curl -sf http://localhost:<port>/health > /dev/null 2>&1 && echo "<service>:UP" || echo "<service>:DOWN"
150
+ # HTTP services
151
+ curl -sf http://localhost:<port><health_path> > /dev/null 2>&1 && echo "<service>: UP" || echo "<service>: DOWN"
152
+
153
+ # Postgres
154
+ pg_isready -h localhost -p <port> 2>/dev/null && echo "Postgres: UP" || echo "Postgres: DOWN"
155
+
156
+ # Redis
157
+ redis-cli -p <port> ping 2>/dev/null | grep -q PONG && echo "Redis: UP" || echo "Redis: DOWN"
158
+
159
+ # Docker services
160
+ docker compose ps <service_name> --format '{{.Status}}' | grep -q "Up" && echo "<service>: UP" || echo "<service>: DOWN"
161
+ ```
162
+
163
+ ### 4b. Crash loop detection (wait 8 seconds, check again)
164
+
165
+ ```bash
166
+ sleep 8
167
+
168
+ # Re-check each service
169
+ curl -sf http://localhost:<port><health_path> > /dev/null 2>&1 && echo "<service>: STABLE" || echo "<service>: CRASHED"
170
+
171
+ # For native services — is the process still running?
172
+ lsof -ti:<port> > /dev/null 2>&1 && echo "<service> process: alive" || echo "<service> process: GONE"
55
173
  ```
56
174
 
57
- 5. **Report** status of all servers.
175
+ If a service is down on the second check:
176
+ 1. **Check logs** — read the last 30 lines of output for error messages
177
+ 2. **Report the failure clearly** with the error
178
+ 3. **Do NOT retry automatically** — tell the user what went wrong
179
+
180
+ ### 4c. Final status report
181
+
182
+ ```
183
+ ✅ Restart complete
184
+
185
+ | Service | Type | Port | Status |
186
+ |----------|--------|------|---------|
187
+ | Postgres | docker | 5432 | STABLE |
188
+ | Backend | native | 8000 | STABLE |
189
+ | Frontend | native | 3000 | STABLE |
190
+
191
+ All services healthy after 10s stability check.
192
+ ```
193
+
194
+ Or if something failed:
195
+
196
+ ```
197
+ ⚠️ Restart partial — 1 service unhealthy
198
+
199
+ | Service | Type | Port | Status |
200
+ |----------|--------|------|---------|
201
+ | Postgres | docker | 5432 | STABLE |
202
+ | Backend | native | 8000 | CRASHED |
203
+ | Frontend | native | 3000 | SKIPPED |
204
+
205
+ Backend crashed after startup. Last error:
206
+ ModuleNotFoundError: No module named 'sqlalchemy'
207
+
208
+ Fix: Run `pip install -r requirements.txt` in backend/ and retry.
209
+ Frontend was skipped because it depends on Backend.
210
+ ```
58
211
 
59
212
  ## Argument Patterns
60
213
 
61
214
  | User Input | Action |
62
215
  |-----------|--------|
63
- | `/restart` (no args) | Kill and restart all configured servers |
64
- | `/restart backend` | Kill and restart only the backend service |
65
- | `/restart frontend` | Kill and restart only the frontend service |
66
- | `/restart <service>` | Kill and restart the named service |
216
+ | `/restart` (no args) | Discover validate → restart all services |
217
+ | `/restart backend` | Restart only the named service (and its dependencies if they're down) |
218
+ | `/restart --preflight` | Discover and validate only don't restart anything |
67
219
 
68
- ## If CLAUDE.md Is Missing Service Config
220
+ ## Key Principles
69
221
 
70
- Report: "No Local Dev Services table found in CLAUDE.md. Add a table with Service, Port, Directory, and Start Command columns. Or specify the services manually."
222
+ 1. **Never guess** if you can't determine how a service runs, ask
223
+ 2. **Dependency order matters** — always start infra → backend → frontend
224
+ 3. **One health check isn't enough** — check twice with a gap to catch crash loops
225
+ 4. **Report errors with context** — show the actual log output, not just "DOWN"
226
+ 5. **Don't retry blindly** — if a service crashes, diagnose and report, don't loop