@procedures/procedure 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +405 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +11 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/module.d.ts +23 -0
  10. package/dist/module.d.ts.map +1 -0
  11. package/dist/module.js +51 -0
  12. package/dist/module.js.map +1 -0
  13. package/dist/procedures/procedure/index.d.ts +5 -0
  14. package/dist/procedures/procedure/index.d.ts.map +1 -0
  15. package/dist/procedures/procedure/index.js +5 -0
  16. package/dist/procedures/procedure/index.js.map +1 -0
  17. package/dist/procedures/procedure/new.d.ts +55 -0
  18. package/dist/procedures/procedure/new.d.ts.map +1 -0
  19. package/dist/procedures/procedure/new.js +448 -0
  20. package/dist/procedures/procedure/new.js.map +1 -0
  21. package/dist/procedures/procedure/registry.d.ts +10 -0
  22. package/dist/procedures/procedure/registry.d.ts.map +1 -0
  23. package/dist/procedures/procedure/registry.js +68 -0
  24. package/dist/procedures/procedure/registry.js.map +1 -0
  25. package/dist/register.d.ts +7 -0
  26. package/dist/register.d.ts.map +1 -0
  27. package/dist/register.js +9 -0
  28. package/dist/register.js.map +1 -0
  29. package/dist/types.d.ts +29 -0
  30. package/dist/types.d.ts.map +1 -0
  31. package/dist/types.js +34 -0
  32. package/dist/types.js.map +1 -0
  33. package/package.json +75 -3
  34. package/src/index.ts +13 -0
  35. package/src/module.ts +61 -0
  36. package/src/procedures/procedure/index.ts +5 -0
  37. package/src/procedures/procedure/new.ts +502 -0
  38. package/src/procedures/procedure/registry.ts +93 -0
  39. package/src/register.ts +11 -0
  40. package/src/types.ts +63 -0
@@ -0,0 +1,448 @@
1
+ /**
2
+ * procedure.new - Scaffold a new procedure
3
+ *
4
+ * Creates the procedure file, its types and its registration. A dot-notation name such as
5
+ * "user.create" makes the procedure at ["user", "create"]: the file is
6
+ * procedures/user/create.ts, and "api.v2.users.create" gives procedures/api/v2/users/create.ts.
7
+ *
8
+ * The scaffolded code compiles with the strict options of the workspace (deep dive CLI-13):
9
+ * - the handler names its unused input `_input` (noUnusedParameters);
10
+ * - types.ts is created, or gets `import { z } from "zod"`, when it needs it;
11
+ * - the registration goes into the defineModule([...]) array of src/module.ts. A package of the
12
+ * old kind, without module.ts, gets it in the registerProcedures([...]) array of src/register.ts.
13
+ * A name whose path, file, types or registration exists already is an error, and nothing is
14
+ * written. Before, "a.b.c" and "a.c" wrote the same file, and existing types were reused silently.
15
+ */
16
+ import { join } from "node:path";
17
+ import { PROCEDURE_REGISTRY } from "@procedures/client";
18
+ /**
19
+ * Check if path exists
20
+ */
21
+ async function pathExists(pathStr, ctx) {
22
+ try {
23
+ const result = await ctx.client.call(["fs", "exists"], { path: pathStr });
24
+ return result.exists;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ async function readText(pathStr, ctx) {
31
+ if (!(await pathExists(pathStr, ctx))) {
32
+ return undefined;
33
+ }
34
+ const result = await ctx.client.call(["fs", "read"], { path: pathStr });
35
+ return result.content;
36
+ }
37
+ async function writeText(pathStr, content, ctx) {
38
+ await ctx.client.call(["fs", "write"], { path: pathStr, content });
39
+ }
40
+ /**
41
+ * Convert camelCase to PascalCase
42
+ */
43
+ function toPascalCase(str) {
44
+ return str.charAt(0).toUpperCase() + str.slice(1);
45
+ }
46
+ /**
47
+ * Convert dot.notation to camelCase
48
+ */
49
+ function toCamelCase(segments) {
50
+ return segments
51
+ .map((s, i) => (i === 0 ? s : toPascalCase(s)))
52
+ .join("");
53
+ }
54
+ /**
55
+ * The layout of a procedure: procedures/<namespace>/<middle segments>/<last segment>.ts
56
+ */
57
+ export function procedureLayout(name, namespace) {
58
+ const segments = name.split(".");
59
+ return {
60
+ segments,
61
+ namespace: namespace ?? segments[0],
62
+ folders: segments.length > 2 ? segments.slice(1, -1) : [],
63
+ fileBase: segments[segments.length - 1],
64
+ camelName: toCamelCase(segments),
65
+ pascalName: segments.map(toPascalCase).join(""),
66
+ };
67
+ }
68
+ /**
69
+ * Generate procedure file content
70
+ */
71
+ function generateProcedureFile(layout, description) {
72
+ const { segments, camelName, pascalName, folders } = layout;
73
+ // procedures/<namespace>/<folders...>/<file>.ts -> src/types.ts
74
+ const typesPath = `${"../".repeat(2 + folders.length)}types.js`;
75
+ return `/**
76
+ * ${segments.join(".")} procedure
77
+ *
78
+ * ${description}
79
+ */
80
+
81
+ import type { ${pascalName}Input, ${pascalName}Output } from "${typesPath}";
82
+
83
+ /**
84
+ * ${description}
85
+ */
86
+ export async function ${camelName}(_input: ${pascalName}Input): Promise<${pascalName}Output> {
87
+ // TODO: Implement ${segments.join(".")} (rename _input to input when the code uses it)
88
+ return {
89
+ success: true,
90
+ message: "Hello from ${segments.join(".")}",
91
+ };
92
+ }
93
+ `;
94
+ }
95
+ /**
96
+ * Generate type definitions
97
+ */
98
+ function generateTypes(layout, description) {
99
+ const { segments, pascalName } = layout;
100
+ const schemaName = `${pascalName}InputSchema`;
101
+ const outputSchemaName = `${pascalName}OutputSchema`;
102
+ // The output has a real schema too: the registry validates each result with it. (Before, the
103
+ // output was an interface with a pass-through outputSchema(), so no result was checked.)
104
+ return `
105
+ // =============================================================================
106
+ // ${segments.join(".")} Types - ${description}
107
+ // =============================================================================
108
+
109
+ export const ${schemaName}: z.ZodObject<{
110
+ // TODO: Add input fields
111
+ }> = z.object({
112
+ // TODO: Add input fields
113
+ });
114
+
115
+ export type ${pascalName}Input = z.infer<typeof ${schemaName}>;
116
+
117
+ export const ${outputSchemaName}: z.ZodObject<{
118
+ success: z.ZodBoolean;
119
+ message: z.ZodString;
120
+ }> = z.object({
121
+ /** Whether the operation succeeded */
122
+ success: z.boolean().describe("Whether the operation succeeded"),
123
+ /** Response message */
124
+ message: z.string().describe("Response message"),
125
+ });
126
+
127
+ export type ${pascalName}Output = z.infer<typeof ${outputSchemaName}>;
128
+ `;
129
+ }
130
+ const TYPES_HEADER = `/**
131
+ * Type definitions of the procedures of this package
132
+ */
133
+
134
+ `;
135
+ const Z_IMPORT = `import { z } from "zod";\n`;
136
+ /** True when the source imports z from "zod" */
137
+ function importsZ(source) {
138
+ return (/import\s*\{[^}]*\bz\b[^}]*\}\s*from\s*["']zod["']/.test(source) ||
139
+ /import\s+\*\s+as\s+z\s+from\s*["']zod["']/.test(source) ||
140
+ /import\s+z\s+from\s*["']zod["']/.test(source));
141
+ }
142
+ /**
143
+ * Add import lines after the last import of a source (or after its leading comment)
144
+ */
145
+ export function addImports(source, lines) {
146
+ if (lines.length === 0) {
147
+ return source;
148
+ }
149
+ const block = lines.join("");
150
+ const importPattern = /^import[\s\S]*?from\s*["'][^"']+["'];?[ \t]*\r?\n|^import\s*["'][^"']+["'];?[ \t]*\r?\n/gm;
151
+ let end = -1;
152
+ for (const match of source.matchAll(importPattern)) {
153
+ end = match.index + match[0].length;
154
+ }
155
+ if (end === -1) {
156
+ const comment = /^\s*\/\*[\s\S]*?\*\/[ \t]*\r?\n(\r?\n)?/.exec(source);
157
+ end = comment ? comment[0].length : 0;
158
+ }
159
+ return source.slice(0, end) + block + source.slice(end);
160
+ }
161
+ /**
162
+ * Add names to the value import from a module, or add the import
163
+ */
164
+ export function ensureNamedImports(source, moduleName, names) {
165
+ const escaped = moduleName.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
166
+ const pattern = new RegExp(`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${escaped}["'];?`);
167
+ const match = pattern.exec(source);
168
+ if (match && !/^import\s+type\b/.test(match[0])) {
169
+ const present = match[1]
170
+ .split(",")
171
+ .map((part) => part.trim())
172
+ .filter((part) => part.length > 0);
173
+ const presentNames = new Set(present.map((part) => part.replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim()));
174
+ const missing = names.filter((name) => !presentNames.has(name));
175
+ if (missing.length === 0) {
176
+ return source;
177
+ }
178
+ const replacement = `import { ${[...present, ...missing].join(", ")} } from "${moduleName}";`;
179
+ return source.slice(0, match.index) + replacement + source.slice(match.index + match[0].length);
180
+ }
181
+ return addImports(source, [`import { ${names.join(", ")} } from "${moduleName}";\n`]);
182
+ }
183
+ /** The index of the bracket that closes the bracket at `open` (strings are skipped) */
184
+ function closingBracket(source, open) {
185
+ let depth = 0;
186
+ let quote;
187
+ for (let i = open; i < source.length; i++) {
188
+ const ch = source[i];
189
+ if (quote) {
190
+ if (ch === "\\")
191
+ i++;
192
+ else if (ch === quote)
193
+ quote = undefined;
194
+ continue;
195
+ }
196
+ if (ch === '"' || ch === "'" || ch === "`")
197
+ quote = ch;
198
+ else if (ch === "[")
199
+ depth++;
200
+ else if (ch === "]" && --depth === 0)
201
+ return i;
202
+ }
203
+ return -1;
204
+ }
205
+ /**
206
+ * Add an item to the array of the first defineModule("name", [...]), registerProcedures([...]) or
207
+ * registerAll([...]) call. Returns undefined when the source has no such call.
208
+ */
209
+ export function addToRegistration(source, item) {
210
+ // The first call in code, not in a comment
211
+ const call = [...source.matchAll(/\b(defineModule|registerProcedures|registerAll)\s*\(/g)].find((match) => {
212
+ const lineStart = source.lastIndexOf("\n", match.index) + 1;
213
+ const before = source.slice(lineStart, match.index).trim();
214
+ return !before.startsWith("*") && !before.startsWith("/*") && !before.includes("//");
215
+ });
216
+ if (!call) {
217
+ return undefined;
218
+ }
219
+ const open = source.indexOf("[", call.index);
220
+ const close = open === -1 ? -1 : closingBracket(source, open);
221
+ if (close === -1) {
222
+ return undefined;
223
+ }
224
+ const content = source.slice(open + 1, close);
225
+ let updated;
226
+ if (content.trim() === "") {
227
+ updated = item;
228
+ }
229
+ else if (content.includes("\n")) {
230
+ // One item per line: add a line with the indentation of the last item
231
+ const trimmed = content.replace(/\s*$/, "");
232
+ const lastLine = trimmed.slice(trimmed.lastIndexOf("\n") + 1);
233
+ const indent = /^\s*/.exec(lastLine)?.[0] ?? " ";
234
+ const comma = trimmed.endsWith(",") ? "" : ",";
235
+ updated = `${trimmed}${comma}\n${indent}${item},${content.slice(trimmed.length)}`;
236
+ }
237
+ else {
238
+ updated = `${content.replace(/,?\s*$/, "")}, ${item}`;
239
+ }
240
+ return source.slice(0, open + 1) + updated + source.slice(close);
241
+ }
242
+ /**
243
+ * The procedure definition that goes into module.ts (or register.ts)
244
+ */
245
+ function generateRegistration(layout, description) {
246
+ const { segments, camelName, pascalName } = layout;
247
+ return `const ${camelName}Procedure = createProcedure()
248
+ .path(${JSON.stringify(segments)})
249
+ .input(zodAdapter<${pascalName}Input>(${pascalName}InputSchema))
250
+ .output(zodAdapter<${pascalName}Output>(${pascalName}OutputSchema))
251
+ .meta({
252
+ description: ${JSON.stringify(description)},
253
+ args: [],
254
+ shorts: {},
255
+ output: "text",
256
+ })
257
+ .handler(async (input: ${pascalName}Input): Promise<${pascalName}Output> => ${camelName}(input))
258
+ .build();
259
+
260
+ `;
261
+ }
262
+ const REGISTER_TEMPLATE = `/**
263
+ * Procedure registration of this package
264
+ *
265
+ * Scaffold a procedure with: mark procedure new <name> --path <this package>
266
+ */
267
+
268
+ import { registerProcedures } from "@procedures/client";
269
+
270
+ export function register(): void {
271
+ registerProcedures([]);
272
+ }
273
+
274
+ // Auto-register
275
+ register();
276
+ `;
277
+ /**
278
+ * Put the procedure into module.ts (or register.ts): its imports, its definition, and its place
279
+ * in the array of the module. Returns undefined when the file has no such array.
280
+ */
281
+ export function registerSource(source, layout, description, importPath) {
282
+ const { camelName, pascalName } = layout;
283
+ const withArray = addToRegistration(source, `${camelName}Procedure`);
284
+ if (withArray === undefined) {
285
+ return undefined;
286
+ }
287
+ let updated = ensureNamedImports(withArray, "@procedures/client", ["createProcedure", "zodAdapter"]);
288
+ updated = addImports(updated, [
289
+ `import { ${camelName} } from "${importPath}";\n`,
290
+ `import { ${pascalName}InputSchema, ${pascalName}OutputSchema, type ${pascalName}Input, type ${pascalName}Output } from "./types.js";\n`,
291
+ ]);
292
+ // The definition goes before the module, or before the code that registers the procedures
293
+ const anchor = /^export\s+const\s+\w+\s*(:\s*\w+\s*)?=\s*defineModule\s*\(|^(export\s+)?(async\s+)?function\s+register\w*\s*\(|^\s*(registerProcedures|PROCEDURE_REGISTRY\.registerAll)\s*\(/m.exec(updated);
294
+ const at = anchor ? anchor.index : updated.length;
295
+ return updated.slice(0, at) + generateRegistration(layout, description) + updated.slice(at);
296
+ }
297
+ /**
298
+ * Generate index.ts export
299
+ */
300
+ function generateIndexExport(relativeFile, functionName) {
301
+ return `export { ${functionName} } from "./${relativeFile}.js";\n`;
302
+ }
303
+ /**
304
+ * Scaffold a new procedure
305
+ */
306
+ export async function procedureNew(input, ctx) {
307
+ const operations = [];
308
+ const created = [];
309
+ const modified = [];
310
+ const errors = [];
311
+ const layout = procedureLayout(input.name, input.namespace);
312
+ const { segments, namespace, folders, fileBase, camelName, pascalName } = layout;
313
+ // Resolve paths
314
+ const projectPath = input.path ?? process.cwd();
315
+ const srcPath = join(projectPath, "src");
316
+ const namespacePath = join(srcPath, "procedures", namespace);
317
+ const procedureDir = join(namespacePath, ...folders);
318
+ const procedureFile = join(procedureDir, `${fileBase}.ts`);
319
+ const namespaceIndex = join(namespacePath, "index.ts");
320
+ const typesFile = join(srcPath, "types.ts");
321
+ const moduleFile = join(srcPath, "module.ts");
322
+ const relativeFile = [...folders, fileBase].join("/");
323
+ const importPath = `./procedures/${namespace}/${relativeFile}.js`;
324
+ const description = input.description ?? `${segments.join(".")} procedure`;
325
+ const fail = (message) => ({
326
+ success: false,
327
+ procedurePath: segments,
328
+ created,
329
+ modified,
330
+ operations,
331
+ errors: [...errors, message],
332
+ });
333
+ // Check every collision before anything is written
334
+ // The registry of the invocation (a host with its own registry), else the global one
335
+ if ((ctx.registry ?? PROCEDURE_REGISTRY).has(segments)) {
336
+ return fail(`A procedure is registered at ${segments.join(".")} already. Choose another name.`);
337
+ }
338
+ if (await pathExists(procedureFile, ctx)) {
339
+ return fail(`Procedure file already exists: ${procedureFile}`);
340
+ }
341
+ const existingTypes = await readText(typesFile, ctx);
342
+ if (existingTypes !== undefined && new RegExp(`\\b${pascalName}(Input|Output|InputSchema|OutputSchema)\\b`).test(existingTypes)) {
343
+ return fail(`types.ts already has types named ${pascalName}: the name ${segments.join(".")} collides with another procedure. Choose another name.`);
344
+ }
345
+ // The procedures go into module.ts. A package of the old kind, without it, has them in register.ts.
346
+ const existingModule = await readText(moduleFile, ctx);
347
+ const registerFile = existingModule !== undefined ? moduleFile : join(srcPath, "register.ts");
348
+ const registerName = existingModule !== undefined ? "module.ts" : "register.ts";
349
+ const existingRegister = existingModule ?? (await readText(registerFile, ctx));
350
+ if (existingRegister !== undefined) {
351
+ if (existingRegister.includes(JSON.stringify(segments)) || new RegExp(`\\b${camelName}Procedure\\b`).test(existingRegister)) {
352
+ return fail(`${registerName} already registers ${segments.join(".")} (or ${camelName}Procedure). Choose another name.`);
353
+ }
354
+ }
355
+ const registerBase = existingRegister ?? REGISTER_TEMPLATE;
356
+ const newRegister = registerSource(registerBase, layout, description, importPath);
357
+ if (input.dryRun) {
358
+ const [indexExists] = await Promise.all([pathExists(namespaceIndex, ctx)]);
359
+ return {
360
+ success: true,
361
+ procedurePath: segments,
362
+ created: [
363
+ procedureFile,
364
+ ...(indexExists ? [] : [namespaceIndex]),
365
+ ...(existingTypes === undefined ? [typesFile] : []),
366
+ ...(existingRegister === undefined ? [registerFile] : []),
367
+ ],
368
+ modified: [
369
+ ...(indexExists ? [namespaceIndex] : []),
370
+ ...(existingTypes !== undefined ? [typesFile] : []),
371
+ ...(existingRegister !== undefined && newRegister !== undefined ? [registerFile] : []),
372
+ ],
373
+ operations: [
374
+ `Would create procedure file: ${procedureFile}`,
375
+ `Would create/update index: ${namespaceIndex}`,
376
+ existingTypes === undefined ? `Would create ${typesFile}` : `Would append types to: ${typesFile}`,
377
+ newRegister === undefined
378
+ ? `Would not change ${registerFile}: it has no defineModule or registerProcedures array`
379
+ : `Would register the procedure in: ${registerFile}`,
380
+ ],
381
+ errors: [],
382
+ };
383
+ }
384
+ try {
385
+ // Step 1: Create the folder and the procedure file
386
+ if (!(await pathExists(procedureDir, ctx))) {
387
+ operations.push(`Creating directory: ${procedureDir}`);
388
+ await ctx.client.call(["fs", "mkdir"], { path: procedureDir, recursive: true });
389
+ created.push(procedureDir);
390
+ }
391
+ operations.push(`Creating procedure file: ${procedureFile}`);
392
+ await writeText(procedureFile, generateProcedureFile(layout, description), ctx);
393
+ created.push(procedureFile);
394
+ // Step 2: Create/update namespace index.ts
395
+ const indexExport = generateIndexExport(relativeFile, camelName);
396
+ const existingIndex = await readText(namespaceIndex, ctx);
397
+ if (existingIndex !== undefined) {
398
+ if (!existingIndex.includes(`from "./${relativeFile}.js"`)) {
399
+ operations.push(`Updating index: ${namespaceIndex}`);
400
+ await writeText(namespaceIndex, existingIndex + indexExport, ctx);
401
+ modified.push(namespaceIndex);
402
+ }
403
+ }
404
+ else {
405
+ operations.push(`Creating index: ${namespaceIndex}`);
406
+ await writeText(namespaceIndex, indexExport, ctx);
407
+ created.push(namespaceIndex);
408
+ }
409
+ // Step 3: Add the types (create types.ts, or add the z import that the types need)
410
+ const newTypes = generateTypes(layout, description);
411
+ if (existingTypes === undefined) {
412
+ operations.push(`Creating types: ${typesFile}`);
413
+ await writeText(typesFile, TYPES_HEADER + Z_IMPORT + newTypes, ctx);
414
+ created.push(typesFile);
415
+ }
416
+ else {
417
+ operations.push(`Appending types to: ${typesFile}`);
418
+ const withImport = importsZ(existingTypes) ? existingTypes : addImports(existingTypes, [Z_IMPORT]);
419
+ await writeText(typesFile, withImport + newTypes, ctx);
420
+ modified.push(typesFile);
421
+ }
422
+ // Step 4: Register the procedure
423
+ if (newRegister === undefined) {
424
+ operations.push(`${registerName} has no defineModule or registerProcedures array: add ${camelName}Procedure to the module in ${registerFile}`);
425
+ }
426
+ else {
427
+ operations.push(`${existingRegister === undefined ? "Creating" : "Updating"} registration: ${registerFile}`);
428
+ await writeText(registerFile, newRegister, ctx);
429
+ (existingRegister === undefined ? created : modified).push(registerFile);
430
+ if (existingRegister === undefined) {
431
+ operations.push(`Export the procedures from src/index.ts, and give the package a "./register" entry (see lib new)`);
432
+ }
433
+ }
434
+ operations.push(`Next: implement ${segments.join(".")} in ${procedureFile}, then run pnpm build`);
435
+ return {
436
+ success: errors.length === 0,
437
+ procedurePath: segments,
438
+ created,
439
+ modified,
440
+ operations,
441
+ errors,
442
+ };
443
+ }
444
+ catch (error) {
445
+ return fail(error instanceof Error ? error.message : String(error));
446
+ }
447
+ }
448
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/procedures/procedure/new.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;AAQ/E;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,GAAqB;IAC9D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAClC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAChB,EAAE,IAAI,EAAE,OAAO,EAAE,CAClB,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe,EAAE,GAAqB;IAC5D,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAiC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAA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AAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACzE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,UAAU,CAAC,IAAI,CAAC,kGAAkG,CAAC,CAAC;YACtH,CAAC;QACH,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,mBAAmB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,aAAa,uBAAuB,CAAC,CAAC;QAElG,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC5B,aAAa,EAAE,QAAQ;YACvB,OAAO;YACP,QAAQ;YACR,UAAU;YACV,MAAM;SACP,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * procedure.* Registry Procedures
3
+ *
4
+ * Procedures for managing the procedure registry dynamically.
5
+ * Enables procedure-as-data patterns, remote registration, and persistence.
6
+ */
7
+ import type { AnyProcedure } from "@procedures/client";
8
+ export declare const procedureExportProcedure: AnyProcedure;
9
+ export declare const procedureRegistryProcedures: AnyProcedure[];
10
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/procedures/procedure/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,oBAAoB,CAAC;AA4CtE,eAAO,MAAM,wBAAwB,EAAE,YAkCrC,CAAC;AAMH,eAAO,MAAM,2BAA2B,EAAE,YAAY,EAA+B,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * procedure.* Registry Procedures
3
+ *
4
+ * Procedures for managing the procedure registry dynamically.
5
+ * Enables procedure-as-data patterns, remote registration, and persistence.
6
+ */
7
+ import { defineProcedure, PROCEDURE_REGISTRY, REGISTRY_READ_EFFECTS, pathToKey, keyToPath } from "@procedures/client";
8
+ import { z } from "zod";
9
+ // procedure.list and procedure.get are core procedures (`@procedures/client`, in
10
+ // define-procedure.ts). This package gave its own versions for the whole registry and replaced
11
+ // the core ones, so the results depended on the imports of the host (docs review DOC-6). The core
12
+ // versions now list and describe the whole registry of the caller, with a `runtime` flag.
13
+ // =============================================================================
14
+ // procedure.export - Export procedure as JSON
15
+ // =============================================================================
16
+ const ProcedureExportInputSchema = z.object({
17
+ /** Procedure path (array or dot-separated) */
18
+ path: z.union([z.array(z.string()), z.string()]).describe("Procedure path (array or dot-separated)"),
19
+ });
20
+ /** The output of `procedure.export` (roadmap 2.1: before, a pass-through schema) */
21
+ const ProcedureExportOutputSchema = z.looseObject({
22
+ success: z.boolean().describe("True when the registry has the procedure"),
23
+ definition: z
24
+ .looseObject({
25
+ $proc: z.array(z.string()).describe("The path of the procedure"),
26
+ metadata: z.record(z.string(), z.unknown()).optional().describe("The metadata of the procedure"),
27
+ })
28
+ .optional()
29
+ .describe("The procedure as a procedure reference, when it exists"),
30
+ error: z.string().optional().describe("The error message when the registry has no such procedure"),
31
+ });
32
+ export const procedureExportProcedure = defineProcedure({
33
+ path: ["procedure", "export"],
34
+ input: ProcedureExportInputSchema,
35
+ output: ProcedureExportOutputSchema,
36
+ metadata: {
37
+ description: "Export a procedure definition as JSON",
38
+ tags: ["procedure", "registry"],
39
+ effects: REGISTRY_READ_EFFECTS,
40
+ args: ["path"],
41
+ shorts: {},
42
+ output: "json",
43
+ },
44
+ handler: async (input) => {
45
+ const path = typeof input.path === "string"
46
+ ? keyToPath(input.path)
47
+ : input.path;
48
+ const proc = PROCEDURE_REGISTRY.get(path);
49
+ if (!proc) {
50
+ return {
51
+ success: false,
52
+ error: `Procedure not found: ${pathToKey(path)}`,
53
+ };
54
+ }
55
+ return {
56
+ success: true,
57
+ definition: {
58
+ $proc: proc.path,
59
+ metadata: proc.metadata,
60
+ },
61
+ };
62
+ },
63
+ });
64
+ // =============================================================================
65
+ // Export all procedure.* procedures
66
+ // =============================================================================
67
+ export const procedureRegistryProcedures = [procedureExportProcedure];
68
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/procedures/procedure/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iFAAiF;AACjF,+FAA+F;AAC/F,kGAAkG;AAClG,0FAA0F;AAE1F,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,8CAA8C;IAC9C,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CACrG,CAAC,CAAC;AAgBH,oFAAoF;AACpF,MAAM,2BAA2B,GAAG,CAAC,CAAC,WAAW,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACzE,UAAU,EAAE,CAAC;SACV,WAAW,CAAC;QACX,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAChE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAA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AAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF,MAAM,CAAC,MAAM,2BAA2B,GAAmB,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/procedure, and of the modules that it
3
+ * requires, in the global registry: `import "@procedures/procedure/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/procedure, and of the modules that it
3
+ * requires, in the global registry: `import "@procedures/procedure/register"`. The package root and the
4
+ * `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
5
+ */
6
+ import { registerProcedureProcedures } from "./module.js";
7
+ export * from "./module.js";
8
+ registerProcedureProcedures();
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,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,aAAa,CAAC;AAE5B,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Type definitions for client-procedure
3
+ */
4
+ import { z } from "zod";
5
+ export declare const ProcedureNewInputSchema: z.ZodObject<{
6
+ name: z.ZodString;
7
+ namespace: z.ZodOptional<z.ZodString>;
8
+ description: z.ZodOptional<z.ZodString>;
9
+ path: z.ZodOptional<z.ZodString>;
10
+ dryRun: z.ZodDefault<z.ZodBoolean>;
11
+ }>;
12
+ export type ProcedureNewInput = z.infer<typeof ProcedureNewInputSchema>;
13
+ export interface ProcedureNewOutput {
14
+ /** Whether creation succeeded */
15
+ success: boolean;
16
+ /** Full procedure path (e.g., ["user", "create"]) */
17
+ procedurePath: string[];
18
+ /** Files created */
19
+ created: string[];
20
+ /** Files modified */
21
+ modified: string[];
22
+ /** Operations performed */
23
+ operations: string[];
24
+ /** Any errors encountered */
25
+ errors: string[];
26
+ }
27
+ /** The output schema of procedure.new (roadmap 2.1). Loose: a field that it does not name stays. */
28
+ export declare const ProcedureNewOutputSchema: z.ZodType<ProcedureNewOutput>;
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,SAAS,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC;IAClB,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACtC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;CACpC,CAmBC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,oBAAoB;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,oGAAoG;AACpG,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAOjE,CAAC"}