@hasna/knowledge 0.2.27 → 0.2.28

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 (58) hide show
  1. package/README.md +41 -0
  2. package/bin/open-knowledge-mcp.js +15 -7
  3. package/bin/open-knowledge.js +17 -17
  4. package/dist/agent.d.ts +35 -0
  5. package/dist/artifact-store.d.ts +63 -0
  6. package/dist/auth.d.ts +35 -0
  7. package/dist/embeddings.d.ts +77 -0
  8. package/dist/index.d.ts +20 -0
  9. package/dist/index.js +5709 -0
  10. package/dist/knowledge-db.d.ts +27 -0
  11. package/dist/manifest-ingest.d.ts +35 -0
  12. package/dist/outbox-consume.d.ts +25 -0
  13. package/dist/provenance.d.ts +50 -0
  14. package/dist/providers.d.ts +89 -0
  15. package/dist/reindex.d.ts +37 -0
  16. package/dist/remote-client.d.ts +108 -0
  17. package/dist/retrieval.d.ts +71 -0
  18. package/dist/safety.d.ts +70 -0
  19. package/dist/sdk.d.ts +72 -0
  20. package/dist/search.d.ts +65 -0
  21. package/dist/service.d.ts +117 -0
  22. package/dist/source-ingest.d.ts +18 -0
  23. package/dist/source-ref.d.ts +30 -0
  24. package/dist/source-resolver.d.ts +92 -0
  25. package/dist/storage-contract.d.ts +106 -0
  26. package/dist/web-search.d.ts +40 -0
  27. package/dist/wiki-compiler.d.ts +67 -0
  28. package/dist/wiki-layout.d.ts +23 -0
  29. package/dist/workspace.d.ts +111 -0
  30. package/package.json +15 -7
  31. package/src/agent.ts +0 -367
  32. package/src/artifact-store.ts +0 -184
  33. package/src/auth.ts +0 -123
  34. package/src/cli.ts +0 -1184
  35. package/src/embeddings.ts +0 -516
  36. package/src/knowledge-db.ts +0 -354
  37. package/src/manifest-ingest.ts +0 -515
  38. package/src/mcp-http.js +0 -110
  39. package/src/mcp.js +0 -1503
  40. package/src/outbox-consume.ts +0 -463
  41. package/src/provenance.ts +0 -93
  42. package/src/providers.ts +0 -308
  43. package/src/reindex.ts +0 -260
  44. package/src/remote-client.ts +0 -268
  45. package/src/retrieval.ts +0 -326
  46. package/src/safety.ts +0 -265
  47. package/src/schema.js +0 -25
  48. package/src/search.ts +0 -510
  49. package/src/service.ts +0 -443
  50. package/src/source-ingest.ts +0 -268
  51. package/src/source-ref.ts +0 -104
  52. package/src/source-resolver.ts +0 -436
  53. package/src/storage-contract.ts +0 -346
  54. package/src/store.ts +0 -113
  55. package/src/web-search.ts +0 -330
  56. package/src/wiki-compiler.ts +0 -711
  57. package/src/wiki-layout.ts +0 -251
  58. package/src/workspace.ts +0 -251
package/README.md CHANGED
@@ -32,6 +32,47 @@ Or run directly:
32
32
  bun x @hasna/knowledge add "My Note" "Some content"
33
33
  ```
34
34
 
35
+ ## SDK
36
+
37
+ Apps can install the package and use the public SDK without shelling out to the
38
+ CLI or importing internal source files:
39
+
40
+ ```ts
41
+ import { createKnowledgeClient } from '@hasna/knowledge';
42
+
43
+ const knowledge = createKnowledgeClient({
44
+ scope: 'project',
45
+ cwd: process.cwd(),
46
+ });
47
+
48
+ await knowledge.setup({ mode: 'hosted', canonicalHasnaXyz: true });
49
+ await knowledge.ingest.source('file:///absolute/path/to/handbook.md', 'knowledge_index');
50
+
51
+ const results = await knowledge.search({
52
+ query: 'company wiki policy',
53
+ semantic: true,
54
+ limit: 5,
55
+ });
56
+
57
+ const answer = await knowledge.ask('How do we cite handbook policy?', {
58
+ semantic: true,
59
+ limit: 5,
60
+ });
61
+ ```
62
+
63
+ The stable package surface is the top-level `@hasna/knowledge` export:
64
+ `createKnowledgeClient`, `createKnowledgeSdk`, service/result types, workspace
65
+ helpers, source-ref helpers, storage contracts, search/retrieval types,
66
+ provider helpers, and remote contract types. CLI and MCP entrypoints remain
67
+ available as package bins.
68
+
69
+ The SDK uses the same `.hasna/apps/knowledge` project workspace as the CLI. In
70
+ local mode it writes the SQLite catalog and generated artifacts under that path.
71
+ In hosted/canonical mode it can point generated artifacts at S3 while keeping
72
+ raw source ownership outside open-knowledge. Source files remain referenced via
73
+ `open-files://`, `file://`, `s3://`, or web refs; open-knowledge stores derived
74
+ chunks, citations, indexes, run logs, and generated wiki artifacts.
75
+
35
76
  ## Quick Start
36
77
 
37
78
  ```bash
@@ -13660,9 +13660,17 @@ import { existsSync as existsSync8, readFileSync as readFileSync8, writeFileSync
13660
13660
  // package.json
13661
13661
  var package_default = {
13662
13662
  name: "@hasna/knowledge",
13663
- version: "0.2.27",
13663
+ version: "0.2.28",
13664
13664
  description: "Agent-friendly local knowledge CLI with JSON output, pagination, and safe destructive actions",
13665
13665
  type: "module",
13666
+ exports: {
13667
+ ".": {
13668
+ import: "./dist/index.js",
13669
+ types: "./dist/index.d.ts"
13670
+ }
13671
+ },
13672
+ main: "./dist/index.js",
13673
+ types: "./dist/index.d.ts",
13666
13674
  bin: {
13667
13675
  knowledge: "bin/open-knowledge.js",
13668
13676
  "open-knowledge": "bin/open-knowledge.js",
@@ -13670,7 +13678,7 @@ var package_default = {
13670
13678
  },
13671
13679
  files: [
13672
13680
  "bin",
13673
- "src",
13681
+ "dist",
13674
13682
  "docs",
13675
13683
  "LICENSE",
13676
13684
  "README.md"
@@ -13678,9 +13686,8 @@ var package_default = {
13678
13686
  scripts: {
13679
13687
  test: "bun test",
13680
13688
  "test:cli": "bun test tests/cli.test.ts",
13681
- build: "bun build --target=bun --outfile=bin/open-knowledge.js --minify --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/cli.ts && bun build --target=bun --outfile=bin/open-knowledge-mcp.js --external @modelcontextprotocol/sdk --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/mcp.js",
13682
- prepublishOnly: "bun run build",
13683
- postinstall: "bun run build"
13689
+ build: "rm -rf dist && bun build --target=bun --outfile=bin/open-knowledge.js --minify --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/cli.ts && bun build --target=bun --outfile=bin/open-knowledge-mcp.js --external @modelcontextprotocol/sdk --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek src/mcp.js && bun build ./src/index.ts --outdir ./dist --target bun --external @aws-sdk/client-s3 --external @aws-sdk/credential-providers --external ai --external @ai-sdk/openai --external @ai-sdk/anthropic --external @ai-sdk/deepseek && bunx tsc -p tsconfig.build.json",
13690
+ prepublishOnly: "bun run build"
13684
13691
  },
13685
13692
  keywords: [
13686
13693
  "knowledge",
@@ -13709,12 +13716,13 @@ var package_default = {
13709
13716
  node: ">=18"
13710
13717
  },
13711
13718
  dependencies: {
13712
- "@aws-sdk/client-s3": "^3.1063.0",
13713
- "@aws-sdk/credential-providers": "^3.1063.0",
13714
13719
  "@ai-sdk/anthropic": "^3.0.81",
13715
13720
  "@ai-sdk/deepseek": "^2.0.35",
13716
13721
  "@ai-sdk/openai": "^3.0.68",
13722
+ "@aws-sdk/client-s3": "^3.1063.0",
13723
+ "@aws-sdk/credential-providers": "^3.1063.0",
13717
13724
  "@modelcontextprotocol/sdk": "^1.29.0",
13725
+ "@types/json-schema": "^7.0.15",
13718
13726
  ai: "^6.0.197",
13719
13727
  zod: "^4.3.6"
13720
13728
  },