@muwi/herdr-app 0.8.0 → 0.10.0

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.
Files changed (2) hide show
  1. package/app/muwi/main.js +153 -15
  2. package/package.json +3 -3
package/app/muwi/main.js CHANGED
@@ -82,8 +82,22 @@ function programIcon(p, size, color) {
82
82
  * Windows에서는 muwi.cmd를 cmd.exe로 실행한다. sh 스크립트는 Windows에서 바로 실행되지 않는다
83
83
  */
84
84
  function runMuwi(args, options) {
85
- if (appWindow()?.platform === "windows") return exec("cmd.exe", ["/d", "/c", `${home()}\\.local\\bin\\muwi.cmd`, ...args], options);
86
- return exec(`${home()}/.local/bin/muwi`, args, options);
85
+ return exec(...muwiArgv(args), options);
86
+ }
87
+
88
+ /** muwi 명령을 실행할 프로그램과 인자 (새 탭의 터미널에서 실행할 때도 쓴다) */
89
+ function muwiArgv(args) {
90
+ if (appWindow()?.platform === "windows") return ["cmd.exe", ["/d", "/c", `${home()}\\.local\\bin\\muwi.cmd`, ...args]];
91
+ return [`${home()}/.local/bin/muwi`, args];
92
+ }
93
+
94
+ /** 나중에 알리라고 한 새 판 (그 판은 다시 알리지 않는다). 브라우저 저장소를 못 쓰면 이번에만 닫는다 */
95
+ const LATER_KEY = "muwi.update.later";
96
+ function laterVersion() {
97
+ try { return localStorage.getItem(LATER_KEY); } catch { return null; }
98
+ }
99
+ function setLaterVersion(v) {
100
+ try { localStorage.setItem(LATER_KEY, v); } catch { /* 이번에만 닫는다 */ }
87
101
  }
88
102
 
89
103
  /** 레이아웃 나무에서 id로 칸을 찾는다 */
@@ -186,8 +200,12 @@ const SAMPLE = (() => {
186
200
  { ...work, work: "between", title: "다음 노드를 준비하는 작업", state: "doing", between: "working", past: false, active: [] },
187
201
  { ...work, work: "quiet", title: "세션이 멈춘 작업", state: "waiting", quiet: "stopped", past: false, active: [{ id: "y", title: "하던 일", status: "doing", quiet: "stopped" }] },
188
202
  { ...work, work: "old", title: "지난 작업", state: "done", past: true, active: [] },
203
+ { ...work, work: "finished", title: "끝난 작업", state: "done", past: false, active: [] },
204
+ { ...work, work: "shelved", title: "보관한 작업", state: "done", archived: true, past: false, active: [] },
189
205
  ],
190
206
  errors: [],
207
+ // herdr-app check는 견본으로 새 판 배너까지 그려 본다
208
+ update: { current: "0.9.0", latest: "0.10.0", url: "https://github.com/Ssoon-m/muwi/releases/tag/v0.10.0" },
191
209
  sessions: [{ key: "s1", terminal: "t1", work: "sample", seenAt: "2026-01-01T00:00:00.000Z" }],
192
210
  owners: { t1: "s1" },
193
211
  suggest: false,
@@ -240,6 +258,13 @@ export default class Muwi extends View {
240
258
  this.focusKey = null;
241
259
  this.stale = false;
242
260
  this.showPast = false;
261
+ /** 보관한 작업 묶음을 펼쳤는가, 마우스가 올라간 작업 줄 (보관 버튼을 보여 준다), 보관하거나 꺼내는 중 */
262
+ this.showShelf = false;
263
+ this.hoverRow = null;
264
+ this.shelving = false;
265
+ /** 목록 아래의 알림: 보관·꺼내기의 결과와 되돌리기, 못 했을 때의 까닭. 잠시 뒤에 사라진다 */
266
+ this.shelfToast = null;
267
+ this.toastSeq = 0;
243
268
  /** 접어 둔 묶음 (작업 목록의 "응답 대기" 같은 것) */
244
269
  this.folded = new Set();
245
270
  /** 키보드가 있는 터미널과 그 작업. 바뀔 때만 따라간다 (사람이 고른 것을 덮어쓰지 않게) */
@@ -253,6 +278,8 @@ export default class Muwi extends View {
253
278
  this.applying = false;
254
279
  this.bannerNote = null;
255
280
  this.bannerClosed = false;
281
+ /** muwi 새 판 안내를 이번에 닫았다 (나중에) */
282
+ this.updateClosed = false;
256
283
  /** 그래프 칸의 자리를 바꾸는 중 */
257
284
  this.moving = false;
258
285
  /** 그래프를 위→아래로 그렸는가 (마지막으로 읽은 것) */
@@ -277,6 +304,9 @@ export default class Muwi extends View {
277
304
  this.data = SAMPLE;
278
305
  this.node = "impl";
279
306
  this.tab = "node";
307
+ // herdr-app check는 견본으로 보관함과 알림 줄까지 그려 본다
308
+ this.showShelf = true;
309
+ this.shelfToast = { id: 0, text: "1개 보관했어요. 목록 맨 아래 \"보관\"에 있어요", undo: { works: ["finished"], on: false } };
280
310
  return;
281
311
  }
282
312
  this.load(cx);
@@ -954,7 +984,8 @@ export default class Muwi extends View {
954
984
  */
955
985
  groups(t, works, links) {
956
986
  const c = this.colors(t);
957
- const current = works.filter((w) => !w.past);
987
+ // 보관한 작업은 맨 아래 "보관"에만 둔다
988
+ const current = works.filter((w) => !w.past && !w.archived);
958
989
  const open = new Set(current.filter((w) => w.state !== "done").map((w) => w.work));
959
990
  const byWork = new Map();
960
991
  const free = [];
@@ -988,17 +1019,22 @@ export default class Muwi extends View {
988
1019
  }
989
1020
 
990
1021
  /**
991
- * 작업 목록: 묶음 머리와 줄들. 끝났거나 멈춘 채로 오래된 작업(past)은 맨 아래에 "지난 작업 N개"로 접어 둔다. 지우지는 않는다.
1022
+ * 작업 목록: 묶음 머리와 줄들. 끝났거나 멈춘 채로 오래된 작업(past)은 맨 아래에 "지난 작업 N개"로 접어 둔다.
1023
+ * 사람이 보관한 작업(muwi archive)은 그 아래 "보관 N개"로 접어 둔다. 둘 다 지우지는 않는다.
992
1024
  * compact: 사이드바를 좁혀 아이콘만 보일 때
993
1025
  */
994
1026
  list(t, works, groups, selected, now, fill, compact) {
995
1027
  const c = this.colors(t);
996
1028
  const box = fill ? v_flex().flex_1().min_h(0) : v_flex().flex_none();
1029
+ const outer = fill ? v_flex().flex_1().min_h(0) : v_flex().flex_none();
997
1030
  const row = (item) => (item.kind === "work" ? this.workRow(t, c, item, selected, now, compact) : this.agentRow(t, item.a, compact));
998
1031
  const past = works.filter((w) => w.past);
1032
+ const shelf = works.filter((w) => w.archived);
999
1033
  // 접어 둔 작업을 보고 있으면 펼쳐 둔다
1000
1034
  const open = this.showPast || past.some((w) => w.work === selected);
1001
- return box.id("works").overflow_y_scrollbar().px(compact ? 4 : 8).pb(8).gap(1)
1035
+ // 보관함은 사람이 펼칠 때만 연다 (모두 보관한 뒤에 수십 줄이 한꺼번에 펼쳐지지 않게). 어디로 갔는지는 알림이 알려 준다
1036
+ const openShelf = this.showShelf;
1037
+ return outer.child(box.id("works").overflow_y_scrollbar().px(compact ? 4 : 8).pb(8).gap(1)
1002
1038
  .children(groups.flatMap((g) => [
1003
1039
  ...(compact ? [] : [this.groupHead(t, g)]),
1004
1040
  ...(this.folded.has(g.id) && !compact ? [] : g.items.map(row)),
@@ -1009,7 +1045,82 @@ export default class Muwi extends View {
1009
1045
  .on_click((_e, cx) => { this.showPast = !open; cx.notify(); })
1010
1046
  .child(div().w(14).flex_none().text_size(10).text_color(t.dim).child(open ? "▾" : "▸"))
1011
1047
  .child(div().flex_1().text_size(11).text_color(t.dim).child(`지난 작업 ${past.length}개`)))
1012
- .when(open, (el2) => el2.children(past.map((w) => row({ kind: "work", w, agents: [], ask: false })))));
1048
+ .when(open, (el2) => el2.children(past.map((w) => row({ kind: "work", w, agents: [], ask: false })))))
1049
+ .when(shelf.length > 0 && !compact, (el) => el
1050
+ .child(h_flex().id("shelf-toggle").px(8).py(6).mt(4).gap(8).items_center().rounded(7).cursor_pointer()
1051
+ .hover((s) => s.bg(t.hover))
1052
+ .on_click((_e, cx) => { this.showShelf = !openShelf; cx.notify(); })
1053
+ .child(div().w(14).flex_none().text_size(10).text_color(t.dim).child(openShelf ? "▾" : "▸"))
1054
+ .child(div().flex_1().text_size(11).text_color(t.dim).child(`보관 ${shelf.length}개`)))
1055
+ .when(openShelf, (el2) => el2.children(shelf.map((w) => row({ kind: "work", w, agents: [], ask: false }))))))
1056
+ // 알림은 스크롤 밖, 목록 아래에 붙인다 (목록이 길어도 보인다)
1057
+ .when(Boolean(this.shelfToast) && !compact, (el) => el.child(this.toastBar(t)));
1058
+ }
1059
+
1060
+ /** 목록 아래의 알림 줄: 결과, 되돌리기, 닫기 */
1061
+ toastBar(t) {
1062
+ const n = this.shelfToast;
1063
+ return h_flex().id("shelf-toast").flex_none().mx(8).mb(8).px(10).py(7).gap(8).items_center().rounded(7)
1064
+ .bg(t.surface).border_1().border_color(n.error ? t.blocked : t.border).text_size(11)
1065
+ .child(div().flex_1().min_w(0).text_color(n.error ? t.blocked : t.foreground).child(n.text))
1066
+ .when(Boolean(n.undo), (el) => el.child(div().id("shelf-undo").flex_none().px(6).py(2).rounded(5).font_medium().text_color(t.accent).cursor_pointer()
1067
+ .hover((s) => s.bg(t.hover))
1068
+ .on_click((_e, cx) => { const u = n.undo; this.shelfToast = null; this.shelve(u.works, u.on, cx); })
1069
+ .child("되돌리기")))
1070
+ .child(div().id("shelf-toast-close").flex_none().px(4).text_color(t.dim).cursor_pointer()
1071
+ .hover((s) => s.text_color(t.foreground))
1072
+ .tooltip("닫기")
1073
+ .on_click((_e, cx) => { this.shelfToast = null; cx.notify(); })
1074
+ .child("×"));
1075
+ }
1076
+
1077
+ /**
1078
+ * 작업을 보관하거나 꺼낸다 (muwi archive·unarchive). 기록을 바꾸는 것은 muwi 명령이 하고, 이 칸은 다시 읽을 뿐이다.
1079
+ * args: 작업 이름들, 또는 ["--done"] (끝난 작업 모두)
1080
+ */
1081
+ shelve(args, on, cx) {
1082
+ if (this.shelving) return;
1083
+ this.shelving = true;
1084
+ cx.notify();
1085
+ cx.spawn(async (cx) => {
1086
+ const r = await runMuwi([on ? "archive" : "unarchive", ...args], { timeout: 10000 }).catch((e) => ({ code: 1, stderr: String(e?.message ?? e) }));
1087
+ this.shelving = false;
1088
+ this.stale = true;
1089
+ let toast;
1090
+ if (r?.code !== 0) toast = { text: `${on ? "보관" : "꺼내기"}하지 못했어요: ${(r?.stderr || r?.stdout || "").trim().split("\n")[0]}`, error: true };
1091
+ else {
1092
+ // muwi가 실제로 보관하거나 꺼낸 작업들. 되돌리기는 이 작업들만 되돌린다
1093
+ const moved = (r.stdout ?? "").split("\n").map((l) => /^(.+?): (보관했어요|목록으로 꺼냈어요)/.exec(l)?.[1]).filter(Boolean);
1094
+ toast = moved.length
1095
+ ? { text: on ? `${moved.length}개 보관했어요. 목록 맨 아래 "보관"에 있어요` : `${moved.length}개를 목록으로 꺼냈어요`, undo: { works: moved, on: !on } }
1096
+ : { text: (r.stdout ?? "").trim().split("\n")[0] || "바뀐 것이 없어요" };
1097
+ }
1098
+ const id = ++this.toastSeq;
1099
+ this.shelfToast = { ...toast, id };
1100
+ cx.notify();
1101
+ // 잠시 뒤에 사라진다. 그 사이에 다른 알림이 떴으면 그대로 둔다
1102
+ await cx.sleep(toast.error ? 10000 : 6000);
1103
+ if (this.shelfToast?.id === id) {
1104
+ this.shelfToast = null;
1105
+ cx.notify();
1106
+ }
1107
+ });
1108
+ }
1109
+
1110
+ /**
1111
+ * 끝났거나 멈춘 작업 줄의 버튼: 보관 (보관한 작업은 꺼내기). 마우스를 올린 줄과 고른 줄에 보인다.
1112
+ * 줄 오른쪽 위에 겹쳐 띄워서 줄의 모양이 흔들리지 않게 한다
1113
+ */
1114
+ shelveButton(t, w, selected) {
1115
+ const on = !w.archived;
1116
+ return div().id(`shelve-${w.work}`).absolute().top(5).right(6).px(7).py(2).rounded(5).text_size(10.5).text_color(t.muted).cursor_pointer()
1117
+ .bg(selected ? t.selected : t.hover).border_1().border_color(t.border)
1118
+ .hover((s) => s.text_color(t.foreground).bg(t.surface))
1119
+ .tooltip(on ? "목록에서 치워요. 기록은 그대로예요 (다시 시작하면 돌아와요)" : "목록으로 꺼내요")
1120
+ // 줄을 누른 것으로 치지 않는다 (그 작업을 고르지 않는다)
1121
+ .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
1122
+ .on_click((_e, cx) => { cx.stop_propagation(); this.shelve([w.work], on, cx); })
1123
+ .child(on ? "보관" : "꺼내기");
1013
1124
  }
1014
1125
 
1015
1126
  /** 묶음 머리. 누르면 접는다 */
@@ -1021,6 +1132,13 @@ export default class Muwi extends View {
1021
1132
  .child(div().truncate().text_color(g.color).child(g.label))
1022
1133
  .child(div().text_color(t.dim).child(String(g.items.length)))
1023
1134
  .child(div().flex_1())
1135
+ // 끝난 작업을 한 번에 보관한다
1136
+ .when(g.id === "done", (el) => el.child(div().id("shelve-done").flex_none().px(7).py(2).rounded(5).text_size(10.5).font_normal().text_color(t.dim).cursor_pointer()
1137
+ .hover((s) => s.text_color(t.foreground).bg(t.hover))
1138
+ .tooltip(`끝난 작업 ${g.items.length}개를 모두 보관해요. 목록에서만 빠지고 기록은 그대로예요 (되돌릴 수 있어요)`)
1139
+ .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
1140
+ .on_click((_e, cx) => { cx.stop_propagation(); this.shelve(["--done"], true, cx); })
1141
+ .child(this.shelving ? "보관하는 중…" : "모두 보관")))
1024
1142
  .when(!open, (el) => el.child(div().text_size(10).text_color(t.dim).child("▸")));
1025
1143
  }
1026
1144
 
@@ -1080,9 +1198,15 @@ export default class Muwi extends View {
1080
1198
  : first ? `${first.title}${w.active.length > 1 ? ` 외 ${w.active.length - 1}` : ""}${first.closed ? " · 세션이 닫힘" : w.quiet ? ` · ${QUIET_NAME[w.quiet]}` : first.note ? ` · ${first.note}` : ""}`
1081
1199
  // 하는 노드가 없다 (몇 단계째인지는 오른쪽에 나온다)
1082
1200
  : (w.between && BETWEEN_NAME[w.between]) || "다음 노드 전";
1083
- return h_flex().id(`work-${w.work}`).px(8).py(6).gap(8).items_center().rounded(7)
1201
+ // 끝났거나 멈춘 작업(과 보관한 작업)은 마우스를 올리면 보관(꺼내기) 버튼이 나온다
1202
+ const shelvable = w.archived || w.state === "done" || w.state === "stalled";
1203
+ return h_flex().id(`work-${w.work}`).relative().px(8).py(6).gap(8).items_center().rounded(7)
1084
1204
  .bg(on ? t.selected : t.chrome).hover((s) => s.bg(on ? t.selected : t.hover)).cursor_pointer()
1085
1205
  .on_click(click)
1206
+ .when(shelvable, (el) => el.on_hover((hovered, cx) => {
1207
+ const next = hovered ? w.work : this.hoverRow === w.work ? null : this.hoverRow;
1208
+ if (next !== this.hoverRow) { this.hoverRow = next; cx.notify(); }
1209
+ }))
1086
1210
  .child(this.workMark(t, w, c, item.ask))
1087
1211
  .child(v_flex().flex_1().min_w(0).gap(1)
1088
1212
  .child(div().truncate().text_size(12).text_color(on || w.unread ? t.foreground : t.muted).when(on || w.unread, (el) => el.font_medium()).child(w.title ?? w.work))
@@ -1090,7 +1214,8 @@ export default class Muwi extends View {
1090
1214
  .child(div().flex_1().min_w(0).truncate().text_color(item.ask ? c.waiting : c[w.state] ?? t.dim).child(line))
1091
1215
  // 끝나지 않은 작업은 몇 단계째인지: 끝난 노드 / 전체
1092
1216
  // 오른쪽: 몇 단계째인지와 작업 시간 (노드들이 작업한 시간의 합. 작업 중이면 초마다 늘어난다). 끝난 작업은 작업 시간과 끝난 때
1093
- .child(div().flex_none().text_color(t.dim).child(this.rowMeta(w, now)))));
1217
+ .child(div().flex_none().text_color(t.dim).child(this.rowMeta(w, now)))))
1218
+ .when(shelvable && (this.hoverRow === w.work || on), (el) => el.child(this.shelveButton(t, w, on)));
1094
1219
  }
1095
1220
 
1096
1221
  /** 계획 없이 일하는 세션 한 줄 (Herdr의 Agents 칸과 같은 모양). 누르면 그 터미널로 간다 */
@@ -1142,11 +1267,14 @@ export default class Muwi extends View {
1142
1267
  * muwi layout으로 만든 화면인데 Herdr가 업데이트됐으면: 새 모양에 맞추자고
1143
1268
  */
1144
1269
  banner(t, variant) {
1145
- if (checking() || !this.data || this.bannerClosed) return null;
1146
- const tree = shownLayout();
1147
- const has = anyNode(tree, (n) => n?.content?.mod === "muwi");
1148
- let text = null, act = null, later = null;
1149
- if (!has && variant === "full" && this.data.suggest) {
1270
+ if (!this.data) return null;
1271
+ let text = null, act = null, later = null, more = null;
1272
+ // 화면에 대한 안내(Herdr 업데이트, 칸 배치)가 먼저다. 화면이 어긋나는 문제라서. 닫으면 muwi 새 판 안내가 뜬다
1273
+ const tree = checking() || this.bannerClosed ? null : shownLayout();
1274
+ const has = tree ? anyNode(tree, (n) => n?.content?.mod === "muwi") : true;
1275
+ if (checking() || this.bannerClosed) {
1276
+ // 견본과 닫은 뒤에는 화면 안내를 보지 않는다
1277
+ } else if (!has && variant === "full" && this.data.suggest) {
1150
1278
  text = "사이드바의 Agents 자리에 작업 목록을 두고, 그래프를 터미널 아래에 고정할 수 있어요. 지금 레이아웃은 그대로 남아요.";
1151
1279
  act = { label: "바꾸기", run: (cx) => this.applyLayout(cx, true) };
1152
1280
  later = { label: "묻지 않기", run: (cx) => this.stopAsking(cx) };
@@ -1166,6 +1294,14 @@ export default class Muwi extends View {
1166
1294
  later = later0;
1167
1295
  }
1168
1296
  }
1297
+ // muwi 새 판: [업데이트]는 새 탭에서 muwi update를 돌린다 (진행과 오류가 보이게). [나중에]는 그 판만 다시 알리지 않는다
1298
+ const update = this.data.update;
1299
+ if (!text && update?.latest && !this.updateClosed && laterVersion() !== update.latest) {
1300
+ text = `muwi ${update.latest}이 나왔어요 (지금 ${update.current}). 업데이트하면 훅·그래프 칸·커넥터까지 새 판에 맞춰요.`;
1301
+ act = { label: "업데이트", run: () => { const [program, args] = muwiArgv(["update"]); this.openTerminal("muwi-update", [program, ...args], null, "muwi update"); } };
1302
+ more = update.url ? { label: "바뀐 점", run: (cx) => cx.open_url(update.url) } : null;
1303
+ later = { label: "나중에", run: (cx) => { setLaterVersion(update.latest); this.updateClosed = true; cx.notify(); } };
1304
+ }
1169
1305
  if (!text) return null;
1170
1306
  const button = (id, b, primary) => h_flex().id(id).h(24).px(10).flex_none().items_center().rounded(6)
1171
1307
  .bg(primary ? t.accent : t.raised).border_1().border_color(primary ? t.accent : t.border)
@@ -1175,7 +1311,9 @@ export default class Muwi extends View {
1175
1311
  .child(b.label);
1176
1312
  return h_flex().flex_none().px(14).py(7).gap(10).items_center().bg(t.surface).border_b(1).border_color(t.border)
1177
1313
  .child(div().flex_1().min_w(0).text_size(11.5).text_color(this.bannerNote && !this.applying ? t.blocked : t.foreground).child(this.bannerNote ?? text))
1178
- .when(!this.applying, (el) => el.child(button("banner-act", act, true)).child(button("banner-later", later, false)));
1314
+ .when(!this.applying, (el) => el.child(button("banner-act", act, true))
1315
+ .when(Boolean(more), (el2) => el2.child(button("banner-more", more, false)))
1316
+ .child(button("banner-later", later, false)));
1179
1317
  }
1180
1318
 
1181
1319
  /** muwi layout을 실행한다. 터미널 옆에 따로 연 칸이면 바꾼 뒤 그 칸을 닫는다 (같은 그래프가 두 번 보이지 않게) */
@@ -1220,7 +1358,7 @@ export default class Muwi extends View {
1220
1358
  chips(t, works, selected, links) {
1221
1359
  const c = this.colors(t);
1222
1360
  return h_flex().id("chips").flex_none().h(34).px(10).gap(6).items_center().overflow_x_hidden().border_b(1).border_color(t.border)
1223
- .children([...works.filter((w) => !w.past), ...works.filter((w) => w.past)].slice(0, 8).map((w) => {
1361
+ .children([...works.filter((w) => !w.past && !w.archived), ...works.filter((w) => w.past)].slice(0, 8).map((w) => {
1224
1362
  const on = w.work === selected;
1225
1363
  return h_flex().id(`chip-${w.work}`).h(22).px(8).gap(5).flex_none().items_center().rounded(11)
1226
1364
  .bg(on ? t.selected : t.surface).border_1().border_color(on ? t.accent : t.border).cursor_pointer()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muwi/herdr-app",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "muwi를 Herdr 앱에서 보기: 작업 목록과 그래프 칸, 레이아웃",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,8 +12,8 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "dependencies": {
15
- "@muwi/core": "0.8.0",
16
- "@muwi/herdr": "0.8.0"
15
+ "@muwi/core": "0.10.0",
16
+ "@muwi/herdr": "0.10.0"
17
17
  },
18
18
  "engines": {
19
19
  "node": ">=24"