create-posthuman 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/bin/create.mjs +72 -0
  4. package/package.json +32 -4
  5. package/template/AGENTS.md +207 -0
  6. package/template/CLAUDE.md +1 -0
  7. package/template/README.md +61 -0
  8. package/template/_env.example +9 -0
  9. package/template/_gitignore +5 -0
  10. package/template/_mcp.json +8 -0
  11. package/template/brand/about.md +22 -0
  12. package/template/brand/accounts.md +7 -0
  13. package/template/brand/sources.md +10 -0
  14. package/template/brand/voice.md +19 -0
  15. package/template/ideas/_template.md +8 -0
  16. package/template/ideas/inbox.md +5 -0
  17. package/template/library/INDEX.md +7 -0
  18. package/template/posts/_template.md +24 -0
  19. package/template/recipes/README.md +14 -0
  20. package/template/recipes/empty-days.md +23 -0
  21. package/template/recipes/humanize.md +32 -0
  22. package/template/recipes/photo-to-video.md +25 -0
  23. package/template/recipes/voiceover.md +29 -0
  24. package/template/recipes/weekly-batch.md +22 -0
  25. package/template/tools/account-rules.mjs +144 -0
  26. package/template/tools/brands.mjs +141 -0
  27. package/template/tools/fal.mjs +82 -0
  28. package/template/tools/humanize-rules.mjs +86 -0
  29. package/template/tools/humanize.mjs +84 -0
  30. package/template/tools/knowyou.mjs +240 -0
  31. package/template/tools/length-rules.mjs +76 -0
  32. package/template/tools/lib.mjs +84 -0
  33. package/template/tools/mix.mjs +37 -0
  34. package/template/tools/post-rules.mjs +99 -0
  35. package/template/tools/sources.mjs +196 -0
  36. package/template/tools/studio-accounts.mjs +132 -0
  37. package/template/tools/studio-more.mjs +254 -0
  38. package/template/tools/studio-stuff.mjs +104 -0
  39. package/template/tools/studio.html +1183 -0
  40. package/template/tools/studio.mjs +614 -0
  41. package/template/tools/substance-rules.mjs +37 -0
  42. package/template/tools/substance.mjs +37 -0
  43. package/template/tools/topic-rules.mjs +43 -0
  44. package/template/tools/vertical.mjs +60 -0
  45. package/template/tools/voice.mjs +56 -0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ // The substance check from the command line: does each post give the reader something?
3
+ //
4
+ // node tools/substance.mjs posts/*.md flags per post (exit 1 if any)
5
+ //
6
+ // Run it before the humanize pass (tools/humanize.mjs). Rules and the five kinds: tools/substance-rules.mjs.
7
+
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ import { listOf, parsePost } from "./post-rules.mjs";
12
+ import { substance } from "./substance-rules.mjs";
13
+ export { GIVES, substance } from "./substance-rules.mjs";
14
+
15
+ /** gives / payload / media and the main words from a post file. */
16
+ export function readPost(file) {
17
+ const p = parsePost(fs.readFileSync(file, "utf8"));
18
+ return { gives: p.front.gives ?? "", payload: p.front.payload ?? "", media: listOf(p.front.media), words: p.everywhere };
19
+ }
20
+
21
+ const HERE = fileURLToPath(import.meta.url);
22
+ if (process.argv[1] && path.resolve(process.argv[1]) === HERE) {
23
+ const files = process.argv.slice(2).filter((f) => !path.basename(f).startsWith("_"));
24
+ if (!files.length) {
25
+ console.error("Usage: node tools/substance.mjs posts/file.md [more…]");
26
+ process.exit(2);
27
+ }
28
+ let any = 0;
29
+ for (const f of files) {
30
+ const p = readPost(f);
31
+ const flags = substance(p);
32
+ any += flags.length;
33
+ console.log(flags.length ? `${f}: ${flags.length} to look at` : `${f}: gives ${p.gives} (${p.payload})`);
34
+ for (const x of flags) console.log(` - ${x.issue}. ${x.fix}`);
35
+ }
36
+ process.exit(any ? 1 : 0);
37
+ }
@@ -0,0 +1,43 @@
1
+ // Topics: the few things the brand posts about, from brand/about.md (## Topics, or ## Pillars), so each post can say
2
+ // which one it is (frontmatter `topic:`) and the week can keep its mix. Pure, so the page and tools agree.
3
+ //
4
+ // ## Topics ## Pillars (about 6–7 posts a week)
5
+ // - Building the app (~3 a week) 1. Building in public (~7): Posthuman, Kitchen Table…
6
+ // - Behind the scenes 2. AI agents doing the work (~3): overnight runs…
7
+ //
8
+ // A number like "~3" is how many a week the user wants of it (optional).
9
+
10
+ /** [{ name, per_week|null }] from the about file's Topics or Pillars section. */
11
+ export function topicsOf(about = "") {
12
+ const m = String(about).replace(/\r/g, "").match(/^## (?:Topics|Pillars)[^\n]*\n([\s\S]*?)(?=^## |(?![\s\S]))/m);
13
+ if (!m) return [];
14
+ return m[1]
15
+ .split("\n")
16
+ .map((l) => l.match(/^\s*(?:[-*]|\d+[.)])\s+(.+)$/)?.[1])
17
+ .filter(Boolean)
18
+ .map((l) => {
19
+ const per = l.match(/\(~?\s*(\d+)[^)]*\)/);
20
+ const name = l.split(/\s*[(:]/)[0].replace(/\*\*/g, "").trim();
21
+ return { name, per_week: per ? Number(per[1]) : null };
22
+ })
23
+ .filter((t) => t.name && !t.name.startsWith("<!--"));
24
+ }
25
+
26
+ /** The topic a post's `topic:` names, matched loosely ("building" → "Building in public"). */
27
+ export function matchTopic(value, topics) {
28
+ const v = String(value || "").trim().toLowerCase();
29
+ if (!v) return null;
30
+ return topics.find((t) => t.name.toLowerCase() === v) || topics.find((t) => t.name.toLowerCase().startsWith(v) || v.startsWith(t.name.toLowerCase())) || topics.find((t) => t.name.toLowerCase().includes(v)) || null;
31
+ }
32
+
33
+ /** This week's mix: [{ name, count, per_week }] plus posts with no topic. */
34
+ export function mixOf(posts, topics) {
35
+ const out = topics.map((t) => ({ name: t.name, count: 0, per_week: t.per_week }));
36
+ let none = 0;
37
+ for (const p of posts) {
38
+ const t = matchTopic(p.topic, topics);
39
+ if (t) out.find((x) => x.name === t.name).count++;
40
+ else none++;
41
+ }
42
+ return { mix: out, none };
43
+ }
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ // Make a wide clip or photo fit Reels, TikTok, Shorts (9:16) or an Instagram picture (4:5, 1:1). Free, with ffmpeg.
3
+ //
4
+ // node tools/vertical.mjs library/clip.mp4 9:16, the clip sharp over a blurred copy of itself
5
+ // node tools/vertical.mjs library/clip.mp4 --fit crop 9:16, cut to fill (loses the sides)
6
+ // node tools/vertical.mjs library/photo.png --size 4:5 an Instagram picture
7
+ // ... [--out library/name.mp4] [--dry]
8
+ //
9
+ // blur (the default) keeps the whole picture: nothing important gets cut off. crop fills the frame but cuts the
10
+ // sides of a wide clip, so only use it when the thing is in the middle. The sound is kept. The new file goes next to
11
+ // the old one (`-vertical`, `-4x5`, `-square`) with a line in library/INDEX.md. Needs ffmpeg (ffmpeg -version).
12
+
13
+ import { spawnSync } from "node:child_process";
14
+ import fs from "node:fs";
15
+ import path from "node:path";
16
+ import { addToLibrary, fail, parseArgs } from "./lib.mjs";
17
+
18
+ export const SIZES = { "9:16": { w: 1080, h: 1920, tag: "vertical" }, "4:5": { w: 1080, h: 1350, tag: "4x5" }, "1:1": { w: 1080, h: 1080, tag: "square" } };
19
+ const PICTURE = /\.(jpe?g|png|webp)$/i;
20
+
21
+ /** ffmpeg's arguments for one file (pure, so the test can read them). */
22
+ export function verticalArgs(input, out, { size = "9:16", fit = "blur" } = {}) {
23
+ const s = SIZES[size];
24
+ if (!s) throw new Error(`--size is one of ${Object.keys(SIZES).join(", ")}.`);
25
+ if (!["blur", "crop"].includes(fit)) throw new Error("--fit is blur or crop.");
26
+ const { w, h } = s;
27
+ const fill = `scale=${w}:${h}:force_original_aspect_ratio=increase,crop=${w}:${h}`;
28
+ const filter = fit === "crop" ? `[0:v]${fill},setsar=1[v]` : `[0:v]${fill},boxblur=30:3,eq=brightness=-0.06[bg];[0:v]scale=${w}:${h}:force_original_aspect_ratio=decrease[fg];[bg][fg]overlay=(W-w)/2:(H-h)/2,setsar=1[v]`;
29
+ const picture = PICTURE.test(input);
30
+ return picture
31
+ ? ["-y", "-i", input, "-filter_complex", filter, "-map", "[v]", "-frames:v", "1", out]
32
+ : ["-y", "-i", input, "-filter_complex", filter, "-map", "[v]", "-map", "0:a?", "-c:v", "libx264", "-crf", "20", "-preset", "medium", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "192k", "-movflags", "+faststart", out];
33
+ }
34
+
35
+ if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(new URL(import.meta.url).pathname)) {
36
+ const a = parseArgs(process.argv.slice(2));
37
+ const input = a._[0];
38
+ if (!input) fail("Usage: node tools/vertical.mjs library/clip.mp4 [--size 9:16|4:5|1:1] [--fit blur|crop] [--out library/name.mp4]");
39
+ if (!fs.existsSync(input)) fail(`No such file: ${input}`);
40
+ const size = typeof a.size === "string" ? a.size : "9:16";
41
+ const fit = typeof a.fit === "string" ? a.fit : "blur";
42
+ const ext = path.extname(input);
43
+ const out = typeof a.out === "string" ? a.out : path.join(path.dirname(input), `${path.basename(input, ext)}-${SIZES[size]?.tag ?? "x"}${ext}`);
44
+ let args;
45
+ try {
46
+ args = verticalArgs(String(input), String(out), { size, fit });
47
+ } catch (e) {
48
+ fail(e.message);
49
+ }
50
+ if (a.dry) {
51
+ console.log(["ffmpeg", ...args.map((x) => (/[\s;\[\]=:,]/.test(x) ? `'${x}'` : x))].join(" "));
52
+ process.exit(0);
53
+ }
54
+ if (spawnSync("ffmpeg", ["-version"]).error) fail("ffmpeg isn't installed. Install it from your package manager, then try again.");
55
+ fs.mkdirSync(path.dirname(path.resolve(out)), { recursive: true });
56
+ const r = spawnSync("ffmpeg", args, { encoding: "utf8" });
57
+ if (r.status !== 0) fail(`ffmpeg failed:\n${(r.stderr || "").split("\n").slice(-12).join("\n")}`);
58
+ addToLibrary(out, `${path.basename(input)} as ${size}${fit === "blur" ? ", over a blurred copy of itself" : ", cropped to fill"}`, "ffmpeg (tools/vertical.mjs)");
59
+ console.log(JSON.stringify({ saved: path.resolve(out), size, fit }, null, 2));
60
+ }
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ // ElevenLabs: a voiceover from a script, or a list of your voices.
3
+ //
4
+ // node tools/voice.mjs --list
5
+ // node tools/voice.mjs --text-file posts/2026-11-24-slug.script.txt --out library/2026-11-24-voice.mp3 [--voice <id>] [--model eleven_v4] [--dry]
6
+ // node tools/voice.mjs --text "Short line to read" --out library/line.mp3
7
+ // node tools/voice.mjs --sfx "a page turning, quiet room" --seconds 3 --out library/page.mp3
8
+ //
9
+ // The voice comes from --voice or ELEVENLABS_VOICE_ID in .env. ElevenLabs hands back the audio itself, saved to --out.
10
+ // Put it on a clip with ffmpeg (recipes/voiceover.md). Checked against ElevenLabs' docs 2026-11-20.
11
+
12
+ import fs from "node:fs";
13
+ import { addToLibrary, fail, key, need, parseArgs, save } from "./lib.mjs";
14
+
15
+ const a = parseArgs(process.argv.slice(2));
16
+ const API = "https://api.elevenlabs.io";
17
+
18
+ if (a.list) {
19
+ const KEY = need("ELEVENLABS_API_KEY", "elevenlabs.io (Developers → API keys)");
20
+ const r = await fetch(`${API}/v2/voices?page_size=100`, { headers: { "xi-api-key": KEY } });
21
+ if (!r.ok) fail(`ElevenLabs said ${r.status}: ${(await r.text()).slice(0, 400)}`);
22
+ const { voices = [] } = await r.json();
23
+ for (const v of voices) console.log(`${v.voice_id} ${v.name}${v.labels ? ` (${Object.values(v.labels).join(", ")})` : ""}`);
24
+ process.exit(0);
25
+ }
26
+
27
+ if (!a.out) fail("Say where to save it: --out library/name.mp3");
28
+
29
+ let url, body, what;
30
+ if (a.sfx) {
31
+ const seconds = a.seconds ? Number(a.seconds) : undefined;
32
+ if (seconds !== undefined && !(seconds >= 0.5 && seconds <= 30)) fail("--seconds is 0.5 to 30.");
33
+ url = `${API}/v1/sound-generation?output_format=mp3_44100_128`;
34
+ body = { text: String(a.sfx), ...(seconds ? { duration_seconds: seconds } : {}) };
35
+ what = `Sound: ${a.sfx}`;
36
+ } else {
37
+ const text = a["text-file"] ? fs.readFileSync(String(a["text-file"]), "utf8").trim() : typeof a.text === "string" ? a.text.trim() : "";
38
+ if (!text) fail("Give it the words: --text-file path or --text \"…\"");
39
+ const voice = typeof a.voice === "string" ? a.voice : key("ELEVENLABS_VOICE_ID");
40
+ if (!voice) fail("Which voice? --voice <id>, or ELEVENLABS_VOICE_ID in .env (node tools/voice.mjs --list shows yours).");
41
+ url = `${API}/v1/text-to-speech/${encodeURIComponent(voice)}?output_format=mp3_44100_128`;
42
+ body = { text, model_id: typeof a.model === "string" ? a.model : "eleven_v4" };
43
+ what = `Voiceover: ${text.slice(0, 80)}${text.length > 80 ? "…" : ""}`;
44
+ }
45
+
46
+ if (a.dry) {
47
+ console.log(JSON.stringify({ post: url, body, out: a.out, characters: body.text.length }, null, 2));
48
+ process.exit(0);
49
+ }
50
+
51
+ const KEY = need("ELEVENLABS_API_KEY", "elevenlabs.io (Developers → API keys)");
52
+ const r = await fetch(url, { method: "POST", headers: { "xi-api-key": KEY, "Content-Type": "application/json", Accept: "audio/mpeg" }, body: JSON.stringify(body) });
53
+ if (!r.ok) fail(`ElevenLabs said ${r.status}: ${(await r.text()).slice(0, 600)}`);
54
+ const saved = save(String(a.out), Buffer.from(await r.arrayBuffer()));
55
+ addToLibrary(saved, what, a.sfx ? "ElevenLabs sound effects" : `ElevenLabs ${body.model_id}`);
56
+ console.log(JSON.stringify({ saved, characters: body.text.length }, null, 2));