bluera-knowledge 0.9.32 → 0.9.36

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.
Files changed (198) hide show
  1. package/.claude/hooks/post-edit-check.sh +5 -3
  2. package/.claude/skills/atomic-commits/SKILL.md +3 -1
  3. package/.husky/pre-commit +3 -2
  4. package/.prettierrc +9 -0
  5. package/.versionrc.json +1 -1
  6. package/CHANGELOG.md +70 -0
  7. package/CLAUDE.md +6 -0
  8. package/README.md +25 -13
  9. package/bun.lock +277 -33
  10. package/dist/{chunk-L2YVNC63.js → chunk-6FHWC36B.js} +9 -1
  11. package/dist/chunk-6FHWC36B.js.map +1 -0
  12. package/dist/{chunk-RST4XGRL.js → chunk-DC7CGSGT.js} +288 -241
  13. package/dist/chunk-DC7CGSGT.js.map +1 -0
  14. package/dist/{chunk-6PBP5DVD.js → chunk-WFNPNAAP.js} +3212 -3054
  15. package/dist/chunk-WFNPNAAP.js.map +1 -0
  16. package/dist/{chunk-WT2DAEO7.js → chunk-Z2KKVH45.js} +548 -482
  17. package/dist/chunk-Z2KKVH45.js.map +1 -0
  18. package/dist/index.js +871 -758
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp/server.js +3 -3
  21. package/dist/watch.service-BJV3TI3F.js +7 -0
  22. package/dist/workers/background-worker-cli.js +97 -71
  23. package/dist/workers/background-worker-cli.js.map +1 -1
  24. package/eslint.config.js +43 -1
  25. package/package.json +18 -11
  26. package/plugin.json +8 -0
  27. package/python/requirements.txt +1 -1
  28. package/src/analysis/ast-parser.test.ts +12 -11
  29. package/src/analysis/ast-parser.ts +28 -22
  30. package/src/analysis/code-graph.test.ts +52 -62
  31. package/src/analysis/code-graph.ts +9 -13
  32. package/src/analysis/dependency-usage-analyzer.test.ts +91 -271
  33. package/src/analysis/dependency-usage-analyzer.ts +52 -24
  34. package/src/analysis/go-ast-parser.test.ts +22 -22
  35. package/src/analysis/go-ast-parser.ts +18 -25
  36. package/src/analysis/parser-factory.test.ts +9 -9
  37. package/src/analysis/parser-factory.ts +3 -3
  38. package/src/analysis/python-ast-parser.test.ts +27 -27
  39. package/src/analysis/python-ast-parser.ts +2 -2
  40. package/src/analysis/repo-url-resolver.test.ts +82 -82
  41. package/src/analysis/rust-ast-parser.test.ts +19 -19
  42. package/src/analysis/rust-ast-parser.ts +17 -27
  43. package/src/analysis/tree-sitter-parser.test.ts +3 -3
  44. package/src/analysis/tree-sitter-parser.ts +10 -16
  45. package/src/cli/commands/crawl.test.ts +40 -24
  46. package/src/cli/commands/crawl.ts +186 -166
  47. package/src/cli/commands/index-cmd.test.ts +90 -90
  48. package/src/cli/commands/index-cmd.ts +52 -36
  49. package/src/cli/commands/mcp.test.ts +6 -6
  50. package/src/cli/commands/mcp.ts +2 -2
  51. package/src/cli/commands/plugin-api.test.ts +16 -18
  52. package/src/cli/commands/plugin-api.ts +9 -6
  53. package/src/cli/commands/search.test.ts +16 -7
  54. package/src/cli/commands/search.ts +124 -87
  55. package/src/cli/commands/serve.test.ts +67 -25
  56. package/src/cli/commands/serve.ts +18 -3
  57. package/src/cli/commands/setup.test.ts +176 -101
  58. package/src/cli/commands/setup.ts +140 -117
  59. package/src/cli/commands/store.test.ts +82 -53
  60. package/src/cli/commands/store.ts +56 -37
  61. package/src/cli/program.ts +2 -2
  62. package/src/crawl/article-converter.test.ts +4 -1
  63. package/src/crawl/article-converter.ts +46 -31
  64. package/src/crawl/bridge.test.ts +240 -132
  65. package/src/crawl/bridge.ts +87 -30
  66. package/src/crawl/claude-client.test.ts +124 -56
  67. package/src/crawl/claude-client.ts +7 -15
  68. package/src/crawl/intelligent-crawler.test.ts +65 -22
  69. package/src/crawl/intelligent-crawler.ts +86 -53
  70. package/src/crawl/markdown-utils.ts +1 -4
  71. package/src/db/embeddings.ts +4 -6
  72. package/src/db/lance.test.ts +4 -4
  73. package/src/db/lance.ts +16 -12
  74. package/src/index.ts +26 -17
  75. package/src/logging/index.ts +1 -5
  76. package/src/logging/logger.ts +3 -5
  77. package/src/logging/payload.test.ts +1 -1
  78. package/src/logging/payload.ts +3 -5
  79. package/src/mcp/commands/index.ts +2 -2
  80. package/src/mcp/commands/job.commands.ts +12 -18
  81. package/src/mcp/commands/meta.commands.ts +13 -13
  82. package/src/mcp/commands/registry.ts +5 -8
  83. package/src/mcp/commands/store.commands.ts +19 -19
  84. package/src/mcp/handlers/execute.handler.test.ts +10 -10
  85. package/src/mcp/handlers/execute.handler.ts +4 -5
  86. package/src/mcp/handlers/index.ts +10 -14
  87. package/src/mcp/handlers/job.handler.test.ts +10 -10
  88. package/src/mcp/handlers/job.handler.ts +22 -25
  89. package/src/mcp/handlers/search.handler.test.ts +36 -65
  90. package/src/mcp/handlers/search.handler.ts +135 -104
  91. package/src/mcp/handlers/store.handler.test.ts +41 -52
  92. package/src/mcp/handlers/store.handler.ts +108 -88
  93. package/src/mcp/schemas/index.test.ts +73 -68
  94. package/src/mcp/schemas/index.ts +18 -12
  95. package/src/mcp/server.test.ts +1 -1
  96. package/src/mcp/server.ts +59 -46
  97. package/src/plugin/commands.test.ts +230 -95
  98. package/src/plugin/commands.ts +24 -25
  99. package/src/plugin/dependency-analyzer.test.ts +52 -52
  100. package/src/plugin/dependency-analyzer.ts +85 -22
  101. package/src/plugin/git-clone.test.ts +24 -13
  102. package/src/plugin/git-clone.ts +3 -7
  103. package/src/server/app.test.ts +109 -109
  104. package/src/server/app.ts +32 -23
  105. package/src/server/index.test.ts +64 -66
  106. package/src/services/chunking.service.test.ts +32 -32
  107. package/src/services/chunking.service.ts +16 -9
  108. package/src/services/code-graph.service.test.ts +30 -36
  109. package/src/services/code-graph.service.ts +24 -10
  110. package/src/services/code-unit.service.test.ts +55 -11
  111. package/src/services/code-unit.service.ts +85 -11
  112. package/src/services/config.service.test.ts +37 -18
  113. package/src/services/config.service.ts +30 -7
  114. package/src/services/index.service.test.ts +49 -18
  115. package/src/services/index.service.ts +98 -48
  116. package/src/services/index.ts +6 -9
  117. package/src/services/job.service.test.ts +22 -22
  118. package/src/services/job.service.ts +18 -18
  119. package/src/services/project-root.service.test.ts +1 -3
  120. package/src/services/search.service.test.ts +248 -120
  121. package/src/services/search.service.ts +286 -156
  122. package/src/services/services.test.ts +1 -1
  123. package/src/services/snippet.service.test.ts +14 -6
  124. package/src/services/snippet.service.ts +7 -5
  125. package/src/services/store.service.test.ts +68 -29
  126. package/src/services/store.service.ts +41 -12
  127. package/src/services/watch.service.test.ts +34 -14
  128. package/src/services/watch.service.ts +11 -1
  129. package/src/types/brands.test.ts +3 -1
  130. package/src/types/index.ts +2 -13
  131. package/src/types/search.ts +10 -8
  132. package/src/utils/type-guards.test.ts +20 -15
  133. package/src/utils/type-guards.ts +1 -1
  134. package/src/workers/background-worker-cli.ts +28 -30
  135. package/src/workers/background-worker.test.ts +54 -40
  136. package/src/workers/background-worker.ts +76 -60
  137. package/src/workers/pid-file.test.ts +167 -0
  138. package/src/workers/pid-file.ts +82 -0
  139. package/src/workers/spawn-worker.test.ts +22 -10
  140. package/src/workers/spawn-worker.ts +6 -6
  141. package/tests/analysis/ast-parser.test.ts +3 -3
  142. package/tests/analysis/code-graph.test.ts +5 -5
  143. package/tests/fixtures/code-snippets/api/error-handling.ts +4 -15
  144. package/tests/fixtures/code-snippets/api/rest-controller.ts +3 -9
  145. package/tests/fixtures/code-snippets/auth/jwt-auth.ts +5 -21
  146. package/tests/fixtures/code-snippets/auth/oauth-flow.ts +4 -4
  147. package/tests/fixtures/code-snippets/database/repository-pattern.ts +11 -3
  148. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +2 -2
  149. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +1 -1
  150. package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +2 -2
  151. package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +2 -2
  152. package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +22 -20
  153. package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +13 -10
  154. package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +10 -7
  155. package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +2 -2
  156. package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +1 -1
  157. package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +16 -16
  158. package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +2 -2
  159. package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +3 -3
  160. package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +1 -1
  161. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +2 -2
  162. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +1 -1
  163. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +7 -7
  164. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +3 -3
  165. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +1 -1
  166. package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +6 -6
  167. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +3 -3
  168. package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +1 -1
  169. package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +1 -1
  170. package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +1 -1
  171. package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +2 -2
  172. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +4 -4
  173. package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +1 -1
  174. package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +1 -1
  175. package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +166 -169
  176. package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +8 -8
  177. package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +3 -3
  178. package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +2 -2
  179. package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +2 -2
  180. package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +30 -33
  181. package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +2 -2
  182. package/tests/fixtures/test-server.ts +3 -2
  183. package/tests/helpers/performance-metrics.ts +8 -25
  184. package/tests/helpers/search-relevance.ts +14 -69
  185. package/tests/integration/cli-consistency.test.ts +6 -5
  186. package/tests/integration/python-bridge.test.ts +13 -3
  187. package/tests/mcp/server.test.ts +1 -1
  188. package/tests/services/code-unit.service.test.ts +48 -0
  189. package/tests/services/job.service.test.ts +124 -0
  190. package/tests/services/search.progressive-context.test.ts +2 -2
  191. package/.claude-plugin/plugin.json +0 -13
  192. package/dist/chunk-6PBP5DVD.js.map +0 -1
  193. package/dist/chunk-L2YVNC63.js.map +0 -1
  194. package/dist/chunk-RST4XGRL.js.map +0 -1
  195. package/dist/chunk-WT2DAEO7.js.map +0 -1
  196. package/dist/watch.service-YAIKKDCF.js +0 -7
  197. package/skills/atomic-commits/SKILL.md +0 -77
  198. /package/dist/{watch.service-YAIKKDCF.js.map → watch.service-BJV3TI3F.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { mkdir } from 'node:fs/promises';
3
- import type { Result } from '../types/result.js';
4
3
  import { ok, err } from '../types/result.js';
4
+ import type { Result } from '../types/result.js';
5
5
 
6
6
  export interface CloneOptions {
7
7
  url: string;
@@ -10,9 +10,7 @@ export interface CloneOptions {
10
10
  depth?: number;
11
11
  }
12
12
 
13
- export async function cloneRepository(
14
- options: CloneOptions
15
- ): Promise<Result<string>> {
13
+ export async function cloneRepository(options: CloneOptions): Promise<Result<string>> {
16
14
  const { url, targetDir, branch, depth = 1 } = options;
17
15
 
18
16
  await mkdir(targetDir, { recursive: true });
@@ -42,9 +40,7 @@ export async function cloneRepository(
42
40
  }
43
41
 
44
42
  export function isGitUrl(source: string): boolean {
45
- return source.startsWith('http://') ||
46
- source.startsWith('https://') ||
47
- source.startsWith('git@');
43
+ return source.startsWith('http://') || source.startsWith('https://') || source.startsWith('git@');
48
44
  }
49
45
 
50
46
  export function extractRepoName(url: string): string {
@@ -13,17 +13,17 @@ describe('Server App - Health Check', () => {
13
13
  list: vi.fn(),
14
14
  getByIdOrName: vi.fn(),
15
15
  create: vi.fn(),
16
- delete: vi.fn()
16
+ delete: vi.fn(),
17
17
  },
18
18
  lance: {
19
- initialize: vi.fn()
19
+ initialize: vi.fn(),
20
20
  },
21
21
  search: {
22
- search: vi.fn()
22
+ search: vi.fn(),
23
23
  },
24
24
  index: {
25
- indexStore: vi.fn()
26
- }
25
+ indexStore: vi.fn(),
26
+ },
27
27
  } as unknown as ServiceContainer;
28
28
  });
29
29
 
@@ -51,11 +51,11 @@ describe('Server App - CORS', () => {
51
51
  beforeEach(() => {
52
52
  mockServices = {
53
53
  store: {
54
- list: vi.fn()
54
+ list: vi.fn(),
55
55
  },
56
56
  lance: {},
57
57
  search: {},
58
- index: {}
58
+ index: {},
59
59
  } as unknown as ServiceContainer;
60
60
  });
61
61
 
@@ -77,8 +77,8 @@ describe('Server App - CORS', () => {
77
77
  headers: {
78
78
  'Access-Control-Request-Method': 'POST',
79
79
  'Access-Control-Request-Headers': 'content-type',
80
- 'Origin': 'http://localhost:3000'
81
- }
80
+ Origin: 'http://localhost:3000',
81
+ },
82
82
  });
83
83
 
84
84
  expect(res.status).toBe(204);
@@ -92,8 +92,8 @@ describe('Server App - GET /api/stores', () => {
92
92
  beforeEach(() => {
93
93
  mockServices = {
94
94
  store: {
95
- list: vi.fn()
96
- }
95
+ list: vi.fn(),
96
+ },
97
97
  } as unknown as ServiceContainer;
98
98
  });
99
99
 
@@ -105,8 +105,8 @@ describe('Server App - GET /api/stores', () => {
105
105
  type: 'file',
106
106
  path: '/tmp/test',
107
107
  createdAt: new Date(),
108
- updatedAt: new Date()
109
- }
108
+ updatedAt: new Date(),
109
+ },
110
110
  ];
111
111
 
112
112
  vi.mocked(mockServices.store.list).mockResolvedValue(mockStores);
@@ -120,7 +120,7 @@ describe('Server App - GET /api/stores', () => {
120
120
  expect(json[0]).toMatchObject({
121
121
  id: 'store-1',
122
122
  name: 'test-store',
123
- type: 'file'
123
+ type: 'file',
124
124
  });
125
125
  });
126
126
 
@@ -142,8 +142,8 @@ describe('Server App - POST /api/stores', () => {
142
142
  beforeEach(() => {
143
143
  mockServices = {
144
144
  store: {
145
- create: vi.fn()
146
- }
145
+ create: vi.fn(),
146
+ },
147
147
  } as unknown as ServiceContainer;
148
148
  });
149
149
 
@@ -154,25 +154,25 @@ describe('Server App - POST /api/stores', () => {
154
154
  type: 'file',
155
155
  path: '/tmp/new',
156
156
  createdAt: new Date(),
157
- updatedAt: new Date()
157
+ updatedAt: new Date(),
158
158
  };
159
159
 
160
160
  vi.mocked(mockServices.store.create).mockResolvedValue({
161
161
  success: true,
162
- data: newStore
162
+ data: newStore,
163
163
  });
164
164
 
165
165
  const app = createApp(mockServices);
166
166
  const res = await app.request('/api/stores', {
167
167
  method: 'POST',
168
168
  headers: {
169
- 'Content-Type': 'application/json'
169
+ 'Content-Type': 'application/json',
170
170
  },
171
171
  body: JSON.stringify({
172
172
  name: 'new-store',
173
173
  type: 'file',
174
- path: '/tmp/new'
175
- })
174
+ path: '/tmp/new',
175
+ }),
176
176
  });
177
177
 
178
178
  expect(res.status).toBe(201);
@@ -180,7 +180,7 @@ describe('Server App - POST /api/stores', () => {
180
180
  expect(json).toMatchObject({
181
181
  id: 'new-store',
182
182
  name: 'new-store',
183
- type: 'file'
183
+ type: 'file',
184
184
  });
185
185
  });
186
186
 
@@ -192,25 +192,25 @@ describe('Server App - POST /api/stores', () => {
192
192
  path: '/tmp/repo',
193
193
  url: 'https://github.com/user/repo.git',
194
194
  createdAt: new Date(),
195
- updatedAt: new Date()
195
+ updatedAt: new Date(),
196
196
  };
197
197
 
198
198
  vi.mocked(mockServices.store.create).mockResolvedValue({
199
199
  success: true,
200
- data: newStore
200
+ data: newStore,
201
201
  });
202
202
 
203
203
  const app = createApp(mockServices);
204
204
  const res = await app.request('/api/stores', {
205
205
  method: 'POST',
206
206
  headers: {
207
- 'Content-Type': 'application/json'
207
+ 'Content-Type': 'application/json',
208
208
  },
209
209
  body: JSON.stringify({
210
210
  name: 'repo-store',
211
211
  type: 'repo',
212
- url: 'https://github.com/user/repo.git'
213
- })
212
+ url: 'https://github.com/user/repo.git',
213
+ }),
214
214
  });
215
215
 
216
216
  expect(res.status).toBe(201);
@@ -219,26 +219,26 @@ describe('Server App - POST /api/stores', () => {
219
219
  it('returns 400 on store creation failure', async () => {
220
220
  vi.mocked(mockServices.store.create).mockResolvedValue({
221
221
  success: false,
222
- error: new Error('Invalid path')
222
+ error: new Error('Invalid path'),
223
223
  });
224
224
 
225
225
  const app = createApp(mockServices);
226
226
  const res = await app.request('/api/stores', {
227
227
  method: 'POST',
228
228
  headers: {
229
- 'Content-Type': 'application/json'
229
+ 'Content-Type': 'application/json',
230
230
  },
231
231
  body: JSON.stringify({
232
232
  name: 'bad-store',
233
233
  type: 'file',
234
- path: '/invalid'
235
- })
234
+ path: '/invalid',
235
+ }),
236
236
  });
237
237
 
238
238
  expect(res.status).toBe(400);
239
239
  const json = await res.json();
240
240
  expect(json).toMatchObject({
241
- error: 'Invalid path'
241
+ error: 'Invalid path',
242
242
  });
243
243
  });
244
244
 
@@ -249,9 +249,9 @@ describe('Server App - POST /api/stores', () => {
249
249
  headers: { 'Content-Type': 'application/json' },
250
250
  body: JSON.stringify({
251
251
  name: 'bad-file-store',
252
- type: 'file'
252
+ type: 'file',
253
253
  // missing path
254
- })
254
+ }),
255
255
  });
256
256
 
257
257
  expect(res.status).toBe(400);
@@ -266,9 +266,9 @@ describe('Server App - POST /api/stores', () => {
266
266
  headers: { 'Content-Type': 'application/json' },
267
267
  body: JSON.stringify({
268
268
  name: 'bad-web-store',
269
- type: 'web'
269
+ type: 'web',
270
270
  // missing url
271
- })
271
+ }),
272
272
  });
273
273
 
274
274
  expect(res.status).toBe(400);
@@ -283,9 +283,9 @@ describe('Server App - POST /api/stores', () => {
283
283
  headers: { 'Content-Type': 'application/json' },
284
284
  body: JSON.stringify({
285
285
  name: 'bad-repo-store',
286
- type: 'repo'
286
+ type: 'repo',
287
287
  // missing both path and url
288
- })
288
+ }),
289
289
  });
290
290
 
291
291
  expect(res.status).toBe(400);
@@ -301,12 +301,12 @@ describe('Server App - POST /api/stores', () => {
301
301
  url: 'https://example.com',
302
302
  depth: 1,
303
303
  createdAt: new Date(),
304
- updatedAt: new Date()
304
+ updatedAt: new Date(),
305
305
  };
306
306
 
307
307
  vi.mocked(mockServices.store.create).mockResolvedValue({
308
308
  success: true,
309
- data: newStore
309
+ data: newStore,
310
310
  });
311
311
 
312
312
  const app = createApp(mockServices);
@@ -316,8 +316,8 @@ describe('Server App - POST /api/stores', () => {
316
316
  body: JSON.stringify({
317
317
  name: 'web-store',
318
318
  type: 'web',
319
- url: 'https://example.com'
320
- })
319
+ url: 'https://example.com',
320
+ }),
321
321
  });
322
322
 
323
323
  expect(res.status).toBe(201);
@@ -330,8 +330,8 @@ describe('Server App - GET /api/stores/:id', () => {
330
330
  beforeEach(() => {
331
331
  mockServices = {
332
332
  store: {
333
- getByIdOrName: vi.fn()
334
- }
333
+ getByIdOrName: vi.fn(),
334
+ },
335
335
  } as unknown as ServiceContainer;
336
336
  });
337
337
 
@@ -342,7 +342,7 @@ describe('Server App - GET /api/stores/:id', () => {
342
342
  type: 'file',
343
343
  path: '/tmp/test',
344
344
  createdAt: new Date(),
345
- updatedAt: new Date()
345
+ updatedAt: new Date(),
346
346
  };
347
347
 
348
348
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
@@ -354,7 +354,7 @@ describe('Server App - GET /api/stores/:id', () => {
354
354
  expect(res.status).toBe(200);
355
355
  expect(json).toMatchObject({
356
356
  id: 'store-1',
357
- name: 'test-store'
357
+ name: 'test-store',
358
358
  });
359
359
  });
360
360
 
@@ -365,7 +365,7 @@ describe('Server App - GET /api/stores/:id', () => {
365
365
  type: 'file',
366
366
  path: '/tmp/test',
367
367
  createdAt: new Date(),
368
- updatedAt: new Date()
368
+ updatedAt: new Date(),
369
369
  };
370
370
 
371
371
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
@@ -385,7 +385,7 @@ describe('Server App - GET /api/stores/:id', () => {
385
385
  expect(res.status).toBe(404);
386
386
  const json = await res.json();
387
387
  expect(json).toMatchObject({
388
- error: 'Not found'
388
+ error: 'Not found',
389
389
  });
390
390
  });
391
391
  });
@@ -397,8 +397,8 @@ describe('Server App - DELETE /api/stores/:id', () => {
397
397
  mockServices = {
398
398
  store: {
399
399
  getByIdOrName: vi.fn(),
400
- delete: vi.fn()
401
- }
400
+ delete: vi.fn(),
401
+ },
402
402
  } as unknown as ServiceContainer;
403
403
  });
404
404
 
@@ -409,24 +409,24 @@ describe('Server App - DELETE /api/stores/:id', () => {
409
409
  type: 'file',
410
410
  path: '/tmp/test',
411
411
  createdAt: new Date(),
412
- updatedAt: new Date()
412
+ updatedAt: new Date(),
413
413
  };
414
414
 
415
415
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
416
416
  vi.mocked(mockServices.store.delete).mockResolvedValue({
417
417
  success: true,
418
- data: undefined
418
+ data: undefined,
419
419
  });
420
420
 
421
421
  const app = createApp(mockServices);
422
422
  const res = await app.request('/api/stores/store-1', {
423
- method: 'DELETE'
423
+ method: 'DELETE',
424
424
  });
425
425
 
426
426
  expect(res.status).toBe(200);
427
427
  const json = await res.json();
428
428
  expect(json).toMatchObject({
429
- deleted: true
429
+ deleted: true,
430
430
  });
431
431
  });
432
432
 
@@ -435,7 +435,7 @@ describe('Server App - DELETE /api/stores/:id', () => {
435
435
 
436
436
  const app = createApp(mockServices);
437
437
  const res = await app.request('/api/stores/nonexistent', {
438
- method: 'DELETE'
438
+ method: 'DELETE',
439
439
  });
440
440
 
441
441
  expect(res.status).toBe(404);
@@ -448,24 +448,24 @@ describe('Server App - DELETE /api/stores/:id', () => {
448
448
  type: 'file',
449
449
  path: '/tmp/test',
450
450
  createdAt: new Date(),
451
- updatedAt: new Date()
451
+ updatedAt: new Date(),
452
452
  };
453
453
 
454
454
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
455
455
  vi.mocked(mockServices.store.delete).mockResolvedValue({
456
456
  success: false,
457
- error: new Error('Deletion failed')
457
+ error: new Error('Deletion failed'),
458
458
  });
459
459
 
460
460
  const app = createApp(mockServices);
461
461
  const res = await app.request('/api/stores/store-1', {
462
- method: 'DELETE'
462
+ method: 'DELETE',
463
463
  });
464
464
 
465
465
  expect(res.status).toBe(400);
466
466
  const json = await res.json();
467
467
  expect(json).toMatchObject({
468
- error: 'Deletion failed'
468
+ error: 'Deletion failed',
469
469
  });
470
470
  });
471
471
  });
@@ -476,14 +476,14 @@ describe('Server App - POST /api/search', () => {
476
476
  beforeEach(() => {
477
477
  mockServices = {
478
478
  store: {
479
- list: vi.fn()
479
+ list: vi.fn(),
480
480
  },
481
481
  lance: {
482
- initialize: vi.fn()
482
+ initialize: vi.fn(),
483
483
  },
484
484
  search: {
485
- search: vi.fn()
486
- }
485
+ search: vi.fn(),
486
+ },
487
487
  } as unknown as ServiceContainer;
488
488
  });
489
489
 
@@ -495,30 +495,30 @@ describe('Server App - POST /api/search', () => {
495
495
  type: 'file',
496
496
  path: '/tmp/test',
497
497
  createdAt: new Date(),
498
- updatedAt: new Date()
499
- }
498
+ updatedAt: new Date(),
499
+ },
500
500
  ]);
501
501
 
502
502
  vi.mocked(mockServices.search.search).mockResolvedValue({
503
503
  results: [],
504
- totalResults: 0
504
+ totalResults: 0,
505
505
  });
506
506
 
507
507
  const app = createApp(mockServices);
508
508
  const res = await app.request('/api/search', {
509
509
  method: 'POST',
510
510
  headers: {
511
- 'Content-Type': 'application/json'
511
+ 'Content-Type': 'application/json',
512
512
  },
513
513
  body: JSON.stringify({
514
- query: 'test query'
515
- })
514
+ query: 'test query',
515
+ }),
516
516
  });
517
517
 
518
518
  expect(res.status).toBe(200);
519
519
  expect(mockServices.search.search).toHaveBeenCalledWith(
520
520
  expect.objectContaining({
521
- query: 'test query'
521
+ query: 'test query',
522
522
  })
523
523
  );
524
524
  });
@@ -531,7 +531,7 @@ describe('Server App - POST /api/search', () => {
531
531
  type: 'file',
532
532
  path: '/tmp/test1',
533
533
  createdAt: new Date(),
534
- updatedAt: new Date()
534
+ updatedAt: new Date(),
535
535
  },
536
536
  {
537
537
  id: createStoreId('store-2'),
@@ -539,24 +539,24 @@ describe('Server App - POST /api/search', () => {
539
539
  type: 'file',
540
540
  path: '/tmp/test2',
541
541
  createdAt: new Date(),
542
- updatedAt: new Date()
543
- }
542
+ updatedAt: new Date(),
543
+ },
544
544
  ]);
545
545
 
546
546
  vi.mocked(mockServices.search.search).mockResolvedValue({
547
547
  results: [],
548
- totalResults: 0
548
+ totalResults: 0,
549
549
  });
550
550
 
551
551
  const app = createApp(mockServices);
552
552
  await app.request('/api/search', {
553
553
  method: 'POST',
554
554
  headers: {
555
- 'Content-Type': 'application/json'
555
+ 'Content-Type': 'application/json',
556
556
  },
557
557
  body: JSON.stringify({
558
- query: 'test'
559
- })
558
+ query: 'test',
559
+ }),
560
560
  });
561
561
 
562
562
  expect(mockServices.lance.initialize).toHaveBeenCalledTimes(2);
@@ -572,30 +572,30 @@ describe('Server App - POST /api/search', () => {
572
572
  type: 'file',
573
573
  path: '/tmp/test',
574
574
  createdAt: new Date(),
575
- updatedAt: new Date()
576
- }
575
+ updatedAt: new Date(),
576
+ },
577
577
  ]);
578
578
 
579
579
  vi.mocked(mockServices.search.search).mockResolvedValue({
580
580
  results: [],
581
- totalResults: 0
581
+ totalResults: 0,
582
582
  });
583
583
 
584
584
  const app = createApp(mockServices);
585
585
  await app.request('/api/search', {
586
586
  method: 'POST',
587
587
  headers: {
588
- 'Content-Type': 'application/json'
588
+ 'Content-Type': 'application/json',
589
589
  },
590
590
  body: JSON.stringify({
591
591
  query: 'test',
592
- stores: [createStoreId('custom-store')]
593
- })
592
+ stores: [createStoreId('custom-store')],
593
+ }),
594
594
  });
595
595
 
596
596
  expect(mockServices.search.search).toHaveBeenCalledWith(
597
597
  expect.objectContaining({
598
- stores: [createStoreId('custom-store')]
598
+ stores: [createStoreId('custom-store')],
599
599
  })
600
600
  );
601
601
  });
@@ -608,22 +608,22 @@ describe('Server App - POST /api/search', () => {
608
608
  score: 0.95,
609
609
  summary: {
610
610
  location: 'test.ts:10-20',
611
- purpose: 'Test function'
612
- }
613
- }
611
+ purpose: 'Test function',
612
+ },
613
+ },
614
614
  ],
615
- totalResults: 1
615
+ totalResults: 1,
616
616
  });
617
617
 
618
618
  const app = createApp(mockServices);
619
619
  const res = await app.request('/api/search', {
620
620
  method: 'POST',
621
621
  headers: {
622
- 'Content-Type': 'application/json'
622
+ 'Content-Type': 'application/json',
623
623
  },
624
624
  body: JSON.stringify({
625
- query: 'test'
626
- })
625
+ query: 'test',
626
+ }),
627
627
  });
628
628
 
629
629
  const json = await res.json();
@@ -638,14 +638,14 @@ describe('Server App - POST /api/stores/:id/index', () => {
638
638
  beforeEach(() => {
639
639
  mockServices = {
640
640
  store: {
641
- getByIdOrName: vi.fn()
641
+ getByIdOrName: vi.fn(),
642
642
  },
643
643
  lance: {
644
- initialize: vi.fn()
644
+ initialize: vi.fn(),
645
645
  },
646
646
  index: {
647
- indexStore: vi.fn()
648
- }
647
+ indexStore: vi.fn(),
648
+ },
649
649
  } as unknown as ServiceContainer;
650
650
  });
651
651
 
@@ -656,7 +656,7 @@ describe('Server App - POST /api/stores/:id/index', () => {
656
656
  type: 'file',
657
657
  path: '/tmp/test',
658
658
  createdAt: new Date(),
659
- updatedAt: new Date()
659
+ updatedAt: new Date(),
660
660
  };
661
661
 
662
662
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
@@ -665,13 +665,13 @@ describe('Server App - POST /api/stores/:id/index', () => {
665
665
  data: {
666
666
  documentsIndexed: 10,
667
667
  chunksCreated: 50,
668
- timeMs: 1000
669
- }
668
+ timeMs: 1000,
669
+ },
670
670
  });
671
671
 
672
672
  const app = createApp(mockServices);
673
673
  const res = await app.request('/api/stores/store-1/index', {
674
- method: 'POST'
674
+ method: 'POST',
675
675
  });
676
676
 
677
677
  expect(res.status).toBe(200);
@@ -679,7 +679,7 @@ describe('Server App - POST /api/stores/:id/index', () => {
679
679
  expect(json).toMatchObject({
680
680
  documentsIndexed: 10,
681
681
  chunksCreated: 50,
682
- timeMs: 1000
682
+ timeMs: 1000,
683
683
  });
684
684
  });
685
685
 
@@ -690,7 +690,7 @@ describe('Server App - POST /api/stores/:id/index', () => {
690
690
  type: 'file',
691
691
  path: '/tmp/test',
692
692
  createdAt: new Date(),
693
- updatedAt: new Date()
693
+ updatedAt: new Date(),
694
694
  };
695
695
 
696
696
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
@@ -699,13 +699,13 @@ describe('Server App - POST /api/stores/:id/index', () => {
699
699
  data: {
700
700
  documentsIndexed: 0,
701
701
  chunksCreated: 0,
702
- timeMs: 0
703
- }
702
+ timeMs: 0,
703
+ },
704
704
  });
705
705
 
706
706
  const app = createApp(mockServices);
707
707
  await app.request('/api/stores/store-1/index', {
708
- method: 'POST'
708
+ method: 'POST',
709
709
  });
710
710
 
711
711
  expect(mockServices.lance.initialize).toHaveBeenCalledWith(createStoreId('store-1'));
@@ -716,7 +716,7 @@ describe('Server App - POST /api/stores/:id/index', () => {
716
716
 
717
717
  const app = createApp(mockServices);
718
718
  const res = await app.request('/api/stores/nonexistent/index', {
719
- method: 'POST'
719
+ method: 'POST',
720
720
  });
721
721
 
722
722
  expect(res.status).toBe(404);
@@ -729,24 +729,24 @@ describe('Server App - POST /api/stores/:id/index', () => {
729
729
  type: 'file',
730
730
  path: '/tmp/test',
731
731
  createdAt: new Date(),
732
- updatedAt: new Date()
732
+ updatedAt: new Date(),
733
733
  };
734
734
 
735
735
  vi.mocked(mockServices.store.getByIdOrName).mockResolvedValue(mockStore);
736
736
  vi.mocked(mockServices.index.indexStore).mockResolvedValue({
737
737
  success: false,
738
- error: new Error('Indexing failed')
738
+ error: new Error('Indexing failed'),
739
739
  });
740
740
 
741
741
  const app = createApp(mockServices);
742
742
  const res = await app.request('/api/stores/store-1/index', {
743
- method: 'POST'
743
+ method: 'POST',
744
744
  });
745
745
 
746
746
  expect(res.status).toBe(400);
747
747
  const json = await res.json();
748
748
  expect(json).toMatchObject({
749
- error: 'Indexing failed'
749
+ error: 'Indexing failed',
750
750
  });
751
751
  });
752
752
  });