aegiscode 6.8.30 → 6.8.33

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/src/ping.js ADDED
@@ -0,0 +1,223 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * /ping — the terminal's "reply ready" alert.
5
+ *
6
+ * WHAT IT IS, AND WHY HERE. aegis-desktop already tells the user a turn landed
7
+ * when they are looking somewhere else: `notifyReplyIfUnfocused()` in
8
+ * desktop/main.js raises a native Notification from the one place every chat
9
+ * call resolves, and only when the window is minimized, hidden or unfocused — a
10
+ * foregrounded chat needs no OS-level nudge. The terminal has no `isFocused()`,
11
+ * so the two things that function reads have to be re-derived:
12
+ *
13
+ * * "the window is not in front" — approximate it with TIME. A turn that took
14
+ * less than `pingMinSeconds` ran while the user was still watching the
15
+ * spinner; one that took longer is a turn they plausibly walked away from.
16
+ * That is the only honest proxy a TUI has, and it is why the threshold
17
+ * exists at all rather than pinging on every reply.
18
+ * * "the window can show a notification" — check `process.stdout.isTTY`
19
+ * instead of `Notification.isSupported()`. A `-p` headless run, a piped
20
+ * transcript or an autonomous queue worker has no user to notify, and
21
+ * writing escape sequences into a file is not a notice.
22
+ *
23
+ * WHAT IT SENDS. Terminal notification escapes, the only channel a CLI has:
24
+ * OSC 9 (iTerm2, WezTerm, Windows Terminal, conhost) and OSC 777
25
+ * (`notify;title;body` — VTE/GNOME Terminal, kitty, urxvt), each BEL-terminated,
26
+ * plus optionally the plain BEL bell for terminals that implement neither
27
+ * (macOS Terminal.app) — what the user hears is then whatever their terminal's
28
+ * bell setting says. Modes are one word on purpose: `off`, `bell`, `notify`,
29
+ * `both`.
30
+ *
31
+ * Ported verbatim in behaviour from the upstream engine's `src/ping.js`, ESM →
32
+ * CommonJS, dependency-free: no TTY, no config file, no app.js import, so the
33
+ * decision and the byte sequence are both unit-testable. It keeps all four of
34
+ * the properties that module is built around:
35
+ *
36
+ * 1. It cannot break the host. `writePing()` returns a boolean and never
37
+ * throws, whatever the stream does (a closed stdout, an EPIPE, a stub with
38
+ * no `write`). A notice that can take down a session is worse than none.
39
+ * 2. It cannot corrupt the terminal. Both payloads are free text written
40
+ * INSIDE an escape sequence: a BEL in the text would end the OSC early, an
41
+ * ESC would start a new escape, a newline would break a WM's rendering.
42
+ * `sanitizePingText()` strips every control byte before anything is
43
+ * written — the same reasoning as `flattenTitle` at the OSC 0 edge in
44
+ * this host's `title.js`.
45
+ * 3. It cannot lie about what happened. The notice row is only pushed when a
46
+ * sequence was actually written; `off` writes nothing and says nothing
47
+ * rather than reporting a ping it did not send.
48
+ * 4. It cannot nag. An aborted turn never pings — the user pressed Escape, so
49
+ * they are demonstrably looking at the screen.
50
+ */
51
+
52
+ /** The one-word modes, in the order `/ping` lists them. */
53
+ const PING_MODES = Object.freeze(['off', 'bell', 'notify', 'both']);
54
+
55
+ /** Default mode. On, like the desktop's own notification — it is the whole
56
+ * point of the feature, and the threshold below is what keeps it quiet. */
57
+ const DEFAULT_PING_MODE = 'both';
58
+
59
+ /** The desktop's rule is "unfocused", not "slow". 30s is where a terminal turn
60
+ * stops reading as one the user is still watching, and it is the floor under
61
+ * the noise: a two-second reply never pings. */
62
+ const DEFAULT_PING_SECONDS = 30;
63
+
64
+ /** One hour. Past this the duration is a story, not a threshold. */
65
+ const MAX_PING_SECONDS = 3600;
66
+
67
+ /** The title every notification carries, matching desktop/main.js's own. */
68
+ const PING_TITLE = 'AEGIS Code';
69
+
70
+ /** Longest payload the sanitizer will pass through. A title is a short line; a
71
+ * notification daemon truncates anyway, so a cap here only bounds what this
72
+ * module can be made to write. */
73
+ const PING_TEXT_MAX = 120;
74
+
75
+ const BEL = '\u0007';
76
+ const ESC = '\u001b';
77
+ const BODY = 'Reply ready';
78
+
79
+ /**
80
+ * One of PING_MODES, or the default. An unknown string is NOT an error here —
81
+ * the config file is user-editable and a typo must not disable the feature
82
+ * silently, so it reads as "unset" and takes the default. `/ping` refuses the
83
+ * same strings out loud, which is where a typo is actually seen.
84
+ */
85
+ function normalizePingMode(value) {
86
+ const v = String(value == null ? '' : value).trim().toLowerCase();
87
+ return PING_MODES.includes(v) ? v : DEFAULT_PING_MODE;
88
+ }
89
+
90
+ /**
91
+ * Seconds, clamped to [0, MAX_PING_SECONDS]. 0 is legal and means "ping every
92
+ * turn, however short". Anything unparseable falls back to the default rather
93
+ * than to 0, so a corrupt config cannot turn the notice into a per-turn nag.
94
+ */
95
+ function normalizePingSeconds(value) {
96
+ // `Number('')` is 0 and `Number(' ')` is 0, so an ABSENT value would read as
97
+ // "ping every turn" — the loudest setting from the weakest input. Unset is
98
+ // separated from zero before anything is parsed.
99
+ const raw = typeof value === 'number' ? value : String(value == null ? '' : value).trim();
100
+ if (raw === '') return DEFAULT_PING_SECONDS;
101
+ const n = typeof raw === 'number' ? raw : Number(raw);
102
+ if (!Number.isFinite(n) || n < 0) return DEFAULT_PING_SECONDS;
103
+ return Math.min(MAX_PING_SECONDS, Math.floor(n));
104
+ }
105
+
106
+ /** Strip every byte that could end or re-open the escape sequence, collapse to
107
+ * one printable line, cap the length. */
108
+ function sanitizePingText(text, max = PING_TEXT_MAX) {
109
+ const flat = String(text == null ? '' : text)
110
+ .replace(/[\u0000-\u001f\u007f]/g, ' ')
111
+ .replace(/\s+/g, ' ')
112
+ .trim();
113
+ const limit = Number.isFinite(max) && max > 0 ? Math.floor(max) : PING_TEXT_MAX;
114
+ return flat.length > limit ? `${flat.slice(0, Math.max(0, limit - 1))}…` : flat;
115
+ }
116
+
117
+ /**
118
+ * The decision, in one place so it can be tested without a TTY:
119
+ *
120
+ * off → never. "Off is off" is the rule /yolo and /confirm follow.
121
+ * aborted → never. Escape means the user was looking at the screen.
122
+ * !isTTY → never. Headless/piped: there is no one to ping.
123
+ * short turn → never, until the threshold.
124
+ */
125
+ function shouldPing({ mode, elapsedMs, minSeconds, isTTY, aborted } = {}) {
126
+ if (normalizePingMode(mode) === 'off') return false;
127
+ if (aborted) return false;
128
+ if (!isTTY) return false;
129
+ // `Number(null)` is 0 and 0 is a legal duration, so an ABSENT elapsed time
130
+ // would read as "this turn just finished" and ping on a caller's bug. Only a
131
+ // real number (or a non-empty numeric string) counts.
132
+ const raw = typeof elapsedMs === 'number' ? elapsedMs : String(elapsedMs == null ? '' : elapsedMs).trim();
133
+ if (raw === '') return false;
134
+ const elapsed = Number(raw);
135
+ if (!Number.isFinite(elapsed) || elapsed < 0) return false;
136
+ return elapsed >= normalizePingSeconds(minSeconds) * 1000;
137
+ }
138
+
139
+ /**
140
+ * The bytes to write. Empty string when the mode is off, so a caller cannot
141
+ * accidentally send something "off" did not mean. Both payloads are sanitized
142
+ * into locals first, so no branch can write an unsanitized string.
143
+ */
144
+ function buildPing({ mode = DEFAULT_PING_MODE, title = PING_TITLE, body = BODY } = {}) {
145
+ const m = normalizePingMode(mode);
146
+ if (m === 'off') return '';
147
+ const t = sanitizePingText(title);
148
+ const b = sanitizePingText(body);
149
+ const parts = [];
150
+ if (m === 'notify' || m === 'both') {
151
+ // OSC 9: "notification with this body" — no title field, so it carries the
152
+ // body only. OSC 777: the form that DOES take a title, and the one VTE and
153
+ // kitty implement. Both are BEL-terminated; both are ignored harmlessly by
154
+ // a terminal that knows neither.
155
+ parts.push(`${ESC}]9;${b}${BEL}`);
156
+ parts.push(`${ESC}]777;notify;${t};${b}${BEL}`);
157
+ }
158
+ if (m === 'bell' || m === 'both') parts.push(BEL);
159
+ return parts.join('');
160
+ }
161
+
162
+ /**
163
+ * Write it, or do not — never throws. Returns whether anything was written, and
164
+ * the caller pushes its notice row only on `true` (property 3 above).
165
+ */
166
+ function writePing(stream, text) {
167
+ if (!text) return false;
168
+ if (!stream || typeof stream.write !== 'function') return false;
169
+ try {
170
+ stream.write(text);
171
+ return true;
172
+ } catch {
173
+ return false;
174
+ }
175
+ }
176
+
177
+ /** "45s" / "3m12s" / "1h02m" — the compact shape the turn's own timing row
178
+ * uses. Seconds in, one short string out. */
179
+ function formatPingDuration(seconds) {
180
+ const s = Math.max(0, Math.floor(Number(seconds) || 0));
181
+ if (s < 60) return `${s}s`;
182
+ const m = Math.floor(s / 60);
183
+ if (m < 60) return `${m}m${String(s % 60).padStart(2, '0')}s`;
184
+ return `${Math.floor(m / 60)}h${String(m % 60).padStart(2, '0')}m`;
185
+ }
186
+
187
+ /** The transcript row: the duration, which channel fired, and the one switch a
188
+ * user needs at that moment. */
189
+ function pingNoticeText({ seconds, mode } = {}) {
190
+ const m = normalizePingMode(mode);
191
+ const how = m === 'bell' ? 'bell rung' : m === 'notify' ? 'notification sent' : 'bell rung, notification sent';
192
+ return `[ping] reply ready after ${formatPingDuration(seconds)} — ${how}; /ping off silences this`;
193
+ }
194
+
195
+ /**
196
+ * The whole act, in one call the session loop can make: decide, write, and
197
+ * describe. Returns the notice text to push, or null when nothing was sent
198
+ * (off, aborted, not a TTY, under the threshold, or a stream that refused).
199
+ */
200
+ function pingTurn({ stream, mode, minSeconds, elapsedMs, isTTY, aborted } = {}) {
201
+ if (!shouldPing({ mode, minSeconds, elapsedMs, isTTY, aborted })) return null;
202
+ const text = buildPing({ mode });
203
+ if (!writePing(stream, text)) return null;
204
+ return pingNoticeText({ seconds: Number(elapsedMs) / 1000, mode });
205
+ }
206
+
207
+ module.exports = {
208
+ PING_MODES,
209
+ DEFAULT_PING_MODE,
210
+ DEFAULT_PING_SECONDS,
211
+ MAX_PING_SECONDS,
212
+ PING_TITLE,
213
+ PING_TEXT_MAX,
214
+ normalizePingMode,
215
+ normalizePingSeconds,
216
+ sanitizePingText,
217
+ shouldPing,
218
+ buildPing,
219
+ writePing,
220
+ formatPingDuration,
221
+ pingNoticeText,
222
+ pingTurn,
223
+ };
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * /config — read and write every setting from the prompt, over the split store.
5
+ *
6
+ * The upstream engine's version of this (`src/session.js`, `parseConfigValue` /
7
+ * `configRows` / `setConfigValue`) sits on a single config file, so it can list
8
+ * `Object.keys(cfg)` and write whatever it is given. This host cannot: since
9
+ * AEGISONE D5, `cli/src/config.js` keeps host-local keys in `config.json` and
10
+ * *preferences* in the shared `preferences.json` the desktop's settings window
11
+ * writes too (`SHARED_PREF_KEYS`, mirrored in `client/prefs.js`). A `/config`
12
+ * that showed one flat list and wrote it back blind would reintroduce exactly
13
+ * the drift ON8/D8 rule 1 just closed — two stores holding two answers to one
14
+ * question. So the two things this module adds over the port:
15
+ *
16
+ * 1. Every row says which store holds the key, and the write goes through
17
+ * `updateConfig()`, which routes each key to the store that owns it. There
18
+ * is no path here that writes a file directly.
19
+ * 2. Values are SUMMARIZED for the list. `models` is a several-hundred-line
20
+ * model table and `updateCheck` is an object; dumping them is how `/config`
21
+ * becomes unreadable. `/config <key>` still shows one in full, on demand.
22
+ *
23
+ * Typed parsing is the upstream's, unchanged and deliberately narrow: `true` /
24
+ * `false` / `null`, integers, floats, JSON arrays and objects, everything else a
25
+ * string. An unknown key is refused rather than created — a typo that silently
26
+ * grows the config file is a config file nobody can reason about later.
27
+ */
28
+
29
+ const { loadConfig, updateConfig, DEFAULT_CONFIG } = require('./config.js');
30
+ // The one list of keys that live in the shared store. Imported rather than
31
+ // re-listed: a second copy here is how the two hosts drift back apart.
32
+ const { prefs } = require('./shared.js');
33
+
34
+ const SHARED_KEYS = new Set(prefs.SHARED_PREF_KEYS);
35
+
36
+ /** Where a key lives: the store both hosts read, or this host's own file. */
37
+ function configStore(key) {
38
+ return SHARED_KEYS.has(key) ? 'shared' : 'host';
39
+ }
40
+
41
+ /** Coerce a prompt-ish string into the JSON type the config key wants. */
42
+ function parseConfigValue(raw) {
43
+ const s = String(raw == null ? '' : raw).trim();
44
+ if (s === '') return '';
45
+ if (s === 'true') return true;
46
+ if (s === 'false') return false;
47
+ if (s === 'null') return null;
48
+ if (/^-?\d+$/.test(s)) return Number.parseInt(s, 10);
49
+ if (/^-?\d*\.\d+$/.test(s)) return Number.parseFloat(s);
50
+ if (s.startsWith('[') || s.startsWith('{')) {
51
+ try { return JSON.parse(s); } catch { return s; }
52
+ }
53
+ return s;
54
+ }
55
+
56
+ /**
57
+ * One line for the list. Smaller values print as the value the user would have
58
+ * typed (so `/config <key> <value>` round-trips); anything structured is
59
+ * counted. `''` is shown as `""` because an empty row and a missing row must
60
+ * not look alike.
61
+ */
62
+ function summarizeValue(value, max = 48) {
63
+ if (value === null) return 'null';
64
+ if (value === undefined) return '(unset)';
65
+ if (Array.isArray(value)) return `[${value.length} item${value.length === 1 ? '' : 's'}]`;
66
+ if (typeof value === 'object') {
67
+ const n = Object.keys(value).length;
68
+ return `{${n} key${n === 1 ? '' : 's'}}`;
69
+ }
70
+ if (typeof value === 'string') {
71
+ if (value === '') return '""';
72
+ return value.length > max ? `${value.slice(0, max - 1)}…` : value;
73
+ }
74
+ return String(value);
75
+ }
76
+
77
+ /** Render a value for `/config <key>` — pretty JSON when it is structured. */
78
+ function fullValue(value) {
79
+ if (value && typeof value === 'object') return JSON.stringify(value, null, 2);
80
+ if (value === '') return '""';
81
+ return String(value);
82
+ }
83
+
84
+ /**
85
+ * Every key, with its current (defaulted) value and the store that owns it.
86
+ * `defaulted` marks a key still at its shipped value, so "I never changed this"
87
+ * is visible rather than inferred.
88
+ */
89
+ function configRows(cfg = loadConfig()) {
90
+ return Object.keys(cfg).sort().map((key) => ({
91
+ key,
92
+ value: cfg[key],
93
+ store: configStore(key),
94
+ defaulted: Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG, key)
95
+ && JSON.stringify(cfg[key]) === JSON.stringify(DEFAULT_CONFIG[key]),
96
+ }));
97
+ }
98
+
99
+ /** Panel lines: `key = value [store]`. */
100
+ function formatConfigRows(rows = configRows()) {
101
+ if (!rows.length) return [' No config keys.'];
102
+ const width = Math.max(...rows.map((r) => r.key.length));
103
+ return rows.map((r) => ` ${r.key.padEnd(width)} ${summarizeValue(r.value).padEnd(26)} ${r.store}${r.defaulted ? ' (default)' : ''}`);
104
+ }
105
+
106
+ /**
107
+ * Set one key. Returns `{ key, value, store }` on success or `{ error }`.
108
+ * The known-key check reads the *merged* config, which is the set of keys a
109
+ * later `loadConfig()` will actually return — so a write can never land on a
110
+ * key the read side would not report.
111
+ */
112
+ function setConfigValue(key, rawValue) {
113
+ const k = String(key || '').trim();
114
+ if (!k) return { error: 'usage: /config <key> <value>' };
115
+ const cfg = loadConfig();
116
+ if (!Object.prototype.hasOwnProperty.call(cfg, k)) {
117
+ return { error: `unknown config key "${k}" — run /config to list the keys` };
118
+ }
119
+ const value = parseConfigValue(rawValue);
120
+ updateConfig({ [k]: value });
121
+ return { key: k, value, store: configStore(k) };
122
+ }
123
+
124
+ /**
125
+ * Put one key back to its shipped value. Returns `{ error }` for an unknown key
126
+ * or for a key this host has no default for (a host-local extra is deleted
127
+ * rather than set to `undefined`, which is not a JSON value).
128
+ */
129
+ function resetConfigValue(key) {
130
+ const k = String(key || '').trim();
131
+ if (!k) return { error: 'usage: /config reset <key>' };
132
+ if (!Object.prototype.hasOwnProperty.call(loadConfig(), k)) {
133
+ return { error: `unknown config key "${k}" — run /config to list the keys` };
134
+ }
135
+ if (!Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG, k)) {
136
+ return { error: `"${k}" has no shipped default to reset to — /config ${k} <value> sets it directly` };
137
+ }
138
+ updateConfig({ [k]: DEFAULT_CONFIG[k] });
139
+ return { key: k, value: DEFAULT_CONFIG[k], store: configStore(k) };
140
+ }
141
+
142
+ module.exports = {
143
+ SHARED_KEYS,
144
+ configStore,
145
+ parseConfigValue,
146
+ summarizeValue,
147
+ fullValue,
148
+ configRows,
149
+ formatConfigRows,
150
+ setConfigValue,
151
+ resetConfigValue,
152
+ };
package/src/shared.js CHANGED
@@ -41,5 +41,9 @@ function resolveClientModule(name) {
41
41
 
42
42
  const credentials = require(resolveClientModule('credentials.js'));
43
43
  const sessionStore = require(resolveClientModule('session-store.js'));
44
+ // The one shared non-secret preference store (AEGISONE D5). `config.js` reads
45
+ // and writes it, and the desktop's settings store writes the same file — so it
46
+ // belongs here, resolved by existence, rather than as a second path guess.
47
+ const prefs = require(resolveClientModule('prefs.js'));
44
48
 
45
- module.exports = { credentials, sessionStore, resolveClientModule };
49
+ module.exports = { credentials, sessionStore, prefs, resolveClientModule };
package/src/todos.js ADDED
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * /todos — a session todo list the user owns, and the agent can read.
5
+ *
6
+ * Ported from the upstream engine's `src/session.js` (todosFile/readTodos/
7
+ * writeTodos/addTodo/completeTodo/clearTodos/formatTodos). The upstream writes
8
+ * to `$AEGISCODEX_HOME/todos.json`; here the dir comes from this host's own
9
+ * `aegisDir()`, so the list lands in `$AEGISCODE_HOME/todos.json` beside
10
+ * credentials.json and permissions.json.
11
+ *
12
+ * Three properties carried over deliberately, because each is a failure a todo
13
+ * list is uniquely good at:
14
+ *
15
+ * 1. It cannot throw. A corrupt or hand-edited file reads as `[]` rather than
16
+ * taking the prompt down — the list is a convenience, not a dependency.
17
+ * 2. It cannot half-write. `writeTodos` writes a temp file and renames it, so
18
+ * a crash during the write leaves the previous list intact rather than a
19
+ * truncated JSON blob that the next read has to guess at.
20
+ * 3. It cannot accept an empty item. A blank todo is a rendering artifact, so
21
+ * blank text is filtered on write and refused on add.
22
+ *
23
+ * `completeTodo` takes either the 1-based number from `/todos` or a unique text
24
+ * prefix. Ambiguity is reported, never guessed: matching two todos and picking
25
+ * the first is how the wrong item gets closed silently.
26
+ */
27
+
28
+ const fs = require('node:fs');
29
+ const path = require('node:path');
30
+
31
+ const { aegisDir } = require('./config.js');
32
+
33
+ function todosFile() {
34
+ return path.join(aegisDir(), 'todos.json');
35
+ }
36
+
37
+ /** The session todo list (never throws; a corrupt file reads as empty). */
38
+ function readTodos() {
39
+ try {
40
+ const parsed = JSON.parse(fs.readFileSync(todosFile(), 'utf8'));
41
+ if (!Array.isArray(parsed)) return [];
42
+ return parsed
43
+ .filter((t) => t && typeof t.text === 'string')
44
+ .map((t) => ({ text: t.text, done: t.done === true, at: t.at || null }));
45
+ } catch {
46
+ return [];
47
+ }
48
+ }
49
+
50
+ /** Persist the list and return the cleaned copy that was written. */
51
+ function writeTodos(list) {
52
+ const clean = (Array.isArray(list) ? list : [])
53
+ .filter((t) => t && typeof t.text === 'string' && t.text.trim())
54
+ .map((t) => ({ text: t.text.trim(), done: t.done === true, at: t.at || new Date().toISOString() }));
55
+ try {
56
+ fs.mkdirSync(aegisDir(), { recursive: true });
57
+ const tmp = `${todosFile()}.tmp`;
58
+ fs.writeFileSync(tmp, `${JSON.stringify(clean, null, 2)}\n`);
59
+ fs.renameSync(tmp, todosFile());
60
+ } catch {
61
+ /* best-effort, like every other store in this host */
62
+ }
63
+ return clean;
64
+ }
65
+
66
+ function addTodo(text) {
67
+ const t = String(text || '').trim();
68
+ if (!t) return { error: 'usage: /todos add <text>' };
69
+ const list = readTodos();
70
+ list.push({ text: t, done: false, at: new Date().toISOString() });
71
+ return { list: writeTodos(list), added: t };
72
+ }
73
+
74
+ /**
75
+ * Toggle done by 1-based index or by unique text prefix. Returns
76
+ * `{ list, item }` or `{ error }` — an ambiguous prefix is an error naming how
77
+ * many matched, not a silent first-match.
78
+ */
79
+ function completeTodo(token) {
80
+ const list = readTodos();
81
+ const key = String(token || '').trim();
82
+ if (!key) return { error: 'usage: /todos done <n|text>' };
83
+ let idx = -1;
84
+ const n = Number.parseInt(key, 10);
85
+ if (Number.isFinite(n) && String(n) === key) idx = n - 1;
86
+ else {
87
+ const matches = list.map((t, i) => (t.text.startsWith(key) ? i : -1)).filter((i) => i >= 0);
88
+ if (matches.length === 1) idx = matches[0];
89
+ else if (matches.length > 1) return { error: `"${key}" matches ${matches.length} todos — use the number from /todos` };
90
+ }
91
+ if (idx < 0 || idx >= list.length) return { error: `no todo #${key} — run /todos to list them` };
92
+ list[idx].done = !list[idx].done;
93
+ return { list: writeTodos(list), item: list[idx] };
94
+ }
95
+
96
+ function clearTodos() {
97
+ writeTodos([]);
98
+ return { list: [] };
99
+ }
100
+
101
+ /** Panel lines for the list. */
102
+ function formatTodos(list = readTodos()) {
103
+ if (!list.length) return [' No todos yet — /todos add <text>'];
104
+ return list.map((t, i) => ` ${String(i + 1).padStart(2)}. ${t.done ? '✔' : '○'} ${t.text}`);
105
+ }
106
+
107
+ module.exports = {
108
+ todosFile, readTodos, writeTodos, addTodo, completeTodo, clearTodos, formatTodos,
109
+ };