Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion plugins/omo/components/ulw-loop/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@ import { runPreToolUseGoalBudgetGuardCli, runUlwLoopHookCli } from "./codex-hook
const TOP_LEVEL_HELP =
"Usage:\n omo ulw-loop <subcommand> [args]\n omo hook user-prompt-submit (Codex UserPromptSubmit hook)\n omo help | --help | -h (this message)\n\nRun `omo ulw-loop help` for ulw-loop subcommands.\n";

const ULW_LOOP_DIRECT_COMMANDS = new Set([
"help",
"--help",
"-h",
"create-goals",
"status",
"complete-goals",
"checkpoint",
"steer",
"add-goal",
"criteria",
"record-evidence",
"record-review-blockers",
]);

async function main(): Promise<number> {
const argv = process.argv.slice(2);
const command = argv[0];
if (command === undefined || command === "help" || command === "--help" || command === "-h") {
if (command === undefined) {
process.stdout.write(TOP_LEVEL_HELP);
return 0;
}
if (command === "ulw-loop") return ulwLoopCommand(argv.slice(1));
if (ULW_LOOP_DIRECT_COMMANDS.has(command)) return ulwLoopCommand(argv);
if (command === "hook") {
const sub = argv[1];
if (sub === "user-prompt-submit") {
Expand Down
36 changes: 36 additions & 0 deletions plugins/omo/components/ulw-loop/test/cli-entrypoint.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { execFile } from "node:child_process";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { promisify } from "node:util";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

const execFileAsync = promisify(execFile);
const repoRoot = resolve(import.meta.dirname, "..");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a Node 20.0-compatible dirname fallback

On Node 20.0–20.10, which is still allowed by this package's engines: >=20.0.0 and the component AGENTS.md guidance, import.meta.dirname is not available, so this module throws during evaluation before the test can run. The existing tests use fileURLToPath(import.meta.url)/dirname(...); use that pattern here or raise the supported Node floor to a version that provides import.meta.dirname.

Useful? React with 👍 / 👎.

let qaRoot = "";

beforeAll(async () => {
await execFileAsync("npm", ["run", "build"], { cwd: repoRoot });
qaRoot = await mkdtemp(join(tmpdir(), "omo-ulw-loop-cli-entrypoint-"));
});

afterAll(async () => {
if (qaRoot) await rm(qaRoot, { recursive: true, force: true });
});

describe("dist/cli.js component entrypoint", () => {
it("dispatches direct subcommands when invoked as omo-ulw-loop", async () => {
const cliPath = join(repoRoot, "dist", "cli.js");
const result = await execFileAsync(process.execPath, [cliPath, "status", "--json"], { cwd: qaRoot }).catch(
(error: unknown) => {
if (error instanceof Error && "stderr" in error && "stdout" in error) {
return error as Error & { readonly stdout: string; readonly stderr: string };
}
throw error;
},
);

expect(result.stderr).toContain("[ulw-loop] No ulw-loop plan found");
expect(result.stderr).not.toContain("[omo] unknown command: status");
});
});
Loading