@procedures/cli-run 0.34.0 → 0.35.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/CHANGELOG.md +35 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/module.d.ts +2 -2
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +6 -7
- package/dist/module.js.map +1 -1
- package/dist/procedures/cli/run.d.ts.map +1 -1
- package/dist/procedures/cli/run.js +8 -40
- package/dist/procedures/cli/run.js.map +1 -1
- package/dist/types.d.ts +3 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -7
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/module.ts +7 -7
- package/src/procedures/cli/run.ts +8 -59
- package/src/types.ts +4 -19
package/dist/module.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Provides cli.run procedure for calling mark CLI commands via client-shell.
|
|
7
7
|
*/
|
|
8
|
-
import { type ProcedureModule, type
|
|
8
|
+
import { type ProcedureModule, type PackageDefinition } from "@procedures/client";
|
|
9
9
|
/**
|
|
10
10
|
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
11
11
|
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
@@ -17,5 +17,5 @@ export default cliModule;
|
|
|
17
17
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
18
18
|
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
19
19
|
*/
|
|
20
|
-
export declare
|
|
20
|
+
export declare const registerCliProcedures: PackageDefinition["register"];
|
|
21
21
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAkC,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAoClH;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,eAAmC,CAAC;eAE7C,SAAS;AAExB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,UAAU,CAAuB,CAAC"}
|
package/dist/module.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Provides cli.run procedure for calling mark CLI commands via client-shell.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { definePackage, createProcedure } from "@procedures/client";
|
|
9
9
|
import shellModule from "@procedures/shell/module";
|
|
10
10
|
import { cliRun } from "./procedures/cli/index.js";
|
|
11
11
|
import { CliRunInputSchema, CliRunOutputSchema } from "./types.js";
|
|
@@ -32,20 +32,19 @@ const cliRunProcedure = createProcedure()
|
|
|
32
32
|
// =============================================================================
|
|
33
33
|
// Registration
|
|
34
34
|
// =============================================================================
|
|
35
|
+
const cliPackage = definePackage("@procedures/cli-run", [
|
|
36
|
+
cliRunProcedure,
|
|
37
|
+
], [shellModule]);
|
|
35
38
|
/**
|
|
36
39
|
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
37
40
|
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
38
41
|
*/
|
|
39
|
-
export const cliModule =
|
|
40
|
-
cliRunProcedure,
|
|
41
|
-
], [shellModule]);
|
|
42
|
+
export const cliModule = cliPackage.module;
|
|
42
43
|
export default cliModule;
|
|
43
44
|
/**
|
|
44
45
|
* This function registers the procedures of @procedures/cli-run, and of the modules that it requires, in
|
|
45
46
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
46
47
|
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
47
48
|
*/
|
|
48
|
-
export
|
|
49
|
-
registerModules(registry, [cliModule]);
|
|
50
|
-
}
|
|
49
|
+
export const registerCliProcedures = cliPackage.register;
|
|
51
50
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAgD,MAAM,oBAAoB,CAAC;AAClH,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAuC,MAAM,YAAY,CAAC;AAGxG,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,MAAM,eAAe,GAAG,eAAe,EAAE;KACtC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACpB,KAAK,CAAC,iBAAiB,CAAC;KACxB,MAAM,CAAC,kBAAkB,CAAC;KAC1B,IAAI,CAAC;IACJ,WAAW,EAAE,wBAAwB;IACrC,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE;IAClC,MAAM,EAAE,MAAM;IACd,mFAAmF;IACnF,4DAA4D;IAC5D,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE;CAC3D,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAkB,EAAE,GAAqB,EAAyB,EAAE;IAClF,OAAO,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,MAAM,UAAU,GAAsB,aAAa,CAAC,qBAAqB,EAAE;IACvE,eAAe;CAChB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB,UAAU,CAAC,MAAM,CAAC;AAE5D,eAAe,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkC,UAAU,CAAC,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/procedures/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/procedures/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAwBhE;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAAC,GAAG,MAAM,EAAE,CAUhG;AAKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,YAAY,CAAC,CAMvB"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { defineCliTool, nodeScript } from "@procedures/shell/cli";
|
|
11
12
|
/**
|
|
12
13
|
* Find the mark CLI of the workspace that contains this package (packages/mark/dist/cli.js)
|
|
13
14
|
*/
|
|
@@ -51,30 +52,8 @@ export function buildMarkArgs(input) {
|
|
|
51
52
|
}
|
|
52
53
|
return args;
|
|
53
54
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
*/
|
|
57
|
-
async function shellExecution(input, ctx, startTime) {
|
|
58
|
-
const args = buildMarkArgs(input);
|
|
59
|
-
// Build shell input
|
|
60
|
-
const shellInput = {
|
|
61
|
-
command: process.execPath,
|
|
62
|
-
args: [resolveMarkCli(), ...args],
|
|
63
|
-
};
|
|
64
|
-
if (input.cwd !== undefined)
|
|
65
|
-
shellInput.cwd = input.cwd;
|
|
66
|
-
if (input.timeout !== undefined)
|
|
67
|
-
shellInput.timeout = input.timeout;
|
|
68
|
-
// Call shell.run
|
|
69
|
-
const result = await ctx.client.call(["shell", "run"], shellInput);
|
|
70
|
-
return {
|
|
71
|
-
exitCode: result.exitCode,
|
|
72
|
-
stdout: result.stdout,
|
|
73
|
-
stderr: result.stderr,
|
|
74
|
-
success: result.exitCode === 0,
|
|
75
|
-
duration: Date.now() - startTime,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
55
|
+
/** The runner of mark: the mark CLI of the workspace, run with Node through `shell.run`. */
|
|
56
|
+
const mark = defineCliTool({ name: "mark", resolve: () => nodeScript(resolveMarkCli()) });
|
|
78
57
|
/**
|
|
79
58
|
* Run a mark CLI command
|
|
80
59
|
*
|
|
@@ -95,21 +74,10 @@ async function shellExecution(input, ctx, startTime) {
|
|
|
95
74
|
* });
|
|
96
75
|
*/
|
|
97
76
|
export async function cliRun(input, ctx) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return await shellExecution(input, ctx, startTime);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
return {
|
|
107
|
-
exitCode: 1,
|
|
108
|
-
stdout: "",
|
|
109
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
110
|
-
success: false,
|
|
111
|
-
duration: Date.now() - startTime,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
77
|
+
// Always through the mark CLI. Before, a second path sent the input straight to a running
|
|
78
|
+
// CLI server, without mark's argument mapping, so the two paths gave different results
|
|
79
|
+
// (a "dry run" wrote files), and it had its own copy of the lockfile logic (deep dive CLI-12).
|
|
80
|
+
// The runner does not throw: an error gives exit code 1 and its message.
|
|
81
|
+
return mark.run(buildMarkArgs(input), { cwd: input.cwd, timeout: input.timeout }, ctx);
|
|
114
82
|
}
|
|
115
83
|
//# sourceMappingURL=run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/procedures/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/procedures/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGlE;;GAEG;AACH,SAAS,cAAc;IACrB,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC;YACjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC5D,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,OAAO,GAAG,CAAC;YACb,CAAC;YACD,MAAM;QACR,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM;QACR,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;AAC/G,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAAwD;IACpF,MAAM,IAAI,GAAa,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,4FAA4F;AAC5F,MAAM,IAAI,GAAG,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;AAE1F;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAAkB,EAClB,GAAqB;IAErB,0FAA0F;IAC1F,uFAAuF;IACvF,+FAA+F;IAC/F,yEAAyE;IACzE,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* client-cli wraps the mark CLI as procedures using client-shell.
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
|
+
import { type CliToolOutput } from "@procedures/shell/cli";
|
|
7
8
|
export declare const CliRunInputSchema: z.ZodObject<{
|
|
8
9
|
path: z.ZodArray<z.ZodString>;
|
|
9
10
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -12,17 +13,8 @@ export declare const CliRunInputSchema: z.ZodObject<{
|
|
|
12
13
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
13
14
|
}>;
|
|
14
15
|
export type CliRunInput = z.infer<typeof CliRunInputSchema>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exitCode: number;
|
|
18
|
-
/** Standard output */
|
|
19
|
-
stdout: string;
|
|
20
|
-
/** Standard error */
|
|
21
|
-
stderr: string;
|
|
22
|
-
/** Whether command succeeded (exit code 0) */
|
|
23
|
-
success: boolean;
|
|
24
|
-
/** Duration in milliseconds */
|
|
25
|
-
duration: number;
|
|
16
|
+
/** The result of cli.run: the shared result of a CLI tool (`@procedures/shell/cli`). */
|
|
17
|
+
export interface CliRunOutput extends CliToolOutput {
|
|
26
18
|
}
|
|
27
19
|
/** The output schema of cli.run (roadmap 2.1). Loose: a field that it does not name stays. */
|
|
28
20
|
export declare const CliRunOutputSchema: z.ZodType<CliRunOutput>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMhF,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,SAAS,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9B,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7G,UAAU,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACnD,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACrC,CAWC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,wFAAwF;AACxF,MAAM,WAAW,YAAa,SAAQ,aAAa;CAAG;AAEtD,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAA+B,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* client-cli wraps the mark CLI as procedures using client-shell.
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
|
+
import { cliToolOutputSchema } from "@procedures/shell/cli";
|
|
7
8
|
// =============================================================================
|
|
8
9
|
// cli.run Types
|
|
9
10
|
// =============================================================================
|
|
@@ -20,11 +21,5 @@ export const CliRunInputSchema = z.object({
|
|
|
20
21
|
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
21
22
|
});
|
|
22
23
|
/** The output schema of cli.run (roadmap 2.1). Loose: a field that it does not name stays. */
|
|
23
|
-
export const CliRunOutputSchema =
|
|
24
|
-
exitCode: z.number().describe("The exit code of mark"),
|
|
25
|
-
stdout: z.string().describe("The standard output of mark"),
|
|
26
|
-
stderr: z.string().describe("The standard error of mark"),
|
|
27
|
-
success: z.boolean().describe("True when the exit code is 0"),
|
|
28
|
-
duration: z.number().describe("The time of the command, in milliseconds"),
|
|
29
|
-
});
|
|
24
|
+
export const CliRunOutputSchema = cliToolOutputSchema("mark");
|
|
30
25
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAsB,MAAM,uBAAuB,CAAC;AAEhF,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,iBAAiB,GAMzB,CAAC,CAAC,MAAM,CAAC;IACZ,qEAAqE;IACrE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;IAC1G,+EAA+E;IAC/E,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8EAA8E,CAAC;IAC9K,0CAA0C;IAC1C,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAC1F,wBAAwB;IACxB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACxD,8BAA8B;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;CACnE,CAAC,CAAC;AAOH,8FAA8F;AAC9F,MAAM,CAAC,MAAM,kBAAkB,GAA4B,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/cli-run",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.1",
|
|
5
5
|
"description": "Run any mark CLI command as a procedure (cli.run) with a safe argv mapping: no shell, typed flags and captured output.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cli",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"provenance": true
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@procedures/client": "0.
|
|
64
|
-
"@procedures/shell": "0.
|
|
63
|
+
"@procedures/client": "0.35.1",
|
|
64
|
+
"@procedures/shell": "0.35.1",
|
|
65
65
|
"zod": "^4.6.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
package/src/module.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { definePackage, createProcedure, type ProcedureModule, type PackageDefinition } from "@procedures/client";
|
|
11
11
|
import shellModule from "@procedures/shell/module";
|
|
12
12
|
import { cliRun } from "./procedures/cli/index.js";
|
|
13
13
|
import { CliRunInputSchema, CliRunOutputSchema, type CliRunInput, type CliRunOutput } from "./types.js";
|
|
@@ -39,13 +39,15 @@ const cliRunProcedure = createProcedure()
|
|
|
39
39
|
// Registration
|
|
40
40
|
// =============================================================================
|
|
41
41
|
|
|
42
|
+
const cliPackage: PackageDefinition = definePackage("@procedures/cli-run", [
|
|
43
|
+
cliRunProcedure,
|
|
44
|
+
], [shellModule]);
|
|
45
|
+
|
|
42
46
|
/**
|
|
43
47
|
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
44
48
|
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
45
49
|
*/
|
|
46
|
-
export const cliModule: ProcedureModule =
|
|
47
|
-
cliRunProcedure,
|
|
48
|
-
], [shellModule]);
|
|
50
|
+
export const cliModule: ProcedureModule = cliPackage.module;
|
|
49
51
|
|
|
50
52
|
export default cliModule;
|
|
51
53
|
|
|
@@ -54,6 +56,4 @@ export default cliModule;
|
|
|
54
56
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
55
57
|
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
56
58
|
*/
|
|
57
|
-
export
|
|
58
|
-
registerModules(registry, [cliModule]);
|
|
59
|
-
}
|
|
59
|
+
export const registerCliProcedures: PackageDefinition["register"] = cliPackage.register;
|
|
@@ -10,6 +10,7 @@ import { existsSync } from "node:fs";
|
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import type { ProcedureContext } from "@procedures/client";
|
|
13
|
+
import { defineCliTool, nodeScript } from "@procedures/shell/cli";
|
|
13
14
|
import type { CliRunInput, CliRunOutput } from "../../types.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -56,49 +57,8 @@ export function buildMarkArgs(input: Pick<CliRunInput, "path" | "positional" | "
|
|
|
56
57
|
return args;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
async function shellExecution(
|
|
63
|
-
input: CliRunInput,
|
|
64
|
-
ctx: ProcedureContext,
|
|
65
|
-
startTime: number
|
|
66
|
-
): Promise<CliRunOutput> {
|
|
67
|
-
const args = buildMarkArgs(input);
|
|
68
|
-
|
|
69
|
-
// Build shell input
|
|
70
|
-
const shellInput: {
|
|
71
|
-
command: string;
|
|
72
|
-
args: string[];
|
|
73
|
-
cwd?: string | undefined;
|
|
74
|
-
timeout?: number | undefined;
|
|
75
|
-
} = {
|
|
76
|
-
command: process.execPath,
|
|
77
|
-
args: [resolveMarkCli(), ...args],
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
if (input.cwd !== undefined) shellInput.cwd = input.cwd;
|
|
81
|
-
if (input.timeout !== undefined) shellInput.timeout = input.timeout;
|
|
82
|
-
|
|
83
|
-
// Call shell.run
|
|
84
|
-
const result = await ctx.client.call<
|
|
85
|
-
typeof shellInput,
|
|
86
|
-
{
|
|
87
|
-
exitCode: number;
|
|
88
|
-
stdout: string;
|
|
89
|
-
stderr: string;
|
|
90
|
-
signal?: string | undefined;
|
|
91
|
-
}
|
|
92
|
-
>(["shell", "run"], shellInput);
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
exitCode: result.exitCode,
|
|
96
|
-
stdout: result.stdout,
|
|
97
|
-
stderr: result.stderr,
|
|
98
|
-
success: result.exitCode === 0,
|
|
99
|
-
duration: Date.now() - startTime,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
60
|
+
/** The runner of mark: the mark CLI of the workspace, run with Node through `shell.run`. */
|
|
61
|
+
const mark = defineCliTool({ name: "mark", resolve: () => nodeScript(resolveMarkCli()) });
|
|
102
62
|
|
|
103
63
|
/**
|
|
104
64
|
* Run a mark CLI command
|
|
@@ -123,20 +83,9 @@ export async function cliRun(
|
|
|
123
83
|
input: CliRunInput,
|
|
124
84
|
ctx: ProcedureContext
|
|
125
85
|
): Promise<CliRunOutput> {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// (a "dry run" wrote files), and it had its own copy of the lockfile logic (deep dive CLI-12).
|
|
132
|
-
return await shellExecution(input, ctx, startTime);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
return {
|
|
135
|
-
exitCode: 1,
|
|
136
|
-
stdout: "",
|
|
137
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
138
|
-
success: false,
|
|
139
|
-
duration: Date.now() - startTime,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
86
|
+
// Always through the mark CLI. Before, a second path sent the input straight to a running
|
|
87
|
+
// CLI server, without mark's argument mapping, so the two paths gave different results
|
|
88
|
+
// (a "dry run" wrote files), and it had its own copy of the lockfile logic (deep dive CLI-12).
|
|
89
|
+
// The runner does not throw: an error gives exit code 1 and its message.
|
|
90
|
+
return mark.run(buildMarkArgs(input), { cwd: input.cwd, timeout: input.timeout }, ctx);
|
|
142
91
|
}
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
import { cliToolOutputSchema, type CliToolOutput } from "@procedures/shell/cli";
|
|
8
9
|
|
|
9
10
|
// =============================================================================
|
|
10
11
|
// cli.run Types
|
|
@@ -31,24 +32,8 @@ export const CliRunInputSchema: z.ZodObject<{
|
|
|
31
32
|
|
|
32
33
|
export type CliRunInput = z.infer<typeof CliRunInputSchema>;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exitCode: number;
|
|
37
|
-
/** Standard output */
|
|
38
|
-
stdout: string;
|
|
39
|
-
/** Standard error */
|
|
40
|
-
stderr: string;
|
|
41
|
-
/** Whether command succeeded (exit code 0) */
|
|
42
|
-
success: boolean;
|
|
43
|
-
/** Duration in milliseconds */
|
|
44
|
-
duration: number;
|
|
45
|
-
}
|
|
35
|
+
/** The result of cli.run: the shared result of a CLI tool (`@procedures/shell/cli`). */
|
|
36
|
+
export interface CliRunOutput extends CliToolOutput {}
|
|
46
37
|
|
|
47
38
|
/** The output schema of cli.run (roadmap 2.1). Loose: a field that it does not name stays. */
|
|
48
|
-
export const CliRunOutputSchema: z.ZodType<CliRunOutput> =
|
|
49
|
-
exitCode: z.number().describe("The exit code of mark"),
|
|
50
|
-
stdout: z.string().describe("The standard output of mark"),
|
|
51
|
-
stderr: z.string().describe("The standard error of mark"),
|
|
52
|
-
success: z.boolean().describe("True when the exit code is 0"),
|
|
53
|
-
duration: z.number().describe("The time of the command, in milliseconds"),
|
|
54
|
-
});
|
|
39
|
+
export const CliRunOutputSchema: z.ZodType<CliRunOutput> = cliToolOutputSchema("mark");
|