gitmem-mcp 1.0.4 → 1.0.6

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/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.6] - 2026-02-16
11
+
12
+ ### Fixed
13
+ - **Session close crash on malformed scars_to_record**: Agents writing `{title, description, severity}` (create_learning shape) instead of `{scar_identifier, reference_type, reference_context}` (ScarUsageEntry shape) in closing payload caused `Cannot read properties of undefined (reading 'length')` crash in `formatCloseDisplay`. Now auto-coerces salvageable entries and drops invalid ones with warnings.
14
+ - **Defensive property access in formatCloseDisplay**: Guard against undefined `scar_identifier`, `reference_type`, and `reference_context` as belt-and-suspenders protection.
15
+
10
16
  ## [1.0.3] - 2026-02-15
11
17
 
12
18
  ### Changed
@@ -297,9 +297,10 @@ function formatCloseDisplay(sessionId, compliance, params, learningsCount, succe
297
297
  const ref = s.reference_type === "explicit" ? "applied" :
298
298
  s.reference_type === "implicit" ? "implicit" :
299
299
  s.reference_type === "acknowledged" ? "ack'd" :
300
- s.reference_type === "refuted" ? "REFUTED" : s.reference_type;
301
- const id = s.scar_identifier.length > 12 ? s.scar_identifier.slice(0, 8) : s.scar_identifier;
302
- lines.push(` ${id} ${ref.padEnd(8)} ${truncate(s.reference_context, 50)}`);
300
+ s.reference_type === "refuted" ? "REFUTED" : (s.reference_type || "?");
301
+ const scarId = s.scar_identifier || "(unknown)";
302
+ const id = scarId.length > 12 ? scarId.slice(0, 8) : scarId;
303
+ lines.push(` ${id} ${ref.padEnd(8)} ${truncate(s.reference_context || "", 50)}`);
303
304
  }
304
305
  }
305
306
  // Transcript status
@@ -737,6 +738,35 @@ export async function sessionClose(params) {
737
738
  catch (error) {
738
739
  console.warn("[session_close] Failed to read closing-payload.json:", error);
739
740
  }
741
+ // Sanitize scars_to_record: agents frequently write create_learning shape
742
+ // ({title, description, severity}) instead of ScarUsageEntry shape
743
+ // ({scar_identifier, reference_type, reference_context}).
744
+ // Filter out entries missing required fields to prevent crashes in formatCloseDisplay.
745
+ if (Array.isArray(params.scars_to_record) && params.scars_to_record.length > 0) {
746
+ const valid = [];
747
+ for (const entry of params.scars_to_record) {
748
+ if (entry && typeof entry === "object" && typeof entry.scar_identifier === "string" && entry.scar_identifier.length > 0) {
749
+ valid.push(entry);
750
+ }
751
+ else {
752
+ // Try to salvage: if agent wrote {title, description} instead of {scar_identifier, reference_context}
753
+ const raw = entry;
754
+ if (raw && typeof raw.title === "string" && raw.title.length > 0) {
755
+ valid.push({
756
+ scar_identifier: raw.title,
757
+ reference_type: (typeof raw.reference_type === "string" ? raw.reference_type : "acknowledged"),
758
+ reference_context: (typeof raw.description === "string" ? raw.description : "auto-coerced from payload"),
759
+ surfaced_at: new Date().toISOString(),
760
+ });
761
+ console.error(`[session_close] Coerced malformed scar entry "${raw.title}" → scar_identifier`);
762
+ }
763
+ else {
764
+ console.error(`[session_close] Dropped malformed scars_to_record entry: ${JSON.stringify(entry).slice(0, 100)}`);
765
+ }
766
+ }
767
+ }
768
+ params.scars_to_record = valid.length > 0 ? valid : undefined;
769
+ }
740
770
  // Normalize closing_reflection field aliases (q1_broke → what_broke, etc.)
741
771
  // Agents frequently guess field names instead of using canonical keys from CLOSING_QUESTIONS.
742
772
  if (params.closing_reflection && typeof params.closing_reflection === "object") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitmem-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Institutional memory for AI coding agents. Memory that compounds.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",