@picassohq/cli 1.0.4 → 1.0.5
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/dist/build-info.json +2 -1
- package/dist/index.js +1557 -1353
- package/package.json +1 -1
- package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +4 -7
- package/runtime/dsh/picasso-sdk.patch.yml +47 -0
- package/runtime/engine-manifest.json +20 -10
- package/runtime/packages/picasso-compaction/index.js +257 -5
- package/runtime/packages/picasso-hooks/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-hooks/index.js +302 -0
- package/runtime/packages/picasso-hooks/lifecycle-events.js +651 -0
- package/runtime/packages/picasso-hooks/package.json +29 -0
- package/runtime/packages/picasso-lean-context/glob-walk.js +518 -0
- package/runtime/packages/picasso-lean-context/index.js +136 -9
- package/runtime/packages/picasso-memory/index.js +66 -24
- package/runtime/packages/picasso-model-router/connections.js +164 -7
- package/runtime/packages/picasso-model-router/index.js +97 -1
- package/runtime/packages/picasso-model-router/thinking-default.js +29 -5
- package/runtime/packages/picasso-progress-reports/index.js +128 -18
- package/runtime/packages/picasso-sdk-server/command-runs.js +37 -0
- package/runtime/packages/picasso-sdk-server/ignore-file.js +5 -1
- package/runtime/packages/picasso-sdk-server/index.js +11 -3
- package/runtime/packages/picasso-sdk-server/package.json +1 -0
- package/runtime/packages/picasso-sdk-server/wave2-hooks.js +26 -6
- package/runtime/packages/picasso-x-reader/settings.js +4 -1
- package/runtime/plugins/picasso-auto-approve/index.js +21 -8
- package/runtime/plugins/picasso-compaction/index.js +257 -5
- package/runtime/plugins/picasso-hooks/index.js +302 -0
- package/runtime/plugins/picasso-hooks/lifecycle-events.js +651 -0
- package/runtime/plugins/picasso-hooks/package.json +29 -0
- package/runtime/plugins/picasso-lean-context/glob-walk.js +518 -0
- package/runtime/plugins/picasso-lean-context/index.js +136 -9
- package/runtime/plugins/picasso-memory/index.js +66 -24
- package/runtime/plugins/picasso-model-router/connections.js +164 -7
- package/runtime/plugins/picasso-model-router/index.js +97 -1
- package/runtime/plugins/picasso-model-router/thinking-default.js +29 -5
- package/runtime/plugins/picasso-progress-reports/index.js +128 -18
- package/runtime/plugins/picasso-trackers/index.js +12 -2
- package/runtime/plugins/picasso-x-reader/settings.js +4 -1
- package/runtime/relay/main.mjs +2254 -1648
- package/runtime/relay/versions-routes.mjs +24 -20
|
@@ -28,7 +28,7 @@ import { readFileSync, statSync } from 'node:fs';
|
|
|
28
28
|
import { userInfo } from 'node:os';
|
|
29
29
|
import { join } from 'node:path';
|
|
30
30
|
|
|
31
|
-
import { isProgressReport } from './report.js';
|
|
31
|
+
import { isProgressReport, parseProgressReport } from './report.js';
|
|
32
32
|
|
|
33
33
|
export { formatReportMarkdown, isProgressReport, parseProgressReport, splitReportItems } from './report.js';
|
|
34
34
|
|
|
@@ -131,11 +131,24 @@ function freshState() {
|
|
|
131
131
|
openerSeen: true,
|
|
132
132
|
/** A reminder is in history with no report after it yet. */
|
|
133
133
|
reminderPending: false,
|
|
134
|
+
/** Reminders in history since the newest report (the ones the model has not answered). */
|
|
135
|
+
unanswered: 0,
|
|
134
136
|
/** The model has reported without being reminded (its own instructions ask for reports). */
|
|
135
137
|
selfReporting: false,
|
|
138
|
+
/** The last `todo/write` list (`[]` before any). */
|
|
139
|
+
todos: [],
|
|
140
|
+
/** The newest report's percent written after the last `todo/write` (undefined when none since). */
|
|
141
|
+
reportPercentSincePlan: undefined,
|
|
142
|
+
/** A plan-drift nudge is in history since the last `todo/write`. */
|
|
143
|
+
driftNudged: false,
|
|
136
144
|
};
|
|
137
145
|
}
|
|
138
146
|
|
|
147
|
+
function todosFrom(data) {
|
|
148
|
+
const list = isRecord(data) && Array.isArray(data.todos) ? data.todos : [];
|
|
149
|
+
return list.filter(isRecord).map((todo) => ({ status: typeof todo.status === 'string' ? todo.status : 'pending' }));
|
|
150
|
+
}
|
|
151
|
+
|
|
139
152
|
/** Fold one durable session event into the timing state. */
|
|
140
153
|
export function foldEvent(state, event) {
|
|
141
154
|
if (!isRecord(event)) return state;
|
|
@@ -155,16 +168,27 @@ export function foldEvent(state, event) {
|
|
|
155
168
|
if (message?.source?.kind === SOURCE_KIND && time !== undefined) {
|
|
156
169
|
state.lastReminder = time;
|
|
157
170
|
state.reminderPending = true;
|
|
171
|
+
state.unanswered += 1;
|
|
158
172
|
}
|
|
173
|
+
if (message?.source?.kind === DRIFT_SOURCE_KIND) state.driftNudged = true;
|
|
159
174
|
break;
|
|
160
175
|
}
|
|
161
|
-
case '
|
|
162
|
-
|
|
176
|
+
case 'todo/write':
|
|
177
|
+
state.todos = todosFrom(event.data);
|
|
178
|
+
state.reportPercentSincePlan = undefined;
|
|
179
|
+
state.driftNudged = false;
|
|
180
|
+
break;
|
|
181
|
+
case 'assistant/message': {
|
|
182
|
+
const report = parseProgressReport(textOf(event.data?.message));
|
|
183
|
+
if (report !== undefined && report.percent !== undefined) state.reportPercentSincePlan = report.percent;
|
|
184
|
+
if (time !== undefined && report !== undefined) {
|
|
163
185
|
state.lastReport = time;
|
|
164
186
|
if (!state.reminderPending) state.selfReporting = true;
|
|
165
187
|
state.reminderPending = false;
|
|
188
|
+
state.unanswered = 0;
|
|
166
189
|
}
|
|
167
190
|
break;
|
|
191
|
+
}
|
|
168
192
|
default:
|
|
169
193
|
break;
|
|
170
194
|
}
|
|
@@ -209,12 +233,36 @@ export function reminderDue(state, now, intervalMs, proposed = []) {
|
|
|
209
233
|
return now - baseline >= (state.selfReporting ? intervalMs * SELF_REPORT_GRACE : intervalMs);
|
|
210
234
|
}
|
|
211
235
|
|
|
212
|
-
/**
|
|
213
|
-
export function
|
|
236
|
+
/** "10 minutes" / "30 seconds" for an interval in ms (the dev/test overrides go below a minute). */
|
|
237
|
+
export function intervalLabel(intervalMs) {
|
|
238
|
+
const ms = Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : DEFAULT_INTERVAL_MINUTES * 60_000;
|
|
239
|
+
if (ms < 60_000) {
|
|
240
|
+
const seconds = Math.max(1, Math.round(ms / 1000));
|
|
241
|
+
return `${seconds} second${seconds === 1 ? '' : 's'}`;
|
|
242
|
+
}
|
|
243
|
+
const minutes = Math.round(ms / 60_000);
|
|
244
|
+
return `${minutes} minute${minutes === 1 ? '' : 's'}`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The reminder's text. `minutes` is the elapsed wall time it reports; `intervalMs` the configured cadence;
|
|
249
|
+
* `unanswered` how many earlier reminders since the last report got none (from history, so resume-safe).
|
|
250
|
+
*
|
|
251
|
+
* Owner 2026-11-17: on managed Claude Fable 5.1 four reminders in a row (16:55–17:37) reached the model and got no
|
|
252
|
+
* report, because the run's prompt said "No unnecessary progress reports" and the old text read as an optional harness
|
|
253
|
+
* nudge ("In your next reply … do not mention this reminder"). The text now says whose request it is (the user's
|
|
254
|
+
* setting, shown in the status panel), that a general "fewer status messages" instruction does not cover it, and to
|
|
255
|
+
* write it before the next tool call (a Claude-style model reads "reply" as its final answer).
|
|
256
|
+
*/
|
|
257
|
+
export function renderReminder(minutes, options = {}) {
|
|
214
258
|
const elapsed = minutes >= 1 ? `about ${Math.round(minutes)} minute${Math.round(minutes) === 1 ? '' : 's'}` : 'a while';
|
|
259
|
+
const unanswered = Number.isSafeInteger(options.unanswered) && options.unanswered > 0 ? options.unanswered : 0;
|
|
215
260
|
return [
|
|
216
261
|
'<system-reminder>',
|
|
217
|
-
`Progress check: you have been working for ${elapsed} without a progress report
|
|
262
|
+
`Progress check: you have been working for ${elapsed} without a progress report.`,
|
|
263
|
+
`The user's Picasso settings ask for a progress report every ${intervalLabel(options.intervalMs)} of work; Picasso shows it in the status panel so the user can follow a long run without interrupting it. This is that scheduled report, not an unnecessary update: a general instruction to keep status messages down does not cover it (to stop these, the user switches Progress reports off in Picasso settings).`,
|
|
264
|
+
...(unanswered > 0 ? [`The last ${unanswered === 1 ? 'progress check' : `${unanswered} progress checks`} got no report.`] : []),
|
|
265
|
+
'In your next message, before any further tool call, post the report as a normal message in exactly this shape, then keep working — do not stop, wait, or ask for confirmation:',
|
|
218
266
|
'',
|
|
219
267
|
'**Progress report** · <overall %> (<how you measured it, e.g. 3 of 7 steps done>)',
|
|
220
268
|
'Goal: <the original request, one line>',
|
|
@@ -223,14 +271,14 @@ export function renderReminder(minutes) {
|
|
|
223
271
|
'Next: <the next steps>',
|
|
224
272
|
'Blockers: <blockers, or none>',
|
|
225
273
|
'',
|
|
226
|
-
'Keep it under eight short lines
|
|
274
|
+
'Keep it under eight short lines and report only what actually happened. Write it straight to the user, with no preamble about this check.',
|
|
227
275
|
'</system-reminder>',
|
|
228
276
|
].join('\n');
|
|
229
277
|
}
|
|
230
278
|
|
|
231
279
|
/** A frozen user-role message shaped like dsh-llm's `createUserMessage` output. */
|
|
232
|
-
export function reminderMessage(minutes) {
|
|
233
|
-
const text = renderReminder(minutes);
|
|
280
|
+
export function reminderMessage(minutes, options = {}) {
|
|
281
|
+
const text = renderReminder(minutes, options);
|
|
234
282
|
return Object.freeze({
|
|
235
283
|
role: 'user',
|
|
236
284
|
content: Object.freeze([Object.freeze({ type: 'text', text })]),
|
|
@@ -239,6 +287,60 @@ export function reminderMessage(minutes) {
|
|
|
239
287
|
});
|
|
240
288
|
}
|
|
241
289
|
|
|
290
|
+
// ── Plan drift (Tier 2) ───────────────────────────────────────────────────────────────────────────────────────
|
|
291
|
+
//
|
|
292
|
+
// Owner 2026-11-17: the status panel showed a report's "95%" over "Plan 0/6": the model kept reporting but never
|
|
293
|
+
// updated its todo list. When the newest report written since the last `todo/write` claims at least
|
|
294
|
+
// PLAN_DRIFT_POINTS more than the list's own completion (completed steps whole, the step in progress half), the next
|
|
295
|
+
// step gets ONE sourced `<system-reminder>` at the tail of its messages asking it to update the list. Once per
|
|
296
|
+
// `todo/write`; top-level agents only; the text depends only on history (the two percents and counts), so identical
|
|
297
|
+
// history yields identical bytes. Tier 1 is never touched.
|
|
298
|
+
|
|
299
|
+
export const DRIFT_SOURCE_KIND = 'picasso-plan-drift';
|
|
300
|
+
export const PLAN_DRIFT_POINTS = 50;
|
|
301
|
+
|
|
302
|
+
/** The list's completion (0–100): completed steps whole, the step in progress half. */
|
|
303
|
+
export function planCompletion(todos) {
|
|
304
|
+
const list = Array.isArray(todos) ? todos : [];
|
|
305
|
+
if (list.length === 0) return 0;
|
|
306
|
+
const credit = list.reduce((sum, todo) => sum + (todo?.status === 'completed' ? 1 : todo?.status === 'in_progress' ? 0.5 : 0), 0);
|
|
307
|
+
return (credit / list.length) * 100;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The report percent that makes the drift nudge due, else undefined: a list with steps, a report since its last write
|
|
312
|
+
* (this step's proposed assistant text counts as the newest), ≥ PLAN_DRIFT_POINTS above the list, no nudge yet.
|
|
313
|
+
*/
|
|
314
|
+
export function planDriftDue(state, proposed = []) {
|
|
315
|
+
if (!isRecord(state) || state.driftNudged === true || !Array.isArray(state.todos) || state.todos.length === 0) return undefined;
|
|
316
|
+
let reported = state.reportPercentSincePlan;
|
|
317
|
+
for (const message of proposed) {
|
|
318
|
+
if (message?.role !== 'assistant') continue;
|
|
319
|
+
const report = parseProgressReport(textOf(message));
|
|
320
|
+
if (report?.percent !== undefined) reported = report.percent;
|
|
321
|
+
}
|
|
322
|
+
if (reported === undefined) return undefined;
|
|
323
|
+
return reported - planCompletion(state.todos) >= PLAN_DRIFT_POINTS ? reported : undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The nudge text: the report's percent against the list's, with the list's counts. */
|
|
327
|
+
export function renderPlanDrift(reported, todos) {
|
|
328
|
+
const list = Array.isArray(todos) ? todos : [];
|
|
329
|
+
const done = list.filter((todo) => todo?.status === 'completed').length;
|
|
330
|
+
const plan = Math.round(planCompletion(list));
|
|
331
|
+
return `<system-reminder>\nYour latest progress report says ${reported}% done, but your todo list shows ${plan}% (${done} of ${list.length} step${list.length === 1 ? '' : 's'} completed). Update it with todo_write so the plan matches the work, then keep going.\n</system-reminder>`;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** A frozen sourced user-role reminder carrying the plan-drift nudge. */
|
|
335
|
+
export function planDriftMessage(reported, todos) {
|
|
336
|
+
return Object.freeze({
|
|
337
|
+
role: 'user',
|
|
338
|
+
content: Object.freeze([Object.freeze({ type: 'text', text: renderPlanDrift(reported, todos) })]),
|
|
339
|
+
source: Object.freeze({ kind: DRIFT_SOURCE_KIND, form: 'reminder' }),
|
|
340
|
+
id: randomUUID(),
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
|
|
242
344
|
export function apply(ctx, config = {}, deps = {}) {
|
|
243
345
|
const readSettings = deps.settings ?? settingsReader(config, deps.env ?? process.env);
|
|
244
346
|
const clock = deps.now ?? Date.now;
|
|
@@ -251,17 +353,25 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
251
353
|
const agent = args?.agent;
|
|
252
354
|
const session = agent?.session;
|
|
253
355
|
if (!session || typeof session.eventAt !== 'function' || isChildAgent(agent)) return decision;
|
|
254
|
-
const { enabled, intervalMs } = readSettings();
|
|
255
|
-
if (!enabled) return decision;
|
|
256
|
-
if (decision.messages.some((message) => message?.source?.kind === SOURCE_KIND)) return decision;
|
|
257
356
|
const state = scanSession(states, session);
|
|
357
|
+
// The plan-drift nudge reads only history; it is not the timed report reminder, so that setting does not gate it.
|
|
358
|
+
const drift = decision.messages.some((message) => message?.source?.kind === DRIFT_SOURCE_KIND) ? undefined : planDriftDue(state, decision.messages);
|
|
359
|
+
const extra = [];
|
|
360
|
+
if (drift !== undefined) {
|
|
361
|
+
// Recorded now so a step that is rejected downstream cannot send it twice before its event lands.
|
|
362
|
+
state.driftNudged = true;
|
|
363
|
+
extra.push(planDriftMessage(drift, state.todos));
|
|
364
|
+
}
|
|
365
|
+
const { enabled, intervalMs } = readSettings();
|
|
258
366
|
const now = clock();
|
|
259
|
-
if (!reminderDue(state, now, intervalMs, decision.messages))
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
367
|
+
if (enabled && !decision.messages.some((message) => message?.source?.kind === SOURCE_KIND) && reminderDue(state, now, intervalMs, decision.messages)) {
|
|
368
|
+
const baseline = Math.max(state.runStart ?? now, state.lastReport ?? 0, state.lastReminder ?? 0);
|
|
369
|
+
// Recorded now so a step that is rejected downstream cannot re-arm it before its event lands.
|
|
370
|
+
state.lastReminder = now;
|
|
371
|
+
state.reminderPending = true;
|
|
372
|
+
extra.push(reminderMessage((now - baseline) / 60_000, { intervalMs, unanswered: state.unanswered }));
|
|
373
|
+
}
|
|
374
|
+
return extra.length === 0 ? decision : { ...decision, messages: [...decision.messages, ...extra] };
|
|
265
375
|
});
|
|
266
376
|
}
|
|
267
377
|
|
|
@@ -52,7 +52,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
|
52
52
|
import { mkdir, rename, writeFile } from 'node:fs/promises';
|
|
53
53
|
import { createRequire } from 'node:module';
|
|
54
54
|
import { homedir } from 'node:os';
|
|
55
|
-
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
55
|
+
import { basename, delimiter, dirname, join, resolve } from 'node:path';
|
|
56
56
|
|
|
57
57
|
export const name = 'picasso-trackers';
|
|
58
58
|
/** The dsh release this plugin is written and tested against (Picasso pins the engine to it). */
|
|
@@ -247,6 +247,14 @@ function authAccount(output) {
|
|
|
247
247
|
return match?.[1] ?? match?.[2];
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/** Test-only hermetic mode (`PICASSO_TEST_HERMETIC=1`): the developer's own `gh`/`glab` sign-ins are never asked. */
|
|
251
|
+
function hermeticTest(env) {
|
|
252
|
+
return String(env?.PICASSO_TEST_HERMETIC ?? process.env.PICASSO_TEST_HERMETIC ?? '').trim() === '1';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** What the real exec answers for a `gh`/`glab` call in hermetic mode: not signed in, without running it. */
|
|
256
|
+
const HERMETIC_SIGNED_OUT = Object.freeze({ code: 1, output: 'not logged in (hermetic test)' });
|
|
257
|
+
|
|
250
258
|
function requireTool(path, provider, tool) {
|
|
251
259
|
if (path === undefined) {
|
|
252
260
|
throw new TrackerError('provider-unconfigured', `${tool} is not installed — install it, then sign in.`, { provider, tool });
|
|
@@ -564,7 +572,9 @@ export class TrackerRegistry {
|
|
|
564
572
|
this.dataDir = resolve(options.dataDir);
|
|
565
573
|
this.sidecar = join(this.dataDir, SIDECAR_FILENAME);
|
|
566
574
|
this.now = options.now ?? Date.now;
|
|
567
|
-
this.exec = options.exec ?? ((file, args, opts = {}) =>
|
|
575
|
+
this.exec = options.exec ?? ((file, args, opts = {}) => (hermeticTest(this.env) && /^(?:gh|glab)$/u.test(basename(String(file)))
|
|
576
|
+
? Promise.resolve(HERMETIC_SIGNED_OUT)
|
|
577
|
+
: execArgv(file, args, { ...opts, env: opts.env ?? cliEnv(this.env) })));
|
|
568
578
|
this.http = options.http ?? httpRequest;
|
|
569
579
|
this.env = options.env ?? process.env;
|
|
570
580
|
this.providerConfigSource = typeof options.providers === 'function' ? options.providers : () => options.providers ?? {};
|
|
@@ -89,7 +89,10 @@ function run(cmd, args) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/** Read the stored key from the system keychain; `undefined` when there is none. */
|
|
92
|
-
export async function readKeychainApiKey({ platform = process.platform, runner
|
|
92
|
+
export async function readKeychainApiKey({ platform = process.platform, runner } = {}) {
|
|
93
|
+
// Test-only hermetic mode (`PICASSO_TEST_HERMETIC=1`): no key in the login Keychain, unless a test passes a runner.
|
|
94
|
+
if (runner === undefined && process.env.PICASSO_TEST_HERMETIC?.trim() === '1') return undefined;
|
|
95
|
+
runner ??= run;
|
|
93
96
|
if (platform === 'darwin') {
|
|
94
97
|
const result = await runner('/usr/bin/security', ['find-generic-password', '-s', X_READER_KEYCHAIN_SERVICE, '-a', X_READER_KEYCHAIN_ACCOUNT, '-w']);
|
|
95
98
|
const key = result.ok ? result.stdout.trim() : '';
|