P-0000: Plugin aus skill/ und viewer/ gebaut (Manifest, SKILL.md mit Format 1, Build-Skript, init.sh legt Git-Repo an), Tests skill2plugin
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1
skill/viewer/dist/assets/index-Cd54ZlSB.css
vendored
Normal file
1
skill/viewer/dist/assets/index-Cd54ZlSB.css
vendored
Normal file
File diff suppressed because one or more lines are too long
67
skill/viewer/dist/assets/index-DpwYxPe8.js
vendored
Normal file
67
skill/viewer/dist/assets/index-DpwYxPe8.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
skill/viewer/dist/index.html
vendored
Normal file
13
skill/viewer/dist/index.html
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Roadmap-Viewer</title>
|
||||
<script type="module" crossorigin src="/assets/index-DpwYxPe8.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Cd54ZlSB.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
66
skill/viewer/server.mjs
Normal file
66
skill/viewer/server.mjs
Normal file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env node
|
||||
// Roadmap-Viewer: liefert ROADMAP.md, KLICKTESTS.md und testberichte/ der angegebenen Projekte (nur lesend)
|
||||
// und die gebaute Oberfläche aus dist/.
|
||||
//
|
||||
// Aufruf: node server.mjs <projektordner> [weitere Projektordner …] (Port: env PORT, Standard 4177)
|
||||
import { createServer } from "node:http";
|
||||
import { readFile, readdir, stat } from "node:fs/promises";
|
||||
import { basename, extname, join, normalize, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const here = fileURLToPath(new URL(".", import.meta.url));
|
||||
const dist = join(here, "dist");
|
||||
const port = Number(process.env.PORT ?? 4177);
|
||||
const host = process.env.HOST ?? "127.0.0.1";
|
||||
|
||||
const projects = process.argv.slice(2).map((p) => resolve(p));
|
||||
if (!projects.length) {
|
||||
console.error("Aufruf: node server.mjs <projektordner> [weitere …]");
|
||||
process.exit(1);
|
||||
}
|
||||
const list = () => projects.map((p, i) => ({ id: String(i), name: basename(p), path: p }));
|
||||
const dirOf = (id) => projects[Number(id)];
|
||||
|
||||
const text = async (file) => { try { return await readFile(file, "utf8"); } catch { return null; } };
|
||||
const MIME = { ".html": "text/html; charset=utf-8", ".js": "text/javascript; charset=utf-8", ".css": "text/css; charset=utf-8", ".svg": "image/svg+xml", ".json": "application/json; charset=utf-8" };
|
||||
|
||||
function send(res, code, body, type = "text/plain; charset=utf-8") {
|
||||
res.writeHead(code, { "content-type": type, "cache-control": "no-store" });
|
||||
res.end(body);
|
||||
}
|
||||
|
||||
const server = createServer(async (req, res) => {
|
||||
const url = new URL(req.url ?? "/", "http://x");
|
||||
if (req.method !== "GET") return send(res, 405, "nur GET");
|
||||
|
||||
if (url.pathname === "/api/projects") return send(res, 200, JSON.stringify(list()), MIME[".json"]);
|
||||
|
||||
const m = url.pathname.match(/^\/api\/(roadmap|klicktests|reports)$/);
|
||||
if (m) {
|
||||
const dir = dirOf(url.searchParams.get("project") ?? "0");
|
||||
if (!dir) return send(res, 404, "unbekanntes Projekt");
|
||||
if (m[1] === "roadmap" || m[1] === "klicktests") {
|
||||
const name = m[1] === "roadmap" ? "ROADMAP.md" : "KLICKTESTS.md";
|
||||
const t = await text(join(dir, name));
|
||||
return t === null ? send(res, 404, `${name} fehlt in ${dir}`) : send(res, 200, t);
|
||||
}
|
||||
let files = [];
|
||||
try { files = (await readdir(join(dir, "testberichte"))).filter((f) => f.endsWith(".md")).sort(); } catch { /* kein Ordner: keine Berichte */ }
|
||||
const out = [];
|
||||
for (const file of files) out.push({ file, text: (await text(join(dir, "testberichte", file))) ?? "" });
|
||||
return send(res, 200, JSON.stringify(out), MIME[".json"]);
|
||||
}
|
||||
|
||||
// Oberfläche aus dist/ (ohne Ausbruch aus dem Ordner)
|
||||
const rel = normalize(decodeURIComponent(url.pathname)).replace(/^([/\\])+/, "");
|
||||
let file = join(dist, rel || "index.html");
|
||||
if (!file.startsWith(dist)) return send(res, 403, "verboten");
|
||||
try { if ((await stat(file)).isDirectory()) file = join(file, "index.html"); } catch { file = join(dist, "index.html"); }
|
||||
try { send(res, 200, await readFile(file), MIME[extname(file)] ?? "application/octet-stream"); }
|
||||
catch { send(res, 404, "dist/ fehlt: erst `npm run build`"); }
|
||||
});
|
||||
|
||||
server.listen(port, host, () => {
|
||||
console.log(`Roadmap-Viewer auf http://${host}:${port}`);
|
||||
for (const p of list()) console.log(` ${p.name}: ${p.path}`);
|
||||
});
|
||||
3
skill/viewer/start.sh
Executable file
3
skill/viewer/start.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
# Startet den Viewer (dist/ ist vorgebaut, keine Abhängigkeiten nötig).
|
||||
exec node "$(dirname "$0")/server.mjs" "$@"
|
||||
Reference in New Issue
Block a user