create-mono-agent 0.5.1

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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # create-mono-agent
2
+
3
+ The unscoped npm-init installer for the mono-agent CLI. It ships two bins —
4
+ `create-mono-agent` and `mono-agent` — each of which delegates every command to
5
+ the CLI that lives in [`@mono-agent/agent-app`](https://www.npmjs.com/package/@mono-agent/agent-app).
6
+
7
+ Three equivalent entry points, one behaviour:
8
+
9
+ - `npm create mono-agent@latest` — npm's `create-*` convention resolves this package (no install).
10
+ - `npx create-mono-agent` — the same, spelled explicitly.
11
+ - `npm i -g create-mono-agent` — a global install that puts the natural `mono-agent` command on your `PATH`.
12
+
13
+ The bare `mono-agent` npm name is unavailable — npm rejects it as too similar to
14
+ an unrelated `monoagent` package — so this installer follows the `create-*`
15
+ convention while still exposing the ergonomic `mono-agent` bin.
16
+
17
+ ## Category
18
+
19
+ Category: `app`
20
+
21
+ This is the catalog's sole `tier: "alias"` package: an unscoped publishable
22
+ installer, not a core package with its own responsibility. It is excluded from the
23
+ core/plugin package counts and carries no library API.
24
+
25
+ ## Responsibility
26
+
27
+ Provide the discoverable, unscoped `create-mono-agent` name on npm so
28
+ `npm create mono-agent`/`npx create-mono-agent` and a global `mono-agent` command
29
+ work, and forward every invocation, unchanged, to `@mono-agent/agent-app`'s
30
+ `mono-agent` CLI. It owns no CLI behaviour of its own.
31
+
32
+ ## Install / Usage
33
+
34
+ ```bash
35
+ # One-off, no install (npm-init convention resolves create-mono-agent):
36
+ npm create mono-agent@latest init
37
+ npx create-mono-agent init
38
+
39
+ # Or install globally for the persistent `mono-agent` command:
40
+ npm i -g create-mono-agent
41
+ mono-agent init
42
+ mono-agent validate
43
+ mono-agent --version
44
+ ```
45
+
46
+ Every command, flag, and exit code is exactly what `@mono-agent/agent-app`
47
+ provides — including interactive shutdown: Ctrl-C on `mono-agent start --foreground`
48
+ runs the same graceful teardown and yields the same exit status as calling
49
+ agent-app's bin directly (the bin forwards signals without double-signalling the
50
+ child; see `delegateSignals`). This package adds nothing but the names. Prefer
51
+ pinning the scoped host directly (`npm i -g @mono-agent/agent-app`) if you don't
52
+ need the installer.
53
+
54
+ ## Public API
55
+
56
+ None. This package exports no library surface; it ships `create-mono-agent` and
57
+ `mono-agent` bins that both delegate to `@mono-agent/agent-app`.
58
+
59
+ ## Dependency Boundary
60
+
61
+ Depends only on `@mono-agent/agent-app` (category `app`) at the same lockstep
62
+ version, resolved at runtime through its published `bin`. It must not depend on
63
+ runtime, communication, memory, observability, or operator-surface packages, and
64
+ it must not reimplement any CLI logic.
65
+
66
+ ## What This Package Does Not Own
67
+
68
+ It does not parse args, load config, run models, scaffold files, or define any
69
+ command — all of that lives in `@mono-agent/agent-app`. It is metadata plus a
70
+ delegating bin, nothing more. If the installer ever needs behaviour, that
71
+ behaviour belongs in `@mono-agent/agent-app`, not here.
72
+
73
+ ## Verification
74
+
75
+ ```bash
76
+ pnpm --filter create-mono-agent run build
77
+ pnpm --filter create-mono-agent run typecheck
78
+ pnpm --filter create-mono-agent run test
79
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=mono-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mono-agent.d.ts","sourceRoot":"","sources":["../../src/bin/mono-agent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { delegateSignals } from "../delegate.js";
4
+ import { resolveAgentAppCliEntry } from "../resolve-agent-app-cli.js";
5
+ /**
6
+ * Delegating bin for the `create-mono-agent` installer. Both of its bin names
7
+ * (`create-mono-agent` and `mono-agent`) point here. It owns no CLI logic of its
8
+ * own: it locates `@mono-agent/agent-app`'s `mono-agent` CLI entry and runs it in a
9
+ * child process with the same args and inherited stdio, so behaviour — output,
10
+ * interactive shutdown, and exit status — is byte-identical to calling
11
+ * `@mono-agent/agent-app`'s own bin directly.
12
+ *
13
+ * Why a child process instead of importing `runCli` in-process: agent-app's
14
+ * `dist/cli.js` auto-runs the CLI when it detects it is the entry module (by
15
+ * `argv[1]` basename), which is exactly what a bin symlink named `mono-agent`
16
+ * looks like under an npm/npx global install. Importing it here would risk a
17
+ * double-run (the auto-run guard AND an explicit call) on some install layouts,
18
+ * and avoiding that would require agent-app to grow a side-effect-free entry —
19
+ * widening its surface. Spawning agent-app's real bin keeps this package pure
20
+ * delegation with zero agent-app changes and one deterministic execution path.
21
+ *
22
+ * Signal/exit fidelity is delegated to `delegateSignals` (see there): the child
23
+ * shares this process group, so Ctrl-C already reaches it; the shim must NOT
24
+ * re-forward group-delivered signals (that would hard-kill a child mid-shutdown),
25
+ * only relay a targeted SIGTERM, and mirror the child's exit code/signal exactly.
26
+ */
27
+ const cliEntry = resolveAgentAppCliEntry();
28
+ const child = spawn(process.execPath, [cliEntry, ...process.argv.slice(2)], { stdio: "inherit" });
29
+ delegateSignals(child, process);
30
+ //# sourceMappingURL=mono-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mono-agent.js","sourceRoot":"","sources":["../../src/bin/mono-agent.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAC;AAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAClG,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ /**
3
+ * The subset of `NodeJS.Process` the delegator touches, named so the wiring is
4
+ * unit-testable with a fake process.
5
+ */
6
+ export interface DelegatorProcess {
7
+ readonly pid: number;
8
+ exitCode?: string | number | null | undefined;
9
+ on(event: NodeJS.Signals, listener: () => void): unknown;
10
+ removeAllListeners(event: NodeJS.Signals): unknown;
11
+ kill(pid: number, signal: NodeJS.Signals): unknown;
12
+ exit(code?: number): never;
13
+ readonly stderr: {
14
+ write(chunk: string): unknown;
15
+ };
16
+ }
17
+ /**
18
+ * Wires a spawned agent-app CLI child to the shim process so exit status and
19
+ * shutdown are byte-identical to invoking agent-app's bin directly:
20
+ *
21
+ * - SIGINT/SIGHUP: inert keep-alive handlers (the group already delivered them to
22
+ * the child); we wait for the child's graceful exit rather than re-signalling.
23
+ * - SIGTERM: forwarded once — a targeted `kill <shim-pid>` reaches only the shim,
24
+ * so the child needs it relayed to shut down gracefully.
25
+ * - child exit by code: mirror the code.
26
+ * - child exit by signal: mirror it by re-raising on ourselves, first removing our
27
+ * own handler for that signal so the re-raise actually terminates us (otherwise
28
+ * our keep-alive handler catches it and we'd exit 0 instead of 128+signum).
29
+ */
30
+ export declare function delegateSignals(child: Pick<ChildProcess, "on" | "kill">, proc: DelegatorProcess): void;
31
+ //# sourceMappingURL=delegate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../src/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;IACzD,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACnD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACnD,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACpD;AAaD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAuBtG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Signals the terminal delivers to the ENTIRE foreground process group. Because
3
+ * the delegated child is spawned into this same group (inherited stdio, not
4
+ * detached), it already receives these directly — so the shim must NOT forward a
5
+ * second copy, which would land on a child that has already removed its own
6
+ * handler and started an async shutdown, hard-killing it mid-teardown (no channel
7
+ * teardown, no trace flush, no memory-DB close). The shim installs inert handlers
8
+ * only, to stay alive until the child's own graceful shutdown drives our exit.
9
+ */
10
+ const GROUP_DELIVERED_SIGNALS = ["SIGINT", "SIGHUP"];
11
+ /**
12
+ * Wires a spawned agent-app CLI child to the shim process so exit status and
13
+ * shutdown are byte-identical to invoking agent-app's bin directly:
14
+ *
15
+ * - SIGINT/SIGHUP: inert keep-alive handlers (the group already delivered them to
16
+ * the child); we wait for the child's graceful exit rather than re-signalling.
17
+ * - SIGTERM: forwarded once — a targeted `kill <shim-pid>` reaches only the shim,
18
+ * so the child needs it relayed to shut down gracefully.
19
+ * - child exit by code: mirror the code.
20
+ * - child exit by signal: mirror it by re-raising on ourselves, first removing our
21
+ * own handler for that signal so the re-raise actually terminates us (otherwise
22
+ * our keep-alive handler catches it and we'd exit 0 instead of 128+signum).
23
+ */
24
+ export function delegateSignals(child, proc) {
25
+ for (const signal of GROUP_DELIVERED_SIGNALS) {
26
+ proc.on(signal, () => {
27
+ // Intentionally inert: the child owns the shutdown; we await its exit.
28
+ });
29
+ }
30
+ proc.on("SIGTERM", () => {
31
+ child.kill("SIGTERM");
32
+ });
33
+ child.on("error", (error) => {
34
+ proc.stderr.write(`mono-agent: failed to launch the @mono-agent/agent-app CLI: ${error.message}\n`);
35
+ proc.exitCode = 1;
36
+ });
37
+ child.on("exit", (code, signal) => {
38
+ if (signal !== null) {
39
+ proc.removeAllListeners(signal);
40
+ proc.kill(proc.pid, signal);
41
+ return;
42
+ }
43
+ proc.exit(code ?? 0);
44
+ });
45
+ }
46
+ //# sourceMappingURL=delegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.js","sourceRoot":"","sources":["../src/delegate.ts"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwC,EAAE,IAAsB;IAC9F,KAAK,MAAM,MAAM,IAAI,uBAAuB,EAAE,CAAC;QAC7C,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACnB,uEAAuE;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACtB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+DAA+D,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACpG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,MAA6B,EAAE,EAAE;QACtE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Resolves the absolute path of `@mono-agent/agent-app`'s `mono-agent` CLI entry
3
+ * from the installed dependency's own `package.json` `bin` field.
4
+ *
5
+ * Reading the `bin` path from the manifest (rather than hardcoding `dist/cli.js`)
6
+ * means this survives any install layout — npm/npx global, pnpm-linked — and any
7
+ * future change to agent-app's bin location. We resolve it through CJS
8
+ * `require.resolve` of `@mono-agent/agent-app/package.json` (which agent-app
9
+ * exports), so this works on every Node ≥20 without depending on the newer
10
+ * synchronous `import.meta.resolve` (Node 20.6+).
11
+ */
12
+ export declare function resolveAgentAppCliEntry(from?: string | URL): string;
13
+ //# sourceMappingURL=resolve-agent-app-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-agent-app-cli.d.ts","sourceRoot":"","sources":["../src/resolve-agent-app-cli.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,MAAM,GAAG,GAAqB,GAAG,MAAM,CAkBpF"}
@@ -0,0 +1,32 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname, resolve } from "node:path";
3
+ /**
4
+ * Resolves the absolute path of `@mono-agent/agent-app`'s `mono-agent` CLI entry
5
+ * from the installed dependency's own `package.json` `bin` field.
6
+ *
7
+ * Reading the `bin` path from the manifest (rather than hardcoding `dist/cli.js`)
8
+ * means this survives any install layout — npm/npx global, pnpm-linked — and any
9
+ * future change to agent-app's bin location. We resolve it through CJS
10
+ * `require.resolve` of `@mono-agent/agent-app/package.json` (which agent-app
11
+ * exports), so this works on every Node ≥20 without depending on the newer
12
+ * synchronous `import.meta.resolve` (Node 20.6+).
13
+ */
14
+ export function resolveAgentAppCliEntry(from = import.meta.url) {
15
+ const require = createRequire(from);
16
+ let manifestPath;
17
+ try {
18
+ manifestPath = require.resolve("@mono-agent/agent-app/package.json");
19
+ }
20
+ catch (error) {
21
+ const reason = error instanceof Error ? error.message : String(error);
22
+ throw new Error(`the create-mono-agent installer could not find @mono-agent/agent-app (its CLI host) — reinstall it (\`npm i -g create-mono-agent\`). (${reason})`);
23
+ }
24
+ const manifest = require("@mono-agent/agent-app/package.json");
25
+ const bin = manifest.bin;
26
+ const relative = typeof bin === "string" ? bin : bin?.["mono-agent"];
27
+ if (typeof relative !== "string" || relative.length === 0) {
28
+ throw new Error("@mono-agent/agent-app does not declare a `mono-agent` bin; cannot delegate.");
29
+ }
30
+ return resolve(dirname(manifestPath), relative);
31
+ }
32
+ //# sourceMappingURL=resolve-agent-app-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-agent-app-cli.js","sourceRoot":"","sources":["../src/resolve-agent-app-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAM7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAqB,MAAM,CAAC,IAAI,CAAC,GAAG;IAC1E,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,YAAoB,CAAC;IACzB,IAAI,CAAC;QACH,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAC;IACvE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,KAAK,CACb,yIAAyI,MAAM,GAAG,CACnJ,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,oCAAoC,CAAqB,CAAC;IACnF,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACzB,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;IACrE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "create-mono-agent",
3
+ "version": "0.5.1",
4
+ "description": "npm-init style installer for the mono-agent CLI: `npm create mono-agent`. Ships both a `create-mono-agent` and a `mono-agent` bin, each delegating to the @mono-agent/agent-app CLI.",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "private": false,
8
+ "bin": {
9
+ "create-mono-agent": "./dist/bin/mono-agent.js",
10
+ "mono-agent": "./dist/bin/mono-agent.js"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "dependencies": {
17
+ "@mono-agent/agent-app": "0.5.1"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "typecheck": "tsc -p tsconfig.json --noEmit",
25
+ "test": "vitest run --passWithNoTests"
26
+ }
27
+ }