bluera-knowledge 0.9.25 → 0.9.30

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 (56) hide show
  1. package/.claude/commands/commit.md +4 -7
  2. package/.claude/hooks/post-edit-check.sh +21 -24
  3. package/.claude/skills/atomic-commits/SKILL.md +6 -0
  4. package/.claude-plugin/plugin.json +1 -1
  5. package/.env.example +4 -0
  6. package/.husky/pre-push +12 -2
  7. package/.versionrc.json +0 -4
  8. package/CHANGELOG.md +76 -0
  9. package/README.md +55 -20
  10. package/bun.lock +35 -1
  11. package/commands/crawl.md +2 -0
  12. package/dist/{chunk-BICFAWMN.js → chunk-DNOIM7BO.js} +73 -8
  13. package/dist/chunk-DNOIM7BO.js.map +1 -0
  14. package/dist/{chunk-5QMHZUC4.js → chunk-NJUMU4X2.js} +462 -105
  15. package/dist/chunk-NJUMU4X2.js.map +1 -0
  16. package/dist/{chunk-J7J6LXOJ.js → chunk-SZNTYLYT.js} +106 -41
  17. package/dist/chunk-SZNTYLYT.js.map +1 -0
  18. package/dist/index.js +65 -25
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp/server.js +2 -2
  21. package/dist/workers/background-worker-cli.js +2 -2
  22. package/eslint.config.js +1 -1
  23. package/package.json +3 -1
  24. package/src/analysis/ast-parser.test.ts +46 -0
  25. package/src/cli/commands/crawl.test.ts +99 -12
  26. package/src/cli/commands/crawl.ts +76 -24
  27. package/src/crawl/article-converter.ts +36 -1
  28. package/src/crawl/bridge.ts +18 -7
  29. package/src/crawl/intelligent-crawler.ts +45 -4
  30. package/src/db/embeddings.test.ts +16 -0
  31. package/src/logging/index.ts +29 -0
  32. package/src/logging/logger.test.ts +75 -0
  33. package/src/logging/logger.ts +147 -0
  34. package/src/logging/payload.test.ts +152 -0
  35. package/src/logging/payload.ts +121 -0
  36. package/src/mcp/handlers/search.handler.test.ts +28 -9
  37. package/src/mcp/handlers/search.handler.ts +69 -29
  38. package/src/mcp/handlers/store.handler.test.ts +1 -0
  39. package/src/mcp/server.ts +44 -16
  40. package/src/services/chunking.service.ts +23 -0
  41. package/src/services/index.service.test.ts +921 -1
  42. package/src/services/index.service.ts +76 -1
  43. package/src/services/index.ts +10 -1
  44. package/src/services/search.service.test.ts +573 -21
  45. package/src/services/search.service.ts +257 -105
  46. package/src/services/snippet.service.ts +28 -3
  47. package/src/services/token.service.test.ts +45 -0
  48. package/src/services/token.service.ts +33 -0
  49. package/src/types/result.test.ts +10 -0
  50. package/src/workers/spawn-worker.test.ts +19 -21
  51. package/tests/integration/cli-consistency.test.ts +1 -4
  52. package/vitest.config.ts +4 -0
  53. package/dist/chunk-5QMHZUC4.js.map +0 -1
  54. package/dist/chunk-BICFAWMN.js.map +0 -1
  55. package/dist/chunk-J7J6LXOJ.js.map +0 -1
  56. package/scripts/readme-version-updater.cjs +0 -18
@@ -22,27 +22,26 @@ describe('spawnBackgroundWorker', () => {
22
22
  it('should use tsx in development mode (src folder)', () => {
23
23
  spawnBackgroundWorker('test-job', '/test/data');
24
24
 
25
- const callArgs = mockSpawn.mock.calls[0];
26
- const command = callArgs?.[0];
27
- const args = callArgs?.[1];
25
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
26
+ const [command, args] = mockSpawn.mock.calls[0] as [string, string[], object];
28
27
 
29
28
  // In development (src folder), should use npx tsx
30
29
  expect(command).toBe('npx');
31
- expect(args?.[0]).toBe('tsx');
30
+ expect(args[0]).toBe('tsx');
32
31
  });
33
32
 
34
33
  it('should spawn a background worker process', () => {
35
34
  spawnBackgroundWorker('test-job-id', '/test/data/dir');
36
35
 
37
- expect(mockSpawn).toHaveBeenCalled();
38
- expect(mockUnref).toHaveBeenCalled();
36
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
37
+ expect(mockUnref).toHaveBeenCalledTimes(1);
39
38
  });
40
39
 
41
40
  it('should pass job ID as argument', () => {
42
41
  spawnBackgroundWorker('my-job-123', '/test/data/dir');
43
42
 
44
- const callArgs = mockSpawn.mock.calls[0];
45
- const args = callArgs?.[1];
43
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
44
+ const [, args] = mockSpawn.mock.calls[0] as [string, string[], object];
46
45
 
47
46
  expect(args).toContain('my-job-123');
48
47
  });
@@ -50,8 +49,8 @@ describe('spawnBackgroundWorker', () => {
50
49
  it('should spawn detached process with ignored stdio', () => {
51
50
  spawnBackgroundWorker('test-job', '/test/data/dir');
52
51
 
53
- const callArgs = mockSpawn.mock.calls[0];
54
- const options = callArgs?.[2];
52
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
53
+ const [, , options] = mockSpawn.mock.calls[0] as [string, string[], { detached: boolean; stdio: string }];
55
54
 
56
55
  expect(options).toMatchObject({
57
56
  detached: true,
@@ -63,10 +62,10 @@ describe('spawnBackgroundWorker', () => {
63
62
  const dataDir = '/custom/data/directory';
64
63
  spawnBackgroundWorker('test-job', dataDir);
65
64
 
66
- const callArgs = mockSpawn.mock.calls[0];
67
- const options = callArgs?.[2];
65
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
66
+ const [, , options] = mockSpawn.mock.calls[0] as [string, string[], { env: Record<string, string> }];
68
67
 
69
- expect(options?.env).toMatchObject({
68
+ expect(options.env).toMatchObject({
70
69
  ...process.env,
71
70
  BLUERA_DATA_DIR: dataDir
72
71
  });
@@ -76,10 +75,10 @@ describe('spawnBackgroundWorker', () => {
76
75
  const testDataDir = '.bluera/bluera-knowledge/data';
77
76
  spawnBackgroundWorker('job-456', testDataDir);
78
77
 
79
- const callArgs = mockSpawn.mock.calls[0];
80
- const options = callArgs?.[2];
78
+ expect(mockSpawn).toHaveBeenCalledTimes(1);
79
+ const [, , options] = mockSpawn.mock.calls[0] as [string, string[], { env: Record<string, string> }];
81
80
 
82
- expect(options?.env?.BLUERA_DATA_DIR).toBe(testDataDir);
81
+ expect(options.env.BLUERA_DATA_DIR).toBe(testDataDir);
83
82
  });
84
83
  });
85
84
 
@@ -116,13 +115,12 @@ describe('spawnBackgroundWorker (production mode)', () => {
116
115
 
117
116
  spawnProd('test-job', '/test/data');
118
117
 
119
- const callArgs = mockSpawnProd.mock.calls[0];
120
- const command = callArgs?.[0];
121
- const args = callArgs?.[1];
118
+ expect(mockSpawnProd).toHaveBeenCalledTimes(1);
119
+ const [command, args] = mockSpawnProd.mock.calls[0] as [string, string[]];
122
120
 
123
121
  // In production (dist folder), should use Node.js directly
124
122
  expect(command).toBe(process.execPath);
125
- expect(args?.[0]).toContain('background-worker-cli.js');
126
- expect(args?.[1]).toBe('test-job');
123
+ expect(args[0]).toContain('background-worker-cli.js');
124
+ expect(args[1]).toBe('test-job');
127
125
  });
128
126
  });
@@ -231,10 +231,7 @@ describe('CLI Consistency', () => {
231
231
  expect(result.stderr).toMatch(/^Error: Store not found: nonexistent/m);
232
232
  });
233
233
 
234
- it('uses consistent "Error:" prefix for crawl store not found', () => {
235
- const result = runCli('crawl https://example.com nonexistent');
236
- expect(result.stderr).toMatch(/^Error: /m);
237
- });
234
+ // Note: crawl auto-creates stores when not found, so no error test needed
238
235
  });
239
236
 
240
237
  describe('store delete Confirmation', () => {
package/vitest.config.ts CHANGED
@@ -19,6 +19,8 @@ export default defineConfig({
19
19
  'src/crawl/bridge.test.ts',
20
20
  'src/plugin/git-clone.test.ts',
21
21
  'src/services/project-root.service.test.ts',
22
+ 'src/workers/spawn-worker.test.ts',
23
+ 'src/logging/payload.test.ts',
22
24
  ],
23
25
  // Use forks pool for onnxruntime-node compatibility
24
26
  pool: 'forks',
@@ -38,6 +40,8 @@ export default defineConfig({
38
40
  'src/crawl/bridge.test.ts',
39
41
  'src/plugin/git-clone.test.ts',
40
42
  'src/services/project-root.service.test.ts',
43
+ 'src/workers/spawn-worker.test.ts',
44
+ 'src/logging/payload.test.ts',
41
45
  ],
42
46
  // Use forks pool for onnxruntime-node compatibility
43
47
  pool: 'forks',