@mks2508/coolify-mks-cli-mcp 0.5.0 → 0.6.1
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/cli/coolify-state.d.ts +51 -0
- package/dist/cli/coolify-state.d.ts.map +1 -0
- package/dist/cli/index.js +2862 -631
- package/dist/coolify/config.d.ts +1 -1
- package/dist/coolify/config.d.ts.map +1 -1
- package/dist/coolify/index.d.ts +626 -12
- package/dist/coolify/index.d.ts.map +1 -1
- package/dist/coolify/types.d.ts +87 -3
- package/dist/coolify/types.d.ts.map +1 -1
- package/dist/dist-C4hIkHif.js +66 -0
- package/dist/dist-C4hIkHif.js.map +1 -0
- package/dist/dist-DEPvJhbP.js +3 -0
- package/dist/index.cjs +8511 -28542
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8470 -28506
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +75 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/sdk.d.ts +356 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/sse.js +3 -1
- package/dist/server/stdio.d.ts +0 -2
- package/dist/server/stdio.d.ts.map +1 -1
- package/dist/server/stdio.js +3307 -1618
- package/dist/tools/definitions.d.ts +1 -1
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/handlers.d.ts +6 -7
- package/dist/tools/handlers.d.ts.map +1 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/trace.d.ts +71 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/package.json +15 -9
- package/src/cli/actions.ts +162 -0
- package/src/cli/commands/active-deployments.ts +24 -0
- package/src/cli/commands/build-logs.ts +25 -22
- package/src/cli/commands/cancel-deploy.ts +35 -0
- package/src/cli/commands/config.ts +53 -47
- package/src/cli/commands/create.ts +74 -53
- package/src/cli/commands/databases.ts +63 -0
- package/src/cli/commands/db.ts +68 -0
- package/src/cli/commands/delete.ts +41 -29
- package/src/cli/commands/deploy.ts +42 -21
- package/src/cli/commands/deployments.ts +41 -31
- package/src/cli/commands/destinations.ts +19 -27
- package/src/cli/commands/diagnose.ts +139 -0
- package/src/cli/commands/env.ts +66 -41
- package/src/cli/commands/environments.ts +36 -32
- package/src/cli/commands/exec.ts +39 -0
- package/src/cli/commands/keys.ts +46 -0
- package/src/cli/commands/list.ts +29 -27
- package/src/cli/commands/logs.ts +33 -18
- package/src/cli/commands/network.ts +145 -0
- package/src/cli/commands/projects.ts +51 -39
- package/src/cli/commands/restart.ts +34 -18
- package/src/cli/commands/server-resources.ts +71 -0
- package/src/cli/commands/servers.ts +23 -23
- package/src/cli/commands/service-logs.ts +24 -16
- package/src/cli/commands/services.ts +63 -0
- package/src/cli/commands/show.ts +72 -41
- package/src/cli/commands/start.ts +34 -18
- package/src/cli/commands/stop.ts +34 -18
- package/src/cli/commands/svc.ts +68 -0
- package/src/cli/commands/teams.ts +60 -0
- package/src/cli/commands/update.ts +73 -49
- package/src/cli/commands/version.ts +37 -0
- package/src/cli/coolify-state.ts +88 -0
- package/src/cli/index.ts +383 -151
- package/src/coolify/config.ts +29 -27
- package/src/coolify/index.ts +1829 -123
- package/src/coolify/types.ts +217 -124
- package/src/index.ts +82 -868
- package/src/network.ts +298 -0
- package/src/sdk.ts +597 -0
- package/src/server/index.ts +13 -0
- package/src/server/sse.ts +33 -25
- package/src/server/stdio.ts +24 -27
- package/src/tools/definitions.ts +893 -264
- package/src/tools/handlers.ts +556 -748
- package/src/tools/index.ts +8 -0
- package/src/trace.ts +116 -0
- package/src/utils/format.ts +36 -33
package/src/trace.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operation tracing system.
|
|
3
|
+
*
|
|
4
|
+
* Provides step-by-step tracing for all operations across CLI, MCP, and SDK.
|
|
5
|
+
* - **CLI mode**: Logs to stderr with chalk colors (no spinners in trace)
|
|
6
|
+
* - **MCP mode**: Collects steps silently, returns in response
|
|
7
|
+
* - **SDK mode**: Fires callback if provided, otherwise collects
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A single trace step.
|
|
14
|
+
*/
|
|
15
|
+
export interface ITraceStep {
|
|
16
|
+
/** Timestamp */
|
|
17
|
+
ts: string;
|
|
18
|
+
/** Step label */
|
|
19
|
+
step: string;
|
|
20
|
+
/** Duration in ms (filled after completion) */
|
|
21
|
+
durationMs?: number;
|
|
22
|
+
/** Optional detail */
|
|
23
|
+
detail?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Complete operation trace.
|
|
28
|
+
*/
|
|
29
|
+
export interface IOperationTrace {
|
|
30
|
+
/** Operation name */
|
|
31
|
+
operation: string;
|
|
32
|
+
/** All steps */
|
|
33
|
+
steps: ITraceStep[];
|
|
34
|
+
/** Total duration */
|
|
35
|
+
totalMs: number;
|
|
36
|
+
/** Whether operation succeeded */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** Error message if failed */
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Callback for real-time trace updates.
|
|
44
|
+
*/
|
|
45
|
+
export type TraceCallback = (step: string, detail?: string) => void;
|
|
46
|
+
|
|
47
|
+
/** Detect if running as MCP server (stdout is the transport). */
|
|
48
|
+
export function isMcpMode(): boolean {
|
|
49
|
+
// MCP servers communicate over stdout — if we're piped, assume MCP
|
|
50
|
+
return !process.stdout.isTTY;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Operation tracer that collects steps.
|
|
55
|
+
*/
|
|
56
|
+
export class OperationTracer {
|
|
57
|
+
private steps: ITraceStep[] = [];
|
|
58
|
+
private startTime: number;
|
|
59
|
+
private stepStart: number;
|
|
60
|
+
private onStep?: TraceCallback;
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
public readonly operation: string,
|
|
64
|
+
onStep?: TraceCallback,
|
|
65
|
+
) {
|
|
66
|
+
this.startTime = Date.now();
|
|
67
|
+
this.stepStart = this.startTime;
|
|
68
|
+
this.onStep = onStep;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Records a trace step.
|
|
73
|
+
*
|
|
74
|
+
* @param step - Step description
|
|
75
|
+
* @param detail - Optional detail
|
|
76
|
+
*/
|
|
77
|
+
step(step: string, detail?: string): void {
|
|
78
|
+
const now = Date.now();
|
|
79
|
+
const traceStep: ITraceStep = {
|
|
80
|
+
ts: new Date(now).toISOString(),
|
|
81
|
+
step,
|
|
82
|
+
durationMs: now - this.stepStart,
|
|
83
|
+
detail,
|
|
84
|
+
};
|
|
85
|
+
this.steps.push(traceStep);
|
|
86
|
+
this.stepStart = now;
|
|
87
|
+
|
|
88
|
+
// Fire callback for real-time updates
|
|
89
|
+
this.onStep?.(step, detail);
|
|
90
|
+
|
|
91
|
+
// In TTY (CLI) mode, log to stderr so it doesn't pollute MCP stdout
|
|
92
|
+
if (process.stderr.isTTY) {
|
|
93
|
+
const prefix = `\x1b[90m[${this.operation}]\x1b[0m`;
|
|
94
|
+
const elapsed = `\x1b[33m${traceStep.durationMs}ms\x1b[0m`;
|
|
95
|
+
const detailStr = detail ? ` \x1b[90m(${detail})\x1b[0m` : "";
|
|
96
|
+
process.stderr.write(`${prefix} ${step} ${elapsed}${detailStr}\n`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Finalizes the trace.
|
|
102
|
+
*
|
|
103
|
+
* @param success - Whether operation succeeded
|
|
104
|
+
* @param error - Error message if failed
|
|
105
|
+
* @returns Complete operation trace
|
|
106
|
+
*/
|
|
107
|
+
finish(success: boolean, error?: string): IOperationTrace {
|
|
108
|
+
return {
|
|
109
|
+
operation: this.operation,
|
|
110
|
+
steps: this.steps,
|
|
111
|
+
totalMs: Date.now() - this.startTime,
|
|
112
|
+
success,
|
|
113
|
+
error,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
package/src/utils/format.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import Table from
|
|
10
|
-
import chalk from
|
|
9
|
+
import Table from "cli-table3";
|
|
10
|
+
import chalk from "chalk";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Gets the terminal width.
|
|
@@ -15,7 +15,7 @@ import chalk from 'chalk'
|
|
|
15
15
|
* @returns Terminal column count
|
|
16
16
|
*/
|
|
17
17
|
function getTerminalWidth(): number {
|
|
18
|
-
return process.stdout.columns || 80
|
|
18
|
+
return process.stdout.columns || 80;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -26,12 +26,12 @@ function getTerminalWidth(): number {
|
|
|
26
26
|
* @returns Configured Table instance
|
|
27
27
|
*/
|
|
28
28
|
export function createTable(headers: string[], colWidths?: number[]) {
|
|
29
|
-
const columns = getTerminalWidth()
|
|
29
|
+
const columns = getTerminalWidth();
|
|
30
30
|
|
|
31
31
|
return new Table({
|
|
32
32
|
head: headers.map((h) => chalk.cyan(h)),
|
|
33
33
|
colWidths: colWidths || calculateColumnWidths(columns, headers.length),
|
|
34
|
-
})
|
|
34
|
+
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -41,11 +41,14 @@ export function createTable(headers: string[], colWidths?: number[]) {
|
|
|
41
41
|
* @param numColumns - Number of columns
|
|
42
42
|
* @returns Array of column widths
|
|
43
43
|
*/
|
|
44
|
-
function calculateColumnWidths(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
function calculateColumnWidths(
|
|
45
|
+
totalWidth: number,
|
|
46
|
+
numColumns: number,
|
|
47
|
+
): number[] {
|
|
48
|
+
const padding = 4;
|
|
49
|
+
const availableWidth = totalWidth - padding * numColumns;
|
|
50
|
+
const colWidth = Math.floor(availableWidth / numColumns);
|
|
51
|
+
return Array(numColumns).fill(colWidth);
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
/**
|
|
@@ -56,15 +59,15 @@ function calculateColumnWidths(totalWidth: number, numColumns: number): number[]
|
|
|
56
59
|
*/
|
|
57
60
|
export function formatStatus(status: string): string {
|
|
58
61
|
const statusMap: Record<string, string> = {
|
|
59
|
-
running: chalk.green(
|
|
60
|
-
|
|
61
|
-
stopped: chalk.red(
|
|
62
|
-
|
|
63
|
-
error: chalk.red(
|
|
64
|
-
deploying: chalk.yellow(
|
|
65
|
-
}
|
|
62
|
+
running: chalk.green("● Running"),
|
|
63
|
+
"running:unknown": chalk.green("● Running"),
|
|
64
|
+
stopped: chalk.red("○ Stopped"),
|
|
65
|
+
restarting: chalk.yellow("◐ Restarting"),
|
|
66
|
+
error: chalk.red("✗ Error"),
|
|
67
|
+
deploying: chalk.yellow("◐ Deploying"),
|
|
68
|
+
};
|
|
66
69
|
|
|
67
|
-
return statusMap[status] || status
|
|
70
|
+
return statusMap[status] || status;
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
/**
|
|
@@ -74,13 +77,13 @@ export function formatStatus(status: string): string {
|
|
|
74
77
|
* @returns Formatted string with unit
|
|
75
78
|
*/
|
|
76
79
|
export function formatBytes(bytes: number): string {
|
|
77
|
-
const units = [
|
|
78
|
-
let i = 0
|
|
80
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
81
|
+
let i = 0;
|
|
79
82
|
while (bytes >= 1024 && i < units.length - 1) {
|
|
80
|
-
bytes /= 1024
|
|
81
|
-
i
|
|
83
|
+
bytes /= 1024;
|
|
84
|
+
i++;
|
|
82
85
|
}
|
|
83
|
-
return `${bytes.toFixed(1)} ${units[i]}
|
|
86
|
+
return `${bytes.toFixed(1)} ${units[i]}`;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/**
|
|
@@ -90,15 +93,15 @@ export function formatBytes(bytes: number): string {
|
|
|
90
93
|
* @returns Relative time string
|
|
91
94
|
*/
|
|
92
95
|
export function formatRelativeTime(timestamp: string): string {
|
|
93
|
-
const date = new Date(timestamp)
|
|
94
|
-
const now = new Date()
|
|
95
|
-
const diffMs = now.getTime() - date.getTime()
|
|
96
|
-
const diffMins = Math.floor(diffMs / 60000)
|
|
97
|
-
const diffHours = Math.floor(diffMs / 3600000)
|
|
98
|
-
const diffDays = Math.floor(diffMs / 86400000)
|
|
96
|
+
const date = new Date(timestamp);
|
|
97
|
+
const now = new Date();
|
|
98
|
+
const diffMs = now.getTime() - date.getTime();
|
|
99
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
100
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
101
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
99
102
|
|
|
100
|
-
if (diffMins < 1) return
|
|
101
|
-
if (diffMins < 60) return `${diffMins}m ago
|
|
102
|
-
if (diffHours < 24) return `${diffHours}h ago
|
|
103
|
-
return `${diffDays}d ago
|
|
103
|
+
if (diffMins < 1) return "just now";
|
|
104
|
+
if (diffMins < 60) return `${diffMins}m ago`;
|
|
105
|
+
if (diffHours < 24) return `${diffHours}h ago`;
|
|
106
|
+
return `${diffDays}d ago`;
|
|
104
107
|
}
|