shadok-ai 0.19.81 → 0.19.83

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 CHANGED
@@ -597,6 +597,9 @@ Enter to skip; you can add it later from the web UI).
597
597
  isn't on screen is **dropped rather than faked** — an empty cockpit has no
598
598
  agent menu, a cockpit with no group has no groups column, a member has no
599
599
  Reports button — so it gets a shorter tour instead of a spotlight on nothing.
600
+ Which steps exist is **re-read from the page at every step**, and the first
601
+ count waits (4s at most) for the agents and the account to load — a tour that
602
+ filtered its list once, at start, played five stops on a cockpit that has eleven.
600
603
  The bubble sits below its target, above it, or **beside** it when the target
601
604
  is a full-height column, so it never covers what it describes. The
602
605
  **phone gets the whole tour**, because a step can name the landmark on either
@@ -92,9 +92,16 @@ Write the **whole** prompt: it replaces the old one, it does not add to it.
92
92
  5. task finished: `diff <id>` and present the changes to the user. The
93
93
  `shadok-ai/<tag>` branch and its worktree are NEVER merged or deleted
94
94
  automatically — the user is the one who merges.
95
+ 6. result delivered, nothing left to ask it: `stop <id>`. An agent left open
96
+ stays a channel in the human's cockpit and a process resumed at every
97
+ restart. Stopping loses no work (the branch, and a checkout with uncommitted
98
+ changes, are kept — only an empty worktree is pruned). Keep it only when the
99
+ human wants to steer it, when it must still answer a review, or when it owns
100
+ a schedule or a webhook: those are deleted with the channel.
95
101
 
96
102
  Parallel agents: repeat `spawn` (one id per agent), and launch the `prompt`
97
- calls in the background simultaneously.
103
+ calls in the background simultaneously — and `stop` each one as its result
104
+ comes in.
98
105
 
99
106
  ## You get told: your agents report back
100
107
 
@@ -106,6 +106,15 @@ other** — do not wait to be asked. Two tools, for two different shapes:
106
106
  branch, a PR, a change in another repo — or that the human may want to follow
107
107
  and steer apart from you. It gets its own worktree and its own channel in
108
108
  the cockpit. Name it so the human can tell it apart.
109
+ - **Close the sibling agents you spawned once their job is done** —
110
+ `node ~/.claude/skills/shadok-ai-agents/pilotctl.mjs stop <id>`. Each one you leave open stays a channel in the
111
+ human's cockpit, a running process and a resume at every restart, long after
112
+ anyone needs it. Done means its result is delivered: you read its answer,
113
+ presented its diff or its PR, and nothing is left to ask it. Closing loses no
114
+ work — its branch and any uncommitted checkout are kept. Keep it open only
115
+ when the human wants to follow or steer it, when it still has to answer a
116
+ review, or when it carries a schedule or a webhook (those are deleted with
117
+ it). Close only agents YOU spawned, never someone else's.
109
118
 
110
119
  The human cannot see a sub-agent's progress: the chat shows only its call and
111
120
  its result. So say in one line what you delegated and why before you wait on it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.81",
3
+ "version": "0.19.83",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test --test-timeout=120000 test/*.ts context/*/test/*.test.mjs",
package/public/index.html CHANGED
@@ -4753,7 +4753,7 @@
4753
4753
  import { shrinkToFit, nameReads, chanOverflowIds, chanOverflowItems } from "/bar-overflow.js?v=__ASSET_V__";
4754
4754
  import { echoAuthor, isOwnPrompt } from "/echo-author.js?v=__ASSET_V__";
4755
4755
  import { dialPos, dialColor, dialTitle } from "/gauge-dial.js?v=__ASSET_V__";
4756
- import { TOUR_STEPS, bubblePlacement, unionRect, visibleSteps } from "/tour-steps.js?v=__ASSET_V__";
4756
+ import { TOUR_STEPS, bubblePlacement, tourStanding, unionRect, visibleSteps } from "/tour-steps.js?v=__ASSET_V__";
4757
4757
  import { pickChannelSource, dirKey, serverSwapped } from "/channel-store.js?v=__ASSET_V__";
4758
4758
  import { MODEL_CHOICES, composeModel } from "/model-choice.js?v=__ASSET_V__";
4759
4759
  import { EFFORT_CHOICES, effortLabel } from "/effort-choice.js?v=__ASSET_V__";
@@ -4846,6 +4846,7 @@
4846
4846
  window.bubblePlacement = bubblePlacement;
4847
4847
  window.unionRect = unionRect;
4848
4848
  window.visibleSteps = visibleSteps;
4849
+ window.tourStanding = tourStanding;
4849
4850
  window.extractLiveText = extractLiveText;
4850
4851
  window.livePreviewDecision = livePreviewDecision;
4851
4852
  window.profileBlurb = profileBlurb;
@@ -5053,6 +5054,7 @@
5053
5054
  bubblePlacement: () => null,
5054
5055
  unionRect: () => null,
5055
5056
  visibleSteps: (steps) => steps ?? [],
5057
+ tourStanding: () => ({ step: null, index: 0, total: 0 }),
5056
5058
  // The viewer is opened by a click, so the module is long since loaded —
5057
5059
  // but a stub is still the rule (invariant 10), and the honest one here
5058
5060
  // shows the table UNFILTERED rather than an empty panel that reads as
@@ -6645,6 +6647,10 @@
6645
6647
  // directory), so it survives a wiped browser, another device or a reboot.
6646
6648
  let channelPushTimer = null;
6647
6649
  let restoring = true; // suppress pushes until the initial restore is done
6650
+ // Resolved once the boot restore has painted its tabs (or found none) — what
6651
+ // the guided tour waits for before counting its steps.
6652
+ let markBootSettled = () => {};
6653
+ const bootSettled = new Promise((r) => { markBootSettled = r; });
6648
6654
  // Set once the server on this origin turns out to be a DIFFERENT instance than
6649
6655
  // the one this page was loaded from (its port was taken over after a stop).
6650
6656
  // From then on the tab must not write — it would only poison the new
@@ -17140,7 +17146,7 @@
17140
17146
  $("peerName").value = ""; $("peerBrief").value = "";
17141
17147
  renderPeers();
17142
17148
  });
17143
- loadMe();
17149
+ const meReady = loadMe(); // the guided tour waits for it: the role decides its people step
17144
17150
 
17145
17151
  $("profilesBtn").addEventListener("click", () => openProfilesPanel());
17146
17152
  $("editProfilesLink").addEventListener("click", () => openProfilesPanel());
@@ -17309,8 +17315,11 @@
17309
17315
  else alert((await r.json()).error || "update failed");
17310
17316
  }
17311
17317
  // --- Guided tour --------------------------------------------------------
17312
- let tourSteps = [];
17313
- let tourAt = 0;
17318
+ // The id of the step on screen, null before the first one. NOT an index into
17319
+ // a list filtered at start: which steps exist is re-read from the page at
17320
+ // every step (window.tourStanding), because the tour can start before the
17321
+ // agents and the account have landed.
17322
+ let tourId = null;
17314
17323
  let tourOnEnd = null;
17315
17324
 
17316
17325
  /** Every element a step points at, in DOM order. */
@@ -17327,14 +17336,15 @@
17327
17336
  });
17328
17337
  }
17329
17338
 
17330
- function paintTourStep() {
17331
- const step = tourSteps[tourAt];
17339
+ function paintTourStep(advance = false) {
17340
+ const { step, index, total } = window.tourStanding(window.TOUR_STEPS, tourId, tourVisible, advance);
17332
17341
  if (!step) return endTour();
17342
+ tourId = step.id;
17333
17343
  const overlay = $("tourOverlay");
17334
17344
  $("tourTitle").textContent = step.title;
17335
17345
  $("tourBody").textContent = step.body;
17336
- $("tourCount").textContent = `${tourAt + 1}/${tourSteps.length}`;
17337
- $("tourNext").textContent = tourAt === tourSteps.length - 1 ? "Done" : "Next ›";
17346
+ $("tourCount").textContent = `${index}/${total}`;
17347
+ $("tourNext").textContent = index === total ? "Done" : "Next ›";
17338
17348
 
17339
17349
  if (step.target === null) {
17340
17350
  overlay.classList.remove("spotlight");
@@ -17348,7 +17358,7 @@
17348
17358
  const box = window.unionRect(rects);
17349
17359
  // The step was filtered in because it was visible; if it vanished since
17350
17360
  // (a closed tab), skip forward rather than frame nothing.
17351
- if (!box) { tourAt++; return paintTourStep(); }
17361
+ if (!box) return paintTourStep(true);
17352
17362
  overlay.classList.add("spotlight");
17353
17363
  const pad = 6;
17354
17364
  Object.assign($("tourHole").style, {
@@ -17371,12 +17381,17 @@
17371
17381
  function startTour(onEnd) {
17372
17382
  // window.visibleSteps comes from the ESM bridge, which runs AFTER this
17373
17383
  // classic script — so this must never be called at parse time (invariant 10).
17374
- tourSteps = window.visibleSteps(window.TOUR_STEPS, tourVisible);
17375
- if (!tourSteps.length) { onEnd?.(); return; }
17384
+ tourId = null;
17385
+ // Nothing to show (or the bridge never landed): hand over WITHOUT marking
17386
+ // the tour as seen — endTour would, and the person never saw it.
17387
+ if (!window.tourStanding(window.TOUR_STEPS, null, tourVisible).step) { onEnd?.(); return; }
17376
17388
  tourOnEnd = onEnd ?? null;
17377
- tourAt = 0;
17378
17389
  $("tourOverlay").hidden = false;
17379
17390
  paintTourStep();
17391
+ // One repaint a moment later: something that lands just after the first
17392
+ // paint (the groups column is drawn a frame behind the tabs) should not
17393
+ // leave the welcome card on a count the next step contradicts.
17394
+ setTimeout(() => { if (!$("tourOverlay").hidden) paintTourStep(); }, 1200);
17380
17395
  }
17381
17396
 
17382
17397
  function endTour() {
@@ -17388,7 +17403,7 @@
17388
17403
  done?.();
17389
17404
  }
17390
17405
 
17391
- $("tourNext").addEventListener("click", () => { tourAt++; paintTourStep(); });
17406
+ $("tourNext").addEventListener("click", () => paintTourStep(true));
17392
17407
  $("tourSkip").addEventListener("click", endTour);
17393
17408
  // A click on the overlay itself — including through the hole, which has
17394
17409
  // pointer-events: none — ends it. Nobody is trapped in a tutorial.
@@ -17417,6 +17432,16 @@
17417
17432
  // gives up after 3s and leaves the cache in charge).
17418
17433
  await prefsReady;
17419
17434
  if (cachedPref("tourSeen") === true) { checkAuth(); return; }
17435
+ // And for the page itself: the agents (boot restore) and the account
17436
+ // (loadMe) decide which steps have a target. Started before them, the
17437
+ // welcome card read "1/5" on a cockpit whose tour has eleven stops. Each
17438
+ // step re-reads the page anyway, so this only makes the FIRST count right
17439
+ // — hence bounded: a slow server delays the tour by 4s at most, never
17440
+ // holds it.
17441
+ await Promise.race([
17442
+ Promise.all([bootSettled, meReady]).catch(() => {}),
17443
+ new Promise((r) => setTimeout(r, 4000)),
17444
+ ]);
17420
17445
  startTour(() => checkAuth());
17421
17446
  }
17422
17447
 
@@ -18490,6 +18515,10 @@
18490
18515
  // Only now: `syncChannels` is a no-op while `restoring`, so kicking the loop
18491
18516
  // off any earlier would leave the first EFFECTIVE pass a full period away —
18492
18517
  // which is the four-second blank this whole change is about.
18518
+ // The tabs are painted (or there are none): the guided tour may count its
18519
+ // steps. A restore that threw never gets here — the tour's own 4s bound is
18520
+ // what releases it then.
18521
+ markBootSettled();
18493
18522
  if (!followAgentHash()) followDeepLink();
18494
18523
  syncLoop();
18495
18524
  })();
@@ -223,6 +223,37 @@ export function visibleSteps(steps, isVisible) {
223
223
  return steps.filter((s) => s.target === null || isVisible(s.target));
224
224
  }
225
225
 
226
+ /**
227
+ * Pure: where the tour stands, re-read against the page as it is NOW.
228
+ *
229
+ * `currentId` null means "not started": the answer is the first visible step.
230
+ * Otherwise it is the next visible step AFTER the current one in the tour's own
231
+ * order (`advance`), or the current one again (a repaint).
232
+ *
233
+ * The list used to be filtered ONCE, when the tour started — and on a first
234
+ * visit it starts with the page still loading: no agent restored yet, the
235
+ * account not yet known. Every step about an agent, the composer and the
236
+ * people buttons was dropped for good before its target had a chance to
237
+ * exist, and an eleven-step tour played five. Visibility is a fact about a
238
+ * moment, so it is asked again at every step; the counter is therefore over
239
+ * the steps visible NOW, and may grow while the welcome card is being read.
240
+ *
241
+ * The current step always counts as present, even if its target just went
242
+ * away: a counter reading "4/3" is worse than one step framing nothing, which
243
+ * the caller already skips.
244
+ */
245
+ export function tourStanding(steps, currentId, isVisible, advance = false) {
246
+ const here = currentId == null ? -1 : steps.findIndex((s) => s.id === currentId);
247
+ const shown = (s, i) => i === here || s.target === null || isVisible(s.target);
248
+ let at = here;
249
+ if (here < 0 || advance) {
250
+ at = steps.findIndex((s, i) => i > here && shown(s, i));
251
+ if (at < 0) return { step: null, index: 0, total: 0 };
252
+ }
253
+ const visible = steps.filter((s, i) => i === at || shown(s, i));
254
+ return { step: steps[at], index: visible.indexOf(steps[at]) + 1, total: visible.length };
255
+ }
256
+
226
257
  /**
227
258
  * Pure: the rectangle enclosing them all, or null when there are none.
228
259
  *