Commit Graph

1750 Commits

Author SHA1 Message Date
Alex Newman 95889c7b4e feat: expand smart-explore to 24 languages with markdown support and user-installable grammars
Add 15 new tree-sitter language grammars (Kotlin, Swift, PHP, Elixir, Lua, Scala,
Bash, Haskell, Zig, CSS, SCSS, TOML, YAML, SQL, Markdown) with verified SCM queries.
Add markdown-specific formatting with heading hierarchy, code block detection, and
section-aware unfold. Add user-installable grammar system via .claude-mem.json config
with custom query file support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 13:24:56 -07:00
Alex Newman 25bb93a995 fix: address PR #1641 review comments (round 2)
- Remove duplicate TranscriptWatcher/config imports in worker-service.ts
- Use normalizePlatformSource in handleSessionInitByClaudeId for consistency
- Don't skip DB completion when session not in memory (completeByClaudeId)
- Add try-catch around fetch in useContextPreview refresh callback
- Deduplicate store.getAllProjects() call in DataRoutes
- Fix malformed comment separators in migration runner
- Fix missing closing brace and JSDoc opener (merge artifact) in migration runner

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 13:22:58 -07:00
Alex Newman c21e49d9fa fix: address PR review comments and add file read gate docs
Fix indentation bugs flagged in PR review (SettingsDefaultsManager,
MigrationRunner), add current date/time to file read gate timeline
so the model can judge observation recency, and add documentation
for the file read gate feature.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 13:09:46 -07:00
Alex Newman f4570f2a0a chore: rebuild plugin artifacts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:31:53 -07:00
Alex Newman cbb68ad9e1 fix: worker startup crash and missing observation columns
Two bugs fixed:

1. SessionCompletionHandler called dbManager.getSessionStore() during
   WorkerService construction, before DB initialization. Changed to
   accept DatabaseManager and defer the call to runtime.

2. migration009 (generated_by_model, relevance_count columns) only ran
   via the deprecated MigrationRunner path, never through SessionStore's
   migration chain. Added addObservationModelColumns() to SessionStore
   constructor. Checks column existence directly since schema_versions
   may have been marked applied without the ALTER TABLE succeeding.

Also removed duplicate transcriptWatcher declaration and shutdown block
(merge artifact).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:20:10 -07:00
Alex Newman b8999c1181 Merge branch 'thedotmack/file-read-timeline-inject' into integration/validation-batch 2026-04-07 11:18:58 -07:00
Alex Newman 052da384b2 chore: rebuild worker-service.cjs with filePath escaping fix
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:17:21 -07:00
Alex Newman d8947473b8 fix: escape filePath in recovery hints to prevent malformed output
Filenames containing quotes, backslashes, or newlines could produce
malformed smart_outline/smart_unfold examples in the deny message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:06:32 -07:00
Ousama Ben Younes 53f98fad67 fix: use null-check instead of falsy-OR for depth defaults to preserve 0
Number(x) || 10 converts 0 to 10 since 0 is falsy, making it impossible
to request zero context depth (anchor only). Replace with explicit null
check in timeline(), getContextTimeline(), getTimelineByQuery().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 17:40:15 +00:00
Ousama Ben Younes 64062ac761 fix: address CodeRabbit review — remove side-effectful test import and normalize timeline depth params
- tests/servers/mcp-tool-schemas.test.ts: remove `import '../../src/servers/mcp-server.js'`
  which triggered server startup side effects; test only needs to read the TS source as text
- src/services/worker/SearchManager.ts: add Number() coercion for depth_before/depth_after
  in timeline(), getContextTimeline(), getTimelineByQuery() — HTTP query strings deliver
  these as strings, coercion ensures they are always numbers before being passed to
  filterByDepth() and getTimelineAround*()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 17:30:59 +00:00
Ousama Ben Younes 8cdabe6315 fix: declare inputSchema properties for search and timeline MCP tools (#1384 #1413)
Both tools had properties:{} which prevents MCP clients from exposing
params to the LLM, causing every call to send {} and get a 500 error
("Either query or filters required for search").

- search: declare query, limit, project, type, obs_type, dateStart, dateEnd, offset, orderBy
- timeline: declare anchor, query, depth_before, depth_after, project
- Add 3 schema regression tests (static source validation)

Closes #1384
Closes #1413

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 17:21:19 +00:00
Alex Newman e3475180cd fix: address PR review — day sort, path canonicalization, dead code cleanup
- Sort within-day observations chronologically (was specificity-ordered)
- Canonicalize relative paths to POSIX format before DB lookup
- Skip projects param when allProjects is empty (prevents cross-project leaks)
- Remove dead stderrMessage field and hook-command block (unused after permissionDecision switch)
- Type permissionDecision as 'allow' | 'deny' union instead of string
- Remove redundant non-null assertions in getObservationsByFilePath
- Add edit guidance to deny message (use sed via Bash with smart tools)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:59:30 -07:00
Alex Newman ef1b427a2a fix: update timeline deny message to route to smart tools
The deny reason is the routing surface — show all cheaper exits:
semantic priming from the timeline, get_observations for details,
and smart_outline/smart_unfold for current code structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 00:25:55 -07:00
Alex Newman 455aeaf654 fix: remove per-session gate, use permissionDecision deny for every read
The per-session FileReadGate was never requested and broke the cost
savings loop — subsequent reads in the same session silently bypassed
the timeline, hiding newly created observations.

Now the timeline fires on every read that has observations, using the
hook contract's permissionDecision: "deny" with the timeline as the
reason (exit 0 + JSON) instead of exit code 2 + stderr.

- Delete FileReadGate.ts entirely
- Remove /api/file-context/gate endpoint from DataRoutes
- Switch handler from exit code 2 to permissionDecision: "deny"
- Restore permissionDecision fields to HookResult
- Eliminate one HTTP round-trip per read (no gate check needed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 22:05:40 -07:00
Alex Newman 31910fb265 fix: address PR review feedback — path safety, SQL injection, gate scoping
- Resolve relative filePath against input.cwd before statSync; early-return on ENOENT
- Replace LIKE '%path%' with exact json_each equality to prevent false matches
- Sanitize and parameterize LIMIT to prevent NaN SQL errors
- Fix day-sorting to use earliest epoch in group, not first (specificity-sorted) item
- Use exact path equality in deduplicateObservations instead of substring includes
- Scope FileReadGate by session+cwd to prevent worktree collisions
- Refresh lastAccess TTL on active sessions; throttle prune to every 50 calls
- Type params as (string | number)[] instead of any[]
- Remove unused permissionDecision fields from HookResult

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:29:59 -07:00
Alex Newman 6250a194dd Merge branch 'pr-1472' into integration/validation-batch
# Conflicts:
#	plugin/scripts/context-generator.cjs
#	plugin/scripts/mcp-server.cjs
#	plugin/scripts/worker-service.cjs
#	plugin/ui/viewer-bundle.js
#	src/cli/handlers/context.ts
#	src/services/sqlite/SessionStore.ts
#	src/services/sqlite/migrations/runner.ts
#	src/services/worker-service.ts
#	src/shared/SettingsDefaultsManager.ts
2026-04-06 14:23:18 -07:00
Alex Newman 3b935294bf Merge branch 'pr-1575' into integration/validation-batch
# Conflicts:
#	plugin/scripts/bun-runner.js
2026-04-06 14:22:13 -07:00
Alex Newman 58fcd85724 Merge branch 'pr-1578' into integration/validation-batch
# Conflicts:
#	plugin/scripts/context-generator.cjs
#	plugin/scripts/worker-service.cjs
#	src/utils/tag-stripping.ts
2026-04-06 14:21:45 -07:00
Alex Newman 2d5480b5e4 Merge branch 'pr-1612' into integration/validation-batch
# Conflicts:
#	plugin/hooks/hooks.json
2026-04-06 14:21:24 -07:00
Alex Newman c1a3fc27ec Merge branch 'pr-1557' into integration/validation-batch
# Conflicts:
#	plugin/hooks/hooks.json
#	tests/infrastructure/plugin-distribution.test.ts
2026-04-06 14:20:49 -07:00
Alex Newman d570909bf1 Merge branch 'pr-1491' into integration/validation-batch
# Conflicts:
#	plugin/scripts/mcp-server.cjs
#	plugin/scripts/worker-service.cjs
#	src/shared/hook-constants.ts
2026-04-06 14:20:05 -07:00
Alex Newman 5dd2a6f758 Merge branch 'pr-1553' into integration/validation-batch
# Conflicts:
#	src/services/worker/session/SessionCompletionHandler.ts
2026-04-06 14:19:50 -07:00
Alex Newman c3cb8f81ed Merge branch 'pr-1368' into integration/validation-batch
# Conflicts:
#	plugin/scripts/context-generator.cjs
#	plugin/scripts/mcp-server.cjs
#	plugin/scripts/worker-service.cjs
#	plugin/ui/viewer-bundle.js
2026-04-06 14:19:23 -07:00
Alex Newman 8d02271321 Merge branch 'pr-1411' into integration/validation-batch 2026-04-06 14:19:03 -07:00
Alex Newman 54289b34e6 Merge branch 'pr-1529' into integration/validation-batch 2026-04-06 14:19:03 -07:00
Alex Newman 5a52121216 Merge branch 'pr-1602' into integration/validation-batch 2026-04-06 14:19:02 -07:00
Alex Newman 5cffff7d40 Merge branch 'pr-1620' into integration/validation-batch 2026-04-06 14:19:02 -07:00
Alex Newman d63d73acc2 Merge branch 'pr-1524' into integration/validation-batch 2026-04-06 14:19:01 -07:00
Alex Newman 9a4afab4c2 Merge branch 'pr-1610' into integration/validation-batch 2026-04-06 14:19:01 -07:00
Alex Newman 832bd755ed Merge branch 'pr-1506' into integration/validation-batch 2026-04-06 14:19:01 -07:00
Alex Newman 995f69e4e9 Merge branch 'pr-1584' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 842d614adb Merge branch 'pr-1550' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman b1da4c7e2c Merge branch 'pr-1457' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 4d2bb1f13e Merge branch 'pr-1441' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman a9de029c02 Merge branch 'pr-1549' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman a4115d055a Merge branch 'pr-1585' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 53c1fc9a70 Merge branch 'pr-1479' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 79d3ca6aaa Merge branch 'pr-1499' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 85f57e6440 Merge branch 'pr-1554' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 36de44d661 Merge branch 'pr-1556' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman f32fda8b35 Merge branch 'pr-1494' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 4509da1409 Merge branch 'pr-1588' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman b0f70b8302 Merge branch 'pr-1619' into integration/validation-batch 2026-04-06 14:18:28 -07:00
Alex Newman 1f808c0be7 Merge branch 'pr-1579' into integration/validation-batch 2026-04-06 14:18:27 -07:00
Alex Newman a28eddb925 Merge branch 'pr-1552' into integration/validation-batch 2026-04-06 14:18:02 -07:00
Alex Newman a60f79c44d feat: file-size threshold and observation dedup for timeline gate
- Skip gate for files under 1,500 bytes — timeline (~370 tokens) costs
  more than just reading small files directly
- Deduplicate observations by memory_session_id (one per session)
- Rank by specificity: files_modified > files_read, fewer tagged files > many
- Fetch 40 candidates, dedup/score down to 15 for display
- Reduce default by-file query limit from 30 to 15

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 13:29:28 -07:00
Alessandro Costa 5e696888d6 fix: add migration for generated_by_model and relevance_count columns
The compiled binary (v10.6.3) creates these columns at runtime via
MigrationRunner, but no corresponding migration exists in the TypeScript
source. Anyone building from source gets observations without these
columns, breaking the feedback pipeline and model tracking.

This migration conditionally adds both columns using PRAGMA table_info
checks, making it safe for databases that already have them.

Refs: #1626

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 07:20:48 -03:00
Alex Newman 17fa383450 Merge main into thedotmack/file-read-timeline-inject
# Conflicts:
#	plugin/scripts/mcp-server.cjs
#	plugin/scripts/worker-service.cjs
2026-04-05 21:37:45 -07:00
Alex Newman 9f01228a2b docs: update CHANGELOG.md for v11.0.1
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 21:11:07 -07:00
Alex Newman 18aa5dc4e7 chore: bump version to 11.0.1
Publish to npm / publish (push) Has been cancelled
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v11.0.1
2026-04-05 21:08:32 -07:00