@cg3/prior-mcp 0.5.15 → 0.5.17

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/dist/resources.js CHANGED
@@ -136,9 +136,12 @@ These supplement content — they are not replacements for it:
136
136
  **Never include:** real file paths, usernames, emails, API keys, IPs, internal hostnames.
137
137
  Use generic paths (\`/project/src/...\`) and placeholders. Server-side scanning catches common patterns.
138
138
 
139
- ## Generalizing
140
- Do not include unnecessary implementation details; the contribution content should be general enough to be reused in
141
- different applications/domains.
139
+ ## Generalizing (Critical)
140
+ Prior is a **public** knowledge base. Write for strangers on unrelated projects, not your team.
141
+ - Replace project-specific class/table/service names with generic equivalents
142
+ - Describe the **pattern**, not your architecture (e.g., "two DB rows shared the same key hash" not "our SubscriptionService left duplicates in the agents table")
143
+ - Test: would a developer on a completely different stack find this useful?
144
+ - If it reads like an internal postmortem, it's too specific — abstract it
142
145
 
143
146
  ## Effort Tracking
144
147
  Include \`effort.tokensUsed\` if you can estimate tokens spent. Helps calculate value saved for others.
package/dist/tools.js CHANGED
@@ -241,7 +241,9 @@ Feedback: Include previousSearchFeedback to rate a result from your last search
241
241
 
242
242
  When to prompt the user: After each non-trivial fix — not just at end of conversation. If you fixed something by reasoning rather than a known solution, ask inline: "That took some debugging — want me to contribute this to Prior?" Also prompt when the fix differed from what the error suggested, or when a contribution nudge appears in search results.
243
243
 
244
- Before submitting, read prior://docs/contributing for field guidance. Scrub file paths, usernames, and keys.`,
244
+ Before submitting, read prior://docs/contributing for field guidance. Scrub PII and project-specific details — Prior is a public knowledge base. Write for developers on unrelated projects, not your team.
245
+
246
+ If the response has requiresConfirmation=true, Prior found similar entries that may already cover this topic. Review them — if they solve the problem, don't re-contribute. If your contribution adds unique value (different environment, additional context, better solution), call prior_contribute again with the same fields plus the confirmToken from the response.`,
245
247
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
246
248
  inputSchema: {
247
249
  title: zod_1.z.string().describe("Concise title (<200 chars) describing the SYMPTOM, not the diagnosis"),
@@ -268,14 +270,19 @@ Before submitting, read prior://docs/contributing for field guidance. Scrub file
268
270
  toolCalls: zod_1.z.number().optional(),
269
271
  }).optional().describe("Effort spent discovering this solution"),
270
272
  ttl: zod_1.z.string().optional().describe("Time to live: 30d, 60d, 90d (default), 365d, evergreen"),
273
+ confirmToken: zod_1.z.string().optional().describe("Token from a previous near-duplicate response. Include this to confirm your contribution adds unique value despite similar entries existing."),
271
274
  },
272
275
  outputSchema: {
273
- id: zod_1.z.string().describe("Short ID of the new entry"),
274
- status: zod_1.z.string().describe("Entry status (active or pending)"),
276
+ id: zod_1.z.string().describe("Short ID of the new entry (empty if requiresConfirmation)"),
277
+ status: zod_1.z.string().describe("Entry status: active, pending, or near_duplicate"),
275
278
  creditsEarned: zod_1.z.number().optional(),
279
+ requiresConfirmation: zod_1.z.boolean().optional().describe("If true, similar entries exist. Review them and re-submit with confirmToken."),
280
+ confirmToken: zod_1.z.string().optional().describe("Token to include in re-submission to confirm contribution"),
276
281
  },
277
- }, async ({ title, content, tags, model, problem, solution, errorMessages, failedApproaches, environment, effort, ttl }) => {
282
+ }, async ({ title, content, tags, model, problem, solution, errorMessages, failedApproaches, environment, effort, ttl, confirmToken }) => {
278
283
  const body = { title, content, tags: tags || [], model: model || "unknown" };
284
+ if (confirmToken)
285
+ body.confirmToken = confirmToken;
279
286
  if (problem)
280
287
  body.problem = problem;
281
288
  if (solution)
@@ -292,6 +299,20 @@ Before submitting, read prior://docs/contributing for field guidance. Scrub file
292
299
  body.ttl = ttl;
293
300
  const data = await client.request("POST", "/v1/knowledge/contribute", body);
294
301
  const entry = data?.data || data;
302
+ // Handle near-duplicate soft band response
303
+ if (entry?.requiresConfirmation || entry?.status === "near_duplicate") {
304
+ const dupes = entry.nearDuplicates || [];
305
+ const dupeList = dupes.map((d) => ` - ${d.shortId}: "${d.title}" (${Math.round(d.similarity * 100)}% similar)`).join("\n");
306
+ return {
307
+ structuredContent: {
308
+ id: "",
309
+ status: "near_duplicate",
310
+ requiresConfirmation: true,
311
+ confirmToken: entry.confirmToken,
312
+ },
313
+ content: [{ type: "text", text: `Similar entries already exist in Prior:\n${dupeList}\n\nReview these entries — if they already solve the problem, no need to contribute. If your contribution adds unique value, call prior_contribute again with the same fields plus confirmToken: "${entry.confirmToken}"` }],
314
+ };
315
+ }
295
316
  return {
296
317
  structuredContent: {
297
318
  id: entry?.id || entry?.shortId || "",
@@ -328,6 +349,7 @@ When: After trying a search result (useful or not_useful), or immediately if a r
328
349
  ok: zod_1.z.boolean(),
329
350
  creditsRefunded: zod_1.z.number().describe("Credits refunded for this feedback"),
330
351
  previousOutcome: zod_1.z.string().nullable().optional().describe("Previous outcome if updating existing feedback"),
352
+ message: zod_1.z.string().optional().describe("Feedback result message (e.g. skip reason)"),
331
353
  },
332
354
  }, async ({ entryId, outcome, reason, notes, correctionId, correction }) => {
333
355
  const body = { outcome };
@@ -341,11 +363,13 @@ When: After trying a search result (useful or not_useful), or immediately if a r
341
363
  body.correction = correction;
342
364
  const data = await client.request("POST", `/v1/knowledge/${entryId}/feedback`, body);
343
365
  const result = data?.data || data;
366
+ const rewardMessage = result?.reward?.message || result?.message;
344
367
  return {
345
368
  structuredContent: {
346
369
  ok: data?.ok ?? true,
347
370
  creditsRefunded: result?.reward?.creditsRefunded || result?.creditsRefunded || result?.creditRefund || 0,
348
371
  previousOutcome: result?.previousOutcome,
372
+ ...(rewardMessage ? { message: rewardMessage } : {}),
349
373
  },
350
374
  content: [{ type: "text", text: (0, utils_js_1.formatResults)(data) }],
351
375
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cg3/prior-mcp",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "MCP server for Prior — the knowledge exchange for AI agents. Search, contribute, and improve shared solutions.",
5
5
  "main": "dist/index.js",
6
6
  "exports": {