Dashboard › opencode › Distillation
0cc8695c-47f4-4c0d-af87-4344a57f2343["lore_tm_v1_htYnQ_rB43Q2lVNbQxjj1xoTOJ65yPJrst-YdIeXz_g","lore_tm_v1_rhs8R99O-UqBAzkn-45s-bTunAFTofAUKRf3LyhNW7o","lore_tm_v1_qtJtRr2gz0cVdVRkSGR6k_R6wH4mjdoWSvAhFmB0XbQ","lore_tm_v1_aoHqrA-P1cT97te_IFNTmMmH3aBwRBzJOtmCa8X0V-k","lore_tm_v1_AtTv5CYu04o2U8JTG-X90PbOEdylyk4qx_Q_x1Uo-y0","lore_tm_v1_U1UZaYO4IhpY6t1EBOKlXG2cgI_0y4KERqGsBOH_QV0","lore_tm_v1_1BOJPCoyu3BNbQOHXh4HB-4rLM9rQ_O-wszQvEhsMpQ","lore_tm_v1_r-RAaLBBtEsqADu783k8yivC7XS9v1ganlRn-49k9W0","lore_tm_v1_NMFzAgFTpLVqLo91YpNDq1TcnmsWvCGifOh1eZxl-Zs","lore_tm_v1_wrOdgpJkW8yubctNqTaZMB3MGr9dFedT8CLztdv-82o"]
in_progress); 2. add dual legacy and V2 Lore plugin entrypoints (pending); 3. add V2 routing and lifecycle regression tests (pending); 4. run Lore package and repository validation (pending); 5. package and verify Lore in an isolated V2 wrapper (pending); 6. activate Lore in the V2 pilot after frozen reviews complete (pending); 7. obtain independent final PTY correctness and security approval (pending)./home/byk/Code/opencode-lore/AGENTS.md states Lore uses Node.js >=22.5, TypeScript with pnpm workspaces, and SQLite in WAL mode with FTS5; the normal database is ~/.local/share/lore/lore.db.@loreai/core in packages/core/ provides the shared memory engine; @loreai/gateway in packages/gateway/ provides the transparent LLM proxy and lore CLI; @loreai/opencode in packages/opencode/ is the OpenCode adapter; @loreai/pi in packages/pi/ is the Pi adapter. Gateway bundles core into one CJS file via esbuild, while the OpenCode package ships raw TypeScript.packages/core/src/temporal.ts, with store(), distilled=0/1, FTS5 indexing, and \x1f chunk separators; 2. distillation in packages/core/src/distillation.ts, flowing through resetOrphans() → undistilled messages → detectSegments() with a maximum 16K tokens per segment → distillSegment(), with metaDistill() triggered when gen-0 count exceeds 20; 3. gradient context management in packages/core/src/gradient.ts, using Layer 0 full passthrough, Layer 1 distilled prefix plus compressed raw context, Layer 2 aggressive tool-output stripping, and Layer 3 emergency compression.packages/core/src/ltm.ts uses categories decision, pattern, preference, architecture, and gotcha; fields are id (UUIDv7), project_id, category, title, content (maximum 1200 characters), confidence (0.0-1.0), and cross_project.packages/core/src/curator.ts; 2. regex-based pattern extraction in packages/core/src/pattern-extract.ts; 3. .lore.md file import through packages/core/src/agents-file.ts; 4. curator.ts consolidate() when entry count exceeds maxEntries (25)..lore.md behavior: entries use <!-- lore:UUID --> markers and are sorted alphabetically by title within category; exportLoreFile() skips writes when the content hash is unchanged; importLoreFile() updates a known UUID whose content changed and creates an unknown UUID; shouldImportLoreFile() checks mtime first and then content hash; exportToFile() and splitFile() preserve manual AGENTS.md content outside Lore’s markers.packages/core/test/setup.ts—never the production DB at ~/.local/share/lore/lore.db.gh workflow run release.yml -f version=auto and gh workflow run release.yml -f version=0.23.0.scripts/bump-version.sh updates all package.json versions; 2. changelog is generated from conventional commits; 3. a release/X.Y.Z branch is created and pushed; 4. CI runs tests and builds npm tarballs, standalone binaries, and delta patches; 5. Craft opens a publish issue and the Publish workflow runs after it is labeled accepted; 6. publishing uses npm OIDC trusted publishing and creates a GitHub Release with binaries and patches. .craft.yml targets 4 npm workspaces, the legacy opencode-lore alias, and the GitHub Release..lore.md (M .lore.md).packages/opencode; never run package tests from the repository root.effect-smol source under .opencode/references/effect-smol and nearby repository code rather than relying on memory or Effect v2/v3 examples; if absent, clone https://github.com/Effect-TS/effect-smol into that project path.Effect.gen(function* () { ... }) for multi-step workflows; use Effect.fn("Name") or Effect.fnUntraced(...) for reusable service methods or important workflows; prefer Effect Schema, branded ID schemas, and Schema.TaggedErrorClass; keep HTTP handlers thin and business rules in services; keep layer composition explicit; do not introduce any, non-null assertions, unchecked casts, or old Effect APIs merely to satisfy types.testEffect(...) from packages/opencode/test/lib/effect.ts for Effect services/layers/runtime context/scoped resources; use it.live(...) for filesystems, git, child processes, HTTP servers, sockets, locks, timing, and other live platform behavior; use explicit test layers and scoped fixtures/finalizers for temporary directories, flags, databases, fibers, servers, and global state.SYNCED_TABLES → sync-registry-contract.test.ts, verifying shape, pull-only/no-capture, and composite-PK behavior; MIGRATIONS → db.test.ts schema-version assertion using toBe(MIGRATIONS.length) plus migration-specific tests; AGENTS → agents.test.ts, requiring name, displayName, binary, and detect(), with binary a constant placeholder string.packages/core/test/sync-registry-contract.test.ts; per-operation sync invariants in packages/core/src/sync-data.ts via assertSyncInvariants; sequence properties in packages/gateway/test/sync.property.test.ts, covering invariants after every operation, prune-floor liveness, eventual convergence, no ping-pong, and currentTier correctness.NOT EXISTS, latest <> 'upsert', and content-match guards as highest risk; require every skip branch to have a test where it would wrongly skip; favor property tests over faithful mocks; freeze memoized arrays shared by callers; and use log.registerSink({ withDbSpan }) rather than monkeypatching db().query, because the tracing Proxy shadows the latter.pnpm test, pnpm run typecheck, pnpm run lint, and pnpm run format:check, checking exit codes; run property tests ×10; confirm the final working tree is hash-verified and unmodified; and report per-point PASS / FAIL / CONCERN / MUST-FIX with file:line evidence plus an overall MERGE / DO-NOT-MERGE verdict.packages/opencode/package.json shows @loreai/opencode version 0.40.0, raw-TypeScript root entry ./src/index.ts, and only the "." export mapped to ./src/index.ts; peer dependency is @opencode-ai/plugin >=1.1.0; dev dependencies include @opencode-ai/plugin ^1.1.39, @opencode-ai/sdk ^1.1.39, and @types/bun ^1.2.0.packages/opencode/src/index.ts exports only LorePlugin and a same-reference default export because the legacy OpenCode loader invokes every function export as a plugin and rejects non-function exports; helpers remain in ./internal.ts, and test/index.test.ts guards the entry-module export shape.resolveGatewayUrl() is: 0. LORE_REMOTE_URL; 1. LORE_GATEWAY_URL; 2. port-file value followed by known ports 3207 and 5673; 3. probe each candidate at http://127.0.0.1:${port}. startInProcess() dynamically imports @loreai/gateway, calls startGateway({ quiet: true, local: true }), and currently returns only the URL rather than retaining the shutdown handle.processInitDone, processLoreActive, processLoreBase, and loreInitPromise; project state is keyed by ctx.project.id; SESSION_STATE_TTL_MS is 24 * 60 * 60 * 1000; project and session-parent entries are reaped after 24 hours.currentProject: { path: string; gitRemote: string } | undefined.resolveParentSession() calls client.session.get({ path: { id: sessionID } }), reads res.data?.parentID, caches successful results including null, does not cache failures, and forwards non-null parents as x-parent-session-id.isInertTestEnv() is true for NODE_ENV=test or any argv entry containing .test., unless LORE_OPENCODE_FORCE_ACTIVE=1; active routing tests retain NODE_ENV=test and point LORE_GATEWAY_URL to a controlled in-process gateway.config hook sets compaction = { auto: false, prune: false } and defines 3 hidden subagent-mode workers under cfg.agent: lore-distill (“Lore memory distillation worker”), lore-curator (“Lore knowledge curator worker”), and lore-query-expand (“Lore query expansion worker”).chat.headers hook emits gateway access headers plus x-lore-session-id, x-lore-agent, optional x-parent-session-id, x-lore-project, x-lore-git-remote, and x-lore-provider; it maps local provider IDs to LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} and may emit that value as x-lore-upstream-url.LORE_UPSTREAM_EXTRA_HEADERS line-by-line as name:value, trims both sides, skips blank/malformed lines, and forwards only names accepted by shouldForwardUpstreamExtraHeader(name).installFetchInterceptor({ gatewayBase, getHeaders }) once per process, with fallback headers from the paired currentProject; startup logs route through log rather than raw stderr because OpenCode owns a full-screen TUI, and initialization errors are logged with stack/message before being rethrown.