@procedures/dag 0.3.0 → 0.5.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 +44 -0
- package/README.md +49 -25
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +24 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +55 -0
- package/dist/module.js.map +1 -0
- package/dist/procedures/traverse.d.ts +69 -0
- package/dist/procedures/traverse.d.ts.map +1 -0
- package/dist/procedures/traverse.js +267 -0
- package/dist/procedures/traverse.js.map +1 -0
- package/dist/procedures/types.d.ts +86 -0
- package/dist/procedures/types.d.ts.map +1 -0
- package/dist/procedures/types.js +74 -0
- package/dist/procedures/types.js.map +1 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +10 -0
- package/dist/register.js.map +1 -0
- package/package.json +20 -3
- package/src/index.ts +15 -0
- package/src/module.ts +76 -0
- package/src/procedures/traverse.ts +306 -0
- package/src/procedures/types.ts +152 -0
- package/src/register.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @procedures/dag
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 01e5b1f: `dag.traverse` reports the packages that it did not visit. A failed visit stops the traversal after its level when `continueOnError` is false. Before, the output did not list the packages of the later levels.
|
|
8
|
+
|
|
9
|
+
- Each package without a visit has a result with `skipped: true`, `success: false`, `duration: 0` and a `reason`. These results come after the results of the visits, in dependency order.
|
|
10
|
+
- The output has the new count `skipped`. `failed` counts only the visits that failed.
|
|
11
|
+
- The loop that "ensured a result for each node" is removed. It could not add a result, because each visit records its own result.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [0f75644]
|
|
16
|
+
- Updated dependencies [09e5566]
|
|
17
|
+
- Updated dependencies [ab77f75]
|
|
18
|
+
- Updated dependencies [a47bee6]
|
|
19
|
+
- Updated dependencies [bc74091]
|
|
20
|
+
- @procedures/client@0.5.0
|
|
21
|
+
|
|
22
|
+
## 0.4.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- 2fd2398: `dag.traverse` moved from `@procedures/lib` to `@procedures/dag`. Its name, input, output and effects stay the same. In this version, `@procedures/dag` has a `./module` entry, a `./register` entry and the `client.procedures` field, and it depends on `@procedures/client` and `zod`. The graph algorithms of its root do not change.
|
|
27
|
+
|
|
28
|
+
`dag.traverse` gets the packages from `lib.scan` through `ctx.client` (`calls: ["lib.scan"]`). `@procedures/lib` depends on `@procedures/dag`, so the module of `@procedures/dag` does not list the module of `@procedures/lib` as a dependency: a host registers the two modules. `bundle-dev`, `bundle-mcp` and `mark` do. The module of `@procedures/lib` does not register `dag.traverse` any more.
|
|
29
|
+
|
|
30
|
+
`DagTraverseInputSchema`, `DagTraverseInput`, `DagTraverseOutput` and `TraverseNodeResult` are exports of `@procedures/dag`, not of `@procedures/lib`.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [d919678]
|
|
35
|
+
- Updated dependencies [057d69a]
|
|
36
|
+
- Updated dependencies [b2a1a1e]
|
|
37
|
+
- Updated dependencies [057d69a]
|
|
38
|
+
- Updated dependencies [057d69a]
|
|
39
|
+
- Updated dependencies [057d69a]
|
|
40
|
+
- Updated dependencies [057d69a]
|
|
41
|
+
- Updated dependencies [057d69a]
|
|
42
|
+
- Updated dependencies [afd6a19]
|
|
43
|
+
- Updated dependencies [057d69a]
|
|
44
|
+
- Updated dependencies [4e751da]
|
|
45
|
+
- @procedures/client@0.4.0
|
|
46
|
+
|
|
3
47
|
## 0.3.0
|
|
4
48
|
|
|
5
49
|
No changes in this release.
|
package/README.md
CHANGED
|
@@ -382,7 +382,7 @@ graph LR
|
|
|
382
382
|
|
|
383
383
|
### Package Build Order
|
|
384
384
|
|
|
385
|
-
Build packages in dependency order (`dag.traverse` of
|
|
385
|
+
Build packages in dependency order (the procedure `dag.traverse` of this package does this):
|
|
386
386
|
|
|
387
387
|
```typescript
|
|
388
388
|
const packages = [
|
|
@@ -439,20 +439,56 @@ await executeDAG(dag, async (mod) => {
|
|
|
439
439
|
|
|
440
440
|
## Integration
|
|
441
441
|
|
|
442
|
-
###
|
|
442
|
+
### The procedure `dag.traverse`
|
|
443
|
+
|
|
444
|
+
The package has one procedure, `dag.traverse`. It came from `client-lib` in version 0.4.0, and its name stays the same. The graph algorithms of the package root do not need it.
|
|
445
|
+
|
|
446
|
+
`dag.traverse` starts the `visit` procedure once for each package, with `cwd` set to the folder of the package. A package starts after the packages that it depends on.
|
|
447
|
+
|
|
448
|
+
| Field | Default | Function |
|
|
449
|
+
|---|---|---|
|
|
450
|
+
| `visit` | | A procedure path, or a call with `$when: "$parent"` (or `$never`) |
|
|
451
|
+
| `filter` | | Only these package names |
|
|
452
|
+
| `root` | | Only this package and the packages that it depends on |
|
|
453
|
+
| `rootPath` | the workspace | The workspace root |
|
|
454
|
+
| `concurrency` | 4 | The number of visits at the same time |
|
|
455
|
+
| `serialize` | `auto` | When the visits in one git repository start one at a time: `auto` (when the visit uses a `git` procedure), `repository` (always) or `none` |
|
|
456
|
+
| `continueOnError` | false | Continue after a failed visit |
|
|
457
|
+
| `dryRun` | false | Give the plan only |
|
|
458
|
+
|
|
459
|
+
All packages of the monorepo are in one git repository. Concurrent `git add` commands fail on `index.lock`, so `auto` starts git visits one at a time (deep dive DATA-17).
|
|
460
|
+
|
|
461
|
+
The output has one result for each package of the graph. A failed visit stops the traversal after its level when `continueOnError` is false. Each package that the traversal did not visit then has a result with `skipped: true`, `success: false` and a `reason`. These results come after the results of the visits. `visited` counts the visits that succeeded, `failed` counts the visits that failed, and `skipped` counts the packages without a visit.
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
|
|
465
|
+
import "@procedures/lib/register"; // lib.scan, and the fs and git procedures that it uses
|
|
466
|
+
import "@procedures/dag/register"; // dag.traverse
|
|
443
467
|
|
|
444
|
-
|
|
468
|
+
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
|
|
469
|
+
|
|
470
|
+
await client.exec(["dag", "traverse"], {
|
|
471
|
+
visit: { $proc: ["pnpm", "run"], input: { script: "build" }, $when: "$parent" },
|
|
472
|
+
root: "@procedures/fs",
|
|
473
|
+
});
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
- `dag.traverse` gets the packages from `lib.scan` of `@procedures/lib`, through `ctx.client`. Its metadata declares the call (`calls: ["lib.scan"]`).
|
|
477
|
+
- `@procedures/lib` depends on this package. Thus this package does not import `@procedures/lib`, and the module of this package does not list the module of `@procedures/lib` as a dependency. A host registers the two modules. `bundle-dev`, `bundle-mcp` and `mark` do.
|
|
478
|
+
- `dag.traverse` has the tag `runs-refs`: it starts the refs of its input. Thus a server with an `expose` rule lets it use only exposed procedures, `lib.scan` too.
|
|
479
|
+
- A call in `visit` with `$when: "dag.traverse"` waits for this runner ([PROGRAM-FORMAT.md](../documentation/PROGRAM-FORMAT.md), section 5).
|
|
480
|
+
- `bundle-mcp` registers the procedure, but `dag` is not a tool namespace of the MCP server.
|
|
445
481
|
|
|
446
482
|
```mermaid
|
|
447
483
|
graph TB
|
|
448
|
-
subgraph "client-
|
|
449
|
-
Scan[lib.scan<br/>Discover packages]
|
|
484
|
+
subgraph "client-dag"
|
|
450
485
|
Traverse[dag.traverse<br/>Visit in dependency order]
|
|
486
|
+
Build[buildLeveledDAG]
|
|
487
|
+
Execute[executeDAG]
|
|
451
488
|
end
|
|
452
489
|
|
|
453
|
-
subgraph "client-
|
|
454
|
-
|
|
455
|
-
Execute[executeDAG]
|
|
490
|
+
subgraph "client-lib"
|
|
491
|
+
Scan[lib.scan<br/>Find the packages]
|
|
456
492
|
end
|
|
457
493
|
|
|
458
494
|
subgraph "Packages"
|
|
@@ -461,36 +497,24 @@ graph TB
|
|
|
461
497
|
P3[Package C]
|
|
462
498
|
end
|
|
463
499
|
|
|
464
|
-
|
|
500
|
+
Traverse -->|ctx.client| Scan
|
|
501
|
+
Traverse --> Build
|
|
465
502
|
Build --> Execute
|
|
466
|
-
Traverse --> Execute
|
|
467
503
|
Execute --> P1
|
|
468
504
|
Execute --> P2
|
|
469
505
|
Execute --> P3
|
|
470
506
|
```
|
|
471
507
|
|
|
472
|
-
###
|
|
473
|
-
|
|
474
|
-
The `dag.traverse` procedure in `client-lib` wraps this functionality:
|
|
475
|
-
|
|
476
|
-
```typescript
|
|
477
|
-
// Via procedure
|
|
478
|
-
await client.exec(["dag", "traverse"], {
|
|
479
|
-
visit: ["pnpm", "install"],
|
|
480
|
-
concurrency: 4,
|
|
481
|
-
});
|
|
508
|
+
### With client-lib
|
|
482
509
|
|
|
483
|
-
|
|
484
|
-
const dag = buildDAG(packages);
|
|
485
|
-
await executeDAG(dag, processor);
|
|
486
|
-
```
|
|
510
|
+
`client-lib` uses the algorithms of this package for `lib.graph`.
|
|
487
511
|
|
|
488
512
|
---
|
|
489
513
|
|
|
490
514
|
## Requirements
|
|
491
515
|
|
|
492
516
|
- **Node.js** >= 22
|
|
493
|
-
- **Dependencies:**
|
|
517
|
+
- **Dependencies:** `@procedures/client` and `zod`, for the procedure. The graph algorithms use neither.
|
|
494
518
|
|
|
495
519
|
---
|
|
496
520
|
|