@picassohq/cli 1.0.6 → 1.0.9

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 (42) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +104 -0
  3. package/dist/build-info.json +1 -1
  4. package/dist/index.js +1955 -1530
  5. package/package.json +27 -5
  6. package/runtime/dsh/picasso-providers.patch.yml +49 -61
  7. package/runtime/dsh/picasso-runtime.cordis.yml +49 -61
  8. package/runtime/engine-manifest.json +18 -8
  9. package/runtime/packages/picasso-browser/cordis.patch.yml +4 -0
  10. package/runtime/packages/picasso-browser/index.js +915 -0
  11. package/runtime/packages/picasso-browser/package.json +29 -0
  12. package/runtime/packages/picasso-commands/index.js +51 -1
  13. package/runtime/packages/picasso-compaction/index.js +116 -1
  14. package/runtime/packages/picasso-computer/cordis.patch.yml +5 -0
  15. package/runtime/packages/picasso-computer/index.js +670 -0
  16. package/runtime/packages/picasso-computer/native-anthropic.js +212 -0
  17. package/runtime/packages/picasso-computer/package.json +30 -0
  18. package/runtime/packages/picasso-computer/support.js +95 -0
  19. package/runtime/packages/picasso-lean-context/index.js +751 -15
  20. package/runtime/packages/picasso-lean-context/timeline.js +3 -2
  21. package/runtime/packages/picasso-model-router/connections.js +1 -1
  22. package/runtime/packages/picasso-progress-reports/index.js +121 -3
  23. package/runtime/packages/picasso-sdk-server/browser-host.js +94 -0
  24. package/runtime/packages/picasso-sdk-server/index.js +23 -3
  25. package/runtime/plugins/picasso-browser/index.js +319 -22
  26. package/runtime/plugins/picasso-browser/package.json +1 -1
  27. package/runtime/plugins/picasso-commands/index.js +51 -1
  28. package/runtime/plugins/picasso-compaction/index.js +116 -1
  29. package/runtime/plugins/picasso-computer/index.js +670 -0
  30. package/runtime/plugins/picasso-computer/native-anthropic.js +212 -0
  31. package/runtime/plugins/picasso-computer/package.json +30 -0
  32. package/runtime/plugins/picasso-computer/support.js +95 -0
  33. package/runtime/plugins/picasso-lean-context/index.js +751 -15
  34. package/runtime/plugins/picasso-lean-context/timeline.js +3 -2
  35. package/runtime/plugins/picasso-model-router/connections.js +1 -1
  36. package/runtime/plugins/picasso-progress-reports/index.js +121 -3
  37. package/runtime/relay/main.mjs +5005 -2250
  38. package/runtime/relay/remote/index.html +10 -2
  39. package/runtime/relay/remote/remote.css +8 -1
  40. package/runtime/relay/remote/remote.js +78 -17
  41. package/runtime/relay/versions-routes.mjs +52 -37
  42. package/scripts/install-runtime.mjs +33 -7
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@picasso/browser",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "dsh cordis plugin: browser_* model tools executed by the Picasso Mac app on the thread's Preview pane, or by the CLI's headless browser (localhost, thread files and public sites the person allows), over the picassoBrowser/* Host Remote service the helper relay or the CLI's SDK server long-polls.",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./cordis.patch.yml": "./cordis.patch.yml",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "dshTarget": "0.2.2-rc.3",
14
+ "dsh": {
15
+ "bundle": {
16
+ "patch": "./cordis.patch.yml"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "test": "node --import ../../test/setup/hermetic-preload.mjs --test test/*.test.mjs"
21
+ },
22
+ "files": [
23
+ "index.js",
24
+ "page",
25
+ "cordis.patch.yml",
26
+ "README.md"
27
+ ],
28
+ "license": "UNLICENSED"
29
+ }
@@ -2,7 +2,7 @@
2
2
  // in the dsh command registry (ctx.commands). Handlers acknowledge the command;
3
3
  // execution stays on the picasso surface (TUI/CLI/Mac app).
4
4
  // Generated from packages/commands/src/manifest.ts (dsh's own goal/plan excluded).
5
- // The `init` and `worktree` registrations below are hand-maintained: unlike the
5
+ // The `init`, `worktree`, `plan-clear` and `review` registrations below are hand-maintained: unlike the
6
6
  // generated rows their handlers do the work in-dsh (`init` writes AGENTS.md into
7
7
  // the session workspace; `worktree` drives the engine's `worktrees` service).
8
8
  import { existsSync, readFileSync, writeFileSync } from 'node:fs'
@@ -463,6 +463,50 @@ async function reviewHandler(ctx, invocation) {
463
463
  }
464
464
  }
465
465
 
466
+ // ---- hand-maintained: /plan-clear ----------------------------------------------------------------
467
+ // Clears the session's plan (its todo list) the way the model's own `todo_write` with an empty list does: one
468
+ // `todo/write` record with `todos: []` in the session log, marked `clearedBy: 'user'`. Every surface folds "the last
469
+ // todo/write" into the plan it shows (TUI, Mac, the plan reminders), so the plan stays cleared after a reopen. The TUI's
470
+ // `/plan clear`, `picasso plan clear --session <id>` and the Mac's "Clear plan" all run this command. Owner 2026-11-18:
471
+ // a 6/10 plan from an earlier task showed beside a 100% progress bar through every close and reopen.
472
+
473
+ export const PLAN_CLEAR_COMMAND = 'plan-clear'
474
+ export const PLAN_CLEAR_DESCRIPTION = "Clear this session's plan (its todo list), e.g. one left from an earlier task."
475
+ export const PLAN_CLEARED_TEXT = 'Plan cleared.'
476
+ export const NO_PLAN_TEXT = 'There is no plan to clear.'
477
+
478
+ /** The session's last todo list (the newest `todo/write`), or undefined when it never wrote one. */
479
+ export function lastTodoList(session) {
480
+ const length = Number.isSafeInteger(session?.seq) ? session.seq : 0
481
+ if (typeof session?.eventAt !== 'function') return undefined
482
+ for (let seq = length - 1; seq >= 0; seq -= 1) {
483
+ let event
484
+ try {
485
+ event = session.eventAt(seq)
486
+ } catch {
487
+ event = undefined
488
+ }
489
+ if (event?.type === 'todo/write') return Array.isArray(event.data?.todos) ? event.data.todos : []
490
+ }
491
+ return undefined
492
+ }
493
+
494
+ /** `/plan-clear`: appends the empty `todo/write`; a session with no plan (or an already empty one) is left as it is. */
495
+ export function planClearHandler(invocation) {
496
+ const session = invocation?.agent?.session
497
+ if (session === undefined || session === null || typeof session.append !== 'function') {
498
+ return { kind: 'error', text: '/plan-clear needs a session — there is no calling agent.' }
499
+ }
500
+ const last = lastTodoList(session)
501
+ if (last === undefined || last.length === 0) return { kind: 'success', text: NO_PLAN_TEXT }
502
+ const event = session.append('todo/write', { todos: [], clearedBy: 'user' })
503
+ return {
504
+ kind: 'success',
505
+ text: PLAN_CLEARED_TEXT,
506
+ ...(Number.isSafeInteger(event?.seq) && event.seq >= 0 ? { sourceEventSeq: event.seq } : {}),
507
+ }
508
+ }
509
+
466
510
  export function apply(ctx) {
467
511
  for (const cmd of COMMANDS) {
468
512
  ctx.commands.register({
@@ -487,6 +531,12 @@ export function apply(ctx) {
487
531
  input: { hint: '[<name>]' },
488
532
  handler: (invocation) => worktreeHandler(ctx, invocation),
489
533
  });
534
+ // Real engine-side handler: records the cleared plan in the session log (see planClearHandler).
535
+ ctx.commands.register({
536
+ name: PLAN_CLEAR_COMMAND,
537
+ description: PLAN_CLEAR_DESCRIPTION,
538
+ handler: (invocation) => planClearHandler(invocation),
539
+ });
490
540
  // Real engine-side handler: starts the reviewer subagents and returns the merged findings.
491
541
  ctx.commands.register({
492
542
  name: 'review',
@@ -102,6 +102,7 @@ const RULES = [
102
102
  '- Do NOT mention this summarization request or that the context was compacted.',
103
103
  '- Output only the checkpoint text: do not call any tool or take any other action.',
104
104
  '- A <compacted-summary> block in the material is an earlier checkpoint: keep its still-true facts, drop stale ones, and merge newer information into one consolidated summary.',
105
+ '- A <session-state> block is the session\'s live plan, goal and newest progress report: list every plan item with its exact status under Pending Jobs, and keep the goal and the progress percent in Critical Context.',
105
106
  ].join('\n');
106
107
 
107
108
  /** The instruction after the replayed history (single call: the engine's request shape). */
@@ -594,6 +595,119 @@ export function createSummarizer({ llm, stock, engineConfig = () => undefined, l
594
595
  };
595
596
  }
596
597
 
598
+ // ── Session state in the summary input ──────────────────────────────────────────────────────────────────────────
599
+ //
600
+ // Owner 2026-11-18 (session m0-d03430f0): neither compaction summary of a session with a 10-item plan named one item,
601
+ // so the model after `/compact` (and the models switched in after it) did not know a plan existed. The summarizer now
602
+ // gets the session's live state as one last user message after the history it condenses: the plan as last written
603
+ // with `todo_write` (every item and status), the active goal (and its contract file) and the newest progress report
604
+ // line, each folded from the session's durable log. It is appended after the replayed history, so the summary call
605
+ // keeps the conversation's cached prefix; it never reaches the conversation itself (only the summary does), and Tier 1
606
+ // is untouched. Lean-context re-states the plan after the compaction too (`plan-state`); this keeps it in the summary.
607
+
608
+ export const SESSION_STATE_SOURCE_KIND = 'picasso-session-state';
609
+ const SESSION_STATE_MAX_ITEMS = 60;
610
+ const SESSION_STATE_ITEM_MAX_CHARS = 400;
611
+ const SESSION_STATE_OBJECTIVE_MAX_CHARS = 2_000;
612
+ const TODO_DONE = new Set(['completed', 'cancelled', 'canceled', 'done', 'skipped']);
613
+ const PROGRESS_LINE_RE = /progress(?: report)?\b[^\n]*?\b\d{1,3}(?:\.\d+)?\s?%/iu;
614
+
615
+ const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
616
+ const oneLine = (value, max) => {
617
+ const flat = String(value ?? '').replace(/\s+/gu, ' ').trim();
618
+ return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
619
+ };
620
+
621
+ /** The session's plan, active goal (with its contract) and newest progress line, folded from its durable log. */
622
+ export function sessionStateOf(session) {
623
+ const state = { todos: [], goal: undefined, contracts: [], report: undefined };
624
+ if (typeof session?.eventAt !== 'function' || !Number.isSafeInteger(session?.seq)) return state;
625
+ for (let seq = 0; seq < session.seq; seq += 1) {
626
+ let event;
627
+ try {
628
+ event = session.eventAt(seq);
629
+ } catch {
630
+ event = undefined;
631
+ }
632
+ if (!isObject(event)) continue;
633
+ const data = isObject(event.data) ? event.data : {};
634
+ switch (event.type) {
635
+ case 'todo/write':
636
+ state.todos = (Array.isArray(data.todos) ? data.todos : []).filter(isObject).map((todo) => ({
637
+ content: typeof todo.content === 'string' ? todo.content : '',
638
+ status: typeof todo.status === 'string' ? todo.status : 'pending',
639
+ }));
640
+ break;
641
+ case 'goal/change':
642
+ if (data.operation === 'clear') state.goal = undefined;
643
+ else if (isObject(data.goal) && typeof data.goal.objective === 'string') {
644
+ state.goal = { id: data.goal.id, objective: data.goal.objective, phase: data.goal.phase };
645
+ }
646
+ break;
647
+ case 'plugin:picasso/goal-contract': {
648
+ const approval = isObject(data.event) ? data.event : undefined;
649
+ if (approval && typeof approval.objective === 'string' && typeof approval.contractPath === 'string') state.contracts.push(approval);
650
+ break;
651
+ }
652
+ case 'assistant/message': {
653
+ const blocks = Array.isArray(data.message?.content) ? data.message.content : [];
654
+ const textOf = blocks.map((block) => (block?.type === 'text' && typeof block.text === 'string' ? block.text : '')).join('\n');
655
+ const first = textOf.split('\n').find((line) => line.trim().length > 0);
656
+ if (first !== undefined && PROGRESS_LINE_RE.test(first)) state.report = first;
657
+ break;
658
+ }
659
+ default:
660
+ break;
661
+ }
662
+ }
663
+ return state;
664
+ }
665
+
666
+ /** The `<session-state>` text for the summarizer, or undefined when the session has no plan, goal or report. */
667
+ export function renderSessionState(state) {
668
+ const lines = [];
669
+ const goal = isObject(state?.goal) && state.goal.phase !== 'complete' && state.goal.phase !== 'completed' ? state.goal : undefined;
670
+ if (goal !== undefined) {
671
+ lines.push(`Goal (${typeof goal.phase === 'string' ? goal.phase : 'set'}): ${oneLine(goal.objective, SESSION_STATE_OBJECTIVE_MAX_CHARS)}`);
672
+ const contracts = Array.isArray(state.contracts) ? state.contracts : [];
673
+ const contract = [...contracts].reverse().find((entry) => entry.goalId === goal.id || (entry.goalId === undefined && entry.objective === goal.objective));
674
+ if (contract !== undefined) lines.push(`Goal contract: ${contract.contractPath}`);
675
+ }
676
+ const todos = Array.isArray(state?.todos) ? state.todos : [];
677
+ if (todos.length > 0) {
678
+ const done = todos.filter((todo) => TODO_DONE.has(todo.status)).length;
679
+ lines.push(`Plan (last todo_write), ${done} of ${todos.length} done:`);
680
+ for (const todo of todos.slice(0, SESSION_STATE_MAX_ITEMS)) lines.push(`- [${oneLine(todo.status, 24)}] ${oneLine(todo.content, SESSION_STATE_ITEM_MAX_CHARS)}`);
681
+ if (todos.length > SESSION_STATE_MAX_ITEMS) lines.push(`- … ${todos.length - SESSION_STATE_MAX_ITEMS} more`);
682
+ }
683
+ if (typeof state?.report === 'string') lines.push(`Newest progress report: ${oneLine(state.report, SESSION_STATE_ITEM_MAX_CHARS)}`);
684
+ if (lines.length === 0) return undefined;
685
+ return [
686
+ '<session-state>',
687
+ 'The live state of this session as Picasso records it (not part of the conversation). Keep all of it in the checkpoint: every plan item with its exact status, the goal, the progress.',
688
+ ...lines,
689
+ '</session-state>',
690
+ ].join('\n');
691
+ }
692
+
693
+ /** `input` with the session's state appended as a last user message (unchanged when there is none). */
694
+ export function withSessionState(input, agent) {
695
+ let text;
696
+ try {
697
+ text = renderSessionState(sessionStateOf(agent?.session));
698
+ } catch {
699
+ text = undefined;
700
+ }
701
+ if (text === undefined || !isObject(input) || !Array.isArray(input.messages)) return input;
702
+ const message = {
703
+ id: `${SESSION_STATE_SOURCE_KIND}-${Number.isSafeInteger(agent?.session?.seq) ? agent.session.seq : 0}`,
704
+ role: 'user',
705
+ content: [{ type: 'text', text }],
706
+ source: { kind: SESSION_STATE_SOURCE_KIND, form: 'reminder' },
707
+ };
708
+ return { ...input, messages: [...input.messages, message] };
709
+ }
710
+
597
711
  /** The service object behind cordis's tracing proxy (its own `summarize` must be set on the real instance). */
598
712
  function rawService(service) {
599
713
  if (service === undefined || service === null) return undefined;
@@ -751,7 +865,8 @@ export function installSummarizer(compaction, llm, log = () => undefined, deps =
751
865
  const notice = createNoticeWriter({ engine, llm, log, appendRecord: deps.appendRecord });
752
866
  const override = async function summarize(input, agent, signal) {
753
867
  await notice(agent, reasons.get(agent));
754
- return summarizer.summarize(input, agent, signal);
868
+ // The plan, goal and newest progress line ride along so the summary keeps them (`withSessionState`).
869
+ return summarizer.summarize(withSessionState(input, agent), agent, signal);
755
870
  };
756
871
  const installed = { summarize: override };
757
872
  // Shortening starts near the window, not at 80% of it (PRESSURE_RATIO). The engine reads its config at every check.
@@ -0,0 +1,5 @@
1
+ # Picasso computer use — one bundle patch layer row (loader insert). dshBin and host are supplied by the relay's
2
+ # generated patch (host: mac on Picasso for Mac); without host the tools answer "Computer use needs Picasso for Mac."
3
+ - insert:
4
+ - id: picasso-computer
5
+ name: '@picasso/computer'