bluera-knowledge 0.9.26 → 0.9.31
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/.claude/commands/commit.md +4 -7
- package/.claude/hooks/post-edit-check.sh +21 -24
- package/.claude/skills/atomic-commits/SKILL.md +6 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.env.example +4 -0
- package/.husky/pre-push +12 -2
- package/.versionrc.json +0 -4
- package/BUGS-FOUND.md +71 -0
- package/CHANGELOG.md +76 -0
- package/README.md +55 -20
- package/bun.lock +35 -1
- package/commands/crawl.md +2 -0
- package/dist/{chunk-BICFAWMN.js → chunk-2SJHNRXD.js} +73 -8
- package/dist/chunk-2SJHNRXD.js.map +1 -0
- package/dist/{chunk-J7J6LXOJ.js → chunk-OGEY66FZ.js} +106 -41
- package/dist/chunk-OGEY66FZ.js.map +1 -0
- package/dist/{chunk-5QMHZUC4.js → chunk-RWSXP3PQ.js} +482 -106
- package/dist/chunk-RWSXP3PQ.js.map +1 -0
- package/dist/index.js +73 -28
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/eslint.config.js +1 -1
- package/package.json +3 -1
- package/src/analysis/ast-parser.test.ts +46 -0
- package/src/cli/commands/crawl.test.ts +99 -12
- package/src/cli/commands/crawl.ts +76 -24
- package/src/cli/commands/store.test.ts +68 -1
- package/src/cli/commands/store.ts +9 -3
- package/src/crawl/article-converter.ts +36 -1
- package/src/crawl/bridge.ts +18 -7
- package/src/crawl/intelligent-crawler.ts +45 -4
- package/src/db/embeddings.test.ts +16 -0
- package/src/db/lance.test.ts +31 -0
- package/src/db/lance.ts +8 -0
- package/src/logging/index.ts +29 -0
- package/src/logging/logger.test.ts +75 -0
- package/src/logging/logger.ts +147 -0
- package/src/logging/payload.test.ts +152 -0
- package/src/logging/payload.ts +121 -0
- package/src/mcp/handlers/search.handler.test.ts +28 -9
- package/src/mcp/handlers/search.handler.ts +69 -29
- package/src/mcp/handlers/store.handler.test.ts +1 -0
- package/src/mcp/server.ts +44 -16
- package/src/services/chunking.service.ts +23 -0
- package/src/services/index.service.test.ts +921 -1
- package/src/services/index.service.ts +76 -1
- package/src/services/index.ts +20 -2
- package/src/services/search.service.test.ts +573 -21
- package/src/services/search.service.ts +257 -105
- package/src/services/services.test.ts +2 -2
- package/src/services/snippet.service.ts +28 -3
- package/src/services/store.service.test.ts +28 -0
- package/src/services/store.service.ts +4 -0
- package/src/services/token.service.test.ts +45 -0
- package/src/services/token.service.ts +33 -0
- package/src/types/result.test.ts +10 -0
- package/tests/integration/cli-consistency.test.ts +1 -4
- package/vitest.config.ts +4 -0
- package/dist/chunk-5QMHZUC4.js.map +0 -1
- package/dist/chunk-BICFAWMN.js.map +0 -1
- package/dist/chunk-J7J6LXOJ.js.map +0 -1
- package/scripts/readme-version-updater.cjs +0 -18
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token estimation service using Anthropic's recommended heuristic.
|
|
3
|
+
* For Claude 3+ models, Anthropic recommends ~3.5 characters per token
|
|
4
|
+
* for English text. This varies by language.
|
|
5
|
+
*
|
|
6
|
+
* Note: The official @anthropic-ai/tokenizer package only works for
|
|
7
|
+
* pre-Claude 3 models. For accurate counts on Claude 3+, use the
|
|
8
|
+
* Token Count API. This heuristic is suitable for display purposes.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const CHARS_PER_TOKEN = 3.5;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Estimate token count for a string using character-based heuristic.
|
|
15
|
+
* @param text - The text to estimate tokens for
|
|
16
|
+
* @returns Estimated token count (rounded up)
|
|
17
|
+
*/
|
|
18
|
+
export function estimateTokens(text: string): number {
|
|
19
|
+
if (!text) return 0;
|
|
20
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Format token count for display with appropriate suffix.
|
|
25
|
+
* @param tokens - Token count
|
|
26
|
+
* @returns Formatted string like "~1.2k" or "~847"
|
|
27
|
+
*/
|
|
28
|
+
export function formatTokenCount(tokens: number): string {
|
|
29
|
+
if (tokens >= 1000) {
|
|
30
|
+
return `~${(tokens / 1000).toFixed(1)}k`;
|
|
31
|
+
}
|
|
32
|
+
return `~${String(tokens)}`;
|
|
33
|
+
}
|
package/src/types/result.test.ts
CHANGED
|
@@ -28,6 +28,16 @@ describe('Result type', () => {
|
|
|
28
28
|
const result = err(new Error('failed'));
|
|
29
29
|
expect(() => unwrap(result)).toThrow('failed');
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('throws wrapped error for non-Error error value', () => {
|
|
33
|
+
const result = err('string error message');
|
|
34
|
+
expect(() => unwrap(result)).toThrow('string error message');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('converts non-string error to string', () => {
|
|
38
|
+
const result = err(404);
|
|
39
|
+
expect(() => unwrap(result)).toThrow('404');
|
|
40
|
+
});
|
|
31
41
|
});
|
|
32
42
|
|
|
33
43
|
describe('unwrapOr', () => {
|
|
@@ -231,10 +231,7 @@ describe('CLI Consistency', () => {
|
|
|
231
231
|
expect(result.stderr).toMatch(/^Error: Store not found: nonexistent/m);
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
|
|
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',
|