@oneie/cli 5.7.6 → 5.8.1
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 +19 -1
- package/dist/package.json +7 -8
- package/dist/src/age-yefbe8pe.js +1 -0
- package/dist/src/evm-tx-ee2q0e3w.js +1 -0
- package/dist/src/hl-run-tgrkrk69.js +1 -0
- package/dist/src/index-0rj9wdk9.js +4 -0
- package/dist/src/index-91y484c2.js +2052 -0
- package/dist/src/index-940y3rnv.js +12 -0
- package/dist/src/index.js +1047 -121
- package/dist/src/message-key-db1xjdkw.js +1 -0
- package/dist/src/message-lock-5vr8079x.js +5 -0
- package/dist/src/sweep-order-c2p6rk8c.js +1 -0
- package/dist/src/sweep-runner-t68xe7vx.js +1 -0
- package/package.json +7 -8
- package/dist/src/agent.d.ts +0 -75
- package/dist/src/agent.js +0 -1334
- package/dist/src/agentverse.d.ts +0 -26
- package/dist/src/agentverse.js +0 -171
- package/dist/src/args.d.ts +0 -9
- package/dist/src/args.js +0 -61
- package/dist/src/auth.d.ts +0 -6
- package/dist/src/auth.js +0 -121
- package/dist/src/balances.d.ts +0 -89
- package/dist/src/balances.js +0 -202
- package/dist/src/banner.d.ts +0 -1
- package/dist/src/banner.js +0 -17
- package/dist/src/broadcast.d.ts +0 -8
- package/dist/src/broadcast.js +0 -175
- package/dist/src/catalog.d.ts +0 -12
- package/dist/src/catalog.js +0 -76
- package/dist/src/chat.d.ts +0 -2
- package/dist/src/chat.js +0 -92
- package/dist/src/client.d.ts +0 -5
- package/dist/src/client.js +0 -157
- package/dist/src/compiler.d.ts +0 -36
- package/dist/src/compiler.js +0 -366
- package/dist/src/config.d.ts +0 -24
- package/dist/src/config.js +0 -70
- package/dist/src/connect.d.ts +0 -2
- package/dist/src/connect.js +0 -64
- package/dist/src/coordinate.d.ts +0 -3
- package/dist/src/coordinate.js +0 -58
- package/dist/src/create.d.ts +0 -2
- package/dist/src/create.js +0 -113
- package/dist/src/deploy.d.ts +0 -2
- package/dist/src/deploy.js +0 -19
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.js +0 -75
- package/dist/src/device-flow.d.ts +0 -57
- package/dist/src/device-flow.js +0 -173
- package/dist/src/doctor.d.ts +0 -26
- package/dist/src/doctor.js +0 -146
- package/dist/src/draw.d.ts +0 -18
- package/dist/src/draw.js +0 -156
- package/dist/src/endpoint.d.ts +0 -2
- package/dist/src/endpoint.js +0 -250
- package/dist/src/env.d.ts +0 -3
- package/dist/src/env.js +0 -37
- package/dist/src/eval.d.ts +0 -2
- package/dist/src/eval.js +0 -43
- package/dist/src/fn.d.ts +0 -2
- package/dist/src/fn.js +0 -70
- package/dist/src/group.d.ts +0 -2
- package/dist/src/group.js +0 -117
- package/dist/src/hl-run.d.ts +0 -119
- package/dist/src/hl-run.js +0 -480
- package/dist/src/hl.d.ts +0 -17
- package/dist/src/hl.js +0 -148
- package/dist/src/index.d.ts +0 -2
- package/dist/src/init.d.ts +0 -76
- package/dist/src/init.js +0 -278
- package/dist/src/join.d.ts +0 -11
- package/dist/src/join.js +0 -293
- package/dist/src/key-publish.d.ts +0 -40
- package/dist/src/key-publish.js +0 -232
- package/dist/src/key-seal.d.ts +0 -21
- package/dist/src/key-seal.js +0 -142
- package/dist/src/key-sweep.d.ts +0 -93
- package/dist/src/key-sweep.js +0 -263
- package/dist/src/key.d.ts +0 -26
- package/dist/src/key.js +0 -338
- package/dist/src/lib/age-plugin.d.ts +0 -51
- package/dist/src/lib/age-plugin.js +0 -130
- package/dist/src/lib/agent-env.d.ts +0 -12
- package/dist/src/lib/agent-env.js +0 -48
- package/dist/src/lib/api-path.d.ts +0 -2
- package/dist/src/lib/api-path.js +0 -40
- package/dist/src/lib/asker.d.ts +0 -34
- package/dist/src/lib/asker.js +0 -126
- package/dist/src/lib/client.d.ts +0 -20
- package/dist/src/lib/client.js +0 -71
- package/dist/src/lib/env-sealed.d.ts +0 -53
- package/dist/src/lib/env-sealed.js +0 -184
- package/dist/src/lib/flow-tag.d.ts +0 -86
- package/dist/src/lib/flow-tag.js +0 -230
- package/dist/src/lib/hl-core/actions.d.ts +0 -99
- package/dist/src/lib/hl-core/actions.js +0 -69
- package/dist/src/lib/hl-core/eip712.d.ts +0 -33
- package/dist/src/lib/hl-core/eip712.js +0 -107
- package/dist/src/lib/hl-core/errors.d.ts +0 -10
- package/dist/src/lib/hl-core/errors.js +0 -15
- package/dist/src/lib/hl-core/exchange.d.ts +0 -24
- package/dist/src/lib/hl-core/exchange.js +0 -47
- package/dist/src/lib/hl-core/index.d.ts +0 -13
- package/dist/src/lib/hl-core/index.js +0 -14
- package/dist/src/lib/hl-core/meta.d.ts +0 -57
- package/dist/src/lib/hl-core/meta.js +0 -110
- package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
- package/dist/src/lib/hl-core/msgpack.js +0 -136
- package/dist/src/lib/hl-core/net.d.ts +0 -2
- package/dist/src/lib/hl-core/net.js +0 -7
- package/dist/src/lib/hl-core/signing.d.ts +0 -103
- package/dist/src/lib/hl-core/signing.js +0 -295
- package/dist/src/lib/hl-core/wire.d.ts +0 -34
- package/dist/src/lib/hl-core/wire.js +0 -81
- package/dist/src/lib/invoked-as.d.ts +0 -2
- package/dist/src/lib/invoked-as.js +0 -24
- package/dist/src/lib/journey-words.d.ts +0 -84
- package/dist/src/lib/journey-words.js +0 -360
- package/dist/src/lib/journey.d.ts +0 -148
- package/dist/src/lib/journey.js +0 -245
- package/dist/src/lib/key-receipt.d.ts +0 -48
- package/dist/src/lib/key-receipt.js +0 -116
- package/dist/src/lib/key-source.d.ts +0 -9
- package/dist/src/lib/key-source.js +0 -33
- package/dist/src/lib/keyfile.d.ts +0 -136
- package/dist/src/lib/keyfile.js +0 -397
- package/dist/src/lib/launch-claude.d.ts +0 -5
- package/dist/src/lib/launch-claude.js +0 -45
- package/dist/src/lib/lock-lookup.d.ts +0 -40
- package/dist/src/lib/lock-lookup.js +0 -92
- package/dist/src/lib/message-seal.d.ts +0 -63
- package/dist/src/lib/message-seal.js +0 -150
- package/dist/src/lib/network.d.ts +0 -15
- package/dist/src/lib/network.js +0 -41
- package/dist/src/lib/paths.d.ts +0 -41
- package/dist/src/lib/paths.js +0 -91
- package/dist/src/lib/plan-draw.d.ts +0 -56
- package/dist/src/lib/plan-draw.js +0 -219
- package/dist/src/lib/plan-live.d.ts +0 -20
- package/dist/src/lib/plan-live.js +0 -192
- package/dist/src/lib/qr.d.ts +0 -21
- package/dist/src/lib/qr.js +0 -402
- package/dist/src/lib/roster.d.ts +0 -20
- package/dist/src/lib/roster.js +0 -79
- package/dist/src/lib/sale-card.d.ts +0 -117
- package/dist/src/lib/sale-card.js +0 -261
- package/dist/src/lib/shop-init.d.ts +0 -62
- package/dist/src/lib/shop-init.js +0 -63
- package/dist/src/lib/sui-grpc-send.d.ts +0 -50
- package/dist/src/lib/sui-grpc-send.js +0 -89
- package/dist/src/lib/swap-core.d.ts +0 -163
- package/dist/src/lib/swap-core.js +0 -405
- package/dist/src/lib/tasks-digest.d.ts +0 -66
- package/dist/src/lib/tasks-digest.js +0 -200
- package/dist/src/lib/tasks-graph.d.ts +0 -79
- package/dist/src/lib/tasks-graph.js +0 -463
- package/dist/src/lib/tasks-lens.d.ts +0 -31
- package/dist/src/lib/tasks-lens.js +0 -47
- package/dist/src/lib/tasks-next.d.ts +0 -25
- package/dist/src/lib/tasks-next.js +0 -103
- package/dist/src/lib/tasks-prove.d.ts +0 -15
- package/dist/src/lib/tasks-prove.js +0 -68
- package/dist/src/lib/tasks-route.d.ts +0 -29
- package/dist/src/lib/tasks-route.js +0 -151
- package/dist/src/lib/tasks-score.d.ts +0 -36
- package/dist/src/lib/tasks-score.js +0 -152
- package/dist/src/lib/tasks-workspace.d.ts +0 -18
- package/dist/src/lib/tasks-workspace.js +0 -73
- package/dist/src/lib/vault-read.d.ts +0 -24
- package/dist/src/lib/vault-read.js +0 -77
- package/dist/src/lib/vaultfile.d.ts +0 -88
- package/dist/src/lib/vaultfile.js +0 -222
- package/dist/src/lib/wallet-money.d.ts +0 -222
- package/dist/src/lib/wallet-money.js +0 -578
- package/dist/src/lib/wallet-request.d.ts +0 -50
- package/dist/src/lib/wallet-request.js +0 -86
- package/dist/src/links.d.ts +0 -5
- package/dist/src/links.js +0 -45
- package/dist/src/media.d.ts +0 -29
- package/dist/src/media.js +0 -487
- package/dist/src/message-receipt.d.ts +0 -25
- package/dist/src/message-receipt.js +0 -71
- package/dist/src/message.d.ts +0 -13
- package/dist/src/message.js +0 -92
- package/dist/src/onboard.d.ts +0 -16
- package/dist/src/onboard.js +0 -149
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -193
- package/dist/src/push.d.ts +0 -2
- package/dist/src/push.js +0 -115
- package/dist/src/render.d.ts +0 -21
- package/dist/src/render.js +0 -32
- package/dist/src/secrets-device.d.ts +0 -32
- package/dist/src/secrets-device.js +0 -127
- package/dist/src/secrets-give.d.ts +0 -125
- package/dist/src/secrets-give.js +0 -236
- package/dist/src/secrets-list.d.ts +0 -27
- package/dist/src/secrets-list.js +0 -84
- package/dist/src/secrets-run.d.ts +0 -31
- package/dist/src/secrets-run.js +0 -182
- package/dist/src/secrets.d.ts +0 -33
- package/dist/src/secrets.js +0 -200
- package/dist/src/setup.d.ts +0 -6
- package/dist/src/setup.js +0 -127
- package/dist/src/ship.d.ts +0 -2
- package/dist/src/ship.js +0 -18
- package/dist/src/shop.d.ts +0 -10
- package/dist/src/shop.js +0 -110
- package/dist/src/skill-parser.d.ts +0 -14
- package/dist/src/skill-parser.js +0 -113
- package/dist/src/skill.d.ts +0 -2
- package/dist/src/skill.js +0 -493
- package/dist/src/slug.d.ts +0 -2
- package/dist/src/slug.js +0 -6
- package/dist/src/social.d.ts +0 -2
- package/dist/src/social.js +0 -106
- package/dist/src/staff.d.ts +0 -2
- package/dist/src/staff.js +0 -104
- package/dist/src/start.d.ts +0 -15
- package/dist/src/start.js +0 -203
- package/dist/src/status.d.ts +0 -2
- package/dist/src/status.js +0 -52
- package/dist/src/substrate.d.ts +0 -2
- package/dist/src/substrate.js +0 -258
- package/dist/src/swap.d.ts +0 -93
- package/dist/src/swap.js +0 -622
- package/dist/src/tasks.d.ts +0 -2
- package/dist/src/tasks.js +0 -743
- package/dist/src/templates.d.ts +0 -1
- package/dist/src/templates.js +0 -213
- package/dist/src/trade.d.ts +0 -2
- package/dist/src/trade.js +0 -91
- package/dist/src/trail.d.ts +0 -2
- package/dist/src/trail.js +0 -41
- package/dist/src/validate.d.ts +0 -13
- package/dist/src/validate.js +0 -35
- package/dist/src/wallet-money.d.ts +0 -152
- package/dist/src/wallet-money.js +0 -564
- package/dist/src/wallet.d.ts +0 -167
- package/dist/src/wallet.js +0 -855
- package/dist/src/workflow.d.ts +0 -2
- package/dist/src/workflow.js +0 -166
- package/dist/src/write.d.ts +0 -43
- package/dist/src/write.js +0 -180
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* message-seal.ts — the shared parts of `one key lock | seal | open | identity` and
|
|
3
|
-
* `one write`: where the key comes from, where the note comes from, and what an age
|
|
4
|
-
* failure is called in plain words.
|
|
5
|
-
*
|
|
6
|
-
* THE KEY NEVER COMES FROM STDIN OR A PROMPT. `seal` and `open` read the NOTE on stdin,
|
|
7
|
-
* so the 24 words cannot also arrive there, and an agent runs these with nothing to
|
|
8
|
-
* prompt. The words come from a key file (`--key`, the file `one key new --out` writes)
|
|
9
|
-
* or from ONE_WALLET_MNEMONIC. No key is an error with a plain sentence, never a hang.
|
|
10
|
-
*
|
|
11
|
-
* THE SDK MODULES LOAD LAZILY, same reason as key-sweep.ts: key.ts registers these
|
|
12
|
-
* commands, so a static import of `@oneie/sdk/age` would crash every `one key` verb —
|
|
13
|
-
* `key new` included — on an installed SDK that predates the export.
|
|
14
|
-
*
|
|
15
|
-
* Derivation and format live in `@oneie/sdk/{age,message-key}`, which are copies of
|
|
16
|
-
* one.ie/web's lib/key/{age,message-key}.ts; the SDK test fails if either drifts.
|
|
17
|
-
*/
|
|
18
|
-
import { readFileSync } from 'node:fs';
|
|
19
|
-
/** The most a note or a file may be read as — a ceiling on a caller-controlled read. */
|
|
20
|
-
export const MAX_INPUT_BYTES = 8 * 1024 * 1024;
|
|
21
|
-
export const ageModule = () => import('@oneie/sdk/age');
|
|
22
|
-
export const messageKeyModule = () => import('@oneie/sdk/message-key');
|
|
23
|
-
const SECRETS_KEY_SPEC = '@oneie/sdk/secrets-key'; // a variable, so a bundler/vite does not resolve it at build time
|
|
24
|
-
/**
|
|
25
|
-
* Swappable in tests: the cli resolves `@oneie/sdk` through its own node_modules, which can be a
|
|
26
|
-
* published or main-tree SDK older than `./secrets-key` (C4). A test serves the source instead.
|
|
27
|
-
*/
|
|
28
|
-
export const loaders = { secretsKey: () => import(/* @vite-ignore */ SECRETS_KEY_SPEC) };
|
|
29
|
-
export const secretsKeyModule = () => loaders.secretsKey();
|
|
30
|
-
/** Swappable in tests; the defaults are the process's real stdin. */
|
|
31
|
-
export const io = {
|
|
32
|
-
stdinIsTTY: () => Boolean(process.stdin.isTTY),
|
|
33
|
-
async readStdin() {
|
|
34
|
-
const chunks = [];
|
|
35
|
-
let n = 0;
|
|
36
|
-
for await (const c of process.stdin) {
|
|
37
|
-
const b = Buffer.isBuffer(c) ? c : Buffer.from(c);
|
|
38
|
-
n += b.length;
|
|
39
|
-
if (n > MAX_INPUT_BYTES)
|
|
40
|
-
throw new Error(`that is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB — too big to seal or open here`);
|
|
41
|
-
chunks.push(b);
|
|
42
|
-
}
|
|
43
|
-
return new Uint8Array(Buffer.concat(chunks));
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
/** The 24 words from a key file. JSON with a `mnemonic` field, or a bare phrase. */
|
|
47
|
-
export function wordsFromKeyFile(path) {
|
|
48
|
-
let raw;
|
|
49
|
-
try {
|
|
50
|
-
raw = readFileSync(path, 'utf8');
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return { ok: false, error: `cannot read the key file ${path} — make one with: one key new --out ${path} --yes-i-accept-plaintext-file`, code: 'no_key' };
|
|
54
|
-
}
|
|
55
|
-
const t = raw.trim();
|
|
56
|
-
if (t.startsWith('{')) {
|
|
57
|
-
try {
|
|
58
|
-
const m = JSON.parse(t).mnemonic;
|
|
59
|
-
if (typeof m === 'string' && m.trim())
|
|
60
|
-
return m;
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
/* fall through to the plain sentence */
|
|
64
|
-
}
|
|
65
|
-
return { ok: false, error: `${path} is not a key file — it has no "mnemonic" field`, code: 'no_key' };
|
|
66
|
-
}
|
|
67
|
-
return t;
|
|
68
|
-
}
|
|
69
|
-
/** The key's words: --key file, else ONE_WALLET_MNEMONIC. Never stdin, never a prompt. */
|
|
70
|
-
export function keyWords(keyPath) {
|
|
71
|
-
if (keyPath)
|
|
72
|
-
return wordsFromKeyFile(keyPath);
|
|
73
|
-
const env = process.env.ONE_WALLET_MNEMONIC?.trim();
|
|
74
|
-
if (env)
|
|
75
|
-
return env;
|
|
76
|
-
return { ok: false, error: 'no key — pass --key key.json (made by: one key new --out key.json) or set ONE_WALLET_MNEMONIC', code: 'no_key' };
|
|
77
|
-
}
|
|
78
|
-
/** The message key for the given key source, or a plain failure. The caller zeroes `.secret`. */
|
|
79
|
-
export async function loadMessageKey(keyPath) {
|
|
80
|
-
const words = keyWords(keyPath);
|
|
81
|
-
if (typeof words !== 'string')
|
|
82
|
-
return words;
|
|
83
|
-
const { messageKeyFromPhrase } = await messageKeyModule();
|
|
84
|
-
try {
|
|
85
|
-
return messageKeyFromPhrase(words);
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
// The SDK's message never repeats the phrase; this one stays in this sentence too.
|
|
89
|
-
return { ok: false, error: e.message, code: 'bad_key' };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/** The paper (secrets) key for the given key source, or a plain failure. The caller zeroes `.secret`. */
|
|
93
|
-
export async function loadSecretsKey(keyPath) {
|
|
94
|
-
const words = keyWords(keyPath);
|
|
95
|
-
if (typeof words !== 'string')
|
|
96
|
-
return words;
|
|
97
|
-
let mod;
|
|
98
|
-
try {
|
|
99
|
-
mod = await secretsKeyModule();
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
return { ok: false, error: 'this @oneie/sdk is too old for the paper key — update it: npm i -g oneie@latest', code: 'sdk_too_old' };
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
return mod.secretsKeyFromPhrase(words);
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
return { ok: false, error: e.message, code: 'bad_key' };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** A note from a file path, or stdin for `-` / no argument. Refuses a terminal rather than hang. */
|
|
112
|
-
export async function readNote(arg) {
|
|
113
|
-
if (arg && arg !== '-') {
|
|
114
|
-
try {
|
|
115
|
-
const b = readFileSync(arg);
|
|
116
|
-
if (b.length > MAX_INPUT_BYTES)
|
|
117
|
-
return { ok: false, error: `${arg} is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB — too big to seal or open here`, code: 'too_big' };
|
|
118
|
-
return new Uint8Array(b);
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
return { ok: false, error: `cannot read ${arg}`, code: 'no_input' };
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (io.stdinIsTTY())
|
|
125
|
-
return { ok: false, error: 'nothing to read — pass a file, or pipe the note in (echo "hi" | one key seal --to age1…)', code: 'no_input' };
|
|
126
|
-
try {
|
|
127
|
-
return await io.readStdin();
|
|
128
|
-
}
|
|
129
|
-
catch (e) {
|
|
130
|
-
return { ok: false, error: e.message, code: 'too_big' };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/** Plain-word sentences for every way an age note can refuse to open. */
|
|
134
|
-
export function ageFailure(e) {
|
|
135
|
-
const code = e?.code;
|
|
136
|
-
switch (code) {
|
|
137
|
-
case 'no_identity':
|
|
138
|
-
return { ok: false, error: 'this note is not for your key — it was sealed to a different lock', code };
|
|
139
|
-
case 'tampered':
|
|
140
|
-
return { ok: false, error: 'this note was changed after it was sealed, or it is damaged — it cannot be trusted', code };
|
|
141
|
-
case 'unsupported':
|
|
142
|
-
return { ok: false, error: 'this note is locked with a passphrase or an ssh key, which ONE does not open — use the age tool', code };
|
|
143
|
-
case 'malformed':
|
|
144
|
-
return { ok: false, error: 'this is not an age note, or it is cut short', code };
|
|
145
|
-
case 'bad_key':
|
|
146
|
-
return { ok: false, error: e.message, code };
|
|
147
|
-
default:
|
|
148
|
-
return { ok: false, error: 'could not open this note', code: 'failed' };
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which Sui network is the API this CLI is talking to on? One's answer is the deploy's own: Layout.astro
|
|
3
|
-
* writes `<meta name="one:network" content="testnet|mainnet">` into every page from the worker's `NETWORK`
|
|
4
|
-
* (one.ie/web/src/lib/sui-network.ts `DEPLOY_NET_META_NAME`), so the CLI asks the home page — the one door
|
|
5
|
-
* that carries it today. There is no status route for it.
|
|
6
|
-
*
|
|
7
|
-
* It only ever shapes the WORDS of a first run (the faucet line, "test money"), never a command's
|
|
8
|
-
* behaviour, and it must never block or fail a run: a slow, failing or unreadable answer is `testnet`
|
|
9
|
-
* (the display rule: show the network where a mistake costs nothing). The home page is large, so the
|
|
10
|
-
* body is read only until the meta tag or `</head>` appears, then dropped.
|
|
11
|
-
*/
|
|
12
|
-
export type Net = 'testnet' | 'mainnet';
|
|
13
|
-
/** Parse the meta tag out of the start of a page. Null when it is not there (yet). */
|
|
14
|
-
export declare function netFromHtml(html: string): Net | null;
|
|
15
|
-
export declare function learnNetwork(api: string, f?: typeof fetch, timeoutMs?: number): Promise<Net>;
|
package/dist/src/lib/network.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** Parse the meta tag out of the start of a page. Null when it is not there (yet). */
|
|
2
|
-
export function netFromHtml(html) {
|
|
3
|
-
const tag = /<meta\b[^>]*\bname=["']one:network["'][^>]*>/i.exec(html)?.[0];
|
|
4
|
-
const content = tag ? /\bcontent=["']([^"']*)["']/i.exec(tag)?.[1] : undefined;
|
|
5
|
-
if (content === 'mainnet' || content === 'testnet')
|
|
6
|
-
return content;
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
export async function learnNetwork(api, f = fetch, timeoutMs = 3000) {
|
|
10
|
-
const ctl = new AbortController();
|
|
11
|
-
const timer = setTimeout(() => ctl.abort(), timeoutMs);
|
|
12
|
-
try {
|
|
13
|
-
const res = await f(`${api.replace(/\/$/, '')}/`, { signal: ctl.signal, headers: { accept: 'text/html' } });
|
|
14
|
-
if (!res.ok || !res.body)
|
|
15
|
-
return 'testnet';
|
|
16
|
-
const reader = res.body.getReader();
|
|
17
|
-
const dec = new TextDecoder();
|
|
18
|
-
let seen = '';
|
|
19
|
-
while (seen.length < 131_072) {
|
|
20
|
-
const { done, value } = await reader.read();
|
|
21
|
-
if (done)
|
|
22
|
-
break;
|
|
23
|
-
seen += dec.decode(value, { stream: true });
|
|
24
|
-
const net = netFromHtml(seen);
|
|
25
|
-
if (net) {
|
|
26
|
-
void reader.cancel().catch(() => { });
|
|
27
|
-
return net;
|
|
28
|
-
}
|
|
29
|
-
if (seen.includes('</head>'))
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
void reader.cancel().catch(() => { });
|
|
33
|
-
return 'testnet';
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return 'testnet';
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
clearTimeout(timer);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/dist/src/lib/paths.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** `~/.config/one` — the current home for CLI state. */
|
|
2
|
-
export declare const CONFIG_DIR: string;
|
|
3
|
-
/**
|
|
4
|
-
* `~/.config/oneie` — where everything lived until the rename. READ-ONLY: kept
|
|
5
|
-
* so an existing install keeps working, never written to.
|
|
6
|
-
*/
|
|
7
|
-
export declare const LEGACY_CONFIG_DIR: string;
|
|
8
|
-
/** The machine-wide API key. Written here; also read from the legacy path. */
|
|
9
|
-
export declare const KEY_FILE: string;
|
|
10
|
-
export declare const LEGACY_KEY_FILE: string;
|
|
11
|
-
/**
|
|
12
|
-
* The per-machine binding id used by the folder-key guard (`keyfile.ts`).
|
|
13
|
-
*
|
|
14
|
-
* Kept on the SAME fallback ladder as the key, and for a sharper reason: this
|
|
15
|
-
* value is baked into every `.oneie/agent.json` already on disk. Reading only
|
|
16
|
-
* the new path would mint a fresh id, every existing folder key would compare
|
|
17
|
-
* `machine` mismatched, and they would all go `foreign` at once — a silent
|
|
18
|
-
* mass logout caused by a rename.
|
|
19
|
-
*/
|
|
20
|
-
export declare const MACHINE_ID_FILE: string;
|
|
21
|
-
export declare const LEGACY_MACHINE_ID_FILE: string;
|
|
22
|
-
/**
|
|
23
|
-
* First existing path from `candidates`, or null.
|
|
24
|
-
*
|
|
25
|
-
* Existence, not readability — a caller that needs the contents handles its own
|
|
26
|
-
* errors, and a path that exists but cannot be read is a different problem from
|
|
27
|
-
* one that was never there.
|
|
28
|
-
*/
|
|
29
|
-
export declare function firstExisting(...candidates: string[]): string | null;
|
|
30
|
-
/** The machine-wide key, new path first, legacy second. Empty string when absent. */
|
|
31
|
-
export declare function readMachineKey(): string;
|
|
32
|
-
/** Which path the machine-wide key actually came from — for `doctor`, never for auth. */
|
|
33
|
-
export declare function machineKeyPath(): string | null;
|
|
34
|
-
/**
|
|
35
|
-
* Write the machine-wide key: atomically (temp + rename, so a concurrent reader
|
|
36
|
-
* never sees half a key), 0600, always at the NEW path. The one writer — `onboard`
|
|
37
|
-
* and `init` each carried their own copy pointed at the legacy `~/.config/oneie`,
|
|
38
|
-
* so a key minted by `onboard` sat where only the CLI's read fallback could find it
|
|
39
|
-
* and the MCP server, which reads the same ladder, was one rename away from missing it.
|
|
40
|
-
*/
|
|
41
|
-
export declare function writeMachineKey(value: string): void;
|
package/dist/src/lib/paths.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* paths.ts — the ONE place that knows where ONE keeps things on disk.
|
|
3
|
-
*
|
|
4
|
-
* WHY THIS FILE EXISTS. Six modules each carried their own
|
|
5
|
-
* `resolve(homedir(), '.config', 'oneie', 'key')` — `client.ts`, `doctor.ts`,
|
|
6
|
-
* `auth.ts`, `keyfile.ts` and `skill.ts` in three places. Six literals is six
|
|
7
|
-
* chances to change five of them: `login` writes one path, `skill push` reads
|
|
8
|
-
* another, and the user sees "I'm logged in but nothing works", which is the
|
|
9
|
-
* hardest class of bug to recognise because every individual command is correct.
|
|
10
|
-
*
|
|
11
|
-
* THE MIGRATION IS A READ FALLBACK, NOT A MOVE. The directory is now
|
|
12
|
-
* `~/.config/one/`. Anyone who authenticated before this change has a key at
|
|
13
|
-
* `~/.config/oneie/key`, and an upgrade that silently logs them out would look
|
|
14
|
-
* like a broken release. So: writes always go to the new path, reads try the new
|
|
15
|
-
* path and then the old one. Nothing is copied or deleted behind the user's
|
|
16
|
-
* back — `one auth login` rewrites at the new path on its own, and the old file
|
|
17
|
-
* is theirs to remove.
|
|
18
|
-
*/
|
|
19
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
20
|
-
import { homedir } from 'node:os';
|
|
21
|
-
import { join, resolve } from 'node:path';
|
|
22
|
-
/** `~/.config/one` — the current home for CLI state. */
|
|
23
|
-
export const CONFIG_DIR = resolve(homedir(), '.config', 'one');
|
|
24
|
-
/**
|
|
25
|
-
* `~/.config/oneie` — where everything lived until the rename. READ-ONLY: kept
|
|
26
|
-
* so an existing install keeps working, never written to.
|
|
27
|
-
*/
|
|
28
|
-
export const LEGACY_CONFIG_DIR = resolve(homedir(), '.config', 'oneie');
|
|
29
|
-
/** The machine-wide API key. Written here; also read from the legacy path. */
|
|
30
|
-
export const KEY_FILE = resolve(CONFIG_DIR, 'key');
|
|
31
|
-
export const LEGACY_KEY_FILE = resolve(LEGACY_CONFIG_DIR, 'key');
|
|
32
|
-
/**
|
|
33
|
-
* The per-machine binding id used by the folder-key guard (`keyfile.ts`).
|
|
34
|
-
*
|
|
35
|
-
* Kept on the SAME fallback ladder as the key, and for a sharper reason: this
|
|
36
|
-
* value is baked into every `.oneie/agent.json` already on disk. Reading only
|
|
37
|
-
* the new path would mint a fresh id, every existing folder key would compare
|
|
38
|
-
* `machine` mismatched, and they would all go `foreign` at once — a silent
|
|
39
|
-
* mass logout caused by a rename.
|
|
40
|
-
*/
|
|
41
|
-
export const MACHINE_ID_FILE = resolve(CONFIG_DIR, 'machine-id');
|
|
42
|
-
export const LEGACY_MACHINE_ID_FILE = resolve(LEGACY_CONFIG_DIR, 'machine-id');
|
|
43
|
-
/**
|
|
44
|
-
* First existing path from `candidates`, or null.
|
|
45
|
-
*
|
|
46
|
-
* Existence, not readability — a caller that needs the contents handles its own
|
|
47
|
-
* errors, and a path that exists but cannot be read is a different problem from
|
|
48
|
-
* one that was never there.
|
|
49
|
-
*/
|
|
50
|
-
export function firstExisting(...candidates) {
|
|
51
|
-
for (const p of candidates) {
|
|
52
|
-
try {
|
|
53
|
-
if (existsSync(p))
|
|
54
|
-
return p;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
/* unreadable home, permission denied — treat as absent */
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
/** The machine-wide key, new path first, legacy second. Empty string when absent. */
|
|
63
|
-
export function readMachineKey() {
|
|
64
|
-
const file = firstExisting(KEY_FILE, LEGACY_KEY_FILE);
|
|
65
|
-
if (!file)
|
|
66
|
-
return '';
|
|
67
|
-
try {
|
|
68
|
-
return readFileSync(file, 'utf8').trim();
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return '';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/** Which path the machine-wide key actually came from — for `doctor`, never for auth. */
|
|
75
|
-
export function machineKeyPath() {
|
|
76
|
-
return firstExisting(KEY_FILE, LEGACY_KEY_FILE);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Write the machine-wide key: atomically (temp + rename, so a concurrent reader
|
|
80
|
-
* never sees half a key), 0600, always at the NEW path. The one writer — `onboard`
|
|
81
|
-
* and `init` each carried their own copy pointed at the legacy `~/.config/oneie`,
|
|
82
|
-
* so a key minted by `onboard` sat where only the CLI's read fallback could find it
|
|
83
|
-
* and the MCP server, which reads the same ladder, was one rename away from missing it.
|
|
84
|
-
*/
|
|
85
|
-
export function writeMachineKey(value) {
|
|
86
|
-
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
87
|
-
const tmp = join(CONFIG_DIR, '.key.tmp');
|
|
88
|
-
writeFileSync(tmp, value, { mode: 0o600 });
|
|
89
|
-
chmodSync(tmp, 0o600);
|
|
90
|
-
renameSync(tmp, KEY_FILE);
|
|
91
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type PlanResult, type Row } from './tasks-graph.js';
|
|
2
|
-
export declare const BOX_W = 26;
|
|
3
|
-
export type Style = 'selected' | 'critical' | 'ready' | 'changed' | 'dim';
|
|
4
|
-
export interface Drawn {
|
|
5
|
-
lines: string[];
|
|
6
|
-
/** style per cell, keyed "x,y" — only for cells that carry one */
|
|
7
|
-
styles: Map<string, Style>;
|
|
8
|
-
boxes: Map<string, {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
col: number;
|
|
12
|
-
idx: number;
|
|
13
|
-
}>;
|
|
14
|
-
/** columns[c] = tids in draw order, for arrow-key navigation */
|
|
15
|
-
columns: string[][];
|
|
16
|
-
}
|
|
17
|
-
/** Status after local receipts: a write we just made is the truth about that
|
|
18
|
-
* row, even while the board snapshot (a ≤60s memo) still shows the old state. */
|
|
19
|
-
export declare function withOverrides(rows: Row[], overrides: ReadonlyMap<string, string>): Row[];
|
|
20
|
-
/** Open blockers of a row.
|
|
21
|
-
* - in view: by name, from its CURRENT status (a local receipt counts);
|
|
22
|
-
* - outside the view but in `world` (the board read, as the snapshot saw it): by status;
|
|
23
|
-
* - not returned by the read at all (the read carries ACTIVE rows, so a DONE
|
|
24
|
-
* blocker is simply absent): the snapshot's own `openBlockers` count decides —
|
|
25
|
-
* whatever it counted open beyond the blockers we can see is still open. */
|
|
26
|
-
export declare function openBlockers(r: Row, byTid: ReadonlyMap<string, Row>, world?: ReadonlyMap<string, Row>): {
|
|
27
|
-
names: string[];
|
|
28
|
-
outside: number;
|
|
29
|
-
};
|
|
30
|
-
export declare function isReady(r: Row, byTid: ReadonlyMap<string, Row>, world?: ReadonlyMap<string, Row>): boolean;
|
|
31
|
-
/** A short handle: a `cli-*`-style slug tag when the row carries one, else its name. */
|
|
32
|
-
export declare function shortName(r: Row): string;
|
|
33
|
-
export interface DrawOpts {
|
|
34
|
-
title?: string;
|
|
35
|
-
selected?: string;
|
|
36
|
-
changed?: ReadonlySet<string>;
|
|
37
|
-
/** every row the board read returned — resolves blockers outside the view */
|
|
38
|
-
world?: ReadonlyMap<string, Row>;
|
|
39
|
-
}
|
|
40
|
-
export declare function drawPlan(rows: Row[], opts?: DrawOpts): Drawn & {
|
|
41
|
-
plan: PlanResult;
|
|
42
|
-
};
|
|
43
|
-
/** The one-paragraph header both the print and the live view carry. */
|
|
44
|
-
export declare function planHeader(rows: Row[], plan: PlanResult, opts: {
|
|
45
|
-
title?: string;
|
|
46
|
-
asOf?: string;
|
|
47
|
-
world?: ReadonlyMap<string, Row>;
|
|
48
|
-
}): string[];
|
|
49
|
-
/** What changed between two views of the same plan — the answer to "what happened?" */
|
|
50
|
-
export declare function planDelta(before: Row[], after: Row[], world?: ReadonlyMap<string, Row>): {
|
|
51
|
-
nowReady: string[];
|
|
52
|
-
critBefore: string[];
|
|
53
|
-
critAfter: string[];
|
|
54
|
-
};
|
|
55
|
-
/** lazydraw's file shape, so `one draw <name>` can open and edit the picture. */
|
|
56
|
-
export declare function toLazydraw(lines: string[], name: string): string;
|
|
@@ -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>;
|