|
14 | 14 | - `kb init` and `kb install-skill` must keep generated local Mimir state ignored in target |
15 | 15 | repositories. By default, add `.kb/`, `.mimir/`, and private raw-document paths to the |
16 | 16 | target repository `.gitignore`. |
17 | | -- Keep confidentiality features low-friction: local-only network policy, redaction before |
18 | | - indexing, metadata-only access logs, bounded MCP retrieval, and `security-audit` should work |
19 | | - from default config. |
| 17 | +- Keep confidentiality features low-friction: local-hash retrieval by default, optional |
| 18 | + Transformers.js embeddings with remote model loading disabled by default, redaction before |
| 19 | + indexing, metadata-only access logs, bounded MCP retrieval, configurable text-extension ingestion, |
| 20 | + and `security-audit` should work from default config. |
| 21 | +- Keep public positioning focused on sovereign local RAG for confidential datasets and AI agents. |
| 22 | + Avoid claiming universal binary-file support; unsupported proprietary formats need extraction or |
| 23 | + dedicated parsers. |
| 24 | +- Keep optional audio summaries separate from core ingestion/query behavior. The |
| 25 | + `mimir-audio-summary` skill must prefer `kb audio` / `@jcode.labs/mimir-tts`, support offline |
| 26 | + model loading, and keep generated audio under ignored local Mimir state. |
| 27 | +- Keep the repository as a simple pnpm workspace monorepo. Add Turbo only if multiple packages or |
| 28 | + apps start needing task caching/orchestration beyond `pnpm --filter`. |
| 29 | +- Keep Mimir core free of Ollama. `embeddingProvider: "local-hash"` supports ingestion, search, MCP, |
| 30 | + and cited retrieval without a model server, but it must not be described as equivalent to semantic |
| 31 | + retrieval. `embeddingProvider: "transformers"` is the optional semantic embedding path. |
| 32 | +- Keep `packages/mimir/examples/sovereign-rag-demo` synthetic and safe to commit. It exists for |
| 33 | + package/user testing only; never place real confidential documents there. |
20 | 34 | - Use Context7 before changing dependencies or public APIs that rely on external libraries. |
21 | 35 | - Run `pnpm validate` before opening a release pull request or publishing. It covers |
22 | 36 | Biome, TypeScript, Vitest, build output, production CLI/MCP smoke tests, and npm package |
23 | 37 | metadata. |
24 | 38 | - Do not publish from a local machine or direct push to `main`. npm releases must go through |
25 | | - the protected manual `Publish npm` GitHub Actions workflow after `main` has green CI. |
| 39 | + the protected manual `Publish npm` GitHub Actions workflow after `main` has green CI. The workflow |
| 40 | + publishes `@jcode.labs/mimir-tts` first, then `@jcode.labs/mimir`. |
| 41 | + |
| 42 | +## Coding Conventions |
| 43 | + |
| 44 | +General principles (KISS, DRY, YAGNI, SOLID) as applied in this codebase. Match the surrounding style. |
| 45 | + |
| 46 | +- One responsibility per module. The ingest pipeline is split on purpose: `files` discovers, |
| 47 | + `parsing` extracts, `redaction` strips, `chunking` splits, `embeddings` vectorizes, `store` |
| 48 | + persists, `query` retrieves. Add logic to the module that owns the concern, or a new small module. |
| 49 | +- No duplicated logic. Reuse existing helpers (`loadConfig`, `embedText`/`embedTexts`, |
| 50 | + `openRowsTable`, `redactText`, `supportedExtensions`, `recordAccess`); extract instead of copying. |
| 51 | + `embedText` delegating to `embedTexts` is the reference pattern. |
| 52 | +- No dead or obsolete code. Delete replaced code, unused exports, and commented-out blocks in the |
| 53 | + same change; a deletion must cover both source and the regenerated package `dist/`. |
| 54 | +- No magic strings or numbers. Name meaningful literals as constants, and put shared paths, provider |
| 55 | + defaults, and ignore constants in `packages/mimir/src/defaults.ts` rather than copying them across |
| 56 | + modules. |
| 57 | +- Validate at the boundary, narrow inside. Use Zod at external edges (config in `config.ts`, MCP |
| 58 | + inputs in `mcp.ts`) and CLI parsers (`parsePositiveInt`); trust the types past that point. |
| 59 | +- Type-guard instead of casting. Prefer runtime guards over `as`/`!` (`hasToList`, `isNumberArray`, |
| 60 | + `isNumberMatrix`); LanceDB row casts at the `store`/`query` driver boundary are the only exception. |
| 61 | +- Named exports only; keep the public surface explicit in `index.ts`. Functions stay small and pure; |
| 62 | + private helpers sit below the exported function in the same file. |
| 63 | +- Comments explain why, not what; the codebase is near comment-free. Only the CLI (`cli.ts`) writes |
| 64 | + to stdout/stderr — library, MCP, and pipeline code return data, never log. |
| 65 | +- YAGNI: no options, providers, or abstractions ahead of a real need. |
26 | 66 |
|
27 | 67 | ## Architecture |
28 | 68 |
|
29 | | -- `src/cli.ts` exposes the `kb` CLI. |
30 | | -- `src/config.ts` resolves `.kb/config.json` from the target repository. |
31 | | -- `src/ingest.ts` parses supported files, chunks text, embeds chunks, and rebuilds the |
| 69 | +- `packages/mimir` is the core package published as `@jcode.labs/mimir`. |
| 70 | +- `packages/mimir/src/cli.ts` exposes the `kb` CLI. |
| 71 | +- `packages/mimir/src/config.ts` resolves `.kb/config.json` from the target repository. |
| 72 | +- `packages/mimir/src/defaults.ts` owns shared default paths, provider defaults, and generated-state ignore |
| 73 | + constants. Keep config/init/security/gitignore aligned through this module instead of copying |
| 74 | + literals. |
| 75 | +- `packages/mimir/src/ingest.ts` parses supported files, chunks text, embeds chunks, and rebuilds the |
32 | 76 | local LanceDB table. |
33 | | -- `src/query.ts` performs vector search and local Ollama answer synthesis. |
34 | | -- `src/mcp.ts` exposes Mimir as an MCP stdio server for agents. |
35 | | -- `src/gitignore.ts` owns target-repository `.gitignore` entries for local generated Mimir |
| 77 | +- `packages/mimir/src/query.ts` performs vector search and returns cited retrieval context; LLM synthesis belongs |
| 78 | + outside Mimir core. |
| 79 | +- `packages/mimir/src/mcp.ts` exposes Mimir as an MCP stdio server for agents. |
| 80 | +- `packages/mimir-tts` is the standalone JS/ONNX TTS package used by `kb audio`. |
| 81 | +- `packages/mimir/src/gitignore.ts` owns target-repository `.gitignore` entries for local generated Mimir |
36 | 82 | state. |
37 | | -- `src/security.ts`, `src/network.ts`, `src/redaction.ts`, and `src/access-log.ts` own the |
| 83 | +- `packages/mimir/src/security.ts`, `packages/mimir/src/redaction.ts`, and |
| 84 | + `packages/mimir/src/access-log.ts` own the |
38 | 85 | privacy and confidentiality hardening layer. |
39 | | -- `skills/mimir/SKILL.md` is the bundled portable agent skill. |
| 86 | +- `packages/mimir/skills/mimir/SKILL.md` is the bundled portable agent skill. |
| 87 | +- `packages/mimir/skills/mimir-audio-summary/SKILL.md` is the optional bundled audio-summary skill. |
| 88 | +- `packages/mimir/examples/sovereign-rag-demo` is the tracked synthetic test workspace for manual |
| 89 | + and package validation. |
40 | 90 | - `.kb/`, `.mimir/`, and project `private/` folders are local user data or generated agent |
41 | 91 | state in target repositories and must not be committed. |
0 commit comments