1实现原理 · 为什么它能做到
自包含本地服务:scripts/server.mjs 是纯 Node stdlib HTTP 服务器(无第三方包),绑定 127.0.0.1,默认端口 8765,被占则自动 +1 递增(上限 +20);UI 模板 assets/index.html 由同一目录提供。
The server prints the actual URL. It starts at `http://127.0.0.1:8765/` and tries later ports if the default is occupied.
API 面就两个:GET /api/images 递归 walk 图片根目录返回 {rootPath, items[](path/mtime/size)}(按 mtime 降序);GET /images/<rel> 流式返回图片文件——两者都做路径穿越防护(safePath 校验解析后路径必须留在根内)。
if (fullPath !== root && !fullPath.startsWith(`${root}${path.sep}`)) { return null; }
『复用优先』协议:先 fetch /api/images 探测默认 URL(成功即复用已在跑的 server),失败再 pgrep 找进程并试后续端口,最后才新起 server——避免每请求叠一个实例。
If this succeeds, reuse the running server at `http://127.0.0.1:8765/`.
前端 index.html 是同源 fetch('/api/images') 渲染网格/灯箱/批量标签,纯本地数据无第三方 CDN/字体/脚本依赖。
const response = await fetch("/api/images", { cache: "no-store" });
验收路径可自动验证:node --check 语法 + 起服后核对 /api/images 有 items、/images/<rel> 能出图、首页来自 bundled index.html——SKILL 明示改完代码后要跑这三条再宣称 healthy。
Before declaring the skill healthy after edits, run: `node --check scripts/server.mjs`
2核心能力
3外部依赖
| Kind | Dependency / Endpoint |
|---|---|
| cli | node(运行 server.mjs;SKILL 亦用 node -e fetch 做探测) |
| cli | pgrep(探测已有 server 进程) |
| cli | open(可选,打开浏览器到本地 URL) |
4管控建议与判定依据
- scripts/: 执行本地脚本或命令: node scripts/server.mjs(本地 HTTP 服务,纯 stdlib)
- 环境变量 / API Key: 读取厂商服务密钥: 无
- 本地工作目录: 文件读写与工件输出: 无(服务器只读图片目录与 assets;不写任何文件)
5第二遍独立确认
- [ok] 绑定地址与端口递增 — server.mjs 'HOST = process.env.HOST || "127.0.0.1"' + 'error.code === "EADDRINUSE" && port < DEFAULT_PORT + 20'。
- [ok] 路径穿越防护 — safePath resolve 后 prefix 校验,越界 403;decodeURIComponent 包 try/catch。
- [ok] 无外发网络/第三方依赖 — server imports 仅 node:http/fs/os/path/url;index.html 外链扫描仅同源。
- [ok] SKILL 探测复用协议可实现性 — fetch('/api/images')、pgrep pattern 'node .*server\.mjs' 与 server 实际进程命令行一致(node scripts/server.mjs)。
- [ok] 鉴权缺失的暴露半径 — 代码无任何鉴权/CORS 头;暴露限于回环(本机)——已在 risk 记录;浏览器 PNA 缓解无法在源码验证,标注为宿主/浏览器行为。
- [unlocatable] 真实浏览器端渲染验证 — index.html 视觉行为未在浏览器实测(本环境无 Codex 图片目录/浏览器),验证止于静态代码与 SKILL 自述。
6结论
b2b0045b3baaf9a9…