Skip to content

feat: long term memo - #176

Merged
nutstore-dev merged 47 commits into
nutstore:mainfrom
miaobuao:feat/long-term-memo
Sep 8, 2026
Merged

nutstore-dev merged 47 commits into
nutstore:mainfrom
miaobuao:feat/long-term-memo

Conversation

@miaobuao

@miaobuao miaobuao commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Upgrade pbkdf2, sha.js, fast-xml-parser and related fixes.
### What
- Add MemoryIndexRepository: scans .agents/nutstore-sync/memory/archive/<YYYY>/<YYYY-MM-DD>.md within a 30-day window and emits one memory:<date> delta per file, carrying the agent-written frontmatter index when present.
- Ship the long-term-memory built-in Skill: authoritative daily archive, derived per-year TSV catalog, index-constraint rules, retrieval by recency, and freeze/rebuild semantics.
- Extract the shared parseYamlFrontmatter (frontmatter.ts) used by both SkillRepository and MemoryIndexRepository; drop the private copy in repository.ts.
- Add settings.ai.longTermMemory (default off): gates the built-in Skill catalog entry and memory delta injection.

### Why
Nothing carried the agent's cross-session memory into context; the archive layout existed only as prose. The plugin now injects the recent memory window directly so unchanged days are not re-sent, and older memory stays reachable via find/grep over the archive and catalog.

### Key changes
- captureWorkspaceContexts and both message paths accept an optional MemoryIndexRepository and refresh it on user messages.
- ChatService syncs the settings gate into both repositories after settings load, never in the constructor (settings load after construction).
- Tests cover window filtering, missing archive, derived-content exclusion, mixed zh/en/emoji indexes, enable/disable, and re-emitting only the changed day via delta hashing.
Add a currentDate delta (local date, English weekday, optional timezone) so the model always knows today's date. The delta hashes per day, so same-day captures dedupe away while a midnight rollover emits exactly one new delta. Date helpers fall back to manual formatting when Intl is missing or partial, which is common in older WebView runtimes.

Tests cover date capture, midnight dedupe/rollover, Intl-absent fallbacks, and serialization of the new delta into model messages.
Unify bash, apply_patch, image, and reversible-operation handling around a shared vault-root filesystem so agent paths match the user's vault while hidden plugin data remains available through virtual mounts.\n\nPreserve restoration of legacy /vault and /tmp session records, scope filesystem reads per invocation, and report only changed settings in permission prompts. Add coverage for mounts, Unicode paths, exports, MCP/UI flows, and stricter test oracles.
Plugin startup previously scanned the whole Vault through an adapter path index and restored the active chat session during ChatService.onload. Both are now lazy: opening the ChatBox triggers session restore and the view shows a Restoring chat... state until it completes.

- Drop the adapter-backed path index and listVaultPaths; shell filesystems read the live Vault directory per call
- Build the session index from the meta file without reading session bodies when meta matches disk; fall back to full reconciliation otherwise
- Restore the active session via SessionUnavailableError-aware loading with a fresh-index fallback for corrupt or missing session files
- Mount the ChatBox view before restoring, then restore in the background with a loading indicator
- Settings changes reuse an in-flight initialization instead of forcing a new one
### What
- split build, PostCSS, raw-text, UnoCSS, and polyfill logic into plugins
- finalize JavaScript and CSS from in-memory esbuild outputs

### Why
- avoid intermediate main.css files and reduce development rebuild overhead
- keep output post-processing in one finalization stage
Replace the legacy TypeScript ESLint setup with Obsidian's recommended rules and type-aware project discovery. Add the strict lint script, unused-import checks, and JavaScript config files to the TypeScript project while refreshing the lockfile for the new tooling.
Extract inference and context-compaction coordination, consolidate message helpers, and keep chat sessions JSON-safe across Obsidian storage. Update related agent, UI, service, and test integrations.
### What
- preserve local calendar dates for memory windows and log filenames
- decode legacy typed-array session payloads and reconcile unavailable sessions
- avoid submitting Enter during IME confirmation and add regression coverage

### Why
Keep synced chat data recoverable across older storage formats, time zones, and CJK input workflows.
@miaobuao
miaobuao force-pushed the feat/long-term-memo branch from 12ff7f1 to 4b1ea2b Compare September 2, 2026 06:46
@miaobuao
miaobuao force-pushed the feat/long-term-memo branch from 6d17197 to a896646 Compare September 2, 2026 07:47
Comment thread package.json
Comment thread src/ai/chat/runtime/context-compaction-coordinator.ts Outdated
Comment thread src/ai/tools/vault-filesystem.ts Outdated
Comment thread src/index.ts
Group real-runtime checks by plugin, provider, vault, and chat while keeping orchestration and execution order in the harness.
### Why
Stop/abort/rehydration were governed by scattered flags (stopRequested,
isDeleted, pending submissions) that could go stale, letting a dead turn
keep mutating the timeline, persisting sessions, or delivering subagent
results after the user stopped, the session was rehydrated, or the
plugin unloaded.

### What
- Every unit of execution now carries a TaskOrigin (turnId + AbortSignal)
  from the master turn scheduler; scattered liveness checks collapse into
  a single isTurnAlive fence (agent loop, runner, event projector,
  compaction, task settlement, persistence).
- SessionProcessor becomes a turn worker draining the scheduler queue
  (user submissions, subagent continuations, regeneration) and owns turn
  materialization, cancellation trees, and failure handling; Stop aborts
  the active turn and only the executions derived from it.
- TaskManager tracks per-agent origins, settles agents through a single
  path with liveness re-checks around async persists, and stages parent
  continuations through the scheduler with fencing.
- Regeneration becomes transactional (begin/commit/rollback), restoring
  timeline, reversible ops, tool timings, and session index state.
- Runtime execution never survives rehydration: resetExecution replaces
  the runtime state while keeping the draft, and rehydration cleanup
  clears pending inputs, incomplete tool calls, and non-terminal agent
  statuses.
- Summarizer receives schema-only tools without execute entry points, and
  manual compression gets its own abort controller.
### What
- Seed the snapshot from vault.getAllLoadedFiles() — the same
  authoritative view the file explorer shows — plus a scoped walk of
  the plugin's .agents domain directory, which the Vault index
  excludes because it is hidden.
- Hidden paths outside the plugin domain are deliberately left out of
  wildcard expansion; direct path reads are unaffected.

### Test infra
- waitForResult now polls until the harness clears its started
  sentinel; previously it returned that sentinel immediately, so the
  suite never actually waited for results.
- The harness writes results after every check so a hung check still
  leaves completed results behind for diagnostics. (The ChatBox check
  hangs in the offline sandbox and needs a separate fix; the Bash
  wildcard checks run before it.)
- New integration checks pin the snapshot boundary: exclude unrelated
  hidden paths, include .agents content.
File change blocks in the chatbox previously rendered expanded, pushing
conversation history off-screen whenever the agent applied patches. They
now start collapsed; the summary still shows the vault path and +N -N
stats, and users can expand on demand.
Comment thread src/ai/chat/runtime/task-manager.ts
Comment thread src/ai/tools/vault-filesystem.ts
Comment thread src/ai/chat/runtime/task-manager.ts Outdated
Comment thread src/services/settings.service.ts
Comment thread src/ai/chat/runtime/task-manager.ts Outdated
@nutstore-dev
nutstore-dev merged commit 8b3c98b into nutstore:main Sep 8, 2026
1 check passed
@miaobuao
miaobuao deleted the feat/long-term-memo branch September 8, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants