sqlew 5.0.5 → 5.0.7
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 +26 -0
- package/README.md +5 -6
- package/dist/cli/hooks/on-prompt.d.ts +49 -0
- package/dist/cli/hooks/on-prompt.d.ts.map +1 -0
- package/dist/cli/hooks/on-prompt.js +104 -0
- package/dist/cli/hooks/on-prompt.js.map +1 -0
- package/dist/cli/hooks/stdin-parser.d.ts +11 -0
- package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
- package/dist/cli/hooks/stdin-parser.js +20 -0
- package/dist/cli/hooks/stdin-parser.js.map +1 -1
- package/dist/cli/hooks/track-plan.d.ts.map +1 -1
- package/dist/cli/hooks/track-plan.js +19 -17
- package/dist/cli/hooks/track-plan.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -7
- package/dist/cli.js.map +1 -1
- package/dist/config/global-config.d.ts +2 -0
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js.map +1 -1
- package/dist/index.js +10 -35
- package/dist/index.js.map +1 -1
- package/dist/init-rules.d.ts +15 -16
- package/dist/init-rules.d.ts.map +1 -1
- package/dist/init-rules.js +36 -92
- package/dist/init-rules.js.map +1 -1
- package/dist/server/tool-handlers.d.ts +3 -3
- package/dist/server/tool-handlers.d.ts.map +1 -1
- package/dist/server/tool-handlers.js +4 -4
- package/dist/server/tool-handlers.js.map +1 -1
- package/dist/server/tool-registration.d.ts +18 -0
- package/dist/server/tool-registration.d.ts.map +1 -0
- package/dist/server/tool-registration.js +42 -0
- package/dist/server/tool-registration.js.map +1 -0
- package/dist/server/tool-registry.d.ts +8 -3
- package/dist/server/tool-registry.d.ts.map +1 -1
- package/dist/server/tool-registry.js +15 -263
- package/dist/server/tool-registry.js.map +1 -1
- package/dist/server/tool-schemas.d.ts +141 -0
- package/dist/server/tool-schemas.d.ts.map +1 -0
- package/dist/server/tool-schemas.js +160 -0
- package/dist/server/tool-schemas.js.map +1 -0
- package/dist/tools/constraints/actions/get.js +5 -5
- package/package.json +3 -2
- package/assets/claude-md-snippets/plan-mode-integration.md +0 -107
- package/assets/claude-md-snippets/queue-monitoring.md +0 -84
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const cliCommands = [
|
|
|
17
17
|
'db:dump', 'db:export', 'db:import', 'query',
|
|
18
18
|
'suggest', 'track-plan', 'save', 'check-completion', 'mark-done', 'init',
|
|
19
19
|
// Hook events (v4.2.0+, v5.0.0+)
|
|
20
|
-
'on-subagent-stop', 'on-stop', 'on-enter-plan', 'on-exit-plan', 'on-session-start',
|
|
20
|
+
'on-subagent-stop', 'on-stop', 'on-enter-plan', 'on-exit-plan', 'on-session-start', 'on-prompt',
|
|
21
21
|
];
|
|
22
22
|
// CLI flags that should route to CLI (not MCP server)
|
|
23
23
|
const cliFlags = ['--init', '--help', '--version'];
|
|
@@ -39,12 +39,10 @@ else {
|
|
|
39
39
|
// MCP Server
|
|
40
40
|
// ============================================================================
|
|
41
41
|
async function startMcpServer() {
|
|
42
|
-
const {
|
|
42
|
+
const { McpServer } = await import('@modelcontextprotocol/sdk/server/mcp.js');
|
|
43
43
|
const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
|
|
44
|
-
const { CallToolRequestSchema, ListToolsRequestSchema, } = await import('@modelcontextprotocol/sdk/types.js');
|
|
45
44
|
const { parseArgs, validateArgs } = await import('./server/arg-parser.js');
|
|
46
|
-
const {
|
|
47
|
-
const { handleToolCall } = await import('./server/tool-handlers.js');
|
|
45
|
+
const { registerAllTools } = await import('./server/tool-registration.js');
|
|
48
46
|
const { initializeServer } = await import('./server/setup.js');
|
|
49
47
|
const { registerShutdownHandlers, performCleanup } = await import('./server/shutdown.js');
|
|
50
48
|
const { handleInitializationError, safeConsoleError } = await import('./utils/error-handler.js');
|
|
@@ -61,41 +59,18 @@ async function startMcpServer() {
|
|
|
61
59
|
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
62
60
|
process.exit(1);
|
|
63
61
|
}
|
|
64
|
-
// Create MCP server
|
|
65
|
-
|
|
66
|
-
// See: @modelcontextprotocol/sdk/server/mcp.js
|
|
67
|
-
const server = new Server({
|
|
62
|
+
// Create MCP server (McpServer wraps the low-level Server)
|
|
63
|
+
const mcpServer = new McpServer({
|
|
68
64
|
name: 'sqlew',
|
|
69
|
-
version: '5.0.
|
|
65
|
+
version: '5.0.7',
|
|
70
66
|
}, {
|
|
71
67
|
capabilities: {
|
|
72
68
|
tools: {},
|
|
73
69
|
},
|
|
74
70
|
});
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
tools: getToolRegistry(),
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
// Flag for one-time agent name initialization
|
|
82
|
-
let agentNameInitialized = false;
|
|
83
|
-
// Handle tool execution
|
|
84
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
85
|
-
// Lazy initialization of agent name (after MCP handshake is complete)
|
|
86
|
-
if (!agentNameInitialized) {
|
|
87
|
-
agentNameInitialized = true;
|
|
88
|
-
const clientVersion = server.getClientVersion();
|
|
89
|
-
if (clientVersion?.name) {
|
|
90
|
-
const { getBackend } = await import('./backend/backend-factory.js');
|
|
91
|
-
const backend = getBackend();
|
|
92
|
-
if (backend.setAgentName) {
|
|
93
|
-
backend.setAgentName(clientVersion.name);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return await handleToolCall(request);
|
|
98
|
-
});
|
|
71
|
+
// Register all tools via McpServer.registerTool() API
|
|
72
|
+
// Handles ListTools + CallTool automatically (no manual setRequestHandler needed)
|
|
73
|
+
registerAllTools(mcpServer);
|
|
99
74
|
// Setup centralized global error handlers
|
|
100
75
|
registerShutdownHandlers();
|
|
101
76
|
// Start server
|
|
@@ -107,7 +82,7 @@ async function startMcpServer() {
|
|
|
107
82
|
// Connect MCP server transport FIRST (before any stderr writes)
|
|
108
83
|
// This prevents EPIPE errors with clients expecting pure JSON-RPC protocol
|
|
109
84
|
const transport = new StdioServerTransport();
|
|
110
|
-
await
|
|
85
|
+
await mcpServer.connect(transport);
|
|
111
86
|
// NOW safe to write diagnostic messages (using EPIPE-safe wrapper)
|
|
112
87
|
safeConsoleError('✓ MCP Shared Context Server running on stdio');
|
|
113
88
|
const dbPath = parsedArgs.dbPath || setupResult.fileConfig.database?.path;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,+EAA+E;AAC/E,gEAAgE;AAChE,+EAA+E;AAC/E,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAElC,yCAAyC;AACzC,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO;IAC5C,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM;IACxE,iCAAiC;IACjC,kBAAkB,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,+EAA+E;AAC/E,gEAAgE;AAChE,+EAA+E;AAC/E,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAElC,yCAAyC;AACzC,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO;IAC5C,SAAS,EAAE,YAAY,EAAE,MAAM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AAC,sBAAsB,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,uDAAuD,EAAE,KAAK,CAAC,CAAC;YAC9E,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAC1C,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,oEAAoE;QACpE,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEjC,cAAc,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/init-rules.d.ts
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-initialize sqlew on server startup
|
|
3
3
|
*
|
|
4
|
-
* As of v5.0.
|
|
5
|
-
* -
|
|
4
|
+
* As of v5.0.6, this module handles:
|
|
5
|
+
* - Cleanup of legacy CLAUDE.md injection (~/.claude/CLAUDE.md)
|
|
6
6
|
* - Project .gitignore updates
|
|
7
7
|
*
|
|
8
|
+
* Plan mode enforcement is now handled by:
|
|
9
|
+
* - UserPromptSubmit hook (on-prompt.ts) with permission_mode check
|
|
10
|
+
* - PreToolUse hook (track-plan.ts) for EnterPlanMode
|
|
11
|
+
* - Enhanced Skills (sqlew-decision-format, sqlew-plan-guidance)
|
|
12
|
+
*
|
|
8
13
|
* Skills and Hooks are managed by the sqlew-plugin (Claude Code Plugin).
|
|
9
14
|
* @see https://github.com/sqlew-io/sqlew-plugin for Skills/Hooks/Agents
|
|
10
15
|
*/
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* As of v5.0.0, snippets are injected directly into CLAUDE.md instead of
|
|
15
|
-
* being copied to ~/.claude/rules/sqlew/. This ensures higher priority
|
|
16
|
-
* and better compatibility with other CLI tools (Codex, Gemini CLI).
|
|
17
|
+
* Clean up legacy sqlew injection from global ~/.claude/CLAUDE.md
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* - No impact on Markdown rendering
|
|
19
|
+
* As of v5.0.6, plan mode enforcement is handled by Hooks (UserPromptSubmit)
|
|
20
|
+
* instead of CLAUDE.md injection. This function removes the legacy injected
|
|
21
|
+
* section (between <!-- sqlew:auto-injected:start/end --> markers).
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* Use server.getClientVersion() after MCP initialization
|
|
23
|
+
* Safe to call multiple times - does nothing if no markers found.
|
|
25
24
|
*/
|
|
26
|
-
export declare function
|
|
25
|
+
export declare function cleanupGlobalClaudeMd(): void;
|
|
27
26
|
/**
|
|
28
27
|
* Initialize sqlew on MCP server startup
|
|
29
28
|
*
|
|
30
|
-
* As of v5.0.
|
|
31
|
-
* -
|
|
29
|
+
* As of v5.0.6:
|
|
30
|
+
* - Cleans up legacy CLAUDE.md injection (one-time)
|
|
32
31
|
* - Updates project .gitignore
|
|
33
32
|
*
|
|
34
33
|
* @param projectRoot - Project root directory (for .gitignore updates)
|
package/dist/init-rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-rules.d.ts","sourceRoot":"","sources":["../src/init-rules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init-rules.d.ts","sourceRoot":"","sources":["../src/init-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkBH;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CA8B5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAQ9D;AAoBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAkE7D"}
|
package/dist/init-rules.js
CHANGED
|
@@ -1,133 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-initialize sqlew on server startup
|
|
3
3
|
*
|
|
4
|
-
* As of v5.0.
|
|
5
|
-
* -
|
|
4
|
+
* As of v5.0.6, this module handles:
|
|
5
|
+
* - Cleanup of legacy CLAUDE.md injection (~/.claude/CLAUDE.md)
|
|
6
6
|
* - Project .gitignore updates
|
|
7
7
|
*
|
|
8
|
+
* Plan mode enforcement is now handled by:
|
|
9
|
+
* - UserPromptSubmit hook (on-prompt.ts) with permission_mode check
|
|
10
|
+
* - PreToolUse hook (track-plan.ts) for EnterPlanMode
|
|
11
|
+
* - Enhanced Skills (sqlew-decision-format, sqlew-plan-guidance)
|
|
12
|
+
*
|
|
8
13
|
* Skills and Hooks are managed by the sqlew-plugin (Claude Code Plugin).
|
|
9
14
|
* @see https://github.com/sqlew-io/sqlew-plugin for Skills/Hooks/Agents
|
|
10
15
|
*/
|
|
11
16
|
import * as fs from 'fs';
|
|
12
17
|
import * as path from 'path';
|
|
13
18
|
import * as os from 'os';
|
|
14
|
-
import { fileURLToPath } from 'url';
|
|
15
19
|
import { debugLog } from './utils/debug-logger.js';
|
|
16
|
-
|
|
17
|
-
const
|
|
20
|
+
/** Marker for sqlew auto-injected section in CLAUDE.md (legacy) */
|
|
21
|
+
const CLAUDE_MD_MARKER_START = '<!-- sqlew:auto-injected:start -->';
|
|
22
|
+
const CLAUDE_MD_MARKER_END = '<!-- sqlew:auto-injected:end -->';
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
24
|
+
* Escape special regex characters in a string
|
|
20
25
|
*/
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
const packageRoot = path.dirname(distDir); // .../mcp-sqlew
|
|
24
|
-
return path.join(packageRoot, 'assets');
|
|
26
|
+
function escapeRegex(str) {
|
|
27
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
25
28
|
}
|
|
26
|
-
/** Marker for sqlew auto-injected section in CLAUDE.md */
|
|
27
|
-
const CLAUDE_MD_MARKER_START = '<!-- sqlew:auto-injected:start -->';
|
|
28
|
-
const CLAUDE_MD_MARKER_END = '<!-- sqlew:auto-injected:end -->';
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Clean up legacy sqlew injection from global ~/.claude/CLAUDE.md
|
|
31
31
|
*
|
|
32
|
-
* As of v5.0.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* As of v5.0.6, plan mode enforcement is handled by Hooks (UserPromptSubmit)
|
|
33
|
+
* instead of CLAUDE.md injection. This function removes the legacy injected
|
|
34
|
+
* section (between <!-- sqlew:auto-injected:start/end --> markers).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
* - Easy identification of auto-managed content
|
|
38
|
-
* - Safe updates (replace existing section)
|
|
39
|
-
* - No impact on Markdown rendering
|
|
40
|
-
*
|
|
41
|
-
* TODO: Add client detection to conditionally inject based on CLI type
|
|
42
|
-
* Use server.getClientVersion() after MCP initialization
|
|
36
|
+
* Safe to call multiple times - does nothing if no markers found.
|
|
43
37
|
*/
|
|
44
|
-
export function
|
|
38
|
+
export function cleanupGlobalClaudeMd() {
|
|
45
39
|
const home = os.homedir();
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Check if snippets directory exists
|
|
50
|
-
if (!fs.existsSync(snippetsDir)) {
|
|
51
|
-
debugLog('WARN', 'Claude MD snippets directory not found', { snippetsDir });
|
|
40
|
+
const claudeMdPath = path.join(home, '.claude', 'CLAUDE.md');
|
|
41
|
+
// Skip if file doesn't exist
|
|
42
|
+
if (!fs.existsSync(claudeMdPath)) {
|
|
52
43
|
return;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
debugLog('INFO', 'Created ~/.claude directory', { claudeDir });
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
debugLog('WARN', 'Failed to create ~/.claude directory', { error });
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Read current CLAUDE.md content (or empty string if doesn't exist)
|
|
66
|
-
let content = '';
|
|
67
|
-
if (fs.existsSync(claudeMdPath)) {
|
|
68
|
-
content = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
debugLog('INFO', 'Creating new ~/.claude/CLAUDE.md', { claudeMdPath });
|
|
72
|
-
}
|
|
73
|
-
// Find all .md files in snippets directory
|
|
74
|
-
const snippetFiles = fs.readdirSync(snippetsDir).filter(f => f.endsWith('.md'));
|
|
75
|
-
if (snippetFiles.length === 0) {
|
|
76
|
-
debugLog('WARN', 'No snippet files found', { snippetsDir });
|
|
45
|
+
const content = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
46
|
+
// Skip if no markers found (already clean)
|
|
47
|
+
if (!content.includes(CLAUDE_MD_MARKER_START)) {
|
|
48
|
+
debugLog('DEBUG', 'CLAUDE.md has no sqlew injection markers (already clean)');
|
|
77
49
|
return;
|
|
78
50
|
}
|
|
79
|
-
//
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
.join('\n\n');
|
|
83
|
-
// Build the injected section
|
|
84
|
-
const injectedSection = `${CLAUDE_MD_MARKER_START}\n${snippetContent}\n${CLAUDE_MD_MARKER_END}`;
|
|
85
|
-
// Check if section already exists
|
|
86
|
-
if (content.includes(CLAUDE_MD_MARKER_START)) {
|
|
87
|
-
// Check if content is the same (no update needed)
|
|
88
|
-
const regex = new RegExp(`${escapeRegex(CLAUDE_MD_MARKER_START)}[\\s\\S]*?${escapeRegex(CLAUDE_MD_MARKER_END)}`, 'g');
|
|
89
|
-
const existingMatch = content.match(regex);
|
|
90
|
-
if (existingMatch && existingMatch[0] === injectedSection) {
|
|
91
|
-
debugLog('DEBUG', 'CLAUDE.md sqlew section is up-to-date');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// Replace existing section
|
|
95
|
-
content = content.replace(regex, injectedSection);
|
|
96
|
-
debugLog('INFO', 'Updated sqlew section in CLAUDE.md', { files: snippetFiles.length });
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Append new section
|
|
100
|
-
content = content.trimEnd() + '\n\n' + injectedSection + '\n';
|
|
101
|
-
debugLog('INFO', 'Injected sqlew section into CLAUDE.md', { files: snippetFiles.length });
|
|
102
|
-
}
|
|
103
|
-
// Write updated content
|
|
51
|
+
// Remove the injected section
|
|
52
|
+
const regex = new RegExp(`\\n?\\n?${escapeRegex(CLAUDE_MD_MARKER_START)}[\\s\\S]*?${escapeRegex(CLAUDE_MD_MARKER_END)}\\n?`, 'g');
|
|
53
|
+
const cleaned = content.replace(regex, '').trimEnd() + '\n';
|
|
104
54
|
try {
|
|
105
|
-
fs.writeFileSync(claudeMdPath,
|
|
55
|
+
fs.writeFileSync(claudeMdPath, cleaned, 'utf-8');
|
|
56
|
+
debugLog('INFO', 'Removed legacy sqlew injection from ~/.claude/CLAUDE.md');
|
|
106
57
|
}
|
|
107
58
|
catch (error) {
|
|
108
|
-
debugLog('WARN', 'Failed to
|
|
59
|
+
debugLog('WARN', 'Failed to clean up CLAUDE.md', { error });
|
|
109
60
|
}
|
|
110
61
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Escape special regex characters in a string
|
|
113
|
-
*/
|
|
114
|
-
function escapeRegex(str) {
|
|
115
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
116
|
-
}
|
|
117
62
|
/**
|
|
118
63
|
* Initialize sqlew on MCP server startup
|
|
119
64
|
*
|
|
120
|
-
* As of v5.0.
|
|
121
|
-
* -
|
|
65
|
+
* As of v5.0.6:
|
|
66
|
+
* - Cleans up legacy CLAUDE.md injection (one-time)
|
|
122
67
|
* - Updates project .gitignore
|
|
123
68
|
*
|
|
124
69
|
* @param projectRoot - Project root directory (for .gitignore updates)
|
|
125
70
|
*/
|
|
126
71
|
export function initializeSqlewRules(projectRoot) {
|
|
127
72
|
debugLog('DEBUG', 'Initializing sqlew', { projectRoot });
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
injectToGlobalClaudeMd();
|
|
73
|
+
// Clean up legacy CLAUDE.md injection (safe to call multiple times)
|
|
74
|
+
cleanupGlobalClaudeMd();
|
|
131
75
|
// Initialize .gitignore entries for sqlew-generated files
|
|
132
76
|
initializeGitignore(projectRoot);
|
|
133
77
|
}
|
package/dist/init-rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-rules.js","sourceRoot":"","sources":["../src/init-rules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init-rules.js","sourceRoot":"","sources":["../src/init-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,mEAAmE;AACnE,MAAM,sBAAsB,GAAG,oCAAoC,CAAC;AACpE,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAEhE;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAE7D,6BAA6B;IAC7B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEvD,2CAA2C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8
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
/**
|
|
10
|
-
* Handle
|
|
10
|
+
* Handle tool call - dispatch to appropriate tool action
|
|
11
11
|
*
|
|
12
12
|
* Routes requests through the ToolBackend abstraction layer:
|
|
13
13
|
* - LocalBackend: Executes against local database via Knex
|
|
14
14
|
* - Plugin backends: Execute via plugin implementation (e.g., HTTP API)
|
|
15
15
|
*/
|
|
16
|
-
export declare function handleToolCall(
|
|
16
|
+
export declare function handleToolCall(toolName: string, args: Record<string, unknown>): Promise<CallToolResult>;
|
|
17
17
|
/**
|
|
18
18
|
* Check if error requires fallback to LocalBackend
|
|
19
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-handlers.d.ts","sourceRoot":"","sources":["../../src/server/tool-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-handlers.d.ts","sourceRoot":"","sources":["../../src/server/tool-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAMpE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAiD7G;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAgB/D"}
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
import { debugLogToolCall, debugLogToolResponse } from '../utils/debug-logger.js';
|
|
9
9
|
import { handleToolError } from '../utils/error-handler.js';
|
|
10
10
|
import { getBackend, getBackendType } from '../backend/index.js';
|
|
11
|
-
import { LocalBackend } from '../backend/
|
|
11
|
+
import { LocalBackend } from '../backend/index.js';
|
|
12
12
|
/**
|
|
13
|
-
* Handle
|
|
13
|
+
* Handle tool call - dispatch to appropriate tool action
|
|
14
14
|
*
|
|
15
15
|
* Routes requests through the ToolBackend abstraction layer:
|
|
16
16
|
* - LocalBackend: Executes against local database via Knex
|
|
17
17
|
* - Plugin backends: Execute via plugin implementation (e.g., HTTP API)
|
|
18
18
|
*/
|
|
19
|
-
export async function handleToolCall(
|
|
20
|
-
const
|
|
19
|
+
export async function handleToolCall(toolName, args) {
|
|
20
|
+
const name = toolName;
|
|
21
21
|
const params = args;
|
|
22
22
|
const action = params.action || 'N/A';
|
|
23
23
|
// Debug logging: Tool call
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-handlers.js","sourceRoot":"","sources":["../../src/server/tool-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tool-handlers.js","sourceRoot":"","sources":["../../src/server/tool-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB,EAAE,IAA6B;IAClF,MAAM,IAAI,GAAG,QAAQ,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,MAAM,GAAI,MAAM,CAAC,MAAiB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AAC,CAAC,WAAW,CAAC,CAAE,gDAAgD;QAElE,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YACzE,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,iDAAiD;QACjD,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,4EAA4E;QAC5E,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC;QACD,+DAA+D;QAC/D,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server - Tool Registration
|
|
3
|
+
* Registers all tools via McpServer.registerTool() API.
|
|
4
|
+
*
|
|
5
|
+
* This replaces the manual setRequestHandler(ListToolsRequestSchema/CallToolRequestSchema)
|
|
6
|
+
* pattern. registerTool() automatically handles ListTools and CallTool requests.
|
|
7
|
+
*/
|
|
8
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
/**
|
|
10
|
+
* Register all MCP tools on the given McpServer instance.
|
|
11
|
+
*
|
|
12
|
+
* Each tool is registered with:
|
|
13
|
+
* - Zod input schema (for validation + JSON Schema generation)
|
|
14
|
+
* - Description string
|
|
15
|
+
* - Callback that delegates to handleToolCall()
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerAllTools(mcpServer: McpServer): void;
|
|
18
|
+
//# sourceMappingURL=tool-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../src/server/tool-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CA0B3D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server - Tool Registration
|
|
3
|
+
* Registers all tools via McpServer.registerTool() API.
|
|
4
|
+
*
|
|
5
|
+
* This replaces the manual setRequestHandler(ListToolsRequestSchema/CallToolRequestSchema)
|
|
6
|
+
* pattern. registerTool() automatically handles ListTools and CallTool requests.
|
|
7
|
+
*/
|
|
8
|
+
import { TOOL_SCHEMAS, TOOL_DESCRIPTIONS } from './tool-schemas.js';
|
|
9
|
+
import { handleToolCall } from './tool-handlers.js';
|
|
10
|
+
let agentNameInitialized = false;
|
|
11
|
+
/**
|
|
12
|
+
* Register all MCP tools on the given McpServer instance.
|
|
13
|
+
*
|
|
14
|
+
* Each tool is registered with:
|
|
15
|
+
* - Zod input schema (for validation + JSON Schema generation)
|
|
16
|
+
* - Description string
|
|
17
|
+
* - Callback that delegates to handleToolCall()
|
|
18
|
+
*/
|
|
19
|
+
export function registerAllTools(mcpServer) {
|
|
20
|
+
for (const [name, schema] of Object.entries(TOOL_SCHEMAS)) {
|
|
21
|
+
mcpServer.registerTool(name, {
|
|
22
|
+
description: TOOL_DESCRIPTIONS[name],
|
|
23
|
+
inputSchema: schema,
|
|
24
|
+
}, async (args) => {
|
|
25
|
+
// Lazy initialization of agent name (after MCP handshake)
|
|
26
|
+
if (!agentNameInitialized) {
|
|
27
|
+
agentNameInitialized = true;
|
|
28
|
+
const clientVersion = mcpServer.server.getClientVersion();
|
|
29
|
+
if (clientVersion?.name) {
|
|
30
|
+
const { getBackend } = await import('../backend/backend-factory.js');
|
|
31
|
+
const backend = getBackend();
|
|
32
|
+
if (backend.setAgentName) {
|
|
33
|
+
backend.setAgentName(clientVersion.name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Args are already validated by registerTool's Zod schema
|
|
38
|
+
return await handleToolCall(name, args);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=tool-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../src/server/tool-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,IAAI,oBAAoB,GAAG,KAAK,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAoB;IACnD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,SAAS,CAAC,YAAY,CACpB,IAAI,EACJ;YACE,WAAW,EAAE,iBAAiB,CAAC,IAAI,CAAC;YACpC,WAAW,EAAE,MAAM;SACpB,EACD,KAAK,EAAE,IAAa,EAAE,EAAE;YACtB,0DAA0D;YAC1D,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC1B,oBAAoB,GAAG,IAAI,CAAC;gBAC5B,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAC1D,IAAI,aAAa,EAAE,IAAI,EAAE,CAAC;oBACxB,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;oBACrE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;oBAC7B,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;wBACzB,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;oBAC3C,CAAC;gBACH,CAAC;YACH,CAAC;YACD,0DAA0D;YAC1D,OAAO,MAAM,cAAc,CAAC,IAAI,EAAE,IAA+B,CAAC,CAAC;QACrE,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP Server - Tool Registry
|
|
3
|
-
*
|
|
3
|
+
* Generates MCP Tool[] list from Zod schemas.
|
|
4
|
+
*
|
|
5
|
+
* Previously: hand-written JSON Schema (273 lines)
|
|
6
|
+
* Now: Zod schemas → toJSONSchema() + description
|
|
7
|
+
*
|
|
8
|
+
* Note: This function is no longer used by index.ts (registerTool handles ListTools
|
|
9
|
+
* automatically), but is retained for verification and external consumers.
|
|
4
10
|
*/
|
|
5
11
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
12
|
/**
|
|
7
|
-
* Get list of all available MCP tools
|
|
8
|
-
* Used by ListToolsRequest handler
|
|
13
|
+
* Get list of all available MCP tools (JSON Schema format)
|
|
9
14
|
*/
|
|
10
15
|
export declare function getToolRegistry(): Tool[];
|
|
11
16
|
//# sourceMappingURL=tool-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/server/tool-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/server/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI1D;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,EAAE,CAMxC"}
|