@soederpop/luca 0.0.2
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.md +71 -0
- package/README.md +78 -0
- package/bun.lock +2928 -0
- package/bunfig.toml +3 -0
- package/commands/audit-docs.ts +740 -0
- package/commands/build-scaffolds.ts +154 -0
- package/commands/generate-api-docs.ts +114 -0
- package/commands/update-introspection.ts +67 -0
- package/docs/CLI.md +335 -0
- package/docs/README.md +88 -0
- package/docs/TABLE-OF-CONTENTS.md +157 -0
- package/docs/apis/clients/elevenlabs.md +84 -0
- package/docs/apis/clients/graph.md +56 -0
- package/docs/apis/clients/openai.md +69 -0
- package/docs/apis/clients/rest.md +41 -0
- package/docs/apis/clients/websocket.md +107 -0
- package/docs/apis/features/agi/assistant.md +471 -0
- package/docs/apis/features/agi/assistants-manager.md +154 -0
- package/docs/apis/features/agi/claude-code.md +602 -0
- package/docs/apis/features/agi/conversation-history.md +352 -0
- package/docs/apis/features/agi/conversation.md +333 -0
- package/docs/apis/features/agi/docs-reader.md +121 -0
- package/docs/apis/features/agi/openai-codex.md +318 -0
- package/docs/apis/features/agi/openapi.md +138 -0
- package/docs/apis/features/agi/semantic-search.md +387 -0
- package/docs/apis/features/agi/skills-library.md +216 -0
- package/docs/apis/features/node/container-link.md +133 -0
- package/docs/apis/features/node/content-db.md +313 -0
- package/docs/apis/features/node/disk-cache.md +379 -0
- package/docs/apis/features/node/dns.md +651 -0
- package/docs/apis/features/node/docker.md +705 -0
- package/docs/apis/features/node/downloader.md +81 -0
- package/docs/apis/features/node/esbuild.md +59 -0
- package/docs/apis/features/node/file-manager.md +182 -0
- package/docs/apis/features/node/fs.md +581 -0
- package/docs/apis/features/node/git.md +330 -0
- package/docs/apis/features/node/google-auth.md +174 -0
- package/docs/apis/features/node/google-calendar.md +187 -0
- package/docs/apis/features/node/google-docs.md +151 -0
- package/docs/apis/features/node/google-drive.md +225 -0
- package/docs/apis/features/node/google-sheets.md +179 -0
- package/docs/apis/features/node/grep.md +290 -0
- package/docs/apis/features/node/helpers.md +135 -0
- package/docs/apis/features/node/ink.md +334 -0
- package/docs/apis/features/node/ipc-socket.md +260 -0
- package/docs/apis/features/node/json-tree.md +86 -0
- package/docs/apis/features/node/launcher-app-command-listener.md +145 -0
- package/docs/apis/features/node/networking.md +281 -0
- package/docs/apis/features/node/nlp.md +133 -0
- package/docs/apis/features/node/opener.md +97 -0
- package/docs/apis/features/node/os.md +118 -0
- package/docs/apis/features/node/package-finder.md +402 -0
- package/docs/apis/features/node/postgres.md +212 -0
- package/docs/apis/features/node/proc.md +430 -0
- package/docs/apis/features/node/process-manager.md +210 -0
- package/docs/apis/features/node/python.md +278 -0
- package/docs/apis/features/node/repl.md +88 -0
- package/docs/apis/features/node/runpod.md +673 -0
- package/docs/apis/features/node/secure-shell.md +169 -0
- package/docs/apis/features/node/semantic-search.md +401 -0
- package/docs/apis/features/node/sqlite.md +211 -0
- package/docs/apis/features/node/telegram.md +254 -0
- package/docs/apis/features/node/tts.md +118 -0
- package/docs/apis/features/node/ui.md +703 -0
- package/docs/apis/features/node/vault.md +64 -0
- package/docs/apis/features/node/vm.md +84 -0
- package/docs/apis/features/node/window-manager.md +337 -0
- package/docs/apis/features/node/yaml-tree.md +85 -0
- package/docs/apis/features/node/yaml.md +176 -0
- package/docs/apis/features/web/asset-loader.md +47 -0
- package/docs/apis/features/web/container-link.md +133 -0
- package/docs/apis/features/web/esbuild.md +59 -0
- package/docs/apis/features/web/helpers.md +135 -0
- package/docs/apis/features/web/network.md +30 -0
- package/docs/apis/features/web/speech.md +55 -0
- package/docs/apis/features/web/vault.md +64 -0
- package/docs/apis/features/web/vm.md +84 -0
- package/docs/apis/features/web/voice.md +67 -0
- package/docs/apis/servers/express.md +127 -0
- package/docs/apis/servers/mcp.md +213 -0
- package/docs/apis/servers/websocket.md +99 -0
- package/docs/documentation-audit.md +134 -0
- package/docs/examples/content-db.md +77 -0
- package/docs/examples/disk-cache.md +83 -0
- package/docs/examples/docker.md +101 -0
- package/docs/examples/downloader.md +70 -0
- package/docs/examples/esbuild.md +80 -0
- package/docs/examples/file-manager.md +82 -0
- package/docs/examples/fs.md +83 -0
- package/docs/examples/git.md +85 -0
- package/docs/examples/google-auth.md +88 -0
- package/docs/examples/google-calendar.md +94 -0
- package/docs/examples/google-docs.md +82 -0
- package/docs/examples/google-drive.md +96 -0
- package/docs/examples/google-sheets.md +95 -0
- package/docs/examples/grep.md +85 -0
- package/docs/examples/ink-blocks.md +75 -0
- package/docs/examples/ink-renderer.md +41 -0
- package/docs/examples/ink.md +103 -0
- package/docs/examples/ipc-socket.md +103 -0
- package/docs/examples/json-tree.md +91 -0
- package/docs/examples/launcher-app-command-listener.md +120 -0
- package/docs/examples/networking.md +58 -0
- package/docs/examples/nlp.md +91 -0
- package/docs/examples/opener.md +78 -0
- package/docs/examples/os.md +72 -0
- package/docs/examples/package-finder.md +89 -0
- package/docs/examples/port-exposer.md +89 -0
- package/docs/examples/postgres.md +91 -0
- package/docs/examples/proc.md +81 -0
- package/docs/examples/process-manager.md +79 -0
- package/docs/examples/python.md +91 -0
- package/docs/examples/repl.md +93 -0
- package/docs/examples/runpod.md +119 -0
- package/docs/examples/secure-shell.md +92 -0
- package/docs/examples/sqlite.md +86 -0
- package/docs/examples/telegram.md +77 -0
- package/docs/examples/tts.md +86 -0
- package/docs/examples/ui.md +80 -0
- package/docs/examples/vault.md +70 -0
- package/docs/examples/vm.md +86 -0
- package/docs/examples/window-manager.md +125 -0
- package/docs/examples/yaml-tree.md +93 -0
- package/docs/examples/yaml.md +104 -0
- package/docs/ideas/class-registration-refactor-possibilities.md +197 -0
- package/docs/ideas/container-use-api.md +9 -0
- package/docs/ideas/easy-auth-for-express-servers-and-luca-serve.md +0 -0
- package/docs/ideas/feature-stacks.md +22 -0
- package/docs/ideas/luca-cli-self-sufficiency-demo.md +23 -0
- package/docs/ideas/mcp-design.md +9 -0
- package/docs/ideas/web-container-debugging-feature.md +13 -0
- package/docs/introspection-audit.md +49 -0
- package/docs/introspection.md +154 -0
- package/docs/mcp/readme.md +162 -0
- package/docs/models.ts +38 -0
- package/docs/philosophy.md +85 -0
- package/docs/principles.md +7 -0
- package/docs/prompts/audit-codebase-for-failures-to-use-the-container.md +34 -0
- package/docs/prompts/mcp-test-easy-command.md +27 -0
- package/docs/reports/assistant-bugs.md +38 -0
- package/docs/reports/attach-pattern-usage.md +18 -0
- package/docs/reports/code-audit-results.md +391 -0
- package/docs/reports/introspection-audit-tasks.md +378 -0
- package/docs/reports/luca-mcp-improvements.md +128 -0
- package/docs/scaffolds/client.md +140 -0
- package/docs/scaffolds/command.md +106 -0
- package/docs/scaffolds/endpoint.md +176 -0
- package/docs/scaffolds/feature.md +148 -0
- package/docs/scaffolds/server.md +187 -0
- package/docs/tasks/web-container-helper-discovery.md +71 -0
- package/docs/todos.md +1 -0
- package/docs/tutorials/01-getting-started.md +106 -0
- package/docs/tutorials/02-container.md +210 -0
- package/docs/tutorials/03-scripts.md +194 -0
- package/docs/tutorials/04-features-overview.md +196 -0
- package/docs/tutorials/05-state-and-events.md +171 -0
- package/docs/tutorials/06-servers.md +157 -0
- package/docs/tutorials/07-endpoints.md +198 -0
- package/docs/tutorials/08-commands.md +171 -0
- package/docs/tutorials/09-clients.md +162 -0
- package/docs/tutorials/10-creating-features.md +198 -0
- package/docs/tutorials/11-contentbase.md +191 -0
- package/docs/tutorials/12-assistants.md +215 -0
- package/docs/tutorials/13-introspection.md +147 -0
- package/docs/tutorials/14-type-system.md +174 -0
- package/docs/tutorials/15-project-patterns.md +222 -0
- package/docs/tutorials/16-google-features.md +534 -0
- package/docs/tutorials/17-tui-blocks.md +530 -0
- package/docs/tutorials/18-semantic-search.md +334 -0
- package/index.ts +1 -0
- package/luca.console.ts +9 -0
- package/main.py +6 -0
- package/package.json +154 -0
- package/pyproject.toml +7 -0
- package/scripts/animations/chrome-glitch.ts +55 -0
- package/scripts/animations/index.ts +16 -0
- package/scripts/animations/neon-pulse.ts +64 -0
- package/scripts/animations/types.ts +6 -0
- package/scripts/build-web.ts +28 -0
- package/scripts/examples/ask-luca-expert.ts +42 -0
- package/scripts/examples/assistant-questions.ts +12 -0
- package/scripts/examples/excalidraw-expert.ts +75 -0
- package/scripts/examples/expert-chat.ts +0 -0
- package/scripts/examples/file-manager.ts +14 -0
- package/scripts/examples/ideas.ts +12 -0
- package/scripts/examples/interactive-chat.ts +20 -0
- package/scripts/examples/openai-tool-calls.ts +113 -0
- package/scripts/examples/opening-a-web-browser.ts +5 -0
- package/scripts/examples/telegram-bot.ts +79 -0
- package/scripts/examples/telegram-ink-ui.ts +302 -0
- package/scripts/examples/using-assistant-with-mcp.ts +560 -0
- package/scripts/examples/using-claude-code.ts +10 -0
- package/scripts/examples/using-contentdb.ts +35 -0
- package/scripts/examples/using-conversations.ts +35 -0
- package/scripts/examples/using-disk-cache.ts +10 -0
- package/scripts/examples/using-docker-shell.ts +75 -0
- package/scripts/examples/using-elevenlabs.ts +25 -0
- package/scripts/examples/using-google-calendar.ts +57 -0
- package/scripts/examples/using-google-docs.ts +74 -0
- package/scripts/examples/using-google-drive.ts +74 -0
- package/scripts/examples/using-google-sheets.ts +89 -0
- package/scripts/examples/using-nlp.ts +55 -0
- package/scripts/examples/using-ollama.ts +10 -0
- package/scripts/examples/using-openai-codex.ts +23 -0
- package/scripts/examples/using-postgres.ts +55 -0
- package/scripts/examples/using-runpod.ts +32 -0
- package/scripts/examples/using-tts.ts +40 -0
- package/scripts/examples/vm-loading-esm-modules.ts +16 -0
- package/scripts/scaffold.ts +391 -0
- package/scripts/scratch.ts +15 -0
- package/scripts/test-command-listener.ts +123 -0
- package/scripts/test-window-manager-lifecycle.ts +86 -0
- package/scripts/test-window-manager.ts +43 -0
- package/scripts/update-introspection-data.ts +58 -0
- package/src/agi/README.md +14 -0
- package/src/agi/container.server.ts +114 -0
- package/src/agi/endpoints/ask.ts +60 -0
- package/src/agi/endpoints/conversations/[id].ts +45 -0
- package/src/agi/endpoints/conversations.ts +31 -0
- package/src/agi/endpoints/experts.ts +37 -0
- package/src/agi/features/assistant.ts +767 -0
- package/src/agi/features/assistants-manager.ts +260 -0
- package/src/agi/features/claude-code.ts +1111 -0
- package/src/agi/features/conversation-history.ts +497 -0
- package/src/agi/features/conversation.ts +799 -0
- package/src/agi/features/openai-codex.ts +631 -0
- package/src/agi/features/openapi.ts +438 -0
- package/src/agi/features/skills-library.ts +425 -0
- package/src/agi/index.ts +6 -0
- package/src/agi/lib/token-counter.ts +122 -0
- package/src/browser.ts +25 -0
- package/src/bus.ts +100 -0
- package/src/cli/cli.ts +70 -0
- package/src/client.ts +461 -0
- package/src/clients/civitai/index.ts +541 -0
- package/src/clients/client-template.ts +41 -0
- package/src/clients/comfyui/index.ts +597 -0
- package/src/clients/elevenlabs/index.ts +291 -0
- package/src/clients/openai/index.ts +451 -0
- package/src/clients/supabase/index.ts +366 -0
- package/src/command.ts +164 -0
- package/src/commands/chat.ts +182 -0
- package/src/commands/console.ts +192 -0
- package/src/commands/describe.ts +433 -0
- package/src/commands/eval.ts +116 -0
- package/src/commands/help.ts +214 -0
- package/src/commands/index.ts +14 -0
- package/src/commands/mcp.ts +64 -0
- package/src/commands/prompt.ts +807 -0
- package/src/commands/run.ts +257 -0
- package/src/commands/sandbox-mcp.ts +439 -0
- package/src/commands/scaffold.ts +79 -0
- package/src/commands/serve.ts +172 -0
- package/src/container.ts +781 -0
- package/src/endpoint.ts +340 -0
- package/src/feature.ts +75 -0
- package/src/hash-object.ts +97 -0
- package/src/helper.ts +543 -0
- package/src/introspection/generated.agi.ts +23388 -0
- package/src/introspection/generated.node.ts +18899 -0
- package/src/introspection/generated.web.ts +2021 -0
- package/src/introspection/index.ts +256 -0
- package/src/introspection/scan.ts +912 -0
- package/src/node/container.ts +354 -0
- package/src/node/feature.ts +13 -0
- package/src/node/features/container-link.ts +558 -0
- package/src/node/features/content-db.ts +475 -0
- package/src/node/features/disk-cache.ts +382 -0
- package/src/node/features/dns.ts +655 -0
- package/src/node/features/docker.ts +912 -0
- package/src/node/features/downloader.ts +92 -0
- package/src/node/features/esbuild.ts +68 -0
- package/src/node/features/file-manager.ts +357 -0
- package/src/node/features/fs.ts +534 -0
- package/src/node/features/git.ts +492 -0
- package/src/node/features/google-auth.ts +502 -0
- package/src/node/features/google-calendar.ts +300 -0
- package/src/node/features/google-docs.ts +404 -0
- package/src/node/features/google-drive.ts +339 -0
- package/src/node/features/google-sheets.ts +279 -0
- package/src/node/features/grep.ts +406 -0
- package/src/node/features/helpers.ts +374 -0
- package/src/node/features/ink.ts +490 -0
- package/src/node/features/ipc-socket.ts +459 -0
- package/src/node/features/json-tree.ts +188 -0
- package/src/node/features/launcher-app-command-listener.ts +388 -0
- package/src/node/features/networking.ts +925 -0
- package/src/node/features/nlp.ts +211 -0
- package/src/node/features/opener.ts +166 -0
- package/src/node/features/os.ts +157 -0
- package/src/node/features/package-finder.ts +539 -0
- package/src/node/features/port-exposer.ts +342 -0
- package/src/node/features/postgres.ts +273 -0
- package/src/node/features/proc.ts +502 -0
- package/src/node/features/process-manager.ts +542 -0
- package/src/node/features/python.ts +444 -0
- package/src/node/features/repl.ts +194 -0
- package/src/node/features/runpod.ts +802 -0
- package/src/node/features/secure-shell.ts +248 -0
- package/src/node/features/semantic-search.ts +924 -0
- package/src/node/features/sqlite.ts +289 -0
- package/src/node/features/telegram.ts +342 -0
- package/src/node/features/tts.ts +184 -0
- package/src/node/features/ui.ts +857 -0
- package/src/node/features/vault.ts +164 -0
- package/src/node/features/vm.ts +312 -0
- package/src/node/features/window-manager.ts +804 -0
- package/src/node/features/yaml-tree.ts +149 -0
- package/src/node/features/yaml.ts +132 -0
- package/src/node.ts +70 -0
- package/src/react/index.ts +175 -0
- package/src/registry.ts +199 -0
- package/src/scaffolds/generated.ts +1613 -0
- package/src/scaffolds/template.ts +37 -0
- package/src/schemas/base.ts +255 -0
- package/src/server.ts +135 -0
- package/src/servers/express.ts +209 -0
- package/src/servers/mcp.ts +805 -0
- package/src/servers/socket.ts +120 -0
- package/src/state.ts +101 -0
- package/src/web/clients/socket.ts +82 -0
- package/src/web/container.ts +74 -0
- package/src/web/extension.ts +30 -0
- package/src/web/feature.ts +12 -0
- package/src/web/features/asset-loader.ts +64 -0
- package/src/web/features/container-link.ts +385 -0
- package/src/web/features/esbuild.ts +79 -0
- package/src/web/features/helpers.ts +267 -0
- package/src/web/features/network.ts +61 -0
- package/src/web/features/speech.ts +87 -0
- package/src/web/features/vault.ts +189 -0
- package/src/web/features/vm.ts +78 -0
- package/src/web/features/voice-recognition.ts +129 -0
- package/src/web/shims/isomorphic-vm.ts +149 -0
- package/test/bus.test.ts +134 -0
- package/test/clients-servers.test.ts +216 -0
- package/test/container-link.test.ts +274 -0
- package/test/features.test.ts +160 -0
- package/test/integration.test.ts +787 -0
- package/test/node-container.test.ts +121 -0
- package/test/rate-limit.test.ts +272 -0
- package/test/semantic-search.test.ts +550 -0
- package/test/state.test.ts +121 -0
- package/test-integration/assistant.test.ts +138 -0
- package/test-integration/assistants-manager.test.ts +123 -0
- package/test-integration/claude-code.test.ts +98 -0
- package/test-integration/conversation-history.test.ts +205 -0
- package/test-integration/conversation.test.ts +137 -0
- package/test-integration/elevenlabs.test.ts +55 -0
- package/test-integration/google-services.test.ts +80 -0
- package/test-integration/helpers.ts +89 -0
- package/test-integration/openai-codex.test.ts +93 -0
- package/test-integration/runpod.test.ts +58 -0
- package/test-integration/server-endpoints.test.ts +97 -0
- package/test-integration/skills-library.test.ts +157 -0
- package/test-integration/telegram.test.ts +46 -0
- package/tsconfig.json +58 -0
- package/uv.lock +8 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# ContentDb (features.contentDb)
|
|
2
|
+
|
|
3
|
+
Provides access to a Contentbase Collection for a folder of structured markdown files. Models are defined in the collection's models.ts file and auto-discovered on load. This feature is a thin wrapper that manages the collection lifecycle and provides convenience accessors for models and documents.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
container.feature('contentDb', {
|
|
9
|
+
// Root directory path containing the structured markdown collection
|
|
10
|
+
rootPath,
|
|
11
|
+
})
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Options (Zod v4 schema)
|
|
15
|
+
|
|
16
|
+
| Property | Type | Description |
|
|
17
|
+
|----------|------|-------------|
|
|
18
|
+
| `rootPath` | `string` | Root directory path containing the structured markdown collection |
|
|
19
|
+
|
|
20
|
+
## Methods
|
|
21
|
+
|
|
22
|
+
### query
|
|
23
|
+
|
|
24
|
+
Query documents belonging to a specific model definition.
|
|
25
|
+
|
|
26
|
+
**Parameters:**
|
|
27
|
+
|
|
28
|
+
| Name | Type | Required | Description |
|
|
29
|
+
|------|------|----------|-------------|
|
|
30
|
+
| `model` | `T` | ✓ | The model definition to query against |
|
|
31
|
+
|
|
32
|
+
**Returns:** `void`
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
36
|
+
await contentDb.load()
|
|
37
|
+
const articles = await contentDb.query(contentDb.models.Article).fetchAll()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### parseMarkdownAtPath
|
|
43
|
+
|
|
44
|
+
Parse a markdown file at the given path without loading the full collection.
|
|
45
|
+
|
|
46
|
+
**Parameters:**
|
|
47
|
+
|
|
48
|
+
| Name | Type | Required | Description |
|
|
49
|
+
|------|------|----------|-------------|
|
|
50
|
+
| `path` | `string` | ✓ | Absolute or relative path to the markdown file |
|
|
51
|
+
|
|
52
|
+
**Returns:** `void`
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const doc = contentDb.parseMarkdownAtPath('./docs/getting-started.md')
|
|
56
|
+
console.log(doc.frontmatter, doc.content)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### load
|
|
62
|
+
|
|
63
|
+
Load the collection, discovering models from models.ts and parsing all documents.
|
|
64
|
+
|
|
65
|
+
**Returns:** `Promise<ContentDb>`
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
69
|
+
await contentDb.load()
|
|
70
|
+
console.log(contentDb.isLoaded) // true
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### read
|
|
76
|
+
|
|
77
|
+
Read a single document by its path ID, optionally filtering to specific sections. The document title (H1) is always included in the output. When using `include`, the leading content (paragraphs between the H1 and first H2) is also included by default, controlled by the `leadingContent` option. When `include` is provided, only those sections are returned (via extractSections in flat mode). When `exclude` is provided, those sections are removed from the full document. If both are set, `include` takes precedence.
|
|
78
|
+
|
|
79
|
+
**Parameters:**
|
|
80
|
+
|
|
81
|
+
| Name | Type | Required | Description |
|
|
82
|
+
|------|------|----------|-------------|
|
|
83
|
+
| `idStringOrObject` | `string | { id: string }` | ✓ | Document path ID string, or an object with an `id` property |
|
|
84
|
+
| `options` | `{ exclude?: string[], include?: string[], meta?: boolean, leadingContent?: boolean }` | | Optional filtering and formatting options |
|
|
85
|
+
|
|
86
|
+
`{ exclude?: string[], include?: string[], meta?: boolean, leadingContent?: boolean }` properties:
|
|
87
|
+
|
|
88
|
+
| Property | Type | Description |
|
|
89
|
+
|----------|------|-------------|
|
|
90
|
+
| `include` | `any` | Only return sections matching these heading names |
|
|
91
|
+
| `exclude` | `any` | Remove sections matching these heading names |
|
|
92
|
+
| `meta` | `any` | Whether to include YAML frontmatter in the output (default: false) |
|
|
93
|
+
| `leadingContent` | `any` | Include content between the H1 and first H2 when using include filter (default: true) |
|
|
94
|
+
|
|
95
|
+
**Returns:** `Promise<string>`
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
await contentDb.read('guides/intro')
|
|
99
|
+
await contentDb.read('guides/intro', { include: ['Installation', 'Usage'] })
|
|
100
|
+
await contentDb.read('guides/intro', { exclude: ['Changelog'], meta: true })
|
|
101
|
+
await contentDb.read('guides/intro', { include: ['API'], leadingContent: false })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### readMultiple
|
|
107
|
+
|
|
108
|
+
Read multiple documents by their path IDs, concatenated into a single string. By default each document is wrapped in `<!-- BEGIN: id -->` / `<!-- END: id -->` dividers for easy identification. Supports the same filtering options as {@link read}.
|
|
109
|
+
|
|
110
|
+
**Parameters:**
|
|
111
|
+
|
|
112
|
+
| Name | Type | Required | Description |
|
|
113
|
+
|------|------|----------|-------------|
|
|
114
|
+
| `ids` | `string[] | { id: string }[]` | ✓ | Array of document path ID strings or objects with `id` properties |
|
|
115
|
+
| `options` | `{ exclude?: string[], include?: string[], meta?: boolean, leadingContent?: boolean, dividers?: boolean }` | | Optional filtering and formatting options (applied to each document) |
|
|
116
|
+
|
|
117
|
+
`{ exclude?: string[], include?: string[], meta?: boolean, leadingContent?: boolean, dividers?: boolean }` properties:
|
|
118
|
+
|
|
119
|
+
| Property | Type | Description |
|
|
120
|
+
|----------|------|-------------|
|
|
121
|
+
| `dividers` | `any` | Wrap each document in BEGIN/END comment dividers showing the ID (default: true) |
|
|
122
|
+
|
|
123
|
+
**Returns:** `Promise<string>`
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
await contentDb.readMultiple(['guides/intro', 'guides/setup'])
|
|
127
|
+
await contentDb.readMultiple([{ id: 'guides/intro' }], { include: ['Overview'], dividers: false })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### generateTableOfContents
|
|
133
|
+
|
|
134
|
+
**Returns:** `void`
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
### generateModelSummary
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
|
|
142
|
+
| Name | Type | Required | Description |
|
|
143
|
+
|------|------|----------|-------------|
|
|
144
|
+
| `options` | `any` | ✓ | Parameter options |
|
|
145
|
+
|
|
146
|
+
**Returns:** `void`
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### search
|
|
151
|
+
|
|
152
|
+
BM25 keyword search across indexed documents. If no search index exists, throws with an actionable message.
|
|
153
|
+
|
|
154
|
+
**Parameters:**
|
|
155
|
+
|
|
156
|
+
| Name | Type | Required | Description |
|
|
157
|
+
|------|------|----------|-------------|
|
|
158
|
+
| `query` | `string` | ✓ | Parameter query |
|
|
159
|
+
| `options` | `{ limit?: number; model?: string; where?: Record<string, any> }` | | Parameter options |
|
|
160
|
+
|
|
161
|
+
**Returns:** `void`
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### vectorSearch
|
|
166
|
+
|
|
167
|
+
Vector similarity search using embeddings. Finds conceptually related documents even without keyword matches.
|
|
168
|
+
|
|
169
|
+
**Parameters:**
|
|
170
|
+
|
|
171
|
+
| Name | Type | Required | Description |
|
|
172
|
+
|------|------|----------|-------------|
|
|
173
|
+
| `query` | `string` | ✓ | Parameter query |
|
|
174
|
+
| `options` | `{ limit?: number; model?: string; where?: Record<string, any> }` | | Parameter options |
|
|
175
|
+
|
|
176
|
+
**Returns:** `void`
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### hybridSearch
|
|
181
|
+
|
|
182
|
+
Combined keyword + semantic search with Reciprocal Rank Fusion. Best for general questions about the collection.
|
|
183
|
+
|
|
184
|
+
**Parameters:**
|
|
185
|
+
|
|
186
|
+
| Name | Type | Required | Description |
|
|
187
|
+
|------|------|----------|-------------|
|
|
188
|
+
| `query` | `string` | ✓ | Parameter query |
|
|
189
|
+
| `options` | `{ limit?: number; model?: string; where?: Record<string, any>; ftsWeight?: number; vecWeight?: number }` | | Parameter options |
|
|
190
|
+
|
|
191
|
+
**Returns:** `void`
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### buildSearchIndex
|
|
196
|
+
|
|
197
|
+
Build the search index from all documents in the collection. Chunks documents and generates embeddings.
|
|
198
|
+
|
|
199
|
+
**Parameters:**
|
|
200
|
+
|
|
201
|
+
| Name | Type | Required | Description |
|
|
202
|
+
|------|------|----------|-------------|
|
|
203
|
+
| `options` | `{ force?: boolean; embeddingProvider?: string; embeddingModel?: string; onProgress?: (indexed: number, total: number) => void }` | | Parameter options |
|
|
204
|
+
|
|
205
|
+
**Returns:** `void`
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
### rebuildSearchIndex
|
|
210
|
+
|
|
211
|
+
Rebuild the entire search index from scratch.
|
|
212
|
+
|
|
213
|
+
**Parameters:**
|
|
214
|
+
|
|
215
|
+
| Name | Type | Required | Description |
|
|
216
|
+
|------|------|----------|-------------|
|
|
217
|
+
| `options` | `{ embeddingProvider?: string; embeddingModel?: string; onProgress?: (indexed: number, total: number) => void }` | | Parameter options |
|
|
218
|
+
|
|
219
|
+
**Returns:** `void`
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
## Getters
|
|
224
|
+
|
|
225
|
+
| Property | Type | Description |
|
|
226
|
+
|----------|------|-------------|
|
|
227
|
+
| `isLoaded` | `any` | Whether the content database has been loaded. |
|
|
228
|
+
| `collection` | `any` | Returns the lazily-initialized Collection instance for the configured rootPath. |
|
|
229
|
+
| `collectionPath` | `any` | Returns the absolute resolved path to the collection root directory. |
|
|
230
|
+
| `models` | `Record<string, ModelDefinition>` | Returns an object mapping model names to their model definitions, sourced from the collection. |
|
|
231
|
+
| `modelNames` | `string[]` | Returns an array of all registered model names from the collection. |
|
|
232
|
+
| `searchIndexStatus` | `any` | Get the current search index status. |
|
|
233
|
+
| `queries` | `Record<string, ReturnType<typeof this.query>>` | Returns an object with query builders keyed by model name (singular and plural, lowercased). Provides a convenient shorthand for querying without looking up model definitions manually. |
|
|
234
|
+
|
|
235
|
+
## State (Zod v4 schema)
|
|
236
|
+
|
|
237
|
+
| Property | Type | Description |
|
|
238
|
+
|----------|------|-------------|
|
|
239
|
+
| `enabled` | `boolean` | Whether this feature is currently enabled |
|
|
240
|
+
| `loaded` | `boolean` | Whether the content collection has been loaded and parsed |
|
|
241
|
+
| `tableOfContents` | `string` | Generated table of contents string for the collection |
|
|
242
|
+
| `modelSummary` | `string` | Summary of all discovered content models and their document counts |
|
|
243
|
+
|
|
244
|
+
## Examples
|
|
245
|
+
|
|
246
|
+
**features.contentDb**
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
250
|
+
await contentDb.load()
|
|
251
|
+
console.log(contentDb.modelNames) // ['Article', 'Page', ...]
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
**query**
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
260
|
+
await contentDb.load()
|
|
261
|
+
const articles = await contentDb.query(contentDb.models.Article).fetchAll()
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
**parseMarkdownAtPath**
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
const doc = contentDb.parseMarkdownAtPath('./docs/getting-started.md')
|
|
270
|
+
console.log(doc.frontmatter, doc.content)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
**load**
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
279
|
+
await contentDb.load()
|
|
280
|
+
console.log(contentDb.isLoaded) // true
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
**read**
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
await contentDb.read('guides/intro')
|
|
289
|
+
await contentDb.read('guides/intro', { include: ['Installation', 'Usage'] })
|
|
290
|
+
await contentDb.read('guides/intro', { exclude: ['Changelog'], meta: true })
|
|
291
|
+
await contentDb.read('guides/intro', { include: ['API'], leadingContent: false })
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
**readMultiple**
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
await contentDb.readMultiple(['guides/intro', 'guides/setup'])
|
|
300
|
+
await contentDb.readMultiple([{ id: 'guides/intro' }], { include: ['Overview'], dividers: false })
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
**queries**
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
const contentDb = container.feature('contentDb', { rootPath: './docs' })
|
|
309
|
+
await contentDb.load()
|
|
310
|
+
const allArticles = await contentDb.queries.articles.fetchAll()
|
|
311
|
+
const firstTask = await contentDb.queries.task.first()
|
|
312
|
+
```
|
|
313
|
+
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# DiskCache (features.diskCache)
|
|
2
|
+
|
|
3
|
+
File-backed key-value cache built on top of the cacache library (the same store that powers npm). Suitable for persisting arbitrary data including very large blobs when necessary, with optional encryption support.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
container.feature('diskCache')
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
### saveFile
|
|
14
|
+
|
|
15
|
+
Retrieve a file from the disk cache and save it to the local disk
|
|
16
|
+
|
|
17
|
+
**Parameters:**
|
|
18
|
+
|
|
19
|
+
| Name | Type | Required | Description |
|
|
20
|
+
|------|------|----------|-------------|
|
|
21
|
+
| `key` | `string` | ✓ | The cache key to retrieve |
|
|
22
|
+
| `outputPath` | `string` | ✓ | The local path where the file should be saved |
|
|
23
|
+
| `isBase64` | `any` | | Whether the cached content is base64 encoded |
|
|
24
|
+
|
|
25
|
+
**Returns:** `void`
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
await diskCache.saveFile('myFile', './output/file.txt')
|
|
29
|
+
await diskCache.saveFile('encodedImage', './images/photo.jpg', true)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### ensure
|
|
35
|
+
|
|
36
|
+
Ensure a key exists in the cache, setting it with the provided content if it doesn't exist
|
|
37
|
+
|
|
38
|
+
**Parameters:**
|
|
39
|
+
|
|
40
|
+
| Name | Type | Required | Description |
|
|
41
|
+
|------|------|----------|-------------|
|
|
42
|
+
| `key` | `string` | ✓ | The cache key to check/set |
|
|
43
|
+
| `content` | `string` | ✓ | The content to set if the key doesn't exist |
|
|
44
|
+
|
|
45
|
+
**Returns:** `void`
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
await diskCache.ensure('config', JSON.stringify(defaultConfig))
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### copy
|
|
54
|
+
|
|
55
|
+
Copy a cached item from one key to another
|
|
56
|
+
|
|
57
|
+
**Parameters:**
|
|
58
|
+
|
|
59
|
+
| Name | Type | Required | Description |
|
|
60
|
+
|------|------|----------|-------------|
|
|
61
|
+
| `source` | `string` | ✓ | The source cache key |
|
|
62
|
+
| `destination` | `string` | ✓ | The destination cache key |
|
|
63
|
+
| `overwrite` | `boolean` | | Whether to overwrite if destination exists (default: false) |
|
|
64
|
+
|
|
65
|
+
**Returns:** `void`
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
await diskCache.copy('original', 'backup')
|
|
69
|
+
await diskCache.copy('file1', 'file2', true) // force overwrite
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### move
|
|
75
|
+
|
|
76
|
+
Move a cached item from one key to another (copy then delete source)
|
|
77
|
+
|
|
78
|
+
**Parameters:**
|
|
79
|
+
|
|
80
|
+
| Name | Type | Required | Description |
|
|
81
|
+
|------|------|----------|-------------|
|
|
82
|
+
| `source` | `string` | ✓ | The source cache key |
|
|
83
|
+
| `destination` | `string` | ✓ | The destination cache key |
|
|
84
|
+
| `overwrite` | `boolean` | | Whether to overwrite if destination exists (default: false) |
|
|
85
|
+
|
|
86
|
+
**Returns:** `void`
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
await diskCache.move('temp', 'permanent')
|
|
90
|
+
await diskCache.move('old_key', 'new_key', true) // force overwrite
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### has
|
|
96
|
+
|
|
97
|
+
Check if a key exists in the cache
|
|
98
|
+
|
|
99
|
+
**Parameters:**
|
|
100
|
+
|
|
101
|
+
| Name | Type | Required | Description |
|
|
102
|
+
|------|------|----------|-------------|
|
|
103
|
+
| `key` | `string` | ✓ | The cache key to check |
|
|
104
|
+
|
|
105
|
+
**Returns:** `void`
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
if (await diskCache.has('myKey')) {
|
|
109
|
+
console.log('Key exists!')
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### get
|
|
116
|
+
|
|
117
|
+
Retrieve a value from the cache
|
|
118
|
+
|
|
119
|
+
**Parameters:**
|
|
120
|
+
|
|
121
|
+
| Name | Type | Required | Description |
|
|
122
|
+
|------|------|----------|-------------|
|
|
123
|
+
| `key` | `string` | ✓ | The cache key to retrieve |
|
|
124
|
+
| `json` | `any` | | Whether to parse the value as JSON (default: false) |
|
|
125
|
+
|
|
126
|
+
**Returns:** `void`
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const text = await diskCache.get('myText')
|
|
130
|
+
const data = await diskCache.get('myData', true) // parse as JSON
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### set
|
|
136
|
+
|
|
137
|
+
Store a value in the cache
|
|
138
|
+
|
|
139
|
+
**Parameters:**
|
|
140
|
+
|
|
141
|
+
| Name | Type | Required | Description |
|
|
142
|
+
|------|------|----------|-------------|
|
|
143
|
+
| `key` | `string` | ✓ | The cache key to store under |
|
|
144
|
+
| `value` | `any` | ✓ | The value to store (string, object, or any serializable data) |
|
|
145
|
+
| `meta` | `any` | | Optional metadata to associate with the cached item |
|
|
146
|
+
|
|
147
|
+
**Returns:** `void`
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
await diskCache.set('myKey', 'Hello World')
|
|
151
|
+
await diskCache.set('userData', { name: 'John', age: 30 })
|
|
152
|
+
await diskCache.set('file', content, { size: 1024, type: 'image' })
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### rm
|
|
158
|
+
|
|
159
|
+
Remove a cached item
|
|
160
|
+
|
|
161
|
+
**Parameters:**
|
|
162
|
+
|
|
163
|
+
| Name | Type | Required | Description |
|
|
164
|
+
|------|------|----------|-------------|
|
|
165
|
+
| `key` | `string` | ✓ | The cache key to remove |
|
|
166
|
+
|
|
167
|
+
**Returns:** `void`
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
await diskCache.rm('obsoleteKey')
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### clearAll
|
|
176
|
+
|
|
177
|
+
Clear all cached items
|
|
178
|
+
|
|
179
|
+
**Parameters:**
|
|
180
|
+
|
|
181
|
+
| Name | Type | Required | Description |
|
|
182
|
+
|------|------|----------|-------------|
|
|
183
|
+
| `confirm` | `any` | | Must be set to true to confirm the operation |
|
|
184
|
+
|
|
185
|
+
**Returns:** `void`
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
await diskCache.clearAll(true) // Must explicitly confirm
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
### keys
|
|
194
|
+
|
|
195
|
+
Get all cache keys
|
|
196
|
+
|
|
197
|
+
**Returns:** `Promise<string[]>`
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const allKeys = await diskCache.keys()
|
|
201
|
+
console.log(`Cache contains ${allKeys.length} items`)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### listKeys
|
|
207
|
+
|
|
208
|
+
List all cache keys (alias for keys())
|
|
209
|
+
|
|
210
|
+
**Returns:** `Promise<string[]>`
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const keyList = await diskCache.listKeys()
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
### create
|
|
219
|
+
|
|
220
|
+
Create a cacache instance with the specified path
|
|
221
|
+
|
|
222
|
+
**Parameters:**
|
|
223
|
+
|
|
224
|
+
| Name | Type | Required | Description |
|
|
225
|
+
|------|------|----------|-------------|
|
|
226
|
+
| `path` | `string` | | Optional cache directory path (defaults to options.path or node_modules/.cache/luca-disk-cache) |
|
|
227
|
+
|
|
228
|
+
**Returns:** `void`
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
const customCache = diskCache.create('/custom/cache/path')
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Getters
|
|
237
|
+
|
|
238
|
+
| Property | Type | Description |
|
|
239
|
+
|----------|------|-------------|
|
|
240
|
+
| `cache` | `any` | Returns the underlying cacache instance configured with the cache directory path. |
|
|
241
|
+
| `securely` | `any` | Get encrypted cache operations interface Requires encryption to be enabled and a secret to be provided |
|
|
242
|
+
|
|
243
|
+
## State (Zod v4 schema)
|
|
244
|
+
|
|
245
|
+
| Property | Type | Description |
|
|
246
|
+
|----------|------|-------------|
|
|
247
|
+
| `enabled` | `boolean` | Whether this feature is currently enabled |
|
|
248
|
+
|
|
249
|
+
## Examples
|
|
250
|
+
|
|
251
|
+
**features.diskCache**
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
const diskCache = container.feature('diskCache', { path: '/tmp/cache' })
|
|
255
|
+
await diskCache.set('greeting', 'Hello World')
|
|
256
|
+
const value = await diskCache.get('greeting')
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
**saveFile**
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
await diskCache.saveFile('myFile', './output/file.txt')
|
|
265
|
+
await diskCache.saveFile('encodedImage', './images/photo.jpg', true)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
**ensure**
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
await diskCache.ensure('config', JSON.stringify(defaultConfig))
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
**copy**
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
await diskCache.copy('original', 'backup')
|
|
282
|
+
await diskCache.copy('file1', 'file2', true) // force overwrite
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
**move**
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
await diskCache.move('temp', 'permanent')
|
|
291
|
+
await diskCache.move('old_key', 'new_key', true) // force overwrite
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
**has**
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
if (await diskCache.has('myKey')) {
|
|
300
|
+
console.log('Key exists!')
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
**get**
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
const text = await diskCache.get('myText')
|
|
310
|
+
const data = await diskCache.get('myData', true) // parse as JSON
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
**set**
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
await diskCache.set('myKey', 'Hello World')
|
|
319
|
+
await diskCache.set('userData', { name: 'John', age: 30 })
|
|
320
|
+
await diskCache.set('file', content, { size: 1024, type: 'image' })
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
**rm**
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
await diskCache.rm('obsoleteKey')
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
**clearAll**
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
await diskCache.clearAll(true) // Must explicitly confirm
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
**keys**
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
const allKeys = await diskCache.keys()
|
|
345
|
+
console.log(`Cache contains ${allKeys.length} items`)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
**listKeys**
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
const keyList = await diskCache.listKeys()
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
**create**
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
const customCache = diskCache.create('/custom/cache/path')
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
**securely**
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
// Initialize with encryption
|
|
370
|
+
const cache = container.feature('diskCache', {
|
|
371
|
+
encrypt: true,
|
|
372
|
+
secret: Buffer.from('my-secret-key')
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
// Use encrypted operations
|
|
376
|
+
await cache.securely.set('sensitive', 'secret data')
|
|
377
|
+
const decrypted = await cache.securely.get('sensitive')
|
|
378
|
+
```
|
|
379
|
+
|