Skip to content

DoHyun468/claw-hwp / plugins/claw-hwp/skills/hwp

FileKindSize
SKILL.mdskill md101.9 KB
references/README.mdmarkdown834 B
references/equation-syntax.mdmarkdown5.9 KB
references/hwp-internals.mdmarkdown4.9 KB
references/hwp-object-placement.mdmarkdown5.8 KB
references/hwpx-edit-ops.mdmarkdown52.8 KB
references/hwpx-format.mdmarkdown14.8 KB
references/hwpx-object-placement.mdmarkdown7.1 KB
references/hwpx-style-spacing.mdmarkdown10.7 KB
references/rhwp-api.mdmarkdown15.8 KB
scripts/README.mdmarkdown2.4 KB
scripts/cell-inspect.jsscript4.9 KB
scripts/cell-patch.jsscript525.8 KB
scripts/create.jsexecutablebinary235.8 KB
scripts/extract_text.jsexecutablescript12.0 KB
scripts/hwpx-edit.jsscript292.7 KB
scripts/launcher/preview-linux.shexecutablescript2.0 KB
scripts/launcher/preview-mac.commandexecutablescript1.9 KB
scripts/launcher/preview-windows.batscript2.1 KB
scripts/make_seal.pyscript3.4 KB
scripts/pack.pyexecutablescript8.0 KB
scripts/package-lock.jsonmanifest2.0 KB
scripts/package.jsonmanifest298 B
scripts/preview-server.jsscript5.3 KB
scripts/preview-viewer.htmlother11.5 KB
scripts/preview-viewer.jsscript17.2 KB
scripts/references/chart-templates/chart-0.jsonconfig6.4 KB
scripts/references/chart-templates/chart-1.jsonconfig6.4 KB
scripts/references/chart-templates/chart-10.jsonconfig6.3 KB
scripts/references/chart-templates/chart-11.jsonconfig6.3 KB
scripts/references/chart-templates/chart-12.jsonconfig6.5 KB
scripts/references/chart-templates/chart-13.jsonconfig6.5 KB
scripts/references/chart-templates/chart-14.jsonconfig6.5 KB
scripts/references/chart-templates/chart-15.jsonconfig6.5 KB
scripts/references/chart-templates/chart-16.jsonconfig5.9 KB
scripts/references/chart-templates/chart-17.jsonconfig5.9 KB
scripts/references/chart-templates/chart-18.jsonconfig6.3 KB
scripts/references/chart-templates/chart-19.jsonconfig6.3 KB
scripts/references/chart-templates/chart-2.jsonconfig6.4 KB
scripts/references/chart-templates/chart-3.jsonconfig6.4 KB
scripts/references/chart-templates/chart-4.jsonconfig6.4 KB
scripts/references/chart-templates/chart-5.jsonconfig6.3 KB
scripts/references/chart-templates/chart-6.jsonconfig5.9 KB
scripts/references/chart-templates/chart-7.jsonconfig5.9 KB
scripts/references/chart-templates/chart-8.jsonconfig5.9 KB
scripts/references/chart-templates/chart-9.jsonconfig6.3 KB
scripts/secure-fill.mjsscript38.0 KB
scripts/templates/hancom_native_stub.hwpxbinary128.0 KB
scripts/unpack.pyexecutablescript2.5 KB
scripts/validate.pyexecutablescript3.7 KB
themes/arctic-frost.mdmarkdown777 B
themes/botanical-garden.mdmarkdown751 B
themes/desert-rose.mdmarkdown748 B
themes/forest-canopy.mdmarkdown755 B
themes/golden-hour.mdmarkdown778 B
themes/midnight-galaxy.mdmarkdown766 B
themes/modern-minimalist.mdmarkdown766 B
themes/ocean-depths.mdmarkdown758 B
themes/sunset-boulevard.mdmarkdown811 B
themes/tech-innovation.mdmarkdown729 B

scripts/preview-server.js

View on GitHub
#!/usr/bin/env node
// preview-server.js — Tiny static + file-passthrough HTTP server that backs
// the Claude Code preview pane for HWP / HWPX files. All HWP parsing and
// rendering happens in the browser via the vendored rhwp WASM; this server
// only ships static assets and (on demand) the user's HWP bytes by absolute
// path.
//
// Wired to Claude's preview pane via .claude/launch.json — see SKILL.md.

import { createServer } from "node:http";
import { readFile } from "node:fs/promises";
import { existsSync, statSync } from "node:fs";
import path from "node:path";
import url from "node:url";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

// Port. Reads ONLY the claw-hwp-specific env var — deliberately NOT the generic
// `process.env.PORT`, which other tools/shells set freely: honoring it would move
// the server off 3737, the port Claude Code Desktop's preview pane auto-discovers
// (so the pane would silently go blank). Set CLAW_HWP_PREVIEW_PORT to override when
// 3737 is taken. (Cross-platform-safe as-is; do not "fix" this to add process.env.PORT.)
const PORT = Number(process.env.CLAW_HWP_PREVIEW_PORT || 3737);
const HOST = process.env.CLAW_HWP_PREVIEW_HOST || "127.0.0.1";

// Auto-shutdown: the viewer pings /__heartbeat every 30s while open. If no
// heartbeat (or any other request) arrives for IDLE_TIMEOUT_MS, the server
// kills itself. MIN_LIFETIME_MS keeps it alive long enough for the user to
// notice the chat link and click it even if no client ever connects.
const IDLE_TIMEOUT_MS = Number(process.env.CLAW_HWP_PREVIEW_IDLE_MS || 120_000);
const MIN_LIFETIME_MS = Number(process.env.CLAW_HWP_PREVIEW_MIN_LIFETIME_MS || 180_000);
const startTime = Date.now();
let lastActivity = startTime;
const touch = () => { lastActivity = Date.now(); };

// Files we know how to serve from the script directory. Anything outside
// this list is rejected so the server can't be used as a generic file
// browser even though it accepts absolute paths on /file (those go through
// a separate, narrower check).
const STATIC_ROUTES = {
  "/": ["preview-viewer.html", "text/html; charset=utf-8"],
  "/preview-viewer.js": ["preview-viewer.js", "application/javascript; charset=utf-8"],
  "/vendor/rhwp/rhwp.js": ["vendor/rhwp/rhwp.js", "application/javascript; charset=utf-8"],
  "/vendor/rhwp/rhwp_bg.wasm": ["vendor/rhwp/rhwp_bg.wasm", "application/wasm"],
};

function send(res, status, contentType, body, extraHeaders = {}) {
  res.writeHead(status, {
    "content-type": contentType,
    "cache-control": "no-store",
    ...extraHeaders,
  });
  res.end(body);
}

const ALLOWED_EXT = new Set([".hwp", ".hwpx"]);

const server = createServer(async (req, res) => {
  let parsed;
  try {
    parsed = new URL(req.url, `http://${HOST}:${PORT}`);
  } catch {
    return send(res, 400, "text/plain", "bad URL");
  }

  touch();

  // Liveness ping from the viewer — also resets the idle timer via touch()
  // above. Kept lightweight so a tab can fire it on a tight interval without
  // showing up in DevTools network noise too much.
  if (parsed.pathname === "/__heartbeat") {
    return send(res, 204, "text/plain", "");
  }

  // Explicit shutdown for ❌-style kill buttons or agent commands. Writes
  // the response first, then exits on the next tick so the client sees the
  // 204 before the socket closes.
  if (parsed.pathname === "/__shutdown" && req.method === "POST") {
    send(res, 204, "text/plain", "");
    setTimeout(() => process.exit(0), 50);
    return;
  }

  // Static assets — viewer page, vendored WASM/JS.
  const route = STATIC_ROUTES[parsed.pathname];
  if (route) {
    const [file, ct] = route;
    try {
      const data = await readFile(path.join(__dirname, file));
      return send(res, 200, ct, data);
    } catch (err) {
      return send(res, 500, "text/plain", `failed to read ${file}: ${err.message}`);
    }
  }

  // /file?path=<absolute path to .hwp / .hwpx>
  if (parsed.pathname === "/file") {
    const p = parsed.searchParams.get("path");
    if (!p) return send(res, 400, "text/plain", "missing ?path=");
    const abs = path.resolve(p);
    if (!existsSync(abs)) return send(res, 404, "text/plain", `not found: ${abs}`);
    const ext = path.extname(abs).toLowerCase();
    if (!ALLOWED_EXT.has(ext))
      return send(res, 415, "text/plain", `unsupported extension: ${ext}`);
    try {
      const stat = statSync(abs);
      const data = await readFile(abs);
      // x-filename must be ASCII (RFC 7230); percent-encode so Korean
      // filenames survive the round-trip. Client decodes via decodeURIComponent.
      return send(res, 200, "application/octet-stream", data, {
        "content-length": String(stat.size),
        "x-filename": encodeURIComponent(path.basename(abs)),
      });
    } catch (err) {
      return send(res, 500, "text/plain", `failed to read file: ${err.message}`);
    }
  }

  send(res, 404, "text/plain", "not found");
});

server.listen(PORT, HOST, () => {
  process.stderr.write(`claw-hwp preview server listening on http://${HOST}:${PORT}\n`);
});

setInterval(() => {
  const now = Date.now();
  if (now - startTime < MIN_LIFETIME_MS) return;
  if (now - lastActivity > IDLE_TIMEOUT_MS) {
    process.stderr.write(
      `claw-hwp preview server: idle for ${Math.round((now - lastActivity) / 1000)}s, shutting down\n`,
    );
    process.exit(0);
  }
}, 30_000).unref();
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall