@litfamily/litmuse 0.1.21 → 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 +9 -0
- package/README.md +41 -15
- package/README_ko-KR.md +41 -15
- package/bin/litmuse.mjs +17 -33
- package/lib/agent-file.mjs +2 -11
- package/lib/agent-guide.mjs +71 -0
- package/lib/config.mjs +18 -0
- package/lib/doctor.mjs +3 -1
- package/lib/flags.mjs +35 -0
- package/lib/glyphs.mjs +55 -7
- package/lib/guard.mjs +38 -1
- package/lib/icon-font.mjs +198 -0
- package/lib/install-cards.mjs +8 -3
- package/lib/install.mjs +39 -8
- package/lib/paths.mjs +4 -1
- package/lib/safe-write.mjs +1 -1
- package/lib/uninstall.mjs +13 -1
- package/package.json +1 -1
- package/plugin/.muse-plugin/plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.22 — 2026-11-26
|
|
4
|
+
|
|
5
|
+
- `litmuse install --agent` (or `--agent`) prints an install guide for coding agents. It writes nothing, starts nothing and needs no Muse. `--help`, the first line of an install without a person, and the plan card point to it; the README prompts carry the same steps.
|
|
6
|
+
- `install --yes` never waits for an answer, at a terminal too. Approvals stay with you: the commands are printed, and only `--approve` approves without a question.
|
|
7
|
+
- An unknown flag, a missing value or a wrong value ends the run with exit code 2 before anything is written.
|
|
8
|
+
- `install --round` adds the symbols-only Nerd Font to your own font folder when no icon font is here (macOS, Linux). `--glyphs auto|round|square` saves the ends of pills and gauges; `round` holds over SSH. `LITMUSE_GLYPHS` takes `auto` too and still wins. `uninstall` removes the font files LitMuse added and left unchanged.
|
|
9
|
+
- `install`, `update` and `doctor` end with one `ROUND_ENDS:` line (`shown`, `ready`, `check` or `square` with a reason and a fix), and the install says to restart Muse.
|
|
10
|
+
- No hook or context file changed, so Muse asks for no new hook approval.
|
|
11
|
+
|
|
3
12
|
## 0.1.21 — 2026-11-25
|
|
4
13
|
|
|
5
14
|
- `litmuse status --card` and `--watch` draw a framed card in a dark truecolor terminal of 64 columns or more (it was 90): workflow and state on the top edge, a stage map with the current stage as a pill, the plan or goal with a gauge and the next row, the tool that finished last, aligned rows for threads and child agents, skill chips, and context, git branch, plan file and time on the bottom edge. A part with no record is left out. The version moved from the pill to the bottom edge, and a finished plan shows `DONE ✓` there in place of the `✨` line. `--json`, a pipe, `NO_COLOR`, 256 or fewer colours, a light background and narrower terminals print what they did before.
|
package/README.md
CHANGED
|
@@ -171,7 +171,7 @@ The [Quick start](#quick-start) line installs LitMuse at user scope, so it is av
|
|
|
171
171
|
1. **Preview** shows every destination and writes nothing; `--dry-run` stops here.
|
|
172
172
|
2. **Stage** backs up the Muse files it is about to change and copies the plugin to `~/.local/share/litmuse/bundle`, LitMuse's own folder.
|
|
173
173
|
3. **Install in Muse** runs `muse plugins install` at user scope, and the `muse` CLI records the plugin in Muse's plugin store. Skills and commands work right away.
|
|
174
|
-
4. **Approve** covers the 21 capabilities (10 hooks, 11 agents) that Muse runs only after you approve them. The installer asks you once whether to approve them all and keeps your yes in Muse's settings; say no and it prints the `muse plugins approve ...` lines for later.
|
|
174
|
+
4. **Approve** covers the 21 capabilities (10 hooks, 11 agents) that Muse runs only after you approve them. The installer asks you once whether to approve them all and keeps your yes in Muse's settings; say no, or run with `--yes`, and it prints the `muse plugins approve ...` lines for later.
|
|
175
175
|
|
|
176
176
|
The bottom row of the picture covers why an update may ask again, what install leaves alone, and the one file it writes only after you agree ([the rules-file block](./docs/reference.md#a-short-block-in-muses-own-rules-file)). Muse re-arms the agent approvals whenever the plugin is updated, so after an update the installer asks once more for those. In `doctor`, each capability that still waits for approval appears as `APPROVAL NEEDED` together with the exact command.
|
|
177
177
|
|
|
@@ -183,9 +183,14 @@ In a terminal window of at least 40 columns and 12 rows, the plan, the questions
|
|
|
183
183
|
<summary>Install switches</summary>
|
|
184
184
|
|
|
185
185
|
- **`--dry-run`** previews and writes nothing.
|
|
186
|
-
- **`--yes`**
|
|
186
|
+
- **`--yes`** installs without a question, for an agent or a CI shell; a shell without a terminal otherwise only previews. The rules-file block goes in (`--no-agent-file` leaves it out of that run, and `config agentFile off` keeps it out), and the approvals stay yours: their commands are printed.
|
|
187
187
|
- **`--approve`** approves the capabilities without the question, for scripts.
|
|
188
188
|
- **`--scope project`** installs for one project.
|
|
189
|
+
- **`--round`** adds the icon font that holds the round ends when no icon font is here ([Round ends](#round-ends)).
|
|
190
|
+
- **`--glyphs auto|round|square`** saves the ends you want; a later plain install keeps the choice.
|
|
191
|
+
- **`--agent`** prints the install guide for coding agents and does nothing else.
|
|
192
|
+
|
|
193
|
+
A flag the installer does not know ends the run with exit code 2 before anything is written.
|
|
189
194
|
|
|
190
195
|
</details>
|
|
191
196
|
|
|
@@ -195,15 +200,29 @@ In a terminal window of at least 40 columns and 12 rows, the plan, the questions
|
|
|
195
200
|
Paste this into a coding agent opened in any folder:
|
|
196
201
|
|
|
197
202
|
```text
|
|
198
|
-
Install LitMuse, the LitFamily plugin for Meta's Muse Code.
|
|
199
|
-
Use only the official npm package @litfamily/litmuse
|
|
200
|
-
1. Check that Node.js 20
|
|
201
|
-
2. Preview: npx @litfamily/litmuse install --dry-run
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
Install LitMuse, the LitFamily plugin for Meta's Muse Code. "npx --yes @litfamily/litmuse@latest install --agent" prints these same steps.
|
|
204
|
+
Use only the official npm package @litfamily/litmuse; add no other source, and do not approve hooks, trust or sign-in for me.
|
|
205
|
+
1. Check that Node.js 20 or newer and muse are on PATH (muse --version).
|
|
206
|
+
2. Preview: npx --yes @litfamily/litmuse@latest install --dry-run --round
|
|
207
|
+
Show me what it would change.
|
|
208
|
+
3. Ask me, with the defaults:
|
|
209
|
+
- Keep every default? (yes)
|
|
210
|
+
- Add the short LitFamily block to Muse's user rules file? (yes; for no, add --no-agent-file to every install and update command below; it lasts one run)
|
|
211
|
+
- Approve the LitMuse hooks and agents? (no; I run the muse plugins approve commands myself)
|
|
212
|
+
- Install for every project? (yes; for the current project only, add --scope project)
|
|
213
|
+
- Round or square ends on the status card? (auto; or add --glyphs round or --glyphs square)
|
|
214
|
+
Tell me about the icon font: --round adds SymbolsNerdFontMono-Regular.ttf and its licence file to ~/Library/Fonts on macOS or ${XDG_DATA_HOME:-~/.local/share}/fonts on Linux, only when no icon font is here. On Windows it adds none.
|
|
215
|
+
Tell me what I will see: the status card. It needs no flag; I run npx --yes @litfamily/litmuse@latest status --card in my own terminal.
|
|
216
|
+
4. Wait for my yes, then install: npx --yes @litfamily/litmuse@latest install --yes --round
|
|
217
|
+
Later updates: npx --yes @litfamily/litmuse@latest update --yes --round
|
|
218
|
+
5. Check: the install must print a line that starts with ROUND_ENDS:. Then run npx --yes @litfamily/litmuse@latest doctor
|
|
219
|
+
It passes with "LitMuse doctor: PASS". Until I approve, "approvals needed" and exit code 1 are expected. A FAIL line is a failed step: show me the lines and stop.
|
|
220
|
+
6. Show me this and ask if both ends are round, in the terminal that will show the status card: LIT
|
|
221
|
+
Round: npx --yes @litfamily/litmuse@latest install --yes --glyphs round
|
|
222
|
+
Boxes or question marks: npx --yes @litfamily/litmuse@latest install --yes --glyphs square
|
|
223
|
+
For round ends I then set my terminal's own font to a full Nerd Font, or add Symbols Nerd Font Mono as its fallback font (iTerm2: Non-ASCII Font, VS Code: terminal.integrated.fontFamily, kitty: symbol_map). Terminal.app has no fallback setting, so it needs a full Nerd Font as its font.
|
|
224
|
+
Over SSH, on a phone, or no answer: leave it. Undo: npx --yes @litfamily/litmuse@latest install --yes --glyphs auto
|
|
225
|
+
7. Show me the "Written:" list, anything it refused, and the muse plugins approve commands it printed. Only I run those commands, quit Muse and start it again, sign in, and trust a folder or Git repository.
|
|
207
226
|
```
|
|
208
227
|
|
|
209
228
|
</details>
|
|
@@ -228,7 +247,7 @@ Ticking a row moves the count and the next-row pointer:
|
|
|
228
247
|
|
|
229
248
|
<p align="center"><img src="./docs/assets/card/after.webp" width="960" alt="The same card after row 1 is ticked: task 1/2 with a half-filled gauge, next 2. Write the tests." /></p>
|
|
230
249
|
|
|
231
|
-
Run in a terminal, `litmuse status --card` also puts the mark above the card. In the framed card a half-sunk sun with stars above it and a sea running out from it fills cells that hold no text; a card with no room for it grows a row or two. The sun is dim while no route runs, amber while the card waits for you, and rainbow during `lit-adhd`. Pills and gauges have round ends when your terminal or an installed icon font can draw them, and are square everywhere otherwise;
|
|
250
|
+
Run in a terminal, `litmuse status --card` also puts the mark above the card. In the framed card a half-sunk sun with stars above it and a sea running out from it fills cells that hold no text; a card with no room for it grows a row or two. The sun is dim while no route runs, amber while the card waits for you, and rainbow during `lit-adhd`. Pills and gauges have round ends when your terminal or an installed icon font can draw them, and are square everywhere otherwise; [Round ends](#round-ends) says how to choose. When `/lit-status` has the model run the card through its bash tool, or colour is off, the card keeps its plain `LIT ·` headline, and `--json` prints only the record.
|
|
232
251
|
|
|
233
252
|
To keep the card open beside your work, add `--watch`. It takes over the terminal and, while your Muse session is working, lets the sea flow, the stars twinkle and light run across the sun and the pills. When the session stops, or nothing has happened for 15 minutes, the picture holds still and only the words and times keep up. Press `q` or Ctrl+C and your terminal comes back as it was.
|
|
234
253
|
|
|
@@ -236,6 +255,12 @@ To keep the card open beside your work, add `--watch`. It takes over the termina
|
|
|
236
255
|
|
|
237
256
|
This runs in your own shell, in a second window or pane, because Muse draws no plugin text inside its screen. `LITMUSE_MOTION=off` keeps the scene and stops the motion; `NO_COLOR`, fewer colours, a light background, or under 64 columns show the plain card, kept up to date.
|
|
238
257
|
|
|
258
|
+
#### Round ends
|
|
259
|
+
|
|
260
|
+
The round ends are two icon-font characters, so they need a terminal that draws them or a font that holds them. `npx --yes @litfamily/litmuse@latest install --yes --round` adds the symbols-only Nerd Font (`SymbolsNerdFontMono-Regular.ttf` and its licence) to your own font folder, `~/Library/Fonts` on macOS or `${XDG_DATA_HOME:-~/.local/share}/fonts` on Linux, when no icon font is here. An installed font is no proof that your terminal uses it. Set the terminal's own font to a full Nerd Font, or add Symbols Nerd Font Mono as its fallback font (iTerm2: Non-ASCII Font, VS Code: `terminal.integrated.fontFamily`, kitty: `symbol_map`). Terminal.app has no fallback setting, so it needs a full Nerd Font as its font.
|
|
261
|
+
|
|
262
|
+
`install`, `update` and `doctor` end with one `ROUND_ENDS:` line: `shown` when you have confirmed the ends with `--glyphs round`, `ready` when the terminal draws them itself, `check` when an icon font is here and somebody has to look, and `square` with the reason and one fix. `--glyphs round` holds over SSH too, `--glyphs square` ends the boxes, and `--glyphs auto` goes back. `LITMUSE_GLYPHS` (`auto`, `round`, `square`) wins for one run.
|
|
263
|
+
|
|
239
264
|
The card reads the hook-kept state under `~/.local/state/litmuse/`, outside the project. How it lists other sessions is in [the reference](./docs/reference.md#the-live-record-behind-the-card).
|
|
240
265
|
|
|
241
266
|
### Automatic handoff
|
|
@@ -398,13 +423,13 @@ Route state lives outside the project, under `~/.local/state/litmuse/`, so no to
|
|
|
398
423
|
|
|
399
424
|
## Update and uninstall
|
|
400
425
|
|
|
401
|
-
To update, run the install line again. To remove everything, run `uninstall` (add `--dry-run` to preview); it takes the rules-file block out too, and
|
|
426
|
+
To update, run the install line again; the ends you chose stay. To remove everything, run `uninstall` (add `--dry-run` to preview); it takes the rules-file block out too, and the icon font when `--round` added it and it is unchanged (other products may then draw square ends). Plans and `.litmuse/` folders in your projects stay where they are.
|
|
402
427
|
|
|
403
428
|
| Task | Command |
|
|
404
429
|
| --- | --- |
|
|
405
430
|
| Install | `npx @litfamily/litmuse install` |
|
|
406
431
|
| Preview first | `npx @litfamily/litmuse install --dry-run` |
|
|
407
|
-
| Update | `npx @litfamily/litmuse
|
|
432
|
+
| Update | `npx @litfamily/litmuse@latest update` |
|
|
408
433
|
| Check | `npx @litfamily/litmuse doctor` |
|
|
409
434
|
| Remove | `npx @litfamily/litmuse uninstall` |
|
|
410
435
|
|
|
@@ -424,13 +449,14 @@ To update, run the install line again. To remove everything, run `uninstall` (ad
|
|
|
424
449
|
|
|
425
450
|
### Safety
|
|
426
451
|
|
|
427
|
-
The installer writes to `~/.local/share/litmuse/` and, through the `muse` CLI, to Muse's own plugin store and settings, and it writes nothing under `~/.claude` or `~/.codex`. Hooks fail open: if one breaks, your session continues.
|
|
452
|
+
The installer writes to `~/.local/share/litmuse/` and, through the `muse` CLI, to Muse's own plugin store and settings, and it writes nothing under `~/.claude` or `~/.codex`. Only `--round` writes elsewhere: the icon font and its licence, in your own font folder. Hooks fail open: if one breaks, your session continues.
|
|
428
453
|
|
|
429
454
|
<details>
|
|
430
455
|
<summary>Everything the installer and <code>extensions</code> write, back up and refuse</summary>
|
|
431
456
|
|
|
432
457
|
- **Backups first.** The installer backs up `~/.config/muse/settings.json` and Muse's `installed.json` first, and it reads Muse's credential file in no step. The one file it edits outside those is Muse's user rules file, and only inside its own marked block ([details](./docs/reference.md#a-short-block-in-muses-own-rules-file)).
|
|
433
458
|
- **Refusals.** It refuses to replace a bundle directory that is a symbolic link, holds someone else's files, or was edited after install.
|
|
459
|
+
- **The icon font.** `--round` writes `SymbolsNerdFontMono-Regular.ttf` and `SymbolsNerdFontMono-LICENSE.txt` and no other name. The archive and both files must match pinned SHA-256 values, an existing file is never replaced, a linked folder is refused, and `icon-font.json` in LitMuse's folder lists what was added. When any of this fails, the install still succeeds and says why.
|
|
434
460
|
- **Pinned by a test.** It writes nothing under `~/.claude` or `~/.codex`; a test pins that.
|
|
435
461
|
- **`extensions`** writes only when you add `--yes`, and then only three places: Muse's user skills (through `muse skills install` and `uninstall`), `~/.config/muse/extension-backups/`, and its own clone in `~/.cache/litmuse/extensions-src`. A linked folder in any of them stops it before the first change.
|
|
436
462
|
|
package/README_ko-KR.md
CHANGED
|
@@ -162,7 +162,7 @@ Muse 안에는 카드를 그릴 자리가 없어서 LitMuse의 카드는 둘째
|
|
|
162
162
|
1. **미리 보기**는 쓸 위치를 모두 보여 주고 아무것도 쓰지 않습니다. `--dry-run`이면 여기서 끝납니다.
|
|
163
163
|
2. **준비**는 바꿀 Muse 파일을 백업하고, 플러그인을 LitMuse 폴더인 `~/.local/share/litmuse/bundle`에 복사합니다.
|
|
164
164
|
3. **Muse에 설치**는 `muse plugins install`을 user 범위로 실행하고, `muse` CLI가 Muse 플러그인 저장소에 플러그인을 기록합니다. 스킬과 명령은 이때부터 바로 동작합니다.
|
|
165
|
-
4. **승인**은 Muse가 사용자 승인 뒤에만 실행하는 21개(훅 10, 에이전트 11)를 다룹니다. 설치기는 한 번에 승인할지 딱 한 번 묻고, 예라고 답하면 그 답이 Muse 설정에 남습니다. 아니라고
|
|
165
|
+
4. **승인**은 Muse가 사용자 승인 뒤에만 실행하는 21개(훅 10, 에이전트 11)를 다룹니다. 설치기는 한 번에 승인할지 딱 한 번 묻고, 예라고 답하면 그 답이 Muse 설정에 남습니다. 아니라고 답하거나 `--yes`로 실행하면 나중에 실행할 `muse plugins approve ...` 줄을 출력합니다.
|
|
166
166
|
|
|
167
167
|
그림의 맨 아래 줄은 업데이트 뒤에 다시 묻는 이유, 설치가 손대지 않는 곳, 동의를 받은 뒤에만 쓰는 파일 하나([규칙 파일 블록](./docs/reference_ko-KR.md#muse-자체-규칙-파일의-짧은-블록))를 정리했습니다. Muse는 플러그인이 업데이트될 때마다 에이전트 승인을 다시 요구하므로, 업데이트 뒤에는 설치기가 그 부분만 한 번 더 묻습니다. `doctor`에서는 아직 승인을 기다리는 항목이 `APPROVAL NEEDED`와 실행할 명령으로 표시됩니다.
|
|
168
168
|
|
|
@@ -174,9 +174,14 @@ Muse 안에는 카드를 그릴 자리가 없어서 LitMuse의 카드는 둘째
|
|
|
174
174
|
<summary>설치 옵션</summary>
|
|
175
175
|
|
|
176
176
|
- **`--dry-run`**: 미리 보기만 하고 아무것도 쓰지 않습니다.
|
|
177
|
-
- **`--yes`**:
|
|
177
|
+
- **`--yes`**: 에이전트나 CI 셸에서 질문 없이 설치합니다. 터미널이 없는 셸은 이 옵션이 없으면 미리 보기만 합니다. 규칙 파일 블록은 들어가고(`--no-agent-file`이면 그 실행에서만 빠지고, `config agentFile off`면 계속 빠짐), 승인은 사용자 몫으로 남아 명령만 출력됩니다.
|
|
178
178
|
- **`--approve`**: 질문 없이 승인까지 진행하는 스크립트용입니다.
|
|
179
179
|
- **`--scope project`**: 한 프로젝트에만 설치합니다.
|
|
180
|
+
- **`--round`**: 아이콘 글꼴이 없을 때 둥근 끝이 들어 있는 글꼴을 추가합니다([둥근 끝](#둥근-끝)).
|
|
181
|
+
- **`--glyphs auto|round|square`**: 원하는 끝 모양을 저장합니다. 나중에 그냥 설치해도 선택이 유지됩니다.
|
|
182
|
+
- **`--agent`**: 코딩 에이전트용 설치 안내만 출력하고 끝납니다.
|
|
183
|
+
|
|
184
|
+
설치기가 모르는 옵션이 있으면 아무것도 쓰지 않고 종료 코드 2로 끝납니다.
|
|
180
185
|
|
|
181
186
|
</details>
|
|
182
187
|
|
|
@@ -186,15 +191,29 @@ Muse 안에는 카드를 그릴 자리가 없어서 LitMuse의 카드는 둘째
|
|
|
186
191
|
아무 폴더에서 연 코딩 에이전트에 아래를 붙여 넣으세요.
|
|
187
192
|
|
|
188
193
|
```text
|
|
189
|
-
Meta Muse Code용 LitFamily 플러그인인 LitMuse를 설치해 줘.
|
|
190
|
-
공식 npm 패키지 @litfamily/litmuse만
|
|
191
|
-
1. Node.js 20 이상과 muse가 PATH에 있는지 확인해 (
|
|
192
|
-
2. 미리 보기: npx @litfamily/litmuse install --dry-run
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
Meta Muse Code용 LitFamily 플러그인인 LitMuse를 설치해 줘. "npx --yes @litfamily/litmuse@latest install --agent"를 실행하면 같은 단계가 나와.
|
|
195
|
+
공식 npm 패키지 @litfamily/litmuse만 쓰고 다른 출처는 더하지 마. 훅 승인, 신뢰, 로그인은 나 대신 하지 마.
|
|
196
|
+
1. Node.js 20 이상과 muse가 PATH에 있는지 확인해 (muse --version).
|
|
197
|
+
2. 미리 보기: npx --yes @litfamily/litmuse@latest install --dry-run --round
|
|
198
|
+
무엇이 바뀌는지 보여 줘.
|
|
199
|
+
3. 기본값과 함께 나에게 물어봐.
|
|
200
|
+
- 모두 기본값으로 할까? (예)
|
|
201
|
+
- Muse 사용자 규칙 파일에 짧은 LitFamily 블록을 넣을까? (예, 넣지 않으려면 아래의 모든 install, update 명령에 --no-agent-file 추가, 한 번의 실행에만 적용돼)
|
|
202
|
+
- LitMuse 훅과 에이전트를 승인할까? (아니요, muse plugins approve 명령은 내가 직접 실행해)
|
|
203
|
+
- 모든 프로젝트에 설치할까? (예, 지금 프로젝트에만 하려면 --scope project 추가)
|
|
204
|
+
- 상태 카드의 끝은 둥글게 할까, 네모로 할까? (auto, 정하려면 --glyphs round 또는 --glyphs square 추가)
|
|
205
|
+
아이콘 글꼴도 알려 줘: --round는 아이콘 글꼴이 없을 때만 SymbolsNerdFontMono-Regular.ttf와 라이선스 파일을 macOS는 ~/Library/Fonts, Linux는 ${XDG_DATA_HOME:-~/.local/share}/fonts 에 추가해. Windows에서는 추가하지 않아.
|
|
206
|
+
내가 보게 될 화면도 알려 줘: 상태 카드야. 옵션 없이 쓸 수 있고, 내 터미널에서 npx --yes @litfamily/litmuse@latest status --card 를 실행하면 돼.
|
|
207
|
+
4. 내가 좋다고 하면 설치: npx --yes @litfamily/litmuse@latest install --yes --round
|
|
208
|
+
나중에 업데이트: npx --yes @litfamily/litmuse@latest update --yes --round
|
|
209
|
+
5. 확인: 설치 출력에 ROUND_ENDS: 로 시작하는 줄이 있어야 해. 그다음 npx --yes @litfamily/litmuse@latest doctor 를 실행해.
|
|
210
|
+
"LitMuse doctor: PASS"면 통과야. 내가 승인하기 전에는 "approvals needed"와 종료 코드 1이 정상이야. FAIL로 시작하는 줄이 있으면 실패한 단계니까 그 줄을 보여 주고 멈춰.
|
|
211
|
+
6. 상태 카드를 볼 터미널에서 이것을 보여 주고 양쪽 끝이 둥근지 물어봐: LIT
|
|
212
|
+
둥글면: npx --yes @litfamily/litmuse@latest install --yes --glyphs round
|
|
213
|
+
네모 상자나 물음표면: npx --yes @litfamily/litmuse@latest install --yes --glyphs square
|
|
214
|
+
둥근 끝을 쓰려면 내가 터미널 글꼴을 전체 Nerd Font로 바꾸거나 Symbols Nerd Font Mono를 대체 글꼴로 추가할게 (iTerm2는 Non-ASCII Font, VS Code는 terminal.integrated.fontFamily, kitty는 symbol_map). Terminal.app에는 대체 글꼴 설정이 없어서 글꼴 자체를 전체 Nerd Font로 바꿔야 해.
|
|
215
|
+
SSH나 휴대폰이거나 답이 없으면 그대로 둬. 되돌리기: npx --yes @litfamily/litmuse@latest install --yes --glyphs auto
|
|
216
|
+
7. "Written:" 목록, 거부한 것, 출력된 muse plugins approve 명령을 보여 줘. 그 명령을 실행하고, Muse를 끄고 다시 시작하고, 로그인하고, 폴더나 Git 저장소를 신뢰하는 일은 나만 해.
|
|
198
217
|
```
|
|
199
218
|
|
|
200
219
|
</details>
|
|
@@ -219,7 +238,7 @@ Muse의 `/hud`는 켜고 끄는 고정 항목 목록이라서 플러그인 글
|
|
|
219
238
|
|
|
220
239
|
<p align="center"><img src="./docs/assets/card/after.webp" width="960" alt="1번 행을 체크한 뒤의 같은 카드. task 1/2 게이지가 반쯤 차고 다음 행은 2. Write the tests입니다." /></p>
|
|
221
240
|
|
|
222
|
-
터미널에서 `litmuse status --card`를 실행하면 카드 위에 마크도 붙습니다. 테두리 카드에서는 반쯤 잠긴 해와 그 위의 별, 해에서 퍼지는 바다가 글이 없는 칸을 채우고, 자리가 없으면 카드가 한두 줄 늘어납니다. 해는 활성 경로가 없으면 어둡고, 카드가 사용자를 기다리면 호박색, `lit-adhd` 때는 무지개색입니다. 터미널이나 설치된 아이콘 글꼴이 둥근 끝을 그릴 수 있으면 알약과 게이지가 모두 둥글고, 아니면 모두 네모입니다.
|
|
241
|
+
터미널에서 `litmuse status --card`를 실행하면 카드 위에 마크도 붙습니다. 테두리 카드에서는 반쯤 잠긴 해와 그 위의 별, 해에서 퍼지는 바다가 글이 없는 칸을 채우고, 자리가 없으면 카드가 한두 줄 늘어납니다. 해는 활성 경로가 없으면 어둡고, 카드가 사용자를 기다리면 호박색, `lit-adhd` 때는 무지개색입니다. 터미널이나 설치된 아이콘 글꼴이 둥근 끝을 그릴 수 있으면 알약과 게이지가 모두 둥글고, 아니면 모두 네모입니다. 고르는 방법은 [둥근 끝](#둥근-끝)에 있습니다. `/lit-status`가 모델의 bash 도구로 카드를 돌릴 때나 색이 꺼져 있을 때는 원래의 `LIT ·` 머리줄이 그대로 남고, `--json`은 기록만 출력합니다.
|
|
223
242
|
|
|
224
243
|
카드를 작업 옆에 계속 띄워 두려면 `--watch`를 붙입니다. 카드가 터미널을 차지하고, Muse 세션이 일하는 동안 바다가 흐르고 별이 반짝이고 해와 알약 위로 빛이 지나갑니다. 세션이 멈추거나 15분 동안 아무 일이 없으면 그림은 멈추고 글과 시간만 갱신됩니다. `q`나 Ctrl+C를 누르면 터미널이 원래대로 돌아옵니다.
|
|
225
244
|
|
|
@@ -227,6 +246,12 @@ Muse의 `/hud`는 켜고 끄는 고정 항목 목록이라서 플러그인 글
|
|
|
227
246
|
|
|
228
247
|
Muse는 자기 화면 안에 플러그인 글을 그리지 않으므로, 이 카드는 다른 창이나 분할 창에 연 셸에서 실행합니다. `LITMUSE_MOTION=off`면 장면은 그대로 두고 움직임만 멈춥니다. `NO_COLOR`, 색이 적은 터미널, 밝은 배경, 64칸 미만에서는 계속 갱신되는 일반 카드를 보여 줍니다.
|
|
229
248
|
|
|
249
|
+
#### 둥근 끝
|
|
250
|
+
|
|
251
|
+
둥근 끝은 아이콘 글꼴 글자 두 개라서, 직접 그려 주는 터미널이나 그 글자가 있는 글꼴이 필요합니다. `npx --yes @litfamily/litmuse@latest install --yes --round`는 아이콘 글꼴이 없을 때 기호 전용 Nerd Font(`SymbolsNerdFontMono-Regular.ttf`와 라이선스)를 사용자 글꼴 폴더에 추가합니다. macOS는 `~/Library/Fonts`, Linux는 `${XDG_DATA_HOME:-~/.local/share}/fonts`입니다. 글꼴이 설치됐다고 터미널이 그 글꼴을 쓰는 것은 아닙니다. 터미널 글꼴을 전체 Nerd Font로 바꾸거나 Symbols Nerd Font Mono를 대체 글꼴로 추가하세요(iTerm2는 Non-ASCII Font, VS Code는 `terminal.integrated.fontFamily`, kitty는 `symbol_map`). Terminal.app에는 대체 글꼴 설정이 없어 글꼴 자체를 전체 Nerd Font로 바꿔야 합니다.
|
|
252
|
+
|
|
253
|
+
`install`, `update`, `doctor`는 `ROUND_ENDS:` 한 줄로 끝납니다. `shown`은 `--glyphs round`로 둥근 끝을 확인한 상태, `ready`는 터미널이 직접 그리는 상태, `check`는 아이콘 글꼴이 있어서 눈으로 확인할 차례인 상태이고, `square`에는 이유와 해결 방법 하나가 붙습니다. `--glyphs round`는 SSH에서도 유지되고, 네모 상자가 보이면 `--glyphs square`, 되돌리려면 `--glyphs auto`를 씁니다. `LITMUSE_GLYPHS`(`auto`, `round`, `square`)는 그 실행에서 가장 먼저 적용됩니다.
|
|
254
|
+
|
|
230
255
|
카드는 프로젝트 밖에 있는 `~/.local/state/litmuse/` 아래 훅 기록을 읽습니다. 다른 세션을 어떻게 보여 주는지는 [참고 자료](./docs/reference_ko-KR.md#카드-뒤의-실시간-기록)에 있습니다.
|
|
231
256
|
|
|
232
257
|
### 자동 핸드오프
|
|
@@ -389,13 +414,13 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
|
|
|
389
414
|
|
|
390
415
|
## 업데이트와 제거
|
|
391
416
|
|
|
392
|
-
업데이트하려면 설치 명령을 다시 실행하세요. 전부 지우려면 `uninstall`을 실행하고(미리 보려면 `--dry-run`), 규칙 파일의 블록도 함께 빠집니다. 프로젝트 안의 계획과 `.litmuse/` 폴더는 그대로 남습니다.
|
|
417
|
+
업데이트하려면 설치 명령을 다시 실행하세요. 고른 끝 모양은 유지됩니다. 전부 지우려면 `uninstall`을 실행하고(미리 보려면 `--dry-run`), 규칙 파일의 블록도 함께 빠집니다. `--round`로 추가한 아이콘 글꼴도 그대로라면 지워지며, 그러면 다른 제품의 끝이 네모로 보일 수 있습니다. 프로젝트 안의 계획과 `.litmuse/` 폴더는 그대로 남습니다.
|
|
393
418
|
|
|
394
419
|
| 작업 | 명령 |
|
|
395
420
|
| --- | --- |
|
|
396
421
|
| 설치 | `npx @litfamily/litmuse install` |
|
|
397
422
|
| 미리 보기 | `npx @litfamily/litmuse install --dry-run` |
|
|
398
|
-
| 업데이트 | `npx @litfamily/litmuse
|
|
423
|
+
| 업데이트 | `npx @litfamily/litmuse@latest update` |
|
|
399
424
|
| 확인 | `npx @litfamily/litmuse doctor` |
|
|
400
425
|
| 제거 | `npx @litfamily/litmuse uninstall` |
|
|
401
426
|
|
|
@@ -415,13 +440,14 @@ npx @litfamily/litmuse extensions prune-backups --older-than 30 --yes
|
|
|
415
440
|
|
|
416
441
|
### 안전
|
|
417
442
|
|
|
418
|
-
설치기는 `~/.local/share/litmuse/`에 쓰고, `muse` CLI를 거쳐 Muse의 플러그인 저장소와 설정에 쓰며, `~/.claude`와 `~/.codex` 아래에는 아무것도 쓰지 않습니다. 훅은 실패해도 세션을 막지 않고 그대로 통과시킵니다.
|
|
443
|
+
설치기는 `~/.local/share/litmuse/`에 쓰고, `muse` CLI를 거쳐 Muse의 플러그인 저장소와 설정에 쓰며, `~/.claude`와 `~/.codex` 아래에는 아무것도 쓰지 않습니다. 이 밖에는 `--round`일 때만 사용자 글꼴 폴더에 아이콘 글꼴과 라이선스를 씁니다. 훅은 실패해도 세션을 막지 않고 그대로 통과시킵니다.
|
|
419
444
|
|
|
420
445
|
<details>
|
|
421
446
|
<summary>설치기와 <code>extensions</code>가 쓰고, 백업하고, 거부하는 것</summary>
|
|
422
447
|
|
|
423
448
|
- **먼저 백업.** 설치기는 `~/.config/muse/settings.json`과 Muse의 `installed.json`을 먼저 백업하며, Muse 인증 파일은 열어 보지 않습니다. 이 밖에 손대는 파일은 Muse의 사용자 규칙 파일 하나뿐이고, 그것도 표시된 자기 블록 안에서만 씁니다([자세히](./docs/reference_ko-KR.md#muse-자체-규칙-파일의-짧은-블록)).
|
|
424
449
|
- **거부.** 번들 폴더가 심볼릭 링크이거나, 다른 사람의 파일이 들어 있거나, 설치 후 수정되었으면 교체를 거부합니다.
|
|
450
|
+
- **아이콘 글꼴.** `--round`는 `SymbolsNerdFontMono-Regular.ttf`와 `SymbolsNerdFontMono-LICENSE.txt`만 씁니다. 압축 파일과 두 파일은 고정된 SHA-256과 같아야 하고, 이미 있는 파일은 바꾸지 않으며, 링크된 폴더는 거부합니다. 추가한 파일은 LitMuse 폴더의 `icon-font.json`에 적힙니다. 어디서 실패하든 설치는 성공하고 이유를 알려 줍니다.
|
|
425
451
|
- **테스트로 고정.** `~/.claude`와 `~/.codex` 아래에는 아무것도 쓰지 않으며, 테스트가 이를 고정합니다.
|
|
426
452
|
- **`extensions`**는 `--yes`를 붙였을 때만 쓰고, 그때도 세 곳에만 씁니다. Muse 사용자 스킬(`muse skills install`과 `uninstall`을 거쳐), `~/.config/muse/extension-backups/`, 그리고 `~/.cache/litmuse/extensions-src`의 자기 클론입니다. 이 중 어느 곳이든 링크된 폴더면 첫 변경 전에 멈춥니다.
|
|
427
453
|
|
package/bin/litmuse.mjs
CHANGED
|
@@ -18,13 +18,17 @@ import { runRewindCli } from '../plugin/lib/rewind/collect.mjs';
|
|
|
18
18
|
import { extensionsCommand } from '../lib/extensions.mjs';
|
|
19
19
|
import { markFor } from '../lib/mark.mjs';
|
|
20
20
|
import { cardsFor } from '../lib/install-cards.mjs';
|
|
21
|
+
import { AGENT_LINE, agentGuide } from '../lib/agent-guide.mjs';
|
|
22
|
+
import { NPX, parse } from '../lib/flags.mjs';
|
|
21
23
|
|
|
22
24
|
const HELP = `LitMuse ${packageVersion()}: LitFamily workflows for Meta's Muse Code
|
|
23
25
|
|
|
24
26
|
Usage: litmuse <command> [options]
|
|
27
|
+
Are you an agent? Run ${NPX} install --agent
|
|
25
28
|
|
|
26
29
|
Commands
|
|
27
30
|
install Stage the plugin, install it into Muse at user scope, and offer the approvals
|
|
31
|
+
update The same as install; your saved choices stay
|
|
28
32
|
doctor Check install state, every approval, skill enrollment, catalog bytes and overlaps
|
|
29
33
|
status Short version of doctor plus an update check; --card shows the live LIT card for this folder
|
|
30
34
|
(add --watch to keep it open; q or Ctrl+C leaves)
|
|
@@ -43,6 +47,9 @@ Options
|
|
|
43
47
|
--yes, -y Allow writes from a shell without a terminal (agents, CI)
|
|
44
48
|
--approve Approve the hooks and agents without asking (for scripts)
|
|
45
49
|
--scope <s> Muse install scope: user (default) or project
|
|
50
|
+
--agent Print the install guide for coding agents and stop
|
|
51
|
+
--round install, update: add the icon font for round ends when no icon font is here (macOS, Linux)
|
|
52
|
+
--glyphs <g> install, update: save the ends of pills and gauges: auto (default), round or square
|
|
46
53
|
--json Machine-readable output (doctor, models)
|
|
47
54
|
--no-agent-file install: leave Muse's user rules file alone for this run
|
|
48
55
|
--offline Skip the npm update check
|
|
@@ -50,33 +57,6 @@ Options
|
|
|
50
57
|
--from <p> extensions: use this wjgoarxiv-skills clone instead of LitMuse's cached one
|
|
51
58
|
--version Print the version`;
|
|
52
59
|
|
|
53
|
-
function parse(argv) {
|
|
54
|
-
const flags = {};
|
|
55
|
-
const rest = [];
|
|
56
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
57
|
-
const a = argv[i];
|
|
58
|
-
if (a === '--dry-run') flags.dryRun = true;
|
|
59
|
-
else if (a === '--yes' || a === '-y') flags.yes = true;
|
|
60
|
-
else if (a === '--approve') flags.approve = true;
|
|
61
|
-
else if (a === '--json') flags.json = true;
|
|
62
|
-
else if (a === '--offline') flags.offline = true;
|
|
63
|
-
else if (a === '--no-agent-file') flags.noAgentFile = true;
|
|
64
|
-
else if (a === '--discard-modified') flags.discardModified = true;
|
|
65
|
-
else if (a === '--card') flags.card = true;
|
|
66
|
-
else if (a === '--watch') flags.watch = true;
|
|
67
|
-
else if (a === '--scope') flags.scope = argv[++i];
|
|
68
|
-
else if (a === '--from') flags.from = argv[++i];
|
|
69
|
-
else if (a === '--family') flags.family = argv[++i];
|
|
70
|
-
else if (a === '--older-than') flags.olderThan = argv[++i];
|
|
71
|
-
else if (a === '--all') flags.all = true;
|
|
72
|
-
else if (a === '--allow-shadow') flags.allowShadow = true;
|
|
73
|
-
else if (a === '--help' || a === '-h') flags.help = true;
|
|
74
|
-
else if (a === '--version' || a === '-v') flags.version = true;
|
|
75
|
-
else rest.push(a);
|
|
76
|
-
}
|
|
77
|
-
return { command: rest[0] ?? 'help', args: rest.slice(1), flags };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
60
|
async function ask(question, { defaultYes = false } = {}) {
|
|
81
61
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
82
62
|
try {
|
|
@@ -88,10 +68,18 @@ async function ask(question, { defaultYes = false } = {}) {
|
|
|
88
68
|
}
|
|
89
69
|
|
|
90
70
|
async function main() {
|
|
91
|
-
const { command, args, flags } = parse(process.argv.slice(2));
|
|
71
|
+
const { command, args, flags, problem } = parse(process.argv.slice(2));
|
|
72
|
+
if (flags.agent) {
|
|
73
|
+
process.stdout.write(agentGuide());
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
92
76
|
const env = process.env;
|
|
93
77
|
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY && !env.CI);
|
|
94
78
|
const print = (line) => process.stdout.write(`${line}\n`);
|
|
79
|
+
if (problem) {
|
|
80
|
+
print(`${problem} Run litmuse --help for the list.`);
|
|
81
|
+
return 2;
|
|
82
|
+
}
|
|
95
83
|
if (flags.version) {
|
|
96
84
|
print(packageVersion());
|
|
97
85
|
return 0;
|
|
@@ -102,15 +90,11 @@ async function main() {
|
|
|
102
90
|
print(HELP);
|
|
103
91
|
return 0;
|
|
104
92
|
}
|
|
105
|
-
if (flags.scope && !['user', 'project'].includes(flags.scope)) {
|
|
106
|
-
print('--scope takes user or project');
|
|
107
|
-
return 2;
|
|
108
|
-
}
|
|
109
93
|
switch (command) {
|
|
110
94
|
case 'install':
|
|
111
95
|
case 'update': {
|
|
112
96
|
const cards = cardsFor({ env, flags });
|
|
113
|
-
if (!cards) print(markFor({ env }));
|
|
97
|
+
if (!cards) print(interactive || flags.json ? markFor({ env }) : `${markFor({ env })}${AGENT_LINE}\n`);
|
|
114
98
|
return install({ env, flags, interactive, ask: cards?.ask ?? ask, print, cards });
|
|
115
99
|
}
|
|
116
100
|
case 'uninstall':
|
package/lib/agent-file.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chmodSync, lstatSync, readdirSync, readFileSync, statSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { readConfig, writeConfig } from './config.mjs';
|
|
4
5
|
import { paths } from './paths.mjs';
|
|
5
6
|
import { packageVersion } from './bundle.mjs';
|
|
6
7
|
import { writeFileAtomic, copyFileAtomic } from './safe-write.mjs';
|
|
@@ -31,16 +32,6 @@ const CARD = {
|
|
|
31
32
|
|
|
32
33
|
export const agentFileBody = () => readFileSync(BLOCK_FILE, 'utf8');
|
|
33
34
|
|
|
34
|
-
function readConfig(env) {
|
|
35
|
-
try {
|
|
36
|
-
const file = paths(env).config;
|
|
37
|
-
if (lstatSync(file).isSymbolicLink()) return {};
|
|
38
|
-
return JSON.parse(readFileSync(file, 'utf8')) ?? {};
|
|
39
|
-
} catch {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
35
|
/** `{mode, stored}`: `mode` is what acts (LITMUSE_AGENT_FILE, else the stored value, else on); `stored` is only what the user chose. */
|
|
45
36
|
export function readAgentFileSetting(env = process.env) {
|
|
46
37
|
const stored = readConfig(env).agentFile;
|
|
@@ -51,7 +42,7 @@ export function readAgentFileSetting(env = process.env) {
|
|
|
51
42
|
|
|
52
43
|
export function writeAgentFileSetting(env, mode) {
|
|
53
44
|
if (!AGENT_FILE_MODES.includes(mode)) throw new Error(`agentFile takes one of: ${AGENT_FILE_MODES.join(', ')}`);
|
|
54
|
-
|
|
45
|
+
writeConfig(env, { agentFile: mode });
|
|
55
46
|
}
|
|
56
47
|
|
|
57
48
|
// 'missing', 'file', 'symlink' or 'other', without following a link.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// `litmuse install --agent`: the install guide a coding agent follows and its user can read. Plain text, the same bytes
|
|
2
|
+
// everywhere; printing it reads no setting and starts nothing. The READMEs carry the same steps as a prompt, and
|
|
3
|
+
// test/agent-guide.test.mjs binds the guide, the parser, the installer's questions and both prompts.
|
|
4
|
+
import { CAP_LEFT, CAP_RIGHT } from './glyphs.mjs';
|
|
5
|
+
import { FONT_FILES } from './guard.mjs';
|
|
6
|
+
import { NPX } from './flags.mjs';
|
|
7
|
+
|
|
8
|
+
export const AGENT_LINE = `Agent? See ${NPX} install --agent.`;
|
|
9
|
+
// For a card too narrow for the line above.
|
|
10
|
+
export const AGENT_LINE_SHORT = 'Agent? See install --agent.';
|
|
11
|
+
export const PILL = `${CAP_LEFT} LIT ${CAP_RIGHT}`;
|
|
12
|
+
|
|
13
|
+
export const COMMANDS = Object.freeze({
|
|
14
|
+
preview: `${NPX} install --dry-run --round`,
|
|
15
|
+
install: `${NPX} install --yes --round`,
|
|
16
|
+
update: `${NPX} update --yes --round`,
|
|
17
|
+
doctor: `${NPX} doctor`,
|
|
18
|
+
card: `${NPX} status --card`,
|
|
19
|
+
round: `${NPX} install --yes --glyphs round`,
|
|
20
|
+
square: `${NPX} install --yes --glyphs square`,
|
|
21
|
+
auto: `${NPX} install --yes --glyphs auto`,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// `card` is the title of the installer's own question card; the last two are choices the installer takes as flags only.
|
|
25
|
+
export const QUESTIONS = Object.freeze([
|
|
26
|
+
{ card: 'Rules file', ask: "Add the short LitFamily block to Muse's user rules file?", base: 'yes', other: 'For no, add --no-agent-file to every install and update command below; it lasts one run.', flag: '--no-agent-file' },
|
|
27
|
+
{ card: 'Approvals', ask: 'Approve the LitMuse hooks and agents?', base: 'no', other: 'Your user can choose it later with the "muse plugins approve" commands the install prints.' },
|
|
28
|
+
{ ask: 'Install for every project (user scope)?', base: 'yes', other: 'For the current project only, add --scope project to the install line.', flag: '--scope project' },
|
|
29
|
+
{ ask: 'Round or square ends on the status card?', base: 'auto', other: 'Add --glyphs round or --glyphs square; step 7 asks this again with a picture.', flag: '--glyphs round' },
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export const agentGuide = () => `LitMuse install guide for coding agents
|
|
33
|
+
|
|
34
|
+
If you are a coding agent and your user asked you to install LitMuse, follow these steps. They are written for your user to read too.
|
|
35
|
+
|
|
36
|
+
1. Preview. LitMuse needs Node.js 20 or newer and Muse Code ("muse --version").
|
|
37
|
+
${COMMANDS.preview}
|
|
38
|
+
Show your user what it would change.
|
|
39
|
+
|
|
40
|
+
2. Ask. Show your user these questions and their defaults.
|
|
41
|
+
- Keep every default? Default: yes.
|
|
42
|
+
${QUESTIONS.map((q) => ` - ${q.ask} Default: ${q.base}. ${q.other}`).join('\n')}
|
|
43
|
+
- Icon font: --round adds ${FONT_FILES.font} and its licence file (${FONT_FILES.license}) to ~/Library/Fonts on macOS or \${XDG_DATA_HOME:-~/.local/share}/fonts on Linux, only when no icon font is here. On Windows it adds none.
|
|
44
|
+
- What your user will see: the status card. It needs no flag: your user runs "${COMMANDS.card}" in their own terminal, with --watch to keep it open.
|
|
45
|
+
|
|
46
|
+
3. Wait for your user's yes. Use only this package; add no other source, and do not approve hooks, trust or sign-in for your user.
|
|
47
|
+
|
|
48
|
+
4. Install.
|
|
49
|
+
${COMMANDS.install}
|
|
50
|
+
|
|
51
|
+
5. Update, later.
|
|
52
|
+
${COMMANDS.update}
|
|
53
|
+
|
|
54
|
+
6. Check. The install must print a line that starts with ROUND_ENDS:. Then run
|
|
55
|
+
${COMMANDS.doctor}
|
|
56
|
+
It passes with "LitMuse doctor: PASS". Until your user approves the hooks and agents it says "LitMuse: installed, <n> approvals needed" and exits 1; that is expected. A line that starts with FAIL is a failed step.
|
|
57
|
+
If a step fails, show your user the lines and stop.
|
|
58
|
+
|
|
59
|
+
7. Rounded ends. Show your user this and ask if both ends are round: ${PILL}
|
|
60
|
+
Ask for an answer from the terminal that will show the status card.
|
|
61
|
+
- Round: ${COMMANDS.round}
|
|
62
|
+
- Boxes or question marks: ${COMMANDS.square}
|
|
63
|
+
An installed symbols font alone is no proof that a terminal uses it. For round ends your user sets the terminal's own font to a full Nerd Font, or adds Symbols Nerd Font Mono as its fallback font (iTerm2: Non-ASCII Font, VS Code: terminal.integrated.fontFamily, kitty: symbol_map). Terminal.app has no fallback setting, so it needs a full Nerd Font as its font.
|
|
64
|
+
- Over SSH, on a phone, or no answer: leave it.
|
|
65
|
+
- Undo: ${COMMANDS.auto}
|
|
66
|
+
|
|
67
|
+
8. Only your user can
|
|
68
|
+
- approve: run the "muse plugins approve" commands the install printed, then run the doctor command again;
|
|
69
|
+
- restart: quit Muse if it is open and start it again;
|
|
70
|
+
- sign in to Muse, and trust a folder or Git repository when Muse or Git asks.
|
|
71
|
+
`;
|
package/lib/config.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { lstatSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { paths } from './paths.mjs';
|
|
3
|
+
import { writeFileAtomic } from './safe-write.mjs';
|
|
4
|
+
|
|
5
|
+
// LitMuse's own config.json: the rules-file choice (agentFile) and the round-ends choice (glyphs).
|
|
6
|
+
export function readConfig(env) {
|
|
7
|
+
try {
|
|
8
|
+
const file = paths(env).config;
|
|
9
|
+
if (lstatSync(file).isSymbolicLink()) return {};
|
|
10
|
+
return JSON.parse(readFileSync(file, 'utf8')) ?? {};
|
|
11
|
+
} catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function writeConfig(env, patch) {
|
|
17
|
+
return writeFileAtomic(paths(env).config, `${JSON.stringify({ ...readConfig(env), ...patch }, null, 2)}\n`);
|
|
18
|
+
}
|
package/lib/doctor.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { approvalStates } from './approvals.mjs';
|
|
|
10
10
|
import { checkUpdate } from './update-check.mjs';
|
|
11
11
|
import { agentFileRow } from './agent-file.mjs';
|
|
12
12
|
import { survey, findings, CLI } from './extensions.mjs';
|
|
13
|
+
import { roundEndsLine } from './glyphs.mjs';
|
|
13
14
|
|
|
14
15
|
const CATALOG_CAP = 32 * 1024;
|
|
15
16
|
|
|
@@ -143,7 +144,7 @@ export async function doctor({ env = process.env, flags = {}, print = console.lo
|
|
|
143
144
|
const summary = fails
|
|
144
145
|
? `LitMuse doctor: FAIL (${fails} failing check${fails === 1 ? '' : 's'}${needed ? `, ${needed} approvals needed` : ''})`
|
|
145
146
|
: needed
|
|
146
|
-
? `LitMuse: installed, ${needed} approvals needed.
|
|
147
|
+
? `LitMuse: installed, ${needed} approvals needed. The person who uses Muse runs the commands above.`
|
|
147
148
|
: `LitMuse doctor: PASS${warns ? ` (${warns} warning${warns === 1 ? '' : 's'})` : ''}`;
|
|
148
149
|
|
|
149
150
|
if (flags.json) {
|
|
@@ -155,6 +156,7 @@ export async function doctor({ env = process.env, flags = {}, print = console.lo
|
|
|
155
156
|
}
|
|
156
157
|
print('');
|
|
157
158
|
print(summary);
|
|
159
|
+
print(roundEndsLine({ env, surface: Boolean(plugin) && plugin.enabled !== false && st.state !== 'absent' }));
|
|
158
160
|
}
|
|
159
161
|
return fails || needed ? 1 : 0;
|
|
160
162
|
}
|
package/lib/flags.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The command line: every flag LitMuse takes. Anything else that starts with a dash is refused, except for `rewind`,
|
|
2
|
+
// which reads its own flags.
|
|
3
|
+
export const NPX = 'npx --yes @litfamily/litmuse@latest';
|
|
4
|
+
export const GLYPH_CHOICES = ['auto', 'round', 'square'];
|
|
5
|
+
|
|
6
|
+
const SWITCHES = new Map([
|
|
7
|
+
['--dry-run', 'dryRun'], ['--yes', 'yes'], ['-y', 'yes'], ['--approve', 'approve'], ['--json', 'json'], ['--offline', 'offline'],
|
|
8
|
+
['--no-agent-file', 'noAgentFile'], ['--discard-modified', 'discardModified'], ['--card', 'card'], ['--watch', 'watch'],
|
|
9
|
+
['--all', 'all'], ['--allow-shadow', 'allowShadow'], ['--round', 'round'], ['--agent', 'agent'],
|
|
10
|
+
['--help', 'help'], ['-h', 'help'], ['--version', 'version'], ['-v', 'version'],
|
|
11
|
+
]);
|
|
12
|
+
const VALUES = new Map([['--scope', 'scope'], ['--from', 'from'], ['--family', 'family'], ['--older-than', 'olderThan'], ['--glyphs', 'glyphs']]);
|
|
13
|
+
|
|
14
|
+
export const FLAGS = [...SWITCHES.keys(), ...VALUES.keys()];
|
|
15
|
+
|
|
16
|
+
/** `{command, args, flags, problem}`; `problem` is what makes the line unusable, or null. */
|
|
17
|
+
export function parse(argv) {
|
|
18
|
+
const flags = {};
|
|
19
|
+
const rest = [];
|
|
20
|
+
const problems = [];
|
|
21
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
22
|
+
const a = argv[i];
|
|
23
|
+
if (SWITCHES.has(a)) flags[SWITCHES.get(a)] = true;
|
|
24
|
+
else if (!VALUES.has(a)) rest.push(a);
|
|
25
|
+
else if (argv[i + 1] === undefined || argv[i + 1].startsWith('-')) problems.push(`${a} needs a value.`);
|
|
26
|
+
else flags[VALUES.get(a)] = argv[++i];
|
|
27
|
+
}
|
|
28
|
+
const command = rest[0] ?? 'help';
|
|
29
|
+
const unknown = command === 'rewind' ? undefined : rest.find((a) => a.startsWith('-'));
|
|
30
|
+
if (unknown) problems.unshift(`Unknown option: ${unknown}.`);
|
|
31
|
+
if (flags.scope && !['user', 'project'].includes(flags.scope)) problems.push('--scope takes user or project.');
|
|
32
|
+
if (flags.glyphs && !GLYPH_CHOICES.includes(flags.glyphs)) problems.push(`--glyphs takes ${GLYPH_CHOICES.join(', ')}.`);
|
|
33
|
+
if ((flags.round || flags.glyphs) && !['install', 'update'].includes(command)) problems.push('--round and --glyphs work with install and update.');
|
|
34
|
+
return { command, args: rest.slice(1), flags, problem: problems[0] ?? null };
|
|
35
|
+
}
|
package/lib/glyphs.mjs
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// Whether LitMuse draws round ends (U+E0B6, U+E0B4) on pills and gauges. Every surface asks here, so one terminal never
|
|
2
|
-
// shows both forms. LITMUSE_GLYPHS decides when set (round or nerd, basic or square)
|
|
3
|
-
// word, then, off SSH, whether an icon font is installed here. Only
|
|
2
|
+
// shows both forms. LITMUSE_GLYPHS decides when set (auto, round or nerd, basic or square), then the choice saved by
|
|
3
|
+
// `install --glyphs`; on auto it is the terminal's own word, then, off SSH, whether an icon font is installed here. Only
|
|
4
|
+
// file names in the font folders are read.
|
|
4
5
|
import { readdirSync } from 'node:fs';
|
|
5
6
|
import { homedir } from 'node:os';
|
|
6
|
-
import { join } from 'node:path';
|
|
7
|
+
import { isAbsolute, join } from 'node:path';
|
|
8
|
+
import { readConfig } from './config.mjs';
|
|
9
|
+
import { GLYPH_CHOICES, NPX } from './flags.mjs';
|
|
10
|
+
import { colourDepth } from './mark.mjs';
|
|
7
11
|
|
|
8
12
|
export const CAP_LEFT = '';
|
|
9
13
|
export const CAP_RIGHT = '';
|
|
@@ -11,6 +15,7 @@ const MAX_NAMES = 4000;
|
|
|
11
15
|
const MAX_DEPTH = 3;
|
|
12
16
|
const FONT = /\.(?:ttf|otf|ttc)$/i;
|
|
13
17
|
const ICONS = /nerd[ _-]?font|[ _-]nf[mp]?(?=[ _.-])/i;
|
|
18
|
+
const SETTING = new Map([['auto', 'auto'], ['round', 'round'], ['nerd', 'round'], ['square', 'square'], ['basic', 'square']]);
|
|
14
19
|
|
|
15
20
|
const drawsCaps = (env) => Boolean(env.WT_SESSION || env.KITTY_WINDOW_ID) || env.TERM === 'xterm-kitty'
|
|
16
21
|
|| /^(?:vscode|wezterm|ghostty)$/i.test(env.TERM_PROGRAM ?? '');
|
|
@@ -19,7 +24,7 @@ const fontFolders = (env, platform) => {
|
|
|
19
24
|
const home = env.HOME || homedir();
|
|
20
25
|
if (platform === 'darwin') return [join(home, 'Library', 'Fonts'), '/Library/Fonts'];
|
|
21
26
|
if (platform === 'win32') return [env.LOCALAPPDATA && join(env.LOCALAPPDATA, 'Microsoft', 'Windows', 'Fonts'), env.WINDIR && join(env.WINDIR, 'Fonts')].filter(Boolean);
|
|
22
|
-
return [join(env.XDG_DATA_HOME
|
|
27
|
+
return [join(isAbsolute(env.XDG_DATA_HOME ?? '') ? env.XDG_DATA_HOME : join(home, '.local', 'share'), 'fonts'), join(home, '.fonts'), '/usr/local/share/fonts', '/usr/share/fonts'];
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
/** An icon font file is installed. Links are not followed; an unreadable folder or too many names means no. */
|
|
@@ -46,10 +51,53 @@ export function iconFontInstalled({ env = process.env, platform = process.platfo
|
|
|
46
51
|
let installed = null;
|
|
47
52
|
const iconFontOnce = () => (installed ??= iconFontInstalled());
|
|
48
53
|
|
|
54
|
+
/** A font was added or removed: look again. */
|
|
55
|
+
export const forgetIconFont = () => { installed = null; };
|
|
56
|
+
|
|
57
|
+
/** `{choice, from}`: round, square or auto, and whether LITMUSE_GLYPHS, the saved choice or neither said so. */
|
|
58
|
+
export function glyphChoice(env = process.env) {
|
|
59
|
+
const set = SETTING.get((env.LITMUSE_GLYPHS ?? '').toLowerCase());
|
|
60
|
+
if (set) return { choice: set, from: 'environment' };
|
|
61
|
+
const saved = readConfig(env).glyphs;
|
|
62
|
+
return GLYPH_CHOICES.includes(saved) ? { choice: saved, from: 'saved' } : { choice: 'auto', from: 'default' };
|
|
63
|
+
}
|
|
64
|
+
|
|
49
65
|
export function roundGlyphs(env = process.env, iconFont = iconFontOnce) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
if (chosen === 'square' || chosen === 'basic') return false;
|
|
66
|
+
const { choice } = glyphChoice(env);
|
|
67
|
+
if (choice !== 'auto') return choice === 'round';
|
|
53
68
|
if (drawsCaps(env)) return true;
|
|
54
69
|
return !env.SSH_CONNECTION && iconFont();
|
|
55
70
|
}
|
|
71
|
+
|
|
72
|
+
// What the window on stdout rules out. Without a terminal it says nothing about the window the user will look at.
|
|
73
|
+
function windowLimit(env) {
|
|
74
|
+
if (env.NO_COLOR) return 'NO_COLOR is set; unset it';
|
|
75
|
+
if (/^dumb$/i.test(env.TERM ?? '')) return 'TERM is dumb; use a full terminal';
|
|
76
|
+
if (/;(7|15)$/.test(env.COLORFGBG ?? '')) return 'light ground; use a dark terminal';
|
|
77
|
+
return colourDepth({ env, isTTY: true }) === 'truecolor' ? null : 'fewer colours than truecolor; use a truecolor terminal';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The ROUND_ENDS line of install, update and doctor. `surface` is whether LitMuse is installed, so that its status card
|
|
82
|
+
* is there; `fontWhy` is why --round could not add the font. An installed font is no proof that the terminal uses it.
|
|
83
|
+
*/
|
|
84
|
+
export function roundEndsLine({
|
|
85
|
+
env = process.env, surface = true, tty = Boolean(process.stdout.isTTY), platform = process.platform, fontWhy = null,
|
|
86
|
+
iconFont = () => iconFontInstalled({ env, platform }),
|
|
87
|
+
} = {}) {
|
|
88
|
+
const again = `${NPX} install --yes`;
|
|
89
|
+
const square = (why) => `ROUND_ENDS: square (${why})`;
|
|
90
|
+
const check = (why) => `ROUND_ENDS: check (${why}; show your user the pill in step 7 of ${NPX} install --agent)`;
|
|
91
|
+
if (!surface) return square(`no surface enabled; run ${again} --round`);
|
|
92
|
+
const limit = tty ? windowLimit(env) : null;
|
|
93
|
+
if (limit) return square(limit);
|
|
94
|
+
const { choice, from } = glyphChoice(env);
|
|
95
|
+
if (choice === 'square') return square(`choice is square; ${from === 'environment' ? 'unset LITMUSE_GLYPHS' : `run ${again} --glyphs auto`}`);
|
|
96
|
+
if (choice === 'round') return from === 'saved' || readConfig(env).glyphs === 'round' ? 'ROUND_ENDS: shown' : check('LITMUSE_GLYPHS asks for round ends and no answer is saved');
|
|
97
|
+
if (drawsCaps(env)) return `ROUND_ENDS: ready${tty ? '' : ' in a dark full-colour terminal'}`;
|
|
98
|
+
if (env.SSH_CONNECTION) return square(`SSH; run ${again} --glyphs round when your user sees the pill in step 7 of ${NPX} install --agent as round`);
|
|
99
|
+
if (iconFont()) return check('an icon font is here, and this terminal is not known to use it');
|
|
100
|
+
if (fontWhy) return square(`font not installed (${fontWhy}); run ${again} --round again`);
|
|
101
|
+
if (platform === 'win32') return square('Windows console; use Windows Terminal or VS Code');
|
|
102
|
+
return square(`no icon font; run ${again} --round`);
|
|
103
|
+
}
|
package/lib/guard.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lstatSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { isAbsolute, join, resolve, sep } from 'node:path';
|
|
2
4
|
|
|
3
5
|
const FOREIGN_DIRS = new Set(['.claude', '.codex']);
|
|
4
6
|
|
|
@@ -9,3 +11,38 @@ export function assertSafeWritePath(target) {
|
|
|
9
11
|
if (hit) throw new Error(`refused: LitMuse never writes under ${hit}${sep} (${target})`);
|
|
10
12
|
return target;
|
|
11
13
|
}
|
|
14
|
+
|
|
15
|
+
export const FONT_FILES = Object.freeze({ font: 'SymbolsNerdFontMono-Regular.ttf', license: 'SymbolsNerdFontMono-LICENSE.txt' });
|
|
16
|
+
|
|
17
|
+
/** XDG_DATA_HOME where it is absolute; by the XDG rule a relative one counts as not set. A slash at its end would hide a link. */
|
|
18
|
+
export const xdgData = (env) => (isAbsolute(env.XDG_DATA_HOME ?? '') ? resolve(env.XDG_DATA_HOME) : null);
|
|
19
|
+
|
|
20
|
+
/** The per-user font folder, or null on Windows, where LitMuse installs no font. */
|
|
21
|
+
export function fontFolder({ env = process.env, platform = process.platform } = {}) {
|
|
22
|
+
const home = env.HOME || homedir();
|
|
23
|
+
if (platform === 'win32') return null;
|
|
24
|
+
return platform === 'darwin' ? join(home, 'Library', 'Fonts') : join(xdgData(env) ?? join(home, '.local', 'share'), 'fonts');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Why the font folder cannot be used, or null: it, or a folder between it and the user's home (or XDG_DATA_HOME), is a
|
|
29
|
+
* link or no folder. A missing folder is fine.
|
|
30
|
+
*/
|
|
31
|
+
export function fontFolderProblem({ env = process.env, platform = process.platform } = {}) {
|
|
32
|
+
const home = env.HOME || homedir();
|
|
33
|
+
const steps = platform === 'darwin' ? [join(home, 'Library'), join(home, 'Library', 'Fonts')]
|
|
34
|
+
: xdgData(env) ? [xdgData(env), join(xdgData(env), 'fonts')]
|
|
35
|
+
: [join(home, '.local'), join(home, '.local', 'share'), join(home, '.local', 'share', 'fonts')];
|
|
36
|
+
for (const step of steps) {
|
|
37
|
+
const st = lstatSync(step, { throwIfNoEntry: false });
|
|
38
|
+
if (st && !st.isDirectory()) return `${step} is ${st.isSymbolicLink() ? 'a link' : 'not a folder'}`;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// `install --round` is the one write outside LitMuse's folder and Muse's own files: these two names, in that folder.
|
|
44
|
+
export function assertFontPath(target, { env = process.env, platform = process.platform } = {}) {
|
|
45
|
+
const dir = fontFolder({ env, platform });
|
|
46
|
+
if (!dir || !Object.values(FONT_FILES).some((name) => target === join(dir, name))) throw new Error(`refused: ${target} is not an icon font path LitMuse writes`);
|
|
47
|
+
return assertSafeWritePath(target);
|
|
48
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// The opt-in icon font of `install --round`: the symbols-only Nerd Font, which holds the round ends (U+E0B6, U+E0B4).
|
|
2
|
+
// It comes from one pinned release archive, and archive and files must match their SHA-256. A file that is already there
|
|
3
|
+
// is never replaced, and icon-font.json in LitMuse's data folder lists what LitMuse added, so uninstall removes only that.
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { linkSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { inflateRawSync } from 'node:zlib';
|
|
9
|
+
import { forgetIconFont, iconFontInstalled } from './glyphs.mjs';
|
|
10
|
+
import { FONT_FILES, assertFontPath, assertSafeWritePath, fontFolder, fontFolderProblem } from './guard.mjs';
|
|
11
|
+
import { paths } from './paths.mjs';
|
|
12
|
+
import { realExistingAncestor, writeFileAtomic } from './safe-write.mjs';
|
|
13
|
+
|
|
14
|
+
const MIB = 1024 * 1024;
|
|
15
|
+
export const ICON_FONT = Object.freeze({
|
|
16
|
+
release: 'v3.5.1',
|
|
17
|
+
url: 'https://github.com/ryanoasis/nerd-fonts/releases/download/v3.5.1/NerdFontsSymbolsOnly.zip',
|
|
18
|
+
sha256: 'fdca3682534f6f65e1ccb2345b0362ccf67d9b8eca7c8025330946e93e2473bc',
|
|
19
|
+
maxBytes: 8 * MIB,
|
|
20
|
+
files: Object.freeze([
|
|
21
|
+
Object.freeze({ entry: 'SymbolsNerdFontMono-Regular.ttf', name: FONT_FILES.font, sha256: 'fe471e538392f51910faab985fa8e192a39dd3426125edd15b71b3680df0e749' }),
|
|
22
|
+
Object.freeze({ entry: 'LICENSE', name: FONT_FILES.license, sha256: '84a7a98c82140fb12c37fe42b93805baa16024cb3e5acc599b7ffe612c55d847' }),
|
|
23
|
+
]),
|
|
24
|
+
});
|
|
25
|
+
const DOWNLOAD_MS = 60_000;
|
|
26
|
+
|
|
27
|
+
const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
28
|
+
const lstatOrNull = (path) => {
|
|
29
|
+
try {
|
|
30
|
+
return lstatSync(path);
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// absent, same (a regular file with exactly these bytes) or other.
|
|
36
|
+
const stateOf = (path, hash) => {
|
|
37
|
+
const st = lstatOrNull(path);
|
|
38
|
+
if (!st) return 'absent';
|
|
39
|
+
return st.isFile() && sha256(readFileSync(path)) === hash ? 'same' : 'other';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Bytes of the named entries of a zip held in memory; a missing name is left out. */
|
|
43
|
+
export function unzip(zip, names) {
|
|
44
|
+
const out = new Map();
|
|
45
|
+
let end = zip.length - 22;
|
|
46
|
+
while (end >= 0 && zip.readUInt32LE(end) !== 0x06054b50) end -= 1;
|
|
47
|
+
if (end < 0) throw new Error('the archive is not a zip file');
|
|
48
|
+
let at = zip.readUInt32LE(end + 16);
|
|
49
|
+
for (let left = zip.readUInt16LE(end + 10); left > 0; left -= 1) {
|
|
50
|
+
const [nameSize, extraSize, noteSize] = [28, 30, 32].map((offset) => zip.readUInt16LE(at + offset));
|
|
51
|
+
const name = zip.toString('utf8', at + 46, at + 46 + nameSize);
|
|
52
|
+
if (names.includes(name)) {
|
|
53
|
+
const local = zip.readUInt32LE(at + 42);
|
|
54
|
+
const from = local + 30 + zip.readUInt16LE(local + 26) + zip.readUInt16LE(local + 28);
|
|
55
|
+
const data = zip.subarray(from, from + zip.readUInt32LE(at + 20));
|
|
56
|
+
const method = zip.readUInt16LE(at + 10);
|
|
57
|
+
if (method !== 0 && method !== 8) throw new Error(`the archive packs ${name} in a way LitMuse does not read`);
|
|
58
|
+
out.set(name, method === 0 ? Buffer.from(data) : inflateRawSync(data, { maxOutputLength: 4 * ICON_FONT.maxBytes }));
|
|
59
|
+
}
|
|
60
|
+
at += 46 + nameSize + extraSize + noteSize;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function download(pins, fetchImpl) {
|
|
66
|
+
const res = await fetchImpl(pins.url, { redirect: 'follow', signal: AbortSignal.timeout(DOWNLOAD_MS) });
|
|
67
|
+
if (!res.ok) throw new Error(`the download answered HTTP ${res.status}`);
|
|
68
|
+
const chunks = [];
|
|
69
|
+
let size = 0;
|
|
70
|
+
for await (const chunk of res.body) {
|
|
71
|
+
size += chunk.length;
|
|
72
|
+
if (size > pins.maxBytes) throw new Error('the download is larger than 8 MiB');
|
|
73
|
+
chunks.push(chunk);
|
|
74
|
+
}
|
|
75
|
+
return Buffer.concat(chunks);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The pinned archive: the file LITMUSE_ICON_FONT_SOURCE names (tests, offline), else the download. */
|
|
79
|
+
async function archiveBytes({ env, pins, fetchImpl }) {
|
|
80
|
+
const local = env.LITMUSE_ICON_FONT_SOURCE;
|
|
81
|
+
let bytes;
|
|
82
|
+
if (local) {
|
|
83
|
+
const st = lstatSync(local);
|
|
84
|
+
if (!st.isFile() || st.size > pins.maxBytes) throw new Error(`${local} is not a regular file of at most 8 MiB`);
|
|
85
|
+
bytes = readFileSync(local);
|
|
86
|
+
} else bytes = await download(pins, fetchImpl);
|
|
87
|
+
if (sha256(bytes) !== pins.sha256) throw new Error('the archive does not match its pinned SHA-256');
|
|
88
|
+
return bytes;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const readManifest = (file) => {
|
|
92
|
+
try {
|
|
93
|
+
const { files } = lstatSync(file).isFile() ? JSON.parse(readFileSync(file, 'utf8')) : {};
|
|
94
|
+
return Array.isArray(files) ? files.filter((f) => typeof f?.path === 'string' && typeof f?.sha256 === 'string') : [];
|
|
95
|
+
} catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Why the folder or the font's own place in it cannot take the file, or null. Nothing is written or fetched before this.
|
|
101
|
+
function blocked(target, where) {
|
|
102
|
+
const problem = fontFolderProblem(where);
|
|
103
|
+
if (problem) return problem;
|
|
104
|
+
assertSafeWritePath(realExistingAncestor(dirname(target)));
|
|
105
|
+
return lstatOrNull(target) ? `something else is already at ${target}` : null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// The bytes go to a temporary file in LitMuse's own folder; the hard link that claims the name fails when anything is
|
|
109
|
+
// there already. Returns false in that case.
|
|
110
|
+
function claim(target, bytes, data, write) {
|
|
111
|
+
mkdirSync(data, { recursive: true });
|
|
112
|
+
const staged = join(data, `.icon-font-${process.pid}`);
|
|
113
|
+
try {
|
|
114
|
+
write(staged, bytes, { flag: 'wx', mode: 0o644 });
|
|
115
|
+
try {
|
|
116
|
+
linkSync(staged, target);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
if (e.code === 'EEXIST') return false;
|
|
119
|
+
throw e.code === 'EXDEV' ? new Error(`${dirname(target)} and ${data} are on different disks`) : e;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
} finally {
|
|
123
|
+
rmSync(staged, { force: true });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** What `--round` would do, for the plan and the dry run. */
|
|
128
|
+
export function iconFontPlan({ env = process.env, platform = process.platform, hasFont = () => iconFontInstalled({ env, platform }) } = {}) {
|
|
129
|
+
if (hasFont()) return 'an icon font is already here; nothing is added';
|
|
130
|
+
const dir = fontFolder({ env, platform });
|
|
131
|
+
if (!dir) return 'no font is installed on Windows (Windows Terminal and VS Code draw the round ends)';
|
|
132
|
+
return `add ${FONT_FILES.font} and its licence (${FONT_FILES.license}) to ${dir}, ${env.LITMUSE_ICON_FONT_SOURCE ? `from ${env.LITMUSE_ICON_FONT_SOURCE}` : `downloaded from ${ICON_FONT.url}`}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Adds the icon font when none is here. Returns `{status, why?, written}` with status here, added, unsupported or failed;
|
|
137
|
+
* it never throws, because an install succeeds with square ends too.
|
|
138
|
+
*/
|
|
139
|
+
export async function addIconFont({
|
|
140
|
+
env = process.env, platform = process.platform, pins = ICON_FONT, fetchImpl = globalThis.fetch, spawn = spawnSync, write = writeFileSync,
|
|
141
|
+
hasFont = () => iconFontInstalled({ env, platform }),
|
|
142
|
+
} = {}) {
|
|
143
|
+
const linked = [];
|
|
144
|
+
try {
|
|
145
|
+
if (hasFont()) return { status: 'here', written: [] };
|
|
146
|
+
const p = paths(env);
|
|
147
|
+
const dir = fontFolder({ env, platform });
|
|
148
|
+
if (!dir) return { status: 'unsupported', why: 'LitMuse installs no font on Windows', written: [] };
|
|
149
|
+
const why = blocked(join(dir, FONT_FILES.font), { env, platform });
|
|
150
|
+
if (why) return { status: 'failed', why, written: [] };
|
|
151
|
+
const entries = unzip(await archiveBytes({ env, pins, fetchImpl }), pins.files.map((f) => f.entry));
|
|
152
|
+
for (const f of pins.files) {
|
|
153
|
+
const bytes = entries.get(f.entry);
|
|
154
|
+
if (!bytes || sha256(bytes) !== f.sha256) throw new Error(`${f.entry} in the archive does not match its pinned SHA-256`);
|
|
155
|
+
}
|
|
156
|
+
mkdirSync(dir, { recursive: true });
|
|
157
|
+
const late = blocked(join(dir, FONT_FILES.font), { env, platform });
|
|
158
|
+
if (late) throw new Error(late);
|
|
159
|
+
for (const f of pins.files) {
|
|
160
|
+
const path = assertFontPath(join(dir, f.name), { env, platform });
|
|
161
|
+
if (claim(path, entries.get(f.entry), p.data, write)) linked.push({ path, sha256: f.sha256 });
|
|
162
|
+
else if (f.name === FONT_FILES.font) throw new Error(`something else is already at ${path}`);
|
|
163
|
+
}
|
|
164
|
+
const kept = readManifest(p.iconFont).filter((f) => !linked.some((l) => l.path === f.path) && stateOf(f.path, f.sha256) === 'same');
|
|
165
|
+
writeFileAtomic(p.iconFont, `${JSON.stringify({ release: pins.release, files: [...kept, ...linked] }, null, 2)}\n`);
|
|
166
|
+
if (platform !== 'darwin') spawn('fc-cache', ['-f', dir], { stdio: 'ignore', timeout: DOWNLOAD_MS });
|
|
167
|
+
return { status: 'added', written: [...linked.map((f) => f.path), p.iconFont] };
|
|
168
|
+
} catch (e) {
|
|
169
|
+
for (const f of linked) rmSync(f.path, { force: true });
|
|
170
|
+
return { status: 'failed', why: e.name === 'TimeoutError' ? 'the download took longer than 60 seconds' : e.code ? `${e.code}${e.path ? ` ${e.path}` : ''}` : e.message, written: [] };
|
|
171
|
+
} finally {
|
|
172
|
+
forgetIconFont();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The files LitMuse added that are still exactly as written (`remove`), and those that changed since (`keep`). */
|
|
177
|
+
export function ownedIconFont({ env = process.env, platform = process.platform } = {}) {
|
|
178
|
+
const out = { remove: [], keep: [] };
|
|
179
|
+
const linked = fontFolderProblem({ env, platform });
|
|
180
|
+
for (const f of readManifest(paths(env).iconFont)) {
|
|
181
|
+
let state = 'other';
|
|
182
|
+
try {
|
|
183
|
+
const found = stateOf(assertFontPath(f.path, { env, platform }), f.sha256);
|
|
184
|
+
state = linked && found === 'same' ? 'other' : found;
|
|
185
|
+
} catch { /* not a path LitMuse writes: left alone */ }
|
|
186
|
+
if (state !== 'absent') out[state === 'same' ? 'remove' : 'keep'].push(f.path);
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function removeIconFont({ env = process.env, platform = process.platform } = {}) {
|
|
192
|
+
const owned = ownedIconFont({ env, platform });
|
|
193
|
+
for (const path of owned.remove) rmSync(path, { force: true });
|
|
194
|
+
const list = assertSafeWritePath(paths(env).iconFont);
|
|
195
|
+
if (lstatOrNull(list)?.isFile()) rmSync(list);
|
|
196
|
+
forgetIconFont();
|
|
197
|
+
return owned;
|
|
198
|
+
}
|
package/lib/install-cards.mjs
CHANGED
|
@@ -197,8 +197,11 @@ export function createCards({ env, stdin, stdout, proc = process, now = Date.now
|
|
|
197
197
|
/** Wrapped text under a heading. A command (four spaces in) stays on one line, so it can be copied. */
|
|
198
198
|
const text = (heading, lines) => { stdout.write(`${apart('text')}${textLines(heading, lines).join('\n')}\n`); };
|
|
199
199
|
|
|
200
|
-
/**
|
|
201
|
-
const
|
|
200
|
+
/** One line that is never wrapped, so it can be found and copied whole. */
|
|
201
|
+
const line = (words) => { stdout.write(`${apart('text')} ${bold(say(words))}\n`); };
|
|
202
|
+
|
|
203
|
+
/** A finished card: sections of { head, rows: [{ mark, label, value }] }. Values wrap and are never cut. The first of `hints` that fits takes the empty top row. */
|
|
204
|
+
const panel = ({ title, sections, bad = false, hints: lines = [] }) => {
|
|
202
205
|
const markCells = 2;
|
|
203
206
|
const labelCells = inner() < 56 ? 0 : LABEL;
|
|
204
207
|
const body = sections.flatMap(({ head, rows: list }) => [
|
|
@@ -214,6 +217,8 @@ export function createCards({ env, stdin, stdout, proc = process, now = Date.now
|
|
|
214
217
|
return wrap(say(short(value)), inner() - cells(start)).map((line, i) => (i ? ' '.repeat(cells(start)) : start) + loud(line));
|
|
215
218
|
}),
|
|
216
219
|
]);
|
|
220
|
+
const hint = lines.find((line) => cells(line) <= inner());
|
|
221
|
+
if (hint) body[0] = dim(say(hint));
|
|
217
222
|
stdout.write(`${apart('card')}${frame({ title, body, bad }).join('\n')}\n`);
|
|
218
223
|
};
|
|
219
224
|
|
|
@@ -397,5 +402,5 @@ export function createCards({ env, stdin, stdout, proc = process, now = Date.now
|
|
|
397
402
|
}
|
|
398
403
|
};
|
|
399
404
|
|
|
400
|
-
return { ask, row, text, panel, work, intro, short };
|
|
405
|
+
return { ask, row, text, line, panel, work, intro, short };
|
|
401
406
|
}
|
package/lib/install.mjs
CHANGED
|
@@ -11,6 +11,10 @@ import { SHELF, extensionsNotice, leftoverRuntime } from '../plugin/hooks/lib/ex
|
|
|
11
11
|
import { noticeHash, wasShown, recordShown } from './shown.mjs';
|
|
12
12
|
import { survey, findings, CLI } from './extensions.mjs';
|
|
13
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';
|
|
14
18
|
|
|
15
19
|
function remedy(state, detail, p) {
|
|
16
20
|
const saved = `${p.stage}.saved-${new Date().toISOString().slice(0, 10)}`;
|
|
@@ -72,7 +76,8 @@ const counted = (list) => {
|
|
|
72
76
|
return `${list.length} (${[...of('hook', 'hook'), ...of('agent', 'agent')].join(', ')})`;
|
|
73
77
|
};
|
|
74
78
|
|
|
75
|
-
|
|
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 = {} }) {
|
|
76
81
|
const p = paths(env);
|
|
77
82
|
const version = packageVersion();
|
|
78
83
|
const scope = flags.scope || 'user';
|
|
@@ -142,12 +147,15 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
142
147
|
['backups', `${p.backups} (Muse settings.json and installed.json, when present)`],
|
|
143
148
|
['receipt', p.receipt],
|
|
144
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}`]] : []),
|
|
145
152
|
['muse', `muse ${installArgs.join(' ')}`],
|
|
146
153
|
['approvals', `up to ${approvals.length} capabilities may need your approval in Muse (hooks and agents):`],
|
|
147
154
|
];
|
|
148
155
|
if (cards) {
|
|
149
156
|
cards.panel({
|
|
150
157
|
title: `LitMuse ${version} install plan`,
|
|
158
|
+
hints: [AGENT_LINE, AGENT_LINE_SHORT],
|
|
151
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)}`]]) }],
|
|
152
160
|
});
|
|
153
161
|
} else {
|
|
@@ -164,7 +172,7 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
164
172
|
}
|
|
165
173
|
if (!interactive && !flags.yes) {
|
|
166
174
|
print('');
|
|
167
|
-
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.');
|
|
168
176
|
return 0;
|
|
169
177
|
}
|
|
170
178
|
|
|
@@ -219,7 +227,7 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
219
227
|
let states = approvalStates(muse(env, ['plugins', 'inspect', 'litmuse', '--json']).json);
|
|
220
228
|
const pending = states.filter((s) => s.status !== 'trusted_enabled');
|
|
221
229
|
const named = (s) => ` ${s.id} (${s.what})`;
|
|
222
|
-
const asksApproval = pending.length > 0 && !flags.approve && interactive && Boolean(ask);
|
|
230
|
+
const asksApproval = pending.length > 0 && !flags.approve && !flags.yes && interactive && Boolean(ask);
|
|
223
231
|
const questions = Number(asksApproval) + Number(agentFileAsks({ env, flags, interactive, ask, version }));
|
|
224
232
|
if (pending.length) {
|
|
225
233
|
let approve = Boolean(flags.approve);
|
|
@@ -266,7 +274,7 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
266
274
|
if (!cards && still.length) section(`${still.length} are still waiting:`, still.map(named));
|
|
267
275
|
else if (!cards) print('No capabilities are still waiting for approval.');
|
|
268
276
|
} else if (!cards) {
|
|
269
|
-
section('Approval needed. Run these when you are ready (or rerun install with --approve):', pending.map((s) => ` muse plugins approve ${s.id}`));
|
|
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}`));
|
|
270
278
|
}
|
|
271
279
|
}
|
|
272
280
|
|
|
@@ -280,6 +288,25 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
280
288
|
env, flags, interactive, ask, print: cards ? rulesRow : print, version, backupDir: p.backups, tag: `LIT ${questions}/${questions}`,
|
|
281
289
|
}));
|
|
282
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 });
|
|
309
|
+
|
|
283
310
|
const left = states.filter((s) => s.status !== 'trusted_enabled').length;
|
|
284
311
|
// A new version (or a first install) arms the one-time notice for the next Muse session; a same-version reinstall
|
|
285
312
|
// leaves whatever the last one armed.
|
|
@@ -300,9 +327,9 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
300
327
|
plain('');
|
|
301
328
|
if (cards) {
|
|
302
329
|
const names = new Map([
|
|
303
|
-
[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'],
|
|
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'],
|
|
304
331
|
]);
|
|
305
|
-
const nameOf = (path) => names.get(path) ?? (path.startsWith(p.backups) ? 'Backup' : 'Muse settings');
|
|
332
|
+
const nameOf = (path) => names.get(path) ?? (path.startsWith(p.backups) ? 'Backup' : /SymbolsNerdFont/.test(path) ? 'Icon font' : 'Muse settings');
|
|
306
333
|
const waiting = states.filter((s) => s.status !== 'trusted_enabled');
|
|
307
334
|
cards.panel({
|
|
308
335
|
title: `LitMuse ${version} is installed`,
|
|
@@ -315,11 +342,12 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
315
342
|
] },
|
|
316
343
|
{ head: 'Next', rows: planRows([
|
|
317
344
|
...(left ? [['Approve', 'run the commands below']] : []),
|
|
345
|
+
['Restart', 'quit Muse if it is open, then start it again'],
|
|
318
346
|
['Start', 'open Muse in a project and begin a prompt with lit'], ['Check', 'npx @litfamily/litmuse doctor'],
|
|
319
347
|
]) },
|
|
320
348
|
],
|
|
321
349
|
});
|
|
322
|
-
if (left) cards.text('Approval needed. Run these when you are ready (or rerun install with --approve):', waiting.map((s) => ` muse plugins approve ${s.id}`));
|
|
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}`));
|
|
323
351
|
}
|
|
324
352
|
// The notice and the fixed line after it are printed once per text; the live count of folders to check always is.
|
|
325
353
|
const [fixedLine, ...liveLines] = extensionLines(env);
|
|
@@ -333,11 +361,14 @@ export async function install({ env = process.env, flags = {}, interactive = fal
|
|
|
333
361
|
else for (const line of [...noticeLines, ...liveLines]) print(line);
|
|
334
362
|
recordShown(p.shown, hash);
|
|
335
363
|
}
|
|
336
|
-
if (
|
|
364
|
+
if (cards) cards.line(ends);
|
|
365
|
+
else {
|
|
337
366
|
print('');
|
|
367
|
+
print('Restart: quit Muse if it is open, then start it again, so it loads this LitMuse.');
|
|
338
368
|
print(left === 0
|
|
339
369
|
? 'Status: Ready. Start Muse in a project and begin a prompt with `lit`. Check any time with `npx @litfamily/litmuse doctor`.'
|
|
340
370
|
: `Status: installed, approval needed for ${left} capabilities. Run the commands above, then \`npx @litfamily/litmuse doctor\`.`);
|
|
371
|
+
print(ends);
|
|
341
372
|
}
|
|
342
373
|
return 0;
|
|
343
374
|
}
|
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/uninstall.mjs
CHANGED
|
@@ -6,8 +6,9 @@ import { assertSafeWritePath } from './guard.mjs';
|
|
|
6
6
|
import { removeAgentFile } from './agent-file.mjs';
|
|
7
7
|
import { packageVersion } from './bundle.mjs';
|
|
8
8
|
import { planRows } from './install-cards.mjs';
|
|
9
|
+
import { ownedIconFont, removeIconFont } from './icon-font.mjs';
|
|
9
10
|
|
|
10
|
-
export async function uninstall({ env = process.env, flags = {}, interactive = false, print = console.log, cards = null }) {
|
|
11
|
+
export async function uninstall({ env = process.env, flags = {}, interactive = false, print = console.log, cards = null, font: { platform } = {} }) {
|
|
11
12
|
const p = paths(env);
|
|
12
13
|
const plugin = installedPlugin(env);
|
|
13
14
|
const st = stageState(p);
|
|
@@ -16,10 +17,12 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
|
|
|
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})`;
|
|
20
|
+
const font = ownedIconFont({ env, platform });
|
|
19
21
|
const plan = [
|
|
20
22
|
['muse plugin', pluginLine],
|
|
21
23
|
['bundle', bundleLine],
|
|
22
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(', ')}`]] : []),
|
|
23
26
|
['kept', `${p.backups} and ${p.receipt}`],
|
|
24
27
|
];
|
|
25
28
|
if (cards) cards.panel({ title: 'LitMuse uninstall', sections: [{ rows: planRows(plan.map(([label, value]) => [label[0].toUpperCase() + label.slice(1), value])) }] });
|
|
@@ -52,6 +55,15 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
|
|
|
52
55
|
if (cards) cards.row('done', 'Bundle', `removed ${p.stage}`);
|
|
53
56
|
else print(`Removed ${p.stage}.`);
|
|
54
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
|
+
}
|
|
55
67
|
const rules = removeAgentFile({ env, version: packageVersion() });
|
|
56
68
|
const stays = 'Project files LitMuse sessions wrote (plans/, .litmuse/) stay in each project.';
|
|
57
69
|
if (cards) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "litmuse",
|
|
4
4
|
"displayName": "LitMuse",
|
|
5
|
-
"version": "0.1.
|
|
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",
|