@microvac/plugin-wayfinder 0.0.0-stage → 0.2.0-rc.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/LICENSE +22 -0
- package/lib/client.js +222 -0
- package/package.json +40 -4
- package/src/client.tsx +40 -0
- package/src/index.js +65 -0
- package/src/map-model.ts +138 -0
- package/src/map.tsx +174 -0
- package/src/microvac-ui.d.ts +24 -0
- package/src/modes.js +106 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Paperclip AI
|
|
4
|
+
Copyright (c) 2026 Microvac contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@microvac/plugin-wayfinder",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
require("@microvac/ui").requireVersion("^1.4.0", "@microvac/plugin-wayfinder");
|
|
5
|
+
const module = { exports: {} };
|
|
6
|
+
const exports = module.exports;
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name2 in all)
|
|
14
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
|
|
26
|
+
// src/client.tsx
|
|
27
|
+
var client_exports = {};
|
|
28
|
+
__export(client_exports, {
|
|
29
|
+
MAP_MODE: () => MAP_MODE,
|
|
30
|
+
MapOccupant: () => MapOccupant,
|
|
31
|
+
TASK_MODE_TAB_SLOT: () => TASK_MODE_TAB_SLOT,
|
|
32
|
+
apply: () => apply,
|
|
33
|
+
inject: () => inject,
|
|
34
|
+
name: () => name
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(client_exports);
|
|
37
|
+
|
|
38
|
+
// src/map.tsx
|
|
39
|
+
var import_ui = require("@microvac/ui");
|
|
40
|
+
|
|
41
|
+
// src/map-model.ts
|
|
42
|
+
var MAP_GROUPS = [
|
|
43
|
+
{ mode: "wayfinder.grilling", label: "Grilling" },
|
|
44
|
+
{ mode: "wayfinder.research", label: "Research" },
|
|
45
|
+
{ mode: "planning", label: "Plan" },
|
|
46
|
+
{ mode: "wayfinder.delivery", label: "Delivery" }
|
|
47
|
+
];
|
|
48
|
+
var OTHER = { mode: "other", label: "Other" };
|
|
49
|
+
var FINISHED = /* @__PURE__ */ new Set(["done", "cancelled"]);
|
|
50
|
+
function toTask(child) {
|
|
51
|
+
return {
|
|
52
|
+
id: child.id,
|
|
53
|
+
ref: child.identifier ?? child.id,
|
|
54
|
+
title: child.title,
|
|
55
|
+
status: child.status,
|
|
56
|
+
finished: FINISHED.has(child.status)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function openQuestions(children, interactionsByIssue) {
|
|
60
|
+
const questions = [];
|
|
61
|
+
for (const child of children) {
|
|
62
|
+
if (child.workMode !== "wayfinder.grilling" || FINISHED.has(child.status)) continue;
|
|
63
|
+
for (const interaction of interactionsByIssue.get(child.id) ?? []) {
|
|
64
|
+
if (interaction.kind !== "ask_user_questions" || interaction.status !== "pending") continue;
|
|
65
|
+
const prompts = (interaction.payload?.questions ?? []).map((question) => question.prompt);
|
|
66
|
+
questions.push({
|
|
67
|
+
interactionId: interaction.id,
|
|
68
|
+
task: toTask(child),
|
|
69
|
+
title: interaction.payload?.title?.trim() || child.title,
|
|
70
|
+
prompts
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return questions;
|
|
75
|
+
}
|
|
76
|
+
function grillingChildren(children) {
|
|
77
|
+
return children.filter((child) => child.workMode === "wayfinder.grilling" && !FINISHED.has(child.status));
|
|
78
|
+
}
|
|
79
|
+
function buildMap(children, interactionsByIssue, planDocuments) {
|
|
80
|
+
const groups = /* @__PURE__ */ new Map();
|
|
81
|
+
for (const { mode, label } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, label, tasks: [] });
|
|
82
|
+
for (const child of children) {
|
|
83
|
+
const mode = child.workMode && groups.has(child.workMode) ? child.workMode : OTHER.mode;
|
|
84
|
+
groups.get(mode).tasks.push(toTask(child));
|
|
85
|
+
}
|
|
86
|
+
const plansByIssue = new Map(planDocuments.filter((entry) => entry.document).map((entry) => [entry.issueId, entry.document]));
|
|
87
|
+
const plans = [];
|
|
88
|
+
for (const child of children) {
|
|
89
|
+
const document = plansByIssue.get(child.id);
|
|
90
|
+
if (document || child.workMode === "planning") {
|
|
91
|
+
plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "Plan" : null });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const counted = children.filter((child) => child.status !== "cancelled");
|
|
95
|
+
return {
|
|
96
|
+
groups: [...groups.values()].filter((group) => group.tasks.length > 0),
|
|
97
|
+
questions: openQuestions(children, interactionsByIssue),
|
|
98
|
+
plans,
|
|
99
|
+
progress: { done: counted.filter((child) => child.status === "done").length, total: counted.length }
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/map.tsx
|
|
104
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
105
|
+
var DOCUMENT_BATCH_MAX = 200;
|
|
106
|
+
async function loadMap(context) {
|
|
107
|
+
const company = encodeURIComponent(context.companyId);
|
|
108
|
+
const children = await import_ui.api.get(`/companies/${company}/issues?parentId=${encodeURIComponent(context.issueId)}`);
|
|
109
|
+
const ids = children.map((child) => child.id).slice(0, DOCUMENT_BATCH_MAX);
|
|
110
|
+
const [plans, interactions] = await Promise.all([
|
|
111
|
+
ids.length ? import_ui.api.get(`/companies/${company}/issue-documents?key=plan&includeBody=false&issueIds=${ids.join(",")}`).then((batch) => batch.items) : Promise.resolve([]),
|
|
112
|
+
Promise.all(
|
|
113
|
+
grillingChildren(children).map(async (child) => [
|
|
114
|
+
child.id,
|
|
115
|
+
await import_ui.api.get(`/issues/${encodeURIComponent(child.id)}/interactions`)
|
|
116
|
+
])
|
|
117
|
+
)
|
|
118
|
+
]);
|
|
119
|
+
return buildMap(children, new Map(interactions), plans);
|
|
120
|
+
}
|
|
121
|
+
function TaskLink({ task, context }) {
|
|
122
|
+
const open = (event) => {
|
|
123
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
context.openTask(task.ref);
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", { href: context.taskHref(task.ref), onClick: open, className: "min-w-0 break-words hover:underline", children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mr-1.5 font-mono text-xs text-muted-foreground", children: task.ref }),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_ui.cn)(task.finished && "text-muted-foreground line-through"), children: task.title })
|
|
130
|
+
] });
|
|
131
|
+
}
|
|
132
|
+
function Section({ title, aside, children }) {
|
|
133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "space-y-2", children: [
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-sm font-semibold", children: title }),
|
|
136
|
+
aside
|
|
137
|
+
] }),
|
|
138
|
+
children
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
function MapView({ map, context }) {
|
|
142
|
+
const { done, total } = map.progress;
|
|
143
|
+
const percent = total ? Math.round(done / total * 100) : 0;
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-6", "data-testid": "wayfinder-map", children: [
|
|
145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Progress", aside: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
|
|
146
|
+
done,
|
|
147
|
+
" / ",
|
|
148
|
+
total,
|
|
149
|
+
" done"
|
|
150
|
+
] }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: "h-2 w-full overflow-hidden rounded-full bg-muted",
|
|
154
|
+
role: "progressbar",
|
|
155
|
+
"aria-valuemin": 0,
|
|
156
|
+
"aria-valuemax": total,
|
|
157
|
+
"aria-valuenow": done,
|
|
158
|
+
"aria-label": "Children done",
|
|
159
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full rounded-full bg-primary", style: { width: `${percent}%` } })
|
|
160
|
+
}
|
|
161
|
+
) }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Open questions", aside: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "outline", children: map.questions.length }), children: map.questions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No question waiting for an answer." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-2", children: map.questions.map((question) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "rounded-md border border-border p-3 text-sm", children: [
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium", children: question.title }),
|
|
164
|
+
question.prompts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground", children: question.prompts.map((prompt, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: prompt }, index)) }) : null,
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task: question.task, context }) })
|
|
166
|
+
] }, question.interactionId)) }) }),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Plan", children: map.plans.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No plan yet." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-1 text-sm", children: map.plans.map((plan) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex flex-wrap items-center gap-2", children: [
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task: plan.task, context }),
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "outline", children: plan.documentTitle ?? "No plan document" })
|
|
170
|
+
] }, plan.task.id)) }) }),
|
|
171
|
+
map.groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No sub-task yet: the Wayfinder task creates them as it maps the initiative." }) : map.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
Section,
|
|
173
|
+
{
|
|
174
|
+
title: group.label,
|
|
175
|
+
aside: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
|
|
176
|
+
group.tasks.filter((task) => task.status === "done").length,
|
|
177
|
+
" / ",
|
|
178
|
+
group.tasks.length
|
|
179
|
+
] }),
|
|
180
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "divide-y divide-border rounded-md border border-border text-sm", children: group.tasks.map((task) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task, context }),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "secondary", className: "shrink-0", children: task.status.replace(/_/g, " ") })
|
|
183
|
+
] }, task.id)) })
|
|
184
|
+
},
|
|
185
|
+
group.mode
|
|
186
|
+
))
|
|
187
|
+
] });
|
|
188
|
+
}
|
|
189
|
+
function MapTab({ context }) {
|
|
190
|
+
const query = (0, import_ui.useQuery)({
|
|
191
|
+
queryKey: ["microvac", "wayfinder", "map", context.issueId],
|
|
192
|
+
queryFn: () => loadMap(context)
|
|
193
|
+
});
|
|
194
|
+
if (query.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "Loading the map\u2026" });
|
|
195
|
+
if (query.error || !query.data) {
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm text-destructive", role: "alert", children: [
|
|
197
|
+
"Could not load the map: ",
|
|
198
|
+
query.error instanceof Error ? query.error.message : "unknown error",
|
|
199
|
+
"."
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapView, { map: query.data, context });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/client.tsx
|
|
206
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
207
|
+
var name = "@microvac/plugin-wayfinder";
|
|
208
|
+
var inject = ["slots"];
|
|
209
|
+
var TASK_MODE_TAB_SLOT = "microvac.task-mode-tab";
|
|
210
|
+
var MAP_MODE = "wayfinder.map";
|
|
211
|
+
function MapOccupant(props) {
|
|
212
|
+
const context = props.context;
|
|
213
|
+
if (context?.workMode !== MAP_MODE || !context.companyId || !context.issueId) return null;
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MapTab, { context });
|
|
215
|
+
}
|
|
216
|
+
function apply(ctx) {
|
|
217
|
+
ctx.effect(() => ctx.slots.register({ name: TASK_MODE_TAB_SLOT, id: name }, MapOccupant), "wayfinder: Map tab");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return module.exports;
|
|
221
|
+
},
|
|
222
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microvac/plugin-wayfinder",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0-rc.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Microvac plugin: Wayfinder, Grilling, Research and Delivery task modes, off by default.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js",
|
|
9
|
+
"./client": "./lib/client.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"lib"
|
|
15
|
+
],
|
|
16
|
+
"microvac": {
|
|
17
|
+
"ui": "^1.4.0"
|
|
18
|
+
},
|
|
19
|
+
"dsh": {
|
|
20
|
+
"client": {
|
|
21
|
+
"platform": "web",
|
|
22
|
+
"inject": [
|
|
23
|
+
"slots"
|
|
24
|
+
],
|
|
25
|
+
"external": [
|
|
26
|
+
"@microvac/ui"
|
|
27
|
+
],
|
|
28
|
+
"immediately": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@deepseek-ai/schemastery": "3.20.0-alpha.2"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build:client": "node ../../scripts/microvac/build-client-plugin.mjs .",
|
|
36
|
+
"typecheck": "tsc --noEmit"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/microvac-ai/microvac"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/client.tsx
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client face of the `wayfinder` plugin (`docs/microvac/task-modes.md`): the
|
|
3
|
+
* Map tab of Wayfinder tasks, in the task page's mode tab slot
|
|
4
|
+
* (`microvac.task-mode-tab`). The build checks the Microvac UI range
|
|
5
|
+
* (`microvac.ui` in `package.json`).
|
|
6
|
+
*/
|
|
7
|
+
import { MapTab, type MapTabContext } from "./map.js";
|
|
8
|
+
|
|
9
|
+
export const name = "@microvac/plugin-wayfinder";
|
|
10
|
+
export const inject = ["slots"];
|
|
11
|
+
|
|
12
|
+
/** `MICROVAC_TASK_MODE_TAB_SLOT` in `@paperclipai/shared`. */
|
|
13
|
+
export const TASK_MODE_TAB_SLOT = "microvac.task-mode-tab";
|
|
14
|
+
|
|
15
|
+
/** The mode whose tasks get the Map. */
|
|
16
|
+
export const MAP_MODE = "wayfinder.map";
|
|
17
|
+
|
|
18
|
+
/** Owner props the renderer spreads on the occupant (`MicrovacSlotHost` context). */
|
|
19
|
+
interface SlotOwner {
|
|
20
|
+
context?: Partial<MapTabContext>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface WayfinderClientContext {
|
|
24
|
+
slots: {
|
|
25
|
+
register(options: { name: string; id: string }, component: (props: SlotOwner) => unknown): () => void;
|
|
26
|
+
};
|
|
27
|
+
effect(start: () => () => void, label?: string): unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Renders the Map on Wayfinder tasks only. */
|
|
31
|
+
export function MapOccupant(props: SlotOwner) {
|
|
32
|
+
const context = props.context;
|
|
33
|
+
if (context?.workMode !== MAP_MODE || !context.companyId || !context.issueId) return null;
|
|
34
|
+
return <MapTab context={context as MapTabContext} />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The slot is a list: each occupant needs its own id. */
|
|
38
|
+
export function apply(ctx: WayfinderClientContext) {
|
|
39
|
+
ctx.effect(() => ctx.slots.register({ name: TASK_MODE_TAB_SLOT, id: name }, MapOccupant), "wayfinder: Map tab");
|
|
40
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* The `wayfinder` plugin (ADR 0018, `docs/microvac/task-modes.md`): official,
|
|
4
|
+
* bundled, off by default. It registers four task modes through the kernel's
|
|
5
|
+
* task mode registry (`taskModes`):
|
|
6
|
+
*
|
|
7
|
+
* - Wayfinder (`wayfinder.map`, base standard, skill `wayfinder`): maps an
|
|
8
|
+
* initiative and creates its children in the modes below;
|
|
9
|
+
* - Grilling (`wayfinder.grilling`, base Ask, skill `grill-with-docs`): asks
|
|
10
|
+
* the human in batches of question cards and ends with a plan the core plan
|
|
11
|
+
* card validates;
|
|
12
|
+
* - Research (`wayfinder.research`, base standard): result as a document;
|
|
13
|
+
* - Delivery (`wayfinder.delivery`, base standard): implementation.
|
|
14
|
+
*
|
|
15
|
+
* The Plan child uses the core Plan mode unchanged. Child assignment decides
|
|
16
|
+
* who gets a child created without assignee under a Wayfinder task.
|
|
17
|
+
*
|
|
18
|
+
* # microvac.yml
|
|
19
|
+
* - id: wayfinder
|
|
20
|
+
* name: "@microvac/plugin-wayfinder"
|
|
21
|
+
* config:
|
|
22
|
+
* childAssignment: parent # parent | none | perMode
|
|
23
|
+
*/
|
|
24
|
+
import z from "@deepseek-ai/schemastery";
|
|
25
|
+
import { MODES, childAssignee } from "./modes.js";
|
|
26
|
+
|
|
27
|
+
export const name = "@microvac/plugin-wayfinder";
|
|
28
|
+
|
|
29
|
+
export const inject = ["taskModes"];
|
|
30
|
+
|
|
31
|
+
const ASSIGNMENTS = /** @type {const} */ (["parent", "none", "perMode"]);
|
|
32
|
+
|
|
33
|
+
const ASSIGNMENT_HELP =
|
|
34
|
+
"Who gets a child created without assignee under a Wayfinder task: the Wayfinder task's agent (parent), " +
|
|
35
|
+
"nobody, so task routing assigns it (none), or a fixed agent per mode (perMode).";
|
|
36
|
+
const AGENTS_HELP = "perMode: agent id per mode id (wayfinder.grilling, wayfinder.research, planning, wayfinder.delivery).";
|
|
37
|
+
|
|
38
|
+
/** @type {z<Partial<WayfinderConfig>, WayfinderConfig>} */
|
|
39
|
+
export const Config = z.object({
|
|
40
|
+
childAssignment: z.union(ASSIGNMENTS).default("parent").description(ASSIGNMENT_HELP),
|
|
41
|
+
agents: z.dict(z.string()).default({}).description(AGENTS_HELP),
|
|
42
|
+
companies: z
|
|
43
|
+
.dict(z.object({ childAssignment: z.union(ASSIGNMENTS), agents: z.dict(z.string()) }))
|
|
44
|
+
.default({})
|
|
45
|
+
.description("Per-company override, keyed by company id."),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {import("./modes.js").WayfinderConfig} WayfinderConfig
|
|
50
|
+
* @typedef {{ taskModes: { register(definition: import("./modes.js").ModeDefinition): unknown } }} WayfinderContext
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {WayfinderContext} ctx
|
|
55
|
+
* @param {Partial<WayfinderConfig>} [config]
|
|
56
|
+
*/
|
|
57
|
+
export function apply(ctx, config = {}) {
|
|
58
|
+
const settings = { childAssignment: config.childAssignment ?? "parent", agents: config.agents ?? {}, companies: config.companies ?? {} };
|
|
59
|
+
for (const mode of MODES) {
|
|
60
|
+
const hooks = mode.id === "wayfinder.map"
|
|
61
|
+
? { ...mode.hooks, childAssignee: (/** @type {import("./modes.js").Child} */ child) => childAssignee(child, settings) }
|
|
62
|
+
: mode.hooks;
|
|
63
|
+
ctx.taskModes.register({ ...mode, hooks });
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/map-model.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Map of a Wayfinder task, as data: its children grouped by mode, the open
|
|
3
|
+
* questions (pending question cards of its Grilling children), the plan, and
|
|
4
|
+
* progress. Pure, so it is tested without a page.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface MapChild {
|
|
8
|
+
id: string;
|
|
9
|
+
identifier: string | null;
|
|
10
|
+
title: string;
|
|
11
|
+
status: string;
|
|
12
|
+
workMode: string | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MapInteraction {
|
|
16
|
+
id: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
status: string;
|
|
19
|
+
payload?: { title?: string | null; questions?: readonly { prompt: string }[] } | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MapPlanDocument {
|
|
23
|
+
issueId: string;
|
|
24
|
+
document: { title: string | null; updatedAt?: string | Date | null } | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MapTask {
|
|
28
|
+
id: string;
|
|
29
|
+
ref: string;
|
|
30
|
+
title: string;
|
|
31
|
+
status: string;
|
|
32
|
+
finished: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MapGroup {
|
|
36
|
+
mode: string;
|
|
37
|
+
label: string;
|
|
38
|
+
tasks: MapTask[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface MapQuestion {
|
|
42
|
+
interactionId: string;
|
|
43
|
+
task: MapTask;
|
|
44
|
+
title: string;
|
|
45
|
+
prompts: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MapPlan {
|
|
49
|
+
task: MapTask;
|
|
50
|
+
/** Title of the plan document, or null when the task is a Plan task without one yet. */
|
|
51
|
+
documentTitle: string | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface WayfinderMap {
|
|
55
|
+
groups: MapGroup[];
|
|
56
|
+
questions: MapQuestion[];
|
|
57
|
+
plans: MapPlan[];
|
|
58
|
+
progress: { done: number; total: number };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Mode order on the Map, with labels; anything else goes under "Other". */
|
|
62
|
+
export const MAP_GROUPS: readonly { mode: string; label: string }[] = [
|
|
63
|
+
{ mode: "wayfinder.grilling", label: "Grilling" },
|
|
64
|
+
{ mode: "wayfinder.research", label: "Research" },
|
|
65
|
+
{ mode: "planning", label: "Plan" },
|
|
66
|
+
{ mode: "wayfinder.delivery", label: "Delivery" },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const OTHER = { mode: "other", label: "Other" };
|
|
70
|
+
|
|
71
|
+
const FINISHED = new Set(["done", "cancelled"]);
|
|
72
|
+
|
|
73
|
+
function toTask(child: MapChild): MapTask {
|
|
74
|
+
return {
|
|
75
|
+
id: child.id,
|
|
76
|
+
ref: child.identifier ?? child.id,
|
|
77
|
+
title: child.title,
|
|
78
|
+
status: child.status,
|
|
79
|
+
finished: FINISHED.has(child.status),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Pending question cards (`ask_user_questions`) of the Grilling children. */
|
|
84
|
+
export function openQuestions(
|
|
85
|
+
children: readonly MapChild[],
|
|
86
|
+
interactionsByIssue: ReadonlyMap<string, readonly MapInteraction[]>,
|
|
87
|
+
): MapQuestion[] {
|
|
88
|
+
const questions: MapQuestion[] = [];
|
|
89
|
+
for (const child of children) {
|
|
90
|
+
if (child.workMode !== "wayfinder.grilling" || FINISHED.has(child.status)) continue;
|
|
91
|
+
for (const interaction of interactionsByIssue.get(child.id) ?? []) {
|
|
92
|
+
if (interaction.kind !== "ask_user_questions" || interaction.status !== "pending") continue;
|
|
93
|
+
const prompts = (interaction.payload?.questions ?? []).map((question) => question.prompt);
|
|
94
|
+
questions.push({
|
|
95
|
+
interactionId: interaction.id,
|
|
96
|
+
task: toTask(child),
|
|
97
|
+
title: interaction.payload?.title?.trim() || child.title,
|
|
98
|
+
prompts,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return questions;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Children whose questions the Map reads: unfinished Grilling children. */
|
|
106
|
+
export function grillingChildren(children: readonly MapChild[]): MapChild[] {
|
|
107
|
+
return children.filter((child) => child.workMode === "wayfinder.grilling" && !FINISHED.has(child.status));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function buildMap(
|
|
111
|
+
children: readonly MapChild[],
|
|
112
|
+
interactionsByIssue: ReadonlyMap<string, readonly MapInteraction[]>,
|
|
113
|
+
planDocuments: readonly MapPlanDocument[],
|
|
114
|
+
): WayfinderMap {
|
|
115
|
+
const groups = new Map<string, MapGroup>();
|
|
116
|
+
for (const { mode, label } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, label, tasks: [] });
|
|
117
|
+
for (const child of children) {
|
|
118
|
+
const mode = child.workMode && groups.has(child.workMode) ? child.workMode : OTHER.mode;
|
|
119
|
+
groups.get(mode)!.tasks.push(toTask(child));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const plansByIssue = new Map(planDocuments.filter((entry) => entry.document).map((entry) => [entry.issueId, entry.document!]));
|
|
123
|
+
const plans: MapPlan[] = [];
|
|
124
|
+
for (const child of children) {
|
|
125
|
+
const document = plansByIssue.get(child.id);
|
|
126
|
+
if (document || child.workMode === "planning") {
|
|
127
|
+
plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "Plan" : null });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const counted = children.filter((child) => child.status !== "cancelled");
|
|
132
|
+
return {
|
|
133
|
+
groups: [...groups.values()].filter((group) => group.tasks.length > 0),
|
|
134
|
+
questions: openQuestions(children, interactionsByIssue),
|
|
135
|
+
plans,
|
|
136
|
+
progress: { done: counted.filter((child) => child.status === "done").length, total: counted.length },
|
|
137
|
+
};
|
|
138
|
+
}
|
package/src/map.tsx
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Map tab of a Wayfinder task: children grouped by mode, open questions,
|
|
3
|
+
* the plan, progress. Reads the board API through Microvac UI.
|
|
4
|
+
*/
|
|
5
|
+
import type { MouseEvent, ReactNode } from "react";
|
|
6
|
+
import { api, Badge, cn, useQuery } from "@microvac/ui";
|
|
7
|
+
import {
|
|
8
|
+
buildMap,
|
|
9
|
+
grillingChildren,
|
|
10
|
+
type MapChild,
|
|
11
|
+
type MapInteraction,
|
|
12
|
+
type MapPlanDocument,
|
|
13
|
+
type MapTask,
|
|
14
|
+
type WayfinderMap,
|
|
15
|
+
} from "./map-model.js";
|
|
16
|
+
|
|
17
|
+
/** What the task page hands the tab (`TaskModeTabContext` in `@paperclipai/shared`). */
|
|
18
|
+
export interface MapTabContext {
|
|
19
|
+
companyId: string;
|
|
20
|
+
issueId: string;
|
|
21
|
+
identifier: string | null;
|
|
22
|
+
workMode: string;
|
|
23
|
+
taskHref(ref: string): string;
|
|
24
|
+
openTask(ref: string): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const DOCUMENT_BATCH_MAX = 200;
|
|
28
|
+
|
|
29
|
+
async function loadMap(context: MapTabContext): Promise<WayfinderMap> {
|
|
30
|
+
const company = encodeURIComponent(context.companyId);
|
|
31
|
+
const children = await api.get<MapChild[]>(`/companies/${company}/issues?parentId=${encodeURIComponent(context.issueId)}`);
|
|
32
|
+
const ids = children.map((child) => child.id).slice(0, DOCUMENT_BATCH_MAX);
|
|
33
|
+
const [plans, interactions] = await Promise.all([
|
|
34
|
+
ids.length
|
|
35
|
+
? api
|
|
36
|
+
.get<{ items: MapPlanDocument[] }>(`/companies/${company}/issue-documents?key=plan&includeBody=false&issueIds=${ids.join(",")}`)
|
|
37
|
+
.then((batch) => batch.items)
|
|
38
|
+
: Promise.resolve([] as MapPlanDocument[]),
|
|
39
|
+
Promise.all(
|
|
40
|
+
grillingChildren(children).map(async (child) => [
|
|
41
|
+
child.id,
|
|
42
|
+
await api.get<MapInteraction[]>(`/issues/${encodeURIComponent(child.id)}/interactions`),
|
|
43
|
+
] as const),
|
|
44
|
+
),
|
|
45
|
+
]);
|
|
46
|
+
return buildMap(children, new Map(interactions), plans);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function TaskLink({ task, context }: { task: MapTask; context: MapTabContext }) {
|
|
50
|
+
const open = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
51
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
context.openTask(task.ref);
|
|
54
|
+
};
|
|
55
|
+
return (
|
|
56
|
+
<a href={context.taskHref(task.ref)} onClick={open} className="min-w-0 break-words hover:underline">
|
|
57
|
+
<span className="mr-1.5 font-mono text-xs text-muted-foreground">{task.ref}</span>
|
|
58
|
+
<span className={cn(task.finished && "text-muted-foreground line-through")}>{task.title}</span>
|
|
59
|
+
</a>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function Section({ title, aside, children }: { title: string; aside?: ReactNode; children: ReactNode }) {
|
|
64
|
+
return (
|
|
65
|
+
<section className="space-y-2">
|
|
66
|
+
<div className="flex items-center justify-between gap-2">
|
|
67
|
+
<h3 className="text-sm font-semibold">{title}</h3>
|
|
68
|
+
{aside}
|
|
69
|
+
</div>
|
|
70
|
+
{children}
|
|
71
|
+
</section>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function MapView({ map, context }: { map: WayfinderMap; context: MapTabContext }) {
|
|
76
|
+
const { done, total } = map.progress;
|
|
77
|
+
const percent = total ? Math.round((done / total) * 100) : 0;
|
|
78
|
+
return (
|
|
79
|
+
<div className="space-y-6" data-testid="wayfinder-map">
|
|
80
|
+
<Section title="Progress" aside={<span className="text-xs text-muted-foreground">{done} / {total} done</span>}>
|
|
81
|
+
<div
|
|
82
|
+
className="h-2 w-full overflow-hidden rounded-full bg-muted"
|
|
83
|
+
role="progressbar"
|
|
84
|
+
aria-valuemin={0}
|
|
85
|
+
aria-valuemax={total}
|
|
86
|
+
aria-valuenow={done}
|
|
87
|
+
aria-label="Children done"
|
|
88
|
+
>
|
|
89
|
+
<div className="h-full rounded-full bg-primary" style={{ width: `${percent}%` }} />
|
|
90
|
+
</div>
|
|
91
|
+
</Section>
|
|
92
|
+
|
|
93
|
+
<Section title="Open questions" aside={<Badge variant="outline">{map.questions.length}</Badge>}>
|
|
94
|
+
{map.questions.length === 0 ? (
|
|
95
|
+
<p className="text-sm text-muted-foreground">No question waiting for an answer.</p>
|
|
96
|
+
) : (
|
|
97
|
+
<ul className="space-y-2">
|
|
98
|
+
{map.questions.map((question) => (
|
|
99
|
+
<li key={question.interactionId} className="rounded-md border border-border p-3 text-sm">
|
|
100
|
+
<div className="font-medium">{question.title}</div>
|
|
101
|
+
{question.prompts.length > 0 ? (
|
|
102
|
+
<ul className="mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground">
|
|
103
|
+
{question.prompts.map((prompt, index) => (
|
|
104
|
+
<li key={index}>{prompt}</li>
|
|
105
|
+
))}
|
|
106
|
+
</ul>
|
|
107
|
+
) : null}
|
|
108
|
+
<div className="mt-2 text-xs">
|
|
109
|
+
<TaskLink task={question.task} context={context} />
|
|
110
|
+
</div>
|
|
111
|
+
</li>
|
|
112
|
+
))}
|
|
113
|
+
</ul>
|
|
114
|
+
)}
|
|
115
|
+
</Section>
|
|
116
|
+
|
|
117
|
+
<Section title="Plan">
|
|
118
|
+
{map.plans.length === 0 ? (
|
|
119
|
+
<p className="text-sm text-muted-foreground">No plan yet.</p>
|
|
120
|
+
) : (
|
|
121
|
+
<ul className="space-y-1 text-sm">
|
|
122
|
+
{map.plans.map((plan) => (
|
|
123
|
+
<li key={plan.task.id} className="flex flex-wrap items-center gap-2">
|
|
124
|
+
<TaskLink task={plan.task} context={context} />
|
|
125
|
+
<Badge variant="outline">{plan.documentTitle ?? "No plan document"}</Badge>
|
|
126
|
+
</li>
|
|
127
|
+
))}
|
|
128
|
+
</ul>
|
|
129
|
+
)}
|
|
130
|
+
</Section>
|
|
131
|
+
|
|
132
|
+
{map.groups.length === 0 ? (
|
|
133
|
+
<p className="text-sm text-muted-foreground">No sub-task yet: the Wayfinder task creates them as it maps the initiative.</p>
|
|
134
|
+
) : (
|
|
135
|
+
map.groups.map((group) => (
|
|
136
|
+
<Section
|
|
137
|
+
key={group.mode}
|
|
138
|
+
title={group.label}
|
|
139
|
+
aside={
|
|
140
|
+
<span className="text-xs text-muted-foreground">
|
|
141
|
+
{group.tasks.filter((task) => task.status === "done").length} / {group.tasks.length}
|
|
142
|
+
</span>
|
|
143
|
+
}
|
|
144
|
+
>
|
|
145
|
+
<ul className="divide-y divide-border rounded-md border border-border text-sm">
|
|
146
|
+
{group.tasks.map((task) => (
|
|
147
|
+
<li key={task.id} className="flex items-center justify-between gap-3 px-3 py-2">
|
|
148
|
+
<TaskLink task={task} context={context} />
|
|
149
|
+
<Badge variant="secondary" className="shrink-0">{task.status.replace(/_/g, " ")}</Badge>
|
|
150
|
+
</li>
|
|
151
|
+
))}
|
|
152
|
+
</ul>
|
|
153
|
+
</Section>
|
|
154
|
+
))
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function MapTab({ context }: { context: MapTabContext }) {
|
|
161
|
+
const query = useQuery({
|
|
162
|
+
queryKey: ["microvac", "wayfinder", "map", context.issueId],
|
|
163
|
+
queryFn: () => loadMap(context),
|
|
164
|
+
});
|
|
165
|
+
if (query.isPending) return <p className="text-sm text-muted-foreground">Loading the map…</p>;
|
|
166
|
+
if (query.error || !query.data) {
|
|
167
|
+
return (
|
|
168
|
+
<p className="text-sm text-destructive" role="alert">
|
|
169
|
+
Could not load the map: {query.error instanceof Error ? query.error.message : "unknown error"}.
|
|
170
|
+
</p>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return <MapView map={query.data} context={context} />;
|
|
174
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of Microvac UI (`ui/src/microvac/ui-module`) this plugin uses; the
|
|
3
|
+
* page provides the module at run time. `tsconfig.json` maps `@microvac/ui`
|
|
4
|
+
* here for type checking; the build keeps it external.
|
|
5
|
+
*/
|
|
6
|
+
import type { ComponentType } from "react";
|
|
7
|
+
|
|
8
|
+
type AnyComponent = ComponentType<any>;
|
|
9
|
+
|
|
10
|
+
export declare const version: string;
|
|
11
|
+
export declare function requireVersion(range: string, plugin?: string): void;
|
|
12
|
+
|
|
13
|
+
export declare function useQuery<T>(options: {
|
|
14
|
+
queryKey: readonly unknown[];
|
|
15
|
+
queryFn: () => Promise<T>;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
}): { data?: T; error: unknown; isPending: boolean; refetch(): Promise<unknown> };
|
|
18
|
+
|
|
19
|
+
export declare const api: {
|
|
20
|
+
get<T>(path: string): Promise<T>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export declare const Badge: AnyComponent;
|
|
24
|
+
export declare function cn(...classes: unknown[]): string;
|
package/src/modes.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* The Wayfinder modes and their hooks. Directives follow Matt Pocock's skills
|
|
4
|
+
* `wayfinder` and `grill-with-docs`; the skills themselves are attached to the
|
|
5
|
+
* runs by the core when the company has them installed.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {"standard" | "ask" | "planning"} BaseMode
|
|
10
|
+
* @typedef {{ id?: string | null, identifier?: string | null, title?: string | null, workMode: string }} Task
|
|
11
|
+
* @typedef {{ companyId: string, workMode: string, parent: { id: string, workMode: string, assigneeAgentId: string | null } }} Child
|
|
12
|
+
* @typedef {"parent" | "none" | "perMode"} ChildAssignment
|
|
13
|
+
* @typedef {{ childAssignment: ChildAssignment, agents: Record<string, string> }} AssignmentSettings
|
|
14
|
+
* @typedef {AssignmentSettings & { companies: Record<string, AssignmentSettings> }} WayfinderConfig
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* promptSection?(task: Task): string[] | null,
|
|
17
|
+
* runLiveness?(task: Task): { planExempt?: boolean } | null,
|
|
18
|
+
* planReview?(task: Task): boolean,
|
|
19
|
+
* childAssignee?(child: Child): { assigneeAgentId: string | null } | undefined,
|
|
20
|
+
* }} ModeHooks
|
|
21
|
+
* @typedef {{ id: string, label: string, baseMode: BaseMode, description?: string, skill?: string, tab?: { label: string }, hooks?: ModeHooks }} ModeDefinition
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** The modes a Wayfinder task's children take; the Plan child is the core Plan mode. */
|
|
25
|
+
export const CHILD_MODES = /** @type {const} */ (["wayfinder.grilling", "wayfinder.research", "planning", "wayfinder.delivery"]);
|
|
26
|
+
|
|
27
|
+
/** @type {readonly ModeDefinition[]} */
|
|
28
|
+
export const MODES = [
|
|
29
|
+
{
|
|
30
|
+
id: "wayfinder.map",
|
|
31
|
+
label: "Wayfinder",
|
|
32
|
+
baseMode: "standard",
|
|
33
|
+
skill: "wayfinder",
|
|
34
|
+
description: "Maps an initiative and creates its children: Grilling, Research, Plan, Delivery.",
|
|
35
|
+
// The Map tab; the client face fills it (`src/client.tsx`).
|
|
36
|
+
tab: { label: "Map" },
|
|
37
|
+
hooks: {
|
|
38
|
+
promptSection: () => [
|
|
39
|
+
"Wayfinder mode directive:",
|
|
40
|
+
"Map the initiative: the destination, what is known, what is open. Do not implement it yourself.",
|
|
41
|
+
"Create sub-tasks of this task for the work, each in its mode: `wayfinder.grilling` to settle open questions with the human, " +
|
|
42
|
+
"`wayfinder.research` for a spike or an investigation, `planning` for the plan, `wayfinder.delivery` for implementation.",
|
|
43
|
+
"Keep the map current in this task's description as children finish, and mark the next step.",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "wayfinder.grilling",
|
|
49
|
+
label: "Grilling",
|
|
50
|
+
baseMode: "ask",
|
|
51
|
+
skill: "grill-with-docs",
|
|
52
|
+
description: "Asks the human in batches of question cards, writes the decisions down, ends with a plan.",
|
|
53
|
+
hooks: {
|
|
54
|
+
promptSection: () => [
|
|
55
|
+
"Grilling mode directive:",
|
|
56
|
+
"Interview the human relentlessly, in batches of question cards, one decision per question, each with your recommended answer. " +
|
|
57
|
+
"Settle a question yourself when the code or the docs answer it.",
|
|
58
|
+
"As answers come, write them into the repository: glossary terms, ADRs for hard-to-reverse decisions, specs.",
|
|
59
|
+
"When no open question remains, write the plan as this task's plan document and stop: the plan card validates it. Do not implement.",
|
|
60
|
+
],
|
|
61
|
+
// Asking questions is the work: a run that only asked is progress.
|
|
62
|
+
runLiveness: () => ({ planExempt: true }),
|
|
63
|
+
planReview: () => true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "wayfinder.research",
|
|
68
|
+
label: "Research",
|
|
69
|
+
baseMode: "standard",
|
|
70
|
+
description: "Spike or investigation; the result is a document on the task.",
|
|
71
|
+
hooks: {
|
|
72
|
+
promptSection: () => [
|
|
73
|
+
"Research mode directive:",
|
|
74
|
+
"Investigate the question against primary sources or with a throwaway spike. Do not ship code.",
|
|
75
|
+
"Write the result as a document on this task: the answer, the evidence, what stays open.",
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "wayfinder.delivery",
|
|
81
|
+
label: "Delivery",
|
|
82
|
+
baseMode: "standard",
|
|
83
|
+
description: "Implementation of a planned piece of the initiative.",
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Who gets a child created without assignee under a Wayfinder task.
|
|
89
|
+
* @param {Child} child
|
|
90
|
+
* @param {WayfinderConfig} config
|
|
91
|
+
* @returns {{ assigneeAgentId: string | null } | undefined}
|
|
92
|
+
*/
|
|
93
|
+
export function childAssignee(child, config) {
|
|
94
|
+
const settings = config.companies[child.companyId] ?? config;
|
|
95
|
+
switch (settings.childAssignment) {
|
|
96
|
+
case "parent":
|
|
97
|
+
return child.parent.assigneeAgentId ? { assigneeAgentId: child.parent.assigneeAgentId } : undefined;
|
|
98
|
+
case "perMode": {
|
|
99
|
+
const agent = settings.agents?.[child.workMode];
|
|
100
|
+
return agent ? { assigneeAgentId: agent } : undefined;
|
|
101
|
+
}
|
|
102
|
+
default:
|
|
103
|
+
// none: left unassigned for task routing's decider (ADR 0016).
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
package/README.md
DELETED