@picassohq/cli 0.0.0-stage → 1.0.2
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/agents/browser_agent.yaml +53 -0
- package/agents/code_reviewer.yaml +49 -0
- package/agents/codebase_investigator.yaml +70 -0
- package/agents/design_auditor.yaml +50 -0
- package/agents/devex_auditor.yaml +50 -0
- package/agents/doc_writer.yaml +54 -0
- package/agents/engineering_architect.yaml +51 -0
- package/agents/generalist.yaml +55 -0
- package/agents/migration_planner.yaml +51 -0
- package/agents/product_reviewer.yaml +48 -0
- package/agents/qa_operator.yaml +52 -0
- package/agents/release_engineer.yaml +50 -0
- package/agents/security_auditor.yaml +62 -0
- package/agents/test_writer.yaml +52 -0
- package/assets/first-light-lockup.png +0 -0
- package/assets/first-light-tagline.png +0 -0
- package/assets/house/README.md +26 -0
- package/assets/house/auraone-banner.png +0 -0
- package/assets/house/auraone-logo.png +0 -0
- package/assets/house/kiro-prism-banner.png +0 -0
- package/assets/house/kiro-prism-logo.png +0 -0
- package/assets/house/picasso-banner.png +0 -0
- package/assets/house/picasso-logo.png +0 -0
- package/assets/wordmark-app.png +0 -0
- package/assets/wordmark-tight.png +0 -0
- package/assets/wordmark.png +0 -0
- package/design/styles.css +1042 -0
- package/dist/build-info.json +37 -0
- package/dist/index.js +3062 -0
- package/goals/cli-hardening.yaml +40 -0
- package/goals/repo-maintenance.yaml +40 -0
- package/package.json +49 -4
- package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
- package/runtime/dsh/picasso-ecosystem.community.json +185 -0
- package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
- package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
- package/runtime/dsh/picasso-isolation.patch.yml +25 -0
- package/runtime/dsh/picasso-providers.patch.yml +373 -0
- package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
- package/runtime/dsh/picasso-sdk.patch.yml +204 -0
- package/runtime/engine-manifest.json +215 -0
- package/runtime/package.json +6 -0
- package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
- package/runtime/packages/picasso-cache-probe/index.js +477 -0
- package/runtime/packages/picasso-cache-probe/package.json +38 -0
- package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-commands/fresh-review.js +573 -0
- package/runtime/packages/picasso-commands/index.js +497 -0
- package/runtime/packages/picasso-commands/package.json +28 -0
- package/runtime/packages/picasso-instructions/conflicts.js +115 -0
- package/runtime/packages/picasso-instructions/formats.js +145 -0
- package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
- package/runtime/packages/picasso-instructions/glob.js +114 -0
- package/runtime/packages/picasso-instructions/globals.js +90 -0
- package/runtime/packages/picasso-instructions/imports.js +123 -0
- package/runtime/packages/picasso-instructions/index.js +326 -0
- package/runtime/packages/picasso-instructions/modes.js +64 -0
- package/runtime/packages/picasso-instructions/package.json +30 -0
- package/runtime/packages/picasso-instructions/parse.js +134 -0
- package/runtime/packages/picasso-instructions/report.js +161 -0
- package/runtime/packages/picasso-instructions/resolve.js +939 -0
- package/runtime/packages/picasso-instructions/scan.js +181 -0
- package/runtime/packages/picasso-instructions/settings.js +150 -0
- package/runtime/packages/picasso-instructions/skills.js +345 -0
- package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
- package/runtime/packages/picasso-lean-context/index.js +6280 -0
- package/runtime/packages/picasso-lean-context/package.json +26 -0
- package/runtime/packages/picasso-lean-context/read-image-recovery.js +306 -0
- package/runtime/packages/picasso-lean-context/timeline.js +418 -0
- package/runtime/packages/picasso-librarian/classify.js +146 -0
- package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-librarian/index.js +878 -0
- package/runtime/packages/picasso-librarian/notes.js +159 -0
- package/runtime/packages/picasso-librarian/package.json +34 -0
- package/runtime/packages/picasso-librarian/state.js +478 -0
- package/runtime/packages/picasso-memory/index.js +1184 -0
- package/runtime/packages/picasso-memory/package.json +21 -0
- package/runtime/packages/picasso-model-router/connections.js +912 -0
- package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
- package/runtime/packages/picasso-model-router/index.js +1083 -0
- package/runtime/packages/picasso-model-router/package.json +30 -0
- package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-options/index.js +263 -0
- package/runtime/packages/picasso-options/package.json +28 -0
- package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-progress-reports/index.js +267 -0
- package/runtime/packages/picasso-progress-reports/package.json +30 -0
- package/runtime/packages/picasso-progress-reports/report.js +235 -0
- package/runtime/packages/picasso-sdk-server/aside.js +142 -0
- package/runtime/packages/picasso-sdk-server/connections.js +38 -0
- package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
- package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
- package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
- package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
- package/runtime/packages/picasso-sdk-server/goal.js +131 -0
- package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
- package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
- package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
- package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
- package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
- package/runtime/packages/picasso-sdk-server/index.js +891 -0
- package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
- package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
- package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
- package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
- package/runtime/packages/picasso-sdk-server/package.json +50 -0
- package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
- package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
- package/runtime/packages/picasso-sdk-server/queue.js +322 -0
- package/runtime/packages/picasso-sdk-server/requester.js +43 -0
- package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
- package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
- package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
- package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
- package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
- package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
- package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
- package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
- package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
- package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
- package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
- package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
- package/runtime/packages/picasso-web-search/backends.js +412 -0
- package/runtime/packages/picasso-web-search/config.js +121 -0
- package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
- package/runtime/packages/picasso-web-search/failure.js +116 -0
- package/runtime/packages/picasso-web-search/format.js +42 -0
- package/runtime/packages/picasso-web-search/index.js +71 -0
- package/runtime/packages/picasso-web-search/package.json +38 -0
- package/runtime/packages/picasso-web-search/router.js +156 -0
- package/runtime/packages/picasso-x-reader/circle.js +324 -0
- package/runtime/packages/picasso-x-reader/command.js +169 -0
- package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
- package/runtime/packages/picasso-x-reader/index.js +170 -0
- package/runtime/packages/picasso-x-reader/package.json +39 -0
- package/runtime/packages/picasso-x-reader/read.js +370 -0
- package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
- package/runtime/packages/picasso-x-reader/settings.js +131 -0
- package/runtime/packages/picasso-x-reader/urls.js +154 -0
- package/runtime/packages/picasso-x-reader/xmd.js +512 -0
- package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
- package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
- package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
- package/runtime/plugins/picasso-auto-approve/package.json +28 -0
- package/runtime/plugins/picasso-browser/index.js +424 -0
- package/runtime/plugins/picasso-browser/package.json +28 -0
- package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
- package/runtime/plugins/picasso-checkpoints/index.js +885 -0
- package/runtime/plugins/picasso-checkpoints/package.json +29 -0
- package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
- package/runtime/plugins/picasso-commands/index.js +497 -0
- package/runtime/plugins/picasso-commands/package.json +28 -0
- package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
- package/runtime/plugins/picasso-instructions/formats.js +145 -0
- package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
- package/runtime/plugins/picasso-instructions/glob.js +114 -0
- package/runtime/plugins/picasso-instructions/globals.js +90 -0
- package/runtime/plugins/picasso-instructions/imports.js +123 -0
- package/runtime/plugins/picasso-instructions/index.js +326 -0
- package/runtime/plugins/picasso-instructions/modes.js +64 -0
- package/runtime/plugins/picasso-instructions/package.json +30 -0
- package/runtime/plugins/picasso-instructions/parse.js +134 -0
- package/runtime/plugins/picasso-instructions/report.js +161 -0
- package/runtime/plugins/picasso-instructions/resolve.js +939 -0
- package/runtime/plugins/picasso-instructions/scan.js +181 -0
- package/runtime/plugins/picasso-instructions/settings.js +150 -0
- package/runtime/plugins/picasso-instructions/skills.js +345 -0
- package/runtime/plugins/picasso-lean-context/index.js +6280 -0
- package/runtime/plugins/picasso-lean-context/package.json +26 -0
- package/runtime/plugins/picasso-lean-context/read-image-recovery.js +306 -0
- package/runtime/plugins/picasso-lean-context/timeline.js +418 -0
- package/runtime/plugins/picasso-librarian/classify.js +146 -0
- package/runtime/plugins/picasso-librarian/index.js +878 -0
- package/runtime/plugins/picasso-librarian/notes.js +159 -0
- package/runtime/plugins/picasso-librarian/package.json +34 -0
- package/runtime/plugins/picasso-librarian/state.js +478 -0
- package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
- package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
- package/runtime/plugins/picasso-mail/inbox.js +207 -0
- package/runtime/plugins/picasso-mail/index.js +293 -0
- package/runtime/plugins/picasso-mail/package.json +22 -0
- package/runtime/plugins/picasso-memory/index.js +1184 -0
- package/runtime/plugins/picasso-memory/package.json +21 -0
- package/runtime/plugins/picasso-model-router/connections.js +912 -0
- package/runtime/plugins/picasso-model-router/index.js +1083 -0
- package/runtime/plugins/picasso-model-router/package.json +30 -0
- package/runtime/plugins/picasso-options/index.js +263 -0
- package/runtime/plugins/picasso-options/package.json +28 -0
- package/runtime/plugins/picasso-progress-reports/index.js +267 -0
- package/runtime/plugins/picasso-progress-reports/package.json +30 -0
- package/runtime/plugins/picasso-progress-reports/report.js +235 -0
- package/runtime/plugins/picasso-provider-models/index.js +436 -0
- package/runtime/plugins/picasso-provider-models/package.json +28 -0
- package/runtime/plugins/picasso-repo-index/index.js +1850 -0
- package/runtime/plugins/picasso-repo-index/package.json +28 -0
- package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
- package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
- package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
- package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
- package/runtime/plugins/picasso-trackers/index.js +895 -0
- package/runtime/plugins/picasso-trackers/package.json +28 -0
- package/runtime/plugins/picasso-web-search/backends.js +412 -0
- package/runtime/plugins/picasso-web-search/config.js +121 -0
- package/runtime/plugins/picasso-web-search/failure.js +116 -0
- package/runtime/plugins/picasso-web-search/format.js +42 -0
- package/runtime/plugins/picasso-web-search/index.js +71 -0
- package/runtime/plugins/picasso-web-search/package.json +38 -0
- package/runtime/plugins/picasso-web-search/router.js +156 -0
- package/runtime/plugins/picasso-x-reader/circle.js +324 -0
- package/runtime/plugins/picasso-x-reader/command.js +169 -0
- package/runtime/plugins/picasso-x-reader/index.js +170 -0
- package/runtime/plugins/picasso-x-reader/package.json +39 -0
- package/runtime/plugins/picasso-x-reader/read.js +370 -0
- package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
- package/runtime/plugins/picasso-x-reader/settings.js +131 -0
- package/runtime/plugins/picasso-x-reader/urls.js +154 -0
- package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
- package/runtime/relay/attachment-text.mjs +737 -0
- package/runtime/relay/companion/companion.css +126 -0
- package/runtime/relay/companion/companion.js +648 -0
- package/runtime/relay/companion/icon.svg +5 -0
- package/runtime/relay/companion/index.html +25 -0
- package/runtime/relay/companion/manifest.json +13 -0
- package/runtime/relay/companion/sw.js +41 -0
- package/runtime/relay/main.mjs +38580 -0
- package/runtime/relay/model-listing.mjs +614 -0
- package/runtime/relay/versions-routes.mjs +1400 -0
- package/runtime/verify-plugins.mjs +205 -0
- package/runtime-lock/package-lock.json +10779 -0
- package/runtime-lock/package.json +7 -0
- package/scripts/install-runtime.mjs +400 -0
- package/README.md +0 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// `.picassoignore` for per-turn workspace snapshots.
|
|
2
|
+
//
|
|
3
|
+
// dsh-workspace-changes has no exclusion configuration: each turn it writes
|
|
4
|
+
// the whole work tree (`git add --all`, honouring only git's own ignore
|
|
5
|
+
// rules) into a private scratch object store and lists every changed path.
|
|
6
|
+
// Picasso therefore filters what it keeps and serves:
|
|
7
|
+
//
|
|
8
|
+
// summaries `workspace/changes/get|diff`, restore and rewind see the
|
|
9
|
+
// summary without ignored files (counts adjusted), so an
|
|
10
|
+
// ignored file is never listed, diffed or restored.
|
|
11
|
+
// archive the durable copy (workspace-archive.js) stores snapshot trees
|
|
12
|
+
// rewritten without ignored paths, and copies only the objects
|
|
13
|
+
// those trees reach, so ignored contents never reach
|
|
14
|
+
// `~/.dsh/picasso-workspace`.
|
|
15
|
+
//
|
|
16
|
+
// dsh's own scratch store (a temp directory removed when the session is
|
|
17
|
+
// disposed) still holds what dsh wrote; Picasso never reads ignored entries
|
|
18
|
+
// from it.
|
|
19
|
+
import { spawn } from 'node:child_process';
|
|
20
|
+
import { existsSync } from 'node:fs';
|
|
21
|
+
import { copyFile, mkdir, mkdtemp, realpath, rm } from 'node:fs/promises';
|
|
22
|
+
import { tmpdir } from 'node:os';
|
|
23
|
+
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
24
|
+
|
|
25
|
+
const TREE = /^[a-f0-9]{40,64}$/u;
|
|
26
|
+
|
|
27
|
+
/** A summary without the files `isIgnored(absolutePath)` excludes (the same object when none are). */
|
|
28
|
+
export function withoutIgnoredFiles(summary, isIgnored) {
|
|
29
|
+
if (summary === null || typeof summary !== 'object' || !Array.isArray(summary.files) || typeof isIgnored !== 'function') return summary;
|
|
30
|
+
const base = typeof summary.cwd === 'string' ? summary.cwd : process.cwd();
|
|
31
|
+
const removed = summary.files.filter((file) => typeof file?.path === 'string' && isIgnored(resolve(base, file.path)));
|
|
32
|
+
if (removed.length === 0) return summary;
|
|
33
|
+
const sum = (key) => removed.reduce((total, file) => total + (Number.isFinite(file[key]) ? file[key] : 0), 0);
|
|
34
|
+
return {
|
|
35
|
+
...summary,
|
|
36
|
+
files: summary.files.filter((file) => !removed.includes(file)),
|
|
37
|
+
...(Number.isFinite(summary.total) ? { total: Math.max(0, summary.total - removed.length) } : {}),
|
|
38
|
+
...(Number.isFinite(summary.added) ? { added: Math.max(0, summary.added - sum('added')) } : {}),
|
|
39
|
+
...(Number.isFinite(summary.deleted) ? { deleted: Math.max(0, summary.deleted - sum('deleted')) } : {}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function git(args, { cwd, env, input }) {
|
|
44
|
+
return new Promise((resolvePromise, reject) => {
|
|
45
|
+
const child = spawn('git', ['-C', cwd, ...args], { env: { ...process.env, ...env }, stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'] });
|
|
46
|
+
const out = [];
|
|
47
|
+
const err = [];
|
|
48
|
+
const timer = setTimeout(() => child.kill('SIGKILL'), 60000);
|
|
49
|
+
child.stdout.on('data', (chunk) => out.push(chunk));
|
|
50
|
+
child.stderr.on('data', (chunk) => err.push(chunk));
|
|
51
|
+
child.on('error', (error) => {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
reject(error);
|
|
54
|
+
});
|
|
55
|
+
child.on('close', (code) => {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
if (code === 0) resolvePromise(Buffer.concat(out).toString('utf8'));
|
|
58
|
+
else reject(new Error(`git ${args[0]} failed (${code}): ${Buffer.concat(err).toString('utf8').trim()}`));
|
|
59
|
+
});
|
|
60
|
+
if (input !== undefined) {
|
|
61
|
+
// git may exit before reading all of its input; its exit status reports the failure.
|
|
62
|
+
child.stdin.on('error', () => {});
|
|
63
|
+
child.stdin.end(input);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Store a summary's snapshot trees in `objects` without ignored paths.
|
|
70
|
+
* Each tree is rewritten (read into a private index, ignored entries removed,
|
|
71
|
+
* written back) and only the loose objects the rewritten trees reach are
|
|
72
|
+
* copied from dsh's live scratch store; objects already in the repository's
|
|
73
|
+
* own store stay there (reached through an alternate when reading).
|
|
74
|
+
*
|
|
75
|
+
* @param {object} input
|
|
76
|
+
* @param {any} input.summary - dsh workspace summary with `cwd` and `snapshot`.
|
|
77
|
+
* @param {string} input.objects - destination object directory.
|
|
78
|
+
* @param {(tree: string) => string | undefined} input.findObjects - dsh's live object store for a tree.
|
|
79
|
+
* @param {(absolutePath: string) => boolean} input.isIgnored
|
|
80
|
+
* @returns {Promise<any>} the summary to persist (files filtered, trees rewritten).
|
|
81
|
+
*/
|
|
82
|
+
export async function storeSnapshotWithoutIgnored({ summary, objects, findObjects, isIgnored }) {
|
|
83
|
+
const snapshot = summary.snapshot;
|
|
84
|
+
if (snapshot === undefined || typeof summary.cwd !== 'string') return withoutIgnoredFiles(summary, isIgnored);
|
|
85
|
+
for (const tree of Object.values(snapshot)) {
|
|
86
|
+
if (typeof tree !== 'string' || !TREE.test(tree)) throw new Error('invalid workspace snapshot tree');
|
|
87
|
+
}
|
|
88
|
+
const cwd = await realpath(summary.cwd);
|
|
89
|
+
const [root, repoObjectsRelative] = (await git(['rev-parse', '--show-toplevel', '--git-path', 'objects'], { cwd })).trimEnd().split('\n');
|
|
90
|
+
const repoObjects = resolve(cwd, repoObjectsRelative);
|
|
91
|
+
const trees = [...new Set(Object.values(snapshot))];
|
|
92
|
+
const live = trees.map((tree) => findObjects(tree)).find((dir) => dir !== undefined);
|
|
93
|
+
await mkdir(objects, { recursive: true, mode: 0o700 });
|
|
94
|
+
const env = {
|
|
95
|
+
GIT_OBJECT_DIRECTORY: objects,
|
|
96
|
+
GIT_ALTERNATE_OBJECT_DIRECTORIES: [live, repoObjects].filter((dir) => dir !== undefined && dir !== objects).join(delimiter),
|
|
97
|
+
};
|
|
98
|
+
const rewritten = new Map();
|
|
99
|
+
for (const tree of trees) {
|
|
100
|
+
await git(['cat-file', '-e', `${tree}^{tree}`], { cwd: root, env });
|
|
101
|
+
const listed = (await git(['ls-tree', '-r', '-z', '--name-only', '--full-tree', tree], { cwd: root, env })).split('\0').filter(Boolean);
|
|
102
|
+
const ignored = listed.filter((path) => isIgnored(join(root, path)));
|
|
103
|
+
if (ignored.length === 0) {
|
|
104
|
+
rewritten.set(tree, tree);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const scratch = await mkdtemp(join(tmpdir(), 'picasso-ignore-index-'));
|
|
108
|
+
try {
|
|
109
|
+
const indexEnv = { ...env, GIT_INDEX_FILE: join(scratch, 'index') };
|
|
110
|
+
await git(['read-tree', tree], { cwd: root, env: indexEnv });
|
|
111
|
+
await git(['update-index', '--force-remove', '-z', '--stdin'], { cwd: root, env: indexEnv, input: `${ignored.join('\0')}\0` });
|
|
112
|
+
rewritten.set(tree, (await git(['write-tree'], { cwd: root, env: indexEnv })).trim());
|
|
113
|
+
} finally {
|
|
114
|
+
await rm(scratch, { recursive: true, force: true });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (live !== undefined) {
|
|
118
|
+
const reachable = (await git(['rev-list', '--objects', ...new Set(rewritten.values())], { cwd: root, env })).split('\n');
|
|
119
|
+
for (const line of reachable) {
|
|
120
|
+
const oid = line.slice(0, line.indexOf(' ') < 0 ? line.length : line.indexOf(' '));
|
|
121
|
+
if (!TREE.test(oid)) continue;
|
|
122
|
+
const source = join(live, oid.slice(0, 2), oid.slice(2));
|
|
123
|
+
const target = join(objects, oid.slice(0, 2), oid.slice(2));
|
|
124
|
+
if (!existsSync(source) || existsSync(target)) continue;
|
|
125
|
+
await mkdir(dirname(target), { recursive: true, mode: 0o700 });
|
|
126
|
+
await copyFile(source, target);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const filteredSnapshot = Object.fromEntries(Object.entries(snapshot).map(([side, tree]) => [side, rewritten.get(tree)]));
|
|
130
|
+
return { ...withoutIgnoredFiles(summary, isIgnored), snapshot: filteredSnapshot };
|
|
131
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Image prompts on text-only models.
|
|
2
|
+
//
|
|
3
|
+
// dsh accepts image blocks for any model and, when the model's
|
|
4
|
+
// `inputModalities` lack 'image', silently replaces each image with a text
|
|
5
|
+
// placeholder before the request (dsh-llm `projectImagesForTextModel`). A user
|
|
6
|
+
// who attached a screenshot would get an answer that never saw it, so the
|
|
7
|
+
// Picasso SDK server refuses such a prompt up front:
|
|
8
|
+
//
|
|
9
|
+
// session/image-unsupported: <provider>/<model> does not accept image input ...
|
|
10
|
+
//
|
|
11
|
+
// Models that do not declare modalities are trusted (dsh sends the image).
|
|
12
|
+
|
|
13
|
+
export class ImageInputError extends Error {
|
|
14
|
+
constructor(provider, model) {
|
|
15
|
+
super(`session/image-unsupported: ${provider}/${model} does not accept image input; switch to a vision-capable model (/model) or send the prompt without the image`);
|
|
16
|
+
this.name = 'ImageInputError';
|
|
17
|
+
this.code = 'session/image-unsupported';
|
|
18
|
+
this.data = { provider, model };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Whether prompt content (a string or blocks) carries an image block. */
|
|
23
|
+
export function hasImageBlock(content) {
|
|
24
|
+
return Array.isArray(content) && content.some((block) => block !== null && typeof block === 'object' && block.type === 'image');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reject image content when the model declares no image input.
|
|
29
|
+
* @param {object} input
|
|
30
|
+
* @param {any} input.llm - dsh's LLM registry (`resolveModelInfo`).
|
|
31
|
+
* @param {{ provider: string, model: string } | undefined} input.route - the model the prompt will reach.
|
|
32
|
+
* @param {unknown} input.content - prompt content.
|
|
33
|
+
*/
|
|
34
|
+
export async function assertImageInput({ llm, route, content }) {
|
|
35
|
+
if (!hasImageBlock(content) || route === undefined || llm === undefined) return;
|
|
36
|
+
let info;
|
|
37
|
+
try {
|
|
38
|
+
info = await llm.resolveModelInfo(route.provider, route.model);
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const modalities = info?.inputModalities;
|
|
43
|
+
if (Array.isArray(modalities) && !modalities.includes('image')) throw new ImageInputError(route.provider, route.model);
|
|
44
|
+
}
|