@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/lib/sunset.mjs CHANGED
@@ -1,25 +1,20 @@
1
1
  // The status card's sunset, for a person's truecolor terminal only: a half-sunk sun with stars over it and a sea under
2
- // it, painted after the end of each row's words. Words are never touched; a row with no room keeps exactly its text.
2
+ // it, painted only in cells that hold no text.
3
3
  // `t` is seconds into the motion; null is the resting pose. Shapes hold still: only colours move, plus the ASCII sea,
4
4
  // stars and shooting star.
5
5
  import { displayWidth } from '../plugin/lib/rewind/gauge.mjs';
6
6
  import { sample } from './mark.mjs';
7
7
 
8
8
  const ESC = '\u001b';
9
- export const MIN_COLS = 90;
9
+ export const MIN_COLS = 64;
10
10
  export const MAX_WIDTH = 120;
11
11
  export const SUN_W = 18;
12
12
  export const SUN_ROWS = 3;
13
13
  // The moment a single print of a working card shows. No shooting star is in flight then.
14
14
  export const STILL_T = 4;
15
- export const BRAND = Object.freeze(['#ff8f3c', '#ff2d8a']);
16
- const STAGE = Object.freeze(['#b48cff', '#8be9fd']);
17
15
  const NEON = Object.freeze(['#ff2d95', '#b48cff', '#8be9fd']);
18
- const INK = '#0b0e14';
19
- const TRACK = '#2a2340';
20
- const FAINT = '#30363d';
16
+ export const FAINT = '#30363d';
21
17
  const SLIT = '#1a1030';
22
- const CAP = Object.freeze(['', '']);
23
18
 
24
19
  const LOOKS = {
25
20
  sunset: { sun: [['#ffd24a', '#fff0a0'], ['#ff8f3c', '#ffc15a'], ['#ff2d8a', '#ff6b8f']], sea: ['#ffdc73', '#ff9a4a', '#ff4f8b', '#b457d6', '#5a46a8'] },
@@ -33,21 +28,11 @@ export function sceneOn({ depth, env = process.env, cols }) {
33
28
  return depth === 'truecolor' && !light && cols >= MIN_COLS;
34
29
  }
35
30
 
36
- // These terminals draw the rounded caps themselves, whatever the font.
37
- export const roundCaps = (env = process.env) => Boolean(env.WT_SESSION) || env.TERM_PROGRAM === 'vscode';
38
-
39
31
  export const motionOff = (env = process.env) => /^(off|reduced|0)$/i.test(env.LITMUSE_MOTION ?? '');
40
32
 
41
33
  const SGR = /\u001b\[[0-9;]*m/gu;
42
34
  const charCells = (ch) => Math.max(displayWidth(ch), /\p{Emoji_Presentation}/u.test(ch) ? 2 : 0);
43
35
 
44
- // Cells a row's words take, or Infinity when terminals disagree about them (tabs, joined emoji, stray controls).
45
- export function rowCells(row) {
46
- const text = row.replace(SGR, '');
47
- if (/[\p{Cc}‍️\p{Regional_Indicator}]/u.test(text)) return Infinity;
48
- return [...text].reduce((sum, ch) => sum + charCells(ch), 0);
49
- }
50
-
51
36
  // A row cut into rows of at most `width` cells; the colour in force carries on. Control characters are dropped.
52
37
  export function wrapRow(row, width) {
53
38
  const out = [];
@@ -105,33 +90,6 @@ export function ink(cells) {
105
90
  return last ? `${out}${ESC}[0m` : out;
106
91
  }
107
92
 
108
- // Text on a fill graded along two stops. Its first and last characters are padding, which become round caps.
109
- export function gradedPill(text, stops, caps) {
110
- const chars = [...text];
111
- const last = chars.length - 1;
112
- return ink(chars.map((ch, i) => {
113
- const fill = sample(stops, i / last);
114
- if (caps && (i === 0 || i === last)) return { ch: CAP[i === 0 ? 0 : 1], fg: fill };
115
- return { ch, fg: INK, bg: fill, bold: true };
116
- }));
117
- }
118
-
119
- // ` RED ` as the current stage: round caps take its two spaces, otherwise only the letters are filled.
120
- export function stagePill(text, caps) {
121
- if (caps) return gradedPill(text, STAGE, true);
122
- const chars = [...text];
123
- const span = Math.max(1, chars.length - 3);
124
- return ink(chars.map((ch, i) => (i === 0 || i === chars.length - 1 ? null : { ch, fg: INK, bg: sample(STAGE, Math.min(1, (i - 1) / span)), bold: true })));
125
- }
126
-
127
- // `[▉▉░] 2/3` with its brackets as round caps on one smooth track, in the same cells. Anything else is returned as is.
128
- export function roundGauge(text) {
129
- const parts = /^\[([▉░]+)\](.*)$/u.exec(text);
130
- if (!parts) return text;
131
- const tints = [...parts[1]].map((ch, i, all) => (ch === '▉' ? sample(['#ff8f3c', '#ff2d8a'], i / all.length) : TRACK));
132
- return ink([{ ch: CAP[0], fg: tints[0] }, ...tints.map((bg) => ({ ch: ' ', bg })), { ch: CAP[1], fg: tints.at(-1) }]) + parts[2];
133
- }
134
-
135
93
  // The neon a place on the card takes, pink to violet to cyan.
136
94
  export const neon = (k) => (k < 0.5 ? mix(NEON[0], NEON[1], k * 2) : mix(NEON[1], NEON[2], k * 2 - 1));
137
95
 
@@ -148,18 +106,21 @@ const STARS = [[0, -30], [1, -24], [0, -18], [1, -13], [0, -9], [1, -5], [0, 22]
148
106
  const CLEAR = 3;
149
107
 
150
108
  /**
151
- * Where the scene goes on these rows: the lowest three rows in a run with room for the sun, so one long row moves the
152
- * sun up instead of putting it out. `top` is null when there is no room anywhere. Work this out once per state, then
153
- * paint it as often as needed.
109
+ * Where the scene goes over rows of cells, where an empty cell is null: the lowest three rows in a run that leave the
110
+ * sun room, as near its usual place as they allow. `top` is null when there is no room anywhere.
154
111
  */
155
- export function place(rows, width) {
156
- const ends = rows.map(rowCells);
157
- const at = Math.round(width * 0.62);
158
- let top = null;
159
- for (let r = rows.length - SUN_ROWS; r >= 0 && top === null; r -= 1) {
160
- if (at + SUN_W + 2 <= width && [0, 1, 2].every((i) => ends[r + i] + 2 <= at)) top = r;
112
+ export function place(grid, width) {
113
+ const home = Math.round(width * 0.62);
114
+ const free = (r, from, to) => {
115
+ for (let x = from; x < to; x += 1) if (x < 0 || x >= width || grid[r][x]) return false;
116
+ return true;
117
+ };
118
+ const spots = Array.from({ length: Math.max(0, width - SUN_W - 1) }, (_, i) => i).filter((at) => Math.abs(at - home) <= 14).sort((a, b) => Math.abs(a - home) - Math.abs(b - home));
119
+ for (let top = grid.length - SUN_ROWS; top >= 0; top -= 1) {
120
+ const at = spots.find((x) => [0, 1, 2].every((i) => free(top + i, x - 2, x + SUN_W + 2)));
121
+ if (at !== undefined) return { grid, width, at, top, sea: top + 2 };
161
122
  }
162
- return { ends, width, at, top, sea: top === null ? rows.length - 1 : top + 2 };
123
+ return { grid, width, at: home, top: null, sea: grid.length - 1 };
163
124
  }
164
125
 
165
126
  function seaCell(dx, s, stops) {
@@ -173,11 +134,11 @@ function seaCell(dx, s, stops) {
173
134
  }
174
135
 
175
136
  /**
176
- * The scene for one moment: a Map from row index to that row's cells, `width` long and holey; the cells before the
177
- * row's end are always empty. `look` is sunset, turn (amber) or rainbow; `dim` is the resting card's quieter light.
137
+ * The scene for one moment: a Map from row index to that row's cells, `width` long and holey, and holey wherever the
138
+ * grid holds text. `look` is sunset, turn (amber) or rainbow; `dim` is the resting card's quieter light.
178
139
  */
179
140
  export function paint(spot, { t = null, look = 'sunset', dim = false } = {}) {
180
- const { ends, width, at, top, sea } = spot;
141
+ const { grid, width, at, top, sea } = spot;
181
142
  const out = new Map();
182
143
  if (top === null && (t === null || sea < 0)) return out;
183
144
  const s = t ?? 0;
@@ -188,7 +149,11 @@ export function paint(spot, { t = null, look = 'sunset', dim = false } = {}) {
188
149
  if (!out.has(r)) out.set(r, new Array(width).fill(null));
189
150
  return out.get(r);
190
151
  };
191
- const clear = (r, x) => x >= 0 && x < width && x - ends[r] >= CLEAR;
152
+ const clear = (r, x) => {
153
+ if (x < 0 || x >= width) return false;
154
+ for (let d = -CLEAR + 1; d < CLEAR; d += 1) if (grid[r][x + d]) return false;
155
+ return true;
156
+ };
192
157
  const mid = at + SUN_W / 2 - 0.5;
193
158
  if (top !== null) {
194
159
  for (const [r, dx] of STARS) {
@@ -219,14 +184,3 @@ export function paint(spot, { t = null, look = 'sunset', dim = false } = {}) {
219
184
  }
220
185
  return out;
221
186
  }
222
-
223
- // Rows with the scene painted after their words; a row the scene does not reach is returned as it came.
224
- export function paintRows(rows, width, options) {
225
- const spot = place(rows, width);
226
- const tails = paint(spot, options);
227
- return rows.map((text, r) => {
228
- const cells = tails.get(r)?.slice(spot.ends[r]);
229
- const last = cells ? cells.findLastIndex(Boolean) : -1;
230
- return last < 0 ? text : text + ink(cells.slice(0, last + 1));
231
- });
232
- }
package/lib/uninstall.mjs CHANGED
@@ -5,20 +5,31 @@ import { stageState } from './bundle.mjs';
5
5
  import { assertSafeWritePath } from './guard.mjs';
6
6
  import { removeAgentFile } from './agent-file.mjs';
7
7
  import { packageVersion } from './bundle.mjs';
8
+ import { planRows } from './install-cards.mjs';
9
+ import { ownedIconFont, removeIconFont } from './icon-font.mjs';
8
10
 
9
- export async function uninstall({ env = process.env, flags = {}, interactive = false, print = console.log }) {
11
+ export async function uninstall({ env = process.env, flags = {}, interactive = false, print = console.log, cards = null, font: { platform } = {} }) {
10
12
  const p = paths(env);
11
13
  const plugin = installedPlugin(env);
12
14
  const st = stageState(p);
13
- print('LitMuse uninstall');
14
- print(` muse plugin ${plugin ? 'muse plugins remove litmuse (also clears its approvals)' : 'not installed in Muse'}`);
15
+ const pluginLine = plugin ? 'muse plugins remove litmuse (also clears its approvals)' : 'not installed in Muse';
15
16
  const discard = st.state === 'modified' && flags.discardModified;
16
17
  const bundleLine = st.state === 'owned' || discard
17
18
  ? `remove ${p.stage}${discard ? ` (discarding edits: ${st.detail})` : ''}`
18
19
  : st.state === 'absent' ? 'absent' : `keep ${p.stage} (${st.state}: ${st.detail})`;
19
- print(` bundle ${bundleLine}`);
20
- if (st.state === 'modified' && !discard) print(' hint add --discard-modified to remove the edited bundle too');
21
- print(` kept ${p.backups} and ${p.receipt}`);
20
+ const font = ownedIconFont({ env, platform });
21
+ const plan = [
22
+ ['muse plugin', pluginLine],
23
+ ['bundle', bundleLine],
24
+ ...(st.state === 'modified' && !discard ? [['hint', 'add --discard-modified to remove the edited bundle too']] : []),
25
+ ...(font.remove.length ? [['icon font', `remove ${font.remove.join(', ')}`]] : []),
26
+ ['kept', `${p.backups} and ${p.receipt}`],
27
+ ];
28
+ if (cards) cards.panel({ title: 'LitMuse uninstall', sections: [{ rows: planRows(plan.map(([label, value]) => [label[0].toUpperCase() + label.slice(1), value])) }] });
29
+ else {
30
+ print('LitMuse uninstall');
31
+ for (const [label, value] of plan) print(` ${label.padEnd(14)}${value}`);
32
+ }
22
33
  if (flags.dryRun) {
23
34
  print(removeAgentFile({ env, version: packageVersion(), dryRun: true }));
24
35
  print('Dry run: nothing removed.');
@@ -31,16 +42,36 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
31
42
  if (plugin) {
32
43
  const r = muse(env, ['plugins', 'remove', 'litmuse', '--json']);
33
44
  if (!r.ok) {
34
- print(`FAIL ${r.command}: ${(r.stderr || r.stdout).trim().split(/\r?\n/)[0]}`);
45
+ const why = `${r.command}: ${(r.stderr || r.stdout).trim().split(/\r?\n/)[0]}`;
46
+ if (cards) cards.row('fail', 'Muse plugin', why);
47
+ else print(`FAIL ${why}`);
35
48
  return 1;
36
49
  }
37
- print('Removed the LitMuse plugin from Muse.');
50
+ if (cards) cards.row('done', 'Muse plugin', 'removed from Muse');
51
+ else print('Removed the LitMuse plugin from Muse.');
38
52
  }
39
53
  if (st.state === 'owned' || discard) {
40
54
  rmSync(assertSafeWritePath(p.stage), { recursive: true, force: true });
41
- print(`Removed ${p.stage}.`);
55
+ if (cards) cards.row('done', 'Bundle', `removed ${p.stage}`);
56
+ else print(`Removed ${p.stage}.`);
57
+ }
58
+ const gone = removeIconFont({ env, platform });
59
+ const fontLines = [
60
+ ...(gone.remove.length ? [`removed ${gone.remove.join(', ')}; other products may draw square ends until an icon font is installed again`] : []),
61
+ ...(gone.keep.length ? [`kept ${gone.keep.join(', ')} (the file changed, or its folder is now a link)`] : []),
62
+ ];
63
+ for (const line of fontLines) {
64
+ if (cards) cards.row('done', 'Icon font', line);
65
+ else print(`Icon font: ${line}.`);
66
+ }
67
+ const rules = removeAgentFile({ env, version: packageVersion() });
68
+ const stays = 'Project files LitMuse sessions wrote (plans/, .litmuse/) stay in each project.';
69
+ if (cards) {
70
+ cards.row(/refused/.test(rules) ? 'warn' : 'done', 'Rules file', rules.replace('AGENT_FILE: ', ''));
71
+ cards.panel({ title: 'LitMuse uninstall is done', sections: [{ rows: [{ value: stays }] }] });
72
+ } else {
73
+ print(rules);
74
+ print(stays);
42
75
  }
43
- print(removeAgentFile({ env, version: packageVersion() }));
44
- print('Project files LitMuse sessions wrote (plans/, .litmuse/) stay in each project.');
45
76
  return 0;
46
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litfamily/litmuse",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Installer for LitMuse: skills, hooks and agents that help Meta's Muse Code plan, build, check and hand off work.",
5
5
  "keywords": [
6
6
  "muse",
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "name": "litmuse",
4
4
  "displayName": "LitMuse",
5
- "version": "0.1.20",
5
+ "version": "0.1.22",
6
6
  "description": "LitFamily workflows for Muse Code: bare lit activation, planning, evidence-bound execution, review, research, handoff and Korean prose care.",
7
7
  "compat": {
8
8
  "source": "native",