get-shit-done-cc 1.9.1 → 1.9.2
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 +0 -46
- package/agents/gsd-executor.md +0 -14
- package/agents/gsd-planner.md +0 -22
- package/bin/install.js +0 -66
- package/commands/gsd/help.md +0 -28
- package/commands/gsd/new-project.md +22 -20
- package/commands/gsd/plan-phase.md +0 -8
- package/get-shit-done/workflows/execute-plan.md +1 -144
- package/package.json +2 -3
- package/scripts/build-hooks.js +5 -58
- package/agents/gsd-entity-generator.md +0 -237
- package/commands/gsd/analyze-codebase.md +0 -410
- package/commands/gsd/query-intel.md +0 -128
- package/get-shit-done/templates/entity.md +0 -173
- package/hooks/dist/gsd-intel-index.js +0 -97
- package/hooks/dist/gsd-intel-prune.js +0 -78
- package/hooks/dist/gsd-intel-session.js +0 -39
- package/hooks/dist/statusline.js +0 -84
|
@@ -1,237 +0,0 @@
|
|
|
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>
|
|
@@ -1,410 +0,0 @@
|
|
|
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
|
-
- Orchestrator selects files for entity generation (up to 50 based on priority)
|
|
33
|
-
- Spawns `gsd-entity-generator` subagent with file list (paths only, not contents)
|
|
34
|
-
- Subagent reads files in fresh 200k context, generates entities, writes to disk
|
|
35
|
-
- PostToolUse hook automatically syncs entities to graph.db
|
|
36
|
-
- Subagent returns statistics only (not entity contents)
|
|
37
|
-
- This preserves orchestrator context for large codebases (500+ files)
|
|
38
|
-
- Users can skip Step 9 if they only want the index (faster)
|
|
39
|
-
</context>
|
|
40
|
-
|
|
41
|
-
<process>
|
|
42
|
-
|
|
43
|
-
## Step 1: Create directory structure
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
mkdir -p .planning/intel
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Step 2: Find all indexable files
|
|
50
|
-
|
|
51
|
-
Use Glob tool with pattern: `**/*.{js,ts,jsx,tsx,mjs,cjs}`
|
|
52
|
-
|
|
53
|
-
Exclude directories (skip any path containing):
|
|
54
|
-
- node_modules
|
|
55
|
-
- dist
|
|
56
|
-
- build
|
|
57
|
-
- .git
|
|
58
|
-
- vendor
|
|
59
|
-
- coverage
|
|
60
|
-
- .next
|
|
61
|
-
- __pycache__
|
|
62
|
-
|
|
63
|
-
Filter results to remove excluded paths before processing.
|
|
64
|
-
|
|
65
|
-
## Step 3: Process each file
|
|
66
|
-
|
|
67
|
-
Initialize the index structure:
|
|
68
|
-
```javascript
|
|
69
|
-
{
|
|
70
|
-
version: 1,
|
|
71
|
-
updated: Date.now(),
|
|
72
|
-
files: {}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
For each file found:
|
|
77
|
-
|
|
78
|
-
1. Read file content using Read tool
|
|
79
|
-
|
|
80
|
-
2. Extract exports using these patterns:
|
|
81
|
-
- Named exports: `export\s*\{([^}]+)\}`
|
|
82
|
-
- Declaration exports: `export\s+(?:const|let|var|function\*?|async\s+function|class)\s+(\w+)`
|
|
83
|
-
- Default exports: `export\s+default\s+(?:function\s*\*?\s*|class\s+)?(\w+)?`
|
|
84
|
-
- CommonJS object: `module\.exports\s*=\s*\{([^}]+)\}`
|
|
85
|
-
- CommonJS single: `module\.exports\s*=\s*(\w+)\s*[;\n]`
|
|
86
|
-
- TypeScript: `export\s+(?:type|interface)\s+(\w+)`
|
|
87
|
-
|
|
88
|
-
3. Extract imports using these patterns:
|
|
89
|
-
- ES6: `import\s+(?:\{[^}]*\}|\*\s+as\s+\w+|\w+)\s+from\s+['"]([^'"]+)['"]`
|
|
90
|
-
- Side-effect: `import\s+['"]([^'"]+)['"]` (not preceded by 'from')
|
|
91
|
-
- CommonJS: `require\s*\(\s*['"]([^'"]+)['"]\s*\)`
|
|
92
|
-
|
|
93
|
-
4. Store in index:
|
|
94
|
-
```javascript
|
|
95
|
-
index.files[absolutePath] = {
|
|
96
|
-
exports: [], // Array of export names
|
|
97
|
-
imports: [], // Array of import sources
|
|
98
|
-
indexed: Date.now()
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Step 4: Detect conventions
|
|
103
|
-
|
|
104
|
-
Analyze the collected index for patterns.
|
|
105
|
-
|
|
106
|
-
**Naming conventions** (require 5+ exports, 70%+ match rate):
|
|
107
|
-
- camelCase: `^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$` or single lowercase `^[a-z][a-z0-9]*$`
|
|
108
|
-
- PascalCase: `^[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)*$` or single `^[A-Z][a-z0-9]+$`
|
|
109
|
-
- snake_case: `^[a-z][a-z0-9]*(?:_[a-z0-9]+)+$`
|
|
110
|
-
- SCREAMING_SNAKE: `^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$` or single `^[A-Z][A-Z0-9]*$`
|
|
111
|
-
- Skip 'default' when counting (it's a keyword, not naming convention)
|
|
112
|
-
|
|
113
|
-
**Directory patterns** (use lookup table):
|
|
114
|
-
```
|
|
115
|
-
components -> UI components
|
|
116
|
-
hooks -> React/custom hooks
|
|
117
|
-
utils, lib -> Utility functions
|
|
118
|
-
services -> Service layer
|
|
119
|
-
api, routes -> API endpoints
|
|
120
|
-
types -> TypeScript types
|
|
121
|
-
models -> Data models
|
|
122
|
-
tests, __tests__, test, spec -> Test files
|
|
123
|
-
controllers -> Controllers
|
|
124
|
-
middleware -> Middleware
|
|
125
|
-
config -> Configuration
|
|
126
|
-
constants -> Constants
|
|
127
|
-
pages -> Page components
|
|
128
|
-
views -> View templates
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
**Suffix patterns** (require 5+ occurrences):
|
|
132
|
-
```
|
|
133
|
-
.test.*, .spec.* -> Test files
|
|
134
|
-
.service.* -> Service layer
|
|
135
|
-
.controller.* -> Controllers
|
|
136
|
-
.model.* -> Data models
|
|
137
|
-
.util.*, .utils.* -> Utility functions
|
|
138
|
-
.helper.*, .helpers.* -> Helper functions
|
|
139
|
-
.config.* -> Configuration
|
|
140
|
-
.types.*, .type.* -> TypeScript types
|
|
141
|
-
.hook.*, .hooks.* -> React/custom hooks
|
|
142
|
-
.context.* -> React context
|
|
143
|
-
.store.* -> State store
|
|
144
|
-
.slice.* -> Redux slice
|
|
145
|
-
.reducer.* -> Redux reducer
|
|
146
|
-
.action.*, .actions.* -> Redux actions
|
|
147
|
-
.api.* -> API layer
|
|
148
|
-
.route.*, .routes.* -> Route definitions
|
|
149
|
-
.middleware.* -> Middleware
|
|
150
|
-
.schema.* -> Schema definitions
|
|
151
|
-
.mock.*, .mocks.* -> Mock data
|
|
152
|
-
.fixture.*, .fixtures.* -> Test fixtures
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Step 5: Write index.json
|
|
156
|
-
|
|
157
|
-
Write to `.planning/intel/index.json`:
|
|
158
|
-
```javascript
|
|
159
|
-
{
|
|
160
|
-
"version": 1,
|
|
161
|
-
"updated": 1737360330000,
|
|
162
|
-
"files": {
|
|
163
|
-
"/absolute/path/to/file.js": {
|
|
164
|
-
"exports": ["functionA", "ClassB"],
|
|
165
|
-
"imports": ["react", "./utils"],
|
|
166
|
-
"indexed": 1737360330000
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Step 6: Write conventions.json
|
|
173
|
-
|
|
174
|
-
Write to `.planning/intel/conventions.json`:
|
|
175
|
-
```javascript
|
|
176
|
-
{
|
|
177
|
-
"version": 1,
|
|
178
|
-
"updated": 1737360330000,
|
|
179
|
-
"naming": {
|
|
180
|
-
"exports": {
|
|
181
|
-
"dominant": "camelCase",
|
|
182
|
-
"count": 42,
|
|
183
|
-
"percentage": 85
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
"directories": {
|
|
187
|
-
"components": { "purpose": "UI components", "files": 15 },
|
|
188
|
-
"hooks": { "purpose": "React/custom hooks", "files": 8 }
|
|
189
|
-
},
|
|
190
|
-
"suffixes": {
|
|
191
|
-
".test.js": { "purpose": "Test files", "count": 12 }
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Step 7: Generate summary.md
|
|
197
|
-
|
|
198
|
-
Write to `.planning/intel/summary.md`:
|
|
199
|
-
|
|
200
|
-
```markdown
|
|
201
|
-
# Codebase Intelligence Summary
|
|
202
|
-
|
|
203
|
-
Last updated: [ISO timestamp]
|
|
204
|
-
Indexed files: [N]
|
|
205
|
-
|
|
206
|
-
## Naming Conventions
|
|
207
|
-
|
|
208
|
-
- Export naming: [case] ([percentage]% of [count] exports)
|
|
209
|
-
|
|
210
|
-
## Key Directories
|
|
211
|
-
|
|
212
|
-
- `[dir]/`: [purpose] ([N] files)
|
|
213
|
-
- ... (top 5)
|
|
214
|
-
|
|
215
|
-
## File Patterns
|
|
216
|
-
|
|
217
|
-
- `*[suffix]`: [purpose] ([count] files)
|
|
218
|
-
- ... (top 3)
|
|
219
|
-
|
|
220
|
-
Total exports: [N]
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
Target: < 500 tokens. Keep concise for context injection.
|
|
224
|
-
|
|
225
|
-
## Step 8: Report completion
|
|
226
|
-
|
|
227
|
-
Display summary statistics:
|
|
228
|
-
|
|
229
|
-
```
|
|
230
|
-
Codebase Analysis Complete
|
|
231
|
-
|
|
232
|
-
Files indexed: [N]
|
|
233
|
-
Exports found: [N]
|
|
234
|
-
Imports found: [N]
|
|
235
|
-
|
|
236
|
-
Conventions detected:
|
|
237
|
-
- Naming: [dominant case] ([percentage]%)
|
|
238
|
-
- Directories: [list]
|
|
239
|
-
- Patterns: [list]
|
|
240
|
-
|
|
241
|
-
Files created:
|
|
242
|
-
- .planning/intel/index.json
|
|
243
|
-
- .planning/intel/conventions.json
|
|
244
|
-
- .planning/intel/summary.md
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
## Step 9: Generate semantic entities (optional)
|
|
248
|
-
|
|
249
|
-
Generate entity files that capture semantic understanding of key files. These provide PURPOSE, not just syntax.
|
|
250
|
-
|
|
251
|
-
**Skip this step if:** User only wants the index, or codebase has < 10 files.
|
|
252
|
-
|
|
253
|
-
### 9.1 Create entities directory
|
|
254
|
-
|
|
255
|
-
```bash
|
|
256
|
-
mkdir -p .planning/intel/entities
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### 9.2 Select files for entity generation
|
|
260
|
-
|
|
261
|
-
Select up to 50 files based on these criteria (in priority order):
|
|
262
|
-
|
|
263
|
-
1. **High-export files:** 3+ exports (likely core modules)
|
|
264
|
-
2. **Hub files:** Referenced by 5+ other files (via imports analysis)
|
|
265
|
-
3. **Key directories:** Entry points (index.js, main.js, app.js), config files
|
|
266
|
-
4. **Structural files:** Files matching convention patterns (services, controllers, models)
|
|
267
|
-
|
|
268
|
-
From the index.json, identify candidates and limit to 50 files maximum per run.
|
|
269
|
-
|
|
270
|
-
### 9.3 Spawn entity generator subagent
|
|
271
|
-
|
|
272
|
-
Spawn `gsd-entity-generator` with the selected file list.
|
|
273
|
-
|
|
274
|
-
**Pass to subagent:**
|
|
275
|
-
- Total file count
|
|
276
|
-
- Output directory: `.planning/intel/entities/`
|
|
277
|
-
- Slug convention: `src/lib/db.ts` -> `src-lib-db` (replace / with -, remove extension, lowercase)
|
|
278
|
-
- Entity template (include full template from agent definition)
|
|
279
|
-
- List of absolute file paths (one per line)
|
|
280
|
-
|
|
281
|
-
**Task tool invocation:**
|
|
282
|
-
|
|
283
|
-
```python
|
|
284
|
-
# Build file list (one absolute path per line)
|
|
285
|
-
file_list = "\n".join(selected_files)
|
|
286
|
-
today = date.today().isoformat()
|
|
287
|
-
|
|
288
|
-
Task(
|
|
289
|
-
prompt=f"""Generate semantic entity documentation for key codebase files.
|
|
290
|
-
|
|
291
|
-
You are a GSD entity generator. Read source files and create semantic documentation that captures PURPOSE (what/why), not just syntax.
|
|
292
|
-
|
|
293
|
-
**Parameters:**
|
|
294
|
-
- Files to process: {len(selected_files)}
|
|
295
|
-
- Output directory: .planning/intel/entities/
|
|
296
|
-
- Date: {today}
|
|
297
|
-
|
|
298
|
-
**Slug convention:**
|
|
299
|
-
- Remove leading /
|
|
300
|
-
- Remove file extension
|
|
301
|
-
- Replace / and . with -
|
|
302
|
-
- Lowercase everything
|
|
303
|
-
- Example: src/lib/db.ts -> src-lib-db
|
|
304
|
-
|
|
305
|
-
**Entity template:**
|
|
306
|
-
```markdown
|
|
307
|
-
---
|
|
308
|
-
path: {{absolute_path}}
|
|
309
|
-
type: [module|component|util|config|api|hook|service|model|test]
|
|
310
|
-
updated: {today}
|
|
311
|
-
status: active
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
# {{filename}}
|
|
315
|
-
|
|
316
|
-
## Purpose
|
|
317
|
-
|
|
318
|
-
[1-3 sentences: What does this file do? Why does it exist? What problem does it solve?]
|
|
319
|
-
|
|
320
|
-
## Exports
|
|
321
|
-
|
|
322
|
-
- `functionName(params): ReturnType` - Brief description
|
|
323
|
-
- `ClassName` - What this class represents
|
|
324
|
-
|
|
325
|
-
If no exports: "None"
|
|
326
|
-
|
|
327
|
-
## Dependencies
|
|
328
|
-
|
|
329
|
-
- [[internal-file-slug]] - Why needed (for internal deps)
|
|
330
|
-
- external-package - What it provides (for npm packages)
|
|
331
|
-
|
|
332
|
-
If no dependencies: "None"
|
|
333
|
-
|
|
334
|
-
## Used By
|
|
335
|
-
|
|
336
|
-
TBD
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**Process:**
|
|
340
|
-
For each file path below:
|
|
341
|
-
1. Read file content using Read tool
|
|
342
|
-
2. Analyze purpose, exports, dependencies
|
|
343
|
-
3. Check if entity already exists (skip if so)
|
|
344
|
-
4. Write entity to .planning/intel/entities/{{slug}}.md
|
|
345
|
-
5. PostToolUse hook syncs to graph.db automatically
|
|
346
|
-
|
|
347
|
-
**Files:**
|
|
348
|
-
{file_list}
|
|
349
|
-
|
|
350
|
-
**Return format:**
|
|
351
|
-
When complete, return ONLY statistics:
|
|
352
|
-
|
|
353
|
-
## ENTITY GENERATION COMPLETE
|
|
354
|
-
|
|
355
|
-
**Files processed:** {{N}}
|
|
356
|
-
**Entities created:** {{M}}
|
|
357
|
-
**Already existed:** {{K}}
|
|
358
|
-
**Errors:** {{E}}
|
|
359
|
-
|
|
360
|
-
Entities written to: .planning/intel/entities/
|
|
361
|
-
|
|
362
|
-
Do NOT include entity contents in your response.
|
|
363
|
-
""",
|
|
364
|
-
subagent_type="gsd-entity-generator"
|
|
365
|
-
)
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
**Wait for completion:** Task() blocks until subagent finishes.
|
|
369
|
-
|
|
370
|
-
**Parse result:** Extract entities_created count from response for final report.
|
|
371
|
-
|
|
372
|
-
### 9.4 Verify entity generation
|
|
373
|
-
|
|
374
|
-
Confirm entities were written:
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
ls .planning/intel/entities/*.md 2>/dev/null | wc -l
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
### 9.5 Report entity statistics
|
|
381
|
-
|
|
382
|
-
```
|
|
383
|
-
Entity Generation Complete
|
|
384
|
-
|
|
385
|
-
Entity files created: [N] (from subagent response)
|
|
386
|
-
Location: .planning/intel/entities/
|
|
387
|
-
Graph database: Updated automatically via PostToolUse hook
|
|
388
|
-
|
|
389
|
-
Next: Intel hooks will continue incremental updates as you code.
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
</process>
|
|
393
|
-
|
|
394
|
-
<output>
|
|
395
|
-
- .planning/intel/index.json - File index with exports and imports
|
|
396
|
-
- .planning/intel/conventions.json - Detected naming and structural patterns
|
|
397
|
-
- .planning/intel/summary.md - Concise summary for context injection
|
|
398
|
-
- .planning/intel/entities/*.md - Semantic entity files (optional, Step 9)
|
|
399
|
-
</output>
|
|
400
|
-
|
|
401
|
-
<success_criteria>
|
|
402
|
-
- [ ] .planning/intel/ directory created
|
|
403
|
-
- [ ] All JS/TS files scanned (excluding node_modules, dist, build, .git, vendor, coverage)
|
|
404
|
-
- [ ] index.json populated with exports and imports for each file
|
|
405
|
-
- [ ] conventions.json has detected patterns (naming, directories, suffixes)
|
|
406
|
-
- [ ] summary.md is concise (< 500 tokens)
|
|
407
|
-
- [ ] Statistics reported to user
|
|
408
|
-
- [ ] Entity files generated for key files (if Step 9 executed)
|
|
409
|
-
- [ ] Entity files contain Purpose section with semantic understanding
|
|
410
|
-
</success_criteria>
|