@procedures/lib 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.
- package/CHANGELOG.md +30 -0
- package/LICENSE +21 -0
- package/README.md +119 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/cli-flags.d.ts +27 -0
- package/dist/cli-flags.d.ts.map +1 -0
- package/dist/cli-flags.js +33 -0
- package/dist/cli-flags.js.map +1 -0
- package/dist/dag/builder.d.ts +18 -0
- package/dist/dag/builder.d.ts.map +1 -0
- package/dist/dag/builder.js +35 -0
- package/dist/dag/builder.js.map +1 -0
- package/dist/dag/index.d.ts +12 -0
- package/dist/dag/index.d.ts.map +1 -0
- package/dist/dag/index.js +12 -0
- package/dist/dag/index.js.map +1 -0
- package/dist/git/index.d.ts +5 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +5 -0
- package/dist/git/index.js.map +1 -0
- package/dist/git/ref-parser.d.ts +34 -0
- package/dist/git/ref-parser.d.ts.map +1 -0
- package/dist/git/ref-parser.js +70 -0
- package/dist/git/ref-parser.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +180 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/core/catch.d.ts +33 -0
- package/dist/procedures/core/catch.d.ts.map +1 -0
- package/dist/procedures/core/catch.js +118 -0
- package/dist/procedures/core/catch.js.map +1 -0
- package/dist/procedures/core/index.d.ts +9 -0
- package/dist/procedures/core/index.d.ts.map +1 -0
- package/dist/procedures/core/index.js +8 -0
- package/dist/procedures/core/index.js.map +1 -0
- package/dist/procedures/dag/index.d.ts +5 -0
- package/dist/procedures/dag/index.d.ts.map +1 -0
- package/dist/procedures/dag/index.js +5 -0
- package/dist/procedures/dag/index.js.map +1 -0
- package/dist/procedures/dag/traverse.d.ts +54 -0
- package/dist/procedures/dag/traverse.d.ts.map +1 -0
- package/dist/procedures/dag/traverse.js +252 -0
- package/dist/procedures/dag/traverse.js.map +1 -0
- package/dist/procedures/ecosystem/index.d.ts +7 -0
- package/dist/procedures/ecosystem/index.d.ts.map +1 -0
- package/dist/procedures/ecosystem/index.js +6 -0
- package/dist/procedures/ecosystem/index.js.map +1 -0
- package/dist/procedures/ecosystem/procedures.d.ts +63 -0
- package/dist/procedures/ecosystem/procedures.d.ts.map +1 -0
- package/dist/procedures/ecosystem/procedures.js +215 -0
- package/dist/procedures/ecosystem/procedures.js.map +1 -0
- package/dist/procedures/lib/audit.d.ts +29 -0
- package/dist/procedures/lib/audit.d.ts.map +1 -0
- package/dist/procedures/lib/audit.js +236 -0
- package/dist/procedures/lib/audit.js.map +1 -0
- package/dist/procedures/lib/index.d.ts +8 -0
- package/dist/procedures/lib/index.d.ts.map +1 -0
- package/dist/procedures/lib/index.js +8 -0
- package/dist/procedures/lib/index.js.map +1 -0
- package/dist/procedures/lib/new.d.ts +20 -0
- package/dist/procedures/lib/new.d.ts.map +1 -0
- package/dist/procedures/lib/new.js +205 -0
- package/dist/procedures/lib/new.js.map +1 -0
- package/dist/procedures/lib/rename.d.ts +28 -0
- package/dist/procedures/lib/rename.d.ts.map +1 -0
- package/dist/procedures/lib/rename.js +267 -0
- package/dist/procedures/lib/rename.js.map +1 -0
- package/dist/procedures/lib/scan.d.ts +14 -0
- package/dist/procedures/lib/scan.d.ts.map +1 -0
- package/dist/procedures/lib/scan.js +102 -0
- package/dist/procedures/lib/scan.js.map +1 -0
- package/dist/register.d.ts +7 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/scoped-input.d.ts +17 -0
- package/dist/scoped-input.d.ts.map +1 -0
- package/dist/scoped-input.js +23 -0
- package/dist/scoped-input.js.map +1 -0
- package/dist/types.d.ts +248 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +231 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace.d.ts +46 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +98 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +87 -3
- package/src/cli-flags.ts +49 -0
- package/src/dag/builder.ts +44 -0
- package/src/dag/index.ts +23 -0
- package/src/git/index.ts +11 -0
- package/src/git/ref-parser.ts +83 -0
- package/src/index.ts +56 -0
- package/src/module.ts +232 -0
- package/src/procedures/core/catch.ts +142 -0
- package/src/procedures/core/index.ts +9 -0
- package/src/procedures/dag/index.ts +5 -0
- package/src/procedures/dag/traverse.ts +281 -0
- package/src/procedures/ecosystem/index.ts +12 -0
- package/src/procedures/ecosystem/procedures.ts +317 -0
- package/src/procedures/lib/audit.ts +307 -0
- package/src/procedures/lib/index.ts +8 -0
- package/src/procedures/lib/new.ts +253 -0
- package/src/procedures/lib/rename.ts +355 -0
- package/src/procedures/lib/scan.ts +143 -0
- package/src/register.ts +11 -0
- package/src/types.ts +526 -0
- package/src/workspace.ts +110 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core.catch procedure
|
|
3
|
+
*
|
|
4
|
+
* Wraps a procedure execution with error handling.
|
|
5
|
+
* The `try` procedure ref should use `$when: "catch"` so it's not
|
|
6
|
+
* executed during hydration but instead by this procedure.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* {
|
|
11
|
+
* $proc: ["core", "catch"],
|
|
12
|
+
* input: {
|
|
13
|
+
* try: {
|
|
14
|
+
* $proc: ["git", "commit"],
|
|
15
|
+
* input: { message: "auto" },
|
|
16
|
+
* $when: "catch" // Defer execution to catch procedure
|
|
17
|
+
* },
|
|
18
|
+
* handler: {
|
|
19
|
+
* $proc: ["core", "identity"],
|
|
20
|
+
* input: { value: { continue: true } },
|
|
21
|
+
* $when: "catch"
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { isAnyProcedureRef, normalizeRef, hydrateInput, scopeOf, } from "@procedures/client";
|
|
28
|
+
/**
|
|
29
|
+
* Execute a procedure with error handling
|
|
30
|
+
*/
|
|
31
|
+
export async function coreCatch(input, ctx) {
|
|
32
|
+
const { try: tryRef, handler: handlerRef, cwd } = input;
|
|
33
|
+
// The names of the chain around this procedure: a `$ref` in an operand can read them
|
|
34
|
+
const scope = scopeOf(input);
|
|
35
|
+
// Validate try is a procedure ref
|
|
36
|
+
if (!isAnyProcedureRef(tryRef)) {
|
|
37
|
+
throw new Error("catch: 'try' must be a procedure reference with $when: \"catch\"");
|
|
38
|
+
}
|
|
39
|
+
// Create executor that uses client.call
|
|
40
|
+
const executor = async (path, inp) => {
|
|
41
|
+
// Inject cwd if provided
|
|
42
|
+
const inputWithCwd = cwd && typeof inp === "object" && inp !== null
|
|
43
|
+
? { ...inp, cwd }
|
|
44
|
+
: inp;
|
|
45
|
+
return ctx.client.call(path, inputWithCwd);
|
|
46
|
+
};
|
|
47
|
+
// Normalize the try ref
|
|
48
|
+
const normalizedTry = normalizeRef(tryRef);
|
|
49
|
+
// Build input for try, merging with cwd
|
|
50
|
+
const tryInput = {
|
|
51
|
+
...(typeof normalizedTry.input === "object" ? normalizedTry.input : {}),
|
|
52
|
+
...(cwd ? { cwd } : {}),
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
// Hydrate the try input (execute any nested $immediate refs). The hydration is inside the
|
|
56
|
+
// `try`: a nested ref that throws is an error of the `try` step (deep dive DATA-22).
|
|
57
|
+
const hydratedTryInput = await hydrateInput(tryInput, executor, {
|
|
58
|
+
contextStack: ["catch"],
|
|
59
|
+
onRef: ctx.onRef,
|
|
60
|
+
scope,
|
|
61
|
+
});
|
|
62
|
+
// Execute the try procedure
|
|
63
|
+
const result = await ctx.client.call(normalizedTry.path, hydratedTryInput);
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
result,
|
|
67
|
+
continue: true,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
72
|
+
// If no handler, return error result with continue: false
|
|
73
|
+
if (!handlerRef || !isAnyProcedureRef(handlerRef)) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
error: errorMessage,
|
|
77
|
+
continue: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Build StepResultInfo for handler
|
|
81
|
+
const resultInfo = {
|
|
82
|
+
success: false,
|
|
83
|
+
error: errorMessage,
|
|
84
|
+
proc: normalizedTry.path,
|
|
85
|
+
};
|
|
86
|
+
// Execute handler with result info merged into its input
|
|
87
|
+
const normalizedHandler = normalizeRef(handlerRef);
|
|
88
|
+
const handlerInput = {
|
|
89
|
+
...(typeof normalizedHandler.input === "object" ? normalizedHandler.input : {}),
|
|
90
|
+
...resultInfo,
|
|
91
|
+
...(cwd ? { cwd } : {}),
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
// Hydrate handler input (a failure here is a failure of the handler)
|
|
95
|
+
const hydratedHandlerInput = await hydrateInput(handlerInput, executor, {
|
|
96
|
+
contextStack: ["catch"],
|
|
97
|
+
onRef: ctx.onRef,
|
|
98
|
+
scope,
|
|
99
|
+
});
|
|
100
|
+
const decision = await ctx.client.call(normalizedHandler.path, hydratedHandlerInput);
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
error: errorMessage,
|
|
104
|
+
result: decision,
|
|
105
|
+
continue: decision.continue ?? false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (handlerError) {
|
|
109
|
+
// Handler itself failed
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: `Handler failed: ${handlerError instanceof Error ? handlerError.message : String(handlerError)}`,
|
|
113
|
+
continue: false,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
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AiB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/E,GAAG,UAAU;YACb,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxB,CAAC;QAEF,IAAI,CAAC;YACH,qEAAqE;YACrE,MAAM,oBAAoB,GAAG,MAAM,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE;gBACtE,YAAY,EAAE,CAAC,OAAO,CAAC;gBACvB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,KAAK;aACN,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,CAAqB,CAAC;YAEzG,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,YAAY;gBACnB,MAAM,EAAE,QAAQ;gBAChB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,KAAK;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YACtB,wBAAwB;YACxB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,mBAAmB,YAAY,YAAY,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;gBACvG,QAAQ,EAAE,KAAK;aAChB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core control-flow procedures that require ProcedureContext
|
|
3
|
+
*
|
|
4
|
+
* These procedures need access to the client for executing procedure refs
|
|
5
|
+
* with proper error handling and control flow.
|
|
6
|
+
*/
|
|
7
|
+
export { coreCatch } from "./catch.js";
|
|
8
|
+
export type { CoreCatchInput, CoreCatchOutput } from "../../types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core control-flow procedures that require ProcedureContext
|
|
3
|
+
*
|
|
4
|
+
* These procedures need access to the client for executing procedure refs
|
|
5
|
+
* with proper error handling and control flow.
|
|
6
|
+
*/
|
|
7
|
+
export { coreCatch } from "./catch.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/dag/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/dag/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dag.traverse procedure
|
|
3
|
+
*
|
|
4
|
+
* General-purpose DAG traversal that executes a visit procedure
|
|
5
|
+
* for each node in dependency order.
|
|
6
|
+
*
|
|
7
|
+
* This enables declarative composition of traversals:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Execute git add on all packages (using $when: "$parent")
|
|
10
|
+
* await client.exec({
|
|
11
|
+
* $proc: ["dag", "traverse"],
|
|
12
|
+
* input: {
|
|
13
|
+
* visit: {
|
|
14
|
+
* $proc: ["git", "add"],
|
|
15
|
+
* input: { all: true },
|
|
16
|
+
* $when: "$parent" // Defer to dag.traverse
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Simple form with just procedure path
|
|
22
|
+
* await client.exec({
|
|
23
|
+
* $proc: ["dag", "traverse"],
|
|
24
|
+
* input: {
|
|
25
|
+
* visit: ["git", "add"]
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The `$when` field controls when nested $proc refs are executed:
|
|
31
|
+
* - "$immediate" (default): Execute during hydration
|
|
32
|
+
* - "$parent": Defer to parent procedure (dag.traverse executes per-node)
|
|
33
|
+
* - "$never": Never auto-execute, pass as pure data
|
|
34
|
+
*/
|
|
35
|
+
import type { ProcedureContext } from "@procedures/client";
|
|
36
|
+
import type { DagTraverseInput, DagTraverseOutput } from "../../types.js";
|
|
37
|
+
/** The folder of the git repository that holds `path` (it has `.git`), or `path` itself. */
|
|
38
|
+
export declare function repositoryRoot(path: string): string;
|
|
39
|
+
/** True when the value names a `git` procedure: a path, or a `$proc` ref at any depth. */
|
|
40
|
+
export declare function callsGit(value: unknown): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Run the tasks of one key one at a time, in the order of the calls. Tasks of other keys run
|
|
43
|
+
* in parallel.
|
|
44
|
+
*/
|
|
45
|
+
export declare function keyedLock(): <T>(key: string, task: () => Promise<T>) => Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Execute a DAG traversal with a custom visit procedure
|
|
48
|
+
*
|
|
49
|
+
* The visits of nodes in one git repository run one at a time when the visit calls git (or
|
|
50
|
+
* with `serialize: "repository"`). All the packages of a workspace share one repository, and
|
|
51
|
+
* concurrent `git add` calls failed on `index.lock` (deep dive DATA-17).
|
|
52
|
+
*/
|
|
53
|
+
export declare function dagTraverse(input: DagTraverseInput, ctx: ProcedureContext): Promise<DagTraverseOutput>;
|
|
54
|
+
//# sourceMappingURL=traverse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../../src/procedures/dag/traverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAEV,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAUxB,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAShD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAkBlF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAyK5B"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dag.traverse procedure
|
|
3
|
+
*
|
|
4
|
+
* General-purpose DAG traversal that executes a visit procedure
|
|
5
|
+
* for each node in dependency order.
|
|
6
|
+
*
|
|
7
|
+
* This enables declarative composition of traversals:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Execute git add on all packages (using $when: "$parent")
|
|
10
|
+
* await client.exec({
|
|
11
|
+
* $proc: ["dag", "traverse"],
|
|
12
|
+
* input: {
|
|
13
|
+
* visit: {
|
|
14
|
+
* $proc: ["git", "add"],
|
|
15
|
+
* input: { all: true },
|
|
16
|
+
* $when: "$parent" // Defer to dag.traverse
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Simple form with just procedure path
|
|
22
|
+
* await client.exec({
|
|
23
|
+
* $proc: ["dag", "traverse"],
|
|
24
|
+
* input: {
|
|
25
|
+
* visit: ["git", "add"]
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The `$when` field controls when nested $proc refs are executed:
|
|
31
|
+
* - "$immediate" (default): Execute during hydration
|
|
32
|
+
* - "$parent": Defer to parent procedure (dag.traverse executes per-node)
|
|
33
|
+
* - "$never": Never auto-execute, pass as pure data
|
|
34
|
+
*/
|
|
35
|
+
import { existsSync } from "node:fs";
|
|
36
|
+
import { dirname, join, resolve } from "node:path";
|
|
37
|
+
import { isAnyProcedureRef, hydrateInput, scopeOf } from "@procedures/client";
|
|
38
|
+
import { libScan } from "../lib/scan.js";
|
|
39
|
+
import { buildDAGNodes, buildLeveledDAG, executeDAG, createProcessor, filterDAGFromRoot, } from "../../dag/index.js";
|
|
40
|
+
/** The folder of the git repository that holds `path` (it has `.git`), or `path` itself. */
|
|
41
|
+
export function repositoryRoot(path) {
|
|
42
|
+
let current = resolve(path);
|
|
43
|
+
for (;;) {
|
|
44
|
+
if (existsSync(join(current, ".git")))
|
|
45
|
+
return current;
|
|
46
|
+
const parent = dirname(current);
|
|
47
|
+
if (parent === current)
|
|
48
|
+
return resolve(path);
|
|
49
|
+
current = parent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** True when the value names a `git` procedure: a path, or a `$proc` ref at any depth. */
|
|
53
|
+
export function callsGit(value) {
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
if (value[0] === "git" && value.every((part) => typeof part === "string"))
|
|
56
|
+
return true;
|
|
57
|
+
return value.some(callsGit);
|
|
58
|
+
}
|
|
59
|
+
if (typeof value === "object" && value !== null) {
|
|
60
|
+
return Object.values(value).some(callsGit);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run the tasks of one key one at a time, in the order of the calls. Tasks of other keys run
|
|
66
|
+
* in parallel.
|
|
67
|
+
*/
|
|
68
|
+
export function keyedLock() {
|
|
69
|
+
const tails = new Map();
|
|
70
|
+
return async (key, task) => {
|
|
71
|
+
const previous = tails.get(key) ?? Promise.resolve();
|
|
72
|
+
let release;
|
|
73
|
+
const done = new Promise((resolveDone) => {
|
|
74
|
+
release = resolveDone;
|
|
75
|
+
});
|
|
76
|
+
const tail = previous.then(() => done);
|
|
77
|
+
tails.set(key, tail);
|
|
78
|
+
await previous;
|
|
79
|
+
try {
|
|
80
|
+
return await task();
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
release();
|
|
84
|
+
if (tails.get(key) === tail)
|
|
85
|
+
tails.delete(key);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Execute a DAG traversal with a custom visit procedure
|
|
91
|
+
*
|
|
92
|
+
* The visits of nodes in one git repository run one at a time when the visit calls git (or
|
|
93
|
+
* with `serialize: "repository"`). All the packages of a workspace share one repository, and
|
|
94
|
+
* concurrent `git add` calls failed on `index.lock` (deep dive DATA-17).
|
|
95
|
+
*/
|
|
96
|
+
export async function dagTraverse(input, ctx) {
|
|
97
|
+
const startTime = Date.now();
|
|
98
|
+
const results = [];
|
|
99
|
+
// Scan for all packages
|
|
100
|
+
const scanResult = await libScan(input.rootPath !== undefined ? { rootPath: input.rootPath } : {}, ctx);
|
|
101
|
+
let allNodes = buildDAGNodes(scanResult.packages);
|
|
102
|
+
// Filter to specific packages if requested
|
|
103
|
+
if (input.filter && input.filter.length > 0) {
|
|
104
|
+
const filtered = new Map();
|
|
105
|
+
for (const name of input.filter) {
|
|
106
|
+
const node = allNodes.get(name);
|
|
107
|
+
if (node) {
|
|
108
|
+
filtered.set(name, node);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
allNodes = filtered;
|
|
112
|
+
}
|
|
113
|
+
// Filter to root and its dependencies if requested
|
|
114
|
+
if (input.root) {
|
|
115
|
+
const rootNode = allNodes.get(input.root);
|
|
116
|
+
if (!rootNode) {
|
|
117
|
+
return {
|
|
118
|
+
success: false,
|
|
119
|
+
results: [],
|
|
120
|
+
totalDuration: Date.now() - startTime,
|
|
121
|
+
visited: 0,
|
|
122
|
+
failed: 0,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
allNodes = filterDAGFromRoot(allNodes, input.root);
|
|
126
|
+
}
|
|
127
|
+
// Build DAG for dependency-ordered execution
|
|
128
|
+
const dag = buildLeveledDAG(allNodes);
|
|
129
|
+
// Determine how to execute the visit procedure
|
|
130
|
+
// visit can be:
|
|
131
|
+
// - Array: procedure path like ["git", "add"]
|
|
132
|
+
// - $proc ref: { $proc: [...], input: {...}, $when: "$parent" }
|
|
133
|
+
const visitIsRef = isAnyProcedureRef(input.visit);
|
|
134
|
+
let visitPath;
|
|
135
|
+
let baseInput = {};
|
|
136
|
+
if (Array.isArray(input.visit)) {
|
|
137
|
+
visitPath = input.visit;
|
|
138
|
+
}
|
|
139
|
+
else if (visitIsRef && typeof input.visit === "object" && "$proc" in input.visit) {
|
|
140
|
+
visitPath = input.visit.$proc;
|
|
141
|
+
baseInput = input.visit.input ?? {};
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error("visit must be a procedure path or $proc reference with $when");
|
|
145
|
+
}
|
|
146
|
+
const serialize = input.serialize ?? "auto";
|
|
147
|
+
const oneAtATime = serialize === "repository" || (serialize === "auto" && callsGit(input.visit));
|
|
148
|
+
const lock = keyedLock();
|
|
149
|
+
// Create processor that executes visit procedure per node
|
|
150
|
+
const processor = createProcessor(async (node) => {
|
|
151
|
+
if (oneAtATime) {
|
|
152
|
+
await lock(repositoryRoot(node.repoPath), () => visit(node));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await visit(node);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
async function visit(node) {
|
|
159
|
+
if (input.dryRun) {
|
|
160
|
+
results.push({
|
|
161
|
+
name: node.name,
|
|
162
|
+
path: node.repoPath,
|
|
163
|
+
success: true,
|
|
164
|
+
duration: 0,
|
|
165
|
+
output: { dryRun: true, wouldExecute: visitPath },
|
|
166
|
+
});
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const nodeStartTime = Date.now();
|
|
170
|
+
try {
|
|
171
|
+
// Merge base input with node context
|
|
172
|
+
const visitInput = {
|
|
173
|
+
...(typeof baseInput === "object" ? baseInput : {}),
|
|
174
|
+
cwd: node.repoPath,
|
|
175
|
+
node: {
|
|
176
|
+
name: node.name,
|
|
177
|
+
path: node.repoPath,
|
|
178
|
+
dependencies: node.dependencies,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
// Create executor for hydration that injects cwd into every call
|
|
182
|
+
const executor = async (path, inp) => {
|
|
183
|
+
// Inject cwd into the input so nested procedures run in correct directory
|
|
184
|
+
const inputWithCwd = typeof inp === "object" && inp !== null
|
|
185
|
+
? { ...inp, cwd: node.repoPath }
|
|
186
|
+
: inp;
|
|
187
|
+
return ctx.client.call(path, inputWithCwd);
|
|
188
|
+
};
|
|
189
|
+
// Hydrate the input (execute any nested procedure refs like chain steps)
|
|
190
|
+
// Push "dag.traverse" onto context stack so refs with $when: "dag.traverse" execute
|
|
191
|
+
const hydratedInput = await hydrateInput(visitInput, executor, {
|
|
192
|
+
contextStack: ["dag.traverse"],
|
|
193
|
+
onRef: ctx.onRef,
|
|
194
|
+
// The names of the chain around this procedure: a `$ref` in the visit can read them
|
|
195
|
+
scope: scopeOf(input),
|
|
196
|
+
});
|
|
197
|
+
// Execute visit procedure with hydrated input
|
|
198
|
+
const output = await ctx.client.call(visitPath, hydratedInput);
|
|
199
|
+
results.push({
|
|
200
|
+
name: node.name,
|
|
201
|
+
path: node.repoPath,
|
|
202
|
+
success: true,
|
|
203
|
+
duration: Date.now() - nodeStartTime,
|
|
204
|
+
output,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
const result = {
|
|
209
|
+
name: node.name,
|
|
210
|
+
path: node.repoPath,
|
|
211
|
+
success: false,
|
|
212
|
+
duration: Date.now() - nodeStartTime,
|
|
213
|
+
error: error instanceof Error ? error.message : String(error),
|
|
214
|
+
};
|
|
215
|
+
results.push(result);
|
|
216
|
+
throw error; // Re-throw for DAG executor to handle
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Execute DAG traversal
|
|
220
|
+
const dagResult = await executeDAG(dag, processor, {
|
|
221
|
+
concurrency: input.concurrency ?? 4,
|
|
222
|
+
failFast: !input.continueOnError,
|
|
223
|
+
});
|
|
224
|
+
// If dry run, we already populated results in the processor
|
|
225
|
+
if (!input.dryRun) {
|
|
226
|
+
// Ensure all nodes have results (some may have been skipped due to errors)
|
|
227
|
+
for (const [name, nodeResult] of dagResult.results) {
|
|
228
|
+
const existing = results.find((r) => r.name === name);
|
|
229
|
+
if (!existing) {
|
|
230
|
+
const node = allNodes.get(name);
|
|
231
|
+
const result = {
|
|
232
|
+
name,
|
|
233
|
+
path: node?.repoPath ?? "unknown",
|
|
234
|
+
success: nodeResult.success,
|
|
235
|
+
duration: nodeResult.duration,
|
|
236
|
+
};
|
|
237
|
+
if (nodeResult.error?.message) {
|
|
238
|
+
result.error = nodeResult.error.message;
|
|
239
|
+
}
|
|
240
|
+
results.push(result);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
success: dagResult.success,
|
|
246
|
+
results,
|
|
247
|
+
totalDuration: Date.now() - startTime,
|
|
248
|
+
visited: results.filter((r) => r.success).length,
|
|
249
|
+
failed: results.filter((r) => !r.success).length,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=traverse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../../src/procedures/dag/traverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAO9E,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,SAAS,CAAC;QACR,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO,OAAO,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;QACvF,OAAO,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S,CAAC,OAAO,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAChC,MAAM,MAAM,GAAuB;oBACjC,IAAI;oBACJ,IAAI,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS;oBACjC,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;iBAC9B,CAAC;gBACF,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;oBAC9B,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;gBAC1C,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,OAAO;QACP,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;QACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ecosystem procedures
|
|
3
|
+
*/
|
|
4
|
+
export { ecosystemProcedures } from "./procedures.js";
|
|
5
|
+
export type { EcosystemProceduresInput, EcosystemProceduresOutput, ProcedureInfo, PackageProcedures, } from "./procedures.js";
|
|
6
|
+
export { EcosystemProceduresInputSchema, EcosystemProceduresOutputSchema } from "./procedures.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/ecosystem/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/ecosystem/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,OAAO,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ecosystem.procedures
|
|
3
|
+
*
|
|
4
|
+
* Enumerates all procedures across the ecosystem by:
|
|
5
|
+
* 1. Scanning all packages (lib.scan)
|
|
6
|
+
* 2. Loading each package's procedure registry
|
|
7
|
+
* 3. Aggregating using the collector pattern (pure)
|
|
8
|
+
*
|
|
9
|
+
* This is a composition of dag traversal + procedure discovery.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { ProcedureContext } from "@procedures/client";
|
|
13
|
+
export declare const EcosystemProceduresInputSchema: z.ZodObject<{
|
|
14
|
+
rootPath: z.ZodOptional<z.ZodString>;
|
|
15
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
16
|
+
includeMetadata: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
}>;
|
|
18
|
+
export type EcosystemProceduresInput = z.infer<typeof EcosystemProceduresInputSchema>;
|
|
19
|
+
export interface ProcedureInfo {
|
|
20
|
+
/** Procedure path as array */
|
|
21
|
+
path: string[];
|
|
22
|
+
/** Procedure path as dot-separated key */
|
|
23
|
+
key: string;
|
|
24
|
+
/** Source package */
|
|
25
|
+
package: string;
|
|
26
|
+
/** Package path on disk */
|
|
27
|
+
packagePath: string;
|
|
28
|
+
/** Description from metadata */
|
|
29
|
+
description?: string | undefined;
|
|
30
|
+
/** Tags from metadata */
|
|
31
|
+
tags?: string[] | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface PackageProcedures {
|
|
34
|
+
/** Package name */
|
|
35
|
+
name: string;
|
|
36
|
+
/** Package path */
|
|
37
|
+
path: string;
|
|
38
|
+
/** Procedures defined in this package */
|
|
39
|
+
procedures: ProcedureInfo[];
|
|
40
|
+
/** Whether loading succeeded */
|
|
41
|
+
success: boolean;
|
|
42
|
+
/** Error if loading failed */
|
|
43
|
+
error?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface EcosystemProceduresOutput {
|
|
46
|
+
/** All procedures aggregated */
|
|
47
|
+
procedures: ProcedureInfo[];
|
|
48
|
+
/** Procedures grouped by package */
|
|
49
|
+
byPackage: PackageProcedures[];
|
|
50
|
+
/** Procedures grouped by namespace */
|
|
51
|
+
byNamespace: Record<string, ProcedureInfo[]>;
|
|
52
|
+
/** Summary counts */
|
|
53
|
+
summary: {
|
|
54
|
+
totalPackages: number;
|
|
55
|
+
packagesWithProcedures: number;
|
|
56
|
+
totalProcedures: number;
|
|
57
|
+
namespaces: string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The output schema of ecosystem.procedures (roadmap 2.1). Loose: other fields stay. */
|
|
61
|
+
export declare const EcosystemProceduresOutputSchema: z.ZodType<EcosystemProceduresOutput>;
|
|
62
|
+
export declare function ecosystemProcedures(input: EcosystemProceduresInput, ctx: ProcedureContext): Promise<EcosystemProceduresOutput>;
|
|
63
|
+
//# sourceMappingURL=procedures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../../src/procedures/ecosystem/procedures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,eAAO,MAAM,8BAA8B,EAAE,CAAC,CAAC,SAAS,CAAC;IACvD,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACtC,eAAe,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;CAC7C,CAOC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,KAAK,CAAC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