@paretools/make 0.8.5 → 0.10.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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/formatters.d.ts +4 -1
- package/dist/lib/formatters.d.ts.map +1 -1
- package/dist/lib/formatters.js +37 -5
- package/dist/lib/formatters.js.map +1 -1
- package/dist/lib/parsers.d.ts +117 -1
- package/dist/lib/parsers.d.ts.map +1 -1
- package/dist/lib/parsers.js +269 -4
- package/dist/lib/parsers.js.map +1 -1
- package/dist/schemas/index.d.ts +24 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +13 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/tools/list.d.ts.map +1 -1
- package/dist/tools/list.js +128 -16
- package/dist/tools/list.js.map +1 -1
- package/dist/tools/run.d.ts.map +1 -1
- package/dist/tools/run.js +102 -16
- package/dist/tools/run.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { registerAllTools } from "./tools/index.js";
|
|
5
5
|
const server = new McpServer({ name: "@paretools/make", version: "0.8.1" }, {
|
|
6
|
-
instructions: "Structured Make/Just task runner operations (run, list). Auto-detects make vs just. Returns typed JSON.
|
|
6
|
+
instructions: "Structured Make/Just task runner operations (run, list). Auto-detects make vs just. Returns typed JSON.",
|
|
7
7
|
});
|
|
8
8
|
registerAllTools(server);
|
|
9
9
|
const transport = new StdioServerTransport();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC7C;IACE,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC7C;IACE,YAAY,EACV,yGAAyG;CAC5G,CACF,CAAC;AAEF,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/lib/formatters.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { MakeRunResult, MakeListResult } from "../schemas/index.js";
|
|
|
3
3
|
export declare function formatRun(data: MakeRunResult): string;
|
|
4
4
|
/** Formats structured list results into a human-readable target listing. */
|
|
5
5
|
export declare function formatList(data: MakeListResult): string;
|
|
6
|
-
/** Compact run: target, exitCode, success, duration. Drop stdout/stderr. */
|
|
6
|
+
/** Compact run: target, exitCode, success, duration, timedOut. Drop stdout/stderr. */
|
|
7
7
|
export interface MakeRunCompact {
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
target: string;
|
|
@@ -11,6 +11,8 @@ export interface MakeRunCompact {
|
|
|
11
11
|
exitCode: number;
|
|
12
12
|
duration: number;
|
|
13
13
|
tool: "make" | "just";
|
|
14
|
+
timedOut: boolean;
|
|
15
|
+
errorType?: "missing-target" | "recipe-failure" | "parse-error";
|
|
14
16
|
}
|
|
15
17
|
export declare function compactRunMap(data: MakeRunResult): MakeRunCompact;
|
|
16
18
|
export declare function formatRunCompact(data: MakeRunCompact): string;
|
|
@@ -18,6 +20,7 @@ export declare function formatRunCompact(data: MakeRunCompact): string;
|
|
|
18
20
|
export interface MakeListCompact {
|
|
19
21
|
[key: string]: unknown;
|
|
20
22
|
total: number;
|
|
23
|
+
patternRuleCount: number;
|
|
21
24
|
tool: "make" | "just";
|
|
22
25
|
}
|
|
23
26
|
export declare function compactListMap(data: MakeListResult): MakeListCompact;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/lib/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIzE,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/lib/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIzE,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAiBrD;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CA4BvD;AAID,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,aAAa,CAAC;CACjE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,cAAc,CAUjE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAM7D;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAMpE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAG/D"}
|
package/dist/lib/formatters.js
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
/** Formats structured run results into a human-readable output summary. */
|
|
3
3
|
export function formatRun(data) {
|
|
4
4
|
const lines = [];
|
|
5
|
-
if (data.
|
|
5
|
+
if (data.timedOut) {
|
|
6
|
+
lines.push(`${data.tool} ${data.target}: TIMED OUT after ${data.duration}ms (exit code ${data.exitCode}).`);
|
|
7
|
+
}
|
|
8
|
+
else if (data.success) {
|
|
6
9
|
lines.push(`${data.tool} ${data.target}: success (${data.duration}ms).`);
|
|
7
10
|
}
|
|
8
11
|
else {
|
|
9
12
|
lines.push(`${data.tool} ${data.target}: exit code ${data.exitCode} (${data.duration}ms).`);
|
|
10
13
|
}
|
|
14
|
+
if (data.errorType) {
|
|
15
|
+
lines.push(`errorType: ${data.errorType}`);
|
|
16
|
+
}
|
|
11
17
|
if (data.stdout)
|
|
12
18
|
lines.push(data.stdout);
|
|
13
19
|
if (data.stderr)
|
|
@@ -20,8 +26,28 @@ export function formatList(data) {
|
|
|
20
26
|
return `${data.tool}: no targets found.`;
|
|
21
27
|
const lines = [`${data.tool}: ${data.total} targets`];
|
|
22
28
|
for (const t of data.targets ?? []) {
|
|
23
|
-
const
|
|
24
|
-
|
|
29
|
+
const parts = [` ${t.name}`];
|
|
30
|
+
if (t.isPhony)
|
|
31
|
+
parts.push("[phony]");
|
|
32
|
+
if (t.dependencies && t.dependencies.length > 0) {
|
|
33
|
+
parts.push(`-> ${t.dependencies.join(", ")}`);
|
|
34
|
+
}
|
|
35
|
+
if (t.description)
|
|
36
|
+
parts.push(`# ${t.description}`);
|
|
37
|
+
lines.push(parts.join(" "));
|
|
38
|
+
for (const cmd of t.recipe ?? []) {
|
|
39
|
+
lines.push(` $ ${cmd}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if ((data.patternRules ?? []).length > 0) {
|
|
43
|
+
lines.push(`pattern rules: ${data.patternRules?.length ?? 0}`);
|
|
44
|
+
for (const r of data.patternRules ?? []) {
|
|
45
|
+
const deps = (r.dependencies ?? []).length > 0 ? ` -> ${r.dependencies?.join(", ")}` : "";
|
|
46
|
+
lines.push(` ${r.pattern}${deps}`);
|
|
47
|
+
for (const cmd of r.recipe ?? []) {
|
|
48
|
+
lines.push(` $ ${cmd}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
25
51
|
}
|
|
26
52
|
return lines.join("\n");
|
|
27
53
|
}
|
|
@@ -32,22 +58,28 @@ export function compactRunMap(data) {
|
|
|
32
58
|
exitCode: data.exitCode,
|
|
33
59
|
duration: data.duration,
|
|
34
60
|
tool: data.tool,
|
|
61
|
+
timedOut: data.timedOut,
|
|
62
|
+
errorType: data.errorType,
|
|
35
63
|
};
|
|
36
64
|
}
|
|
37
65
|
export function formatRunCompact(data) {
|
|
66
|
+
if (data.timedOut) {
|
|
67
|
+
return `${data.tool} ${data.target}: TIMED OUT after ${data.duration}ms (exit code ${data.exitCode}).`;
|
|
68
|
+
}
|
|
38
69
|
if (data.success)
|
|
39
70
|
return `${data.tool} ${data.target}: success (${data.duration}ms).`;
|
|
40
|
-
return `${data.tool} ${data.target}: exit code ${data.exitCode} (${data.duration}ms).`;
|
|
71
|
+
return `${data.tool} ${data.target}: exit code ${data.exitCode} (${data.duration}ms)${data.errorType ? ` [${data.errorType}]` : ""}.`;
|
|
41
72
|
}
|
|
42
73
|
export function compactListMap(data) {
|
|
43
74
|
return {
|
|
44
75
|
total: data.total,
|
|
76
|
+
patternRuleCount: (data.patternRules ?? []).length,
|
|
45
77
|
tool: data.tool,
|
|
46
78
|
};
|
|
47
79
|
}
|
|
48
80
|
export function formatListCompact(data) {
|
|
49
81
|
if (data.total === 0)
|
|
50
82
|
return `${data.tool}: no targets found.`;
|
|
51
|
-
return `${data.tool}: ${data.total} targets`;
|
|
83
|
+
return `${data.tool}: ${data.total} targets (${data.patternRuleCount} pattern rules)`;
|
|
52
84
|
}
|
|
53
85
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/lib/formatters.ts"],"names":[],"mappings":"AAEA,wEAAwE;AAExE,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/lib/formatters.ts"],"names":[],"mappings":"AAEA,wEAAwE;AAExE,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CACR,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,qBAAqB,IAAI,CAAC,QAAQ,iBAAiB,IAAI,CAAC,QAAQ,IAAI,CAChG,CAAC;IACJ,CAAC;SAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI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qB,CAAC;IAC/D,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,aAAa,IAAI,CAAC,gBAAgB,iBAAiB,CAAC;AACxF,CAAC"}
|
package/dist/lib/parsers.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { MakeTool } from "./make-runner.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Parses the output of a `make` or `just` run into structured result data.
|
|
5
5
|
*/
|
|
6
|
-
export declare function parseRunOutput(target: string, stdout: string, stderr: string, exitCode: number, duration: number, tool: MakeTool): MakeRunResult;
|
|
6
|
+
export declare function parseRunOutput(target: string, stdout: string, stderr: string, exitCode: number, duration: number, tool: MakeTool, timedOut?: boolean): MakeRunResult;
|
|
7
7
|
/**
|
|
8
8
|
* Parses `just --list` output into structured target data.
|
|
9
9
|
*
|
|
@@ -22,6 +22,43 @@ export declare function parseJustList(stdout: string): {
|
|
|
22
22
|
}[];
|
|
23
23
|
total: number;
|
|
24
24
|
};
|
|
25
|
+
/** Shape returned by `just --dump-format json`. */
|
|
26
|
+
export interface JustDumpRecipe {
|
|
27
|
+
name?: string;
|
|
28
|
+
doc?: string | null;
|
|
29
|
+
parameters?: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
default?: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
dependencies?: Array<{
|
|
34
|
+
recipe: string;
|
|
35
|
+
} | string>;
|
|
36
|
+
body?: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface JustDump {
|
|
39
|
+
recipes?: Record<string, JustDumpRecipe>;
|
|
40
|
+
aliases?: Record<string, {
|
|
41
|
+
target: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parses `just --dump-format json` output into structured target data.
|
|
46
|
+
*
|
|
47
|
+
* The JSON dump includes recipe names, parameters, dependencies, and docs.
|
|
48
|
+
* All just recipes are inherently phony (no file targets).
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseJustDumpJson(jsonOutput: string, opts?: {
|
|
51
|
+
showRecipe?: boolean;
|
|
52
|
+
}): {
|
|
53
|
+
targets: {
|
|
54
|
+
name: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
isPhony?: boolean;
|
|
57
|
+
dependencies?: string[];
|
|
58
|
+
recipe?: string[];
|
|
59
|
+
}[];
|
|
60
|
+
total: number;
|
|
61
|
+
};
|
|
25
62
|
/**
|
|
26
63
|
* Parses `make -pRrq` database output to extract user-defined target names.
|
|
27
64
|
*
|
|
@@ -38,9 +75,80 @@ export declare function parseJustList(stdout: string): {
|
|
|
38
75
|
export declare function parseMakeTargets(stdout: string): {
|
|
39
76
|
targets: {
|
|
40
77
|
name: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
dependencies?: string[];
|
|
41
80
|
}[];
|
|
42
81
|
total: number;
|
|
43
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Parses `.PHONY` declarations from Makefile source to determine which targets are phony.
|
|
85
|
+
*
|
|
86
|
+
* @param makefileSource - Raw contents of the Makefile
|
|
87
|
+
* @returns Set of target names declared as .PHONY
|
|
88
|
+
*/
|
|
89
|
+
export declare function parsePhonyTargets(makefileSource: string): Set<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Enriches targets with isPhony flag based on .PHONY declarations.
|
|
92
|
+
*
|
|
93
|
+
* @param targets - Targets previously extracted from `make -pRrq` output
|
|
94
|
+
* @param phonySet - Set of phony target names from parsePhonyTargets
|
|
95
|
+
* @returns The same targets array, mutated with `isPhony` fields where applicable
|
|
96
|
+
*/
|
|
97
|
+
export declare function enrichPhonyFlags(targets: {
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
isPhony?: boolean;
|
|
101
|
+
dependencies?: string[];
|
|
102
|
+
recipe?: string[];
|
|
103
|
+
}[], phonySet: Set<string>): void;
|
|
104
|
+
/**
|
|
105
|
+
* Enriches parsed make targets with descriptions extracted from the Makefile source.
|
|
106
|
+
*
|
|
107
|
+
* Supports the common `target: [deps] ## Description text` convention where a
|
|
108
|
+
* double-hash comment at the end of the target rule line serves as documentation.
|
|
109
|
+
* This convention is widely used in Makefiles that provide a `help` target.
|
|
110
|
+
*
|
|
111
|
+
* @param targets - Targets previously extracted from `make -pRrq` output
|
|
112
|
+
* @param makefileSource - Raw contents of the Makefile
|
|
113
|
+
* @returns The same targets array, mutated with `description` fields where found
|
|
114
|
+
*/
|
|
115
|
+
export declare function enrichMakeTargetDescriptions(targets: {
|
|
116
|
+
name: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
recipe?: string[];
|
|
119
|
+
}[], makefileSource: string): {
|
|
120
|
+
name: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
recipe?: string[];
|
|
123
|
+
}[];
|
|
124
|
+
/**
|
|
125
|
+
* Parses dependency lists from Makefile source for best-effort dependency enrichment.
|
|
126
|
+
* This extracts dependencies from `target: dep1 dep2` lines in the Makefile source
|
|
127
|
+
* (not the make database output), providing cleaner results for user-defined rules.
|
|
128
|
+
*/
|
|
129
|
+
export declare function parseMakeDependencies(makefileSource: string): Map<string, string[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Parses explicit target recipe bodies from Makefile source.
|
|
132
|
+
*
|
|
133
|
+
* Captures tab-indented command lines that immediately follow target rules.
|
|
134
|
+
* Pattern rules (`%.o: %.c`) are excluded here and returned via parsePatternRules.
|
|
135
|
+
*/
|
|
136
|
+
export declare function parseMakeRecipes(makefileSource: string): Map<string, string[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Parses Makefile pattern rules (e.g., `%.o: %.c`) with optional recipes.
|
|
139
|
+
*/
|
|
140
|
+
export declare function parsePatternRules(makefileSource: string): {
|
|
141
|
+
pattern: string;
|
|
142
|
+
dependencies?: string[];
|
|
143
|
+
recipe?: string[];
|
|
144
|
+
}[];
|
|
145
|
+
/**
|
|
146
|
+
* Adds parsed recipe bodies to already-discovered make targets.
|
|
147
|
+
*/
|
|
148
|
+
export declare function enrichTargetRecipes(targets: {
|
|
149
|
+
name: string;
|
|
150
|
+
recipe?: string[];
|
|
151
|
+
}[], recipeMap: Map<string, string[]>): void;
|
|
44
152
|
/**
|
|
45
153
|
* Builds a full MakeListResult from parsed target data and the detected tool.
|
|
46
154
|
*/
|
|
@@ -48,6 +156,14 @@ export declare function buildListResult(parsed: {
|
|
|
48
156
|
targets: {
|
|
49
157
|
name: string;
|
|
50
158
|
description?: string;
|
|
159
|
+
isPhony?: boolean;
|
|
160
|
+
dependencies?: string[];
|
|
161
|
+
recipe?: string[];
|
|
162
|
+
}[];
|
|
163
|
+
patternRules?: {
|
|
164
|
+
pattern: string;
|
|
165
|
+
dependencies?: string[];
|
|
166
|
+
recipe?: string[];
|
|
51
167
|
}[];
|
|
52
168
|
total: number;
|
|
53
169
|
}, tool: MakeTool): MakeListResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../../src/lib/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../../src/lib/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAqCjD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,EACd,QAAQ,GAAE,OAAe,GACxB,aAAa,CAaf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG;IAC7C,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M,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,EAAE,CAwCF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,EAC9C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAC/B,IAAI,CAON;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IACN,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB,EAAE,CAAC;IACJ,YAAY,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACjF,KAAK,EAAE,MAAM,CAAC;CACf,EACD,IAAI,EAAE,QAAQ,GACb,cAAc,CAOhB"}
|
package/dist/lib/parsers.js
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
|
+
function detectRunErrorType(tool, stdout, stderr) {
|
|
2
|
+
const text = `${stderr}\n${stdout}`.toLowerCase();
|
|
3
|
+
if (text.includes("no rule to make target") ||
|
|
4
|
+
text.includes("justfile does not contain recipe") ||
|
|
5
|
+
text.includes("unknown recipe")) {
|
|
6
|
+
return "missing-target";
|
|
7
|
+
}
|
|
8
|
+
if (text.includes("missing separator") ||
|
|
9
|
+
text.includes("makefile parse error") ||
|
|
10
|
+
text.includes("error parsing")) {
|
|
11
|
+
return "parse-error";
|
|
12
|
+
}
|
|
13
|
+
if (text.includes("recipe for target") ||
|
|
14
|
+
text.includes("error ") ||
|
|
15
|
+
text.includes("recipe failed") ||
|
|
16
|
+
(tool === "just" && text.includes("exited with status code"))) {
|
|
17
|
+
return "recipe-failure";
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* Parses the output of a `make` or `just` run into structured result data.
|
|
3
23
|
*/
|
|
4
|
-
export function parseRunOutput(target, stdout, stderr, exitCode, duration, tool) {
|
|
24
|
+
export function parseRunOutput(target, stdout, stderr, exitCode, duration, tool, timedOut = false) {
|
|
25
|
+
const success = exitCode === 0 && !timedOut;
|
|
5
26
|
return {
|
|
6
27
|
target,
|
|
7
|
-
success
|
|
28
|
+
success,
|
|
8
29
|
exitCode,
|
|
9
30
|
stdout: stdout.trimEnd() || undefined,
|
|
10
31
|
stderr: stderr.trimEnd() || undefined,
|
|
11
32
|
duration,
|
|
12
33
|
tool,
|
|
34
|
+
timedOut,
|
|
35
|
+
errorType: !success ? detectRunErrorType(tool, stdout, stderr) : undefined,
|
|
13
36
|
};
|
|
14
37
|
}
|
|
15
38
|
/**
|
|
@@ -39,6 +62,58 @@ export function parseJustList(stdout) {
|
|
|
39
62
|
}
|
|
40
63
|
return { targets, total: targets.length };
|
|
41
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Parses `just --dump-format json` output into structured target data.
|
|
67
|
+
*
|
|
68
|
+
* The JSON dump includes recipe names, parameters, dependencies, and docs.
|
|
69
|
+
* All just recipes are inherently phony (no file targets).
|
|
70
|
+
*/
|
|
71
|
+
export function parseJustDumpJson(jsonOutput, opts) {
|
|
72
|
+
const dump = JSON.parse(jsonOutput);
|
|
73
|
+
const targets = [];
|
|
74
|
+
if (dump.recipes) {
|
|
75
|
+
for (const [recipeName, recipe] of Object.entries(dump.recipes)) {
|
|
76
|
+
const deps = [];
|
|
77
|
+
if (recipe.dependencies && recipe.dependencies.length > 0) {
|
|
78
|
+
for (const dep of recipe.dependencies) {
|
|
79
|
+
if (typeof dep === "string") {
|
|
80
|
+
deps.push(dep);
|
|
81
|
+
}
|
|
82
|
+
else if (dep && typeof dep === "object" && "recipe" in dep) {
|
|
83
|
+
deps.push(dep.recipe);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
targets.push({
|
|
88
|
+
name: recipeName,
|
|
89
|
+
description: recipe.doc?.trim() || undefined,
|
|
90
|
+
isPhony: true,
|
|
91
|
+
dependencies: deps.length > 0 ? deps : undefined,
|
|
92
|
+
recipe: opts?.showRecipe && Array.isArray(recipe.body)
|
|
93
|
+
? recipe.body.filter((line) => typeof line === "string")
|
|
94
|
+
: undefined,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Sort alphabetically by default (consistent with just --list default)
|
|
99
|
+
targets.sort((a, b) => a.name.localeCompare(b.name));
|
|
100
|
+
return { targets, total: targets.length };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Strips order-only dependencies from a make dependency list.
|
|
104
|
+
* In make, `target: normal_dep1 | order_only_dep` — everything after `|` is order-only.
|
|
105
|
+
* We only return dependencies before the `|` separator.
|
|
106
|
+
*/
|
|
107
|
+
function stripOrderOnlyDeps(tokens) {
|
|
108
|
+
const result = [];
|
|
109
|
+
for (const token of tokens) {
|
|
110
|
+
if (token === "|")
|
|
111
|
+
break;
|
|
112
|
+
if (token.length > 0)
|
|
113
|
+
result.push(token);
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
42
117
|
/**
|
|
43
118
|
* Parses `make -pRrq` database output to extract user-defined target names.
|
|
44
119
|
*
|
|
@@ -57,7 +132,7 @@ export function parseMakeTargets(stdout) {
|
|
|
57
132
|
const seen = new Set();
|
|
58
133
|
// The make -pRrq output includes a "# Files" section followed by rules.
|
|
59
134
|
// Target lines appear as: "targetname: deps" or "targetname:"
|
|
60
|
-
const targetRe = /^([a-zA-Z0-9_][a-zA-Z0-9_.\-/]*)
|
|
135
|
+
const targetRe = /^([a-zA-Z0-9_][a-zA-Z0-9_.\-/]*):\s*(.*)/;
|
|
61
136
|
for (const line of stdout.split("\n")) {
|
|
62
137
|
// Skip comments and empty lines
|
|
63
138
|
if (line.startsWith("#") || line.startsWith("\t") || !line.trim())
|
|
@@ -70,12 +145,201 @@ export function parseMakeTargets(stdout) {
|
|
|
70
145
|
continue;
|
|
71
146
|
if (!seen.has(name)) {
|
|
72
147
|
seen.add(name);
|
|
73
|
-
|
|
148
|
+
// Parse dependencies from the right side of ":"
|
|
149
|
+
const depsStr = match[2].trim();
|
|
150
|
+
const tokens = depsStr ? depsStr.split(/\s+/) : [];
|
|
151
|
+
const deps = stripOrderOnlyDeps(tokens);
|
|
152
|
+
targets.push({
|
|
153
|
+
name,
|
|
154
|
+
dependencies: deps.length > 0 ? deps : undefined,
|
|
155
|
+
});
|
|
74
156
|
}
|
|
75
157
|
}
|
|
76
158
|
}
|
|
77
159
|
return { targets, total: targets.length };
|
|
78
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Parses `.PHONY` declarations from Makefile source to determine which targets are phony.
|
|
163
|
+
*
|
|
164
|
+
* @param makefileSource - Raw contents of the Makefile
|
|
165
|
+
* @returns Set of target names declared as .PHONY
|
|
166
|
+
*/
|
|
167
|
+
export function parsePhonyTargets(makefileSource) {
|
|
168
|
+
const phonySet = new Set();
|
|
169
|
+
const phonyRe = /^\.PHONY\s*:\s*(.+)$/;
|
|
170
|
+
for (const line of makefileSource.split("\n")) {
|
|
171
|
+
const trimmed = line.trim();
|
|
172
|
+
const match = trimmed.match(phonyRe);
|
|
173
|
+
if (match) {
|
|
174
|
+
const names = match[1].split(/\s+/).filter((n) => n.length > 0);
|
|
175
|
+
for (const name of names) {
|
|
176
|
+
phonySet.add(name);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return phonySet;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Enriches targets with isPhony flag based on .PHONY declarations.
|
|
184
|
+
*
|
|
185
|
+
* @param targets - Targets previously extracted from `make -pRrq` output
|
|
186
|
+
* @param phonySet - Set of phony target names from parsePhonyTargets
|
|
187
|
+
* @returns The same targets array, mutated with `isPhony` fields where applicable
|
|
188
|
+
*/
|
|
189
|
+
export function enrichPhonyFlags(targets, phonySet) {
|
|
190
|
+
for (const target of targets) {
|
|
191
|
+
if (phonySet.has(target.name)) {
|
|
192
|
+
target.isPhony = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Enriches parsed make targets with descriptions extracted from the Makefile source.
|
|
198
|
+
*
|
|
199
|
+
* Supports the common `target: [deps] ## Description text` convention where a
|
|
200
|
+
* double-hash comment at the end of the target rule line serves as documentation.
|
|
201
|
+
* This convention is widely used in Makefiles that provide a `help` target.
|
|
202
|
+
*
|
|
203
|
+
* @param targets - Targets previously extracted from `make -pRrq` output
|
|
204
|
+
* @param makefileSource - Raw contents of the Makefile
|
|
205
|
+
* @returns The same targets array, mutated with `description` fields where found
|
|
206
|
+
*/
|
|
207
|
+
export function enrichMakeTargetDescriptions(targets, makefileSource) {
|
|
208
|
+
// Build a map of target name → description from lines matching: target: ... ## desc
|
|
209
|
+
const descMap = new Map();
|
|
210
|
+
// Match: targetname: [anything] ## description
|
|
211
|
+
const descRe = /^([a-zA-Z0-9_][a-zA-Z0-9_.\-/]*):[^#]*##\s*(.+)$/;
|
|
212
|
+
for (const line of makefileSource.split("\n")) {
|
|
213
|
+
const match = line.match(descRe);
|
|
214
|
+
if (match) {
|
|
215
|
+
const name = match[1];
|
|
216
|
+
const desc = match[2].trim();
|
|
217
|
+
if (desc) {
|
|
218
|
+
descMap.set(name, desc);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Enrich targets with descriptions
|
|
223
|
+
for (const target of targets) {
|
|
224
|
+
const desc = descMap.get(target.name);
|
|
225
|
+
if (desc) {
|
|
226
|
+
target.description = desc;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return targets;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Parses dependency lists from Makefile source for best-effort dependency enrichment.
|
|
233
|
+
* This extracts dependencies from `target: dep1 dep2` lines in the Makefile source
|
|
234
|
+
* (not the make database output), providing cleaner results for user-defined rules.
|
|
235
|
+
*/
|
|
236
|
+
export function parseMakeDependencies(makefileSource) {
|
|
237
|
+
const depMap = new Map();
|
|
238
|
+
const depRe = /^([a-zA-Z0-9_][a-zA-Z0-9_.\-/]*):\s*([^#\n]*)/;
|
|
239
|
+
for (const line of makefileSource.split("\n")) {
|
|
240
|
+
const match = line.match(depRe);
|
|
241
|
+
if (match) {
|
|
242
|
+
const name = match[1];
|
|
243
|
+
const depsStr = match[2].trim();
|
|
244
|
+
if (depsStr) {
|
|
245
|
+
const tokens = depsStr.split(/\s+/);
|
|
246
|
+
const deps = stripOrderOnlyDeps(tokens);
|
|
247
|
+
if (deps.length > 0) {
|
|
248
|
+
depMap.set(name, deps);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return depMap;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Parses explicit target recipe bodies from Makefile source.
|
|
257
|
+
*
|
|
258
|
+
* Captures tab-indented command lines that immediately follow target rules.
|
|
259
|
+
* Pattern rules (`%.o: %.c`) are excluded here and returned via parsePatternRules.
|
|
260
|
+
*/
|
|
261
|
+
export function parseMakeRecipes(makefileSource) {
|
|
262
|
+
const recipeMap = new Map();
|
|
263
|
+
const lines = makefileSource.split("\n");
|
|
264
|
+
const targetRe = /^([a-zA-Z0-9_][a-zA-Z0-9_.\-/]*):\s*([^#\n]*)/;
|
|
265
|
+
let currentTarget;
|
|
266
|
+
for (const line of lines) {
|
|
267
|
+
const match = line.match(targetRe);
|
|
268
|
+
if (match && !line.trimStart().startsWith(".PHONY")) {
|
|
269
|
+
currentTarget = match[1];
|
|
270
|
+
if (!recipeMap.has(currentTarget)) {
|
|
271
|
+
recipeMap.set(currentTarget, []);
|
|
272
|
+
}
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (line.startsWith("\t") && currentTarget) {
|
|
276
|
+
const cmd = line.trim();
|
|
277
|
+
if (cmd.length > 0) {
|
|
278
|
+
recipeMap.get(currentTarget)?.push(cmd);
|
|
279
|
+
}
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (line.trim().length > 0) {
|
|
283
|
+
currentTarget = undefined;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
for (const [target, recipe] of recipeMap.entries()) {
|
|
287
|
+
if (recipe.length === 0) {
|
|
288
|
+
recipeMap.delete(target);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return recipeMap;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Parses Makefile pattern rules (e.g., `%.o: %.c`) with optional recipes.
|
|
295
|
+
*/
|
|
296
|
+
export function parsePatternRules(makefileSource) {
|
|
297
|
+
const lines = makefileSource.split("\n");
|
|
298
|
+
const patternRe = /^([^\s:#]*%[^\s:#]*):\s*([^#\n]*)/;
|
|
299
|
+
const rules = [];
|
|
300
|
+
let currentRule;
|
|
301
|
+
for (const line of lines) {
|
|
302
|
+
const match = line.match(patternRe);
|
|
303
|
+
if (match) {
|
|
304
|
+
const depsStr = match[2].trim();
|
|
305
|
+
const deps = depsStr ? stripOrderOnlyDeps(depsStr.split(/\s+/)) : [];
|
|
306
|
+
currentRule = {
|
|
307
|
+
pattern: match[1],
|
|
308
|
+
dependencies: deps.length > 0 ? deps : undefined,
|
|
309
|
+
recipe: [],
|
|
310
|
+
};
|
|
311
|
+
rules.push(currentRule);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (line.startsWith("\t") && currentRule) {
|
|
315
|
+
const cmd = line.trim();
|
|
316
|
+
if (cmd.length > 0) {
|
|
317
|
+
currentRule.recipe?.push(cmd);
|
|
318
|
+
}
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (line.trim().length > 0) {
|
|
322
|
+
currentRule = undefined;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
for (const rule of rules) {
|
|
326
|
+
if ((rule.recipe ?? []).length === 0) {
|
|
327
|
+
delete rule.recipe;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return rules;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Adds parsed recipe bodies to already-discovered make targets.
|
|
334
|
+
*/
|
|
335
|
+
export function enrichTargetRecipes(targets, recipeMap) {
|
|
336
|
+
for (const target of targets) {
|
|
337
|
+
const recipe = recipeMap.get(target.name);
|
|
338
|
+
if (recipe && recipe.length > 0) {
|
|
339
|
+
target.recipe = recipe;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
79
343
|
/**
|
|
80
344
|
* Builds a full MakeListResult from parsed target data and the detected tool.
|
|
81
345
|
*/
|
|
@@ -84,6 +348,7 @@ export function buildListResult(parsed, tool) {
|
|
|
84
348
|
targets: parsed.targets,
|
|
85
349
|
total: parsed.total,
|
|
86
350
|
tool,
|
|
351
|
+
...(parsed.patternRules ? { patternRules: parsed.patternRules } : {}),
|
|
87
352
|
};
|
|
88
353
|
}
|
|
89
354
|
//# sourceMappingURL=parsers.js.map
|
package/dist/lib/parsers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../src/lib/parsers.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,MAAc,EACd,MAAc,EACd,QAAgB,EAChB,QAAgB,EAChB,IAAc
|
|
1
|
+
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../src/lib/parsers.ts"],"names":[],"mappings":"AAGA,SAAS,kBAAkB,CACzB,IAAc,EACd,MAA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M,UAAU,eAAe,CAC7B,MAUC,EACD,IAAc;IAEd,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI;QACJ,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC"}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -11,18 +11,41 @@ export declare const MakeRunResultSchema: z.ZodObject<{
|
|
|
11
11
|
make: "make";
|
|
12
12
|
just: "just";
|
|
13
13
|
}>;
|
|
14
|
+
timedOut: z.ZodBoolean;
|
|
15
|
+
errorType: z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
"missing-target": "missing-target";
|
|
17
|
+
"recipe-failure": "recipe-failure";
|
|
18
|
+
"parse-error": "parse-error";
|
|
19
|
+
}>>;
|
|
14
20
|
}, z.core.$strip>;
|
|
15
21
|
export type MakeRunResult = z.infer<typeof MakeRunResultSchema>;
|
|
16
|
-
/** Zod schema for a single target entry with name
|
|
22
|
+
/** Zod schema for a single target entry with name, optional description, phony flag, and dependencies. */
|
|
17
23
|
export declare const MakeTargetSchema: z.ZodObject<{
|
|
18
24
|
name: z.ZodString;
|
|
19
25
|
description: z.ZodOptional<z.ZodString>;
|
|
26
|
+
isPhony: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
recipe: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/** Zod schema for a Make pattern rule entry (e.g., `%.o: %.c`). */
|
|
31
|
+
export declare const MakePatternRuleSchema: z.ZodObject<{
|
|
32
|
+
pattern: z.ZodString;
|
|
33
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
recipe: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
35
|
}, z.core.$strip>;
|
|
21
36
|
/** Zod schema for structured make/just list output with targets and total count. */
|
|
22
37
|
export declare const MakeListResultSchema: z.ZodObject<{
|
|
23
38
|
targets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
39
|
name: z.ZodString;
|
|
25
40
|
description: z.ZodOptional<z.ZodString>;
|
|
41
|
+
isPhony: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
recipe: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
patternRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
46
|
+
pattern: z.ZodString;
|
|
47
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
recipe: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
49
|
}, z.core.$strip>>>;
|
|
27
50
|
total: z.ZodNumber;
|
|
28
51
|
tool: z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mGAAmG;AACnG,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mGAAmG;AACnG,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,0GAA0G;AAC1G,eAAO,MAAM,gBAAgB;;;;;;iBAM3B,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAC;AAEH,oFAAoF;AACpF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAK/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/schemas/index.js
CHANGED
|
@@ -8,15 +8,27 @@ export const MakeRunResultSchema = z.object({
|
|
|
8
8
|
stderr: z.string().optional(),
|
|
9
9
|
duration: z.number(),
|
|
10
10
|
tool: z.enum(["make", "just"]),
|
|
11
|
+
timedOut: z.boolean(),
|
|
12
|
+
errorType: z.enum(["missing-target", "recipe-failure", "parse-error"]).optional(),
|
|
11
13
|
});
|
|
12
|
-
/** Zod schema for a single target entry with name
|
|
14
|
+
/** Zod schema for a single target entry with name, optional description, phony flag, and dependencies. */
|
|
13
15
|
export const MakeTargetSchema = z.object({
|
|
14
16
|
name: z.string(),
|
|
15
17
|
description: z.string().optional(),
|
|
18
|
+
isPhony: z.boolean().optional(),
|
|
19
|
+
dependencies: z.array(z.string()).optional(),
|
|
20
|
+
recipe: z.array(z.string()).optional(),
|
|
21
|
+
});
|
|
22
|
+
/** Zod schema for a Make pattern rule entry (e.g., `%.o: %.c`). */
|
|
23
|
+
export const MakePatternRuleSchema = z.object({
|
|
24
|
+
pattern: z.string(),
|
|
25
|
+
dependencies: z.array(z.string()).optional(),
|
|
26
|
+
recipe: z.array(z.string()).optional(),
|
|
16
27
|
});
|
|
17
28
|
/** Zod schema for structured make/just list output with targets and total count. */
|
|
18
29
|
export const MakeListResultSchema = z.object({
|
|
19
30
|
targets: z.array(MakeTargetSchema).optional(),
|
|
31
|
+
patternRules: z.array(MakePatternRuleSchema).optional(),
|
|
20
32
|
total: z.number(),
|
|
21
33
|
tool: z.enum(["make", "just"]),
|
|
22
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"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"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/tools/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/tools/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgDzE,yDAAyD;AACzD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QAqKjD"}
|
package/dist/tools/list.js
CHANGED
|
@@ -1,48 +1,160 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { compactDualOutput, INPUT_LIMITS } from "@paretools/shared";
|
|
2
|
+
import { compactDualOutput, assertNoFlagInjection, INPUT_LIMITS } from "@paretools/shared";
|
|
3
3
|
import { makeCmd, justCmd, resolveTool } from "../lib/make-runner.js";
|
|
4
|
-
import { parseJustList, parseMakeTargets, buildListResult } from "../lib/parsers.js";
|
|
4
|
+
import { parseJustList, parseJustDumpJson, parseMakeTargets, enrichMakeTargetDescriptions, parsePhonyTargets, enrichPhonyFlags, parseMakeRecipes, enrichTargetRecipes, parsePatternRules, buildListResult, } from "../lib/parsers.js";
|
|
5
5
|
import { formatList, compactListMap, formatListCompact } from "../lib/formatters.js";
|
|
6
6
|
import { MakeListResultSchema } from "../schemas/index.js";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
/** Attempts to use `just --dump-format json` for structured recipe parsing. */
|
|
10
|
+
async function tryJustJsonDump(cwd, file, showRecipe) {
|
|
11
|
+
try {
|
|
12
|
+
const jsonArgs = ["--dump-format", "json"];
|
|
13
|
+
if (file)
|
|
14
|
+
jsonArgs.push("--justfile", file);
|
|
15
|
+
const jsonResult = await justCmd(jsonArgs, cwd);
|
|
16
|
+
if (jsonResult.exitCode === 0 && jsonResult.stdout.trim()) {
|
|
17
|
+
return parseJustDumpJson(jsonResult.stdout, { showRecipe });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// JSON dump not supported or failed — fall back
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
7
25
|
/** Registers the `list` tool on the given MCP server. */
|
|
8
26
|
export function registerListTool(server) {
|
|
9
27
|
server.registerTool("list", {
|
|
10
28
|
title: "Make/Just List Targets",
|
|
11
|
-
description: "Lists available make or just targets with optional descriptions. Auto-detects make vs just.
|
|
29
|
+
description: "Lists available make or just targets with optional descriptions. Auto-detects make vs just.",
|
|
12
30
|
inputSchema: {
|
|
13
|
-
path: z
|
|
14
|
-
.string()
|
|
15
|
-
.max(INPUT_LIMITS.PATH_MAX)
|
|
16
|
-
.optional()
|
|
17
|
-
.describe("Project root path (default: cwd)"),
|
|
31
|
+
path: z.string().max(INPUT_LIMITS.PATH_MAX).optional().describe("Project root path"),
|
|
18
32
|
tool: z
|
|
19
33
|
.enum(["auto", "make", "just"])
|
|
20
34
|
.optional()
|
|
21
35
|
.default("auto")
|
|
22
36
|
.describe('Task runner to use: "auto" detects from files, or force "make"/"just"'),
|
|
23
|
-
|
|
37
|
+
file: z
|
|
38
|
+
.string()
|
|
39
|
+
.max(INPUT_LIMITS.PATH_MAX)
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Path to a non-default makefile or justfile (maps to make -f FILE / just --justfile FILE)"),
|
|
42
|
+
filter: z
|
|
43
|
+
.string()
|
|
44
|
+
.max(INPUT_LIMITS.SHORT_STRING_MAX)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Client-side regex filter on target names — useful for projects with many targets"),
|
|
47
|
+
includeSubmodules: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("Include recipes from justfile submodules (just --list-submodules, just only)"),
|
|
51
|
+
unsorted: z
|
|
24
52
|
.boolean()
|
|
25
53
|
.optional()
|
|
26
|
-
.
|
|
27
|
-
|
|
54
|
+
.describe("List targets in definition order instead of alphabetical (just --unsorted, just only)"),
|
|
55
|
+
showRecipe: z
|
|
56
|
+
.boolean()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Include recipe command bodies per target where available (from just JSON dump or Makefile source)"),
|
|
59
|
+
compact: z.boolean().optional().default(true).describe("Prefer compact output"),
|
|
28
60
|
},
|
|
29
61
|
outputSchema: MakeListResultSchema,
|
|
30
|
-
}, async ({ path, tool, compact }) => {
|
|
62
|
+
}, async ({ path, tool, file, filter, includeSubmodules, unsorted, showRecipe, compact }) => {
|
|
63
|
+
if (file)
|
|
64
|
+
assertNoFlagInjection(file, "file");
|
|
65
|
+
if (filter)
|
|
66
|
+
assertNoFlagInjection(filter, "filter");
|
|
31
67
|
const cwd = path || process.cwd();
|
|
32
68
|
const resolved = resolveTool(tool || "auto", cwd);
|
|
33
69
|
let parsed;
|
|
34
70
|
let rawOutput;
|
|
35
71
|
if (resolved === "just") {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
72
|
+
// Try JSON dump first for more reliable parsing (Gap #171)
|
|
73
|
+
const jsonParsed = await tryJustJsonDump(cwd, file, showRecipe);
|
|
74
|
+
if (jsonParsed) {
|
|
75
|
+
parsed = jsonParsed;
|
|
76
|
+
// Get --list output for raw display and optional ordering
|
|
77
|
+
const listArgs = ["--list"];
|
|
78
|
+
if (file)
|
|
79
|
+
listArgs.push("--justfile", file);
|
|
80
|
+
if (includeSubmodules)
|
|
81
|
+
listArgs.push("--list-submodules");
|
|
82
|
+
if (unsorted) {
|
|
83
|
+
listArgs.push("--unsorted");
|
|
84
|
+
// Reorder JSON-parsed targets to match --list definition order
|
|
85
|
+
const listResult = await justCmd(listArgs, cwd);
|
|
86
|
+
rawOutput = listResult.stdout.trim();
|
|
87
|
+
const listParsed = parseJustList(listResult.stdout);
|
|
88
|
+
const orderMap = new Map(listParsed.targets.map((t, i) => [t.name, i]));
|
|
89
|
+
parsed.targets.sort((a, b) => {
|
|
90
|
+
const aIdx = orderMap.get(a.name) ?? Infinity;
|
|
91
|
+
const bIdx = orderMap.get(b.name) ?? Infinity;
|
|
92
|
+
return aIdx - bIdx;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const listResult = await justCmd(listArgs, cwd);
|
|
97
|
+
rawOutput = listResult.stdout.trim();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Fall back to text parsing if JSON dump fails
|
|
102
|
+
const justArgs = ["--list"];
|
|
103
|
+
if (file)
|
|
104
|
+
justArgs.push("--justfile", file);
|
|
105
|
+
if (includeSubmodules)
|
|
106
|
+
justArgs.push("--list-submodules");
|
|
107
|
+
if (unsorted)
|
|
108
|
+
justArgs.push("--unsorted");
|
|
109
|
+
const result = await justCmd(justArgs, cwd);
|
|
110
|
+
rawOutput = result.stdout.trim();
|
|
111
|
+
const textParsed = parseJustList(result.stdout);
|
|
112
|
+
// Mark all just targets as phony (Gap #172: just recipes are inherently phony)
|
|
113
|
+
parsed = {
|
|
114
|
+
targets: textParsed.targets.map((t) => ({
|
|
115
|
+
...t,
|
|
116
|
+
isPhony: true,
|
|
117
|
+
})),
|
|
118
|
+
total: textParsed.total,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
39
121
|
}
|
|
40
122
|
else {
|
|
41
|
-
const
|
|
123
|
+
const makeArgs = ["-pRrq"];
|
|
124
|
+
if (file)
|
|
125
|
+
makeArgs.push("-f", file);
|
|
126
|
+
makeArgs.push(":");
|
|
127
|
+
const result = await makeCmd(makeArgs, cwd);
|
|
42
128
|
// make -pRrq exits non-zero when the dummy target ":" fails, but still
|
|
43
129
|
// prints the database to stdout. We only care about stdout.
|
|
44
130
|
rawOutput = result.stdout.trim();
|
|
45
131
|
parsed = parseMakeTargets(result.stdout);
|
|
132
|
+
// Enrich targets with ## descriptions and .PHONY info from the Makefile source
|
|
133
|
+
const makefilePath = file || join(cwd, "Makefile");
|
|
134
|
+
try {
|
|
135
|
+
const makefileSource = await readFile(makefilePath, "utf-8");
|
|
136
|
+
enrichMakeTargetDescriptions(parsed.targets, makefileSource);
|
|
137
|
+
// Gap #172: Extract .PHONY declarations
|
|
138
|
+
const phonySet = parsePhonyTargets(makefileSource);
|
|
139
|
+
enrichPhonyFlags(parsed.targets, phonySet);
|
|
140
|
+
if (showRecipe) {
|
|
141
|
+
const recipes = parseMakeRecipes(makefileSource);
|
|
142
|
+
enrichTargetRecipes(parsed.targets, recipes);
|
|
143
|
+
}
|
|
144
|
+
parsed = {
|
|
145
|
+
...parsed,
|
|
146
|
+
patternRules: parsePatternRules(makefileSource),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// Makefile not readable (e.g. generated targets only) — skip enrichment
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Apply client-side filter if provided
|
|
154
|
+
if (filter) {
|
|
155
|
+
const re = new RegExp(filter);
|
|
156
|
+
parsed.targets = parsed.targets.filter((t) => re.test(t.name));
|
|
157
|
+
parsed.total = parsed.targets.length;
|
|
46
158
|
}
|
|
47
159
|
const data = buildListResult(parsed, resolved);
|
|
48
160
|
return compactDualOutput(data, rawOutput, formatList, compactListMap, formatListCompact, compact === false);
|
package/dist/tools/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/tools/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/tools/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WA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AC,CAAC;YAC9B,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/D,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACvC,CAAC;QAED,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,iBAAiB,CACtB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,OAAO,KAAK,KAAK,CAClB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/tools/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/tools/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAOzE,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,QAkKhD"}
|
package/dist/tools/run.js
CHANGED
|
@@ -8,7 +8,7 @@ import { MakeRunResultSchema } from "../schemas/index.js";
|
|
|
8
8
|
export function registerRunTool(server) {
|
|
9
9
|
server.registerTool("run", {
|
|
10
10
|
title: "Make/Just Run",
|
|
11
|
-
description: "Runs a make or just target and returns structured output (stdout, stderr, exit code, duration). Auto-detects make vs just.
|
|
11
|
+
description: "Runs a make or just target and returns structured output (stdout, stderr, exit code, duration). Auto-detects make vs just.",
|
|
12
12
|
inputSchema: {
|
|
13
13
|
target: z.string().max(INPUT_LIMITS.SHORT_STRING_MAX).describe("Target to run"),
|
|
14
14
|
args: z
|
|
@@ -17,35 +17,121 @@ export function registerRunTool(server) {
|
|
|
17
17
|
.optional()
|
|
18
18
|
.default([])
|
|
19
19
|
.describe("Additional arguments to pass to the target"),
|
|
20
|
-
path: z
|
|
21
|
-
.string()
|
|
22
|
-
.max(INPUT_LIMITS.PATH_MAX)
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Project root path (default: cwd)"),
|
|
20
|
+
path: z.string().max(INPUT_LIMITS.PATH_MAX).optional().describe("Project root path"),
|
|
25
21
|
tool: z
|
|
26
22
|
.enum(["auto", "make", "just"])
|
|
27
23
|
.optional()
|
|
28
24
|
.default("auto")
|
|
29
25
|
.describe('Task runner to use: "auto" detects from files, or force "make"/"just"'),
|
|
30
|
-
|
|
26
|
+
file: z
|
|
27
|
+
.string()
|
|
28
|
+
.max(INPUT_LIMITS.PATH_MAX)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Path to a non-default makefile or justfile (maps to make -f FILE / just --justfile FILE)"),
|
|
31
|
+
env: z
|
|
32
|
+
.record(z.string(), z.string())
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("Environment variables to pass to the target execution (key-value pairs)"),
|
|
35
|
+
dryRun: z
|
|
36
|
+
.boolean()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Preview commands without executing (make -n / just --dry-run)"),
|
|
39
|
+
jobs: z.number().optional().describe("Number of parallel jobs (make -j N, make only)"),
|
|
40
|
+
silent: z
|
|
31
41
|
.boolean()
|
|
32
42
|
.optional()
|
|
33
|
-
.
|
|
34
|
-
|
|
43
|
+
.describe("Suppress command echoing (make -s / just --quiet)"),
|
|
44
|
+
keepGoing: z
|
|
45
|
+
.boolean()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Continue after errors in independent targets (make -k, make only)"),
|
|
48
|
+
alwaysMake: z
|
|
49
|
+
.boolean()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Force rebuild regardless of timestamps (make -B, make only)"),
|
|
52
|
+
verbose: z
|
|
53
|
+
.boolean()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Enable verbose output (just --verbose, just only)"),
|
|
56
|
+
trace: z.boolean().optional().describe("Trace execution order (make --trace, make only)"),
|
|
57
|
+
question: z
|
|
58
|
+
.boolean()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Check if target is up to date without executing (make -q, make only). Exit code 0 = up to date."),
|
|
61
|
+
compact: z.boolean().optional().default(true).describe("Prefer compact output"),
|
|
35
62
|
},
|
|
36
63
|
outputSchema: MakeRunResultSchema,
|
|
37
|
-
}, async ({ target, args, path, tool, compact }) => {
|
|
64
|
+
}, async ({ target, args, path, tool, file, env, dryRun, jobs, silent, keepGoing, alwaysMake, verbose, trace, question, compact, }) => {
|
|
38
65
|
const cwd = path || process.cwd();
|
|
39
66
|
assertNoFlagInjection(target, "target");
|
|
40
|
-
|
|
41
|
-
assertNoFlagInjection(
|
|
42
|
-
}
|
|
67
|
+
if (file)
|
|
68
|
+
assertNoFlagInjection(file, "file");
|
|
43
69
|
const resolved = resolveTool(tool || "auto", cwd);
|
|
44
|
-
|
|
70
|
+
// Build flags before the target
|
|
71
|
+
const flags = [];
|
|
72
|
+
if (resolved === "just") {
|
|
73
|
+
if (file)
|
|
74
|
+
flags.push("--justfile", file);
|
|
75
|
+
if (dryRun)
|
|
76
|
+
flags.push("--dry-run");
|
|
77
|
+
if (silent)
|
|
78
|
+
flags.push("--quiet");
|
|
79
|
+
if (verbose)
|
|
80
|
+
flags.push("--verbose");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// make
|
|
84
|
+
if (file)
|
|
85
|
+
flags.push("-f", file);
|
|
86
|
+
if (dryRun)
|
|
87
|
+
flags.push("-n");
|
|
88
|
+
if (jobs !== undefined)
|
|
89
|
+
flags.push("-j", String(jobs));
|
|
90
|
+
if (silent)
|
|
91
|
+
flags.push("-s");
|
|
92
|
+
if (keepGoing)
|
|
93
|
+
flags.push("-k");
|
|
94
|
+
if (alwaysMake)
|
|
95
|
+
flags.push("-B");
|
|
96
|
+
if (trace)
|
|
97
|
+
flags.push("--trace");
|
|
98
|
+
if (question)
|
|
99
|
+
flags.push("-q");
|
|
100
|
+
}
|
|
101
|
+
// Build environment variable arguments
|
|
102
|
+
// For make: pass as VAR=VALUE positional args
|
|
103
|
+
// For just: pass as VAR=VALUE positional args (just supports env var overrides this way)
|
|
104
|
+
const envArgs = [];
|
|
105
|
+
if (env) {
|
|
106
|
+
for (const [key, value] of Object.entries(env)) {
|
|
107
|
+
envArgs.push(`${key}=${value}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const cmdArgs = [...flags, target, ...(args || []), ...envArgs];
|
|
45
111
|
const start = Date.now();
|
|
46
|
-
|
|
112
|
+
let timedOut = false;
|
|
113
|
+
let result;
|
|
114
|
+
try {
|
|
115
|
+
result = resolved === "just" ? await justCmd(cmdArgs, cwd) : await makeCmd(cmdArgs, cwd);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
119
|
+
// Gap #174: Detect timeout errors from the shared runner
|
|
120
|
+
if (errMsg.includes("timed out")) {
|
|
121
|
+
timedOut = true;
|
|
122
|
+
result = {
|
|
123
|
+
exitCode: 124, // Standard timeout exit code
|
|
124
|
+
stdout: "",
|
|
125
|
+
stderr: errMsg,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Re-throw non-timeout errors
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
47
133
|
const duration = Date.now() - start;
|
|
48
|
-
const data = parseRunOutput(target, result.stdout, result.stderr, result.exitCode, duration, resolved);
|
|
134
|
+
const data = parseRunOutput(target, result.stdout, result.stderr, result.exitCode, duration, resolved, timedOut);
|
|
49
135
|
const rawOutput = (result.stdout + "\n" + result.stderr).trim();
|
|
50
136
|
return compactDualOutput(data, rawOutput, formatRun, compactRunMap, formatRunCompact, compact === false);
|
|
51
137
|
});
|
package/dist/tools/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/tools/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wDAAwD;AACxD,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,MAAM,CAAC,YAAY,CACjB,KAAK,EACL;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/tools/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wDAAwD;AACxD,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,MAA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ACT,CAAC;QACF,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,OAAO,iBAAiB,CACtB,IAAI,EACJ,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,OAAO,KAAK,KAAK,CAClB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paretools/make",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"mcpName": "io.github.Dave-London/pare-make",
|
|
5
5
|
"description": "MCP server for Make/Just task runners with structured, token-efficient output",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
53
53
|
"zod": "^4.3.6",
|
|
54
|
-
"@paretools/shared": "0.
|
|
54
|
+
"@paretools/shared": "0.10.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^25.2.3",
|