speclock 3.5.4 → 4.0.0

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/src/mcp/server.js CHANGED
@@ -220,10 +220,15 @@ server.tool(
220
220
  .describe("Who created this lock"),
221
221
  },
222
222
  async ({ text, tags, source }) => {
223
- const { lockId } = addLock(PROJECT_ROOT, text, tags, source);
223
+ const { lockId, rewritten, rewriteReason } = addLock(PROJECT_ROOT, text, tags, source);
224
+
225
+ // Read the stored lock to get the normalized text
226
+ const brain = readBrain(PROJECT_ROOT);
227
+ const storedLock = brain?.specLock?.items?.find(l => l.id === lockId);
228
+ const storedText = storedLock?.text || text;
224
229
 
225
230
  // Auto-guard related files
226
- const guardResult = autoGuardRelatedFiles(PROJECT_ROOT, text);
231
+ const guardResult = autoGuardRelatedFiles(PROJECT_ROOT, storedText);
227
232
  const guardMsg = guardResult.guarded.length > 0
228
233
  ? `\nAuto-guarded ${guardResult.guarded.length} file(s): ${guardResult.guarded.join(", ")}`
229
234
  : "";
@@ -231,9 +236,14 @@ server.tool(
231
236
  // Sync active locks to package.json
232
237
  syncLocksToPackageJson(PROJECT_ROOT);
233
238
 
239
+ // Report rewrite if it happened
240
+ const rewriteMsg = rewritten
241
+ ? `\n\nSmart Lock Authoring: Rewritten for accuracy.\n Original: "${text}"\n Stored as: "${storedText}"\n Reason: ${rewriteReason}`
242
+ : "";
243
+
234
244
  return {
235
245
  content: [
236
- { type: "text", text: `Lock added (${lockId}): "${text}"${guardMsg}` },
246
+ { type: "text", text: `Lock added (${lockId}): "${storedText}"${guardMsg}${rewriteMsg}` },
237
247
  ],
238
248
  };
239
249
  }