@procedures/lib 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 +74 -0
- package/README.md +13 -43
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli-flags.d.ts +2 -0
- package/dist/cli-flags.d.ts.map +1 -1
- package/dist/cli-flags.js +12 -0
- package/dist/cli-flags.js.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +6 -51
- package/dist/module.js.map +1 -1
- package/dist/procedures/lib/audit.d.ts +15 -2
- package/dist/procedures/lib/audit.d.ts.map +1 -1
- package/dist/procedures/lib/audit.js +32 -4
- package/dist/procedures/lib/audit.js.map +1 -1
- package/dist/types.d.ts +17 -58
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -92
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cli-flags.ts +14 -0
- package/src/module.ts +5 -61
- package/src/procedures/lib/audit.ts +34 -4
- package/src/types.ts +30 -150
- package/dist/procedures/core/catch.d.ts +0 -33
- package/dist/procedures/core/catch.d.ts.map +0 -1
- package/dist/procedures/core/catch.js +0 -118
- package/dist/procedures/core/catch.js.map +0 -1
- package/dist/procedures/core/index.d.ts +0 -9
- package/dist/procedures/core/index.d.ts.map +0 -1
- package/dist/procedures/core/index.js +0 -8
- package/dist/procedures/core/index.js.map +0 -1
- package/dist/procedures/dag/index.d.ts +0 -5
- package/dist/procedures/dag/index.d.ts.map +0 -1
- package/dist/procedures/dag/index.js +0 -5
- package/dist/procedures/dag/index.js.map +0 -1
- package/dist/procedures/dag/traverse.d.ts +0 -54
- package/dist/procedures/dag/traverse.d.ts.map +0 -1
- package/dist/procedures/dag/traverse.js +0 -252
- package/dist/procedures/dag/traverse.js.map +0 -1
- package/src/procedures/core/catch.ts +0 -142
- package/src/procedures/core/index.ts +0 -9
- package/src/procedures/dag/index.ts +0 -5
- package/src/procedures/dag/traverse.ts +0 -281
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @procedures/lib
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a47bee6: The hosts can confine the file procedures to a root (roadmap R33).
|
|
8
|
+
|
|
9
|
+
- `confineFsProcedures(registry, root)` of `@procedures/fs` replaces the handler of each `fs.*` procedure of a registry with the handler of `createFsModule({ root })`. It adds no procedure. A nested `fs.*` call of another procedure is confined too. The root must be a folder that exists.
|
|
10
|
+
- `mark --fs-root <folder>` confines the `fs.*` procedures of each mode and host of `mark`: a command, the REPL, `--server`, `serve` and `mcp`. Give the flag before the command.
|
|
11
|
+
- A `mark` command uses a CLI server only when the server has the same root. The lockfile of `@procedures/peer` has the new field `fsRoot`, and `findServer()` compares it.
|
|
12
|
+
- `procedure-server --fs-root <folder>` and `mark serve --fs-root <folder>` confine the procedures of the server.
|
|
13
|
+
- The MCP server reads `MCP_FS_ROOT`, and `mark mcp` has the flag `--fs-root`. `fs` is not a tool namespace, so the tools do not change.
|
|
14
|
+
- A path outside the root gives `FORBIDDEN` with the reason `outside-root`. A procedure that reads files with `node:fs`, or that starts a program, is not confined.
|
|
15
|
+
- `@procedures/lib/cli-flags` has the global flags `--fs-root` and `--events`, and the field `repeatable`.
|
|
16
|
+
- 64120d9: `lib.audit` reports each procedure without `metadata.effects`. A host with a capability refuses such a procedure.
|
|
17
|
+
|
|
18
|
+
- The output has the new list `procedureIssues`. Each issue has the kind `missing-effects`, the procedure path (for example `git.status`) and a message.
|
|
19
|
+
- The issues are warnings. They do not change `success`, so the audit step of CI does not fail for them. CI shows each one as a warning annotation.
|
|
20
|
+
- The audit examines the procedures of the registry of the host, as it does for `flagNotices`. It imports no package code, so its effects do not change.
|
|
21
|
+
- `mark` loads its registry from the built `./module` entry of each package. Thus the audit does not examine a package without a build.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [0f75644]
|
|
26
|
+
- Updated dependencies [09e5566]
|
|
27
|
+
- Updated dependencies [ab77f75]
|
|
28
|
+
- Updated dependencies [01e5b1f]
|
|
29
|
+
- Updated dependencies [da56027]
|
|
30
|
+
- Updated dependencies [a47bee6]
|
|
31
|
+
- Updated dependencies [a47bee6]
|
|
32
|
+
- Updated dependencies [bc74091]
|
|
33
|
+
- @procedures/client@0.5.0
|
|
34
|
+
- @procedures/dag@0.5.0
|
|
35
|
+
- @procedures/git@0.5.0
|
|
36
|
+
- @procedures/fs@0.5.0
|
|
37
|
+
- @procedures/pnpm@0.5.0
|
|
38
|
+
- @procedures/shell@0.5.0
|
|
39
|
+
|
|
40
|
+
## 0.4.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- 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.
|
|
45
|
+
|
|
46
|
+
`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.
|
|
47
|
+
|
|
48
|
+
`DagTraverseInputSchema`, `DagTraverseInput`, `DagTraverseOutput` and `TraverseNodeResult` are exports of `@procedures/dag`, not of `@procedures/lib`.
|
|
49
|
+
- 3fefa43: `core.catch` is removed. Use `client.tryCatch`.
|
|
50
|
+
|
|
51
|
+
`core.catch` did the same as `client.tryCatch` of `@procedures/client`. `CoreCatchInputSchema`, `CoreCatchInput`, `CoreCatchOutput` and `CoreCatchOutputSchema` are removed too. `client.tryCatch` gives no context name: a call of its `try` or `catch` operand needs no `$when: "catch"`.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [d919678]
|
|
56
|
+
- Updated dependencies [057d69a]
|
|
57
|
+
- Updated dependencies [b2a1a1e]
|
|
58
|
+
- Updated dependencies [057d69a]
|
|
59
|
+
- Updated dependencies [057d69a]
|
|
60
|
+
- Updated dependencies [057d69a]
|
|
61
|
+
- Updated dependencies [057d69a]
|
|
62
|
+
- Updated dependencies [057d69a]
|
|
63
|
+
- Updated dependencies [afd6a19]
|
|
64
|
+
- Updated dependencies [057d69a]
|
|
65
|
+
- Updated dependencies [2fd2398]
|
|
66
|
+
- Updated dependencies [3d76cb7]
|
|
67
|
+
- Updated dependencies [0ecc788]
|
|
68
|
+
- Updated dependencies [4c51727]
|
|
69
|
+
- Updated dependencies [4e751da]
|
|
70
|
+
- @procedures/client@0.4.0
|
|
71
|
+
- @procedures/dag@0.4.0
|
|
72
|
+
- @procedures/fs@0.4.0
|
|
73
|
+
- @procedures/git@0.4.0
|
|
74
|
+
- @procedures/shell@0.4.0
|
|
75
|
+
- @procedures/pnpm@0.4.0
|
|
76
|
+
|
|
3
77
|
## 0.3.0
|
|
4
78
|
|
|
5
79
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
npm install @procedures/lib
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
`client-lib` gives the procedures that manage the packages of the monorepo
|
|
9
|
+
`client-lib` gives the procedures that manage the packages of the monorepo.
|
|
10
10
|
|
|
11
11
|
| Procedure | Function |
|
|
12
12
|
|---|---|
|
|
@@ -16,11 +16,14 @@ npm install @procedures/lib
|
|
|
16
16
|
| `lib.rename` | Rename a package in each file of the workspace |
|
|
17
17
|
| `lib.graph` | Give the dependency graph of the workspace packages, with its cycles |
|
|
18
18
|
| `ecosystem.procedures` | List the procedures of the packages |
|
|
19
|
-
| `dag.traverse` | Start a procedure for each package, in the order of their dependencies |
|
|
20
|
-
| `core.catch` | Start a deferred call, and give the error to a handler call |
|
|
21
19
|
|
|
22
20
|
Until October 2026, `client-lib` also had `lib.install`, `lib.pull` and `lib.refresh`, for one repository per package. The monorepo does not need them, and they are gone ([DECISIONS-2026-10.md](../documentation/DECISIONS-2026-10.md)).
|
|
23
21
|
|
|
22
|
+
In version 0.3.0 and before, `client-lib` also had two runners of programs:
|
|
23
|
+
|
|
24
|
+
- `dag.traverse` moved to [`client-dag`](../client-dag) (`@procedures/dag`), with the same name. It gets the packages from `lib.scan` of this package. Thus a host registers the two modules.
|
|
25
|
+
- `core.catch` is removed. It did the same as `client.tryCatch` of `@procedures/client`. Use `client.tryCatch`.
|
|
26
|
+
|
|
24
27
|
## Use
|
|
25
28
|
|
|
26
29
|
```typescript
|
|
@@ -67,6 +70,12 @@ Input: `rootPath` and `fix`. For each package, the output gives the files and th
|
|
|
67
70
|
|
|
68
71
|
The output also has `flagNotices`: the procedure flags whose short form is also a global flag of `mark`. After the command path, the flag of the procedure wins (deep dive CLI-7).
|
|
69
72
|
|
|
73
|
+
The output also has `procedureIssues`. It has one issue of the kind `missing-effects` for each procedure without `metadata.effects`. A host with a capability refuses such a procedure. `procedure new` writes no effects, so the author writes them.
|
|
74
|
+
|
|
75
|
+
- The issues are warnings. They do not change `success`, so the audit step of CI does not fail for them.
|
|
76
|
+
- The audit examines the procedures of the registry of the host. It does not import the code of a package.
|
|
77
|
+
- `mark` loads its registry from the built `./module` entry of each package. Thus start `pnpm build` before the audit. The audit does not examine a package without a build.
|
|
78
|
+
|
|
70
79
|
## `lib.rename`
|
|
71
80
|
|
|
72
81
|
Input: `oldName`, `newName`, `rootPath` and `dryRun`. The procedure changes the package name, the dependencies, the imports and the dynamic imports in the workspace. The output lists each change and gives a summary.
|
|
@@ -89,47 +98,8 @@ node packages/mark/dist/cli.js lib graph
|
|
|
89
98
|
|
|
90
99
|
Input: `rootPath`, `namespace` and `includeMetadata`. The output lists the procedures of the packages that have a `client.procedures` field.
|
|
91
100
|
|
|
92
|
-
## `dag.traverse`
|
|
93
|
-
|
|
94
|
-
`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.
|
|
95
|
-
|
|
96
|
-
| Field | Default | Function |
|
|
97
|
-
|---|---|---|
|
|
98
|
-
| `visit` | | A procedure path, or a call with `$when: "$parent"` (or `$never`) |
|
|
99
|
-
| `filter` | | Only these package names |
|
|
100
|
-
| `root` | | Only this package and the packages that it depends on |
|
|
101
|
-
| `rootPath` | the workspace | The workspace root |
|
|
102
|
-
| `concurrency` | 4 | The number of visits at the same time |
|
|
103
|
-
| `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` |
|
|
104
|
-
| `continueOnError` | false | Continue after a failed visit |
|
|
105
|
-
| `dryRun` | false | Give the plan only |
|
|
106
|
-
|
|
107
|
-
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).
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
await client.exec(["dag", "traverse"], {
|
|
111
|
-
visit: { $proc: ["pnpm", "run"], input: { script: "build" }, $when: "$parent" },
|
|
112
|
-
root: "@procedures/fs",
|
|
113
|
-
});
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
`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. A call in `visit` with `$when: "dag.traverse"` waits for this runner ([PROGRAM-FORMAT.md](../documentation/PROGRAM-FORMAT.md), section 5).
|
|
117
|
-
|
|
118
|
-
## `core.catch`
|
|
119
|
-
|
|
120
|
-
`core.catch` starts the `try` call. When it fails, `core.catch` starts the `handler` call with the error in its input (`success: false`, `error`, `proc`). Give both calls `$when: "catch"`, so that they wait for this runner.
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
await client.exec(["core", "catch"], {
|
|
124
|
-
try: { $proc: ["git", "commit"], input: { message: "auto" }, $when: "catch" },
|
|
125
|
-
handler: { $proc: ["client", "identity"], input: { value: { continue: true } }, $when: "catch" },
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
The output gives `success`, `result`, `error` and `continue`. The calls of the `try` input start inside the error handling (deep dive DATA-22).
|
|
130
|
-
|
|
131
101
|
## Related packages
|
|
132
102
|
|
|
133
|
-
- `client-dag`: the graph algorithms of `dag.traverse`.
|
|
103
|
+
- `client-dag`: the graph algorithms of `lib.graph`, and the procedure `dag.traverse`, which uses `lib.scan`.
|
|
134
104
|
- `client-procedure`: `procedure.new`, the scaffold of a procedure.
|
|
135
105
|
- `mark`: the CLI that starts these procedures.
|