@todoforai/tfa-surface 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +71 -62
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -116,7 +116,7 @@ function resolveToken(opts = {}) {
116
116
  // package.json
117
117
  var package_default = {
118
118
  name: "@todoforai/tfa-surface",
119
- version: "0.1.2",
119
+ version: "0.1.3",
120
120
  description: "TODOforAI surface CLI — see and drive what is shown in the user's live UI (describe, todo/panel views, renderer cards, surface render, controls). Replaces tfa-frontend. Reuses bridge credentials.",
121
121
  type: "module",
122
122
  bin: {
@@ -156,22 +156,23 @@ Usage:
156
156
  tfa-surface <command> [args...]
157
157
 
158
158
  Discovery:
159
- describe What's open in the target frontend:
160
- todos, focus, panel surfaces, sidebar,
161
- embedded-browser CDP URL, show/card
162
- instances in loaded chats. YAML; --json
163
- for the raw structure.
159
+ describe Every surface in the target frontend — kind, id,
160
+ ref, focus; plus sidebar, embedded-browser CDP
161
+ URL and the show instances loaded in each todo.
162
+ YAML; --json for the raw structure.
164
163
 
165
- Todos (views):
166
- todo open <todoId> [--popout] Open a todo (full-page overlay); --popout
167
- forces a floating preview window.
168
- todo focus <todoId> Focus an open todo's window.
169
- todo close <todoId> Close an open todo view.
170
-
171
- Panels (surfaces inside a todo; --todo defaults to $TODOFORAI_TODO_ID):
172
- panel open <surface> [--todo <id>] [--url <url>]
173
- surface: changes|agents|preview|browser|terminal
174
- panel close [--todo <id>]
164
+ Surfaces — a ref is a todo id, <todoId>:<alias> (a shown artifact, live) or an http(s) url:
165
+ open overlay <todoId> The full-page todo (todos only).
166
+ open window <ref> A floating preview window (any ref).
167
+ open panel <view> [--todo <id>] [--url <url>]
168
+ A todo's side panel: changes|agents|preview|browser|terminal
169
+ (--todo defaults to $TODOFORAI_TODO_ID).
170
+ open card <ref> [--id <id>] [--title <t>] [--group <slug>]
171
+ A card on the project board, for every member —
172
+ its own card, or a tile inside a group's card.
173
+ Persisted; the same --id updates in place.
174
+ close <kind> <id> overlay: no id · window: the ref · panel: the todo · card: its id
175
+ focus window <ref> Bring a window (or its docked tab) to front.
175
176
 
176
177
  Renderer cards (data plane — works headless, no frontend needed;
177
178
  --project defaults to $TODOFORAI_PROJECT_ID):
@@ -193,6 +194,7 @@ Content (inherited from tfa-frontend, broadcast to all tabs):
193
194
 
194
195
  Options:
195
196
  --frontend <tabId> Target frontend (overrides $TODOFORAI_FRONTEND_ID)
197
+ --id <surfaceId> Card id (open card); --group <slug> files it into a group card
196
198
  --api-url <url> Backend URL (default: env/credentials)
197
199
  --api-token <tok> Token (default: env/credentials)
198
200
  --json Machine-readable output
@@ -202,9 +204,12 @@ Options:
202
204
  Examples:
203
205
  tfa-surface describe
204
206
  tfa-surface card add kpi-tile dashboards/kpi.html --title "KPI tile"
205
- tfa-surface todo open 3f2a91... --popout
206
- tfa-surface panel open browser --url https://example.com
207
- agent-browser connect "$(tfa-surface describe --json | jq -r '.todos[0].browser.cdp')"
207
+ tfa-surface open window 3f2a91...
208
+ tfa-surface open window $TODOFORAI_TODO_ID:kpi # a shown artifact, in its own window
209
+ tfa-surface open card $TODOFORAI_TODO_ID:kpi --title "Weekly KPIs" --group marketing
210
+ tfa-surface open panel browser --url https://example.com
211
+ tfa-surface close card weekly-kpis
212
+ agent-browser connect "$(tfa-surface describe --json | jq -r '.surfaces[] | select(.browser) | .browser.cdp' | head -1)"
208
213
  git diff --stat | tfa-surface show chat.panel $TODOFORAI_TODO_ID
209
214
 
210
215
  Exit codes: 0 ok · 1 error · 2 frontend not reachable / no frontend id`);
@@ -284,24 +289,18 @@ function printResult(ctx, data) {
284
289
  function printDescribe(d) {
285
290
  console.log(`frontend: ${d.frontendId} (${d.platform}, ${d.kind})`);
286
291
  console.log(`sidebar: ${d.sidebar}`);
287
- console.log(d.todos.length ? "todos:" : "todos: []");
288
- for (const t of d.todos) {
289
- const flags = [t.mode === "window" ? "window" : "", t.focused ? "focused" : ""].filter(Boolean).join(", ");
290
- console.log(` ${t.todoId}:${flags ? ` ${flags}` : ""}${t.title ? ` # ${t.title}` : ""}`);
291
- if (t.panel && t.panel !== "browser")
292
- console.log(` ${t.panel}`);
293
- if (t.browser)
294
- console.log(` browser: ${t.browser.open ? t.browser.url : "(idle)"} cdp: ${t.browser.cdp}`);
295
- if (t.shows?.length) {
292
+ console.log(d.surfaces.length ? "surfaces:" : "surfaces: []");
293
+ for (const s of d.surfaces) {
294
+ const flags = [s.focused ? "focused" : "", s.docked ? "docked" : "", s.view ?? "", s.group ? `in ${s.group}` : ""].filter(Boolean).join(", ");
295
+ const id = s.kind === "overlay" || s.id === s.ref ? "" : ` ${s.id}`;
296
+ console.log(` ${s.kind}${id}: ${s.ref}${flags ? ` ${flags}` : ""}${s.title ? ` # ${s.title}` : ""}`);
297
+ if (s.browser)
298
+ console.log(` browser: ${s.browser.open ? s.browser.url : "(idle)"} cdp: ${s.browser.cdp}`);
299
+ if (s.shows?.length) {
296
300
  console.log(" shows:");
297
- for (const s of t.shows) {
298
- const bits = [
299
- s.card ? `card=${s.card}` : "",
300
- s.mime || "",
301
- s.url ? `url ${s.url}` : "",
302
- s.title || ""
303
- ].filter(Boolean);
304
- console.log(` ${s.ref}${bits.length ? ` ${bits.join(" ")}` : ""}`);
301
+ for (const x of s.shows) {
302
+ const bits = [x.card ? `card=${x.card}` : "", x.mime || "", x.url ? `url ${x.url}` : "", x.title || ""].filter(Boolean);
303
+ console.log(` ${x.ref}${bits.length ? ` ${bits.join(" ")}` : ""}`);
305
304
  }
306
305
  }
307
306
  }
@@ -315,7 +314,8 @@ async function main() {
315
314
  project: { type: "string" },
316
315
  title: { type: "string" },
317
316
  description: { type: "string" },
318
- popout: { type: "boolean", default: false },
317
+ id: { type: "string" },
318
+ group: { type: "string" },
319
319
  "api-url": { type: "string" },
320
320
  "api-token": { type: "string" },
321
321
  json: { type: "boolean", default: false },
@@ -354,37 +354,46 @@ async function main() {
354
354
  printDescribe(result);
355
355
  break;
356
356
  }
357
- case "todo": {
358
- const [verb, todoId] = args;
359
- if (!verb || !todoId)
360
- die("usage: tfa-surface todo open|focus|close <todoId>");
361
- if (verb === "open") {
362
- const result = await uiCall(ctx, "todo.open", { todoId, ...values.popout ? { mode: "window" } : {} });
363
- console.log(ctx.json ? JSON.stringify(result) : `${result.created ? "opened" : "already open"} (${result.mode})`);
364
- } else if (verb === "focus" || verb === "close") {
365
- await uiCall(ctx, `todo.${verb}`, { todoId });
366
- console.log(ctx.json ? '{"ok":true}' : "ok");
367
- } else {
368
- die(`unknown todo verb: ${verb}`);
369
- }
370
- break;
371
- }
372
- case "panel": {
373
- const [verb, surface] = args;
374
- if (verb === "open") {
375
- if (!surface)
376
- die("usage: tfa-surface panel open changes|agents|preview|browser|terminal [--todo <id>] [--url <url>]");
377
- const result = await uiCall(ctx, "panel.open", { todoId: todoArg(), surface, ...values.url ? { url: values.url } : {} });
357
+ case "open": {
358
+ const [kind, arg] = args;
359
+ const usage = "usage: tfa-surface open overlay <todoId> | window <ref> | panel <view> [--todo <id>] [--url <url>] | card <ref> [--id <id>] [--title <t>] [--group <slug>]";
360
+ if (kind === "overlay" || kind === "window") {
361
+ if (!arg)
362
+ die(usage);
363
+ const result = await uiCall(ctx, "surface.open", { kind, ref: arg });
364
+ console.log(ctx.json ? JSON.stringify(result) : `${result.created ? "opened" : "already open"} (${kind})`);
365
+ } else if (kind === "panel") {
366
+ if (!arg)
367
+ die(usage);
368
+ const result = await uiCall(ctx, "surface.open", { kind, id: todoArg(), view: arg, ref: values.url ?? arg });
378
369
  const pending = result?.browserReady === false;
379
370
  console.log(ctx.json ? JSON.stringify(result ?? { ok: true }) : pending ? "ok (browser opening — its CDP url appears in `device_list` shortly)" : "ok");
380
- } else if (verb === "close") {
381
- await uiCall(ctx, "panel.close", { todoId: todoArg() });
382
- console.log(ctx.json ? '{"ok":true}' : "ok");
371
+ } else if (kind === "card") {
372
+ if (!arg)
373
+ die(usage);
374
+ const result = await uiCall(ctx, "surface.open", {
375
+ kind,
376
+ ref: arg,
377
+ ...values.id ? { id: values.id } : {},
378
+ ...values.title !== undefined ? { title: values.title } : {},
379
+ ...values.group !== undefined ? { group: values.group } : {}
380
+ });
381
+ console.log(ctx.json ? JSON.stringify(result) : `card ${result.id} ${result.created ? "added to" : "updated on"} the board`);
383
382
  } else {
384
- die("usage: tfa-surface panel open|close ...");
383
+ die(usage);
385
384
  }
386
385
  break;
387
386
  }
387
+ case "close":
388
+ case "focus": {
389
+ const [kind, arg] = args;
390
+ const id = kind === "overlay" ? "" : kind === "panel" ? arg || todoArg() : arg;
391
+ if (!kind || kind !== "overlay" && !id)
392
+ die(`usage: tfa-surface ${cmd} overlay | window <ref> | panel [<todoId>] | card <id>`);
393
+ await uiCall(ctx, `surface.${cmd}`, { kind, id });
394
+ console.log(ctx.json ? '{"ok":true}' : "ok");
395
+ break;
396
+ }
388
397
  case "card": {
389
398
  const [verb, name] = args;
390
399
  const cardPath = (n) => `/resources/cards/${projectArg()}/${encodeURIComponent(n)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/tfa-surface",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "TODOforAI surface CLI — see and drive what is shown in the user's live UI (describe, todo/panel views, renderer cards, surface render, controls). Replaces tfa-frontend. Reuses bridge credentials.",
5
5
  "type": "module",
6
6
  "bin": {