@azerate/claudette-mcp 1.0.0 → 1.2.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/dist/__tests__/checkpoints.test.d.ts +1 -0
- package/dist/__tests__/checkpoints.test.js +59 -0
- package/dist/__tests__/utils.test.d.ts +1 -0
- package/dist/__tests__/utils.test.js +28 -0
- package/dist/__tests__/workspace.test.d.ts +1 -0
- package/dist/__tests__/workspace.test.js +30 -0
- package/dist/actions.d.ts +6 -0
- package/dist/actions.js +30 -0
- package/dist/checkpoints.d.ts +21 -0
- package/dist/checkpoints.js +247 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +37 -0
- package/dist/git.d.ts +6 -0
- package/dist/git.js +34 -0
- package/dist/index.js +557 -431
- package/dist/scripts.d.ts +29 -0
- package/dist/scripts.js +61 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +12 -0
- package/dist/workspace.d.ts +12 -0
- package/dist/workspace.js +74 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ScriptInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
command: string;
|
|
4
|
+
status: 'running' | 'stopped' | 'error';
|
|
5
|
+
startedAt?: string;
|
|
6
|
+
exitCode?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ScriptStatus {
|
|
9
|
+
found: boolean;
|
|
10
|
+
script?: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
status: string;
|
|
14
|
+
output: string[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function getScripts(workspacePath: string): Promise<{
|
|
18
|
+
scripts: ScriptInfo[];
|
|
19
|
+
hasPackageJson: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getScriptOutput(workspacePath: string, scriptName: string): Promise<string | null>;
|
|
22
|
+
export declare function startScript(workspacePath: string, scriptName: string): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
error?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function stopScript(workspacePath: string, scriptName: string): Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
error?: string;
|
|
29
|
+
}>;
|
package/dist/scripts.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Script management functions for Claudette MCP server
|
|
2
|
+
import { stripAnsi } from './utils.js';
|
|
3
|
+
// Claudette server API base URL
|
|
4
|
+
const CLAUDETTE_API = "http://localhost:52001";
|
|
5
|
+
// Get list of scripts from workspace
|
|
6
|
+
export async function getScripts(workspacePath) {
|
|
7
|
+
try {
|
|
8
|
+
const response = await fetch(`${CLAUDETTE_API}/api/scripts?path=${encodeURIComponent(workspacePath)}`);
|
|
9
|
+
if (!response.ok)
|
|
10
|
+
return { scripts: [], hasPackageJson: false };
|
|
11
|
+
return await response.json();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return { scripts: [], hasPackageJson: false };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Get script output
|
|
18
|
+
export async function getScriptOutput(workspacePath, scriptName) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(`${CLAUDETTE_API}/api/scripts/status?path=${encodeURIComponent(workspacePath)}&scriptName=${encodeURIComponent(scriptName)}`);
|
|
21
|
+
if (!response.ok)
|
|
22
|
+
return null;
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
if (!data.found || !data.script)
|
|
25
|
+
return null;
|
|
26
|
+
// Join output lines and strip ANSI codes
|
|
27
|
+
const output = data.script.output.join('');
|
|
28
|
+
return stripAnsi(output);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Start a script
|
|
35
|
+
export async function startScript(workspacePath, scriptName) {
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(`${CLAUDETTE_API}/api/scripts/run`, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: { 'Content-Type': 'application/json' },
|
|
40
|
+
body: JSON.stringify({ path: workspacePath, scriptName, autoLaunchBrowser: true }),
|
|
41
|
+
});
|
|
42
|
+
return await response.json();
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
return { success: false, error: err.message };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Stop a script
|
|
49
|
+
export async function stopScript(workspacePath, scriptName) {
|
|
50
|
+
try {
|
|
51
|
+
const response = await fetch(`${CLAUDETTE_API}/api/scripts/stop`, {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: { 'Content-Type': 'application/json' },
|
|
54
|
+
body: JSON.stringify({ path: workspacePath, scriptName }),
|
|
55
|
+
});
|
|
56
|
+
return await response.json();
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return { success: false, error: err.message };
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripAnsi(str: string): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Utility functions for Claudette MCP server
|
|
2
|
+
// Strip ANSI escape codes from a string
|
|
3
|
+
export function stripAnsi(str) {
|
|
4
|
+
return str
|
|
5
|
+
.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '')
|
|
6
|
+
.replace(/\x1b\][^\x07]*\x07/g, '')
|
|
7
|
+
.replace(/\x1b[()][AB012]/g, '')
|
|
8
|
+
.replace(/\x1b[>=]/g, '')
|
|
9
|
+
.replace(/\x07/g, '')
|
|
10
|
+
.replace(/\r/g, '')
|
|
11
|
+
.replace(/\x1b\[\?[0-9;]*[a-zA-Z]/g, '');
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WorkspaceConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
configured: boolean;
|
|
5
|
+
memory: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function getWorkspaceConfigPath(workspacePath: string): string;
|
|
8
|
+
export declare function getWorkspaceConfig(workspacePath: string): WorkspaceConfig | null;
|
|
9
|
+
export declare function saveWorkspaceConfig(config: WorkspaceConfig): void;
|
|
10
|
+
export declare function clearMemory(workspacePath: string): boolean;
|
|
11
|
+
export declare function deleteMemoryNotes(workspacePath: string, indices: number[]): number;
|
|
12
|
+
export declare function replaceMemory(workspacePath: string, notes: string[]): boolean;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Workspace configuration functions for Claudette MCP server
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
// Claudette data directory
|
|
6
|
+
const DATA_DIR = join(homedir(), '.claudette');
|
|
7
|
+
const WORKSPACE_CONFIGS_DIR = join(DATA_DIR, 'workspace-configs');
|
|
8
|
+
// Get workspace config path
|
|
9
|
+
export function getWorkspaceConfigPath(workspacePath) {
|
|
10
|
+
const safeName = workspacePath.replace(/[\\/:*?"<>|]/g, '-').replace(/--+/g, '-');
|
|
11
|
+
return join(WORKSPACE_CONFIGS_DIR, `${safeName}.json`);
|
|
12
|
+
}
|
|
13
|
+
// Read workspace config
|
|
14
|
+
export function getWorkspaceConfig(workspacePath) {
|
|
15
|
+
const configPath = getWorkspaceConfigPath(workspacePath);
|
|
16
|
+
if (!existsSync(configPath))
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Save workspace config
|
|
26
|
+
export function saveWorkspaceConfig(config) {
|
|
27
|
+
if (!existsSync(WORKSPACE_CONFIGS_DIR)) {
|
|
28
|
+
mkdirSync(WORKSPACE_CONFIGS_DIR, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
const configPath = getWorkspaceConfigPath(config.path);
|
|
31
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
32
|
+
}
|
|
33
|
+
// Clear all memory notes
|
|
34
|
+
export function clearMemory(workspacePath) {
|
|
35
|
+
const config = getWorkspaceConfig(workspacePath);
|
|
36
|
+
if (!config)
|
|
37
|
+
return false;
|
|
38
|
+
config.memory = [];
|
|
39
|
+
saveWorkspaceConfig(config);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// Delete specific memory notes by indices (0-based)
|
|
43
|
+
export function deleteMemoryNotes(workspacePath, indices) {
|
|
44
|
+
const config = getWorkspaceConfig(workspacePath);
|
|
45
|
+
if (!config || !config.memory)
|
|
46
|
+
return 0;
|
|
47
|
+
// Sort indices in descending order to delete from end first
|
|
48
|
+
const sortedIndices = [...indices].sort((a, b) => b - a);
|
|
49
|
+
let deleted = 0;
|
|
50
|
+
for (const idx of sortedIndices) {
|
|
51
|
+
if (idx >= 0 && idx < config.memory.length) {
|
|
52
|
+
config.memory.splice(idx, 1);
|
|
53
|
+
deleted++;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
saveWorkspaceConfig(config);
|
|
57
|
+
return deleted;
|
|
58
|
+
}
|
|
59
|
+
// Replace all memory with new notes (for summarization)
|
|
60
|
+
export function replaceMemory(workspacePath, notes) {
|
|
61
|
+
let config = getWorkspaceConfig(workspacePath);
|
|
62
|
+
if (!config) {
|
|
63
|
+
config = {
|
|
64
|
+
name: workspacePath.split(/[/\\]/).pop() || "workspace",
|
|
65
|
+
path: workspacePath,
|
|
66
|
+
configured: false,
|
|
67
|
+
memory: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const timestamp = new Date().toLocaleString();
|
|
71
|
+
config.memory = notes.map(note => `[${timestamp}] ${note}`);
|
|
72
|
+
saveWorkspaceConfig(config);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
package/package.json
CHANGED