get-shit-done-cc 1.8.0 → 1.9.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 (34) hide show
  1. package/README.md +104 -0
  2. package/agents/gsd-entity-generator.md +237 -0
  3. package/agents/gsd-executor.md +15 -0
  4. package/agents/gsd-planner.md +22 -0
  5. package/bin/install.js +78 -7
  6. package/commands/gsd/analyze-codebase.md +410 -0
  7. package/commands/gsd/audit-milestone.md +20 -1
  8. package/commands/gsd/debug.md +20 -0
  9. package/commands/gsd/execute-phase.md +37 -4
  10. package/commands/gsd/help.md +91 -0
  11. package/commands/gsd/new-milestone.md +27 -7
  12. package/commands/gsd/new-project.md +104 -11
  13. package/commands/gsd/plan-phase.md +84 -26
  14. package/commands/gsd/progress.md +2 -0
  15. package/commands/gsd/query-intel.md +128 -0
  16. package/commands/gsd/quick.md +23 -0
  17. package/commands/gsd/research-phase.md +20 -0
  18. package/commands/gsd/set-profile.md +106 -0
  19. package/commands/gsd/settings.md +136 -0
  20. package/get-shit-done/references/model-profiles.md +73 -0
  21. package/get-shit-done/templates/config.json +5 -0
  22. package/get-shit-done/templates/entity.md +173 -0
  23. package/get-shit-done/workflows/execute-phase.md +45 -9
  24. package/get-shit-done/workflows/execute-plan.md +165 -4
  25. package/get-shit-done/workflows/map-codebase.md +24 -2
  26. package/get-shit-done/workflows/verify-work.md +22 -0
  27. package/hooks/dist/gsd-intel-index.js +97 -0
  28. package/hooks/dist/gsd-intel-prune.js +78 -0
  29. package/hooks/dist/gsd-intel-session.js +39 -0
  30. package/hooks/dist/statusline.js +84 -0
  31. package/package.json +12 -2
  32. package/scripts/build-hooks.js +95 -0
  33. /package/hooks/{gsd-check-update.js → dist/gsd-check-update.js} +0 -0
  34. /package/hooks/{statusline.js → dist/gsd-statusline.js} +0 -0
package/README.md CHANGED
@@ -324,6 +324,50 @@ Use for: bug fixes, small features, config changes, one-off tasks.
324
324
 
325
325
  ## Why It Works
326
326
 
327
+ ### Codebase Intelligence
328
+
329
+ GSD learns your codebase patterns automatically. As Claude writes code, a PostToolUse hook indexes exports and imports, detects naming conventions, and builds a semantic understanding of your codebase.
330
+
331
+ **How it works:**
332
+
333
+ 1. **Automatic learning** — Every time Claude writes or edits a JS/TS file, the hook extracts exports/imports and updates `.planning/intel/index.json`
334
+ 2. **Convention detection** — Analyzes exports for naming patterns (camelCase, PascalCase, etc.), identifies directory purposes, detects file suffixes
335
+ 3. **Graph database** — Stores entity relationships in SQLite for dependency analysis
336
+ 4. **Context injection** — At session start, injects a summary into Claude's context so it knows your codebase structure and conventions
337
+
338
+ **For existing codebases:**
339
+
340
+ ```
341
+ /gsd:analyze-codebase
342
+ ```
343
+
344
+ Performs a bulk scan of your codebase to bootstrap the intelligence layer. Works standalone — no `/gsd:new-project` required. After initial analysis, hooks continue incremental learning.
345
+
346
+ **Query the graph:**
347
+
348
+ ```
349
+ /gsd:query-intel dependents src/lib/db.ts # What depends on this file?
350
+ /gsd:query-intel hotspots # Most-depended-on files
351
+ ```
352
+
353
+ **Files created:**
354
+
355
+ | File | Purpose |
356
+ |------|---------|
357
+ | `.planning/intel/index.json` | File exports and imports index |
358
+ | `.planning/intel/conventions.json` | Detected patterns (naming, directories, suffixes) |
359
+ | `.planning/intel/graph.db` | SQLite database with entity relationships |
360
+ | `.planning/intel/summary.md` | Concise context for session injection |
361
+
362
+ **Benefits:**
363
+
364
+ - Claude follows your naming conventions automatically
365
+ - New files go in the right directories
366
+ - Consistency maintained across sessions
367
+ - Query blast radius before refactoring
368
+ - Identify high-impact hotspot files
369
+ - No manual documentation of patterns needed
370
+
327
371
  ### Context Engineering
328
372
 
329
373
  Claude Code is incredibly powerful *if* you give it the context it needs. Most people don't.
@@ -416,6 +460,7 @@ You're never locked in. The system adapts.
416
460
  | `/gsd:plan-phase [N]` | Research + plan + verify for a phase |
417
461
  | `/gsd:execute-phase <N>` | Execute all plans in parallel waves, verify when complete |
418
462
  | `/gsd:verify-work [N]` | Manual user acceptance testing ¹ |
463
+ | `/gsd:audit-milestone` | Verify milestone achieved its definition of done |
419
464
  | `/gsd:complete-milestone` | Archive milestone, tag release |
420
465
  | `/gsd:new-milestone [name]` | Start next version: questions → research → requirements → roadmap |
421
466
 
@@ -425,12 +470,16 @@ You're never locked in. The system adapts.
425
470
  |---------|--------------|
426
471
  | `/gsd:progress` | Where am I? What's next? |
427
472
  | `/gsd:help` | Show all commands and usage guide |
473
+ | `/gsd:whats-new` | See what changed since your installed version |
474
+ | `/gsd:update` | Update GSD with changelog preview |
428
475
 
429
476
  ### Brownfield
430
477
 
431
478
  | Command | What it does |
432
479
  |---------|--------------|
433
480
  | `/gsd:map-codebase` | Analyze existing codebase before new-project |
481
+ | `/gsd:analyze-codebase` | Bootstrap codebase intelligence for existing projects |
482
+ | `/gsd:query-intel <type>` | Query dependency graph (dependents, hotspots) |
434
483
 
435
484
  ### Phase Management
436
485
 
@@ -439,6 +488,8 @@ You're never locked in. The system adapts.
439
488
  | `/gsd:add-phase` | Append phase to roadmap |
440
489
  | `/gsd:insert-phase [N]` | Insert urgent work between phases |
441
490
  | `/gsd:remove-phase [N]` | Remove future phase, renumber |
491
+ | `/gsd:list-phase-assumptions [N]` | See Claude's intended approach before planning |
492
+ | `/gsd:plan-milestone-gaps` | Create phases to close gaps from audit |
442
493
 
443
494
  ### Session
444
495
 
@@ -451,6 +502,8 @@ You're never locked in. The system adapts.
451
502
 
452
503
  | Command | What it does |
453
504
  |---------|--------------|
505
+ | `/gsd:settings` | Configure model profile and workflow agents |
506
+ | `/gsd:set-profile <profile>` | Switch model profile (quality/balanced/budget) |
454
507
  | `/gsd:add-todo [desc]` | Capture idea for later |
455
508
  | `/gsd:check-todos` | List pending todos |
456
509
  | `/gsd:debug [desc]` | Systematic debugging with persistent state |
@@ -460,6 +513,57 @@ You're never locked in. The system adapts.
460
513
 
461
514
  ---
462
515
 
516
+ ## Configuration
517
+
518
+ GSD stores project settings in `.planning/config.json`. Configure during `/gsd:new-project` or update later with `/gsd:settings`.
519
+
520
+ ### Core Settings
521
+
522
+ | Setting | Options | Default | What it controls |
523
+ |---------|---------|---------|------------------|
524
+ | `mode` | `yolo`, `interactive` | `interactive` | Auto-approve vs confirm at each step |
525
+ | `depth` | `quick`, `standard`, `comprehensive` | `standard` | Planning thoroughness (phases × plans) |
526
+
527
+ ### Model Profiles
528
+
529
+ Control which Claude model each agent uses. Balance quality vs token spend.
530
+
531
+ | Profile | Planning | Execution | Verification |
532
+ |---------|----------|-----------|--------------|
533
+ | `quality` | Opus | Opus | Sonnet |
534
+ | `balanced` (default) | Opus | Sonnet | Sonnet |
535
+ | `budget` | Sonnet | Sonnet | Haiku |
536
+
537
+ Switch profiles:
538
+ ```
539
+ /gsd:set-profile budget
540
+ ```
541
+
542
+ Or configure via `/gsd:settings`.
543
+
544
+ ### Workflow Agents
545
+
546
+ These spawn additional agents during planning/execution. They improve quality but add tokens and time.
547
+
548
+ | Setting | Default | What it does |
549
+ |---------|---------|--------------|
550
+ | `workflow.research` | `true` | Researches domain before planning each phase |
551
+ | `workflow.plan_check` | `true` | Verifies plans achieve phase goals before execution |
552
+ | `workflow.verifier` | `true` | Confirms must-haves were delivered after execution |
553
+
554
+ Use `/gsd:settings` to toggle these, or override per-invocation:
555
+ - `/gsd:plan-phase --skip-research`
556
+ - `/gsd:plan-phase --skip-verify`
557
+
558
+ ### Execution
559
+
560
+ | Setting | Default | What it controls |
561
+ |---------|---------|------------------|
562
+ | `parallelization.enabled` | `true` | Run independent plans simultaneously |
563
+ | `planning.commit_docs` | `true` | Track `.planning/` in git |
564
+
565
+ ---
566
+
463
567
  ## Troubleshooting
464
568
 
465
569
  **Commands not found after install?**
@@ -0,0 +1,237 @@
1
+ ---
2
+ name: gsd-entity-generator
3
+ description: Generates semantic entity documentation for codebase files. Spawned by analyze-codebase with file list. Writes entities directly to disk.
4
+ tools: Read, Write, Bash
5
+ color: cyan
6
+ ---
7
+
8
+ <role>
9
+ You are a GSD entity generator. You create semantic documentation for source files that captures PURPOSE (what the code does and why it exists), not just syntax.
10
+
11
+ You are spawned by `/gsd:analyze-codebase` with a list of file paths.
12
+
13
+ Your job: Read each file, analyze its purpose, write entity markdown to `.planning/intel/entities/`, return statistics only.
14
+ </role>
15
+
16
+ <why_this_matters>
17
+ **Entities are consumed by the intelligence system:**
18
+
19
+ **PostToolUse hook** syncs each entity to graph.db:
20
+ - Extracts frontmatter (path, type, status)
21
+ - Extracts [[wiki-links]] from Dependencies section
22
+ - Creates nodes and edges in the graph
23
+
24
+ **Query interface** uses entities to answer:
25
+ - "What depends on this file?"
26
+ - "What does this file depend on?"
27
+ - "What are the most connected files?"
28
+
29
+ **Summary generation** aggregates entities into `.planning/intel/summary.md`:
30
+ - Dependency hotspots
31
+ - Module statistics
32
+ - Connection patterns
33
+
34
+ **What this means for your output:**
35
+
36
+ 1. **Frontmatter must be valid YAML** - Hook parses it to create graph nodes
37
+ 2. **[[wiki-links]] must use correct slugs** - Hook extracts these for edges
38
+ 3. **Purpose must be substantive** - "Handles authentication" not "Exports auth functions"
39
+ 4. **Type must match heuristics** - Enables filtering by module type
40
+ </why_this_matters>
41
+
42
+ <process>
43
+
44
+ <step name="parse_file_list">
45
+ Extract file paths from your prompt. You'll receive:
46
+ - Total file count
47
+ - Output directory path
48
+ - Slug convention rules
49
+ - Entity template
50
+ - List of absolute file paths
51
+
52
+ Parse file paths into a list for processing. Track progress counters:
53
+ - files_processed = 0
54
+ - entities_created = 0
55
+ - already_existed = 0
56
+ - errors = 0
57
+ </step>
58
+
59
+ <step name="process_each_file">
60
+ For each file path:
61
+
62
+ 1. **Read file content:**
63
+ Use the Read tool with the absolute file path.
64
+
65
+ 2. **Analyze the file:**
66
+ - What is its purpose? (Why does this file exist? What problem does it solve?)
67
+ - What does it export? (Functions, classes, types, constants)
68
+ - What does it import? (Dependencies and why they're needed)
69
+ - What type of module is it? (Use type heuristics table)
70
+
71
+ 3. **Generate slug:**
72
+ - Remove leading `/`
73
+ - Remove file extension
74
+ - Replace `/` and `.` with `-`
75
+ - Lowercase everything
76
+ - Example: `src/lib/db.ts` -> `src-lib-db`
77
+ - Example: `/Users/foo/project/src/auth/login.ts` -> `users-foo-project-src-auth-login`
78
+ - Use path relative to project root when possible for cleaner slugs
79
+
80
+ 4. **Check if entity exists:**
81
+ ```bash
82
+ ls .planning/intel/entities/{slug}.md 2>/dev/null
83
+ ```
84
+ If exists, increment already_existed and skip to next file.
85
+
86
+ 5. **Build entity content using template:**
87
+ - Frontmatter with path, type, date, status
88
+ - Purpose section (1-3 substantive sentences)
89
+ - Exports section (signatures + descriptions)
90
+ - Dependencies section ([[wiki-links]] for internal, plain text for external)
91
+ - Used By: Always "TBD" (graph analysis fills this later)
92
+ - Notes: Optional (only if important context)
93
+
94
+ 6. **Write entity file:**
95
+ Write to `.planning/intel/entities/{slug}.md`
96
+
97
+ 7. **Track statistics:**
98
+ Increment files_processed and entities_created.
99
+
100
+ 8. **Handle errors:**
101
+ If file can't be read or analyzed, increment errors and continue.
102
+
103
+ **Important:** PostToolUse hook automatically syncs each entity to graph.db after you write it. You don't need to touch the graph.
104
+ </step>
105
+
106
+ <step name="return_statistics">
107
+ After all files processed, return ONLY statistics. Do NOT include entity contents.
108
+
109
+ Format:
110
+ ```
111
+ ## ENTITY GENERATION COMPLETE
112
+
113
+ **Files processed:** {files_processed}
114
+ **Entities created:** {entities_created}
115
+ **Already existed:** {already_existed}
116
+ **Errors:** {errors}
117
+
118
+ Entities written to: .planning/intel/entities/
119
+ ```
120
+
121
+ If errors occurred, list the file paths that failed (not the error messages).
122
+ </step>
123
+
124
+ </process>
125
+
126
+ <entity_template>
127
+ Use this EXACT format for every entity:
128
+
129
+ ```markdown
130
+ ---
131
+ path: {absolute_path}
132
+ type: [module|component|util|config|api|hook|service|model|test]
133
+ updated: {YYYY-MM-DD}
134
+ status: active
135
+ ---
136
+
137
+ # {filename}
138
+
139
+ ## Purpose
140
+
141
+ [1-3 sentences: What does this file do? Why does it exist? What problem does it solve? Focus on the "why", not implementation details.]
142
+
143
+ ## Exports
144
+
145
+ [List each export with signature and purpose:]
146
+ - `functionName(params): ReturnType` - Brief description of what it does
147
+ - `ClassName` - What this class represents
148
+ - `CONSTANT_NAME` - What this constant configures
149
+
150
+ If no exports: "None"
151
+
152
+ ## Dependencies
153
+
154
+ [Internal dependencies use [[wiki-links]], external use plain text:]
155
+ - [[internal-file-slug]] - Why this dependency is needed
156
+ - external-package - What functionality it provides
157
+
158
+ If no dependencies: "None"
159
+
160
+ ## Used By
161
+
162
+ TBD
163
+
164
+ ## Notes
165
+
166
+ [Optional: Patterns, gotchas, important context. Omit section entirely if nothing notable.]
167
+ ```
168
+ </entity_template>
169
+
170
+ <type_heuristics>
171
+ Determine entity type from file path and content:
172
+
173
+ | Type | Indicators |
174
+ |------|-----------|
175
+ | api | In api/, routes/, endpoints/ directory, exports route handlers |
176
+ | component | In components/, exports React/Vue/Svelte components |
177
+ | util | In utils/, lib/, helpers/, exports utility functions |
178
+ | config | In config/, *.config.*, exports configuration objects |
179
+ | hook | In hooks/, exports use* functions (React hooks) |
180
+ | service | In services/, exports service classes/functions |
181
+ | model | In models/, types/, exports data models or TypeScript types |
182
+ | test | *.test.*, *.spec.*, contains test suites |
183
+ | module | Default if unclear, general-purpose module |
184
+ </type_heuristics>
185
+
186
+ <wiki_link_rules>
187
+ **Internal dependencies** (files in the codebase):
188
+ - Convert import path to slug format
189
+ - Wrap in [[double brackets]]
190
+ - Example: Import from `../../lib/db.ts` -> Dependency: `[[src-lib-db]]`
191
+ - Example: Import from `@/services/auth` -> Dependency: `[[src-services-auth]]`
192
+
193
+ **External dependencies** (npm/pip/cargo packages):
194
+ - Plain text, no brackets
195
+ - Include brief purpose
196
+ - Example: `import { z } from 'zod'` -> Dependency: `zod - Schema validation`
197
+
198
+ **Identifying internal vs external:**
199
+ - Import path starts with `.` or `..` -> internal (wiki-link)
200
+ - Import path starts with `@/` or `~/` -> internal (wiki-link, resolve alias)
201
+ - Import path is package name (no path separator) -> external (plain text)
202
+ - Import path starts with `@org/` -> usually external (npm scoped package)
203
+ </wiki_link_rules>
204
+
205
+ <critical_rules>
206
+
207
+ **WRITE ENTITIES DIRECTLY.** Do not return entity contents to orchestrator. The whole point is reducing context transfer.
208
+
209
+ **USE EXACT TEMPLATE FORMAT.** The PostToolUse hook parses frontmatter and [[wiki-links]]. Wrong format = broken graph sync.
210
+
211
+ **FRONTMATTER MUST BE VALID YAML.** No tabs, proper quoting for paths with special characters.
212
+
213
+ **PURPOSE MUST BE SUBSTANTIVE.** Bad: "Exports database functions." Good: "Manages database connection pooling and query execution. Provides transaction support and connection health monitoring."
214
+
215
+ **INTERNAL DEPS USE [[WIKI-LINKS]].** Hook extracts these to create graph edges. Plain text deps don't create edges.
216
+
217
+ **RETURN ONLY STATISTICS.** Your response should be ~10 lines. Just confirm what was written.
218
+
219
+ **DO NOT COMMIT.** The orchestrator handles git operations.
220
+
221
+ **SKIP EXISTING ENTITIES.** Check if entity file exists before writing. Don't overwrite existing entities.
222
+
223
+ </critical_rules>
224
+
225
+ <success_criteria>
226
+ Entity generation complete when:
227
+
228
+ - [ ] All file paths processed
229
+ - [ ] Each new entity written to `.planning/intel/entities/{slug}.md`
230
+ - [ ] Entity markdown follows template exactly
231
+ - [ ] Frontmatter is valid YAML
232
+ - [ ] Purpose section is substantive (not just "exports X")
233
+ - [ ] Internal dependencies use [[wiki-links]]
234
+ - [ ] External dependencies are plain text
235
+ - [ ] Statistics returned (not entity contents)
236
+ - [ ] Existing entities skipped (not overwritten)
237
+ </success_criteria>
@@ -52,6 +52,21 @@ git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false
52
52
  Store `COMMIT_PLANNING_DOCS` for use in git operations.
53
53
  </step>
54
54
 
55
+ <step name="load_codebase_intelligence">
56
+ Check for codebase intelligence:
57
+
58
+ ```bash
59
+ cat .planning/intel/summary.md 2>/dev/null
60
+ ```
61
+
62
+ If exists:
63
+ - Follow detected naming conventions when writing code
64
+ - Place new files in directories that match their purpose
65
+ - Use established patterns (camelCase, PascalCase, etc.)
66
+
67
+ This context helps maintain codebase consistency during execution.
68
+ </step>
69
+
55
70
  <step name="load_plan">
56
71
  Read the plan file provided in your prompt context.
57
72
 
@@ -416,6 +416,9 @@ Output: [What artifacts will be created]
416
416
  @.planning/ROADMAP.md
417
417
  @.planning/STATE.md
418
418
 
419
+ # Codebase intelligence (if exists)
420
+ @.planning/intel/summary.md
421
+
419
422
  # Only reference prior plan SUMMARYs if genuinely needed
420
423
  @path/to/relevant/source.ts
421
424
  </context>
@@ -1036,6 +1039,25 @@ If exists, load relevant documents based on phase type:
1036
1039
  | (default) | STACK.md, ARCHITECTURE.md |
1037
1040
  </step>
1038
1041
 
1042
+ <step name="load_codebase_intelligence">
1043
+ Check for codebase intelligence:
1044
+
1045
+ ```bash
1046
+ cat .planning/intel/summary.md 2>/dev/null
1047
+ ```
1048
+
1049
+ If exists, this provides:
1050
+ - File count and structure overview
1051
+ - Detected naming conventions (use these when creating new files)
1052
+ - Key directories and their purposes
1053
+ - Export patterns
1054
+
1055
+ **How to use:**
1056
+ - Follow detected naming conventions when planning new exports
1057
+ - Place new files in directories that match their purpose
1058
+ - Reference existing patterns when describing implementation
1059
+ </step>
1060
+
1039
1061
  <step name="identify_phase">
1040
1062
  Check roadmap and existing phases:
1041
1063
 
package/bin/install.js CHANGED
@@ -162,6 +162,7 @@ function copyWithPathReplacement(srcDir, destDir, pathPrefix) {
162
162
  function cleanupOrphanedFiles(claudeDir) {
163
163
  const orphanedFiles = [
164
164
  'hooks/gsd-notify.sh', // Removed in v1.6.x
165
+ 'hooks/statusline.js', // Renamed to gsd-statusline.js in v1.9.0
165
166
  ];
166
167
 
167
168
  for (const relPath of orphanedFiles) {
@@ -179,6 +180,7 @@ function cleanupOrphanedFiles(claudeDir) {
179
180
  function cleanupOrphanedHooks(settings) {
180
181
  const orphanedHookPatterns = [
181
182
  'gsd-notify.sh', // Removed in v1.6.x
183
+ 'hooks/statusline.js', // Renamed to gsd-statusline.js in v1.9.0
182
184
  ];
183
185
 
184
186
  let cleaned = false;
@@ -353,19 +355,22 @@ function install(isGlobal) {
353
355
  failures.push('VERSION');
354
356
  }
355
357
 
356
- // Copy hooks
357
- const hooksSrc = path.join(src, 'hooks');
358
+ // Copy hooks from dist/ (bundled with dependencies)
359
+ const hooksSrc = path.join(src, 'hooks', 'dist');
358
360
  if (fs.existsSync(hooksSrc)) {
359
361
  const hooksDest = path.join(claudeDir, 'hooks');
360
362
  fs.mkdirSync(hooksDest, { recursive: true });
361
363
  const hookEntries = fs.readdirSync(hooksSrc);
362
364
  for (const entry of hookEntries) {
363
365
  const srcFile = path.join(hooksSrc, entry);
364
- const destFile = path.join(hooksDest, entry);
365
- fs.copyFileSync(srcFile, destFile);
366
+ // Only copy files, not directories
367
+ if (fs.statSync(srcFile).isFile()) {
368
+ const destFile = path.join(hooksDest, entry);
369
+ fs.copyFileSync(srcFile, destFile);
370
+ }
366
371
  }
367
372
  if (verifyInstalled(hooksDest, 'hooks')) {
368
- console.log(` ${green}✓${reset} Installed hooks`);
373
+ console.log(` ${green}✓${reset} Installed hooks (bundled)`);
369
374
  } else {
370
375
  failures.push('hooks');
371
376
  }
@@ -382,8 +387,8 @@ function install(isGlobal) {
382
387
  const settingsPath = path.join(claudeDir, 'settings.json');
383
388
  const settings = cleanupOrphanedHooks(readSettings(settingsPath));
384
389
  const statuslineCommand = isGlobal
385
- ? 'node "$HOME/.claude/hooks/statusline.js"'
386
- : 'node .claude/hooks/statusline.js';
390
+ ? 'node "$HOME/.claude/hooks/gsd-statusline.js"'
391
+ : 'node .claude/hooks/gsd-statusline.js';
387
392
  const updateCheckCommand = isGlobal
388
393
  ? 'node "$HOME/.claude/hooks/gsd-check-update.js"'
389
394
  : 'node .claude/hooks/gsd-check-update.js';
@@ -413,6 +418,72 @@ function install(isGlobal) {
413
418
  console.log(` ${green}✓${reset} Configured update check hook`);
414
419
  }
415
420
 
421
+ // Register intel hooks for codebase intelligence
422
+ const intelIndexCommand = isGlobal
423
+ ? 'node "$HOME/.claude/hooks/gsd-intel-index.js"'
424
+ : 'node .claude/hooks/gsd-intel-index.js';
425
+
426
+ const intelSessionCommand = isGlobal
427
+ ? 'node "$HOME/.claude/hooks/gsd-intel-session.js"'
428
+ : 'node .claude/hooks/gsd-intel-session.js';
429
+
430
+ // PostToolUse hook for indexing
431
+ if (!settings.hooks.PostToolUse) {
432
+ settings.hooks.PostToolUse = [];
433
+ }
434
+
435
+ const hasIntelIndexHook = settings.hooks.PostToolUse.some(entry =>
436
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('gsd-intel-index'))
437
+ );
438
+
439
+ if (!hasIntelIndexHook) {
440
+ settings.hooks.PostToolUse.push({
441
+ hooks: [{
442
+ type: 'command',
443
+ command: intelIndexCommand
444
+ }]
445
+ });
446
+ console.log(` ${green}✓${reset} Configured intel indexing hook`);
447
+ }
448
+
449
+ // SessionStart hook for context injection
450
+ const hasIntelSessionHook = settings.hooks.SessionStart.some(entry =>
451
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('gsd-intel-session'))
452
+ );
453
+
454
+ if (!hasIntelSessionHook) {
455
+ settings.hooks.SessionStart.push({
456
+ hooks: [{
457
+ type: 'command',
458
+ command: intelSessionCommand
459
+ }]
460
+ });
461
+ console.log(` ${green}✓${reset} Configured intel session hook`);
462
+ }
463
+
464
+ // Stop hook for pruning deleted files
465
+ const intelPruneCommand = isGlobal
466
+ ? 'node "$HOME/.claude/hooks/gsd-intel-prune.js"'
467
+ : 'node .claude/hooks/gsd-intel-prune.js';
468
+
469
+ if (!settings.hooks.Stop) {
470
+ settings.hooks.Stop = [];
471
+ }
472
+
473
+ const hasIntelPruneHook = settings.hooks.Stop.some(entry =>
474
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('gsd-intel-prune'))
475
+ );
476
+
477
+ if (!hasIntelPruneHook) {
478
+ settings.hooks.Stop.push({
479
+ hooks: [{
480
+ type: 'command',
481
+ command: intelPruneCommand
482
+ }]
483
+ });
484
+ console.log(` ${green}✓${reset} Configured intel prune hook`);
485
+ }
486
+
416
487
  return { settingsPath, settings, statuslineCommand };
417
488
  }
418
489