@liustack/modlens 2.6.1 → 2.7.1
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 +5 -1
- package/README.zh-CN.md +5 -1
- package/dist/main.js +107 -12
- package/package.json +1 -1
- package/skills/modlens/SKILL.md +4 -4
package/README.md
CHANGED
|
@@ -44,6 +44,8 @@ or do it yourself:
|
|
|
44
44
|
npx -y skills add liustack/modlens
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Harnesses look for skills in different places: Claude Code reads `~/.claude/skills/`, Codex reads `~/.codex/skills/`, Pi and OpenCode read `~/.agents/skills/`. Symlinks work in all of them, so linking the skill folder once keeps every agent on the latest version.
|
|
48
|
+
|
|
47
49
|
**3. Use it.** Paste an image path into the CLI and ask anything. The skill fires on its own.
|
|
48
50
|
|
|
49
51
|
## See it work
|
|
@@ -158,7 +160,9 @@ One catch: once text-only is declared, the Codex TUI **blocks Ctrl+V image paste
|
|
|
158
160
|
|
|
159
161
|
No setup needed: drag the image file into the terminal, or type its path, and the skill takes over.
|
|
160
162
|
|
|
161
|
-
Paste is trickier. If you run a text-only model behind `ANTHROPIC_BASE_URL`, Claude Code never writes pasted images to a regular temp file and has no modality switch, so a pasted image reaches the model as a pathless `[Unsupported Image]` placeholder (lenient gateways like DeepSeek's Anthropic endpoint) or breaks the request outright ([#62009](https://github.com/anthropics/claude-code/issues/62009)). But the bytes are not gone: Claude Code appends every user message, images included, to the local session transcript before the gateway ever sees it. That is what `modlens recover-paste` exploits: it pulls the most recent pasted images back out of the transcript and prints real file paths, ready for `modlens -i`. The skill runs this automatically when it spots the placeholder. Verified end to end in a real DeepSeek-gateway Claude Code session: paste an image, the model sees only the placeholder, recovers the file by session id, and answers with full image content. Transcripts are per-session files. Skills can pass the exact session via `--session` (Claude Code substitutes `${CLAUDE_SESSION_ID}` into skill text since v2.1.9); without it, recovery picks the transcript holding the newest pasted image by message timestamp, so concurrent sessions in the same project do not confuse it either way. [Pi](https://github.com/earendil-works/pi) stores sessions the same way (`~/.pi/agent/sessions/`, images as base64 in JSONL). [OpenCode](https://github.com/sst/opencode) keeps them in SQLite instead (`~/.local/share/opencode/opencode.db`, images as data URLs; reading it needs Node 22.5+ for node:sqlite). `recover-paste`
|
|
163
|
+
Paste is trickier. If you run a text-only model behind `ANTHROPIC_BASE_URL`, Claude Code never writes pasted images to a regular temp file and has no modality switch, so a pasted image reaches the model as a pathless `[Unsupported Image]` placeholder (lenient gateways like DeepSeek's Anthropic endpoint) or breaks the request outright ([#62009](https://github.com/anthropics/claude-code/issues/62009)). But the bytes are not gone: Claude Code appends every user message, images included, to the local session transcript before the gateway ever sees it. That is what `modlens recover-paste` exploits: it pulls the most recent pasted images back out of the transcript and prints real file paths, ready for `modlens -i`. The skill runs this automatically when it spots the placeholder. Verified end to end in a real DeepSeek-gateway Claude Code session: paste an image, the model sees only the placeholder, recovers the file by session id, and answers with full image content. Transcripts are per-session files. Skills can pass the exact session via `--session` (Claude Code substitutes `${CLAUDE_SESSION_ID}` into skill text since v2.1.9); without it, recovery picks the transcript holding the newest pasted image by message timestamp, so concurrent sessions in the same project do not confuse it either way. [Pi](https://github.com/earendil-works/pi) stores sessions the same way (`~/.pi/agent/sessions/`, images as base64 in JSONL). [OpenCode](https://github.com/sst/opencode) keeps them in SQLite instead (`~/.local/share/opencode/opencode.db`, images as data URLs; reading it needs Node 22.5+ for node:sqlite). `recover-paste` first identifies the harness it is running inside, by walking the process ancestry and checking env fingerprints (`CLAUDECODE`, `PI_CODING_AGENT`, `CODEX_THREAD_ID`), and reads only that harness's storage, so one tool's stale sessions can never hijack another tool's paste; in Claude Code it even targets the exact session from the injected session id, and in Codex it refuses outright and points back to the path tag. Only when detection comes up empty does it fall back to racing all three stores by newest image timestamp. Verified live in all four harnesses: Claude Code recovers the paste via its injected session id, OpenCode runs the whole loop on DeepSeek with the skill firing on its own, Pi stays scoped to its own store, and Codex is refused with the path-tag guidance. One honest caveat: transcript layouts are internal implementation details of those tools with no compatibility promise; if recovery ever breaks, dragging the file still works everywhere.
|
|
164
|
+
|
|
165
|
+
Pointing OpenCode at DeepSeek takes two lines of setup: `opencode auth login`, pick DeepSeek and paste your key (it lands in `~/.local/share/opencode/auth.json`), then set the default model in `~/.config/opencode/opencode.jsonc` to `deepseek/deepseek-v4-flash`. Pi reads its key from `~/.pi/agent/auth.json`.
|
|
162
166
|
|
|
163
167
|
## Why a bridge instead of a multimodal model?
|
|
164
168
|
|
package/README.zh-CN.md
CHANGED
|
@@ -44,6 +44,8 @@ agy # 浏览器完成登录后退出
|
|
|
44
44
|
npx -y skills add liustack/modlens
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
各家 harness 找 skill 的位置不一样:Claude Code 读 `~/.claude/skills/`,Codex 读 `~/.codex/skills/`,Pi 和 OpenCode 读 `~/.agents/skills/`。软链接在哪家都好使,把 skill 目录链一次,各家永远用最新版。
|
|
48
|
+
|
|
47
49
|
**3. 用起来。** 在 cli 里粘贴个图片路径,随便问,skill 会自动触发。
|
|
48
50
|
|
|
49
51
|
## 看看效果
|
|
@@ -158,7 +160,9 @@ Codex 只认 Responses API,DeepSeek 官方端点原生支持。先照着[官
|
|
|
158
160
|
|
|
159
161
|
不用任何配置:把图片文件拖进终端,或手打路径,skill 直接接手。
|
|
160
162
|
|
|
161
|
-
粘贴要多说两句。走 `ANTHROPIC_BASE_URL` 网关跑纯文本模型时,Claude Code 粘贴的图片从不写普通临时文件,也没有声明模型无视觉的开关,粘贴的图要么变成一个不带路径的 `[Unsupported Image]` 占位符到达模型(DeepSeek 的 Anthropic 兼容端点这类宽容网关),要么直接把请求搞挂([#62009](https://github.com/anthropics/claude-code/issues/62009))。但图片字节没有蒸发:Claude Code 在网关看到消息之前,就把每条用户消息(含图片)原样写进了本地会话记录。`modlens recover-paste` 干的就是这件事:从会话记录里把最近粘贴的图捞回来,落成真实文件路径,直接喂给 `modlens -i`。skill 看到占位符会自动跑这一步。已在真实的 DeepSeek 网关 Claude Code 会话里端到端验证:粘贴一张图,模型只看到占位符,按会话 ID 捞回文件,带着完整图片内容回答。会话记录本来就是一个会话一个文件。skill 可以通过 `--session` 传入精确会话(Claude Code 从 v2.1.9 起会把 `${CLAUDE_SESSION_ID}` 替换进 skill 文本),不传时按消息时间戳挑「持有最新粘贴图」的那份,两条路都不怕同项目并发多开。[Pi](https://github.com/earendil-works/pi) 的会话存储和它同构(`~/.pi/agent/sessions/`,图片以 base64 存 JSONL)。[OpenCode](https://github.com/sst/opencode) 换了个存法,图片以 data URL 塞进 SQLite(`~/.local/share/opencode/opencode.db`,读它需要 Node 22.5+ 的 node:sqlite)。`recover-paste`
|
|
163
|
+
粘贴要多说两句。走 `ANTHROPIC_BASE_URL` 网关跑纯文本模型时,Claude Code 粘贴的图片从不写普通临时文件,也没有声明模型无视觉的开关,粘贴的图要么变成一个不带路径的 `[Unsupported Image]` 占位符到达模型(DeepSeek 的 Anthropic 兼容端点这类宽容网关),要么直接把请求搞挂([#62009](https://github.com/anthropics/claude-code/issues/62009))。但图片字节没有蒸发:Claude Code 在网关看到消息之前,就把每条用户消息(含图片)原样写进了本地会话记录。`modlens recover-paste` 干的就是这件事:从会话记录里把最近粘贴的图捞回来,落成真实文件路径,直接喂给 `modlens -i`。skill 看到占位符会自动跑这一步。已在真实的 DeepSeek 网关 Claude Code 会话里端到端验证:粘贴一张图,模型只看到占位符,按会话 ID 捞回文件,带着完整图片内容回答。会话记录本来就是一个会话一个文件。skill 可以通过 `--session` 传入精确会话(Claude Code 从 v2.1.9 起会把 `${CLAUDE_SESSION_ID}` 替换进 skill 文本),不传时按消息时间戳挑「持有最新粘贴图」的那份,两条路都不怕同项目并发多开。[Pi](https://github.com/earendil-works/pi) 的会话存储和它同构(`~/.pi/agent/sessions/`,图片以 base64 存 JSONL)。[OpenCode](https://github.com/sst/opencode) 换了个存法,图片以 data URL 塞进 SQLite(`~/.local/share/opencode/opencode.db`,读它需要 Node 22.5+ 的 node:sqlite)。`recover-paste` 会先搞清楚自己正跑在哪家宿主里(沿进程祖先链往上找,再核对 `CLAUDECODE`、`PI_CODING_AGENT`、`CODEX_THREAD_ID` 这些环境变量指纹),然后只读那一家的存储,别家的陈年会话再也没机会冒充。在 Claude Code 里还会直接用注入的会话 ID 精确定位,在 Codex 里则干脆拒绝执行并把你指回 path tag。实在识别不出来才退回按最新图片时间戳在三家赛跑。四家宿主全部活体验证过:Claude Code 靠注入的会话 ID 精确捞回粘贴,OpenCode 上 DeepSeek 全程自动触发 skill 跑完整条链路,Pi 只认自家存储不受别家污染,Codex 被拒之门外并指回 path tag。一句老实话:会话记录格式是这些工具的内部实现,没有兼容承诺,哪天捞不动了,拖文件永远是保底。
|
|
164
|
+
|
|
165
|
+
OpenCode 接 DeepSeek 只要两步:`opencode auth login` 选 DeepSeek 贴上 key(落在 `~/.local/share/opencode/auth.json`),再把 `~/.config/opencode/opencode.jsonc` 的默认模型设成 `deepseek/deepseek-v4-flash`。Pi 的 key 放 `~/.pi/agent/auth.json`。
|
|
162
166
|
|
|
163
167
|
## 为什么外挂,而不是换多模态模型?
|
|
164
168
|
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
import * as path from "path";
|
|
5
|
+
import * as childProcess from "child_process";
|
|
5
6
|
import { spawn } from "child_process";
|
|
6
7
|
import * as os from "os";
|
|
7
8
|
import * as crypto from "crypto";
|
|
@@ -1064,6 +1065,64 @@ const opencodeAdapter = {
|
|
|
1064
1065
|
};
|
|
1065
1066
|
}
|
|
1066
1067
|
};
|
|
1068
|
+
const HARNESS_BY_BASENAME = {
|
|
1069
|
+
claude: "claude-code",
|
|
1070
|
+
"claude-code": "claude-code",
|
|
1071
|
+
pi: "pi",
|
|
1072
|
+
opencode: "opencode",
|
|
1073
|
+
codex: "codex"
|
|
1074
|
+
};
|
|
1075
|
+
function harnessFromPsTable(psOutput, startPid) {
|
|
1076
|
+
const table = /* @__PURE__ */ new Map();
|
|
1077
|
+
for (const line of psOutput.split("\n")) {
|
|
1078
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(line);
|
|
1079
|
+
if (match) {
|
|
1080
|
+
table.set(Number(match[1]), { ppid: Number(match[2]), command: match[3] });
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
let pid = table.get(startPid)?.ppid;
|
|
1084
|
+
for (let hops = 0; hops < 50 && pid !== void 0 && pid > 1; hops++) {
|
|
1085
|
+
const proc = table.get(pid);
|
|
1086
|
+
if (!proc) {
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
for (const token of proc.command.trim().split(/\s+/).slice(0, 8)) {
|
|
1090
|
+
const mapped = HARNESS_BY_BASENAME[path.basename(token)];
|
|
1091
|
+
if (mapped) {
|
|
1092
|
+
return mapped;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
pid = proc.ppid;
|
|
1096
|
+
}
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1099
|
+
function detectHarness() {
|
|
1100
|
+
const override = process.env.MODLENS_HARNESS;
|
|
1101
|
+
if (override) {
|
|
1102
|
+
return override === "none" ? null : override;
|
|
1103
|
+
}
|
|
1104
|
+
try {
|
|
1105
|
+
const ps = childProcess.execFileSync("ps", ["-Ao", "pid=,ppid=,command="], {
|
|
1106
|
+
encoding: "utf-8",
|
|
1107
|
+
maxBuffer: 16 * 1024 * 1024
|
|
1108
|
+
});
|
|
1109
|
+
const found = harnessFromPsTable(ps, process.pid);
|
|
1110
|
+
if (found) {
|
|
1111
|
+
return found;
|
|
1112
|
+
}
|
|
1113
|
+
} catch {
|
|
1114
|
+
}
|
|
1115
|
+
if (process.env.PI_CODING_AGENT) {
|
|
1116
|
+
return "pi";
|
|
1117
|
+
}
|
|
1118
|
+
if (process.env.CODEX_THREAD_ID || process.env.CODEX_SANDBOX) {
|
|
1119
|
+
return "codex";
|
|
1120
|
+
}
|
|
1121
|
+
if (process.env.CLAUDECODE || process.env.CLAUDE_CODE_SESSION_ID) {
|
|
1122
|
+
return "claude-code";
|
|
1123
|
+
}
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1067
1126
|
const ADAPTERS = [claudeAdapter, piAdapter, opencodeAdapter];
|
|
1068
1127
|
function sourceForExplicitPath(filePath) {
|
|
1069
1128
|
if (filePath.endsWith(".db")) {
|
|
@@ -1078,9 +1137,9 @@ function sourceForExplicitPath(filePath) {
|
|
|
1078
1137
|
}
|
|
1079
1138
|
return jsonlSource("claude-code", filePath, claudeExtractLine);
|
|
1080
1139
|
}
|
|
1081
|
-
function locateSource(cwd) {
|
|
1140
|
+
function locateSource(cwd, adapters = ADAPTERS) {
|
|
1082
1141
|
let best = null;
|
|
1083
|
-
for (const adapter of
|
|
1142
|
+
for (const adapter of adapters) {
|
|
1084
1143
|
let candidate = null;
|
|
1085
1144
|
try {
|
|
1086
1145
|
candidate = adapter.findNewest(cwd);
|
|
@@ -1091,15 +1150,15 @@ function locateSource(cwd) {
|
|
|
1091
1150
|
}
|
|
1092
1151
|
}
|
|
1093
1152
|
if (!best) {
|
|
1094
|
-
const dirs =
|
|
1153
|
+
const dirs = adapters.map((a) => a.describe(cwd)).join(" , ");
|
|
1095
1154
|
throw new Error(
|
|
1096
1155
|
`No pasted images found in any session storage for this directory (looked in: ${dirs}). The user may not have pasted any, or the storage format changed; ask for a file path instead.`
|
|
1097
1156
|
);
|
|
1098
1157
|
}
|
|
1099
1158
|
return best.ref;
|
|
1100
1159
|
}
|
|
1101
|
-
function sourceForSession(cwd, sessionId) {
|
|
1102
|
-
for (const adapter of
|
|
1160
|
+
function sourceForSession(cwd, sessionId, adapters = ADAPTERS) {
|
|
1161
|
+
for (const adapter of adapters) {
|
|
1103
1162
|
try {
|
|
1104
1163
|
const ref = adapter.findSession(cwd, sessionId);
|
|
1105
1164
|
if (ref) {
|
|
@@ -1108,14 +1167,42 @@ function sourceForSession(cwd, sessionId) {
|
|
|
1108
1167
|
} catch {
|
|
1109
1168
|
}
|
|
1110
1169
|
}
|
|
1111
|
-
const dirs =
|
|
1170
|
+
const dirs = adapters.map((a) => a.describe(cwd)).join(" , ");
|
|
1112
1171
|
throw new Error(
|
|
1113
1172
|
`No session ${sessionId} with pasted images under this project (looked in: ${dirs}). Check --cwd, or drop --session to auto-locate by newest pasted image.`
|
|
1114
1173
|
);
|
|
1115
1174
|
}
|
|
1116
1175
|
function recoverPastedImages(options = {}) {
|
|
1117
1176
|
const cwd = options.cwd ?? process.cwd();
|
|
1118
|
-
const
|
|
1177
|
+
const detected = options.transcript ? null : options.harness ?? detectHarness();
|
|
1178
|
+
if (detected === "codex") {
|
|
1179
|
+
throw new Error(
|
|
1180
|
+
"This is a Codex session: pasted images already exist as temp files, and each image tag in the message carries its path. Read the path from the tag instead of running recover-paste."
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
const scoped = detected && detected !== "none" ? detected : null;
|
|
1184
|
+
if (scoped && !ADAPTERS.some((adapter) => adapter.name === scoped)) {
|
|
1185
|
+
throw new Error(
|
|
1186
|
+
`Unknown harness "${scoped}". Supported: claude-code, pi, opencode (or none to scan all).`
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
const adapters = scoped ? ADAPTERS.filter((adapter) => adapter.name === scoped) : ADAPTERS;
|
|
1190
|
+
let source = null;
|
|
1191
|
+
if (options.transcript) {
|
|
1192
|
+
source = sourceForExplicitPath(options.transcript);
|
|
1193
|
+
} else if (options.session) {
|
|
1194
|
+
source = sourceForSession(cwd, options.session, adapters);
|
|
1195
|
+
} else {
|
|
1196
|
+
const envSession = detected === "claude-code" ? process.env.CLAUDE_CODE_SESSION_ID : void 0;
|
|
1197
|
+
if (envSession) {
|
|
1198
|
+
try {
|
|
1199
|
+
source = sourceForSession(cwd, envSession, adapters);
|
|
1200
|
+
} catch {
|
|
1201
|
+
source = null;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
source ??= locateSource(cwd, adapters);
|
|
1205
|
+
}
|
|
1119
1206
|
const count = Math.max(1, options.count ?? 1);
|
|
1120
1207
|
const outDir = options.outDir ?? path.join(os.tmpdir(), "modlens-paste");
|
|
1121
1208
|
const all = source.extract();
|
|
@@ -1142,10 +1229,14 @@ function recoverPastedImages(options = {}) {
|
|
|
1142
1229
|
}
|
|
1143
1230
|
return recovered;
|
|
1144
1231
|
});
|
|
1145
|
-
|
|
1232
|
+
const result = { harness: source.harness, transcript: source.location, images };
|
|
1233
|
+
if (scoped) {
|
|
1234
|
+
result.detected = scoped;
|
|
1235
|
+
}
|
|
1236
|
+
return result;
|
|
1146
1237
|
}
|
|
1147
1238
|
const program = new Command();
|
|
1148
|
-
program.name("modlens").description("Plug-in vision for text-only LLMs: image in, structured JSON evidence out").version("2.
|
|
1239
|
+
program.name("modlens").description("Plug-in vision for text-only LLMs: image in, structured JSON evidence out").version("2.7.1");
|
|
1149
1240
|
program.command("analyze", { isDefault: true }).description("Analyze an image into structured JSON evidence (default command)").requiredOption("-i, --input <path|url>", "Input image path or https URL").option("-o, --output <path>", "Write result JSON to a file").option("-m, --model <name>", "Provider model name").option("-p, --provider <name>", `Vision provider (${listProviders().join(", ")})`).option("--prompt <text>", "Extra focus for this image").option("--timeout <ms>", "Provider timeout in milliseconds", "180000").option("--provider-bin <path>", "Provider binary path (default: agy)").option("--workdir <path>", "Working directory for the provider").action(async (options) => {
|
|
1150
1241
|
try {
|
|
1151
1242
|
const timeoutMs = Number.parseInt(options.timeout, 10);
|
|
@@ -1178,11 +1269,14 @@ program.command("analyze", { isDefault: true }).description("Analyze an image in
|
|
|
1178
1269
|
}
|
|
1179
1270
|
});
|
|
1180
1271
|
program.command("recover-paste").description(
|
|
1181
|
-
"Recover images pasted into Claude Code from
|
|
1272
|
+
"Recover images pasted into Claude Code, Pi, or OpenCode from local session storage (they never hit disk otherwise)"
|
|
1182
1273
|
).option("--count <n>", "How many recent pasted images to recover", "1").option("--out-dir <path>", "Directory to write recovered images to").option(
|
|
1183
1274
|
"--session <id>",
|
|
1184
1275
|
"Claude Code session id for exact targeting (skills get it via ${CLAUDE_SESSION_ID})"
|
|
1185
|
-
).option("--transcript <path>", "Explicit transcript .jsonl (overrides --session)").option(
|
|
1276
|
+
).option("--transcript <path>", "Explicit transcript .jsonl or .db (overrides --session)").option(
|
|
1277
|
+
"--harness <name>",
|
|
1278
|
+
"Force the storage scope: claude-code, pi, opencode, or none (default: auto-detect via process ancestry and env)"
|
|
1279
|
+
).option("--cwd <path>", "Project directory the image was pasted in", process.cwd()).action(async (options) => {
|
|
1186
1280
|
try {
|
|
1187
1281
|
const count = Number.parseInt(options.count, 10);
|
|
1188
1282
|
if (!Number.isFinite(count) || count <= 0) {
|
|
@@ -1193,7 +1287,8 @@ program.command("recover-paste").description(
|
|
|
1193
1287
|
outDir: options.outDir,
|
|
1194
1288
|
transcript: options.transcript,
|
|
1195
1289
|
session: options.session,
|
|
1196
|
-
cwd: options.cwd
|
|
1290
|
+
cwd: options.cwd,
|
|
1291
|
+
harness: options.harness
|
|
1197
1292
|
});
|
|
1198
1293
|
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
1199
1294
|
`);
|
package/package.json
CHANGED
package/skills/modlens/SKILL.md
CHANGED
|
@@ -65,14 +65,14 @@ Harnesses rarely hand you a clean path. First identify which harness you are in,
|
|
|
65
65
|
|
|
66
66
|
**Codex** (you see a text tag like `<image name=[Image #1] path="/tmp/xxxx.png">`):
|
|
67
67
|
|
|
68
|
-
- Extract the `path` value from the tag and run modlens on it. Pasted images live in a temp file Codex already created; a stripped image keeps its path tag next to the placeholder. Do NOT use `recover-paste` here: it
|
|
68
|
+
- Extract the `path` value from the tag and run modlens on it. Pasted images live in a temp file Codex already created; a stripped image keeps its path tag next to the placeholder. Do NOT use `recover-paste` here: it detects Codex and refuses with this same guidance.
|
|
69
69
|
|
|
70
70
|
**Claude Code, Pi, or OpenCode** (no path tag anywhere; the image reads as `[Unsupported Image]`, a bare `[Image #1]`, or an attachment you simply cannot see):
|
|
71
71
|
|
|
72
|
-
- None of these harnesses writes pasted images to a regular temp file, but all of them persist user messages locally before any gateway strips them: Claude Code and Pi in session JSONL files (`~/.claude/projects/`, `~/.pi/agent/sessions/`), OpenCode in a SQLite database (`~/.local/share/opencode/opencode.db`, read via node:sqlite, needs Node 22.5+). `recover-paste`
|
|
72
|
+
- None of these harnesses writes pasted images to a regular temp file, but all of them persist user messages locally before any gateway strips them: Claude Code and Pi in session JSONL files (`~/.claude/projects/`, `~/.pi/agent/sessions/`), OpenCode in a SQLite database (`~/.local/share/opencode/opencode.db`, read via node:sqlite, needs Node 22.5+). Run `modlens recover-paste` from the project directory the conversation is happening in (add `--count <n>` for several images). It detects which harness it is running inside (process ancestry, then env fingerprints) and reads ONLY that harness's storage, so another tool's old sessions cannot leak in. In Claude Code it also targets your exact session automatically via the injected CLAUDE_CODE_SESSION_ID; `--session <id>` (e.g. from the ${CLAUDE_SESSION_ID} substitution) is only needed to override.
|
|
73
|
+
- The output is JSON with real file paths, ordered oldest to newest, so the LAST path is the user's most recent paste. Analyze that one first. Entries carry `filename` (the original attachment name) when the harness stored one; if the user's message or an error mentions a filename, match on it.
|
|
73
74
|
- Run every command yourself: `recover-paste`, then `modlens -i <path>` on the recovered file, then answer from the JSON. Never ask the user to run modlens or to relay paths.
|
|
74
|
-
-
|
|
75
|
-
- Session targeting: your session id is ${CLAUDE_SESSION_ID}. If that value reads as a UUID, pass it as `--session <uuid>` for exact targeting (on OpenCode, the session id or slug works too). If it reads as a literal placeholder, omit `--session`: the command auto-locates by scanning this project's sessions for the newest pasted-image message, which is the session the user just pasted into, even with concurrent sessions. Run it from the project directory the conversation is happening in.
|
|
75
|
+
- The output's `detected` field names the harness scope that was applied. If it is absent, detection failed and every store was scanned by newest-image timestamp: before describing anything, check that `harness` and `filename` match what you expect, force the scope with `--harness <claude-code|pi|opencode>` if they do not, and when in doubt ask the user for the file instead of describing the wrong image.
|
|
76
76
|
- If recovery fails (session storage is each harness's internals and may change), ask the user to drag the image file into the terminal or type its path.
|
|
77
77
|
|
|
78
78
|
**Any other harness, or nothing matches** (no path tag and `recover-paste` reports no transcripts): do not guess. Ask the user for the image file path, or suggest dragging the file into the terminal.
|