@litfamily/litmuse 0.1.20 → 0.1.22
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/CHANGELOG.md +23 -0
- package/README.md +59 -27
- package/README_ko-KR.md +57 -25
- package/bin/litmuse.mjs +23 -36
- package/docs/assets/card/after.webp +0 -0
- package/docs/assets/card/idle.webp +0 -0
- package/docs/assets/card/watch-still.webp +0 -0
- package/docs/assets/card/watch.webp +0 -0
- package/docs/assets/card/working.webp +0 -0
- package/docs/assets/cover-motion-still.webp +0 -0
- package/docs/assets/cover-motion.webp +0 -0
- package/docs/assets/readme/demo.webp +0 -0
- package/lib/agent-file.mjs +18 -13
- package/lib/agent-guide.mjs +71 -0
- package/lib/card-facts.mjs +109 -0
- package/lib/card-view.mjs +35 -74
- package/lib/config.mjs +18 -0
- package/lib/doctor.mjs +3 -1
- package/lib/flags.mjs +35 -0
- package/lib/framed-card.mjs +379 -0
- package/lib/glyphs.mjs +103 -0
- package/lib/guard.mjs +38 -1
- package/lib/icon-font.mjs +198 -0
- package/lib/install-cards.mjs +406 -0
- package/lib/install.mjs +207 -74
- package/lib/mark.mjs +1 -2
- package/lib/paths.mjs +4 -1
- package/lib/safe-write.mjs +1 -1
- package/lib/stage-card.mjs +5 -22
- package/lib/sunset.mjs +24 -70
- package/lib/uninstall.mjs +42 -11
- package/package.json +1 -1
- package/plugin/.muse-plugin/plugin.json +1 -1
package/lib/install.mjs
CHANGED
|
@@ -5,11 +5,16 @@ import { preflightDestinations, writeFileAtomic, copyFileAtomic } from './safe-w
|
|
|
5
5
|
import { muse, museVersion, installedPlugin } from './muse.mjs';
|
|
6
6
|
import { stageState, stageBundle, packageVersion } from './bundle.mjs';
|
|
7
7
|
import { expectedApprovals, approvalStates } from './approvals.mjs';
|
|
8
|
-
import { agentFilePlan, installAgentFile } from './agent-file.mjs';
|
|
8
|
+
import { agentFileAsks, agentFilePlan, installAgentFile } from './agent-file.mjs';
|
|
9
9
|
import { MOVED, movedSkill, installLine } from '../plugin/hooks/lib/moved.mjs';
|
|
10
10
|
import { SHELF, extensionsNotice, leftoverRuntime } from '../plugin/hooks/lib/extensions.mjs';
|
|
11
11
|
import { noticeHash, wasShown, recordShown } from './shown.mjs';
|
|
12
12
|
import { survey, findings, CLI } from './extensions.mjs';
|
|
13
|
+
import { planRows } from './install-cards.mjs';
|
|
14
|
+
import { AGENT_LINE, AGENT_LINE_SHORT } from './agent-guide.mjs';
|
|
15
|
+
import { writeConfig } from './config.mjs';
|
|
16
|
+
import { addIconFont, iconFontPlan } from './icon-font.mjs';
|
|
17
|
+
import { roundEndsLine } from './glyphs.mjs';
|
|
13
18
|
|
|
14
19
|
function remedy(state, detail, p) {
|
|
15
20
|
const saved = `${p.stage}.saved-${new Date().toISOString().slice(0, 10)}`;
|
|
@@ -63,53 +68,102 @@ function samePath(a, b) {
|
|
|
63
68
|
return real(a) === real(b);
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
const counted = (list) => {
|
|
72
|
+
const of = (kind, word) => {
|
|
73
|
+
const n = list.filter((a) => a.kind === kind).length;
|
|
74
|
+
return n ? [`${n} ${word}${n === 1 ? '' : 's'}`] : [];
|
|
75
|
+
};
|
|
76
|
+
return `${list.length} (${[...of('hook', 'hook'), ...of('agent', 'agent')].join(', ')})`;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// `font` carries test doubles for addIconFont.
|
|
80
|
+
export async function install({ env = process.env, flags = {}, interactive = false, ask, print = console.log, cards = null, tty = Boolean(process.stdout.isTTY), font = {} }) {
|
|
67
81
|
const p = paths(env);
|
|
68
82
|
const version = packageVersion();
|
|
69
83
|
const scope = flags.scope || 'user';
|
|
70
|
-
|
|
84
|
+
// With cards, these lines are drawn as rows and panels instead.
|
|
85
|
+
const plain = cards ? () => {} : print;
|
|
86
|
+
let stage = 'Check';
|
|
87
|
+
const fail = (what, ...notes) => {
|
|
88
|
+
if (cards) {
|
|
89
|
+
cards.panel({
|
|
90
|
+
title: 'INSTALL STOPPED', bad: true,
|
|
91
|
+
sections: [{ rows: [
|
|
92
|
+
{ mark: 'fail', label: 'Stage', value: stage }, { mark: 'fail', label: 'Reason', value: what },
|
|
93
|
+
{ mark: 'note', label: 'Next', value: notes.length ? 'the lines below' : 'fix this, then run the install again' },
|
|
94
|
+
] }],
|
|
95
|
+
});
|
|
96
|
+
if (notes.length) print('');
|
|
97
|
+
for (const line of notes) print(line);
|
|
98
|
+
} else for (const line of [`FAIL ${what}`, ...notes]) print(line);
|
|
99
|
+
return 1;
|
|
100
|
+
};
|
|
101
|
+
const section = (heading, lines) => {
|
|
102
|
+
if (cards) {
|
|
103
|
+
cards.text(heading, lines);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
print('');
|
|
107
|
+
print(heading);
|
|
108
|
+
for (const line of lines) print(line);
|
|
109
|
+
};
|
|
110
|
+
plain(`LitMuse ${version} installer for Muse Code`);
|
|
111
|
+
cards?.intro(`Installs into ${p.data}. Your Muse settings are backed up first.`);
|
|
71
112
|
|
|
72
113
|
const major = Number(process.versions.node.split('.')[0]);
|
|
73
114
|
if (major < 20) {
|
|
74
|
-
|
|
75
|
-
return 1;
|
|
115
|
+
return fail(`Node.js ${process.versions.node} is too old; LitMuse needs Node.js 20 or newer.`);
|
|
76
116
|
}
|
|
77
117
|
const mv = museVersion(env);
|
|
78
118
|
if (!mv) {
|
|
79
|
-
|
|
80
|
-
return 1;
|
|
119
|
+
return fail('muse was not found on PATH. Install Muse Code first (https://dev.meta.ai/docs/muse-code), sign in once, then run this again.');
|
|
81
120
|
}
|
|
82
|
-
|
|
121
|
+
plain(`Host: ${mv}`);
|
|
83
122
|
|
|
84
123
|
const st = preflightDestinations(p) ?? stageState(p);
|
|
85
124
|
if (['symlinked', 'foreign', 'modified'].includes(st.state)) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
125
|
+
return fail(
|
|
126
|
+
`destination ${st.state}: ${st.detail}`,
|
|
127
|
+
remedy(st.state, st.detail, p),
|
|
128
|
+
...(st.state === 'modified' ? extensionRemedy(st.changed, p) : []),
|
|
129
|
+
'No files written.',
|
|
130
|
+
);
|
|
91
131
|
}
|
|
92
132
|
|
|
93
133
|
const existing = installedPlugin(env);
|
|
94
134
|
const existingSource = existing?.source?.path;
|
|
95
135
|
if (existingSource && !samePath(existingSource, p.stage)) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
136
|
+
return fail(
|
|
137
|
+
`Muse already has LitMuse ${existing.version ?? ''} installed from ${existingSource}.`.replace(' ', ' '),
|
|
138
|
+
`This installer manages the copy in ${p.stage}. Remove the other one first with: muse plugins remove litmuse (this also clears its approvals), then run install again.`,
|
|
139
|
+
'No files written.',
|
|
140
|
+
);
|
|
100
141
|
}
|
|
101
142
|
const installArgs = existing ? ['plugins', 'update', 'litmuse', '--json'] : ['plugins', 'install', p.stage, '--scope', scope, '--json'];
|
|
102
143
|
const approvals = expectedApprovals();
|
|
103
144
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
145
|
+
const plan = [
|
|
146
|
+
['bundle', `${p.stage}${st.state === 'owned' ? ` (replaces LitMuse ${st.version})` : ''}`],
|
|
147
|
+
['backups', `${p.backups} (Muse settings.json and installed.json, when present)`],
|
|
148
|
+
['receipt', p.receipt],
|
|
149
|
+
['rules file', agentFilePlan({ env, flags })],
|
|
150
|
+
...(flags.round ? [['icon font', iconFontPlan({ env, ...font })]] : []),
|
|
151
|
+
...(flags.glyphs ? [['round ends', `save ${flags.glyphs} in ${p.config}`]] : []),
|
|
152
|
+
['muse', `muse ${installArgs.join(' ')}`],
|
|
153
|
+
['approvals', `up to ${approvals.length} capabilities may need your approval in Muse (hooks and agents):`],
|
|
154
|
+
];
|
|
155
|
+
if (cards) {
|
|
156
|
+
cards.panel({
|
|
157
|
+
title: `LitMuse ${version} install plan`,
|
|
158
|
+
hints: [AGENT_LINE, AGENT_LINE_SHORT],
|
|
159
|
+
sections: [{ rows: planRows([['Host', mv], ...plan.map(([label, value]) => [label[0].toUpperCase() + label.slice(1), value]).slice(0, -1), ['Approvals', `up to ${counted(approvals)}`]]) }],
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
print('');
|
|
163
|
+
print('Plan');
|
|
164
|
+
for (const [label, value] of plan) print(` ${label.padEnd(12)}${value}`);
|
|
165
|
+
for (const a of approvals) print(` ${a.id}`);
|
|
166
|
+
}
|
|
113
167
|
|
|
114
168
|
if (flags.dryRun) {
|
|
115
169
|
print('');
|
|
@@ -118,7 +172,7 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
118
172
|
}
|
|
119
173
|
if (!interactive && !flags.yes) {
|
|
120
174
|
print('');
|
|
121
|
-
print('No files written: this shell has no terminal. Rerun with --yes to install
|
|
175
|
+
print('No files written: this shell has no terminal. Rerun with --yes to install; the capabilities above then wait for approval, and the commands are printed.');
|
|
122
176
|
return 0;
|
|
123
177
|
}
|
|
124
178
|
|
|
@@ -126,51 +180,77 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
126
180
|
const leftovers = [leftoverRuntime(p.data)].filter((d) => existsSync(d));
|
|
127
181
|
|
|
128
182
|
const written = [];
|
|
183
|
+
const steps = cards?.work(`Installing LitMuse ${version}`, 'Install steps', [
|
|
184
|
+
['Backups', 'save your Muse settings'], ['Bundle', 'copy the plugin bundle'], ['Validate', 'muse plugins validate'], ['Muse', `muse plugins ${existing ? 'update' : 'install'}`],
|
|
185
|
+
]);
|
|
186
|
+
const step = (name) => {
|
|
187
|
+
stage = name;
|
|
188
|
+
steps?.next();
|
|
189
|
+
};
|
|
190
|
+
const stopped = (...told) => {
|
|
191
|
+
steps?.fail();
|
|
192
|
+
return fail(...told);
|
|
193
|
+
};
|
|
194
|
+
step('Backups');
|
|
129
195
|
written.push(...backupHostFiles(p));
|
|
196
|
+
step('Bundle');
|
|
130
197
|
stageBundle(p);
|
|
131
198
|
written.push(p.stage);
|
|
132
199
|
|
|
200
|
+
step('Validate');
|
|
133
201
|
const validation = muse(env, ['plugins', 'validate', p.stage, '--json']);
|
|
134
202
|
const diagnostics = validation.json?.diagnostics ?? [];
|
|
135
203
|
if (!validation.ok || validation.json?.valid !== true || diagnostics.length) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
204
|
+
return stopped(
|
|
205
|
+
'muse plugins validate rejected the bundle:',
|
|
206
|
+
...diagnostics.map((d) => ` ${d.code ?? 'diagnostic'}: ${d.message ?? JSON.stringify(d)}`),
|
|
207
|
+
...(diagnostics.length ? [] : [` ${validation.stderr.trim() || validation.stdout.trim()}`]),
|
|
208
|
+
'Muse was left unchanged.',
|
|
209
|
+
);
|
|
141
210
|
}
|
|
142
211
|
|
|
212
|
+
step('Muse');
|
|
143
213
|
const result = muse(env, installArgs);
|
|
144
214
|
if (!result.ok) {
|
|
145
|
-
|
|
146
|
-
print(` ${(result.stderr || result.stdout).trim().split('\n').slice(0, 6).join('\n ')}`);
|
|
147
|
-
return 1;
|
|
215
|
+
return stopped(`${result.command} exited ${result.status}:`, ` ${(result.stderr || result.stdout).trim().split('\n').slice(0, 6).join('\n ')}`);
|
|
148
216
|
}
|
|
149
217
|
const cachePath = result.json?.installed?.cache_path;
|
|
150
218
|
written.push(p.museInstalled);
|
|
151
219
|
if (cachePath) written.push(cachePath);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
220
|
+
const installed = existing
|
|
221
|
+
? `LitMuse ${version} is updated in Muse from ${p.stage}. Skills and commands are active now.`
|
|
222
|
+
: `LitMuse ${version} is installed in Muse at ${scope} scope. Skills and commands are active now.`;
|
|
223
|
+
plain('');
|
|
224
|
+
plain(`Installed: ${installed}`);
|
|
225
|
+
steps?.done();
|
|
156
226
|
|
|
157
227
|
let states = approvalStates(muse(env, ['plugins', 'inspect', 'litmuse', '--json']).json);
|
|
158
228
|
const pending = states.filter((s) => s.status !== 'trusted_enabled');
|
|
229
|
+
const named = (s) => ` ${s.id} (${s.what})`;
|
|
230
|
+
const asksApproval = pending.length > 0 && !flags.approve && !flags.yes && interactive && Boolean(ask);
|
|
231
|
+
const questions = Number(asksApproval) + Number(agentFileAsks({ env, flags, interactive, ask, version }));
|
|
159
232
|
if (pending.length) {
|
|
160
233
|
let approve = Boolean(flags.approve);
|
|
161
234
|
const decided = approve;
|
|
162
|
-
if (!decided) {
|
|
163
|
-
|
|
164
|
-
print(`Muse runs plugin hooks and agents only after you approve them (an update re-arms the agent approvals, and the hook approvals whenever hook code changed). ${pending.length} are waiting:`);
|
|
165
|
-
for (const s of pending) print(` ${s.id} (${s.what})`);
|
|
235
|
+
if (!decided && !(cards && asksApproval)) {
|
|
236
|
+
section(`Muse runs plugin hooks and agents only after you approve them (an update re-arms the agent approvals, and the hook approvals whenever hook code changed). ${pending.length} are waiting:`, pending.map(named));
|
|
166
237
|
}
|
|
167
|
-
if (
|
|
168
|
-
approve = await ask(`Approve these ${pending.length} LitMuse capabilities now? [y/N]
|
|
238
|
+
if (asksApproval) {
|
|
239
|
+
approve = await ask(`Approve these ${pending.length} LitMuse capabilities now? [y/N] `, {
|
|
240
|
+
card: {
|
|
241
|
+
tag: `LIT 1/${questions}`,
|
|
242
|
+
title: 'Approvals',
|
|
243
|
+
note: `Muse runs plugin hooks and agents only after you approve them. Yes approves these ${counted(pending)} now; No prints the commands for later.`,
|
|
244
|
+
yes: `approve ${pending.length}`,
|
|
245
|
+
no: 'not now',
|
|
246
|
+
list: { hint: `l list all ${pending.length}`, heading: `${pending.length} LitMuse capabilities are waiting`, lines: pending.map((s) => (s.kind === 'hook' ? named(s) : ` ${s.id}`)) },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
169
249
|
}
|
|
170
250
|
if (approve) {
|
|
171
251
|
if (decided) {
|
|
172
|
-
|
|
173
|
-
|
|
252
|
+
plain('');
|
|
253
|
+
plain(`Approving ${pending.length} LitMuse capabilities...`);
|
|
174
254
|
}
|
|
175
255
|
const failed = [];
|
|
176
256
|
for (const s of pending) {
|
|
@@ -178,32 +258,54 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
178
258
|
if (!r.ok) failed.push(`${s.id}: ${(r.stderr || r.stdout).trim().split(/\r?\n/)[0]}`);
|
|
179
259
|
}
|
|
180
260
|
written.push(`${p.museSettings} (runtime_capabilities for litmuse)`);
|
|
181
|
-
for (const f of failed)
|
|
261
|
+
for (const f of failed) {
|
|
262
|
+
if (cards) cards.row('fail', 'Approve', f);
|
|
263
|
+
else print(` FAIL approve ${f}`);
|
|
264
|
+
}
|
|
182
265
|
states = approvalStates(muse(env, ['plugins', 'inspect', 'litmuse', '--json']).json);
|
|
183
266
|
const byId = new Map(states.map((s) => [s.id, s]));
|
|
184
267
|
const approved = pending.filter((s) => byId.get(s.id)?.status === 'trusted_enabled');
|
|
185
268
|
const still = states.filter((s) => s.status !== 'trusted_enabled');
|
|
186
269
|
if (approved.length) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
for (const s of approved) print(` ${s.id} (${s.what})`);
|
|
190
|
-
}
|
|
191
|
-
if (still.length) {
|
|
192
|
-
print('');
|
|
193
|
-
print(`${still.length} are still waiting:`);
|
|
194
|
-
for (const s of still) print(` ${s.id} (${s.what})`);
|
|
195
|
-
} else {
|
|
196
|
-
print('No capabilities are still waiting for approval.');
|
|
270
|
+
if (cards) cards.row('done', 'Approved', counted(approved));
|
|
271
|
+
else section(`Approved ${approved.length} LitMuse capabilities:`, approved.map(named));
|
|
197
272
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
print('
|
|
201
|
-
|
|
273
|
+
// With cards, the closing card and the commands after it say what is left.
|
|
274
|
+
if (!cards && still.length) section(`${still.length} are still waiting:`, still.map(named));
|
|
275
|
+
else if (!cards) print('No capabilities are still waiting for approval.');
|
|
276
|
+
} else if (!cards) {
|
|
277
|
+
section(flags.yes ? 'Approval needed. The person who uses Muse runs these when ready:' : 'Approval needed. Run these when you are ready (or rerun install with --approve):', pending.map((s) => ` muse plugins approve ${s.id}`));
|
|
202
278
|
}
|
|
203
279
|
}
|
|
204
280
|
|
|
205
|
-
|
|
206
|
-
|
|
281
|
+
plain('');
|
|
282
|
+
let rules = null;
|
|
283
|
+
const rulesRow = (line) => {
|
|
284
|
+
const value = line.replace('AGENT_FILE: ', '');
|
|
285
|
+
rules = { mark: /^(created|updated|unchanged)/.test(value) ? 'done' : /^(off|skipped)/.test(value) ? 'note' : 'warn', label: 'Rules file', value };
|
|
286
|
+
};
|
|
287
|
+
written.push(...await installAgentFile({
|
|
288
|
+
env, flags, interactive, ask, print: cards ? rulesRow : print, version, backupDir: p.backups, tag: `LIT ${questions}/${questions}`,
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
const told = (mark, label, word, value) => (cards ? cards.row(mark, label, value) : print(`${word}: ${value}`));
|
|
292
|
+
if (flags.glyphs) {
|
|
293
|
+
try {
|
|
294
|
+
written.push(writeConfig(env, { glyphs: flags.glyphs }));
|
|
295
|
+
told('done', 'Round ends', 'GLYPHS', `saved ${flags.glyphs}`);
|
|
296
|
+
} catch (e) {
|
|
297
|
+
told('fail', 'Round ends', 'GLYPHS', `not saved (${e.message})`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
let fontWhy = null;
|
|
301
|
+
if (flags.round) {
|
|
302
|
+
const added = await addIconFont({ env, ...font });
|
|
303
|
+
written.push(...added.written);
|
|
304
|
+
if (added.status === 'failed') fontWhy = added.why;
|
|
305
|
+
const value = { here: 'an icon font is already here; nothing added', added: `added ${added.written[0]}` }[added.status] ?? `not installed (${added.why})`;
|
|
306
|
+
told(added.status === 'failed' ? 'warn' : 'done', 'Icon font', 'ICON_FONT', value);
|
|
307
|
+
}
|
|
308
|
+
const ends = roundEndsLine({ env, tty, fontWhy, platform: font.platform, iconFont: font.hasFont });
|
|
207
309
|
|
|
208
310
|
const left = states.filter((s) => s.status !== 'trusted_enabled').length;
|
|
209
311
|
// A new version (or a first install) arms the one-time notice for the next Muse session; a same-version reinstall
|
|
@@ -219,23 +321,54 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
219
321
|
}, null, 2)}\n`);
|
|
220
322
|
written.push(p.receipt);
|
|
221
323
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
for (const w of written)
|
|
225
|
-
|
|
324
|
+
plain('');
|
|
325
|
+
plain('Written:');
|
|
326
|
+
for (const w of written) plain(` ${w}`);
|
|
327
|
+
plain('');
|
|
328
|
+
if (cards) {
|
|
329
|
+
const names = new Map([
|
|
330
|
+
[p.stage, 'Bundle'], [p.museInstalled, 'Muse plugin list'], [cachePath, 'Muse copy'], [p.museRules, 'Rules file'], [p.notice, 'First-run note'], [p.receipt, 'Receipt'], [p.config, 'Config'], [p.iconFont, 'Icon font list'],
|
|
331
|
+
]);
|
|
332
|
+
const nameOf = (path) => names.get(path) ?? (path.startsWith(p.backups) ? 'Backup' : /SymbolsNerdFont/.test(path) ? 'Icon font' : 'Muse settings');
|
|
333
|
+
const waiting = states.filter((s) => s.status !== 'trusted_enabled');
|
|
334
|
+
cards.panel({
|
|
335
|
+
title: `LitMuse ${version} is installed`,
|
|
336
|
+
sections: [
|
|
337
|
+
{ head: 'Installed', rows: [
|
|
338
|
+
{ label: 'Muse plugin', value: `${existing ? 'updated' : `installed at ${scope} scope`}; skills and commands are active now` },
|
|
339
|
+
...written.filter((path) => path !== p.museRules).map((path) => ({ label: nameOf(path), value: path })),
|
|
340
|
+
...(rules ? [rules] : []),
|
|
341
|
+
left === 0 ? { label: 'Approvals', value: 'every hook and agent is approved' } : { mark: 'warn', label: 'Approvals', value: `${counted(waiting)} still to approve; the commands are below` },
|
|
342
|
+
] },
|
|
343
|
+
{ head: 'Next', rows: planRows([
|
|
344
|
+
...(left ? [['Approve', 'run the commands below']] : []),
|
|
345
|
+
['Restart', 'quit Muse if it is open, then start it again'],
|
|
346
|
+
['Start', 'open Muse in a project and begin a prompt with lit'], ['Check', 'npx @litfamily/litmuse doctor'],
|
|
347
|
+
]) },
|
|
348
|
+
],
|
|
349
|
+
});
|
|
350
|
+
if (left) cards.text(flags.yes ? 'Approval needed. The person who uses Muse runs these when ready:' : 'Approval needed. Run these when you are ready (or rerun install with --approve):', waiting.map((s) => ` muse plugins approve ${s.id}`));
|
|
351
|
+
}
|
|
226
352
|
// The notice and the fixed line after it are printed once per text; the live count of folders to check always is.
|
|
227
353
|
const [fixedLine, ...liveLines] = extensionLines(env);
|
|
228
354
|
const noticeLines = [...extensionsNotice({ leftovers }), fixedLine];
|
|
229
355
|
const hash = noticeHash(noticeLines.join('\n'));
|
|
230
356
|
if (wasShown(p.shown, hash)) {
|
|
231
|
-
|
|
357
|
+
if (cards && liveLines.length) cards.text('LitFamily extensions', liveLines);
|
|
358
|
+
else for (const line of liveLines) print(line);
|
|
232
359
|
} else {
|
|
233
|
-
|
|
360
|
+
if (cards) cards.text(noticeLines[0], [...noticeLines.slice(1), ...liveLines]);
|
|
361
|
+
else for (const line of [...noticeLines, ...liveLines]) print(line);
|
|
234
362
|
recordShown(p.shown, hash);
|
|
235
363
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
:
|
|
364
|
+
if (cards) cards.line(ends);
|
|
365
|
+
else {
|
|
366
|
+
print('');
|
|
367
|
+
print('Restart: quit Muse if it is open, then start it again, so it loads this LitMuse.');
|
|
368
|
+
print(left === 0
|
|
369
|
+
? 'Status: Ready. Start Muse in a project and begin a prompt with `lit`. Check any time with `npx @litfamily/litmuse doctor`.'
|
|
370
|
+
: `Status: installed, approval needed for ${left} capabilities. Run the commands above, then \`npx @litfamily/litmuse doctor\`.`);
|
|
371
|
+
print(ends);
|
|
372
|
+
}
|
|
240
373
|
return 0;
|
|
241
374
|
}
|
package/lib/mark.mjs
CHANGED
|
@@ -100,8 +100,7 @@ const tagline = (width, depth) => {
|
|
|
100
100
|
|
|
101
101
|
// The mark as printable rows for `cols` cells at `depth`: the art, then one centred tagline.
|
|
102
102
|
// Below 24 columns it is the single plain line.
|
|
103
|
-
export function markRows({ cols = 80, depth = 'none' } = {}) {
|
|
104
|
-
const size = markSize(cols);
|
|
103
|
+
export function markRows({ cols = 80, depth = 'none', size = markSize(cols) } = {}) {
|
|
105
104
|
if (!size) return [FALLBACK];
|
|
106
105
|
const art = depth === 'none' ? [...MONO_ROWS[size]] : artRows(size, depth);
|
|
107
106
|
return [...art, tagline(PIXEL_ROWS[size][0].length, depth)];
|
package/lib/paths.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { xdgData } from './guard.mjs';
|
|
3
4
|
|
|
4
5
|
// Every location LitMuse reads or writes, resolved from one environment so tests can sandbox HOME.
|
|
5
6
|
export function paths(env = process.env) {
|
|
6
7
|
const home = env.HOME || homedir();
|
|
7
8
|
const dataHome = env.XDG_DATA_HOME || join(home, '.local', 'share');
|
|
8
9
|
const configHome = env.XDG_CONFIG_HOME || join(home, '.config');
|
|
9
|
-
|
|
10
|
+
// Our own records stay in one place whatever the working folder; Muse's own files are where Muse puts them.
|
|
11
|
+
const data = join(xdgData(env) ?? join(home, '.local', 'share'), 'litmuse');
|
|
10
12
|
return {
|
|
11
13
|
home,
|
|
12
14
|
data,
|
|
@@ -15,6 +17,7 @@ export function paths(env = process.env) {
|
|
|
15
17
|
receipt: join(data, 'receipt.json'),
|
|
16
18
|
updateCache: join(data, 'update-check.json'),
|
|
17
19
|
config: join(data, 'config.json'),
|
|
20
|
+
iconFont: join(data, 'icon-font.json'),
|
|
18
21
|
notice: join(data, 'first-session-notice.json'),
|
|
19
22
|
shown: join(data, 'shown.jsonl'),
|
|
20
23
|
museSettings: join(configHome, 'muse', 'settings.json'),
|
package/lib/safe-write.mjs
CHANGED
|
@@ -11,7 +11,7 @@ function lstatOrNull(p) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// The nearest existing ancestor, resolved through links, so the guard judges where bytes really land.
|
|
14
|
-
function realExistingAncestor(p) {
|
|
14
|
+
export function realExistingAncestor(p) {
|
|
15
15
|
let cur = p;
|
|
16
16
|
while (!lstatOrNull(cur) && dirname(cur) !== cur) cur = dirname(cur);
|
|
17
17
|
return realpathSync(cur);
|
package/lib/stage-card.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { newerThan } from '../plugin/hooks/lib/common.mjs';
|
|
|
5
5
|
import { readManifest } from './bundle.mjs';
|
|
6
6
|
import { paths } from './paths.mjs';
|
|
7
7
|
import { gauge } from '../plugin/lib/rewind/gauge.mjs';
|
|
8
|
-
import { ink, neon, roundGauge, stagePill } from './sunset.mjs';
|
|
9
8
|
// One rainbow-tinted line at most (a static ANSI gradient, flash-safe); it marks the adhd turn.
|
|
10
9
|
import { rainbowLine } from '../plugin/lib/rewind/rainbow.mjs';
|
|
11
10
|
|
|
@@ -258,7 +257,7 @@ const paint = (code, text, color) => (color ? `\u001b[${code}m${text}\u001b[0m`
|
|
|
258
257
|
|
|
259
258
|
// Waiting on the user: a paused thread, or a lane that reported failure. A turn where the
|
|
260
259
|
// model asked a question but left no tool state is not visible to the card.
|
|
261
|
-
const waitingOf = (card) => (card.threads?.rows ?? []).some((row) => row.status === 'paused')
|
|
260
|
+
export const waitingOf = (card) => (card.threads?.rows ?? []).some((row) => row.status === 'paused')
|
|
262
261
|
|| (card.lanes ?? []).some((lane) => lane.status === 'failed');
|
|
263
262
|
|
|
264
263
|
// With a pill (truecolor TTY only) the pill stands in for the leading `LIT · `.
|
|
@@ -273,7 +272,7 @@ const headlineFor = (card, color, pill = null) => {
|
|
|
273
272
|
|
|
274
273
|
// Canonical review-lane display names, in REVIEW_LANES order; the strip reads the same
|
|
275
274
|
// list, so the two cannot drift apart.
|
|
276
|
-
const REVIEW_LANE_LABELS = Object.freeze({ goal: 'scope', quality: 'package', security: 'security', qa: 'tests+evidence', context: 'surface' });
|
|
275
|
+
export const REVIEW_LANE_LABELS = Object.freeze({ goal: 'scope', quality: 'package', security: 'security', qa: 'tests+evidence', context: 'surface' });
|
|
277
276
|
const VERDICT_DOT = Object.freeze({ pass: ['32;1', '●'], fail: ['31;1', '●'], running: ['33;1', '◐'], pending: ['33', '○'] });
|
|
278
277
|
|
|
279
278
|
const laneSegment = (id, verdict, color) => {
|
|
@@ -293,7 +292,7 @@ const lanesStrip = (card, color) => {
|
|
|
293
292
|
// prints one celebratory line until the freshness window passes, then the card settles on
|
|
294
293
|
// its own. A published release has no signal the card can see.
|
|
295
294
|
const BURST_FRESH_MS = 15 * 60 * 1000;
|
|
296
|
-
const burstOf = (card, now) => {
|
|
295
|
+
export const burstOf = (card, now) => {
|
|
297
296
|
const plan = card.plan;
|
|
298
297
|
if (plan && plan.total > 0 && plan.done >= plan.total && Number.isFinite(plan.mtimeMs) && now - plan.mtimeMs <= BURST_FRESH_MS) {
|
|
299
298
|
return `✨ done: ${plan.file} · ${plan.done}/${plan.total} rows ticked ✨`;
|
|
@@ -305,14 +304,6 @@ const burstOf = (card, now) => {
|
|
|
305
304
|
return null;
|
|
306
305
|
};
|
|
307
306
|
|
|
308
|
-
// The sunset's light for this card, or null when the burst has the stage: amber while it waits on the user, rainbow
|
|
309
|
-
// for the adhd turn, dimmed with no route.
|
|
310
|
-
export function cardLight(card) {
|
|
311
|
-
if (burstOf(card, card.now ?? Date.now())) return null;
|
|
312
|
-
const look = !card.active ? 'sunset' : waitingOf(card) ? 'turn' : card.route === 'lit-adhd' ? 'rainbow' : 'sunset';
|
|
313
|
-
return { look, dim: !card.active };
|
|
314
|
-
}
|
|
315
|
-
|
|
316
307
|
// Work is going on: a route is active, its session has not stopped since the record last moved, and something moved
|
|
317
308
|
// in the last quarter hour. Only then does the watched card move.
|
|
318
309
|
export function cardWorking(card, { env = process.env, now = card.now ?? Date.now() } = {}) {
|
|
@@ -325,9 +316,7 @@ export function cardWorking(card, { env = process.env, now = card.now ?? Date.no
|
|
|
325
316
|
|
|
326
317
|
// badge: { text, width } from lib/mark.mjs litPill, or null. It is dropped when the headline
|
|
327
318
|
// would no longer fit `cols`, so the plain headline stays the fallback at every width.
|
|
328
|
-
|
|
329
|
-
// words and widths stay the same.
|
|
330
|
-
export function renderCard(card, { badge = null, cols = Infinity, dress = null } = {}) {
|
|
319
|
+
export function renderCard(card, { badge = null, cols = Infinity } = {}) {
|
|
331
320
|
const out = [];
|
|
332
321
|
const color = !card.noColor;
|
|
333
322
|
const plainRest = headlineFor(card, false).length - 'LIT · '.length;
|
|
@@ -338,17 +327,11 @@ export function renderCard(card, { badge = null, cols = Infinity, dress = null }
|
|
|
338
327
|
const threads = card.threads?.rows ?? [];
|
|
339
328
|
if (threads.length) {
|
|
340
329
|
out.push('threads:');
|
|
341
|
-
const current = threads.findLastIndex((thread) => !thread.sibling && thread.status === 'active');
|
|
342
330
|
threads.forEach((thread, index) => {
|
|
343
331
|
const branch = index === threads.length - 1 && !card.threads.omitted ? '└─' : '├─';
|
|
344
332
|
const name = thread.pane ? `${thread.skill} · ${thread.pane}` : thread.skill;
|
|
345
333
|
const where = thread.sibling && !thread.pane ? ` (${thread.session})` : '';
|
|
346
|
-
|
|
347
|
-
// The current stage is a pill as wide as before: its letters filled, or, with round caps, the two spaces around it.
|
|
348
|
-
const plainStage = thread.stage ? ` ${thread.stage} ` : ' ';
|
|
349
|
-
const stage = dress && thread.stage && index === current ? stagePill(plainStage, dress.caps) : plainStage;
|
|
350
|
-
const meter = dress?.caps ? roundGauge(thread.gauge) : thread.gauge;
|
|
351
|
-
out.push(`${rail} ${name}${stage}${thread.status}${thread.gauge ? ` ${meter}` : ''}${where}`);
|
|
334
|
+
out.push(`${branch} ${name}${thread.stage ? ` ${thread.stage}` : ''} ${thread.status}${thread.gauge ? ` ${thread.gauge}` : ''}${where}`);
|
|
352
335
|
});
|
|
353
336
|
if (card.threads.omitted) out.push(`+${card.threads.omitted} more`);
|
|
354
337
|
}
|