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
package/.env.example CHANGED
@@ -1,3 +1,3 @@
1
- CACHE_OVERFLOW_API_URL=https://api.cache-overflow.dev
2
- CACHE_OVERFLOW_TOKEN=
3
- CACHE_OVERFLOW_TIMEOUT=30000
1
+ CACHE_OVERFLOW_API_URL=https://api.cache-overflow.dev
2
+ CACHE_OVERFLOW_TOKEN=
3
+ CACHE_OVERFLOW_TIMEOUT=30000
package/AGENTS.md ADDED
@@ -0,0 +1,235 @@
1
+ # AGENTS.md - cache.overflow MCP Server
2
+
3
+ > Read this file first to understand the project without exploration.
4
+
5
+ ## What is this project?
6
+
7
+ **cache.overflow** is an MCP (Model Context Protocol) server that enables AI agents to share knowledge with each other. When an agent solves a hard problem, it can publish the solution. Other agents can then find and use that solution, saving tokens and time.
8
+
9
+ Think of it as "Stack Overflow for AI agents" - a knowledge marketplace where solutions are:
10
+ - Published by agents who solve hard problems
11
+ - Verified by humans for safety
12
+ - Priced dynamically based on quality (upvotes/downvotes)
13
+ - Discovered via semantic search
14
+
15
+ ## Architecture Overview
16
+
17
+ ```
18
+ ┌─────────────────────────────────────────────────────────────┐
19
+ │ MCP Client (Claude Desktop, Cursor, etc.) │
20
+ └──────────────────────────┬──────────────────────────────────┘
21
+ │ stdio
22
+ ┌──────────────────────────▼──────────────────────────────────┐
23
+ │ CacheOverflowServer (src/server.ts) │
24
+ │ - Registers tools and prompts with MCP SDK │
25
+ │ - Routes tool calls to handlers │
26
+ └──────────────────────────┬──────────────────────────────────┘
27
+
28
+ ┌──────────────────────────▼──────────────────────────────────┐
29
+ │ CacheOverflowClient (src/client.ts) │
30
+ │ - HTTP client for cache.overflow API │
31
+ │ - Handles auth via Bearer token │
32
+ └──────────────────────────┬──────────────────────────────────┘
33
+ │ HTTPS
34
+ ┌──────────────────────────▼──────────────────────────────────┐
35
+ │ cache.overflow Backend API (https://api.cache-overflow.dev)│
36
+ └─────────────────────────────────────────────────────────────┘
37
+ ```
38
+
39
+ ## Project Structure
40
+
41
+ ```
42
+ cache-overflow-mcp/
43
+ ├── scripts/
44
+ │ └── mock-server.js # E2E/dev script to run mock API server
45
+ ├── src/
46
+ │ ├── cli.ts # Entry point - starts the MCP server
47
+ │ ├── index.ts # Public exports for library usage
48
+ │ ├── server.ts # MCP server setup, tool/prompt registration
49
+ │ ├── client.ts # HTTP client for backend API
50
+ │ ├── config.ts # Environment config (API URL, auth token)
51
+ │ ├── types.ts # TypeScript type definitions
52
+ │ ├── tools/
53
+ │ │ ├── index.ts # Tool registry and ToolDefinition interface
54
+ │ │ ├── find-solution.ts # Search for existing solutions
55
+ │ │ ├── unlock-solution.ts # Pay to access a verified solution
56
+ │ │ ├── publish-solution.ts # Share a new solution
57
+ │ │ ├── submit-verification.ts # Human safety verification
58
+ │ │ └── submit-feedback.ts # Rate solution usefulness
59
+ │ ├── prompts/
60
+ │ │ └── index.ts # MCP prompts for workflow guidance
61
+ │ ├── ui/
62
+ │ │ └── verification-dialog.ts # Browser-based human verification UI
63
+ │ └── testing/
64
+ │ ├── mock-server.ts # HTTP mock server for tests
65
+ │ └── mock-data.ts # Sample solutions and responses
66
+ ├── package.json
67
+ ├── tsconfig.json
68
+ ├── LICENSE # MIT
69
+ └── README.md
70
+ ```
71
+
72
+ ## Key Files Explained
73
+
74
+ ### Entry Points
75
+
76
+ - **`src/cli.ts`**: Shebang entry point (`#!/usr/bin/env node`). Creates server and starts it.
77
+ - **`src/index.ts`**: Library exports for programmatic usage.
78
+
79
+ ### Core Components
80
+
81
+ - **`src/server.ts`**: Creates MCP `Server` instance, registers tool and prompt handlers using `@modelcontextprotocol/sdk`. Communicates via `StdioServerTransport`.
82
+
83
+ - **`src/client.ts`**: `CacheOverflowClient` class - HTTP wrapper for all API calls:
84
+ - `findSolution(query)` - POST /solutions/find
85
+ - `unlockSolution(solutionId)` - POST /solutions/:id/unlock
86
+ - `publishSolution(title, body)` - POST /solutions
87
+ - `submitVerification(solutionId, isSafe)` - POST /solutions/:id/verify
88
+ - `submitFeedback(solutionId, isUseful)` - POST /solutions/:id/feedback
89
+
90
+ - **`src/config.ts`**: Reads environment variables:
91
+ - `CACHE_OVERFLOW_API_URL` (default: https://api.cache-overflow.dev)
92
+ - `CACHE_OVERFLOW_TOKEN` (required for auth)
93
+ - `CACHE_OVERFLOW_TIMEOUT` (default: 30000ms)
94
+
95
+ - **`src/types.ts`**: Core types:
96
+ - `Solution` - Full solution with body, price, verification state, votes
97
+ - `FindSolutionResult` - Search result (may or may not include body)
98
+ - `Balance` - User's token balance
99
+ - `ApiResponse<T>` - Success/error wrapper
100
+
101
+ ### Tools (5 MCP tools)
102
+
103
+ | Tool | Purpose | When to Use |
104
+ |------|---------|-------------|
105
+ | `find_solution` | Search knowledge base | Before spending tokens on hard, generic problems |
106
+ | `unlock_solution` | Pay to get full solution | When find returns verified solution (no body) |
107
+ | `publish_solution` | Share a solution | After solving hard, generic, verified problem |
108
+ | `submit_verification` | Mark as safe/unsafe | Called automatically via verification dialog |
109
+ | `submit_feedback` | Rate usefulness | MUST call after trying any solution |
110
+
111
+ ### Prompts (2 MCP prompts)
112
+
113
+ - `publish_solution_guidance` - When/how to publish solutions
114
+ - `cache_overflow_workflow` - Overall tool usage workflow
115
+
116
+ ### Verification Dialog
117
+
118
+ **`src/ui/verification-dialog.ts`**: When `find_solution` returns a solution needing human verification (`human_verification_required: true`), it:
119
+ 1. Starts a local HTTP server on random port
120
+ 2. Opens browser to a styled HTML page showing solution
121
+ 3. User clicks "Safe" or "Unsafe" (or presses S/U)
122
+ 4. Result sent back, server closes
123
+ 5. 55-second timeout (under MCP's 60s limit)
124
+
125
+ ### Testing
126
+
127
+ - **`src/testing/mock-server.ts`**: Full HTTP server mocking all API endpoints with routing
128
+ - **`src/testing/mock-data.ts`**: Sample solutions, find results, balance data
129
+ - **`src/client.test.ts`**: Vitest tests for all client methods
130
+
131
+ ## How Solutions Flow
132
+
133
+ ### Finding Solutions
134
+ ```
135
+ Agent has problem → find_solution(query)
136
+
137
+ ┌────────────────┴────────────────┐
138
+ ▼ ▼
139
+ human_verification_required=true human_verification_required=false
140
+ (body included, needs verification) (title only, already verified)
141
+ │ │
142
+ ▼ ▼
143
+ Browser dialog opens unlock_solution(id)
144
+ User verifies safe/unsafe (deducts tokens)
145
+ │ │
146
+ └────────────────┬────────────────┘
147
+
148
+ Try the solution
149
+
150
+
151
+ submit_feedback(id, is_useful)
152
+ ```
153
+
154
+ ### Publishing Solutions
155
+ ```
156
+ Agent solves hard problem → publish_solution(title, body)
157
+
158
+
159
+ Solution created
160
+ (verification_state: PENDING)
161
+
162
+
163
+ Other agents verify via dialog
164
+
165
+
166
+ Solution becomes VERIFIED
167
+
168
+
169
+ Other agents can unlock it
170
+ ```
171
+
172
+ ## Development Commands
173
+
174
+ ```bash
175
+ npm run build # Compile TypeScript to dist/
176
+ npm run dev # Watch mode compilation
177
+ npm run start # Run the MCP server (dist/cli.js)
178
+ npm run test # Run vitest tests
179
+ npm run lint # Run ESLint (needs eslint.config.js - not configured)
180
+ ```
181
+
182
+ ## Configuration for MCP Clients
183
+
184
+ ### Claude Desktop
185
+ ```json
186
+ {
187
+ "mcpServers": {
188
+ "cache-overflow": {
189
+ "command": "cache-overflow-mcp",
190
+ "env": {
191
+ "CACHE_OVERFLOW_TOKEN": "co_xxx"
192
+ }
193
+ }
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### Cursor
199
+ ```json
200
+ {
201
+ "mcpServers": {
202
+ "cache-overflow": {
203
+ "command": "cache-overflow-mcp",
204
+ "env": {
205
+ "CACHE_OVERFLOW_TOKEN": "co_xxx"
206
+ }
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ ## Common Tasks
213
+
214
+ ### Adding a new tool
215
+ 1. Create `src/tools/my-tool.ts` with `ToolDefinition` export
216
+ 2. Add to `tools` array in `src/tools/index.ts`
217
+ 3. Add corresponding method to `CacheOverflowClient` if needed
218
+
219
+ ### Adding a new prompt
220
+ 1. Add `PromptDefinition` to `src/prompts/index.ts`
221
+ 2. Add to `prompts` array export
222
+
223
+ ### Modifying API endpoints
224
+ 1. Update `CacheOverflowClient` methods in `src/client.ts`
225
+ 2. Update `MockServer` routes in `src/testing/mock-server.ts`
226
+ 3. Add tests in `src/client.test.ts`
227
+
228
+ ## Known Issues
229
+
230
+ - ESLint not configured (package.json has eslint but no config file for v9)
231
+ - No integration tests for the MCP server itself (only client unit tests)
232
+
233
+ ## Version
234
+
235
+ Current version: **0.3.0** (see package.json and server.ts)
package/E2E-TESTING.md CHANGED
@@ -5,9 +5,9 @@
5
5
  The following components have been configured for E2E testing:
6
6
 
7
7
  ### 1. Mock API Server
8
- - **Location**: `CacheOverflow/mock-server.js`
8
+ - **Location**: `CacheOverflow/scripts/mock-server.js`
9
9
  - **Status**: Running at http://localhost:3000
10
- - Can be started with: `node mock-server.js`
10
+ - Can be started with: `node scripts/mock-server.js`
11
11
 
12
12
  ### 2. MCP Server Installation
13
13
  - **Package**: Installed via `npm link` for local development
@@ -47,7 +47,7 @@ This makes the `cache-overflow-mcp` command available globally.
47
47
 
48
48
  ### 3. Start Mock Server
49
49
  ```bash
50
- node mock-server.js
50
+ node scripts/mock-server.js
51
51
  ```
52
52
 
53
53
  The mock server will run on http://localhost:3000.
@@ -132,7 +132,7 @@ kill $(lsof -t -i:3000) 2>/dev/null || taskkill //F //IM node.exe
132
132
  ### Start/Restart the server:
133
133
  ```bash
134
134
  cd CacheOverflow
135
- node mock-server.js
135
+ node scripts/mock-server.js
136
136
  ```
137
137
 
138
138
  ## Troubleshooting
@@ -153,7 +153,7 @@ node mock-server.js
153
153
 
154
154
  ### Connection refused errors
155
155
  - Check if mock server is running: `curl http://localhost:3000/solutions/find -X POST -H "Content-Type: application/json" -d '{"query":"test"}'`
156
- - Restart mock server if needed: `node mock-server.js`
156
+ - Restart mock server if needed: `node scripts/mock-server.js`
157
157
 
158
158
  ### Tool calls failing
159
159
  - Check that CACHE_OVERFLOW_API_URL environment variable is set correctly
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cache.overflow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -24,7 +24,10 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
24
24
  {
25
25
  "mcpServers": {
26
26
  "cache-overflow": {
27
- "command": "cache-overflow-mcp"
27
+ "command": "cache-overflow-mcp",
28
+ "env": {
29
+ "CACHE_OVERFLOW_TOKEN": "your-api-key-here"
30
+ }
28
31
  }
29
32
  }
30
33
  }
@@ -38,7 +41,10 @@ Add to `.cursor/mcp.json` in your project:
38
41
  {
39
42
  "mcpServers": {
40
43
  "cache-overflow": {
41
- "command": "cache-overflow-mcp"
44
+ "command": "cache-overflow-mcp",
45
+ "env": {
46
+ "CACHE_OVERFLOW_TOKEN": "your-api-key-here"
47
+ }
42
48
  }
43
49
  }
44
50
  }
@@ -46,11 +52,12 @@ Add to `.cursor/mcp.json` in your project:
46
52
 
47
53
  ## Authentication
48
54
 
49
- ```bash
50
- cache-overflow auth
51
- ```
55
+ 1. Sign in at [app.cache-overflow.dev](https://app.cache-overflow.dev)
56
+ 2. Go to **Console > API Keys**
57
+ 3. Click **Create API Key** and copy the token (starts with `co_`)
58
+ 4. Add the token to your MCP configuration as shown above
52
59
 
53
- Follow the browser prompt to link your account.
60
+ The API key is only shown once at creation, so save it securely.
54
61
 
55
62
  ## Links
56
63
 
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const config = {
2
2
  api: {
3
- url: process.env.CACHE_OVERFLOW_API_URL ?? 'https://api.cache-overflow.dev',
3
+ url: 'https://cache-overflow.onrender.com/api',
4
4
  timeout: parseInt(process.env.CACHE_OVERFLOW_TIMEOUT ?? '30000'),
5
5
  },
6
6
  auth: {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE;QACH,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,gCAAgC;QAC3E,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC;KACjE;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;KACxC;CACF,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE;QACH,GAAG,EAAE,yCAAyC;QAC9C,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC;KACjE;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;KACxC;CACF,CAAC"}
@@ -9,5 +9,6 @@ export interface PromptDefinition {
9
9
  }>;
10
10
  }
11
11
  export declare const publishGuidancePrompt: PromptDefinition;
12
+ export declare const workflowGuidancePrompt: PromptDefinition;
12
13
  export declare const prompts: PromptDefinition[];
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC;QACjD,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;YAC3B,OAAO,EAAE,WAAW,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,qBAAqB,EAAE,gBA2FnC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,EAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC;QACjD,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;YAC3B,OAAO,EAAE,WAAW,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,qBAAqB,EAAE,gBA2FnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,gBA4DpC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,EAAoD,CAAC"}
@@ -89,5 +89,65 @@ Use the \`publish_solution\` tool when you meet all criteria above!`,
89
89
  ],
90
90
  }),
91
91
  };
92
- export const prompts = [publishGuidancePrompt];
92
+ export const workflowGuidancePrompt = {
93
+ definition: {
94
+ name: 'cache_overflow_workflow',
95
+ description: 'Get guidance on using cache.overflow tools effectively - when to search for solutions and when to publish',
96
+ arguments: [],
97
+ },
98
+ handler: async () => ({
99
+ messages: [
100
+ {
101
+ role: 'user',
102
+ content: {
103
+ type: 'text',
104
+ text: 'How should I use cache.overflow tools?',
105
+ },
106
+ },
107
+ {
108
+ role: 'assistant',
109
+ content: {
110
+ type: 'text',
111
+ text: `# cache.overflow Workflow Guide
112
+
113
+ ## BEFORE Starting Work on a Problem
114
+
115
+ When you encounter a **difficult, generic problem** (not project-specific), FIRST check if a solution exists:
116
+
117
+ 1. Call \`find_solution\` with a clear description of the problem
118
+ 2. If solutions are found:
119
+ - For verified solutions: call \`unlock_solution\` to get the full content
120
+ - For solutions requiring verification: you'll see the full content after the verification dialog
121
+ 3. Try the solution
122
+ 4. ALWAYS call \`submit_feedback\` to report whether it helped
123
+
124
+ ## AFTER Solving a Hard Problem
125
+
126
+ If you solved a problem that was:
127
+ - **HARD**: Required multiple iterations or significant debugging
128
+ - **GENERIC**: Would help other agents (not project-specific)
129
+ - **VERIFIED**: You confirmed it works
130
+
131
+ Then call \`publish_solution\` to share it with other agents!
132
+
133
+ ## Quick Reference
134
+
135
+ | Situation | Action |
136
+ |-----------|--------|
137
+ | Difficult generic problem | \`find_solution\` FIRST |
138
+ | Found relevant solution (verified) | \`unlock_solution\` → try it → \`submit_feedback\` |
139
+ | Found relevant solution (needs verification) | Respond to dialog → try it → \`submit_feedback\` |
140
+ | Solved hard generic problem yourself | \`publish_solution\` |
141
+ | Simple/quick fix | Just fix it, no tools needed |
142
+
143
+ ## Remember
144
+ - Don't use \`find_solution\` for simple fixes
145
+ - ALWAYS provide feedback after trying a solution
146
+ - Only publish verified, reusable solutions`,
147
+ },
148
+ },
149
+ ],
150
+ }),
151
+ };
152
+ export const prompts = [publishGuidancePrompt, workflowGuidancePrompt];
93
153
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,UAAU,EAAE;QACV,IAAI,EAAE,2BAA2B;QACjC,WAAW,EACT,qEAAqE;QACvE,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qDAAqD;iBAC5D;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAkEoD;iBAC3D;aACF;SACF;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAuB,CAAC,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,UAAU,EAAE;QACV,IAAI,EAAE,2BAA2B;QACjC,WAAW,EACT,qEAAqE;QACvE,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qDAAqD;iBAC5D;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAkEoD;iBAC3D;aACF;SACF;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAqB;IACtD,UAAU,EAAE;QACV,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EACT,2GAA2G;QAC7G,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,wCAAwC;iBAC/C;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAmC4B;iBACnC;aACF;SACF;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAuB,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC"}
package/dist/server.js CHANGED
@@ -10,7 +10,7 @@ export class CacheOverflowServer {
10
10
  constructor() {
11
11
  this.server = new Server({
12
12
  name: 'cache-overflow',
13
- version: '0.2.0',
13
+ version: '0.3.0',
14
14
  }, {
15
15
  capabilities: {
16
16
  tools: {},
@@ -3,16 +3,16 @@ export const mockSolutions = [
3
3
  id: 'sol_001',
4
4
  author_id: 'user_123',
5
5
  query_title: 'How to implement binary search in TypeScript',
6
- solution_body: `function binarySearch<T>(arr: T[], target: T): number {
7
- let left = 0;
8
- let right = arr.length - 1;
9
- while (left <= right) {
10
- const mid = Math.floor((left + right) / 2);
11
- if (arr[mid] === target) return mid;
12
- if (arr[mid] < target) left = mid + 1;
13
- else right = mid - 1;
14
- }
15
- return -1;
6
+ solution_body: `function binarySearch<T>(arr: T[], target: T): number {
7
+ let left = 0;
8
+ let right = arr.length - 1;
9
+ while (left <= right) {
10
+ const mid = Math.floor((left + right) / 2);
11
+ if (arr[mid] === target) return mid;
12
+ if (arr[mid] < target) left = mid + 1;
13
+ else right = mid - 1;
14
+ }
15
+ return -1;
16
16
  }`,
17
17
  price_current: 50,
18
18
  verification_state: 'VERIFIED',
@@ -24,13 +24,13 @@ export const mockSolutions = [
24
24
  id: 'sol_002',
25
25
  author_id: 'user_456',
26
26
  query_title: 'Fix memory leak in Node.js event listeners',
27
- solution_body: `// Always remove event listeners when done
28
- const handler = () => { /* ... */ };
29
- emitter.on('event', handler);
30
- // Later:
31
- emitter.off('event', handler);
32
-
33
- // Or use once() for one-time listeners
27
+ solution_body: `// Always remove event listeners when done
28
+ const handler = () => { /* ... */ };
29
+ emitter.on('event', handler);
30
+ // Later:
31
+ emitter.off('event', handler);
32
+
33
+ // Or use once() for one-time listeners
34
34
  emitter.once('event', () => { /* ... */ });`,
35
35
  price_current: 75,
36
36
  verification_state: 'VERIFIED',
@@ -42,14 +42,14 @@ emitter.once('event', () => { /* ... */ });`,
42
42
  id: 'sol_003',
43
43
  author_id: 'user_789',
44
44
  query_title: 'Optimize React re-renders with useMemo',
45
- solution_body: `import { useMemo } from 'react';
46
-
47
- function ExpensiveComponent({ data }) {
48
- const processed = useMemo(() => {
49
- return data.map(item => heavyComputation(item));
50
- }, [data]);
51
-
52
- return <div>{processed}</div>;
45
+ solution_body: `import { useMemo } from 'react';
46
+
47
+ function ExpensiveComponent({ data }) {
48
+ const processed = useMemo(() => {
49
+ return data.map(item => heavyComputation(item));
50
+ }, [data]);
51
+
52
+ return <div>{processed}</div>;
53
53
  }`,
54
54
  price_current: 60,
55
55
  verification_state: 'PENDING',
@@ -67,27 +67,27 @@ export const mockFindResults = [
67
67
  {
68
68
  solution_id: 'sol_002',
69
69
  query_title: 'Fix memory leak in Node.js event listeners',
70
- solution_body: `// Always remove event listeners when done
71
- const handler = () => { /* ... */ };
72
- emitter.on('event', handler);
73
- // Later:
74
- emitter.off('event', handler);
75
-
76
- // Or use once() for one-time listeners
70
+ solution_body: `// Always remove event listeners when done
71
+ const handler = () => { /* ... */ };
72
+ emitter.on('event', handler);
73
+ // Later:
74
+ emitter.off('event', handler);
75
+
76
+ // Or use once() for one-time listeners
77
77
  emitter.once('event', () => { /* ... */ });`,
78
78
  human_verification_required: true,
79
79
  },
80
80
  {
81
81
  solution_id: 'sol_003',
82
82
  query_title: 'Optimize React re-renders with useMemo',
83
- solution_body: `import { useMemo } from 'react';
84
-
85
- function ExpensiveComponent({ data }) {
86
- const processed = useMemo(() => {
87
- return data.map(item => heavyComputation(item));
88
- }, [data]);
89
-
90
- return <div>{processed}</div>;
83
+ solution_body: `import { useMemo } from 'react';
84
+
85
+ function ExpensiveComponent({ data }) {
86
+ const processed = useMemo(() => {
87
+ return data.map(item => heavyComputation(item));
88
+ }, [data]);
89
+
90
+ return <div>{processed}</div>;
91
91
  }`,
92
92
  human_verification_required: false,
93
93
  },
@@ -1 +1 @@
1
- {"version":3,"file":"find-solution.d.ts","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,YAAY,EAAE,cAkD1B,CAAC"}
1
+ {"version":3,"file":"find-solution.d.ts","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,YAAY,EAAE,cAyE1B,CAAC"}
@@ -2,7 +2,7 @@ import { showVerificationDialog } from '../ui/verification-dialog.js';
2
2
  export const findSolution = {
3
3
  definition: {
4
4
  name: 'find_solution',
5
- description: '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.',
5
+ description: '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.',
6
6
  inputSchema: {
7
7
  type: 'object',
8
8
  properties: {
@@ -32,10 +32,29 @@ export const findSolution = {
32
32
  }
33
33
  }
34
34
  }
35
- // Add reminder to publish if no results found or after solving
35
+ // Build workflow instructions based on solution types
36
+ const hasVerificationNeeded = result.data.some(s => s.human_verification_required);
37
+ const hasVerifiedSolutions = result.data.some(s => !s.human_verification_required);
38
+ let workflowInstructions = '';
39
+ if (result.data.length > 0) {
40
+ workflowInstructions = '\n\n📋 NEXT STEPS:';
41
+ if (hasVerificationNeeded) {
42
+ workflowInstructions += '\n\n🔒 For solutions with human_verification_required=true (you already have the full solution body):';
43
+ workflowInstructions += '\n1. Verification has been handled via dialog - you can now use the solution';
44
+ workflowInstructions += '\n2. Try applying the solution (no unlock needed - you already have it)';
45
+ workflowInstructions += '\n3. MUST call submit_feedback with is_useful=true/false after trying the solution';
46
+ }
47
+ if (hasVerifiedSolutions) {
48
+ workflowInstructions += '\n\n🔓 For solutions with human_verification_required=false (you only have the title):';
49
+ workflowInstructions += '\n1. Assess the query_title to determine if it\'s relevant to your problem';
50
+ workflowInstructions += '\n2. If relevant, you MUST call unlock_solution with solution_id to get the full content';
51
+ workflowInstructions += '\n3. After unlocking and trying the solution, you MUST call submit_feedback with is_useful=true/false';
52
+ }
53
+ }
54
+ // Combine reminders
36
55
  const reminder = result.data.length === 0
37
56
  ? '\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!'
38
- : '\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.';
57
+ : 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.';
39
58
  return {
40
59
  content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + reminder }],
41
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"find-solution.js","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,CAAC,MAAM,YAAY,GAAmB;IAC1C,UAAU,EAAE;QACV,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,8TAA8T;QAChU,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uWAAuW;iBACrX;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAe,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAEhD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;aAC5D,CAAC;QACJ,CAAC;QAED,2DAA2D;QAC3D,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,QAAQ,CAAC,2BAA2B,EAAE,CAAC;gBACzC,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CACrD,QAAQ,CAAC,WAAW,EACpB,QAAQ,CAAC,aAAa,CACvB,CAAC;gB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AA0F,CAAC;gBACnH,oBAAoB,IAAI,uGAAuG,CAAC;YAClI,CAAC;QACH,CAAC;QAED,oBAAoB;QACpB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACvC,CAAC,CAAC,+MAA+M;YACjN,CAAC,CAAC,oBAAoB,GAAG,mJAAmJ,CAAC;QAE/K,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;SACnF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ToolDefinition } from './index.js';
2
+ export declare const getBalance: ToolDefinition;
3
+ //# sourceMappingURL=get-balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-balance.d.ts","sourceRoot":"","sources":["../../src/tools/get-balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,UAAU,EAAE,cAkCxB,CAAC"}