feat: Live Context System with Distributed CLAUDE.md Generation (#556)

* docs: add folder index generator plan

RFC for auto-generating folder-level CLAUDE.md files with observation
timelines. Includes IDE symlink support and root CLAUDE.md integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: implement folder index generator (Phase 1)

Add automatic CLAUDE.md generation for folders containing observed files.
This enables IDE context providers to access relevant memory observations.

Core modules:
- FolderDiscovery: Extract folders from observation file paths
- FolderTimelineCompiler: Compile chronological timeline per folder
- ClaudeMdGenerator: Write CLAUDE.md with tag-based content replacement
- FolderIndexOrchestrator: Coordinate regeneration on observation save

Integration:
- Event-driven regeneration after observation save in ResponseProcessor
- HTTP endpoints for folder discovery, timeline, and manual generation
- Settings for enabling/configuring folder index behavior

The <claude-mem-context> tag wrapping ensures:
- Manual CLAUDE.md content is preserved
- Auto-generated content won't be recursively observed
- Clean separation between user and system content

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add updateFolderClaudeMd function to CursorHooksInstaller

Adds function to update CLAUDE.md files for folders touched by observations.
Uses existing /api/search/by-file endpoint, preserves content outside
<claude-mem-context> tags, and writes atomically via temp file + rename.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: hook updateFolderClaudeMd into ResponseProcessor

Calls updateFolderClaudeMd after observation save to update folder-level
CLAUDE.md files. Uses fire-and-forget pattern with error logging.
Extracts file paths from saved observations and workspace path from registry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add timeline formatting for folder CLAUDE.md files

Implements formatTimelineForClaudeMd function that transforms API response
into compact markdown table format. Converts emojis to text labels,
handles ditto marks for timestamps, and groups under "Recent" header.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: remove old folder-index implementation

Deletes redundant folder-index services that were replaced by the simpler
updateFolderClaudeMd approach in CursorHooksInstaller.ts.

Removed:
- src/services/folder-index/ directory (5 files)
- FolderIndexRoutes.ts
- folder-index settings from SettingsDefaultsManager
- folder-index route registration from worker-service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add worktree-aware project filtering for unified timelines

Detect git worktrees and show both parent repo and worktree observations
in the session start timeline. When running in a worktree, the context
now includes observations from both projects, interleaved chronologically.

- Add detectWorktree() utility to identify worktree directories
- Add getProjectContext() to return parent + worktree projects
- Update context hook to pass multi-project queries
- Add queryObservationsMulti() and querySummariesMulti() for IN clauses
- Maintain backward compatibility with single-project queries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* fix: restructure logging to prove session correctness and reduce noise

Add critical logging at each stage of the session lifecycle to prove the session ID chain (contentSessionId → sessionDbId → memorySessionId) stays aligned. New logs include CREATED, ENQUEUED, CLAIMED, MEMORY_ID_CAPTURED, STORING, and STORED. Move intermediate migration and backfill progress logs to DEBUG level to reduce noise, keeping only essential initialization and completion logs at INFO level.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* refactor: extract folder CLAUDE.md utils to shared location

Moves folder CLAUDE.md utilities from CursorHooksInstaller to a new
shared utils file. Removes Cursor registry dependency - file paths
from observations are already absolute, no workspace lookup needed.

New file: src/utils/claude-md-utils.ts
- replaceTaggedContent() - preserves user content outside tags
- writeClaudeMdToFolder() - atomic writes with tag preservation
- formatTimelineForClaudeMd() - API response to compact markdown
- updateFolderClaudeMdFiles() - orchestrates folder updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: trigger folder CLAUDE.md updates when observations are saved

The folder CLAUDE.md update was previously only triggered in
syncAndBroadcastSummary, but summaries run with observationCount=0
(observations are saved separately). Moved the update logic to
syncAndBroadcastObservations where file paths are available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* all the claudes

* test: add unit tests for claude-md-utils pure functions

Add 11 tests covering replaceTaggedContent and formatTimelineForClaudeMd:
- replaceTaggedContent: empty content, tag replacement, appending, partial tags
- formatTimelineForClaudeMd: empty input, parsing, ditto marks, session IDs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add integration tests for file operation functions

Add 9 tests for writeClaudeMdToFolder and updateFolderClaudeMdFiles:
- writeClaudeMdToFolder: folder creation, content preservation, nested dirs, atomic writes
- updateFolderClaudeMdFiles: empty skip, fetch/write, deduplication, error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add unit tests for timeline-formatting utilities

Add 14 tests for extractFirstFile and groupByDate functions:
- extractFirstFile: relative paths, fallback to files_read, null handling, invalid JSON
- groupByDate: empty arrays, date grouping, chronological sorting, item preservation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: rebuild plugin scripts with merged features

* docs: add project-specific CLAUDE.md with architecture and development notes

* fix: exclude project root from auto-generated CLAUDE.md updates

Skip folders containing .git directory when auto-updating subfolder
CLAUDE.md files. This ensures:

1. Root CLAUDE.md remains user-managed and untouched by the system
2. SessionStart context injection stays pristine throughout the session
3. Subfolder CLAUDE.md files continue to receive live context updates
4. Cleaner separation between user-authored root docs and auto-generated folder indexes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: prevent crash from resuming stale SDK sessions on worker restart

When the worker restarts, it was incorrectly passing the `resume` parameter
to INIT prompts (lastPromptNumber=1) when a memorySessionId existed from a
previous SDK session. This caused "Claude Code process exited with code 1"
crashes because the SDK tried to resume into a session that no longer exists.

Root cause: The resume condition only checked `hasRealMemorySessionId` but
did not verify that this was a CONTINUATION prompt (lastPromptNumber > 1).

Fix: Add `session.lastPromptNumber > 1` check to the resume condition:
- Before: `...(hasRealMemorySessionId && { resume: session.memorySessionId })`
- After: `...(hasRealMemorySessionId && session.lastPromptNumber > 1 && { resume: ... })`

Also added:
- Enhanced debug logging that warns when skipping resume for INIT prompts
- Unit tests in tests/sdk-agent-resume.test.ts (9 test cases)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: properly handle Chroma MCP connection errors

Previously, ensureCollection() caught ALL errors from chroma_get_collection_info
and assumed they meant "collection doesn't exist", triggering unnecessary
collection creation attempts. Connection errors like "Not connected" or
"MCP error -32000: Connection closed" would cascade into failed creation attempts.

Similarly, queryChroma() would silently return empty results when the MCP call
failed, masking the underlying connection problem.

Changes:
- ensureCollection(): Detect connection errors and re-throw immediately instead
  of attempting collection creation
- queryChroma(): Wrap MCP call in try-catch and throw connection errors instead
  of returning empty results
- Both methods reset connection state (connected=false, client=null) on
  connection errors so subsequent operations can attempt to reconnect

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* pushed

* fix: scope regenerate-claude-md.ts to current working directory

Critical bug fix: The script was querying ALL observations from the database
across ALL projects ever recorded (1396+ folders), then attempting to write
CLAUDE.md files everywhere including other projects, non-existent paths, and
ignored directories.

Changes:
- Use git ls-files to discover folders (respects .gitignore automatically)
- Filter database query to current project only (by folder name)
- Use relative paths for database queries (matches storage format)
- Add --clean flag to remove auto-generated CLAUDE.md files
- Add fallback directory walker for non-git repos

Now correctly scopes to 26 folders with observations instead of 1396+.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs and adjustments

* fix: cleanup mode strips tags instead of deleting files blindly

The cleanup mode was incorrectly deleting entire files that contained
<claude-mem-context> tags. The correct behavior (per original design):

1. Strip the <claude-mem-context>...</claude-mem-context> section
2. If empty after stripping → delete the file
3. If has remaining content → save the stripped version

Now properly preserves user content in CLAUDE.md files while removing
only the auto-generated sections.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* deleted some files

* chore: regenerate folder CLAUDE.md files with fixed script

Regenerated 23 folder CLAUDE.md files using the corrected script that:
- Scopes to current working directory only
- Uses git ls-files to respect .gitignore
- Filters by project name

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update CLAUDE.md files for January 5, 2026

- Regenerated and staged 23 CLAUDE.md files with a mix of new and modified content.
- Fixed cleanup mode to properly strip tags instead of deleting files blindly.
- Cleaned up empty CLAUDE.md files from various directories, including ~/.claude and ~/Scripts.
- Conducted dry-run cleanup that identified a significant reduction in auto-generated CLAUDE.md files.
- Removed the isAutoGeneratedClaudeMd function due to incorrect file deletion behavior.

* feat: use settings for observation limit in batch regeneration script

Replace hard-coded limit of 10 with configurable CLAUDE_MEM_CONTEXT_OBSERVATIONS
setting (default: 50). This allows users to control how many observations appear
in folder CLAUDE.md files.

Changes:
- Import SettingsDefaultsManager and load settings at script startup
- Use OBSERVATION_LIMIT constant derived from settings at both call sites
- Remove stale default parameter from findObservationsByFolder function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: use settings for observation limit in event-driven updates

Replace hard-coded limit of 10 in updateFolderClaudeMdFiles with
configurable CLAUDE_MEM_CONTEXT_OBSERVATIONS setting (default: 50).

Changes:
- Import SettingsDefaultsManager and os module
- Load settings at function start (once, not in loop)
- Use limit from settings in API call

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: Implement configurable observation limits and enhance search functionality

- Added configurable observation limits to batch regeneration scripts.
- Enhanced SearchManager to handle folder queries and normalize parameters.
- Introduced methods to check for direct child files in observations and sessions.
- Updated SearchOptions interface to include isFolder flag for filtering.
- Improved code quality with comprehensive reviews and anti-pattern checks.
- Cleaned up auto-generated CLAUDE.md files across various directories.
- Documented recent changes and improvements in CLAUDE.md files.

* build asset

* Project Context from Claude-Mem auto-added (can be auto removed at any time)

* CLAUDE.md updates

* fix: resolve CLAUDE.md files to correct directory in worktree setups

When using git worktrees, CLAUDE.md files were being written relative to
the worker's process.cwd() instead of the actual project directory. This
fix threads the project's cwd from message processing through to the file
writing utilities, ensuring CLAUDE.md files are created in the correct
project directory regardless of where the worker was started.

Changes:
- Add projectRoot parameter to updateFolderClaudeMdFiles for path resolution
- Thread projectRoot through ResponseProcessor call chain
- Track lastCwd from messages in SDKAgent, GeminiAgent, OpenRouterAgent
- Add tests for relative/absolute path handling with projectRoot

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* more project context updates

* context updates

* fix: preserve actual dates in folder CLAUDE.md generation

Previously, formatTimelineForClaudeMd used today's date for all
observations because the API only returned time (e.g., "4:30 PM")
without date information. This caused all historical observations
to appear as if they happened today.

Changes:
- SearchManager.findByFile now groups results by date with headers
  (e.g., "### Jan 4, 2026") matching formatSearchResults behavior
- formatTimelineForClaudeMd now parses these date headers and uses
  the correct date when constructing epochs for date grouping

The timeline dates are critical for claude-mem context - LLMs need
accurate temporal context to understand when work happened.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build: update worker assets with date parsing fix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* claude-mem context: Fixed critical date parsing bug in PR #556

* fix: address PR #556 review items

- Use getWorkerHost() instead of hard-coded 127.0.0.1 in claude-md-utils
- Add error message and stack details to FOLDER_INDEX logging
- Add 5 new tests for worktree/projectRoot path resolution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Refactor CLAUDE documentation across multiple components and tests

- Updated CLAUDE.md files in src/ui/viewer, src/ui/viewer/constants, src/ui/viewer/hooks, tests/server, tests/worker/agents, and plans to reflect recent changes and improvements.
- Removed outdated entries and consolidated recent activities for clarity.
- Enhanced documentation for hooks, settings, and pagination implementations.
- Streamlined test suite documentation for server and worker agents, indicating recent test audits and cleanup efforts.
- Adjusted plans to remove obsolete entries and focus on current implementation strategies.

* docs: comprehensive v9.0 documentation audit and updates

- Add usage/folder-context to docs.json navigation (was documented but hidden!)
- Update introduction.mdx with v9.0 release notes (Live Context, Worktree Support, Windows Fixes)
- Add CLAUDE_MEM_WORKER_HOST setting to configuration.mdx
- Add Folder Context Files section with link to detailed docs
- Document worktree support in folder-context.mdx
- Update terminology from "mem-search skill" to "MCP tools" throughout active docs
- Update Search Pipeline in architecture/overview.mdx
- Update usage/getting-started.mdx with MCP tools terminology
- Update usage/claude-desktop.mdx title and terminology
- Update hooks-architecture.mdx reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add recent activity log for worker CLI with detailed entries

* chore: update CLAUDE.md context files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add brainstorming report for CLAUDE.md distribution architecture

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-01-05 22:41:42 -05:00
committed by GitHub
parent 21a1e272d9
commit e1ab73decc
152 changed files with 10367 additions and 2103 deletions
+63
View File
@@ -0,0 +1,63 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 10, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23832 | 11:15 PM | 🔵 | Current worker-service.ts Lacks Admin Endpoints | ~393 |
### Dec 14, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #26740 | 11:26 PM | 🔵 | Worker Service Refactored to Orchestrator with Background Initialization | ~421 |
| #26739 | 11:25 PM | 🔵 | Worker Service Architecture Uses Domain Services and Background Initialization | ~438 |
| #26255 | 8:31 PM | 🔵 | Context Generator Timeline Rendering Logic Details File Grouping Implementation | ~397 |
| #26251 | 8:30 PM | 🔵 | Worker Service Orchestrates Domain Services and Route Handlers | ~292 |
| #26246 | 8:29 PM | 🔵 | Context Generator Implements Rich Date-Grouped Timeline Format | ~468 |
### Dec 17, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #28548 | 4:49 PM | 🔵 | Worker service cleanup method uses Unix-specific process management | ~323 |
| #28446 | 4:23 PM | 🔵 | Worker Service Refactored to Orchestrator Pattern | ~529 |
### Dec 18, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29340 | 3:11 PM | ✅ | Constructor Initialization Comment Updated | ~267 |
| #29339 | " | ✅ | Class Member Comment Updated in WorkerService | ~267 |
| #29338 | " | ✅ | Service Import Comment Updated | ~222 |
| #29337 | 3:10 PM | ✅ | Terminology Update in Worker Service Documentation | ~268 |
| #29239 | 12:11 AM | 🔵 | Worker Service Refactored as Domain-Driven Orchestrator | ~477 |
### Dec 20, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30808 | 6:05 PM | 🔴 | Fixed worker readiness check to fail on initialization errors | ~315 |
| #30800 | 6:03 PM | 🔵 | Dual Error Logging in Background Initialization | ~367 |
| #30799 | " | 🔵 | Background Initialization Invocation Pattern | ~365 |
| #30797 | " | 🔵 | Background Initialization Sequence and Error Handler Confirmed | ~450 |
| #30795 | 6:02 PM | 🔵 | Readiness Endpoint Returns 503 During Initialization | ~397 |
| #30793 | " | 🔵 | Dual Initialization State Tracking Pattern | ~388 |
| #30791 | " | 🔵 | Worker Service Constructor Defers SearchRoutes Initialization | ~387 |
| #30790 | " | 🔵 | Initialization Promise Resolver Pattern Located | ~321 |
| #30788 | " | 🔵 | Worker Service Initialization Resolves Promise Despite Errors | ~388 |
### Jan 1, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35654 | 11:29 PM | ✅ | Added APPROVED OVERRIDE annotation for instruction loading HTTP route error handler | ~339 |
| #35651 | 11:28 PM | ✅ | Added APPROVED OVERRIDE annotation for shutdown error handler with process.exit | ~354 |
| #35649 | " | ✅ | Added APPROVED OVERRIDE annotation for readiness check retry loop error handling | ~374 |
| #35647 | " | ✅ | Added APPROVED OVERRIDE annotation for port availability probe error handling | ~327 |
| #35646 | " | ✅ | Added APPROVED OVERRIDE annotation for Cursor context file update error handling | ~342 |
| #35643 | 11:27 PM | ✅ | Added APPROVED OVERRIDE annotation for PID file cleanup error handling | ~320 |
</claude-mem-context>
+7
View File
@@ -0,0 +1,7 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
*No recent activity*
</claude-mem-context>
+12 -3
View File
@@ -17,7 +17,9 @@ import { loadContextConfig } from './ContextConfigLoader.js';
import { calculateTokenEconomics } from './TokenCalculator.js';
import {
queryObservations,
queryObservationsMulti,
querySummaries,
querySummariesMulti,
getPriorSessionMessages,
prepareSummariesForTimeline,
buildTimeline,
@@ -129,6 +131,9 @@ export async function generateContext(
const cwd = input?.cwd ?? process.cwd();
const project = getProjectName(cwd);
// Use provided projects array (for worktree support) or fall back to single project
const projects = input?.projects || [project];
// Initialize database
const db = initializeDatabase();
if (!db) {
@@ -136,9 +141,13 @@ export async function generateContext(
}
try {
// Query data
const observations = queryObservations(db, project, config);
const summaries = querySummaries(db, project, config);
// Query data for all projects (supports worktree: parent + worktree combined)
const observations = projects.length > 1
? queryObservationsMulti(db, projects, config)
: queryObservations(db, project, config);
const summaries = projects.length > 1
? querySummariesMulti(db, projects, config)
: querySummaries(db, project, config);
// Handle empty state
if (observations.length === 0 && summaries.length === 0) {
@@ -66,6 +66,65 @@ export function querySummaries(
`).all(project, config.sessionCount + SUMMARY_LOOKAHEAD) as SessionSummary[];
}
/**
* Query observations from multiple projects (for worktree support)
*
* Returns observations from all specified projects, interleaved chronologically.
* Used when running in a worktree to show both parent repo and worktree observations.
*/
export function queryObservationsMulti(
db: SessionStore,
projects: string[],
config: ContextConfig
): Observation[] {
const typeArray = Array.from(config.observationTypes);
const typePlaceholders = typeArray.map(() => '?').join(',');
const conceptArray = Array.from(config.observationConcepts);
const conceptPlaceholders = conceptArray.map(() => '?').join(',');
// Build IN clause for projects
const projectPlaceholders = projects.map(() => '?').join(',');
return db.db.prepare(`
SELECT
id, memory_session_id, type, title, subtitle, narrative,
facts, concepts, files_read, files_modified, discovery_tokens,
created_at, created_at_epoch, project
FROM observations
WHERE project IN (${projectPlaceholders})
AND type IN (${typePlaceholders})
AND EXISTS (
SELECT 1 FROM json_each(concepts)
WHERE value IN (${conceptPlaceholders})
)
ORDER BY created_at_epoch DESC
LIMIT ?
`).all(...projects, ...typeArray, ...conceptArray, config.totalObservationCount) as Observation[];
}
/**
* Query session summaries from multiple projects (for worktree support)
*
* Returns summaries from all specified projects, interleaved chronologically.
* Used when running in a worktree to show both parent repo and worktree summaries.
*/
export function querySummariesMulti(
db: SessionStore,
projects: string[],
config: ContextConfig
): SessionSummary[] {
// Build IN clause for projects
const projectPlaceholders = projects.map(() => '?').join(',');
return db.db.prepare(`
SELECT id, memory_session_id, request, investigated, learned, completed, next_steps, created_at, created_at_epoch, project
FROM session_summaries
WHERE project IN (${projectPlaceholders})
ORDER BY created_at_epoch DESC
LIMIT ?
`).all(...projects, config.sessionCount + SUMMARY_LOOKAHEAD) as SessionSummary[];
}
/**
* Convert cwd path to dashed format for transcript lookup
*/
@@ -0,0 +1,7 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
*No recent activity*
</claude-mem-context>
+26
View File
@@ -0,0 +1,26 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**FooterRenderer.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
| #36283 | 8:02 PM | 🔄 | Phase 4: FooterRenderer Extracted with Conditional Display Logic | ~464 |
**TimelineRenderer.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36292 | 8:04 PM | 🔄 | Phase 4 Module Inventory: 12 Files Created in Context Architecture | ~571 |
| #36281 | 8:01 PM | 🔄 | Phase 4: TimelineRenderer Extracted with Dual Format Support | ~531 |
### Jan 5, 2026
**FooterRenderer.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37545 | 4:47 PM | ✅ | Issue #544 Analysis Report Created for mem-search Skill Messaging Problem | ~480 |
</claude-mem-context>
@@ -93,7 +93,7 @@ export function renderDayTimeline(
}
} else {
const obs = item.data as Observation;
const file = extractFirstFile(obs.files_modified, cwd);
const file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
const time = formatTime(obs.created_at);
const showTime = time !== lastTime;
const timeDisplay = showTime ? time : '';
+6
View File
@@ -11,6 +11,8 @@ export interface ContextInput {
cwd?: string;
hook_event_name?: string;
source?: "startup" | "resume" | "clear" | "compact";
/** Array of projects to query (for worktree support: [parent, worktree]) */
projects?: string[];
[key: string]: any;
}
@@ -56,6 +58,8 @@ export interface Observation {
discovery_tokens: number | null;
created_at: string;
created_at_epoch: number;
/** Project this observation belongs to (for multi-project queries) */
project?: string;
}
/**
@@ -71,6 +75,8 @@ export interface SessionSummary {
next_steps: string | null;
created_at: string;
created_at_epoch: number;
/** Project this summary belongs to (for multi-project queries) */
project?: string;
}
/**
+127
View File
@@ -0,0 +1,127 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 21, 2025
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31766 | 11:11 PM | 🟣 | Expansión de ModePrompts con campos de configuración granular | ~327 |
| #31765 | 11:10 PM | 🔵 | Sistema de configuración de modos con interfaces TypeScript | ~321 |
| #31764 | 11:09 PM | ⚖️ | Consulta arquitectónica con Gemini sobre reconstrucción completa de prompts por modos | ~469 |
| #31704 | 9:37 PM | 🔵 | Mode system architecture discovered in claude-mem | ~457 |
| #31428 | 6:56 PM | 🔵 | Domain Types Define Observation System Interfaces | ~292 |
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31747 | 10:43 PM | 🔵 | PR #412 Code Review Identifies Two Critical Bugs in Mode System | ~545 |
| #31746 | 10:42 PM | 🔵 | PR #412 Documentation Audit Identifies Comment Quality Issues | ~535 |
| #31743 | 10:36 PM | 🔵 | PR #412 proposes mode system with inheritance and multilingual support | ~523 |
| #31739 | 10:28 PM | 🟣 | Mode Inheritance System with Parent-Override Pattern | ~373 |
| #31732 | 10:05 PM | 🟣 | Implemented mode inheritance system with parent-override pattern | ~430 |
| #31731 | " | 🟣 | Added deep merge infrastructure for mode inheritance | ~313 |
| #31729 | 9:55 PM | 🟣 | Mode Inheritance Parser Implementation | ~299 |
| #31728 | 9:54 PM | 🔵 | ModeManager System Architecture | ~314 |
| #31727 | " | ⚖️ | Mode Inheritance System for Multilingual Support | ~509 |
| #31725 | 9:51 PM | ⚖️ | Mode Inheritance System Architecture | ~509 |
| #31709 | 9:39 PM | 🔵 | Mode system architecture comprehensively documented | ~588 |
| #31697 | 9:24 PM | 🔵 | Root Cause Found: getPackageRoot() Returns Wrong Directory for ModeManager | ~399 |
| #31662 | 8:56 PM | 🔵 | ModeManager Path Resolution Dependency on getPackageRoot | ~361 |
| #31649 | 8:46 PM | 🟣 | ModeManager singleton implements dynamic mode profile loading | ~363 |
| #31446 | 7:22 PM | 🔵 | ModeManager Loading System Investigation | ~297 |
| #31445 | 7:21 PM | 🔵 | ModeManager Icon Resolution Methods | ~358 |
| #31427 | 6:56 PM | 🔵 | ModeManager Imports ObservationType and ObservationConcept Types | ~192 |
| #31422 | 6:50 PM | 🔵 | Observation Metadata Constants Usage Across Codebase | ~366 |
| #31407 | 6:26 PM | 🔵 | ModeManager provides observation type metadata access methods | ~283 |
### Dec 22, 2025
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31896 | 7:18 PM | ✅ | Commit amendé avec les nouveaux types pour support multilingue des résumés | ~290 |
| #31895 | " | 🟣 | Ajout de quatre champs de prompts de résumé à l'interface ModePrompts | ~347 |
| #31894 | " | 🔵 | Interface ModePrompts contient les placeholders XML pour résumés | ~354 |
| #31808 | 6:07 PM | 🟣 | Added customizable XML placeholder fields to ModePrompts interface | ~432 |
| #31804 | 4:53 PM | ⚖️ | Refined scope for prompt placeholder extraction to mode configuration | ~439 |
| #31803 | 4:52 PM | 🔵 | Explored prompt system architecture for placeholder customization | ~472 |
| #31800 | 4:51 PM | ⚖️ | Initiated design task to extract hardcoded placeholders into mode configuration | ~441 |
| #31797 | 4:49 PM | 🔵 | ModePrompts interface defines high-level prompt sections but not field placeholders | ~364 |
| #31793 | 4:41 PM | 🔵 | Completed comprehensive exploration of mode system architecture | ~525 |
| #31784 | 4:37 PM | 🔵 | Examined ModeConfig type definitions for prompt customization | ~317 |
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31790 | 4:39 PM | 🔵 | Identified files that interact with ModeManager and prompts | ~332 |
| #31785 | 4:37 PM | 🔵 | Examined ModeManager for mode loading and inheritance system | ~286 |
### Dec 23, 2025
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32033 | 7:50 PM | ⚖️ | Mode-to-Settings Auto-Sync Architecture Designed | ~583 |
| #32032 | 7:45 PM | 🔵 | Queue System Bug: Mode Loaded Once at Startup Prevents Processing | ~450 |
| #32026 | 7:39 PM | 🔵 | Email Investigation Mode Configuration Located | ~300 |
| #32025 | 7:35 PM | 🔵 | ModeManager Implementation with Inheritance System | ~474 |
### Dec 24, 2025
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32214 | 8:17 PM | 🔵 | ModeManager singleton handles mode profiles with inheritance support | ~483 |
### Dec 25, 2025
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32701 | 9:00 PM | 🔵 | Test Coverage Report Generated | ~471 |
| #32580 | 8:22 PM | 🔵 | Grep for resetStuckMessages and processing | ~242 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32558 | 8:18 PM | 🔵 | Identified files containing 'summary' or 'Summary' | ~167 |
### Dec 31, 2025
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34631 | 3:02 PM | 🟣 | Context-Preservation Workflow Design Documents Created | ~729 |
| #34610 | 2:58 PM | 🔵 | Mode Configuration System Architecture for Memory Agent Behavior | ~570 |
### Jan 1, 2026
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35433 | 8:43 PM | 🔵 | Try-Catch Block Distribution Across Services | ~372 |
### Jan 2, 2026
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
### Jan 3, 2026
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36539 | 9:39 PM | 🔵 | ModeManager Singleton Pattern with Inheritance | ~343 |
### Jan 5, 2026
**ModeManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37665 | 5:52 PM | 🔵 | Codebase uses dependency injection and lazy initialization patterns to avoid circular dependencies | ~548 |
</claude-mem-context>
+37
View File
@@ -0,0 +1,37 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 4, 2026
**FolderDiscovery.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37021 | 4:59 PM | ✅ | Deleted Redundant Folder Index Service Directory | ~299 |
| #37011 | 4:50 PM | 🔵 | FolderDiscovery extracts folders from observations and applies depth, exclusion, and activity filters | ~433 |
**ClaudeMdGenerator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37012 | 4:51 PM | 🔵 | ClaudeMdGenerator writes tag-wrapped timeline markdown while preserving manual content | ~446 |
| #36981 | 4:25 PM | 🔵 | ClaudeMdGenerator creates and updates CLAUDE.md files with timeline content | ~336 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37010 | 4:50 PM | 🔵 | Type definitions specify folder-index configuration schema and timeline data structures | ~349 |
**FolderTimelineCompiler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37009 | 4:50 PM | 🔵 | FolderTimelineCompiler queries database and groups activity chronologically by date | ~419 |
| #37002 | 4:45 PM | 🔴 | Fixed session file deduplication and summary selection in FolderTimelineCompiler | ~306 |
| #37001 | " | 🔴 | Fixed FolderTimelineCompiler to generate concise summaries and deduplicate files | ~284 |
**FolderIndexOrchestrator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37008 | 4:50 PM | 🔵 | FolderIndexOrchestrator implements event-driven regeneration triggered by observation saves | ~418 |
| #36983 | 4:26 PM | 🔵 | FolderIndexOrchestrator coordinates automatic CLAUDE.md regeneration after observation saves | ~367 |
</claude-mem-context>
+12
View File
@@ -0,0 +1,12 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 4, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36864 | 1:52 AM | 🔵 | ProcessManager Module Imports Reviewed | ~245 |
| #36860 | 1:50 AM | 🔵 | ProcessManager Source Code Reviewed for WMIC Implementation | ~608 |
</claude-mem-context>
+7
View File
@@ -0,0 +1,7 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
*No recent activity*
</claude-mem-context>
+60
View File
@@ -0,0 +1,60 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 28, 2025
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33396 | 9:53 PM | ✅ | Queue refactoring touched 12 files with net addition of 1021 lines | ~402 |
| #33395 | " | 🟣 | Queue system refactored with atomic message processing | ~487 |
| #33374 | 7:12 PM | 🟣 | Refactored Queue System with Atomic Message Claiming and In-Memory State Elimination | ~477 |
| #33384 | " | 🔵 | Confirmed `SessionQueueProcessor` Integration in `SessionManager` | ~289 |
| #33387 | " | ⚖️ | Formulated Plan to Address PR #470 Review Issues | ~441 |
### Dec 30, 2025
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34409 | 1:55 PM | 🔵 | SessionQueueProcessor Event-Driven Message Iteration | ~433 |
| #34391 | 1:40 PM | 🔵 | SessionQueueProcessor Respects Abort Signal But Only Stops Iterator Loop | ~382 |
### Jan 1, 2026
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35521 | 9:35 PM | 🔵 | Queue Processor Uses Database-Backed Message Store | ~316 |
| #35433 | 8:43 PM | 🔵 | Try-Catch Block Distribution Across Services | ~372 |
| #35432 | " | 🔵 | Services Directory Structure Mapped | ~268 |
### Jan 2, 2026
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
| #35887 | 2:47 PM | 🔵 | SessionQueueProcessor Has Error Recovery But Doesn't Mark Failed | ~353 |
| #35851 | 2:32 PM | 🔵 | Queue Processor Uses Atomic Claiming with Event-Driven Wake-Up | ~464 |
### Jan 3, 2026
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36343 | 8:29 PM | 🔄 | SessionQueueProcessor Updated to Use claimAndDelete | ~299 |
| #36340 | 8:28 PM | 🔵 | Complete Duplicate Bug Analysis via Explore Agent | ~435 |
| #36323 | 8:25 PM | 🔵 | Message Queue Architecture Scope Expanded | ~302 |
| #36314 | " | 🔵 | Message Queue Processing Duplicate Bug Investigation | ~316 |
### Jan 4, 2026
**SessionQueueProcessor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36713 | 12:11 AM | 🔵 | Issue #520 Stuck Messages Already Resolved | ~569 |
| #36711 | " | 🔵 | Issue #520 Stuck Messages Analysis - Already Resolved | ~526 |
</claude-mem-context>
+34
View File
@@ -0,0 +1,34 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**Server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36689 | 11:56 PM | 🔵 | PR #538 Review Findings - Modular Architecture Refactor | ~590 |
| #36583 | 9:57 PM | 🟣 | Server Test Suite Created | ~485 |
| #36427 | 8:59 PM | 🔵 | Server Class Architecture and Route Registration | ~447 |
**ErrorHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36581 | 9:57 PM | 🟣 | ErrorHandler Test Suite Created for Phase 6 | ~444 |
| #36454 | 9:03 PM | 🔵 | Centralized Express Error Handling | ~446 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**index.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36575 | 9:55 PM | 🔵 | Server Layer API Documentation for Phase 6 | ~521 |
### Jan 5, 2026
**Server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37758 | 6:25 PM | ⚖️ | Integration Test Design for Four Critical Testing Gaps | ~729 |
| #37533 | 4:44 PM | 🔵 | Windows IPC Detection Logic and Managed Mode Handling | ~427 |
</claude-mem-context>
+95
View File
@@ -0,0 +1,95 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 8, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22310 | 9:46 PM | 🟣 | Complete Hook Lifecycle Documentation Generated | ~603 |
| #22305 | 9:45 PM | 🔵 | Session Summary Storage and Status Lifecycle | ~472 |
| #22304 | " | 🔵 | Session Creation Idempotency and Observation Storage | ~481 |
| #22303 | " | 🔵 | SessionStore CRUD Operations for Hook Integration | ~392 |
| #22300 | 9:44 PM | 🔵 | SessionStore Database Management and Schema Migrations | ~455 |
| #22299 | " | 🔵 | Database Schema and Entity Types | ~460 |
| #21976 | 5:24 PM | 🟣 | storeObservation Saves tool_use_id to Database | ~298 |
### Dec 10, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23808 | 10:42 PM | 🔵 | migrations.ts Already Migrated to bun:sqlite | ~312 |
| #23807 | " | 🔵 | SessionSearch.ts Already Migrated to bun:sqlite | ~321 |
| #23805 | " | 🔵 | Database.ts Already Migrated to bun:sqlite | ~290 |
| #23784 | 9:59 PM | ✅ | SessionStore.ts db.pragma() Converted to db.query().all() Pattern | ~198 |
| #23783 | 9:58 PM | ✅ | SessionStore.ts Migration004 Multi-Statement db.exec() Converted to db.run() | ~220 |
| #23782 | " | ✅ | SessionStore.ts initializeSchema() db.exec() Converted to db.run() | ~197 |
| #23781 | " | ✅ | SessionStore.ts Constructor PRAGMA Calls Converted to db.run() | ~215 |
| #23780 | " | ✅ | SessionStore.ts Type Annotation Updated | ~183 |
| #23779 | " | ✅ | SessionStore.ts Import Updated to bun:sqlite | ~237 |
| #23778 | 9:57 PM | ✅ | Database.ts Import Updated to bun:sqlite | ~177 |
| #23777 | " | 🔵 | SessionStore.ts Current Implementation - better-sqlite3 Import and API Usage | ~415 |
| #23776 | " | 🔵 | migrations.ts Current Implementation - better-sqlite3 Import | ~285 |
| #23775 | " | 🔵 | Database.ts Current Implementation - better-sqlite3 Import | ~286 |
| #23774 | " | 🔵 | SessionSearch.ts Current Implementation - better-sqlite3 Import | ~309 |
| #23671 | 8:36 PM | 🔵 | getUserPromptsByIds Method Implementation with Filtering and Ordering | ~326 |
| #23670 | " | 🔵 | getUserPromptsByIds Method Location in SessionStore | ~145 |
| #23635 | 8:10 PM | 🔴 | Fixed SessionStore.ts Concepts Filter SQL Parameter Bug | ~297 |
| #23634 | " | 🔵 | SessionStore.ts Concepts Filter Bug Confirmed at Line 849 | ~356 |
| #23522 | 5:27 PM | 🔵 | Complete TypeScript Type Definitions for Database Entities | ~433 |
| #23521 | " | 🔵 | Database Schema Structure with 7 Migration Versions | ~461 |
### Dec 18, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29868 | 8:19 PM | 🔵 | SessionStore Architecture Review for Mode Metadata Addition | ~350 |
| #29243 | 12:13 AM | 🔵 | Observations Table Schema Migration: Text Field Made Nullable | ~496 |
| #29241 | 12:12 AM | 🔵 | Migration001: Core Schema for Sessions, Memories, Overviews, Diagnostics, Transcripts | ~555 |
| #29238 | 12:11 AM | 🔵 | Observation Type Schema Evolution: Five to Six Types | ~331 |
| #29237 | " | 🔵 | SQLite SessionStore with Schema Migrations and WAL Mode | ~520 |
### Dec 21, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31622 | 8:26 PM | 🔄 | Completed SessionStore logging standardization | ~270 |
| #31621 | " | 🔄 | Standardized error logging for boundary timestamps query | ~253 |
| #31620 | " | 🔄 | Standardized error logging in getTimelineAroundObservation | ~252 |
| #31619 | " | 🔄 | Replaced console.log with logger.debug in SessionStore | ~263 |
### Dec 27, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33213 | 9:04 PM | 🔵 | SessionStore Implements KISS Session ID Threading via INSERT OR IGNORE Pattern | ~673 |
### Dec 28, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33548 | 10:59 PM | ✅ | Reverted memory_session_id NULL Initialization to contentSessionId Placeholder | ~421 |
| #33546 | 10:57 PM | 🔴 | Fixed createSDKSession to Initialize memory_session_id as NULL | ~406 |
| #33545 | " | 🔵 | createSDKSession Sets memory_session_id Equal to content_session_id Initially | ~378 |
| #33544 | " | 🔵 | SessionStore Migration 17 Already Renamed Session ID Columns | ~451 |
### Jan 2, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36028 | 9:20 PM | 🔄 | Try-Catch Block Removed from Database Migration | ~291 |
### Jan 3, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36653 | 11:03 PM | 🔵 | storeObservation Method Signature Shows Parameter Named memorySessionId | ~474 |
| #36652 | " | 🔵 | createSDKSession Implementation Confirms NULL Initialization With Security Rationale | ~488 |
| #36650 | 11:02 PM | 🔵 | Phase 1 Analysis Reveals Implementation-Test Mismatch on NULL vs Placeholder Initialization | ~687 |
| #36649 | " | 🔵 | SessionStore Implementation Reveals NULL-Based Memory Session ID Initialization Pattern | ~770 |
| #36175 | 6:52 PM | ✅ | MigrationRunner Re-exported from Migrations.ts | ~405 |
| #36172 | " | 🔵 | Migrations.ts Contains Legacy Migration System | ~650 |
| #36163 | 6:48 PM | 🔵 | SessionStore Method Inventory and Extraction Boundaries | ~692 |
| #36162 | 6:47 PM | 🔵 | SessionStore Architecture and Migration History | ~593 |
</claude-mem-context>
@@ -96,6 +96,11 @@ export class PendingMessageStore {
// Delete immediately - no "processing" state needed
const deleteStmt = this.db.prepare('DELETE FROM pending_messages WHERE id = ?');
deleteStmt.run(msg.id);
// Log claim with minimal info (avoid logging full payload)
logger.info('QUEUE', `CLAIMED | sessionDbId=${sessionId} | messageId=${msg.id} | type=${msg.message_type}`, {
sessionId: sessionId
});
}
return msg;
});
+64 -5
View File
@@ -336,15 +336,64 @@ export class SessionSearch {
return this.db.prepare(sql).all(...params) as ObservationSearchResult[];
}
/**
* Check if a file is a direct child of a folder (not in a subfolder)
*/
private isDirectChild(filePath: string, folderPath: string): boolean {
if (!filePath.startsWith(folderPath + '/')) return false;
const remainder = filePath.slice(folderPath.length + 1);
return !remainder.includes('/');
}
/**
* Check if an observation has any files that are direct children of the folder
*/
private hasDirectChildFile(obs: ObservationSearchResult, folderPath: string): boolean {
const checkFiles = (filesJson: string | null): boolean => {
if (!filesJson) return false;
try {
const files = JSON.parse(filesJson);
if (Array.isArray(files)) {
return files.some(f => this.isDirectChild(f, folderPath));
}
} catch {}
return false;
};
return checkFiles(obs.files_modified) || checkFiles(obs.files_read);
}
/**
* Check if a session has any files that are direct children of the folder
*/
private hasDirectChildFileSession(session: SessionSummarySearchResult, folderPath: string): boolean {
const checkFiles = (filesJson: string | null): boolean => {
if (!filesJson) return false;
try {
const files = JSON.parse(filesJson);
if (Array.isArray(files)) {
return files.some(f => this.isDirectChild(f, folderPath));
}
} catch {}
return false;
};
return checkFiles(session.files_read) || checkFiles(session.files_edited);
}
/**
* Find observations and summaries by file path
* When isFolder=true, only returns results with files directly in the folder (not subfolders)
*/
findByFile(filePath: string, options: SearchOptions = {}): {
observations: ObservationSearchResult[];
sessions: SessionSummarySearchResult[];
} {
const params: any[] = [];
const { limit = 50, offset = 0, orderBy = 'date_desc', ...filters } = options;
const { limit = 50, offset = 0, orderBy = 'date_desc', isFolder = false, ...filters } = options;
// Query more results if we're filtering to direct children
const queryLimit = isFolder ? limit * 3 : limit;
// Add file to filters
const fileFilters = { ...filters, files: filePath };
@@ -359,9 +408,14 @@ export class SessionSearch {
LIMIT ? OFFSET ?
`;
params.push(limit, offset);
params.push(queryLimit, offset);
const observations = this.db.prepare(observationsSql).all(...params) as ObservationSearchResult[];
let observations = this.db.prepare(observationsSql).all(...params) as ObservationSearchResult[];
// Post-filter to direct children if isFolder mode
if (isFolder) {
observations = observations.filter(obs => this.hasDirectChildFile(obs, filePath)).slice(0, limit);
}
// For session summaries, search files_read and files_edited
const sessionParams: any[] = [];
@@ -403,9 +457,14 @@ export class SessionSearch {
LIMIT ? OFFSET ?
`;
sessionParams.push(limit, offset);
sessionParams.push(queryLimit, offset);
const sessions = this.db.prepare(sessionsSql).all(...sessionParams) as SessionSummarySearchResult[];
let sessions = this.db.prepare(sessionsSql).all(...sessionParams) as SessionSummarySearchResult[];
// Post-filter to direct children if isFolder mode
if (isFolder) {
sessions = sessions.filter(s => this.hasDirectChildFileSession(s, filePath)).slice(0, limit);
}
return { observations, sessions };
}
+21 -21
View File
@@ -152,7 +152,7 @@ export class SessionStore {
if (!hasWorkerPort) {
this.db.run('ALTER TABLE sdk_sessions ADD COLUMN worker_port INTEGER');
logger.info('DB', 'Added worker_port column to sdk_sessions table');
logger.debug('DB', 'Added worker_port column to sdk_sessions table');
}
// Record migration
@@ -173,7 +173,7 @@ export class SessionStore {
if (!hasPromptCounter) {
this.db.run('ALTER TABLE sdk_sessions ADD COLUMN prompt_counter INTEGER DEFAULT 0');
logger.info('DB', 'Added prompt_counter column to sdk_sessions table');
logger.debug('DB', 'Added prompt_counter column to sdk_sessions table');
}
// Check observations for prompt_number
@@ -182,7 +182,7 @@ export class SessionStore {
if (!obsHasPromptNumber) {
this.db.run('ALTER TABLE observations ADD COLUMN prompt_number INTEGER');
logger.info('DB', 'Added prompt_number column to observations table');
logger.debug('DB', 'Added prompt_number column to observations table');
}
// Check session_summaries for prompt_number
@@ -191,7 +191,7 @@ export class SessionStore {
if (!sumHasPromptNumber) {
this.db.run('ALTER TABLE session_summaries ADD COLUMN prompt_number INTEGER');
logger.info('DB', 'Added prompt_number column to session_summaries table');
logger.debug('DB', 'Added prompt_number column to session_summaries table');
}
// Record migration
@@ -216,7 +216,7 @@ export class SessionStore {
return;
}
logger.info('DB', 'Removing UNIQUE constraint from session_summaries.memory_session_id');
logger.debug('DB', 'Removing UNIQUE constraint from session_summaries.memory_session_id');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -270,7 +270,7 @@ export class SessionStore {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(7, new Date().toISOString());
logger.info('DB', 'Successfully removed UNIQUE constraint from session_summaries.memory_session_id');
logger.debug('DB', 'Successfully removed UNIQUE constraint from session_summaries.memory_session_id');
}
/**
@@ -291,7 +291,7 @@ export class SessionStore {
return;
}
logger.info('DB', 'Adding hierarchical fields to observations table');
logger.debug('DB', 'Adding hierarchical fields to observations table');
// Add new columns
this.db.run(`
@@ -307,7 +307,7 @@ export class SessionStore {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(8, new Date().toISOString());
logger.info('DB', 'Successfully added hierarchical fields to observations table');
logger.debug('DB', 'Successfully added hierarchical fields to observations table');
}
/**
@@ -329,7 +329,7 @@ export class SessionStore {
return;
}
logger.info('DB', 'Making observations.text nullable');
logger.debug('DB', 'Making observations.text nullable');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -385,7 +385,7 @@ export class SessionStore {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(9, new Date().toISOString());
logger.info('DB', 'Successfully made observations.text nullable');
logger.debug('DB', 'Successfully made observations.text nullable');
}
/**
@@ -404,7 +404,7 @@ export class SessionStore {
return;
}
logger.info('DB', 'Creating user_prompts table with FTS5 support');
logger.debug('DB', 'Creating user_prompts table with FTS5 support');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -462,7 +462,7 @@ export class SessionStore {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(10, new Date().toISOString());
logger.info('DB', 'Successfully created user_prompts table with FTS5 support');
logger.debug('DB', 'Successfully created user_prompts table with FTS5 support');
}
/**
@@ -481,7 +481,7 @@ export class SessionStore {
if (!obsHasDiscoveryTokens) {
this.db.run('ALTER TABLE observations ADD COLUMN discovery_tokens INTEGER DEFAULT 0');
logger.info('DB', 'Added discovery_tokens column to observations table');
logger.debug('DB', 'Added discovery_tokens column to observations table');
}
// Check if discovery_tokens column exists in session_summaries table
@@ -490,7 +490,7 @@ export class SessionStore {
if (!sumHasDiscoveryTokens) {
this.db.run('ALTER TABLE session_summaries ADD COLUMN discovery_tokens INTEGER DEFAULT 0');
logger.info('DB', 'Added discovery_tokens column to session_summaries table');
logger.debug('DB', 'Added discovery_tokens column to session_summaries table');
}
// Record migration only after successful column verification/addition
@@ -514,7 +514,7 @@ export class SessionStore {
return;
}
logger.info('DB', 'Creating pending_messages table');
logger.debug('DB', 'Creating pending_messages table');
this.db.run(`
CREATE TABLE pending_messages (
@@ -544,7 +544,7 @@ export class SessionStore {
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(16, new Date().toISOString());
logger.info('DB', 'pending_messages table created successfully');
logger.debug('DB', 'pending_messages table created successfully');
}
/**
@@ -559,7 +559,7 @@ export class SessionStore {
const applied = this.db.prepare('SELECT version FROM schema_versions WHERE version = ?').get(17) as SchemaVersion | undefined;
if (applied) return;
logger.info('DB', 'Checking session ID columns for semantic clarity rename');
logger.debug('DB', 'Checking session ID columns for semantic clarity rename');
let renamesPerformed = 0;
@@ -577,7 +577,7 @@ export class SessionStore {
if (hasOldCol) {
// SQLite 3.25+ supports ALTER TABLE RENAME COLUMN
this.db.run(`ALTER TABLE ${table} RENAME COLUMN ${oldCol} TO ${newCol}`);
logger.info('DB', `Renamed ${table}.${oldCol} to ${newCol}`);
logger.debug('DB', `Renamed ${table}.${oldCol} to ${newCol}`);
return true;
}
@@ -606,9 +606,9 @@ export class SessionStore {
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(17, new Date().toISOString());
if (renamesPerformed > 0) {
logger.info('DB', `Successfully renamed ${renamesPerformed} session ID columns`);
logger.debug('DB', `Successfully renamed ${renamesPerformed} session ID columns`);
} else {
logger.info('DB', 'No session ID column renames needed (already up to date)');
logger.debug('DB', 'No session ID column renames needed (already up to date)');
}
}
@@ -639,7 +639,7 @@ export class SessionStore {
if (!hasColumn) {
this.db.run('ALTER TABLE pending_messages ADD COLUMN failed_at_epoch INTEGER');
logger.info('DB', 'Added failed_at_epoch column to pending_messages table');
logger.debug('DB', 'Added failed_at_epoch column to pending_messages table');
}
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(20, new Date().toISOString());
+14
View File
@@ -0,0 +1,14 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**bulk.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36469 | 9:04 PM | 🔵 | Bulk Import with Duplicate Detection | ~451 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
</claude-mem-context>
+15
View File
@@ -0,0 +1,15 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**runner.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36487 | 9:13 PM | 🔴 | Fixed Foreign Key Constraint Issues in Observations Test Suite | ~677 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
| #36353 | 8:42 PM | 🔵 | Multiple observation table definitions found across codebase | ~280 |
| #36323 | 8:25 PM | 🔵 | Message Queue Architecture Scope Expanded | ~302 |
</claude-mem-context>
+21 -21
View File
@@ -136,7 +136,7 @@ export class MigrationRunner {
if (!hasWorkerPort) {
this.db.run('ALTER TABLE sdk_sessions ADD COLUMN worker_port INTEGER');
logger.info('DB', 'Added worker_port column to sdk_sessions table');
logger.debug('DB', 'Added worker_port column to sdk_sessions table');
}
// Record migration
@@ -157,7 +157,7 @@ export class MigrationRunner {
if (!hasPromptCounter) {
this.db.run('ALTER TABLE sdk_sessions ADD COLUMN prompt_counter INTEGER DEFAULT 0');
logger.info('DB', 'Added prompt_counter column to sdk_sessions table');
logger.debug('DB', 'Added prompt_counter column to sdk_sessions table');
}
// Check observations for prompt_number
@@ -166,7 +166,7 @@ export class MigrationRunner {
if (!obsHasPromptNumber) {
this.db.run('ALTER TABLE observations ADD COLUMN prompt_number INTEGER');
logger.info('DB', 'Added prompt_number column to observations table');
logger.debug('DB', 'Added prompt_number column to observations table');
}
// Check session_summaries for prompt_number
@@ -175,7 +175,7 @@ export class MigrationRunner {
if (!sumHasPromptNumber) {
this.db.run('ALTER TABLE session_summaries ADD COLUMN prompt_number INTEGER');
logger.info('DB', 'Added prompt_number column to session_summaries table');
logger.debug('DB', 'Added prompt_number column to session_summaries table');
}
// Record migration
@@ -200,7 +200,7 @@ export class MigrationRunner {
return;
}
logger.info('DB', 'Removing UNIQUE constraint from session_summaries.memory_session_id');
logger.debug('DB', 'Removing UNIQUE constraint from session_summaries.memory_session_id');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -254,7 +254,7 @@ export class MigrationRunner {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(7, new Date().toISOString());
logger.info('DB', 'Successfully removed UNIQUE constraint from session_summaries.memory_session_id');
logger.debug('DB', 'Successfully removed UNIQUE constraint from session_summaries.memory_session_id');
}
/**
@@ -275,7 +275,7 @@ export class MigrationRunner {
return;
}
logger.info('DB', 'Adding hierarchical fields to observations table');
logger.debug('DB', 'Adding hierarchical fields to observations table');
// Add new columns
this.db.run(`
@@ -291,7 +291,7 @@ export class MigrationRunner {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(8, new Date().toISOString());
logger.info('DB', 'Successfully added hierarchical fields to observations table');
logger.debug('DB', 'Successfully added hierarchical fields to observations table');
}
/**
@@ -313,7 +313,7 @@ export class MigrationRunner {
return;
}
logger.info('DB', 'Making observations.text nullable');
logger.debug('DB', 'Making observations.text nullable');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -369,7 +369,7 @@ export class MigrationRunner {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(9, new Date().toISOString());
logger.info('DB', 'Successfully made observations.text nullable');
logger.debug('DB', 'Successfully made observations.text nullable');
}
/**
@@ -388,7 +388,7 @@ export class MigrationRunner {
return;
}
logger.info('DB', 'Creating user_prompts table with FTS5 support');
logger.debug('DB', 'Creating user_prompts table with FTS5 support');
// Begin transaction
this.db.run('BEGIN TRANSACTION');
@@ -446,7 +446,7 @@ export class MigrationRunner {
// Record migration
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(10, new Date().toISOString());
logger.info('DB', 'Successfully created user_prompts table with FTS5 support');
logger.debug('DB', 'Successfully created user_prompts table with FTS5 support');
}
/**
@@ -465,7 +465,7 @@ export class MigrationRunner {
if (!obsHasDiscoveryTokens) {
this.db.run('ALTER TABLE observations ADD COLUMN discovery_tokens INTEGER DEFAULT 0');
logger.info('DB', 'Added discovery_tokens column to observations table');
logger.debug('DB', 'Added discovery_tokens column to observations table');
}
// Check if discovery_tokens column exists in session_summaries table
@@ -474,7 +474,7 @@ export class MigrationRunner {
if (!sumHasDiscoveryTokens) {
this.db.run('ALTER TABLE session_summaries ADD COLUMN discovery_tokens INTEGER DEFAULT 0');
logger.info('DB', 'Added discovery_tokens column to session_summaries table');
logger.debug('DB', 'Added discovery_tokens column to session_summaries table');
}
// Record migration only after successful column verification/addition
@@ -498,7 +498,7 @@ export class MigrationRunner {
return;
}
logger.info('DB', 'Creating pending_messages table');
logger.debug('DB', 'Creating pending_messages table');
this.db.run(`
CREATE TABLE pending_messages (
@@ -528,7 +528,7 @@ export class MigrationRunner {
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(16, new Date().toISOString());
logger.info('DB', 'pending_messages table created successfully');
logger.debug('DB', 'pending_messages table created successfully');
}
/**
@@ -543,7 +543,7 @@ export class MigrationRunner {
const applied = this.db.prepare('SELECT version FROM schema_versions WHERE version = ?').get(17) as SchemaVersion | undefined;
if (applied) return;
logger.info('DB', 'Checking session ID columns for semantic clarity rename');
logger.debug('DB', 'Checking session ID columns for semantic clarity rename');
let renamesPerformed = 0;
@@ -561,7 +561,7 @@ export class MigrationRunner {
if (hasOldCol) {
// SQLite 3.25+ supports ALTER TABLE RENAME COLUMN
this.db.run(`ALTER TABLE ${table} RENAME COLUMN ${oldCol} TO ${newCol}`);
logger.info('DB', `Renamed ${table}.${oldCol} to ${newCol}`);
logger.debug('DB', `Renamed ${table}.${oldCol} to ${newCol}`);
return true;
}
@@ -590,9 +590,9 @@ export class MigrationRunner {
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(17, new Date().toISOString());
if (renamesPerformed > 0) {
logger.info('DB', `Successfully renamed ${renamesPerformed} session ID columns`);
logger.debug('DB', `Successfully renamed ${renamesPerformed} session ID columns`);
} else {
logger.info('DB', 'No session ID column renames needed (already up to date)');
logger.debug('DB', 'No session ID column renames needed (already up to date)');
}
}
@@ -623,7 +623,7 @@ export class MigrationRunner {
if (!hasColumn) {
this.db.run('ALTER TABLE pending_messages ADD COLUMN failed_at_epoch INTEGER');
logger.info('DB', 'Added failed_at_epoch column to pending_messages table');
logger.debug('DB', 'Added failed_at_epoch column to pending_messages table');
}
this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(20, new Date().toISOString());
@@ -0,0 +1,33 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**files.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36453 | 9:02 PM | 🔵 | Session File Aggregation | ~384 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**store.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36483 | 9:11 PM | 🟣 | Observations Module Test Suite Implemented | ~716 |
| #36445 | 9:01 PM | 🔵 | Observation Storage with Timestamp Override | ~444 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36470 | 9:06 PM | 🔵 | SQLite Module API Documentation Verified for Test Implementation | ~765 |
| #36447 | 9:02 PM | 🔵 | Observation Type Definitions | ~459 |
### Jan 4, 2026
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36770 | 12:42 AM | 🔵 | Export Script Type Duplication Analysis Complete | ~555 |
</claude-mem-context>
+32
View File
@@ -0,0 +1,32 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**get.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36464 | 9:04 PM | 🔵 | User Prompt Retrieval Functions | ~471 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**store.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36485 | 9:12 PM | 🟣 | Prompts Module Test Suite Implemented | ~680 |
| #36466 | 9:04 PM | 🔵 | User Prompt Storage | ~363 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36470 | 9:06 PM | 🔵 | SQLite Module API Documentation Verified for Test Implementation | ~765 |
### Jan 4, 2026
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36770 | 12:42 AM | 🔵 | Export Script Type Duplication Analysis Complete | ~555 |
</claude-mem-context>
+32
View File
@@ -0,0 +1,32 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**create.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36482 | 9:10 PM | 🟣 | Sessions Module Test Suite Implemented | ~627 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36470 | 9:06 PM | 🔵 | SQLite Module API Documentation Verified for Test Implementation | ~765 |
| #36439 | 9:01 PM | 🔵 | Session Type Hierarchy | ~420 |
**get.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36438 | 9:01 PM | 🔵 | Session Retrieval Functions with Database-First Pattern | ~479 |
### Jan 4, 2026
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36770 | 12:42 AM | 🔵 | Export Script Type Duplication Analysis Complete | ~555 |
</claude-mem-context>
+32
View File
@@ -0,0 +1,32 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**get.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**store.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36484 | 9:11 PM | 🟣 | Summaries Module Test Suite Implemented | ~708 |
| #36461 | 9:03 PM | 🔵 | Summary Storage with Timestamp Override | ~439 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36470 | 9:06 PM | 🔵 | SQLite Module API Documentation Verified for Test Implementation | ~765 |
| #36457 | 9:03 PM | 🔵 | Summary Type Hierarchy | ~426 |
### Jan 4, 2026
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36770 | 12:42 AM | 🔵 | Export Script Type Duplication Analysis Complete | ~555 |
</claude-mem-context>
+12
View File
@@ -0,0 +1,12 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**queries.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
</claude-mem-context>
+2
View File
@@ -267,6 +267,8 @@ export interface SearchOptions extends SearchFilters {
limit?: number;
offset?: number;
orderBy?: 'relevance' | 'date_desc' | 'date_asc';
/** When true, treats filePath as a folder and only matches direct children (not descendants) */
isFolder?: boolean;
}
export interface ObservationSearchResult extends ObservationRow {
+133
View File
@@ -0,0 +1,133 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 21, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31745 | 10:42 PM | 🔵 | PR #412 Error Handling Audit Reveals Seven Silent Failure Patterns | ~529 |
| #31741 | 10:29 PM | 🟣 | Configurable Local Embedding Models with Multilingual Support | ~461 |
| #31738 | 10:26 PM | 🔵 | Configurable Embedding Models Already Implemented in Feature Branch | ~622 |
| #31737 | 10:23 PM | 🔵 | ChromaSync Embedding Architecture Investigation | ~582 |
| #31715 | 9:42 PM | 🔵 | Multilingual Embeddings Feature Branch Found | ~371 |
| #31591 | 8:11 PM | 🔄 | Phase 4 completed - Removed error hiding from utility files | ~441 |
### Dec 22, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31790 | 4:39 PM | 🔵 | Identified files that interact with ModeManager and prompts | ~332 |
### Dec 24, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32154 | 6:41 PM | 🔵 | ChromaSync Vector Database Architecture | ~558 |
| #32153 | 6:40 PM | 🔵 | Session Identifier Architecture Across Codebase | ~529 |
### Dec 25, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32558 | 8:18 PM | 🔵 | Identified files containing 'summary' or 'Summary' | ~167 |
### Dec 26, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32912 | 10:02 PM | 🔵 | Error handling uses consistent logger.error and logger.failure patterns throughout codebase | ~508 |
### Dec 27, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33245 | 9:53 PM | 🔵 | Chroma Collection Creation Fails Silently in Fire-and-Forget Backfill | ~355 |
| #33244 | " | 🔵 | Commit 63fd158 Removed Double JSON Serialization from SDKAgent | ~304 |
| #33242 | 9:52 PM | 🔵 | ChromaSync Double-JSON Pattern Intact - Regression Not From Code Changes | ~367 |
| #33241 | " | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~568 |
| #33240 | 9:51 PM | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~478 |
| #33239 | 9:50 PM | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~460 |
| #33238 | 9:49 PM | 🔵 | Chroma Vector Search Initialization Failure in DatabaseManager | ~446 |
| #33233 | 9:44 PM | 🔵 | Vector Search Unavailable in mem-search - Chroma Not Initialized | ~335 |
| #33225 | 9:37 PM | 🔵 | Worker Performance Barriers Analysis | ~415 |
| #33224 | 9:35 PM | 🔵 | Worker Performance Barriers: Timeouts and Rate Limiting | ~491 |
| #33082 | 6:45 PM | 🔵 | User directory path patterns in codebase | ~362 |
### Dec 28, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33439 | 10:15 PM | 🔄 | Extended Session ID Renaming to Additional Codebase Components | ~352 |
| #33322 | 3:09 PM | 🔵 | Worker Performance Bottlenecks Identified Across Multiple Subsystems | ~399 |
| #33299 | 3:08 PM | 🔵 | mem-search Regression Caused by Logger Error Serialization Bug | ~417 |
| #33292 | " | 🔄 | ChromaSync Lazy Initialization Replaces Startup Backfill | ~398 |
### Dec 29, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33860 | 4:35 PM | 🔵 | Comprehensive Bun integration architecture and platform-specific implementation details | ~619 |
| #33791 | 3:48 PM | 🔵 | ChromaSync.close() terminates subprocess via transport.close() | ~302 |
| #33786 | 3:47 PM | 🔵 | ChromaDB vector database synchronization architecture | ~535 |
| #33778 | 3:36 PM | 🔵 | ChromaSync spawns chroma-mcp subprocess via StdioClientTransport | ~419 |
### Dec 30, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34440 | 2:16 PM | 🔵 | TypeScript type errors identified across multiple components | ~328 |
### Jan 1, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35434 | 8:45 PM | 🔵 | Comprehensive Try-Catch Audit of Worker Service Error Handling | ~792 |
| #35433 | 8:43 PM | 🔵 | Try-Catch Block Distribution Across Services | ~372 |
| #35432 | " | 🔵 | Services Directory Structure Mapped | ~268 |
### Jan 2, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
| #35902 | 2:49 PM | 🔴 | Improved ChromaSync Error Logging | ~280 |
| #35901 | " | 🔵 | PR #525 File Changes Summary | ~376 |
| #35864 | 2:35 PM | 🔵 | Chroma Sync Methods Block on addDocuments Completion | ~441 |
| #35861 | 2:34 PM | 🔵 | ChromaSync Provides Vector Database Integration with Fail-Fast Design | ~476 |
| #35789 | 1:53 PM | ⚖️ | Error Logging Anti-Pattern Identified: Incomplete Error Information | ~404 |
| #35785 | 1:46 PM | 🔵 | Incomplete Error Logging Pattern in ChromaSync Collection Check | ~349 |
| #35783 | 1:45 PM | ⚖️ | Error Logging Anti-Pattern Identification Task | ~399 |
| #35775 | 1:24 PM | 🔵 | ensureConnection Call Sites in ChromaSync | ~309 |
| #35774 | " | 🔴 | Added Connection Error Detection in ensureCollection | ~342 |
| #35773 | " | 🔵 | ChromaSync Service Architecture and Connection Flow | ~420 |
| #35726 | 1:09 PM | ✅ | ChromaDB Error Handling Fix Committed to Bugfix Branch | ~314 |
| #35725 | " | 🔴 | ChromaDB Connection Error Handling Fixed | ~335 |
| #35724 | " | ✅ | Bugfix Branch Created with ChromaDB Connection Changes | ~303 |
### Jan 3, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36296 | 8:04 PM | 🔵 | TypeScript Compilation Check: Pre-Existing Errors Unrelated to Refactoring | ~621 |
### Jan 5, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37758 | 6:25 PM | ⚖️ | Integration Test Design for Four Critical Testing Gaps | ~729 |
</claude-mem-context>
+43 -10
View File
@@ -165,10 +165,24 @@ export class ChromaSync {
logger.debug('CHROMA_SYNC', 'Collection exists', { collection: this.collectionName });
} catch (error) {
// Log the FULL error - don't try to guess what type it is
logger.warn('CHROMA_SYNC', 'Collection check failed, attempting to create', { collection: this.collectionName }, error as Error);
// Check if this is a connection error - don't try to create collection
const errorMessage = error instanceof Error ? error.message : String(error);
const isConnectionError =
errorMessage.includes('Not connected') ||
errorMessage.includes('Connection closed') ||
errorMessage.includes('MCP error -32000');
// Try to create collection - if this also fails, we'll see that error too
if (isConnectionError) {
// Reset connection state so next call attempts reconnect
this.connected = false;
this.client = null;
logger.error('CHROMA_SYNC', 'Connection lost during collection check',
{ collection: this.collectionName }, error as Error);
throw new Error(`Chroma connection lost: ${errorMessage}`);
}
// Only attempt creation if it's genuinely a "collection not found" error
logger.warn('CHROMA_SYNC', 'Collection check failed, attempting to create', { collection: this.collectionName }, error as Error);
logger.info('CHROMA_SYNC', 'Creating collection', { collection: this.collectionName });
try {
@@ -642,7 +656,7 @@ export class ChromaSync {
const batch = allDocs.slice(i, i + this.BATCH_SIZE);
await this.addDocuments(batch);
logger.info('CHROMA_SYNC', 'Backfill progress', {
logger.debug('CHROMA_SYNC', 'Backfill progress', {
project: this.project,
progress: `${Math.min(i + this.BATCH_SIZE, allDocs.length)}/${allDocs.length}`
});
@@ -683,7 +697,7 @@ export class ChromaSync {
const batch = summaryDocs.slice(i, i + this.BATCH_SIZE);
await this.addDocuments(batch);
logger.info('CHROMA_SYNC', 'Backfill progress', {
logger.debug('CHROMA_SYNC', 'Backfill progress', {
project: this.project,
progress: `${Math.min(i + this.BATCH_SIZE, summaryDocs.length)}/${summaryDocs.length}`
});
@@ -732,7 +746,7 @@ export class ChromaSync {
const batch = promptDocs.slice(i, i + this.BATCH_SIZE);
await this.addDocuments(batch);
logger.info('CHROMA_SYNC', 'Backfill progress', {
logger.debug('CHROMA_SYNC', 'Backfill progress', {
project: this.project,
progress: `${Math.min(i + this.BATCH_SIZE, promptDocs.length)}/${promptDocs.length}`
});
@@ -788,10 +802,29 @@ export class ChromaSync {
where: whereStringified
};
const result = await this.client.callTool({
name: 'chroma_query_documents',
arguments: arguments_obj
});
let result;
try {
result = await this.client.callTool({
name: 'chroma_query_documents',
arguments: arguments_obj
});
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
const isConnectionError =
errorMessage.includes('Not connected') ||
errorMessage.includes('Connection closed') ||
errorMessage.includes('MCP error -32000');
if (isConnectionError) {
// Reset connection state so next call attempts reconnect
this.connected = false;
this.client = null;
logger.error('CHROMA_SYNC', 'Connection lost during query',
{ project: this.project, query }, error as Error);
throw new Error(`Chroma query failed - connection lost: ${errorMessage}`);
}
throw error;
}
const resultText = logger.happyPathError(
'CHROMA',
+125
View File
@@ -0,0 +1,125 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 10, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23673 | 8:36 PM | ✅ | Add Project Filter Parameter to Session and Prompt Hydration in Search | ~306 |
| #23596 | 5:54 PM | ⚖️ | Import/Export Bug Fix Priority and Scope | ~415 |
| #23595 | 5:53 PM | 🔴 | SearchManager Returns Wrong Format for Empty Results | ~320 |
| #23594 | " | 🔵 | SearchManager Search Method Control Flow | ~313 |
| #23591 | 5:51 PM | 🔵 | SearchManager JSON Response Structure | ~231 |
| #23590 | " | 🔵 | Import/Export Feature Status Review | ~490 |
| #23583 | 5:50 PM | 🔵 | SearchManager Hybrid Search Architecture | ~495 |
### Dec 13, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #25191 | 8:04 PM | 🔵 | ChromaSync Instantiated in DatabaseManager Constructor | ~315 |
### Dec 14, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #26263 | 8:32 PM | 🔵 | SearchManager Timeline Methods Use Rich Formatting, Search Method Uses Flat Tables | ~464 |
| #26243 | 8:29 PM | 🔵 | FormattingService Provides Basic Table Format Without Dates or File Grouping | ~390 |
| #26240 | " | 🔵 | SearchManager Formats Results as Tables, Timeline Uses Rich Date-Grouped Format | ~416 |
| #26108 | 7:43 PM | ✅ | changes() Method Format Logic Removed | ~401 |
| #26107 | " | ✅ | changes() Method Format Parameter Removed | ~317 |
| #26106 | 7:42 PM | ✅ | decisions() Method Format Logic Removed | ~405 |
| #26105 | " | ✅ | decisions() Method Format Parameter Removed | ~310 |
| #26104 | " | ✅ | Main search() Method Format Handling Removed | ~430 |
| #26103 | 7:41 PM | ✅ | FormattingService.ts Rewritten to Table Format | ~457 |
| #26102 | " | 🔵 | SearchManager.ts Format Parameter Removal Status | ~478 |
### Dec 15, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27043 | 6:04 PM | 🔵 | Subagent confirms no version switcher UI exists, only orphaned backend infrastructure | ~539 |
| #27041 | 6:03 PM | 🔵 | Branch switching code isolated to two backend files, no frontend UI components | ~473 |
| #27037 | 6:02 PM | 🔵 | Branch switching functionality exists in SettingsRoutes with UI switcher removal intent | ~463 |
### Dec 16, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27727 | 5:45 PM | 🔵 | SearchManager returns raw data arrays when format=json is specified | ~349 |
### Dec 17, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #28473 | 4:25 PM | 🔵 | PaginationHelper LIMIT+1 Trick and Project Path Sanitization | ~499 |
| #28458 | 4:24 PM | 🔵 | SDK Agent Observer-Only Event-Driven Query Loop | ~513 |
| #28455 | " | 🔵 | Event-Driven Session Manager with Zero-Latency Queuing | ~566 |
### Dec 18, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29240 | 12:12 AM | 🔵 | SDK Agent Event-Driven Query Loop with Tool Restrictions | ~507 |
### Dec 20, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31100 | 8:01 PM | 🔵 | Summary and Memory Message Generation in SDK Agent | ~324 |
### Dec 25, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32616 | 8:43 PM | 🔵 | Comprehensive analysis of "enable billing" setting and its impact on rate limiting | ~533 |
| #32599 | 8:40 PM | 🔄 | Added validation and explicit default for Gemini model configuration | ~393 |
| #32598 | " | 🔵 | Gemini configuration loaded from settings or environment variables | ~363 |
| #32591 | 8:38 PM | 🔴 | Removed Unsupported Gemini Model from Agent | ~282 |
| #32583 | " | 🔵 | Gemini Agent Implementation Details | ~434 |
| #32543 | 7:29 PM | 🔄 | Rate limiting applied conditionally based on billing status | ~164 |
| #32542 | " | 🔄 | Query Gemini now accepts billing status | ~163 |
| #32541 | " | 🔄 | Gemini config now includes billing status | ~182 |
| #32540 | " | 🔄 | Rate limiting logic refactored for Gemini billing | ~164 |
### Dec 26, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32949 | 10:55 PM | 🔵 | Complete settings persistence flow for Xiaomi MIMO v2 Flash model | ~320 |
| #32948 | 10:53 PM | 🔵 | OpenRouterAgent uses CLAUDE_MEM_OPENROUTER_MODEL setting with Xiaomi as default | ~183 |
### Dec 27, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33215 | 9:06 PM | 🔵 | SessionManager Implements Event-Driven Lifecycle with Database-First Persistence and Auto-Initialization | ~853 |
| #33214 | " | 🔵 | SDKAgent Implements Event-Driven Query Loop with Init/Continuation Prompt Selection | ~769 |
### Dec 28, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33551 | 11:00 PM | 🔵 | GeminiAgent Does Not Implement Resume Functionality | ~307 |
| #33550 | " | 🔵 | OpenRouterAgent Does Not Implement Resume Functionality | ~294 |
| #33549 | 10:59 PM | 🔴 | SDKAgent Now Checks memorySessionId Differs From contentSessionId Before Resume | ~419 |
| #33547 | " | 🔵 | All Agents Call storeObservation with contentSessionId Instead of memorySessionId | ~407 |
| #33543 | 10:56 PM | 🔵 | SDKAgent Already Implements Memory Session ID Capture and Resume Logic | ~467 |
| #33542 | " | 🔵 | SessionManager Already Uses Renamed Session ID Fields | ~390 |
### Dec 30, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34504 | 2:31 PM | 🔵 | SDKAgent V2 Message Handling and Processing Flow Detailed | ~583 |
| #34459 | 2:23 PM | 🔵 | Complete SDKAgent V2 Architecture with Comprehensive Message Processing | ~619 |
| #34453 | 2:21 PM | 🔵 | Memory Agent Configured as Observer-Only | ~379 |
### Jan 4, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36853 | 1:49 AM | 🔵 | GeminiAgent Implementation Reviewed for Model Support | ~555 |
</claude-mem-context>
+11 -2
View File
@@ -173,7 +173,14 @@ export class GeminiAgent {
}
// Process pending messages
// Track cwd from messages for CLAUDE.md generation
let lastCwd: string | undefined;
for await (const message of this.sessionManager.getMessageIterator(session.sessionDbId)) {
// Capture cwd from each message for worktree support
if (message.cwd) {
lastCwd = message.cwd;
}
// Capture earliest timestamp BEFORE processing (will be cleared after)
// This ensures backlog messages get their original timestamps, not current time
const originalTimestamp = session.earliestPendingTimestamp;
@@ -217,7 +224,8 @@ export class GeminiAgent {
worker,
tokensUsed,
originalTimestamp,
'Gemini'
'Gemini',
lastCwd
);
} else if (message.type === 'summarize') {
@@ -253,7 +261,8 @@ export class GeminiAgent {
worker,
tokensUsed,
originalTimestamp,
'Gemini'
'Gemini',
lastCwd
);
}
}
+13 -3
View File
@@ -121,7 +121,8 @@ export class OpenRouterAgent {
worker,
tokensUsed,
null,
'OpenRouter'
'OpenRouter',
undefined // No lastCwd yet - before message processing
);
} else {
logger.warn('SDK', 'Empty OpenRouter init response - session may lack context', {
@@ -130,8 +131,15 @@ export class OpenRouterAgent {
});
}
// Track lastCwd from messages for CLAUDE.md generation
let lastCwd: string | undefined;
// Process pending messages
for await (const message of this.sessionManager.getMessageIterator(session.sessionDbId)) {
// Capture cwd from messages for proper worktree support
if (message.cwd) {
lastCwd = message.cwd;
}
// Capture earliest timestamp BEFORE processing (will be cleared after)
const originalTimestamp = session.earliestPendingTimestamp;
@@ -174,7 +182,8 @@ export class OpenRouterAgent {
worker,
tokensUsed,
originalTimestamp,
'OpenRouter'
'OpenRouter',
lastCwd
);
} else if (message.type === 'summarize') {
@@ -210,7 +219,8 @@ export class OpenRouterAgent {
worker,
tokensUsed,
originalTimestamp,
'OpenRouter'
'OpenRouter',
lastCwd
);
}
}
+51 -14
View File
@@ -39,6 +39,10 @@ export class SDKAgent {
* @param worker WorkerService reference for spinner control (optional)
*/
async startSession(session: ActiveSession, worker?: WorkerRef): Promise<void> {
// Track cwd from messages for CLAUDE.md generation (worktree support)
// Uses mutable object so generator updates are visible in response processing
const cwdTracker = { lastCwd: undefined as string | undefined };
// Find Claude executable
const claudePath = this.findClaudeExecutable();
@@ -61,10 +65,13 @@ export class SDKAgent {
];
// Create message generator (event-driven)
const messageGenerator = this.createMessageGenerator(session);
const messageGenerator = this.createMessageGenerator(session, cwdTracker);
// CRITICAL: Only resume if memorySessionId exists (was captured from a previous SDK response).
// memorySessionId starts as NULL and is captured on first SDK message.
// CRITICAL: Only resume if:
// 1. memorySessionId exists (was captured from a previous SDK response)
// 2. lastPromptNumber > 1 (this is a continuation within the same SDK session)
// On worker restart or crash recovery, memorySessionId may exist from a previous
// SDK session but we must NOT resume because the SDK context was lost.
// NEVER use contentSessionId for resume - that would inject messages into the user's transcript!
const hasRealMemorySessionId = !!session.memorySessionId;
@@ -77,11 +84,17 @@ export class SDKAgent {
lastPromptNumber: session.lastPromptNumber
});
// SESSION ALIGNMENT LOG: Resume decision proof - show if we're resuming with correct memorySessionId
// Debug-level alignment logs for detailed tracing
if (session.lastPromptNumber > 1) {
logger.info('SDK', `[ALIGNMENT] Resume Decision | contentSessionId=${session.contentSessionId} | memorySessionId=${session.memorySessionId} | prompt#=${session.lastPromptNumber} | hasRealMemorySessionId=${hasRealMemorySessionId} | resumeWith=${hasRealMemorySessionId ? session.memorySessionId : 'NONE (fresh SDK session)'}`);
const willResume = hasRealMemorySessionId;
logger.debug('SDK', `[ALIGNMENT] Resume Decision | contentSessionId=${session.contentSessionId} | memorySessionId=${session.memorySessionId} | prompt#=${session.lastPromptNumber} | hasRealMemorySessionId=${hasRealMemorySessionId} | willResume=${willResume} | resumeWith=${willResume ? session.memorySessionId : 'NONE'}`);
} else {
logger.info('SDK', `[ALIGNMENT] First Prompt | contentSessionId=${session.contentSessionId} | prompt#=${session.lastPromptNumber} | Will capture memorySessionId from first SDK response`);
// INIT prompt - never resume even if memorySessionId exists (stale from previous session)
const hasStaleMemoryId = hasRealMemorySessionId;
logger.debug('SDK', `[ALIGNMENT] First Prompt (INIT) | contentSessionId=${session.contentSessionId} | prompt#=${session.lastPromptNumber} | hasStaleMemoryId=${hasStaleMemoryId} | action=START_FRESH | Will capture new memorySessionId from SDK response`);
if (hasStaleMemoryId) {
logger.warn('SDK', `Skipping resume for INIT prompt despite existing memorySessionId=${session.memorySessionId} - SDK context was lost (worker restart or crash recovery)`);
}
}
// Run Agent SDK query loop
@@ -90,8 +103,10 @@ export class SDKAgent {
prompt: messageGenerator,
options: {
model: modelId,
// Resume with captured memorySessionId (null on first prompt, real ID on subsequent)
...(hasRealMemorySessionId && { resume: session.memorySessionId }),
// Only resume if BOTH: (1) we have a memorySessionId AND (2) this isn't the first prompt
// On worker restart, memorySessionId may exist from a previous SDK session but we
// need to start fresh since the SDK context was lost
...(hasRealMemorySessionId && session.lastPromptNumber > 1 && { resume: session.memorySessionId }),
disallowedTools,
abortController: session.abortController,
pathToClaudeCodeExecutable: claudePath
@@ -109,12 +124,20 @@ export class SDKAgent {
session.sessionDbId,
message.session_id
);
logger.info('SDK', 'Captured memory session ID', {
sessionDbId: session.sessionDbId,
// Verify the update by reading back from DB
const verification = this.dbManager.getSessionStore().getSessionById(session.sessionDbId);
const dbVerified = verification?.memory_session_id === message.session_id;
logger.info('SESSION', `MEMORY_ID_CAPTURED | sessionDbId=${session.sessionDbId} | memorySessionId=${message.session_id} | dbVerified=${dbVerified}`, {
sessionId: session.sessionDbId,
memorySessionId: message.session_id
});
// SESSION ALIGNMENT LOG: Memory session ID captured - now contentSessionId→memorySessionId mapping is complete
logger.info('SDK', `[ALIGNMENT] Captured | contentSessionId=${session.contentSessionId} → memorySessionId=${message.session_id} | Future prompts will resume with this ID`);
if (!dbVerified) {
logger.error('SESSION', `MEMORY_ID_MISMATCH | sessionDbId=${session.sessionDbId} | expected=${message.session_id} | got=${verification?.memory_session_id}`, {
sessionId: session.sessionDbId
});
}
// Debug-level alignment log for detailed tracing
logger.debug('SDK', `[ALIGNMENT] Captured | contentSessionId=${session.contentSessionId} → memorySessionId=${message.session_id} | Future prompts will resume with this ID`);
}
// Handle assistant messages
@@ -177,7 +200,8 @@ export class SDKAgent {
worker,
discoveryTokens,
originalTimestamp,
'SDK'
'SDK',
cwdTracker.lastCwd
);
}
@@ -224,8 +248,16 @@ export class SDKAgent {
* - Each user message is added to session.conversationHistory
* - This allows provider switching (ClaudeGemini) with full context
* - SDK manages its own internal state, but we mirror it for interop
*
* CWD TRACKING:
* - cwdTracker is a mutable object shared with startSession
* - As messages with cwd are processed, cwdTracker.lastCwd is updated
* - This enables processAgentResponse to use the correct cwd for CLAUDE.md
*/
private async *createMessageGenerator(session: ActiveSession): AsyncIterableIterator<SDKUserMessage> {
private async *createMessageGenerator(
session: ActiveSession,
cwdTracker: { lastCwd: string | undefined }
): AsyncIterableIterator<SDKUserMessage> {
// Load active mode
const mode = ModeManager.getInstance().getActiveMode();
@@ -261,6 +293,11 @@ export class SDKAgent {
// Consume pending messages from SessionManager (event-driven, no polling)
for await (const message of this.sessionManager.getMessageIterator(session.sessionDbId)) {
// Capture cwd from each message for worktree support
if (message.cwd) {
cwdTracker.lastCwd = message.cwd;
}
if (message.type === 'observation') {
// Update last prompt number
if (message.prompt_number !== undefined) {
+65 -17
View File
@@ -71,6 +71,12 @@ export class SearchManager {
private normalizeParams(args: any): any {
const normalized: any = { ...args };
// Map filePath to files (API uses filePath, internal uses files)
if (normalized.filePath && !normalized.files) {
normalized.files = normalized.filePath;
delete normalized.filePath;
}
// Parse comma-separated concepts into array
if (normalized.concepts && typeof normalized.concepts === 'string') {
normalized.concepts = normalized.concepts.split(',').map((s: string) => s.trim()).filter(Boolean);
@@ -101,6 +107,13 @@ export class SearchManager {
delete normalized.dateEnd;
}
// Parse isFolder boolean from string
if (normalized.isFolder === 'true') {
normalized.isFolder = true;
} else if (normalized.isFolder === 'false') {
normalized.isFolder = false;
}
return normalized;
}
@@ -301,7 +314,7 @@ export class SearchManager {
for (const result of dayResults) {
let file = 'General';
if (result.type === 'observation') {
file = extractFirstFile(result.data.files_modified, cwd);
file = extractFirstFile(result.data.files_modified, cwd, result.data.files_read);
}
if (!resultsByFile.has(file)) {
resultsByFile.set(file, []);
@@ -577,7 +590,7 @@ export class SearchManager {
lines.push('');
} else if (item.type === 'observation') {
const obs = item.data as ObservationSearchResult;
const file = extractFirstFile(obs.files_modified, cwd);
const file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
if (file !== currentFile) {
if (tableOpen) {
@@ -1079,7 +1092,9 @@ export class SearchManager {
*/
async findByFile(args: any): Promise<any> {
const normalized = this.normalizeParams(args);
const { files: filePath, ...filters } = normalized;
const { files: rawFilePath, ...filters } = normalized;
// Handle both string and array (normalizeParams may split on comma)
const filePath = Array.isArray(rawFilePath) ? rawFilePath[0] : rawFilePath;
let observations: ObservationSearchResult[] = [];
let sessions: SessionSummarySearchResult[] = [];
@@ -1138,24 +1153,57 @@ export class SearchManager {
};
}
// Format as table
const header = `Found ${totalResults} result(s) for file "${filePath}"\n\n${this.formatter.formatTableHeader()}`;
const formattedResults: string[] = [];
// Combine observations and sessions with timestamps for date grouping
const combined: Array<{
type: 'observation' | 'session';
data: ObservationSearchResult | SessionSummarySearchResult;
epoch: number;
created_at: string;
}> = [
...observations.map(obs => ({
type: 'observation' as const,
data: obs,
epoch: obs.created_at_epoch,
created_at: obs.created_at
})),
...sessions.map(sess => ({
type: 'session' as const,
data: sess,
epoch: sess.created_at_epoch,
created_at: sess.created_at
}))
];
// Add observations
observations.forEach((obs, i) => {
formattedResults.push(this.formatter.formatObservationIndex(obs, i));
});
// Sort by date (most recent first)
combined.sort((a, b) => b.epoch - a.epoch);
// Add sessions
sessions.forEach((session, i) => {
formattedResults.push(this.formatter.formatSessionIndex(session, i + observations.length));
});
// Group by date for proper timeline rendering
const resultsByDate = groupByDate(combined, item => item.created_at);
// Format with date headers for proper date parsing by folder CLAUDE.md generator
const lines: string[] = [];
lines.push(`Found ${totalResults} result(s) for file "${filePath}"`);
lines.push('');
for (const [day, dayResults] of resultsByDate) {
lines.push(`### ${day}`);
lines.push('');
lines.push(this.formatter.formatTableHeader());
for (const result of dayResults) {
if (result.type === 'observation') {
lines.push(this.formatter.formatObservationIndex(result.data as ObservationSearchResult, 0));
} else {
lines.push(this.formatter.formatSessionIndex(result.data as SessionSummarySearchResult, 0));
}
}
lines.push('');
}
return {
content: [{
type: 'text' as const,
text: header + '\n' + formattedResults.join('\n')
text: lines.join('\n')
}]
};
}
@@ -1519,7 +1567,7 @@ export class SearchManager {
} else if (item.type === 'observation') {
// Render observation in table
const obs = item.data as ObservationSearchResult;
const file = extractFirstFile(obs.files_modified, cwd);
const file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
// Check if we need a new file section
if (file !== currentFile) {
@@ -1749,7 +1797,7 @@ export class SearchManager {
} else if (item.type === 'observation') {
// Render observation in table
const obs = item.data as ObservationSearchResult;
const file = extractFirstFile(obs.files_modified, cwd);
const file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
// Check if we need a new file section
if (file !== currentFile) {
+11 -25
View File
@@ -48,7 +48,7 @@ export class SessionManager {
* Initialize a new session or return existing one
*/
initializeSession(sessionDbId: number, currentUserPrompt?: string, promptNumber?: number): ActiveSession {
logger.info('SESSION', 'initializeSession called', {
logger.debug('SESSION', 'initializeSession called', {
sessionDbId,
promptNumber,
has_currentUserPrompt: !!currentUserPrompt
@@ -57,7 +57,7 @@ export class SessionManager {
// Check if already active
let session = this.sessions.get(sessionDbId);
if (session) {
logger.info('SESSION', 'Returning cached session', {
logger.debug('SESSION', 'Returning cached session', {
sessionDbId,
contentSessionId: session.contentSessionId,
lastPromptNumber: session.lastPromptNumber
@@ -99,7 +99,7 @@ export class SessionManager {
// Fetch from database
const dbSession = this.dbManager.getSessionById(sessionDbId);
logger.info('SESSION', 'Fetched session from database', {
logger.debug('SESSION', 'Fetched session from database', {
sessionDbId,
content_session_id: dbSession.content_session_id,
memory_session_id: dbSession.memory_session_id
@@ -142,7 +142,7 @@ export class SessionManager {
currentProvider: null // Will be set when generator starts
};
logger.info('SESSION', 'Creating new session object', {
logger.debug('SESSION', 'Creating new session object', {
sessionDbId,
contentSessionId: dbSession.content_session_id,
memorySessionId: dbSession.memory_session_id || '(none - fresh session)',
@@ -199,10 +199,10 @@ export class SessionManager {
try {
const messageId = this.getPendingStore().enqueue(sessionDbId, session.contentSessionId, message);
logger.debug('SESSION', `Observation persisted to DB`, {
sessionId: sessionDbId,
messageId,
tool: data.tool_name
const queueDepth = this.getPendingStore().getPendingCount(sessionDbId);
const toolSummary = logger.formatTool(data.tool_name, data.tool_input);
logger.info('QUEUE', `ENQUEUED | sessionDbId=${sessionDbId} | messageId=${messageId} | type=observation | tool=${toolSummary} | depth=${queueDepth}`, {
sessionId: sessionDbId
});
} catch (error) {
logger.error('SESSION', 'Failed to persist observation to DB', {
@@ -215,15 +215,6 @@ export class SessionManager {
// Notify generator immediately (zero latency)
const emitter = this.sessionQueues.get(sessionDbId);
emitter?.emit('message');
// Format tool name for logging
const toolSummary = logger.formatTool(data.tool_name, data.tool_input);
logger.info('SESSION', `Observation queued`, {
sessionId: sessionDbId,
tool: toolSummary,
hasGenerator: !!session.generatorPromise
});
}
/**
@@ -248,9 +239,9 @@ export class SessionManager {
try {
const messageId = this.getPendingStore().enqueue(sessionDbId, session.contentSessionId, message);
logger.debug('SESSION', `Summarize persisted to DB`, {
sessionId: sessionDbId,
messageId
const queueDepth = this.getPendingStore().getPendingCount(sessionDbId);
logger.info('QUEUE', `ENQUEUED | sessionDbId=${sessionDbId} | messageId=${messageId} | type=summarize | depth=${queueDepth}`, {
sessionId: sessionDbId
});
} catch (error) {
logger.error('SESSION', 'Failed to persist summarize to DB', {
@@ -261,11 +252,6 @@ export class SessionManager {
const emitter = this.sessionQueues.get(sessionDbId);
emitter?.emit('message');
logger.info('SESSION', `Summarize queued`, {
sessionId: sessionDbId,
hasGenerator: !!session.generatorPromise
});
}
/**
+7
View File
@@ -0,0 +1,7 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
*No recent activity*
</claude-mem-context>
@@ -14,6 +14,7 @@
import { logger } from '../../../utils/logger.js';
import { parseObservations, parseSummary, type ParsedObservation, type ParsedSummary } from '../../../sdk/parser.js';
import { updateCursorContextForProject } from '../../worker-service.js';
import { updateFolderClaudeMdFiles } from '../../../utils/claude-md-utils.js';
import { getWorkerPort } from '../../../shared/worker-utils.js';
import type { ActiveSession } from '../../worker-types.js';
import type { DatabaseManager } from '../DatabaseManager.js';
@@ -50,7 +51,8 @@ export async function processAgentResponse(
worker: WorkerRef | undefined,
discoveryTokens: number,
originalTimestamp: number | null,
agentName: string
agentName: string,
projectRoot?: string
): Promise<void> {
// Add assistant response to shared conversation history for provider interop
if (text) {
@@ -72,6 +74,12 @@ export async function processAgentResponse(
throw new Error('Cannot store observations: memorySessionId not yet captured');
}
// Log pre-storage with session ID chain for verification
logger.info('DB', `STORING | sessionDbId=${session.sessionDbId} | memorySessionId=${session.memorySessionId} | obsCount=${observations.length} | hasSummary=${!!summaryForStore}`, {
sessionId: session.sessionDbId,
memorySessionId: session.memorySessionId
});
// ATOMIC TRANSACTION: Store observations + summary ONCE
// Messages are already deleted from queue on claim, so no completion tracking needed
const result = sessionStore.storeObservations(
@@ -84,12 +92,10 @@ export async function processAgentResponse(
originalTimestamp ?? undefined
);
// Log what was saved
logger.info('SDK', `${agentName} observations and summary saved atomically`, {
// Log storage result with IDs for end-to-end traceability
logger.info('DB', `STORED | sessionDbId=${session.sessionDbId} | memorySessionId=${session.memorySessionId} | obsCount=${result.observationIds.length} | obsIds=[${result.observationIds.join(',')}] | summaryId=${result.summaryId || 'none'}`, {
sessionId: session.sessionDbId,
observationCount: result.observationIds.length,
hasSummary: !!result.summaryId,
atomicTransaction: true
memorySessionId: session.memorySessionId
});
// AFTER transaction commits - async operations (can fail safely without data loss)
@@ -100,7 +106,8 @@ export async function processAgentResponse(
dbManager,
worker,
discoveryTokens,
agentName
agentName,
projectRoot
);
// Sync and broadcast summary if present
@@ -152,7 +159,8 @@ async function syncAndBroadcastObservations(
dbManager: DatabaseManager,
worker: WorkerRef | undefined,
discoveryTokens: number,
agentName: string
agentName: string,
projectRoot?: string
): Promise<void> {
for (let i = 0; i < observations.length; i++) {
const obsId = result.observationIds[i];
@@ -204,6 +212,25 @@ async function syncAndBroadcastObservations(
created_at_epoch: result.createdAtEpoch
});
}
// Update folder CLAUDE.md files for touched folders (fire-and-forget)
// This runs per-observation batch to ensure folders are updated as work happens
const allFilePaths: string[] = [];
for (const obs of observations) {
allFilePaths.push(...(obs.files_modified || []));
allFilePaths.push(...(obs.files_read || []));
}
if (allFilePaths.length > 0) {
updateFolderClaudeMdFiles(
allFilePaths,
session.project,
getWorkerPort(),
projectRoot
).catch(error => {
logger.warn('FOLDER_INDEX', 'CLAUDE.md update failed (non-critical)', { project: session.project }, error as Error);
});
}
}
/**
+87
View File
@@ -0,0 +1,87 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 7, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #21829 | 11:05 PM | 🔄 | Massive refactor adds 8,671 lines and removes 5,585 lines across 60 files | ~619 |
| #21824 | 10:59 PM | 🔵 | SessionEventBroadcaster methods called 7 times across SessionRoutes and SessionCompletionHandler | ~398 |
| #21822 | " | 🔵 | SessionEventBroadcaster instantiated in WorkerService and injected into routes and handlers | ~372 |
| #21816 | 10:58 PM | 🔵 | SessionEventBroadcaster provides semantic SSE event broadcasting | ~398 |
| #21807 | 10:49 PM | ⚖️ | KISS Audit Identified 587 Lines of Ceremonial Complexity | ~699 |
| #21796 | 10:46 PM | 🔵 | SessionEventBroadcaster Duplicates Processing Status Updates | ~388 |
| #21743 | 10:16 PM | 🟣 | Created SessionEventBroadcaster for Semantic Session Event Broadcasting | ~514 |
### Dec 8, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22107 | 6:47 PM | 🔵 | SessionEventBroadcaster Has observation_queued But No observation_completed Event | ~429 |
| #22049 | 6:04 PM | 🔵 | broadcastProcessingStatus method synchronizes queue state across six system components | ~477 |
| #22043 | 6:02 PM | 🔵 | SessionEventBroadcaster provides semantic event broadcasting with SSE and processing status updates | ~449 |
| #22036 | 6:00 PM | 🔵 | Found processing_status tracking across UI, hooks, and event systems | ~312 |
### Dec 11, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23962 | 1:59 PM | 🔵 | Services Layer Implements Full Backend Architecture | ~490 |
### Dec 20, 2025
**session-events.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30609 | 5:01 PM | 🔄 | Phase 4: Eliminated Over-Engineering in Hook/Worker System | ~504 |
| #30567 | 4:56 PM | 🟣 | Session Event Broadcasting Utilities | ~313 |
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30593 | 4:59 PM | 🔄 | Deleted SessionEventBroadcaster Class File | ~298 |
| #30548 | 4:53 PM | 🔵 | SessionEventBroadcaster SSE Notification Layer | ~338 |
### Dec 25, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32597 | 8:40 PM | 🔵 | Identified session completion mechanism and potential method discrepancy | ~470 |
| #32580 | 8:22 PM | 🔵 | Grep for resetStuckMessages and processing | ~242 |
### Dec 28, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33439 | 10:15 PM | 🔄 | Extended Session ID Renaming to Additional Codebase Components | ~352 |
| #33328 | 3:10 PM | 🟣 | Merged centralized logger and session continuity diagnostics to main | ~397 |
| #33280 | 3:07 PM | 🔄 | Logger coverage refactor for background services | ~428 |
### Dec 30, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34550 | 4:53 PM | 🔵 | Phase 2 Review Reveals Critical Incomplete Error Handling | ~577 |
### Dec 31, 2025
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34558 | 2:32 PM | 🔵 | Code Quality Fix Plan Created for Seven Identified Issues | ~629 |
### Jan 2, 2026
**SessionEventBroadcaster.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
</claude-mem-context>
+58
View File
@@ -0,0 +1,58 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 28, 2025
**BaseRouteHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33396 | 9:53 PM | ✅ | Queue refactoring touched 12 files with net addition of 1021 lines | ~402 |
| #33336 | 3:36 PM | 🔴 | Fixed Windows Worker Crashes and Headers Already Sent Errors | ~351 |
| #33259 | 2:46 PM | 🔴 | Windows Worker Stability Pull Request Created | ~386 |
| #33258 | 2:38 PM | 🔴 | Added headersSent Guard to Error Handler | ~338 |
| #33256 | 2:36 PM | ⚖️ | Implementation Plan for Windows Worker Issues | ~471 |
### Jan 1, 2026
**middleware.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35614 | 10:57 PM | 🔴 | Suppressed /api/logs endpoint logging to reduce noise | ~252 |
| #35612 | " | ✅ | HTTP logging middleware excludes /api/logs polling endpoint | ~262 |
| #35611 | " | 🔵 | HTTP Middleware Architecture in Worker Service | ~360 |
**BaseRouteHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35433 | 8:43 PM | 🔵 | Try-Catch Block Distribution Across Services | ~372 |
### Jan 2, 2026
**middleware.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
### Jan 3, 2026
**middleware.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36689 | 11:56 PM | 🔵 | PR #538 Review Findings - Modular Architecture Refactor | ~590 |
### Jan 5, 2026
**BaseRouteHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37665 | 5:52 PM | 🔵 | Codebase uses dependency injection and lazy initialization patterns to avoid circular dependencies | ~548 |
| #37662 | " | 🔵 | BaseRouteHandler imports logger demonstrating HTTP layer dependency on logger | ~367 |
**middleware.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37626 | 5:35 PM | 🔵 | FormatTool Function Usage Across Codebase | ~493 |
| #37537 | 4:45 PM | 🔵 | Middleware formatTool Call Confirmed as Critical Crash Point | ~361 |
</claude-mem-context>
+97
View File
@@ -0,0 +1,97 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 5, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #20734 | 9:08 PM | 🔵 | SearchRoutes Context Injection Endpoint with Dynamic Import | ~614 |
| #20548 | 8:21 PM | 🔵 | Context generator imported from services directory in worker | ~334 |
| #20547 | " | 🔵 | Context injection route implementation in SearchRoutes.ts | ~289 |
### Dec 7, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #21742 | 10:16 PM | 🔵 | SessionRoutes Analysis: Identified 10+ Scattered Broadcast Calls | ~540 |
### Dec 8, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22301 | 9:44 PM | 🔵 | Privacy Validation in Observation Processing | ~399 |
| #22296 | 9:43 PM | 🔵 | SessionRoutes HTTP Endpoints and SDK Agent Lifecycle | ~442 |
| #22222 | 8:29 PM | 🔵 | Found waiting logic in SessionRoutes but it may not be working correctly | ~359 |
| #22005 | 5:40 PM | 🔵 | handleObservationsByClaudeId Current Implementation | ~443 |
| #22004 | " | 🔵 | Legacy Observation Handling Pattern Identified | ~337 |
| #22003 | " | 🔵 | SessionRoutes Architecture Confirmed | ~354 |
| #21969 | 5:22 PM | 🟣 | Worker Routes Pass tool_use_id to SessionManager Queue | ~290 |
| #21968 | " | ✅ | Worker Endpoint Extracts toolUseId from Observation Request | ~243 |
| #21962 | 5:21 PM | 🟣 | Implemented handleGetObservationsForToolUse Endpoint Handler | ~325 |
| #21961 | " | 🟣 | Added GET Endpoint for Fetching Observations by Tool Use ID | ~272 |
| #21951 | 5:18 PM | 🔵 | Worker SessionRoutes Architecture and Endpoints Reviewed | ~418 |
| #21948 | 5:09 PM | 🟣 | Implemented PreToolUse Endpoint Handler | ~334 |
| #21947 | 5:07 PM | 🟣 | Added PreToolUse Route Registration | ~287 |
### Dec 9, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23143 | 6:42 PM | ✅ | Updated Skip Tools Logic to Use USER_SETTINGS_PATH Constant | ~150 |
| #23142 | " | ✅ | Fixed Settings Path Import in SessionRoutes | ~148 |
| #23140 | 6:41 PM | 🟣 | Implemented Skip Tools Filtering in Observations Endpoint | ~386 |
| #23138 | " | ✅ | Added SettingsDefaultsManager and Paths Imports to SessionRoutes | ~222 |
| #23136 | " | 🔵 | SessionRoutes handleObservationsByClaudeId Handler Structure | ~329 |
| #23007 | 4:02 PM | 🔵 | Settings Write Implementation Using Nested Schema | ~398 |
| #22859 | 2:28 PM | 🔴 | Fixed Python Version Validation to Support 3.10+ | ~322 |
| #22854 | 2:27 PM | 🔵 | Located Python Version Validation Regex in SettingsRoutes | ~316 |
### Dec 10, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23593 | 5:52 PM | 🔵 | SearchRoutes Handler Pattern | ~268 |
| #23588 | 5:51 PM | 🔵 | Search Routes HTTP API Integration | ~281 |
### Dec 14, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #26253 | 8:31 PM | 🔵 | SearchRoutes Confirms Context Endpoints Use generateContext, Search Uses SearchManager | ~397 |
| #25689 | 4:23 PM | 🔵 | SessionRoutes queueSummarize receives messages but doesn't persist them to database | ~496 |
### Dec 15, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27043 | 6:04 PM | 🔵 | Subagent confirms no version switcher UI exists, only orphaned backend infrastructure | ~539 |
| #27041 | 6:03 PM | 🔵 | Branch switching code isolated to two backend files, no frontend UI components | ~473 |
| #27037 | 6:02 PM | 🔵 | Branch switching functionality exists in SettingsRoutes with UI switcher removal intent | ~463 |
### Dec 16, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27414 | 3:25 PM | 🔵 | Batch Observations Endpoint Already Implemented | ~330 |
### Dec 19, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30077 | 8:05 PM | 🔵 | SessionRoutes HTTP API Manages SDK Agent Lifecycle and Message Queue | ~516 |
### Dec 26, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32949 | 10:55 PM | 🔵 | Complete settings persistence flow for Xiaomi MIMO v2 Flash model | ~320 |
| #32939 | 10:53 PM | 🔵 | Settings API routes handle model configuration persistence | ~288 |
### Dec 30, 2025
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34491 | 2:28 PM | 🔵 | SessionRoutes Implements Multi-Provider Agent Management | ~635 |
</claude-mem-context>
@@ -195,31 +195,46 @@ export class SearchRoutes extends BaseRouteHandler {
/**
* Context injection endpoint for hooks
* GET /api/context/inject?project=...&colors=true
* GET /api/context/inject?projects=...&colors=true
* GET /api/context/inject?project=...&colors=true (legacy, single project)
*
* Returns pre-formatted context string ready for display.
* Use colors=true for ANSI-colored terminal output.
*
* For worktrees, pass comma-separated projects (e.g., "main,worktree-branch")
* to get a unified timeline from both parent and worktree.
*/
private handleContextInject = this.wrapHandler(async (req: Request, res: Response): Promise<void> => {
const projectName = req.query.project as string;
// Support both legacy `project` and new `projects` parameter
const projectsParam = (req.query.projects as string) || (req.query.project as string);
const useColors = req.query.colors === 'true';
if (!projectName) {
this.badRequest(res, 'Project parameter is required');
if (!projectsParam) {
this.badRequest(res, 'Project(s) parameter is required');
return;
}
// Parse comma-separated projects list
const projects = projectsParam.split(',').map(p => p.trim()).filter(Boolean);
if (projects.length === 0) {
this.badRequest(res, 'At least one project is required');
return;
}
// Import context generator (runs in worker, has access to database)
const { generateContext } = await import('../../../context-generator.js');
// Use project name as CWD (generateContext uses path.basename to get project)
const cwd = `/context/${projectName}`;
// Use first project name as CWD (for display purposes)
const primaryProject = projects[projects.length - 1]; // Last is the current/primary project
const cwd = `/context/${primaryProject}`;
// Generate context
// Generate context with all projects
const contextText = await generateContext(
{
session_id: 'context-inject-' + Date.now(),
cwd: cwd
cwd: cwd,
projects: projects
},
useColors
);
@@ -560,31 +560,23 @@ export class SessionRoutes extends BaseRouteHandler {
// Step 1: Create/get SDK session (idempotent INSERT OR IGNORE)
const sessionDbId = store.createSDKSession(contentSessionId, project, prompt);
logger.info('HTTP', 'SessionRoutes: createSDKSession returned', {
sessionDbId,
contentSessionId
});
// SESSION ALIGNMENT LOG: DB lookup proof - show content→memory mapping
// Verify session creation with DB lookup
const dbSession = store.getSessionById(sessionDbId);
const memorySessionId = dbSession?.memory_session_id || null;
const hasCapturedMemoryId = !!memorySessionId;
const isNewSession = !dbSession?.memory_session_id;
logger.info('SESSION', `CREATED | contentSessionId=${contentSessionId} → sessionDbId=${sessionDbId} | isNew=${isNewSession} | project=${project}`, {
sessionId: sessionDbId
});
// Step 2: Get next prompt number from user_prompts count
const currentCount = store.getPromptNumberFromUserPrompts(contentSessionId);
const promptNumber = currentCount + 1;
logger.info('HTTP', 'SessionRoutes: Calculated promptNumber', {
sessionDbId,
promptNumber,
currentCount
});
// SESSION ALIGNMENT LOG: For prompt > 1, prove we looked up memorySessionId from contentSessionId
// Debug-level alignment logs for detailed tracing
const memorySessionId = dbSession?.memory_session_id || null;
if (promptNumber > 1) {
logger.info('HTTP', `[ALIGNMENT] DB Lookup Proof | contentSessionId=${contentSessionId} → memorySessionId=${memorySessionId || '(not yet captured)'} | prompt#=${promptNumber} | hasCapturedMemoryId=${hasCapturedMemoryId}`);
logger.debug('HTTP', `[ALIGNMENT] DB Lookup Proof | contentSessionId=${contentSessionId} → memorySessionId=${memorySessionId || '(not yet captured)'} | prompt#=${promptNumber}`);
} else {
logger.info('HTTP', `[ALIGNMENT] New Session | contentSessionId=${contentSessionId} | prompt#=${promptNumber} | memorySessionId will be captured on first SDK response`);
logger.debug('HTTP', `[ALIGNMENT] New Session | contentSessionId=${contentSessionId} | prompt#=${promptNumber} | memorySessionId will be captured on first SDK response`);
}
// Step 3: Strip privacy tags from prompt
@@ -610,10 +602,10 @@ export class SessionRoutes extends BaseRouteHandler {
// Step 5: Save cleaned user prompt
store.saveUserPrompt(contentSessionId, promptNumber, cleanedPrompt);
logger.info('SESSION', 'Session initialized via HTTP', {
// Debug-level log since CREATED already logged the key info
logger.debug('SESSION', 'User prompt saved', {
sessionId: sessionDbId,
promptNumber,
project
promptNumber
});
res.json({
+48
View File
@@ -0,0 +1,48 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**ResultFormatter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36540 | 9:39 PM | 🟣 | ResultFormatter Test Suite Created | ~424 |
| #36533 | 9:35 PM | 🔵 | ResultFormatter for Unified Search Result Display | ~598 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**SearchOrchestrator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36545 | 9:41 PM | 🟣 | Phase 3 Search Strategy Test Suite Completion | ~564 |
| #36544 | 9:40 PM | 🟣 | Phase 3 Search Strategy Test Suite Complete | ~449 |
| #36543 | " | 🟣 | Phase 3 Search Strategy Tests Completed | ~458 |
| #36541 | 9:39 PM | 🟣 | SearchOrchestrator Test Suite Implementation | ~588 |
| #36531 | 9:34 PM | 🔵 | SearchOrchestrator Strategy Selection Logic | ~334 |
| #36529 | " | 🔵 | Search Module Architecture Discovery | ~302 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36538 | 9:38 PM | 🟣 | SQLiteSearchStrategy Test Suite Created | ~527 |
| #36537 | " | 🟣 | HybridSearchStrategy Test Suite Created | ~435 |
| #36536 | " | 🟣 | ChromaSearchStrategy Test Suite Created | ~430 |
| #36523 | 9:34 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Services | ~386 |
| #36519 | " | 🔴 | Fixed Type Import Issues Preventing Worker Tests | ~308 |
| #36516 | 9:33 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Search Modules | ~377 |
**index.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36527 | 9:34 PM | 🔵 | Search Strategy Architecture Analysis for Phase 3 Testing | ~486 |
| #36421 | 8:58 PM | 🔄 | Search Module Public API Organization | ~393 |
### Jan 5, 2026
**ResultFormatter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37968 | 8:22 PM | 🔵 | ResultFormatter Uses Epoch Timestamps from Database | ~364 |
</claude-mem-context>
@@ -62,10 +62,8 @@ export class ResultFormatter {
for (const result of dayResults) {
let file = 'General';
if (result.type === 'observation') {
file = extractFirstFile(
(result.data as ObservationSearchResult).files_modified,
cwd
);
const obs = result.data as ObservationSearchResult;
file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
}
if (!resultsByFile.has(file)) {
resultsByFile.set(file, []);
@@ -216,7 +216,7 @@ export class TimelineBuilder {
} else if (item.type === 'observation') {
const obs = item.data as ObservationSearchResult;
const file = extractFirstFile(obs.files_modified, cwd);
const file = extractFirstFile(obs.files_modified, cwd, obs.files_read);
if (file !== currentFile) {
if (tableOpen) {
@@ -0,0 +1,21 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**DateFilter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36523 | 9:34 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Services | ~386 |
| #36519 | " | 🔴 | Fixed Type Import Issues Preventing Worker Tests | ~308 |
| #36516 | 9:33 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Search Modules | ~377 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**ProjectFilter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36529 | 9:34 PM | 🔵 | Search Module Architecture Discovery | ~302 |
</claude-mem-context>
@@ -0,0 +1,45 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**SearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36534 | 9:35 PM | 🔵 | SearchStrategy Interface Pattern | ~341 |
| #36523 | 9:34 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Services | ~386 |
| #36519 | " | 🔴 | Fixed Type Import Issues Preventing Worker Tests | ~308 |
| #36516 | 9:33 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Search Modules | ~377 |
| #36449 | 9:02 PM | 🔵 | Search Strategy Base Implementation | ~410 |
| #36419 | 8:57 PM | 🔵 | Search Strategy Interface Pattern | ~380 |
**SQLiteSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36545 | 9:41 PM | 🟣 | Phase 3 Search Strategy Test Suite Completion | ~564 |
| #36544 | 9:40 PM | 🟣 | Phase 3 Search Strategy Test Suite Complete | ~449 |
| #36538 | 9:38 PM | 🟣 | SQLiteSearchStrategy Test Suite Created | ~527 |
| #36527 | 9:34 PM | 🔵 | Search Strategy Architecture Analysis for Phase 3 Testing | ~486 |
| #36526 | " | 🔵 | SQLite Search Strategy Architecture | ~439 |
| #36451 | 9:02 PM | 🔵 | SQLite Search Strategy Implementation | ~453 |
**ChromaSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36543 | 9:40 PM | 🟣 | Phase 3 Search Strategy Tests Completed | ~458 |
| #36536 | 9:38 PM | 🟣 | ChromaSearchStrategy Test Suite Created | ~430 |
| #36530 | 9:34 PM | 🔵 | Chroma Vector Search Strategy Architecture | ~508 |
| #36529 | " | 🔵 | Search Module Architecture Discovery | ~302 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**HybridSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36537 | 9:38 PM | 🟣 | HybridSearchStrategy Test Suite Created | ~435 |
| #36532 | 9:34 PM | 🔵 | HybridSearchStrategy Four-Step Pattern | ~333 |
| #36528 | " | 🔵 | Hybrid Search Strategy Combining Metadata Filtering with Semantic Ranking | ~525 |
| #36459 | 9:03 PM | 🔵 | Hybrid Search Strategy with Four-Step Algorithm | ~530 |
</claude-mem-context>
+103
View File
@@ -0,0 +1,103 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 7, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #21829 | 11:05 PM | 🔄 | Massive refactor adds 8,671 lines and removes 5,585 lines across 60 files | ~619 |
| #21825 | 11:00 PM | 🔵 | SessionCompletionHandler methods called 3 times in SessionRoutes | ~342 |
| #21824 | 10:59 PM | 🔵 | SessionEventBroadcaster methods called 7 times across SessionRoutes and SessionCompletionHandler | ~398 |
| #21822 | " | 🔵 | SessionEventBroadcaster instantiated in WorkerService and injected into routes and handlers | ~372 |
| #21818 | 10:58 PM | 🔵 | SessionCompletionHandler is instantiated in SessionRoutes | ~282 |
| #21817 | " | 🔵 | SessionCompletionHandler consolidates session completion logic | ~414 |
| #21807 | 10:49 PM | ⚖️ | KISS Audit Identified 587 Lines of Ceremonial Complexity | ~699 |
| #21794 | 10:46 PM | 🔵 | SessionCompletionHandler Consolidates Duplicate Completion Logic | ~341 |
| #21764 | 10:23 PM | ✅ | Phase 4 Build and Deployment Successful | ~376 |
| #21759 | 10:21 PM | 🟣 | SessionCompletionHandler Service Created | ~426 |
### Dec 11, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23962 | 1:59 PM | 🔵 | Services Layer Implements Full Backend Architecture | ~490 |
### Dec 14, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #26088 | 7:32 PM | 🔵 | API Endpoint Architecture Discovery | ~416 |
### Dec 20, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30725 | 5:12 PM | 🔵 | Revealed extensive work-in-progress changes across hook and worker systems | ~479 |
| #30569 | 4:56 PM | 🔄 | SessionCompletionHandler Broadcasting Implementation | ~264 |
| #30568 | " | 🔄 | SessionCompletionHandler Event Broadcasting Refactor | ~282 |
| #30566 | " | 🔵 | Session Completion Handler Consolidation | ~323 |
### Dec 24, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32350 | 8:42 PM | 🔵 | Detailed Cleanup Hook Evolution Documentation Retrieved | ~597 |
| #32316 | 8:41 PM | 🔄 | Removed markSessionComplete method from DatabaseManager | ~251 |
| #32194 | 7:42 PM | 🔵 | Session completion handler implementation analysis | ~329 |
| #32193 | " | 🔵 | Session completion endpoint usage across codebase | ~278 |
| #32182 | 7:15 PM | 🔄 | Removed markSessionComplete database call from session completion flow | ~316 |
| #32179 | 7:11 PM | 🔄 | SessionCompletionHandler switched to direct SQL query | ~273 |
| #32153 | 6:40 PM | 🔵 | Session Identifier Architecture Across Codebase | ~529 |
### Dec 25, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32597 | 8:40 PM | 🔵 | Identified session completion mechanism and potential method discrepancy | ~470 |
| #32456 | 5:41 PM | ✅ | Completed merge of main branch into feature/titans-phase1-3 | ~354 |
| #32198 | 7:41 PM | 🔄 | Removed redundant SessionEnd cleanup hook | ~317 |
### Dec 27, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33099 | 7:10 PM | 🔵 | SessionCompletionHandler Manual Session Termination Flow | ~348 |
### Dec 28, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33328 | 3:10 PM | 🟣 | Merged centralized logger and session continuity diagnostics to main | ~397 |
| #33280 | 3:07 PM | 🔄 | Logger coverage refactor for background services | ~428 |
### Dec 30, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34388 | 1:40 PM | 🔵 | SessionCompletionHandler Relies on SessionManager Abort Without Process Cleanup | ~309 |
### Dec 31, 2025
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34707 | 4:45 PM | 🔵 | SessionCompletionHandler Aborts SDK Agent During Cleanup | ~291 |
### Jan 2, 2026
**SessionCompletionHandler.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
</claude-mem-context>
+77
View File
@@ -0,0 +1,77 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 7, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #21829 | 11:05 PM | 🔄 | Massive refactor adds 8,671 lines and removes 5,585 lines across 60 files | ~619 |
| #21820 | 10:59 PM | 🔵 | PrivacyCheckValidator used twice in SessionRoutes for observation and summarize endpoints | ~303 |
| #21814 | 10:58 PM | 🔵 | PrivacyCheckValidator centralizes user prompt privacy validation | ~359 |
| #21807 | 10:49 PM | ⚖️ | KISS Audit Identified 587 Lines of Ceremonial Complexity | ~699 |
| #21797 | 10:46 PM | 🔵 | PrivacyCheckValidator Implements Single Validation Method | ~349 |
| #21770 | 10:36 PM | 🟣 | Implemented PrivacyCheckValidator for Centralized Privacy Validation | ~318 |
### Dec 8, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22274 | 9:22 PM | 🔵 | Event-Driven Architecture for SDK Response Coordination Fully Mapped | ~1136 |
| #22270 | 9:12 PM | 🔵 | DRY violations identified in endless-mode-v7.1 branch | ~553 |
### Dec 9, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22808 | 2:01 PM | 🔵 | Logger Utility Pattern Identified | ~300 |
| #22750 | 1:27 PM | 🔵 | PrivacyCheckValidator Centralizes Privacy Logic | ~450 |
### Dec 11, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23962 | 1:59 PM | 🔵 | Services Layer Implements Full Backend Architecture | ~490 |
### Dec 20, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #30609 | 5:01 PM | 🔄 | Phase 4: Eliminated Over-Engineering in Hook/Worker System | ~504 |
| #30598 | 5:00 PM | 🔄 | Removed PrivacyCheckValidator module | ~201 |
| #30549 | 4:53 PM | 🔵 | PrivacyCheckValidator for User Prompt Filtering | ~325 |
### Dec 24, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32153 | 6:40 PM | 🔵 | Session Identifier Architecture Across Codebase | ~529 |
### Dec 25, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32580 | 8:22 PM | 🔵 | Grep for resetStuckMessages and processing | ~242 |
### Dec 28, 2025
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33439 | 10:15 PM | 🔄 | Extended Session ID Renaming to Additional Codebase Components | ~352 |
### Jan 2, 2026
**PrivacyCheckValidator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
</claude-mem-context>