chief-clancy 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +426 -0
  3. package/bin/install.js +169 -0
  4. package/package.json +42 -0
  5. package/registry/boards.json +47 -0
  6. package/src/agents/arch-agent.md +72 -0
  7. package/src/agents/concerns-agent.md +89 -0
  8. package/src/agents/design-agent.md +130 -0
  9. package/src/agents/quality-agent.md +161 -0
  10. package/src/agents/tech-agent.md +92 -0
  11. package/src/commands/doctor.md +7 -0
  12. package/src/commands/help.md +50 -0
  13. package/src/commands/init.md +7 -0
  14. package/src/commands/logs.md +7 -0
  15. package/src/commands/map-codebase.md +16 -0
  16. package/src/commands/once.md +13 -0
  17. package/src/commands/review.md +9 -0
  18. package/src/commands/run.md +11 -0
  19. package/src/commands/settings.md +7 -0
  20. package/src/commands/status.md +9 -0
  21. package/src/commands/uninstall.md +5 -0
  22. package/src/commands/update-docs.md +9 -0
  23. package/src/commands/update.md +9 -0
  24. package/src/templates/.env.example.github +43 -0
  25. package/src/templates/.env.example.jira +53 -0
  26. package/src/templates/.env.example.linear +43 -0
  27. package/src/templates/CLAUDE.md +69 -0
  28. package/src/templates/scripts/clancy-afk.sh +111 -0
  29. package/src/templates/scripts/clancy-once-github.sh +225 -0
  30. package/src/templates/scripts/clancy-once-linear.sh +252 -0
  31. package/src/templates/scripts/clancy-once.sh +259 -0
  32. package/src/workflows/doctor.md +115 -0
  33. package/src/workflows/init.md +423 -0
  34. package/src/workflows/logs.md +82 -0
  35. package/src/workflows/map-codebase.md +124 -0
  36. package/src/workflows/once.md +80 -0
  37. package/src/workflows/review.md +165 -0
  38. package/src/workflows/run.md +119 -0
  39. package/src/workflows/scaffold.md +289 -0
  40. package/src/workflows/settings.md +344 -0
  41. package/src/workflows/status.md +120 -0
  42. package/src/workflows/uninstall.md +75 -0
  43. package/src/workflows/update-docs.md +89 -0
  44. package/src/workflows/update.md +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alex Clapperton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,426 @@
1
+ # Clancy
2
+
3
+ **Autonomous, board-driven development for Claude Code.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/chief-clancy?color=cb3837)](https://www.npmjs.com/package/chief-clancy) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) [![Tests](https://img.shields.io/badge/tests-34%20passing-brightgreen)](./test/) [![GitHub Stars](https://img.shields.io/github/stars/Pushedskydiver/clancy?style=flat)](https://github.com/Pushedskydiver/clancy/stargazers)
6
+
7
+ ```bash
8
+ npx chief-clancy
9
+ ```
10
+
11
+ Works on Mac and Linux. Windows requires [WSL](https://learn.microsoft.com/en-us/windows/wsl/install).
12
+
13
+ [What it does](#what-it-does) · [Install](#install) · [Commands](#commands) · [Supported boards](#supported-boards) · [Comparison](./COMPARISON.md) · [Roadmap](./ROADMAP.md) · [Contributing](./CONTRIBUTING.md)
14
+
15
+ ---
16
+
17
+ ![Clancy terminal preview](assets/terminal-preview.svg)
18
+
19
+ Named after Chief Clancy Wiggum (The Simpsons) — built on the [Ralph technique](https://ghuntley.com/ralph/) by Geoffrey Huntley. [See lineage →](#lineage)
20
+
21
+ ---
22
+
23
+ ## What it does
24
+
25
+ Clancy does three things:
26
+
27
+ 1. **Scaffolds itself** into a project — scripts, docs, CLAUDE.md, .clancy/.env
28
+ 2. **Scans your codebase** with 5 parallel specialist agents and writes 10 structured docs that Claude reads before every run
29
+ 3. **Runs autonomously** — picking one ticket per loop from your Kanban board, implementing it, committing, squash-merging, and logging progress
30
+
31
+ One ticket per run. Fresh context window every iteration. No context rot.
32
+
33
+ ---
34
+
35
+ ## Who this is for
36
+
37
+ Clancy is for developers who:
38
+
39
+ - Use a Kanban board (Jira, GitHub Issues, or Linear) and want Claude to work through their backlog unattended
40
+ - Are comfortable with Claude Code and want to extend it for team workflows — not just solo hacking
41
+ - Have a codebase with enough structure that an AI agent can make meaningful progress on a ticket without constant hand-holding
42
+ - Want to go AFK and come back to committed, merged work
43
+
44
+ **Clancy is not for you if:**
45
+
46
+ - You want to supervise every change — use Claude Code directly instead
47
+ - Your tickets are large, vague, or span multiple sessions — Clancy works best with small, well-scoped tickets
48
+ - You don't use a Kanban board — you can still use `/clancy:map-codebase` for codebase scanning, but the run loop won't apply
49
+
50
+ Evaluating other tools? See [COMPARISON.md](./COMPARISON.md) for a side-by-side with GSD and PAUL.
51
+
52
+ ---
53
+
54
+ ## Expectations
55
+
56
+ Clancy is powerful but not magic. Here's what to expect:
57
+
58
+ **It will get things wrong sometimes.** Claude can misread a ticket, make the wrong architectural choice, or produce code that doesn't compile. This is normal. Use `/clancy:once` to watch the first few runs, then review the output before going fully AFK. Over time you'll learn which ticket types Clancy handles well on your codebase.
59
+
60
+ **Ticket quality matters more than you think.** A vague ticket produces vague implementation. Clancy works best when tickets have a clear summary, a description that explains the _why_, and concrete acceptance criteria. Use `/clancy:review` to score a ticket before running — it'll tell you exactly what's missing.
61
+
62
+ **You still own the code.** Clancy commits and merges locally, but it never pushes to remote. Review the squash commit before pushing. Treat it like code from a junior developer who works very fast — it needs a sanity check, not a full rewrite.
63
+
64
+ **Some tickets will need a retry.** If Claude gets stuck or produces something obviously wrong, delete the branch and run `/clancy:once` again. Fresh context, fresh attempt. If it fails twice on the same ticket, the ticket probably needs more detail.
65
+
66
+ **Clancy is token-heavy.** Each ticket starts a fresh Claude session that reads your codebase docs, CLAUDE.md, and then implements the ticket — before writing a single line of code, it has already consumed significant context. Rough estimates per ticket:
67
+
68
+ | Ticket complexity | Approximate total tokens | Approximate cost (Sonnet) |
69
+ |---|---|---|
70
+ | Simple (small change, clear scope) | 50,000–100,000 | $0.25–$0.75 |
71
+ | Medium (feature, 5–15 files touched) | 100,000–250,000 | $0.75–$2.00 |
72
+ | Complex (large feature, many files) | 250,000–500,000+ | $2.00–$5.00+ |
73
+
74
+ These are rough estimates — actual usage depends on your codebase doc size, how many files Claude reads during implementation, and how much code it writes. **Check Claude Code's usage dashboard after your first `/clancy:once` run to see real numbers for your codebase.**
75
+
76
+ A few ways to manage costs:
77
+ - Use a lighter model — set `CLANCY_MODEL=claude-haiku-4-5` in `.clancy/.env` for simpler tickets (significantly cheaper, less capable)
78
+ - Keep `.clancy/docs/` files concise — they're read in full on every ticket
79
+ - Use small, well-scoped tickets — fewer files read, less output generated
80
+
81
+ ---
82
+
83
+ ## Supported boards
84
+
85
+ - **Jira** — via REST API v3, JQL, ADF description parsing
86
+ - **GitHub Issues** — via REST API with PR filtering
87
+ - **Linear** — via GraphQL, `viewer.assignedIssues`, `state.type: unstarted`
88
+
89
+ Community can add boards — see [CONTRIBUTING.md](./CONTRIBUTING.md).
90
+
91
+ ---
92
+
93
+ ## Install
94
+
95
+ ```bash
96
+ npx chief-clancy
97
+ ```
98
+
99
+ You'll be asked: global install (`~/.claude`) or local (`./.claude`). Either works. Global makes commands available in all projects.
100
+
101
+ **Prerequisites:**
102
+
103
+ - [Claude Code](https://claude.ai/code) CLI installed
104
+ - `jq` installed (`brew install jq` or `apt install jq`)
105
+ - `curl` installed (comes with macOS/most Linux)
106
+ - `git` installed (comes with most development environments)
107
+
108
+ ### Permissions
109
+
110
+ Clancy is designed to run Claude with `--dangerously-skip-permissions`:
111
+
112
+ ```bash
113
+ claude --dangerously-skip-permissions
114
+ ```
115
+
116
+ > [!TIP]
117
+ > This is how Clancy is intended to be used — stopping to approve `git commit` and `curl` 50 times defeats the purpose. Only use it on codebases you own and trust.
118
+
119
+ ---
120
+
121
+ ## Getting started
122
+
123
+ ```bash
124
+ # 1. Install Clancy commands
125
+ npx chief-clancy
126
+
127
+ # 2. Open a project in Claude Code, then:
128
+ /clancy:init
129
+
130
+ # 3. Scan your codebase (or say yes during init)
131
+ /clancy:map-codebase
132
+
133
+ # 4. Watch your first ticket
134
+ /clancy:once
135
+
136
+ # 5. Go AFK
137
+ /clancy:run
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Commands
143
+
144
+ | Command | Description |
145
+ | ---------------------- | ------------------------------------------------------------------------ |
146
+ | `/clancy:init` | Wizard — choose board, collect config, scaffold everything |
147
+ | `/clancy:run` | Loop mode — processes tickets until queue is empty or MAX_ITERATIONS hit |
148
+ | `/clancy:run 20` | Same, override MAX_ITERATIONS to 20 for this session |
149
+ | `/clancy:once` | Pick up one ticket and stop |
150
+ | `/clancy:status` | Show next tickets without running — read-only |
151
+ | `/clancy:review` | Score next ticket (0–100%) with actionable recommendations |
152
+ | `/clancy:logs` | Format and display `.clancy/progress.txt` |
153
+ | `/clancy:map-codebase` | Full 5-agent parallel codebase scan, writes 10 docs |
154
+ | `/clancy:update-docs` | Incremental refresh — re-runs agents for changed areas |
155
+ | `/clancy:settings` | View and change configuration — model, iterations, board, and more |
156
+ | `/clancy:doctor` | Diagnose your setup — test every integration, report what's broken |
157
+ | `/clancy:update` | Update Clancy to latest version |
158
+ | `/clancy:uninstall` | Remove Clancy commands — optionally remove `.clancy/` too |
159
+ | `/clancy:help` | Command reference |
160
+
161
+ ---
162
+
163
+ ## What gets created
164
+
165
+ ```
166
+ .clancy/
167
+ clancy-once.sh — picks up one ticket, implements, commits, merges
168
+ clancy-afk.sh — loop runner (board-agnostic)
169
+ docs/ — 10 structured docs read before every run
170
+ STACK.md
171
+ INTEGRATIONS.md
172
+ ARCHITECTURE.md
173
+ CONVENTIONS.md
174
+ TESTING.md
175
+ GIT.md
176
+ DESIGN-SYSTEM.md
177
+ ACCESSIBILITY.md
178
+ DEFINITION-OF-DONE.md
179
+ CONCERNS.md
180
+ progress.txt — append-only log of completed tickets
181
+ .env — your board credentials (gitignored)
182
+ .env.example — credential template for your board
183
+ ```
184
+
185
+ Clancy also merges a section into your `CLAUDE.md` (or creates one) that tells Claude to read all these docs before every run.
186
+
187
+ ---
188
+
189
+ ## Optional enhancements
190
+
191
+ Set during `/clancy:init` advanced setup, or by editing `.clancy/.env` directly.
192
+
193
+ ### Figma MCP
194
+
195
+ ```
196
+ FIGMA_API_KEY=your-key
197
+ ```
198
+
199
+ When a ticket description contains a Figma URL, Clancy fetches design specs automatically:
200
+
201
+ 1. Figma MCP: `get_metadata` → `get_design_context` → `get_screenshot` (3 calls)
202
+ 2. Figma REST API image export (fallback)
203
+ 3. Ticket image attachment (fallback)
204
+
205
+ ### Playwright visual checks
206
+
207
+ ```
208
+ PLAYWRIGHT_ENABLED=true
209
+ PLAYWRIGHT_DEV_COMMAND="yarn dev"
210
+ PLAYWRIGHT_DEV_PORT=5173
211
+ PLAYWRIGHT_STORYBOOK_COMMAND="yarn storybook" # if applicable
212
+ PLAYWRIGHT_STORYBOOK_PORT=6006 # if applicable
213
+ PLAYWRIGHT_STARTUP_WAIT=15
214
+ ```
215
+
216
+ After implementing a UI ticket, Clancy starts the dev server or Storybook, screenshots, assesses visually, checks the console, and fixes anything wrong before committing.
217
+
218
+ ### Notifications
219
+
220
+ ```
221
+ CLANCY_NOTIFY_WEBHOOK=https://hooks.slack.com/services/your/webhook/url
222
+ ```
223
+
224
+ Posts to Slack or Teams when a ticket completes or Clancy hits an error. URL is auto-detected.
225
+
226
+ ---
227
+
228
+ ## How the loop works
229
+
230
+ ```
231
+ clancy-afk.sh
232
+ └─ while i < MAX_ITERATIONS:
233
+ bash clancy-once.sh
234
+ 1. Preflight checks (credentials, git state, board reachability)
235
+ 2. Fetch next ticket from board (maxResults=1)
236
+ 3. git checkout $EPIC_BRANCH
237
+ 4. git checkout -b feature/{ticket-key}
238
+ 5. Read .clancy/docs/* (especially GIT.md)
239
+ 6. echo "$PROMPT" | claude --dangerously-skip-permissions
240
+ 7. git checkout $EPIC_BRANCH
241
+ 8. git merge --squash feature/{ticket-key}
242
+ 9. git commit -m "feat(TICKET): summary"
243
+ 10. git branch -d feature/{ticket-key}
244
+ 11. Append to .clancy/progress.txt
245
+ if "No tickets found": break
246
+ ```
247
+
248
+ Clancy reads `GIT.md` before every run and follows whatever conventions are documented there. The defaults above apply on greenfield projects or when GIT.md is silent.
249
+
250
+ ---
251
+
252
+ ## Lineage
253
+
254
+ ![Chief Clancy Wiggum inspiration. Generated by Google Gemini](assets/inspired-chief-clancy.webp)
255
+
256
+ Clancy is built on the **Ralph technique** coined by **Geoffrey Huntley** ([ghuntley.com/ralph/](https://ghuntley.com/ralph/)).
257
+
258
+ Ralph in its purest form:
259
+
260
+ ```bash
261
+ while :; do cat PROMPT.md | claude-code; done
262
+ ```
263
+
264
+ Clancy is what happens when you take that idea seriously for team development. See [CREDITS.md](./CREDITS.md) for the full story.
265
+
266
+ ---
267
+
268
+ ## Security
269
+
270
+ ### Permissions model
271
+
272
+ Clancy runs Claude with `--dangerously-skip-permissions`, which suppresses all permission prompts so it can work unattended. This means Claude has full read/write access to your file system and can execute shell commands without asking.
273
+
274
+ **Only run Clancy on codebases you own and trust.** Review the scripts in `.clancy/` before your first run if you want to see exactly what executes.
275
+
276
+ **Alternative — granular permissions:** if you run Claude Code without `--dangerously-skip-permissions` by default, you can pre-approve only the commands Clancy needs. Add this to `.claude/settings.json` in your project (or `~/.claude/settings.json` globally):
277
+
278
+ ```json
279
+ {
280
+ "permissions": {
281
+ "allow": [
282
+ "Bash(git:*)",
283
+ "Bash(bash:*)",
284
+ "Bash(curl:*)",
285
+ "Bash(jq:*)",
286
+ "Bash(chmod:*)",
287
+ "Bash(npm:*)",
288
+ "Bash(mkdir:*)",
289
+ "Bash(cat:*)",
290
+ "Bash(cp:*)",
291
+ "Bash(echo:*)",
292
+ "Bash(ls:*)",
293
+ "Bash(grep:*)",
294
+ "Bash(wc:*)",
295
+ "Bash(sort:*)",
296
+ "Bash(tr:*)",
297
+ "Bash(head:*)",
298
+ "Bash(tail:*)",
299
+ "Bash(lsof:*)",
300
+ "Bash(command:*)"
301
+ ]
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### Protect your credentials from Claude
307
+
308
+ Your board tokens and API keys live in `.clancy/.env`. Although Claude doesn't need to read this file during a run (the shell script sources it before invoking Claude), adding it to Claude Code's deny list is good defence-in-depth. Add it to `.claude/settings.json` in your project, or `~/.claude/settings.json` globally:
309
+
310
+ ```json
311
+ {
312
+ "permissions": {
313
+ "deny": [
314
+ "Read(.clancy/.env)",
315
+ "Read(.env)",
316
+ "Read(.env.*)",
317
+ "Read(**/*.pem)",
318
+ "Read(**/*.key)"
319
+ ]
320
+ }
321
+ }
322
+ ```
323
+
324
+ This prevents Claude from reading these files regardless of what commands run. Clancy automatically adds `.clancy/.env` to `.gitignore` during init, but the deny list is an additional layer.
325
+
326
+ ### Token scopes
327
+
328
+ Use the minimum permissions each integration requires:
329
+
330
+ | Integration | Recommended scope |
331
+ |---|---|
332
+ | GitHub PAT | `repo` — read/write issues and contents for your repo only |
333
+ | Jira API token | Standard user — no admin rights needed |
334
+ | Linear API key | Personal API key — read/write to your assigned issues |
335
+ | Figma API key | Read-only access is sufficient |
336
+
337
+ ### Webhook URLs
338
+
339
+ If you configure Slack or Teams notifications, treat the webhook URL as a secret — anyone who has it can post to your channel. Keep `.clancy/.env` gitignored (Clancy does this automatically during init) and never share the URL.
340
+
341
+ ---
342
+
343
+ ## Troubleshooting
344
+
345
+ **Start here:** run `/clancy:doctor` — it tests every integration and tells you exactly what's broken and how to fix it.
346
+
347
+ ---
348
+
349
+ **Commands not found after install?**
350
+
351
+ Restart Claude Code to reload commands, then verify the files exist:
352
+
353
+ ```bash
354
+ ls ~/.claude/commands/clancy/ # global install
355
+ ls .claude/commands/clancy/ # local install
356
+ ```
357
+
358
+ If missing, re-run `npx chief-clancy`.
359
+
360
+ ---
361
+
362
+ **Board connection fails?**
363
+
364
+ Run `/clancy:doctor` to test your credentials. If it reports a failure, open `.clancy/.env` and check your tokens — they're the most common cause. You can also run `/clancy:settings` → Switch board to re-enter credentials without re-running full init.
365
+
366
+ ---
367
+
368
+ **No tickets showing up?**
369
+
370
+ Run `/clancy:status` to see what Clancy would pick up. If the queue is empty:
371
+
372
+ - Check that tickets are assigned to you on the board
373
+ - For Jira: verify the status filter in `/clancy:settings` matches your board's status name exactly (e.g. `To Do` vs `TODO`)
374
+ - For Linear: Clancy filters by `state.type: unstarted` — ensure your backlog state maps to this type
375
+
376
+ ---
377
+
378
+ **Scripts not executable?**
379
+
380
+ ```bash
381
+ chmod +x .clancy/*.sh
382
+ ```
383
+
384
+ ---
385
+
386
+ **`.clancy/clancy-once.sh` not found?**
387
+
388
+ Re-run `/clancy:init` — it will detect the existing setup and offer to re-scaffold without asking for credentials again.
389
+
390
+ ---
391
+
392
+ **Playwright port already in use?**
393
+
394
+ ```bash
395
+ lsof -ti:5173 | xargs kill -9 # replace 5173 with your PLAYWRIGHT_DEV_PORT
396
+ ```
397
+
398
+ ---
399
+
400
+ **Updating Clancy?**
401
+
402
+ ```bash
403
+ /clancy:update
404
+ ```
405
+
406
+ Or directly: `npx chief-clancy@latest`
407
+
408
+ ---
409
+
410
+ **Uninstalling?**
411
+
412
+ ```
413
+ /clancy:uninstall
414
+ ```
415
+
416
+ Removes slash commands from your chosen location. Optionally removes `.clancy/` (credentials and docs). Never touches `CLAUDE.md`.
417
+
418
+ ---
419
+
420
+ ## Contributing
421
+
422
+ See [CONTRIBUTING.md](./CONTRIBUTING.md). The most useful contribution is adding a new board — it's a shell script + a JSON entry.
423
+
424
+ ## License
425
+
426
+ MIT — see [LICENSE](./LICENSE).
package/bin/install.js ADDED
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const readline = require('readline');
7
+
8
+ const PKG = require('../package.json');
9
+ const COMMANDS_SRC = path.join(__dirname, '..', 'src', 'commands');
10
+ const WORKFLOWS_SRC = path.join(__dirname, '..', 'src', 'workflows');
11
+
12
+ const homeDir = process.env.HOME || process.env.USERPROFILE;
13
+ if (!homeDir) {
14
+ process.stderr.write('\x1b[31m\n Error: HOME or USERPROFILE environment variable is not set.\x1b[0m\n');
15
+ process.exit(1);
16
+ }
17
+
18
+ const GLOBAL_DEST = path.join(homeDir, '.claude', 'commands', 'clancy');
19
+ const LOCAL_DEST = path.join(process.cwd(), '.claude', 'commands', 'clancy');
20
+
21
+ // Workflows live outside commands/ so Claude Code doesn't expose them as slash commands
22
+ const GLOBAL_WORKFLOWS_DEST = path.join(homeDir, '.claude', 'clancy', 'workflows');
23
+ const LOCAL_WORKFLOWS_DEST = path.join(process.cwd(), '.claude', 'clancy', 'workflows');
24
+
25
+ // ANSI helpers
26
+ const dim = s => `\x1b[2m${s}\x1b[0m`;
27
+ const bold = s => `\x1b[1m${s}\x1b[0m`;
28
+ const blue = s => `\x1b[1;34m${s}\x1b[0m`;
29
+ const cyan = s => `\x1b[36m${s}\x1b[0m`;
30
+ const green = s => `\x1b[32m${s}\x1b[0m`;
31
+ const red = s => `\x1b[31m${s}\x1b[0m`;
32
+
33
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
34
+ // Ensure readline is always closed — process.exit() doesn't trigger finally blocks
35
+ process.on('exit', () => rl.close());
36
+
37
+ function ask(label) {
38
+ return new Promise(resolve => rl.question(label, resolve));
39
+ }
40
+
41
+ async function choose(question, options, defaultChoice = 1) {
42
+ console.log('');
43
+ console.log(blue(question));
44
+ console.log('');
45
+ options.forEach((opt, i) => console.log(` ${i + 1}) ${opt}`));
46
+ console.log('');
47
+ const raw = await ask(cyan(`Choice [${defaultChoice}]: `));
48
+ return raw.trim() || String(defaultChoice);
49
+ }
50
+
51
+ function copyDir(src, dest) {
52
+ // Use lstatSync (not statSync) to detect symlinks — statSync follows them and misreports
53
+ if (fs.existsSync(dest)) {
54
+ const stat = fs.lstatSync(dest);
55
+ if (stat.isSymbolicLink()) {
56
+ throw new Error(`${dest} is a symlink. Remove it first before installing.`);
57
+ }
58
+ }
59
+ fs.mkdirSync(dest, { recursive: true });
60
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
61
+ const s = path.join(src, entry.name);
62
+ const d = path.join(dest, entry.name);
63
+ entry.isDirectory() ? copyDir(s, d) : fs.copyFileSync(s, d);
64
+ }
65
+ }
66
+
67
+ async function main() {
68
+ console.log('');
69
+ console.log(blue(' ██████╗██╗ █████╗ ███╗ ██╗ ██████╗██╗ ██╗'));
70
+ console.log(blue(' ██╔════╝██║ ██╔══██╗████╗ ██║██╔════╝╚██╗ ██╔╝'));
71
+ console.log(blue(' ██║ ██║ ███████║██╔██╗ ██║██║ ╚████╔╝ '));
72
+ console.log(blue(' ██║ ██║ ██╔══██║██║╚██╗██║██║ ╚██╔╝ '));
73
+ console.log(blue(' ╚██████╗███████╗██║ ██║██║ ╚████║╚██████╗ ██║ '));
74
+ console.log(blue(' ╚═════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ '));
75
+ console.log('');
76
+ console.log(' ' + bold(`v${PKG.version}`) + dim(' Autonomous, board-driven development for Claude Code.'));
77
+ console.log(dim(' Named after Chief Clancy Wiggum. Built on the Ralph technique by Geoffrey Huntley.'));
78
+
79
+ const installChoice = await choose(
80
+ 'Where would you like to install?',
81
+ [
82
+ `Global ${dim('(~/.claude)')} — available in all projects`,
83
+ `Local ${dim('(./.claude)')} — this project only`,
84
+ ]
85
+ );
86
+
87
+ let dest, workflowsDest;
88
+ if (installChoice === '1' || installChoice.toLowerCase() === 'global') {
89
+ dest = GLOBAL_DEST;
90
+ workflowsDest = GLOBAL_WORKFLOWS_DEST;
91
+ } else if (installChoice === '2' || installChoice.toLowerCase() === 'local') {
92
+ dest = LOCAL_DEST;
93
+ workflowsDest = LOCAL_WORKFLOWS_DEST;
94
+ } else {
95
+ console.log(red('\n Invalid choice. Run npx chief-clancy again and enter 1 or 2.'));
96
+ rl.close();
97
+ process.exit(1);
98
+ }
99
+
100
+ // Validate source directories — guards against corrupted npm package
101
+ if (!fs.existsSync(COMMANDS_SRC)) {
102
+ console.error(red(`\n Error: Source not found: ${COMMANDS_SRC}`));
103
+ console.error(red(' The npm package may be corrupted. Try: npm cache clean --force'));
104
+ rl.close();
105
+ process.exit(1);
106
+ }
107
+ if (!fs.existsSync(WORKFLOWS_SRC)) {
108
+ console.error(red(`\n Error: Source not found: ${WORKFLOWS_SRC}`));
109
+ console.error(red(' The npm package may be corrupted. Try: npm cache clean --force'));
110
+ rl.close();
111
+ process.exit(1);
112
+ }
113
+
114
+ console.log('');
115
+ console.log(dim(` Installing to: ${dest}`));
116
+
117
+ try {
118
+ if (fs.existsSync(dest) || fs.existsSync(workflowsDest)) {
119
+ console.log('');
120
+ const overwrite = await ask(blue(` Commands already exist at ${dest}. Overwrite? [y/N] `));
121
+ if (!overwrite.trim().toLowerCase().startsWith('y')) {
122
+ console.log('\n Aborted. No files changed.');
123
+ rl.close();
124
+ process.exit(0);
125
+ }
126
+ }
127
+
128
+ copyDir(COMMANDS_SRC, dest);
129
+ copyDir(WORKFLOWS_SRC, workflowsDest);
130
+
131
+ // Write VERSION file so /clancy:doctor and /clancy:update can read the installed version
132
+ fs.writeFileSync(path.join(dest, 'VERSION'), PKG.version);
133
+
134
+ console.log('');
135
+ console.log(green(' ✓ Clancy installed successfully.'));
136
+ console.log('');
137
+ console.log(' Next steps:');
138
+ console.log(dim(' 1. Open a project in Claude Code'));
139
+ console.log(` 2. Run: ${cyan('/clancy:init')}`);
140
+ console.log('');
141
+ console.log(' Commands available:');
142
+ console.log('');
143
+ const cmds = [
144
+ ['/clancy:init', 'Set up Clancy in your project'],
145
+ ['/clancy:map-codebase', 'Scan codebase with 5 parallel agents'],
146
+ ['/clancy:run', 'Run Clancy in loop mode'],
147
+ ['/clancy:once', 'Pick up one ticket and stop'],
148
+ ['/clancy:status', 'Show next tickets without running'],
149
+ ['/clancy:review', 'Score next ticket and get recommendations'],
150
+ ['/clancy:logs', 'Display progress log'],
151
+ ['/clancy:settings', 'View and change configuration'],
152
+ ['/clancy:doctor', 'Diagnose your setup'],
153
+ ['/clancy:update', 'Update Clancy to latest version'],
154
+ ['/clancy:help', 'Show all commands'],
155
+ ];
156
+ for (const [cmd, desc] of cmds) {
157
+ console.log(` ${cyan(cmd.padEnd(22))} ${dim(desc)}`);
158
+ }
159
+ console.log('');
160
+ } catch (err) {
161
+ console.error(red(`\n Install failed: ${err.message}`));
162
+ rl.close();
163
+ process.exit(1);
164
+ }
165
+
166
+ rl.close();
167
+ }
168
+
169
+ main();
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "chief-clancy",
3
+ "version": "0.1.0",
4
+ "description": "Autonomous, board-driven development for Claude Code — scaffolds docs, integrates Kanban boards, runs tickets in a loop.",
5
+ "keywords": [
6
+ "claude",
7
+ "claude-code",
8
+ "ai",
9
+ "kanban",
10
+ "jira",
11
+ "github-issues",
12
+ "linear",
13
+ "autonomous",
14
+ "slash-commands"
15
+ ],
16
+ "homepage": "https://github.com/Pushedskydiver/clancy#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/Pushedskydiver/clancy/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Pushedskydiver/clancy.git"
23
+ },
24
+ "license": "MIT",
25
+ "author": "Alex Clapperton",
26
+ "bin": {
27
+ "clancy": "bin/install.js"
28
+ },
29
+ "main": "bin/install.js",
30
+ "files": [
31
+ "bin/",
32
+ "src/",
33
+ "registry/"
34
+ ],
35
+ "scripts": {
36
+ "test": "bash test/unit/jira.test.sh && bash test/unit/github.test.sh && bash test/unit/linear.test.sh",
37
+ "smoke": "bash test/smoke/smoke.sh"
38
+ },
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ }
42
+ }