@procedures/cli-run 0.0.0-stage → 0.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.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * Procedure Registration for CLI operations
5
+ *
6
+ * Provides cli.run procedure for calling mark CLI commands via client-shell.
7
+ */
8
+ import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
9
+ /**
10
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
11
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
12
+ */
13
+ export declare const cliModule: ProcedureModule;
14
+ export default cliModule;
15
+ /**
16
+ * This function registers the procedures of @procedures/cli-run, and of the modules that it requires, in
17
+ * a registry. The default is the global registry. Importing this file registers nothing: the
18
+ * `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
19
+ */
20
+ export declare function registerCliProcedures(registry?: ProcedureRegistry): void;
21
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAA6C,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAgClK;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,eAEL,CAAC;eAEL,SAAS;AAExB;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE5F"}
package/dist/module.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * Procedure Registration for CLI operations
5
+ *
6
+ * Provides cli.run procedure for calling mark CLI commands via client-shell.
7
+ */
8
+ import { createProcedure, zodAdapter, defineModule, PROCEDURE_REGISTRY, registerModules } from "@procedures/client";
9
+ import shellModule from "@procedures/shell/module";
10
+ import { cliRun } from "./procedures/cli/index.js";
11
+ import { CliRunInputSchema, CliRunOutputSchema } from "./types.js";
12
+ // =============================================================================
13
+ // cli.run Procedure
14
+ // =============================================================================
15
+ const cliRunProcedure = createProcedure()
16
+ .path(["cli", "run"])
17
+ .input(zodAdapter(CliRunInputSchema))
18
+ .output(zodAdapter(CliRunOutputSchema))
19
+ .meta({
20
+ description: "Run a mark CLI command",
21
+ args: ["path"],
22
+ shorts: { cwd: "C", timeout: "t" },
23
+ output: "json",
24
+ // The caller chooses the mark command, and a mark command can start any procedure.
25
+ // It also finds the mark CLI in the files of the workspace.
26
+ effects: { reads: ["fs", "process"], writes: ["process"] },
27
+ })
28
+ .handler(async (input, ctx) => {
29
+ return cliRun(input, ctx);
30
+ })
31
+ .build();
32
+ // =============================================================================
33
+ // Registration
34
+ // =============================================================================
35
+ /**
36
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
37
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
38
+ */
39
+ export const cliModule = defineModule("@procedures/cli-run", [
40
+ cliRunProcedure,
41
+ ], [shellModule]);
42
+ export default cliModule;
43
+ /**
44
+ * This function registers the procedures of @procedures/cli-run, and of the modules that it requires, in
45
+ * a registry. The default is the global registry. Importing this file registers nothing: the
46
+ * `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
47
+ */
48
+ export function registerCliProcedures(registry = PROCEDURE_REGISTRY) {
49
+ registerModules(registry, [cliModule]);
50
+ }
51
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAwB,kBAAkB,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AAClK,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,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
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI Procedures
3
+ */
4
+ export { cliRun } from "./run.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * cli.run procedure
3
+ *
4
+ * Wraps the mark CLI as a procedure using client-shell.
5
+ * This allows calling any mark CLI command programmatically. The mark CLI itself uses a running
6
+ * CLI server when that server is safe to use (same folder, same build, its token).
7
+ */
8
+ import type { ProcedureContext } from "@procedures/client";
9
+ import type { CliRunInput, CliRunOutput } from "../../types.js";
10
+ /**
11
+ * The argv of `mark` for an input: the command path, then each named argument as
12
+ * `--key=<text>`, then `--` and the positional arguments.
13
+ *
14
+ * A string value goes as it is. Another value goes as JSON, which `mark` converts by the type of
15
+ * the field: `--flag=false` for a boolean, `--files=["a","b"]` for an array, `--env={"A":"1"}`
16
+ * for a record. Before, the procedure sent `--key value`, so a value that starts with "-" became
17
+ * a flag, and it dropped a `false` boolean, so a default of `true` could not be turned off.
18
+ * The `--` keeps a positional argument that starts with "-" from becoming a flag.
19
+ */
20
+ export declare function buildMarkArgs(input: Pick<CliRunInput, "path" | "positional" | "args">): string[];
21
+ /**
22
+ * Run a mark CLI command
23
+ *
24
+ *
25
+ * @example
26
+ * // Equivalent to: mark lib new my-package
27
+ * await client.call(["cli", "run"], {
28
+ * path: ["lib", "new"],
29
+ * positional: ["my-package"],
30
+ * });
31
+ *
32
+ * @example
33
+ * // Equivalent to: mark procedure new fs.read --description "Read a file"
34
+ * await client.call(["cli", "run"], {
35
+ * path: ["procedure", "new"],
36
+ * positional: ["fs.read"],
37
+ * args: { description: "Read a file" },
38
+ * });
39
+ */
40
+ export declare function cliRun(input: CliRunInput, ctx: ProcedureContext): Promise<CliRunOutput>;
41
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +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;AAC3D,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;AA8CD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,YAAY,CAAC,CAiBvB"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * cli.run procedure
3
+ *
4
+ * Wraps the mark CLI as a procedure using client-shell.
5
+ * This allows calling any mark CLI command programmatically. The mark CLI itself uses a running
6
+ * CLI server when that server is safe to use (same folder, same build, its token).
7
+ */
8
+ import { existsSync } from "node:fs";
9
+ import { dirname, join } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ /**
12
+ * Find the mark CLI of the workspace that contains this package (packages/mark/dist/cli.js)
13
+ */
14
+ function resolveMarkCli() {
15
+ let dir = dirname(fileURLToPath(import.meta.url));
16
+ for (;;) {
17
+ if (existsSync(join(dir, "pnpm-workspace.yaml"))) {
18
+ const cli = join(dir, "packages", "mark", "dist", "cli.js");
19
+ if (existsSync(cli)) {
20
+ return cli;
21
+ }
22
+ break;
23
+ }
24
+ const parent = dirname(dir);
25
+ if (parent === dir) {
26
+ break;
27
+ }
28
+ dir = parent;
29
+ }
30
+ throw new Error("Could not find the mark CLI (packages/mark/dist/cli.js in the workspace). Run pnpm build.");
31
+ }
32
+ /**
33
+ * The argv of `mark` for an input: the command path, then each named argument as
34
+ * `--key=<text>`, then `--` and the positional arguments.
35
+ *
36
+ * A string value goes as it is. Another value goes as JSON, which `mark` converts by the type of
37
+ * the field: `--flag=false` for a boolean, `--files=["a","b"]` for an array, `--env={"A":"1"}`
38
+ * for a record. Before, the procedure sent `--key value`, so a value that starts with "-" became
39
+ * a flag, and it dropped a `false` boolean, so a default of `true` could not be turned off.
40
+ * The `--` keeps a positional argument that starts with "-" from becoming a flag.
41
+ */
42
+ export function buildMarkArgs(input) {
43
+ const args = [...input.path];
44
+ for (const [key, value] of Object.entries(input.args ?? {})) {
45
+ if (value === undefined || value === null)
46
+ continue;
47
+ args.push(`--${key}=${typeof value === "string" ? value : JSON.stringify(value)}`);
48
+ }
49
+ if (input.positional && input.positional.length > 0) {
50
+ args.push("--", ...input.positional.map(String));
51
+ }
52
+ return args;
53
+ }
54
+ /**
55
+ * Execute via shell (spawn node process)
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
+ }
78
+ /**
79
+ * Run a mark CLI command
80
+ *
81
+ *
82
+ * @example
83
+ * // Equivalent to: mark lib new my-package
84
+ * await client.call(["cli", "run"], {
85
+ * path: ["lib", "new"],
86
+ * positional: ["my-package"],
87
+ * });
88
+ *
89
+ * @example
90
+ * // Equivalent to: mark procedure new fs.read --description "Read a file"
91
+ * await client.call(["cli", "run"], {
92
+ * path: ["procedure", "new"],
93
+ * positional: ["fs.read"],
94
+ * args: { description: "Read a file" },
95
+ * });
96
+ */
97
+ export async function cliRun(input, ctx) {
98
+ const startTime = Date.now();
99
+ try {
100
+ // Always through the mark CLI. Before, a second path sent the input straight to a running
101
+ // CLI server, without mark's argument mapping, so the two paths gave different results
102
+ // (a "dry run" wrote files), and it had its own copy of the lockfile logic (deep dive CLI-12).
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
+ }
114
+ }
115
+ //# sourceMappingURL=run.js.map
@@ -0,0 +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;AAIzC;;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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IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/cli-run, and of the modules that it
3
+ * requires, in the global registry: `import "@procedures/cli-run/register"`. The package root and the
4
+ * `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
5
+ */
6
+ export * from "./module.js";
7
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/cli-run, and of the modules that it
3
+ * requires, in the global registry: `import "@procedures/cli-run/register"`. The package root and the
4
+ * `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
5
+ */
6
+ import { registerCliProcedures } from "./module.js";
7
+ export * from "./module.js";
8
+ registerCliProcedures();
9
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,cAAc,aAAa,CAAC;AAE5B,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Type definitions for client-cli procedures
3
+ *
4
+ * client-cli wraps the mark CLI as procedures using client-shell.
5
+ */
6
+ import { z } from "zod";
7
+ export declare const CliRunInputSchema: z.ZodObject<{
8
+ path: z.ZodArray<z.ZodString>;
9
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
10
+ positional: z.ZodOptional<z.ZodArray<z.ZodString>>;
11
+ cwd: z.ZodOptional<z.ZodString>;
12
+ timeout: z.ZodOptional<z.ZodNumber>;
13
+ }>;
14
+ export type CliRunInput = z.infer<typeof CliRunInputSchema>;
15
+ export interface CliRunOutput {
16
+ /** Exit code of the command */
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;
26
+ }
27
+ /** The output schema of cli.run (roadmap 2.1). Loose: a field that it does not name stays. */
28
+ export declare const CliRunOutputSchema: z.ZodType<CliRunOutput>;
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;AAMxB,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,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAMrD,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Type definitions for client-cli procedures
3
+ *
4
+ * client-cli wraps the mark CLI as procedures using client-shell.
5
+ */
6
+ import { z } from "zod";
7
+ // =============================================================================
8
+ // cli.run Types
9
+ // =============================================================================
10
+ export const CliRunInputSchema = z.object({
11
+ /** Procedure path to call, e.g. ["lib", "new"] for "mark lib new" */
12
+ path: z.array(z.string()).describe("Procedure path to call, e.g. [\"lib\", \"new\"] for \"mark lib new\""),
13
+ /** Named arguments as key-value pairs, e.g. { name: "foo" } -> "--name foo" */
14
+ args: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional().describe("Named arguments as key-value pairs, e.g. { name: \"foo\" } -> \"--name foo\""),
15
+ /** Positional arguments after the path */
16
+ positional: z.array(z.string()).optional().describe("Positional arguments after the path"),
17
+ /** Working directory */
18
+ cwd: z.string().optional().describe("Working directory"),
19
+ /** Timeout in milliseconds */
20
+ timeout: z.number().optional().describe("Timeout in milliseconds"),
21
+ });
22
+ /** The output schema of cli.run (roadmap 2.1). Loose: a field that it does not name stays. */
23
+ export const CliRunOutputSchema = z.looseObject({
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
+ });
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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1D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACzD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAC7D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;CAC1E,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@procedures/cli-run",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
4
+ "version": "0.2.0",
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
+ "keywords": [
7
+ "cli",
8
+ "mark",
9
+ "procedures",
10
+ "automation",
11
+ "argv"
12
+ ],
13
+ "homepage": "https://mark1russell7.github.io/client/",
14
+ "bugs": {
15
+ "url": "https://github.com/mark1russell7/client/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/mark1russell7/client.git",
20
+ "directory": "packages/client-cli"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Mark Russell (https://github.com/mark1russell7)",
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./module": {
33
+ "types": "./dist/module.d.ts",
34
+ "import": "./dist/module.js"
35
+ },
36
+ "./register": {
37
+ "types": "./dist/register.d.ts",
38
+ "import": "./dist/register.js"
39
+ },
40
+ "./register.js": {
41
+ "import": "./dist/register.js"
42
+ }
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "src",
47
+ "!src/**/*.test.ts",
48
+ "!src/**/*.test.tsx",
49
+ "!src/**/__tests__",
50
+ "CHANGELOG.md"
51
+ ],
52
+ "sideEffects": [
53
+ "./dist/register.js"
54
+ ],
55
+ "engines": {
56
+ "node": ">=22"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "provenance": true
61
+ },
62
+ "dependencies": {
63
+ "@procedures/client": "0.2.0",
64
+ "@procedures/shell": "0.2.0",
65
+ "zod": "^4.6.5"
66
+ },
67
+ "devDependencies": {
68
+ "typescript": "^7.0.2",
69
+ "@types/node": "^22.0.0",
70
+ "@mark1russell7/cue": "^1.0.0",
71
+ "vitest": "^5.0.3"
72
+ },
73
+ "client": {
74
+ "procedures": "./dist/register.js"
75
+ },
76
+ "scripts": {
77
+ "build": "tsc -b",
78
+ "typecheck": "tsc --noEmit",
79
+ "clean": "rm -rf dist .tsbuildinfo",
80
+ "test": "vitest run --passWithNoTests",
81
+ "test:watch": "vitest"
82
+ }
6
83
  }
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @procedures/cli-run
3
+ *
4
+ * Wraps the mark CLI as procedures using client-shell.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { Client } from "@procedures/client";
9
+ *
10
+ * // Equivalent to: mark lib new my-package
11
+ * const result = await client.call(["cli", "run"], {
12
+ * path: ["lib", "new"],
13
+ * positional: ["my-package"],
14
+ * });
15
+ *
16
+ * if (result.success) {
17
+ * console.log(result.stdout);
18
+ * }
19
+ * ```
20
+ */
21
+
22
+ // Types
23
+ export type { CliRunInput, CliRunOutput } from "./types.js";
24
+ export { CliRunInputSchema } from "./types.js";
25
+
26
+ // Procedures
27
+ export { cliRun } from "./procedures/cli/index.js";
28
+
29
+ // Registration
30
+ export { registerCliProcedures } from "./module.js";
package/src/module.ts ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * Procedure Registration for CLI operations
5
+ *
6
+ * Provides cli.run procedure for calling mark CLI commands via client-shell.
7
+ */
8
+
9
+
10
+ import { createProcedure, zodAdapter, defineModule, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
11
+ import shellModule from "@procedures/shell/module";
12
+ import { cliRun } from "./procedures/cli/index.js";
13
+ import { CliRunInputSchema, CliRunOutputSchema, type CliRunInput, type CliRunOutput } from "./types.js";
14
+ import type { ProcedureContext } from "@procedures/client";
15
+
16
+ // =============================================================================
17
+ // cli.run Procedure
18
+ // =============================================================================
19
+
20
+ const cliRunProcedure = createProcedure()
21
+ .path(["cli", "run"])
22
+ .input(zodAdapter<CliRunInput>(CliRunInputSchema))
23
+ .output(zodAdapter<CliRunOutput>(CliRunOutputSchema))
24
+ .meta({
25
+ description: "Run a mark CLI command",
26
+ args: ["path"],
27
+ shorts: { cwd: "C", timeout: "t" },
28
+ output: "json",
29
+ // The caller chooses the mark command, and a mark command can start any procedure.
30
+ // It also finds the mark CLI in the files of the workspace.
31
+ effects: { reads: ["fs", "process"], writes: ["process"] },
32
+ })
33
+ .handler(async (input: CliRunInput, ctx: ProcedureContext): Promise<CliRunOutput> => {
34
+ return cliRun(input, ctx);
35
+ })
36
+ .build();
37
+
38
+ // =============================================================================
39
+ // Registration
40
+ // =============================================================================
41
+
42
+ /**
43
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
44
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
45
+ */
46
+ export const cliModule: ProcedureModule = defineModule("@procedures/cli-run", [
47
+ cliRunProcedure,
48
+ ], [shellModule]);
49
+
50
+ export default cliModule;
51
+
52
+ /**
53
+ * This function registers the procedures of @procedures/cli-run, and of the modules that it requires, in
54
+ * a registry. The default is the global registry. Importing this file registers nothing: the
55
+ * `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
56
+ */
57
+ export function registerCliProcedures(registry: ProcedureRegistry = PROCEDURE_REGISTRY): void {
58
+ registerModules(registry, [cliModule]);
59
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI Procedures
3
+ */
4
+
5
+ export { cliRun } from "./run.js";