Resolve remaining PR review comments
- Remove redundant project-existence check after autoDetectProject - Wrap SIGTERM in try/catch for restart flow (dead process case) - Remove unused setCallerContext export from caller-context.ts - Fix unused vi import lint error in init.test.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
47a043ff6f
commit
511d2b7fb9
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, it, expect, vi } from "vitest";
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
import { Command } from "commander";
|
||||
import { registerInit } from "../../src/commands/init.js";
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ vi.mock("../../src/lib/running-state.js", () => ({
|
|||
vi.mock("../../src/lib/caller-context.js", () => ({
|
||||
isHumanCaller: vi.fn().mockReturnValue(true),
|
||||
getCallerType: vi.fn().mockReturnValue("human"),
|
||||
setCallerContext: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../src/lib/detect-env.js", () => ({
|
||||
|
|
|
|||
|
|
@ -214,15 +214,6 @@ export function registerSpawn(program: Command): void {
|
|||
}
|
||||
}
|
||||
|
||||
if (!config.projects[projectId]) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Unknown project: ${projectId}\nAvailable: ${Object.keys(config.projects).join(", ")}`,
|
||||
),
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!opts.claimPr && opts.assignOnGithub) {
|
||||
console.error(chalk.red("--assign-on-github requires --claim-pr on `ao spawn`."));
|
||||
process.exit(1);
|
||||
|
|
|
|||
|
|
@ -802,7 +802,7 @@ export function registerStart(program: Command): void {
|
|||
project = config.projects[newId];
|
||||
// Continue to startup below
|
||||
} else if (choice.trim() === "3") {
|
||||
process.kill(running.pid, "SIGTERM");
|
||||
try { process.kill(running.pid, "SIGTERM"); } catch { /* already dead */ }
|
||||
const { waitForExit } = await import("../lib/running-state.js");
|
||||
if (!waitForExit(running.pid, 5000)) {
|
||||
console.log(chalk.yellow(" Process didn't exit cleanly, sending SIGKILL..."));
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
export type CallerType = "human" | "orchestrator" | "agent";
|
||||
|
||||
export interface CallerContextOpts {
|
||||
callerType: CallerType;
|
||||
sessionId?: string;
|
||||
projectId?: string;
|
||||
configPath?: string;
|
||||
port?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect who is calling the CLI.
|
||||
* - If AO_CALLER_TYPE is set, trust it.
|
||||
|
|
@ -28,18 +20,3 @@ export function getCallerType(): CallerType {
|
|||
export function isHumanCaller(): boolean {
|
||||
return getCallerType() === "human";
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject AO context environment variables into an env record.
|
||||
* Used when spawning orchestrator/agent sessions so they know their context.
|
||||
*/
|
||||
export function setCallerContext(
|
||||
env: Record<string, string>,
|
||||
opts: CallerContextOpts,
|
||||
): void {
|
||||
env["AO_CALLER_TYPE"] = opts.callerType;
|
||||
if (opts.sessionId) env["AO_SESSION_ID"] = opts.sessionId;
|
||||
if (opts.projectId) env["AO_PROJECT_ID"] = opts.projectId;
|
||||
if (opts.configPath) env["AO_CONFIG_PATH"] = opts.configPath;
|
||||
if (opts.port !== undefined && opts.port !== null) env["AO_PORT"] = String(opts.port);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue