@higherdev/cli 0.7.0 → 0.8.0
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 +2 -1
- package/dist/index.js +13 -0
- package/dist/out.js +1 -0
- package/dist/plan.js +94 -0
- package/dist/tui/App.js +18 -2
- package/dist/tui/Help.js +1 -0
- package/dist/tui/parse.js +2 -0
- package/package.json +3 -2
- package/prompts/architect.md +23 -0
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ workspace-map config shapes are migrated automatically when they are read.
|
|
|
34
34
|
| `hd ticket queue KEY` | Queue a complete ticket now |
|
|
35
35
|
| `hd epic new PATH [--title TITLE]` | Create an epic from a Markdown spec |
|
|
36
36
|
| `hd epic list` | List epics and ticket progress |
|
|
37
|
+
| `hd plan [--repo DIR]` | Hand the terminal to Codex to author an epic spec |
|
|
37
38
|
| `hd workspace ls` | List every workspace available to the configured key |
|
|
38
39
|
| `hd workspace new --name NAME --repo OWNER/NAME [options]` | Create a paused workspace |
|
|
39
40
|
| `hd agents` | List agents |
|
|
@@ -48,6 +49,6 @@ workspace-map config shapes are migrated automatically when they are read.
|
|
|
48
49
|
| `hd upgrade [options]` | Refresh this host configuration |
|
|
49
50
|
|
|
50
51
|
Inside the TUI, use `/board`, `/inbox`, `/ticket`, `/queue`, `/epic new`,
|
|
51
|
-
`/epics`, `/decide`, `/agents`, `/settings`, `/workspace`, `/feed`,
|
|
52
|
+
`/epics`, `/plan`, `/decide`, `/agents`, `/settings`, `/workspace`, `/feed`,
|
|
52
53
|
`/orchestrator`, `/refresh`, `/help`, or `/exit`. The display refreshes from
|
|
53
54
|
the HDX API every five seconds.
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { initHost, parseHostFlags } from "./host.js";
|
|
|
6
6
|
import { loadConfig, writeHdConfig } from "./config.js";
|
|
7
7
|
import { epicProgressRows, readEpicSpec } from "./epics.js";
|
|
8
8
|
import { banner, c, statusChip, table, truncate, usage } from "./out.js";
|
|
9
|
+
import { launchArchitect } from "./plan.js";
|
|
9
10
|
function fail(message) {
|
|
10
11
|
console.error(message);
|
|
11
12
|
process.exit(1);
|
|
@@ -145,6 +146,14 @@ async function cmdEpic(argv) {
|
|
|
145
146
|
}
|
|
146
147
|
fail("usage: hd epic new PATH [--title TITLE] | list");
|
|
147
148
|
}
|
|
149
|
+
async function cmdPlan(argv) {
|
|
150
|
+
const { rest, opts, bools } = flags(argv);
|
|
151
|
+
if (rest.length || bools.size || Object.keys(opts).some((key) => key !== "repo")) {
|
|
152
|
+
fail("usage: hd plan [--repo DIR]");
|
|
153
|
+
}
|
|
154
|
+
const { workspace } = await getStatus();
|
|
155
|
+
await launchArchitect({ workspaceRepo: workspace.repo, repo: opts.repo });
|
|
156
|
+
}
|
|
148
157
|
async function cmdLogs(argv) {
|
|
149
158
|
const { rest, bools } = flags(argv);
|
|
150
159
|
const key = rest[0];
|
|
@@ -303,6 +312,10 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
303
312
|
await cmdEpic(rest);
|
|
304
313
|
return;
|
|
305
314
|
}
|
|
315
|
+
if (cmd === "plan") {
|
|
316
|
+
await cmdPlan(rest);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
306
319
|
if (cmd === "logs") {
|
|
307
320
|
await cmdLogs(rest);
|
|
308
321
|
return;
|
package/dist/out.js
CHANGED
|
@@ -66,6 +66,7 @@ export function usage() {
|
|
|
66
66
|
` ${c.blue("hd status")} workspace overview`,
|
|
67
67
|
` ${c.blue("hd ticket list | show | new | queue")} ticket operations`,
|
|
68
68
|
` ${c.blue("hd epic new PATH | list")} epic operations`,
|
|
69
|
+
` ${c.blue("hd plan [--repo DIR]")} author an epic with Codex`,
|
|
69
70
|
` ${c.blue("hd workspace ls | new")} list or create workspaces`,
|
|
70
71
|
` ${c.blue("hd agents [set]")} inspect or update agents`,
|
|
71
72
|
` ${c.blue("hd logs KEY [-f]")} run events`,
|
package/dist/plan.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { createInterface } from "node:readline/promises";
|
|
6
|
+
const ARCHITECT_PROMPT = new URL("../prompts/architect.md", import.meta.url);
|
|
7
|
+
function gitOutput(cwd, args) {
|
|
8
|
+
const result = spawnSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
9
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
10
|
+
}
|
|
11
|
+
export function remoteRepo(remote) {
|
|
12
|
+
const trimmed = remote.trim().replace(/\/$/, "").replace(/\.git$/, "");
|
|
13
|
+
const scp = trimmed.match(/^[^@]+@[^:]+:(.+)$/);
|
|
14
|
+
if (scp)
|
|
15
|
+
return scp[1] ?? null;
|
|
16
|
+
try {
|
|
17
|
+
const url = new URL(trimmed);
|
|
18
|
+
return url.pathname.replace(/^\//, "") || null;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return trimmed.includes("/") ? trimmed : null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function expanded(path) {
|
|
25
|
+
const value = path.trim();
|
|
26
|
+
if (value === "~")
|
|
27
|
+
return homedir();
|
|
28
|
+
if (value.startsWith("~/"))
|
|
29
|
+
return join(homedir(), value.slice(2));
|
|
30
|
+
return isAbsolute(value) ? value : resolve(value);
|
|
31
|
+
}
|
|
32
|
+
export function matchingWorkspaceRepo(directory, workspaceRepo) {
|
|
33
|
+
const root = gitOutput(expanded(directory), ["rev-parse", "--show-toplevel"]);
|
|
34
|
+
if (!root)
|
|
35
|
+
return null;
|
|
36
|
+
const origin = gitOutput(root, ["remote", "get-url", "origin"]);
|
|
37
|
+
return origin && remoteRepo(origin)?.toLowerCase() === workspaceRepo.toLowerCase() ? root : null;
|
|
38
|
+
}
|
|
39
|
+
async function askForRepo(workspaceRepo) {
|
|
40
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
41
|
+
throw new Error(`Current directory is not ${workspaceRepo}. Pass --repo DIR.`);
|
|
42
|
+
}
|
|
43
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
44
|
+
try {
|
|
45
|
+
return (await prompt.question(`Repository directory for ${workspaceRepo}: `)).trim();
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
prompt.close();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function resolveWorkspaceRepo(workspaceRepo, requested) {
|
|
52
|
+
if (requested) {
|
|
53
|
+
const match = matchingWorkspaceRepo(requested, workspaceRepo);
|
|
54
|
+
if (!match)
|
|
55
|
+
throw new Error(`${requested} is not a checkout of ${workspaceRepo}.`);
|
|
56
|
+
return match;
|
|
57
|
+
}
|
|
58
|
+
const current = matchingWorkspaceRepo(process.cwd(), workspaceRepo);
|
|
59
|
+
if (current)
|
|
60
|
+
return current;
|
|
61
|
+
const answer = await askForRepo(workspaceRepo);
|
|
62
|
+
if (!answer)
|
|
63
|
+
throw new Error("A repository directory is required.");
|
|
64
|
+
const match = matchingWorkspaceRepo(answer, workspaceRepo);
|
|
65
|
+
if (!match)
|
|
66
|
+
throw new Error(`${answer} is not a checkout of ${workspaceRepo}.`);
|
|
67
|
+
return match;
|
|
68
|
+
}
|
|
69
|
+
export function verifyCodex(checkVersion = () => spawnSync("codex", ["--version"], { stdio: "ignore" })) {
|
|
70
|
+
const check = checkVersion();
|
|
71
|
+
if (check.error || check.status !== 0) {
|
|
72
|
+
throw new Error("Codex CLI is unavailable. Install it if needed, then run `codex login`.");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function runCodex(cwd, prompt) {
|
|
76
|
+
return new Promise((resolveRun, rejectRun) => {
|
|
77
|
+
const child = spawn("codex", [prompt], { cwd, stdio: "inherit" });
|
|
78
|
+
child.once("error", rejectRun);
|
|
79
|
+
child.once("exit", (code, signal) => {
|
|
80
|
+
if (code === 0)
|
|
81
|
+
resolveRun();
|
|
82
|
+
else
|
|
83
|
+
rejectRun(new Error(`codex exited ${signal ? `with signal ${signal}` : `with status ${code ?? "unknown"}`}.`));
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export async function launchArchitect(options, runtime = {}) {
|
|
88
|
+
(runtime.verifyCodex ?? verifyCodex)();
|
|
89
|
+
const [cwd, prompt] = await Promise.all([
|
|
90
|
+
resolveWorkspaceRepo(options.workspaceRepo, options.repo),
|
|
91
|
+
readFile(ARCHITECT_PROMPT, "utf8"),
|
|
92
|
+
]);
|
|
93
|
+
await (runtime.invokeCodex ?? runCodex)(cwd, prompt);
|
|
94
|
+
}
|
package/dist/tui/App.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Box, Static, Text, useApp, useInput, useStdout } from "ink";
|
|
4
4
|
import { epicProgressRows } from "../epics.js";
|
|
5
|
+
import { launchArchitect } from "../plan.js";
|
|
5
6
|
import { Banner } from "./Banner.js";
|
|
6
7
|
import { Bubble } from "./Bubble.js";
|
|
7
8
|
import { Cockpit, StreamPanel, boardTicketIds, nextCursor } from "./Dashboard.js";
|
|
@@ -23,7 +24,7 @@ import { WorkspaceLoads } from "./workspace-load.js";
|
|
|
23
24
|
let messageSeq = 0;
|
|
24
25
|
const nextId = () => `m${messageSeq++}`;
|
|
25
26
|
export function App({ initial }) {
|
|
26
|
-
const { exit } = useApp();
|
|
27
|
+
const { exit, suspendTerminal } = useApp();
|
|
27
28
|
const { stdout } = useStdout();
|
|
28
29
|
const columns = stdout?.columns && stdout.columns > 0 ? stdout.columns : 80;
|
|
29
30
|
const rows = stdout?.rows && stdout.rows > 0 ? stdout.rows : 24;
|
|
@@ -347,6 +348,20 @@ export function App({ initial }) {
|
|
|
347
348
|
setBusy(false);
|
|
348
349
|
}
|
|
349
350
|
return;
|
|
351
|
+
case "plan":
|
|
352
|
+
setBusy(true);
|
|
353
|
+
try {
|
|
354
|
+
await suspendTerminal(() => launchArchitect({ workspaceRepo: workspace.repo }));
|
|
355
|
+
say("system", "Architect session ended. Review the spec, then run /epic new PATH.");
|
|
356
|
+
await refresh();
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
360
|
+
}
|
|
361
|
+
finally {
|
|
362
|
+
setBusy(false);
|
|
363
|
+
}
|
|
364
|
+
return;
|
|
350
365
|
case "decide": {
|
|
351
366
|
const decision = board.decisions[0];
|
|
352
367
|
if (!decision) {
|
|
@@ -393,7 +408,8 @@ export function App({ initial }) {
|
|
|
393
408
|
default:
|
|
394
409
|
return;
|
|
395
410
|
}
|
|
396
|
-
}, [view, settings, applyEdit, board, browsing, mode, say, askOrchestrator, order, settingsOrder, changeWorkspace,
|
|
411
|
+
}, [view, settings, applyEdit, board, browsing, mode, say, askOrchestrator, order, settingsOrder, changeWorkspace,
|
|
412
|
+
config, workspace.repo, refresh, suspendTerminal, exit]);
|
|
397
413
|
useInput((input, key) => {
|
|
398
414
|
if (key.ctrl && input === "c")
|
|
399
415
|
exit();
|
package/dist/tui/Help.js
CHANGED
|
@@ -11,6 +11,7 @@ export const COMMANDS = [
|
|
|
11
11
|
{ name: "/queue", args: "HD-12", help: "queue a complete ticket now" },
|
|
12
12
|
{ name: "/epic", args: "new PATH", help: "create an epic from a Markdown spec" },
|
|
13
13
|
{ name: "/epics", help: "list epics and ticket progress" },
|
|
14
|
+
{ name: "/plan", help: "author an epic with your Codex CLI" },
|
|
14
15
|
{ name: "/decide", args: "2 | text", help: "answer the decision on screen" },
|
|
15
16
|
{ name: "/agents", help: "every agent in full, and the live run stream" },
|
|
16
17
|
{ name: "/settings", help: "change provider caps and agent settings" },
|
package/dist/tui/parse.js
CHANGED
|
@@ -39,6 +39,8 @@ export function parseLine(raw) {
|
|
|
39
39
|
return argument
|
|
40
40
|
? { kind: "queue", key: argument.toUpperCase() }
|
|
41
41
|
: { kind: "unknown", command: "queue needs a key" };
|
|
42
|
+
case "plan":
|
|
43
|
+
return argument ? { kind: "unknown", command: "plan takes no arguments" } : { kind: "plan" };
|
|
42
44
|
case "decide": {
|
|
43
45
|
const dismiss = /(^|\s)--(skip|dismiss)(\s|$)/.test(argument);
|
|
44
46
|
return {
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@higherdev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hd": "dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"prompts"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "tsc",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
You are helping the operator author an HDX epic for this repository.
|
|
2
|
+
|
|
3
|
+
Start by interviewing the operator about the goal. Ask focused questions until the intended outcome, boundaries, and important tradeoffs are clear. Read the repository as needed so the plan reflects the code that actually exists.
|
|
4
|
+
|
|
5
|
+
Draft the epic in this exact structure:
|
|
6
|
+
|
|
7
|
+
# <title>
|
|
8
|
+
|
|
9
|
+
## Goal
|
|
10
|
+
|
|
11
|
+
## Scope
|
|
12
|
+
|
|
13
|
+
## Out of scope
|
|
14
|
+
|
|
15
|
+
## Acceptance
|
|
16
|
+
|
|
17
|
+
## Constraints
|
|
18
|
+
|
|
19
|
+
The operator is the author. Let them review and revise the draft before saving it. Do not submit the epic to HDX yourself.
|
|
20
|
+
|
|
21
|
+
Once the operator accepts the spec, write it to `docs/epics/<slug>.md`, where `<slug>` is a concise kebab-case name for the epic. End by printing the exact next command, with the real path substituted:
|
|
22
|
+
|
|
23
|
+
`hd epic new docs/epics/<slug>.md`
|