codebasesearch 0.1.25 → 0.1.26

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,6 +1,6 @@
1
1
  {
2
2
  "name": "codebasesearch",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Ultra-simple code search tool with Jina embeddings, LanceDB, and MCP protocol support",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,31 +38,30 @@ function tokenizeToFrequency(text, index, chunkIdx) {
38
38
  const camelTokens = word.match(/[A-Z]?[a-z]+|[A-Z]+(?=[A-Z][a-z]|\d|\W|$)|[0-9]+/g);
39
39
  if (camelTokens) {
40
40
  for (const t of camelTokens) {
41
- if (t.length > 1) addToken(t.toLowerCase(), frequency, index, chunkIdx);
41
+ if (t.length > 1) frequency.set(t.toLowerCase(), (frequency.get(t.toLowerCase()) || 0) + 1);
42
42
  }
43
43
  }
44
44
  }
45
45
 
46
46
  const cleaned = word.replace(/[^\w]/g, '').toLowerCase();
47
47
  if (cleaned.length > 1) {
48
- addToken(cleaned, frequency, index, chunkIdx);
48
+ frequency.set(cleaned, (frequency.get(cleaned) || 0) + 1);
49
49
  if (word.includes('-') || word.includes('_') || word.includes('.')) {
50
50
  for (const part of word.split(/[-_.]/)) {
51
51
  const partCleaned = part.replace(/[^\w]/g, '').toLowerCase();
52
- if (partCleaned.length > 1 && partCleaned !== cleaned) addToken(partCleaned, frequency, index, chunkIdx);
52
+ if (partCleaned.length > 1 && partCleaned !== cleaned) frequency.set(partCleaned, (frequency.get(partCleaned) || 0) + 1);
53
53
  }
54
54
  }
55
55
  }
56
56
  }
57
57
 
58
- return frequency;
59
- }
58
+ for (const token of frequency.keys()) {
59
+ let docSet = index.get(token);
60
+ if (!docSet) { docSet = new Set(); index.set(token, docSet); }
61
+ docSet.add(chunkIdx);
62
+ }
60
63
 
61
- function addToken(token, frequency, index, chunkIdx) {
62
- frequency.set(token, (frequency.get(token) || 0) + 1);
63
- let docSet = index.get(token);
64
- if (!docSet) { docSet = new Set(); index.set(token, docSet); }
65
- docSet.add(chunkIdx);
64
+ return frequency;
66
65
  }
67
66
 
68
67
  export function searchText(query, chunks, indexData) {
package/.prd DELETED
@@ -1 +0,0 @@
1
- {}
@@ -1,248 +0,0 @@
1
- Performance profiling across codebases...
2
- This will take several minutes.
3
-
4
-
5
- ▶ Profiling xbot...
6
- Scanned: 7 chunks in 8ms
7
- Vector store initialized
8
- Loading embeddings model (this may take a moment on first run)...
9
- dtype not specified for "model". Using the default dtype (fp32) for this device (cpu).
10
- Indexed 7 chunks
11
- Embeddings: 7/7 chunks in 1530ms
12
- Searching for: "function class method"
13
- Text search: 7 results in 88ms
14
-
15
- ▶ Profiling fsbrowse...
16
- Scanned: 6 chunks in 7ms
17
- Vector store initialized
18
- Indexed 6 chunks
19
- Embeddings: 6/6 chunks in 1126ms
20
- Searching for: "function class method"
21
- Text search: 6 results in 26ms
22
-
23
- ▶ Profiling agentauth...
24
- Scanned: 11 chunks in 2ms
25
- Vector store initialized
26
- Indexed 11 chunks
27
- Embeddings: 11/11 chunks in 1957ms
28
- Searching for: "function class method"
29
- Text search: 10 results in 40ms
30
-
31
- ▶ Profiling webtalk...
32
- Scanned: 40 chunks in 28ms
33
- Vector store initialized
34
- Indexed 32 chunks
35
- Indexed 8 chunks
36
- Embeddings: 40/40 chunks in 6680ms
37
- Searching for: "function class method"
38
- Text search: 10 results in 80ms
39
-
40
- ▶ Profiling plugforge...
41
- Scanned: 66 chunks in 11ms
42
- Vector store initialized
43
- Indexed 32 chunks
44
- Indexed 32 chunks
45
- Indexed 2 chunks
46
- Embeddings: 66/66 chunks in 10923ms
47
- Searching for: "function class method"
48
- Text search: 10 results in 83ms
49
-
50
- ▶ Profiling agentgui...
51
- Scanned: 83 chunks in 10ms
52
- Vector store initialized
53
- Indexed 32 chunks
54
- Indexed 32 chunks
55
- Indexed 19 chunks
56
- Embeddings: 83/83 chunks in 16535ms
57
- Searching for: "function class method"
58
- Text search: 10 results in 146ms
59
-
60
- ▶ Profiling seqos...
61
- Scanned: 76 chunks in 9ms
62
- Vector store initialized
63
- Indexed 32 chunks
64
- Indexed 32 chunks
65
- Indexed 12 chunks
66
- Embeddings: 76/76 chunks in 13730ms
67
- Searching for: "function class method"
68
- Text search: 10 results in 113ms
69
-
70
- ▶ Profiling docmcp...
71
- Scanned: 74 chunks in 53ms
72
- Vector store initialized
73
- Indexed 32 chunks
74
- Indexed 32 chunks
75
- Indexed 10 chunks
76
- Embeddings: 74/74 chunks in 13526ms
77
- Searching for: "function class method"
78
- Text search: 10 results in 95ms
79
-
80
- ▶ Profiling zellous...
81
- Scanned: 77 chunks in 54ms
82
- Vector store initialized
83
- Indexed 32 chunks
84
- Indexed 32 chunks
85
- Indexed 13 chunks
86
- Embeddings: 77/77 chunks in 13463ms
87
- Searching for: "function class method"
88
- Text search: 10 results in 120ms
89
-
90
- ▶ Profiling teatree...
91
- Scanned: 93 chunks in 10ms
92
- Vector store initialized
93
- Indexed 32 chunks
94
- Indexed 32 chunks
95
- Indexed 29 chunks
96
- Embeddings: 93/93 chunks in 15931ms
97
- Searching for: "function class method"
98
- Text search: 10 results in 82ms
99
-
100
- ▶ Profiling moonlanding...
101
- Scanned: 323 chunks in 35ms
102
- Vector store initialized
103
- Indexed 32 chunks
104
- Indexed 32 chunks
105
- Indexed 32 chunks
106
- Indexed 32 chunks
107
- Indexed 32 chunks
108
- Indexed 32 chunks
109
- Indexed 32 chunks
110
- Indexed 32 chunks
111
- Indexed 32 chunks
112
- Indexed 32 chunks
113
- Indexed 3 chunks
114
- Embeddings: 323/323 chunks in 69519ms
115
- Searching for: "function class method"
116
- Text search: 10 results in 672ms
117
-
118
- ▶ Profiling pp...
119
- Scanned: 1041 chunks in 461ms
120
- Vector store initialized
121
- Indexed 32 chunks
122
- Indexed 32 chunks
123
- Indexed 32 chunks
124
- Indexed 32 chunks
125
- Indexed 32 chunks
126
- Indexed 32 chunks
127
- Indexed 32 chunks
128
- Indexed 32 chunks
129
- Indexed 32 chunks
130
- Indexed 32 chunks
131
- Indexed 32 chunks
132
- Indexed 32 chunks
133
- Indexed 32 chunks
134
- Indexed 32 chunks
135
- Indexed 32 chunks
136
- Indexed 32 chunks
137
- Indexed 32 chunks
138
- Indexed 32 chunks
139
- Indexed 32 chunks
140
- Indexed 32 chunks
141
- Indexed 32 chunks
142
- Indexed 32 chunks
143
- Indexed 32 chunks
144
- Indexed 32 chunks
145
- Indexed 32 chunks
146
- Indexed 32 chunks
147
- Indexed 32 chunks
148
- Indexed 32 chunks
149
- Indexed 32 chunks
150
- Indexed 32 chunks
151
- Indexed 32 chunks
152
- Indexed 32 chunks
153
- Indexed 17 chunks
154
- Embeddings: 1041/1041 chunks in 286137ms
155
- Searching for: "function class method"
156
- Text search: 10 results in 1312ms
157
-
158
- ================================================================================
159
- PERFORMANCE PROFILE
160
- ================================================================================
161
-
162
- scan:
163
- Total: 687.90ms
164
- Avg: 57.32ms
165
- Min: 2.05ms
166
- Max: 461.34ms
167
- Count: 12
168
- Per-chunk: 8.189ms/chunk
169
-
170
- embeddings:
171
- Total: 451057.24ms
172
- Avg: 37588.10ms
173
- Min: 1125.83ms
174
- Max: 286136.65ms
175
- Count: 12
176
- Per-chunk: 5369.729ms/chunk
177
-
178
- search-text:
179
- Total: 2856.57ms
180
- Avg: 238.05ms
181
- Min: 26.30ms
182
- Max: 1311.63ms
183
- Count: 12
184
- Per-chunk: 34.007ms/chunk
185
-
186
- --------------------------------------------------------------------------------
187
- CODEBASE TIMING
188
- --------------------------------------------------------------------------------
189
-
190
- xbot (7 chunks): 1625ms
191
- scan: 8ms (0.5%)
192
- embeddings: 1530ms (94.1%)
193
- search-text: 88ms (5.4%)
194
-
195
- fsbrowse (6 chunks): 1159ms
196
- scan: 7ms (0.6%)
197
- embeddings: 1126ms (97.1%)
198
- search-text: 26ms (2.3%)
199
-
200
- agentauth (11 chunks): 1999ms
201
- scan: 2ms (0.1%)
202
- embeddings: 1957ms (97.9%)
203
- search-text: 40ms (2.0%)
204
-
205
- webtalk (40 chunks): 6788ms
206
- scan: 28ms (0.4%)
207
- embeddings: 6680ms (98.4%)
208
- search-text: 80ms (1.2%)
209
-
210
- plugforge (66 chunks): 11018ms
211
- scan: 11ms (0.1%)
212
- embeddings: 10923ms (99.1%)
213
- search-text: 83ms (0.8%)
214
-
215
- agentgui (83 chunks): 16691ms
216
- scan: 10ms (0.1%)
217
- embeddings: 16535ms (99.1%)
218
- search-text: 146ms (0.9%)
219
-
220
- seqos (76 chunks): 13852ms
221
- scan: 9ms (0.1%)
222
- embeddings: 13730ms (99.1%)
223
- search-text: 113ms (0.8%)
224
-
225
- docmcp (74 chunks): 13674ms
226
- scan: 53ms (0.4%)
227
- embeddings: 13526ms (98.9%)
228
- search-text: 95ms (0.7%)
229
-
230
- zellous (77 chunks): 13637ms
231
- scan: 54ms (0.4%)
232
- embeddings: 13463ms (98.7%)
233
- search-text: 120ms (0.9%)
234
-
235
- teatree (93 chunks): 16023ms
236
- scan: 10ms (0.1%)
237
- embeddings: 15931ms (99.4%)
238
- search-text: 82ms (0.5%)
239
-
240
- moonlanding (323 chunks): 70226ms
241
- scan: 35ms (0.0%)
242
- embeddings: 69519ms (99.0%)
243
- search-text: 672ms (1.0%)
244
-
245
- pp (1041 chunks): 287910ms
246
- scan: 461ms (0.2%)
247
- embeddings: 286137ms (99.4%)
248
- search-text: 1312ms (0.5%)
package/profile.js DELETED
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { existsSync } from 'fs';
4
- import { loadIgnorePatterns } from './src/ignore-parser.js';
5
- import { scanRepository } from './src/scanner.js';
6
- import { buildTextIndex, searchText } from './src/text-search.js';
7
-
8
- const CODEBASES = [
9
- '~/workspace/agentauth',
10
- '~/workspace/agentgui',
11
- '~/workspace/docmcp',
12
- '~/workspace/friday-staging',
13
- '~/workspace/fsbrowse',
14
- '~/workspace/gmweb',
15
- '~/workspace/hookie',
16
- '~/workspace/invoic',
17
- '~/workspace/mcp-thorns',
18
- '~/workspace/models',
19
- '~/workspace/moonlanding',
20
- '~/workspace/myworkreview-staging',
21
- '~/workspace/opencode-source',
22
- '~/workspace/plugforge',
23
- '~/workspace/pp',
24
- '~/workspace/proxypilot-setup',
25
- '~/workspace/seqos',
26
- '~/workspace/sttttsmodels',
27
- '~/workspace/teatree',
28
- '~/workspace/webtalk',
29
- '~/workspace/webtalk-repo',
30
- '~/workspace/xbot',
31
- '~/workspace/zellous',
32
- ];
33
-
34
- // Realistic queries that represent actual usage
35
- const TEST_QUERIES = [
36
- 'authentication',
37
- 'database connection',
38
- 'error handling',
39
- 'HTTP request',
40
- 'user session',
41
- ];
42
-
43
- class Profiler {
44
- constructor() {
45
- this.marks = {};
46
- this.measurements = [];
47
- }
48
-
49
- start(name) {
50
- this.marks[name] = performance.now();
51
- }
52
-
53
- end(name, extra = null) {
54
- if (!this.marks[name]) return 0;
55
- const duration = performance.now() - this.marks[name];
56
- this.measurements.push({ name, duration, extra });
57
- delete this.marks[name];
58
- return duration;
59
- }
60
-
61
- report(results) {
62
- console.log('\n' + '='.repeat(80));
63
- console.log('PERFORMANCE SUMMARY');
64
- console.log('='.repeat(80));
65
-
66
- const scanTimes = this.measurements.filter(m => m.name.startsWith('scan:'));
67
- const indexTimes = this.measurements.filter(m => m.name.startsWith('index:'));
68
- const searchTimes = this.measurements.filter(m => m.name.startsWith('search:'));
69
-
70
- const avg = arr => arr.reduce((a, b) => a + b, 0) / arr.length;
71
- const fmt = ms => ms.toFixed(1) + 'ms';
72
-
73
- console.log(`\nScan: avg ${fmt(avg(scanTimes.map(m => m.duration)))} max ${fmt(Math.max(...scanTimes.map(m => m.duration)))}`);
74
- console.log(`Index: avg ${fmt(avg(indexTimes.map(m => m.duration)))} max ${fmt(Math.max(...indexTimes.map(m => m.duration)))}`);
75
- console.log(`Search: avg ${fmt(avg(searchTimes.map(m => m.duration)))} max ${fmt(Math.max(...searchTimes.map(m => m.duration)))}`);
76
-
77
- console.log('\n' + '-'.repeat(80));
78
- console.log('PER-CODEBASE RESULTS');
79
- console.log('-'.repeat(80));
80
-
81
- for (const r of results) {
82
- if (r.skipped) {
83
- console.log(`\n${r.label}: skipped (not found)`);
84
- continue;
85
- }
86
- const scanT = scanTimes.find(m => m.name === `scan:${r.label}`)?.duration || 0;
87
- const indexT = indexTimes.find(m => m.name === `index:${r.label}`)?.duration || 0;
88
- console.log(`\n${r.label} (${r.chunks} chunks): scan ${fmt(scanT)} | index ${fmt(indexT)}`);
89
- for (const q of r.queries) {
90
- const top = q.results[0];
91
- const topStr = top ? `${top.file_path}:${top.line_start} (${(top.score * 100).toFixed(0)}%)` : 'no results';
92
- console.log(` "${q.query}" → ${q.count} results in ${fmt(q.time)} | top: ${topStr}`);
93
- }
94
- }
95
- }
96
- }
97
-
98
- async function profileCodebase(codebasePath, profiler) {
99
- const rootPath = codebasePath.replace('~', process.env.HOME);
100
- const label = codebasePath.split('/').pop();
101
-
102
- if (!existsSync(rootPath)) {
103
- console.log(` ${label}: not found, skipping`);
104
- return { label, skipped: true };
105
- }
106
-
107
- process.stdout.write(`▶ ${label}... `);
108
-
109
- profiler.start(`scan:${label}`);
110
- const ignorePatterns = loadIgnorePatterns(rootPath);
111
- const chunks = scanRepository(rootPath, ignorePatterns);
112
- profiler.end(`scan:${label}`, chunks.length);
113
-
114
- if (chunks.length === 0) {
115
- console.log('0 chunks');
116
- return { label, chunks: 0, queries: [] };
117
- }
118
-
119
- profiler.start(`index:${label}`);
120
- const indexData = buildTextIndex(chunks);
121
- profiler.end(`index:${label}`, chunks.length);
122
-
123
- const queryResults = [];
124
- for (const query of TEST_QUERIES) {
125
- const t0 = performance.now();
126
- const results = searchText(query, chunks, indexData);
127
- const elapsed = performance.now() - t0;
128
- profiler.measurements.push({ name: `search:${label}:${query}`, duration: elapsed });
129
- queryResults.push({ query, count: results.length, time: elapsed, results: results.slice(0, 1) });
130
- }
131
-
132
- console.log(`${chunks.length} chunks, ${queryResults.map(q => q.time.toFixed(0) + 'ms').join('/')}`);
133
- return { label, chunks: chunks.length, queries: queryResults };
134
- }
135
-
136
- async function main() {
137
- console.log('Profiling search across codebases...\n');
138
-
139
- const profiler = new Profiler();
140
- const results = [];
141
-
142
- for (const codebase of CODEBASES) {
143
- results.push(await profileCodebase(codebase, profiler));
144
- }
145
-
146
- profiler.report(results);
147
- }
148
-
149
- main().catch(err => {
150
- console.error('Profile error:', err.message);
151
- process.exit(1);
152
- });