demobites 1.32.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skill/scripts/plan.mjs +34 -5
package/package.json
CHANGED
package/skill/scripts/plan.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import { estimateTake } from "./clock.mjs";
|
|
|
22
22
|
import path from "node:path";
|
|
23
23
|
import { spawnSync } from "node:child_process";
|
|
24
24
|
import { fileURLToPath } from "node:url";
|
|
25
|
-
import { listening, postEvent } from "./listen-event.mjs";
|
|
25
|
+
import { listening, postEvent, poll } from "./listen-event.mjs";
|
|
26
26
|
|
|
27
27
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
28
28
|
const dir = process.argv[2];
|
|
@@ -218,7 +218,7 @@ const firstMessage = async () => {
|
|
|
218
218
|
// storyboard is the base; the note says what to keep an eye on; the probe finds what moved.
|
|
219
219
|
job.retake_of && job.storyboard
|
|
220
220
|
? `## This is a retake\nThe person wants the same demo filmed again, the same length and the same shots, because the app changed since. Their note: "${(job.retake_note || "no note").replace(/"/g, "'")}". ${job.storyboard.storyboard ? "Start from the previous storyboard below: keep its steps and its lines; probe it; fix only what no longer resolves or what the note names; then submit_storyboard. Never explore when the probe passes." : "Only the previous storyboard's lines survive (below): rebuild the same steps with the same lines, find the controls again, probe, then submit_storyboard."}\n\n## The previous storyboard\n${JSON.stringify(job.storyboard.storyboard ?? job.storyboard.steps ?? job.storyboard)}`
|
|
221
|
-
: codeOn ? `Write the storyboard from the page's own words, probe it, fix it, probe again, then submit_storyboard. Read a file only when the page's words do not name a control you need; never as a first move. You have
|
|
221
|
+
: codeOn ? `Write the storyboard from the page's own words, probe it, fix it, probe again, then submit_storyboard. Read a file only when the page's words do not name a control you need; never as a first move. You have three dry runs and two minutes from the first one; when a control of the brief is not where you looked, ask_person at once: the person is there and knows the app.` : `There is no code: explore first (explore from the starting address, looking_for = the brief's nouns), then write the storyboard, probe it, fix it, probe again, then submit_storyboard. You have three dry runs and two minutes from the first one; when a control of the brief is not where you looked, ask_person at once: the person is there and knows the app.`,
|
|
222
222
|
];
|
|
223
223
|
return parts.join("\n\n");
|
|
224
224
|
};
|
|
@@ -230,12 +230,40 @@ const messages = [{ role: "user", content: [{ type: "text", text: await firstMes
|
|
|
230
230
|
// three minutes from the first one, whichever comes first. After that no probe runs; the next move is the storyboard
|
|
231
231
|
// as it stands, with the steps it could not find named in `unsure`, so the person answers the question instead of
|
|
232
232
|
// waiting while it rewrites and retries (that job: 18 dry runs, 13 model turns).
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
// THE PERSON LEADS (founder 2026-10-18: "if the planner gets stuck, he should put the customer into discussion…
|
|
234
|
+
// I wouldn't go more than 2 minutes"): three dry runs, or two minutes from the first, and the planner ASKS — one
|
|
235
|
+
// short question through the chat (ask_person); the answer comes back as the tool's result and the counters start
|
|
236
|
+
// again. The person is there and knows their app; a storyboard guessed in minute six is worth less than a question
|
|
237
|
+
// in minute two.
|
|
238
|
+
const CAP_PROBES = 3;
|
|
239
|
+
const CAP_MS = 2 * 60 * 1000;
|
|
235
240
|
let probes = 0;
|
|
236
241
|
let firstProbeAt = 0;
|
|
242
|
+
let asked = 0;
|
|
237
243
|
const capped = () => probes >= CAP_PROBES || (firstProbeAt && Date.now() - firstProbeAt > CAP_MS);
|
|
238
|
-
const CAP_TEXT = () =>
|
|
244
|
+
const CAP_TEXT = () => asked < 2
|
|
245
|
+
? `STOP (${probes} dry run${probes === 1 ? "" : "s"}, ${Math.round((Date.now() - (firstProbeAt || Date.now())) / 1000)} s since the first). No more dry runs, no more reading. Call ask_person NOW with ONE short question in plain words: what you were looking for, where you looked, and how they want to play it (where it is, or what to show instead). The person is there and knows the app. Their answer comes back as the result; then fix the storyboard from their words, probe once, and hand it in.`
|
|
246
|
+
: `STOP. Hand in the storyboard NOW with submit_storyboard: keep every step that passed; a step that failed becomes a hover or a settle on the nearest element the page does have, or goes; name in \`unsure\` what you could not find.`;
|
|
247
|
+
/** The question goes to the chat; the planner waits here for the person's word (up to 30 minutes). */
|
|
248
|
+
const askPerson = async (text) => {
|
|
249
|
+
const q = String(text || "").trim().slice(0, 600);
|
|
250
|
+
if (!q) return "ask_person needs a question.";
|
|
251
|
+
say("Asking you in the chat…");
|
|
252
|
+
if (!listening) return "(no chat here: decide yourself and hand in the storyboard)";
|
|
253
|
+
await postEvent("question", { text: q });
|
|
254
|
+
const started = Date.now();
|
|
255
|
+
while (Date.now() - started < 30 * 60 * 1000) {
|
|
256
|
+
const st = await poll();
|
|
257
|
+
if (st?.status === "cancelled" || st?.status === "failed") { console.log(" The person cancelled."); process.exit(0); }
|
|
258
|
+
if (st && st.status !== "waiting_answer") {
|
|
259
|
+
const a = st.answer && typeof st.answer === "object" ? st.answer : null;
|
|
260
|
+
asked += 1; probes = 0; firstProbeAt = 0;
|
|
261
|
+
return a?.note ? `The person says: "${String(a.note).slice(0, 2000)}"` : "The person said to go on as you see fit.";
|
|
262
|
+
}
|
|
263
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
264
|
+
}
|
|
265
|
+
return "No answer came in 30 minutes: hand in the storyboard as it stands, with what you could not find in unsure.";
|
|
266
|
+
};
|
|
239
267
|
const plan = async () => {
|
|
240
268
|
say("Writing the storyboard…");
|
|
241
269
|
storyboard = null;
|
|
@@ -265,6 +293,7 @@ const plan = async () => {
|
|
|
265
293
|
else if (u.name === "harvest_words") { say(`Reading the app's own words on ${(input.urls || []).length} page${(input.urls || []).length === 1 ? "" : "s"}…`); out = harvest(input.urls); }
|
|
266
294
|
else if (u.name === "explore") { say(`Walking the app from ${where(input.from)}, looking for ${String(input.looking_for || "the brief's words").slice(0, 60)}…`); out = explore(input.from, input.looking_for, input.depth); }
|
|
267
295
|
else if (u.name === "screenshot") { say(`Looking at ${where(input.url)}…`); out = screenshot(input.url); }
|
|
296
|
+
else if (u.name === "ask_person") { out = await askPerson(input.question); }
|
|
268
297
|
else if (u.name === "probe") {
|
|
269
298
|
if (capped()) out = CAP_TEXT();
|
|
270
299
|
else {
|