forge-cw 0.1.22 → 0.1.23
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/console/assets/index-_CULM3sT.js +31 -0
- package/console/index.html +1 -1
- package/console/shared/forge-dev-sdk.js +1 -1
- package/dist/index.js +767 -465
- package/modules/mod-today/dist/banner.js +414 -0
- package/modules/mod-today/dist/server.js +776 -0
- package/modules/mod-today/dist/view.js +322 -0
- package/modules/mod-today/forge-module.json +70 -0
- package/modules/mod-today/package.json +26 -0
- package/package.json +1 -1
- package/console/assets/index-WdL2WXjO.js +0 -31
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
// src/view.tsx
|
|
2
|
+
import { useEffect as useEffect2, useState as useState2 } from "preact/hooks";
|
|
3
|
+
import { ActionButton, EmptyState } from "@forge-dev/ui";
|
|
4
|
+
import { definePanel } from "@forge-dev/sdk";
|
|
5
|
+
|
|
6
|
+
// src/ops.ts
|
|
7
|
+
var errorMessage = (e) => e instanceof Error ? e.message : String(e);
|
|
8
|
+
var STARTS = ["issue", "request", "review"];
|
|
9
|
+
var startsTask = (kind) => STARTS.includes(kind);
|
|
10
|
+
var inAccount = (items, account) => account ? items.filter((i) => i.account === account) : items;
|
|
11
|
+
function opFor(item, project) {
|
|
12
|
+
if (item.kind === "to-task") return item.targetSession ? "send" : null;
|
|
13
|
+
if (item.kind === "research") return "research";
|
|
14
|
+
return project ?? item.project ? "start" : null;
|
|
15
|
+
}
|
|
16
|
+
var EMPTY_PROJECTS = { names: [], owners: {} };
|
|
17
|
+
function projectsFor({ names, owners }, account) {
|
|
18
|
+
return account ? names.filter((n) => !owners[n] || owners[n] === account) : names;
|
|
19
|
+
}
|
|
20
|
+
var failedLine = (error) => `Last reading failed: ${error}`;
|
|
21
|
+
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
22
|
+
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
23
|
+
var GROUPS = [
|
|
24
|
+
{ title: "In open tasks", pick: (i) => i.kind === "to-task" },
|
|
25
|
+
{ title: "New", pick: (i) => i.kind === "issue" || i.kind === "request" },
|
|
26
|
+
{ title: "To review", pick: (i) => i.kind === "review" },
|
|
27
|
+
{ title: "Researching", pick: (i) => i.kind === "research" }
|
|
28
|
+
];
|
|
29
|
+
function sections(all) {
|
|
30
|
+
const live = all.filter((i) => i.state !== "dismissed");
|
|
31
|
+
const groups = GROUPS.map((g) => ({ title: g.title, items: live.filter(g.pick) }));
|
|
32
|
+
return [...groups, { title: "Dismissed", items: all.filter((i) => i.state === "dismissed") }].filter((g) => g.items.length > 0);
|
|
33
|
+
}
|
|
34
|
+
var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
|
|
35
|
+
function byAccount(items) {
|
|
36
|
+
const accounts = accountsOf(items);
|
|
37
|
+
if (accounts.length < 2) return [{ sections: sections(items) }];
|
|
38
|
+
const blocks = accounts.map((account) => ({ account, sections: sections(inAccount(items, account)) }));
|
|
39
|
+
const rest = items.filter((i) => !i.account);
|
|
40
|
+
return rest.length ? [...blocks, { sections: sections(rest) }] : blocks;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/rows.tsx
|
|
44
|
+
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
|
45
|
+
import { showToast } from "@forge-dev/ui";
|
|
46
|
+
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
47
|
+
var soft = (token, pct) => `color-mix(in srgb, var(${token}) ${pct}%, transparent)`;
|
|
48
|
+
var AVATARS = ["--blue", "--purple", "--orange", "--green", "--teal", "--red"];
|
|
49
|
+
var ACCOUNT_TOKENS = ["--blue", "--purple", "--orange", "--green", "--teal"];
|
|
50
|
+
function accountToken(name) {
|
|
51
|
+
let h = 0;
|
|
52
|
+
for (const c of name) h = h * 31 + c.charCodeAt(0) >>> 0;
|
|
53
|
+
return ACCOUNT_TOKENS[h % ACCOUNT_TOKENS.length];
|
|
54
|
+
}
|
|
55
|
+
function AccountChip({ account }) {
|
|
56
|
+
const token = accountToken(account);
|
|
57
|
+
return /* @__PURE__ */ jsx("span", { title: `Account ${account}`, style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) }, children: account });
|
|
58
|
+
}
|
|
59
|
+
function useDigest(forge, path = "/digest") {
|
|
60
|
+
const [reply, setReply] = useState(null);
|
|
61
|
+
const [error, setError] = useState(null);
|
|
62
|
+
const latest = useRef(0);
|
|
63
|
+
const load = useCallback(async () => {
|
|
64
|
+
const mine = ++latest.current;
|
|
65
|
+
try {
|
|
66
|
+
const next = await forge.route(path);
|
|
67
|
+
if (mine !== latest.current) return;
|
|
68
|
+
setReply(next);
|
|
69
|
+
setError(null);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
if (mine === latest.current) setError(errorMessage(e));
|
|
72
|
+
}
|
|
73
|
+
}, [forge, path]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
void load();
|
|
76
|
+
const poll = () => {
|
|
77
|
+
if (!document.hidden) void load();
|
|
78
|
+
};
|
|
79
|
+
const t = setInterval(poll, 6e4);
|
|
80
|
+
document.addEventListener("visibilitychange", poll);
|
|
81
|
+
return () => {
|
|
82
|
+
clearInterval(t);
|
|
83
|
+
document.removeEventListener("visibilitychange", poll);
|
|
84
|
+
};
|
|
85
|
+
}, [load]);
|
|
86
|
+
return { reply, error, reload: load };
|
|
87
|
+
}
|
|
88
|
+
function useProjects(forge) {
|
|
89
|
+
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
forge.route("/projects").then((r) => setProjects({ names: r.projects, owners: r.owners ?? {} }), () => {
|
|
92
|
+
});
|
|
93
|
+
}, [forge]);
|
|
94
|
+
return projects;
|
|
95
|
+
}
|
|
96
|
+
function useActing(forge, date, reload) {
|
|
97
|
+
const [busy, setBusy] = useState(false);
|
|
98
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
99
|
+
const reading = useRef(false);
|
|
100
|
+
const guarded = async (fn) => {
|
|
101
|
+
try {
|
|
102
|
+
await fn();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
showToast(errorMessage(e), "error");
|
|
105
|
+
}
|
|
106
|
+
await reload();
|
|
107
|
+
};
|
|
108
|
+
const run = async (fn) => {
|
|
109
|
+
if (busy) return;
|
|
110
|
+
setBusy(true);
|
|
111
|
+
await guarded(fn);
|
|
112
|
+
setBusy(false);
|
|
113
|
+
};
|
|
114
|
+
const act = (item, op, project) => run(async () => {
|
|
115
|
+
if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
|
|
116
|
+
});
|
|
117
|
+
const refresh = async () => {
|
|
118
|
+
if (reading.current) return;
|
|
119
|
+
reading.current = true;
|
|
120
|
+
setRefreshing(true);
|
|
121
|
+
await guarded(() => forge.action("refresh"));
|
|
122
|
+
reading.current = false;
|
|
123
|
+
setRefreshing(false);
|
|
124
|
+
};
|
|
125
|
+
return { busy, refreshing, run, act, refresh };
|
|
126
|
+
}
|
|
127
|
+
function dayOf(date) {
|
|
128
|
+
const [y, m, d] = date.split("-").map(Number);
|
|
129
|
+
return new Date(y, m - 1, d);
|
|
130
|
+
}
|
|
131
|
+
var isToday = (date, now) => dayOf(date).toDateString() === now.toDateString();
|
|
132
|
+
function dayLabel(now, date) {
|
|
133
|
+
const day = dayOf(date);
|
|
134
|
+
if (!isToday(date, now)) return `From ${day.toLocaleDateString("en-US", { weekday: "long" })} ${day.getDate()}`;
|
|
135
|
+
const hour = now.getHours();
|
|
136
|
+
const part = hour < 12 ? "Good morning" : hour < 19 ? "Good afternoon" : "Good evening";
|
|
137
|
+
return `${part} \xB7 your ${now.toLocaleDateString("en-US", { weekday: "long" })} ${now.getDate()}`;
|
|
138
|
+
}
|
|
139
|
+
var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
140
|
+
function readLine(d) {
|
|
141
|
+
const read = new Date(d.readAt);
|
|
142
|
+
const since = new Date(d.since);
|
|
143
|
+
const same = read.toDateString() === since.toDateString();
|
|
144
|
+
const day = new Date(read.getTime() - 864e5).toDateString() === since.toDateString() ? "yesterday " : `${since.toLocaleDateString("en-US", { month: "short", day: "numeric" })} `;
|
|
145
|
+
return `Read at ${clock(read)} \xB7 Linear, Slack and GitHub since ${same ? "" : day}${clock(since)}`;
|
|
146
|
+
}
|
|
147
|
+
function ago(iso, now = /* @__PURE__ */ new Date()) {
|
|
148
|
+
const t = new Date(iso);
|
|
149
|
+
const min = Math.round((now.getTime() - t.getTime()) / 6e4);
|
|
150
|
+
if (min < 1) return "just now";
|
|
151
|
+
if (min < 60) return `${min} min ago`;
|
|
152
|
+
if (min < 24 * 60) return `${Math.round(min / 60)} h ago`;
|
|
153
|
+
return t.toLocaleDateString("en-US", { month: "short", day: "numeric" }) + " " + clock(t);
|
|
154
|
+
}
|
|
155
|
+
var SOURCE_LABEL = { linear: "Linear", slack: "Slack", github: "GitHub" };
|
|
156
|
+
var SOURCE_TINT = { linear: "#5e6ad2 22%", slack: "#e01e5a 18%", github: "#8b949e 24%" };
|
|
157
|
+
function SourceIcon({ source }) {
|
|
158
|
+
return /* @__PURE__ */ jsx("div", { title: SOURCE_LABEL[source], style: { width: "30px", height: "30px", borderRadius: "8px", display: "grid", placeItems: "center", flexShrink: 0, background: `color-mix(in srgb, ${SOURCE_TINT[source]}, transparent)` }, children: source === "github" ? /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { fill: "currentColor", style: { color: "var(--ink)" }, d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z" }) }) : source === "linear" ? /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 100 100", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { fill: "#8c94f0", d: "M1.2 61.5 38.5 98.8C19.8 95.6 4.4 80.2 1.2 61.5zM0 46.9 53.1 100c3.4-.2 6.8-.8 10-1.6L1.6 36.9C.8 40.1.2 43.5 0 46.9zM4.9 27 73 95.1c2.6-1.1 5.1-2.5 7.4-4L8.9 19.6c-1.5 2.3-2.9 4.8-4 7.4zM14.4 13.8C23.4 5.3 35.5 0 48.9 0 76 0 100 24 100 51.1c0 13.4-5.3 25.5-13.8 34.5z" }) }) : /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("g", { fill: "none", "stroke-width": "2.6", "stroke-linecap": "round", children: [
|
|
159
|
+
/* @__PURE__ */ jsx("path", { stroke: "#36c5f0", d: "M9 3.5v6" }),
|
|
160
|
+
/* @__PURE__ */ jsx("path", { stroke: "#2eb67d", d: "M20.5 9h-6" }),
|
|
161
|
+
/* @__PURE__ */ jsx("path", { stroke: "#ecb22e", d: "M15 20.5v-6" }),
|
|
162
|
+
/* @__PURE__ */ jsx("path", { stroke: "#e01e5a", d: "M3.5 15h6" })
|
|
163
|
+
] }) }) });
|
|
164
|
+
}
|
|
165
|
+
var KIND = {
|
|
166
|
+
"to-task": { label: "Send to the task", token: "--orange", verb: "Send" },
|
|
167
|
+
issue: { label: "New task", token: "--green", verb: "Start" },
|
|
168
|
+
request: { label: "New task", token: "--green", verb: "Start" },
|
|
169
|
+
research: { label: "Research", token: "--purple", verb: "Research" },
|
|
170
|
+
review: { label: "Review", token: "--blue", verb: "Review" }
|
|
171
|
+
};
|
|
172
|
+
function KindPill({ kind }) {
|
|
173
|
+
const k = KIND[kind];
|
|
174
|
+
return /* @__PURE__ */ jsx("span", { style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${k.token})`, background: soft(k.token, 15) }, children: k.label });
|
|
175
|
+
}
|
|
176
|
+
function Avatar({ who }) {
|
|
177
|
+
const initials = who.split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0].toUpperCase()).join("") || "?";
|
|
178
|
+
let h = 0;
|
|
179
|
+
for (const c of who) h = h * 31 + c.charCodeAt(0) >>> 0;
|
|
180
|
+
return /* @__PURE__ */ jsx("span", { style: { width: "16px", height: "16px", borderRadius: "50%", display: "inline-grid", placeItems: "center", fontSize: "8.5px", fontWeight: 700, color: "#fff", background: `var(${AVATARS[h % AVATARS.length]})` }, children: initials });
|
|
181
|
+
}
|
|
182
|
+
var Sep = () => /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" });
|
|
183
|
+
var strong = (t) => /* @__PURE__ */ jsx("b", { style: { color: "var(--ink)", fontWeight: 550 }, children: t });
|
|
184
|
+
function LiveChip({ label }) {
|
|
185
|
+
return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px", fontSize: "11px", color: "var(--teal)" }, children: [
|
|
186
|
+
/* @__PURE__ */ jsx("i", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "var(--teal)", boxShadow: `0 0 0 3px ${soft("--teal", 25)}` } }),
|
|
187
|
+
label
|
|
188
|
+
] });
|
|
189
|
+
}
|
|
190
|
+
var buttonStyle = { font: "inherit", fontSize: "12px", fontWeight: 550, borderRadius: "8px", padding: "5px 11px", border: "1px solid var(--hair-2)", background: "var(--card-2, var(--elev))", color: "var(--ink)", cursor: "pointer", whiteSpace: "nowrap" };
|
|
191
|
+
var ghostStyle = { ...buttonStyle, border: "1px solid transparent", background: "transparent", color: "var(--ink-2)" };
|
|
192
|
+
var primaryStyle = { ...buttonStyle, background: "var(--blue)", borderColor: "transparent", color: "#fff", boxShadow: `0 2px 8px ${soft("--blue", 35)}` };
|
|
193
|
+
var Btn = ({ label, style = buttonStyle, disabled, title, onClick }) => /* @__PURE__ */ jsx("button", { type: "button", title, disabled, style: { ...style, opacity: disabled ? 0.55 : 1, cursor: disabled ? "default" : "pointer", transition: "opacity .2s var(--ease)" }, onClick, children: label });
|
|
194
|
+
function ProjectPicker({ projects, value, onChange }) {
|
|
195
|
+
return /* @__PURE__ */ jsxs("select", { "aria-label": "Project", value, onChange: (e) => onChange(e.target.value), style: { font: "inherit", fontSize: "12px", padding: "4px 6px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: [
|
|
196
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Project\u2026" }),
|
|
197
|
+
projects.map((p) => /* @__PURE__ */ jsx("option", { value: p, children: p }, p))
|
|
198
|
+
] });
|
|
199
|
+
}
|
|
200
|
+
function outcome(item) {
|
|
201
|
+
const s = item.startedSession;
|
|
202
|
+
const where = s ? `${s.project} / ${s.sessionDir}` : "";
|
|
203
|
+
if (item.kind === "research") return /* @__PURE__ */ jsx(LiveChip, { label: `Researching${where ? ` \xB7 ${where}` : ""}` });
|
|
204
|
+
if (item.kind === "to-task") return /* @__PURE__ */ jsx("span", { style: { fontSize: "11.5px", color: "var(--green)" }, children: "Sent" });
|
|
205
|
+
return /* @__PURE__ */ jsxs("span", { style: { fontSize: "11.5px", color: "var(--green)" }, children: [
|
|
206
|
+
"Started",
|
|
207
|
+
where ? ` \xB7 ${where}` : ""
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
210
|
+
var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
211
|
+
const [project, setProject] = useState(item.project ?? "");
|
|
212
|
+
const open = item.state === "proposed" || item.state === "failed";
|
|
213
|
+
const needsProject = startsTask(item.kind) && !item.project;
|
|
214
|
+
const op = opFor(item, project);
|
|
215
|
+
const where = item.source === "slack" ? "in" : "on";
|
|
216
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "30px 1fr auto", gap: "12px", alignItems: "center", padding: "10px 12px", borderRadius: "11px", background: soft("--ink", 3), border: "1px solid var(--hair)", opacity: item.state === "dismissed" ? 0.55 : 1, transition: "background .2s var(--ease)" }, children: [
|
|
217
|
+
/* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
|
|
218
|
+
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
219
|
+
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
220
|
+
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
221
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item.title })
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
224
|
+
/* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
225
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
226
|
+
item.who,
|
|
227
|
+
" ",
|
|
228
|
+
where,
|
|
229
|
+
" ",
|
|
230
|
+
strong(item.where)
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
233
|
+
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
234
|
+
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
235
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
236
|
+
/* @__PURE__ */ jsx(AccountChip, { account: item.account })
|
|
237
|
+
] }),
|
|
238
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
239
|
+
/* @__PURE__ */ jsxs("a", { href: item.link, target: "_blank", rel: "noopener noreferrer", style: { color: "var(--ink-2)", textDecoration: "none", borderBottom: "1px dotted var(--ink-3)" }, children: [
|
|
240
|
+
"View in ",
|
|
241
|
+
SOURCE_LABEL[item.source],
|
|
242
|
+
" \u2197"
|
|
243
|
+
] }),
|
|
244
|
+
item.kind === "to-task" && item.targetSession && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
245
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
246
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
247
|
+
"goes to ",
|
|
248
|
+
strong(item.targetSession.sessionDir)
|
|
249
|
+
] })
|
|
250
|
+
] }),
|
|
251
|
+
item.project && item.kind !== "to-task" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
252
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
253
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
254
|
+
"project ",
|
|
255
|
+
strong(item.project)
|
|
256
|
+
] })
|
|
257
|
+
] })
|
|
258
|
+
] }),
|
|
259
|
+
item.quote && /* @__PURE__ */ jsxs("div", { style: { marginTop: "6px", fontSize: "12px", color: "var(--ink-2)", borderLeft: "2px solid var(--hair-2)", paddingLeft: "8px", fontStyle: "italic" }, children: [
|
|
260
|
+
"\u201C",
|
|
261
|
+
item.quote,
|
|
262
|
+
"\u201D"
|
|
263
|
+
] }),
|
|
264
|
+
item.error && /* @__PURE__ */ jsx("div", { style: { marginTop: "6px", fontSize: "11.5px", color: "var(--red)" }, children: item.error })
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
267
|
+
/* @__PURE__ */ jsx(KindPill, { kind: item.kind }),
|
|
268
|
+
open && needsProject && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
|
|
269
|
+
open && /* @__PURE__ */ jsx(Btn, { label: item.state === "failed" ? "Retry" : KIND[item.kind].verb, disabled: acting.busy || !op, onClick: () => op && acting.act(item, op, needsProject ? project : void 0) }),
|
|
270
|
+
open && /* @__PURE__ */ jsx(Btn, { label: "Dismiss", style: ghostStyle, disabled: acting.busy, onClick: () => acting.act(item, "dismiss") }),
|
|
271
|
+
item.state === "done" && outcome(item),
|
|
272
|
+
item.state === "done" && item.startedSession && /* @__PURE__ */ jsx(Btn, { label: "Open session", onClick: () => forge.openSession(item.startedSession.project, item.startedSession.sessionDir) }),
|
|
273
|
+
item.state === "dismissed" && /* @__PURE__ */ jsx("span", { style: { fontSize: "11.5px", color: "var(--ink-3)" }, children: "Dismissed" })
|
|
274
|
+
] })
|
|
275
|
+
] });
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// src/view.tsx
|
|
279
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
280
|
+
function View({ forge }) {
|
|
281
|
+
const [days, setDays] = useState2([]);
|
|
282
|
+
const [day, setDay] = useState2(null);
|
|
283
|
+
const { reply, error, reload } = useDigest(forge, day ? `/digest/${day}` : "/digest");
|
|
284
|
+
const projects = useProjects(forge);
|
|
285
|
+
const digest = reply?.digest;
|
|
286
|
+
const acting = useActing(forge, digest?.date, reload);
|
|
287
|
+
const notes = notesLine(digest?.notes);
|
|
288
|
+
const enabled = reply?.enabled === true;
|
|
289
|
+
useEffect2(() => {
|
|
290
|
+
forge.route("/days").then((r) => setDays(r.days), () => {
|
|
291
|
+
});
|
|
292
|
+
}, [forge, digest?.readAt]);
|
|
293
|
+
return /* @__PURE__ */ jsxs2("div", { style: { padding: "22px", display: "flex", flexDirection: "column", gap: "16px", maxWidth: "1180px" }, children: [
|
|
294
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
295
|
+
days.length > 0 && /* @__PURE__ */ jsx2("select", { "aria-label": "Day", value: digest?.date ?? "", onChange: (e) => setDay(e.target.value), style: { font: "inherit", fontSize: "12.5px", padding: "5px 8px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: days.map((d) => /* @__PURE__ */ jsx2("option", { value: d, children: d }, d)) }),
|
|
296
|
+
digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
297
|
+
/* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
298
|
+
/* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
299
|
+
enabled && /* @__PURE__ */ jsx2(ActionButton, { label: "Read now", variant: "primary", size: "sm", loading: acting.refreshing, onClick: acting.refresh }),
|
|
300
|
+
reply && /* @__PURE__ */ jsx2(ActionButton, { label: enabled ? "Turn off" : "Turn on", variant: enabled ? "secondary" : "primary", size: "sm", disabled: acting.busy, onClick: () => acting.run(() => forge.action(enabled ? "disable" : "enable")) })
|
|
301
|
+
] })
|
|
302
|
+
] }),
|
|
303
|
+
reply && !enabled && /* @__PURE__ */ jsx2("div", { style: { padding: "12px 14px", borderRadius: "10px", fontSize: "12.5px", lineHeight: 1.5, color: "var(--ink-2)", background: "var(--card)", border: "1px solid var(--hair)", maxWidth: "640px" }, children: "Today is off. Turned on, it reads your Linear, Slack and GitHub each morning and whenever you press Read now. Each reading spends your account's usage. Research it proposes can start sessions on its own, a few a day." }),
|
|
304
|
+
(error || digest?.error) && /* @__PURE__ */ jsx2("div", { style: { padding: "10px 12px", borderRadius: "10px", fontSize: "12px", color: "var(--red)", background: "var(--card)", border: "1px solid color-mix(in srgb, var(--red) 45%, var(--hair))" }, children: error ? loadFailedLine(error) : failedLine(digest.error) }),
|
|
305
|
+
notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
|
|
306
|
+
!digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
307
|
+
account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
|
|
308
|
+
sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
309
|
+
/* @__PURE__ */ jsxs2("h4", { style: { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" }, children: [
|
|
310
|
+
title,
|
|
311
|
+
" \xB7 ",
|
|
312
|
+
items.length
|
|
313
|
+
] }),
|
|
314
|
+
items.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id))
|
|
315
|
+
] }, title))
|
|
316
|
+
] }, account ?? ""))
|
|
317
|
+
] });
|
|
318
|
+
}
|
|
319
|
+
var view_default = definePanel({ id: "main", title: "Today", component: View });
|
|
320
|
+
export {
|
|
321
|
+
view_default as default
|
|
322
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "today",
|
|
3
|
+
"name": "@forge-dev/mod-today",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"sdk": "^1.1.0",
|
|
6
|
+
"displayName": "Today",
|
|
7
|
+
"description": "A daily digest of your Linear, Slack and GitHub, read by a headless agent",
|
|
8
|
+
"server": "./dist/server.js",
|
|
9
|
+
"view": {
|
|
10
|
+
"entry": "./dist/view.js",
|
|
11
|
+
"title": "Today",
|
|
12
|
+
"banner": "./dist/banner.js"
|
|
13
|
+
},
|
|
14
|
+
"permissions": {
|
|
15
|
+
"agent": true,
|
|
16
|
+
"shell": [
|
|
17
|
+
"gh"
|
|
18
|
+
],
|
|
19
|
+
"cw": [
|
|
20
|
+
"start",
|
|
21
|
+
"send"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"settings": {
|
|
25
|
+
"schema": {
|
|
26
|
+
"accounts": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"label": "Accounts",
|
|
29
|
+
"help": "Comma separated CW accounts to read; empty reads every Claude account",
|
|
30
|
+
"default": ""
|
|
31
|
+
},
|
|
32
|
+
"time": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"label": "Read at",
|
|
35
|
+
"help": "Local time, HH:MM",
|
|
36
|
+
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
|
|
37
|
+
"default": "08:00"
|
|
38
|
+
},
|
|
39
|
+
"autoResearch": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"label": "Start research on its own",
|
|
42
|
+
"default": true
|
|
43
|
+
},
|
|
44
|
+
"maxAuto": {
|
|
45
|
+
"type": "number",
|
|
46
|
+
"label": "Research sessions per day",
|
|
47
|
+
"min": 0,
|
|
48
|
+
"max": 20,
|
|
49
|
+
"default": 3
|
|
50
|
+
},
|
|
51
|
+
"researchProject": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"label": "Research folder",
|
|
54
|
+
"help": "CW project whose folder research sessions use; empty uses your home folder",
|
|
55
|
+
"format": "cw-project",
|
|
56
|
+
"default": ""
|
|
57
|
+
},
|
|
58
|
+
"model": {
|
|
59
|
+
"type": "enum",
|
|
60
|
+
"label": "Reader model",
|
|
61
|
+
"values": [
|
|
62
|
+
"sonnet",
|
|
63
|
+
"opus",
|
|
64
|
+
"haiku"
|
|
65
|
+
],
|
|
66
|
+
"default": "sonnet"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@forge-dev/mod-today",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "Today: a daily digest of Linear and Slack read by a headless agent",
|
|
7
|
+
"keywords": ["forge-module"],
|
|
8
|
+
"forge": { "manifest": "forge-module.json" },
|
|
9
|
+
"files": ["dist", "forge-module.json"],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "node build.mjs",
|
|
12
|
+
"dev": "node build.mjs --watch",
|
|
13
|
+
"test": "tsc --noEmit && vitest run"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": { "@forge-dev/sdk": "workspace:*", "@forge-dev/ui": "workspace:*", "preact": "^10.0.0" },
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@forge-dev/sdk": "workspace:*",
|
|
18
|
+
"@forge-dev/ui": "workspace:*",
|
|
19
|
+
"@preact/signals": "^2.0.0",
|
|
20
|
+
"@types/node": "^22.0.0",
|
|
21
|
+
"esbuild": "^0.25.0",
|
|
22
|
+
"preact": "^10.25.0",
|
|
23
|
+
"typescript": "^5.8.0",
|
|
24
|
+
"vitest": "^4.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|