@chendpoc/pi-memory 0.2.2 → 0.2.3
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/README.md +4 -2
- package/dist/adapters/embed/factory.d.ts +0 -1
- package/dist/adapters/embed/factory.js +0 -1
- package/dist/adapters/embed/hash.d.ts +0 -1
- package/dist/adapters/embed/hash.js +0 -1
- package/dist/adapters/embed/normalize.d.ts +0 -1
- package/dist/adapters/embed/normalize.js +0 -1
- package/dist/adapters/embed/ollama.d.ts +0 -1
- package/dist/adapters/embed/ollama.js +0 -1
- package/dist/adapters/embed/openai.d.ts +0 -1
- package/dist/adapters/embed/openai.js +0 -1
- package/dist/adapters/embed/types.d.ts +0 -1
- package/dist/adapters/embed/types.js +0 -1
- package/dist/adapters/http.d.ts +0 -1
- package/dist/adapters/http.js +0 -1
- package/dist/adapters/index.d.ts +0 -1
- package/dist/adapters/index.js +0 -1
- package/dist/adapters/llm/extractText.d.ts +0 -1
- package/dist/adapters/llm/extractText.js +0 -1
- package/dist/adapters/llm/factory.d.ts +0 -1
- package/dist/adapters/llm/factory.js +0 -1
- package/dist/adapters/llm/index.d.ts +0 -1
- package/dist/adapters/llm/index.js +0 -1
- package/dist/adapters/llm/modelSpec.d.ts +0 -1
- package/dist/adapters/llm/modelSpec.js +0 -1
- package/dist/adapters/llm/ollama.d.ts +0 -1
- package/dist/adapters/llm/ollama.js +0 -1
- package/dist/adapters/llm/openai-compat.d.ts +0 -1
- package/dist/adapters/llm/openai-compat.js +0 -1
- package/dist/adapters/llm/pi-ai.d.ts +0 -1
- package/dist/adapters/llm/pi-ai.js +0 -1
- package/dist/adapters/llm/standalone.d.ts +0 -1
- package/dist/adapters/llm/standalone.js +0 -1
- package/dist/adapters/llm/types.d.ts +0 -1
- package/dist/adapters/llm/types.js +0 -1
- package/dist/cli/init.d.ts +0 -1
- package/dist/cli/init.js +0 -1
- package/dist/cli/jobs.d.ts +0 -1
- package/dist/cli/jobs.js +0 -1
- package/dist/cli/log.d.ts +0 -1
- package/dist/cli/log.js +0 -1
- package/dist/cli/parseArgs.d.ts +0 -1
- package/dist/cli/parseArgs.js +0 -1
- package/dist/cli/status.d.ts +0 -1
- package/dist/cli/status.js +0 -1
- package/dist/cli/theme.d.ts +0 -1
- package/dist/cli/theme.js +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1
- package/dist/commands/index.d.ts +0 -1
- package/dist/commands/index.js +0 -1
- package/dist/commands/parseMemoryStatusArgs.d.ts +0 -1
- package/dist/commands/parseMemoryStatusArgs.js +0 -1
- package/dist/commands/parseRememberArgs.d.ts +0 -1
- package/dist/commands/parseRememberArgs.js +0 -1
- package/dist/commands/remember.d.ts +0 -1
- package/dist/commands/remember.js +0 -1
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/status.js +0 -1
- package/dist/commands/types.d.ts +0 -1
- package/dist/commands/types.js +0 -1
- package/dist/compact/index.d.ts +0 -1
- package/dist/compact/index.js +0 -1
- package/dist/compact/parseMemoryExport.d.ts +0 -1
- package/dist/compact/parseMemoryExport.js +0 -1
- package/dist/compact/register.d.ts +0 -1
- package/dist/compact/register.js +0 -1
- package/dist/compact/runSummary.d.ts +0 -1
- package/dist/compact/runSummary.js +0 -1
- package/dist/compact/subagentDelta.d.ts +0 -1
- package/dist/compact/subagentDelta.js +0 -1
- package/dist/compact/summaryPrompt.d.ts +0 -1
- package/dist/compact/summaryPrompt.js +0 -1
- package/dist/config/agentDir.d.ts +0 -1
- package/dist/config/agentDir.js +0 -1
- package/dist/config/chunking.d.ts +0 -1
- package/dist/config/chunking.js +0 -1
- package/dist/config/env.d.ts +0 -1
- package/dist/config/env.js +0 -1
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/loadEnv.d.ts +0 -1
- package/dist/config/loadEnv.js +0 -1
- package/dist/config/preflight.d.ts +0 -1
- package/dist/config/preflight.js +0 -1
- package/dist/config/preflightBudget.d.ts +0 -1
- package/dist/config/preflightBudget.js +0 -1
- package/dist/config/retrieval.d.ts +0 -1
- package/dist/config/retrieval.js +0 -1
- package/dist/consolidate/entryKey.d.ts +0 -1
- package/dist/consolidate/entryKey.js +0 -1
- package/dist/consolidate/index.d.ts +0 -1
- package/dist/consolidate/index.js +0 -1
- package/dist/consolidate/mergeEntries.d.ts +0 -1
- package/dist/consolidate/mergeEntries.js +0 -1
- package/dist/consolidate/mergePrompt.d.ts +0 -1
- package/dist/consolidate/mergePrompt.js +0 -1
- package/dist/consolidate/mergeWithLlm.d.ts +0 -1
- package/dist/consolidate/mergeWithLlm.js +0 -1
- package/dist/consolidate/runJob.d.ts +0 -1
- package/dist/consolidate/runJob.js +0 -1
- package/dist/consolidate/scheduler.d.ts +0 -1
- package/dist/consolidate/scheduler.js +0 -1
- package/dist/constants/chunking.d.ts +0 -1
- package/dist/constants/chunking.js +0 -1
- package/dist/constants/env.d.ts +0 -1
- package/dist/constants/env.js +0 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -1
- package/dist/constants/memory.d.ts +0 -1
- package/dist/constants/memory.js +0 -1
- package/dist/constants/paths.d.ts +0 -1
- package/dist/constants/paths.js +0 -1
- package/dist/constants/preflight.d.ts +0 -1
- package/dist/constants/preflight.js +0 -1
- package/dist/constants/retrieval.d.ts +0 -1
- package/dist/constants/retrieval.js +0 -1
- package/dist/constants/security.d.ts +0 -1
- package/dist/constants/security.js +0 -1
- package/dist/constants/timing.d.ts +0 -1
- package/dist/constants/timing.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/init/workspace.d.ts +0 -1
- package/dist/init/workspace.js +0 -1
- package/dist/ipc/jsonlFramer.d.ts +0 -1
- package/dist/ipc/jsonlFramer.js +0 -1
- package/dist/pi-extension.d.ts +0 -1
- package/dist/pi-extension.js +0 -1
- package/dist/preflight/episodic.d.ts +0 -1
- package/dist/preflight/episodic.js +0 -1
- package/dist/preflight/intentCache.d.ts +0 -1
- package/dist/preflight/intentCache.js +0 -1
- package/dist/preflight/queryCache.d.ts +0 -1
- package/dist/preflight/queryCache.js +0 -1
- package/dist/preflight/queryIntent.d.ts +0 -1
- package/dist/preflight/queryIntent.js +0 -1
- package/dist/preflight/render.d.ts +0 -1
- package/dist/preflight/render.js +0 -1
- package/dist/preflight/session.d.ts +0 -1
- package/dist/preflight/session.js +0 -1
- package/dist/preflight/strip.d.ts +0 -1
- package/dist/preflight/strip.js +0 -1
- package/dist/shutdown/enqueue.d.ts +0 -1
- package/dist/shutdown/enqueue.js +0 -1
- package/dist/shutdown/extractPrompt.d.ts +0 -1
- package/dist/shutdown/extractPrompt.js +0 -1
- package/dist/shutdown/processed.d.ts +0 -1
- package/dist/shutdown/processed.js +0 -1
- package/dist/shutdown/readQueue.d.ts +0 -1
- package/dist/shutdown/readQueue.js +0 -1
- package/dist/shutdown/runDrainJob.d.ts +0 -1
- package/dist/shutdown/runDrainJob.js +0 -1
- package/dist/shutdown/sessionReader.d.ts +0 -1
- package/dist/shutdown/sessionReader.js +0 -1
- package/dist/sidecar/client.d.ts +0 -1
- package/dist/sidecar/client.js +0 -1
- package/dist/sidecar/paths.d.ts +0 -1
- package/dist/sidecar/paths.js +0 -1
- package/dist/sidecar/protocol.d.ts +0 -1
- package/dist/sidecar/protocol.js +0 -1
- package/dist/sidecar/reindexBridge.d.ts +0 -1
- package/dist/sidecar/reindexBridge.js +0 -1
- package/dist/sidecar/server/process.d.ts +0 -1
- package/dist/sidecar/server/process.js +0 -1
- package/dist/sidecar/server/query.d.ts +0 -1
- package/dist/sidecar/server/query.js +0 -1
- package/dist/sidecar/server/reindex.d.ts +0 -1
- package/dist/sidecar/server/reindex.js +0 -1
- package/dist/sidecar/server/server.d.ts +0 -1
- package/dist/sidecar/server/server.js +0 -1
- package/dist/sidecar/server/stats.d.ts +0 -1
- package/dist/sidecar/server/stats.js +0 -1
- package/dist/sidecar/server/vec/embedder.d.ts +0 -1
- package/dist/sidecar/server/vec/embedder.js +0 -1
- package/dist/sidecar/server/vec/mmr.d.ts +0 -1
- package/dist/sidecar/server/vec/mmr.js +0 -1
- package/dist/sidecar/server/vec/store.d.ts +0 -1
- package/dist/sidecar/server/vec/store.js +0 -1
- package/dist/sidecar/sidecarManager.d.ts +0 -1
- package/dist/sidecar/sidecarManager.js +0 -1
- package/dist/sidecar/utils.d.ts +0 -1
- package/dist/sidecar/utils.js +0 -1
- package/dist/sidecar/warmup.d.ts +0 -1
- package/dist/sidecar/warmup.js +0 -1
- package/dist/store/backend.d.ts +0 -1
- package/dist/store/backend.js +0 -1
- package/dist/store/index.d.ts +0 -1
- package/dist/store/index.js +0 -1
- package/dist/store/indexChunks.d.ts +0 -1
- package/dist/store/indexChunks.js +0 -1
- package/dist/store/markdown/format.d.ts +0 -1
- package/dist/store/markdown/format.js +0 -1
- package/dist/store/markdown/parse.d.ts +0 -1
- package/dist/store/markdown/parse.js +0 -1
- package/dist/store/markdown/template.d.ts +0 -1
- package/dist/store/markdown/template.js +0 -1
- package/dist/store/memoryStore.d.ts +0 -1
- package/dist/store/memoryStore.js +0 -1
- package/dist/store/paths.d.ts +0 -1
- package/dist/store/paths.js +0 -1
- package/dist/store/types.d.ts +0 -1
- package/dist/store/types.js +0 -1
- package/dist/ui/memoryStatusWidget.d.ts +0 -1
- package/dist/ui/memoryStatusWidget.js +0 -1
- package/dist/utils/debugLog.d.ts +0 -1
- package/dist/utils/debugLog.js +0 -1
- package/dist/utils/fs.d.ts +0 -1
- package/dist/utils/fs.js +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/paths.d.ts +0 -1
- package/dist/utils/paths.js +0 -1
- package/dist/utils/platform.d.ts +0 -1
- package/dist/utils/platform.js +0 -1
- package/dist/utils/scheduler.d.ts +0 -1
- package/dist/utils/scheduler.js +0 -1
- package/dist/utils/socket.d.ts +0 -1
- package/dist/utils/socket.js +0 -1
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -1
- package/package.json +6 -11
- package/scripts/prepare.mjs +24 -0
- package/UBIQUITOUS_LANGUAGE.md +0 -81
- package/assets/pi-memory-logo.png +0 -0
- package/dist/adapters/embed/factory.d.ts.map +0 -1
- package/dist/adapters/embed/factory.js.map +0 -1
- package/dist/adapters/embed/hash.d.ts.map +0 -1
- package/dist/adapters/embed/hash.js.map +0 -1
- package/dist/adapters/embed/normalize.d.ts.map +0 -1
- package/dist/adapters/embed/normalize.js.map +0 -1
- package/dist/adapters/embed/ollama.d.ts.map +0 -1
- package/dist/adapters/embed/ollama.js.map +0 -1
- package/dist/adapters/embed/openai.d.ts.map +0 -1
- package/dist/adapters/embed/openai.js.map +0 -1
- package/dist/adapters/embed/types.d.ts.map +0 -1
- package/dist/adapters/embed/types.js.map +0 -1
- package/dist/adapters/http.d.ts.map +0 -1
- package/dist/adapters/http.js.map +0 -1
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/llm/extractText.d.ts.map +0 -1
- package/dist/adapters/llm/extractText.js.map +0 -1
- package/dist/adapters/llm/factory.d.ts.map +0 -1
- package/dist/adapters/llm/factory.js.map +0 -1
- package/dist/adapters/llm/index.d.ts.map +0 -1
- package/dist/adapters/llm/index.js.map +0 -1
- package/dist/adapters/llm/modelSpec.d.ts.map +0 -1
- package/dist/adapters/llm/modelSpec.js.map +0 -1
- package/dist/adapters/llm/ollama.d.ts.map +0 -1
- package/dist/adapters/llm/ollama.js.map +0 -1
- package/dist/adapters/llm/openai-compat.d.ts.map +0 -1
- package/dist/adapters/llm/openai-compat.js.map +0 -1
- package/dist/adapters/llm/pi-ai.d.ts.map +0 -1
- package/dist/adapters/llm/pi-ai.js.map +0 -1
- package/dist/adapters/llm/standalone.d.ts.map +0 -1
- package/dist/adapters/llm/standalone.js.map +0 -1
- package/dist/adapters/llm/types.d.ts.map +0 -1
- package/dist/adapters/llm/types.js.map +0 -1
- package/dist/cli/init.d.ts.map +0 -1
- package/dist/cli/init.js.map +0 -1
- package/dist/cli/jobs.d.ts.map +0 -1
- package/dist/cli/jobs.js.map +0 -1
- package/dist/cli/log.d.ts.map +0 -1
- package/dist/cli/log.js.map +0 -1
- package/dist/cli/parseArgs.d.ts.map +0 -1
- package/dist/cli/parseArgs.js.map +0 -1
- package/dist/cli/status.d.ts.map +0 -1
- package/dist/cli/status.js.map +0 -1
- package/dist/cli/theme.d.ts.map +0 -1
- package/dist/cli/theme.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/parseMemoryStatusArgs.d.ts.map +0 -1
- package/dist/commands/parseMemoryStatusArgs.js.map +0 -1
- package/dist/commands/parseRememberArgs.d.ts.map +0 -1
- package/dist/commands/parseRememberArgs.js.map +0 -1
- package/dist/commands/remember.d.ts.map +0 -1
- package/dist/commands/remember.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands/types.js.map +0 -1
- package/dist/compact/index.d.ts.map +0 -1
- package/dist/compact/index.js.map +0 -1
- package/dist/compact/parseMemoryExport.d.ts.map +0 -1
- package/dist/compact/parseMemoryExport.js.map +0 -1
- package/dist/compact/register.d.ts.map +0 -1
- package/dist/compact/register.js.map +0 -1
- package/dist/compact/runSummary.d.ts.map +0 -1
- package/dist/compact/runSummary.js.map +0 -1
- package/dist/compact/subagentDelta.d.ts.map +0 -1
- package/dist/compact/subagentDelta.js.map +0 -1
- package/dist/compact/summaryPrompt.d.ts.map +0 -1
- package/dist/compact/summaryPrompt.js.map +0 -1
- package/dist/config/agentDir.d.ts.map +0 -1
- package/dist/config/agentDir.js.map +0 -1
- package/dist/config/chunking.d.ts.map +0 -1
- package/dist/config/chunking.js.map +0 -1
- package/dist/config/env.d.ts.map +0 -1
- package/dist/config/env.js.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/loadEnv.d.ts.map +0 -1
- package/dist/config/loadEnv.js.map +0 -1
- package/dist/config/preflight.d.ts.map +0 -1
- package/dist/config/preflight.js.map +0 -1
- package/dist/config/preflightBudget.d.ts.map +0 -1
- package/dist/config/preflightBudget.js.map +0 -1
- package/dist/config/retrieval.d.ts.map +0 -1
- package/dist/config/retrieval.js.map +0 -1
- package/dist/consolidate/entryKey.d.ts.map +0 -1
- package/dist/consolidate/entryKey.js.map +0 -1
- package/dist/consolidate/index.d.ts.map +0 -1
- package/dist/consolidate/index.js.map +0 -1
- package/dist/consolidate/mergeEntries.d.ts.map +0 -1
- package/dist/consolidate/mergeEntries.js.map +0 -1
- package/dist/consolidate/mergePrompt.d.ts.map +0 -1
- package/dist/consolidate/mergePrompt.js.map +0 -1
- package/dist/consolidate/mergeWithLlm.d.ts.map +0 -1
- package/dist/consolidate/mergeWithLlm.js.map +0 -1
- package/dist/consolidate/runJob.d.ts.map +0 -1
- package/dist/consolidate/runJob.js.map +0 -1
- package/dist/consolidate/scheduler.d.ts.map +0 -1
- package/dist/consolidate/scheduler.js.map +0 -1
- package/dist/constants/chunking.d.ts.map +0 -1
- package/dist/constants/chunking.js.map +0 -1
- package/dist/constants/env.d.ts.map +0 -1
- package/dist/constants/env.js.map +0 -1
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js.map +0 -1
- package/dist/constants/memory.d.ts.map +0 -1
- package/dist/constants/memory.js.map +0 -1
- package/dist/constants/paths.d.ts.map +0 -1
- package/dist/constants/paths.js.map +0 -1
- package/dist/constants/preflight.d.ts.map +0 -1
- package/dist/constants/preflight.js.map +0 -1
- package/dist/constants/retrieval.d.ts.map +0 -1
- package/dist/constants/retrieval.js.map +0 -1
- package/dist/constants/security.d.ts.map +0 -1
- package/dist/constants/security.js.map +0 -1
- package/dist/constants/timing.d.ts.map +0 -1
- package/dist/constants/timing.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init/workspace.d.ts.map +0 -1
- package/dist/init/workspace.js.map +0 -1
- package/dist/ipc/jsonlFramer.d.ts.map +0 -1
- package/dist/ipc/jsonlFramer.js.map +0 -1
- package/dist/pi-extension.d.ts.map +0 -1
- package/dist/pi-extension.js.map +0 -1
- package/dist/preflight/episodic.d.ts.map +0 -1
- package/dist/preflight/episodic.js.map +0 -1
- package/dist/preflight/intentCache.d.ts.map +0 -1
- package/dist/preflight/intentCache.js.map +0 -1
- package/dist/preflight/queryCache.d.ts.map +0 -1
- package/dist/preflight/queryCache.js.map +0 -1
- package/dist/preflight/queryIntent.d.ts.map +0 -1
- package/dist/preflight/queryIntent.js.map +0 -1
- package/dist/preflight/render.d.ts.map +0 -1
- package/dist/preflight/render.js.map +0 -1
- package/dist/preflight/session.d.ts.map +0 -1
- package/dist/preflight/session.js.map +0 -1
- package/dist/preflight/strip.d.ts.map +0 -1
- package/dist/preflight/strip.js.map +0 -1
- package/dist/shutdown/enqueue.d.ts.map +0 -1
- package/dist/shutdown/enqueue.js.map +0 -1
- package/dist/shutdown/extractPrompt.d.ts.map +0 -1
- package/dist/shutdown/extractPrompt.js.map +0 -1
- package/dist/shutdown/processed.d.ts.map +0 -1
- package/dist/shutdown/processed.js.map +0 -1
- package/dist/shutdown/readQueue.d.ts.map +0 -1
- package/dist/shutdown/readQueue.js.map +0 -1
- package/dist/shutdown/runDrainJob.d.ts.map +0 -1
- package/dist/shutdown/runDrainJob.js.map +0 -1
- package/dist/shutdown/sessionReader.d.ts.map +0 -1
- package/dist/shutdown/sessionReader.js.map +0 -1
- package/dist/sidecar/client.d.ts.map +0 -1
- package/dist/sidecar/client.js.map +0 -1
- package/dist/sidecar/paths.d.ts.map +0 -1
- package/dist/sidecar/paths.js.map +0 -1
- package/dist/sidecar/protocol.d.ts.map +0 -1
- package/dist/sidecar/protocol.js.map +0 -1
- package/dist/sidecar/reindexBridge.d.ts.map +0 -1
- package/dist/sidecar/reindexBridge.js.map +0 -1
- package/dist/sidecar/server/process.d.ts.map +0 -1
- package/dist/sidecar/server/process.js.map +0 -1
- package/dist/sidecar/server/query.d.ts.map +0 -1
- package/dist/sidecar/server/query.js.map +0 -1
- package/dist/sidecar/server/reindex.d.ts.map +0 -1
- package/dist/sidecar/server/reindex.js.map +0 -1
- package/dist/sidecar/server/server.d.ts.map +0 -1
- package/dist/sidecar/server/server.js.map +0 -1
- package/dist/sidecar/server/stats.d.ts.map +0 -1
- package/dist/sidecar/server/stats.js.map +0 -1
- package/dist/sidecar/server/vec/embedder.d.ts.map +0 -1
- package/dist/sidecar/server/vec/embedder.js.map +0 -1
- package/dist/sidecar/server/vec/mmr.d.ts.map +0 -1
- package/dist/sidecar/server/vec/mmr.js.map +0 -1
- package/dist/sidecar/server/vec/store.d.ts.map +0 -1
- package/dist/sidecar/server/vec/store.js.map +0 -1
- package/dist/sidecar/sidecarManager.d.ts.map +0 -1
- package/dist/sidecar/sidecarManager.js.map +0 -1
- package/dist/sidecar/utils.d.ts.map +0 -1
- package/dist/sidecar/utils.js.map +0 -1
- package/dist/sidecar/warmup.d.ts.map +0 -1
- package/dist/sidecar/warmup.js.map +0 -1
- package/dist/store/backend.d.ts.map +0 -1
- package/dist/store/backend.js.map +0 -1
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js.map +0 -1
- package/dist/store/indexChunks.d.ts.map +0 -1
- package/dist/store/indexChunks.js.map +0 -1
- package/dist/store/markdown/format.d.ts.map +0 -1
- package/dist/store/markdown/format.js.map +0 -1
- package/dist/store/markdown/parse.d.ts.map +0 -1
- package/dist/store/markdown/parse.js.map +0 -1
- package/dist/store/markdown/template.d.ts.map +0 -1
- package/dist/store/markdown/template.js.map +0 -1
- package/dist/store/memoryStore.d.ts.map +0 -1
- package/dist/store/memoryStore.js.map +0 -1
- package/dist/store/paths.d.ts.map +0 -1
- package/dist/store/paths.js.map +0 -1
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js.map +0 -1
- package/dist/ui/memoryStatusWidget.d.ts.map +0 -1
- package/dist/ui/memoryStatusWidget.js.map +0 -1
- package/dist/utils/debugLog.d.ts.map +0 -1
- package/dist/utils/debugLog.js.map +0 -1
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/platform.d.ts.map +0 -1
- package/dist/utils/platform.js.map +0 -1
- package/dist/utils/scheduler.d.ts.map +0 -1
- package/dist/utils/scheduler.js.map +0 -1
- package/dist/utils/socket.d.ts.map +0 -1
- package/dist/utils/socket.js.map +0 -1
- package/dist/utils/time.d.ts.map +0 -1
- package/dist/utils/time.js.map +0 -1
- package/doc/README-zh.md +0 -394
- package/doc/ROADMAP-zh.md +0 -52
- package/doc/ROADMAP.md +0 -52
- package/src/adapters/embed/factory.ts +0 -50
- package/src/adapters/embed/hash.ts +0 -29
- package/src/adapters/embed/normalize.ts +0 -13
- package/src/adapters/embed/ollama.ts +0 -49
- package/src/adapters/embed/openai.ts +0 -46
- package/src/adapters/embed/types.ts +0 -9
- package/src/adapters/http.ts +0 -42
- package/src/adapters/index.ts +0 -16
- package/src/adapters/llm/extractText.ts +0 -6
- package/src/adapters/llm/factory.ts +0 -60
- package/src/adapters/llm/index.ts +0 -7
- package/src/adapters/llm/modelSpec.ts +0 -39
- package/src/adapters/llm/ollama.ts +0 -42
- package/src/adapters/llm/openai-compat.ts +0 -46
- package/src/adapters/llm/pi-ai.ts +0 -75
- package/src/adapters/llm/standalone.ts +0 -60
- package/src/adapters/llm/types.ts +0 -16
- package/src/cli/init.ts +0 -18
- package/src/cli/jobs.ts +0 -144
- package/src/cli/log.ts +0 -46
- package/src/cli/parseArgs.ts +0 -175
- package/src/cli/status.ts +0 -323
- package/src/cli/theme.ts +0 -26
- package/src/cli.ts +0 -105
- package/src/commands/index.ts +0 -20
- package/src/commands/parseMemoryStatusArgs.ts +0 -11
- package/src/commands/parseRememberArgs.ts +0 -55
- package/src/commands/remember.ts +0 -43
- package/src/commands/status.ts +0 -112
- package/src/commands/types.ts +0 -12
- package/src/compact/index.ts +0 -4
- package/src/compact/parseMemoryExport.ts +0 -71
- package/src/compact/register.ts +0 -57
- package/src/compact/runSummary.ts +0 -42
- package/src/compact/subagentDelta.ts +0 -22
- package/src/compact/summaryPrompt.ts +0 -45
- package/src/config/agentDir.ts +0 -24
- package/src/config/chunking.ts +0 -36
- package/src/config/env.ts +0 -97
- package/src/config/index.ts +0 -7
- package/src/config/loadEnv.ts +0 -26
- package/src/config/preflight.ts +0 -34
- package/src/config/preflightBudget.ts +0 -33
- package/src/config/retrieval.ts +0 -50
- package/src/consolidate/entryKey.ts +0 -4
- package/src/consolidate/index.ts +0 -4
- package/src/consolidate/mergeEntries.ts +0 -22
- package/src/consolidate/mergePrompt.ts +0 -46
- package/src/consolidate/mergeWithLlm.ts +0 -39
- package/src/consolidate/runJob.ts +0 -81
- package/src/consolidate/scheduler.ts +0 -54
- package/src/constants/chunking.ts +0 -8
- package/src/constants/env.ts +0 -59
- package/src/constants/index.ts +0 -7
- package/src/constants/memory.ts +0 -22
- package/src/constants/paths.ts +0 -26
- package/src/constants/preflight.ts +0 -22
- package/src/constants/retrieval.ts +0 -10
- package/src/constants/security.ts +0 -5
- package/src/constants/timing.ts +0 -48
- package/src/index.ts +0 -11
- package/src/init/workspace.ts +0 -44
- package/src/ipc/jsonlFramer.ts +0 -29
- package/src/pi-extension.ts +0 -294
- package/src/preflight/episodic.ts +0 -183
- package/src/preflight/intentCache.ts +0 -44
- package/src/preflight/queryCache.ts +0 -59
- package/src/preflight/queryIntent.ts +0 -126
- package/src/preflight/render.ts +0 -71
- package/src/preflight/session.ts +0 -7
- package/src/preflight/strip.ts +0 -43
- package/src/shutdown/enqueue.ts +0 -29
- package/src/shutdown/extractPrompt.ts +0 -27
- package/src/shutdown/processed.ts +0 -45
- package/src/shutdown/readQueue.ts +0 -26
- package/src/shutdown/runDrainJob.ts +0 -202
- package/src/shutdown/sessionReader.ts +0 -61
- package/src/sidecar/client.ts +0 -114
- package/src/sidecar/paths.ts +0 -31
- package/src/sidecar/protocol.ts +0 -38
- package/src/sidecar/reindexBridge.ts +0 -52
- package/src/sidecar/server/process.ts +0 -27
- package/src/sidecar/server/query.ts +0 -16
- package/src/sidecar/server/reindex.ts +0 -21
- package/src/sidecar/server/server.ts +0 -105
- package/src/sidecar/server/stats.ts +0 -23
- package/src/sidecar/server/vec/embedder.ts +0 -1
- package/src/sidecar/server/vec/mmr.ts +0 -55
- package/src/sidecar/server/vec/store.ts +0 -232
- package/src/sidecar/sidecarManager.ts +0 -134
- package/src/sidecar/utils.ts +0 -28
- package/src/sidecar/warmup.ts +0 -50
- package/src/store/backend.ts +0 -66
- package/src/store/index.ts +0 -5
- package/src/store/indexChunks.ts +0 -89
- package/src/store/markdown/format.ts +0 -16
- package/src/store/markdown/parse.ts +0 -63
- package/src/store/markdown/template.ts +0 -24
- package/src/store/memoryStore.ts +0 -518
- package/src/store/paths.ts +0 -33
- package/src/store/proper-lockfile.d.ts +0 -3
- package/src/store/types.ts +0 -46
- package/src/ui/memoryStatusWidget.ts +0 -80
- package/src/utils/debugLog.ts +0 -22
- package/src/utils/fs.ts +0 -115
- package/src/utils/index.ts +0 -68
- package/src/utils/paths.ts +0 -67
- package/src/utils/platform.ts +0 -20
- package/src/utils/scheduler.ts +0 -98
- package/src/utils/socket.ts +0 -33
- package/src/utils/time.ts +0 -51
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MEMORY_SECTIONS } from "../types.js";
|
|
2
|
-
|
|
3
|
-
const SECTION_HINTS: Record<(typeof MEMORY_SECTIONS)[number], string> = {
|
|
4
|
-
Preferences: "User preferences and defaults.",
|
|
5
|
-
Conventions: "Project or workflow conventions.",
|
|
6
|
-
Findings: "Durable conclusions, decisions, and facts.",
|
|
7
|
-
Todos: "Items to carry forward across sessions.",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/** Canonical empty MEMORY.md scaffold (ground truth format). */
|
|
11
|
-
export function defaultMemoryTemplate(): string {
|
|
12
|
-
const sections = MEMORY_SECTIONS.map((section) => {
|
|
13
|
-
return `## ${section}\n\n<!-- ${SECTION_HINTS[section]} -->\n`;
|
|
14
|
-
}).join("\n");
|
|
15
|
-
|
|
16
|
-
return `# Memory
|
|
17
|
-
|
|
18
|
-
<!-- pi-memory ground truth — cross-session durable notes for the Pi agent.
|
|
19
|
-
Sections: Preferences | Conventions | Findings | Todos
|
|
20
|
-
User entries: /remember → - [user] text <!-- id:... user ts:... -->
|
|
21
|
-
Line cap: 150; overflow spills to auto-*.md in this directory. -->
|
|
22
|
-
|
|
23
|
-
${sections}`;
|
|
24
|
-
}
|
package/src/store/memoryStore.ts
DELETED
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
|
|
3
|
-
import { parseMemoryExport } from "../compact/parseMemoryExport.js";
|
|
4
|
-
import {
|
|
5
|
-
filterCompactionDelta,
|
|
6
|
-
shouldSkipSubagentCompactionIngest,
|
|
7
|
-
} from "../compact/subagentDelta.js";
|
|
8
|
-
import { dedupeEntries } from "../consolidate/mergeEntries.js";
|
|
9
|
-
import { mergeEntriesWithLlm } from "../consolidate/mergeWithLlm.js";
|
|
10
|
-
import { MarkdownMemoryBackend } from "./backend.js";
|
|
11
|
-
import {
|
|
12
|
-
AUTO_FILE_PREFIX,
|
|
13
|
-
COMPACTION_STATE_FILE,
|
|
14
|
-
CONSOLIDATE_GC_INTERVAL_DAYS,
|
|
15
|
-
CONSOLIDATE_OVERFLOW_FILE_THRESHOLD,
|
|
16
|
-
DEFAULT_FALLBACK_MAX_CHARS,
|
|
17
|
-
DEFAULT_MAX_LINES,
|
|
18
|
-
DEFAULT_MEMORY_FILE,
|
|
19
|
-
MEMORY_GC_FILE,
|
|
20
|
-
} from "../constants/memory.js";
|
|
21
|
-
import { countLines, formatEntryLine, formatSectionHeader } from "./markdown/format.js";
|
|
22
|
-
import { listOverflowPointers, parseMemoryMarkdown } from "./markdown/parse.js";
|
|
23
|
-
import { initializeMemoryWorkspace } from "../init/workspace.js";
|
|
24
|
-
import { readChunkingConfig } from "../config/chunking.js";
|
|
25
|
-
import {
|
|
26
|
-
joinPath,
|
|
27
|
-
pathBasename,
|
|
28
|
-
readText,
|
|
29
|
-
readTextRequired,
|
|
30
|
-
writeText,
|
|
31
|
-
} from "../utils/fs.js";
|
|
32
|
-
import { buildIndexDocuments } from "./indexChunks.js";
|
|
33
|
-
import { daysSince, formatLocalDate, formatTimestamp, type TimeInput } from "../utils/time.js";
|
|
34
|
-
import { getAgentPaths, resolveAgentDir } from "./paths.js";
|
|
35
|
-
import type {
|
|
36
|
-
IndexDocument,
|
|
37
|
-
IntegrityReport,
|
|
38
|
-
LlmClient,
|
|
39
|
-
MemoryStats,
|
|
40
|
-
MemoryStoreOptions,
|
|
41
|
-
ParsedEntry,
|
|
42
|
-
ResolvedMemory,
|
|
43
|
-
StoreMemoryEntry,
|
|
44
|
-
} from "./types.js";
|
|
45
|
-
import { MEMORY_SECTIONS } from "./types.js";
|
|
46
|
-
|
|
47
|
-
type CompactionState = {
|
|
48
|
-
processed: string[];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export class MemoryStore {
|
|
52
|
-
private readonly paths: ReturnType<typeof getAgentPaths>;
|
|
53
|
-
private readonly backend: MarkdownMemoryBackend;
|
|
54
|
-
private readonly maxLines: number;
|
|
55
|
-
private readonly fallbackMaxChars: number;
|
|
56
|
-
private readonly syncToSidecarListeners = new Set<() => void>();
|
|
57
|
-
private readonly consolidateCheckListeners = new Set<() => void>();
|
|
58
|
-
private consolidating = false;
|
|
59
|
-
|
|
60
|
-
constructor(opts: MemoryStoreOptions) {
|
|
61
|
-
const agentDir = resolveAgentDir(opts.agentDir);
|
|
62
|
-
this.paths = getAgentPaths(agentDir, opts.memoryFileName ?? DEFAULT_MEMORY_FILE);
|
|
63
|
-
this.backend = new MarkdownMemoryBackend(this.paths.memoryFile);
|
|
64
|
-
this.maxLines = opts.maxLines ?? DEFAULT_MAX_LINES;
|
|
65
|
-
this.fallbackMaxChars = opts.defaultFallbackMaxChars ?? DEFAULT_FALLBACK_MAX_CHARS;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get agentDir(): string {
|
|
69
|
-
return this.paths.agentDir;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async ensureInitialized(): Promise<void> {
|
|
73
|
-
await initializeMemoryWorkspace(this.paths.agentDir);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async isEmpty(): Promise<boolean> {
|
|
77
|
-
const entries = await this.listEntries();
|
|
78
|
-
return entries.length === 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async getStats(): Promise<MemoryStats> {
|
|
82
|
-
const raw = await this.readRaw();
|
|
83
|
-
const entries = await this.listEntries();
|
|
84
|
-
const overflowFileCount = (await this.backend.listAutoFiles(this.paths.agentDir)).length;
|
|
85
|
-
const lastConsolidatedAt = await this.readGcTimestamp();
|
|
86
|
-
return {
|
|
87
|
-
lineCount: countLines(raw),
|
|
88
|
-
overflowFileCount,
|
|
89
|
-
entryCount: entries.length,
|
|
90
|
-
lastConsolidatedAt,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async readRaw(): Promise<string> {
|
|
95
|
-
return this.backend.readText(this.paths.memoryFile);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async listEntries(): Promise<ParsedEntry[]> {
|
|
99
|
-
const resolved = await this.readResolved();
|
|
100
|
-
return resolved.entries;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async readResolved(): Promise<ResolvedMemory> {
|
|
104
|
-
await this.ensureInitialized();
|
|
105
|
-
const main = await this.backend.readText(this.paths.memoryFile);
|
|
106
|
-
const entries = [...parseMemoryMarkdown(main, this.paths.memoryFile)];
|
|
107
|
-
|
|
108
|
-
for (const fileName of listOverflowPointers(main)) {
|
|
109
|
-
const path = this.backend.autoFilePath(this.paths.agentDir, fileName);
|
|
110
|
-
const overflow = await this.backend.readText(path);
|
|
111
|
-
entries.push(...parseMemoryMarkdown(overflow, path));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const autoFiles = await this.backend.listAutoFiles(this.paths.agentDir);
|
|
115
|
-
for (const fileName of autoFiles) {
|
|
116
|
-
if (listOverflowPointers(main).includes(fileName)) continue;
|
|
117
|
-
const path = this.backend.autoFilePath(this.paths.agentDir, fileName);
|
|
118
|
-
const orphan = await this.backend.readText(path);
|
|
119
|
-
entries.push(...parseMemoryMarkdown(orphan, path));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return { content: main, entries };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async readForFallback(maxChars = this.fallbackMaxChars): Promise<string> {
|
|
126
|
-
const resolved = await this.readResolved();
|
|
127
|
-
if (resolved.entries.length === 0) return "";
|
|
128
|
-
|
|
129
|
-
const blocks = resolved.entries.map((entry) => {
|
|
130
|
-
const tag = entry.userAuthored ? "[user] " : "";
|
|
131
|
-
return `- ${tag}${entry.content}`;
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
let text = blocks.join("\n");
|
|
135
|
-
if (text.length <= maxChars) return text;
|
|
136
|
-
return `${text.slice(0, maxChars)}\n…`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async exportForIndex(): Promise<IndexDocument[]> {
|
|
140
|
-
const resolved = await this.readResolved();
|
|
141
|
-
return buildIndexDocuments(resolved.entries, readChunkingConfig());
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async append(entry: StoreMemoryEntry): Promise<void> {
|
|
145
|
-
await this.backend.withMemoryLock(async () => {
|
|
146
|
-
await this.appendUnlocked(entry);
|
|
147
|
-
});
|
|
148
|
-
this.notifyAfterWrite();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async appendUser(entry: Omit<StoreMemoryEntry, "userAuthored">): Promise<void> {
|
|
152
|
-
await this.backend.withMemoryLock(async () => {
|
|
153
|
-
await this.appendUnlocked({ ...entry, userAuthored: true });
|
|
154
|
-
});
|
|
155
|
-
this.notifyAfterWrite();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async appendMany(entries: StoreMemoryEntry[], opts?: { mode?: "ifAbsent" }): Promise<void> {
|
|
159
|
-
await this.backend.withMemoryLock(async () => {
|
|
160
|
-
for (const entry of entries) {
|
|
161
|
-
if (opts?.mode === "ifAbsent") {
|
|
162
|
-
const added = await this.appendIfAbsentUnlocked(entry);
|
|
163
|
-
if (!added) continue;
|
|
164
|
-
} else {
|
|
165
|
-
await this.appendUnlocked(entry);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
if (entries.length > 0) this.notifyAfterWrite();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
async appendIfAbsent(entry: StoreMemoryEntry): Promise<boolean> {
|
|
173
|
-
let added = false;
|
|
174
|
-
await this.backend.withMemoryLock(async () => {
|
|
175
|
-
added = await this.appendIfAbsentUnlocked(entry);
|
|
176
|
-
});
|
|
177
|
-
if (added) this.notifyAfterWrite();
|
|
178
|
-
return added;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** Fire-and-forget: parse Memory Export from compact summary → appendIfAbsent. */
|
|
182
|
-
appendFromCompaction(opts: {
|
|
183
|
-
compactionId: string;
|
|
184
|
-
summary: string;
|
|
185
|
-
subagent?: boolean;
|
|
186
|
-
onComplete?: () => void | Promise<void>;
|
|
187
|
-
}): void {
|
|
188
|
-
void this.ingestCompactionSummary(opts).catch(() => {});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private async ingestCompactionSummary(opts: {
|
|
192
|
-
compactionId: string;
|
|
193
|
-
summary: string;
|
|
194
|
-
subagent?: boolean;
|
|
195
|
-
onComplete?: () => void | Promise<void>;
|
|
196
|
-
}): Promise<void> {
|
|
197
|
-
if (await this.hasProcessedCompaction(opts.compactionId)) return;
|
|
198
|
-
|
|
199
|
-
await this.ensureInitialized();
|
|
200
|
-
const parsed = parseMemoryExport(opts.summary);
|
|
201
|
-
|
|
202
|
-
if (opts.subagent) {
|
|
203
|
-
const existing = await this.listEntries();
|
|
204
|
-
const delta = filterCompactionDelta(parsed, existing);
|
|
205
|
-
if (shouldSkipSubagentCompactionIngest(parsed, delta)) {
|
|
206
|
-
await this.markCompactionProcessed(opts.compactionId);
|
|
207
|
-
await opts.onComplete?.();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (delta.length > 0) {
|
|
211
|
-
await this.appendMany(delta, { mode: "ifAbsent" });
|
|
212
|
-
}
|
|
213
|
-
} else if (parsed.length > 0) {
|
|
214
|
-
await this.appendMany(parsed, { mode: "ifAbsent" });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
await this.markCompactionProcessed(opts.compactionId);
|
|
218
|
-
await opts.onComplete?.();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async updateEntry(id: string, patch: Partial<StoreMemoryEntry>): Promise<void> {
|
|
222
|
-
await this.backend.withMemoryLock(async () => {
|
|
223
|
-
const resolved = await this.readResolvedUnlocked();
|
|
224
|
-
const target = resolved.entries.find((entry) => entry.id === id);
|
|
225
|
-
if (!target) throw new Error(`Memory entry not found: ${id}`);
|
|
226
|
-
|
|
227
|
-
const next: StoreMemoryEntry = {
|
|
228
|
-
...target,
|
|
229
|
-
...patch,
|
|
230
|
-
id: target.id,
|
|
231
|
-
section: patch.section ?? target.section,
|
|
232
|
-
content: patch.content ?? target.content,
|
|
233
|
-
timestamp: patch.timestamp ?? target.timestamp,
|
|
234
|
-
userAuthored: patch.userAuthored ?? target.userAuthored,
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
await this.rewriteEntriesUnlocked(resolved.entries.map((entry) => (entry.id === id ? { ...entry, ...next } : entry)));
|
|
238
|
-
});
|
|
239
|
-
this.notifyAfterWrite();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async removeEntry(id: string, opts?: { force?: boolean }): Promise<void> {
|
|
243
|
-
await this.backend.withMemoryLock(async () => {
|
|
244
|
-
const resolved = await this.readResolvedUnlocked();
|
|
245
|
-
const target = resolved.entries.find((entry) => entry.id === id);
|
|
246
|
-
if (!target) return;
|
|
247
|
-
if (target.userAuthored && !opts?.force) {
|
|
248
|
-
throw new Error(`Cannot remove user-authored entry without force: ${id}`);
|
|
249
|
-
}
|
|
250
|
-
await this.rewriteEntriesUnlocked(resolved.entries.filter((entry) => entry.id !== id));
|
|
251
|
-
});
|
|
252
|
-
this.notifyAfterWrite();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async rewrite(content: string): Promise<void> {
|
|
256
|
-
await this.backend.withMemoryLock(async () => {
|
|
257
|
-
await this.backend.writeText(this.paths.memoryFile, content);
|
|
258
|
-
});
|
|
259
|
-
this.notifyAfterWrite({ skipConsolidateCheck: true });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
async shouldConsolidate(at?: TimeInput, cronFired = false): Promise<boolean> {
|
|
263
|
-
const stats = await this.getStats();
|
|
264
|
-
if (stats.overflowFileCount >= CONSOLIDATE_OVERFLOW_FILE_THRESHOLD) return true;
|
|
265
|
-
if (cronFired) return true;
|
|
266
|
-
if (!stats.lastConsolidatedAt) return false;
|
|
267
|
-
return daysSince(stats.lastConsolidatedAt, at) >= CONSOLIDATE_GC_INTERVAL_DAYS;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
async consolidate(llm: LlmClient): Promise<void> {
|
|
271
|
-
if (this.consolidating) return;
|
|
272
|
-
|
|
273
|
-
this.consolidating = true;
|
|
274
|
-
try {
|
|
275
|
-
await this.backend.withMemoryLock(async () => {
|
|
276
|
-
const resolved = await this.readResolvedUnlocked();
|
|
277
|
-
let entries = dedupeEntries(resolved.entries);
|
|
278
|
-
|
|
279
|
-
try {
|
|
280
|
-
entries = await mergeEntriesWithLlm(entries, llm);
|
|
281
|
-
} catch {
|
|
282
|
-
// rule-based dedupe only
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
await this.rewriteEntriesUnlocked(entries);
|
|
286
|
-
await writeText(this.paths.memoryGcFile, `${formatTimestamp()}\n`);
|
|
287
|
-
});
|
|
288
|
-
this.notifySyncToSidecar();
|
|
289
|
-
} finally {
|
|
290
|
-
this.consolidating = false;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
consolidateInBackground(
|
|
295
|
-
llm: LlmClient,
|
|
296
|
-
opts: { onComplete?: () => void | Promise<void> } = {},
|
|
297
|
-
): void {
|
|
298
|
-
void this.consolidate(llm)
|
|
299
|
-
.then(() => opts.onComplete?.())
|
|
300
|
-
.catch(() => {});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
async forceConsolidate(llm: LlmClient): Promise<void> {
|
|
304
|
-
await this.consolidate(llm);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async hasProcessedCompaction(compactionId: string): Promise<boolean> {
|
|
308
|
-
const state = await this.readCompactionState();
|
|
309
|
-
return state.processed.includes(compactionId);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
async markCompactionProcessed(compactionId: string): Promise<void> {
|
|
313
|
-
const state = await this.readCompactionState();
|
|
314
|
-
if (!state.processed.includes(compactionId)) {
|
|
315
|
-
state.processed.push(compactionId);
|
|
316
|
-
}
|
|
317
|
-
await writeText(this.paths.compactionStateFile, JSON.stringify(state, null, 2));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
async verifyIntegrity(): Promise<IntegrityReport> {
|
|
321
|
-
const issues: string[] = [];
|
|
322
|
-
const main = await this.backend.readText(this.paths.memoryFile);
|
|
323
|
-
const pointers = listOverflowPointers(main);
|
|
324
|
-
|
|
325
|
-
for (const fileName of pointers) {
|
|
326
|
-
const path = this.backend.autoFilePath(this.paths.agentDir, fileName);
|
|
327
|
-
try {
|
|
328
|
-
await readTextRequired(path);
|
|
329
|
-
} catch {
|
|
330
|
-
issues.push(`Missing overflow file referenced by MEMORY.md: ${fileName}`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return { ok: issues.length === 0, issues };
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/** Register a listener to sync MEMORY.md changes to the sidecar vector index. */
|
|
338
|
-
onSyncToSidecar(listener: () => void): () => void {
|
|
339
|
-
this.syncToSidecarListeners.add(listener);
|
|
340
|
-
return () => this.syncToSidecarListeners.delete(listener);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/** Register a listener invoked after writes to check shouldConsolidate. */
|
|
344
|
-
onConsolidateCheck(listener: () => void): () => void {
|
|
345
|
-
this.consolidateCheckListeners.add(listener);
|
|
346
|
-
return () => this.consolidateCheckListeners.delete(listener);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private notifyAfterWrite(opts?: { skipConsolidateCheck?: boolean }): void {
|
|
350
|
-
this.notifySyncToSidecar();
|
|
351
|
-
if (!opts?.skipConsolidateCheck && !this.consolidating) {
|
|
352
|
-
this.notifyConsolidateCheck();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
private notifySyncToSidecar(): void {
|
|
357
|
-
for (const listener of this.syncToSidecarListeners) listener();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
private notifyConsolidateCheck(): void {
|
|
361
|
-
for (const listener of this.consolidateCheckListeners) listener();
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
private async appendUnlocked(entry: StoreMemoryEntry): Promise<void> {
|
|
365
|
-
const normalized = this.normalizeEntry(entry);
|
|
366
|
-
const main = await this.backend.readText(this.paths.memoryFile);
|
|
367
|
-
if (countLines(main) >= this.maxLines) {
|
|
368
|
-
await this.appendToOverflowUnlocked(normalized, main);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const next = this.insertEntryIntoMarkdown(main, normalized);
|
|
373
|
-
if (countLines(next) > this.maxLines) {
|
|
374
|
-
await this.appendToOverflowUnlocked(normalized, main);
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
await this.backend.writeText(this.paths.memoryFile, next);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
private async appendIfAbsentUnlocked(entry: StoreMemoryEntry): Promise<boolean> {
|
|
382
|
-
const resolved = await this.readResolvedUnlocked();
|
|
383
|
-
const exists = resolved.entries.some(
|
|
384
|
-
(item) => item.section === entry.section && item.content.trim() === entry.content.trim(),
|
|
385
|
-
);
|
|
386
|
-
if (exists) return false;
|
|
387
|
-
await this.appendUnlocked(entry);
|
|
388
|
-
return true;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
private async appendToOverflowUnlocked(entry: StoreMemoryEntry, main: string): Promise<void> {
|
|
392
|
-
const autoFiles = await this.backend.listAutoFiles(this.paths.agentDir);
|
|
393
|
-
let targetName = autoFiles.at(-1);
|
|
394
|
-
let targetPath = targetName
|
|
395
|
-
? this.backend.autoFilePath(this.paths.agentDir, targetName)
|
|
396
|
-
: this.newAutoFilePath();
|
|
397
|
-
|
|
398
|
-
if (!targetName) {
|
|
399
|
-
targetName = pathBasename(targetPath);
|
|
400
|
-
await this.backend.writeText(targetPath, `${formatSectionHeader(entry.section)}\n\n`);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
let overflowContent = await this.backend.readText(targetPath);
|
|
404
|
-
const line = formatEntryLine(entry);
|
|
405
|
-
overflowContent = overflowContent.trimEnd() + `\n${line}\n`;
|
|
406
|
-
await this.backend.writeText(targetPath, overflowContent);
|
|
407
|
-
|
|
408
|
-
const pointer = `- (overflow) → ${targetName}`;
|
|
409
|
-
if (!main.includes(pointer)) {
|
|
410
|
-
const withPointer = `${main.trimEnd()}\n${pointer}\n`;
|
|
411
|
-
await this.backend.writeText(this.paths.memoryFile, withPointer);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
private insertEntryIntoMarkdown(content: string, entry: StoreMemoryEntry): string {
|
|
416
|
-
const lines = content.split("\n");
|
|
417
|
-
const header = formatSectionHeader(entry.section);
|
|
418
|
-
const headerIdx = lines.findIndex((line) => line.trim() === header);
|
|
419
|
-
const line = formatEntryLine(entry);
|
|
420
|
-
|
|
421
|
-
if (headerIdx === -1) {
|
|
422
|
-
const trimmed = content.trimEnd();
|
|
423
|
-
return `${trimmed}\n\n${header}\n\n${line}\n`;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
let insertAt = headerIdx + 1;
|
|
427
|
-
while (insertAt < lines.length && lines[insertAt]?.trim() === "") insertAt++;
|
|
428
|
-
|
|
429
|
-
while (insertAt < lines.length) {
|
|
430
|
-
const current = lines[insertAt]!;
|
|
431
|
-
if (current.startsWith("## ")) break;
|
|
432
|
-
insertAt++;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
const next = [...lines.slice(0, insertAt), line, ...lines.slice(insertAt)];
|
|
436
|
-
return `${next.join("\n").trimEnd()}\n`;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
private async rewriteEntriesUnlocked(entries: ParsedEntry[]): Promise<void> {
|
|
440
|
-
const grouped = new Map<string, ParsedEntry[]>();
|
|
441
|
-
for (const section of MEMORY_SECTIONS) grouped.set(section, []);
|
|
442
|
-
for (const entry of entries) {
|
|
443
|
-
grouped.get(entry.section)?.push(entry);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const lines: string[] = [];
|
|
447
|
-
for (const section of MEMORY_SECTIONS) {
|
|
448
|
-
lines.push(formatSectionHeader(section), "");
|
|
449
|
-
for (const entry of grouped.get(section) ?? []) {
|
|
450
|
-
lines.push(
|
|
451
|
-
formatEntryLine({
|
|
452
|
-
id: entry.id,
|
|
453
|
-
section: entry.section,
|
|
454
|
-
content: entry.content,
|
|
455
|
-
userAuthored: entry.userAuthored,
|
|
456
|
-
timestamp: entry.timestamp,
|
|
457
|
-
}),
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
lines.push("");
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
await this.backend.writeText(this.paths.memoryFile, `${lines.join("\n").trimEnd()}\n`);
|
|
464
|
-
const autoFiles = await this.backend.listAutoFiles(this.paths.agentDir);
|
|
465
|
-
await Promise.all(
|
|
466
|
-
autoFiles.map((fileName) =>
|
|
467
|
-
this.backend.deleteAutoFile(this.backend.autoFilePath(this.paths.agentDir, fileName)),
|
|
468
|
-
),
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
private async readResolvedUnlocked(): Promise<ResolvedMemory> {
|
|
473
|
-
const main = await this.backend.readText(this.paths.memoryFile);
|
|
474
|
-
const entries = [...parseMemoryMarkdown(main, this.paths.memoryFile)];
|
|
475
|
-
for (const fileName of listOverflowPointers(main)) {
|
|
476
|
-
const path = this.backend.autoFilePath(this.paths.agentDir, fileName);
|
|
477
|
-
entries.push(...parseMemoryMarkdown(await this.backend.readText(path), path));
|
|
478
|
-
}
|
|
479
|
-
return { content: main, entries };
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
private normalizeEntry(entry: StoreMemoryEntry): StoreMemoryEntry {
|
|
483
|
-
return {
|
|
484
|
-
...entry,
|
|
485
|
-
id: entry.id || this.newEntryId(),
|
|
486
|
-
timestamp: entry.timestamp || formatTimestamp(),
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
private newEntryId(): string {
|
|
491
|
-
return randomBytes(6).toString("hex");
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
private newAutoFilePath(): string {
|
|
495
|
-
const date = formatLocalDate();
|
|
496
|
-
const suffix = randomBytes(3).toString("hex");
|
|
497
|
-
return joinPath(this.paths.agentDir, `${AUTO_FILE_PREFIX}${date}-${suffix}.md`);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
private async readGcTimestamp(): Promise<string | null> {
|
|
501
|
-
const raw = await readText(this.paths.memoryGcFile);
|
|
502
|
-
return raw.trim() || null;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
private async readCompactionState(): Promise<CompactionState> {
|
|
506
|
-
const raw = await readText(this.paths.compactionStateFile);
|
|
507
|
-
if (!raw.trim()) return { processed: [] };
|
|
508
|
-
try {
|
|
509
|
-
return JSON.parse(raw) as CompactionState;
|
|
510
|
-
} catch {
|
|
511
|
-
return { processed: [] };
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
export function createMemoryStore(opts: MemoryStoreOptions): MemoryStore {
|
|
517
|
-
return new MemoryStore(opts);
|
|
518
|
-
}
|
package/src/store/paths.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { expandHomePath } from "../utils/paths.js";
|
|
2
|
-
import { joinPath } from "../utils/fs.js";
|
|
3
|
-
import {
|
|
4
|
-
AUTO_FILE_PREFIX,
|
|
5
|
-
COMPACTION_STATE_FILE,
|
|
6
|
-
DEFAULT_MEMORY_FILE,
|
|
7
|
-
MEMORY_GC_FILE,
|
|
8
|
-
} from "../constants/memory.js";
|
|
9
|
-
|
|
10
|
-
export type AgentPaths = {
|
|
11
|
-
agentDir: string;
|
|
12
|
-
memoryFile: string;
|
|
13
|
-
memoryGcFile: string;
|
|
14
|
-
compactionStateFile: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function resolveAgentDir(agentDir: string): string {
|
|
18
|
-
return expandHomePath(agentDir);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getAgentPaths(agentDir: string, memoryFileName = DEFAULT_MEMORY_FILE): AgentPaths {
|
|
22
|
-
const resolved = resolveAgentDir(agentDir);
|
|
23
|
-
return {
|
|
24
|
-
agentDir: resolved,
|
|
25
|
-
memoryFile: joinPath(resolved, memoryFileName),
|
|
26
|
-
memoryGcFile: joinPath(resolved, MEMORY_GC_FILE),
|
|
27
|
-
compactionStateFile: joinPath(resolved, COMPACTION_STATE_FILE),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function isAutoOverflowFile(name: string): boolean {
|
|
32
|
-
return name.startsWith(AUTO_FILE_PREFIX) && name.endsWith(".md");
|
|
33
|
-
}
|
package/src/store/types.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { IndexDocument } from "../sidecar/protocol.js";
|
|
2
|
-
import { MEMORY_SECTIONS, type MemorySection } from "../constants/memory.js";
|
|
3
|
-
|
|
4
|
-
export { MEMORY_SECTIONS, type MemorySection };
|
|
5
|
-
|
|
6
|
-
/** Durable note stored in MEMORY.md (+ overflow files). */
|
|
7
|
-
export type StoreMemoryEntry = {
|
|
8
|
-
id: string;
|
|
9
|
-
section: MemorySection;
|
|
10
|
-
content: string;
|
|
11
|
-
userAuthored?: boolean;
|
|
12
|
-
timestamp: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type ParsedEntry = StoreMemoryEntry & {
|
|
16
|
-
sourceFile: string;
|
|
17
|
-
line: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type MemoryStats = {
|
|
21
|
-
lineCount: number;
|
|
22
|
-
overflowFileCount: number;
|
|
23
|
-
entryCount: number;
|
|
24
|
-
lastConsolidatedAt: string | null;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type ResolvedMemory = {
|
|
28
|
-
content: string;
|
|
29
|
-
entries: ParsedEntry[];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type IntegrityReport = {
|
|
33
|
-
ok: boolean;
|
|
34
|
-
issues: string[];
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type { LlmClient } from "../adapters/llm/types.js";
|
|
38
|
-
|
|
39
|
-
export type MemoryStoreOptions = {
|
|
40
|
-
agentDir: string;
|
|
41
|
-
memoryFileName?: string;
|
|
42
|
-
maxLines?: number;
|
|
43
|
-
defaultFallbackMaxChars?: number;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type { IndexDocument };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { Component, TUI } from "@earendil-works/pi-tui";
|
|
3
|
-
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
4
|
-
|
|
5
|
-
import type { MemoryStatusReport } from "../cli/status.js";
|
|
6
|
-
import {
|
|
7
|
-
formatMemoryStatusSummary,
|
|
8
|
-
formatMemoryStatusTuiLines,
|
|
9
|
-
piStatusPalette,
|
|
10
|
-
} from "../cli/status.js";
|
|
11
|
-
|
|
12
|
-
export type MemoryStatusWidgetState = {
|
|
13
|
-
report: MemoryStatusReport;
|
|
14
|
-
expanded: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
function formatHeader(theme: Theme, width: number): string {
|
|
18
|
-
const title = theme.fg("accent", theme.bold("pi-memory status"));
|
|
19
|
-
const fill = Math.max(0, width - title.length - 2);
|
|
20
|
-
const left = Math.floor(fill / 2);
|
|
21
|
-
const right = fill - left;
|
|
22
|
-
return `${theme.fg("borderMuted", "─".repeat(left))} ${title} ${theme.fg("borderMuted", "─".repeat(right))}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class MemoryStatusWidget implements Component {
|
|
26
|
-
private cachedWidth?: number;
|
|
27
|
-
private cachedLines?: string[];
|
|
28
|
-
private version = 0;
|
|
29
|
-
private cachedVersion = -1;
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
private readonly theme: Theme,
|
|
33
|
-
private state: MemoryStatusWidgetState,
|
|
34
|
-
) {}
|
|
35
|
-
|
|
36
|
-
invalidate(): void {
|
|
37
|
-
this.cachedLines = undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render(width: number): string[] {
|
|
41
|
-
if (this.cachedLines && this.cachedWidth === width && this.cachedVersion === this.version) {
|
|
42
|
-
return this.cachedLines;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const palette = piStatusPalette(this.theme);
|
|
46
|
-
const lines: string[] = [];
|
|
47
|
-
|
|
48
|
-
if (!this.state.expanded) {
|
|
49
|
-
const summary = formatMemoryStatusSummary(this.state.report, palette, (text) =>
|
|
50
|
-
this.theme.fg("accent", text),
|
|
51
|
-
);
|
|
52
|
-
const hint = this.theme.fg("dim", " (/memory-status to expand)");
|
|
53
|
-
lines.push(truncateToWidth(`${summary}${hint}`, width));
|
|
54
|
-
} else {
|
|
55
|
-
lines.push(truncateToWidth(formatHeader(this.theme, width), width));
|
|
56
|
-
for (const line of formatMemoryStatusTuiLines(this.state.report, palette, this.theme)) {
|
|
57
|
-
lines.push(truncateToWidth(` ${line}`, width));
|
|
58
|
-
}
|
|
59
|
-
lines.push(
|
|
60
|
-
truncateToWidth(
|
|
61
|
-
this.theme.fg("dim", " /memory-status to collapse · /memory-status hide to dismiss"),
|
|
62
|
-
width,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.cachedLines = lines;
|
|
68
|
-
this.cachedWidth = width;
|
|
69
|
-
this.cachedVersion = this.version;
|
|
70
|
-
return lines;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function createMemoryStatusWidget(
|
|
75
|
-
_tui: TUI,
|
|
76
|
-
theme: Theme,
|
|
77
|
-
state: MemoryStatusWidgetState,
|
|
78
|
-
): MemoryStatusWidget {
|
|
79
|
-
return new MemoryStatusWidget(theme, state);
|
|
80
|
-
}
|