@ken-jo/agent-connector 0.4.93 → 0.4.94
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 +7 -10
- package/dist/{action-DOWHWEDZ.js → action-VW5SACXY.js} +2 -2
- package/dist/{chunk-OEADFFKO.js → chunk-TQRLMA2C.js} +17 -17
- package/dist/chunk-TQRLMA2C.js.map +1 -0
- package/dist/cli/sdk.d.ts +53 -12
- package/dist/cli/sdk.js +79 -11
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/{detect-DYQNUMXL.js → detect-P5OA5UYM.js} +2 -2
- package/dist/{doctor-H6XXAR63.js → doctor-2O2Q6MIB.js} +2 -2
- package/dist/{hook-GIQTUDMN.js → hook-4N3BMKIK.js} +2 -2
- package/dist/{install-T27662FW.js → install-NPN77N3S.js} +2 -2
- package/dist/{leaderboard-CIMQBOUS.js → leaderboard-QKB36OBR.js} +2 -2
- package/dist/{package-LIPZKHAQ.js → package-Q6DV5247.js} +2 -2
- package/dist/{serve-ABTO2NA2.js → serve-MJTTXDX4.js} +2 -2
- package/dist/{status-J7SOUH7O.js → status-Q3UY4NZU.js} +2 -2
- package/dist/{telemetry-EICCFEIF.js → telemetry-JHVRDDNK.js} +2 -2
- package/dist/{uninstall-NJNNZZZY.js → uninstall-H2SOV3AP.js} +2 -2
- package/dist/{upgrade-TIBUOQNM.js → upgrade-UCSG7L5U.js} +2 -2
- package/dist/{usage-VEVBWPLS.js → usage-4EGIJ4TM.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-OEADFFKO.js.map +0 -1
- /package/dist/{action-DOWHWEDZ.js.map → action-VW5SACXY.js.map} +0 -0
- /package/dist/{detect-DYQNUMXL.js.map → detect-P5OA5UYM.js.map} +0 -0
- /package/dist/{doctor-H6XXAR63.js.map → doctor-2O2Q6MIB.js.map} +0 -0
- /package/dist/{hook-GIQTUDMN.js.map → hook-4N3BMKIK.js.map} +0 -0
- /package/dist/{install-T27662FW.js.map → install-NPN77N3S.js.map} +0 -0
- /package/dist/{leaderboard-CIMQBOUS.js.map → leaderboard-QKB36OBR.js.map} +0 -0
- /package/dist/{package-LIPZKHAQ.js.map → package-Q6DV5247.js.map} +0 -0
- /package/dist/{serve-ABTO2NA2.js.map → serve-MJTTXDX4.js.map} +0 -0
- /package/dist/{status-J7SOUH7O.js.map → status-Q3UY4NZU.js.map} +0 -0
- /package/dist/{telemetry-EICCFEIF.js.map → telemetry-JHVRDDNK.js.map} +0 -0
- /package/dist/{uninstall-NJNNZZZY.js.map → uninstall-H2SOV3AP.js.map} +0 -0
- /package/dist/{upgrade-TIBUOQNM.js.map → upgrade-UCSG7L5U.js.map} +0 -0
- /package/dist/{usage-VEVBWPLS.js.map → usage-4EGIJ4TM.js.map} +0 -0
package/README.md
CHANGED
|
@@ -189,25 +189,22 @@ npx @ken-jo/agent-connector install --method marketplace --connector ./agent-con
|
|
|
189
189
|
### Ship a branded CLI
|
|
190
190
|
|
|
191
191
|
A connector developer can ship their **own** bin instead of having users type
|
|
192
|
-
`agent-connector`. `createConnectorCli({
|
|
193
|
-
`@ken-jo/agent-connector/cli` export)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
install/doctor/uninstall. See
|
|
192
|
+
`agent-connector`. `createConnectorCli({ packageJson, connector })` (from the
|
|
193
|
+
`@ken-jo/agent-connector/cli` export) derives the bin name/version from
|
|
194
|
+
`package.json` and exposes **every** subcommand under your brand, fully
|
|
195
|
+
delegated and **auto-scoped** to your connector — so your users do not need a
|
|
196
|
+
framework global install or `--connector` for branded MCP install/doctor/uninstall. See
|
|
197
197
|
[`examples/branded-cli`](examples/branded-cli) for the full, runnable package.
|
|
198
198
|
|
|
199
199
|
```js
|
|
200
200
|
#!/usr/bin/env node
|
|
201
201
|
// bin.mjs — every agent-connector subcommand, branded as `acme-db`
|
|
202
|
-
import { fileURLToPath } from "node:url";
|
|
203
202
|
import { createConnectorCli } from "@ken-jo/agent-connector/cli";
|
|
204
203
|
|
|
205
204
|
// run() resolves to the exit code and never calls process.exit
|
|
206
205
|
process.exitCode = await createConnectorCli({
|
|
207
|
-
|
|
208
|
-
connector:
|
|
209
|
-
new URL("./agent-connector.config.mjs", import.meta.url),
|
|
210
|
-
),
|
|
206
|
+
packageJson: new URL("./package.json", import.meta.url),
|
|
207
|
+
connector: new URL("./agent-connector.config.mjs", import.meta.url),
|
|
211
208
|
}).run();
|
|
212
209
|
```
|
|
213
210
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TQRLMA2C.js";
|
|
5
5
|
import {
|
|
6
6
|
runAction
|
|
7
7
|
} from "./chunk-EHP7WISI.js";
|
|
@@ -52,4 +52,4 @@ async function run(argv) {
|
|
|
52
52
|
export {
|
|
53
53
|
run
|
|
54
54
|
};
|
|
55
|
-
//# sourceMappingURL=action-
|
|
55
|
+
//# sourceMappingURL=action-VW5SACXY.js.map
|
|
@@ -460,23 +460,23 @@ function renderInstallResult(result, verb) {
|
|
|
460
460
|
return lines.join("\n");
|
|
461
461
|
}
|
|
462
462
|
var COMMANDS = {
|
|
463
|
-
detect: () => import("./detect-
|
|
464
|
-
install: () => import("./install-
|
|
465
|
-
uninstall: () => import("./uninstall-
|
|
463
|
+
detect: () => import("./detect-P5OA5UYM.js"),
|
|
464
|
+
install: () => import("./install-NPN77N3S.js"),
|
|
465
|
+
uninstall: () => import("./uninstall-H2SOV3AP.js"),
|
|
466
466
|
// `upgrade` is the single "bring everything current" verb (re-render host
|
|
467
467
|
// config + refresh the home pointer + managed channel guidance). `sync` and
|
|
468
468
|
// `update` are kept as back-compat aliases that route to the same module so
|
|
469
469
|
// existing scripts/docs keep working without a second concept to learn.
|
|
470
|
-
upgrade: () => import("./upgrade-
|
|
471
|
-
sync: () => import("./upgrade-
|
|
472
|
-
update: () => import("./upgrade-
|
|
473
|
-
package: () => import("./package-
|
|
474
|
-
doctor: () => import("./doctor-
|
|
475
|
-
status: () => import("./status-
|
|
476
|
-
telemetry: () => import("./telemetry-
|
|
477
|
-
usage: () => import("./usage-
|
|
478
|
-
leaderboard: () => import("./leaderboard-
|
|
479
|
-
hook: () => import("./hook-
|
|
470
|
+
upgrade: () => import("./upgrade-UCSG7L5U.js"),
|
|
471
|
+
sync: () => import("./upgrade-UCSG7L5U.js"),
|
|
472
|
+
update: () => import("./upgrade-UCSG7L5U.js"),
|
|
473
|
+
package: () => import("./package-Q6DV5247.js"),
|
|
474
|
+
doctor: () => import("./doctor-2O2Q6MIB.js"),
|
|
475
|
+
status: () => import("./status-Q3UY4NZU.js"),
|
|
476
|
+
telemetry: () => import("./telemetry-JHVRDDNK.js"),
|
|
477
|
+
usage: () => import("./usage-4EGIJ4TM.js"),
|
|
478
|
+
leaderboard: () => import("./leaderboard-QKB36OBR.js"),
|
|
479
|
+
hook: () => import("./hook-4N3BMKIK.js"),
|
|
480
480
|
// Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's
|
|
481
481
|
// status line config points at. Fail-safe: always exits 0 with at most a
|
|
482
482
|
// rendered line. See cli/commands/statusline.ts.
|
|
@@ -484,8 +484,8 @@ var COMMANDS = {
|
|
|
484
484
|
// Internal (omitted from USAGE): the user-invokable action entrypoint a future
|
|
485
485
|
// host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),
|
|
486
486
|
// unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.
|
|
487
|
-
action: () => import("./action-
|
|
488
|
-
serve: () => import("./serve-
|
|
487
|
+
action: () => import("./action-VW5SACXY.js"),
|
|
488
|
+
serve: () => import("./serve-MJTTXDX4.js"),
|
|
489
489
|
// Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an
|
|
490
490
|
// AfterModel / PostInvocation hook points at. Always exits 0; records a
|
|
491
491
|
// distinct `model_turn` row. See cli/commands/usage-event.ts.
|
|
@@ -541,7 +541,7 @@ async function main(argv, opts = {}) {
|
|
|
541
541
|
return command == null ? 1 : 0;
|
|
542
542
|
}
|
|
543
543
|
if (command === "--version" || command === "-v") {
|
|
544
|
-
print(`${programName} ${resolveOwnVersion()}`);
|
|
544
|
+
print(`${programName} ${opts.programVersion ?? resolveOwnVersion()}`);
|
|
545
545
|
return 0;
|
|
546
546
|
}
|
|
547
547
|
const loader = COMMANDS[command];
|
|
@@ -587,4 +587,4 @@ export {
|
|
|
587
587
|
renderInstallResult,
|
|
588
588
|
main
|
|
589
589
|
};
|
|
590
|
-
//# sourceMappingURL=chunk-
|
|
590
|
+
//# sourceMappingURL=chunk-TQRLMA2C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/app.ts","../src/cli/banner.ts"],"sourcesContent":["/**\n * cli/app — shared CLI helpers + command dispatch (NO side effects).\n *\n * Command modules import the shared helpers (print, fail, parse-flags,\n * renderInstallResult) from here, and main() dispatches the first positional to a\n * command module.\n * This module never auto-runs — `cli/index.ts` is the thin bin entry that calls\n * `main()`. Keeping the auto-run out of here is what prevents a dispatch recursion\n * (a command module importing a helper must not re-trigger the program) and makes\n * it robust to bundler entry-splitting (the old import.meta.url entry-guard broke\n * once tsup hoisted this code into a shared chunk).\n */\n\nimport { createRequire } from \"node:module\";\nimport { homedir } from \"node:os\";\n\nimport { PALETTES, renderBrandBanner, resolveColorMode, shouldShowBanner } from \"./banner.js\";\nimport type {\n ChangeRecord,\n ConnectorSummary,\n InstallResult,\n InstallScope,\n PlatformId,\n ResolvedConnector,\n} from \"../core/types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Shared helpers (imported by the command modules)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Print a line to stdout (machine-readable payloads must stay on stdout). */\nexport function print(line: string): void {\n process.stdout.write(`${line}\\n`);\n}\n\n/**\n * The brand active for THIS invocation. main() sets it from\n * {@link MainOptions.programName} before dispatch, so error messages printed by\n * command modules via {@link fail} read as the embedding tool (e.g. `acme-db:`)\n * instead of always `agent-connector:`.\n */\nlet activeProgramName = \"agent-connector\";\n\n/** Print an error to stderr (branded) and return a non-zero exit code (default 2). */\nexport function fail(message: string, code = 2): number {\n process.stderr.write(`${activeProgramName}: ${message}\\n`);\n return code;\n}\n\n/**\n * The brand active for THIS invocation (what the banner renders in ASCII art).\n * main() sets it from {@link MainOptions.programName} before dispatch; reading it\n * here keeps the banner branded for an embedding SDK CLI without each command\n * module needing the program name threaded through.\n */\nexport function getActiveProgramName(): string {\n return activeProgramName;\n}\n\n/**\n * Print the branded ASCII banner once, atop install / uninstall / upgrade /\n * doctor — but ONLY for an interactive TTY (suppressed when piped/redirected,\n * under --json, or under --quiet) so scripts and pipelines see byte-identical\n * command output. The pure render lives in cli/banner; this thin wrapper reads\n * the real stdout/env and feeds it in.\n */\nexport function maybePrintBanner(flags: { json?: boolean; quiet?: boolean }): void {\n const isTTY = process.stdout.isTTY === true;\n const noColor = process.env.NO_COLOR != null && process.env.NO_COLOR !== \"\";\n if (!shouldShowBanner({ isTTY, noColor, json: flags.json === true, quiet: flags.quiet === true })) {\n return;\n }\n const color = resolveColorMode({\n noColor,\n colorterm: process.env.COLORTERM,\n term: process.env.TERM,\n });\n // Coerce an unknown/zero width to a conservative 80 so an unknown-width TTY\n // shows the safe one-line title rather than the 129-col block art.\n const c = process.stdout.columns;\n const columns = typeof c === \"number\" && c > 0 ? c : 80;\n // Rotate the gradient per run so each real invocation reads differently. The\n // random pick lives HERE (the impure wrapper) so the pure renderer stays\n // deterministic for tests/direct callers.\n const palette = PALETTES[Math.floor(Math.random() * PALETTES.length)]!;\n print(renderBrandBanner(activeProgramName, { color, columns, palette }));\n print(\"\");\n}\n\n/**\n * Resolve agent-connector's own package version at runtime. Works from both the\n * bundled dist layout (dist/*.js → ../package.json) and the src layout under\n * tsx/vitest (src/cli/ → ../../package.json); the name check guards against\n * accidentally reading some other package.json on the walk.\n */\nexport function resolveOwnVersion(): string {\n const req = createRequire(import.meta.url);\n for (const rel of [\"../package.json\", \"../../package.json\", \"../../../package.json\"]) {\n try {\n const pkg = req(rel) as { name?: string; version?: string };\n if (pkg.name === \"@ken-jo/agent-connector\" && typeof pkg.version === \"string\") {\n return pkg.version;\n }\n } catch {\n /* keep walking */\n }\n }\n return \"0.0.0\";\n}\n\n/** Parse a --scope value the CLI accepts (user|project) into an InstallScope. */\nexport function parseScope(value: string | undefined): InstallScope | null {\n if (value === \"user\" || value === \"project\") return value;\n return null;\n}\n\n/**\n * Parse a comma-separated --targets value into PlatformId[]. Returns undefined\n * when the flag is absent/empty so callers can fall back to connector/detection.\n */\nexport function parseTargets(value: string | undefined): PlatformId[] | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const ids = value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\") as PlatformId[];\n return ids.length > 0 ? ids : undefined;\n}\n\n/**\n * Build the render-only {@link ConnectorSummary} from a resolved connector. The\n * command modules call this on the {@link ResolvedConnector} they already loaded\n * and attach the result to {@link InstallResult.connector}, so the friendly\n * renderer can print a header describing WHAT was deployed without importing the\n * heavyweight connector type or its live handlers.\n */\nexport function buildConnectorSummary(connector: ResolvedConnector): ConnectorSummary {\n let server: ConnectorSummary[\"server\"];\n if (connector.server) {\n const s = connector.server;\n // stdio → \"node server.mjs\"; remote → the URL (best-effort one-liner).\n // HOME-relativize each part so a bundled absolute server path reads short.\n const cmd =\n s.transport === \"stdio\"\n ? [s.command, ...(s.args ?? [])]\n .filter((p): p is string => p != null && p !== \"\")\n .map((p) => tildify(p))\n .join(\" \")\n : (s.url ?? \"\");\n server = { transport: s.transport, command: cmd };\n }\n return {\n id: connector.id,\n version: connector.version,\n displayName: connector.displayName,\n server,\n hookEvents: [...connector.hookEvents],\n telemetryEnabled: connector.telemetry.enabled,\n commands: connector.commands.length,\n skills: connector.skills.length,\n subagents: connector.subagents.length,\n memory: connector.memory.length,\n hasStatusline: connector.statusline != null,\n actions: connector.actions.length,\n };\n}\n\n/**\n * Rewrite an absolute path under the user's home dir to a leading `~/…` so the\n * per-host paths read short. Leaves non-home and relative paths untouched.\n */\nfunction tildify(path: string): string {\n // Normalize both to forward slashes so the home-prefix check is separator-\n // robust (Windows mixes `\\` and `/`) and the displayed path reads `~/…`\n // consistently on every platform (Windows terminals accept `/` fine).\n const home = homedir().replace(/\\\\/g, \"/\");\n const np = path.replace(/\\\\/g, \"/\");\n if (home && (np === home || np.startsWith(home + \"/\"))) {\n return \"~\" + np.slice(home.length);\n }\n return np;\n}\n\n/** Truncate a long single-line command for the header (keeps it scannable). */\nfunction truncateCommand(cmd: string, max = 64): string {\n if (cmd.length <= max) return cmd;\n return cmd.slice(0, max - 1) + \"…\";\n}\n\n/**\n * The surface a ChangeRecord touched, derived from its detail (primary signal)\n * then its path (fallback for content files whose detail is a bare basename).\n */\ntype Surface = \"mcp\" | \"hooks\" | \"commands\" | \"skills\" | \"subagents\" | \"memory\" | \"statusline\" | \"actions\" | \"backup\" | \"other\";\n\nfunction classifySurface(c: ChangeRecord): Surface {\n const detail = c.detail.toLowerCase();\n // A safety backup the installer wrote before a destructive change.\n if (detail.startsWith(\"backed up\") || detail.includes(\"backup\")) return \"backup\";\n // MCP server entry: mcpServers.<id> / mcp_servers.<id> / mcp.servers.<id>.\n if (/^mcp[._]?servers?\\./.test(detail) || detail.startsWith(\"mcp.\")) return \"mcp\";\n // Normalized + native hook entries: hooks.<Event> (case varies per host).\n if (detail.startsWith(\"hooks.\") || detail.startsWith(\"hook \")) return \"hooks\";\n if (detail.includes(\"nativehooks\")) return \"hooks\";\n if (detail.startsWith(\"memory\")) return \"memory\";\n if (detail.startsWith(\"statusline\")) return \"statusline\";\n if (detail.startsWith(\"actions\") || detail.startsWith(\"action \")) return \"actions\";\n if (detail.includes(\"configpatch\")) return \"other\";\n // Path-based fallback for content-file surfaces (detail is a bare basename).\n const p = (c.path ?? \"\").replace(/\\\\/g, \"/\").toLowerCase();\n if (/\\/commands?\\//.test(p)) return \"commands\";\n if (/\\/skills?\\//.test(p)) return \"skills\";\n if (/\\/(subagents?|agents?)\\//.test(p)) return \"subagents\";\n // Detail mentions a surface noun (skip/warn lines like \"no skills\").\n if (/\\bcommands?\\b/.test(detail)) return \"commands\";\n if (/\\bskills?\\b/.test(detail)) return \"skills\";\n if (/\\bsubagents?\\b/.test(detail)) return \"subagents\";\n return \"other\";\n}\n\nconst SURFACE_LABEL_SINGULAR: Record<Surface, string> = {\n mcp: \"MCP server\",\n hooks: \"hook\",\n commands: \"command\",\n skills: \"skill\",\n subagents: \"subagent\",\n memory: \"memory block\",\n statusline: \"status line\",\n actions: \"action\",\n backup: \"backup\",\n other: \"change\",\n};\n\n/** Pluralize a surface count, e.g. (2,\"hooks\") → \"2 hooks\". */\nfunction countLabel(n: number, surface: Surface): string {\n const base = SURFACE_LABEL_SINGULAR[surface];\n if (surface === \"mcp\") return \"MCP server\"; // singular by construction\n return n === 1 ? `1 ${base}` : `${n} ${base}s`;\n}\n\n/** Verb-appropriate glyph for a host's NET status. */\nfunction hostGlyph(status: \"ok\" | \"skip\" | \"warn\"): string {\n return status === \"warn\" ? \"!\" : status === \"skip\" ? \"=\" : \"✓\";\n}\n\n/**\n * One host's collapsed view: its net status, a surface summary line, the\n * deduped HOME-relativized paths it touched, and any inline warnings.\n */\ninterface HostGroup {\n platform: PlatformId;\n status: \"ok\" | \"skip\" | \"warn\";\n summary: string;\n paths: string[];\n warnings: string[];\n}\n\n/**\n * Collapse the per-(host,surface) ChangeRecords into ONE entry per host:\n * - status: warn if any record warned; ok if any created/updated/removed;\n * else skip (everything was a no-op).\n * - summary: the active (non-skip) surfaces, joined (\"MCP server + 2 hooks\").\n * When every record skipped, the reason is surfaced instead.\n */\nfunction groupByHost(changes: ChangeRecord[], verb: Verb): HostGroup[] {\n const order: PlatformId[] = [];\n const byHost = new Map<PlatformId, ChangeRecord[]>();\n for (const c of changes) {\n if (!byHost.has(c.platform)) {\n byHost.set(c.platform, []);\n order.push(c.platform);\n }\n byHost.get(c.platform)!.push(c);\n }\n\n const groups: HostGroup[] = [];\n for (const platform of order) {\n const recs = byHost.get(platform)!;\n // A safety backup the installer wrote is INCIDENTAL, not an installed\n // surface: it must not flip an otherwise-no-op host to \"changed\" (an\n // idempotent re-install that only re-backs-up should still read \"already\n // current\"). It is shown only ALONGSIDE a real surface change.\n const written = recs.filter((c) => c.action !== \"skip\" && c.action !== \"warn\");\n const realChanges = written.filter((c) => classifySurface(c) !== \"backup\");\n const warned = recs.filter((c) => c.action === \"warn\");\n const status: HostGroup[\"status\"] =\n warned.length > 0 ? \"warn\" : realChanges.length > 0 ? \"ok\" : \"skip\";\n\n // Surface summary from the written records (created/updated/removed),\n // preserving a stable surface order and collapsing per-surface counts. The\n // incidental `backup` surface is included ONLY when a real surface changed.\n const SURFACE_ORDER: Surface[] = [\n \"mcp\",\n \"hooks\",\n \"commands\",\n \"skills\",\n \"subagents\",\n \"memory\",\n \"statusline\",\n \"actions\",\n \"backup\",\n \"other\",\n ];\n const counts = new Map<Surface, number>();\n const summarySource = realChanges.length > 0 ? written : realChanges;\n for (const c of summarySource) {\n const s = classifySurface(c);\n counts.set(s, (counts.get(s) ?? 0) + 1);\n }\n const parts = SURFACE_ORDER.filter((s) => counts.has(s)).map((s) =>\n countLabel(counts.get(s)!, s),\n );\n\n let summary: string;\n if (parts.length > 0) {\n summary = parts.join(\" + \");\n } else if (status === \"warn\") {\n // No real surface change but a warning — the warning line carries detail.\n summary = \"\";\n } else {\n // Nothing real changed: surface a skip reason (or note the incidental\n // backup) for context.\n const reason =\n recs.find((c) => c.action === \"skip\")?.detail ??\n (written.length > 0 ? \"already current (re-backed-up only)\" : \"no changes\");\n summary = verb === \"uninstall\" ? `nothing to remove (${reason})` : `unchanged (${reason})`;\n }\n\n const paths = [\n ...new Set(\n recs\n .filter((c) => c.path != null && c.path !== \"\")\n .map((c) => tildify(c.path!)),\n ),\n ];\n const warnings = warned.map((c) => c.detail);\n\n groups.push({ platform, status, summary, paths, warnings });\n }\n return groups;\n}\n\ntype Verb = \"install\" | \"upgrade\" | \"uninstall\";\n\n/**\n * Render an InstallResult as a friendly, grouped report (the DEFAULT output):\n * 1. a connector header (id/version/displayName + server/hooks/telemetry +\n * one line per shipped content surface), when the summary is threaded in;\n * 2. one line per host (net glyph + surface summary + deduped ~/… paths),\n * with any host warnings inline beneath it;\n * 3. a friendly closing line + restart hint + doctor/uninstall next steps.\n *\n * Used by install / upgrade / uninstall. The exit-non-zero-on-warn convention\n * is enforced by the callers (this function only renders).\n */\nexport function renderInstallResult(result: InstallResult, verb: Verb): string {\n const lines: string[] = [];\n const summary = result.connector;\n\n // ── 1. Connector header ───────────────────────────────────────────────────\n if (summary) {\n const head = [`${summary.id} v${summary.version}`];\n if (summary.displayName && summary.displayName !== summary.id) {\n head.push(summary.displayName);\n }\n lines.push(head.join(\" · \"));\n\n if (summary.server) {\n lines.push(\n ` server ${summary.server.transport} · ${truncateCommand(summary.server.command)}`,\n );\n } else {\n lines.push(\" server (hooks-only)\");\n }\n if (summary.hookEvents.length > 0) {\n lines.push(` hooks ${summary.hookEvents.join(\", \")}`);\n }\n lines.push(` telemetry ${summary.telemetryEnabled ? \"on\" : \"off\"}`);\n if (summary.commands > 0)\n lines.push(` commands ${summary.commands}`);\n if (summary.skills > 0) lines.push(` skills ${summary.skills}`);\n if (summary.subagents > 0)\n lines.push(` subagents ${summary.subagents}`);\n if (summary.memory > 0) lines.push(` memory ${summary.memory}`);\n if (summary.hasStatusline) lines.push(` statusline 1`);\n if (summary.actions > 0) lines.push(` actions ${summary.actions}`);\n lines.push(\"\");\n } else {\n // No summary threaded (back-compat): keep a minimal verb header.\n const mode = result.dryRun ? \" (dry-run — nothing written)\" : \"\";\n lines.push(`${verb} \"${result.connectorId}\"${mode}`);\n }\n\n // ── 2. Per-host grouping ──────────────────────────────────────────────────\n const groups = groupByHost(result.changes, verb);\n if (groups.length === 0) {\n lines.push(\"(no changes)\");\n } else {\n const verbed = verb === \"uninstall\" ? \"removed from\" : verb === \"upgrade\" ? \"synced to\" : \"detected\";\n lines.push(`→ ${groups.length} agent ${groups.length === 1 ? \"CLI\" : \"CLIs\"} ${verbed}:`);\n // Width-align the platform column for a scannable table; the summary column\n // gets a fixed min width but always keeps a 2-space gap before the paths\n // even when an unusually long summary overflows it.\n const pad = Math.max(...groups.map((g) => g.platform.length));\n for (const g of groups) {\n const glyph = hostGlyph(g.status);\n const name = g.platform.padEnd(pad);\n const pathsCol = g.paths.join(\", \");\n const gap = pathsCol === \"\" ? \"\" : \" \";\n const summaryCol = pathsCol === \"\" ? g.summary : g.summary.padEnd(26) + gap;\n lines.push(` ${glyph} ${name} ${summaryCol}${pathsCol}`.trimEnd());\n for (const w of g.warnings) lines.push(` ! ${w}`);\n }\n }\n\n // ── 3. Closing summary + next steps ───────────────────────────────────────\n // The headline file tally counts only REAL surface writes — an incidental\n // safety backup must not masquerade as an installed file, so a re-install\n // whose only write was a backup honestly reports 0 files / \"already current\".\n const tally = result.changes.reduce(\n (acc, c) => {\n const isWrite = c.action === \"create\" || c.action === \"update\" || c.action === \"remove\";\n if (isWrite && classifySurface(c) !== \"backup\") acc.files += 1;\n if (c.action === \"warn\") acc.warns += 1;\n return acc;\n },\n { files: 0, warns: 0 },\n );\n const cliCount = groups.length;\n const cliWord = cliCount === 1 ? \"CLI\" : \"CLIs\";\n const fileWord = tally.files === 1 ? \"file\" : \"files\";\n\n lines.push(\"\");\n if (verb === \"uninstall\") {\n if (result.dryRun) {\n lines.push(`✓ Would remove ${summary?.id ?? result.connectorId} from ${cliCount} ${cliWord} · ${tally.files} ${fileWord} (dry-run — nothing written).`);\n } else if (tally.files === 0 && tally.warns === 0) {\n lines.push(`✓ Nothing to remove — ${summary?.id ?? result.connectorId} was not installed (zero residue).`);\n } else {\n lines.push(`✓ Removed ${summary?.id ?? result.connectorId} from ${cliCount} ${cliWord} · ${tally.files} ${fileWord} cleaned${tally.warns === 0 ? \" (zero residue)\" : \"\"}.`);\n }\n } else {\n const what = verb === \"upgrade\" ? \"Synced\" : \"Installed\";\n const wouldWhat = verb === \"upgrade\" ? \"sync\" : \"install\";\n if (result.dryRun) {\n lines.push(`✓ Would ${wouldWhat} ${summary?.id ?? result.connectorId} to ${cliCount} ${cliWord} · ${tally.files} ${fileWord} (dry-run — nothing written).`);\n } else if (tally.files === 0) {\n lines.push(`✓ ${summary?.id ?? result.connectorId}: already current on ${cliCount} ${cliWord} — nothing to write.`);\n } else {\n lines.push(`✓ ${what} ${summary?.id ?? result.connectorId} to ${cliCount} ${cliWord} · ${tally.files} ${fileWord}. Restart each CLI to load it.`);\n }\n }\n\n // Warnings block (kept explicit — callers exit non-zero on any warn). A\n // remote-transport connector pushes the SAME string to both a warn\n // ChangeRecord (already shown inline on its host line) and result.warnings, so\n // skip any bottom-block entry already surfaced inline to show each warning ONCE.\n const inlineWarnings = new Set(groups.flatMap((g) => g.warnings));\n const blockWarnings = result.warnings.filter((w) => !inlineWarnings.has(w));\n if (blockWarnings.length > 0) {\n lines.push(\"\");\n lines.push(\"warnings:\");\n for (const w of blockWarnings) lines.push(` ! ${w}`);\n }\n\n // Next-step hints (the verbs read as the active brand).\n if (verb === \"uninstall\") {\n lines.push(` Verify it's gone: ${activeProgramName} doctor`);\n } else {\n lines.push(\n ` Verify: ${activeProgramName} doctor · Remove: ${activeProgramName} uninstall`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Command dispatch\n// ─────────────────────────────────────────────────────────────────────────\n\n/** A command module: takes the post-command argv slice, returns an exit code. */\ntype CommandModule = { run: (argv: string[]) => Promise<number> | number };\n\n/** Lazy command loaders — keyed by the first positional. Imported on demand. */\nconst COMMANDS: Record<string, () => Promise<CommandModule>> = {\n detect: () => import(\"./commands/detect.js\"),\n install: () => import(\"./commands/install.js\"),\n uninstall: () => import(\"./commands/uninstall.js\"),\n // `upgrade` is the single \"bring everything current\" verb (re-render host\n // config + refresh the home pointer + managed channel guidance). `sync` and\n // `update` are kept as back-compat aliases that route to the same module so\n // existing scripts/docs keep working without a second concept to learn.\n upgrade: () => import(\"./commands/upgrade.js\"),\n sync: () => import(\"./commands/upgrade.js\"),\n update: () => import(\"./commands/upgrade.js\"),\n package: () => import(\"./commands/package.js\"),\n doctor: () => import(\"./commands/doctor.js\"),\n status: () => import(\"./commands/status.js\"),\n telemetry: () => import(\"./commands/telemetry.js\"),\n usage: () => import(\"./commands/usage.js\"),\n leaderboard: () => import(\"./commands/leaderboard.js\"),\n hook: () => import(\"./commands/hook.js\"),\n // Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's\n // status line config points at. Fail-safe: always exits 0 with at most a\n // rendered line. See cli/commands/statusline.ts.\n statusline: () => import(\"./commands/statusline.js\"),\n // Internal (omitted from USAGE): the user-invokable action entrypoint a future\n // host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),\n // unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.\n action: () => import(\"./commands/action.js\"),\n serve: () => import(\"./commands/serve.js\"),\n // Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an\n // AfterModel / PostInvocation hook points at. Always exits 0; records a\n // distinct `model_turn` row. See cli/commands/usage-event.ts.\n \"usage-event\": () => import(\"./commands/usage-event.js\"),\n};\n\n/** Default program name; an embedding SDK CLI overrides it via {@link MainOptions}. */\nexport const DEFAULT_PROGRAM_NAME = \"agent-connector\";\n\n/**\n * One-line usage signature per command — the single central copy behind\n * `<command> --help` and the friendly bad-flag error. Command modules use\n * node:util parseArgs (strict), which THROWS on an unknown flag; without the\n * dispatcher-level handling in {@link main}, `agent-connector install --help`\n * would die with a raw ERR_PARSE_ARGS stack trace — the very invocation the\n * root help tells users to run.\n */\nconst COMMAND_USAGE: Record<string, string> = {\n detect: \"detect [--json] [--project <dir>]\",\n install:\n \"install [<source>] [--method direct|marketplace] [--connector <source>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--force] [--quiet]\\n\" +\n \" <source> a local path OR a remote GitHub connector: owner/repo[/subpath][#ref], a github.com URL (incl. /tree/<ref>/<sub>), git@github.com:owner/repo, or github:owner/repo. Remote sources are fetched to ~/.agent-connector/sources/ and must be an agent-connector package (have an agent-connector.config.{mjs,js,json}).\",\n uninstall:\n \"uninstall [--method auto|direct|marketplace] [--connector <path>] [--connector-id <id>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--purge] [--quiet]\",\n upgrade:\n \"upgrade [--method direct|marketplace] [--channel stable|latest] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--quiet]\",\n sync: \"sync — alias of upgrade (see `upgrade --help`)\",\n update: \"update — alias of upgrade (see `upgrade --help`)\",\n package:\n \"package [--connector <path>] [--format <fmt>|all] [--out <dir>] [--project <dir>] [--dry-run]\",\n doctor:\n \"doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--explain] [--json] [--heal] [--dry-run] [--quiet]\\n\" +\n \" --explain per-(host,event) hook honor matrix (honored/degraded/dropped). Exit non-zero ONLY when an explicitly-targeted host DEGRADES a declared event (fires it but silently won't honor the reply); dropped/mcp-only hosts and fleet-wide (targets:auto) gaps are informational (exit 0).\",\n status: \"status [--connector <path>] [--scope user|project] [--project <dir>] [--json]\",\n telemetry:\n \"telemetry report|export|leaderboard [--by <dim>] [--since <dur>] [--connector <id>] [--scope <slice>] [--format csv|json] [--out <file>] [--json]\",\n usage:\n \"usage report|export|leaderboard [--by <dim>] [--since <dur>] [--platform <id>] [--format csv|json] [--out <file>] [--json]\",\n leaderboard: \"leaderboard [--since <dur>] [--connector <id>] [--scope <slice>] [--json]\",\n hook: \"hook <platform> <event> --connector <id> (internal — host hook configs point here)\",\n statusline:\n \"statusline <platform> --connector <id> (internal — host status line configs point here)\",\n action:\n \"action <platform> <actionId> --connector <id> (internal — host action affordances point here)\",\n serve:\n \"serve --connector <id> [--scope user|project] [--host <platformId>] -- <command> [args...] (internal — host MCP entries point here)\",\n};\n\n/**\n * Build the top-level usage string for a given program name. The brand replaces\n * \"agent-connector\" in the title, the `usage:` line, and the per-command help\n * footer so an embedded CLI (e.g. `acme-db`) reads as its own tool.\n */\nfunction buildUsage(programName: string): string {\n return `${programName} — write your MCP server + hooks once, install everywhere.\n\nusage: ${programName} <command> [flags]\n\ncommands:\n detect List the AI-agent platforms installed on this machine.\n install Deploy a connector across its target platforms (--method direct writes host config; --method marketplace drives the host's plugin install).\n uninstall Remove a connector's registrations (--method auto reverses whichever method is actually installed).\n upgrade Bring everything current: re-render host config + heal the home pointer + managed update guidance (alias: update, sync).\n package Emit a marketplace/extension bundle (10 host formats, or the standard artifacts mcp-server-json | mcpb).\n doctor Health-check every detected platform; non-zero exit on any failure.\n status Light install-state summary: which connectors are present on which hosts (always exits 0).\n telemetry Inspect local per-tool token telemetry (report | export | leaderboard).\n usage Inspect host-native token usage from agent CLI logs (report | export | leaderboard).\n leaderboard Three leaderboards: 🔌 MCP/plugin (mcp-self) + 🖥️ host/user (host-scan-logs) + 🛰️ host-native turns (host-native-live) — never summed.\n hook Universal json-stdio hook entrypoint (hosts call this).\n serve Telemetry-wrapping MCP stdio proxy (wraps a real server command).\n\nRun \\`${programName} <command> --help\\` for command-specific flags.`;\n}\n\n/** Options accepted by {@link main}. */\nexport interface MainOptions {\n /**\n * The brand shown in usage/help text. Defaults to {@link DEFAULT_PROGRAM_NAME}.\n * An embedding SDK CLI (see cli/sdk.ts) passes its own bin name so every\n * subcommand's help reads as the developer's tool.\n */\n programName?: string;\n /**\n * Version shown by --version. Defaults to agent-connector's own package version.\n * Embedded branded CLIs pass their package.json version.\n */\n programVersion?: string;\n}\n\nexport async function main(argv: string[], opts: MainOptions = {}): Promise<number> {\n const programName = opts.programName ?? DEFAULT_PROGRAM_NAME;\n activeProgramName = programName; // brand every fail() in this invocation\n const usage = buildUsage(programName);\n const command = argv[0];\n\n if (command == null || command === \"--help\" || command === \"-h\" || command === \"help\") {\n print(usage);\n return command == null ? 1 : 0;\n }\n if (command === \"--version\" || command === \"-v\") {\n print(`${programName} ${opts.programVersion ?? resolveOwnVersion()}`);\n return 0;\n }\n\n const loader = COMMANDS[command];\n if (!loader) {\n process.stderr.write(`${programName}: unknown command \"${command}\"\\n\\n`);\n process.stderr.write(`${usage}\\n`);\n return 2;\n }\n\n // Per-command help: no command module defines a --help flag (strict parseArgs\n // would throw on it), so answer it centrally from COMMAND_USAGE.\n const rest = argv.slice(1);\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n const sig = COMMAND_USAGE[command];\n if (sig) {\n print(`usage: ${programName} ${sig}`);\n return 0;\n }\n }\n\n const mod = await loader();\n try {\n return await mod.run(rest);\n } catch (err) {\n // Friendly bad-flag errors: strict parseArgs throws ERR_PARSE_ARGS_* for an\n // unknown/malformed option — print the message + the usage line instead of\n // letting a raw stack trace reach the user. Everything else still rethrows\n // (the bin entry reports those as fatal).\n const code = (err as { code?: string }).code;\n if (typeof code === \"string\" && code.startsWith(\"ERR_PARSE_ARGS\")) {\n const message = err instanceof Error ? err.message : String(err);\n const sig = COMMAND_USAGE[command];\n if (sig) process.stderr.write(`usage: ${programName} ${sig}\\n`);\n return fail(message);\n }\n throw err;\n }\n}\n","/**\n * cli/banner — the branded ASCII-art header shown once atop install / uninstall\n * / upgrade / doctor.\n *\n * Two PURE functions drive everything (no process.* reads here — the command\n * wiring injects the real env so tests can call these directly without a TTY):\n *\n * renderBrandBanner(name, { color, columns, palette }) → the banner string\n * shouldShowBanner({ isTTY, noColor, json, quiet }) → whether to show it\n *\n * RESPONSIVE (one line, NEVER stacked), two forms:\n * • WIDE — a 6-row \"ANSI Shadow\" block font (solid `█` + `╗╔╝╚║═` shadow,\n * ~8 cols/char, hand-transcribed + fixed-width so it tiles cleanly) when its\n * render fits the terminal width.\n * • NARROW — a single-line gradient TITLE `◆ AGENT-CONNECTOR` (the brand\n * uppercased, each char colored along the palette + bold). ~18 cols, so it\n * fits any real terminal; it is the universal narrow form.\n * The WIDE font covers the connector-id charset [A-Za-z0-9 ._-].\n *\n * COLOR: a palette gradient (three RGB stops, a {@link Palette}) — swept per\n * column across the block art, or per character across the title. The render is\n * PURE and palette-parameterized — the caller picks the palette (the impure\n * app.ts wrapper rotates {@link PALETTES} per run). truecolor→256→16→none tiers\n * all honor the palette; NO_COLOR = zero ANSI.\n */\n\n/** Color capability the host terminal advertises, highest → lowest. */\nexport type ColorMode = \"truecolor\" | \"ansi256\" | \"ansi16\" | \"none\";\n\n/** A 24-bit RGB triple. */\nexport type RGB = readonly [number, number, number];\n\n/** A 3-stop gradient: the sweep lerps stop0 → stop1 → stop2 across the columns. */\nexport type Palette = readonly [RGB, RGB, RGB];\n\n/**\n * The 10 rotation palettes. The impure {@link maybePrintBanner} wrapper picks one\n * at random per run so each real invocation shows a different color; the pure\n * renderer defaults to PALETTES[0] so direct callers + tests stay deterministic.\n */\nexport const PALETTES: readonly Palette[] = [\n [[255, 210, 0], [255, 110, 10], [220, 30, 25]], // Sunset\n [[255, 225, 90], [255, 120, 0], [200, 20, 20]], // Lava\n [[230, 30, 30], [255, 120, 0], [255, 220, 0]], // Fire\n [[255, 225, 120], [255, 170, 40], [225, 110, 20]], // Amber gold\n [[255, 205, 150], [255, 150, 130], [255, 120, 175]], // Peach pastel\n [[255, 80, 170], [200, 40, 200], [100, 60, 210]], // Berry\n [[0, 220, 180], [0, 160, 230], [60, 90, 230]], // Ocean\n [[80, 230, 140], [0, 200, 210], [150, 90, 235]], // Aurora\n [[170, 230, 90], [60, 200, 120], [20, 150, 140]], // Forest\n [[0, 200, 200], [40, 80, 230], [200, 40, 200]], // Synthwave\n] as const;\n\n/** Inputs to {@link renderBrandBanner} — all injected, never read from process. */\nexport interface BannerOptions {\n /** Color capability to render at. \"none\" emits zero ANSI codes. */\n color: ColorMode;\n /** Terminal width in columns; selects the form (wide block art → one-line title). */\n columns: number;\n /** The 3-stop gradient. Defaults to {@link PALETTES}[0] (Sunset) when omitted. */\n palette?: Palette;\n}\n\n/** Inputs to {@link shouldShowBanner} — the real env, injected by the caller. */\nexport interface BannerGate {\n /** process.stdout.isTTY (banner is suppressed entirely when not a TTY). */\n isTTY: boolean;\n /** NO_COLOR is set (the banner still shows, but with zero color codes). */\n noColor: boolean;\n /** A machine-readable --json was requested (suppress entirely). */\n json: boolean;\n /** An explicit --quiet was passed (suppress entirely). */\n quiet: boolean;\n}\n\n/**\n * Whether to print the banner at all. The banner is decorative, so it shows ONLY\n * for an interactive TTY and never when output is being consumed by a script or\n * pipeline: not when piped/redirected (`!isTTY`), not under `--json`, and not\n * under `--quiet`. `NO_COLOR` does NOT suppress it — the banner renders without\n * color in that case (handled by {@link resolveColorMode}).\n */\nexport function shouldShowBanner(gate: BannerGate): boolean {\n return gate.isTTY && !gate.json && !gate.quiet;\n}\n\n/**\n * Resolve the color tier from the (injected) terminal env. 24-bit when the\n * terminal advertises it (COLORTERM=truecolor|24bit), 256-color when TERM names\n * a 256 palette, else 16-color — and PLAIN (no color) under NO_COLOR or a dumb /\n * absent TERM.\n */\nexport function resolveColorMode(env: {\n noColor: boolean;\n colorterm?: string | undefined;\n term?: string | undefined;\n}): ColorMode {\n if (env.noColor) return \"none\";\n const term = (env.term ?? \"\").toLowerCase();\n if (term === \"\" || term === \"dumb\") return \"none\";\n const colorterm = (env.colorterm ?? \"\").toLowerCase();\n if (colorterm === \"truecolor\" || colorterm === \"24bit\") return \"truecolor\";\n if (term.includes(\"256\")) return \"ansi256\";\n return \"ansi16\";\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// WIDE font — \"ANSI Shadow\" (6 rows). Hand-transcribed bold figlet glyphs —\n// solid `█` with a `╗╔╝╚║═` 3D shadow — fixed-width per glyph so they TILE\n// cleanly when concatenated (~8 cols/char → \"agent-connector\" ≈ 126 cols on\n// one line). Used only when the terminal is wide enough.\n// ─────────────────────────────────────────────────────────────────────────\n\nconst WIDE_FONT: Record<string, readonly string[]> = {\n A: [\" █████╗ \", \"██╔══██╗\", \"███████║\", \"██╔══██║\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n B: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔══██╗\", \"██████╔╝\", \"╚═════╝ \"],\n C: [\" ██████╗\", \"██╔════╝\", \"██║ \", \"██║ \", \"╚██████╗\", \" ╚═════╝\"],\n D: [\"██████╗ \", \"██╔══██╗\", \"██║ ██║\", \"██║ ██║\", \"██████╔╝\", \"╚═════╝ \"],\n E: [\"███████╗\", \"██╔════╝\", \"█████╗ \", \"██╔══╝ \", \"███████╗\", \"╚══════╝\"],\n F: [\"███████╗\", \"██╔════╝\", \"█████╗ \", \"██╔══╝ \", \"██║ \", \"╚═╝ \"],\n G: [\" ██████╗ \", \"██╔════╝ \", \"██║ ███╗\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n H: [\"██╗ ██╗\", \"██║ ██║\", \"███████║\", \"██╔══██║\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n I: [\"██╗\", \"██║\", \"██║\", \"██║\", \"██║\", \"╚═╝\"],\n J: [\" ██╗\", \" ██║\", \" ██║\", \"██ ██║\", \"╚█████╔╝\", \" ╚════╝ \"],\n K: [\"██╗ ██╗\", \"██║ ██╔╝\", \"█████╔╝ \", \"██╔═██╗ \", \"██║ ██╗\", \"╚═╝ ╚═╝\"],\n L: [\"██╗ \", \"██║ \", \"██║ \", \"██║ \", \"███████╗\", \"╚══════╝\"],\n M: [\"███╗ ███╗\", \"████╗ ████║\", \"██╔████╔██║\", \"██║╚██╔╝██║\", \"██║ ╚═╝ ██║\", \"╚═╝ ╚═╝\"],\n N: [\"███╗ ██╗\", \"████╗ ██║\", \"██╔██╗ ██║\", \"██║╚██╗██║\", \"██║ ╚████║\", \"╚═╝ ╚═══╝\"],\n O: [\" ██████╗ \", \"██╔═══██╗\", \"██║ ██║\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n P: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔═══╝ \", \"██║ \", \"╚═╝ \"],\n Q: [\" ██████╗ \", \"██╔═══██╗\", \"██║ ██║\", \"██║▄▄ ██║\", \"╚██████╔╝\", \" ╚══▀▀═╝ \"],\n R: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔══██╗\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n S: [\"███████╗\", \"██╔════╝\", \"███████╗\", \"╚════██║\", \"███████║\", \"╚══════╝\"],\n T: [\"████████╗\", \"╚══██╔══╝\", \" ██║ \", \" ██║ \", \" ██║ \", \" ╚═╝ \"],\n U: [\"██╗ ██╗\", \"██║ ██║\", \"██║ ██║\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n V: [\"██╗ ██╗\", \"██║ ██║\", \"██║ ██║\", \"╚██╗ ██╔╝\", \" ╚████╔╝ \", \" ╚═══╝ \"],\n W: [\"██╗ ██╗\", \"██║ ██║\", \"██║ █╗ ██║\", \"██║███╗██║\", \"╚███╔███╔╝\", \" ╚══╝╚══╝ \"],\n X: [\"██╗ ██╗\", \"╚██╗██╔╝\", \" ╚███╔╝ \", \" ██╔██╗ \", \"██╔╝ ██╗\", \"╚═╝ ╚═╝\"],\n Y: [\"██╗ ██╗\", \"╚██╗ ██╔╝\", \" ╚████╔╝ \", \" ╚██╔╝ \", \" ██║ \", \" ╚═╝ \"],\n Z: [\"███████╗\", \"╚══███╔╝\", \" ███╔╝ \", \" ███╔╝ \", \"███████╗\", \"╚══════╝\"],\n \"0\": [\" ██████╗ \", \"██╔═████╗\", \"██║██╔██║\", \"████╔╝██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n \"1\": [\" ██╗\", \"███║\", \"╚██║\", \" ██║\", \" ██║\", \" ╚═╝\"],\n \"2\": [\"██████╗ \", \"╚════██╗\", \" █████╔╝\", \"██╔═══╝ \", \"███████╗\", \"╚══════╝\"],\n \"3\": [\"██████╗ \", \"╚════██╗\", \" █████╔╝\", \" ╚═══██╗\", \"██████╔╝\", \"╚═════╝ \"],\n \"4\": [\"██╗ ██╗\", \"██║ ██║\", \"███████║\", \"╚════██║\", \" ██║\", \" ╚═╝\"],\n \"5\": [\"███████╗\", \"██╔════╝\", \"███████╗\", \"╚════██║\", \"███████║\", \"╚══════╝\"],\n \"6\": [\" ██████╗ \", \"██╔════╝ \", \"███████╗ \", \"██╔═══██╗\", \"╚██████╔╝\", \" ╚═════╝ \"],\n \"7\": [\"███████╗\", \"╚════██║\", \" ██╔╝\", \" ██╔╝ \", \" ██║ \", \" ╚═╝ \"],\n \"8\": [\" █████╗ \", \"██╔══██╗\", \"╚█████╔╝\", \"██╔══██╗\", \"╚█████╔╝\", \" ╚════╝ \"],\n \"9\": [\" █████╗ \", \"██╔══██╗\", \"╚██████║\", \" ╚═══██║\", \" █████╔╝\", \" ╚════╝ \"],\n \"-\": [\" \", \" \", \"█████╗\", \"╚════╝\", \" \", \" \"],\n \"_\": [\" \", \" \", \" \", \" \", \"███████╗\", \"╚══════╝\"],\n \".\": [\" \", \" \", \" \", \" \", \"██╗\", \"╚═╝\"],\n \" \": [\" \", \" \", \" \", \" \", \" \", \" \"],\n};\n\nconst GLYPH_ROWS = 6;\n\n/** Visible column count of a string (full-block + box-drawing are 1 cell each). */\nfunction vlen(s: string): number {\n return [...s].length;\n}\n\n/**\n * Render `name` into the fixed-width `font` as GLYPH_ROWS lines. The ANSI-Shadow\n * glyphs already carry their own trailing shadow column and tile cleanly with NO\n * inter-glyph gap. Returns null when the name has no renderable characters; the\n * glyphs are width-consistent per glyph, so the rows stay aligned.\n */\nfunction renderWithFont(name: string, font: Record<string, readonly string[]>): string[] | null {\n const chars = [...name];\n if (chars.length === 0) return null;\n const blank = font[\" \"]!;\n const rows: string[] = Array.from({ length: GLYPH_ROWS }, () => \"\");\n for (const ch of chars) {\n const glyph = font[ch.toUpperCase()] ?? blank;\n for (let r = 0; r < GLYPH_ROWS; r++) {\n rows[r] += glyph[r] ?? \"\";\n }\n }\n // Drop any fully-blank bottom rows so a name built from narrower glyphs (e.g.\n // \".\" / \"_\") never pads the banner with trailing empty lines.\n while (rows.length > 1 && rows[rows.length - 1]!.trim() === \"\") rows.pop();\n return rows;\n}\n\n/** Max visible width across an art block's rows. */\nfunction blockWidth(rows: string[]): number {\n return rows.length === 0 ? 0 : Math.max(...rows.map(vlen));\n}\n\n/**\n * The WIDE ANSI-Shadow block art for `name` when it fits `columns` (ONE line,\n * never stacked); else null so the caller renders the narrow one-line title.\n * `columns <= 0` means \"no constraint\" → always the WIDE art.\n */\nfunction selectWideArt(name: string, columns: number): string[] | null {\n const limit = columns > 0 ? columns : Infinity;\n const wide = renderWithFont(name, WIDE_FONT);\n return wide != null && blockWidth(wide) <= limit ? wide : null;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Palette-parameterized gradient. The sweep lerps the three palette stops\n// across each row's columns (t∈[0,1]). truecolor uses the exact RGB; 256 and 16\n// derive the nearest representable code FROM the same RGB, so every palette\n// works in every tier. \"none\" emits the bare char.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The interpolated RGB of `palette` at gradient position t∈[0,1]. */\nfunction gradientRGB(t: number, palette: Palette): RGB {\n const clamp = Math.max(0, Math.min(1, t));\n const seg = clamp >= 0.5 ? 1 : 0;\n const local = (clamp - seg * 0.5) / 0.5;\n const a = palette[seg]!;\n const b = palette[seg + 1]!;\n return [\n Math.round(a[0] + (b[0] - a[0]) * local),\n Math.round(a[1] + (b[1] - a[1]) * local),\n Math.round(a[2] + (b[2] - a[2]) * local),\n ];\n}\n\n/** Nearest xterm-256 cube index (16..231) for an RGB triple. */\nfunction rgbTo256(r: number, g: number, b: number): number {\n const q = (v: number): number => (v < 48 ? 0 : v < 115 ? 1 : Math.round((v - 35) / 40));\n return 16 + 36 * q(r) + 6 * q(g) + q(b);\n}\n\n/** Nearest of the 8 bright 16-color fg codes (90..97) for an RGB triple. */\nfunction rgbTo16(r: number, g: number, b: number): number {\n // Threshold each channel; map the on/off triple to its bright SGR code.\n const hi = (v: number): number => (v >= 128 ? 1 : 0);\n const key = (hi(r) << 2) | (hi(g) << 1) | hi(b);\n // index: RGB bits → code. 0:black(90) 1:blue(94) 2:green(92) 3:cyan(96)\n // 4:red(91) 5:magenta(95) 6:yellow(93) 7:white(97)\n return [90, 94, 92, 96, 91, 95, 93, 97][key]!;\n}\n\nconst RESET = \"\\x1b[0m\";\n\n/**\n * Wrap a single grapheme `ch` at gradient position `t` in the SGR escape for the\n * given color tier + palette. Whitespace is never colored (no point paying for\n * an escape around a space) and \"none\" returns the bare char.\n */\nfunction colorChar(ch: string, t: number, color: ColorMode, palette: Palette): string {\n if (color === \"none\" || ch.trim() === \"\") return ch;\n const [r, g, b] = gradientRGB(t, palette);\n if (color === \"truecolor\") return `\\x1b[38;2;${r};${g};${b}m${ch}${RESET}`;\n if (color === \"ansi256\") return `\\x1b[38;5;${rgbTo256(r, g, b)}m${ch}${RESET}`;\n return `\\x1b[${rgbTo16(r, g, b)}m${ch}${RESET}`;\n}\n\n/** Apply the left-to-right gradient across one art row (by visible column). */\nfunction colorizeRow(row: string, color: ColorMode, palette: Palette): string {\n if (color === \"none\") return row;\n const chars = [...row];\n const width = Math.max(1, chars.length - 1);\n let out = \"\";\n for (let i = 0; i < chars.length; i++) {\n out += colorChar(chars[i]!, i / width, color, palette);\n }\n return out;\n}\n\n/** A single BOLD grapheme at gradient position `t` (used by the narrow title). */\nfunction boldColorChar(ch: string, t: number, color: ColorMode, palette: Palette): string {\n if (color === \"none\") return ch;\n const [r, g, b] = gradientRGB(t, palette);\n const fg =\n color === \"truecolor\"\n ? `38;2;${r};${g};${b}`\n : color === \"ansi256\"\n ? `38;5;${rgbTo256(r, g, b)}`\n : `${rgbTo16(r, g, b)}`;\n return `\\x1b[1;${fg}m${ch}${RESET}`;\n}\n\n/**\n * The NARROW one-line title `◆ AGENT-CONNECTOR`: a colored leading diamond (the\n * palette mid stop), two spaces, then the UPPERCASED brand with each character\n * colored along the palette gradient (i → t = i/(len-1)) and bold. Under \"none\"\n * it is the plain text with ZERO ANSI. ~18 cols for \"agent-connector\", so it\n * fits any real terminal.\n */\nfunction renderTitle(name: string, color: ColorMode, palette: Palette): string {\n const upper = name.toUpperCase();\n if (color === \"none\") return `◆ ${upper}`;\n const diamond = boldColorChar(\"◆\", 0.5, color, palette);\n const chars = [...upper];\n const span = Math.max(1, chars.length - 1);\n let title = \"\";\n for (let i = 0; i < chars.length; i++) {\n title += boldColorChar(chars[i]!, i / span, color, palette);\n }\n return `${diamond} ${title}`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Footer (engine attribution). Shown on BOTH the global and branded CLIs — the\n// \"powered by\" wording is intentional.\n// ─────────────────────────────────────────────────────────────────────────\n\nconst FOOTER_LINES = [\n \"powered by @ken-jo/agent-connector\",\n \"more → https://github.com/ken-jo/agent-connector\",\n] as const;\n\n/** Dim (de-emphasized) footer line; plain under \"none\". */\nfunction dim(text: string, color: ColorMode): string {\n return color === \"none\" ? text : `\\x1b[2m${text}${RESET}`;\n}\n\n/**\n * Render the full banner: a responsive brand title with a palette-driven\n * gradient, then a two-line dim footer directly below.\n *\n * • WIDE — the ANSI-Shadow block art when it fits `columns` (ONE line, never\n * stacked; `columns <= 0` = no constraint).\n * • NARROW — the one-line `◆ AGENT-CONNECTOR` gradient title (the universal\n * narrow form, ~18 cols) when the block art would overflow.\n * • `palette` defaults to PALETTES[0] so direct callers + tests are\n * deterministic; the impure app.ts wrapper rotates the palettes per run.\n * • Under `color: \"none\"` (NO_COLOR / dumb term) the output carries zero ANSI\n * escape codes — only the raw art/title + footer text.\n *\n * The result has NO trailing newline; the caller prints it with one.\n */\nexport function renderBrandBanner(name: string, opts: BannerOptions): string {\n const { color, columns } = opts;\n const palette = opts.palette ?? PALETTES[0]!;\n const footer = FOOTER_LINES.map((l) => dim(l, color)).join(\"\\n\");\n\n const art = selectWideArt(name, columns);\n const body =\n art != null\n ? art.map((row) => colorizeRow(row, color, palette)).join(\"\\n\")\n : renderTitle(name, color, palette);\n return `${body}\\n${footer}`;\n}\n"],"mappings":";;;AAaA,SAAS,qBAAqB;AAC9B,S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BAAsB,OAAO;AAAA;AAAA,CAAO;AACvE,YAAQ,OAAO,MAAM,GAAG,KAAK;AAAA,CAAI;AACjC,WAAO;AAAA,EACT;AAIA,QAAM,OAAO,KAAK,MAAM,CAAC;AACzB,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;AAClD,UAAM,MAAM,cAAc,OAAO;AACjC,QAAI,KAAK;AACP,YAAM,UAAU,WAAW,IAAI,GAAG,EAAE;AACpC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,MAAM,MAAM,OAAO;AACzB,MAAI;AACF,WAAO,MAAM,IAAI,IAAI,IAAI;AAAA,EAC3B,SAAS,KAAK;AAKZ,UAAM,OAAQ,IAA0B;AACxC,QAAI,OAAO,SAAS,YAAY,KAAK,WAAW,gBAAgB,GAAG;AACjE,YAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,YAAM,MAAM,cAAc,OAAO;AACjC,UAAI,IAAK,SAAQ,OAAO,MAAM,UAAU,WAAW,IAAI,GAAG;AAAA,CAAI;AAC9D,aAAO,KAAK,OAAO;AAAA,IACrB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
|
package/dist/cli/sdk.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { URL } from 'node:url';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* cli/sdk — the EMBEDDED SDK entry point for a developer-branded CLI.
|
|
3
5
|
*
|
|
@@ -7,13 +9,11 @@
|
|
|
7
9
|
* delegated and AUTO-SCOPED to the developer's connector:
|
|
8
10
|
*
|
|
9
11
|
* #!/usr/bin/env node
|
|
10
|
-
* import { fileURLToPath } from "node:url";
|
|
11
12
|
* import { createConnectorCli } from "@ken-jo/agent-connector/cli";
|
|
12
13
|
* createConnectorCli({
|
|
13
|
-
*
|
|
14
|
-
* connector:
|
|
14
|
+
* packageJson: new URL("./package.json", import.meta.url),
|
|
15
|
+
* connector: new URL("./agent-connector.config.mjs", import.meta.url),
|
|
15
16
|
* }).run();
|
|
16
|
-
* // fileURLToPath, NOT URL.pathname — .pathname yields "/C:/…" on Windows.
|
|
17
17
|
*
|
|
18
18
|
* Then a consumer runs `acme-db install`, `acme-db leaderboard`, `acme-db
|
|
19
19
|
* telemetry`, `acme-db doctor`, etc. — and each one targets the developer's
|
|
@@ -21,28 +21,69 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This module is PURE ARGUMENT TRANSFORMATION: it injects the right --connector
|
|
23
23
|
* (path) or --connector <id> filter when the user did not supply one, then hands
|
|
24
|
-
* off to {@link main} with the developer's program name. It never
|
|
25
|
-
* command logic — every behavior still lives in the command
|
|
24
|
+
* off to {@link main} with the developer's program name/version. It never
|
|
25
|
+
* duplicates any command logic — every behavior still lives in the command
|
|
26
|
+
* modules.
|
|
26
27
|
*/
|
|
28
|
+
|
|
29
|
+
type ConnectorCliPath = string | URL;
|
|
30
|
+
interface ConnectorCliContext {
|
|
31
|
+
/** Resolved brand/bin name shown in usage, errors, and --version output. */
|
|
32
|
+
programName: string;
|
|
33
|
+
/** Resolved branded package version shown by --version. */
|
|
34
|
+
programVersion: string;
|
|
35
|
+
/** Absolute connector config path injected into connector-targeted commands. */
|
|
36
|
+
connector: string;
|
|
37
|
+
/** Lazily resolves the connector id for telemetry/serve/hook scoping. */
|
|
38
|
+
connectorId(): Promise<string>;
|
|
39
|
+
}
|
|
40
|
+
interface ConnectorCliPassthrough {
|
|
41
|
+
/**
|
|
42
|
+
* Return true when this invocation should be handled by custom package logic
|
|
43
|
+
* instead of the agent-connector command dispatcher.
|
|
44
|
+
*/
|
|
45
|
+
when(argv: readonly string[], context: ConnectorCliContext): boolean;
|
|
46
|
+
/** Handle a matched invocation. Return the process exit code. */
|
|
47
|
+
run(argv: readonly string[], context: ConnectorCliContext): number | Promise<number>;
|
|
48
|
+
}
|
|
27
49
|
/** Options for {@link createConnectorCli}. */
|
|
28
50
|
interface CreateConnectorCliOptions {
|
|
29
|
-
/** The developer's bin/brand name (shown in usage/help, e.g. "acme-db"). */
|
|
30
|
-
name: string;
|
|
31
51
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
52
|
+
* The developer's bin/brand name (shown in usage/help, e.g. "acme-db").
|
|
53
|
+
* Prefer `packageJson` for packaged connectors so name/version stay in one
|
|
54
|
+
* source of truth; this remains available for custom launchers and tests.
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* package.json for the branded connector package. When supplied, the CLI
|
|
59
|
+
* derives the bin name and version from package metadata.
|
|
60
|
+
*/
|
|
61
|
+
packageJson?: ConnectorCliPath;
|
|
62
|
+
/**
|
|
63
|
+
* Absolute path or file URL to the developer's connector config (.mjs / .js /
|
|
64
|
+
* .json) that ships inside their package. Injected as `--connector <path>` for
|
|
34
65
|
* connector-targeted subcommands when the user did not pass one.
|
|
35
66
|
*/
|
|
36
|
-
connector:
|
|
67
|
+
connector: ConnectorCliPath;
|
|
37
68
|
/**
|
|
38
69
|
* The connector id used for the telemetry/leaderboard FILTER injection. When
|
|
39
70
|
* omitted it is derived lazily by loading the connector config the first time a
|
|
40
71
|
* telemetry/leaderboard subcommand runs.
|
|
41
72
|
*/
|
|
42
73
|
connectorId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Package-specific command escapes that should run before agent-connector's
|
|
76
|
+
* dispatcher. Use sparingly for legacy/runtime commands that intentionally
|
|
77
|
+
* live outside the universal connector surface.
|
|
78
|
+
*/
|
|
79
|
+
passthrough?: readonly ConnectorCliPassthrough[];
|
|
43
80
|
}
|
|
44
81
|
/** The runner returned by {@link createConnectorCli}. */
|
|
45
82
|
interface ConnectorCli {
|
|
83
|
+
/** Resolved brand/bin name. */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Resolved branded package version. */
|
|
86
|
+
version: string;
|
|
46
87
|
/**
|
|
47
88
|
* Run a branded invocation. `argv` defaults to `process.argv.slice(2)`.
|
|
48
89
|
* Resolves to the process exit code (0 success, non-zero failure).
|
|
@@ -51,4 +92,4 @@ interface ConnectorCli {
|
|
|
51
92
|
}
|
|
52
93
|
declare function createConnectorCli(opts: CreateConnectorCliOptions): ConnectorCli;
|
|
53
94
|
|
|
54
|
-
export { type ConnectorCli, type CreateConnectorCliOptions, createConnectorCli };
|
|
95
|
+
export { type ConnectorCli, type ConnectorCliContext, type ConnectorCliPassthrough, type ConnectorCliPath, type CreateConnectorCliOptions, createConnectorCli };
|
package/dist/cli/sdk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
main
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-TQRLMA2C.js";
|
|
5
5
|
import {
|
|
6
6
|
loadConnectorFromPath
|
|
7
7
|
} from "../chunk-KSPMSRVU.js";
|
|
@@ -12,6 +12,9 @@ import "../chunk-UMQ6NBQR.js";
|
|
|
12
12
|
import "../chunk-GZGLCCEE.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/sdk.ts
|
|
15
|
+
import { readFileSync, realpathSync } from "fs";
|
|
16
|
+
import { dirname, resolve } from "path";
|
|
17
|
+
import { fileURLToPath, URL } from "url";
|
|
15
18
|
var CONFIG_PATH_COMMANDS = /* @__PURE__ */ new Set([
|
|
16
19
|
"install",
|
|
17
20
|
"uninstall",
|
|
@@ -44,29 +47,91 @@ function injectAfterCommand(argv, flag, value) {
|
|
|
44
47
|
function appendFlag(argv, flag, value) {
|
|
45
48
|
return [...argv, flag, value];
|
|
46
49
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
function cleanString(value) {
|
|
51
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
52
|
+
}
|
|
53
|
+
function pathFrom(value, label) {
|
|
54
|
+
if (value instanceof URL) return fileURLToPath(value);
|
|
55
|
+
if (typeof value === "string" && value.trim() !== "") return value;
|
|
56
|
+
throw new TypeError(`createConnectorCli: \`${label}\` must be a non-empty path or file URL`);
|
|
57
|
+
}
|
|
58
|
+
function normalizeBinTarget(target) {
|
|
59
|
+
return target.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
60
|
+
}
|
|
61
|
+
function realPathIfExists(path) {
|
|
62
|
+
try {
|
|
63
|
+
return realpathSync(path);
|
|
64
|
+
} catch {
|
|
65
|
+
return void 0;
|
|
50
66
|
}
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
}
|
|
68
|
+
function packageNameToBinName(packageName) {
|
|
69
|
+
if (!packageName) return void 0;
|
|
70
|
+
if (packageName.startsWith("@")) return cleanString(packageName.split("/")[1]);
|
|
71
|
+
return cleanString(packageName);
|
|
72
|
+
}
|
|
73
|
+
function readPackageCliMetadata(packageJsonPath) {
|
|
74
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
75
|
+
const packageName = cleanString(parsed.name);
|
|
76
|
+
const version = cleanString(parsed.version);
|
|
77
|
+
const packageBinName = packageNameToBinName(packageName);
|
|
78
|
+
let name;
|
|
79
|
+
if (typeof parsed.bin === "string") {
|
|
80
|
+
name = packageBinName;
|
|
81
|
+
} else if (parsed.bin && typeof parsed.bin === "object" && !Array.isArray(parsed.bin)) {
|
|
82
|
+
const entries = Object.entries(parsed.bin).filter(
|
|
83
|
+
(entry) => cleanString(entry[0]) != null && typeof entry[1] === "string"
|
|
84
|
+
).map(([binName, target]) => [binName, normalizeBinTarget(target)]);
|
|
85
|
+
const packageDir = dirname(packageJsonPath);
|
|
86
|
+
const invokedPath = process.argv[1] ? resolve(process.argv[1]) : void 0;
|
|
87
|
+
const invoked = invokedPath ? realPathIfExists(invokedPath) ?? invokedPath : void 0;
|
|
88
|
+
name = (invoked ? entries.find(([, target]) => {
|
|
89
|
+
const targetPath = resolve(packageDir, target);
|
|
90
|
+
return (realPathIfExists(targetPath) ?? targetPath) === invoked;
|
|
91
|
+
})?.[0] : void 0) ?? (packageBinName ? entries.find(([binName]) => binName === packageBinName)?.[0] : void 0) ?? (entries.length === 1 ? entries[0]?.[0] : void 0);
|
|
53
92
|
}
|
|
93
|
+
return { ...name ? { name } : {}, ...version ? { version } : {} };
|
|
94
|
+
}
|
|
95
|
+
function createConnectorCli(opts) {
|
|
96
|
+
const packageJsonPath = opts.packageJson ? pathFrom(opts.packageJson, "packageJson") : void 0;
|
|
97
|
+
const packageMetadata = packageJsonPath ? readPackageCliMetadata(packageJsonPath) : {};
|
|
98
|
+
const name = cleanString(opts.name) ?? packageMetadata.name;
|
|
99
|
+
const version = packageMetadata.version;
|
|
100
|
+
if (!name) {
|
|
101
|
+
throw new TypeError("createConnectorCli: `name` or packageJson-derived bin name is required");
|
|
102
|
+
}
|
|
103
|
+
const programName = name;
|
|
104
|
+
const connectorPath = pathFrom(opts.connector, "connector");
|
|
54
105
|
let cachedId = opts.connectorId;
|
|
55
106
|
async function resolveConnectorId() {
|
|
56
107
|
if (cachedId !== void 0 && cachedId !== "") return cachedId;
|
|
57
|
-
const { connector } = await loadConnectorFromPath(
|
|
108
|
+
const { connector } = await loadConnectorFromPath(connectorPath);
|
|
58
109
|
cachedId = connector.id;
|
|
59
110
|
return cachedId;
|
|
60
111
|
}
|
|
61
112
|
async function run(argv = process.argv.slice(2)) {
|
|
113
|
+
const context = {
|
|
114
|
+
programName,
|
|
115
|
+
programVersion: version ?? "0.0.0",
|
|
116
|
+
connector: connectorPath,
|
|
117
|
+
connectorId: resolveConnectorId
|
|
118
|
+
};
|
|
119
|
+
for (const passthrough of opts.passthrough ?? []) {
|
|
120
|
+
if (passthrough.when(argv, context)) {
|
|
121
|
+
return passthrough.run(argv, context);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
62
124
|
const command = argv[0];
|
|
63
125
|
if (command === void 0 || command.startsWith("-")) {
|
|
64
|
-
return main(
|
|
126
|
+
return main(
|
|
127
|
+
argv,
|
|
128
|
+
version ? { programName, programVersion: version } : { programName }
|
|
129
|
+
);
|
|
65
130
|
}
|
|
66
131
|
let scoped = argv;
|
|
67
132
|
if (!hasConnectorFlag(argv)) {
|
|
68
133
|
if (CONFIG_PATH_COMMANDS.has(command)) {
|
|
69
|
-
scoped = injectAfterCommand(argv, "--connector",
|
|
134
|
+
scoped = injectAfterCommand(argv, "--connector", connectorPath);
|
|
70
135
|
} else if (ID_HEAD_COMMANDS.has(command)) {
|
|
71
136
|
const id = await resolveConnectorId();
|
|
72
137
|
scoped = injectAfterCommand(argv, "--connector", id);
|
|
@@ -75,9 +140,12 @@ function createConnectorCli(opts) {
|
|
|
75
140
|
scoped = appendFlag(argv, "--connector", id);
|
|
76
141
|
}
|
|
77
142
|
}
|
|
78
|
-
return main(
|
|
143
|
+
return main(
|
|
144
|
+
scoped,
|
|
145
|
+
version ? { programName, programVersion: version } : { programName }
|
|
146
|
+
);
|
|
79
147
|
}
|
|
80
|
-
return { run };
|
|
148
|
+
return { name: programName, version: version ?? "0.0.0", run };
|
|
81
149
|
}
|
|
82
150
|
export {
|
|
83
151
|
createConnectorCli
|
package/dist/cli/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/sdk.ts"],"sourcesContent":["/**\n * cli/sdk — the EMBEDDED SDK entry point for a developer-branded CLI.\n *\n * A developer adds agent-connector as a dependency, writes their connector\n * config, and ships their OWN bin. `createConnectorCli` returns a runner that\n * exposes EVERY agent-connector subcommand under the developer's brand, fully\n * delegated and AUTO-SCOPED to the developer's connector:\n *\n * #!/usr/bin/env node\n * import { fileURLToPath } from \"node:url\";\n * import { createConnectorCli } from \"@ken-jo/agent-connector/cli\";\n * createConnectorCli({\n * name: \"acme-db\",\n * connector: fileURLToPath(new URL(\"./agent-connector.config.mjs\", import.meta.url)),\n * }).run();\n * // fileURLToPath, NOT URL.pathname — .pathname yields \"/C:/…\" on Windows.\n *\n * Then a consumer runs `acme-db install`, `acme-db leaderboard`, `acme-db\n * telemetry`, `acme-db doctor`, etc. — and each one targets the developer's\n * connector WITHOUT the consumer having to pass --connector.\n *\n * This module is PURE ARGUMENT TRANSFORMATION: it injects the right --connector\n * (path) or --connector <id> filter when the user did not supply one, then hands\n * off to {@link main} with the developer's program name. It never duplicates any\n * command logic — every behavior still lives in the command modules.\n */\n\nimport { loadConnectorFromPath } from \"../core/load-connector.js\";\nimport { main } from \"./app.js\";\n\n/** Options for {@link createConnectorCli}. */\nexport interface CreateConnectorCliOptions {\n /** The developer's bin/brand name (shown in usage/help, e.g. \"acme-db\"). */\n name: string;\n /**\n * Absolute path to the developer's connector config (.mjs / .js / .json) that\n * ships inside their package. Injected as `--connector <path>` for the\n * connector-targeted subcommands when the user did not pass one.\n */\n connector: string;\n /**\n * The connector id used for the telemetry/leaderboard FILTER injection. When\n * omitted it is derived lazily by loading the connector config the first time a\n * telemetry/leaderboard subcommand runs.\n */\n connectorId?: string;\n}\n\n/** The runner returned by {@link createConnectorCli}. */\nexport interface ConnectorCli {\n /**\n * Run a branded invocation. `argv` defaults to `process.argv.slice(2)`.\n * Resolves to the process exit code (0 success, non-zero failure).\n */\n run(argv?: string[]): Promise<number>;\n}\n\n/**\n * Connector-targeted subcommands whose `--connector` is a CONFIG PATH: they load\n * the connector definition from disk. For these we inject the developer's config\n * PATH so their connector is the implicit target.\n *\n * (`uninstall` also accepts `--connector-id`; injecting the path is sufficient —\n * uninstall derives the id from the config when no explicit id is given.)\n */\nconst CONFIG_PATH_COMMANDS: ReadonlySet<string> = new Set([\n \"install\",\n \"uninstall\",\n \"upgrade\",\n // `sync` + `update` are back-compat aliases of `upgrade`; scope them too so a\n // branded `acme-db sync` / `acme-db update` still targets the dev connector.\n \"sync\",\n \"update\",\n \"doctor\",\n \"status\",\n \"package\",\n]);\n\n/**\n * Connector-targeted subcommands whose `--connector` is the registered connector\n * ID, spliced right AFTER the subcommand token: `serve` and `hook` pass it\n * straight to the runtime. (They cannot take a trailing flag — serve has a `--`\n * separator and hook has positionals — so the flag must lead.)\n */\nconst ID_HEAD_COMMANDS: ReadonlySet<string> = new Set([\"serve\", \"hook\"]);\n\n/**\n * View subcommands where `--connector <id>` is a FILTER appended at the END:\n * `leaderboard` (top-level) and `telemetry` (whose own sub — report|export|\n * leaderboard — is the leading positional, so the filter must come after it).\n * Appending keeps that leading positional intact while parseArgs still reads the\n * flag, so the branded tool shows ITS connector's data.\n *\n * Note: `usage` reads host CLI logs which carry no connector attribution, so it\n * is intentionally absent — there is nothing to scope it to.\n */\nconst ID_TAIL_COMMANDS: ReadonlySet<string> = new Set([\"telemetry\", \"leaderboard\"]);\n\n/**\n * Should the tail (telemetry/leaderboard) filter injection be SKIPPED because the\n * invocation is just asking for help / has no actionable sub? Skipping leaves the\n * branded usage text intact instead of turning `acme-db telemetry` into\n * `telemetry --connector <id>` (which the telemetry dispatcher would reject as an\n * unknown sub). True when a help flag appears, or when `telemetry` has no sub.\n */\nfunction wantsHelp(argv: string[]): boolean {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) return true;\n // `telemetry` with no sub-subcommand → show its help, don't inject a filter.\n if (argv[0] === \"telemetry\" && argv[1] === undefined) return true;\n return false;\n}\n\n/** Did the user already pass a --connector / --connector-id flag (any form)? */\nfunction hasConnectorFlag(argv: string[]): boolean {\n for (const a of argv) {\n if (a === \"--connector\" || a === \"--connector-id\") return true;\n if (a.startsWith(\"--connector=\") || a.startsWith(\"--connector-id=\")) return true;\n }\n return false;\n}\n\n/**\n * Splice `--connector <value>` immediately after the subcommand token (argv[0])\n * so it sits BEFORE any positionals or a `serve` `--` separator. Used for the\n * config-path commands and for serve/hook (whose `--` / positional grammar makes\n * trailing append unsafe). The original argv is never mutated.\n */\nfunction injectAfterCommand(argv: string[], flag: string, value: string): string[] {\n return [argv[0] as string, flag, value, ...argv.slice(1)];\n}\n\n/**\n * Append `--connector <value>` to the END of argv. Used for the view commands\n * (`leaderboard`/`telemetry`) whose leading positional sub must be preserved.\n * The original argv is never mutated.\n */\nfunction appendFlag(argv: string[], flag: string, value: string): string[] {\n return [...argv, flag, value];\n}\n\nexport function createConnectorCli(opts: CreateConnectorCliOptions): ConnectorCli {\n if (typeof opts.name !== \"string\" || opts.name.trim() === \"\") {\n throw new TypeError(\"createConnectorCli: `name` must be a non-empty string\");\n }\n if (typeof opts.connector !== \"string\" || opts.connector.trim() === \"\") {\n throw new TypeError(\"createConnectorCli: `connector` must be a non-empty path\");\n }\n\n // Cache the derived id so the connector module is loaded at most once across\n // repeated `.run()` calls in the same process.\n let cachedId: string | undefined = opts.connectorId;\n\n async function resolveConnectorId(): Promise<string> {\n if (cachedId !== undefined && cachedId !== \"\") return cachedId;\n const { connector } = await loadConnectorFromPath(opts.connector);\n cachedId = connector.id;\n return cachedId;\n }\n\n async function run(argv: string[] = process.argv.slice(2)): Promise<number> {\n const command = argv[0];\n\n // No subcommand, a help/version flag, or an unknown command: nothing to scope\n // — hand off verbatim so usage/version is branded and errors stay accurate.\n if (command === undefined || command.startsWith(\"-\")) {\n return main(argv, { programName: opts.name });\n }\n\n let scoped = argv;\n\n if (!hasConnectorFlag(argv)) {\n if (CONFIG_PATH_COMMANDS.has(command)) {\n // Inject the connector CONFIG PATH as the implicit target.\n scoped = injectAfterCommand(argv, \"--connector\", opts.connector);\n } else if (ID_HEAD_COMMANDS.has(command)) {\n // serve/hook take the connector ID and pass it to the runtime. Splice it\n // right after the subcommand token so a serve `--` separator and hook's\n // positionals are preserved.\n const id = await resolveConnectorId();\n scoped = injectAfterCommand(argv, \"--connector\", id);\n } else if (ID_TAIL_COMMANDS.has(command) && !wantsHelp(argv)) {\n // leaderboard/telemetry use the connector ID as a FILTER. Append it so\n // telemetry's leading positional sub (report|export|leaderboard) stays\n // the first token while parseArgs still reads the flag. We skip injection\n // for a bare/help invocation so the (un-filtered) usage text still shows.\n const id = await resolveConnectorId();\n scoped = appendFlag(argv, \"--connector\", id);\n }\n }\n\n return main(scoped, { programName: opts.name });\n }\n\n return { run };\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,IAAM,uBAA4C,oBAAI,IAAI;AAAA,EACxD;AAAA,EACA;AAAA,EACA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AAe,IAAI,OAAiB,QAAQ,KAAK,MAAM,CAAC,GAAoB;AAC1E,UAAM,UAAU,KAAK,CAAC;AAItB,QAAI,YAAY,UAAa,QAAQ,WAAW,GAAG,GAAG;AACpD,aAAO,KAAK,MAAM,EAAE,aAAa,KAAK,KAAK,CAAC;AAAA,IAC9C;AAEA,QAAI,SAAS;AAEb,QAAI,CAAC,iBAAiB,IAAI,GAAG;AAC3B,UAAI,qBAAqB,IAAI,OAAO,GAAG;AAErC,iBAAS,mBAAmB,MAAM,eAAe,KAAK,SAAS;AAAA,MACjE,WAAW,iBAAiB,IAAI,OAAO,GAAG;AAIxC,cAAM,KAAK,MAAM,mBAAmB;AACpC,iBAAS,mBAAmB,MAAM,eAAe,EAAE;AAAA,MACrD,WAAW,iBAAiB,IAAI,OAAO,KAAK,CAAC,UAAU,IAAI,GAAG;AAK5D,cAAM,KAAK,MAAM,mBAAmB;AACpC,iBAAS,WAAW,MAAM,eAAe,EAAE;AAAA,MAC7C;AAAA,IACF;AAEA,WAAO,KAAK,QAAQ,EAAE,aAAa,KAAK,KAAK,CAAC;AAAA,EAChD;AAEA,SAAO,EAAE,IAAI;AACf;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/sdk.ts"],"sourcesContent":["/**\n * cli/sdk — the EMBEDDED SDK entry point for a developer-branded CLI.\n *\n * A developer adds agent-connector as a dependency, writes their connector\n * config, and ships their OWN bin. `createConnectorCli` returns a runner that\n * exposes EVERY agent-connector subcommand under the developer's brand, fully\n * delegated and AUTO-SCOPED to the developer's connector:\n *\n * #!/usr/bin/env node\n * import { createConnectorCli } from \"@ken-jo/agent-connector/cli\";\n * createConnectorCli({\n * packageJson: new URL(\"./package.json\", import.meta.url),\n * connector: new URL(\"./agent-connector.config.mjs\", import.meta.url),\n * }).run();\n *\n * Then a consumer runs `acme-db install`, `acme-db leaderboard`, `acme-db\n * telemetry`, `acme-db doctor`, etc. — and each one targets the developer's\n * connector WITHOUT the consumer having to pass --connector.\n *\n * This module is PURE ARGUMENT TRANSFORMATION: it injects the right --connector\n * (path) or --connector <id> filter when the user did not supply one, then hands\n * off to {@link main} with the developer's program name/version. It never\n * duplicates any command logic — every behavior still lives in the command\n * modules.\n */\n\nimport { readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath, URL } from \"node:url\";\n\nimport { loadConnectorFromPath } from \"../core/load-connector.js\";\nimport { main } from \"./app.js\";\n\nexport type ConnectorCliPath = string | URL;\n\nexport interface ConnectorCliContext {\n /** Resolved brand/bin name shown in usage, errors, and --version output. */\n programName: string;\n /** Resolved branded package version shown by --version. */\n programVersion: string;\n /** Absolute connector config path injected into connector-targeted commands. */\n connector: string;\n /** Lazily resolves the connector id for telemetry/serve/hook scoping. */\n connectorId(): Promise<string>;\n}\n\nexport interface ConnectorCliPassthrough {\n /**\n * Return true when this invocation should be handled by custom package logic\n * instead of the agent-connector command dispatcher.\n */\n when(argv: readonly string[], context: ConnectorCliContext): boolean;\n /** Handle a matched invocation. Return the process exit code. */\n run(\n argv: readonly string[],\n context: ConnectorCliContext,\n ): number | Promise<number>;\n}\n\n/** Options for {@link createConnectorCli}. */\nexport interface CreateConnectorCliOptions {\n /**\n * The developer's bin/brand name (shown in usage/help, e.g. \"acme-db\").\n * Prefer `packageJson` for packaged connectors so name/version stay in one\n * source of truth; this remains available for custom launchers and tests.\n */\n name?: string;\n /**\n * package.json for the branded connector package. When supplied, the CLI\n * derives the bin name and version from package metadata.\n */\n packageJson?: ConnectorCliPath;\n /**\n * Absolute path or file URL to the developer's connector config (.mjs / .js /\n * .json) that ships inside their package. Injected as `--connector <path>` for\n * connector-targeted subcommands when the user did not pass one.\n */\n connector: ConnectorCliPath;\n /**\n * The connector id used for the telemetry/leaderboard FILTER injection. When\n * omitted it is derived lazily by loading the connector config the first time a\n * telemetry/leaderboard subcommand runs.\n */\n connectorId?: string;\n /**\n * Package-specific command escapes that should run before agent-connector's\n * dispatcher. Use sparingly for legacy/runtime commands that intentionally\n * live outside the universal connector surface.\n */\n passthrough?: readonly ConnectorCliPassthrough[];\n}\n\n/** The runner returned by {@link createConnectorCli}. */\nexport interface ConnectorCli {\n /** Resolved brand/bin name. */\n name: string;\n /** Resolved branded package version. */\n version: string;\n /**\n * Run a branded invocation. `argv` defaults to `process.argv.slice(2)`.\n * Resolves to the process exit code (0 success, non-zero failure).\n */\n run(argv?: string[]): Promise<number>;\n}\n\n/**\n * Connector-targeted subcommands whose `--connector` is a CONFIG PATH: they load\n * the connector definition from disk. For these we inject the developer's config\n * PATH so their connector is the implicit target.\n *\n * (`uninstall` also accepts `--connector-id`; injecting the path is sufficient —\n * uninstall derives the id from the config when no explicit id is given.)\n */\nconst CONFIG_PATH_COMMANDS: ReadonlySet<string> = new Set([\n \"install\",\n \"uninstall\",\n \"upgrade\",\n // `sync` + `update` are back-compat aliases of `upgrade`; scope them too so a\n // branded `acme-db sync` / `acme-db update` still targets the dev connector.\n \"sync\",\n \"update\",\n \"doctor\",\n \"status\",\n \"package\",\n]);\n\n/**\n * Connector-targeted subcommands whose `--connector` is the registered connector\n * ID, spliced right AFTER the subcommand token: `serve` and `hook` pass it\n * straight to the runtime. (They cannot take a trailing flag — serve has a `--`\n * separator and hook has positionals — so the flag must lead.)\n */\nconst ID_HEAD_COMMANDS: ReadonlySet<string> = new Set([\"serve\", \"hook\"]);\n\n/**\n * View subcommands where `--connector <id>` is a FILTER appended at the END:\n * `leaderboard` (top-level) and `telemetry` (whose own sub — report|export|\n * leaderboard — is the leading positional, so the filter must come after it).\n * Appending keeps that leading positional intact while parseArgs still reads the\n * flag, so the branded tool shows ITS connector's data.\n *\n * Note: `usage` reads host CLI logs which carry no connector attribution, so it\n * is intentionally absent — there is nothing to scope it to.\n */\nconst ID_TAIL_COMMANDS: ReadonlySet<string> = new Set([\"telemetry\", \"leaderboard\"]);\n\n/**\n * Should the tail (telemetry/leaderboard) filter injection be SKIPPED because the\n * invocation is just asking for help / has no actionable sub? Skipping leaves the\n * branded usage text intact instead of turning `acme-db telemetry` into\n * `telemetry --connector <id>` (which the telemetry dispatcher would reject as an\n * unknown sub). True when a help flag appears, or when `telemetry` has no sub.\n */\nfunction wantsHelp(argv: string[]): boolean {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) return true;\n // `telemetry` with no sub-subcommand → show its help, don't inject a filter.\n if (argv[0] === \"telemetry\" && argv[1] === undefined) return true;\n return false;\n}\n\n/** Did the user already pass a --connector / --connector-id flag (any form)? */\nfunction hasConnectorFlag(argv: string[]): boolean {\n for (const a of argv) {\n if (a === \"--connector\" || a === \"--connector-id\") return true;\n if (a.startsWith(\"--connector=\") || a.startsWith(\"--connector-id=\")) return true;\n }\n return false;\n}\n\n/**\n * Splice `--connector <value>` immediately after the subcommand token (argv[0])\n * so it sits BEFORE any positionals or a `serve` `--` separator. Used for the\n * config-path commands and for serve/hook (whose `--` / positional grammar makes\n * trailing append unsafe). The original argv is never mutated.\n */\nfunction injectAfterCommand(argv: string[], flag: string, value: string): string[] {\n return [argv[0] as string, flag, value, ...argv.slice(1)];\n}\n\n/**\n * Append `--connector <value>` to the END of argv. Used for the view commands\n * (`leaderboard`/`telemetry`) whose leading positional sub must be preserved.\n * The original argv is never mutated.\n */\nfunction appendFlag(argv: string[], flag: string, value: string): string[] {\n return [...argv, flag, value];\n}\n\nfunction cleanString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction pathFrom(value: ConnectorCliPath, label: string): string {\n if (value instanceof URL) return fileURLToPath(value);\n if (typeof value === \"string\" && value.trim() !== \"\") return value;\n throw new TypeError(`createConnectorCli: \\`${label}\\` must be a non-empty path or file URL`);\n}\n\nfunction normalizeBinTarget(target: string): string {\n return target.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nfunction realPathIfExists(path: string): string | undefined {\n try {\n return realpathSync(path);\n } catch {\n return undefined;\n }\n}\n\nfunction packageNameToBinName(packageName: string | undefined): string | undefined {\n if (!packageName) return undefined;\n if (packageName.startsWith(\"@\")) return cleanString(packageName.split(\"/\")[1]);\n return cleanString(packageName);\n}\n\nfunction readPackageCliMetadata(packageJsonPath: string): {\n name?: string;\n version?: string;\n} {\n const parsed = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n bin?: unknown;\n };\n const packageName = cleanString(parsed.name);\n const version = cleanString(parsed.version);\n const packageBinName = packageNameToBinName(packageName);\n\n let name: string | undefined;\n if (typeof parsed.bin === \"string\") {\n name = packageBinName;\n } else if (parsed.bin && typeof parsed.bin === \"object\" && !Array.isArray(parsed.bin)) {\n const entries = Object.entries(parsed.bin)\n .filter(\n (entry): entry is [string, string] =>\n cleanString(entry[0]) != null && typeof entry[1] === \"string\",\n )\n .map(([binName, target]) => [binName, normalizeBinTarget(target)] as const);\n const packageDir = dirname(packageJsonPath);\n const invokedPath = process.argv[1] ? resolve(process.argv[1]) : undefined;\n const invoked = invokedPath ? (realPathIfExists(invokedPath) ?? invokedPath) : undefined;\n name =\n (invoked\n ? entries.find(([, target]) => {\n const targetPath = resolve(packageDir, target);\n return (realPathIfExists(targetPath) ?? targetPath) === invoked;\n })?.[0]\n : undefined) ??\n (packageBinName ? entries.find(([binName]) => binName === packageBinName)?.[0] : undefined) ??\n (entries.length === 1 ? entries[0]?.[0] : undefined);\n }\n\n return { ...(name ? { name } : {}), ...(version ? { version } : {}) };\n}\n\nexport function createConnectorCli(opts: CreateConnectorCliOptions): ConnectorCli {\n const packageJsonPath = opts.packageJson ? pathFrom(opts.packageJson, \"packageJson\") : undefined;\n const packageMetadata = packageJsonPath ? readPackageCliMetadata(packageJsonPath) : {};\n const name = cleanString(opts.name) ?? packageMetadata.name;\n const version = packageMetadata.version;\n\n if (!name) {\n throw new TypeError(\"createConnectorCli: `name` or packageJson-derived bin name is required\");\n }\n const programName = name;\n const connectorPath = pathFrom(opts.connector, \"connector\");\n\n // Cache the derived id so the connector module is loaded at most once across\n // repeated `.run()` calls in the same process.\n let cachedId: string | undefined = opts.connectorId;\n\n async function resolveConnectorId(): Promise<string> {\n if (cachedId !== undefined && cachedId !== \"\") return cachedId;\n const { connector } = await loadConnectorFromPath(connectorPath);\n cachedId = connector.id;\n return cachedId;\n }\n\n async function run(argv: string[] = process.argv.slice(2)): Promise<number> {\n const context: ConnectorCliContext = {\n programName,\n programVersion: version ?? \"0.0.0\",\n connector: connectorPath,\n connectorId: resolveConnectorId,\n };\n for (const passthrough of opts.passthrough ?? []) {\n if (passthrough.when(argv, context)) {\n return passthrough.run(argv, context);\n }\n }\n\n const command = argv[0];\n\n // No subcommand, a help/version flag, or an unknown command: nothing to scope\n // — hand off verbatim so usage/version is branded and errors stay accurate.\n if (command === undefined || command.startsWith(\"-\")) {\n return main(\n argv,\n version ? { programName, programVersion: version } : { programName },\n );\n }\n\n let scoped = argv;\n\n if (!hasConnectorFlag(argv)) {\n if (CONFIG_PATH_COMMANDS.has(command)) {\n // Inject the connector CONFIG PATH as the implicit target.\n scoped = injectAfterCommand(argv, \"--connector\", connectorPath);\n } else if (ID_HEAD_COMMANDS.has(command)) {\n // serve/hook take the connector ID and pass it to the runtime. Splice it\n // right after the subcommand token so a serve `--` separator and hook's\n // positionals are preserved.\n const id = await resolveConnectorId();\n scoped = injectAfterCommand(argv, \"--connector\", id);\n } else if (ID_TAIL_COMMANDS.has(command) && !wantsHelp(argv)) {\n // leaderboard/telemetry use the connector ID as a FILTER. Append it so\n // telemetry's leading positional sub (report|export|leaderboard) stays\n // the first token while parseArgs still reads the flag. We skip injection\n // for a bare/help invocation so the (un-filtered) usage text still shows.\n const id = await resolveConnectorId();\n scoped = appendFlag(argv, \"--connector\", id);\n }\n }\n\n return main(\n scoped,\n version ? { programName, programVersion: version } : { programName },\n );\n }\n\n return { name: programName, version: version ?? \"0.0.0\", run };\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,SAAS,cAAc,oBAAoB;AAC3C,SAAS,SAAS,eAAe;AACjC,SAAS,eAAe,WAAW;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,EAAE,YAAY;AAAA,MACrE;AAAA,IACF;AAEA,QAAI,SAAS;AAEb,QAAI,CAAC,iBAAiB,IAAI,GAAG;AAC3B,UAAI,qBAAqB,IAAI,OAAO,GAAG;AAErC,iBAAS,mBAAmB,MAAM,eAAe,aAAa;AAAA,MAChE,WAAW,iBAAiB,IAAI,OAAO,GAAG;AAIxC,cAAM,KAAK,MAAM,mBAAmB;AACpC,iBAAS,mBAAmB,MAAM,eAAe,EAAE;AAAA,MACrD,WAAW,iBAAiB,IAAI,OAAO,KAAK,CAAC,UAAU,IAAI,GAAG;AAK5D,cAAM,KAAK,MAAM,mBAAmB;AACpC,iBAAS,WAAW,MAAM,eAAe,EAAE;AAAA,MAC7C;AAAA,IACF;AAEA,WAAO;AAAA,MACL;AAAA,MACA,UAAU,EAAE,aAAa,gBAAgB,QAAQ,IAAI,EAAE,YAAY;AAAA,IACrE;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,aAAa,SAAS,WAAW,SAAS,IAAI;AAC/D;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
print
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TQRLMA2C.js";
|
|
5
5
|
import {
|
|
6
6
|
detectInstalledPlatforms
|
|
7
7
|
} from "./chunk-ZMAJ2XFD.js";
|
|
@@ -71,4 +71,4 @@ async function run(argv) {
|
|
|
71
71
|
export {
|
|
72
72
|
run
|
|
73
73
|
};
|
|
74
|
-
//# sourceMappingURL=detect-
|
|
74
|
+
//# sourceMappingURL=detect-P5OA5UYM.js.map
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
parseScope,
|
|
17
17
|
parseTargets,
|
|
18
18
|
print
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TQRLMA2C.js";
|
|
20
20
|
import {
|
|
21
21
|
LineBuffer,
|
|
22
22
|
idKey,
|
|
@@ -627,4 +627,4 @@ async function run(argv) {
|
|
|
627
627
|
export {
|
|
628
628
|
run
|
|
629
629
|
};
|
|
630
|
-
//# sourceMappingURL=doctor-
|
|
630
|
+
//# sourceMappingURL=doctor-2O2Q6MIB.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TQRLMA2C.js";
|
|
5
5
|
import "./chunk-EHP7WISI.js";
|
|
6
6
|
import "./chunk-OP4KBXUO.js";
|
|
7
7
|
import "./chunk-Z2MRSS2I.js";
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
HOOK_EVENTS,
|
|
94
94
|
run
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=hook-
|
|
96
|
+
//# sourceMappingURL=hook-4N3BMKIK.js.map
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
parseTargets,
|
|
18
18
|
print,
|
|
19
19
|
renderInstallResult
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-TQRLMA2C.js";
|
|
21
21
|
import "./chunk-Z2MRSS2I.js";
|
|
22
22
|
import "./chunk-ZMAJ2XFD.js";
|
|
23
23
|
import "./chunk-KHO5WNTP.js";
|
|
@@ -379,4 +379,4 @@ async function run(argv) {
|
|
|
379
379
|
export {
|
|
380
380
|
run
|
|
381
381
|
};
|
|
382
|
-
//# sourceMappingURL=install-
|
|
382
|
+
//# sourceMappingURL=install-NPN77N3S.js.map
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
fail,
|
|
17
17
|
print
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TQRLMA2C.js";
|
|
19
19
|
import "./chunk-IVAWP6HH.js";
|
|
20
20
|
import "./chunk-GZGLCCEE.js";
|
|
21
21
|
|
|
@@ -134,4 +134,4 @@ export {
|
|
|
134
134
|
parseSince,
|
|
135
135
|
run
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=leaderboard-
|
|
137
|
+
//# sourceMappingURL=leaderboard-QKB36OBR.js.map
|
|
@@ -12,7 +12,7 @@ import "./chunk-OPXAP3AC.js";
|
|
|
12
12
|
import {
|
|
13
13
|
fail,
|
|
14
14
|
print
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TQRLMA2C.js";
|
|
16
16
|
import {
|
|
17
17
|
findConnectorConfig,
|
|
18
18
|
loadConnectorFromPath
|
|
@@ -132,4 +132,4 @@ async function run(argv) {
|
|
|
132
132
|
export {
|
|
133
133
|
run
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=package-
|
|
135
|
+
//# sourceMappingURL=package-Q6DV5247.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TQRLMA2C.js";
|
|
5
5
|
import {
|
|
6
6
|
runServe
|
|
7
7
|
} from "./chunk-EHP7WISI.js";
|
|
@@ -74,4 +74,4 @@ async function run(argv) {
|
|
|
74
74
|
export {
|
|
75
75
|
run
|
|
76
76
|
};
|
|
77
|
-
//# sourceMappingURL=serve-
|
|
77
|
+
//# sourceMappingURL=serve-MJTTXDX4.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
fail,
|
|
8
8
|
parseScope,
|
|
9
9
|
print
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TQRLMA2C.js";
|
|
11
11
|
import {
|
|
12
12
|
detectInstalledPlatforms
|
|
13
13
|
} from "./chunk-ZMAJ2XFD.js";
|
|
@@ -139,4 +139,4 @@ async function run(argv) {
|
|
|
139
139
|
export {
|
|
140
140
|
run
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=status-
|
|
142
|
+
//# sourceMappingURL=status-Q3UY4NZU.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
fail,
|
|
14
14
|
print
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TQRLMA2C.js";
|
|
16
16
|
import {
|
|
17
17
|
openStore
|
|
18
18
|
} from "./chunk-IVAWP6HH.js";
|
|
@@ -349,4 +349,4 @@ export {
|
|
|
349
349
|
parseSince,
|
|
350
350
|
run
|
|
351
351
|
};
|
|
352
|
-
//# sourceMappingURL=telemetry-
|
|
352
|
+
//# sourceMappingURL=telemetry-JHVRDDNK.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
parseTargets,
|
|
23
23
|
print,
|
|
24
24
|
renderInstallResult
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TQRLMA2C.js";
|
|
26
26
|
import "./chunk-Z2MRSS2I.js";
|
|
27
27
|
import "./chunk-ZMAJ2XFD.js";
|
|
28
28
|
import "./chunk-KHO5WNTP.js";
|
|
@@ -183,4 +183,4 @@ async function run(argv) {
|
|
|
183
183
|
export {
|
|
184
184
|
run
|
|
185
185
|
};
|
|
186
|
-
//# sourceMappingURL=uninstall-
|
|
186
|
+
//# sourceMappingURL=uninstall-H2SOV3AP.js.map
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
parseTargets,
|
|
19
19
|
print,
|
|
20
20
|
renderInstallResult
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-TQRLMA2C.js";
|
|
22
22
|
import "./chunk-Z2MRSS2I.js";
|
|
23
23
|
import "./chunk-ZMAJ2XFD.js";
|
|
24
24
|
import "./chunk-KHO5WNTP.js";
|
|
@@ -133,4 +133,4 @@ Refreshed home binary pointer: ${binPath}`);
|
|
|
133
133
|
export {
|
|
134
134
|
run
|
|
135
135
|
};
|
|
136
|
-
//# sourceMappingURL=upgrade-
|
|
136
|
+
//# sourceMappingURL=upgrade-UCSG7L5U.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
fail,
|
|
13
13
|
print
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TQRLMA2C.js";
|
|
15
15
|
|
|
16
16
|
// src/cli/commands/usage.ts
|
|
17
17
|
import { writeFileSync } from "fs";
|
|
@@ -321,4 +321,4 @@ export {
|
|
|
321
321
|
parseSince,
|
|
322
322
|
run
|
|
323
323
|
};
|
|
324
|
-
//# sourceMappingURL=usage-
|
|
324
|
+
//# sourceMappingURL=usage-4EGIJ4TM.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ken-jo/agent-connector",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.94",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write your MCP server + hooks once; agent-connector installs and adapts them across every AI-agent platform (Claude Code, Codex, Cursor, OpenCode, Copilot, Gemini, Warp, …) and gives you default, platform-independent per-tool token telemetry.",
|
|
6
6
|
"keywords": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/app.ts","../src/cli/banner.ts"],"sourcesContent":["/**\n * cli/app — shared CLI helpers + command dispatch (NO side effects).\n *\n * Command modules import the shared helpers (print, fail, parse-flags,\n * renderInstallResult) from here, and main() dispatches the first positional to a\n * command module.\n * This module never auto-runs — `cli/index.ts` is the thin bin entry that calls\n * `main()`. Keeping the auto-run out of here is what prevents a dispatch recursion\n * (a command module importing a helper must not re-trigger the program) and makes\n * it robust to bundler entry-splitting (the old import.meta.url entry-guard broke\n * once tsup hoisted this code into a shared chunk).\n */\n\nimport { createRequire } from \"node:module\";\nimport { homedir } from \"node:os\";\n\nimport { PALETTES, renderBrandBanner, resolveColorMode, shouldShowBanner } from \"./banner.js\";\nimport type {\n ChangeRecord,\n ConnectorSummary,\n InstallResult,\n InstallScope,\n PlatformId,\n ResolvedConnector,\n} from \"../core/types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Shared helpers (imported by the command modules)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Print a line to stdout (machine-readable payloads must stay on stdout). */\nexport function print(line: string): void {\n process.stdout.write(`${line}\\n`);\n}\n\n/**\n * The brand active for THIS invocation. main() sets it from\n * {@link MainOptions.programName} before dispatch, so error messages printed by\n * command modules via {@link fail} read as the embedding tool (e.g. `acme-db:`)\n * instead of always `agent-connector:`.\n */\nlet activeProgramName = \"agent-connector\";\n\n/** Print an error to stderr (branded) and return a non-zero exit code (default 2). */\nexport function fail(message: string, code = 2): number {\n process.stderr.write(`${activeProgramName}: ${message}\\n`);\n return code;\n}\n\n/**\n * The brand active for THIS invocation (what the banner renders in ASCII art).\n * main() sets it from {@link MainOptions.programName} before dispatch; reading it\n * here keeps the banner branded for an embedding SDK CLI without each command\n * module needing the program name threaded through.\n */\nexport function getActiveProgramName(): string {\n return activeProgramName;\n}\n\n/**\n * Print the branded ASCII banner once, atop install / uninstall / upgrade /\n * doctor — but ONLY for an interactive TTY (suppressed when piped/redirected,\n * under --json, or under --quiet) so scripts and pipelines see byte-identical\n * command output. The pure render lives in cli/banner; this thin wrapper reads\n * the real stdout/env and feeds it in.\n */\nexport function maybePrintBanner(flags: { json?: boolean; quiet?: boolean }): void {\n const isTTY = process.stdout.isTTY === true;\n const noColor = process.env.NO_COLOR != null && process.env.NO_COLOR !== \"\";\n if (!shouldShowBanner({ isTTY, noColor, json: flags.json === true, quiet: flags.quiet === true })) {\n return;\n }\n const color = resolveColorMode({\n noColor,\n colorterm: process.env.COLORTERM,\n term: process.env.TERM,\n });\n // Coerce an unknown/zero width to a conservative 80 so an unknown-width TTY\n // shows the safe one-line title rather than the 129-col block art.\n const c = process.stdout.columns;\n const columns = typeof c === \"number\" && c > 0 ? c : 80;\n // Rotate the gradient per run so each real invocation reads differently. The\n // random pick lives HERE (the impure wrapper) so the pure renderer stays\n // deterministic for tests/direct callers.\n const palette = PALETTES[Math.floor(Math.random() * PALETTES.length)]!;\n print(renderBrandBanner(activeProgramName, { color, columns, palette }));\n print(\"\");\n}\n\n/**\n * Resolve agent-connector's own package version at runtime. Works from both the\n * bundled dist layout (dist/*.js → ../package.json) and the src layout under\n * tsx/vitest (src/cli/ → ../../package.json); the name check guards against\n * accidentally reading some other package.json on the walk.\n */\nexport function resolveOwnVersion(): string {\n const req = createRequire(import.meta.url);\n for (const rel of [\"../package.json\", \"../../package.json\", \"../../../package.json\"]) {\n try {\n const pkg = req(rel) as { name?: string; version?: string };\n if (pkg.name === \"@ken-jo/agent-connector\" && typeof pkg.version === \"string\") {\n return pkg.version;\n }\n } catch {\n /* keep walking */\n }\n }\n return \"0.0.0\";\n}\n\n/** Parse a --scope value the CLI accepts (user|project) into an InstallScope. */\nexport function parseScope(value: string | undefined): InstallScope | null {\n if (value === \"user\" || value === \"project\") return value;\n return null;\n}\n\n/**\n * Parse a comma-separated --targets value into PlatformId[]. Returns undefined\n * when the flag is absent/empty so callers can fall back to connector/detection.\n */\nexport function parseTargets(value: string | undefined): PlatformId[] | undefined {\n if (value == null || value.trim() === \"\") return undefined;\n const ids = value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\") as PlatformId[];\n return ids.length > 0 ? ids : undefined;\n}\n\n/**\n * Build the render-only {@link ConnectorSummary} from a resolved connector. The\n * command modules call this on the {@link ResolvedConnector} they already loaded\n * and attach the result to {@link InstallResult.connector}, so the friendly\n * renderer can print a header describing WHAT was deployed without importing the\n * heavyweight connector type or its live handlers.\n */\nexport function buildConnectorSummary(connector: ResolvedConnector): ConnectorSummary {\n let server: ConnectorSummary[\"server\"];\n if (connector.server) {\n const s = connector.server;\n // stdio → \"node server.mjs\"; remote → the URL (best-effort one-liner).\n // HOME-relativize each part so a bundled absolute server path reads short.\n const cmd =\n s.transport === \"stdio\"\n ? [s.command, ...(s.args ?? [])]\n .filter((p): p is string => p != null && p !== \"\")\n .map((p) => tildify(p))\n .join(\" \")\n : (s.url ?? \"\");\n server = { transport: s.transport, command: cmd };\n }\n return {\n id: connector.id,\n version: connector.version,\n displayName: connector.displayName,\n server,\n hookEvents: [...connector.hookEvents],\n telemetryEnabled: connector.telemetry.enabled,\n commands: connector.commands.length,\n skills: connector.skills.length,\n subagents: connector.subagents.length,\n memory: connector.memory.length,\n hasStatusline: connector.statusline != null,\n actions: connector.actions.length,\n };\n}\n\n/**\n * Rewrite an absolute path under the user's home dir to a leading `~/…` so the\n * per-host paths read short. Leaves non-home and relative paths untouched.\n */\nfunction tildify(path: string): string {\n // Normalize both to forward slashes so the home-prefix check is separator-\n // robust (Windows mixes `\\` and `/`) and the displayed path reads `~/…`\n // consistently on every platform (Windows terminals accept `/` fine).\n const home = homedir().replace(/\\\\/g, \"/\");\n const np = path.replace(/\\\\/g, \"/\");\n if (home && (np === home || np.startsWith(home + \"/\"))) {\n return \"~\" + np.slice(home.length);\n }\n return np;\n}\n\n/** Truncate a long single-line command for the header (keeps it scannable). */\nfunction truncateCommand(cmd: string, max = 64): string {\n if (cmd.length <= max) return cmd;\n return cmd.slice(0, max - 1) + \"…\";\n}\n\n/**\n * The surface a ChangeRecord touched, derived from its detail (primary signal)\n * then its path (fallback for content files whose detail is a bare basename).\n */\ntype Surface = \"mcp\" | \"hooks\" | \"commands\" | \"skills\" | \"subagents\" | \"memory\" | \"statusline\" | \"actions\" | \"backup\" | \"other\";\n\nfunction classifySurface(c: ChangeRecord): Surface {\n const detail = c.detail.toLowerCase();\n // A safety backup the installer wrote before a destructive change.\n if (detail.startsWith(\"backed up\") || detail.includes(\"backup\")) return \"backup\";\n // MCP server entry: mcpServers.<id> / mcp_servers.<id> / mcp.servers.<id>.\n if (/^mcp[._]?servers?\\./.test(detail) || detail.startsWith(\"mcp.\")) return \"mcp\";\n // Normalized + native hook entries: hooks.<Event> (case varies per host).\n if (detail.startsWith(\"hooks.\") || detail.startsWith(\"hook \")) return \"hooks\";\n if (detail.includes(\"nativehooks\")) return \"hooks\";\n if (detail.startsWith(\"memory\")) return \"memory\";\n if (detail.startsWith(\"statusline\")) return \"statusline\";\n if (detail.startsWith(\"actions\") || detail.startsWith(\"action \")) return \"actions\";\n if (detail.includes(\"configpatch\")) return \"other\";\n // Path-based fallback for content-file surfaces (detail is a bare basename).\n const p = (c.path ?? \"\").replace(/\\\\/g, \"/\").toLowerCase();\n if (/\\/commands?\\//.test(p)) return \"commands\";\n if (/\\/skills?\\//.test(p)) return \"skills\";\n if (/\\/(subagents?|agents?)\\//.test(p)) return \"subagents\";\n // Detail mentions a surface noun (skip/warn lines like \"no skills\").\n if (/\\bcommands?\\b/.test(detail)) return \"commands\";\n if (/\\bskills?\\b/.test(detail)) return \"skills\";\n if (/\\bsubagents?\\b/.test(detail)) return \"subagents\";\n return \"other\";\n}\n\nconst SURFACE_LABEL_SINGULAR: Record<Surface, string> = {\n mcp: \"MCP server\",\n hooks: \"hook\",\n commands: \"command\",\n skills: \"skill\",\n subagents: \"subagent\",\n memory: \"memory block\",\n statusline: \"status line\",\n actions: \"action\",\n backup: \"backup\",\n other: \"change\",\n};\n\n/** Pluralize a surface count, e.g. (2,\"hooks\") → \"2 hooks\". */\nfunction countLabel(n: number, surface: Surface): string {\n const base = SURFACE_LABEL_SINGULAR[surface];\n if (surface === \"mcp\") return \"MCP server\"; // singular by construction\n return n === 1 ? `1 ${base}` : `${n} ${base}s`;\n}\n\n/** Verb-appropriate glyph for a host's NET status. */\nfunction hostGlyph(status: \"ok\" | \"skip\" | \"warn\"): string {\n return status === \"warn\" ? \"!\" : status === \"skip\" ? \"=\" : \"✓\";\n}\n\n/**\n * One host's collapsed view: its net status, a surface summary line, the\n * deduped HOME-relativized paths it touched, and any inline warnings.\n */\ninterface HostGroup {\n platform: PlatformId;\n status: \"ok\" | \"skip\" | \"warn\";\n summary: string;\n paths: string[];\n warnings: string[];\n}\n\n/**\n * Collapse the per-(host,surface) ChangeRecords into ONE entry per host:\n * - status: warn if any record warned; ok if any created/updated/removed;\n * else skip (everything was a no-op).\n * - summary: the active (non-skip) surfaces, joined (\"MCP server + 2 hooks\").\n * When every record skipped, the reason is surfaced instead.\n */\nfunction groupByHost(changes: ChangeRecord[], verb: Verb): HostGroup[] {\n const order: PlatformId[] = [];\n const byHost = new Map<PlatformId, ChangeRecord[]>();\n for (const c of changes) {\n if (!byHost.has(c.platform)) {\n byHost.set(c.platform, []);\n order.push(c.platform);\n }\n byHost.get(c.platform)!.push(c);\n }\n\n const groups: HostGroup[] = [];\n for (const platform of order) {\n const recs = byHost.get(platform)!;\n // A safety backup the installer wrote is INCIDENTAL, not an installed\n // surface: it must not flip an otherwise-no-op host to \"changed\" (an\n // idempotent re-install that only re-backs-up should still read \"already\n // current\"). It is shown only ALONGSIDE a real surface change.\n const written = recs.filter((c) => c.action !== \"skip\" && c.action !== \"warn\");\n const realChanges = written.filter((c) => classifySurface(c) !== \"backup\");\n const warned = recs.filter((c) => c.action === \"warn\");\n const status: HostGroup[\"status\"] =\n warned.length > 0 ? \"warn\" : realChanges.length > 0 ? \"ok\" : \"skip\";\n\n // Surface summary from the written records (created/updated/removed),\n // preserving a stable surface order and collapsing per-surface counts. The\n // incidental `backup` surface is included ONLY when a real surface changed.\n const SURFACE_ORDER: Surface[] = [\n \"mcp\",\n \"hooks\",\n \"commands\",\n \"skills\",\n \"subagents\",\n \"memory\",\n \"statusline\",\n \"actions\",\n \"backup\",\n \"other\",\n ];\n const counts = new Map<Surface, number>();\n const summarySource = realChanges.length > 0 ? written : realChanges;\n for (const c of summarySource) {\n const s = classifySurface(c);\n counts.set(s, (counts.get(s) ?? 0) + 1);\n }\n const parts = SURFACE_ORDER.filter((s) => counts.has(s)).map((s) =>\n countLabel(counts.get(s)!, s),\n );\n\n let summary: string;\n if (parts.length > 0) {\n summary = parts.join(\" + \");\n } else if (status === \"warn\") {\n // No real surface change but a warning — the warning line carries detail.\n summary = \"\";\n } else {\n // Nothing real changed: surface a skip reason (or note the incidental\n // backup) for context.\n const reason =\n recs.find((c) => c.action === \"skip\")?.detail ??\n (written.length > 0 ? \"already current (re-backed-up only)\" : \"no changes\");\n summary = verb === \"uninstall\" ? `nothing to remove (${reason})` : `unchanged (${reason})`;\n }\n\n const paths = [\n ...new Set(\n recs\n .filter((c) => c.path != null && c.path !== \"\")\n .map((c) => tildify(c.path!)),\n ),\n ];\n const warnings = warned.map((c) => c.detail);\n\n groups.push({ platform, status, summary, paths, warnings });\n }\n return groups;\n}\n\ntype Verb = \"install\" | \"upgrade\" | \"uninstall\";\n\n/**\n * Render an InstallResult as a friendly, grouped report (the DEFAULT output):\n * 1. a connector header (id/version/displayName + server/hooks/telemetry +\n * one line per shipped content surface), when the summary is threaded in;\n * 2. one line per host (net glyph + surface summary + deduped ~/… paths),\n * with any host warnings inline beneath it;\n * 3. a friendly closing line + restart hint + doctor/uninstall next steps.\n *\n * Used by install / upgrade / uninstall. The exit-non-zero-on-warn convention\n * is enforced by the callers (this function only renders).\n */\nexport function renderInstallResult(result: InstallResult, verb: Verb): string {\n const lines: string[] = [];\n const summary = result.connector;\n\n // ── 1. Connector header ───────────────────────────────────────────────────\n if (summary) {\n const head = [`${summary.id} v${summary.version}`];\n if (summary.displayName && summary.displayName !== summary.id) {\n head.push(summary.displayName);\n }\n lines.push(head.join(\" · \"));\n\n if (summary.server) {\n lines.push(\n ` server ${summary.server.transport} · ${truncateCommand(summary.server.command)}`,\n );\n } else {\n lines.push(\" server (hooks-only)\");\n }\n if (summary.hookEvents.length > 0) {\n lines.push(` hooks ${summary.hookEvents.join(\", \")}`);\n }\n lines.push(` telemetry ${summary.telemetryEnabled ? \"on\" : \"off\"}`);\n if (summary.commands > 0)\n lines.push(` commands ${summary.commands}`);\n if (summary.skills > 0) lines.push(` skills ${summary.skills}`);\n if (summary.subagents > 0)\n lines.push(` subagents ${summary.subagents}`);\n if (summary.memory > 0) lines.push(` memory ${summary.memory}`);\n if (summary.hasStatusline) lines.push(` statusline 1`);\n if (summary.actions > 0) lines.push(` actions ${summary.actions}`);\n lines.push(\"\");\n } else {\n // No summary threaded (back-compat): keep a minimal verb header.\n const mode = result.dryRun ? \" (dry-run — nothing written)\" : \"\";\n lines.push(`${verb} \"${result.connectorId}\"${mode}`);\n }\n\n // ── 2. Per-host grouping ──────────────────────────────────────────────────\n const groups = groupByHost(result.changes, verb);\n if (groups.length === 0) {\n lines.push(\"(no changes)\");\n } else {\n const verbed = verb === \"uninstall\" ? \"removed from\" : verb === \"upgrade\" ? \"synced to\" : \"detected\";\n lines.push(`→ ${groups.length} agent ${groups.length === 1 ? \"CLI\" : \"CLIs\"} ${verbed}:`);\n // Width-align the platform column for a scannable table; the summary column\n // gets a fixed min width but always keeps a 2-space gap before the paths\n // even when an unusually long summary overflows it.\n const pad = Math.max(...groups.map((g) => g.platform.length));\n for (const g of groups) {\n const glyph = hostGlyph(g.status);\n const name = g.platform.padEnd(pad);\n const pathsCol = g.paths.join(\", \");\n const gap = pathsCol === \"\" ? \"\" : \" \";\n const summaryCol = pathsCol === \"\" ? g.summary : g.summary.padEnd(26) + gap;\n lines.push(` ${glyph} ${name} ${summaryCol}${pathsCol}`.trimEnd());\n for (const w of g.warnings) lines.push(` ! ${w}`);\n }\n }\n\n // ── 3. Closing summary + next steps ───────────────────────────────────────\n // The headline file tally counts only REAL surface writes — an incidental\n // safety backup must not masquerade as an installed file, so a re-install\n // whose only write was a backup honestly reports 0 files / \"already current\".\n const tally = result.changes.reduce(\n (acc, c) => {\n const isWrite = c.action === \"create\" || c.action === \"update\" || c.action === \"remove\";\n if (isWrite && classifySurface(c) !== \"backup\") acc.files += 1;\n if (c.action === \"warn\") acc.warns += 1;\n return acc;\n },\n { files: 0, warns: 0 },\n );\n const cliCount = groups.length;\n const cliWord = cliCount === 1 ? \"CLI\" : \"CLIs\";\n const fileWord = tally.files === 1 ? \"file\" : \"files\";\n\n lines.push(\"\");\n if (verb === \"uninstall\") {\n if (result.dryRun) {\n lines.push(`✓ Would remove ${summary?.id ?? result.connectorId} from ${cliCount} ${cliWord} · ${tally.files} ${fileWord} (dry-run — nothing written).`);\n } else if (tally.files === 0 && tally.warns === 0) {\n lines.push(`✓ Nothing to remove — ${summary?.id ?? result.connectorId} was not installed (zero residue).`);\n } else {\n lines.push(`✓ Removed ${summary?.id ?? result.connectorId} from ${cliCount} ${cliWord} · ${tally.files} ${fileWord} cleaned${tally.warns === 0 ? \" (zero residue)\" : \"\"}.`);\n }\n } else {\n const what = verb === \"upgrade\" ? \"Synced\" : \"Installed\";\n const wouldWhat = verb === \"upgrade\" ? \"sync\" : \"install\";\n if (result.dryRun) {\n lines.push(`✓ Would ${wouldWhat} ${summary?.id ?? result.connectorId} to ${cliCount} ${cliWord} · ${tally.files} ${fileWord} (dry-run — nothing written).`);\n } else if (tally.files === 0) {\n lines.push(`✓ ${summary?.id ?? result.connectorId}: already current on ${cliCount} ${cliWord} — nothing to write.`);\n } else {\n lines.push(`✓ ${what} ${summary?.id ?? result.connectorId} to ${cliCount} ${cliWord} · ${tally.files} ${fileWord}. Restart each CLI to load it.`);\n }\n }\n\n // Warnings block (kept explicit — callers exit non-zero on any warn). A\n // remote-transport connector pushes the SAME string to both a warn\n // ChangeRecord (already shown inline on its host line) and result.warnings, so\n // skip any bottom-block entry already surfaced inline to show each warning ONCE.\n const inlineWarnings = new Set(groups.flatMap((g) => g.warnings));\n const blockWarnings = result.warnings.filter((w) => !inlineWarnings.has(w));\n if (blockWarnings.length > 0) {\n lines.push(\"\");\n lines.push(\"warnings:\");\n for (const w of blockWarnings) lines.push(` ! ${w}`);\n }\n\n // Next-step hints (the verbs read as the active brand).\n if (verb === \"uninstall\") {\n lines.push(` Verify it's gone: ${activeProgramName} doctor`);\n } else {\n lines.push(\n ` Verify: ${activeProgramName} doctor · Remove: ${activeProgramName} uninstall`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Command dispatch\n// ─────────────────────────────────────────────────────────────────────────\n\n/** A command module: takes the post-command argv slice, returns an exit code. */\ntype CommandModule = { run: (argv: string[]) => Promise<number> | number };\n\n/** Lazy command loaders — keyed by the first positional. Imported on demand. */\nconst COMMANDS: Record<string, () => Promise<CommandModule>> = {\n detect: () => import(\"./commands/detect.js\"),\n install: () => import(\"./commands/install.js\"),\n uninstall: () => import(\"./commands/uninstall.js\"),\n // `upgrade` is the single \"bring everything current\" verb (re-render host\n // config + refresh the home pointer + managed channel guidance). `sync` and\n // `update` are kept as back-compat aliases that route to the same module so\n // existing scripts/docs keep working without a second concept to learn.\n upgrade: () => import(\"./commands/upgrade.js\"),\n sync: () => import(\"./commands/upgrade.js\"),\n update: () => import(\"./commands/upgrade.js\"),\n package: () => import(\"./commands/package.js\"),\n doctor: () => import(\"./commands/doctor.js\"),\n status: () => import(\"./commands/status.js\"),\n telemetry: () => import(\"./commands/telemetry.js\"),\n usage: () => import(\"./commands/usage.js\"),\n leaderboard: () => import(\"./commands/leaderboard.js\"),\n hook: () => import(\"./commands/hook.js\"),\n // Internal (omitted from USAGE): the statusline (HUD) entrypoint a host's\n // status line config points at. Fail-safe: always exits 0 with at most a\n // rendered line. See cli/commands/statusline.ts.\n statusline: () => import(\"./commands/statusline.js\"),\n // Internal (omitted from USAGE): the user-invokable action entrypoint a future\n // host affordance points at. USER-TRIGGERED: surfaces errors (exit 1 + stderr),\n // unlike the fail-open hook / fail-safe statusline. See cli/commands/action.ts.\n action: () => import(\"./commands/action.js\"),\n serve: () => import(\"./commands/serve.js\"),\n // Hidden (omitted from USAGE): the opt-in host-native turn-usage entrypoint an\n // AfterModel / PostInvocation hook points at. Always exits 0; records a\n // distinct `model_turn` row. See cli/commands/usage-event.ts.\n \"usage-event\": () => import(\"./commands/usage-event.js\"),\n};\n\n/** Default program name; an embedding SDK CLI overrides it via {@link MainOptions}. */\nexport const DEFAULT_PROGRAM_NAME = \"agent-connector\";\n\n/**\n * One-line usage signature per command — the single central copy behind\n * `<command> --help` and the friendly bad-flag error. Command modules use\n * node:util parseArgs (strict), which THROWS on an unknown flag; without the\n * dispatcher-level handling in {@link main}, `agent-connector install --help`\n * would die with a raw ERR_PARSE_ARGS stack trace — the very invocation the\n * root help tells users to run.\n */\nconst COMMAND_USAGE: Record<string, string> = {\n detect: \"detect [--json] [--project <dir>]\",\n install:\n \"install [<source>] [--method direct|marketplace] [--connector <source>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--force] [--quiet]\\n\" +\n \" <source> a local path OR a remote GitHub connector: owner/repo[/subpath][#ref], a github.com URL (incl. /tree/<ref>/<sub>), git@github.com:owner/repo, or github:owner/repo. Remote sources are fetched to ~/.agent-connector/sources/ and must be an agent-connector package (have an agent-connector.config.{mjs,js,json}).\",\n uninstall:\n \"uninstall [--method auto|direct|marketplace] [--connector <path>] [--connector-id <id>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--purge] [--quiet]\",\n upgrade:\n \"upgrade [--method direct|marketplace] [--channel stable|latest] [--connector <path>] [--scope user|project] [--targets a,b] [--project <dir>] [--dry-run] [--quiet]\",\n sync: \"sync — alias of upgrade (see `upgrade --help`)\",\n update: \"update — alias of upgrade (see `upgrade --help`)\",\n package:\n \"package [--connector <path>] [--format <fmt>|all] [--out <dir>] [--project <dir>] [--dry-run]\",\n doctor:\n \"doctor [--targets a,b] [--connector <path>] [--scope user|project] [--project <dir>] [--probe] [--explain] [--json] [--heal] [--dry-run] [--quiet]\\n\" +\n \" --explain per-(host,event) hook honor matrix (honored/degraded/dropped). Exit non-zero ONLY when an explicitly-targeted host DEGRADES a declared event (fires it but silently won't honor the reply); dropped/mcp-only hosts and fleet-wide (targets:auto) gaps are informational (exit 0).\",\n status: \"status [--connector <path>] [--scope user|project] [--project <dir>] [--json]\",\n telemetry:\n \"telemetry report|export|leaderboard [--by <dim>] [--since <dur>] [--connector <id>] [--scope <slice>] [--format csv|json] [--out <file>] [--json]\",\n usage:\n \"usage report|export|leaderboard [--by <dim>] [--since <dur>] [--platform <id>] [--format csv|json] [--out <file>] [--json]\",\n leaderboard: \"leaderboard [--since <dur>] [--connector <id>] [--scope <slice>] [--json]\",\n hook: \"hook <platform> <event> --connector <id> (internal — host hook configs point here)\",\n statusline:\n \"statusline <platform> --connector <id> (internal — host status line configs point here)\",\n action:\n \"action <platform> <actionId> --connector <id> (internal — host action affordances point here)\",\n serve:\n \"serve --connector <id> [--scope user|project] [--host <platformId>] -- <command> [args...] (internal — host MCP entries point here)\",\n};\n\n/**\n * Build the top-level usage string for a given program name. The brand replaces\n * \"agent-connector\" in the title, the `usage:` line, and the per-command help\n * footer so an embedded CLI (e.g. `acme-db`) reads as its own tool.\n */\nfunction buildUsage(programName: string): string {\n return `${programName} — write your MCP server + hooks once, install everywhere.\n\nusage: ${programName} <command> [flags]\n\ncommands:\n detect List the AI-agent platforms installed on this machine.\n install Deploy a connector across its target platforms (--method direct writes host config; --method marketplace drives the host's plugin install).\n uninstall Remove a connector's registrations (--method auto reverses whichever method is actually installed).\n upgrade Bring everything current: re-render host config + heal the home pointer + managed update guidance (alias: update, sync).\n package Emit a marketplace/extension bundle (10 host formats, or the standard artifacts mcp-server-json | mcpb).\n doctor Health-check every detected platform; non-zero exit on any failure.\n status Light install-state summary: which connectors are present on which hosts (always exits 0).\n telemetry Inspect local per-tool token telemetry (report | export | leaderboard).\n usage Inspect host-native token usage from agent CLI logs (report | export | leaderboard).\n leaderboard Three leaderboards: 🔌 MCP/plugin (mcp-self) + 🖥️ host/user (host-scan-logs) + 🛰️ host-native turns (host-native-live) — never summed.\n hook Universal json-stdio hook entrypoint (hosts call this).\n serve Telemetry-wrapping MCP stdio proxy (wraps a real server command).\n\nRun \\`${programName} <command> --help\\` for command-specific flags.`;\n}\n\n/** Options accepted by {@link main}. */\nexport interface MainOptions {\n /**\n * The brand shown in usage/help text. Defaults to {@link DEFAULT_PROGRAM_NAME}.\n * An embedding SDK CLI (see cli/sdk.ts) passes its own bin name so every\n * subcommand's help reads as the developer's tool.\n */\n programName?: string;\n}\n\nexport async function main(argv: string[], opts: MainOptions = {}): Promise<number> {\n const programName = opts.programName ?? DEFAULT_PROGRAM_NAME;\n activeProgramName = programName; // brand every fail() in this invocation\n const usage = buildUsage(programName);\n const command = argv[0];\n\n if (command == null || command === \"--help\" || command === \"-h\" || command === \"help\") {\n print(usage);\n return command == null ? 1 : 0;\n }\n if (command === \"--version\" || command === \"-v\") {\n print(`${programName} ${resolveOwnVersion()}`);\n return 0;\n }\n\n const loader = COMMANDS[command];\n if (!loader) {\n process.stderr.write(`${programName}: unknown command \"${command}\"\\n\\n`);\n process.stderr.write(`${usage}\\n`);\n return 2;\n }\n\n // Per-command help: no command module defines a --help flag (strict parseArgs\n // would throw on it), so answer it centrally from COMMAND_USAGE.\n const rest = argv.slice(1);\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n const sig = COMMAND_USAGE[command];\n if (sig) {\n print(`usage: ${programName} ${sig}`);\n return 0;\n }\n }\n\n const mod = await loader();\n try {\n return await mod.run(rest);\n } catch (err) {\n // Friendly bad-flag errors: strict parseArgs throws ERR_PARSE_ARGS_* for an\n // unknown/malformed option — print the message + the usage line instead of\n // letting a raw stack trace reach the user. Everything else still rethrows\n // (the bin entry reports those as fatal).\n const code = (err as { code?: string }).code;\n if (typeof code === \"string\" && code.startsWith(\"ERR_PARSE_ARGS\")) {\n const message = err instanceof Error ? err.message : String(err);\n const sig = COMMAND_USAGE[command];\n if (sig) process.stderr.write(`usage: ${programName} ${sig}\\n`);\n return fail(message);\n }\n throw err;\n }\n}\n","/**\n * cli/banner — the branded ASCII-art header shown once atop install / uninstall\n * / upgrade / doctor.\n *\n * Two PURE functions drive everything (no process.* reads here — the command\n * wiring injects the real env so tests can call these directly without a TTY):\n *\n * renderBrandBanner(name, { color, columns, palette }) → the banner string\n * shouldShowBanner({ isTTY, noColor, json, quiet }) → whether to show it\n *\n * RESPONSIVE (one line, NEVER stacked), two forms:\n * • WIDE — a 6-row \"ANSI Shadow\" block font (solid `█` + `╗╔╝╚║═` shadow,\n * ~8 cols/char, hand-transcribed + fixed-width so it tiles cleanly) when its\n * render fits the terminal width.\n * • NARROW — a single-line gradient TITLE `◆ AGENT-CONNECTOR` (the brand\n * uppercased, each char colored along the palette + bold). ~18 cols, so it\n * fits any real terminal; it is the universal narrow form.\n * The WIDE font covers the connector-id charset [A-Za-z0-9 ._-].\n *\n * COLOR: a palette gradient (three RGB stops, a {@link Palette}) — swept per\n * column across the block art, or per character across the title. The render is\n * PURE and palette-parameterized — the caller picks the palette (the impure\n * app.ts wrapper rotates {@link PALETTES} per run). truecolor→256→16→none tiers\n * all honor the palette; NO_COLOR = zero ANSI.\n */\n\n/** Color capability the host terminal advertises, highest → lowest. */\nexport type ColorMode = \"truecolor\" | \"ansi256\" | \"ansi16\" | \"none\";\n\n/** A 24-bit RGB triple. */\nexport type RGB = readonly [number, number, number];\n\n/** A 3-stop gradient: the sweep lerps stop0 → stop1 → stop2 across the columns. */\nexport type Palette = readonly [RGB, RGB, RGB];\n\n/**\n * The 10 rotation palettes. The impure {@link maybePrintBanner} wrapper picks one\n * at random per run so each real invocation shows a different color; the pure\n * renderer defaults to PALETTES[0] so direct callers + tests stay deterministic.\n */\nexport const PALETTES: readonly Palette[] = [\n [[255, 210, 0], [255, 110, 10], [220, 30, 25]], // Sunset\n [[255, 225, 90], [255, 120, 0], [200, 20, 20]], // Lava\n [[230, 30, 30], [255, 120, 0], [255, 220, 0]], // Fire\n [[255, 225, 120], [255, 170, 40], [225, 110, 20]], // Amber gold\n [[255, 205, 150], [255, 150, 130], [255, 120, 175]], // Peach pastel\n [[255, 80, 170], [200, 40, 200], [100, 60, 210]], // Berry\n [[0, 220, 180], [0, 160, 230], [60, 90, 230]], // Ocean\n [[80, 230, 140], [0, 200, 210], [150, 90, 235]], // Aurora\n [[170, 230, 90], [60, 200, 120], [20, 150, 140]], // Forest\n [[0, 200, 200], [40, 80, 230], [200, 40, 200]], // Synthwave\n] as const;\n\n/** Inputs to {@link renderBrandBanner} — all injected, never read from process. */\nexport interface BannerOptions {\n /** Color capability to render at. \"none\" emits zero ANSI codes. */\n color: ColorMode;\n /** Terminal width in columns; selects the form (wide block art → one-line title). */\n columns: number;\n /** The 3-stop gradient. Defaults to {@link PALETTES}[0] (Sunset) when omitted. */\n palette?: Palette;\n}\n\n/** Inputs to {@link shouldShowBanner} — the real env, injected by the caller. */\nexport interface BannerGate {\n /** process.stdout.isTTY (banner is suppressed entirely when not a TTY). */\n isTTY: boolean;\n /** NO_COLOR is set (the banner still shows, but with zero color codes). */\n noColor: boolean;\n /** A machine-readable --json was requested (suppress entirely). */\n json: boolean;\n /** An explicit --quiet was passed (suppress entirely). */\n quiet: boolean;\n}\n\n/**\n * Whether to print the banner at all. The banner is decorative, so it shows ONLY\n * for an interactive TTY and never when output is being consumed by a script or\n * pipeline: not when piped/redirected (`!isTTY`), not under `--json`, and not\n * under `--quiet`. `NO_COLOR` does NOT suppress it — the banner renders without\n * color in that case (handled by {@link resolveColorMode}).\n */\nexport function shouldShowBanner(gate: BannerGate): boolean {\n return gate.isTTY && !gate.json && !gate.quiet;\n}\n\n/**\n * Resolve the color tier from the (injected) terminal env. 24-bit when the\n * terminal advertises it (COLORTERM=truecolor|24bit), 256-color when TERM names\n * a 256 palette, else 16-color — and PLAIN (no color) under NO_COLOR or a dumb /\n * absent TERM.\n */\nexport function resolveColorMode(env: {\n noColor: boolean;\n colorterm?: string | undefined;\n term?: string | undefined;\n}): ColorMode {\n if (env.noColor) return \"none\";\n const term = (env.term ?? \"\").toLowerCase();\n if (term === \"\" || term === \"dumb\") return \"none\";\n const colorterm = (env.colorterm ?? \"\").toLowerCase();\n if (colorterm === \"truecolor\" || colorterm === \"24bit\") return \"truecolor\";\n if (term.includes(\"256\")) return \"ansi256\";\n return \"ansi16\";\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// WIDE font — \"ANSI Shadow\" (6 rows). Hand-transcribed bold figlet glyphs —\n// solid `█` with a `╗╔╝╚║═` 3D shadow — fixed-width per glyph so they TILE\n// cleanly when concatenated (~8 cols/char → \"agent-connector\" ≈ 126 cols on\n// one line). Used only when the terminal is wide enough.\n// ─────────────────────────────────────────────────────────────────────────\n\nconst WIDE_FONT: Record<string, readonly string[]> = {\n A: [\" █████╗ \", \"██╔══██╗\", \"███████║\", \"██╔══██║\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n B: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔══██╗\", \"██████╔╝\", \"╚═════╝ \"],\n C: [\" ██████╗\", \"██╔════╝\", \"██║ \", \"██║ \", \"╚██████╗\", \" ╚═════╝\"],\n D: [\"██████╗ \", \"██╔══██╗\", \"██║ ██║\", \"██║ ██║\", \"██████╔╝\", \"╚═════╝ \"],\n E: [\"███████╗\", \"██╔════╝\", \"█████╗ \", \"██╔══╝ \", \"███████╗\", \"╚══════╝\"],\n F: [\"███████╗\", \"██╔════╝\", \"█████╗ \", \"██╔══╝ \", \"██║ \", \"╚═╝ \"],\n G: [\" ██████╗ \", \"██╔════╝ \", \"██║ ███╗\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n H: [\"██╗ ██╗\", \"██║ ██║\", \"███████║\", \"██╔══██║\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n I: [\"██╗\", \"██║\", \"██║\", \"██║\", \"██║\", \"╚═╝\"],\n J: [\" ██╗\", \" ██║\", \" ██║\", \"██ ██║\", \"╚█████╔╝\", \" ╚════╝ \"],\n K: [\"██╗ ██╗\", \"██║ ██╔╝\", \"█████╔╝ \", \"██╔═██╗ \", \"██║ ██╗\", \"╚═╝ ╚═╝\"],\n L: [\"██╗ \", \"██║ \", \"██║ \", \"██║ \", \"███████╗\", \"╚══════╝\"],\n M: [\"███╗ ███╗\", \"████╗ ████║\", \"██╔████╔██║\", \"██║╚██╔╝██║\", \"██║ ╚═╝ ██║\", \"╚═╝ ╚═╝\"],\n N: [\"███╗ ██╗\", \"████╗ ██║\", \"██╔██╗ ██║\", \"██║╚██╗██║\", \"██║ ╚████║\", \"╚═╝ ╚═══╝\"],\n O: [\" ██████╗ \", \"██╔═══██╗\", \"██║ ██║\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n P: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔═══╝ \", \"██║ \", \"╚═╝ \"],\n Q: [\" ██████╗ \", \"██╔═══██╗\", \"██║ ██║\", \"██║▄▄ ██║\", \"╚██████╔╝\", \" ╚══▀▀═╝ \"],\n R: [\"██████╗ \", \"██╔══██╗\", \"██████╔╝\", \"██╔══██╗\", \"██║ ██║\", \"╚═╝ ╚═╝\"],\n S: [\"███████╗\", \"██╔════╝\", \"███████╗\", \"╚════██║\", \"███████║\", \"╚══════╝\"],\n T: [\"████████╗\", \"╚══██╔══╝\", \" ██║ \", \" ██║ \", \" ██║ \", \" ╚═╝ \"],\n U: [\"██╗ ██╗\", \"██║ ██║\", \"██║ ██║\", \"██║ ██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n V: [\"██╗ ██╗\", \"██║ ██║\", \"██║ ██║\", \"╚██╗ ██╔╝\", \" ╚████╔╝ \", \" ╚═══╝ \"],\n W: [\"██╗ ██╗\", \"██║ ██║\", \"██║ █╗ ██║\", \"██║███╗██║\", \"╚███╔███╔╝\", \" ╚══╝╚══╝ \"],\n X: [\"██╗ ██╗\", \"╚██╗██╔╝\", \" ╚███╔╝ \", \" ██╔██╗ \", \"██╔╝ ██╗\", \"╚═╝ ╚═╝\"],\n Y: [\"██╗ ██╗\", \"╚██╗ ██╔╝\", \" ╚████╔╝ \", \" ╚██╔╝ \", \" ██║ \", \" ╚═╝ \"],\n Z: [\"███████╗\", \"╚══███╔╝\", \" ███╔╝ \", \" ███╔╝ \", \"███████╗\", \"╚══════╝\"],\n \"0\": [\" ██████╗ \", \"██╔═████╗\", \"██║██╔██║\", \"████╔╝██║\", \"╚██████╔╝\", \" ╚═════╝ \"],\n \"1\": [\" ██╗\", \"███║\", \"╚██║\", \" ██║\", \" ██║\", \" ╚═╝\"],\n \"2\": [\"██████╗ \", \"╚════██╗\", \" █████╔╝\", \"██╔═══╝ \", \"███████╗\", \"╚══════╝\"],\n \"3\": [\"██████╗ \", \"╚════██╗\", \" █████╔╝\", \" ╚═══██╗\", \"██████╔╝\", \"╚═════╝ \"],\n \"4\": [\"██╗ ██╗\", \"██║ ██║\", \"███████║\", \"╚════██║\", \" ██║\", \" ╚═╝\"],\n \"5\": [\"███████╗\", \"██╔════╝\", \"███████╗\", \"╚════██║\", \"███████║\", \"╚══════╝\"],\n \"6\": [\" ██████╗ \", \"██╔════╝ \", \"███████╗ \", \"██╔═══██╗\", \"╚██████╔╝\", \" ╚═════╝ \"],\n \"7\": [\"███████╗\", \"╚════██║\", \" ██╔╝\", \" ██╔╝ \", \" ██║ \", \" ╚═╝ \"],\n \"8\": [\" █████╗ \", \"██╔══██╗\", \"╚█████╔╝\", \"██╔══██╗\", \"╚█████╔╝\", \" ╚════╝ \"],\n \"9\": [\" █████╗ \", \"██╔══██╗\", \"╚██████║\", \" ╚═══██║\", \" █████╔╝\", \" ╚════╝ \"],\n \"-\": [\" \", \" \", \"█████╗\", \"╚════╝\", \" \", \" \"],\n \"_\": [\" \", \" \", \" \", \" \", \"███████╗\", \"╚══════╝\"],\n \".\": [\" \", \" \", \" \", \" \", \"██╗\", \"╚═╝\"],\n \" \": [\" \", \" \", \" \", \" \", \" \", \" \"],\n};\n\nconst GLYPH_ROWS = 6;\n\n/** Visible column count of a string (full-block + box-drawing are 1 cell each). */\nfunction vlen(s: string): number {\n return [...s].length;\n}\n\n/**\n * Render `name` into the fixed-width `font` as GLYPH_ROWS lines. The ANSI-Shadow\n * glyphs already carry their own trailing shadow column and tile cleanly with NO\n * inter-glyph gap. Returns null when the name has no renderable characters; the\n * glyphs are width-consistent per glyph, so the rows stay aligned.\n */\nfunction renderWithFont(name: string, font: Record<string, readonly string[]>): string[] | null {\n const chars = [...name];\n if (chars.length === 0) return null;\n const blank = font[\" \"]!;\n const rows: string[] = Array.from({ length: GLYPH_ROWS }, () => \"\");\n for (const ch of chars) {\n const glyph = font[ch.toUpperCase()] ?? blank;\n for (let r = 0; r < GLYPH_ROWS; r++) {\n rows[r] += glyph[r] ?? \"\";\n }\n }\n // Drop any fully-blank bottom rows so a name built from narrower glyphs (e.g.\n // \".\" / \"_\") never pads the banner with trailing empty lines.\n while (rows.length > 1 && rows[rows.length - 1]!.trim() === \"\") rows.pop();\n return rows;\n}\n\n/** Max visible width across an art block's rows. */\nfunction blockWidth(rows: string[]): number {\n return rows.length === 0 ? 0 : Math.max(...rows.map(vlen));\n}\n\n/**\n * The WIDE ANSI-Shadow block art for `name` when it fits `columns` (ONE line,\n * never stacked); else null so the caller renders the narrow one-line title.\n * `columns <= 0` means \"no constraint\" → always the WIDE art.\n */\nfunction selectWideArt(name: string, columns: number): string[] | null {\n const limit = columns > 0 ? columns : Infinity;\n const wide = renderWithFont(name, WIDE_FONT);\n return wide != null && blockWidth(wide) <= limit ? wide : null;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Palette-parameterized gradient. The sweep lerps the three palette stops\n// across each row's columns (t∈[0,1]). truecolor uses the exact RGB; 256 and 16\n// derive the nearest representable code FROM the same RGB, so every palette\n// works in every tier. \"none\" emits the bare char.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The interpolated RGB of `palette` at gradient position t∈[0,1]. */\nfunction gradientRGB(t: number, palette: Palette): RGB {\n const clamp = Math.max(0, Math.min(1, t));\n const seg = clamp >= 0.5 ? 1 : 0;\n const local = (clamp - seg * 0.5) / 0.5;\n const a = palette[seg]!;\n const b = palette[seg + 1]!;\n return [\n Math.round(a[0] + (b[0] - a[0]) * local),\n Math.round(a[1] + (b[1] - a[1]) * local),\n Math.round(a[2] + (b[2] - a[2]) * local),\n ];\n}\n\n/** Nearest xterm-256 cube index (16..231) for an RGB triple. */\nfunction rgbTo256(r: number, g: number, b: number): number {\n const q = (v: number): number => (v < 48 ? 0 : v < 115 ? 1 : Math.round((v - 35) / 40));\n return 16 + 36 * q(r) + 6 * q(g) + q(b);\n}\n\n/** Nearest of the 8 bright 16-color fg codes (90..97) for an RGB triple. */\nfunction rgbTo16(r: number, g: number, b: number): number {\n // Threshold each channel; map the on/off triple to its bright SGR code.\n const hi = (v: number): number => (v >= 128 ? 1 : 0);\n const key = (hi(r) << 2) | (hi(g) << 1) | hi(b);\n // index: RGB bits → code. 0:black(90) 1:blue(94) 2:green(92) 3:cyan(96)\n // 4:red(91) 5:magenta(95) 6:yellow(93) 7:white(97)\n return [90, 94, 92, 96, 91, 95, 93, 97][key]!;\n}\n\nconst RESET = \"\\x1b[0m\";\n\n/**\n * Wrap a single grapheme `ch` at gradient position `t` in the SGR escape for the\n * given color tier + palette. Whitespace is never colored (no point paying for\n * an escape around a space) and \"none\" returns the bare char.\n */\nfunction colorChar(ch: string, t: number, color: ColorMode, palette: Palette): string {\n if (color === \"none\" || ch.trim() === \"\") return ch;\n const [r, g, b] = gradientRGB(t, palette);\n if (color === \"truecolor\") return `\\x1b[38;2;${r};${g};${b}m${ch}${RESET}`;\n if (color === \"ansi256\") return `\\x1b[38;5;${rgbTo256(r, g, b)}m${ch}${RESET}`;\n return `\\x1b[${rgbTo16(r, g, b)}m${ch}${RESET}`;\n}\n\n/** Apply the left-to-right gradient across one art row (by visible column). */\nfunction colorizeRow(row: string, color: ColorMode, palette: Palette): string {\n if (color === \"none\") return row;\n const chars = [...row];\n const width = Math.max(1, chars.length - 1);\n let out = \"\";\n for (let i = 0; i < chars.length; i++) {\n out += colorChar(chars[i]!, i / width, color, palette);\n }\n return out;\n}\n\n/** A single BOLD grapheme at gradient position `t` (used by the narrow title). */\nfunction boldColorChar(ch: string, t: number, color: ColorMode, palette: Palette): string {\n if (color === \"none\") return ch;\n const [r, g, b] = gradientRGB(t, palette);\n const fg =\n color === \"truecolor\"\n ? `38;2;${r};${g};${b}`\n : color === \"ansi256\"\n ? `38;5;${rgbTo256(r, g, b)}`\n : `${rgbTo16(r, g, b)}`;\n return `\\x1b[1;${fg}m${ch}${RESET}`;\n}\n\n/**\n * The NARROW one-line title `◆ AGENT-CONNECTOR`: a colored leading diamond (the\n * palette mid stop), two spaces, then the UPPERCASED brand with each character\n * colored along the palette gradient (i → t = i/(len-1)) and bold. Under \"none\"\n * it is the plain text with ZERO ANSI. ~18 cols for \"agent-connector\", so it\n * fits any real terminal.\n */\nfunction renderTitle(name: string, color: ColorMode, palette: Palette): string {\n const upper = name.toUpperCase();\n if (color === \"none\") return `◆ ${upper}`;\n const diamond = boldColorChar(\"◆\", 0.5, color, palette);\n const chars = [...upper];\n const span = Math.max(1, chars.length - 1);\n let title = \"\";\n for (let i = 0; i < chars.length; i++) {\n title += boldColorChar(chars[i]!, i / span, color, palette);\n }\n return `${diamond} ${title}`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Footer (engine attribution). Shown on BOTH the global and branded CLIs — the\n// \"powered by\" wording is intentional.\n// ─────────────────────────────────────────────────────────────────────────\n\nconst FOOTER_LINES = [\n \"powered by @ken-jo/agent-connector\",\n \"more → https://github.com/ken-jo/agent-connector\",\n] as const;\n\n/** Dim (de-emphasized) footer line; plain under \"none\". */\nfunction dim(text: string, color: ColorMode): string {\n return color === \"none\" ? text : `\\x1b[2m${text}${RESET}`;\n}\n\n/**\n * Render the full banner: a responsive brand title with a palette-driven\n * gradient, then a two-line dim footer directly below.\n *\n * • WIDE — the ANSI-Shadow block art when it fits `columns` (ONE line, never\n * stacked; `columns <= 0` = no constraint).\n * • NARROW — the one-line `◆ AGENT-CONNECTOR` gradient title (the universal\n * narrow form, ~18 cols) when the block art would overflow.\n * • `palette` defaults to PALETTES[0] so direct callers + tests are\n * deterministic; the impure app.ts wrapper rotates the palettes per run.\n * • Under `color: \"none\"` (NO_COLOR / dumb term) the output carries zero ANSI\n * escape codes — only the raw art/title + footer text.\n *\n * The result has NO trailing newline; the caller prints it with one.\n */\nexport function renderBrandBanner(name: string, opts: BannerOptions): string {\n const { color, columns } = opts;\n const palette = opts.palette ?? PALETTES[0]!;\n const footer = FOOTER_LINES.map((l) => dim(l, color)).join(\"\\n\");\n\n const art = selectWideArt(name, columns);\n const body =\n art != null\n ? art.map((row) => colorizeRow(row, color, palette)).join(\"\\n\")\n : renderTitle(name, color, palette);\n return `${body}\\n${footer}`;\n}\n"],"mappings":";;;AAaA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;;;AC0BjB,IAAM,WAA+B;AAAA,EAC1C,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;AAAA;AAAA,EAC7C,CAAC,CAAC,KAAK,KAAK,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;AAAA;AAAA,EAC7C,CAAC,CAAC,KAAK,IAAI,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;AAAA;AAAA,EAC5C,CAAC,CAAC,KAAK,KAAK,GAAG,GAAG,CAAC,KAAK,KAAK,EAAE,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;AAAA;AAAA,EAChD,CAAC,CAAC,KAAK,KAAK,GAAG,GAAG,CAAC,KAAK,KAAK,GAAG,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC;AAAA;AAAA,EAClD,CAAC,CAAC,KAAK,IAAI,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC;AAAA;AAAA,EAC/C,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC;AAAA;AAAA,EAC5C,CAAC,CAAC,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC;AAAA;AAAA,EAC9C,CAAC,CAAC,KAAK,KAAK,EAAE,GAAG,CAAC,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC;AAAA;AAAA,EAC/C,CAA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AAC,EAAE;AAC7C,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,SAAS,OAAO;AAC/B,MAAI,CAAC,QAAQ;AACX,YAAQ,OAAO,MAAM,GAAG,WAAW,sBAAsB,OAAO;AAAA;AAAA,CAAO;AACvE,YAAQ,OAAO,MAAM,GAAG,KAAK;AAAA,CAAI;AACjC,WAAO;AAAA,EACT;AAIA,QAAM,OAAO,KAAK,MAAM,CAAC;AACzB,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;AAClD,UAAM,MAAM,cAAc,OAAO;AACjC,QAAI,KAAK;AACP,YAAM,UAAU,WAAW,IAAI,GAAG,EAAE;AACpC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,MAAM,MAAM,OAAO;AACzB,MAAI;AACF,WAAO,MAAM,IAAI,IAAI,IAAI;AAAA,EAC3B,SAAS,KAAK;AAKZ,UAAM,OAAQ,IAA0B;AACxC,QAAI,OAAO,SAAS,YAAY,KAAK,WAAW,gBAAgB,GAAG;AACjE,YAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,YAAM,MAAM,cAAc,OAAO;AACjC,UAAI,IAAK,SAAQ,OAAO,MAAM,UAAU,WAAW,IAAI,GAAG;AAAA,CAAI;AAC9D,aAAO,KAAK,OAAO;AAAA,IACrB;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|