Lines 24-88javascript
24 * → migrateTasksToTopLevel — silently moves legacy .kandown/tasks/ → ./tasks/
25 * → cmdInit — installs `.kandown` and top-level `tasks/`
26 * → cmdUpdate — refreshes installed kandown.html
27 * → injectServerRoot — injects the CLI server root into single-file HTML
28 * → createServeServer — creates the local zero-dependency HTTP server
29 * → readDaemonMetadata — reads per-project daemon status metadata
30 * → startDaemon — starts/reconnects the per-project web daemon
31 * → stopDaemon — stops the per-project web daemon
32 * → cmdDaemon — daemon lifecycle command router
33 * → cmdServe — starts/reconnects the daemon, opens web UI, and launches the board TUI
34 * → main — dispatches CLI commands
38/* eslint-disable no-console */
39// 📖 DEV=false prevents Ink from loading react-devtools-core (CJS-only, breaks ESM).
40// Must be set BEFORE any imports because ESM hoists all import statements.
41process.env.DEV = 'false';
42// 📖 Polyfill browser globals that some bundled modules expect.
43if (typeof globalThis.self === 'undefined') Object.defineProperty(globalThis, 'self', { value: globalThis });
44if (typeof globalThis.window === 'undefined') Object.defineProperty(globalThis, 'window', { value: globalThis });
45// 📖 Make require() available in this ESM module so bundled __require() shims work.
46// tsup's __require checks `typeof require !== "undefined"` — this makes it truthy.
MediumDynamic Require
Package source references dynamic require/import behavior.
bin/kandown.jsView on unpkg · L44 47import { createRequire } from 'node:module';
48globalThis.require = createRequire(import.meta.url);
50import { fileURLToPath } from 'node:url';
51import { createServer } from 'node:http';
52import { dirname, join, resolve } from 'node:path';
53import { homedir } from 'node:os';
69import { spawn, execSync } from 'node:child_process';
70import { createConnection } from 'node:net';
HighChild Process
Package source references child process execution.
bin/kandown.jsView on unpkg · L68 71import { randomBytes } from 'node:crypto';
73// 📖 Global safety net: a stray exception or unhandled rejection prints a clean
74// one-liner instead of a raw stack trace. The daemon (KANDOWN_DAEMON=1) logs
75// and keeps serving — a single bad request must not take the web UI down.
76// Set KANDOWN_DEBUG=1 to get the full stack.
77function handleFatal(kind, e) {
78 const msg = e instanceof Error ? e.message : String(e);
79 console.error(`\x1b[31m✗\x1b[0m kandown ${kind}: ${msg}`);
80 if (process.env.KANDOWN_DEBUG && e instanceof Error) console.error(e.stack);
81 if (process.env.KANDOWN_DAEMON !== '1') process.exit(1);
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
bin/kandown.jsView on unpkg · L68 83process.on('uncaughtException', (e) => handleFatal('crashed', e));
84process.on('unhandledRejection', (e) => handleFatal('internal error', e));
86const __filename = fileURLToPath(import.meta.url);
87const __dirname = dirname(__filename);
88const PKG_ROOT = resolve(__dirname, '..');