get-shit-done-cc 1.8.0 → 1.9.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.
- package/README.md +104 -0
- package/agents/gsd-executor.md +15 -0
- package/agents/gsd-planner.md +22 -0
- package/bin/install.js +78 -7
- package/commands/gsd/analyze-codebase.md +363 -0
- package/commands/gsd/audit-milestone.md +20 -1
- package/commands/gsd/debug.md +20 -0
- package/commands/gsd/execute-phase.md +37 -4
- package/commands/gsd/help.md +91 -0
- package/commands/gsd/new-milestone.md +27 -7
- package/commands/gsd/new-project.md +104 -11
- package/commands/gsd/plan-phase.md +84 -26
- package/commands/gsd/progress.md +2 -0
- package/commands/gsd/query-intel.md +128 -0
- package/commands/gsd/quick.md +23 -0
- package/commands/gsd/research-phase.md +20 -0
- package/commands/gsd/set-profile.md +106 -0
- package/commands/gsd/settings.md +136 -0
- package/get-shit-done/references/model-profiles.md +73 -0
- package/get-shit-done/templates/config.json +5 -0
- package/get-shit-done/templates/entity.md +173 -0
- package/get-shit-done/workflows/execute-phase.md +45 -9
- package/get-shit-done/workflows/execute-plan.md +165 -4
- package/get-shit-done/workflows/map-codebase.md +24 -2
- package/get-shit-done/workflows/verify-work.md +22 -0
- package/hooks/dist/gsd-intel-index.js +97 -0
- package/hooks/dist/gsd-intel-prune.js +78 -0
- package/hooks/dist/gsd-intel-session.js +39 -0
- package/package.json +12 -2
- package/scripts/build-hooks.js +95 -0
- /package/hooks/{gsd-check-update.js → dist/gsd-check-update.js} +0 -0
- /package/hooks/{statusline.js → dist/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?**
|
package/agents/gsd-executor.md
CHANGED
|
@@ -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
|
|
package/agents/gsd-planner.md
CHANGED
|
@@ -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
|
-
|
|
365
|
-
fs.
|
|
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
|
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gsd:analyze-codebase
|
|
3
|
+
description: Scan existing codebase and populate .planning/intel/ with file index, conventions, and semantic entity files
|
|
4
|
+
argument-hint: ""
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Bash
|
|
8
|
+
- Glob
|
|
9
|
+
- Write
|
|
10
|
+
- Task
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<objective>
|
|
14
|
+
Scan codebase to populate .planning/intel/ with file index, conventions, and semantic entity files.
|
|
15
|
+
|
|
16
|
+
Works standalone (without /gsd:new-project) for brownfield codebases. Creates summary.md for context injection at session start. Generates entity files that capture file PURPOSE (what it does, why it exists), not just syntax.
|
|
17
|
+
|
|
18
|
+
Output: .planning/intel/index.json, conventions.json, summary.md, entities/*.md
|
|
19
|
+
</objective>
|
|
20
|
+
|
|
21
|
+
<context>
|
|
22
|
+
This command performs bulk codebase scanning to bootstrap the Codebase Intelligence system.
|
|
23
|
+
|
|
24
|
+
**Use for:**
|
|
25
|
+
- Brownfield projects before /gsd:new-project
|
|
26
|
+
- Refreshing intel after major changes
|
|
27
|
+
- Standalone intel without full project setup
|
|
28
|
+
|
|
29
|
+
After initial scan, the PostToolUse hook (hooks/intel-index.js) maintains incremental updates.
|
|
30
|
+
|
|
31
|
+
**Execution model (Step 9 - Entity Generation):**
|
|
32
|
+
- Claude (executing this command) generates entity content directly
|
|
33
|
+
- No embedded JavaScript - Claude reads files and writes semantic documentation
|
|
34
|
+
- Task tool to spawn subagents for batch processing large codebases
|
|
35
|
+
- Each subagent processes 10 files, generating Purpose-focused entity markdown
|
|
36
|
+
- Users can skip Step 9 if they only want the index (faster, less context)
|
|
37
|
+
</context>
|
|
38
|
+
|
|
39
|
+
<process>
|
|
40
|
+
|
|
41
|
+
## Step 1: Create directory structure
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir -p .planning/intel
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Step 2: Find all indexable files
|
|
48
|
+
|
|
49
|
+
Use Glob tool with pattern: `**/*.{js,ts,jsx,tsx,mjs,cjs}`
|
|
50
|
+
|
|
51
|
+
Exclude directories (skip any path containing):
|
|
52
|
+
- node_modules
|
|
53
|
+
- dist
|
|
54
|
+
- build
|
|
55
|
+
- .git
|
|
56
|
+
- vendor
|
|
57
|
+
- coverage
|
|
58
|
+
- .next
|
|
59
|
+
- __pycache__
|
|
60
|
+
|
|
61
|
+
Filter results to remove excluded paths before processing.
|
|
62
|
+
|
|
63
|
+
## Step 3: Process each file
|
|
64
|
+
|
|
65
|
+
Initialize the index structure:
|
|
66
|
+
```javascript
|
|
67
|
+
{
|
|
68
|
+
version: 1,
|
|
69
|
+
updated: Date.now(),
|
|
70
|
+
files: {}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For each file found:
|
|
75
|
+
|
|
76
|
+
1. Read file content using Read tool
|
|
77
|
+
|
|
78
|
+
2. Extract exports using these patterns:
|
|
79
|
+
- Named exports: `export\s*\{([^}]+)\}`
|
|
80
|
+
- Declaration exports: `export\s+(?:const|let|var|function\*?|async\s+function|class)\s+(\w+)`
|
|
81
|
+
- Default exports: `export\s+default\s+(?:function\s*\*?\s*|class\s+)?(\w+)?`
|
|
82
|
+
- CommonJS object: `module\.exports\s*=\s*\{([^}]+)\}`
|
|
83
|
+
- CommonJS single: `module\.exports\s*=\s*(\w+)\s*[;\n]`
|
|
84
|
+
- TypeScript: `export\s+(?:type|interface)\s+(\w+)`
|
|
85
|
+
|
|
86
|
+
3. Extract imports using these patterns:
|
|
87
|
+
- ES6: `import\s+(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+['"]([^'"]+)['"]`
|
|
88
|
+
- Side-effect: `import\s+['"]([^'"]+)['"]` (not preceded by 'from')
|
|
89
|
+
- CommonJS: `require\s*\(\s*['"]([^'"]+)['"]\s*\)`
|
|
90
|
+
|
|
91
|
+
4. Store in index:
|
|
92
|
+
```javascript
|
|
93
|
+
index.files[absolutePath] = {
|
|
94
|
+
exports: [], // Array of export names
|
|
95
|
+
imports: [], // Array of import sources
|
|
96
|
+
indexed: Date.now()
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Step 4: Detect conventions
|
|
101
|
+
|
|
102
|
+
Analyze the collected index for patterns.
|
|
103
|
+
|
|
104
|
+
**Naming conventions** (require 5+ exports, 70%+ match rate):
|
|
105
|
+
- camelCase: `^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$` or single lowercase `^[a-z][a-z0-9]*$`
|
|
106
|
+
- PascalCase: `^[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)*$` or single `^[A-Z][a-z0-9]+$`
|
|
107
|
+
- snake_case: `^[a-z][a-z0-9]*(?:_[a-z0-9]+)+$`
|
|
108
|
+
- SCREAMING_SNAKE: `^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$` or single `^[A-Z][A-Z0-9]*$`
|
|
109
|
+
- Skip 'default' when counting (it's a keyword, not naming convention)
|
|
110
|
+
|
|
111
|
+
**Directory patterns** (use lookup table):
|
|
112
|
+
```
|
|
113
|
+
components -> UI components
|
|
114
|
+
hooks -> React/custom hooks
|
|
115
|
+
utils, lib -> Utility functions
|
|
116
|
+
services -> Service layer
|
|
117
|
+
api, routes -> API endpoints
|
|
118
|
+
types -> TypeScript types
|
|
119
|
+
models -> Data models
|
|
120
|
+
tests, __tests__, test, spec -> Test files
|
|
121
|
+
controllers -> Controllers
|
|
122
|
+
middleware -> Middleware
|
|
123
|
+
config -> Configuration
|
|
124
|
+
constants -> Constants
|
|
125
|
+
pages -> Page components
|
|
126
|
+
views -> View templates
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Suffix patterns** (require 5+ occurrences):
|
|
130
|
+
```
|
|
131
|
+
.test.*, .spec.* -> Test files
|
|
132
|
+
.service.* -> Service layer
|
|
133
|
+
.controller.* -> Controllers
|
|
134
|
+
.model.* -> Data models
|
|
135
|
+
.util.*, .utils.* -> Utility functions
|
|
136
|
+
.helper.*, .helpers.* -> Helper functions
|
|
137
|
+
.config.* -> Configuration
|
|
138
|
+
.types.*, .type.* -> TypeScript types
|
|
139
|
+
.hook.*, .hooks.* -> React/custom hooks
|
|
140
|
+
.context.* -> React context
|
|
141
|
+
.store.* -> State store
|
|
142
|
+
.slice.* -> Redux slice
|
|
143
|
+
.reducer.* -> Redux reducer
|
|
144
|
+
.action.*, .actions.* -> Redux actions
|
|
145
|
+
.api.* -> API layer
|
|
146
|
+
.route.*, .routes.* -> Route definitions
|
|
147
|
+
.middleware.* -> Middleware
|
|
148
|
+
.schema.* -> Schema definitions
|
|
149
|
+
.mock.*, .mocks.* -> Mock data
|
|
150
|
+
.fixture.*, .fixtures.* -> Test fixtures
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Step 5: Write index.json
|
|
154
|
+
|
|
155
|
+
Write to `.planning/intel/index.json`:
|
|
156
|
+
```javascript
|
|
157
|
+
{
|
|
158
|
+
"version": 1,
|
|
159
|
+
"updated": 1737360330000,
|
|
160
|
+
"files": {
|
|
161
|
+
"/absolute/path/to/file.js": {
|
|
162
|
+
"exports": ["functionA", "ClassB"],
|
|
163
|
+
"imports": ["react", "./utils"],
|
|
164
|
+
"indexed": 1737360330000
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Step 6: Write conventions.json
|
|
171
|
+
|
|
172
|
+
Write to `.planning/intel/conventions.json`:
|
|
173
|
+
```javascript
|
|
174
|
+
{
|
|
175
|
+
"version": 1,
|
|
176
|
+
"updated": 1737360330000,
|
|
177
|
+
"naming": {
|
|
178
|
+
"exports": {
|
|
179
|
+
"dominant": "camelCase",
|
|
180
|
+
"count": 42,
|
|
181
|
+
"percentage": 85
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"directories": {
|
|
185
|
+
"components": { "purpose": "UI components", "files": 15 },
|
|
186
|
+
"hooks": { "purpose": "React/custom hooks", "files": 8 }
|
|
187
|
+
},
|
|
188
|
+
"suffixes": {
|
|
189
|
+
".test.js": { "purpose": "Test files", "count": 12 }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Step 7: Generate summary.md
|
|
195
|
+
|
|
196
|
+
Write to `.planning/intel/summary.md`:
|
|
197
|
+
|
|
198
|
+
```markdown
|
|
199
|
+
# Codebase Intelligence Summary
|
|
200
|
+
|
|
201
|
+
Last updated: [ISO timestamp]
|
|
202
|
+
Indexed files: [N]
|
|
203
|
+
|
|
204
|
+
## Naming Conventions
|
|
205
|
+
|
|
206
|
+
- Export naming: [case] ([percentage]% of [count] exports)
|
|
207
|
+
|
|
208
|
+
## Key Directories
|
|
209
|
+
|
|
210
|
+
- `[dir]/`: [purpose] ([N] files)
|
|
211
|
+
- ... (top 5)
|
|
212
|
+
|
|
213
|
+
## File Patterns
|
|
214
|
+
|
|
215
|
+
- `*[suffix]`: [purpose] ([count] files)
|
|
216
|
+
- ... (top 3)
|
|
217
|
+
|
|
218
|
+
Total exports: [N]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Target: < 500 tokens. Keep concise for context injection.
|
|
222
|
+
|
|
223
|
+
## Step 8: Report completion
|
|
224
|
+
|
|
225
|
+
Display summary statistics:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
Codebase Analysis Complete
|
|
229
|
+
|
|
230
|
+
Files indexed: [N]
|
|
231
|
+
Exports found: [N]
|
|
232
|
+
Imports found: [N]
|
|
233
|
+
|
|
234
|
+
Conventions detected:
|
|
235
|
+
- Naming: [dominant case] ([percentage]%)
|
|
236
|
+
- Directories: [list]
|
|
237
|
+
- Patterns: [list]
|
|
238
|
+
|
|
239
|
+
Files created:
|
|
240
|
+
- .planning/intel/index.json
|
|
241
|
+
- .planning/intel/conventions.json
|
|
242
|
+
- .planning/intel/summary.md
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Step 9: Generate semantic entities (optional)
|
|
246
|
+
|
|
247
|
+
Generate entity files that capture semantic understanding of key files. These provide PURPOSE, not just syntax.
|
|
248
|
+
|
|
249
|
+
**Skip this step if:** User only wants the index, or codebase has < 10 files.
|
|
250
|
+
|
|
251
|
+
### 9.1 Create entities directory
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
mkdir -p .planning/intel/entities
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 9.2 Select files for entity generation
|
|
258
|
+
|
|
259
|
+
Select up to 50 files based on these criteria (in priority order):
|
|
260
|
+
|
|
261
|
+
1. **High-export files:** 3+ exports (likely core modules)
|
|
262
|
+
2. **Hub files:** Referenced by 5+ other files (via imports analysis)
|
|
263
|
+
3. **Key directories:** Entry points (index.js, main.js, app.js), config files
|
|
264
|
+
4. **Structural files:** Files matching convention patterns (services, controllers, models)
|
|
265
|
+
|
|
266
|
+
From the index.json, identify candidates and limit to 50 files maximum per run.
|
|
267
|
+
|
|
268
|
+
### 9.3 Generate entities via Task tool batching
|
|
269
|
+
|
|
270
|
+
Process selected files in **batches of 10** using the Task tool to spawn subagents.
|
|
271
|
+
|
|
272
|
+
For each batch, spawn a Task with this instruction:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
Generate semantic entity files for these source files:
|
|
276
|
+
[list of 10 absolute file paths]
|
|
277
|
+
|
|
278
|
+
For each file:
|
|
279
|
+
1. Read the file content
|
|
280
|
+
2. Write an entity markdown file to .planning/intel/entities/
|
|
281
|
+
|
|
282
|
+
Entity filename convention (slug):
|
|
283
|
+
- Take the relative path from project root
|
|
284
|
+
- Replace / with --
|
|
285
|
+
- Replace . with -
|
|
286
|
+
- Example: src/utils/auth.js -> src--utils--auth-js.md
|
|
287
|
+
|
|
288
|
+
Entity template:
|
|
289
|
+
---
|
|
290
|
+
source: [absolute path]
|
|
291
|
+
indexed: [ISO timestamp]
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
# [filename]
|
|
295
|
+
|
|
296
|
+
## Purpose
|
|
297
|
+
|
|
298
|
+
[1-2 sentences: What does this file DO? Why does it exist? What problem does it solve?]
|
|
299
|
+
|
|
300
|
+
## Exports
|
|
301
|
+
|
|
302
|
+
| Name | Type | Purpose |
|
|
303
|
+
|------|------|---------|
|
|
304
|
+
| [export] | [function/class/const/type] | [what it does] |
|
|
305
|
+
|
|
306
|
+
## Dependencies
|
|
307
|
+
|
|
308
|
+
| Import | Purpose |
|
|
309
|
+
|--------|---------|
|
|
310
|
+
| [import source] | [why this file needs it] |
|
|
311
|
+
|
|
312
|
+
## Used By
|
|
313
|
+
|
|
314
|
+
[If this file is imported by others in the codebase, list the key consumers and why they use it. Otherwise: "Entry point" or "Utility - used across codebase"]
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
Focus on PURPOSE and semantic understanding, not just listing syntax.
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### 9.4 Verify entity generation
|
|
322
|
+
|
|
323
|
+
After all batches complete:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
ls .planning/intel/entities/*.md | wc -l
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Confirm entity count matches expected file count.
|
|
330
|
+
|
|
331
|
+
### 9.5 Report entity statistics
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
Entity Generation Complete
|
|
335
|
+
|
|
336
|
+
Entity files created: [N]
|
|
337
|
+
Location: .planning/intel/entities/
|
|
338
|
+
|
|
339
|
+
Batches processed: [N]
|
|
340
|
+
Files per batch: 10
|
|
341
|
+
|
|
342
|
+
Next: Intel hooks will continue incremental learning as you code.
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
</process>
|
|
346
|
+
|
|
347
|
+
<output>
|
|
348
|
+
- .planning/intel/index.json - File index with exports and imports
|
|
349
|
+
- .planning/intel/conventions.json - Detected naming and structural patterns
|
|
350
|
+
- .planning/intel/summary.md - Concise summary for context injection
|
|
351
|
+
- .planning/intel/entities/*.md - Semantic entity files (optional, Step 9)
|
|
352
|
+
</output>
|
|
353
|
+
|
|
354
|
+
<success_criteria>
|
|
355
|
+
- [ ] .planning/intel/ directory created
|
|
356
|
+
- [ ] All JS/TS files scanned (excluding node_modules, dist, build, .git, vendor, coverage)
|
|
357
|
+
- [ ] index.json populated with exports and imports for each file
|
|
358
|
+
- [ ] conventions.json has detected patterns (naming, directories, suffixes)
|
|
359
|
+
- [ ] summary.md is concise (< 500 tokens)
|
|
360
|
+
- [ ] Statistics reported to user
|
|
361
|
+
- [ ] Entity files generated for key files (if Step 9 executed)
|
|
362
|
+
- [ ] Entity files contain Purpose section with semantic understanding
|
|
363
|
+
</success_criteria>
|