nogrep 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/package.json +1 -1
- package/docs/ARCHITECTURE.md +0 -239
- package/docs/CLAUDE.md +0 -161
- package/docs/CONVENTIONS.md +0 -162
- package/docs/SPEC.md +0 -803
- package/docs/TASKS.md +0 -216
package/docs/TASKS.md
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# nogrep — Implementation Tasks
|
|
2
|
-
|
|
3
|
-
> Work through these tasks in order. Each task is independently testable before moving on.
|
|
4
|
-
> Read docs/CLAUDE.md, docs/SPEC.md, docs/ARCHITECTURE.md, and docs/CONVENTIONS.md before starting.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Task 1 — Project Scaffold
|
|
9
|
-
|
|
10
|
-
**Goal:** Buildable TypeScript project with plugin manifest.
|
|
11
|
-
|
|
12
|
-
- [x] Create `package.json` with dependencies: `glob`, `gray-matter`, `js-yaml`
|
|
13
|
-
- [x] Create `package.json` devDependencies: `typescript`, `tsup`, `vitest`, `@types/node`
|
|
14
|
-
- [x] Create `tsconfig.json` (see docs/CONVENTIONS.md)
|
|
15
|
-
- [x] Create `tsup.config.ts` — builds `scripts/` → `dist/`, ESM, declaration files
|
|
16
|
-
- [x] Create `scripts/types.ts` — all types from docs/ARCHITECTURE.md key types section
|
|
17
|
-
- [x] Create `plugin.json` — CC plugin manifest with hook declarations
|
|
18
|
-
- [x] Verify: `npm run build` compiles successfully
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Task 2 — Settings
|
|
23
|
-
|
|
24
|
-
**Goal:** Read/write nogrep settings from `.claude/settings.json` and `.claude/settings.local.json`.
|
|
25
|
-
|
|
26
|
-
- [x] Create `scripts/settings.ts`
|
|
27
|
-
- `readSettings(projectRoot)` — reads both files, local takes precedence over shared
|
|
28
|
-
- `writeSettings(projectRoot, settings, local?)` — writes to shared or local file
|
|
29
|
-
- Creates `.claude/` dir if it doesn't exist
|
|
30
|
-
- CLI interface: `node settings.js --set enabled=true [--local]` / `node settings.js --get`
|
|
31
|
-
- [x] Create `commands/on.md` slash command
|
|
32
|
-
- Runs `node "${CLAUDE_PLUGIN_ROOT}/dist/settings.js" --set enabled=true`
|
|
33
|
-
- Checks if `.nogrep/_index.json` exists
|
|
34
|
-
- If missing: suggests running `/nogrep:init`
|
|
35
|
-
- [x] Create `commands/off.md` slash command
|
|
36
|
-
- Runs `node "${CLAUDE_PLUGIN_ROOT}/dist/settings.js" --set enabled=false`
|
|
37
|
-
- [x] Write `tests/settings.test.ts` — test merge logic, local precedence, file creation
|
|
38
|
-
- [x] Verify: `/nogrep:on` and `/nogrep:off` work in CC
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Task 3 — Phase 1: Universal Signals
|
|
43
|
-
|
|
44
|
-
**Goal:** Collect language-agnostic signals from any project directory.
|
|
45
|
-
|
|
46
|
-
- [x] Create `scripts/signals.ts`
|
|
47
|
-
- `collectSignals(root, options)` → `SignalResult`
|
|
48
|
-
- Walk directory tree (depth 4, skip: node_modules, dist, build, .git, coverage)
|
|
49
|
-
- Group files by extension → `extensionMap`
|
|
50
|
-
- Find dependency manifests: `package.json`, `requirements.txt`, `pom.xml`, `go.mod`, `Podfile`, `Cargo.toml`, `pubspec.yaml`, `composer.json`
|
|
51
|
-
- Find entry points: files named `main.*`, `index.*`, `app.*`, `server.*` at root or src/ level
|
|
52
|
-
- Run `git log --stat --oneline -50` → parse top 20 most changed files
|
|
53
|
-
- Find top 20 largest files (excluding node_modules etc)
|
|
54
|
-
- Find `.env*` files and `config/` directories
|
|
55
|
-
- Find test files matching `*.test.*`, `*.spec.*`, `*_test.*`, `test_*.py`
|
|
56
|
-
- CLI interface: `node signals.js [--root <path>] [--exclude <globs>]` → JSON stdout
|
|
57
|
-
- [x] Create `tests/fixtures/nestjs-project/` — minimal NestJS project (5-10 files)
|
|
58
|
-
- [x] Create `tests/fixtures/django-project/` — minimal Django project
|
|
59
|
-
- [x] Create `tests/fixtures/react-project/` — minimal React project
|
|
60
|
-
- [x] Write `tests/signals.test.ts` — run against all 3 fixtures, assert signal shape
|
|
61
|
-
- [x] Verify: signals correctly identifies NestJS vs Django vs React
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Task 4 — Source Trimming
|
|
66
|
-
|
|
67
|
-
**Goal:** Reduce source files to signatures only, language-agnostic.
|
|
68
|
-
|
|
69
|
-
- [x] Create `scripts/trim.ts`
|
|
70
|
-
- `trimCluster(paths: string[], projectRoot: string)` → `string`
|
|
71
|
-
- For each file in the cluster's src_paths:
|
|
72
|
-
- Read file content
|
|
73
|
-
- Remove function/method bodies (keep signature line + opening brace only)
|
|
74
|
-
- Keep: file header comments, imports, class/interface declarations, decorators/annotations, exported symbols, type definitions
|
|
75
|
-
- Strip: function bodies, private method bodies, inline HTML/template strings
|
|
76
|
-
- Max 300 lines total across all files — truncate least important files first
|
|
77
|
-
- Strategy: regex-based (simple, universal — not perfect but good enough)
|
|
78
|
-
- CLI interface: `node trim.js <path1> <path2> ...` → trimmed output to stdout
|
|
79
|
-
- [x] Write `tests/trim.test.ts` — test against TypeScript, Python, Java snippet fixtures
|
|
80
|
-
- [x] Verify: trimmed output is ~30-50% of original size, signatures intact
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Task 5 — Writers
|
|
85
|
-
|
|
86
|
-
**Goal:** Write all `.nogrep/` files from structured input.
|
|
87
|
-
|
|
88
|
-
- [x] Create `scripts/write.ts`
|
|
89
|
-
- Accepts JSON via stdin or `--input <file>` with NodeResult[] + StackResult
|
|
90
|
-
- `writeContextNodes(nodes, outputDir)` — generates markdown with frontmatter (YAML)
|
|
91
|
-
- Creates subdirectories: `domains/`, `architecture/`, `flows/`, `entities/`
|
|
92
|
-
- Appends empty `## Manual Notes` section at end
|
|
93
|
-
- Existing files: extract Manual Notes, regenerate, re-inject Manual Notes
|
|
94
|
-
- `buildIndex(nodes, stack)` → writes `_index.json`
|
|
95
|
-
- Builds reverse maps: tags → [files], keywords → [files], paths → entry
|
|
96
|
-
- Populates `inverse_relations` by scanning all `relates_to` across nodes
|
|
97
|
-
- `buildRegistry(nodes)` → writes `_registry.json`
|
|
98
|
-
- `patchClaudeMd(projectRoot)` — appends navigation instructions
|
|
99
|
-
- Checks for `<!-- nogrep -->` marker to avoid duplicate patching
|
|
100
|
-
- [x] Create `templates/claude-md-patch.md`:
|
|
101
|
-
```markdown
|
|
102
|
-
<!-- nogrep -->
|
|
103
|
-
## Code Navigation
|
|
104
|
-
|
|
105
|
-
This project uses [nogrep](https://github.com/techtulp/nogrep).
|
|
106
|
-
Context files in `.nogrep/` are a navigable index of this codebase.
|
|
107
|
-
When you see nogrep results injected into your context, trust them —
|
|
108
|
-
read those files before exploring source.
|
|
109
|
-
<!-- /nogrep -->
|
|
110
|
-
```
|
|
111
|
-
- [x] Write `tests/writer.test.ts` — write to temp dirs, verify file contents and frontmatter
|
|
112
|
-
- [x] Verify: running writers on fixture data produces valid markdown with parseable frontmatter
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## Task 6 — Init Slash Command
|
|
117
|
-
|
|
118
|
-
**Goal:** `/nogrep:init` orchestrates the full pipeline with Claude doing the AI work.
|
|
119
|
-
|
|
120
|
-
- [x] Create `commands/init.md`
|
|
121
|
-
- Step 1: Run `node "${CLAUDE_PLUGIN_ROOT}/dist/signals.js" --root .` → collect signals
|
|
122
|
-
- Step 2: Embed Phase 2 prompt — Claude analyzes signals, produces StackResult JSON
|
|
123
|
-
- Step 3: For each domain cluster, embed Phase 3 prompt — Claude reads trimmed source (via `node "${CLAUDE_PLUGIN_ROOT}/dist/trim.js"`), produces NodeResult JSON
|
|
124
|
-
- Step 4: Claude detects flows (clusters touching 3+ domains or named with flow keywords)
|
|
125
|
-
- Step 5: Run `node "${CLAUDE_PLUGIN_ROOT}/dist/write.js"` with all results piped as JSON stdin
|
|
126
|
-
- Step 6: Run `node "${CLAUDE_PLUGIN_ROOT}/dist/settings.js" --set enabled=true`
|
|
127
|
-
- See docs/SPEC.md Section 13 for prompt templates
|
|
128
|
-
- [x] Test: run `/nogrep:init` in CC on a fixture project, inspect `.nogrep/` output
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Task 7 — Query System
|
|
133
|
-
|
|
134
|
-
**Goal:** Fast index lookup without AI.
|
|
135
|
-
|
|
136
|
-
- [x] Create `scripts/query.ts`
|
|
137
|
-
- `extractTerms(question, taxonomy)` → `{ tags, keywords }`
|
|
138
|
-
- Split question into words, lowercase
|
|
139
|
-
- Match against taxonomy domain/tech values → tags
|
|
140
|
-
- Match against any word → keywords (pass through)
|
|
141
|
-
- No AI — pure string matching
|
|
142
|
-
- `resolve(terms, index)` → `RankedResult[]`
|
|
143
|
-
- Union lookup: find all nodes matching any tag or keyword
|
|
144
|
-
- Score: +2 per tag match, +1 per keyword match
|
|
145
|
-
- Sort by score descending, return top N (default 5)
|
|
146
|
-
- CLI interface: `node query.js --tags <tags> | --keywords <words> | --question <text> [--format paths|json|summary] [--limit N]`
|
|
147
|
-
- Throws `NogrepError('NO_INDEX')` if `_index.json` missing
|
|
148
|
-
- [x] Create `commands/query.md` slash command — runs `node "${CLAUDE_PLUGIN_ROOT}/dist/query.js" --question "$ARGUMENTS"`
|
|
149
|
-
- [x] Write `tests/query.test.ts` — test extraction and resolution
|
|
150
|
-
- [ ] Verify: `node dist/query.js --question "how does stripe work"` returns billing context file
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## Task 8 — Validator + Update + Status
|
|
155
|
-
|
|
156
|
-
**Goal:** Staleness detection and incremental updates.
|
|
157
|
-
|
|
158
|
-
- [x] Create `scripts/validate.ts`
|
|
159
|
-
- `checkFreshness(node, projectRoot)` → `StaleResult`
|
|
160
|
-
- Glob all files matching node's `src_paths`
|
|
161
|
-
- Compute SHA256 of all file contents concatenated
|
|
162
|
-
- Compare to `last_synced.src_hash` in frontmatter
|
|
163
|
-
- CLI interface: `node validate.js [--format text|json]` → staleness report
|
|
164
|
-
- [x] Create `commands/update.md` slash command
|
|
165
|
-
- Guides Claude through: git diff → map to affected nodes → re-analyze → write updates
|
|
166
|
-
- Preserves `## Manual Notes` section
|
|
167
|
-
- [x] Create `commands/status.md` slash command
|
|
168
|
-
- Runs `node "${CLAUDE_PLUGIN_ROOT}/dist/validate.js"` and shows node counts, freshness summary
|
|
169
|
-
- [x] Write `tests/validate.test.ts` — test staleness detection
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## Task 9 — Hooks
|
|
174
|
-
|
|
175
|
-
**Goal:** Automatic context injection via CC hooks.
|
|
176
|
-
|
|
177
|
-
- [x] Create `hooks/pre-tool-use.sh` (see docs/SPEC.md Section 10)
|
|
178
|
-
- Intercepts grep/find/rg/ag commands
|
|
179
|
-
- Calls `node "${CLAUDE_PLUGIN_ROOT}/dist/query.js"` with extracted keywords
|
|
180
|
-
- Injects results as `additionalContext`
|
|
181
|
-
- [x] Create `hooks/session-start.sh` (see docs/SPEC.md Section 10)
|
|
182
|
-
- Checks index existence and freshness on session start
|
|
183
|
-
- Calls `node "${CLAUDE_PLUGIN_ROOT}/dist/validate.js"`
|
|
184
|
-
- [x] Create `hooks/prompt-submit.sh` (see docs/SPEC.md Section 10)
|
|
185
|
-
- Injects relevant context for code navigation prompts
|
|
186
|
-
- Calls `node "${CLAUDE_PLUGIN_ROOT}/dist/query.js"`
|
|
187
|
-
- [x] Make all `.sh` scripts executable (`chmod +x`)
|
|
188
|
-
- [ ] Test: install plugin locally in CC, verify hooks fire
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Task 10 — README + Distribution
|
|
193
|
-
|
|
194
|
-
**Goal:** Ready for npm publish as CC plugin.
|
|
195
|
-
|
|
196
|
-
- [x] Write `README.md`:
|
|
197
|
-
- What it does (one paragraph)
|
|
198
|
-
- Install as CC plugin
|
|
199
|
-
- Quick start (3 steps)
|
|
200
|
-
- How it works (brief pipeline overview)
|
|
201
|
-
- Available commands
|
|
202
|
-
- FAQ
|
|
203
|
-
- [x] Add `files` field to `package.json` — ship `dist/`, `commands/`, `hooks/`, `templates/`, `plugin.json`
|
|
204
|
-
- [x] Verify `npm pack` produces correct bundle
|
|
205
|
-
- [x] Add `prepublish` script: `npm run build && npm test`
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Definition of Done
|
|
210
|
-
|
|
211
|
-
All tasks complete when:
|
|
212
|
-
- `/nogrep:init` runs successfully in CC on a real project and produces valid `.nogrep/`
|
|
213
|
-
- `/nogrep:query` returns correct context files
|
|
214
|
-
- CC hooks intercept grep commands and inject nogrep context
|
|
215
|
-
- All unit tests pass: `npm test`
|
|
216
|
-
- README is clear enough for a stranger to get started in 2 minutes
|