@procedures/procedure 0.0.0-stage → 0.1.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 +10 -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 +12 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/module.d.ts +17 -0
  10. package/dist/module.d.ts.map +1 -0
  11. package/dist/module.js +41 -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 +54 -0
  18. package/dist/procedures/procedure/new.d.ts.map +1 -0
  19. package/dist/procedures/procedure/new.js +442 -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 +67 -0
  24. package/dist/procedures/procedure/registry.js.map +1 -0
  25. package/dist/register.d.ts +8 -0
  26. package/dist/register.d.ts.map +1 -0
  27. package/dist/register.js +16 -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 +72 -3
  34. package/src/index.ts +14 -0
  35. package/src/module.ts +50 -0
  36. package/src/procedures/procedure/index.ts +5 -0
  37. package/src/procedures/procedure/new.ts +493 -0
  38. package/src/procedures/procedure/registry.ts +92 -0
  39. package/src/register.ts +19 -0
  40. package/src/types.ts +63 -0
@@ -0,0 +1,442 @@
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 src/register.ts.
12
+ * A name whose path, file, types or registration exists already is an error, and nothing is
13
+ * written. Before, "a.b.c" and "a.c" wrote the same file, and existing types were reused silently.
14
+ */
15
+ import { join } from "node:path";
16
+ import { PROCEDURE_REGISTRY } from "@procedures/client";
17
+ /**
18
+ * Check if path exists
19
+ */
20
+ async function pathExists(pathStr, ctx) {
21
+ try {
22
+ const result = await ctx.client.call(["fs", "exists"], { path: pathStr });
23
+ return result.exists;
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ async function readText(pathStr, ctx) {
30
+ if (!(await pathExists(pathStr, ctx))) {
31
+ return undefined;
32
+ }
33
+ const result = await ctx.client.call(["fs", "read"], { path: pathStr });
34
+ return result.content;
35
+ }
36
+ async function writeText(pathStr, content, ctx) {
37
+ await ctx.client.call(["fs", "write"], { path: pathStr, content });
38
+ }
39
+ /**
40
+ * Convert camelCase to PascalCase
41
+ */
42
+ function toPascalCase(str) {
43
+ return str.charAt(0).toUpperCase() + str.slice(1);
44
+ }
45
+ /**
46
+ * Convert dot.notation to camelCase
47
+ */
48
+ function toCamelCase(segments) {
49
+ return segments
50
+ .map((s, i) => (i === 0 ? s : toPascalCase(s)))
51
+ .join("");
52
+ }
53
+ /**
54
+ * The layout of a procedure: procedures/<namespace>/<middle segments>/<last segment>.ts
55
+ */
56
+ export function procedureLayout(name, namespace) {
57
+ const segments = name.split(".");
58
+ return {
59
+ segments,
60
+ namespace: namespace ?? segments[0],
61
+ folders: segments.length > 2 ? segments.slice(1, -1) : [],
62
+ fileBase: segments[segments.length - 1],
63
+ camelName: toCamelCase(segments),
64
+ pascalName: segments.map(toPascalCase).join(""),
65
+ };
66
+ }
67
+ /**
68
+ * Generate procedure file content
69
+ */
70
+ function generateProcedureFile(layout, description) {
71
+ const { segments, camelName, pascalName, folders } = layout;
72
+ // procedures/<namespace>/<folders...>/<file>.ts -> src/types.ts
73
+ const typesPath = `${"../".repeat(2 + folders.length)}types.js`;
74
+ return `/**
75
+ * ${segments.join(".")} procedure
76
+ *
77
+ * ${description}
78
+ */
79
+
80
+ import type { ${pascalName}Input, ${pascalName}Output } from "${typesPath}";
81
+
82
+ /**
83
+ * ${description}
84
+ */
85
+ export async function ${camelName}(_input: ${pascalName}Input): Promise<${pascalName}Output> {
86
+ // TODO: Implement ${segments.join(".")} (rename _input to input when the code uses it)
87
+ return {
88
+ success: true,
89
+ message: "Hello from ${segments.join(".")}",
90
+ };
91
+ }
92
+ `;
93
+ }
94
+ /**
95
+ * Generate type definitions
96
+ */
97
+ function generateTypes(layout, description) {
98
+ const { segments, pascalName } = layout;
99
+ const schemaName = `${pascalName}InputSchema`;
100
+ const outputSchemaName = `${pascalName}OutputSchema`;
101
+ // The output has a real schema too: the registry validates each result with it. (Before, the
102
+ // output was an interface with a pass-through outputSchema(), so no result was checked.)
103
+ return `
104
+ // =============================================================================
105
+ // ${segments.join(".")} Types - ${description}
106
+ // =============================================================================
107
+
108
+ export const ${schemaName}: z.ZodObject<{
109
+ // TODO: Add input fields
110
+ }> = z.object({
111
+ // TODO: Add input fields
112
+ });
113
+
114
+ export type ${pascalName}Input = z.infer<typeof ${schemaName}>;
115
+
116
+ export const ${outputSchemaName}: z.ZodObject<{
117
+ success: z.ZodBoolean;
118
+ message: z.ZodString;
119
+ }> = z.object({
120
+ /** Whether the operation succeeded */
121
+ success: z.boolean().describe("Whether the operation succeeded"),
122
+ /** Response message */
123
+ message: z.string().describe("Response message"),
124
+ });
125
+
126
+ export type ${pascalName}Output = z.infer<typeof ${outputSchemaName}>;
127
+ `;
128
+ }
129
+ const TYPES_HEADER = `/**
130
+ * Type definitions of the procedures of this package
131
+ */
132
+
133
+ `;
134
+ const Z_IMPORT = `import { z } from "zod";\n`;
135
+ /** True when the source imports z from "zod" */
136
+ function importsZ(source) {
137
+ return (/import\s*\{[^}]*\bz\b[^}]*\}\s*from\s*["']zod["']/.test(source) ||
138
+ /import\s+\*\s+as\s+z\s+from\s*["']zod["']/.test(source) ||
139
+ /import\s+z\s+from\s*["']zod["']/.test(source));
140
+ }
141
+ /**
142
+ * Add import lines after the last import of a source (or after its leading comment)
143
+ */
144
+ export function addImports(source, lines) {
145
+ if (lines.length === 0) {
146
+ return source;
147
+ }
148
+ const block = lines.join("");
149
+ const importPattern = /^import[\s\S]*?from\s*["'][^"']+["'];?[ \t]*\r?\n|^import\s*["'][^"']+["'];?[ \t]*\r?\n/gm;
150
+ let end = -1;
151
+ for (const match of source.matchAll(importPattern)) {
152
+ end = match.index + match[0].length;
153
+ }
154
+ if (end === -1) {
155
+ const comment = /^\s*\/\*[\s\S]*?\*\/[ \t]*\r?\n(\r?\n)?/.exec(source);
156
+ end = comment ? comment[0].length : 0;
157
+ }
158
+ return source.slice(0, end) + block + source.slice(end);
159
+ }
160
+ /**
161
+ * Add names to the value import from a module, or add the import
162
+ */
163
+ export function ensureNamedImports(source, moduleName, names) {
164
+ const escaped = moduleName.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
165
+ const pattern = new RegExp(`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${escaped}["'];?`);
166
+ const match = pattern.exec(source);
167
+ if (match && !/^import\s+type\b/.test(match[0])) {
168
+ const present = match[1]
169
+ .split(",")
170
+ .map((part) => part.trim())
171
+ .filter((part) => part.length > 0);
172
+ const presentNames = new Set(present.map((part) => part.replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim()));
173
+ const missing = names.filter((name) => !presentNames.has(name));
174
+ if (missing.length === 0) {
175
+ return source;
176
+ }
177
+ const replacement = `import { ${[...present, ...missing].join(", ")} } from "${moduleName}";`;
178
+ return source.slice(0, match.index) + replacement + source.slice(match.index + match[0].length);
179
+ }
180
+ return addImports(source, [`import { ${names.join(", ")} } from "${moduleName}";\n`]);
181
+ }
182
+ /** The index of the bracket that closes the bracket at `open` (strings are skipped) */
183
+ function closingBracket(source, open) {
184
+ let depth = 0;
185
+ let quote;
186
+ for (let i = open; i < source.length; i++) {
187
+ const ch = source[i];
188
+ if (quote) {
189
+ if (ch === "\\")
190
+ i++;
191
+ else if (ch === quote)
192
+ quote = undefined;
193
+ continue;
194
+ }
195
+ if (ch === '"' || ch === "'" || ch === "`")
196
+ quote = ch;
197
+ else if (ch === "[")
198
+ depth++;
199
+ else if (ch === "]" && --depth === 0)
200
+ return i;
201
+ }
202
+ return -1;
203
+ }
204
+ /**
205
+ * Add an item to the array of the first registerProcedures([...]) or registerAll([...]) call.
206
+ * Returns undefined when the source has no such call.
207
+ */
208
+ export function addToRegistration(source, item) {
209
+ // The first call in code, not in a comment
210
+ const call = [...source.matchAll(/\b(registerProcedures|registerAll)\s*\(/g)].find((match) => {
211
+ const lineStart = source.lastIndexOf("\n", match.index) + 1;
212
+ const before = source.slice(lineStart, match.index).trim();
213
+ return !before.startsWith("*") && !before.startsWith("/*") && !before.includes("//");
214
+ });
215
+ if (!call) {
216
+ return undefined;
217
+ }
218
+ const open = source.indexOf("[", call.index);
219
+ const close = open === -1 ? -1 : closingBracket(source, open);
220
+ if (close === -1) {
221
+ return undefined;
222
+ }
223
+ const content = source.slice(open + 1, close);
224
+ let updated;
225
+ if (content.trim() === "") {
226
+ updated = item;
227
+ }
228
+ else if (content.includes("\n")) {
229
+ // One item per line: add a line with the indentation of the last item
230
+ const trimmed = content.replace(/\s*$/, "");
231
+ const lastLine = trimmed.slice(trimmed.lastIndexOf("\n") + 1);
232
+ const indent = /^\s*/.exec(lastLine)?.[0] ?? " ";
233
+ const comma = trimmed.endsWith(",") ? "" : ",";
234
+ updated = `${trimmed}${comma}\n${indent}${item},${content.slice(trimmed.length)}`;
235
+ }
236
+ else {
237
+ updated = `${content.replace(/,?\s*$/, "")}, ${item}`;
238
+ }
239
+ return source.slice(0, open + 1) + updated + source.slice(close);
240
+ }
241
+ /**
242
+ * The procedure definition that goes into register.ts
243
+ */
244
+ function generateRegistration(layout, description) {
245
+ const { segments, camelName, pascalName } = layout;
246
+ return `const ${camelName}Procedure = createProcedure()
247
+ .path(${JSON.stringify(segments)})
248
+ .input(zodAdapter<${pascalName}Input>(${pascalName}InputSchema))
249
+ .output(zodAdapter<${pascalName}Output>(${pascalName}OutputSchema))
250
+ .meta({
251
+ description: ${JSON.stringify(description)},
252
+ args: [],
253
+ shorts: {},
254
+ output: "text",
255
+ })
256
+ .handler(async (input: ${pascalName}Input): Promise<${pascalName}Output> => ${camelName}(input))
257
+ .build();
258
+
259
+ `;
260
+ }
261
+ const REGISTER_TEMPLATE = `/**
262
+ * Procedure registration of this package
263
+ *
264
+ * Scaffold a procedure with: mark procedure new <name> --path <this package>
265
+ */
266
+
267
+ import { registerProcedures } from "@procedures/client";
268
+
269
+ export function register(): void {
270
+ registerProcedures([]);
271
+ }
272
+
273
+ // Auto-register
274
+ register();
275
+ `;
276
+ /**
277
+ * Put the procedure into register.ts: its imports, its definition, and its place in the
278
+ * registration array. Returns undefined when register.ts has no registration call.
279
+ */
280
+ export function registerSource(source, layout, description, importPath) {
281
+ const { camelName, pascalName } = layout;
282
+ const withArray = addToRegistration(source, `${camelName}Procedure`);
283
+ if (withArray === undefined) {
284
+ return undefined;
285
+ }
286
+ let updated = ensureNamedImports(withArray, "@procedures/client", ["createProcedure", "zodAdapter"]);
287
+ updated = addImports(updated, [
288
+ `import { ${camelName} } from "${importPath}";\n`,
289
+ `import { ${pascalName}InputSchema, ${pascalName}OutputSchema, type ${pascalName}Input, type ${pascalName}Output } from "./types.js";\n`,
290
+ ]);
291
+ // The definition goes before the code that registers the procedures
292
+ const anchor = /^(export\s+)?(async\s+)?function\s+register\w*\s*\(|^\s*(registerProcedures|PROCEDURE_REGISTRY\.registerAll)\s*\(/m.exec(updated);
293
+ const at = anchor ? anchor.index : updated.length;
294
+ return updated.slice(0, at) + generateRegistration(layout, description) + updated.slice(at);
295
+ }
296
+ /**
297
+ * Generate index.ts export
298
+ */
299
+ function generateIndexExport(relativeFile, functionName) {
300
+ return `export { ${functionName} } from "./${relativeFile}.js";\n`;
301
+ }
302
+ /**
303
+ * Scaffold a new procedure
304
+ */
305
+ export async function procedureNew(input, ctx) {
306
+ const operations = [];
307
+ const created = [];
308
+ const modified = [];
309
+ const errors = [];
310
+ const layout = procedureLayout(input.name, input.namespace);
311
+ const { segments, namespace, folders, fileBase, camelName, pascalName } = layout;
312
+ // Resolve paths
313
+ const projectPath = input.path ?? process.cwd();
314
+ const srcPath = join(projectPath, "src");
315
+ const namespacePath = join(srcPath, "procedures", namespace);
316
+ const procedureDir = join(namespacePath, ...folders);
317
+ const procedureFile = join(procedureDir, `${fileBase}.ts`);
318
+ const namespaceIndex = join(namespacePath, "index.ts");
319
+ const typesFile = join(srcPath, "types.ts");
320
+ const registerFile = join(srcPath, "register.ts");
321
+ const relativeFile = [...folders, fileBase].join("/");
322
+ const importPath = `./procedures/${namespace}/${relativeFile}.js`;
323
+ const description = input.description ?? `${segments.join(".")} procedure`;
324
+ const fail = (message) => ({
325
+ success: false,
326
+ procedurePath: segments,
327
+ created,
328
+ modified,
329
+ operations,
330
+ errors: [...errors, message],
331
+ });
332
+ // Check every collision before anything is written
333
+ if (PROCEDURE_REGISTRY.has(segments)) {
334
+ return fail(`A procedure is registered at ${segments.join(".")} already. Choose another name.`);
335
+ }
336
+ if (await pathExists(procedureFile, ctx)) {
337
+ return fail(`Procedure file already exists: ${procedureFile}`);
338
+ }
339
+ const existingTypes = await readText(typesFile, ctx);
340
+ if (existingTypes !== undefined && new RegExp(`\\b${pascalName}(Input|Output|InputSchema|OutputSchema)\\b`).test(existingTypes)) {
341
+ return fail(`types.ts already has types named ${pascalName}: the name ${segments.join(".")} collides with another procedure. Choose another name.`);
342
+ }
343
+ const existingRegister = await readText(registerFile, ctx);
344
+ if (existingRegister !== undefined) {
345
+ if (existingRegister.includes(JSON.stringify(segments)) || new RegExp(`\\b${camelName}Procedure\\b`).test(existingRegister)) {
346
+ return fail(`register.ts already registers ${segments.join(".")} (or ${camelName}Procedure). Choose another name.`);
347
+ }
348
+ }
349
+ const registerBase = existingRegister ?? REGISTER_TEMPLATE;
350
+ const newRegister = registerSource(registerBase, layout, description, importPath);
351
+ if (input.dryRun) {
352
+ const [indexExists] = await Promise.all([pathExists(namespaceIndex, ctx)]);
353
+ return {
354
+ success: true,
355
+ procedurePath: segments,
356
+ created: [
357
+ procedureFile,
358
+ ...(indexExists ? [] : [namespaceIndex]),
359
+ ...(existingTypes === undefined ? [typesFile] : []),
360
+ ...(existingRegister === undefined ? [registerFile] : []),
361
+ ],
362
+ modified: [
363
+ ...(indexExists ? [namespaceIndex] : []),
364
+ ...(existingTypes !== undefined ? [typesFile] : []),
365
+ ...(existingRegister !== undefined && newRegister !== undefined ? [registerFile] : []),
366
+ ],
367
+ operations: [
368
+ `Would create procedure file: ${procedureFile}`,
369
+ `Would create/update index: ${namespaceIndex}`,
370
+ existingTypes === undefined ? `Would create ${typesFile}` : `Would append types to: ${typesFile}`,
371
+ newRegister === undefined
372
+ ? `Would not change ${registerFile}: it has no registerProcedures([...]) call`
373
+ : `Would register the procedure in: ${registerFile}`,
374
+ ],
375
+ errors: [],
376
+ };
377
+ }
378
+ try {
379
+ // Step 1: Create the folder and the procedure file
380
+ if (!(await pathExists(procedureDir, ctx))) {
381
+ operations.push(`Creating directory: ${procedureDir}`);
382
+ await ctx.client.call(["fs", "mkdir"], { path: procedureDir, recursive: true });
383
+ created.push(procedureDir);
384
+ }
385
+ operations.push(`Creating procedure file: ${procedureFile}`);
386
+ await writeText(procedureFile, generateProcedureFile(layout, description), ctx);
387
+ created.push(procedureFile);
388
+ // Step 2: Create/update namespace index.ts
389
+ const indexExport = generateIndexExport(relativeFile, camelName);
390
+ const existingIndex = await readText(namespaceIndex, ctx);
391
+ if (existingIndex !== undefined) {
392
+ if (!existingIndex.includes(`from "./${relativeFile}.js"`)) {
393
+ operations.push(`Updating index: ${namespaceIndex}`);
394
+ await writeText(namespaceIndex, existingIndex + indexExport, ctx);
395
+ modified.push(namespaceIndex);
396
+ }
397
+ }
398
+ else {
399
+ operations.push(`Creating index: ${namespaceIndex}`);
400
+ await writeText(namespaceIndex, indexExport, ctx);
401
+ created.push(namespaceIndex);
402
+ }
403
+ // Step 3: Add the types (create types.ts, or add the z import that the types need)
404
+ const newTypes = generateTypes(layout, description);
405
+ if (existingTypes === undefined) {
406
+ operations.push(`Creating types: ${typesFile}`);
407
+ await writeText(typesFile, TYPES_HEADER + Z_IMPORT + newTypes, ctx);
408
+ created.push(typesFile);
409
+ }
410
+ else {
411
+ operations.push(`Appending types to: ${typesFile}`);
412
+ const withImport = importsZ(existingTypes) ? existingTypes : addImports(existingTypes, [Z_IMPORT]);
413
+ await writeText(typesFile, withImport + newTypes, ctx);
414
+ modified.push(typesFile);
415
+ }
416
+ // Step 4: Register the procedure
417
+ if (newRegister === undefined) {
418
+ operations.push(`register.ts has no registerProcedures([...]) call: add ${camelName}Procedure to the registration of ${registerFile}`);
419
+ }
420
+ else {
421
+ operations.push(`${existingRegister === undefined ? "Creating" : "Updating"} registration: ${registerFile}`);
422
+ await writeText(registerFile, newRegister, ctx);
423
+ (existingRegister === undefined ? created : modified).push(registerFile);
424
+ if (existingRegister === undefined) {
425
+ operations.push(`Import ./register.js from src/index.ts, so importing the package registers its procedures`);
426
+ }
427
+ }
428
+ operations.push(`Next: implement ${segments.join(".")} in ${procedureFile}, then run pnpm build`);
429
+ return {
430
+ success: errors.length === 0,
431
+ procedurePath: segments,
432
+ created,
433
+ modified,
434
+ operations,
435
+ errors,
436
+ };
437
+ }
438
+ catch (error) {
439
+ return fail(error instanceof Error ? error.message : String(error));
440
+ }
441
+ }
442
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@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CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC;QAED,iCAAiC;QACjC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,UAAU,CAAC,IAAI,CACb,0DAA0D,SAAS,oCAAoC,YAAY,EAAE,CACtH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,GAAG,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,kBAAkB,YAAY,EAAE,CAAC,CAAC;YAC7G,MAAM,SAAS,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;YAChD,CAAC,gBAAgB,KAAK,SAAS,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,2FAA2F,CAAC,CAAC;YAC/G,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,YAiCrC,CAAC;AAMH,eAAO,MAAM,2BAA2B,EAAE,YAAY,EAA+B,CAAC"}
@@ -0,0 +1,67 @@
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, 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
+ args: ["path"],
40
+ shorts: {},
41
+ output: "json",
42
+ },
43
+ handler: async (input) => {
44
+ const path = typeof input.path === "string"
45
+ ? keyToPath(input.path)
46
+ : input.path;
47
+ const proc = PROCEDURE_REGISTRY.get(path);
48
+ if (!proc) {
49
+ return {
50
+ success: false,
51
+ error: `Procedure not found: ${pathToKey(path)}`,
52
+ };
53
+ }
54
+ return {
55
+ success: true,
56
+ definition: {
57
+ $proc: proc.path,
58
+ metadata: proc.metadata,
59
+ },
60
+ };
61
+ },
62
+ });
63
+ // =============================================================================
64
+ // Export all procedure.* procedures
65
+ // =============================================================================
66
+ export const procedureRegistryProcedures = [procedureExportProcedure];
67
+ //# 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,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/F,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,CAA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AAC,CAAC;QAE1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,wBAAwB,SAAS,CAAC,IAAI,CAAC,EAAE;aACjD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,KAAK,EAAE,IAAI,CAAC,IAAI;gBAChB,QAAQ,EAAE,IAAI,CAAC,QAA+C;aAC/D;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,gFAAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF,MAAM,CAAC,MAAM,2BAA2B,GAAmB,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/procedure in the global
3
+ * registry (DECISIONS-2026-10, "Every package root registers its procedures"). The procedures as
4
+ * data are in `module.ts`, which registers nothing: a host with its own registry uses that one.
5
+ */
6
+ export * from "./module.js";
7
+ export declare function registerProcedureProcedures(): void;
8
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,cAAc,aAAa,CAAC;AAE5B,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/procedure in the global
3
+ * registry (DECISIONS-2026-10, "Every package root registers its procedures"). The procedures as
4
+ * data are in `module.ts`, which registers nothing: a host with its own registry uses that one.
5
+ */
6
+ import { PROCEDURE_REGISTRY } from "@procedures/client";
7
+ import { procedureModule } from "./module.js";
8
+ export * from "./module.js";
9
+ export function registerProcedureProcedures() {
10
+ // Override makes the registration idempotent. procedure.list and procedure.get are the core
11
+ // ones: this package does not replace them (docs review DOC-6).
12
+ PROCEDURE_REGISTRY.registerAll(procedureModule.procedures, { override: true });
13
+ }
14
+ // Auto-register
15
+ registerProcedureProcedures();
16
+ //# 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,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,cAAc,aAAa,CAAC;AAE5B,MAAM,UAAU,2BAA2B;IACzC,4FAA4F;IAC5F,gEAAgE;IAChE,kBAAkB,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,gBAAgB;AAChB,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"}