chuspeeism/dashi-ppt-skill / skills/dashi-ppt
dashi-ppt
Flagged制作 PPT、演示文稿、幻灯片、汇报材料时使用。Dashi PPT 基于预置视觉主题组合页面,生成可离线打开、可在浏览器编辑的 HTML 演示,支持导出 PPTX / PDF 文件。
project/scripts/preview/ensure-tmpdir.mjs
View on GitHub// tmpdir 保险丝:沙箱型 Agent App(如豆包)带来的两类临时目录故障,都在这里兜住。
//
// 事故一(0.1.25):宿主在自己的沙箱里启动常驻预览服务,进程继承了指向宿主沙箱临时
// 目录的 TMPDIR;宿主会话结束后该目录被清理而服务还活着——之后导出时 Playwright
// launch 内部的 mkdtemp 直接 ENOENT。处理:检测到 os.tmpdir() 不存在就摘掉
// TMPDIR/TMP/TEMP,回退系统默认位置。
//
// 事故二(0.1.27):宿主的 macOS seatbelt 沙箱会被 daemonize 的服务进程继承。进程
// 没有 TMPDIR 时,Chrome 内部的 NSTemporaryDirectory() 走 confstr 的
// /var/folders/.../T/ 路径去建 ProcessSingleton 的 socket 目录——该位置被沙箱拒绝,
// Chrome 报 "Failed to create socket directory / Failed to create a ProcessSingleton"
// 后主动退出(exitCode=21),而同一沙箱对 /tmp 或 deck 输出目录是放行的。处理:导出
// 前实测探活一个真正可写的临时目录(候选:当前 os.tmpdir() → 显式 /tmp → 调用方给的
// 兜底目录,如导出目录),并把它显式设置为浏览器子进程的 TMPDIR,让 Chrome 的内部
// 临时路径一并改道到可写位置。
//
// 不重建宿主的沙箱目录——那随时会再被清理。
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
export function ensureUsableTmpdir(log = () => {}) {
const current = os.tmpdir();
if (fs.existsSync(current)) return current;
for (const key of ['TMPDIR', 'TMP', 'TEMP']) delete process.env[key];
const fallback = os.tmpdir();
try {
fs.mkdirSync(fallback, { recursive: true });
} catch {
// 系统默认临时目录建不出来的话,后续消费方会用原始错误暴露问题,这里不吞。
}
log(`[tmpdir] ${current} 不存在(宿主沙箱已清理),已回退到 ${fallback}`);
return fallback;
}
// 实测目录可写:真实 mkdtemp 一次再删掉。仅 existsSync 不够——沙箱下目录"存在但不可写"
// 与"可写"无法从元数据区分。
function probeWritable(dir) {
try {
const probe = fs.mkdtempSync(path.join(dir, '.tmp-probe-'));
fs.rmSync(probe, { recursive: true, force: true });
return true;
} catch {
return false;
}
}
// 返回一个实测可写的临时目录,供浏览器子进程用作 TMPDIR。extraFallbacks 里传服务
// 自身必然可写的位置(比如导出目录),作为沙箱连 /tmp 都拒绝时的最后兜底。
export function resolveBrowserTmpdir(extraFallbacks = [], log = () => {}) {
ensureUsableTmpdir(log);
const candidates = [os.tmpdir(), '/tmp', ...extraFallbacks];
for (const candidate of candidates) {
if (!candidate) continue;
try {
fs.mkdirSync(candidate, { recursive: true });
} catch {
continue;
}
if (probeWritable(candidate)) {
if (candidate !== candidates[0]) {
log(`[tmpdir] ${candidates[0]} 不可写(宿主沙箱限制),临时目录改用 ${candidate}`);
// 同时修正本进程的 TMPDIR:Playwright 在 node 侧也会 mkdtemp(playwright-artifacts),
// 只给浏览器子进程改道不够,宿主进程自己的 os.tmpdir() 消费方也必须落到可写位置。
process.env.TMPDIR = candidate;
delete process.env.TMP;
delete process.env.TEMP;
}
return candidate;
}
}
// 全部不可写:返回默认位置,让浏览器用原始错误暴露问题。
return os.tmpdir();
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |