diff --git a/.crew/amos.yaml b/.crew/amos.yaml index b7c0d922..d375cdae 100644 --- a/.crew/amos.yaml +++ b/.crew/amos.yaml @@ -1,5 +1,6 @@ scope: allowed_paths: + - bin/** - lib/** - .crew/** - test/** @@ -11,3 +12,20 @@ branch_conventions: feat: "feat/lr-{task_id}-{slug}" fix: "fix/lr-{task_id}-{slug}" chore: "chore/lr-{task_id}-{slug}" + + +brand_rules: + # MANDATORY — violating these is a hard error, not a style note. + # + # Product name (user-facing text, help strings, log output): "Clagentic: Console" + # CLI binary / command: clagentic-console + # npm package: @clagentic/console + # NEVER use bare "clagentic" as a product name or command. + # + # Technical identifiers that ARE correct: + # CLAGENTIC_* (env var prefix) + # ~/.clagentic/ (home dir) + # clagentic-* (hyphenated service names: clagentic-relay, clagentic-router, etc.) + # + # Before committing any change to bin/cli.js or lib/**/*.js, grep for violations: + # grep -n '"clagentic[^-_/@]' bin/cli.js lib/**/*.js diff --git a/bin/cli.js b/bin/cli.js index 25af6591..79c3e9ee 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -58,6 +58,7 @@ var autoYes = false; var cliPin = null; var shutdownMode = false; var restartMode = false; +var noRestart = false; var addPath = null; var removePath = null; var listMode = false; @@ -102,6 +103,8 @@ for (var i = 0; i < args.length; i++) { shutdownMode = true; } else if (args[i] === "--restart") { restartMode = true; + } else if (args[i] === "--no-restart") { + noRestart = true; } else if (args[i] === "--add") { addPath = args[i + 1] || "."; i++; @@ -120,10 +123,10 @@ for (var i = 0; i < args.length; i++) { } else if (args[i] === "--os-users") { osUsersMode = true; } else if (args[i] === "-h" || args[i] === "--help") { - console.log("Usage: clagentic [-p|--port ] [--host
] [--no-https] [--no-update] [--debug] [-y|--yes] [--pin ] [--shutdown] [--restart]"); - console.log(" clagentic --add Add a project to the running daemon"); - console.log(" clagentic --remove Remove a project from the running daemon"); - console.log(" clagentic --list List registered projects"); + console.log("Usage: clagentic-console [-p|--port ] [--host
] [--no-https] [--no-update] [--debug] [-y|--yes] [--pin ] [--shutdown] [--restart] [--no-restart]"); + console.log(" clagentic-console --add Add a project to the running daemon"); + console.log(" clagentic-console --remove Remove a project from the running daemon"); + console.log(" clagentic-console --list List registered projects"); console.log(""); console.log("Options:"); console.log(" -p, --port Port to listen on (default: 2633)"); @@ -137,6 +140,7 @@ for (var i = 0; i < args.length; i++) { console.log(" --pin Set 6-digit PIN (use with --yes)"); console.log(" --shutdown Shut down the running relay daemon"); console.log(" --restart Restart the running relay daemon"); + console.log(" --no-restart Do not auto-restart on crash (useful for debugging crash state)"); console.log(" --add Add a project directory (use '.' for current)"); console.log(" --remove Remove a project directory"); console.log(" --list List all registered projects"); @@ -389,6 +393,19 @@ function onDaemonDied() { return; } + // --no-restart: leave the daemon dead so the developer can inspect crash state + if (noRestart) { + log(""); + log(sym.warn + " " + a.yellow + "Server crashed. --no-restart is set — not restarting." + a.reset); + if (crashInfo.reason) { + log(a.dim + " " + crashInfo.reason.split("\n")[0] + a.reset); + } + log(a.dim + " Check logs: " + a.reset + logPath()); + log(""); + process.exit(1); + return; + } + // Reset backoff counter if enough time has passed since last restart burst var now = Date.now(); if (_restartBackoffStart && now - _restartBackoffStart > 60000) { @@ -1751,7 +1768,12 @@ async function devMode(mode, keepAwake, existingPinHash, wantOsUsers) { process.exit(78); return; } - // Unexpected exit — auto restart + // Unexpected exit — auto restart (suppressed when --no-restart is set) + if (noRestart) { + console.log("\x1b[33m[dev] Daemon exited (code " + code + "). --no-restart is set — not restarting.\x1b[0m"); + process.exit(code || 1); + return; + } console.log("\x1b[33m[dev] Daemon exited (code " + code + "), restarting...\x1b[0m"); setTimeout(spawnDaemon, 500); }); @@ -1963,7 +1985,7 @@ function showMainMenu(config, ip, setupCode) { function afterQr() { // Status line - log(" " + a.dim + "clagentic" + a.reset + " " + a.dim + "v" + currentVersion + a.reset + a.dim + " — " + url + a.reset); + log(" " + a.dim + "Clagentic: Console" + a.reset + " " + a.dim + "v" + currentVersion + a.reset + a.dim + " — " + url + a.reset); var parts = []; parts.push(a.bold + projs.length + a.reset + a.dim + (projs.length === 1 ? " project" : " projects")); parts.push(a.reset + a.bold + totalSessions + a.reset + a.dim + (totalSessions === 1 ? " session" : " sessions"));