@procedures/mark 0.22.1 → 0.24.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 +72 -0
- package/README.md +49 -12
- package/dist/.tsbuildinfo +1 -1
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +4 -1
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +37 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +157 -78
- package/dist/cli.js.map +1 -1
- package/dist/client-mode.d.ts +26 -4
- package/dist/client-mode.d.ts.map +1 -1
- package/dist/client-mode.js +54 -33
- package/dist/client-mode.js.map +1 -1
- package/dist/command.d.ts +115 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +110 -0
- package/dist/command.js.map +1 -0
- package/dist/manifest.json +2 -2
- package/dist/server-mode.d.ts +2 -1
- package/dist/server-mode.d.ts.map +1 -1
- package/dist/server-mode.js +5 -4
- package/dist/server-mode.js.map +1 -1
- package/package.json +50 -49
- package/src/bin.ts +4 -1
- package/src/cli.ts +183 -79
- package/src/client-mode.ts +73 -38
- package/src/command.ts +181 -0
- package/src/server-mode.ts +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
# @procedures/mark
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4261f65: Breaking: each `mark` command starts under `run()` of `@mark1russell7/service` (CLI-26, decision D17). The cold mode runs the procedures host of the CLI server in its own process. The runner owns the signals, the stop in stages and the exit. Thus the exit codes of a signal change. The release before this one marked the old behaviors as deprecated.
|
|
8
|
+
|
|
9
|
+
The new behavior:
|
|
10
|
+
|
|
11
|
+
- Each `mark` command that runs a procedure is a service of one request, with the profile `ephemeral`. `mark` has no signal handler and no `process.exit` of its own in this path. `interruptSignal()` is gone.
|
|
12
|
+
- The cold mode (no CLI server in this folder, or `--local`): the host has the same registry and policy as `mark --server` (`markHostOptions()`), and no listener, port, token or lockfile. The client sends each call through the local face of the host.
|
|
13
|
+
- `localFace()` of `@procedures/peer` is new. It gives a face factory and a transport of `@procedures/client`. A `Client` on the transport sends its calls to the host of the same process, through the request tracking of the service, with `LOCAL_CREDENTIALS`.
|
|
14
|
+
- A first Ctrl-C starts the stop, and the drain aborts the call at once.
|
|
15
|
+
- The warm mode: the call to the CLI server gets the abort signal. A Ctrl-C aborts the call on the server too. Before, the signal ended `mark`, and the server continued the call.
|
|
16
|
+
- After the command, the runner ends the process with the exit code of the command. A timer or a socket that a procedure left open does not keep the process alive.
|
|
17
|
+
- `run()` and `main()` of `@procedures/mark` get the optional options `run` (the options of `run()`: the process port and the clock) and `ownsProcess`. The bin gives `ownsProcess: true`. Without it, a program keeps its process: no signal handler, and the exit code goes to `process.exitCode`.
|
|
18
|
+
- `CliContext` gets the optional field `registry`. `executeArgs()` does not use `ctx.client` for a command any more.
|
|
19
|
+
- A program that calls `run()` or `executeArgs()` without a port, and the REPL (`mark -i`), get no signal handler for a command.
|
|
20
|
+
|
|
21
|
+
The exit codes, in the cold mode and in the warm mode:
|
|
22
|
+
|
|
23
|
+
| Event | Before | From this release |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| The command ends without a failure | 0 | 0 |
|
|
26
|
+
| The command fails | 1 | 1 |
|
|
27
|
+
| The first Ctrl-C, cold mode | 1 | 130 |
|
|
28
|
+
| The first Ctrl-C, warm mode | the signal ended the process (the shell showed 130) | 130 |
|
|
29
|
+
| `SIGTERM` | the signal ended the process (the shell showed 143) | 143 |
|
|
30
|
+
| A second signal during the stop, cold mode | 130 | 1 |
|
|
31
|
+
|
|
32
|
+
A cold `mark server create` keeps its peer only until the end of the command. Before, the peer kept the process alive after the command.
|
|
33
|
+
|
|
34
|
+
Migration:
|
|
35
|
+
|
|
36
|
+
- A script that reads the exit code of an interrupted `mark` command: read 130 for a Ctrl-C, also in the cold mode. Read 1 for a second signal.
|
|
37
|
+
- A script that starts `mark server create` as a server in the foreground: start `mark --server` or `procedure-server` in its place.
|
|
38
|
+
- A program that calls `run()`, `main()` or `executeArgs()` of `@procedures/mark`: no change. It keeps its process. Give `ownsProcess: true` to give the process to the runner, as the bin does.
|
|
39
|
+
- The site: no change. It does not start `mark`.
|
|
40
|
+
- MiniMongo: no change. Its dev host starts through `runProcedureHost()`, not through `mark`.
|
|
41
|
+
- Graph: no change. It does not start `mark`.
|
|
42
|
+
- jarvis: no change, unless a script of jarvis reads the exit code of an interrupted `mark` command. Then apply the first step.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [4261f65]
|
|
47
|
+
- @procedures/peer@0.24.0
|
|
48
|
+
- @procedures/server@0.24.0
|
|
49
|
+
- @procedures/client@0.24.0
|
|
50
|
+
- @procedures/cli-run@0.24.0
|
|
51
|
+
- @procedures/lib@0.24.0
|
|
52
|
+
- @procedures/pnpm@0.24.0
|
|
53
|
+
- @procedures/procedure@0.24.0
|
|
54
|
+
- @procedures/shell@0.24.0
|
|
55
|
+
- @procedures/vitest@0.24.0
|
|
56
|
+
- @procedures/mcp-dev-tools@0.24.0
|
|
57
|
+
|
|
58
|
+
## 0.23.0
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [f20beb1]
|
|
63
|
+
- Updated dependencies [71091a5]
|
|
64
|
+
- @procedures/client@0.23.0
|
|
65
|
+
- @procedures/peer@0.23.0
|
|
66
|
+
- @procedures/mcp-dev-tools@0.23.0
|
|
67
|
+
- @procedures/cli-run@0.23.0
|
|
68
|
+
- @procedures/lib@0.23.0
|
|
69
|
+
- @procedures/pnpm@0.23.0
|
|
70
|
+
- @procedures/procedure@0.23.0
|
|
71
|
+
- @procedures/shell@0.23.0
|
|
72
|
+
- @procedures/vitest@0.23.0
|
|
73
|
+
- @procedures/server@0.23.0
|
|
74
|
+
|
|
3
75
|
## 0.22.1
|
|
4
76
|
|
|
5
77
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ graph TB
|
|
|
45
45
|
|
|
46
46
|
subgraph "Execution Layer"
|
|
47
47
|
REGISTRY[Procedure Registry]
|
|
48
|
-
TRANSPORT[Local
|
|
48
|
+
TRANSPORT["Local face of the host"]
|
|
49
49
|
CLIENT[Client]
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -145,13 +145,32 @@ The bin is `dist/bin.js`. `node dist/cli.js` also runs the CLI. Importing `@proc
|
|
|
145
145
|
|
|
146
146
|
| Command | Host | Notes |
|
|
147
147
|
|---|---|---|
|
|
148
|
-
| `mark <command>` | This process | The registry has the module of each workspace package with `client.procedures`. |
|
|
148
|
+
| `mark <command>` | This process (the cold mode), or the CLI server (the warm mode) | The registry has the module of each workspace package with `client.procedures`. In the two modes, the command starts under `run()` of `@mark1russell7/service`. |
|
|
149
149
|
| `mark --server` | The CLI server | The same registry, on `127.0.0.1`, with a token in the lockfile. A later `mark` command in the same folder uses it. |
|
|
150
150
|
| `mark serve` | The procedure server | The options of the `procedure-server` command. A package of `--procedures` resolves from the current folder, then from the folder of `mark`. A token is necessary by default. |
|
|
151
151
|
| `mark mcp` | The dev-tools MCP server, over stdio | The server of Claude Code's MCP configuration. stdout holds only protocol lines, and `mark mcp --help` writes to stderr. |
|
|
152
152
|
|
|
153
153
|
`mark mcp <procedure>` runs an `mcp.*` procedure (for example `mark mcp listTools`), not the server. Each host gets its policy from `hostPolicy()` of `@procedures/client`.
|
|
154
154
|
|
|
155
|
+
#### The cold mode and the warm mode
|
|
156
|
+
|
|
157
|
+
Each command that runs a procedure is a service of one request (CLI-26, decision D17). The runner of `@mark1russell7/service` owns the signals, the stop in stages and the exit. `mark` installs no signal handler of its own.
|
|
158
|
+
|
|
159
|
+
- **The warm mode.** A CLI server (`mark --server`) of this build operates in this folder, with the same `--fs-root`. The command goes to the server over HTTP.
|
|
160
|
+
- **The cold mode.** No such server operates, or the command has `--local`. The procedures host of the CLI server then operates in this process, with the same registry and policy. It has no port, no token and no lockfile.
|
|
161
|
+
- **The profile.** The service has the profile `ephemeral`: no checks, no probes, and a flush of the output before the exit.
|
|
162
|
+
- **Ctrl-C.** A first Ctrl-C starts the stop. The drain aborts the call at once: a shell command stops its process tree, and a stream ends. In the warm mode, the server aborts the call too. Before, the server continued it.
|
|
163
|
+
- **A second Ctrl-C.** A second signal during the stop ends the process at once, with the exit code 1.
|
|
164
|
+
- **The exit.** After the command, the runner ends the process with the exit code of the command. A timer or a socket that a procedure left open does not keep the process alive.
|
|
165
|
+
- **The REPL.** `mark -i` starts each line in the cold mode, without the signals: the REPL keeps its process.
|
|
166
|
+
|
|
167
|
+
```mermaid
|
|
168
|
+
graph LR
|
|
169
|
+
CMD[mark command] --> SVC["service of the command<br/>run(), profile ephemeral"]
|
|
170
|
+
SVC -->|warm| HTTP[HttpTransport + signal] --> SERVER["CLI server<br/>runProcedureHost, daemon"]
|
|
171
|
+
SVC -->|cold| FACE["localFace()"] --> HOST["the same host<br/>in this process"]
|
|
172
|
+
```
|
|
173
|
+
|
|
155
174
|
#### Remote events of the hosts
|
|
156
175
|
|
|
157
176
|
`mark --server` and `mark serve` always serve the procedure `events.subscribe` ([EVENTS.md](../documentation/EVENTS.md)):
|
|
@@ -234,15 +253,24 @@ A procedure reports a failure in one of three ways:
|
|
|
234
253
|
|
|
235
254
|
For a streaming procedure, `mark` examines each item. One failed item makes the command fail.
|
|
236
255
|
|
|
237
|
-
|
|
256
|
+
The exit codes of a command, since the MINOR of CLI-26. A signal stops a command through the runner:
|
|
257
|
+
|
|
258
|
+
| Event | Cold mode | Warm mode |
|
|
259
|
+
|---|---|---|
|
|
260
|
+
| The command ends without a failure | 0 | 0 |
|
|
261
|
+
| The command fails | 1 | 1 |
|
|
262
|
+
| The first `SIGINT` (Ctrl-C) | 130 | 130 |
|
|
263
|
+
| `SIGTERM` | 143 | 143 |
|
|
264
|
+
| `SIGQUIT` | 131 | 131 |
|
|
265
|
+
| A second signal during the stop | 1 | 1 |
|
|
238
266
|
|
|
239
|
-
The
|
|
267
|
+
The cold mode is a command in this process: no CLI server operates in this folder, or the command has `--local`. The MINOR of CLI-26 changed three behaviors. The release before it marked them as deprecated:
|
|
240
268
|
|
|
241
|
-
- **The first Ctrl-C in the cold mode.**
|
|
242
|
-
- **A second signal.**
|
|
243
|
-
- **`mark server create` in the cold mode.**
|
|
269
|
+
- **The first Ctrl-C in the cold mode.** Before, the aborted command gave the exit code 1. The runner gives 130.
|
|
270
|
+
- **A second signal.** Before, a second Ctrl-C in the cold mode gave the exit code 130. The runner gives 1.
|
|
271
|
+
- **`mark server create` in the cold mode.** Before, the peer of the command kept the process alive after the command. The peer stops at the end of the command. For a server in the foreground, use `mark --server` or `procedure-server`.
|
|
244
272
|
|
|
245
|
-
|
|
273
|
+
Before CLI-26, a signal in the warm mode ended the process, and the server continued the call. The shell showed 130 or 143. The runner gives the same codes, after the server aborts the call.
|
|
246
274
|
|
|
247
275
|
#### Examples
|
|
248
276
|
|
|
@@ -271,7 +299,7 @@ mark --verbose lib new my-pkg
|
|
|
271
299
|
|
|
272
300
|
### Programmatic API
|
|
273
301
|
|
|
274
|
-
#### `run(argv: string[]): Promise<void>`
|
|
302
|
+
#### `run(argv: string[], options?): Promise<void>`
|
|
275
303
|
|
|
276
304
|
Main CLI entry point.
|
|
277
305
|
|
|
@@ -282,6 +310,10 @@ import { run } from "@procedures/mark";
|
|
|
282
310
|
await run(["lib", "new", "my-package"]);
|
|
283
311
|
```
|
|
284
312
|
|
|
313
|
+
- By default, the program keeps its process. A command installs no signal handler, does not end the process, and sets `process.exitCode`.
|
|
314
|
+
- `ownsProcess: true` gives the process to the runner of each command, as the bin does. The runner then owns the signals, and it ends the process with the exit code of the command.
|
|
315
|
+
- `run` gives the options of `run()` of `@mark1russell7/service`: the process port and the clock. A test gives `fakeProcess()` of `@mark1russell7/service/testing`.
|
|
316
|
+
|
|
285
317
|
#### `parseFromSchema(params, meta, schema?): Record<string, unknown>`
|
|
286
318
|
|
|
287
319
|
Parse CLI arguments based on procedure metadata. With the schema, each value is converted by the type of its field. `parseCommandLine(argv, procedures)` splits a whole command line: the global flags, the path and the input.
|
|
@@ -641,19 +673,24 @@ packages/client-lib/
|
|
|
641
673
|
|
|
642
674
|
### Transport Layer
|
|
643
675
|
|
|
676
|
+
In the cold mode, the client sends each call to the procedures host of this process through `localFace()` of `@procedures/peer` (CLI-26). In the warm mode, the client sends each call to the CLI server through `HttpTransport`.
|
|
677
|
+
|
|
644
678
|
```mermaid
|
|
645
679
|
graph LR
|
|
646
680
|
CLI[CLI]
|
|
647
681
|
CLIENT[Client]
|
|
648
|
-
TRANSPORT[
|
|
682
|
+
TRANSPORT["localFace() transport"]
|
|
683
|
+
HOST["ProcedureServer of the host<br/>(request tracking of the service)"]
|
|
649
684
|
REGISTRY[ProcedureRegistry]
|
|
650
685
|
HANDLER[Procedure Handler]
|
|
651
686
|
|
|
652
687
|
CLI --> CLIENT
|
|
653
688
|
CLIENT --> TRANSPORT
|
|
654
|
-
TRANSPORT -->
|
|
689
|
+
TRANSPORT --> HOST
|
|
690
|
+
HOST --> REGISTRY
|
|
655
691
|
REGISTRY --> HANDLER
|
|
656
|
-
HANDLER -->
|
|
692
|
+
HANDLER --> HOST
|
|
693
|
+
HOST --> TRANSPORT
|
|
657
694
|
TRANSPORT --> CLIENT
|
|
658
695
|
CLIENT --> CLI
|
|
659
696
|
|