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.
- package/LICENSE +21 -0
- package/README.md +32 -2
- package/bin/create.mjs +72 -0
- package/package.json +32 -4
- package/template/AGENTS.md +207 -0
- package/template/CLAUDE.md +1 -0
- package/template/README.md +61 -0
- package/template/_env.example +9 -0
- package/template/_gitignore +5 -0
- package/template/_mcp.json +8 -0
- package/template/brand/about.md +22 -0
- package/template/brand/accounts.md +7 -0
- package/template/brand/sources.md +10 -0
- package/template/brand/voice.md +19 -0
- package/template/ideas/_template.md +8 -0
- package/template/ideas/inbox.md +5 -0
- package/template/library/INDEX.md +7 -0
- package/template/posts/_template.md +24 -0
- package/template/recipes/README.md +14 -0
- package/template/recipes/empty-days.md +23 -0
- package/template/recipes/humanize.md +32 -0
- package/template/recipes/photo-to-video.md +25 -0
- package/template/recipes/voiceover.md +29 -0
- package/template/recipes/weekly-batch.md +22 -0
- package/template/tools/account-rules.mjs +144 -0
- package/template/tools/brands.mjs +141 -0
- package/template/tools/fal.mjs +82 -0
- package/template/tools/humanize-rules.mjs +86 -0
- package/template/tools/humanize.mjs +84 -0
- package/template/tools/knowyou.mjs +240 -0
- package/template/tools/length-rules.mjs +76 -0
- package/template/tools/lib.mjs +84 -0
- package/template/tools/mix.mjs +37 -0
- package/template/tools/post-rules.mjs +99 -0
- package/template/tools/sources.mjs +196 -0
- package/template/tools/studio-accounts.mjs +132 -0
- package/template/tools/studio-more.mjs +254 -0
- package/template/tools/studio-stuff.mjs +104 -0
- package/template/tools/studio.html +1183 -0
- package/template/tools/studio.mjs +614 -0
- package/template/tools/substance-rules.mjs +37 -0
- package/template/tools/substance.mjs +37 -0
- package/template/tools/topic-rules.mjs +43 -0
- package/template/tools/vertical.mjs +60 -0
- package/template/tools/voice.mjs +56 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Humanize: the last pass before the user sees a draft
|
|
2
|
+
|
|
3
|
+
**Needs:** nothing (the check is free; the rewrite uses your agent)
|
|
4
|
+
**When:** every draft, after the substance check (`tools/substance.mjs`), as the final step before you show it to the user. Studio's **Humanize** button runs the same pass.
|
|
5
|
+
|
|
6
|
+
## Steps
|
|
7
|
+
1. Run the check: `node tools/humanize.mjs posts/<file>.md`. Every flag is something to look at again.
|
|
8
|
+
2. Fix each flag the way it says. A flag can stay only if it's really how the user talks (check brand/voice.md and
|
|
9
|
+
their past posts), and then say so in the post's Notes.
|
|
10
|
+
3. Then simplify, even if nothing was flagged:
|
|
11
|
+
- **Say it out loud.** If it sounds like reading, rewrite it until it sounds like talking.
|
|
12
|
+
- **Cut about a fifth.** First words to go: intros, "really", "just", "actually", the line that explains the joke.
|
|
13
|
+
- **Plain words.** "use", not "leverage". "fix", not "address". Contractions: "it's", "I'm", "didn't".
|
|
14
|
+
- **One real detail** beats three general ones: the number, the name, the thing that actually happened.
|
|
15
|
+
- **End the way brand/voice.md says.** A real question people can answer if the voice asks for one (never a
|
|
16
|
+
generic "thoughts?"), otherwise the twist. Never a summary or a tidy moral.
|
|
17
|
+
- **Uneven is fine.** Real people write one short line, then a longer one. Don't make every line the same length.
|
|
18
|
+
4. Never add facts, numbers or moments that aren't true to make it livelier. Funnier, not falser. And keep the post's `payload:`: simplifying must never cut the real thing the post gives.
|
|
19
|
+
5. Run the check again. Clean, or every flag explained.
|
|
20
|
+
|
|
21
|
+
## The usual giveaways (what the check looks for)
|
|
22
|
+
Dashes used like commas · "it's not X, it's Y" · "not just X but Y" · delve, leverage, unlock, seamless,
|
|
23
|
+
game-changer, journey · "here's the thing", "let that sink in", "the best part?" · opening with "Ever wondered" ·
|
|
24
|
+
🚀 ✨ 🔥 🧵 · "…" for drama · more than one "!" · "thoughts?", "follow for more" · hashtags outside Mastodon ·
|
|
25
|
+
sentences over 28 words · tech words a non-coder wouldn't get.
|
|
26
|
+
|
|
27
|
+
## What's theirs (read from the folder)
|
|
28
|
+
- **brand/voice.md:** a phrase quoted under *Never do* (Don't end with "tell me what's bad"), or quoted after a
|
|
29
|
+
no or never anywhere else (Skip the fancy word ("gratifying")). And when the voice says every post ends with an
|
|
30
|
+
ask, a post with no question at the end of it.
|
|
31
|
+
- **brand/accounts.md and the platform:** each account's words against its hard no's and its length. X counts a
|
|
32
|
+
link as 23 and an emoji as 2; on X, Bluesky, Mastodon and Threads each part of a thread has to fit.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Photo → short video
|
|
2
|
+
|
|
3
|
+
**Needs:** `FAL_KEY` in `.env` · a photo of the user's own (product, table, shop) · Posthuman connected
|
|
4
|
+
**Costs:** about 55¢ to $2 per 5-second clip, paid to fal. Kling 3 Pro is about 11¢ a second without sound, Veo 3.1
|
|
5
|
+
about 40¢ a second with sound.
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
1. Get the photo into `library/` (copy it in, named `YYYY-MM-DD-slug.jpg`) and describe it in one sentence.
|
|
9
|
+
2. Ask the user for the motion in a few words: a slow push-in, steam rising, pages turning. Keep everything in the
|
|
10
|
+
photo as it is and only add the motion.
|
|
11
|
+
3. Make it (check the model's API tab first if this is the first run in a while):
|
|
12
|
+
```
|
|
13
|
+
node tools/fal.mjs fal-ai/kling-video/v3/pro/image-to-video \
|
|
14
|
+
--file image_url=library/2026-11-24-mug.jpg \
|
|
15
|
+
--input '{"prompt":"slow push-in, steam rising from the mug, everything else still","duration":"5"}' \
|
|
16
|
+
--out library/2026-11-24-mug.mp4 --what "A mug of coffee on the worksheet, steam rising"
|
|
17
|
+
```
|
|
18
|
+
4. Show the user. If they like it, hand Posthuman the `link` from the output **straight away** with
|
|
19
|
+
`add_media_from_url` (fal's links don't last). If it's gone, use `request_upload_link` and POST the saved file.
|
|
20
|
+
5. Write the post file in `posts/`, with words in the brand's voice. Schedule it to TikTok and Instagram with
|
|
21
|
+
`made_with_ai: true`. Ask who can see it on TikTok, since TikTok has no default.
|
|
22
|
+
|
|
23
|
+
## Watch out
|
|
24
|
+
- A real photo with motion looks like the user. A clip invented from nothing looks like everyone else's.
|
|
25
|
+
- Vertical photos make vertical clips. Crop to 9:16 first if it's for TikTok or Reels.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Voiceover on your own clip
|
|
2
|
+
|
|
3
|
+
**Needs:** `ELEVENLABS_API_KEY` and `ELEVENLABS_VOICE_ID` in `.env` · ffmpeg (`ffmpeg -version`) · a clip of the
|
|
4
|
+
user's own · Posthuman connected. For a business, a paid ElevenLabs plan. The free plan doesn't allow commercial use.
|
|
5
|
+
**Costs:** a few cents per clip on most plans (ElevenLabs counts characters of script).
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
1. Put the clip in `library/`. Note how long it is (`ffprobe -v error -show_entries format=duration -of csv=p=0 file`).
|
|
9
|
+
2. Write a script in the brand's voice that fits the clip: about 2.5 words a second, so 20 seconds is about 50 words.
|
|
10
|
+
Save it next to the post as `posts/YYYY-MM-DD-slug.script.txt`. **Show the user and wait for their OK.**
|
|
11
|
+
3. Make the voice (no voice picked yet? `node tools/voice.mjs --list`, then ask the user):
|
|
12
|
+
```
|
|
13
|
+
node tools/voice.mjs --text-file posts/2026-11-24-slug.script.txt --out library/2026-11-24-slug-voice.mp3
|
|
14
|
+
```
|
|
15
|
+
4. Put it on the clip, with the clip's own sound quietly underneath:
|
|
16
|
+
```
|
|
17
|
+
node tools/mix.mjs --video library/2026-11-24-slug.mp4 --audio library/2026-11-24-slug-voice.mp3 \
|
|
18
|
+
--out library/2026-11-24-slug-voiced.mp4
|
|
19
|
+
```
|
|
20
|
+
5. Get an upload link from Posthuman (`request_upload_link`), POST the file to it, and schedule with the `media_id`
|
|
21
|
+
it returns, to Reels and TikTok with `made_with_ai: true`:
|
|
22
|
+
```
|
|
23
|
+
curl -X POST --data-binary @library/2026-11-24-slug-voiced.mp4 -H "Content-Type: video/mp4" "<upload link>"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Watch out
|
|
27
|
+
- An AI voice counts as AI-made, so set `made_with_ai: true`. Use a voice the user has the right to use. ElevenLabs'
|
|
28
|
+
library voices are fine on a paid plan.
|
|
29
|
+
- Sound effects instead of a voice: `node tools/voice.mjs --sfx "a page turning, quiet room" --seconds 3 --out …`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Weekly batch (once a week, about 20–30 minutes of the user's time)
|
|
2
|
+
|
|
3
|
+
**Needs:** Posthuman connected
|
|
4
|
+
**Costs:** whatever the platforms charge to post (X is about 1.5¢ a post, 20¢ with a link). Nothing for the drafting.
|
|
5
|
+
|
|
6
|
+
## Steps
|
|
7
|
+
1. `briefing`: what's already scheduled, the empty days, and how last week did (`get_results`). Anything that
|
|
8
|
+
clearly beat the usual goes under *What worked* in brand/voice.md, and `remember` it on that account.
|
|
9
|
+
2. **Raw material first.** Gather what's there: `node tools/sources.mjs` (new pictures and clips in their folders,
|
|
10
|
+
each project's commits this week), what they saved for later on their phone (`list_media saved_only`, or Studio's
|
|
11
|
+
**Bring in from your phone**), and raw/<sunday>.md. Add the open lines from ideas/inbox.md.
|
|
12
|
+
3. **Their pick.** Show it all in one message as a short list, ask for what's missing of three real things (a
|
|
13
|
+
screenshot, a number, something that happened), and ask which ones they want posts about this week and how each
|
|
14
|
+
should come across. Wait. They pick the angles; you don't fill the week with your own (AGENTS.md, *The angle is
|
|
15
|
+
theirs*). The repeating posts they already said yes to go in as usual.
|
|
16
|
+
4. For each one they picked: what it **gives** (story / tip / number / show / opinion) and its **payload**, then the
|
|
17
|
+
words, one file each in posts/, in brand/voice.md's voice. Building posts get their screenshot. They gave a topic
|
|
18
|
+
but not the feel? Write two short takes and let them pick.
|
|
19
|
+
5. `node tools/substance.mjs posts/*.md`, then the humanize pass (recipes/humanize.md) on each: it also catches their own no's and anything too long.
|
|
20
|
+
6. Show the user the week in one list (day, time, what it gives, first line), or tell them to open Studio
|
|
21
|
+
(`node tools/studio.mjs`). Their edits are the voice: learn from them.
|
|
22
|
+
7. Schedule what they approve (`status: approved`) through Posthuman and write each `posthuman_post_id` into its file.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Each account's setup ("Make it yours" in Posthuman: who reads it, how the user sounds there, what goes there, how
|
|
2
|
+
// often, the hard no's, a post that's so them), as the local copy in brand/accounts.md. Posthuman holds the real one;
|
|
3
|
+
// the agent refreshes this copy from the briefing each session (or Studio's Refresh). Pure, so Studio's page and the
|
|
4
|
+
// tools read it the same way.
|
|
5
|
+
//
|
|
6
|
+
// ## X @mybrand
|
|
7
|
+
// - account_id: 12
|
|
8
|
+
// - who reads it: indie devs and people building on the side
|
|
9
|
+
// - sounds: short and dry, a punchline at the end
|
|
10
|
+
// - what goes here: its own posts, written for here
|
|
11
|
+
// - how often: one a day, evenings
|
|
12
|
+
// - never: hashtags; naming my day job, Acme
|
|
13
|
+
// - like this: Day 3 of building after the kids go to bed…
|
|
14
|
+
// - posts so far: 46 (how many past posts Posthuman has for it; 0 = a brand-new account, see introFor)
|
|
15
|
+
|
|
16
|
+
const KEYS = { account_id: "account_id", "posts so far": "posts", "who reads it": "who_reads_it", sounds: "sounds", "what goes here": "what_goes_here", "how often": "how_often", never: "never", "like this": "like_this" };
|
|
17
|
+
|
|
18
|
+
export function parseAccounts(text = "") {
|
|
19
|
+
const out = [];
|
|
20
|
+
let cur = null;
|
|
21
|
+
let inComment = false;
|
|
22
|
+
for (const line of String(text).replace(/\r/g, "").split("\n")) {
|
|
23
|
+
if (inComment || /^\s*<!--/.test(line)) {
|
|
24
|
+
inComment = !line.includes("-->");
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const h = line.match(/^## +(.+?)\s*$/);
|
|
28
|
+
if (h) {
|
|
29
|
+
out.push((cur = { account: h[1].trim(), setup: null, posts: null }));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const kv = cur && line.match(/^\s*[-*]\s*([a-z_ ]+):\s*(.*)$/i);
|
|
33
|
+
if (!kv) continue;
|
|
34
|
+
const k = KEYS[kv[1].trim().toLowerCase()];
|
|
35
|
+
if (!k) continue;
|
|
36
|
+
if (k === "account_id") cur.account_id = Number(kv[2]) || null;
|
|
37
|
+
else if (k === "posts") cur.posts = /^\d+$/.test(kv[2].trim()) ? Number(kv[2]) : null;
|
|
38
|
+
else if (/^not yet/i.test(kv[2])) continue;
|
|
39
|
+
else {
|
|
40
|
+
cur.setup ??= {};
|
|
41
|
+
cur.setup[k] = k === "never" ? kv[2].split(kv[2].includes(";") ? ";" : ",").map((s) => s.trim()).filter(Boolean) : kv[2].trim();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The file from the briefing's accounts: [{ account_id, account, setup }] (setup = the briefing's object, or "not yet"). */
|
|
48
|
+
export function writeAccounts(accounts, { url = "", now = new Date() } = {}) {
|
|
49
|
+
const line = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
|
|
50
|
+
const one = (a) => {
|
|
51
|
+
const s = a.setup && typeof a.setup === "object" ? a.setup : null;
|
|
52
|
+
return [
|
|
53
|
+
`## ${line(a.account)}`,
|
|
54
|
+
a.account_id ? `- account_id: ${a.account_id}` : "",
|
|
55
|
+
Number.isInteger(a.past_posts ?? a.posts) ? `- posts so far: ${a.past_posts ?? a.posts}` : "",
|
|
56
|
+
...(s
|
|
57
|
+
? [
|
|
58
|
+
s.who_reads_it && `- who reads it: ${line(s.who_reads_it)}`,
|
|
59
|
+
s.sounds && `- sounds: ${line(s.sounds)}`,
|
|
60
|
+
s.what_goes_here && `- what goes here: ${line(s.what_goes_here)}`,
|
|
61
|
+
s.how_often && `- how often: ${line(s.how_often)}`,
|
|
62
|
+
s.never?.length && `- never: ${[].concat(s.never).map(line).join("; ")}`,
|
|
63
|
+
s.like_this && `- like this: ${line(s.like_this)}`,
|
|
64
|
+
]
|
|
65
|
+
: ["- not yet: ask the setup questions (AGENTS.md, Accounts)"]),
|
|
66
|
+
]
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join("\n");
|
|
69
|
+
};
|
|
70
|
+
return `# Accounts
|
|
71
|
+
|
|
72
|
+
How each account works, as the user set it up in Posthuman ("Make it yours"). This is a copy: your agent refreshes
|
|
73
|
+
it from Posthuman's briefing. To change it, change it in Posthuman${url ? ` (${url.replace(/\/$/, "")}/accounts)` : ""} or ask your agent, which suggests the change there.
|
|
74
|
+
|
|
75
|
+
<!-- refreshed ${now.toISOString().slice(0, 16).replace("T", " ")} UTC -->
|
|
76
|
+
|
|
77
|
+
${accounts.map(one).join("\n\n")}
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Which setup belongs to a post's account line ("x @mybrand", "bluesky mybrand.bsky.social"). */
|
|
82
|
+
export function setupFor(acct, accounts) {
|
|
83
|
+
const a = String(acct).toLowerCase();
|
|
84
|
+
const handle = (a.match(/@?[\w.-]+(?:@[\w.-]+)?$/) || [""])[0].replace(/^@/, "");
|
|
85
|
+
return (
|
|
86
|
+
accounts.find((x) => x.account.toLowerCase() === a) ||
|
|
87
|
+
accounts.find((x) => handle && x.account.toLowerCase().replace(/@/g, "").includes(handle) && x.account.toLowerCase().split(/\s/)[0] === a.split(/\s/)[0]) ||
|
|
88
|
+
accounts.find((x) => handle && x.account.toLowerCase().replace(/@/g, "").includes(handle)) ||
|
|
89
|
+
null
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const EMOJI = /\p{Extended_Pictographic}/u;
|
|
94
|
+
/** Words that break an account's hard no's: [{ issue, fix }] like the other checks. The same rules as Posthuman's hints. */
|
|
95
|
+
export function fitCheck(setup, words) {
|
|
96
|
+
const out = [];
|
|
97
|
+
if (!setup?.never?.length || !words) return out;
|
|
98
|
+
const never = setup.never.map((n) => n.toLowerCase());
|
|
99
|
+
if (never.includes("hashtags") && /(^|\s)#[\p{L}\d_]+/u.test(words)) out.push({ issue: "hashtags, but this account says no hashtags", fix: "Take them out (or give this account its own words)." });
|
|
100
|
+
if (never.includes("links") && /https?:\/\/|\bwww\.\S+\.\S+/i.test(words)) out.push({ issue: "a link, but this account says no links", fix: "Take it out, or say where to find it in words." });
|
|
101
|
+
if (never.includes("emoji") && EMOJI.test(words)) out.push({ issue: "emoji, but this account says no emoji", fix: "Take them out." });
|
|
102
|
+
for (const n of setup.never) {
|
|
103
|
+
const m = n.match(/^naming\s+(.+)$/i);
|
|
104
|
+
if (!m) continue;
|
|
105
|
+
for (const w of m[1].split(",").map((x) => x.trim()).filter((x) => x.length > 1)) {
|
|
106
|
+
if (new RegExp(`(^|[^\\p{L}\\d])${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^\\p{L}\\d])`, "iu").test(words)) out.push({ issue: `names “${w}”, which this account never names`, fix: "Leave it out here." });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ---------- a brand-new account (AGENTS.md: "A new account says hello") ----------
|
|
113
|
+
// Search-first platforms: people find posts there by searching, so a hello reaches no one.
|
|
114
|
+
const SEARCH_FIRST = /pinterest|google/i;
|
|
115
|
+
|
|
116
|
+
/** Should this account get an intro? "yes", "skip" (search-first platform), or "" (not new, or we don't know).
|
|
117
|
+
* postAccounts: the account lines of every post file in posts/ (any status but dropped). */
|
|
118
|
+
export function introFor(a, all, postAccounts = []) {
|
|
119
|
+
if (a.posts !== 0) return ""; // only when Posthuman says it has no posts yet (null = an older copy: unknown)
|
|
120
|
+
// something is already written for it: same platform (setupFor alone would match "X @shop" to "Threads @shop")
|
|
121
|
+
const first = (s) => String(s).trim().toLowerCase().split(/\s+/)[0];
|
|
122
|
+
if (postAccounts.some((line) => first(line) === first(a.account) && setupFor(line, all) === a)) return "";
|
|
123
|
+
return SEARCH_FIRST.test(a.account) ? "skip" : "yes";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ---------- "you choose" (AGENTS.md: suggested setups, saved on the user's yes) ----------
|
|
127
|
+
export const ROLES = { own: "its own posts, written for here", copy: "the same posts as my main account", big: "only the big moments" };
|
|
128
|
+
|
|
129
|
+
/** The six answers as Posthuman's set_up_account takes them → the setup shape the briefing gives back. */
|
|
130
|
+
export function answersToSetup(x = {}) {
|
|
131
|
+
const line = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
|
|
132
|
+
const never = [x.no_hashtags && "hashtags", x.no_links && "links", x.no_emoji && "emoji", line(x.never_name) && `naming ${line(x.never_name)}`].filter(Boolean);
|
|
133
|
+
const s = { who_reads_it: line(x.audience), sounds: line(x.sound), what_goes_here: ROLES[x.role] || "", how_often: line(x.rhythm), never, like_this: String(x.example ?? "").trim() };
|
|
134
|
+
for (const k of Object.keys(s)) if (!s[k] || (Array.isArray(s[k]) && !s[k].length)) delete s[k];
|
|
135
|
+
return s;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Only the fields set_up_account takes, cleaned (what an agent suggested may carry anything). */
|
|
139
|
+
export function cleanAnswers(x = {}) {
|
|
140
|
+
const str = (s, n) => String(s ?? "").replace(/\s+/g, " ").trim().slice(0, n);
|
|
141
|
+
const out = { audience: str(x.audience, 200), sound: str(x.sound, 200), role: ROLES[x.role] ? x.role : "own", rhythm: str(x.rhythm, 120), never_name: str(x.never_name, 200), example: String(x.example ?? "").trim().slice(0, 600), no_hashtags: !!x.no_hashtags, no_links: !!x.no_links, no_emoji: !!x.no_emoji };
|
|
142
|
+
for (const k of ["audience", "sound", "rhythm", "never_name", "example"]) if (!out[k]) delete out[k];
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// More than one brand in one folder (AGENTS.md, "More than one brand").
|
|
3
|
+
//
|
|
4
|
+
// brand/ the main brand: about.md, voice.md, plus the files every brand shares (accounts.md, the
|
|
5
|
+
// copy of all your Posthuman accounts; sources.md, where your stuff is)
|
|
6
|
+
// brands/<name>/ another brand: its own about.md and voice.md (anything missing falls back to brand/)
|
|
7
|
+
//
|
|
8
|
+
// A post belongs to the brand in its `brand:` line. With none, to the brand whose about.md lists its accounts under
|
|
9
|
+
// "Accounts on Posthuman" (by account id, like "Instagram @shop (12)"), and otherwise to the main brand.
|
|
10
|
+
//
|
|
11
|
+
// node tools/brands.mjs the brands here, and which accounts each one has
|
|
12
|
+
// node tools/brands.mjs add "Kitchen Table" [--accounts 10,12,15]
|
|
13
|
+
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { parseAccounts } from "./account-rules.mjs";
|
|
18
|
+
import { fail, parseArgs } from "./lib.mjs";
|
|
19
|
+
import { listOf } from "./post-rules.mjs";
|
|
20
|
+
|
|
21
|
+
const HERE = fileURLToPath(import.meta.url);
|
|
22
|
+
const ROOT0 = path.resolve(path.dirname(HERE), "..");
|
|
23
|
+
const readIf = (f) => (fs.existsSync(f) ? fs.readFileSync(f, "utf8").replace(/\r/g, "") : "");
|
|
24
|
+
export const slugOf = (name) => String(name).toLowerCase().normalize("NFKD").replace(/[^\w\s-]/g, "").trim().replace(/[\s_]+/g, "-").replace(/-+/g, "-").slice(0, 40);
|
|
25
|
+
|
|
26
|
+
/** The account ids a brand's about.md lists under "Accounts on Posthuman": "(12)", "(account 12)", "account_id: 12". */
|
|
27
|
+
export function accountIdsIn(about) {
|
|
28
|
+
const sec = String(about).replace(/\r/g, "").match(/(?:^|\n)## Accounts on Posthuman\n([\s\S]*?)(?=\n## |$)/)?.[1] ?? "";
|
|
29
|
+
const clean = sec.replace(/<!--[\s\S]*?-->/g, "");
|
|
30
|
+
return [...new Set([...clean.matchAll(/\((?:account[ _]?(?:id)?:?\s*)?(\d+)\)|account[ _]id:?\s*(\d+)/gi)].map((m) => Number(m[1] || m[2])))];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** [{ slug, name, dir, ids }]: the main brand first (slug ""), then each folder in brands/. */
|
|
34
|
+
export function brandsOf(root = ROOT0) {
|
|
35
|
+
const one = (slug, dir) => {
|
|
36
|
+
const about = readIf(path.join(dir, "about.md"));
|
|
37
|
+
return { slug, name: about.match(/^# About (.+)$/m)?.[1].trim() || slug || path.basename(root), dir, ids: accountIdsIn(about) };
|
|
38
|
+
};
|
|
39
|
+
const out = [one("", path.join(root, "brand"))];
|
|
40
|
+
const bd = path.join(root, "brands");
|
|
41
|
+
if (fs.existsSync(bd))
|
|
42
|
+
for (const e of fs.readdirSync(bd, { withFileTypes: true }).sort((x, y) => x.name.localeCompare(y.name)))
|
|
43
|
+
if (e.isDirectory() && !e.name.startsWith("_") && (fs.existsSync(path.join(bd, e.name, "about.md")) || fs.existsSync(path.join(bd, e.name, "voice.md")))) out.push(one(e.name, path.join(bd, e.name)));
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A brand's own file, or the main brand's when it doesn't have one. */
|
|
48
|
+
export function brandFile(b, name, root = ROOT0) {
|
|
49
|
+
const own = b && path.join(b.dir, name);
|
|
50
|
+
return own && fs.existsSync(own) ? own : path.join(root, "brand", name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Which brand a post is: its `brand:` line, else the brand that lists its accounts, else the main one. */
|
|
54
|
+
export function brandOfPost(front, brands, accounts = []) {
|
|
55
|
+
const want = String(front?.brand ?? "").trim();
|
|
56
|
+
// the folder name first (it's unique), then the brand's name
|
|
57
|
+
if (want) return brands.find((b) => b.slug && b.slug === slugOf(want)) ?? brands.find((b) => b.name.toLowerCase() === want.toLowerCase()) ?? brands[0];
|
|
58
|
+
const ids = listOf(front?.accounts).map((line) => accounts.find((a) => a.account.toLowerCase() === line.toLowerCase())?.account_id).filter(Boolean);
|
|
59
|
+
if (ids.length) {
|
|
60
|
+
const hit = brands.slice(1).find((b) => b.ids.length && ids.every((id) => b.ids.includes(id)));
|
|
61
|
+
if (hit) return hit;
|
|
62
|
+
}
|
|
63
|
+
return brands[0];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ABOUT = (name, ids) => `# About ${name}
|
|
67
|
+
|
|
68
|
+
## What it is
|
|
69
|
+
<!-- fill: one or two sentences -->
|
|
70
|
+
|
|
71
|
+
## Who it's for
|
|
72
|
+
<!-- fill: the people who should care, in plain words -->
|
|
73
|
+
|
|
74
|
+
## Topics
|
|
75
|
+
<!-- fill: the 3 to 5 things you post about, one per line, with how many a week if you know: "- Building the app (~3)" -->
|
|
76
|
+
|
|
77
|
+
## Links
|
|
78
|
+
<!-- fill: website, shop, app, newsletter -->
|
|
79
|
+
|
|
80
|
+
## Accounts on Posthuman
|
|
81
|
+
${ids.length ? ids.map((id) => `- (${id})`).join("\n") : '<!-- fill: one line each, with its account id in brackets: "- Instagram @shop (12): photos + Reels" -->'}
|
|
82
|
+
|
|
83
|
+
## Goals
|
|
84
|
+
<!-- fill: what posting is for (followers, sign-ups, sales, a launch), the number that means it worked, by when -->
|
|
85
|
+
|
|
86
|
+
## This month
|
|
87
|
+
<!-- fill: what's going on: a launch, a sale, a season, a series -->
|
|
88
|
+
`;
|
|
89
|
+
const VOICE = (name) => `# How ${name} sounds
|
|
90
|
+
|
|
91
|
+
Every agent reads this before it writes a post for ${name}. Keep it to about a page. Lines the user wrote stay. An
|
|
92
|
+
agent can merge and tidy around them, never drop or reword them.
|
|
93
|
+
|
|
94
|
+
## Voice
|
|
95
|
+
<!-- fill: three words, then a few lines -->
|
|
96
|
+
|
|
97
|
+
## Never do
|
|
98
|
+
<!-- fill: "no hashtags", "never mention prices" -->
|
|
99
|
+
|
|
100
|
+
## Words we use
|
|
101
|
+
<!-- fill: names, spellings, sign-offs -->
|
|
102
|
+
|
|
103
|
+
## Examples we love
|
|
104
|
+
<!-- fill: two or three real posts that sound right -->
|
|
105
|
+
|
|
106
|
+
## What worked
|
|
107
|
+
<!-- the agent adds these from real results -->
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
/** Make brands/<slug>/ with a blank about.md and voice.md. */
|
|
111
|
+
export function addBrand(name, { ids = [], root = ROOT0 } = {}) {
|
|
112
|
+
const slug = slugOf(name);
|
|
113
|
+
if (!slug) throw new Error("Give the brand a name.");
|
|
114
|
+
const dir = path.join(root, "brands", slug);
|
|
115
|
+
if (fs.existsSync(dir)) throw new Error(`brands/${slug} is already here.`);
|
|
116
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
117
|
+
fs.writeFileSync(path.join(dir, "about.md"), ABOUT(name, ids));
|
|
118
|
+
fs.writeFileSync(path.join(dir, "voice.md"), VOICE(name));
|
|
119
|
+
return { slug, dir };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === HERE) {
|
|
123
|
+
const a = parseArgs(process.argv.slice(2));
|
|
124
|
+
if (a._[0] === "add") {
|
|
125
|
+
const name = a._.slice(1).join(" ").trim();
|
|
126
|
+
if (!name) fail('Usage: node tools/brands.mjs add "Brand name" [--accounts 10,12]');
|
|
127
|
+
const ids = String(a.accounts ?? "").split(/[,\s]+/).map(Number).filter(Boolean);
|
|
128
|
+
try {
|
|
129
|
+
const b = addBrand(name, { ids });
|
|
130
|
+
console.log(`Made brands/${b.slug}/ (about.md, voice.md). Fill them in, then put "brand: ${b.slug}" on its posts.`);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
fail(e.message);
|
|
133
|
+
}
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}
|
|
136
|
+
const accts = parseAccounts(readIf(path.join(ROOT0, "brand", "accounts.md")));
|
|
137
|
+
for (const b of brandsOf()) {
|
|
138
|
+
const names = b.ids.map((id) => accts.find((x) => x.account_id === id)?.account ?? `account ${id}`);
|
|
139
|
+
console.log(`${b.slug ? `brands/${b.slug}` : "brand (main)"}: ${b.name}${names.length ? `: ${names.join(", ")}` : b.slug ? ": no accounts listed in its about.md" : ""}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Run any fal model and save what it makes into library/.
|
|
3
|
+
//
|
|
4
|
+
// node tools/fal.mjs <model> --input '<json>' [--file key=path ...] --out library/name.ext [--what "alt text"] [--dry]
|
|
5
|
+
//
|
|
6
|
+
// e.g. node tools/fal.mjs fal-ai/flux-2-pro --input '{"prompt":"a worksheet on a kitchen table, morning light","image_size":{"width":1080,"height":1350}}' \
|
|
7
|
+
// --out library/2026-11-24-table.png --what "A printed worksheet on a wooden kitchen table"
|
|
8
|
+
// node tools/fal.mjs fal-ai/kling-video/v3/pro/image-to-video --file image_url=library/photo.jpg \
|
|
9
|
+
// --input '{"prompt":"slow push-in, steam rising from the mug","duration":"5"}' --out library/clip.mp4
|
|
10
|
+
//
|
|
11
|
+
// --file key=path puts a local file into the input as a data: address (or key=https://… as a link).
|
|
12
|
+
// --dry prints what would be sent (without the key and without the file's bytes) and stops.
|
|
13
|
+
// Uses fal's queue: submit, wait, fetch the result. Model names and inputs: fal.ai/models (each model's API tab).
|
|
14
|
+
|
|
15
|
+
import { addToLibrary, dataUri, download, fail, need, parseArgs } from "./lib.mjs";
|
|
16
|
+
|
|
17
|
+
const a = parseArgs(process.argv.slice(2));
|
|
18
|
+
const model = a._[0];
|
|
19
|
+
if (!model || !a.out) fail("Usage: node tools/fal.mjs <model> --input '<json>' [--file key=path] --out library/name.ext");
|
|
20
|
+
|
|
21
|
+
let input = {};
|
|
22
|
+
if (a.input) {
|
|
23
|
+
try {
|
|
24
|
+
input = JSON.parse(a.input);
|
|
25
|
+
} catch {
|
|
26
|
+
fail("--input must be JSON, e.g. '{\"prompt\":\"…\"}'");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const f of [].concat(a.file ?? [])) {
|
|
30
|
+
const i = String(f).indexOf("=");
|
|
31
|
+
if (i < 1) fail(`--file wants key=path, got: ${f}`);
|
|
32
|
+
const k = f.slice(0, i);
|
|
33
|
+
const v = f.slice(i + 1);
|
|
34
|
+
input[k] = /^https?:\/\//.test(v) ? v : dataUri(v);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (a.dry) {
|
|
38
|
+
const shown = Object.fromEntries(Object.entries(input).map(([k, v]) => [k, typeof v === "string" && v.startsWith("data:") ? `${v.slice(0, 30)}… (${Math.round(v.length / 1024)} KB)` : v]));
|
|
39
|
+
console.log(JSON.stringify({ post: `https://queue.fal.run/${model}`, input: shown, out: a.out }, null, 2));
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const KEY = need("FAL_KEY", "fal.ai/dashboard/keys");
|
|
44
|
+
const head = { Authorization: `Key ${KEY}`, "Content-Type": "application/json" };
|
|
45
|
+
|
|
46
|
+
const sub = await fetch(`https://queue.fal.run/${model}`, { method: "POST", headers: head, body: JSON.stringify(input) });
|
|
47
|
+
if (!sub.ok) fail(`fal refused it (${sub.status}): ${(await sub.text()).slice(0, 600)}`);
|
|
48
|
+
const job = await sub.json();
|
|
49
|
+
if (!job.status_url || !job.response_url) fail(`fal's answer had no job in it: ${JSON.stringify(job).slice(0, 400)}`);
|
|
50
|
+
process.stderr.write(`Sent to fal (${job.request_id}). Waiting`);
|
|
51
|
+
|
|
52
|
+
const started = Date.now();
|
|
53
|
+
const LIMIT = 15 * 60e3; // video can take a few minutes
|
|
54
|
+
for (;;) {
|
|
55
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
56
|
+
const s = await fetch(job.status_url, { headers: head });
|
|
57
|
+
const st = s.ok ? await s.json() : { status: `HTTP ${s.status}` };
|
|
58
|
+
if (st.status === "COMPLETED") break;
|
|
59
|
+
if (!["IN_QUEUE", "IN_PROGRESS"].includes(st.status)) fail(`\nfal stopped: ${JSON.stringify(st).slice(0, 600)}`);
|
|
60
|
+
if (Date.now() - started > LIMIT) fail(`\nStill not done after 15 minutes. Check it later: ${job.response_url}`);
|
|
61
|
+
process.stderr.write(".");
|
|
62
|
+
}
|
|
63
|
+
process.stderr.write("\n");
|
|
64
|
+
|
|
65
|
+
const res = await fetch(job.response_url, { headers: head });
|
|
66
|
+
if (!res.ok) fail(`fal finished but the result didn't come (${res.status}): ${(await res.text()).slice(0, 400)}`);
|
|
67
|
+
const out = await res.json();
|
|
68
|
+
|
|
69
|
+
// The file is somewhere in the answer: video.url, images[0].url, audio.url, image.url…
|
|
70
|
+
const find = (o) => {
|
|
71
|
+
if (!o || typeof o !== "object") return null;
|
|
72
|
+
if (typeof o.url === "string" && /^https?:/.test(o.url)) return o.url;
|
|
73
|
+
for (const k of ["video", "images", "image", "audio", "audio_file", "output"]) if (o[k]) { const u = find(Array.isArray(o[k]) ? o[k][0] : o[k]); if (u) return u; }
|
|
74
|
+
for (const v of Object.values(o)) { const u = find(Array.isArray(v) ? v[0] : v); if (u) return u; }
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
77
|
+
const url = find(out);
|
|
78
|
+
if (!url) fail(`fal finished but there's no file in the answer: ${JSON.stringify(out).slice(0, 600)}`);
|
|
79
|
+
|
|
80
|
+
const saved = await download(url, a.out);
|
|
81
|
+
addToLibrary(saved, a.what ?? input.prompt ?? "", `fal ${model}`);
|
|
82
|
+
console.log(JSON.stringify({ saved, link: url, note: "fal's links don't last forever: give the link to Posthuman (add_media_from_url) soon, or upload the saved file." }, null, 2));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The humanize rules and check: pure, no Node imports, so the same file runs in Studio's page and in
|
|
2
|
+
// tools/humanize.mjs. Edit the list here; both pick it up.
|
|
3
|
+
|
|
4
|
+
// [pattern, flags, what it is, how to fix it]. Kept as plain strings so Studio's page can use the same list.
|
|
5
|
+
export const RULES = [
|
|
6
|
+
["—|–| -- ", "g", "dash", "AI's favorite punctuation. Use a period or a comma."],
|
|
7
|
+
["\\b(?:it'?s|this is|that'?s)\\s+not\\s+(?:just\\s+)?(?:about\\s+)?[^.,!?\\n]{1,40}[,;]\\s*(?:it'?s|but)\\b", "gi", "not X, it's Y", "The classic AI contrast. Just say the Y."],
|
|
8
|
+
["\\bnot (?:just|only) [^.,!?\\n]{1,40},? but (?:also )?", "gi", "not just X but Y", "Say the thing directly."],
|
|
9
|
+
["\\b(?:delve|tapestry|testament|landscape|realm|navigat(?:e|ing) the|leverag(?:e|ing)|unlock(?:s|ing)?|elevate|seamless(?:ly)?|robust|game[- ]?changer|revolutioni[sz]e|harness(?:ing)?|embark|journey|crucial|pivotal|foster|vibrant|ever-evolving|supercharge|empower(?:s|ing)?|cutting-edge|next-level|synergy|paradigm|holistic|streamline)\\b", "gi", "AI word", "Nobody says this out loud. Use the plain word."],
|
|
10
|
+
["\\b(?:in today'?s (?:world|fast-paced)|it'?s worth noting|let'?s dive in|dive into|here'?s the thing|buckle up|the truth is|let that sink in|read that again|hot take:|unpopular opinion:|spoiler:|plot twist:|in a world where|at the end of the day|the best part\\?|the result\\?|the secret\\?|the kicker\\?)", "gi", "stock phrase", "A phrase every AI post uses. Cut it, or say it your way."],
|
|
11
|
+
["^(?:ever wondered|have you ever|imagine (?:if|a world)|picture this|what if i told you)", "gim", "rhetorical opener", "Start with the actual thing that happened."],
|
|
12
|
+
["[🚀✨💡🔥👇🧵💯🙌⚡️🎯📈🤯]", "gu", "hype emoji", "Reads as a template. Drop it, or keep one that means something."],
|
|
13
|
+
["\\.\\.\\.|…", "g", "dramatic dots", "Fake drama. End the sentence."],
|
|
14
|
+
["!.*!", "gs", "exclamation marks", "More than one sounds like an ad. Keep at most one."],
|
|
15
|
+
["\\b(?:follow for more|like and share|drop a comment|smash that|let me know (?:what you think|in the comments)|thoughts\\?|agree\\?)", "gi", "generic ask", "Ask a real question people can answer, or none."],
|
|
16
|
+
["\\b(?:commits?|MRR|ARR|deploy(?:ed|s|ing)?|refactor(?:ed|ing)?|endpoints?|repo|API|SDK|latency|codebase|stack trace|PR|merge(?:d)?|devnet|mainnet|blockchain infrastructure|zero-knowledge proof|test suite|polyfill|deprecated)\\b", "g", "tech word", "Would a friend who doesn't code get it? If not, say it in everyday words."],
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const compiled = RULES.map(([src, flags, tell, fix]) => ({ re: new RegExp(src, flags), tell, fix }));
|
|
20
|
+
|
|
21
|
+
// ---------- the user's own rules, from brand/voice.md ----------
|
|
22
|
+
// The fixed list above catches what every AI writes. This part catches what this user said no to:
|
|
23
|
+
// - a quoted phrase under "Never do" (Don't end with "tell me what's bad"), or quoted right after a no, never,
|
|
24
|
+
// don't, skip or avoid anywhere else (Skip the fancy one ("gratifying"));
|
|
25
|
+
// - "end with a real ask / question / convo starter" anywhere in it: then a post with no question at the end
|
|
26
|
+
// of its main part is flagged.
|
|
27
|
+
// Quotes the user said about a post (Sam: "all AI lol", (Sam, 11-24: "sure")) are their reactions, not banned
|
|
28
|
+
// words, so a quote right after a colon is skipped, and so are long ones and excerpts with "…" in them.
|
|
29
|
+
|
|
30
|
+
const norm = (s) => String(s).toLowerCase().replace(/[\u2018\u2019\u02bc]/g, "'").replace(/[\u201c\u201d]/g, '"').replace(/\s+/g, " ").trim();
|
|
31
|
+
|
|
32
|
+
/** { banned: ["tell me what's bad", …], endsWithAsk } from brand/voice.md's text. */
|
|
33
|
+
export function parseVoice(text = "") {
|
|
34
|
+
const banned = [];
|
|
35
|
+
let section = "";
|
|
36
|
+
let endsWithAsk = false;
|
|
37
|
+
const body = String(text).replace(/\r/g, "").replace(/<!--[\s\S]*?-->/g, "");
|
|
38
|
+
// a bullet can wrap onto the next lines: join them first
|
|
39
|
+
const lines = body.split("\n").reduce((a, l) => (/^\s{2,}\S/.test(l) && a.length && !/^#/.test(a[a.length - 1]) ? ((a[a.length - 1] += ` ${l.trim()}`), a) : [...a, l]), []);
|
|
40
|
+
for (const line of lines) {
|
|
41
|
+
const h = line.match(/^## +(.+)$/);
|
|
42
|
+
if (h) {
|
|
43
|
+
section = h[1].trim().toLowerCase();
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (/\bend(?:s|ing)? (?:with|on) (?:a |an )?(?:real |actual |genuine )?(?:ask|question|convo|conversation)/i.test(line)) endsWithAsk = true;
|
|
47
|
+
for (const m of line.matchAll(/["\u201c]([^"\u201d\n]*)["\u201d]/g)) {
|
|
48
|
+
const q = m[1].trim();
|
|
49
|
+
const before = line.slice(Math.max(0, m.index - 40), m.index);
|
|
50
|
+
if (q.length < 2 || /:\s*$/.test(before) || /…|\.\.\./.test(q) || q.split(/\s+/).length > 12) continue;
|
|
51
|
+
const neverHere = /^never/.test(section);
|
|
52
|
+
const negated = /\b(?:no|never|don'?t|do not|skip|avoid|not)\b[^.;]*$/i.test(before);
|
|
53
|
+
if (neverHere || negated) banned.push(norm(q).replace(/[.!?]+$/, ""));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { banned: [...new Set(banned)].filter((b) => b.length > 1), endsWithAsk };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The flags for some words: [{ tell, fix, found: ["…"] }]. Hashtags only count where they're not wanted.
|
|
60
|
+
* voice: parseVoice(brand/voice.md), for the user's own no's. */
|
|
61
|
+
export function check(text, { hashtagsOk = false, voice = null } = {}) {
|
|
62
|
+
const out = [];
|
|
63
|
+
if (voice?.banned?.length) {
|
|
64
|
+
const t = norm(text);
|
|
65
|
+
const hit = voice.banned.filter((b) => new RegExp(`(^|[^\\p{L}\\d])${b.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^\\p{L}\\d])`, "iu").test(t));
|
|
66
|
+
if (hit.length) out.push({ tell: "your never-do", fix: "Your voice.md says not this. Say it another way, or leave it out.", found: hit.slice(0, 5) });
|
|
67
|
+
}
|
|
68
|
+
if (voice?.endsWithAsk) {
|
|
69
|
+
// the main part: the first one, or the one before a reply that's only a link
|
|
70
|
+
const parts = String(text).split(/\n-{3}[ \t]*(?:\n|$)/).map((s) => s.trim()).filter(Boolean);
|
|
71
|
+
const asks = parts.some((p) => /\?["')\u201d]?\s*(?:\p{Extended_Pictographic}\s*)*$/u.test(p.split(/\n\s*\n/).filter((x) => !/^#\w/.test(x.trim())).pop() ?? ""));
|
|
72
|
+
if (parts.length && !asks) out.push({ tell: "no ask at the end", fix: "Your voice.md says every post ends with a real ask. End it on a question people can answer.", found: [(parts[0].split("\n").filter(Boolean).pop() ?? "").slice(0, 60)] });
|
|
73
|
+
}
|
|
74
|
+
for (const { re, tell, fix } of compiled) {
|
|
75
|
+
const found = [...text.matchAll(new RegExp(re.source, re.flags.includes("g") ? re.flags : re.flags + "g"))].map((m) => m[0].trim()).filter(Boolean);
|
|
76
|
+
if (found.length) out.push({ tell, fix, found: [...new Set(found)].slice(0, 5) });
|
|
77
|
+
}
|
|
78
|
+
if (!hashtagsOk) {
|
|
79
|
+
const tags = text.match(/(?:^|\s)#[A-Za-z]\w+/g);
|
|
80
|
+
if (tags) out.push({ tell: "hashtags", fix: "Only Mastodon needs them. Leave them out here.", found: tags.map((t) => t.trim()).slice(0, 5) });
|
|
81
|
+
}
|
|
82
|
+
const long = text.split(/(?<=[.!?])\s+|\n+/).filter((s) => s.split(/\s+/).filter(Boolean).length > 28);
|
|
83
|
+
if (long.length) out.push({ tell: "long sentence", fix: "Over 28 words. Split it or cut it.", found: long.map((s) => `${s.slice(0, 50)}…`).slice(0, 3) });
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|