@comfanion/usethis_search 4.4.0 → 4.5.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/api.ts +34 -17
- package/cache/manager.ts +30 -19
- package/cli.ts +8 -5
- package/file-indexer.ts +28 -11
- package/hooks/message-before.ts +5 -5
- package/hooks/tool-substitution.ts +4 -120
- package/index.ts +17 -6
- package/package.json +3 -2
- package/tools/codeindex.ts +192 -184
- package/tools/graph.ts +265 -0
- package/tools/read-interceptor.ts +7 -3
- package/tools/search.ts +268 -190
- package/tools/workspace-state.ts +1 -2
- package/tools/workspace.ts +76 -108
- package/vectorizer/analyzers/lsp-client.ts +52 -6
- package/vectorizer/chunkers/chunker-factory.ts +6 -0
- package/vectorizer/chunkers/code-chunker.ts +73 -16
- package/vectorizer/chunkers/lsp-chunker.ts +313 -191
- package/vectorizer/graph-db.ts +6 -4
- package/vectorizer/index.ts +328 -132
- package/vectorizer/usage-tracker.ts +36 -0
- package/vectorizer.yaml +2 -2
|
@@ -46,6 +46,8 @@ export interface UsageData {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const MAX_PROVENANCE_PER_CHUNK = 20
|
|
49
|
+
const MAX_TRACKED_CHUNKS = 5000 // Cap total tracked chunks to prevent unbounded growth
|
|
50
|
+
const STALE_CHUNK_AGE_MS = 7 * 24 * 60 * 60 * 1000 // 7 days — evict chunks not used since
|
|
49
51
|
|
|
50
52
|
// ---------------------------------------------------------------------------
|
|
51
53
|
// UsageTracker
|
|
@@ -126,6 +128,40 @@ export class UsageTracker {
|
|
|
126
128
|
stats.lastUsed = now
|
|
127
129
|
}
|
|
128
130
|
this.dirty = true
|
|
131
|
+
|
|
132
|
+
// Evict stale + over-cap entries periodically (every 50 searches)
|
|
133
|
+
if (this.data.totalSearches % 50 === 0) {
|
|
134
|
+
this.evictStaleChunks()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Evict chunks not used within STALE_CHUNK_AGE_MS, then cap at MAX_TRACKED_CHUNKS.
|
|
140
|
+
* Keeps the most recently used chunks.
|
|
141
|
+
*/
|
|
142
|
+
private evictStaleChunks(): void {
|
|
143
|
+
if (!this.data) return
|
|
144
|
+
const now = Date.now()
|
|
145
|
+
const chunks = this.data.chunks
|
|
146
|
+
|
|
147
|
+
// Phase 1: remove stale (not used in 7 days)
|
|
148
|
+
for (const [id, stats] of Object.entries(chunks)) {
|
|
149
|
+
if (stats.lastUsed > 0 && now - stats.lastUsed > STALE_CHUNK_AGE_MS) {
|
|
150
|
+
delete chunks[id]
|
|
151
|
+
this.dirty = true
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Phase 2: if still over cap, evict least-used
|
|
156
|
+
const entries = Object.entries(chunks)
|
|
157
|
+
if (entries.length > MAX_TRACKED_CHUNKS) {
|
|
158
|
+
entries.sort((a, b) => a[1].lastUsed - b[1].lastUsed)
|
|
159
|
+
const toRemove = entries.length - MAX_TRACKED_CHUNKS
|
|
160
|
+
for (let i = 0; i < toRemove; i++) {
|
|
161
|
+
delete chunks[entries[i][0]]
|
|
162
|
+
}
|
|
163
|
+
this.dirty = true
|
|
164
|
+
}
|
|
129
165
|
}
|
|
130
166
|
|
|
131
167
|
// ---- FR-062: "where is chunk X used?" -----------------------------------
|
package/vectorizer.yaml
CHANGED
|
@@ -62,8 +62,8 @@ vectorizer:
|
|
|
62
62
|
max_chunks: 100 # Max number of chunks in workspace
|
|
63
63
|
attach_top_n: 10 # Top N search chunks to attach with full content
|
|
64
64
|
attach_related_per_chunk: 3 # Max graph relation chunks per main chunk
|
|
65
|
-
min_score_main: 0.
|
|
66
|
-
min_score_related: 0.
|
|
65
|
+
min_score_main: 0.5 # Min score for main chunks
|
|
66
|
+
min_score_related: 0.35 # Min score for graph relation chunks
|
|
67
67
|
persist_content: false # Save full chunk content in snapshots (debug mode)
|
|
68
68
|
auto_prune_search: true # Replace old search outputs with compact summaries
|
|
69
69
|
substitute_tool_outputs: true # Replace read() outputs when chunks in workspace
|