@comfanion/usethis_search 4.3.0-dev.4 → 4.3.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comfanion/usethis_search",
3
- "version": "4.3.0-dev.4",
4
- "description": "OpenCode plugin: semantic search with context-efficient workspace state (v4.3: no injection, each tool returns full state inline, auto-prune history, auto-detect modes, line numbers, LSP memory leak fixed)",
3
+ "version": "4.3.1",
4
+ "description": "OpenCode plugin: semantic search with context-efficient workspace state (v4.3.1: improved tool description - chunks contain direct file content, no verification needed)",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
7
7
  "exports": {
package/tools/search.ts CHANGED
@@ -179,30 +179,52 @@ function parseFilter(filter: string): {
179
179
  }
180
180
 
181
181
  export default tool({
182
- description: `Search codebase and automatically attach relevant context to workspace.
183
-
184
- Accepts any query - semantic search, file path, or chunk ID:
185
- - "authentication logic" finds relevant code
186
- - "docs/architecture.md" attaches file
187
- - "src/auth.ts:chunk-5" attaches specific chunk
188
-
189
- Results are optimized for context - top chunks auto-attached with expanded context
190
- (related code, imports, class methods). Returns full workspace state inline.
191
- Previous search outputs are automatically pruned from history.
192
-
193
- IMPORTANT: Workspace has limited token budget. Use workspace_forget() to remove
194
- irrelevant files or old searches before adding new context.
195
-
196
- Choose index based on what you're looking for:
197
- - index: "code" search source code
198
- - index: "docs" search documentation
199
- - searchAll: true search everywhere
182
+ description: `Search the codebase semantically. Use this to find relevant code snippets, functions, or files based on meaning, not just text matching.
183
+
184
+ Available indexes:
185
+ - "code" (default) - Source code files (*.js, *.ts, *.py, *.go, etc.)
186
+ - "docs" - Documentation files (*.md, *.txt, etc.)
187
+ - "config" - Configuration files (*.yaml, *.json, etc.)
188
+ - searchAll: true - Search across all indexes
189
+
190
+ Auto-detects query type:
191
+ - Semantic: "authentication logic" vector search for relevant code
192
+ - File path: "docs/architecture.md" → attaches entire file to workspace
193
+ - Chunk ID: "src/auth.ts:chunk-5" attaches specific chunk
194
+
195
+ How workspace works:
196
+ - Top results are AUTO-ATTACHED to workspace with expanded context (class methods, imports, related code via graph)
197
+ - Workspace has a TOKEN BUDGET (~50K tokens, ~100 chunks). When full, oldest chunks are evicted
198
+ - Each search call returns full <workspace_state> with all chunk contents inline
199
+ - Only the LATEST search/workspace output is kept in chat history — older ones are auto-pruned
200
+ - Workspace persists across searches — new results ADD to existing workspace
201
+
202
+ IMPORTANT: Chunks contain DIRECT file content dumps (raw code/text from files).
203
+ - You DO NOT need to verify chunk content with grep/read tools
204
+ - Chunks are already the actual file content, not summaries or references
205
+ - Trust the chunk content as the source of truth
206
+ - Use Read tool only if you need content OUTSIDE the indexed chunks
207
+
208
+ Context management:
209
+ - BEFORE searching a new topic, use workspace_forget() to remove irrelevant old context
210
+ - Use workspace_clear() when switching to a completely different task
211
+ - The workspace is your working memory — keep it focused on the current task
212
+
213
+ Filter narrows results by path or language:
214
+ - "internal/domain/" → only files under that path
215
+ - "*.go" → only Go files
216
+ - "internal/**/*.go" → path + language combined
217
+ - "service" → files containing "service" in path
200
218
 
201
219
  Examples:
202
220
  - search({ query: "authentication logic" })
203
221
  - search({ query: "how to deploy", index: "docs" })
204
- - search({ query: "docs/prd.md" }) // attach file
205
- - search({ query: "internal/domain/", filter: "*.go" })`,
222
+ - search({ query: "tenant management", filter: "internal/domain/" })
223
+ - search({ query: "event handling", filter: "*.go" })
224
+ - search({ query: "API routes", filter: "internal/**/*.go" })
225
+ - search({ query: "metrics", searchAll: true })
226
+ - search({ query: "docs/prd.md" })
227
+ - search({ query: "src/auth.ts:chunk-5" })`,
206
228
 
207
229
  args: {
208
230
  query: tool.schema.string().describe("What to search: semantic query, file path, or chunk ID"),
@@ -20,7 +20,15 @@ import { buildWorkspaceOutput } from "./workspace-state.ts"
20
20
  // ── workspace.list ──────────────────────────────────────────────────────────
21
21
 
22
22
  export const workspace_list = tool({
23
- description: `Show full workspace state with all chunk content. Returns file listing and inline content for every attached chunk.`,
23
+ description: `Show current workspace contents all attached code chunks with full source code, line numbers, and metadata.
24
+
25
+ Use this to:
26
+ - Check what context is currently loaded after compaction or session restore
27
+ - Verify workspace contents before starting implementation
28
+ - See token budget usage (how much space is left for new searches)
29
+
30
+ Returns <workspace_state> with every chunk's full content. This is the same state appended to every search() call.
31
+ Only the LATEST workspace tool output is kept in chat — older outputs are auto-pruned.`,
24
32
 
25
33
  args: {},
26
34
 
@@ -32,21 +40,26 @@ export const workspace_list = tool({
32
40
  // ── workspace.forget ────────────────────────────────────────────────────────
33
41
 
34
42
  export const workspace_forget = tool({
35
- description: `Remove chunks from workspace context to optimize context size and focus.
43
+ description: `Remove chunks from workspace to free token budget and keep context focused on the current task.
36
44
 
37
- IMPORTANT: Regularly clean up workspace by removing irrelevant files or old search results.
38
- This keeps context focused and prevents token budget overflow.
45
+ WHEN TO USE:
46
+ - Before searching a new topic remove old irrelevant context first
47
+ - When workspace is near budget limit — free space for new results
48
+ - After finishing a subtask — remove code you no longer need
49
+ - When context has stale chunks from files you've since edited
39
50
 
40
- Auto-detects what to remove based on input:
41
- - Chunk ID: "src/auth.ts:chunk-5"
42
- - File path: "docs/architecture.md" (removes ALL chunks)
43
- - Search query: "authentication logic" (removes chunks from this search)
44
- - Age: "5" (removes chunks older than 5 minutes)
51
+ Auto-detects what to remove based on input format:
52
+ - File path: "docs/architecture.md" → removes ALL chunks from that file
53
+ - Chunk ID: "src/auth.ts:chunk-5" removes one specific chunk
54
+ - Search query: "authentication logic" removes all chunks attached by that search
55
+ - Age in minutes: "5" removes all chunks older than 5 minutes
45
56
 
46
- Examples:
47
- - workspace_forget({ what: "docs/prd.md" })
48
- - workspace_forget({ what: "5" }) // older than 5 min
49
- - workspace_forget({ what: "src/auth.ts:chunk-3" })`,
57
+ Best practices:
58
+ - Remove by file path when done with a file: workspace_forget({ what: "docs/prd.md" })
59
+ - Remove stale context by age: workspace_forget({ what: "10" })
60
+ - Remove results from previous search: workspace_forget({ what: "old query text" })
61
+
62
+ Returns updated workspace state after removal.`,
50
63
 
51
64
  args: {
52
65
  what: tool.schema.string().describe("What to forget: chunk ID, file path, search query, or age in minutes"),
@@ -110,7 +123,15 @@ Examples:
110
123
  // ── workspace.clear ─────────────────────────────────────────────────────────
111
124
 
112
125
  export const workspace_clear = tool({
113
- description: `Remove ALL chunks from workspace context. Use when switching tasks or starting fresh.`,
126
+ description: `Remove ALL chunks from workspace complete reset. Frees entire token budget.
127
+
128
+ Use when:
129
+ - Switching to a completely different task or topic
130
+ - Workspace is cluttered with irrelevant context from many searches
131
+ - Starting a fresh investigation from scratch
132
+
133
+ Prefer workspace_forget() for selective cleanup. Use workspace_clear() only for full reset.
134
+ Returns empty workspace state.`,
114
135
 
115
136
  args: {},
116
137
 
@@ -126,7 +147,15 @@ export const workspace_clear = tool({
126
147
  // ── workspace.restore ───────────────────────────────────────────────────────
127
148
 
128
149
  export const workspace_restore = tool({
129
- description: `Restore workspace from a saved session snapshot. Use after compaction or to switch context.`,
150
+ description: `Restore workspace from a previously saved session snapshot.
151
+
152
+ Use when:
153
+ - After compaction — restore the workspace context from before compaction
154
+ - Resuming work on a previous task — switch back to that context
155
+ - After workspace_clear() — if you need the old context back
156
+
157
+ Call without sessionId to list available snapshots with their chunk counts and token sizes.
158
+ Call with sessionId to restore a specific snapshot. Replaces current workspace entirely.`,
130
159
 
131
160
  args: {
132
161
  sessionId: tool.schema.string().optional().describe("Session ID to restore. If not provided, lists available snapshots."),