@krapht/ork 1.0.0-alpha.10 → 1.0.0-alpha.11
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/dist/{__build_info__-DFF18K8y.mjs → __build_info__-CIchF6nr.mjs} +3 -72
- package/dist/bin.mjs +1066 -387
- package/dist/chips-BA7SrrH5.mjs +43 -0
- package/dist/{clean-DVaEH9e7.mjs → clean-Di-KT7Mf.mjs} +1 -1
- package/dist/{completion-Dv5kf598.mjs → completion-C5D0sEs5.mjs} +22 -15
- package/dist/{context-CEaKOVmG.mjs → context-BaNshWr9.mjs} +43 -31
- package/dist/{decide-3l9q8UtX.mjs → decide-B6PnKeqo.mjs} +1 -1
- package/dist/{find-DEjjOlTG.mjs → find-BicBbGMg.mjs} +1 -1
- package/dist/{format-Cb5_m-Qd.mjs → format-lWhN-jYR.mjs} +130 -35
- package/dist/{in-a-run-BS9Nc-JW.mjs → in-a-run-CgkVouyG.mjs} +1 -1
- package/dist/{limits-BSwEjQST.mjs → limits-jZQp9ZJC.mjs} +1 -1
- package/dist/{list-Qxr6rwsY.mjs → list-CEaJ07jd.mjs} +1 -1
- package/dist/{mcp-CslnG5wf.mjs → mcp-DYgVA9f5.mjs} +6 -6
- package/dist/output-CM95njYt.mjs +421 -0
- package/dist/{pause-D7OVB5Ac.mjs → pause-D6PuSlNl.mjs} +4 -4
- package/dist/{relay-EceRIebO.mjs → relay-DNx7be9k.mjs} +2 -2
- package/dist/{remove-0IQZVWmI.mjs → remove-CpMb4NDl.mjs} +3 -3
- package/dist/{report-DK4LGqwF.mjs → report-CEN8VoUb.mjs} +31 -20
- package/dist/{send-C0uwfUYi.mjs → send-CLs_fyg7.mjs} +3 -3
- package/dist/{src-cmmXKHn1.mjs → src-9iGkjnsy.mjs} +234 -150
- package/dist/{src-i5k2Y-kf.mjs → src-B6KvTm7B.mjs} +78 -11
- package/dist/{src-oaJYIddp.mjs → src-BnZgZGrf.mjs} +523 -81
- package/dist/{src-Df6KOIDC.mjs → src-D6_xjm-x.mjs} +1722 -825
- package/dist/ui/assets/{app-qs8Lofv6.js → app-CxURph7a.js} +16 -16
- package/dist/ui/assets/app-QoHVi-mb.css +1 -0
- package/dist/ui/assets/{index-DV1ZaOk-.js → index-By_8KKG6.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/dist/{ui-CBkHJdqk.mjs → ui-CIci4UBW.mjs} +4 -4
- package/dist/{usage-Cd8pEYyK.mjs → usage-GceBGMjU.mjs} +43 -32
- package/dist/{watch-DW5R2OPO.mjs → watch-BmoybMQg.mjs} +28 -16
- package/dist/{workflows-BT1gDRIV.mjs → workflows-DZvW3i1e.mjs} +3 -3
- package/dist/{worktrees-g1MQMGie.mjs → worktrees-Be51E2rB.mjs} +11 -10
- package/package.json +1 -1
- package/dist/output-Bqljtmp_.mjs +0 -40
- package/dist/ui/assets/app-C8uhHVYp.css +0 -1
package/dist/ui/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
href="/favicon.svg"
|
|
20
20
|
type="image/svg+xml"
|
|
21
21
|
/>
|
|
22
|
-
<script type="module" crossorigin src="/assets/index-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-By_8KKG6.js"></script>
|
|
23
23
|
<link rel="modulepreload" crossorigin href="/assets/theme-CdXvqTQ6.js">
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-BPIbqRRb.css">
|
|
25
25
|
</head>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as ORK_VERSION, t as ORK_NAME } from "./__build_info__-
|
|
2
|
-
import { a as write, i as style, o as writeErr } from "./output-
|
|
3
|
-
import { a as mayShowSignIn } from "./in-a-run-
|
|
4
|
-
import { i as uiFilePath, l as newToken, n as startServer, r as runningServer, t as DEFAULT_PORT } from "./src-
|
|
1
|
+
import { n as ORK_VERSION, t as ORK_NAME } from "./__build_info__-CIchF6nr.mjs";
|
|
2
|
+
import { a as write, i as style, o as writeErr } from "./output-CM95njYt.mjs";
|
|
3
|
+
import { a as mayShowSignIn } from "./in-a-run-CgkVouyG.mjs";
|
|
4
|
+
import { i as uiFilePath, l as newToken, n as startServer, r as runningServer, t as DEFAULT_PORT } from "./src-B6KvTm7B.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { constants } from "node:os";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as listOrkWorktrees, t as createdWorktrees } from "./list-
|
|
3
|
-
import { n as usageReport, t as USAGE_DIMENSIONS } from "./report-
|
|
4
|
-
import { a as write, i as style, n as cost, o as writeErr, t as confirm } from "./output-
|
|
5
|
-
import "./
|
|
6
|
-
import {
|
|
1
|
+
import { C as openStore, Un as runDirOf, Vn as placeFor, ot as usd, xt as liveStatus } from "./src-D6_xjm-x.mjs";
|
|
2
|
+
import { n as listOrkWorktrees, t as createdWorktrees } from "./list-CEaJ07jd.mjs";
|
|
3
|
+
import { n as usageReport, t as USAGE_DIMENSIONS } from "./report-CEN8VoUb.mjs";
|
|
4
|
+
import { a as write, b as termOf, i as style, n as cost, o as writeErr, t as confirm } from "./output-CM95njYt.mjs";
|
|
5
|
+
import { n as chip, t as CHIP_LABELS } from "./chips-BA7SrrH5.mjs";
|
|
6
|
+
import { a as header, o as table } from "./format-lWhN-jYR.mjs";
|
|
7
|
+
import { n as limitsHere } from "./limits-jZQp9ZJC.mjs";
|
|
7
8
|
import { existsSync, rmSync } from "node:fs";
|
|
8
9
|
import { defineCommand } from "citty";
|
|
9
10
|
// ../core/src/store/prune.ts
|
|
@@ -197,24 +198,31 @@ const TITLES = {
|
|
|
197
198
|
driver: "By driver",
|
|
198
199
|
project: "By project"
|
|
199
200
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
/** Seconds of CPU, `12.3 s`; empty with none. */
|
|
202
|
+
const cpuText = (ms) => ms === 0 ? "" : `${(ms / 1e3).toFixed(1)} s`;
|
|
203
|
+
/** `cpu`: a column for the CPU Ork's tool commands used. */
|
|
204
|
+
const usageTable = (term, groups, cpu = false) => table(term, [
|
|
205
|
+
{ flex: true },
|
|
206
|
+
{ align: "right" },
|
|
207
|
+
{ align: "right" },
|
|
208
|
+
{},
|
|
209
|
+
{},
|
|
210
|
+
...cpu ? [{ align: "right" }] : []
|
|
211
|
+
], [[
|
|
212
|
+
header(""),
|
|
213
|
+
header("COST"),
|
|
214
|
+
header("SESSIONS"),
|
|
215
|
+
header("TOKENS"),
|
|
216
|
+
header("CACHE"),
|
|
217
|
+
...cpu ? [header("TOOL CPU")] : []
|
|
218
|
+
], ...groups.map((group) => [
|
|
219
|
+
{ text: group.key },
|
|
220
|
+
{ text: cost(group.costUsd) },
|
|
221
|
+
{ text: String(group.sessions) },
|
|
222
|
+
{ text: `${tokens(group.inputTokens + group.cacheReadTokens + group.cacheWriteTokens)} in / ${tokens(group.outputTokens)} out` },
|
|
223
|
+
{ text: percent(group.cacheHitRate) },
|
|
224
|
+
...cpu ? [{ text: cpuText(group.cpuMs) }] : []
|
|
225
|
+
])], " ");
|
|
218
226
|
/** What `ork usage` prints without `--by`. */
|
|
219
227
|
const OVERVIEW = [
|
|
220
228
|
"day",
|
|
@@ -228,29 +236,31 @@ const shortTime = (iso) => new Date(iso).toLocaleString(void 0, {
|
|
|
228
236
|
dateStyle: "medium",
|
|
229
237
|
timeStyle: "short"
|
|
230
238
|
});
|
|
239
|
+
/** A warning line: a `WARN` chip when rich, else the line in yellow. */
|
|
240
|
+
const warned = (term, text) => term.rich ? ` ${chip(term, CHIP_LABELS.warn, "warn")} ${text}` : style("yellow", ` ${text}`);
|
|
231
241
|
/** The limits across runs, above a report; nothing with none set. */
|
|
232
|
-
const formatLimits = ({ problems, caps, plan }) => {
|
|
242
|
+
const formatLimits = ({ problems, caps, plan }, term = termOf(process.stdout)) => {
|
|
233
243
|
if (problems.length === 0 && caps.length === 0 && plan.length === 0) return [];
|
|
234
244
|
return [
|
|
235
245
|
style("bold", "Limits"),
|
|
236
|
-
...problems.map((problem) =>
|
|
246
|
+
...problems.map((problem) => warned(term, problem)),
|
|
237
247
|
...caps.map((cap) => {
|
|
238
248
|
const line = ` ${cap.project === void 0 ? "all projects" : "this project"}, this ${cap.window}: ${usd(cap.spentUsd)} of ${usd(cap.capUsd)}, resets ${shortTime(cap.resetsAt)}`;
|
|
239
|
-
return cap.leftUsd <= 0 ?
|
|
249
|
+
return cap.leftUsd <= 0 ? warned(term, line.trimStart()) : line;
|
|
240
250
|
}),
|
|
241
|
-
...plan.map((limit) =>
|
|
251
|
+
...plan.map((limit) => warned(term, `Claude plan's ${limit.window.replaceAll("_", " ")} limit ${limit.status === "rejected" ? "was reached" : "is close"}${limit.resetsAt === void 0 ? "" : `, resets ${shortTime(limit.resetsAt)}`}`)),
|
|
242
252
|
""
|
|
243
253
|
];
|
|
244
254
|
};
|
|
245
255
|
/** The report, as the terminal shows it. */
|
|
246
|
-
const formatUsage = (report, scope, by) => {
|
|
256
|
+
const formatUsage = (report, scope, by, term = termOf(process.stdout)) => {
|
|
247
257
|
const { totals } = report;
|
|
248
258
|
if (totals.sessions === 0) return [`No Claude sessions in ${scope}.`];
|
|
249
259
|
const lines = [`${style("bold", cost(totals.costUsd))} in ${scope}`, `${counted(totals.runs, "run")} · ${counted(totals.sessions, "session")} · ${counted(totals.turns, "turn")} · ${tokens(totals.inputTokens + totals.cacheReadTokens + totals.cacheWriteTokens)} in / ${tokens(totals.outputTokens)} out · ${percent(totals.cacheHitRate)} from cache`];
|
|
250
260
|
for (const dimension of by === void 0 ? OVERVIEW : [by]) {
|
|
251
261
|
const groups = report.groups[dimension];
|
|
252
262
|
const shown = by === void 0 ? dimension === "day" ? groups.slice(-10) : groups.slice(0, OVERVIEW_ROWS) : groups;
|
|
253
|
-
lines.push("", style("bold", TITLES[dimension]), ...
|
|
263
|
+
lines.push("", style("bold", TITLES[dimension]), ...usageTable(term, shown, dimension === "node"));
|
|
254
264
|
if (shown.length < groups.length) lines.push(style("dim", ` and ${String(groups.length - shown.length)} more (--by ${dimension})`));
|
|
255
265
|
}
|
|
256
266
|
const hints = report.hints.length === 0 ? [] : [
|
|
@@ -333,12 +343,13 @@ const usage = defineCommand({
|
|
|
333
343
|
const store = openStore();
|
|
334
344
|
try {
|
|
335
345
|
if (args["clear-plan-limits"]) store.clearPlanLimits();
|
|
336
|
-
const
|
|
346
|
+
const filter = {
|
|
337
347
|
...args.all ? {} : { project: placeFor(process.cwd(), store.projects()).root },
|
|
338
348
|
...args.workflow === void 0 ? {} : { workflow: args.workflow },
|
|
339
349
|
...since === void 0 ? {} : { since },
|
|
340
350
|
...until === void 0 ? {} : { until }
|
|
341
|
-
}
|
|
351
|
+
};
|
|
352
|
+
const report = usageReport(store.usage(filter), store.toolCpu(filter));
|
|
342
353
|
const limits = limitsHere(store, args.all ? void 0 : placeFor(process.cwd(), store.projects()));
|
|
343
354
|
if (args.json) {
|
|
344
355
|
write(JSON.stringify({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as newRunId } from "./find-
|
|
3
|
-
import { a as write, i as style, o as writeErr, r as plain, t as confirm } from "./output-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { Bn as placeFiles, C as openStore, Ot as stillTheSameProcess, _ as readProjectTriggers, _r as isToolNode, b as watchingPid, et as detachRun, fr as CheckReportSchema, g as declaredTriggers, h as triggerStanding, m as createWatcher, p as triggersReport, xr as timeoutMs, xt as liveStatus, y as takeWatchLock } from "./src-D6_xjm-x.mjs";
|
|
2
|
+
import { n as newRunId } from "./find-BicBbGMg.mjs";
|
|
3
|
+
import { C as widthOf, a as write, b as termOf, i as style, o as writeErr, r as plain, t as confirm, x as cut } from "./output-CM95njYt.mjs";
|
|
4
|
+
import { n as chip, t as CHIP_LABELS } from "./chips-BA7SrrH5.mjs";
|
|
5
|
+
import { c as toolExecutor, o as spawnTool, s as mcpCallExecutor } from "./src-9iGkjnsy.mjs";
|
|
6
|
+
import { i as runLimits, r as limitsRefusal } from "./limits-jZQp9ZJC.mjs";
|
|
7
|
+
import { t as acceptRefusal } from "./in-a-run-CgkVouyG.mjs";
|
|
7
8
|
import path from "node:path";
|
|
8
9
|
import { mkdirSync } from "node:fs";
|
|
9
10
|
import { homedir } from "node:os";
|
|
@@ -63,7 +64,7 @@ const lookAt = async (options) => {
|
|
|
63
64
|
});
|
|
64
65
|
return result.ok ? resultOf(result.output["json"]) : {
|
|
65
66
|
ok: false,
|
|
66
|
-
error: result.error ?? "the check failed"
|
|
67
|
+
error: [result.error ?? "the check failed", result.end?.detail].filter((part) => part !== void 0).join(": ")
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
// src/watch/report.ts
|
|
@@ -73,10 +74,21 @@ const STANDING = {
|
|
|
73
74
|
changed: "off: changed since it was accepted",
|
|
74
75
|
invalid: "off: has an error"
|
|
75
76
|
};
|
|
76
|
-
|
|
77
|
-
const
|
|
77
|
+
/** A failure's mark: a `FAIL` chip when rich, else the red `✗`. */
|
|
78
|
+
const failMark = (term) => term.rich ? chip(term, CHIP_LABELS.fail, "danger") : style("red", "✗");
|
|
79
|
+
/** A warning's mark: a `WARN` chip when rich, else the yellow `!`. */
|
|
80
|
+
const warnMark = (term) => term.rich ? chip(term, CHIP_LABELS.warn, "warn") : style("yellow", "!");
|
|
81
|
+
/** A trigger's standing, rich: a chip and what it adds. */
|
|
82
|
+
const standingChip = (term, standing) => {
|
|
83
|
+
const live = standing === "live";
|
|
84
|
+
const label = live ? "LIVE" : "OFF";
|
|
85
|
+
const text = STANDING[standing] ?? standing;
|
|
86
|
+
return `${chip(term, label, live ? "ok" : standing === "invalid" ? "danger" : "warn")}${live ? "" : ` ${text.replace(/^off: /u, "")}`}`;
|
|
87
|
+
};
|
|
88
|
+
const brokenLines = (broken, term = termOf(process.stdout)) => broken.map(({ file, message }) => `${failMark(term)} ${plain(file)}: ${plain(message)}`);
|
|
89
|
+
const statusLines = (report, term = termOf(process.stdout)) => {
|
|
78
90
|
const head = report.pid === void 0 ? "ork watch isn't running. Start it with `ork watch`, or `ork watch --detach`." : `ork watch is running (process ${String(report.pid)}).`;
|
|
79
|
-
const broken = brokenLines(report.broken);
|
|
91
|
+
const broken = brokenLines(report.broken, term);
|
|
80
92
|
if (report.triggers.length === 0) return [
|
|
81
93
|
head,
|
|
82
94
|
...broken,
|
|
@@ -86,11 +98,11 @@ const statusLines = (report) => {
|
|
|
86
98
|
head,
|
|
87
99
|
...broken,
|
|
88
100
|
...report.triggers.flatMap((status) => [
|
|
89
|
-
`${style("bold", plain(status.trigger))} ${style("dim", plain(`${status.project} → ${status.run}, every ${status.every}`))}`,
|
|
90
|
-
` ${STANDING[status.standing] ?? status.standing}${status.lookedAt === void 0 ? "" : `, last looked ${status.lookedAt}`}`,
|
|
101
|
+
term.rich ? `${style("bold", plain(status.trigger))} ${style("dim", cut(plain(`${status.project} → ${status.run}, every ${status.every}`), Math.max(8, term.width - widthOf(status.trigger) - 1)))}` : `${style("bold", plain(status.trigger))} ${style("dim", plain(`${status.project} → ${status.run}, every ${status.every}`))}`,
|
|
102
|
+
` ${term.rich ? standingChip(term, status.standing) : STANDING[status.standing] ?? status.standing}${status.lookedAt === void 0 ? "" : `, last looked ${status.lookedAt}`}`,
|
|
91
103
|
...status.error === void 0 ? [] : [` last look: ${plain(status.error)}`],
|
|
92
104
|
...status.held === void 0 ? [] : [` waiting: ${plain(status.held)}`],
|
|
93
|
-
...status.problems.map((problem) => ` ${
|
|
105
|
+
...status.problems.map((problem) => ` ${failMark(term)} ${plain(problem)}`)
|
|
94
106
|
])
|
|
95
107
|
];
|
|
96
108
|
};
|
|
@@ -126,16 +138,16 @@ const STANDS = {
|
|
|
126
138
|
new: "new",
|
|
127
139
|
changed: "changed since you accepted it, here or in the workflow it starts"
|
|
128
140
|
};
|
|
129
|
-
const acceptLines = (item, standing) => [
|
|
141
|
+
const acceptLines = (item, standing, term = termOf(process.stdout)) => [
|
|
130
142
|
`${style("bold", plain(item.id))} ${style("dim", plain(item.place.root))}`,
|
|
131
143
|
` ${STANDS[standing] ?? standing}`,
|
|
132
144
|
...checkLines(item),
|
|
133
145
|
` starts: ${plain(item.trigger.run)}, looking every ${item.trigger.every}, with up to ${String(item.trigger.maxRunsPerDay ?? 10)} runs a day`,
|
|
134
146
|
...workflowLines(item),
|
|
135
|
-
...item.diagnostics.filter(({ severity }) => severity === "warning").map(({ message }) => ` ${
|
|
147
|
+
...item.diagnostics.filter(({ severity }) => severity === "warning").map(({ message }) => ` ${warnMark(term)} ${plain(message)}`)
|
|
136
148
|
];
|
|
137
149
|
/** The triggers `--accept` can't offer, so they aren't silently left out. */
|
|
138
|
-
const unacceptableLines = (item) => [`${style("bold", plain(item.id))} ${style("dim", plain(item.place.root))}`, ...item.diagnostics.filter(({ severity }) => severity === "error").map(({ message }) => ` ${
|
|
150
|
+
const unacceptableLines = (item, term = termOf(process.stdout)) => [`${style("bold", plain(item.id))} ${style("dim", plain(item.place.root))}`, ...item.diagnostics.filter(({ severity }) => severity === "error").map(({ message }) => ` ${failMark(term)} ${plain(message)}`)];
|
|
139
151
|
// src/watch/start.ts
|
|
140
152
|
/**
|
|
141
153
|
* @file Starting a trigger's run (RFC-011): an ordinary run in the background,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as builtinWorkflowFile, r as builtinProblem, s as isBuiltinArg } from "./decide-
|
|
3
|
-
import { o as writeErr } from "./output-
|
|
1
|
+
import { Bn as placeFiles, C as openStore, Kn as inside, Un as runDirOf, Vn as placeFor, w as storePath } from "./src-D6_xjm-x.mjs";
|
|
2
|
+
import { i as builtinWorkflowFile, r as builtinProblem, s as isBuiltinArg } from "./decide-B6PnKeqo.mjs";
|
|
3
|
+
import { o as writeErr } from "./output-CM95njYt.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
// src/project/place.ts
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as planClean, i as keyOf, o as stepActs, t as applyClean } from "./clean-
|
|
3
|
-
import { a as readWorktrees, c as mergeStateOf, d as stateParts, l as planLine, n as lostWork, o as repoRoot, r as planRemove, s as labelOf, t as applyRemove } from "./remove-
|
|
4
|
-
import { a as write, i as style, o as writeErr, t as confirm } from "./output-
|
|
1
|
+
import { C as openStore, E as inspectProject } from "./src-D6_xjm-x.mjs";
|
|
2
|
+
import { a as planClean, i as keyOf, o as stepActs, t as applyClean } from "./clean-Di-KT7Mf.mjs";
|
|
3
|
+
import { a as readWorktrees, c as mergeStateOf, d as stateParts, l as planLine, n as lostWork, o as repoRoot, r as planRemove, s as labelOf, t as applyRemove } from "./remove-CpMb4NDl.mjs";
|
|
4
|
+
import { a as write, b as termOf, f as paint, i as style, o as writeErr, t as confirm, x as cut } from "./output-CM95njYt.mjs";
|
|
5
|
+
import { n as chip } from "./chips-BA7SrrH5.mjs";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { realpathSync } from "node:fs";
|
|
7
8
|
import { defineCommand } from "citty";
|
|
@@ -19,7 +20,7 @@ const goAhead = async (yes, verb, terminal = process.stdin.isTTY, ask = confirm)
|
|
|
19
20
|
process.exitCode = 1;
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
|
-
if (await ask("Go ahead?
|
|
23
|
+
if (await ask("Go ahead?")) return true;
|
|
23
24
|
write("Cancelled.");
|
|
24
25
|
return false;
|
|
25
26
|
};
|
|
@@ -32,18 +33,18 @@ const goAhead = async (yes, verb, terminal = process.stdin.isTTY, ask = confirm)
|
|
|
32
33
|
* them.
|
|
33
34
|
*/
|
|
34
35
|
/** One line of state: its merge state, then what clean would care about. */
|
|
35
|
-
const worktreeState = (item) => {
|
|
36
|
+
const worktreeState = (item, term = termOf(process.stdout)) => {
|
|
36
37
|
const merge = mergeStateOf(item);
|
|
37
|
-
const head = merge === "merged" ? [style("green", "merged")] : merge === "detached" ? ["detached"] : [];
|
|
38
|
-
const parts = stateParts(item).map((part) => part.risk ?
|
|
38
|
+
const head = merge === "merged" ? [term.rich ? chip(term, "MERGED", "ok") : style("green", "merged")] : merge === "detached" ? ["detached"] : [];
|
|
39
|
+
const parts = stateParts(item).map((part) => part.risk ? paint(term, "warn", part.text) : part.text);
|
|
39
40
|
return [...head, ...parts].join(" · ");
|
|
40
41
|
};
|
|
41
42
|
/** A name as the list shows it, saying when it's detached. */
|
|
42
43
|
const nameOf = (item) => mergeStateOf(item) === "detached" ? `${labelOf(item)} (detached)` : labelOf(item);
|
|
43
|
-
const formatWorktrees = (items) => {
|
|
44
|
+
const formatWorktrees = (items, term = termOf(process.stdout)) => {
|
|
44
45
|
if (items.length === 0) return ["No Ork worktrees or branches."];
|
|
45
46
|
const width = Math.max(...items.map((i) => nameOf(i).length));
|
|
46
|
-
return items.flatMap((item) => [`${style("bold", nameOf(item).padEnd(width))} ${worktreeState(item)}`, ...item.path === null ? [] : [` ${style("dim", item.path)}`]]);
|
|
47
|
+
return items.flatMap((item) => [`${style("bold", nameOf(item).padEnd(width))} ${worktreeState(item, term)}`, ...item.path === null ? [] : [` ${style("dim", term.rich ? cut(item.path, term.width - 2) : item.path)}`]]);
|
|
47
48
|
};
|
|
48
49
|
const formatPlan = (steps) => steps.map((step) => {
|
|
49
50
|
const { text, reason } = planLine(step);
|
package/package.json
CHANGED
package/dist/output-Bqljtmp_.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { stripVTControlCharacters, styleText } from "node:util";
|
|
3
|
-
// src/output.ts
|
|
4
|
-
/**
|
|
5
|
-
* @file Terminal output helpers: styled text that turns plain when stdout is
|
|
6
|
-
* not a TTY or `NO_COLOR` is set, and a yes-or-no question on the terminal.
|
|
7
|
-
*/
|
|
8
|
-
/** Styles text for stdout; plain when stdout is not a TTY or NO_COLOR is set. */
|
|
9
|
-
const style = (format, text) => styleText(format, text, { stream: process.stdout });
|
|
10
|
-
/**
|
|
11
|
-
* Text from outside, fit for a terminal: escape sequences could hide a line on
|
|
12
|
-
* the very screen a person judges from, and a line break could forge one.
|
|
13
|
-
*/
|
|
14
|
-
const plain = (text) => stripVTControlCharacters(text).replaceAll(/[\p{Cc}\p{Bidi_Control}]/gu, " ");
|
|
15
|
-
const write = (text) => {
|
|
16
|
-
process.stdout.write(`${text}\n`);
|
|
17
|
-
};
|
|
18
|
-
const writeErr = (text) => {
|
|
19
|
-
process.stderr.write(`${text}\n`);
|
|
20
|
-
};
|
|
21
|
-
/** What a run spent: `$0.0312`, or `$0.00` for nothing. */
|
|
22
|
-
const cost = (usd) => usd === 0 ? "$0.00" : `$${usd.toFixed(4)}`;
|
|
23
|
-
/** Asks a yes-or-no question on the terminal; anything but yes is no. */
|
|
24
|
-
const confirm = async (question) => {
|
|
25
|
-
const rl = createInterface({
|
|
26
|
-
input: process.stdin,
|
|
27
|
-
output: process.stderr
|
|
28
|
-
});
|
|
29
|
-
const { promise: ended, resolve: end } = Promise.withResolvers();
|
|
30
|
-
rl.once("close", () => {
|
|
31
|
-
end("");
|
|
32
|
-
});
|
|
33
|
-
try {
|
|
34
|
-
const answer = await Promise.race([rl.question(question), ended]);
|
|
35
|
-
return ["y", "yes"].includes(answer.trim().toLowerCase());
|
|
36
|
-
} finally {
|
|
37
|
-
rl.close();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
export { write as a, style as i, cost as n, writeErr as o, plain as r, confirm as t };
|