AI Engineering Workspace
PartialChat, files, terminal and preview in one place. Chat sessions run on a durable Postgres-backed queue (chat only: no tools or shell). Live models need an API key; the terminal is unavailable.
Project files
read-only- ..
- assets
- basic-languages
- editor
- language
- nls
- abap-D-t0cyap.js
- apex-CcIm7xu6.js
- azcli-BA0tQDCg.js
- bat-C397hTD6.js
- bicep-DF5aW17k.js
- cameligo-plsz8qhj.js
- clojure-Y2auQMzK.js
- coffee-Bu45yuWE.js
- cpp-CkKPQIni.js
- csharp-CX28MZyh.js
- csp-D8uWnyxW.js
- css-CaeNmE3S.js
- css.worker-C7XcYe5x.js
- cssMode-DpEkhVlW.js
- cypher-DVThT8BS.js
- dart-CmGfCvrO.js
- dockerfile-CZqqYdch.js
- ecl-30fUercY.js
- editor-CG9c2pE-.js
- editor.js
- elixir-O3PRlgxO.js
- flow9-DqtmStfK.js
- freemarker2-DTUDMAl2.js
- fsharp-BOMdg4U1.js
- go-D_hbi-Jt.js
- graphql-CKUU4kLG.js
- handlebars-qLqoXa-4.js
- hcl-DTaboeZW.js
- html-DTxBj26n.js
- html.worker-VIR_LTyv.js
- htmlMode-DFBg6CMj.js
- index-BVflv2uG.js
- index.js
- ini--YXggpAu.js
- java-CI4ZMsH9.js
- javascript-BiL3JN6i.js
- json.worker-DzWXGkG8.js
- jsonMode-Dz4r0pwo.js
- julia-BwzEvaQw.js
- kotlin-IUYPiTV8.js
- less-C0eDYdqa.js
- lexon-iON-Kj97.js
- liquid-lXEUQRVn.js
- loader.js
- lspLanguageFeatures-IeRAvoKK.js
- lua-DtygF91M.js
- m3-CsR4AuFi.js
- markdown-C_rD0bIw.js
- mdx-Dtr248s4.js
- mips-CiYP61RB.js
- monaco.contribution-BRs4bdz5.js
- monaco.contribution-ChoOM5Gg.js
- monaco.contribution-DbKqsbmO.js
- monaco.contribution-DKFaWvum.js
- msdax-C38-sJlp.js
- mysql-CdtbpvbG.js
- nls.messages-loader.js
- objective-c-CntZFaHX.js
- pascal-r6kuqfl_.js
- pascaligo-BiXoTmXh.js
- perl-DABw_TcH.js
- pgsql-me_jFXeX.js
- php-D_kh-9LK.js
- pla-VfZjczW0.js
- postiats-BBSzz8Pk.js
- powerquery-Dt-g_2cc.js
- powershell-B-7ap1zc.js
- protobuf-BmtuEB1A.js
- pug-BRpRNeEb.js
- python-Cma5OvNe.js
- qsharp-BzsFaUU9.js
- r-f8dDdrp4.js
- razor-C8pOqqry.js
- redis-fvZQY4PI.js
- redshift-45Et0LQi.js
- restructuredtext-C7UUFKFD.js
- ruby-CZO8zYTz.js
- rust-Bfetafyc.js
- sb-3GYllVck.js
- scala-foMgrKo1.js
- scheme-CHdMtr7p.js
- scss-C1cmLt9V.js
- shell-ClXCKCEW.js
- solidity-MZ6ExpPy.js
- sophia-DWkuSsPQ.js
- sparql-AUGFYSyk.js
- sql-32GpJSV2.js
- st-CuDFIVZ_.js
- swift-t-PfMj7W.js
- systemverilog-Ch4vA8Yt.js
- tcl-D74tq1nH.js
- toggleHighContrast-CmI6H2gJ.js
- ts.worker-Dp2_QI6H.js
- tsMode-DgC3tGu_.js
- twig-C6taOxMV.js
- typescript-PjDChiYw.js
- typespec-D-PIh9Xw.js
- vb-Dyb2648j.js
- wgsl-BhLXMOR0.js
- workers-B_Zs9c54.js
- xml-BgCkTIhY.js
- yaml-D0tu26m-.js
app/src/lib/design.ts
1import fs from "node:fs";2import path from "node:path";3import crypto from "node:crypto";45export const DESIGN_ROOT = path.resolve(process.env.STUDIO_DESIGN_DIR || path.join(process.cwd(), "..", "design"));6export const ALLOWED_DIRS = ["references", "prototypes", "assets", "brand", "manifests", "screenshots", "verification"] as const;7const MIME: Record<string, string> = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp",8 ".svg": "image/svg+xml", ".json": "application/json", ".md": "text/markdown; charset=utf-8", ".html": "text/html; charset=utf-8", ".txt": "text/plain; charset=utf-8" };9export const MAX_BYTES = 5 * 1024 * 1024;10export const mimeFor = (f: string) => MIME[path.extname(f).toLowerCase()];1112export type ManifestEntry = { path: string; sha256: string; bytes: number; type: string; version: number; updated: string };13const manifestPath = () => path.join(DESIGN_ROOT, "manifests", "manifest.json");1415export function readManifest(): { version: number; generated: string; files: ManifestEntry[] } {16 try { return JSON.parse(fs.readFileSync(manifestPath(), "utf8")); } catch { return { version: 0, generated: "", files: [] }; }17}1819/** Only files listed in the manifest (with matching hash) are ever served publicly. */20export function rebuildManifest() {21 const old = new Map(readManifest().files.map(f => [f.path, f]));22 const files: ManifestEntry[] = [];23 const top = ["MASTER-DESIGN.md", "design-tokens.json", "components.md"];24 const consider: string[] = top.filter(f => fs.existsSync(path.join(DESIGN_ROOT, f)));25 for (const d of ALLOWED_DIRS) {26 if (d === "manifests") continue;27 const dir = path.join(DESIGN_ROOT, d);28 if (!fs.existsSync(dir)) continue;29 for (const f of fs.readdirSync(dir)) if (fs.statSync(path.join(dir, f)).isFile() && mimeFor(f)) consider.push(`${d}/${f}`);30 }31 for (const rel of consider) {32 const buf = fs.readFileSync(path.join(DESIGN_ROOT, rel));33 const sha = crypto.createHash("sha256").update(buf).digest("hex");34 const prev = old.get(rel);35 files.push({ path: rel, sha256: sha, bytes: buf.length, type: mimeFor(rel)!, version: prev ? (prev.sha256 === sha ? prev.version : prev.version + 1) : 1,36 updated: prev && prev.sha256 === sha ? prev.updated : new Date().toISOString() });37 }38 const m = { version: (readManifest().version || 0) + 1, generated: new Date().toISOString(), files };39 fs.mkdirSync(path.join(DESIGN_ROOT, "manifests"), { recursive: true });40 fs.writeFileSync(manifestPath(), JSON.stringify(m, null, 2));41 return m;42}4344/** Resolve a public request path to an approved file, or null. Prevents traversal and unlisted access. */45export function resolveApproved(parts: string[]): { file: string; entry: ManifestEntry } | null {46 if (parts.some(p => !p || p === "." || p === ".." || p.includes("\0") || p.includes("\\") || p.startsWith("."))) return null;47 const rel = parts.join("/");48 const entry = readManifest().files.find(f => f.path === rel);49 if (!entry) return null;50 const abs = path.resolve(DESIGN_ROOT, rel);51 if (!abs.startsWith(DESIGN_ROOT + path.sep)) return null;52 try {53 const real = fs.realpathSync(abs);54 if (!real.startsWith(fs.realpathSync(DESIGN_ROOT) + path.sep)) return null;55 const sha = crypto.createHash("sha256").update(fs.readFileSync(real)).digest("hex");56 if (sha !== entry.sha256) return null; // integrity: modified since approval57 return { file: real, entry };58 } catch { return null; }59}6061const MAGIC: [string, number[]][] = [["image/png", [0x89, 0x50, 0x4e, 0x47]], ["image/jpeg", [0xff, 0xd8, 0xff]], ["image/webp", [0x52, 0x49, 0x46, 0x46]]];62export function validateUpload(dir: string, name: string, buf: Buffer): string | null {63 if (!(ALLOWED_DIRS as readonly string[]).includes(dir) || dir === "manifests") return "destination directory not allowed";64 if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/.test(name) || name.includes("..")) return "invalid file name";65 const mime = mimeFor(name);66 if (!mime) return "file type not allowed";67 if (buf.length === 0 || buf.length > MAX_BYTES) return "file empty or larger than 5 MB";68 const magic = MAGIC.find(([m]) => m === mime);69 if (magic && !magic[1].every((b, i) => buf[i] === b)) return "file content does not match its extension";70 if (mime === "application/json") { try { JSON.parse(buf.toString("utf8")); } catch { return "invalid JSON"; } }71 if (mime === "image/svg+xml" && /<script|onload=|javascript:/i.test(buf.toString("utf8"))) return "active content in SVG rejected";72 return null;73}74export function saveAsset(dir: string, name: string, buf: Buffer) {75 fs.mkdirSync(path.join(DESIGN_ROOT, dir), { recursive: true });76 fs.writeFileSync(path.join(DESIGN_ROOT, dir, name), buf);77 return rebuildManifest();78}79export function listDir(dir: string): string[] {80 try { return fs.readdirSync(path.join(DESIGN_ROOT, dir)).sort(); } catch { return []; }81}82
Conversation
PartialSign in to start AI sessions.
Task checklist
- Application shell deployed
- Persistent projects
- Agent runtime
- Sandboxed terminal
Execution activity
No agent sessions. Git HEAD 1c27633 on master.
Approval requests
None pending.