@plurnk/plurnk-execs 0.4.1 → 0.4.3
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/SPEC.md +2 -2
- package/dist/discover.d.ts.map +1 -1
- package/dist/discover.js +30 -7
- package/dist/discover.js.map +1 -1
- package/package.json +1 -1
package/SPEC.md
CHANGED
|
@@ -95,7 +95,7 @@ The envelope is mirrored locally (`TelemetryEvent`, `ContentOffset`, `LogCoordin
|
|
|
95
95
|
|
|
96
96
|
## §3 Discovery
|
|
97
97
|
|
|
98
|
-
`discover(options?) → { registry }`. Scans `<cwd>/node_modules
|
|
98
|
+
`discover(options?) → { registry }`. Scans **every installed package** under `<cwd>/node_modules` — scope-agnostic (scoped and unscoped) — for those declaring `plurnk.kind === "exec"`, and registers each runtime tag from `plurnk.runtimes[]`. The scan is deliberately not limited to `@plurnk/*`: a **third party** can publish an executor under their own scope (`@acme/acme-execs-foo`) and have it discovered with no involvement from this project. (For the batteries-included set, an aggregator package — `@plurnk/plurnk-execs-all` — depends on the framework's daughters flat so one install surfaces them all; the framework itself stays contract-only.)
|
|
99
99
|
|
|
100
100
|
```json
|
|
101
101
|
{
|
|
@@ -131,7 +131,7 @@ interface SpawnArgs { cmd: string; args: string[]; useShell: boolean; }
|
|
|
131
131
|
|
|
132
132
|
`resolveRuntime` never throws; consumers gate unknown runtimes with `isKnownRuntime` and return 501 before invoking.
|
|
133
133
|
|
|
134
|
-
The framework wraps this in **`SubprocessExecutor extends BaseExecutor`** — declares `{ stdout, stderr }` channels and implements `run()` (spawn via `resolveRuntime`, stream into the channels, honor `signal`, `emit` `spawn_failed` on a failed start, return `{ status, exitCode }`). Subclasses with their own interpreter table override the **`protected spawnArgs(runtime, command) → SpawnArgs`** hook (default delegates to `resolveRuntime`) — and so inherit run()'s streaming + process-group abort handling. `SpawnArgs.stdin?` lets filter-style runtimes feed their program/input via stdin (`bc`, `tclsh`; or `""` for an `awk` BEGIN with EOF). On abort it kills the whole **process group** (`detached` spawn + `process.kill(-pid, …)`, SIGTERM→SIGKILL grace) so shell grandchildren can't leak (plurnk-execs#4). The `plurnk-execs-
|
|
134
|
+
The framework wraps this in **`SubprocessExecutor extends BaseExecutor`** — declares `{ stdout, stderr }` channels and implements `run()` (spawn via `resolveRuntime`, stream into the channels, honor `signal`, `emit` `spawn_failed` on a failed start, return `{ status, exitCode }`). Subclasses with their own interpreter table override the **`protected spawnArgs(runtime, command) → SpawnArgs`** hook (default delegates to `resolveRuntime`) — and so inherit run()'s streaming + process-group abort handling. `SpawnArgs.stdin?` lets filter-style runtimes feed their program/input via stdin (`bc`, `tclsh`; or `""` for an `awk` BEGIN with EOF). On abort it kills the whole **process group** (`detached` spawn + `process.kill(-pid, …)`, SIGTERM→SIGKILL grace) so shell grandchildren can't leak (plurnk-execs#4). The `plurnk-execs-common` sibling subclasses it — claiming the whole subprocess set (sh/bash/node/python plus detected host interpreters) via a recipe table behind a `spawnArgs()` / `probe()` override. `isKnownRuntime` / `KNOWN_RUNTIMES` are the legacy 501 gate; the discovery registry + `probe()` supersede them once a consumer wires the registry.
|
|
135
135
|
|
|
136
136
|
## §5 Consumer surface (plurnk-service)
|
|
137
137
|
|
package/dist/discover.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAY,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAY,MAAM,YAAY,CAAC;AAoBvE,wBAAsB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAkBhF"}
|
package/dist/discover.js
CHANGED
|
@@ -3,8 +3,10 @@ import path from "node:path";
|
|
|
3
3
|
// Scan installed executor packages and build the runtime-tag registry the
|
|
4
4
|
// consuming scheme dispatches on. Parallel to plurnk-mimetypes' discover().
|
|
5
5
|
//
|
|
6
|
-
// Default scan target: `<cwd>/node_modules
|
|
7
|
-
//
|
|
6
|
+
// Default scan target: every installed package under `<cwd>/node_modules` —
|
|
7
|
+
// scope-agnostic, so third-party executors (`@acme/foo`) are discovered too,
|
|
8
|
+
// not just `@plurnk/*`. Tests and unusual layouts can pass `packageDirs`
|
|
9
|
+
// explicitly to skip the scan.
|
|
8
10
|
//
|
|
9
11
|
// A package is recognized as an executor when its `package.json` declares
|
|
10
12
|
// `plurnk.kind === "exec"` and exposes one or more runtime tags via
|
|
@@ -31,18 +33,39 @@ export async function discover(options = {}) {
|
|
|
31
33
|
}
|
|
32
34
|
return { registry };
|
|
33
35
|
}
|
|
36
|
+
// Enumerate every installed package directory — scoped (`@scope/name`) and
|
|
37
|
+
// unscoped (`name`) — under `<cwd>/node_modules`. The scan is scope-agnostic so
|
|
38
|
+
// a THIRD PARTY can publish an executor under their own scope (`@acme/foo`) and
|
|
39
|
+
// have it discovered with no involvement from us; `readExecInfos` keeps only the
|
|
40
|
+
// packages that declare `plurnk.kind === "exec"`.
|
|
34
41
|
async function defaultPackageDirs(cwd) {
|
|
35
|
-
const
|
|
42
|
+
const nm = path.join(cwd, "node_modules");
|
|
36
43
|
let entries;
|
|
37
44
|
try {
|
|
38
|
-
entries = await fs.readdir(
|
|
45
|
+
entries = await fs.readdir(nm, { withFileTypes: true });
|
|
39
46
|
}
|
|
40
47
|
catch {
|
|
41
48
|
return [];
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
50
|
+
const dirs = [];
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
if (!entry.isDirectory() || entry.name === ".bin" || entry.name === ".cache")
|
|
53
|
+
continue;
|
|
54
|
+
if (entry.name.startsWith("@")) {
|
|
55
|
+
const scopeDir = path.join(nm, entry.name);
|
|
56
|
+
try {
|
|
57
|
+
const scoped = await fs.readdir(scopeDir, { withFileTypes: true });
|
|
58
|
+
for (const s of scoped)
|
|
59
|
+
if (s.isDirectory())
|
|
60
|
+
dirs.push(path.join(scopeDir, s.name));
|
|
61
|
+
}
|
|
62
|
+
catch { /* unreadable scope dir — skip */ }
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
dirs.push(path.join(nm, entry.name));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return dirs;
|
|
46
69
|
}
|
|
47
70
|
// Produce one ExecInfo per declared runtime tag. Returns [] for non-executor
|
|
48
71
|
// packages or invalid declarations.
|
package/dist/discover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,0EAA0E;AAC1E,4EAA4E;AAC5E,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,0EAA0E;AAC1E,4EAA4E;AAC5E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,yEAAyE;AACzE,+BAA+B;AAC/B,EAAE;AACF,0EAA0E;AAC1E,oEAAoE;AACpE,4EAA4E;AAC5E,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,iCAAiC;AACjC,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,UAA2B,EAAE;IACxD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,kBAAkB,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE3F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|
|
4
4
|
"description": "Framework + contract for the @plurnk/plurnk-execs-* runtime executor family.",
|
|
5
5
|
"keywords": ["plurnk", "exec", "runtime", "executor"],
|
|
6
6
|
"homepage": "https://github.com/plurnk/plurnk-execs#readme",
|