nylorun 0.19.0-beta → 0.20.0-beta
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 +53 -0
- package/README.md +155 -11
- package/dist/cli.js +29 -5
- package/dist/client/agents.d.ts +18 -0
- package/dist/client/agents.js +2 -2
- package/dist/client/apply-agent.d.ts +14 -0
- package/dist/client/apply-agent.js +71 -0
- package/dist/client/apply.d.ts +9 -2
- package/dist/client/apply.js +62 -25
- package/dist/client/chat.d.ts +8 -0
- package/dist/client/chat.js +145 -0
- package/dist/client/convert.d.ts +18 -0
- package/dist/client/convert.js +195 -0
- package/dist/client/folder.d.ts +6 -8
- package/dist/client/folder.js +116 -38
- package/dist/client/init.d.ts +21 -0
- package/dist/client/init.js +210 -0
- package/dist/client/migrate.js +8 -2
- package/dist/client/plan-diff.d.ts +14 -0
- package/dist/client/plan-diff.js +86 -0
- package/dist/client/watch.d.ts +23 -0
- package/dist/client/watch.js +87 -0
- package/dist/nylo.js +2 -2
- package/dist/stack/versions.d.ts +2 -0
- package/dist/stack/versions.js +12 -0
- package/package.json +6 -6
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nylorun apply --watch [--save]` (track T7, design §6): checks the folders and plans their
|
|
3
|
+
* manifests at once, then again on each change to them (debounced), until interrupted. It saves
|
|
4
|
+
* only with `--save`: each save is a new immutable version that moves the Agents tracking the
|
|
5
|
+
* name, so `--watch --save` is for a development manifest. A cycle that fails (a Runtime that
|
|
6
|
+
* refuses, a folder that does not pack) prints why and the watch goes on. The file a
|
|
7
|
+
* `runtime.json` `extends` is watched too.
|
|
8
|
+
*/
|
|
9
|
+
import { watch as watchFiles } from "node:fs";
|
|
10
|
+
import { relative, resolve } from "node:path";
|
|
11
|
+
import { applyCommand } from "./apply.js";
|
|
12
|
+
import { agentFolders, checkCommand, packed } from "./folder.js";
|
|
13
|
+
/** `node:fs` `watch`, recursive for a folder. */
|
|
14
|
+
export const nodeWatcher = (paths, onChange) => {
|
|
15
|
+
const watchers = paths.map((path) => watchFiles(path, { recursive: true }, (_event, file) => onChange(file ? resolve(path, String(file)) : path)));
|
|
16
|
+
return { close: () => watchers.forEach((watcher) => watcher.close()) };
|
|
17
|
+
};
|
|
18
|
+
/** What changes that never start a cycle: version control and dependencies. */
|
|
19
|
+
const QUIET = /(^|[\\/])(\.git|node_modules|\.hg|\.svn)([\\/]|$)/;
|
|
20
|
+
/**
|
|
21
|
+
* Checks and plans `dirs` (apply's other flags in `args`) now and on each change, saving with
|
|
22
|
+
* `save`, until the signal ends it.
|
|
23
|
+
*/
|
|
24
|
+
export async function watchApply(deps, run, options = {}) {
|
|
25
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
26
|
+
const dirs = run.dirs.length > 0 ? run.dirs : ["."];
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const signal = options.signal ?? controller.signal;
|
|
29
|
+
const stop = () => controller.abort();
|
|
30
|
+
if (!options.signal) {
|
|
31
|
+
process.once("SIGINT", stop);
|
|
32
|
+
process.once("SIGTERM", stop);
|
|
33
|
+
}
|
|
34
|
+
const cycle = async () => {
|
|
35
|
+
try {
|
|
36
|
+
if ((await checkCommand(deps, dirs)) === 0)
|
|
37
|
+
await applyCommand(deps, run.args, { planOnly: !run.save, checked: true });
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
deps.err(error instanceof Error ? error.message : String(error));
|
|
41
|
+
}
|
|
42
|
+
deps.out(`Watching ${dirs.join(", ")} for changes${run.save ? ", saving each" : ""} (Ctrl-C stops).`);
|
|
43
|
+
};
|
|
44
|
+
// The folders, and the files their runtime.json extends.
|
|
45
|
+
const paths = new Set(dirs.map((dir) => resolve(cwd, dir)));
|
|
46
|
+
for (const dir of dirs)
|
|
47
|
+
for (const folder of await agentFolders(resolve(cwd, dir)).catch(() => []))
|
|
48
|
+
for (const file of (await packed(folder).catch(() => undefined))?.extended ?? [])
|
|
49
|
+
paths.add(file);
|
|
50
|
+
let running = cycle();
|
|
51
|
+
let timer;
|
|
52
|
+
let changed;
|
|
53
|
+
const watcher = (options.watcher ?? nodeWatcher)([...paths], (path) => {
|
|
54
|
+
if (QUIET.test(path))
|
|
55
|
+
return;
|
|
56
|
+
changed = path;
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
timer = setTimeout(() => {
|
|
59
|
+
const what = changed;
|
|
60
|
+
running = running.then(async () => {
|
|
61
|
+
if (signal.aborted)
|
|
62
|
+
return;
|
|
63
|
+
deps.out("");
|
|
64
|
+
deps.out(`${what === undefined ? "A file" : relative(cwd, what) || "."} changed: checking again.`);
|
|
65
|
+
await cycle();
|
|
66
|
+
});
|
|
67
|
+
}, options.debounceMs ?? 200);
|
|
68
|
+
});
|
|
69
|
+
try {
|
|
70
|
+
await new Promise((done) => {
|
|
71
|
+
if (signal.aborted)
|
|
72
|
+
done();
|
|
73
|
+
else
|
|
74
|
+
signal.addEventListener("abort", () => done(), { once: true });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
clearTimeout(timer);
|
|
79
|
+
watcher.close();
|
|
80
|
+
if (!options.signal) {
|
|
81
|
+
process.off("SIGINT", stop);
|
|
82
|
+
process.off("SIGTERM", stop);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
await running;
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
package/dist/nylo.js
CHANGED
|
@@ -3,7 +3,7 @@ import "./baseline.js";
|
|
|
3
3
|
import { runCommand } from "./command.js";
|
|
4
4
|
import { CliError } from "./errors.js";
|
|
5
5
|
/**
|
|
6
|
-
* `nylo` became part of `nylorun`. Until
|
|
6
|
+
* `nylo` became part of `nylorun`. Until a later release removes it, this command names the
|
|
7
7
|
* `nylorun` command that replaces each of its own and exits 2.
|
|
8
8
|
*/
|
|
9
9
|
const REPLACEMENTS = {
|
|
@@ -18,7 +18,7 @@ function nyloMessage(argv) {
|
|
|
18
18
|
const replacement = REPLACEMENTS[argv[0] ?? ""];
|
|
19
19
|
return `${replacement
|
|
20
20
|
? `nylo is part of nylorun now: nylo ${argv[0]} is ${replacement}.`
|
|
21
|
-
: "nylo is part of nylorun now: run nylorun --help."} nylorun
|
|
21
|
+
: "nylo is part of nylorun now: run nylorun --help."} A later nylorun release removes nylo.`;
|
|
22
22
|
}
|
|
23
23
|
runCommand(async () => {
|
|
24
24
|
throw new CliError(nyloMessage(process.argv.slice(2)), 2);
|
package/dist/stack/versions.d.ts
CHANGED
package/dist/stack/versions.js
CHANGED
|
@@ -6,6 +6,18 @@ function cliPackageJsonPath() {
|
|
|
6
6
|
// src/stack/*.ts and dist/stack/*.js both sit two levels below the package root.
|
|
7
7
|
return join(dirname(fileURLToPath(import.meta.url)), "..", "..", "package.json");
|
|
8
8
|
}
|
|
9
|
+
/** This CLI's version, from its `package.json` (`nylorun --version`). */
|
|
10
|
+
export function cliVersion() {
|
|
11
|
+
try {
|
|
12
|
+
const version = JSON.parse(readFileSync(cliPackageJsonPath(), "utf8")).version;
|
|
13
|
+
if (typeof version === "string")
|
|
14
|
+
return version;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw new CliError(`Cannot read CLI package.json: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
18
|
+
}
|
|
19
|
+
throw new CliError("nylorun's package.json has no version.", 1);
|
|
20
|
+
}
|
|
9
21
|
/**
|
|
10
22
|
* The version this CLI release pins for an image, from its `package.json`
|
|
11
23
|
* `nylorun.runtime` or `nylorun.studio`: the tag of `ghcr.io/nylorun/<name>`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nylorun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Set up and run local Nylorun Tenants (Runtime and Studio) with Docker Compose, and act on a Tenant through its Runtime and Management APIs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"prepack": "npm run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nylorun/admin": "0.19.
|
|
34
|
-
"@nylorun/agents": "0.
|
|
35
|
-
"@nylorun/core": "0.
|
|
33
|
+
"@nylorun/admin": "0.19.4-beta",
|
|
34
|
+
"@nylorun/agents": "0.28.0-beta",
|
|
35
|
+
"@nylorun/core": "0.28.0-beta"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@earendil-works/pi-ai": "1.2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"nylo": "dist/nylo.js"
|
|
47
47
|
},
|
|
48
48
|
"nylorun": {
|
|
49
|
-
"runtime": "0.
|
|
50
|
-
"studio": "0.
|
|
49
|
+
"runtime": "0.32.0-beta",
|
|
50
|
+
"studio": "0.32.0-beta"
|
|
51
51
|
}
|
|
52
52
|
}
|