@jussmor/commit-memory-mcp 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -108,7 +108,8 @@ build_context_pack({
108
108
  ```
109
109
 
110
110
  Use this before invoking a coding subagent to keep prompts small and focused.
111
- If no rows are found in strict scope, the server now falls back automatically to broader scope levels.
111
+ The pack is assembled main-first: promoted facts on `main` are treated as baseline truth, then branch/feature facts are added as in-flight overlay.
112
+ If no rows are found in strict scope, the server falls back automatically to broader scope levels.
112
113
 
113
114
  Important: if you provide `domain`/`feature`/`branch` tags in `build_context_pack`, use the same tags during `sync_pr_context` for best precision.
114
115
 
package/dist/db/client.js CHANGED
@@ -372,6 +372,7 @@ export function promoteContextFacts(db, options) {
372
372
  }
373
373
  export function buildContextPack(db, options) {
374
374
  const taskType = options.taskType ?? "general";
375
+ const GLOBAL_BRANCH = "main";
375
376
  function runQuery(params) {
376
377
  const clauses = [];
377
378
  const values = [taskType];
@@ -383,7 +384,11 @@ export function buildContextPack(db, options) {
383
384
  clauses.push("scope_feature = ?");
384
385
  values.push(options.feature);
385
386
  }
386
- if (params.includeBranch && options.branch) {
387
+ if (params.forcedBranch) {
388
+ clauses.push("scope_branch = ?");
389
+ values.push(params.forcedBranch);
390
+ }
391
+ else if (params.includeBranch && options.branch) {
387
392
  clauses.push("scope_branch = ?");
388
393
  values.push(options.branch);
389
394
  }
@@ -444,27 +449,61 @@ export function buildContextPack(db, options) {
444
449
  updatedAt: String(row.updated_at ?? ""),
445
450
  }));
446
451
  }
447
- const strictRows = runQuery({
452
+ const seenIds = new Set();
453
+ const pack = [];
454
+ const addRows = (rows) => {
455
+ for (const row of rows) {
456
+ if (pack.length >= options.limit) {
457
+ return;
458
+ }
459
+ if (seenIds.has(row.id)) {
460
+ continue;
461
+ }
462
+ seenIds.add(row.id);
463
+ pack.push(row);
464
+ }
465
+ };
466
+ // 1) Main branch domain context is the durable source-of-truth baseline.
467
+ if (pack.length < options.limit) {
468
+ addRows(runQuery({
469
+ includeDomain: true,
470
+ includeFeature: false,
471
+ includeBranch: false,
472
+ forcedBranch: GLOBAL_BRANCH,
473
+ }));
474
+ }
475
+ // 2) Main branch global context fills any remaining baseline slots.
476
+ if (pack.length < options.limit) {
477
+ addRows(runQuery({
478
+ includeDomain: false,
479
+ includeFeature: false,
480
+ includeBranch: false,
481
+ forcedBranch: GLOBAL_BRANCH,
482
+ }));
483
+ }
484
+ // 3) Branch-local feature context overlays main for active, in-flight work.
485
+ addRows(runQuery({
448
486
  includeDomain: true,
449
487
  includeFeature: true,
450
488
  includeBranch: true,
451
- });
452
- if (strictRows.length > 0) {
453
- return strictRows;
489
+ }));
490
+ // 4) Domain-wide branch context provides additional short-lived signal.
491
+ if (pack.length < options.limit) {
492
+ addRows(runQuery({
493
+ includeDomain: true,
494
+ includeFeature: false,
495
+ includeBranch: false,
496
+ }));
454
497
  }
455
- const broadRows = runQuery({
456
- includeDomain: true,
457
- includeFeature: false,
458
- includeBranch: false,
459
- });
460
- if (broadRows.length > 0) {
461
- return broadRows;
498
+ // 5) Final safety net from all promoted context.
499
+ if (pack.length < options.limit) {
500
+ addRows(runQuery({
501
+ includeDomain: false,
502
+ includeFeature: false,
503
+ includeBranch: false,
504
+ }));
462
505
  }
463
- return runQuery({
464
- includeDomain: false,
465
- includeFeature: false,
466
- includeBranch: false,
467
- });
506
+ return pack;
468
507
  }
469
508
  export function archiveFeatureContext(db, options) {
470
509
  const now = new Date().toISOString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jussmor/commit-memory-mcp",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "mcpName": "io.github.jussmor/commit-memory",
5
5
  "description": "Commit-aware RAG with sqlite-vec and MCP tools for local agent workflows",
6
6
  "license": "MIT",