@oneie/cli 5.8.0 → 5.9.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.
Files changed (270) hide show
  1. package/README.md +114 -6
  2. package/dist/package.json +37 -11
  3. package/dist/src/age-1k8hs4ec.js +1 -0
  4. package/dist/src/client-n6fpnd9f.js +1 -0
  5. package/dist/src/evm-tx-cqhm9rtt.js +1 -0
  6. package/dist/src/hl-run-0pv1e0p2.js +1 -0
  7. package/dist/src/index-f5vhzspa.js +12 -0
  8. package/dist/src/index-h3nrt8bx.js +4 -0
  9. package/dist/src/index-st6k9vhc.js +2062 -0
  10. package/dist/src/index.js +1122 -134
  11. package/dist/src/message-key-yczrxszr.js +1 -0
  12. package/dist/src/message-lock-thr851d5.js +5 -0
  13. package/dist/src/sweep-order-jrq2hkye.js +1 -0
  14. package/dist/src/sweep-runner-jftw9em7.js +1 -0
  15. package/package.json +37 -11
  16. package/dist/src/agent.d.ts +0 -75
  17. package/dist/src/agent.js +0 -1334
  18. package/dist/src/agentverse.d.ts +0 -26
  19. package/dist/src/agentverse.js +0 -171
  20. package/dist/src/args.d.ts +0 -9
  21. package/dist/src/args.js +0 -61
  22. package/dist/src/auth.d.ts +0 -6
  23. package/dist/src/auth.js +0 -121
  24. package/dist/src/balances.d.ts +0 -89
  25. package/dist/src/balances.js +0 -202
  26. package/dist/src/banner.d.ts +0 -1
  27. package/dist/src/banner.js +0 -17
  28. package/dist/src/broadcast.d.ts +0 -8
  29. package/dist/src/broadcast.js +0 -175
  30. package/dist/src/catalog.d.ts +0 -12
  31. package/dist/src/catalog.js +0 -76
  32. package/dist/src/ceiling.d.ts +0 -36
  33. package/dist/src/ceiling.js +0 -189
  34. package/dist/src/chat.d.ts +0 -2
  35. package/dist/src/chat.js +0 -92
  36. package/dist/src/check.d.ts +0 -11
  37. package/dist/src/check.js +0 -53
  38. package/dist/src/client.d.ts +0 -5
  39. package/dist/src/client.js +0 -157
  40. package/dist/src/compiler.d.ts +0 -36
  41. package/dist/src/compiler.js +0 -366
  42. package/dist/src/config.d.ts +0 -24
  43. package/dist/src/config.js +0 -70
  44. package/dist/src/connect.d.ts +0 -2
  45. package/dist/src/connect.js +0 -64
  46. package/dist/src/coordinate.d.ts +0 -3
  47. package/dist/src/coordinate.js +0 -58
  48. package/dist/src/create.d.ts +0 -2
  49. package/dist/src/create.js +0 -113
  50. package/dist/src/credits.d.ts +0 -29
  51. package/dist/src/credits.js +0 -88
  52. package/dist/src/deploy.d.ts +0 -2
  53. package/dist/src/deploy.js +0 -19
  54. package/dist/src/dev.d.ts +0 -2
  55. package/dist/src/dev.js +0 -75
  56. package/dist/src/device-flow.d.ts +0 -57
  57. package/dist/src/device-flow.js +0 -173
  58. package/dist/src/doctor.d.ts +0 -26
  59. package/dist/src/doctor.js +0 -146
  60. package/dist/src/draw.d.ts +0 -18
  61. package/dist/src/draw.js +0 -156
  62. package/dist/src/endpoint.d.ts +0 -2
  63. package/dist/src/endpoint.js +0 -250
  64. package/dist/src/env.d.ts +0 -3
  65. package/dist/src/env.js +0 -37
  66. package/dist/src/eval.d.ts +0 -2
  67. package/dist/src/eval.js +0 -43
  68. package/dist/src/fn.d.ts +0 -2
  69. package/dist/src/fn.js +0 -70
  70. package/dist/src/group.d.ts +0 -2
  71. package/dist/src/group.js +0 -117
  72. package/dist/src/hl-run.d.ts +0 -119
  73. package/dist/src/hl-run.js +0 -480
  74. package/dist/src/hl.d.ts +0 -17
  75. package/dist/src/hl.js +0 -148
  76. package/dist/src/index.d.ts +0 -2
  77. package/dist/src/init.d.ts +0 -76
  78. package/dist/src/init.js +0 -278
  79. package/dist/src/join.d.ts +0 -11
  80. package/dist/src/join.js +0 -297
  81. package/dist/src/key-publish.d.ts +0 -40
  82. package/dist/src/key-publish.js +0 -232
  83. package/dist/src/key-seal.d.ts +0 -21
  84. package/dist/src/key-seal.js +0 -142
  85. package/dist/src/key-sweep.d.ts +0 -93
  86. package/dist/src/key-sweep.js +0 -270
  87. package/dist/src/key.d.ts +0 -26
  88. package/dist/src/key.js +0 -338
  89. package/dist/src/lib/age-plugin.d.ts +0 -51
  90. package/dist/src/lib/age-plugin.js +0 -130
  91. package/dist/src/lib/agent-env.d.ts +0 -12
  92. package/dist/src/lib/agent-env.js +0 -48
  93. package/dist/src/lib/api-path.d.ts +0 -2
  94. package/dist/src/lib/api-path.js +0 -40
  95. package/dist/src/lib/asker.d.ts +0 -34
  96. package/dist/src/lib/asker.js +0 -126
  97. package/dist/src/lib/check-words.d.ts +0 -57
  98. package/dist/src/lib/check-words.js +0 -144
  99. package/dist/src/lib/client.d.ts +0 -20
  100. package/dist/src/lib/client.js +0 -71
  101. package/dist/src/lib/env-sealed.d.ts +0 -53
  102. package/dist/src/lib/env-sealed.js +0 -184
  103. package/dist/src/lib/flow-tag.d.ts +0 -86
  104. package/dist/src/lib/flow-tag.js +0 -230
  105. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  106. package/dist/src/lib/hl-core/actions.js +0 -69
  107. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  108. package/dist/src/lib/hl-core/eip712.js +0 -107
  109. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  110. package/dist/src/lib/hl-core/errors.js +0 -15
  111. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  112. package/dist/src/lib/hl-core/exchange.js +0 -47
  113. package/dist/src/lib/hl-core/index.d.ts +0 -13
  114. package/dist/src/lib/hl-core/index.js +0 -14
  115. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  116. package/dist/src/lib/hl-core/meta.js +0 -110
  117. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  118. package/dist/src/lib/hl-core/msgpack.js +0 -136
  119. package/dist/src/lib/hl-core/net.d.ts +0 -2
  120. package/dist/src/lib/hl-core/net.js +0 -7
  121. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  122. package/dist/src/lib/hl-core/signing.js +0 -295
  123. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  124. package/dist/src/lib/hl-core/wire.js +0 -81
  125. package/dist/src/lib/invoked-as.d.ts +0 -2
  126. package/dist/src/lib/invoked-as.js +0 -24
  127. package/dist/src/lib/journey-words.d.ts +0 -84
  128. package/dist/src/lib/journey-words.js +0 -363
  129. package/dist/src/lib/journey.d.ts +0 -150
  130. package/dist/src/lib/journey.js +0 -264
  131. package/dist/src/lib/key-receipt.d.ts +0 -48
  132. package/dist/src/lib/key-receipt.js +0 -116
  133. package/dist/src/lib/key-source.d.ts +0 -9
  134. package/dist/src/lib/key-source.js +0 -33
  135. package/dist/src/lib/keyfile.d.ts +0 -136
  136. package/dist/src/lib/keyfile.js +0 -397
  137. package/dist/src/lib/launch-claude.d.ts +0 -5
  138. package/dist/src/lib/launch-claude.js +0 -45
  139. package/dist/src/lib/lock-lookup.d.ts +0 -40
  140. package/dist/src/lib/lock-lookup.js +0 -92
  141. package/dist/src/lib/message-seal.d.ts +0 -63
  142. package/dist/src/lib/message-seal.js +0 -150
  143. package/dist/src/lib/net-choice.d.ts +0 -28
  144. package/dist/src/lib/net-choice.js +0 -72
  145. package/dist/src/lib/network.d.ts +0 -22
  146. package/dist/src/lib/network.js +0 -50
  147. package/dist/src/lib/next-words.d.ts +0 -105
  148. package/dist/src/lib/next-words.js +0 -298
  149. package/dist/src/lib/paths.d.ts +0 -41
  150. package/dist/src/lib/paths.js +0 -91
  151. package/dist/src/lib/plan-draw.d.ts +0 -56
  152. package/dist/src/lib/plan-draw.js +0 -219
  153. package/dist/src/lib/plan-live.d.ts +0 -20
  154. package/dist/src/lib/plan-live.js +0 -192
  155. package/dist/src/lib/qr.d.ts +0 -21
  156. package/dist/src/lib/qr.js +0 -402
  157. package/dist/src/lib/roster.d.ts +0 -20
  158. package/dist/src/lib/roster.js +0 -79
  159. package/dist/src/lib/sale-card.d.ts +0 -117
  160. package/dist/src/lib/sale-card.js +0 -261
  161. package/dist/src/lib/shop-init.d.ts +0 -62
  162. package/dist/src/lib/shop-init.js +0 -63
  163. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  164. package/dist/src/lib/sui-grpc-send.js +0 -128
  165. package/dist/src/lib/swap-core.d.ts +0 -163
  166. package/dist/src/lib/swap-core.js +0 -405
  167. package/dist/src/lib/tasks-digest.d.ts +0 -66
  168. package/dist/src/lib/tasks-digest.js +0 -200
  169. package/dist/src/lib/tasks-graph.d.ts +0 -79
  170. package/dist/src/lib/tasks-graph.js +0 -463
  171. package/dist/src/lib/tasks-lens.d.ts +0 -31
  172. package/dist/src/lib/tasks-lens.js +0 -47
  173. package/dist/src/lib/tasks-next.d.ts +0 -25
  174. package/dist/src/lib/tasks-next.js +0 -103
  175. package/dist/src/lib/tasks-prove.d.ts +0 -15
  176. package/dist/src/lib/tasks-prove.js +0 -68
  177. package/dist/src/lib/tasks-route.d.ts +0 -29
  178. package/dist/src/lib/tasks-route.js +0 -151
  179. package/dist/src/lib/tasks-score.d.ts +0 -36
  180. package/dist/src/lib/tasks-score.js +0 -152
  181. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  182. package/dist/src/lib/tasks-workspace.js +0 -73
  183. package/dist/src/lib/timed-fetch.d.ts +0 -33
  184. package/dist/src/lib/timed-fetch.js +0 -59
  185. package/dist/src/lib/vault-read.d.ts +0 -24
  186. package/dist/src/lib/vault-read.js +0 -77
  187. package/dist/src/lib/vaultfile.d.ts +0 -103
  188. package/dist/src/lib/vaultfile.js +0 -249
  189. package/dist/src/lib/wallet-money.d.ts +0 -222
  190. package/dist/src/lib/wallet-money.js +0 -578
  191. package/dist/src/lib/wallet-request.d.ts +0 -50
  192. package/dist/src/lib/wallet-request.js +0 -86
  193. package/dist/src/links.d.ts +0 -5
  194. package/dist/src/links.js +0 -45
  195. package/dist/src/media.d.ts +0 -29
  196. package/dist/src/media.js +0 -487
  197. package/dist/src/message-receipt.d.ts +0 -25
  198. package/dist/src/message-receipt.js +0 -71
  199. package/dist/src/message.d.ts +0 -13
  200. package/dist/src/message.js +0 -92
  201. package/dist/src/move.d.ts +0 -36
  202. package/dist/src/move.js +0 -152
  203. package/dist/src/network-cmd.d.ts +0 -17
  204. package/dist/src/network-cmd.js +0 -74
  205. package/dist/src/next.d.ts +0 -12
  206. package/dist/src/next.js +0 -67
  207. package/dist/src/onboard.d.ts +0 -16
  208. package/dist/src/onboard.js +0 -149
  209. package/dist/src/plugin.d.ts +0 -2
  210. package/dist/src/plugin.js +0 -193
  211. package/dist/src/push.d.ts +0 -2
  212. package/dist/src/push.js +0 -115
  213. package/dist/src/render.d.ts +0 -21
  214. package/dist/src/render.js +0 -32
  215. package/dist/src/secrets-device.d.ts +0 -32
  216. package/dist/src/secrets-device.js +0 -127
  217. package/dist/src/secrets-give.d.ts +0 -125
  218. package/dist/src/secrets-give.js +0 -236
  219. package/dist/src/secrets-list.d.ts +0 -27
  220. package/dist/src/secrets-list.js +0 -84
  221. package/dist/src/secrets-run.d.ts +0 -31
  222. package/dist/src/secrets-run.js +0 -182
  223. package/dist/src/secrets.d.ts +0 -33
  224. package/dist/src/secrets.js +0 -200
  225. package/dist/src/setup.d.ts +0 -6
  226. package/dist/src/setup.js +0 -127
  227. package/dist/src/ship.d.ts +0 -2
  228. package/dist/src/ship.js +0 -18
  229. package/dist/src/shop-buy.d.ts +0 -16
  230. package/dist/src/shop-buy.js +0 -101
  231. package/dist/src/shop.d.ts +0 -10
  232. package/dist/src/shop.js +0 -112
  233. package/dist/src/skill-parser.d.ts +0 -14
  234. package/dist/src/skill-parser.js +0 -113
  235. package/dist/src/skill.d.ts +0 -2
  236. package/dist/src/skill.js +0 -493
  237. package/dist/src/slug.d.ts +0 -2
  238. package/dist/src/slug.js +0 -6
  239. package/dist/src/social.d.ts +0 -2
  240. package/dist/src/social.js +0 -106
  241. package/dist/src/staff.d.ts +0 -2
  242. package/dist/src/staff.js +0 -104
  243. package/dist/src/start.d.ts +0 -27
  244. package/dist/src/start.js +0 -225
  245. package/dist/src/status.d.ts +0 -2
  246. package/dist/src/status.js +0 -52
  247. package/dist/src/substrate.d.ts +0 -2
  248. package/dist/src/substrate.js +0 -258
  249. package/dist/src/swap.d.ts +0 -93
  250. package/dist/src/swap.js +0 -622
  251. package/dist/src/tasks.d.ts +0 -2
  252. package/dist/src/tasks.js +0 -743
  253. package/dist/src/templates.d.ts +0 -1
  254. package/dist/src/templates.js +0 -213
  255. package/dist/src/thread.d.ts +0 -2
  256. package/dist/src/thread.js +0 -52
  257. package/dist/src/trade.d.ts +0 -2
  258. package/dist/src/trade.js +0 -91
  259. package/dist/src/trail.d.ts +0 -2
  260. package/dist/src/trail.js +0 -41
  261. package/dist/src/validate.d.ts +0 -13
  262. package/dist/src/validate.js +0 -35
  263. package/dist/src/wallet-money.d.ts +0 -158
  264. package/dist/src/wallet-money.js +0 -664
  265. package/dist/src/wallet.d.ts +0 -169
  266. package/dist/src/wallet.js +0 -973
  267. package/dist/src/workflow.d.ts +0 -2
  268. package/dist/src/workflow.js +0 -169
  269. package/dist/src/write.d.ts +0 -43
  270. package/dist/src/write.js +0 -180
@@ -1,219 +0,0 @@
1
- import { CLOSED, planWaves } from './tasks-graph.js';
2
- // A plan, drawn. Pure — rows in, lines out — so the live view, `--draw` for a
3
- // pipe or an agent, and the tests all render the same picture.
4
- //
5
- // The shape was chosen by looking, not by theory (2026-09-25): drawing every
6
- // dependency as a routed arrow turned 25 edges into a wiring loom nobody could
7
- // read. So only the CRITICAL PATH is drawn as arrows, on one row across the top,
8
- // and every other dependency is written as words inside the box ("waits: view").
9
- // The critical path is the one chain that decides when the plan can finish.
10
- export const BOX_W = 26;
11
- const BOX_H = 5;
12
- const GAP = 6;
13
- const TOP = 0;
14
- /** Status after local receipts: a write we just made is the truth about that
15
- * row, even while the board snapshot (a ≤60s memo) still shows the old state. */
16
- export function withOverrides(rows, overrides) {
17
- if (!overrides.size)
18
- return rows;
19
- return rows.map((r) => (overrides.has(r.tid) ? { ...r, status: overrides.get(r.tid) } : r));
20
- }
21
- /** Open blockers of a row.
22
- * - in view: by name, from its CURRENT status (a local receipt counts);
23
- * - outside the view but in `world` (the board read, as the snapshot saw it): by status;
24
- * - not returned by the read at all (the read carries ACTIVE rows, so a DONE
25
- * blocker is simply absent): the snapshot's own `openBlockers` count decides —
26
- * whatever it counted open beyond the blockers we can see is still open. */
27
- export function openBlockers(r, byTid, world) {
28
- const ids = r.blockedBy ?? [];
29
- const names = [];
30
- let outside = 0;
31
- let openAtSnapshotSeen = 0;
32
- for (const b of ids) {
33
- const snap = world?.get(b);
34
- if (snap && !CLOSED.has(snap.status))
35
- openAtSnapshotSeen++;
36
- const inView = byTid.get(b);
37
- if (inView) {
38
- if (!CLOSED.has(inView.status))
39
- names.push(shortName(inView));
40
- }
41
- else if (snap) {
42
- if (!CLOSED.has(snap.status))
43
- outside++;
44
- }
45
- }
46
- const snapshotOpen = r.openBlockers ?? 0;
47
- outside += Math.max(0, snapshotOpen - openAtSnapshotSeen);
48
- return { names, outside };
49
- }
50
- export function isReady(r, byTid, world) {
51
- if (r.status !== 'open')
52
- return false;
53
- const ob = openBlockers(r, byTid, world);
54
- return ob.names.length === 0 && ob.outside === 0;
55
- }
56
- /** A short handle: a `cli-*`-style slug tag when the row carries one, else its name. */
57
- export function shortName(r) {
58
- const slug = (r.tags ?? []).find((t) => /^[a-z]+-[a-z][a-z0-9-]*$/.test(t) && !/-\d+$/.test(t));
59
- const base = slug && r.name.length > BOX_W - 4 ? slug : r.name;
60
- return base.replace(/\s+—.*$/, '').trim();
61
- }
62
- function wrap(s, w, lines) {
63
- const words = s.split(/\s+/);
64
- const out = [];
65
- let cur = '';
66
- for (const word of words) {
67
- if ((cur + ' ' + word).trim().length > w) {
68
- out.push(cur.trim());
69
- cur = word;
70
- if (out.length === lines)
71
- break;
72
- }
73
- else
74
- cur += ' ' + word;
75
- }
76
- if (out.length < lines && cur.trim())
77
- out.push(cur.trim());
78
- if (out.length === lines && words.join(' ').length > out.join(' ').length) {
79
- out[lines - 1] = out[lines - 1].slice(0, w - 1) + '…';
80
- }
81
- return out.map((l) => l.slice(0, w));
82
- }
83
- export function drawPlan(rows, opts = {}) {
84
- const byTid = new Map(rows.map((r) => [r.tid, r]));
85
- const plan = planWaves(rows);
86
- const crit = plan.criticalPath.tids;
87
- const critSet = new Set(crit);
88
- const G = new Map();
89
- const styles = new Map();
90
- const put = (x, y, s, style) => {
91
- ;
92
- [...s].forEach((c, i) => {
93
- G.set(`${x + i},${y}`, c);
94
- if (style)
95
- styles.set(`${x + i},${y}`, style);
96
- });
97
- };
98
- // Strip a prefix most rows share ("cli-") — it carries no information in a
99
- // box 22 characters wide, and it is what cut every "waits …" line short.
100
- const names = rows.map((r) => shortName(r));
101
- const pre = (names.find((n) => /^[a-z]+-/.test(n)) ?? '').replace(/^([a-z]+-).*$/, '$1');
102
- const strip = pre !== '' && names.filter((n) => n.startsWith(pre)).length >= names.length * 0.6;
103
- const label = (r) => { const n = shortName(r); return strip && n.startsWith(pre) ? n.slice(pre.length) : n; };
104
- // A row with open subtasks cannot be claimed (tasks:claim's containment gate),
105
- // so it is never "ready", whatever its own blockers say.
106
- const openKids = new Map();
107
- for (const r of rows)
108
- if (r.parent && !CLOSED.has(r.status))
109
- openKids.set(r.parent, (openKids.get(r.parent) ?? 0) + 1);
110
- const boxes = new Map();
111
- const columns = [];
112
- plan.waves.forEach((wave, col) => {
113
- const critHere = wave.tids.find((t) => critSet.has(t));
114
- const rest = wave.tids
115
- .filter((t) => t !== critHere)
116
- .sort((a, b) => {
117
- const ra = byTid.get(a), rb = byTid.get(b);
118
- return Number(isReady(rb, byTid, opts.world)) - Number(isReady(ra, byTid, opts.world)) || (rb.priority ?? 0) - (ra.priority ?? 0);
119
- });
120
- // Slot 0 of every column is the critical path's lane — empty when this wave
121
- // has no critical row, so the arrow can pass straight through.
122
- const order = [critHere ?? null, ...rest];
123
- columns[col] = order.filter((t) => t !== null);
124
- order.forEach((tid, idx) => {
125
- const x = col * (BOX_W + GAP);
126
- const y = TOP + idx * (BOX_H + 1);
127
- if (!tid)
128
- return;
129
- const r = byTid.get(tid);
130
- boxes.set(tid, { x, y, col, idx: columns[col].indexOf(tid) });
131
- const kids = openKids.get(tid) ?? 0;
132
- const ready = kids === 0 && isReady(r, byTid, opts.world);
133
- const style = opts.selected === tid ? 'selected'
134
- : opts.changed?.has(tid) ? 'changed'
135
- : critSet.has(tid) ? 'critical'
136
- : ready ? 'ready'
137
- : 'dim';
138
- const edge = critSet.has(tid) ? '=' : '-';
139
- put(x, y, '+' + edge.repeat(BOX_W - 2) + '+', style);
140
- put(x, y + BOX_H - 1, '+' + edge.repeat(BOX_W - 2) + '+', style);
141
- for (let k = 1; k < BOX_H - 1; k++) {
142
- put(x, y + k, '|', style);
143
- put(x + BOX_W - 1, y + k, '|', style);
144
- }
145
- const [l1 = '', l2 = ''] = wrap(label(r), BOX_W - 4, 2);
146
- put(x + 2, y + 1, l1, style);
147
- put(x + 2, y + 2, l2, style);
148
- const ob = openBlockers(r, byTid, opts.world);
149
- const who = r.assignee ? ` @${r.assignee}` : '';
150
- const status = r.status === 'picked' ? `picked${who}`
151
- : ready ? '> ready to start'
152
- : kids ? `waits ${kids} subtasks`
153
- : r.status === 'open' ? `waits ${[...ob.names.map((n) => (strip && n.startsWith(pre) ? n.slice(pre.length) : n)), ...(ob.outside ? [`+${ob.outside} outside`] : [])].join(', ')}`
154
- : r.status;
155
- put(x + 2, y + 3, status.slice(0, BOX_W - 4), style);
156
- });
157
- });
158
- // The critical path, drawn along lane 0 between consecutive critical boxes.
159
- for (let i = 1; i < crit.length; i++) {
160
- const a = boxes.get(crit[i - 1]), b = boxes.get(crit[i]);
161
- if (!a || !b)
162
- continue;
163
- for (let x = a.x + BOX_W; x < b.x - 1; x++) {
164
- if (!G.has(`${x},2`))
165
- put(x, 2, '=', 'critical');
166
- }
167
- put(b.x - 1, 2, '>', 'critical');
168
- }
169
- let maxX = 0, maxY = 0;
170
- for (const k of G.keys()) {
171
- const [x, y] = k.split(',').map(Number);
172
- if (x > maxX)
173
- maxX = x;
174
- if (y > maxY)
175
- maxY = y;
176
- }
177
- const lines = [];
178
- for (let y = 0; y <= maxY; y++) {
179
- let line = '';
180
- for (let x = 0; x <= maxX; x++)
181
- line += G.get(`${x},${y}`) ?? ' ';
182
- lines.push(line.replace(/\s+$/, ''));
183
- }
184
- return { lines, styles, boxes, columns, plan };
185
- }
186
- /** The one-paragraph header both the print and the live view carry. */
187
- export function planHeader(rows, plan, opts) {
188
- const byTid = new Map(rows.map((r) => [r.tid, r]));
189
- const open = rows.filter((r) => !CLOSED.has(r.status));
190
- const parents = new Set(open.map((r) => r.parent).filter(Boolean));
191
- const ready = open.filter((r) => !parents.has(r.tid) && isReady(r, byTid, opts.world)).length;
192
- const cp = plan.criticalPath.tids.map((t) => shortName(byTid.get(t)));
193
- return [
194
- `${opts.title ?? 'plan'} — ${open.length} open · ${ready} ready to start · ${plan.waves.length} waves${opts.asOf ? ` · board read ${opts.asOf.slice(0, 16)}Z` : ''}`,
195
- `critical path (${cp.length} steps decide the finish): ${cp.join(' → ') || '(none)'}`,
196
- ];
197
- }
198
- /** What changed between two views of the same plan — the answer to "what happened?" */
199
- export function planDelta(before, after, world) {
200
- const bBy = new Map(before.map((r) => [r.tid, r]));
201
- const aBy = new Map(after.map((r) => [r.tid, r]));
202
- const nowReady = after
203
- .filter((r) => isReady(r, aBy, world) && !(bBy.has(r.tid) && isReady(bBy.get(r.tid), bBy, world)))
204
- .map((r) => r.tid);
205
- const name = (by) => (t) => shortName(by.get(t));
206
- return {
207
- nowReady,
208
- critBefore: planWaves(before).criticalPath.tids.map(name(bBy)),
209
- critAfter: planWaves(after).criticalPath.tids.map(name(aBy)),
210
- };
211
- }
212
- /** lazydraw's file shape, so `one draw <name>` can open and edit the picture. */
213
- export function toLazydraw(lines, name) {
214
- const cells = [];
215
- lines.forEach((l, y) => [...l].forEach((c, x) => { if (c !== ' ')
216
- cells.push([x, y, c]); }));
217
- const now = new Date().toISOString();
218
- return JSON.stringify({ version: 1, name, createdAt: now, updatedAt: now, cells }, null, 2) + '\n';
219
- }
@@ -1,20 +0,0 @@
1
- import type { Row } from './tasks-graph.js';
2
- export interface LiveData {
3
- rows: Row[];
4
- world: Map<string, Row>;
5
- asOf?: string;
6
- }
7
- export type Act = (receiver: string, data: Record<string, unknown>) => Promise<{
8
- ok: boolean;
9
- error?: string;
10
- detail?: string;
11
- }>;
12
- export interface LiveOpts {
13
- title: string;
14
- load: () => Promise<LiveData>;
15
- act: Act;
16
- workspace?: string;
17
- input?: NodeJS.ReadStream;
18
- output?: NodeJS.WriteStream;
19
- }
20
- export declare function runLivePlan(o: LiveOpts): Promise<void>;
@@ -1,192 +0,0 @@
1
- import { emitKeypressEvents } from 'node:readline';
2
- import { createInterface } from 'node:readline/promises';
3
- import { drawPlan, planDelta, planHeader, shortName, withOverrides } from './plan-draw.js';
4
- const ESC = '\x1b[';
5
- const PAINT = {
6
- selected: `${ESC}7m`, // inverse
7
- critical: `${ESC}33m`, // yellow
8
- ready: `${ESC}32m`, // green
9
- changed: `${ESC}1;35m`, // bold magenta
10
- dim: `${ESC}2m`,
11
- };
12
- const RESET = `${ESC}0m`;
13
- const HELP = '←→↑↓ select · c claim · d done · o reopen · m comment · enter notes · r refresh · q quit';
14
- export async function runLivePlan(o) {
15
- const input = o.input ?? process.stdin;
16
- const out = o.output ?? process.stdout;
17
- let data = await o.load();
18
- const overrides = new Map();
19
- let changed = new Set();
20
- let message = 'Pick a row with the arrow keys, then act on it.';
21
- let showNotes = false;
22
- let selected;
23
- let busy = false;
24
- const view = () => withOverrides(data.rows, overrides);
25
- const render = () => {
26
- const rows = view();
27
- const world = data.world; // the snapshot as read — never the local overrides
28
- const d = drawPlan(rows, { selected, changed, world });
29
- if (!selected || !d.boxes.has(selected))
30
- selected = d.columns.flat()[0];
31
- const d2 = selected ? drawPlan(rows, { selected, changed, world }) : d;
32
- const cols = out.columns || 120;
33
- const height = (out.rows || 40) - 9;
34
- const sel = selected ? d2.boxes.get(selected) : undefined;
35
- // Scroll so the selected box is always on screen.
36
- const x0 = sel ? Math.max(0, Math.min(sel.x - 4, sel.x + 30 - cols)) : 0;
37
- const y0 = sel ? Math.max(0, sel.y + 6 - height) : 0;
38
- const body = [];
39
- for (let y = y0; y < Math.min(d2.lines.length, y0 + height); y++) {
40
- const line = d2.lines[y] ?? '';
41
- let s = '';
42
- let cur;
43
- for (let x = x0; x < Math.min(line.length, x0 + cols); x++) {
44
- const st = d2.styles.get(`${x},${y}`);
45
- if (st !== cur) {
46
- s += RESET + (st ? PAINT[st] : '');
47
- cur = st;
48
- }
49
- s += line[x];
50
- }
51
- body.push(s + RESET);
52
- }
53
- const r = selected ? rows.find((t) => t.tid === selected) : undefined;
54
- const header = planHeader(rows, d2.plan, { title: o.title, asOf: data.asOf, world });
55
- const detail = r ? [`${ESC}1m${r.name}${RESET}`, `${r.tid} · ${r.status}${r.assignee ? ' · @' + r.assignee : ''} · priority ${r.priority ?? 0}`] : [''];
56
- const notes = showNotes && r ? (String(r.notes ?? '(no notes)')).split('\n').slice(0, 12) : [];
57
- out.write(`${ESC}2J${ESC}H`);
58
- out.write([...header, '', ...body, '', ...detail, ...notes, '', `${ESC}1m${message}${RESET}`, `${ESC}2m${HELP}${RESET}`].join('\n') + '\n');
59
- };
60
- const move = (dx, dy) => {
61
- const rows = view();
62
- const d = drawPlan(rows, { world: data.world });
63
- const here = selected ? d.boxes.get(selected) : undefined;
64
- if (!here) {
65
- selected = d.columns.flat()[0];
66
- return;
67
- }
68
- const col = Math.max(0, Math.min(d.columns.length - 1, here.col + dx));
69
- const list = d.columns[col] ?? [];
70
- const idx = dx !== 0 ? Math.min(here.idx, list.length - 1) : Math.max(0, Math.min(list.length - 1, here.idx + dy));
71
- selected = list[idx] ?? selected;
72
- };
73
- const doAct = async (label, receiver, extra, nextStatus) => {
74
- if (!selected || busy)
75
- return;
76
- const tid = selected;
77
- const before = view();
78
- busy = true;
79
- message = `${label} ${shortName(before.find((r) => r.tid === tid))} …`;
80
- render();
81
- try {
82
- const res = await o.act(receiver, { tid, ...(o.workspace ? { workspace: o.workspace } : {}), ...extra });
83
- if (!res.ok) {
84
- message = `✗ ${label} refused: ${res.error ?? 'unknown'}${res.detail ? ' — ' + res.detail : ''} (nothing changed)`;
85
- changed = new Set();
86
- return;
87
- }
88
- if (nextStatus)
89
- overrides.set(tid, nextStatus);
90
- const after = view();
91
- const delta = planDelta(before, after, data.world);
92
- changed = new Set([tid, ...delta.nowReady]);
93
- const name = (t) => shortName(after.find((r) => r.tid === t));
94
- const parts = [`✓ ${label} ${name(tid)}`];
95
- if (delta.nowReady.length)
96
- parts.push(`now ready: ${delta.nowReady.map(name).join(', ')}`);
97
- if (delta.critBefore.join() !== delta.critAfter.join()) {
98
- parts.push(`critical path ${delta.critBefore.length} → ${delta.critAfter.length} steps`);
99
- }
100
- parts.push('(from the receipt; the board snapshot catches up within 60s — r to re-read)');
101
- message = parts.join(' · ');
102
- }
103
- catch (e) {
104
- message = `✗ ${label} failed: ${e.message} (did not land — nothing changed)`;
105
- }
106
- finally {
107
- busy = false;
108
- }
109
- };
110
- const ask = async (prompt) => {
111
- input.setRawMode?.(false);
112
- const rl = createInterface({ input, output: out });
113
- const answer = await rl.question(prompt);
114
- rl.close();
115
- input.setRawMode?.(true);
116
- return answer.trim();
117
- };
118
- emitKeypressEvents(input);
119
- input.setRawMode?.(true);
120
- input.resume();
121
- out.write(`${ESC}?25l`); // hide cursor
122
- render();
123
- await new Promise((resolve) => {
124
- const quit = () => {
125
- input.setRawMode?.(false);
126
- input.pause();
127
- input.removeListener('keypress', onKey);
128
- out.write(`${ESC}?25h\n`);
129
- resolve();
130
- };
131
- const onKey = async (_s, key) => {
132
- if (busy)
133
- return;
134
- if (key.ctrl && key.name === 'c')
135
- return quit();
136
- switch (key.name) {
137
- case 'q': return quit();
138
- case 'left':
139
- move(-1, 0);
140
- break;
141
- case 'right':
142
- move(1, 0);
143
- break;
144
- case 'up':
145
- move(0, -1);
146
- break;
147
- case 'down':
148
- move(0, 1);
149
- break;
150
- case 'return':
151
- showNotes = !showNotes;
152
- break;
153
- case 'c':
154
- await doAct('claimed', 'tasks:claim', {}, 'picked');
155
- break;
156
- case 'd':
157
- await doAct('done', 'tasks:status', { status: 'done' }, 'done');
158
- break;
159
- case 'o':
160
- await doAct('reopened', 'tasks:status', { status: 'open' }, 'open');
161
- break;
162
- case 'm': {
163
- const body = await ask('comment (enter to post, empty to cancel): ');
164
- if (body)
165
- await doAct('commented on', 'tasks:comment', { body });
166
- break;
167
- }
168
- case 'r': {
169
- message = 're-reading the board …';
170
- render();
171
- try {
172
- data = await o.load();
173
- // A receipt stays applied until the snapshot agrees with it.
174
- for (const [tid, st] of overrides)
175
- if (data.rows.find((r) => r.tid === tid)?.status === st)
176
- overrides.delete(tid);
177
- message = overrides.size
178
- ? `board re-read · ${overrides.size} change(s) still ahead of the snapshot, shown from their receipts`
179
- : 'board re-read · the snapshot now matches every change you made';
180
- }
181
- catch (e) {
182
- message = `✗ re-read failed: ${e.message} — still showing the last read`;
183
- }
184
- break;
185
- }
186
- default: return;
187
- }
188
- render();
189
- };
190
- input.on('keypress', onKey);
191
- });
192
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * qr.ts — a QR code for a terminal, with no dependency.
3
- *
4
- * The encoder is Project Nayuki's QR Code generator (MIT), trimmed to the one mode an
5
- * address needs (byte), taken from the copy qrcode.react bundles for one.ie/web — so the
6
- * /w QR and `one wallet receive` draw from the same algorithm. Unchanged apart from the
7
- * trim and the types: version and mask selection, the Reed-Solomon code, the penalty rule.
8
- * tests/wallet-receive.test.ts pins the module matrix to that bundled copy's output.
9
- *
10
- * @license QR Code generator library (TypeScript)
11
- * Copyright (c) Project Nayuki.
12
- * SPDX-License-Identifier: MIT
13
- */
14
- /** Byte mode, error-correction MEDIUM boosted when it fits for free — Nayuki's encodeBinary. */
15
- export declare function qrMatrix(text: string): boolean[][];
16
- /**
17
- * The matrix as terminal text: two module rows per line with half blocks, a 2-module quiet
18
- * zone, dark modules drawn as the terminal's background so it scans on a dark or light theme
19
- * alike (light = '█'). Plain characters only — no colour codes, so it survives a pipe.
20
- */
21
- export declare function qrTerminal(text: string): string;