@chendpoc/pi-memory 0.1.13 → 0.2.1
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 +284 -216
- package/UBIQUITOUS_LANGUAGE.md +81 -0
- package/dist/adapters/embed/factory.d.ts +7 -0
- package/dist/adapters/embed/factory.d.ts.map +1 -0
- package/dist/adapters/embed/factory.js +44 -0
- package/dist/adapters/embed/factory.js.map +1 -0
- package/dist/adapters/embed/hash.d.ts +3 -0
- package/dist/adapters/embed/hash.d.ts.map +1 -0
- package/dist/adapters/embed/hash.js +26 -0
- package/dist/adapters/embed/hash.js.map +1 -0
- package/dist/adapters/embed/normalize.d.ts +3 -0
- package/dist/adapters/embed/normalize.d.ts.map +1 -0
- package/dist/adapters/embed/normalize.js +15 -0
- package/dist/adapters/embed/normalize.js.map +1 -0
- package/dist/adapters/embed/ollama.d.ts +8 -0
- package/dist/adapters/embed/ollama.d.ts.map +1 -0
- package/dist/adapters/embed/ollama.js +31 -0
- package/dist/adapters/embed/ollama.js.map +1 -0
- package/dist/adapters/embed/openai.d.ts +8 -0
- package/dist/adapters/embed/openai.d.ts.map +1 -0
- package/dist/adapters/embed/openai.js +30 -0
- package/dist/adapters/embed/openai.js.map +1 -0
- package/dist/adapters/embed/types.d.ts +9 -0
- package/dist/adapters/embed/types.d.ts.map +1 -0
- package/dist/adapters/embed/types.js.map +1 -0
- package/dist/adapters/http.d.ts +13 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/http.js +31 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/llm/extractText.d.ts +5 -0
- package/dist/adapters/llm/extractText.d.ts.map +1 -0
- package/dist/adapters/llm/extractText.js +7 -0
- package/dist/adapters/llm/extractText.js.map +1 -0
- package/dist/adapters/llm/factory.d.ts +11 -0
- package/dist/adapters/llm/factory.d.ts.map +1 -0
- package/dist/adapters/llm/factory.js +48 -0
- package/dist/adapters/llm/factory.js.map +1 -0
- package/dist/adapters/llm/index.d.ts +8 -0
- package/dist/adapters/llm/index.d.ts.map +1 -0
- package/dist/adapters/llm/index.js +7 -0
- package/dist/adapters/llm/index.js.map +1 -0
- package/dist/adapters/llm/modelSpec.d.ts +10 -0
- package/dist/adapters/llm/modelSpec.d.ts.map +1 -0
- package/dist/adapters/llm/modelSpec.js +21 -0
- package/dist/adapters/llm/modelSpec.js.map +1 -0
- package/dist/adapters/llm/ollama.d.ts +4 -0
- package/dist/adapters/llm/ollama.d.ts.map +1 -0
- package/dist/adapters/llm/ollama.js +32 -0
- package/dist/adapters/llm/ollama.js.map +1 -0
- package/dist/adapters/llm/openai-compat.d.ts +4 -0
- package/dist/adapters/llm/openai-compat.d.ts.map +1 -0
- package/dist/adapters/llm/openai-compat.js +36 -0
- package/dist/adapters/llm/openai-compat.js.map +1 -0
- package/dist/adapters/llm/pi-ai.d.ts +5 -0
- package/dist/adapters/llm/pi-ai.d.ts.map +1 -0
- package/dist/adapters/llm/pi-ai.js +60 -0
- package/dist/adapters/llm/pi-ai.js.map +1 -0
- package/dist/adapters/llm/standalone.d.ts +6 -0
- package/dist/adapters/llm/standalone.d.ts.map +1 -0
- package/dist/adapters/llm/standalone.js +44 -0
- package/dist/adapters/llm/standalone.js.map +1 -0
- package/dist/adapters/llm/types.d.ts +15 -0
- package/dist/adapters/llm/types.d.ts.map +1 -0
- package/dist/adapters/llm/types.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +13 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/jobs.d.ts +32 -0
- package/dist/cli/jobs.d.ts.map +1 -0
- package/dist/cli/jobs.js +100 -0
- package/dist/cli/jobs.js.map +1 -0
- package/dist/cli/log.d.ts +14 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +32 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/cli/parseArgs.d.ts +35 -0
- package/dist/cli/parseArgs.d.ts.map +1 -0
- package/dist/cli/parseArgs.js +127 -0
- package/dist/cli/parseArgs.js.map +1 -0
- package/dist/cli/status.d.ts +44 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +238 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/theme.d.ts +14 -0
- package/dist/cli/theme.d.ts.map +1 -0
- package/dist/cli/theme.js +20 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/cli.js +70 -356
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +14 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/parseMemoryStatusArgs.d.ts +3 -0
- package/dist/commands/parseMemoryStatusArgs.d.ts.map +1 -0
- package/dist/commands/parseMemoryStatusArgs.js +15 -0
- package/dist/commands/parseMemoryStatusArgs.js.map +1 -0
- package/dist/commands/parseRememberArgs.d.ts +10 -0
- package/dist/commands/parseRememberArgs.d.ts.map +1 -0
- package/dist/commands/parseRememberArgs.js +46 -0
- package/dist/commands/parseRememberArgs.js.map +1 -0
- package/dist/commands/remember.d.ts +8 -0
- package/dist/commands/remember.d.ts.map +1 -0
- package/dist/commands/remember.js +30 -0
- package/dist/commands/remember.js.map +1 -0
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +81 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/types.d.ts +10 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +2 -0
- package/dist/{consolidation → commands}/types.js.map +1 -1
- package/dist/compact/index.d.ts +5 -0
- package/dist/compact/index.d.ts.map +1 -0
- package/dist/compact/index.js +5 -0
- package/dist/compact/index.js.map +1 -0
- package/dist/compact/parseMemoryExport.d.ts +6 -0
- package/dist/compact/parseMemoryExport.d.ts.map +1 -0
- package/dist/compact/parseMemoryExport.js +62 -0
- package/dist/compact/parseMemoryExport.js.map +1 -0
- package/dist/compact/register.d.ts +10 -0
- package/dist/compact/register.d.ts.map +1 -0
- package/dist/compact/register.js +47 -0
- package/dist/compact/register.js.map +1 -0
- package/dist/compact/runSummary.d.ts +6 -0
- package/dist/compact/runSummary.d.ts.map +1 -0
- package/dist/compact/runSummary.js +29 -0
- package/dist/compact/runSummary.js.map +1 -0
- package/dist/compact/subagentDelta.d.ts +6 -0
- package/dist/compact/subagentDelta.d.ts.map +1 -0
- package/dist/compact/subagentDelta.js +13 -0
- package/dist/compact/subagentDelta.js.map +1 -0
- package/dist/compact/summaryPrompt.d.ts +3 -0
- package/dist/compact/summaryPrompt.d.ts.map +1 -0
- package/dist/compact/summaryPrompt.js +41 -0
- package/dist/compact/summaryPrompt.js.map +1 -0
- package/dist/config/agentDir.d.ts +11 -0
- package/dist/config/agentDir.d.ts.map +1 -0
- package/dist/config/agentDir.js +21 -0
- package/dist/config/agentDir.js.map +1 -0
- package/dist/config/chunking.d.ts +7 -0
- package/dist/config/chunking.d.ts.map +1 -0
- package/dist/config/chunking.js +20 -0
- package/dist/config/chunking.js.map +1 -0
- package/dist/config/env.d.ts +28 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +43 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loadEnv.d.ts +10 -0
- package/dist/config/loadEnv.d.ts.map +1 -0
- package/dist/config/loadEnv.js +25 -0
- package/dist/config/loadEnv.js.map +1 -0
- package/dist/config/preflight.d.ts +8 -0
- package/dist/config/preflight.d.ts.map +1 -0
- package/dist/config/preflight.js +22 -0
- package/dist/config/preflight.js.map +1 -0
- package/dist/config/preflightBudget.d.ts +9 -0
- package/dist/config/preflightBudget.d.ts.map +1 -0
- package/dist/config/preflightBudget.js +16 -0
- package/dist/config/preflightBudget.js.map +1 -0
- package/dist/config/retrieval.d.ts +10 -0
- package/dist/config/retrieval.d.ts.map +1 -0
- package/dist/config/retrieval.js +31 -0
- package/dist/config/retrieval.js.map +1 -0
- package/dist/consolidate/entryKey.d.ts +6 -0
- package/dist/consolidate/entryKey.d.ts.map +1 -0
- package/dist/consolidate/entryKey.js +5 -0
- package/dist/consolidate/entryKey.js.map +1 -0
- package/dist/consolidate/index.d.ts +5 -0
- package/dist/consolidate/index.d.ts.map +1 -0
- package/dist/consolidate/index.js +5 -0
- package/dist/consolidate/index.js.map +1 -0
- package/dist/consolidate/mergeEntries.d.ts +4 -0
- package/dist/consolidate/mergeEntries.d.ts.map +1 -0
- package/dist/consolidate/mergeEntries.js +17 -0
- package/dist/consolidate/mergeEntries.js.map +1 -0
- package/dist/consolidate/mergePrompt.d.ts +4 -0
- package/dist/consolidate/mergePrompt.d.ts.map +1 -0
- package/dist/consolidate/mergePrompt.js +40 -0
- package/dist/consolidate/mergePrompt.js.map +1 -0
- package/dist/consolidate/mergeWithLlm.d.ts +4 -0
- package/dist/consolidate/mergeWithLlm.d.ts.map +1 -0
- package/dist/consolidate/mergeWithLlm.js +27 -0
- package/dist/consolidate/mergeWithLlm.js.map +1 -0
- package/dist/consolidate/runJob.d.ts +29 -0
- package/dist/consolidate/runJob.d.ts.map +1 -0
- package/dist/consolidate/runJob.js +48 -0
- package/dist/consolidate/runJob.js.map +1 -0
- package/dist/consolidate/scheduler.d.ts +18 -0
- package/dist/consolidate/scheduler.d.ts.map +1 -0
- package/dist/consolidate/scheduler.js +32 -0
- package/dist/consolidate/scheduler.js.map +1 -0
- package/dist/constants/chunking.d.ts +7 -0
- package/dist/constants/chunking.d.ts.map +1 -0
- package/dist/constants/chunking.js +7 -0
- package/dist/constants/chunking.js.map +1 -0
- package/dist/constants/env.d.ts +47 -0
- package/dist/constants/env.d.ts.map +1 -0
- package/dist/constants/env.js +52 -0
- package/dist/constants/env.js.map +1 -0
- package/dist/constants/index.d.ts +8 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +8 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/memory.d.ts +17 -0
- package/dist/constants/memory.d.ts.map +1 -0
- package/dist/constants/memory.js +16 -0
- package/dist/constants/memory.js.map +1 -0
- package/dist/constants/paths.d.ts +23 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +23 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/preflight.d.ts +17 -0
- package/dist/constants/preflight.d.ts.map +1 -0
- package/dist/constants/preflight.js +17 -0
- package/dist/constants/preflight.js.map +1 -0
- package/dist/constants/retrieval.d.ts +10 -0
- package/dist/constants/retrieval.d.ts.map +1 -0
- package/dist/constants/retrieval.js +10 -0
- package/dist/constants/retrieval.js.map +1 -0
- package/dist/constants/security.d.ts +5 -0
- package/dist/constants/security.d.ts.map +1 -0
- package/dist/constants/security.js +5 -0
- package/dist/constants/security.js.map +1 -0
- package/dist/constants/timing.d.ts +38 -0
- package/dist/constants/timing.d.ts.map +1 -0
- package/dist/constants/timing.js +38 -0
- package/dist/constants/timing.js.map +1 -0
- package/dist/index.d.ts +11 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -28
- package/dist/index.js.map +1 -1
- package/dist/init/workspace.d.ts +15 -0
- package/dist/init/workspace.d.ts.map +1 -0
- package/dist/init/workspace.js +32 -0
- package/dist/init/workspace.js.map +1 -0
- package/dist/ipc/jsonlFramer.d.ts +9 -0
- package/dist/ipc/jsonlFramer.d.ts.map +1 -0
- package/dist/ipc/jsonlFramer.js +26 -0
- package/dist/ipc/jsonlFramer.js.map +1 -0
- package/dist/pi-extension.d.ts +0 -2
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +175 -515
- package/dist/pi-extension.js.map +1 -1
- package/dist/preflight/episodic.d.ts +26 -0
- package/dist/preflight/episodic.d.ts.map +1 -0
- package/dist/preflight/episodic.js +125 -0
- package/dist/preflight/episodic.js.map +1 -0
- package/dist/preflight/intentCache.d.ts +13 -0
- package/dist/preflight/intentCache.d.ts.map +1 -0
- package/dist/preflight/intentCache.js +37 -0
- package/dist/preflight/intentCache.js.map +1 -0
- package/dist/preflight/queryCache.d.ts +15 -0
- package/dist/preflight/queryCache.d.ts.map +1 -0
- package/dist/preflight/queryCache.js +46 -0
- package/dist/preflight/queryCache.js.map +1 -0
- package/dist/preflight/queryIntent.d.ts +29 -0
- package/dist/preflight/queryIntent.d.ts.map +1 -0
- package/dist/preflight/queryIntent.js +91 -0
- package/dist/preflight/queryIntent.js.map +1 -0
- package/dist/preflight/render.d.ts +8 -33
- package/dist/preflight/render.d.ts.map +1 -1
- package/dist/preflight/render.js +29 -126
- package/dist/preflight/render.js.map +1 -1
- package/dist/preflight/session.d.ts +3 -0
- package/dist/preflight/session.d.ts.map +1 -0
- package/dist/preflight/session.js +6 -0
- package/dist/preflight/session.js.map +1 -0
- package/dist/preflight/strip.d.ts +0 -8
- package/dist/preflight/strip.d.ts.map +1 -1
- package/dist/preflight/strip.js +2 -11
- package/dist/preflight/strip.js.map +1 -1
- package/dist/shutdown/enqueue.d.ts +12 -0
- package/dist/shutdown/enqueue.d.ts.map +1 -0
- package/dist/shutdown/enqueue.js +14 -0
- package/dist/shutdown/enqueue.js.map +1 -0
- package/dist/shutdown/extractPrompt.d.ts +4 -0
- package/dist/shutdown/extractPrompt.d.ts.map +1 -0
- package/dist/shutdown/extractPrompt.js +29 -0
- package/dist/shutdown/extractPrompt.js.map +1 -0
- package/dist/shutdown/processed.d.ts +9 -0
- package/dist/shutdown/processed.d.ts.map +1 -0
- package/dist/shutdown/processed.js +28 -0
- package/dist/shutdown/processed.js.map +1 -0
- package/dist/shutdown/readQueue.d.ts +4 -0
- package/dist/shutdown/readQueue.d.ts.map +1 -0
- package/dist/shutdown/readQueue.js +26 -0
- package/dist/shutdown/readQueue.js.map +1 -0
- package/dist/shutdown/runDrainJob.d.ts +26 -0
- package/dist/shutdown/runDrainJob.d.ts.map +1 -0
- package/dist/shutdown/runDrainJob.js +143 -0
- package/dist/shutdown/runDrainJob.js.map +1 -0
- package/dist/shutdown/sessionReader.d.ts +6 -0
- package/dist/shutdown/sessionReader.d.ts.map +1 -0
- package/dist/shutdown/sessionReader.js +44 -0
- package/dist/shutdown/sessionReader.js.map +1 -0
- package/dist/sidecar/client.d.ts +17 -16
- package/dist/sidecar/client.d.ts.map +1 -1
- package/dist/sidecar/client.js +64 -100
- package/dist/sidecar/client.js.map +1 -1
- package/dist/sidecar/paths.d.ts +8 -0
- package/dist/sidecar/paths.d.ts.map +1 -0
- package/dist/sidecar/paths.js +23 -0
- package/dist/sidecar/paths.js.map +1 -0
- package/dist/sidecar/protocol.d.ts +54 -0
- package/dist/sidecar/protocol.d.ts.map +1 -0
- package/dist/sidecar/protocol.js +4 -0
- package/dist/sidecar/protocol.js.map +1 -0
- package/dist/sidecar/reindexBridge.d.ts +13 -0
- package/dist/sidecar/reindexBridge.d.ts.map +1 -0
- package/dist/sidecar/reindexBridge.js +37 -0
- package/dist/sidecar/reindexBridge.js.map +1 -0
- package/dist/sidecar/server/process.d.ts +2 -0
- package/dist/sidecar/server/process.d.ts.map +1 -0
- package/dist/sidecar/server/process.js +22 -0
- package/dist/sidecar/server/process.js.map +1 -0
- package/dist/sidecar/server/query.d.ts +8 -0
- package/dist/sidecar/server/query.d.ts.map +1 -0
- package/dist/sidecar/server/query.js +7 -0
- package/dist/sidecar/server/query.js.map +1 -0
- package/dist/sidecar/server/reindex.d.ts +8 -0
- package/dist/sidecar/server/reindex.d.ts.map +1 -0
- package/dist/sidecar/server/reindex.js +12 -0
- package/dist/sidecar/server/reindex.js.map +1 -0
- package/dist/sidecar/server/server.d.ts +11 -0
- package/dist/sidecar/server/server.d.ts.map +1 -0
- package/dist/sidecar/server/server.js +76 -0
- package/dist/sidecar/server/server.js.map +1 -0
- package/dist/sidecar/server/stats.d.ts +8 -0
- package/dist/sidecar/server/stats.d.ts.map +1 -0
- package/dist/sidecar/server/stats.js +18 -0
- package/dist/sidecar/server/stats.js.map +1 -0
- package/dist/sidecar/server/vec/embedder.d.ts +2 -0
- package/dist/sidecar/server/vec/embedder.d.ts.map +1 -0
- package/dist/sidecar/server/vec/embedder.js +2 -0
- package/dist/sidecar/server/vec/embedder.js.map +1 -0
- package/dist/sidecar/server/vec/mmr.d.ts +13 -0
- package/dist/sidecar/server/vec/mmr.d.ts.map +1 -0
- package/dist/sidecar/server/vec/mmr.js +36 -0
- package/dist/sidecar/server/vec/mmr.js.map +1 -0
- package/dist/sidecar/server/vec/store.d.ts +30 -0
- package/dist/sidecar/server/vec/store.d.ts.map +1 -0
- package/dist/sidecar/server/vec/store.js +179 -0
- package/dist/sidecar/server/vec/store.js.map +1 -0
- package/dist/sidecar/sidecarManager.d.ts +10 -0
- package/dist/sidecar/sidecarManager.d.ts.map +1 -0
- package/dist/sidecar/sidecarManager.js +111 -0
- package/dist/sidecar/sidecarManager.js.map +1 -0
- package/dist/sidecar/utils.d.ts +3 -0
- package/dist/sidecar/utils.d.ts.map +1 -0
- package/dist/sidecar/utils.js +27 -0
- package/dist/sidecar/utils.js.map +1 -0
- package/dist/sidecar/warmup.d.ts +6 -0
- package/dist/sidecar/warmup.d.ts.map +1 -0
- package/dist/sidecar/warmup.js +39 -0
- package/dist/sidecar/warmup.js.map +1 -0
- package/dist/store/backend.d.ts +12 -0
- package/dist/store/backend.d.ts.map +1 -0
- package/dist/store/backend.js +47 -0
- package/dist/store/backend.js.map +1 -0
- package/dist/store/index.d.ts +6 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +6 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/indexChunks.d.ts +9 -0
- package/dist/store/indexChunks.d.ts.map +1 -0
- package/dist/store/indexChunks.js +78 -0
- package/dist/store/indexChunks.js.map +1 -0
- package/dist/store/markdown/format.d.ts +5 -0
- package/dist/store/markdown/format.d.ts.map +1 -0
- package/dist/store/markdown/format.js +14 -0
- package/dist/store/markdown/format.js.map +1 -0
- package/dist/store/markdown/parse.d.ts +5 -0
- package/dist/store/markdown/parse.d.ts.map +1 -0
- package/dist/store/markdown/parse.js +57 -0
- package/dist/store/markdown/parse.js.map +1 -0
- package/dist/store/markdown/template.d.ts +3 -0
- package/dist/store/markdown/template.d.ts.map +1 -0
- package/dist/store/markdown/template.js +22 -0
- package/dist/store/markdown/template.js.map +1 -0
- package/dist/store/memoryStore.d.ts +69 -0
- package/dist/store/memoryStore.d.ts.map +1 -0
- package/dist/store/memoryStore.js +421 -0
- package/dist/store/memoryStore.js.map +1 -0
- package/dist/store/paths.d.ts +10 -0
- package/dist/store/paths.d.ts.map +1 -0
- package/dist/store/paths.js +19 -0
- package/dist/store/paths.js.map +1 -0
- package/dist/store/types.d.ts +38 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +3 -0
- package/dist/store/types.js.map +1 -0
- package/dist/ui/memoryStatusWidget.d.ts +20 -0
- package/dist/ui/memoryStatusWidget.d.ts.map +1 -0
- package/dist/ui/memoryStatusWidget.js +51 -0
- package/dist/ui/memoryStatusWidget.js.map +1 -0
- package/dist/utils/debugLog.d.ts +4 -0
- package/dist/utils/debugLog.d.ts.map +1 -0
- package/dist/utils/debugLog.js +14 -0
- package/dist/utils/debugLog.js.map +1 -0
- package/dist/utils/fs.d.ts +26 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +101 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/paths.d.ts +22 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +51 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +18 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/scheduler.d.ts +33 -0
- package/dist/utils/scheduler.d.ts.map +1 -0
- package/dist/utils/scheduler.js +63 -0
- package/dist/utils/scheduler.js.map +1 -0
- package/dist/utils/socket.d.ts +7 -0
- package/dist/utils/socket.d.ts.map +1 -0
- package/dist/utils/socket.js +35 -0
- package/dist/utils/socket.js.map +1 -0
- package/dist/utils/time.d.ts +22 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +42 -0
- package/dist/utils/time.js.map +1 -0
- package/doc/README-zh.md +365 -0
- package/doc/ROADMAP-zh.md +52 -0
- package/doc/ROADMAP.md +52 -0
- package/package.json +31 -10
- package/scripts/init-memory-workspace.mjs +62 -0
- package/scripts/path-utils.mjs +12 -0
- package/scripts/platform-fs.mjs +65 -0
- package/scripts/postinstall.mjs +17 -0
- package/src/adapters/embed/factory.ts +50 -0
- package/src/adapters/embed/hash.ts +29 -0
- package/src/adapters/embed/normalize.ts +13 -0
- package/src/adapters/embed/ollama.ts +49 -0
- package/src/adapters/embed/openai.ts +46 -0
- package/src/adapters/embed/types.ts +9 -0
- package/src/adapters/http.ts +42 -0
- package/src/adapters/index.ts +16 -0
- package/src/adapters/llm/extractText.ts +6 -0
- package/src/adapters/llm/factory.ts +60 -0
- package/src/adapters/llm/index.ts +7 -0
- package/src/adapters/llm/modelSpec.ts +39 -0
- package/src/adapters/llm/ollama.ts +42 -0
- package/src/adapters/llm/openai-compat.ts +46 -0
- package/src/adapters/llm/pi-ai.ts +75 -0
- package/src/adapters/llm/standalone.ts +60 -0
- package/src/adapters/llm/types.ts +16 -0
- package/src/cli/init.ts +18 -0
- package/src/cli/jobs.ts +144 -0
- package/src/cli/log.ts +46 -0
- package/src/cli/parseArgs.ts +175 -0
- package/src/cli/status.ts +323 -0
- package/src/cli/theme.ts +26 -0
- package/src/cli.ts +80 -374
- package/src/commands/index.ts +20 -0
- package/src/commands/parseMemoryStatusArgs.ts +11 -0
- package/src/commands/parseRememberArgs.ts +55 -0
- package/src/commands/remember.ts +43 -0
- package/src/commands/status.ts +112 -0
- package/src/commands/types.ts +12 -0
- package/src/compact/index.ts +4 -0
- package/src/compact/parseMemoryExport.ts +71 -0
- package/src/compact/register.ts +57 -0
- package/src/compact/runSummary.ts +42 -0
- package/src/compact/subagentDelta.ts +22 -0
- package/src/compact/summaryPrompt.ts +45 -0
- package/src/config/agentDir.ts +24 -0
- package/src/config/chunking.ts +36 -0
- package/src/config/env.ts +97 -0
- package/src/config/index.ts +7 -0
- package/src/config/loadEnv.ts +26 -0
- package/src/config/preflight.ts +34 -0
- package/src/config/preflightBudget.ts +33 -0
- package/src/config/retrieval.ts +50 -0
- package/src/consolidate/entryKey.ts +4 -0
- package/src/consolidate/index.ts +4 -0
- package/src/consolidate/mergeEntries.ts +22 -0
- package/src/consolidate/mergePrompt.ts +46 -0
- package/src/consolidate/mergeWithLlm.ts +39 -0
- package/src/consolidate/runJob.ts +81 -0
- package/src/consolidate/scheduler.ts +54 -0
- package/src/constants/chunking.ts +8 -0
- package/src/constants/env.ts +59 -0
- package/src/constants/index.ts +7 -0
- package/src/constants/memory.ts +22 -0
- package/src/constants/paths.ts +26 -0
- package/src/constants/preflight.ts +22 -0
- package/src/constants/retrieval.ts +10 -0
- package/src/constants/security.ts +5 -0
- package/src/constants/timing.ts +48 -0
- package/src/index.ts +11 -247
- package/src/init/workspace.ts +44 -0
- package/src/ipc/jsonlFramer.ts +29 -0
- package/src/pi-extension.ts +196 -605
- package/src/preflight/episodic.ts +183 -0
- package/src/preflight/intentCache.ts +44 -0
- package/src/preflight/queryCache.ts +59 -0
- package/src/preflight/queryIntent.ts +126 -0
- package/src/preflight/render.ts +34 -180
- package/src/preflight/session.ts +7 -0
- package/src/preflight/strip.ts +4 -11
- package/src/shutdown/enqueue.ts +29 -0
- package/src/shutdown/extractPrompt.ts +27 -0
- package/src/shutdown/processed.ts +45 -0
- package/src/shutdown/readQueue.ts +26 -0
- package/src/shutdown/runDrainJob.ts +202 -0
- package/src/shutdown/sessionReader.ts +61 -0
- package/src/sidecar/client.ts +98 -150
- package/src/sidecar/paths.ts +31 -0
- package/src/sidecar/protocol.ts +38 -0
- package/src/sidecar/reindexBridge.ts +52 -0
- package/src/sidecar/server/process.ts +27 -0
- package/src/sidecar/server/query.ts +16 -0
- package/src/sidecar/server/reindex.ts +21 -0
- package/src/sidecar/server/server.ts +105 -0
- package/src/sidecar/server/stats.ts +23 -0
- package/src/sidecar/server/vec/embedder.ts +1 -0
- package/src/sidecar/server/vec/mmr.ts +55 -0
- package/src/sidecar/server/vec/store.ts +232 -0
- package/src/sidecar/sidecarManager.ts +134 -0
- package/src/sidecar/utils.ts +28 -0
- package/src/sidecar/warmup.ts +50 -0
- package/src/store/backend.ts +66 -0
- package/src/store/index.ts +5 -0
- package/src/store/indexChunks.ts +89 -0
- package/src/store/markdown/format.ts +16 -0
- package/src/store/markdown/parse.ts +63 -0
- package/src/store/markdown/template.ts +24 -0
- package/src/store/memoryStore.ts +518 -0
- package/src/store/paths.ts +33 -0
- package/src/store/proper-lockfile.d.ts +3 -0
- package/src/store/types.ts +46 -0
- package/src/ui/memoryStatusWidget.ts +80 -0
- package/src/utils/debugLog.ts +22 -0
- package/src/utils/fs.ts +115 -0
- package/src/utils/index.ts +68 -0
- package/src/utils/paths.ts +67 -0
- package/src/utils/platform.ts +20 -0
- package/src/utils/scheduler.ts +98 -0
- package/src/utils/socket.ts +33 -0
- package/src/utils/time.ts +51 -0
- package/templates/MEMORY.md.example +22 -0
- package/dist/adapters/ollamaClient.d.ts +0 -11
- package/dist/adapters/ollamaClient.d.ts.map +0 -1
- package/dist/adapters/ollamaClient.js +0 -122
- package/dist/adapters/ollamaClient.js.map +0 -1
- package/dist/adapters/openaiCompatClient.d.ts +0 -11
- package/dist/adapters/openaiCompatClient.d.ts.map +0 -1
- package/dist/adapters/openaiCompatClient.js +0 -118
- package/dist/adapters/openaiCompatClient.js.map +0 -1
- package/dist/adapters/piComplete.d.ts +0 -17
- package/dist/adapters/piComplete.d.ts.map +0 -1
- package/dist/adapters/piComplete.js +0 -169
- package/dist/adapters/piComplete.js.map +0 -1
- package/dist/bundle/install.d.ts +0 -34
- package/dist/bundle/install.d.ts.map +0 -1
- package/dist/bundle/install.js +0 -183
- package/dist/bundle/install.js.map +0 -1
- package/dist/cache/memoryCaches.d.ts +0 -32
- package/dist/cache/memoryCaches.d.ts.map +0 -1
- package/dist/cache/memoryCaches.js +0 -59
- package/dist/cache/memoryCaches.js.map +0 -1
- package/dist/config.d.ts +0 -55
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -85
- package/dist/config.js.map +0 -1
- package/dist/consolidation/enqueue.d.ts +0 -33
- package/dist/consolidation/enqueue.d.ts.map +0 -1
- package/dist/consolidation/enqueue.js +0 -145
- package/dist/consolidation/enqueue.js.map +0 -1
- package/dist/consolidation/index.d.ts +0 -19
- package/dist/consolidation/index.d.ts.map +0 -1
- package/dist/consolidation/index.js +0 -15
- package/dist/consolidation/index.js.map +0 -1
- package/dist/consolidation/lock.d.ts +0 -5
- package/dist/consolidation/lock.d.ts.map +0 -1
- package/dist/consolidation/lock.js +0 -33
- package/dist/consolidation/lock.js.map +0 -1
- package/dist/consolidation/log.d.ts +0 -8
- package/dist/consolidation/log.d.ts.map +0 -1
- package/dist/consolidation/log.js +0 -32
- package/dist/consolidation/log.js.map +0 -1
- package/dist/consolidation/memoryIndex.d.ts +0 -18
- package/dist/consolidation/memoryIndex.d.ts.map +0 -1
- package/dist/consolidation/memoryIndex.js +0 -100
- package/dist/consolidation/memoryIndex.js.map +0 -1
- package/dist/consolidation/phase2/runPhase2.d.ts +0 -23
- package/dist/consolidation/phase2/runPhase2.d.ts.map +0 -1
- package/dist/consolidation/phase2/runPhase2.js +0 -196
- package/dist/consolidation/phase2/runPhase2.js.map +0 -1
- package/dist/consolidation/scheduler/launchd.d.ts +0 -5
- package/dist/consolidation/scheduler/launchd.d.ts.map +0 -1
- package/dist/consolidation/scheduler/launchd.js +0 -54
- package/dist/consolidation/scheduler/launchd.js.map +0 -1
- package/dist/consolidation/scheduler/runConsolidate.d.ts +0 -26
- package/dist/consolidation/scheduler/runConsolidate.d.ts.map +0 -1
- package/dist/consolidation/scheduler/runConsolidate.js +0 -83
- package/dist/consolidation/scheduler/runConsolidate.js.map +0 -1
- package/dist/consolidation/scheduler/setupSchedule.d.ts +0 -3
- package/dist/consolidation/scheduler/setupSchedule.d.ts.map +0 -1
- package/dist/consolidation/scheduler/setupSchedule.js +0 -79
- package/dist/consolidation/scheduler/setupSchedule.js.map +0 -1
- package/dist/consolidation/scheduler/systemd.d.ts +0 -9
- package/dist/consolidation/scheduler/systemd.d.ts.map +0 -1
- package/dist/consolidation/scheduler/systemd.js +0 -57
- package/dist/consolidation/scheduler/systemd.js.map +0 -1
- package/dist/consolidation/scheduler/types.d.ts +0 -24
- package/dist/consolidation/scheduler/types.d.ts.map +0 -1
- package/dist/consolidation/scheduler/types.js.map +0 -1
- package/dist/consolidation/scope.d.ts +0 -12
- package/dist/consolidation/scope.d.ts.map +0 -1
- package/dist/consolidation/scope.js +0 -51
- package/dist/consolidation/scope.js.map +0 -1
- package/dist/consolidation/stage1/deltaExtract.d.ts +0 -3
- package/dist/consolidation/stage1/deltaExtract.d.ts.map +0 -1
- package/dist/consolidation/stage1/deltaExtract.js +0 -19
- package/dist/consolidation/stage1/deltaExtract.js.map +0 -1
- package/dist/consolidation/stage1/drainQueue.d.ts +0 -21
- package/dist/consolidation/stage1/drainQueue.d.ts.map +0 -1
- package/dist/consolidation/stage1/drainQueue.js +0 -113
- package/dist/consolidation/stage1/drainQueue.js.map +0 -1
- package/dist/consolidation/stage1/extractSession.d.ts +0 -6
- package/dist/consolidation/stage1/extractSession.d.ts.map +0 -1
- package/dist/consolidation/stage1/extractSession.js +0 -47
- package/dist/consolidation/stage1/extractSession.js.map +0 -1
- package/dist/consolidation/stage1/store.d.ts +0 -45
- package/dist/consolidation/stage1/store.d.ts.map +0 -1
- package/dist/consolidation/stage1/store.js +0 -297
- package/dist/consolidation/stage1/store.js.map +0 -1
- package/dist/consolidation/types.d.ts +0 -49
- package/dist/consolidation/types.d.ts.map +0 -1
- package/dist/errclass.d.ts +0 -7
- package/dist/errclass.d.ts.map +0 -1
- package/dist/errclass.js +0 -32
- package/dist/errclass.js.map +0 -1
- package/dist/extension.d.ts +0 -24
- package/dist/extension.d.ts.map +0 -1
- package/dist/extension.js +0 -7
- package/dist/extension.js.map +0 -1
- package/dist/fallback/index.d.ts +0 -11
- package/dist/fallback/index.d.ts.map +0 -1
- package/dist/fallback/index.js +0 -16
- package/dist/fallback/index.js.map +0 -1
- package/dist/fallback/llmRerank.d.ts +0 -19
- package/dist/fallback/llmRerank.d.ts.map +0 -1
- package/dist/fallback/llmRerank.js +0 -68
- package/dist/fallback/llmRerank.js.map +0 -1
- package/dist/fallback/memoryMd.d.ts +0 -6
- package/dist/fallback/memoryMd.d.ts.map +0 -1
- package/dist/fallback/memoryMd.js +0 -35
- package/dist/fallback/memoryMd.js.map +0 -1
- package/dist/fallback/sessionIndex.d.ts +0 -35
- package/dist/fallback/sessionIndex.d.ts.map +0 -1
- package/dist/fallback/sessionIndex.js +0 -239
- package/dist/fallback/sessionIndex.js.map +0 -1
- package/dist/fallback/sessionSearch.d.ts +0 -18
- package/dist/fallback/sessionSearch.d.ts.map +0 -1
- package/dist/fallback/sessionSearch.js +0 -234
- package/dist/fallback/sessionSearch.js.map +0 -1
- package/dist/local/graphQuery.d.ts +0 -31
- package/dist/local/graphQuery.d.ts.map +0 -1
- package/dist/local/graphQuery.js +0 -195
- package/dist/local/graphQuery.js.map +0 -1
- package/dist/paths.d.ts +0 -7
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -26
- package/dist/paths.js.map +0 -1
- package/dist/preflight/detectIntents.d.ts +0 -102
- package/dist/preflight/detectIntents.d.ts.map +0 -1
- package/dist/preflight/detectIntents.js +0 -631
- package/dist/preflight/detectIntents.js.map +0 -1
- package/dist/preflight/hook.d.ts +0 -76
- package/dist/preflight/hook.d.ts.map +0 -1
- package/dist/preflight/hook.js +0 -122
- package/dist/preflight/hook.js.map +0 -1
- package/dist/service.d.ts +0 -72
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -257
- package/dist/service.js.map +0 -1
- package/dist/session/activeBranch.d.ts +0 -17
- package/dist/session/activeBranch.d.ts.map +0 -1
- package/dist/session/activeBranch.js +0 -251
- package/dist/session/activeBranch.js.map +0 -1
- package/dist/settings.d.ts +0 -41
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js +0 -85
- package/dist/settings.js.map +0 -1
- package/dist/sidecar/bundle.d.ts +0 -19
- package/dist/sidecar/bundle.d.ts.map +0 -1
- package/dist/sidecar/bundle.js +0 -39
- package/dist/sidecar/bundle.js.map +0 -1
- package/dist/sidecar/process.d.ts +0 -14
- package/dist/sidecar/process.d.ts.map +0 -1
- package/dist/sidecar/process.js +0 -138
- package/dist/sidecar/process.js.map +0 -1
- package/dist/tools/memoryAppend.d.ts +0 -47
- package/dist/tools/memoryAppend.d.ts.map +0 -1
- package/dist/tools/memoryAppend.js +0 -138
- package/dist/tools/memoryAppend.js.map +0 -1
- package/dist/tools/memoryRecall.d.ts +0 -113
- package/dist/tools/memoryRecall.d.ts.map +0 -1
- package/dist/tools/memoryRecall.js +0 -351
- package/dist/tools/memoryRecall.js.map +0 -1
- package/dist/trainer/bundleBuilder.d.ts +0 -30
- package/dist/trainer/bundleBuilder.d.ts.map +0 -1
- package/dist/trainer/bundleBuilder.js +0 -106
- package/dist/trainer/bundleBuilder.js.map +0 -1
- package/dist/trainer/bundleLoader.d.ts +0 -12
- package/dist/trainer/bundleLoader.d.ts.map +0 -1
- package/dist/trainer/bundleLoader.js +0 -59
- package/dist/trainer/bundleLoader.js.map +0 -1
- package/dist/trainer/deltaMerge.d.ts +0 -38
- package/dist/trainer/deltaMerge.d.ts.map +0 -1
- package/dist/trainer/deltaMerge.js +0 -183
- package/dist/trainer/deltaMerge.js.map +0 -1
- package/dist/trainer/entityResolver.d.ts +0 -27
- package/dist/trainer/entityResolver.d.ts.map +0 -1
- package/dist/trainer/entityResolver.js +0 -92
- package/dist/trainer/entityResolver.js.map +0 -1
- package/dist/trainer/extractFacts.d.ts +0 -67
- package/dist/trainer/extractFacts.d.ts.map +0 -1
- package/dist/trainer/extractFacts.js +0 -213
- package/dist/trainer/extractFacts.js.map +0 -1
- package/dist/trainer/index.d.ts +0 -54
- package/dist/trainer/index.d.ts.map +0 -1
- package/dist/trainer/index.js +0 -82
- package/dist/trainer/index.js.map +0 -1
- package/dist/trainer/llmExtractor.d.ts +0 -16
- package/dist/trainer/llmExtractor.d.ts.map +0 -1
- package/dist/trainer/llmExtractor.js +0 -146
- package/dist/trainer/llmExtractor.js.map +0 -1
- package/dist/trainer/marker.d.ts +0 -10
- package/dist/trainer/marker.d.ts.map +0 -1
- package/dist/trainer/marker.js +0 -28
- package/dist/trainer/marker.js.map +0 -1
- package/dist/trainer/scheduler.d.ts +0 -33
- package/dist/trainer/scheduler.d.ts.map +0 -1
- package/dist/trainer/scheduler.js +0 -73
- package/dist/trainer/scheduler.js.map +0 -1
- package/dist/trainer/sessionLoader.d.ts +0 -26
- package/dist/trainer/sessionLoader.d.ts.map +0 -1
- package/dist/trainer/sessionLoader.js +0 -145
- package/dist/trainer/sessionLoader.js.map +0 -1
- package/dist/types.d.ts +0 -135
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -8
- package/dist/types.js.map +0 -1
- package/src/adapters/ollamaClient.ts +0 -179
- package/src/adapters/openaiCompatClient.ts +0 -155
- package/src/adapters/piComplete.ts +0 -233
- package/src/bundle/install.ts +0 -206
- package/src/cache/memoryCaches.ts +0 -72
- package/src/config.ts +0 -180
- package/src/consolidation/enqueue.ts +0 -205
- package/src/consolidation/index.ts +0 -90
- package/src/consolidation/lock.ts +0 -41
- package/src/consolidation/log.ts +0 -43
- package/src/consolidation/memoryIndex.ts +0 -127
- package/src/consolidation/phase2/runPhase2.ts +0 -255
- package/src/consolidation/scheduler/launchd.ts +0 -62
- package/src/consolidation/scheduler/runConsolidate.ts +0 -115
- package/src/consolidation/scheduler/setupSchedule.ts +0 -106
- package/src/consolidation/scheduler/systemd.ts +0 -78
- package/src/consolidation/scheduler/types.ts +0 -27
- package/src/consolidation/scope.ts +0 -58
- package/src/consolidation/stage1/deltaExtract.ts +0 -29
- package/src/consolidation/stage1/drainQueue.ts +0 -143
- package/src/consolidation/stage1/extractSession.ts +0 -58
- package/src/consolidation/stage1/store.ts +0 -411
- package/src/consolidation/types.ts +0 -52
- package/src/errclass.ts +0 -37
- package/src/extension.ts +0 -23
- package/src/fallback/index.ts +0 -24
- package/src/fallback/llmRerank.ts +0 -97
- package/src/fallback/memoryMd.ts +0 -36
- package/src/fallback/sessionIndex.ts +0 -290
- package/src/fallback/sessionSearch.ts +0 -261
- package/src/local/graphQuery.ts +0 -252
- package/src/paths.ts +0 -28
- package/src/preflight/detectIntents.ts +0 -660
- package/src/preflight/hook.ts +0 -213
- package/src/service.ts +0 -306
- package/src/session/activeBranch.ts +0 -294
- package/src/settings.ts +0 -161
- package/src/sidecar/bundle.ts +0 -52
- package/src/sidecar/process.ts +0 -160
- package/src/tools/memoryAppend.ts +0 -166
- package/src/tools/memoryRecall.ts +0 -388
- package/src/trainer/bundleBuilder.ts +0 -192
- package/src/trainer/bundleLoader.ts +0 -105
- package/src/trainer/deltaMerge.ts +0 -221
- package/src/trainer/entityResolver.ts +0 -140
- package/src/trainer/extractFacts.ts +0 -312
- package/src/trainer/index.ts +0 -147
- package/src/trainer/llmExtractor.ts +0 -206
- package/src/trainer/marker.ts +0 -30
- package/src/trainer/scheduler.ts +0 -107
- package/src/trainer/sessionLoader.ts +0 -176
- package/src/types.ts +0 -168
- /package/dist/{consolidation/scheduler → adapters/embed}/types.js +0 -0
- /package/dist/{consolidation → adapters/llm}/types.js +0 -0
package/src/cli.ts
CHANGED
|
@@ -1,399 +1,105 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
2
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { getMemoryIndexStats } from "./consolidation/memoryIndex.js";
|
|
9
|
-
import { readRecentConsolidationLogs } from "./consolidation/log.js";
|
|
10
|
-
import { getConsolidationStatus } from "./consolidation/enqueue.js";
|
|
3
|
+
import { createLlmClient } from "./adapters/llm/index.js";
|
|
4
|
+
import { resolveAgentDirFromEnv } from "./config/agentDir.js";
|
|
5
|
+
import { loadEnv } from "./config/loadEnv.js";
|
|
11
6
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const client = new SidecarClient(cfg.socketPath, cfg.clientRequestTimeoutMs);
|
|
33
|
-
try {
|
|
34
|
-
await client.reload();
|
|
35
|
-
} catch {
|
|
36
|
-
/* sidecar not running — install still succeeded */
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function main(): Promise<void> {
|
|
41
|
-
const [cmd, ...rest] = process.argv.slice(2);
|
|
42
|
-
if (!cmd || cmd === "help" || cmd === "--help") {
|
|
43
|
-
printHelp();
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const cfg = loadMemoryConfig();
|
|
48
|
-
const service = new MemoryService(cfg);
|
|
49
|
-
|
|
50
|
-
if (cmd === "health") {
|
|
51
|
-
await service.start();
|
|
52
|
-
const h = await service.health();
|
|
53
|
-
console.log(JSON.stringify({ status: service.getStatus(), health: h }, null, 2));
|
|
54
|
-
await service.stop();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (cmd === "query") {
|
|
59
|
-
const json = rest.join(" ").trim();
|
|
60
|
-
if (!json) {
|
|
61
|
-
console.error('Usage: pi-memory query \'{"anchor_mentions":["Alice"],"mode":"direct_relation"}\'');
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
let intent: QueryIntent;
|
|
65
|
-
try {
|
|
66
|
-
intent = JSON.parse(json) as QueryIntent;
|
|
67
|
-
} catch (e) {
|
|
68
|
-
console.error("Invalid JSON intent:", e);
|
|
69
|
-
process.exit(1);
|
|
7
|
+
runConsolidateCommand,
|
|
8
|
+
runDrainShutdownQueueCommand,
|
|
9
|
+
runMaintenanceCommand,
|
|
10
|
+
} from "./cli/jobs.js";
|
|
11
|
+
import { createCliLog } from "./cli/log.js";
|
|
12
|
+
import { CLI_HELP, parseCliArgs } from "./cli/parseArgs.js";
|
|
13
|
+
import { runInitCommand } from "./cli/init.js";
|
|
14
|
+
import { runStatusCommand } from "./cli/status.js";
|
|
15
|
+
import { theme } from "./cli/theme.js";
|
|
16
|
+
import { createMemoryStore } from "./store/index.js";
|
|
17
|
+
|
|
18
|
+
async function main(): Promise<number> {
|
|
19
|
+
loadEnv();
|
|
20
|
+
|
|
21
|
+
const parsed = parseCliArgs(process.argv.slice(2));
|
|
22
|
+
if (parsed.command === "help") {
|
|
23
|
+
if (parsed.error) {
|
|
24
|
+
console.error(theme.error(parsed.error));
|
|
70
25
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log(JSON.stringify(result, null, 2));
|
|
74
|
-
await service.stop();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (cmd === "status") {
|
|
79
|
-
await service.start();
|
|
80
|
-
console.log(JSON.stringify(service.getStatus(), null, 2));
|
|
81
|
-
await service.stop();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (cmd === "memory-status") {
|
|
86
|
-
const dbPath = defaultConsolidationDbPath(cfg);
|
|
87
|
-
const status = getConsolidationStatus(dbPath);
|
|
88
|
-
const memoryIndex = getMemoryIndexStats(cfg.memoryMdPaths, {
|
|
89
|
-
maxLines: cfg.consolidation.memory_index_max_lines,
|
|
90
|
-
maxBytes: cfg.consolidation.memory_index_max_bytes,
|
|
91
|
-
});
|
|
92
|
-
const recentLogs = await readRecentConsolidationLogs(
|
|
93
|
-
cfg.consolidation.schedule.log_path,
|
|
94
|
-
5,
|
|
95
|
-
);
|
|
96
|
-
const schedule = await readScheduleStatus(cfg);
|
|
97
|
-
console.log(JSON.stringify({
|
|
98
|
-
db_path: dbPath,
|
|
99
|
-
queue: status,
|
|
100
|
-
memory_index: memoryIndex,
|
|
101
|
-
schedule,
|
|
102
|
-
recent_logs: recentLogs,
|
|
103
|
-
}, null, 2));
|
|
104
|
-
return;
|
|
26
|
+
console.log(CLI_HELP);
|
|
27
|
+
return parsed.error ? 1 : 0;
|
|
105
28
|
}
|
|
106
29
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
config: cfg,
|
|
111
|
-
dryRun: flags.dryRun,
|
|
112
|
-
phase1Only: flags.phase1Only,
|
|
113
|
-
phase2Only: flags.phase2Only,
|
|
114
|
-
});
|
|
115
|
-
console.log(JSON.stringify(result, null, 2));
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
30
|
+
const agentDir = resolveAgentDirFromEnv(
|
|
31
|
+
"options" in parsed ? parsed.options.agentDir : undefined,
|
|
32
|
+
);
|
|
118
33
|
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const result = await setupSchedule({
|
|
123
|
-
hour: flags.hour ?? cfg.consolidation.schedule.hour,
|
|
124
|
-
minute: flags.minute ?? cfg.consolidation.schedule.minute,
|
|
125
|
-
logPath: cfg.consolidation.schedule.log_path,
|
|
126
|
-
dryRun: flags.dryRun,
|
|
127
|
-
remove: flags.remove,
|
|
128
|
-
status: flags.status,
|
|
129
|
-
}, platform);
|
|
130
|
-
console.log(JSON.stringify(result, null, 2));
|
|
131
|
-
return;
|
|
34
|
+
if (parsed.command === "init") {
|
|
35
|
+
const log = createCliLog({ verbose: true, debug: parsed.options.verbose });
|
|
36
|
+
return runInitCommand(agentDir, log);
|
|
132
37
|
}
|
|
133
38
|
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
console.error("Usage: pi-memory install-bundle <path-to-bundle-dir>");
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
const result = await installBundle({
|
|
141
|
-
bundleRoot: cfg.bundleRoot,
|
|
142
|
-
sourceDir: bundlePath,
|
|
143
|
-
});
|
|
144
|
-
await tryReloadSidecar(cfg);
|
|
145
|
-
console.log(JSON.stringify(result, null, 2));
|
|
146
|
-
return;
|
|
39
|
+
if (parsed.command === "status") {
|
|
40
|
+
const log = createCliLog({ verbose: true, debug: parsed.options.verbose });
|
|
41
|
+
return runStatusCommand(agentDir, log);
|
|
147
42
|
}
|
|
148
43
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let extractOpts;
|
|
152
|
-
if (flags.extractor === "llm") {
|
|
153
|
-
try {
|
|
154
|
-
const client = createStandaloneLLMClient(flags.model);
|
|
155
|
-
extractOpts = {
|
|
156
|
-
llmExtractor: createLLMFactExtractor({
|
|
157
|
-
client,
|
|
158
|
-
batchSize: cfg.trainer.llm_batch_size,
|
|
159
|
-
}),
|
|
160
|
-
};
|
|
161
|
-
} catch (err) {
|
|
162
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
163
|
-
console.error(`LLM extractor unavailable (${message}) — falling back to regex.`);
|
|
164
|
-
extractOpts = undefined;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
44
|
+
const store = createMemoryStore({ agentDir });
|
|
45
|
+
await store.ensureInitialized();
|
|
167
46
|
|
|
168
|
-
|
|
169
|
-
sessionsDir: flags.sessionsDir ?? cfg.sessionsDir,
|
|
170
|
-
bundleRoot: cfg.bundleRoot,
|
|
171
|
-
full: flags.full,
|
|
172
|
-
dryRun: flags.dryRun,
|
|
173
|
-
noMerge: flags.noMerge,
|
|
174
|
-
extractOpts,
|
|
175
|
-
});
|
|
176
|
-
if (result.sessionsProcessed === 0) {
|
|
177
|
-
console.log("No new sessions to process.");
|
|
178
|
-
} else {
|
|
179
|
-
const output: Record<string, unknown> = {
|
|
180
|
-
sessions_processed: result.sessionsProcessed,
|
|
181
|
-
entities: result.entityCount,
|
|
182
|
-
relations: result.relationCount,
|
|
183
|
-
events: result.eventCount,
|
|
184
|
-
dry_run: result.dryRun,
|
|
185
|
-
bundle_dir: result.bundleResult?.bundleDir ?? null,
|
|
186
|
-
installed: result.installResult?.installed_dir ?? null,
|
|
187
|
-
};
|
|
188
|
-
if (result.delta) {
|
|
189
|
-
output.delta = {
|
|
190
|
-
added: result.delta.added,
|
|
191
|
-
updated: result.delta.updated,
|
|
192
|
-
deleted: result.delta.deleted,
|
|
193
|
-
skipped: result.delta.skipped,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
console.log(JSON.stringify(output, null, 2));
|
|
197
|
-
if (!result.dryRun) {
|
|
198
|
-
await tryReloadSidecar(cfg);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
47
|
+
const llm = await createLlmClient();
|
|
201
48
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
(log) => {
|
|
208
|
-
console.log(JSON.stringify({ type: "scheduled_run", ...log }));
|
|
209
|
-
},
|
|
49
|
+
if (parsed.command === "maintenance") {
|
|
50
|
+
const log = createCliLog({ verbose: parsed.options.verbose });
|
|
51
|
+
if (parsed.options.verbose && !llm) {
|
|
52
|
+
log.warn(
|
|
53
|
+
"no helper LLM configured; consolidate uses rule-based dedupe; shutdown drain skips LLM extract",
|
|
210
54
|
);
|
|
211
|
-
await new Promise(() => {}); // block forever
|
|
212
|
-
}
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (cmd === "index") {
|
|
217
|
-
const sessionsDir = rest.find((a, i) => rest[i - 1] === "--sessions-dir") ?? cfg.sessionsDir;
|
|
218
|
-
const dbPath = path.join(cfg.bundleRoot, "sessions.db");
|
|
219
|
-
const idx = openSessionIndex(dbPath);
|
|
220
|
-
if (!idx) {
|
|
221
|
-
console.error("Failed to open SQLite — is better-sqlite3 installed?");
|
|
222
|
-
process.exit(1);
|
|
223
55
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
56
|
+
return runMaintenanceCommand({
|
|
57
|
+
store,
|
|
58
|
+
agentDir,
|
|
59
|
+
llm,
|
|
60
|
+
options: parsed.options,
|
|
61
|
+
log,
|
|
62
|
+
});
|
|
229
63
|
}
|
|
230
64
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
function parseTrainFlags(args: string[]): {
|
|
237
|
-
sessionsDir?: string;
|
|
238
|
-
full: boolean;
|
|
239
|
-
dryRun: boolean;
|
|
240
|
-
noMerge: boolean;
|
|
241
|
-
extractor: "regex" | "llm";
|
|
242
|
-
watch: boolean;
|
|
243
|
-
model?: string;
|
|
244
|
-
} {
|
|
245
|
-
let sessionsDir: string | undefined;
|
|
246
|
-
let full = false;
|
|
247
|
-
let dryRun = false;
|
|
248
|
-
let noMerge = false;
|
|
249
|
-
let extractor: "regex" | "llm" = "regex";
|
|
250
|
-
let watch = false;
|
|
251
|
-
let model: string | undefined;
|
|
252
|
-
for (let i = 0; i < args.length; i++) {
|
|
253
|
-
const arg = args[i]!;
|
|
254
|
-
if (arg === "--full") { full = true; continue; }
|
|
255
|
-
if (arg === "--dry-run") { dryRun = true; continue; }
|
|
256
|
-
if (arg === "--no-merge") { noMerge = true; continue; }
|
|
257
|
-
if (arg === "--watch") { watch = true; continue; }
|
|
258
|
-
if (arg === "--model" && i + 1 < args.length) {
|
|
259
|
-
model = args[++i];
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
if (arg === "--sessions-dir" && i + 1 < args.length) {
|
|
263
|
-
sessionsDir = args[++i];
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
if (arg === "--extractor" && i + 1 < args.length) {
|
|
267
|
-
const val = args[++i]!;
|
|
268
|
-
if (val === "llm" || val === "regex") extractor = val;
|
|
269
|
-
continue;
|
|
65
|
+
if (parsed.command === "drain-shutdown-queue") {
|
|
66
|
+
const log = createCliLog({ verbose: parsed.options.verbose });
|
|
67
|
+
if (parsed.options.verbose && !llm) {
|
|
68
|
+
log.warn("no helper LLM configured; shutdown drain skips sessions without compaction export");
|
|
270
69
|
}
|
|
70
|
+
return runDrainShutdownQueueCommand({
|
|
71
|
+
store,
|
|
72
|
+
agentDir,
|
|
73
|
+
llm,
|
|
74
|
+
verbose: parsed.options.verbose,
|
|
75
|
+
log,
|
|
76
|
+
});
|
|
271
77
|
}
|
|
272
|
-
return { sessionsDir, full, dryRun, noMerge, extractor, watch, model };
|
|
273
|
-
}
|
|
274
78
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
} {
|
|
280
|
-
return {
|
|
281
|
-
dryRun: args.includes("--dry-run"),
|
|
282
|
-
phase1Only: args.includes("--phase1-only"),
|
|
283
|
-
phase2Only: args.includes("--phase2-only"),
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function parseScheduleFlags(args: string[]): {
|
|
288
|
-
hour?: number;
|
|
289
|
-
minute?: number;
|
|
290
|
-
dryRun: boolean;
|
|
291
|
-
remove: boolean;
|
|
292
|
-
status: boolean;
|
|
293
|
-
} {
|
|
294
|
-
let hour: number | undefined;
|
|
295
|
-
let minute: number | undefined;
|
|
296
|
-
for (let i = 0; i < args.length; i++) {
|
|
297
|
-
const arg = args[i]!;
|
|
298
|
-
if (arg === "--hour" && i + 1 < args.length) {
|
|
299
|
-
hour = Number(args[++i]);
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
302
|
-
if (arg === "--minute" && i + 1 < args.length) {
|
|
303
|
-
minute = Number(args[++i]);
|
|
304
|
-
continue;
|
|
79
|
+
if (parsed.command === "consolidate") {
|
|
80
|
+
const log = createCliLog({ verbose: parsed.options.verbose });
|
|
81
|
+
if (parsed.options.verbose && !llm) {
|
|
82
|
+
log.warn("no helper LLM configured; using rule-based dedupe only");
|
|
305
83
|
}
|
|
84
|
+
return runConsolidateCommand({
|
|
85
|
+
store,
|
|
86
|
+
agentDir,
|
|
87
|
+
llm,
|
|
88
|
+
cron: parsed.options.cron,
|
|
89
|
+
force: parsed.options.force,
|
|
90
|
+
verbose: parsed.options.verbose,
|
|
91
|
+
log,
|
|
92
|
+
});
|
|
306
93
|
}
|
|
307
|
-
return {
|
|
308
|
-
hour,
|
|
309
|
-
minute,
|
|
310
|
-
dryRun: args.includes("--dry-run"),
|
|
311
|
-
remove: args.includes("--remove"),
|
|
312
|
-
status: args.includes("--status"),
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function resolveSchedulePlatform(): SchedulePlatform {
|
|
317
|
-
if (process.platform === "darwin") return "darwin";
|
|
318
|
-
if (process.platform === "linux") return "linux";
|
|
319
|
-
throw new Error(`setup-schedule is not supported on ${process.platform}`);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function tryResolveSchedulePlatform(): SchedulePlatform | null {
|
|
323
|
-
if (process.platform === "darwin") return "darwin";
|
|
324
|
-
if (process.platform === "linux") return "linux";
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
async function readScheduleStatus(cfg: MemoryConfig) {
|
|
329
|
-
const platform = tryResolveSchedulePlatform();
|
|
330
|
-
if (!platform) {
|
|
331
|
-
return {
|
|
332
|
-
supported: false,
|
|
333
|
-
platform: process.platform,
|
|
334
|
-
files: [],
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
const result = await setupSchedule({
|
|
338
|
-
hour: cfg.consolidation.schedule.hour,
|
|
339
|
-
minute: cfg.consolidation.schedule.minute,
|
|
340
|
-
logPath: cfg.consolidation.schedule.log_path,
|
|
341
|
-
status: true,
|
|
342
|
-
}, platform);
|
|
343
|
-
return {
|
|
344
|
-
supported: true,
|
|
345
|
-
platform,
|
|
346
|
-
files: result.files,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function printHelp(): void {
|
|
351
|
-
console.log(`pi-memory — local TLM episodic memory (mode B)
|
|
352
|
-
|
|
353
|
-
Commands:
|
|
354
|
-
health Start sidecar (if bundle present) and print /health
|
|
355
|
-
status Print MemoryService status snapshot
|
|
356
|
-
memory-status Print consolidation queue, MEMORY.md cap, schedule status, and recent job logs
|
|
357
|
-
consolidate Run offline memory consolidation
|
|
358
|
-
--dry-run Report planned work without writing MEMORY.md/stage1
|
|
359
|
-
--phase1-only Drain queue and train graph only
|
|
360
|
-
--phase2-only Consume existing stage1 rows only
|
|
361
|
-
setup-schedule Install/update the OS user scheduler
|
|
362
|
-
--hour Local hour (default from memory.json consolidation.schedule.hour)
|
|
363
|
-
--minute Local minute (default from memory.json consolidation.schedule.minute)
|
|
364
|
-
--dry-run Print files that would be written
|
|
365
|
-
--remove Remove scheduler files
|
|
366
|
-
--status Report scheduler file existence
|
|
367
|
-
query POST /query with JSON QueryIntent
|
|
368
|
-
install-bundle Copy a local bundle dir into ~/.pi/memory/current
|
|
369
|
-
train Build a bundle from session history (delta merge by default)
|
|
370
|
-
--sessions-dir Override sessions directory (default from config)
|
|
371
|
-
--full Ignore marker, rebuild from all sessions
|
|
372
|
-
--dry-run Show extraction stats without writing bundle
|
|
373
|
-
--no-merge Skip delta merge, full rebuild (ignore existing bundle)
|
|
374
|
-
--extractor Extractor type: "regex" (default) or "llm"
|
|
375
|
-
--model LLM model for --extractor llm (default: deepseek/deepseek-v4-flash)
|
|
376
|
-
--watch Run once then schedule periodic re-training
|
|
377
|
-
index Rebuild SQLite FTS5 session search index
|
|
378
|
-
--sessions-dir Override sessions directory (default from config)
|
|
379
|
-
|
|
380
|
-
Environment:
|
|
381
|
-
Place bundle at ~/.pi/memory/current/ (symlink to bundles/<ts>/)
|
|
382
|
-
Session fallback searches ~/.pi/sessions/*.json
|
|
383
|
-
Install tlm on PATH or set memory.tlmPath in Pi extension config
|
|
384
|
-
LLM extractor uses provider env vars (e.g. DEEPSEEK_API_KEY for deepseek/deepseek-v4-flash)
|
|
385
94
|
|
|
386
|
-
|
|
387
|
-
pi-memory query '{"mode":"direct_relation","anchor_mentions":["Alice"]}'
|
|
388
|
-
pi-memory install-bundle ./my-bundle-2026-06-01T00-00-00Z
|
|
389
|
-
pi-memory train --full
|
|
390
|
-
pi-memory train --extractor llm
|
|
391
|
-
pi-memory train --watch
|
|
392
|
-
pi-memory index
|
|
393
|
-
`);
|
|
95
|
+
return 1;
|
|
394
96
|
}
|
|
395
97
|
|
|
396
|
-
main().
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
});
|
|
98
|
+
main().then(
|
|
99
|
+
(code) => process.exit(code),
|
|
100
|
+
(error) => {
|
|
101
|
+
const log = createCliLog({ verbose: true });
|
|
102
|
+
log.error(error instanceof Error ? error.message : String(error));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
},
|
|
105
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { createRememberCommand } from "./remember.js";
|
|
4
|
+
import { createMemoryStatusCommand } from "./status.js";
|
|
5
|
+
import type { CommandDeps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
export type { CommandDeps, MemoryStatusCommandDeps, RememberCommandDeps } from "./types.js";
|
|
8
|
+
export { parseRememberArgs } from "./parseRememberArgs.js";
|
|
9
|
+
|
|
10
|
+
export function registerCommands(pi: ExtensionAPI, deps: CommandDeps): void {
|
|
11
|
+
pi.registerCommand("remember", {
|
|
12
|
+
description: "Append a user-authored note to MEMORY.md",
|
|
13
|
+
handler: createRememberCommand(deps),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
pi.registerCommand("memory-status", {
|
|
17
|
+
description: "Show MEMORY.md, sidecar, and vector index diagnostics (toggle expand/collapse; hide to dismiss)",
|
|
18
|
+
handler: createMemoryStatusCommand(deps),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type MemoryStatusAction = "toggle" | "refresh" | "hide" | "expand" | "collapse";
|
|
2
|
+
|
|
3
|
+
export function parseMemoryStatusArgs(args: string | string[]): MemoryStatusAction {
|
|
4
|
+
const text = (Array.isArray(args) ? args.join(" ") : args).trim().toLowerCase();
|
|
5
|
+
if (!text) return "toggle";
|
|
6
|
+
if (text === "hide" || text === "close" || text === "off" || text === "dismiss") return "hide";
|
|
7
|
+
if (text === "refresh" || text === "reload") return "refresh";
|
|
8
|
+
if (text === "expand" || text === "open" || text === "show") return "expand";
|
|
9
|
+
if (text === "collapse" || text === "fold" || text === "min") return "collapse";
|
|
10
|
+
return "toggle";
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MEMORY_SECTIONS, type MemorySection } from "../store/types.js";
|
|
2
|
+
|
|
3
|
+
const SECTION_ALIASES: Record<string, MemorySection> = {
|
|
4
|
+
preferences: "Preferences",
|
|
5
|
+
preference: "Preferences",
|
|
6
|
+
prefs: "Preferences",
|
|
7
|
+
pref: "Preferences",
|
|
8
|
+
conventions: "Conventions",
|
|
9
|
+
convention: "Conventions",
|
|
10
|
+
conv: "Conventions",
|
|
11
|
+
findings: "Findings",
|
|
12
|
+
finding: "Findings",
|
|
13
|
+
todos: "Todos",
|
|
14
|
+
todo: "Todos",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ParsedRememberArgs =
|
|
18
|
+
| { section: MemorySection; content: string }
|
|
19
|
+
| { error: string };
|
|
20
|
+
|
|
21
|
+
function normalizeArgs(raw: string | string[]): string {
|
|
22
|
+
return (Array.isArray(raw) ? raw.join(" ") : raw).trim();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function matchSection(token: string): MemorySection | undefined {
|
|
26
|
+
const key = token.toLowerCase();
|
|
27
|
+
if (SECTION_ALIASES[key]) return SECTION_ALIASES[key];
|
|
28
|
+
return MEMORY_SECTIONS.find((section) => section.toLowerCase() === key);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Parse `/remember [section]? content`. Default section: Findings. */
|
|
32
|
+
export function parseRememberArgs(raw: string | string[]): ParsedRememberArgs {
|
|
33
|
+
const text = normalizeArgs(raw);
|
|
34
|
+
if (!text) {
|
|
35
|
+
return {
|
|
36
|
+
error: "Usage: /remember [Preferences|Conventions|Findings|Todos] <content>",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const space = text.indexOf(" ");
|
|
41
|
+
const firstToken = space === -1 ? text : text.slice(0, space);
|
|
42
|
+
const section = matchSection(firstToken);
|
|
43
|
+
|
|
44
|
+
if (section) {
|
|
45
|
+
const content = space === -1 ? "" : text.slice(space + 1).trim();
|
|
46
|
+
if (!content) {
|
|
47
|
+
return {
|
|
48
|
+
error: `Usage: /remember ${section} <content>`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { section, content };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { section: "Findings", content: text };
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import type { MemoryStore } from "../store/memoryStore.js";
|
|
4
|
+
import { parseRememberArgs } from "./parseRememberArgs.js";
|
|
5
|
+
|
|
6
|
+
export type RememberCommandDeps = {
|
|
7
|
+
getMemoryStore(): MemoryStore | null;
|
|
8
|
+
onRemembered?(): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function createRememberCommand(deps: RememberCommandDeps) {
|
|
12
|
+
return async (args: string | string[], ctx: ExtensionCommandContext): Promise<void> => {
|
|
13
|
+
const memoryStore = deps.getMemoryStore();
|
|
14
|
+
if (!memoryStore) {
|
|
15
|
+
ctx.ui.notify("pi-memory: not started", "warning");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const parsed = parseRememberArgs(args);
|
|
20
|
+
if ("error" in parsed) {
|
|
21
|
+
ctx.ui.notify(parsed.error, "warning");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await memoryStore.ensureInitialized();
|
|
27
|
+
await memoryStore.appendUser({
|
|
28
|
+
id: "",
|
|
29
|
+
section: parsed.section,
|
|
30
|
+
content: parsed.content,
|
|
31
|
+
timestamp: "",
|
|
32
|
+
});
|
|
33
|
+
await deps.onRemembered?.();
|
|
34
|
+
|
|
35
|
+
ctx.ui.notify(`Saved to MEMORY.md (${parsed.section})`, "info");
|
|
36
|
+
} catch (error) {
|
|
37
|
+
ctx.ui.notify(
|
|
38
|
+
`Remember failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
39
|
+
"warning",
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|