appydave-tools 0.84.0 → 0.85.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.
@@ -0,0 +1,344 @@
1
+ # query_apps — App File Discovery Tool
2
+
3
+ **Purpose**: A new CLI tool in appydave-tools that returns file paths from any registered application, using pre-computed named glob patterns stored in each project's `context.globs.json`.
4
+
5
+ **Status**: Planning
6
+ **Created**: 2026-04-05
7
+ **Backlog**: B041
8
+
9
+ ---
10
+
11
+ ## Problem
12
+
13
+ When an LLM agent (or David) needs files from a project, they currently have to:
14
+ 1. Know the project's directory structure
15
+ 2. Manually construct glob patterns
16
+ 3. Hope the patterns are still valid as the project evolves
17
+
18
+ There's no way to say "give me the backend code from FliHub" or "get me all docs from AngelEye" without prior knowledge of each project's layout. `query_brain` solves this for brains, `query_omi` solves it for OMI transcripts — but there's nothing for applications.
19
+
20
+ ---
21
+
22
+ ## Design
23
+
24
+ ### Architecture — Same Pattern as BrainQuery and OmiQuery
25
+
26
+ ```
27
+ bin/query_apps.rb CLI entry point
28
+ lib/appydave/tools/
29
+ app_context/
30
+ app_finder.rb Core query engine (like BrainQuery, OmiQuery)
31
+ options.rb CLI option parsing
32
+ spec/appydave/tools/
33
+ app_context/
34
+ app_query_spec.rb Unit tests
35
+ options_spec.rb
36
+ ```
37
+
38
+ ### Data Flow
39
+
40
+ ```
41
+ locations.json → Find app path by key/alias/fuzzy match
42
+
43
+ context.globs.json → Read named glob patterns from project root
44
+
45
+ Glob expansion → Resolve patterns against actual filesystem
46
+
47
+ File paths (stdout) → One per line, pipe to llm_context
48
+ ```
49
+
50
+ ### The Sidecar File — `context.globs.json`
51
+
52
+ Generated by the `system-context` skill alongside `CONTEXT.md`. Lives in each project root.
53
+
54
+ ```json
55
+ {
56
+ "generated": "2026-04-05",
57
+ "generator": "system-context",
58
+ "project": "flihub",
59
+ "pattern": "rvets",
60
+ "globs": {
61
+ "docs": ["docs/**/*.md", "BACKLOG.md"],
62
+ "types": ["shared/**/*.ts"],
63
+ "config": ["server/config.json", "*.config.*", ".env.example"],
64
+ "server": ["server/src/**/*.ts"],
65
+ "client": ["client/src/**/*.tsx"],
66
+ "services": ["server/src/services/**/*.ts"],
67
+ "routes": ["server/src/routes/**/*.ts"],
68
+ "components": ["client/src/components/**/*.tsx"],
69
+ "views": ["client/src/views/**/*.tsx"],
70
+ "tests": ["**/*.test.ts", "**/*.spec.ts"],
71
+ "styles": ["**/*.css"],
72
+ "mockups": [".mochaccino/designs/**/*.html"],
73
+ "planning": ["docs/prd/**/*.md", "docs/planning/**/*.md"],
74
+ "context": ["CLAUDE.md", "CONTEXT.md", "STEERING.md"]
75
+ },
76
+ "aliases": {
77
+ "backend": ["services", "routes"],
78
+ "frontend": ["components", "views", "styles"],
79
+ "api": ["routes", "types"],
80
+ "data-layer": ["types", "schema"],
81
+ "react": ["components", "views"],
82
+ "ui": ["components", "views", "styles"]
83
+ },
84
+ "composites": {
85
+ "understand": ["context", "docs", "types", "config"],
86
+ "codebase": ["services", "routes", "components", "views"],
87
+ "all-code": ["server", "client"],
88
+ "full": ["*"]
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Key design choices:**
94
+ - **Globs, not file lists** — durable as files are added/removed; only stale if project structure changes fundamentally
95
+ - **Named categories** — "docs", "services", "types" are human-friendly handles
96
+ - **Aliases** — "backend" → services + routes. Handles vague user intent
97
+ - **Composites** — "understand" → context + docs + types + config. Pre-built bundles for common queries
98
+ - **Pattern type** — "rvets", "nextjs", "ruby-gem", "python" enables cross-app queries by architecture
99
+
100
+ ### App Resolution — 4-Tier (Same as BrainQuery)
101
+
102
+ ```
103
+ 1. Exact key match: "flihub" → locations.json key
104
+ 2. Alias match: "hub" → locations.json aliases (future)
105
+ 3. Jump alias match: "jfli-hub" → locations.json jump field
106
+ 4. Substring/fuzzy: "fli" → partial match on key or description
107
+ ```
108
+
109
+ Source: `~/.config/appydave/locations.json` (the `context` field tells us if `context.globs.json` exists).
110
+
111
+ ### Glob Resolution — 3-Tier
112
+
113
+ When the user asks for `--glob backend`:
114
+
115
+ ```
116
+ 1. Direct glob name: "services" → globs.services
117
+ 2. Alias match: "backend" → aliases.backend → [services, routes]
118
+ 3. Composite match: "understand" → composites.understand → [context, docs, types, config]
119
+ 4. Fuzzy fallback: "back" → closest match to "backend"
120
+ ```
121
+
122
+ ### CLI Interface
123
+
124
+ ```bash
125
+ # Basic: get docs from FliHub
126
+ query_apps flihub --glob docs
127
+
128
+ # Alias: "backend" resolves to services + routes
129
+ query_apps flihub --glob backend
130
+
131
+ # Composite: "understand" = context + docs + types + config
132
+ query_apps angeleye --glob understand
133
+
134
+ # Multiple globs (comma-separated)
135
+ query_apps flihub --glob docs,types,config
136
+
137
+ # Cross-app: all RVETS apps, backend code
138
+ query_apps --pattern rvets --glob backend
139
+
140
+ # List available globs for a project
141
+ query_apps flihub --list
142
+
143
+ # List all registered apps that have context.globs.json
144
+ query_apps --list-apps
145
+
146
+ # Meta output (JSON with file counts, not paths)
147
+ query_apps flihub --glob backend --meta
148
+
149
+ # Pipe to llm_context (the whole point)
150
+ query_apps flihub --glob understand | llm_context --stdin -f content
151
+ query_apps angeleye --glob services | llm_context --stdin -f tree
152
+ ```
153
+
154
+ ### Output
155
+
156
+ Default: one file path per line (same as `query_brain` and `query_omi`).
157
+
158
+ ```
159
+ /Users/davidcruwys/dev/ad/flivideo/flihub/server/src/services/watcher.service.ts
160
+ /Users/davidcruwys/dev/ad/flivideo/flihub/server/src/services/naming.service.ts
161
+ /Users/davidcruwys/dev/ad/flivideo/flihub/server/src/routes/index.ts
162
+ ```
163
+
164
+ With `--meta`:
165
+ ```json
166
+ {
167
+ "app": "flihub",
168
+ "path": "/Users/davidcruwys/dev/ad/flivideo/flihub",
169
+ "pattern": "rvets",
170
+ "matched_globs": ["services", "routes"],
171
+ "resolved_from": "backend (alias)",
172
+ "file_count": 14
173
+ }
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Standard Vocabulary
179
+
180
+ These category names are conventions enforced by `system-context` when generating `context.globs.json`. Projects can add custom categories beyond these.
181
+
182
+ | Category | Aliases | Description |
183
+ |----------|---------|-------------|
184
+ | `docs` | documentation, planning, specs | Markdown documentation |
185
+ | `types` | models, schema, data-layer | Type definitions / data shapes |
186
+ | `config` | settings, configuration | Config files |
187
+ | `services` | backend, business-logic | Server-side logic |
188
+ | `routes` | api, endpoints | API routes |
189
+ | `components` | ui, frontend, react | UI components |
190
+ | `views` | pages, screens | Page-level views |
191
+ | `tests` | specs, test | Test files |
192
+ | `styles` | css, styling | Stylesheets |
193
+ | `context` | meta, about | CLAUDE.md, CONTEXT.md, STEERING.md |
194
+
195
+ Standard composites:
196
+
197
+ | Composite | Expands to |
198
+ |-----------|-----------|
199
+ | `understand` | context + docs + types + config |
200
+ | `codebase` | services + routes + components + views |
201
+ | `full` | all glob categories |
202
+
203
+ ### Pattern-Specific Categories
204
+
205
+ These only appear in projects with the matching `pattern` type:
206
+
207
+ | Pattern | Extra Categories |
208
+ |---------|-----------------|
209
+ | `rvets` | mockups (`.mochaccino/`), shared |
210
+ | `nextjs` | actions, validation, auth, middleware, decisions (KDD) |
211
+ | `ruby-gem` | lib, bin, gemspec |
212
+ | `python` | src, requirements |
213
+ | `bmad` | bmad-config, bmad-output, workflows |
214
+
215
+ ---
216
+
217
+ ## System-Context Integration
218
+
219
+ The `system-context` skill (in appydave-plugins) needs a small addition:
220
+
221
+ 1. **After writing CONTEXT.md**, also generate `context.globs.json`
222
+ 2. **Detect project pattern** (rvets, nextjs, ruby-gem, python) from package.json / Gemfile / pyproject.toml
223
+ 3. **Scan the directory** and map discovered paths to standard category names
224
+ 4. **Add project-specific categories** for non-standard directories (e.g., `.mochaccino/` in RVETS apps)
225
+ 5. **Generate aliases and composites** using the standard vocabulary plus any project-specific additions
226
+
227
+ The `context.globs.json` file should be listed in CONTEXT.md's `sources:` frontmatter.
228
+
229
+ ---
230
+
231
+ ## Locations.json Integration
232
+
233
+ The `context` field in `locations.json` already points to `CONTEXT.md`. We can extend this:
234
+
235
+ ```json
236
+ {
237
+ "key": "flihub",
238
+ "path": "/Users/davidcruwys/dev/ad/flivideo/flihub",
239
+ "context": "CONTEXT.md",
240
+ "context_globs": "context.globs.json",
241
+ ...
242
+ }
243
+ ```
244
+
245
+ Or, simpler: `query_apps` can just check for `context.globs.json` in the same directory as `CONTEXT.md` without needing a separate field.
246
+
247
+ ---
248
+
249
+ ## Provenance Chain
250
+
251
+ ```
252
+ system-context skill (generates)
253
+
254
+ context.globs.json (sidecar in each project)
255
+
256
+ query_apps CLI tool (reads locations.json + globs file, resolves names, expands globs)
257
+
258
+ file paths on stdout
259
+
260
+ llm_context CLI tool (assembles content from file paths)
261
+
262
+ LLM-ready payload
263
+ ```
264
+
265
+ The full query ecosystem:
266
+
267
+ ```
268
+ query_brain → brain files ─┐
269
+ query_omi → OMI transcripts ├─→ llm_context → LLM payload
270
+ query_apps → app files ─┘
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Skill Wrappers (Thin Shims)
276
+
277
+ Each query tool should have a corresponding skill in `appydave-plugins/appydave/skills/`:
278
+
279
+ | CLI Tool | Skill | Status |
280
+ |----------|-------|--------|
281
+ | `query_omi` | `omi-query` | Exists, correct pattern |
282
+ | `query_brain` | (none) | **Needs creating** — thin shim to `query_brain` |
283
+ | `query_apps` | (none) | **Create alongside CLI tool** |
284
+ | `llm_context` | (none) | **Needs creating** — downstream assembler, not a query |
285
+
286
+ The `focus` skill's `resolve_brain.py` should eventually be replaced by a call to `query_brain --find --meta` — the Ruby tool already has the same resolution logic with better test coverage.
287
+
288
+ ---
289
+
290
+ ## Implementation Phases
291
+
292
+ ### Phase 1: context.globs.json Generation
293
+ - Update `system-context` skill to generate `context.globs.json` alongside `CONTEXT.md`
294
+ - Generate for the 12 projects that already have `CONTEXT.md`
295
+ - Validate standard vocabulary coverage
296
+
297
+ ### Phase 2: query_apps CLI Tool
298
+ - `AppQuery` class following BrainQuery/OmiQuery pattern
299
+ - 4-tier app resolution from locations.json
300
+ - 3-tier glob resolution (direct → alias → composite → fuzzy)
301
+ - `find` (file paths) and `find_meta` (structured JSON) methods
302
+ - CLI entry point at `bin/query_apps.rb`
303
+ - Unit tests with fixtures
304
+
305
+ ### Phase 3: Skill Wrappers
306
+ - `app-query` skill in appydave-plugins (thin shim to `query_apps`)
307
+ - `brain-query` skill (thin shim to `query_brain`)
308
+ - `llm-context` skill (thin shim to `llm_context`)
309
+
310
+ ### Phase 4: Cross-App Queries
311
+ - `--pattern rvets` to query across all apps of a pattern type
312
+ - Aggregate results from multiple `context.globs.json` files
313
+
314
+ ---
315
+
316
+ ## Related Files
317
+
318
+ | What | Where |
319
+ |------|-------|
320
+ | BrainQuery (reference impl) | `lib/appydave/tools/brain_context/brain_finder.rb` |
321
+ | OmiQuery (reference impl) | `lib/appydave/tools/brain_context/omi_finder.rb` |
322
+ | FileCollector (downstream) | `lib/appydave/tools/llm_context/file_collector.rb` |
323
+ | Locations registry | `~/.config/appydave/locations.json` |
324
+ | System-context skill | `appydave-plugins/appydave/skills/system-context/SKILL.md` |
325
+ | omi-query skill (pattern) | `appydave-plugins/appydave/skills/omi-query/SKILL.md` |
326
+ | Brain query tests | `spec/appydave/tools/brain_context/brain_query_spec.rb` |
327
+ | OMI query tests | `spec/appydave/tools/brain_context/omi_query_spec.rb` |
328
+
329
+ ---
330
+
331
+ ## Open Questions
332
+
333
+ 1. Should `context.globs.json` live at project root or in `.claude/`?
334
+ - Root is simpler and visible; `.claude/` keeps it with other agent artifacts
335
+ - Leaning root (next to `CONTEXT.md`)
336
+
337
+ 2. Should fuzzy matching use Levenshtein distance or simpler substring?
338
+ - BrainQuery uses substring — probably sufficient here too
339
+
340
+ 3. Should `query_apps` live in `brain_context/` module or a new `app_context/` module?
341
+ - New module — apps are not brains, even though the query pattern is the same
342
+
343
+ 4. Should the `context` field in locations.json be extended to `context_globs`, or should query_apps just look for the file conventionally?
344
+ - Leaning conventional (just check for `context.globs.json` in the project dir)