cache-overflow-mcp 0.3.0 → 0.3.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.
Files changed (48) hide show
  1. package/.env.example +3 -3
  2. package/AGENTS.md +235 -0
  3. package/E2E-TESTING.md +5 -5
  4. package/LICENSE +21 -0
  5. package/README.md +13 -6
  6. package/dist/config.js +1 -1
  7. package/dist/config.js.map +1 -1
  8. package/dist/prompts/index.d.ts +1 -0
  9. package/dist/prompts/index.d.ts.map +1 -1
  10. package/dist/prompts/index.js +61 -1
  11. package/dist/prompts/index.js.map +1 -1
  12. package/dist/server.js +1 -1
  13. package/dist/testing/mock-data.js +40 -40
  14. package/dist/tools/find-solution.d.ts.map +1 -1
  15. package/dist/tools/find-solution.js +22 -3
  16. package/dist/tools/find-solution.js.map +1 -1
  17. package/dist/tools/get-balance.d.ts +3 -0
  18. package/dist/tools/get-balance.d.ts.map +1 -0
  19. package/dist/tools/get-balance.js +34 -0
  20. package/dist/tools/get-balance.js.map +1 -0
  21. package/dist/tools/submit-feedback.js +1 -1
  22. package/dist/tools/submit-feedback.js.map +1 -1
  23. package/dist/tools/submit-verification.js +1 -1
  24. package/dist/tools/submit-verification.js.map +1 -1
  25. package/dist/tools/unlock-solution.d.ts.map +1 -1
  26. package/dist/tools/unlock-solution.js +3 -2
  27. package/dist/tools/unlock-solution.js.map +1 -1
  28. package/dist/ui/verification-dialog.js +267 -267
  29. package/package.json +3 -3
  30. package/{mock-server.js → scripts/mock-server.js} +1 -1
  31. package/src/cli.ts +10 -10
  32. package/src/client.test.ts +116 -116
  33. package/src/client.ts +76 -76
  34. package/src/config.ts +9 -9
  35. package/src/index.ts +3 -3
  36. package/src/prompts/index.ts +63 -1
  37. package/src/server.ts +1 -1
  38. package/src/testing/mock-data.ts +142 -142
  39. package/src/testing/mock-server.ts +176 -176
  40. package/src/tools/find-solution.ts +26 -3
  41. package/src/tools/index.ts +23 -23
  42. package/src/tools/submit-feedback.ts +1 -1
  43. package/src/tools/submit-verification.ts +1 -1
  44. package/src/tools/unlock-solution.ts +4 -2
  45. package/src/types.ts +39 -39
  46. package/src/ui/verification-dialog.ts +342 -342
  47. package/tsconfig.json +20 -20
  48. package/test-dialog.js +0 -37
@@ -5,7 +5,7 @@ export const findSolution: ToolDefinition = {
5
5
  definition: {
6
6
  name: 'find_solution',
7
7
  description:
8
- 'Search for existing solutions in the cache.overflow knowledge base. Use this tool PROACTIVELY when facing a non-trivial problem that other agents might have encountered. Returns matching solutions based on semantic similarity. Check this BEFORE spending significant tokens on debugging or trial-and-error approaches.',
8
+ 'Search for existing solutions in the cache.overflow knowledge base. ONLY use this tool when you encounter a DIFFICULT problem that is GENERIC (not project-specific) and might require SEVERAL ITERATIONS to solve. Do NOT use for simple fixes or quick tasks. Returns matching solutions based on semantic similarity. Check this BEFORE spending significant tokens on debugging or trial-and-error approaches.',
9
9
  inputSchema: {
10
10
  type: 'object',
11
11
  properties: {
@@ -42,10 +42,33 @@ export const findSolution: ToolDefinition = {
42
42
  }
43
43
  }
44
44
 
45
- // Add reminder to publish if no results found or after solving
45
+ // Build workflow instructions based on solution types
46
+ const hasVerificationNeeded = result.data.some(s => s.human_verification_required);
47
+ const hasVerifiedSolutions = result.data.some(s => !s.human_verification_required);
48
+
49
+ let workflowInstructions = '';
50
+ if (result.data.length > 0) {
51
+ workflowInstructions = '\n\nšŸ“‹ NEXT STEPS:';
52
+
53
+ if (hasVerificationNeeded) {
54
+ workflowInstructions += '\n\nšŸ”’ For solutions with human_verification_required=true (you already have the full solution body):';
55
+ workflowInstructions += '\n1. Verification has been handled via dialog - you can now use the solution';
56
+ workflowInstructions += '\n2. Try applying the solution (no unlock needed - you already have it)';
57
+ workflowInstructions += '\n3. MUST call submit_feedback with is_useful=true/false after trying the solution';
58
+ }
59
+
60
+ if (hasVerifiedSolutions) {
61
+ workflowInstructions += '\n\nšŸ”“ For solutions with human_verification_required=false (you only have the title):';
62
+ workflowInstructions += '\n1. Assess the query_title to determine if it\'s relevant to your problem';
63
+ workflowInstructions += '\n2. If relevant, you MUST call unlock_solution with solution_id to get the full content';
64
+ workflowInstructions += '\n3. After unlocking and trying the solution, you MUST call submit_feedback with is_useful=true/false';
65
+ }
66
+ }
67
+
68
+ // Combine reminders
46
69
  const reminder = result.data.length === 0
47
70
  ? '\n\nšŸ’” REMINDER: No existing solutions found. If you solve this problem and it required significant effort (multiple iterations, substantial tokens), remember to use publish_solution to help future agents!'
48
- : '\n\nšŸ’” TIP: If none of these solutions work and you find a different approach that works, consider using publish_solution to share your solution.';
71
+ : workflowInstructions + '\n\nšŸ’” TIP: If none of these solutions work and you find a different approach that works, consider using publish_solution to share your solution.';
49
72
 
50
73
  return {
51
74
  content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + reminder }],
@@ -1,23 +1,23 @@
1
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
- import { CacheOverflowClient } from '../client.js';
3
- import { findSolution } from './find-solution.js';
4
- import { unlockSolution } from './unlock-solution.js';
5
- import { publishSolution } from './publish-solution.js';
6
- import { submitVerification } from './submit-verification.js';
7
- import { submitFeedback } from './submit-feedback.js';
8
-
9
- export interface ToolDefinition {
10
- definition: Tool;
11
- handler: (
12
- args: Record<string, unknown>,
13
- client: CacheOverflowClient
14
- ) => Promise<{ content: Array<{ type: string; text: string }> }>;
15
- }
16
-
17
- export const tools: ToolDefinition[] = [
18
- findSolution,
19
- unlockSolution,
20
- publishSolution,
21
- submitVerification,
22
- submitFeedback,
23
- ];
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { CacheOverflowClient } from '../client.js';
3
+ import { findSolution } from './find-solution.js';
4
+ import { unlockSolution } from './unlock-solution.js';
5
+ import { publishSolution } from './publish-solution.js';
6
+ import { submitVerification } from './submit-verification.js';
7
+ import { submitFeedback } from './submit-feedback.js';
8
+
9
+ export interface ToolDefinition {
10
+ definition: Tool;
11
+ handler: (
12
+ args: Record<string, unknown>,
13
+ client: CacheOverflowClient
14
+ ) => Promise<{ content: Array<{ type: string; text: string }> }>;
15
+ }
16
+
17
+ export const tools: ToolDefinition[] = [
18
+ findSolution,
19
+ unlockSolution,
20
+ publishSolution,
21
+ submitVerification,
22
+ submitFeedback,
23
+ ];
@@ -4,7 +4,7 @@ export const submitFeedback: ToolDefinition = {
4
4
  definition: {
5
5
  name: 'submit_feedback',
6
6
  description:
7
- 'Submit usefulness feedback for a solution you have unlocked and applied. This helps improve the knowledge base quality and affects the solution\'s price. Submit feedback after you have tried applying the solution to your problem.',
7
+ 'Submit usefulness feedback for a solution you have tried. CRITICAL: After using a solution (whether unlocked via unlock_solution OR received directly via verification), you MUST call this tool to provide feedback. This helps improve the knowledge base quality and affects the solution\'s price. Rate whether the solution actually helped solve your problem (is_useful=true) or was not applicable/incorrect (is_useful=false).',
8
8
  inputSchema: {
9
9
  type: 'object',
10
10
  properties: {
@@ -4,7 +4,7 @@ export const submitVerification: ToolDefinition = {
4
4
  definition: {
5
5
  name: 'submit_verification',
6
6
  description:
7
- 'Submit a safety verification for an unverified (PENDING) solution. Verify that the solution is not malicious, does not contain harmful code, and appears to be a legitimate attempt to solve the stated problem. You will receive a verification reward for participating. This is typically called automatically when human verification is required during find_solution.',
7
+ 'Submit a safety verification for a solution. Typically called automatically after responding to a verification dialog in find_solution. Can also be called directly if configured to always verify solutions. You will receive a verification reward for participating.',
8
8
  inputSchema: {
9
9
  type: 'object',
10
10
  properties: {
@@ -4,7 +4,7 @@ export const unlockSolution: ToolDefinition = {
4
4
  definition: {
5
5
  name: 'unlock_solution',
6
6
  description:
7
- 'Unlock a verified solution to access its full content. Use this when a search result (from find_solution) appears relevant to your problem. This will deduct tokens from your balance based on the solution\'s price. Only unlock solutions that are likely to save you more tokens than they cost.',
7
+ 'Unlock a verified solution to access its full content. Use this ONLY for solutions where human_verification_required=false (you only received the title from find_solution). Do NOT call this for solutions that required verification - you already have the full content for those. After receiving find_solution results, assess each solution\'s title. If the title indicates the solution is relevant to your problem, you MUST call this tool to unlock it. This will deduct tokens from your balance based on the solution\'s price. Only unlock solutions that are likely to save you more tokens than they cost.',
8
8
  inputSchema: {
9
9
  type: 'object',
10
10
  properties: {
@@ -26,8 +26,10 @@ export const unlockSolution: ToolDefinition = {
26
26
  };
27
27
  }
28
28
 
29
+ const feedbackReminder = '\n\nāš ļø REQUIRED: You MUST now call submit_feedback with this solution_id after you have tried applying the solution. Report whether it was helpful (is_useful=true/false).';
30
+
29
31
  return {
30
- content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
32
+ content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + feedbackReminder }],
31
33
  };
32
34
  },
33
35
  };
package/src/types.ts CHANGED
@@ -1,39 +1,39 @@
1
- export type VerificationState = 'PENDING' | 'VERIFIED' | 'REJECTED';
2
-
3
- export interface Solution {
4
- id: string;
5
- author_id: string;
6
- query_title: string;
7
- solution_body: string;
8
- price_current: number;
9
- verification_state: VerificationState;
10
- access_count: number;
11
- upvotes: number;
12
- downvotes: number;
13
- }
14
-
15
- export interface FindSolutionResult {
16
- solution_id: string;
17
- query_title: string;
18
- solution_body?: string;
19
- human_verification_required: boolean;
20
- }
21
-
22
- export interface Balance {
23
- available: number;
24
- pending_debits: number;
25
- pending_credits: number;
26
- total_earned: number;
27
- total_spent: number;
28
- }
29
-
30
- export interface User {
31
- id: string;
32
- email: string;
33
- tigerbeetle_account_id: string;
34
- is_blocked: boolean;
35
- }
36
-
37
- export type ApiResponse<T> =
38
- | { success: true; data: T }
39
- | { success: false; error: string };
1
+ export type VerificationState = 'PENDING' | 'VERIFIED' | 'REJECTED';
2
+
3
+ export interface Solution {
4
+ id: string;
5
+ author_id: string;
6
+ query_title: string;
7
+ solution_body: string;
8
+ price_current: number;
9
+ verification_state: VerificationState;
10
+ access_count: number;
11
+ upvotes: number;
12
+ downvotes: number;
13
+ }
14
+
15
+ export interface FindSolutionResult {
16
+ solution_id: string;
17
+ query_title: string;
18
+ solution_body?: string;
19
+ human_verification_required: boolean;
20
+ }
21
+
22
+ export interface Balance {
23
+ available: number;
24
+ pending_debits: number;
25
+ pending_credits: number;
26
+ total_earned: number;
27
+ total_spent: number;
28
+ }
29
+
30
+ export interface User {
31
+ id: string;
32
+ email: string;
33
+ tigerbeetle_account_id: string;
34
+ is_blocked: boolean;
35
+ }
36
+
37
+ export type ApiResponse<T> =
38
+ | { success: true; data: T }
39
+ | { success: false; error: string };