@bigmistqke/workpad 0.19.0 → 0.20.1
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/README.md +29 -16
- package/bin/workpad.ts +193 -37
- package/dist/bin/workpad.js +161 -32
- package/dist/client/runtime.js +141 -18
- package/dist/plugins/chat/README.md +7 -3
- package/dist/plugins/chat/index.js +1 -0
- package/dist/plugins/chat/public/client.js +2 -2
- package/dist/plugins/chat/public/style.css +10 -0
- package/dist/plugins/claude/channel.js +22 -4
- package/dist/plugins/claude/doctor.js +15 -5
- package/dist/plugins/comments/README.md +2 -1
- package/dist/plugins/comments/index.js +2 -0
- package/dist/plugins/comments/public/client.js +6 -5
- package/dist/plugins/comments/public/style.css +9 -0
- package/dist/plugins/form/README.md +1 -1
- package/dist/plugins/index.js +3 -1
- package/dist/plugins/opencode/channel.js +1 -0
- package/dist/plugins/progress/README.md +41 -0
- package/dist/plugins/progress/index.js +117 -0
- package/dist/plugins/progress/public/client.js +1 -0
- package/dist/plugins/progress/public/style.css +85 -0
- package/dist/plugins/progress/state.js +210 -0
- package/dist/solid/index.js +3 -1
- package/dist/src/agents.js +7 -3
- package/dist/src/anchors.js +25 -1
- package/dist/src/build.js +1 -1
- package/dist/src/client/page/base.css +48 -2
- package/dist/src/client/page/main.js +58 -30
- package/dist/src/document.js +6 -4
- package/dist/src/entries.js +6 -2
- package/dist/src/events.js +19 -9
- package/dist/src/files.js +26 -3
- package/dist/src/help.js +43 -8
- package/dist/src/hub.js +20 -4
- package/dist/src/loader.js +11 -6
- package/dist/src/migrate.js +1 -1
- package/dist/src/pages/board.js +1 -1
- package/dist/src/pages/markdown.js +3 -3
- package/dist/src/pages/render.js +16 -0
- package/dist/src/server.js +70 -32
- package/dist/src/set.js +99 -0
- package/dist/src/status.js +47 -8
- package/package.json +6 -1
- package/plugins/README.md +3 -1
- package/plugins/chat/README.md +7 -3
- package/plugins/chat/client.tsx +20 -3
- package/plugins/chat/index.ts +1 -0
- package/plugins/chat/public/style.css +10 -0
- package/plugins/claude/channel.ts +19 -5
- package/plugins/claude/doctor.ts +11 -3
- package/plugins/comments/README.md +2 -1
- package/plugins/comments/client.ts +19 -0
- package/plugins/comments/index.ts +7 -1
- package/plugins/comments/public/style.css +9 -0
- package/plugins/form/README.md +1 -1
- package/plugins/index.ts +2 -0
- package/plugins/opencode/channel.ts +2 -1
- package/plugins/progress/README.md +41 -0
- package/plugins/progress/client.ts +172 -0
- package/plugins/progress/index.ts +166 -0
- package/plugins/progress/public/style.css +85 -0
- package/plugins/progress/state.ts +278 -0
- package/skills/workpad/SKILL.md +126 -15
- package/solid/index.tsx +6 -2
- package/src/agents.ts +17 -2
- package/src/anchors.ts +32 -0
- package/src/build.ts +1 -1
- package/src/client/delivery.ts +49 -0
- package/src/client/forms.ts +18 -11
- package/src/client/page/base.css +48 -2
- package/src/client/page/waiting.ts +45 -25
- package/src/client/read.ts +9 -5
- package/src/client/runtime.ts +7 -3
- package/src/client/toast.ts +27 -3
- package/src/define.ts +92 -8
- package/src/document.ts +19 -5
- package/src/entries.ts +18 -7
- package/src/events.ts +26 -6
- package/src/files.ts +28 -2
- package/src/help.ts +42 -7
- package/src/hub.ts +25 -8
- package/src/loader.ts +20 -10
- package/src/migrate.ts +1 -1
- package/src/pages/board.ts +3 -1
- package/src/pages/markdown.ts +4 -4
- package/src/pages/render.ts +19 -1
- package/src/server.ts +114 -42
- package/src/set.ts +118 -0
- package/src/status.ts +100 -13
|
@@ -801,25 +801,44 @@ function setThemePreference(pref) {
|
|
|
801
801
|
}
|
|
802
802
|
// src/status.ts
|
|
803
803
|
/**
|
|
804
|
+
* Can this be a question's name, the type of its answers? Not with a colon: types with one belong
|
|
805
|
+
* to workpad (`workpad:handled`) or a plugin (`comments:reply`, `chat:message`),
|
|
806
|
+
* named after its owner, so a form's answers never mix with their events.
|
|
807
|
+
*/
|
|
808
|
+
const isQuestionName = (name) => !!name && !name.includes(":");
|
|
809
|
+
/**
|
|
804
810
|
* Was this event written by the reader (a form submit, a comment), not by an agent? Agents write
|
|
805
811
|
* through the command line, which marks its events `from: 'cli'`: an agent's reply, a claim, a mark.
|
|
806
812
|
*/
|
|
807
813
|
const fromReader = (event) => event.from !== "cli";
|
|
808
814
|
/**
|
|
809
|
-
* The
|
|
810
|
-
*
|
|
811
|
-
|
|
812
|
-
|
|
815
|
+
* The fields of an event's `data` its type requires (EventSpec.requires) that it lacks: each must
|
|
816
|
+
* be a non-empty string.
|
|
817
|
+
*/
|
|
818
|
+
const missingData = (data, requires) => requires.filter((field) => {
|
|
819
|
+
const value = data?.[field];
|
|
820
|
+
return typeof value !== "string" || !value.trim();
|
|
821
|
+
});
|
|
822
|
+
/**
|
|
823
|
+
* The agent's messages on a page the reader hasn't read: events from the agent of a type in
|
|
824
|
+
* `messages` (the types for the reader, each with the `data` fields it requires), not named by a
|
|
825
|
+
* `workpad:read` from the reader, not replaced by a later one (`replaces`), with the data their
|
|
826
|
+
* type requires (one without it shows nowhere on the page, so it waits for nobody), and, given the
|
|
827
|
+
* page's `chats`, not in a chat (`data.chat`) that is no longer among them.
|
|
813
828
|
*/
|
|
814
|
-
function unreadMessages(events,
|
|
829
|
+
function unreadMessages(events, messages, chats) {
|
|
815
830
|
const read = /* @__PURE__ */ new Set();
|
|
816
831
|
const replaced = /* @__PURE__ */ new Set();
|
|
817
832
|
for (const e of events) {
|
|
818
833
|
if (e.type === "workpad:read" && fromReader(e)) for (const id of e.data?.ids ?? []) read.add(String(id));
|
|
819
834
|
if (e.data?.replaces) replaced.add(String(e.data.replaces));
|
|
820
835
|
}
|
|
836
|
+
const shown = (e) => {
|
|
837
|
+
const requires = messages.get(e.type);
|
|
838
|
+
return !!requires && !missingData(e.data, requires).length;
|
|
839
|
+
};
|
|
821
840
|
const offPage = (e) => !!chats && typeof e.data?.chat === "string" && !chats.has(e.data.chat);
|
|
822
|
-
return events.filter((e) => !fromReader(e) &&
|
|
841
|
+
return events.filter((e) => !fromReader(e) && shown(e) && !read.has(e.id) && !replaced.has(e.id) && !offPage(e));
|
|
823
842
|
}
|
|
824
843
|
/** How many things on a page wait for the reader: its open questions and unread messages. */
|
|
825
844
|
const awaiting = (p) => p.open.length + p.unread.length;
|
|
@@ -985,6 +1004,7 @@ function targets(kind = "all") {
|
|
|
985
1004
|
}
|
|
986
1005
|
let waitingToast;
|
|
987
1006
|
let unreadToast;
|
|
1007
|
+
let lateToast;
|
|
988
1008
|
let toastTimer = 0;
|
|
989
1009
|
let unreadShown = false;
|
|
990
1010
|
let dismissed = null;
|
|
@@ -1004,7 +1024,8 @@ function card(form, name, last, state) {
|
|
|
1004
1024
|
const choices = el.querySelector(".wp-folded-choices");
|
|
1005
1025
|
choices.replaceChildren(...list.map((c) => Object.assign(document.createElement("li"), { textContent: c })));
|
|
1006
1026
|
choices.hidden = !list.length;
|
|
1007
|
-
|
|
1027
|
+
const received = api$1.delivery().get(last.id)?.text ?? "received";
|
|
1028
|
+
el.querySelector(".wp-folded-change").textContent = `${state === "received" ? received : "decided"} · change`;
|
|
1008
1029
|
const text = el.querySelector(".wp-folded-text");
|
|
1009
1030
|
text.textContent = written.join("\n\n");
|
|
1010
1031
|
text.hidden = !written.length;
|
|
@@ -1042,6 +1063,11 @@ function show(list = forms) {
|
|
|
1042
1063
|
waitingToast.show();
|
|
1043
1064
|
} else waitingToast.hide();
|
|
1044
1065
|
api$1.badge("waiting", n ? `!${n}` : null, -1);
|
|
1066
|
+
const late = lateAnswers().length;
|
|
1067
|
+
if (late) {
|
|
1068
|
+
lateToast.update(`→ not received (${late})`);
|
|
1069
|
+
lateToast.show();
|
|
1070
|
+
} else lateToast.hide();
|
|
1045
1071
|
clearTimeout(toastTimer);
|
|
1046
1072
|
const ids = api$1.unread().map((e) => e.id);
|
|
1047
1073
|
if (dismissed && (!unread || ids.some((id) => !dismissed.has(id)))) dismissed = null;
|
|
@@ -1065,6 +1091,19 @@ function show(list = forms) {
|
|
|
1065
1091
|
});
|
|
1066
1092
|
}
|
|
1067
1093
|
}
|
|
1094
|
+
/**
|
|
1095
|
+
* The reader's answers no agent received for long (late): each of a form only its latest (an older
|
|
1096
|
+
* answer was overtaken by it), every chat message and comment.
|
|
1097
|
+
*/
|
|
1098
|
+
function lateAnswers() {
|
|
1099
|
+
const delivery = api$1.delivery();
|
|
1100
|
+
return api$1.events().filter((e) => delivery.get(e.id)?.state === "late" && (!isQuestionName(e.type) || api$1.last(e.type)?.id === e.id));
|
|
1101
|
+
}
|
|
1102
|
+
/** Where the late answers are on the page, top to bottom: a form's line goes to its form. */
|
|
1103
|
+
function lateTargets() {
|
|
1104
|
+
const top = (el) => el.getBoundingClientRect().top;
|
|
1105
|
+
return [...new Set([...document.querySelectorAll("[data-wp-delivery=late]")].filter((el) => el.getClientRects().length).map((el) => el.closest("form") ?? el))].sort((a, b) => top(a) - top(b));
|
|
1106
|
+
}
|
|
1068
1107
|
let arriving = location.hash === WAITING_HASH;
|
|
1069
1108
|
setTimeout(() => {
|
|
1070
1109
|
arriving = false;
|
|
@@ -1077,7 +1116,7 @@ function next(list) {
|
|
|
1077
1116
|
return list.find((f) => f.getBoundingClientRect().top > viewBottom() / 2) ?? list[0];
|
|
1078
1117
|
}
|
|
1079
1118
|
function jump(what) {
|
|
1080
|
-
const target = next(what === "messages" ? targets("messages") : inState("open"));
|
|
1119
|
+
const target = next(what === "messages" ? targets("messages") : what === "late" ? lateTargets() : inState("open"));
|
|
1081
1120
|
if (target) jumpTo(target);
|
|
1082
1121
|
}
|
|
1083
1122
|
function jumpTo(target) {
|
|
@@ -1111,8 +1150,16 @@ function trackWaiting(root, core) {
|
|
|
1111
1150
|
unreadShown = false;
|
|
1112
1151
|
}
|
|
1113
1152
|
});
|
|
1153
|
+
lateToast = api$1.toast("", {
|
|
1154
|
+
ms: 0,
|
|
1155
|
+
kind: "warn",
|
|
1156
|
+
name: "not-received",
|
|
1157
|
+
order: -1,
|
|
1158
|
+
onClick: () => jump("late")
|
|
1159
|
+
});
|
|
1114
1160
|
waitingToast.hide();
|
|
1115
1161
|
unreadToast.hide();
|
|
1162
|
+
lateToast.hide();
|
|
1116
1163
|
main$2.addEventListener("click", (e) => {
|
|
1117
1164
|
const target = e.target;
|
|
1118
1165
|
const form = target.closest("form[data-wp-folded]");
|
|
@@ -1142,27 +1189,8 @@ function trackWaiting(root, core) {
|
|
|
1142
1189
|
});
|
|
1143
1190
|
api$1.forms.on(show);
|
|
1144
1191
|
api$1.events.on(() => show());
|
|
1192
|
+
api$1.delivery.on(() => show());
|
|
1145
1193
|
show(api$1.forms());
|
|
1146
|
-
document.addEventListener("submit", (e) => {
|
|
1147
|
-
const form = e.target;
|
|
1148
|
-
const name = form.getAttribute("name");
|
|
1149
|
-
if (!name || !main$2.contains(form) || !forms.some((f) => f.form === form)) return;
|
|
1150
|
-
if (api$1.listeners().some((l) => l.type === name || l.type === null)) return;
|
|
1151
|
-
const sent = new MutationObserver(() => {
|
|
1152
|
-
if (form.dataset.wpState === "sending") return;
|
|
1153
|
-
sent.disconnect();
|
|
1154
|
-
if (form.dataset.wpState !== "sent") return;
|
|
1155
|
-
api$1.toast("Sent · nobody listening", {
|
|
1156
|
-
kind: "warn",
|
|
1157
|
-
name: "sent",
|
|
1158
|
-
details: "Your answer stays in the log until someone listens on this page."
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
sent.observe(form, {
|
|
1162
|
-
attributes: true,
|
|
1163
|
-
attributeFilter: ["data-wp-state"]
|
|
1164
|
-
});
|
|
1165
|
-
}, { capture: true });
|
|
1166
1194
|
}
|
|
1167
1195
|
// src/client/page/live.ts
|
|
1168
1196
|
/** A button that copies an agent's id, a check for a moment once it did. */
|
|
@@ -1743,11 +1771,11 @@ function trackHeadingLinks(main) {
|
|
|
1743
1771
|
});
|
|
1744
1772
|
}
|
|
1745
1773
|
// src/client/read.ts
|
|
1746
|
-
let
|
|
1774
|
+
let messages = /* @__PURE__ */ new Map();
|
|
1747
1775
|
let getEvents = () => [];
|
|
1748
1776
|
let chats = () => null;
|
|
1749
1777
|
const sending = /* @__PURE__ */ new Set();
|
|
1750
|
-
const unread = () => unreadMessages(getEvents(),
|
|
1778
|
+
const unread = () => unreadMessages(getEvents(), messages, chats()).filter((e) => !sending.has(e.id));
|
|
1751
1779
|
/**
|
|
1752
1780
|
* The chats the page's content shows, by name: the one under every form and each chat block; null
|
|
1753
1781
|
* while there is no page content (a folder, raw text), when every chat's messages count.
|
package/dist/src/document.js
CHANGED
|
@@ -19,7 +19,7 @@ const BODY_SLOTS = [
|
|
|
19
19
|
* null for a page no browser asked for), and its browser module. One that failed to start or fails
|
|
20
20
|
* here is left out and told to `failed`; so are those in `leaveOut` (a build's skip), silently.
|
|
21
21
|
*/
|
|
22
|
-
async function pluginParts(hooks, req, { asset, messages, leaveOut = /* @__PURE__ */ new Set(), failed }) {
|
|
22
|
+
async function pluginParts(hooks, req, { asset, messages, handedOut = [], leaveOut = /* @__PURE__ */ new Set(), failed }) {
|
|
23
23
|
const included = hooks.filter((h) => !leaveOut.has(h.name));
|
|
24
24
|
for (const h of included) if (h.error) failed(`plugin "${h.name}" failed to start: ${h.error.message}`);
|
|
25
25
|
const working = included.filter((h) => !h.error);
|
|
@@ -50,14 +50,15 @@ async function pluginParts(hooks, req, { asset, messages, leaveOut = /* @__PURE_
|
|
|
50
50
|
name: h.name,
|
|
51
51
|
client: asset(h.client)
|
|
52
52
|
})),
|
|
53
|
-
messages
|
|
53
|
+
messages,
|
|
54
|
+
handedOut
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
/** A stored page's frontmatter, for the browser (PageHandle.frontmatter): a markdown page's, else none. */
|
|
57
58
|
const frontmatterOf = (page) => page.kind === "page" ? page.frontmatter : {};
|
|
58
59
|
/** JSON made safe inside a <script>. */
|
|
59
60
|
const json = (s) => JSON.stringify(s).replace(/</g, "\\u003c");
|
|
60
|
-
const DOCK_STYLE = "#wp-dock{position:fixed;right:16px;bottom:calc(16px + var(--wp-inset-bottom,0px));z-index:30;display:flex;flex-direction:column;align-items:flex-end;gap:6px}#wp-dock:not(:has(> :not(:empty))){display:none}[data-wp-slot]:not(#wp-dock),[data-wp-slot]>[data-plugin]{display:contents}.wp-toasts{display:flex;flex-direction:column;align-items:flex-end;gap:6px}.wp-toasts:empty{display:none}.wp-toast{display:inline-flex;align-items:center;gap:8px;cursor:pointer;padding:5px 12px;border-radius:99px;font:600 .8rem/1.4 var(--sans,system-ui,sans-serif);background:var(--accent,#1d5bbf);color:var(--accent-text,#fff);border:1px solid transparent;box-shadow:0 2px 10px rgb(0 0 0/.18)}.wp-toast[hidden]{display:none}.wp-toast[data-kind=warn]{background:var(--warn,#6b4fc0)}.wp-toast[data-kind=alert]{background:var(--bad,#c4352b);color:#fff}@keyframes wp-flash{from{outline-color:var(--accent,#1d5bbf)}to{outline-color:transparent}}.wp-flash{outline:3px solid transparent;outline-offset:6px;border-radius:4px;animation:wp-flash 2s ease-out}.wp-toast-dismiss{margin-right:-4px;padding:0 4px;border-left:1px solid rgb(255 255 255/.35);opacity:.75}.wp-toast-dismiss:hover{opacity:1}.wp-toast{max-width:min(24rem,calc(100vw - 32px));text-align:left}.wp-toast-more{margin:0 -4px 0 -2px;padding:0 4px;opacity:.75}.wp-toast-more:hover{opacity:1}.wp-toast[data-open]{flex-wrap:wrap;border-radius:12px}.wp-toast-details{flex-basis:100%;padding:2px 0 3px;font-weight:400;cursor:text}.wp-toast-details[hidden]{display:none}";
|
|
61
|
+
const DOCK_STYLE = "#wp-dock{position:fixed;right:16px;bottom:calc(16px + var(--wp-inset-bottom,0px));z-index:30;display:flex;flex-direction:column;align-items:flex-end;gap:6px}#wp-dock:not(:has(> :not(:empty))){display:none}[data-wp-slot]:not(#wp-dock),[data-wp-slot]>[data-plugin]{display:contents}.wp-toasts{display:flex;flex-direction:column;align-items:flex-end;gap:6px}.wp-toasts:empty{display:none}.wp-toast{display:inline-flex;align-items:center;gap:8px;cursor:pointer;padding:5px 12px;border-radius:99px;font:600 .8rem/1.4 var(--sans,system-ui,sans-serif);background:var(--accent,#1d5bbf);color:var(--accent-text,#fff);border:1px solid transparent;box-shadow:0 2px 10px rgb(0 0 0/.18)}.wp-toast[hidden]{display:none}.wp-toast[data-kind=warn]{background:var(--warn,#6b4fc0)}.wp-toast[data-kind=alert]{background:var(--bad,#c4352b);color:#fff}@keyframes wp-flash{from{outline-color:var(--accent,#1d5bbf)}to{outline-color:transparent}}.wp-flash{outline:3px solid transparent;outline-offset:6px;border-radius:4px;animation:wp-flash 2s ease-out}.wp-toast-dismiss{margin-right:-4px;padding:0 4px;border-left:1px solid rgb(255 255 255/.35);opacity:.75}.wp-toast-dismiss:hover{opacity:1}.wp-toast{max-width:min(24rem,calc(100vw - 32px));text-align:left}.wp-toast-more{margin:0 -4px 0 -2px;padding:0 4px;opacity:.75}.wp-toast-more:hover{opacity:1}.wp-toast[data-open]{flex-wrap:wrap;border-radius:12px}.wp-toast-details{flex-basis:100%;padding:2px 0 3px;font-weight:400;cursor:text}.wp-toast-details[hidden]{display:none}.wp-toast[data-kind=quiet]{display:grid;grid-template-columns:1fr auto;align-items:baseline;gap:4px 12px;width:230px;max-width:calc(100vw - 32px);padding:8px 12px 9px;border-radius:10px;background:var(--surface,#fff);color:var(--text,#1b1c1e);border:1px solid var(--border,#e3e5e9);box-shadow:0 4px 16px rgb(0 0 0/.14);font-weight:500}.wp-toast-meta{color:var(--muted,#696e76);font-weight:400;white-space:nowrap;text-align:right}.wp-toast[data-kind=quiet]:not(:has(.wp-toast-meta)) .wp-toast-text{grid-column:1/-1}.wp-toast-bar{grid-column:1/-1;position:relative;height:3px;margin-top:3px;border-radius:2px;overflow:hidden;background:color-mix(in srgb,var(--muted,#696e76) 28%,transparent)}.wp-toast-bar span{position:absolute;inset:0 auto 0 0;width:var(--wp-toast-bar,0%);border-radius:inherit;background:var(--accent,#1d5bbf)}.wp-toast-bar[data-tone=good] span{background:var(--ok,#1a7a49)}.wp-toast-bar[data-tone=bad] span{background:var(--bad,#c4352b)}@keyframes wp-toast-stripe{from{left:-30%}to{left:100%}}.wp-toast-bar[data-indeterminate] span{width:30%;animation:wp-toast-stripe 1.6s ease-in-out infinite}@media (prefers-reduced-motion:reduce){.wp-toast-bar[data-indeterminate] span{animation:none;left:0;width:100%;opacity:.5}}";
|
|
61
62
|
/** Each plugin's own element in a slot, with what it rendered there. */
|
|
62
63
|
const slotted = (list) => list.map((x) => html`<div data-plugin="${x.name}">${x.html}</div>`);
|
|
63
64
|
/** A page as a document: the render, the plugins' parts, and the handoff for the browser runtime. */
|
|
@@ -72,6 +73,7 @@ function pageDocument(page, { page: rendered, out, notices }, parts, o) {
|
|
|
72
73
|
frontmatter: frontmatterOf(page),
|
|
73
74
|
plugins: parts.clients,
|
|
74
75
|
messages: parts.messages,
|
|
76
|
+
handedOut: parts.handedOut,
|
|
75
77
|
...o.stamps && { stamps: o.stamps }
|
|
76
78
|
};
|
|
77
79
|
return String(html(_templateObject || (_templateObject = _taggedTemplateLiteral([
|
|
@@ -88,6 +90,6 @@ function pageDocument(page, { page: rendered, out, notices }, parts, o) {
|
|
|
88
90
|
"\n <\/script>\n <script type=\"module\" src=\"",
|
|
89
91
|
"\"><\/script>\n ",
|
|
90
92
|
"\n </body>\n </html>"
|
|
91
|
-
])), out.title || page.id || o.title, DOCK_STYLE, raw(String(out.head ?? "")), parts.head, page.id, page.kind, notices.map((n) => html`<pre class="wp-error" role="alert">${n}</pre>`), raw(String(out.html)), slotted(parts.slots.corner), raw(json(handoff)), o.runtime, BODY_SLOTS.map((name) => html`<div data-wp-slot="${name}">${slotted(parts.slots[name])}</div>`)));
|
|
93
|
+
])), out.title || page.id || o.title, raw(DOCK_STYLE), raw(String(out.head ?? "")), parts.head, page.id, page.kind, notices.map((n) => html`<pre class="wp-error" role="alert">${n}</pre>`), raw(String(out.html)), slotted(parts.slots.corner), raw(json(handoff)), o.runtime, BODY_SLOTS.map((name) => html`<div data-wp-slot="${name}">${slotted(parts.slots[name])}</div>`)));
|
|
92
94
|
}
|
|
93
95
|
export { PAGE_CLIENT, RUNTIME, frontmatterOf, pageDocument, pluginParts };
|
package/dist/src/entries.js
CHANGED
|
@@ -69,11 +69,15 @@ function readMachineConfig(dir = machineDir()) {
|
|
|
69
69
|
if (!Array.isArray(v) || v.some((x) => typeof x !== "string")) throw new Error(`${file}: entries.${name}.${what} must be a list of globs`);
|
|
70
70
|
return v;
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
const files = e?.files;
|
|
73
|
+
if (files != null && typeof files !== "boolean" && (typeof files !== "object" || Array.isArray(files))) throw new Error(`${file}: entries.${name}.files must be true, false or { "include": [...], "exclude": [...] }`);
|
|
73
74
|
entries[name] = {
|
|
74
75
|
include: list(e?.include, "include"),
|
|
75
76
|
exclude: list(e?.exclude, "exclude"),
|
|
76
|
-
...
|
|
77
|
+
...files != null && { files: typeof files === "boolean" ? files : {
|
|
78
|
+
...files.include != null && { include: list(files.include, "files.include") },
|
|
79
|
+
...files.exclude != null && { exclude: list(files.exclude, "files.exclude") }
|
|
80
|
+
} }
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
const port = raw.port == null ? void 0 : Number(raw.port);
|
package/dist/src/events.js
CHANGED
|
@@ -7,9 +7,11 @@ const isEventId = (id) => typeof id === "string" && /^[0-9a-z]{6,12}-[0-9a-f]{6,
|
|
|
7
7
|
/**
|
|
8
8
|
* Append one event; `action` is the button that submitted a form, null for anything else. `from`
|
|
9
9
|
* is set only for events the command line writes ('cli'), so that waits skip them and pages can
|
|
10
|
-
* tell them apart; what the browser appends has none.
|
|
10
|
+
* tell them apart; what the browser appends has none. `by` is who wrote it; `session`, the agent
|
|
11
|
+
* session it was written in, when that is another id than `by` (`WORKPAD_AGENT` named the writer):
|
|
12
|
+
* a channel that knows the agent by its session still knows the event for its own.
|
|
11
13
|
*/
|
|
12
|
-
function appendEvent(file, input, from = null, by = null) {
|
|
14
|
+
function appendEvent(file, input, from = null, by = null, session = null) {
|
|
13
15
|
const event = {
|
|
14
16
|
id: isEventId(input.id) ? input.id : `${Date.now().toString(36)}-${crypto.randomBytes(3).toString("hex")}`,
|
|
15
17
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18,7 +20,8 @@ function appendEvent(file, input, from = null, by = null) {
|
|
|
18
20
|
action: input.action ?? null,
|
|
19
21
|
data: input.data ?? {},
|
|
20
22
|
...from ? { from } : {},
|
|
21
|
-
...by ? { by } : {}
|
|
23
|
+
...by ? { by } : {},
|
|
24
|
+
...session && session !== by ? { session } : {}
|
|
22
25
|
};
|
|
23
26
|
fs.appendFileSync(file, JSON.stringify(event) + "\n");
|
|
24
27
|
return event;
|
|
@@ -265,9 +268,12 @@ function handle(file, event, by = null) {
|
|
|
265
268
|
const forAgent = (handedOut = /* @__PURE__ */ new Set()) => (type) => !type.includes(":") || handedOut.has(type);
|
|
266
269
|
/**
|
|
267
270
|
* Hand the events that match `filter` to `onEvent`, for agent `agent`: the reader's, and other
|
|
268
|
-
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one)
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
+
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one), never
|
|
272
|
+
* its own (written by `agent` or one of its `aliases`). Each is marked received by `agent` once
|
|
273
|
+
* handed out. First the backlog: what is not handled, also from before this started; of the
|
|
274
|
+
* reader's, those `agent` received before come again, saying so (`again`), until handled; another
|
|
275
|
+
* agent's message it received before doesn't: a message is news once, and an agent's message is
|
|
276
|
+
* never handled by a reply, so it would come back at every start. Then, with `follow`, every new one as
|
|
271
277
|
* it comes. The backlog and the following split the log at one line boundary, so no event falls
|
|
272
278
|
* between them. Any number hand out from one log at once: each gets every event. Of the plugins'
|
|
273
279
|
* events only those for an agent (`forAgent`), unless the filter asks for a type by name.
|
|
@@ -276,7 +282,7 @@ const forAgent = (handedOut = /* @__PURE__ */ new Set()) => (type) => !type.incl
|
|
|
276
282
|
* `follow`, or when `signal` aborts.
|
|
277
283
|
*/
|
|
278
284
|
function handOut(file, filter, onEvent, options = {}) {
|
|
279
|
-
const { count = Infinity, follow: following = true, interval, signal, forAgent: isForAgent = forAgent(), batch = false, mark = true, agent = null, skipReceivedBefore, readerOnly = false, notReceivedByOthers = false } = options;
|
|
285
|
+
const { count = Infinity, follow: following = true, interval, signal, forAgent: isForAgent = forAgent(), batch = false, mark = true, agent = null, aliases = /* @__PURE__ */ new Set(), skipReceivedBefore, readerOnly = false, notReceivedByOthers = false } = options;
|
|
280
286
|
return new Promise((resolve) => {
|
|
281
287
|
let got = 0;
|
|
282
288
|
let stop = () => {};
|
|
@@ -285,7 +291,9 @@ function handOut(file, filter, onEvent, options = {}) {
|
|
|
285
291
|
signal?.removeEventListener("abort", finish);
|
|
286
292
|
resolve(got);
|
|
287
293
|
};
|
|
288
|
-
const
|
|
294
|
+
const me = (id) => !!id && (id === agent || aliases.has(id));
|
|
295
|
+
const own = (e) => me(e.by) || me(e.session);
|
|
296
|
+
const fromOthers = (e) => fromReader(e) || !readerOnly && !!e.by && !own(e);
|
|
289
297
|
const wanted = (e) => fromOthers(e) && matches(e, filter) && (!!filter.type || isForAgent(e.type));
|
|
290
298
|
let before = /* @__PURE__ */ new Set();
|
|
291
299
|
const hand = (e) => {
|
|
@@ -297,12 +305,14 @@ function handOut(file, filter, onEvent, options = {}) {
|
|
|
297
305
|
const { events, end } = read(file);
|
|
298
306
|
const handled = handledIds(events);
|
|
299
307
|
before = receivedBy(events, agent);
|
|
300
|
-
|
|
308
|
+
for (const alias of aliases) for (const id of receivedBy(events, alias)) before.add(id);
|
|
309
|
+
const others = notReceivedByOthers ? new Set(events.filter((e) => e.type === "workpad:received" && !fromReader(e) && !me(e.by) && (e.by ?? null) !== agent).map((e) => String(e.data?.event))) : /* @__PURE__ */ new Set();
|
|
301
310
|
let skipping = !!skipReceivedBefore;
|
|
302
311
|
const receivedAny = skipping ? receivedIds(events) : /* @__PURE__ */ new Set();
|
|
303
312
|
for (const e of events) {
|
|
304
313
|
if (skipping && e.id === skipReceivedBefore) skipping = false;
|
|
305
314
|
if (skipping && !fromReader(e) && receivedAny.has(e.id)) continue;
|
|
315
|
+
if (!fromReader(e) && before.has(e.id)) continue;
|
|
306
316
|
if (wanted(e) && !handled.has(e.id) && !others.has(e.id) && !hand(e)) return finish();
|
|
307
317
|
}
|
|
308
318
|
if (batch && got) return finish();
|
package/dist/src/files.js
CHANGED
|
@@ -2,7 +2,30 @@ import path from "node:path";
|
|
|
2
2
|
// src/files.ts
|
|
3
3
|
/** Left out always: what a repository keeps for its tools. */
|
|
4
4
|
const ALWAYS_EXCLUDED = ["**/node_modules", "**/.git"];
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Does `rel` match `g`? As `path.posix.matchesGlob`, but a `**` takes in folders whose name starts
|
|
7
|
+
* with a dot as well: matchesGlob's doesn't, so `**\/node_modules` left out nothing under `.claude/`,
|
|
8
|
+
* and an install in a worktree kept there reached the watcher as thousands of changes. Segment by
|
|
9
|
+
* segment: `**` stands for any number of folders, every other segment is matched by matchesGlob.
|
|
10
|
+
*/
|
|
11
|
+
function glob(rel, g) {
|
|
12
|
+
const parts = g.split("/");
|
|
13
|
+
const segs = rel.split("/");
|
|
14
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15
|
+
const at = (i, j) => {
|
|
16
|
+
if (i === parts.length) return j === segs.length;
|
|
17
|
+
const key = `${i},${j}`;
|
|
18
|
+
if (seen.has(key)) return false;
|
|
19
|
+
seen.add(key);
|
|
20
|
+
if (parts[i] === "**") {
|
|
21
|
+
for (let k = j; k <= segs.length; k++) if (at(i + 1, k)) return true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return j < segs.length && path.posix.matchesGlob(segs[j], parts[i]) && at(i + 1, j + 1);
|
|
25
|
+
};
|
|
26
|
+
return at(0, 0);
|
|
27
|
+
}
|
|
28
|
+
const ALWAYS_NAMES = new Set(ALWAYS_EXCLUDED.map((g) => g.slice(3)));
|
|
6
29
|
/** The path and each folder above it: `a/b/c` → `a/b/c`, `a/b`, `a`. */
|
|
7
30
|
function* upward(rel) {
|
|
8
31
|
for (let p = rel; p && p !== "."; p = path.posix.dirname(p)) yield p;
|
|
@@ -28,7 +51,7 @@ function fileFilter(files) {
|
|
|
28
51
|
const config = typeof files === "object" && files ? files : {};
|
|
29
52
|
const exclude = [...ALWAYS_EXCLUDED, ...config.exclude ?? []];
|
|
30
53
|
const include = config.include?.length ? config.include : null;
|
|
31
|
-
const excluded = (rel) => [...upward(rel)].some((p) => exclude.some((g) => glob(p, g)));
|
|
54
|
+
const excluded = (rel) => rel.split("/").some((s) => ALWAYS_NAMES.has(s)) || [...upward(rel)].some((p) => exclude.some((g) => glob(p, g)));
|
|
32
55
|
const included = (rel) => !include || [...upward(rel)].some((p) => include.some((g) => glob(p, g)));
|
|
33
56
|
return {
|
|
34
57
|
key: JSON.stringify({
|
|
@@ -44,4 +67,4 @@ function fileFilter(files) {
|
|
|
44
67
|
}
|
|
45
68
|
};
|
|
46
69
|
}
|
|
47
|
-
export { ALWAYS_EXCLUDED, fileFilter };
|
|
70
|
+
export { ALWAYS_EXCLUDED, fileFilter, glob };
|
package/dist/src/help.js
CHANGED
|
@@ -51,9 +51,9 @@ opencode()). Alone, it says your id and your name.
|
|
|
51
51
|
details: "The link leaves out the server's address (`/rg/jobs/x/decisions#form:logger`), so it works however the board is opened; --full prints the whole URL, for outside a board. The page can be another project's: name its file. An anchor the page doesn't have exits 1, listing those it has."
|
|
52
52
|
},
|
|
53
53
|
settle: {
|
|
54
|
-
usage: "<page|file> <form>… | --all",
|
|
54
|
+
usage: "<page|file> <form>… | --all | <form> --replace-with <file|->",
|
|
55
55
|
summary: "settle questions answered elsewhere (a chat, the design moving on): no longer unanswered",
|
|
56
|
-
details: "A form a chat settled, or the design moved past, would otherwise stay \"unanswered\" for good: in `workpad status`, the page's counter, the turn-end check. Settled, it counts as answered elsewhere. With `--all`, every open (or held) question on the page; without forms or `--all` it settles nothing and says which are open. A form with an answer in is left as it is. If the reader answers a settled form after all, it is open again. Say what settled it in its chat first, so the reader sees why."
|
|
56
|
+
details: "A form a chat settled, or the design moved past, would otherwise stay \"unanswered\" for good: in `workpad status`, the page's counter, the turn-end check. Settled, it counts as answered elsewhere. With `--all`, every open (or held) question on the page; without forms or `--all` it settles nothing and says which are open. A form with an answer in is left as it is. If the reader answers a settled form after all, it is open again. Say what settled it in its chat first, so the reader sees why.\n\n --replace-with <file|-> also replace the form on the page with this markdown (a file, or - for\n standard input), such as a line saying what was decided: one form, named.\n The form is found as `workpad set` finds it; one the page lacks settles\n nothing. Its chat goes to the page's folded list of chats no longer on it\n (`workpad chat prune` removes it).\n\n workpad settle plan logger --replace-with - <<'EOF'\n **Decided:** pino, for its speed.\n EOF"
|
|
57
57
|
},
|
|
58
58
|
hold: {
|
|
59
59
|
usage: "<page|file> <form>… \"<reason>\"",
|
|
@@ -66,14 +66,39 @@ opencode()). Alone, it says your id and your name.
|
|
|
66
66
|
},
|
|
67
67
|
check: {
|
|
68
68
|
usage: "[<page|file>…]",
|
|
69
|
-
summary: "what is wrong on pages, as they render: a block nobody brings, an input outside its form, a block's error",
|
|
70
|
-
details: "Every page of the project, or those named. Per page, one line for each problem: a config or frontmatter that doesn't parse, a block that reports an error (a diagram that doesn't parse, a form's name used twice), a block nobody brings (`:::tabz`), a form's input or button outside any form (a block inside the form one colon short), an attribute a block doesn't read, a link to an anchor the page
|
|
69
|
+
summary: "what is wrong on pages, as they render: a block nobody brings, an input outside its form, a block's error, a broken link",
|
|
70
|
+
details: "Every page of the project, or those named. Per page, one line for each problem: a config or frontmatter that doesn't parse, a block that reports an error (a diagram that doesn't parse, a form's name used twice), a block nobody brings (`:::tabz`), a form's input or button outside any form (a block inside the form one colon short), an attribute a block doesn't read, a link to an anchor that isn't there: on the same page (`#form:logger`, which the page shows above it too) or on another page of the project (`decisions.md#form:logger`), with the nearest anchors it does have; a link to a page that doesn't exist. Links to other projects and sites aren't checked. Exits 1 when there is any. Run it after writing a page."
|
|
71
71
|
},
|
|
72
72
|
anchors: {
|
|
73
73
|
usage: "<page|file>",
|
|
74
74
|
summary: "what a page can be linked to: each #anchor, what it is and what it says",
|
|
75
75
|
details: "Headings by their slug (`#open-questions`), and `#<type>:<name>` for the rest: `#form:logger`, `#chat:notes`, `#tab:intro`, `#details:why`. A chat message is `#message:<event id>`, not listed. The page can be another project's: name its file."
|
|
76
76
|
},
|
|
77
|
+
set: {
|
|
78
|
+
usage: "<page|file> <anchor|form> --file <file|->",
|
|
79
|
+
summary: "replace one block of a page by its name: a form, a heading's section, a chat or other named block",
|
|
80
|
+
details: `The markdown comes from a file, or with - from standard input (a heredoc with a quoted
|
|
81
|
+
delimiter: nothing in it passes through the shell's quoting). The block is found by parsing the
|
|
82
|
+
page, as a link names it (\`workpad anchors\`):
|
|
83
|
+
|
|
84
|
+
#form:logger the :::form{name=logger} container
|
|
85
|
+
#open-questions a heading's section: the heading and what follows, up to the next heading
|
|
86
|
+
of the same or a higher level (a deeper one is inside it)
|
|
87
|
+
#chat:notes a :::chat{name=notes}; any block with a name: #<type>:<name>, or with a
|
|
88
|
+
label: #details:why-not-mdx, #item:parser
|
|
89
|
+
logger a bare name: the block whose anchor it is, or whose name it is (form:logger);
|
|
90
|
+
when it fits two (a heading and a form), name it by its anchor, with its #
|
|
91
|
+
|
|
92
|
+
Everything else on the page stays as it was, byte for byte; a form in a code fence is never touched.
|
|
93
|
+
A name the page doesn't have exits 1, listing the blocks it has. To settle a form and put what was
|
|
94
|
+
decided in its place in one step: workpad settle <page> <form> --replace-with <file|->.
|
|
95
|
+
|
|
96
|
+
workpad set plan '#open-questions' --file - <<'EOF'
|
|
97
|
+
## Open questions
|
|
98
|
+
|
|
99
|
+
None left.
|
|
100
|
+
EOF`
|
|
101
|
+
},
|
|
77
102
|
migrate: {
|
|
78
103
|
usage: "[<folder|file>…] [--write]",
|
|
79
104
|
summary: "after updating workpad: rewrite pages written in an older syntax in the current one",
|
|
@@ -110,9 +135,11 @@ One chat's messages: workpad chat prune <page|file> <chat>.`
|
|
|
110
135
|
--skip <a,b> plugins or blocks to leave out (default: form, chat, comments, draft)`
|
|
111
136
|
},
|
|
112
137
|
edit: {
|
|
113
|
-
usage: "<event id> --data <json>",
|
|
138
|
+
usage: "<event id> --data <json> | --file <file|-> | --text-file <file|->",
|
|
114
139
|
summary: "change an agent's own event in place (merged into its data)",
|
|
115
|
-
details:
|
|
140
|
+
details: `Keeps its id, so what refers to it still does. What the reader sent can't be edited.
|
|
141
|
+
The data is taken as append takes it: --data, --file (JSON from a file, or - for standard input),
|
|
142
|
+
--text-file (markdown as its text).`
|
|
116
143
|
},
|
|
117
144
|
scroll: {
|
|
118
145
|
usage: "<page|file> <where>",
|
|
@@ -168,8 +195,16 @@ follower goes, as do new pages. What it hands out counts as received by you. Wit
|
|
|
168
195
|
confirmed channel takes these pages on (none becomes yours) and it exits.`
|
|
169
196
|
},
|
|
170
197
|
append: {
|
|
171
|
-
usage: "--page <p> --type <t> [--data <json>]",
|
|
172
|
-
summary: "add an event to a page's log, as the agent (a reply, a chat message)"
|
|
198
|
+
usage: "--page <p> --type <t> [--data <json> | --file <file|->] [--text-file <file|->]",
|
|
199
|
+
summary: "add an event to a page's log, as the agent (a reply, a chat message)",
|
|
200
|
+
details: ` --data <json> its data, as JSON on the command line: for short data without markdown
|
|
201
|
+
--file <file|-> its data, as JSON from a file, or - for standard input
|
|
202
|
+
--text-file <file|-> markdown from a file, or - for standard input, as the data's "text" (with
|
|
203
|
+
--data or --file for the rest): a chat reply, without shell quoting
|
|
204
|
+
|
|
205
|
+
workpad append --page plan --type chat:message --data '{"chat":"page"}' --text-file - <<'EOF'
|
|
206
|
+
It's **done**: see [the logger question](#form:logger).
|
|
207
|
+
EOF`
|
|
173
208
|
},
|
|
174
209
|
handled: {
|
|
175
210
|
usage: "<event id> [<event id>…]",
|
package/dist/src/hub.js
CHANGED
|
@@ -4,6 +4,8 @@ import { followEntries, machineDir, readMachineConfig, stateDir } from "./entrie
|
|
|
4
4
|
import { VERSION, compareVersions } from "./package.js";
|
|
5
5
|
import { API_LISTS, createServer } from "./server.js";
|
|
6
6
|
import { holdStream, listenerOf } from "./listeners.js";
|
|
7
|
+
import { readEvents } from "./events.js";
|
|
8
|
+
import { isStale, running } from "../plugins/progress/state.js";
|
|
7
9
|
import fs from "node:fs";
|
|
8
10
|
import path from "node:path";
|
|
9
11
|
// src/hub.ts
|
|
@@ -44,7 +46,7 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
44
46
|
};
|
|
45
47
|
function sync(projects) {
|
|
46
48
|
setImmediate(() => touch());
|
|
47
|
-
const wanted = new Map(projects.map((p) => [`${p.base}\n${p.dir}\n${p.files ??
|
|
49
|
+
const wanted = new Map(projects.map((p) => [`${p.base}\n${p.dir}\n${JSON.stringify(p.files ?? null)}`, p]));
|
|
48
50
|
for (const [key, s] of served) if (!wanted.has(key)) {
|
|
49
51
|
for (const el of entryListens) release(s, el);
|
|
50
52
|
for (const ul of unfollowedListens) letGo(s, ul);
|
|
@@ -97,14 +99,17 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
97
99
|
});
|
|
98
100
|
let touching;
|
|
99
101
|
const changes = /* @__PURE__ */ new Set();
|
|
102
|
+
let toldAt = 0;
|
|
100
103
|
const touch = () => {
|
|
101
|
-
|
|
104
|
+
if (touching) return;
|
|
102
105
|
touching = setTimeout(() => {
|
|
106
|
+
touching = void 0;
|
|
107
|
+
toldAt = Date.now();
|
|
103
108
|
root.touch();
|
|
104
109
|
const from = [...changes];
|
|
105
110
|
changes.clear();
|
|
106
111
|
for (const s of served.values()) if (from.some((b) => b !== s.base)) s.server.elsewhere();
|
|
107
|
-
}, 150);
|
|
112
|
+
}, Math.max(150, toldAt + 1e3 - Date.now()));
|
|
108
113
|
};
|
|
109
114
|
const changed = (base) => {
|
|
110
115
|
changes.add(base);
|
|
@@ -145,6 +150,16 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
145
150
|
error: err.message
|
|
146
151
|
};
|
|
147
152
|
}
|
|
153
|
+
const now = Date.now();
|
|
154
|
+
const runs = /* @__PURE__ */ new Map();
|
|
155
|
+
for (const r of running(readEvents(s.project.eventsFile))) if (!runs.has(r.page)) runs.set(r.page, {
|
|
156
|
+
id: r.id,
|
|
157
|
+
note: r.note,
|
|
158
|
+
n: r.n,
|
|
159
|
+
total: r.total,
|
|
160
|
+
ts: r.ts,
|
|
161
|
+
stale: isStale(r, now)
|
|
162
|
+
});
|
|
148
163
|
const pages = statuses.map((p) => ({
|
|
149
164
|
page: p.page,
|
|
150
165
|
title: p.title,
|
|
@@ -153,7 +168,8 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
153
168
|
updated: Math.max(mtimeOf(p.file), p.updated ? Date.parse(p.updated) : 0),
|
|
154
169
|
open: p.open,
|
|
155
170
|
unread: p.unread.length,
|
|
156
|
-
unreceived: p.unreceived.length
|
|
171
|
+
unreceived: p.unreceived.length,
|
|
172
|
+
progress: runs.get(p.page) ?? null
|
|
157
173
|
})).toSorted((a, b) => b.updated - a.updated);
|
|
158
174
|
return {
|
|
159
175
|
...at,
|
package/dist/src/loader.js
CHANGED
|
@@ -23,6 +23,7 @@ const BUILTIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
23
23
|
"release",
|
|
24
24
|
"url",
|
|
25
25
|
"anchors",
|
|
26
|
+
"set",
|
|
26
27
|
"docs",
|
|
27
28
|
"events",
|
|
28
29
|
"listen",
|
|
@@ -86,8 +87,8 @@ function checkPlugin(e, where) {
|
|
|
86
87
|
*/
|
|
87
88
|
const RETRY_FAILED_MS = 5e3;
|
|
88
89
|
/**
|
|
89
|
-
* `files`:
|
|
90
|
-
* entry can say
|
|
90
|
+
* `files`: which of its own files the project serves when its config doesn't say (a machine config's
|
|
91
|
+
* entry can say it for all of its projects; see EntryConfig).
|
|
91
92
|
*/
|
|
92
93
|
function createConfigLoader(proj, { pages: withPages = true, files: filesDefault = true } = {}) {
|
|
93
94
|
let cached = null;
|
|
@@ -130,14 +131,17 @@ function createConfigLoader(proj, { pages: withPages = true, files: filesDefault
|
|
|
130
131
|
ends
|
|
131
132
|
}) : null;
|
|
132
133
|
const declared = (flag) => new Set(plugins.flatMap((p) => Object.entries(p.events ?? {}).filter(([, spec]) => spec?.[flag]).map(([type]) => type)));
|
|
134
|
+
const specs = plugins.flatMap((p) => Object.entries(p.events ?? {}));
|
|
135
|
+
const requires = new Map(specs.flatMap(([type, spec]) => spec?.requires?.length ? [[type, spec.requires]] : []));
|
|
133
136
|
return {
|
|
134
137
|
pages,
|
|
135
138
|
plugins,
|
|
136
139
|
handedOut: declared("handOut"),
|
|
137
|
-
forReader: declared("forReader"),
|
|
140
|
+
forReader: new Map([...declared("forReader")].map((type) => [type, requires.get(type) ?? []])),
|
|
141
|
+
requires,
|
|
138
142
|
publicDirs,
|
|
139
|
-
files: config?.files
|
|
140
|
-
fileFilter: fileFilter(config?.files),
|
|
143
|
+
files: (config?.files ?? filesDefault) !== false,
|
|
144
|
+
fileFilter: fileFilter(config?.files ?? filesDefault),
|
|
141
145
|
build: config?.build ?? {},
|
|
142
146
|
commands: configCommands(config?.commands, {
|
|
143
147
|
taken: RESERVED,
|
|
@@ -158,7 +162,8 @@ function createConfigLoader(proj, { pages: withPages = true, files: filesDefault
|
|
|
158
162
|
pages: null,
|
|
159
163
|
plugins: [],
|
|
160
164
|
handedOut: /* @__PURE__ */ new Set(),
|
|
161
|
-
forReader: /* @__PURE__ */ new
|
|
165
|
+
forReader: /* @__PURE__ */ new Map(),
|
|
166
|
+
requires: /* @__PURE__ */ new Map(),
|
|
162
167
|
publicDirs: /* @__PURE__ */ new Map(),
|
|
163
168
|
files: false,
|
|
164
169
|
fileFilter: fileFilter(),
|
package/dist/src/migrate.js
CHANGED
|
@@ -311,4 +311,4 @@ function markdownFiles(target) {
|
|
|
311
311
|
if (fs.statSync(target).isFile()) return [target];
|
|
312
312
|
return fs.readdirSync(target, { withFileTypes: true }).filter((e) => !e.name.startsWith(".") && e.name !== "node_modules").sort((a, b) => a.name.localeCompare(b.name)).flatMap((e) => e.isDirectory() ? markdownFiles(path.join(target, e.name)) : e.name.endsWith(".md") ? [path.join(target, e.name)] : []);
|
|
313
313
|
}
|
|
314
|
-
export { MIGRATIONS, markdownFiles, migrate };
|
|
314
|
+
export { MIGRATIONS, edit, markdownFiles, migrate };
|
package/dist/src/pages/board.js
CHANGED
|
@@ -25,7 +25,7 @@ function byState(projects, now, activeFor = ACTIVE_FOR) {
|
|
|
25
25
|
project,
|
|
26
26
|
waiting: waitingOn(page)
|
|
27
27
|
};
|
|
28
|
-
columns[total(card.waiting) > 0 ? "waiting" : now - page.updated <= activeFor ? "active" : "quiet"].push(card);
|
|
28
|
+
columns[total(card.waiting) > 0 ? "waiting" : page.progress || now - page.updated <= activeFor ? "active" : "quiet"].push(card);
|
|
29
29
|
}
|
|
30
30
|
for (const cards of [
|
|
31
31
|
columns.waiting,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { html, raw } from "../html.js";
|
|
2
|
-
import { anchorsOf, slugText } from "../anchors.js";
|
|
2
|
+
import { anchorsOf, nearest, slugText } from "../anchors.js";
|
|
3
3
|
import { agentMessagesIn, isQuestionName } from "../status.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import crypto from "node:crypto";
|
|
@@ -874,13 +874,13 @@ plugin "${name}" failed to compose around block "${block.name}": ${err.message}<
|
|
|
874
874
|
await transform(tree);
|
|
875
875
|
const out = stringify(tree.children ?? []);
|
|
876
876
|
if (links.length) {
|
|
877
|
-
const ids =
|
|
877
|
+
const ids = anchorsOf(String(out)).map((a) => a.id);
|
|
878
878
|
for (const url of links) {
|
|
879
879
|
let id = url.slice(1);
|
|
880
880
|
try {
|
|
881
881
|
id = decodeURIComponent(id);
|
|
882
882
|
} catch {}
|
|
883
|
-
if (id && !id.startsWith("message:") && !ids.
|
|
883
|
+
if (id && !id.startsWith("message:") && !ids.includes(id)) problem(`a link to \`${url}\`, which this page doesn't have${nearest(id, ids)}`);
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
return {
|
package/dist/src/pages/render.js
CHANGED
|
@@ -356,12 +356,28 @@ function counts(w, href) {
|
|
|
356
356
|
>${badge("open", w.open, "open", w.open === 1 ? "1 question waiting for you" : `${w.open} questions waiting for you`)}${badge("unread", w.unread, "unread", w.unread === 1 ? "1 message you haven’t read" : `${w.unread} messages you haven’t read`)}${badge("unreceived", w.unreceived, "not received", w.unreceived === 1 ? "1 answer no agent received" : `${w.unreceived} answers no agent received`)}</span
|
|
357
357
|
>`;
|
|
358
358
|
}
|
|
359
|
+
/** A page's running progress on its card: a small bar (or a dot, without a count), its id, count and note. */
|
|
360
|
+
function progressLine(p) {
|
|
361
|
+
const count = p.n != null && p.total != null ? `${p.n.toLocaleString("en-US")} / ${p.total.toLocaleString("en-US")}` : "";
|
|
362
|
+
const width = p.n != null && p.total ? `${Math.round(p.n / p.total * 1e3) / 10}%` : null;
|
|
363
|
+
return html`<span
|
|
364
|
+
class="wp-board-progress"
|
|
365
|
+
${p.stale ? html` data-stale` : ""}
|
|
366
|
+
title="${p.id}: running${p.stale ? ", no update for a while" : ""}"
|
|
367
|
+
>${width != null ? html`<span class="wp-board-progress-bar"><span style="width:${width}"></span></span>` : html`<span class="wp-board-progress-dot"></span>`}<span class="wp-board-progress-text">${[
|
|
368
|
+
p.id,
|
|
369
|
+
count,
|
|
370
|
+
p.note
|
|
371
|
+
].filter(Boolean).join(" · ")}</span></span
|
|
372
|
+
>`;
|
|
373
|
+
}
|
|
359
374
|
/** A page on the board: its title, what waits on it, and (in a column of states) its project. */
|
|
360
375
|
function card(c, withProject) {
|
|
361
376
|
return html`<li class="wp-board-card${total(c.waiting) > 0 ? " wp-board-waits" : ""}">
|
|
362
377
|
<a class="wp-board-title" href="${c.page.url}">${c.page.title}</a>
|
|
363
378
|
${counts(c.waiting, `${c.page.url}#wp-waiting`)}
|
|
364
379
|
${withProject && html`<span class="wp-board-project">${c.project.label}</span>`}
|
|
380
|
+
${c.page.progress && progressLine(c.page.progress)}
|
|
365
381
|
<span class="wp-meta wp-board-when">updated ${time(c.page.updated)}</span>
|
|
366
382
|
</li>`;
|
|
367
383
|
}
|