Add Diagnose and X-ray, shared building habits, fresh-helper reviews, and a Bug fixed spec state

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-16 19:28:11 -07:00
1 parent 80ae3decdd
commit 33a0dbd34a
58 files changed
+3270 -236

No files matched your search

+41
View File
@@ -54,6 +54,9 @@ import {
rememberedWorkspace,
removeCleanup,
remoteWarning,
SHOTS_DIR_NAME,
SHOT_NAME,
shotType,
saveSubagentStoreEntry,
PR_HOST_KINDS,
savePrHost,
@@ -131,6 +134,25 @@ const EXT_ALT = UPLOAD_EXTS.join("|");
const UPLOAD_ANY_ROUTE = new RegExp(`^/uploads/([0-9a-f-]{36})\\.(${EXT_ALT})$`);
const UPLOAD_NAME = new RegExp(`^[0-9a-f-]{36}\\.(${EXT_ALT})$`);
// Screenshots the agent saved for a doc's image block (Show me it working),
// only ever directly inside <session>/shots/ under SHOT_NAME's plain shape.
const SHOTS_DIR = path.join(DIR, SHOTS_DIR_NAME);
const SHOT_TYPES = { png: "image/png", jpeg: "image/jpeg", webp: "image/webp" };
function shotPath(name) {
if (!SHOT_NAME.test(name)) return null;
const file = path.resolve(SHOTS_DIR, name);
if (!file.startsWith(path.resolve(SHOTS_DIR) + path.sep)) return null;
try {
const real = fs.realpathSync.native(file);
const fold = (p) => (process.platform === "win32" || process.platform === "darwin" ? p.toLowerCase() : p);
if (fold(path.dirname(real)) !== fold(fs.realpathSync.native(SHOTS_DIR))) return null;
return fs.statSync(real).isFile() ? real : null;
} catch {
return null;
}
}
// A kept attachment's name, as attachmentName() in lib.mjs writes it:
// <slug>-<first 8 of the upload id>.<the upload's extension>.
const KEPT_ROUTE = new RegExp(`^/attachments/([a-z0-9-]{1,40}-[0-9a-f-]{8}\\.(${EXT_ALT}))$`);
@@ -1468,6 +1490,25 @@ const server = http.createServer((req, res) => {
});
}
// A screenshot for a doc's image block. Matched on the raw request line too,
// like uploads: anything URL parsing had to fold (`..`) is not a shot.
if (pathname.startsWith("/shots/") || req.url.startsWith("/shots/")) {
if (req.method !== "GET") return json(res, 405, { error: "method" });
const name = pathname.slice("/shots/".length);
const file = req.url === pathname ? shotPath(name) : null;
if (!file) return json(res, 404, { error: "not found" });
let buf;
try {
buf = fs.readFileSync(file);
} catch {
return json(res, 404, { error: "not found" });
}
// The bytes, not the name, pick the type: the file may have changed since it was posted.
const type = SHOT_TYPES[shotType(buf)];
if (!type) return json(res, 404, { error: "not found" });
return send(res, 200, buf, type, { "cache-control": "no-store" });
}
// Matched on the raw request line as well as the parsed path: URL parsing
// folds `..` segments away, and nothing that needed folding is an upload.
// GET and DELETE take images and documents alike.