15 Commits

Author SHA1 Message Date
can1357 6b4823181b test: cleaned test suites and documented filtering guidelines
- Remove redundant definedness, null, and type checks across test suites in multiple packages.
- Clean up unused assertions, metadata tests, and obsolete test cases.
- Add good versus bad test filter guidelines and requirements to project documentation.
2026-08-13 08:28:42 +02:00
can1357 34bebbc72f test: aligned hindsight project casing 2026-08-13 02:08:30 +02:00
roboomp 510661437f fix(coding-agent/hindsight): route recall through single injection path
Two recall paths shared the hasRecalledForFirstTurn flag: the agent_start
subscription (maybeRecallOnAgentStart, fire-and-forget with an unawaited
background prompt rebuild) and beforeAgentStartPrompt (awaited before the
turn builds). When the event path consumed the flag first,
beforeAgentStartPrompt returned undefined and the recalled context reached
the model only if the background rebuild had already landed -- on a fast
turn it had not, so autoRecall intermittently never reached the model.

Make beforeAgentStartPrompt the sole injection path and drop the racing
agent_start recall.

Fixes #7568
2026-08-03 23:29:04 +00:00
roboomp b94ab98005 fix(hindsight): preserved local retain timestamps
Sent Hindsight retain timestamps with local timezone offsets and supplied timestamps for automatic and queued retains. Added regression coverage for client serialization and backend timestamp propagation.\n\nFixes #2363
2026-06-12 06:54:30 +00:00
roboomp 0db52a72dc test(coding-agent/hindsight): defended bankId reset routing in both scope modes
Added two regression tests covering the bidirectional reporter scenario:
clearing hindsight.bankId after a non-empty value rebuilds the live state
and routes subsequent retainBatch calls to the recomputed bank under both
per-project and global scoping. The PR's existing fix already handles
this direction; these lock the contract in place explicitly.

Fixes #1902
2026-06-05 08:17:46 +00:00
roboomp a8b3aeaeaa fix(coding-agent/hindsight): serialized live scope rebuilds
Coalesced synchronous Hindsight routing setting hooks into one serialized
session rebuild so cwd reloads and multi-setting updates cannot have
multiple continuations capture the same old state and leak fresh
session listeners.

Also re-read the current state after awaiting the previous queue flush
before installing the replacement state, so an unexpected concurrent
owner cannot leave the actual current state undisposed.

Fixes #1902
2026-06-05 05:35:09 +00:00
roboomp 34005e6656 fix(coding-agent/hindsight): reacted to live bank scope changes and flushed before dispose
Mid-session edits to hindsight.bankId / bankIdPrefix / scoping kept the
active HindsightSessionState pinned to the bank selected at session
start, so retain/recall/reflect calls landed in the stale bank. Settings
hooks now fire onHindsightScopeChanged; the backend rebuilds the
primary state against the recomputed scope, disposing the previous one
after flushing its queue so queued tool-initiated retains still land in
the bank they were enqueued for.

Also:
- Renamed ensureBankMission to ensureBankExists. The old version
  skipped creation entirely when bankMission was blank, so the first
  mental-model POST (auto-seed) could land against a never-PUT bank.
  Bank creation is now idempotent and unconditional, and runs before
  mental-model bootstrap.
- Fixed AgentSession.dispose to flush the retain queue BEFORE clearing
  the session state pointer. Reversed, HindsightRetainQueue.#doFlush's
  identity guard would see the cleared pointer and drop the spliced
  batch with a 'session vanished' warning.
- Snapshotted hindsightScopeCallbacks before iterating because each
  rebuild subscribes a fresh callback inside the same fire; iterating
  the live Set would spin.

Fixes #1902
2026-06-05 05:25:45 +00:00
can1357 f1f6516056 refactor: reorganized exports and removed obsolete helper branches
- Removed export leakage by demoting many helper and const symbols to module-local scope.
- Renamed underscore-prefixed internals and cache fields, then updated related references and `satisfies never` checks.
- Deleted obsolete logic branches and helpers, including harmony-stream interruption flow and unused benchmark runtime helpers.
- Updated Biome config and manifests by broadening lint coverage and removing an unused `@napi-rs/cli` dev dependency.
- Adjusted tests and utilities to use renamed test helpers and remove redundant private test-only helpers/locals.
2026-05-14 04:36:19 +02:00
can1357 0e761ef9e0 feat(coding-agent/hindsight): added per-session HindsightSessionState
- Added `HindsightSessionState` to `AgentSession` and bound hindsight lifecycle hooks to session state.
- Removed global hindsight state/queue handling and replaced it with per-session `HindsightRetainQueue` batching and scoped flushing.
- Reworked recall, reflect, and retain tools to use `session.getHindsightSessionState()` instead of sessionId-based lookup.
- Updated SDK/task/backend/controller flows to pass `session`/`parentHindsightSessionState`, scope `/memory` behavior, and document it in changelog.
2026-05-03 10:27:06 +02:00
can1357 255ef926cf feat(coding-agent): added /memory mm handlers for mental-model seeds
- Added mental-model settings and config defaults for enablement, auto-seed, refresh interval, and render budget.
- Added built-in mental-model seeds and scope-aware rendering with `<mental_models>` extraction, truncation, and tag handling.
- Added `/memory mm` aliases and handlers for list, show, refresh, history, seed, reload, and delete commands.
- Added client APIs and bootstrap/cache wiring so snippets refresh and inject into prompts on startup.
- Added tests covering seed scope behavior, rendering caps, diffs, and backend/session reload behavior.
2026-05-03 09:48:11 +02:00
can1357 1e6235d3fc feat(coding-agent): aliased subagent sessions to shared parent Hindsight state
- Added an optional `aliasOf` link and a `pickPrimaryState` helper to track reusable parent Hindsight state.
- Updated task-depth subagent startup to reuse the latest primary state's bank, client, config, tags, and missions while returning silently when no parent exists.
- Skipped alias states in recall-snippet selection and enqueue so auto-recall/retain work only on the parent session.
2026-05-03 08:37:39 +02:00
can1357 3d8d44f86f refactor(hindsight): migrated dependency to local HindsightApi client
- Removed the `@vectorize-io/hindsight-client` dependency from both package manifests.
- Added a local `HindsightApi` client and changed `createHindsightClient` to instantiate it.
- Replaced `HindsightClient` imports/types with `HindsightApi` across backend, bank, and tests.
- Implemented `HindsightApi` `#request` handling with `fetch`, safe JSON parsing, and `HindsightError` on failures.
2026-05-03 07:47:22 +02:00
can1357 d14e4ae4b9 refactor(coding-agent): standardized Hindsight memory wrappers and tool names
- Standardized Hindsight context output to emit `<memories>` blocks and updated retention stripping to remove both `<memories>` and legacy `<hindsight_memories>`/`<relevant_memories>` tags.
- Renamed built-in Hindsight tool entry points and labels from `hindsight_retain`/`hindsight_recall`/`hindsight_reflect` to `retain`, `recall`, and `reflect`, including tool availability checks.
2026-05-03 07:39:52 +02:00
can1357 7784717935 feat(coding-agent): added first-turn hindsight recall injection to startup prompts
- Added a new optional `beforeAgentStartPrompt` hook to `MemoryBackend` and implemented it in the Hindsight backend to recall long-term context for the first turn.
- Updated `AgentSession` startup flow to inject the recalled context into the turn-specific system prompt before the first response is generated.
- Preserved `<hindsight_memories>` tags in Hindsight developer instructions and added tests for first-turn injection and state caching.
2026-05-03 07:39:52 +02:00
can1357 ce2a109c09 feat(coding-agent): added hindsight memory backends and tools
- Added `memory.backend` and `hindsight.*` settings schema with migration from `memories.enabled` legacy mode.
- Added Hindsight memory backend runtime modules for resolved config, client creation, bank ID derivation, and state lifecycle.
- Added off/local/hindsight backends and resolver wiring across SDK, commands, and compaction context.
- Added `hindsight_recall`, `hindsight_reflect`, and `hindsight_retain` tools with schema validation and backend gating.
- Added Memory tab metadata and symbols to expose backend selection in the settings UI.
- Added package export barrels and tests for bank ID, content formatting, and hindsight config env precedence.
2026-05-03 07:39:52 +02:00