Exported functions in state/lib/positioning.ts. .md file to compare - side-by-side diff against positioning
positioning
description: "Triggers on prompt mention of 'positioning'."
What it does for you
Keeps your brand voice and messaging consistent everywhere.
What it produces
A recent result, so you can see the kind of work it returns.
loading…
How to get it
These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.
For developers how this skill is built, graded, and how it runs
at a glance- the short version
what's inside - the parts that make up a skill 3/4 present
A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.
state/skills/positioning/SKILL.md
present
state/lib/positioning.ts
present
state/bin/positioning/
not present
state/skills/positioning/AGENTS.md
present
how it's graded - what counts as a good run 4 criteria · 4 deterministic
Each row is one thing a good run has to get right. deterministic means a quick check decides, pass or fail. judge means the AI reads the result and rates it. Grading each piece on its own (instead of one overall score) shows exactly where a run fell short, so the fix is obvious.
how it runs - the shared frame every skill uses 5/5 present
Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.
state/log/pending-eval.ndjson - NEVER em-dash or en-dash in reader-facing prose. checkTone() blocks them as dead AI tells.
- NEVER ship hype words (revolutionize, supercharge, unlock, leverage, seamless), Nx claims ("10x"), "Not X, not Y, Z" trifectas, "Here's the thing", "At the end of the day", or engagement-bait closers ("Agree?", "Thoughts?").
- NEVER open a LinkedIn post with a personal story ("I was…", "Last week I…").
- NEVER include author-scoreboard numbers ("620 endpoints", "14 clients") — Robert cringes; restructure as observations about the work.
- ALWAYS exempt image-prompt frontmatter (layer_, metaphor_rationale, image_prompt) from §4a — those go to DALL-E, not a reader.
- Watch for the kernel em-dash backfill artifact: literal , (space-comma-two-spaces) where em-dashes used to be. checkTone() does not catch this; scan the literal string.
what it has learned - fixes written back in over time sample
When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.
- Loading feedback rows…
how the work flows- who makes it, who checks it
SKILL.md- the skill, written out in plain English
positioning
Voice constitution, tone rules, banned phrases.
Ported from kernel snappy-positioning in Phase 0.5. See state/lib/positioning.ts for the full API surface.
Steps
getToneGuide()- seestate/lib/positioning.tsgetBannedPhrases()- seestate/lib/positioning.tscheckTone()- seestate/lib/positioning.tsrequireCitations()- seestate/lib/positioning.tscheckFlow()- seestate/lib/positioning.ts
Eval
Actor: the exported functions in state/lib/positioning.ts. Auditor: none wired yet - eval is manual (Robert review). File a state/log/pending-eval.ndjson row on each run.
Score convention:
| Outcome | Score |
|---|---|
| Pass on first try | 1.0 |
| Failed first, auto-fix applied, re-check passed | 0.5 |
| Still failing or unrecoverable | 0.0 |
Gotchas
via the Phase 0.5 driver. Only these rewrites were applied: already in state/lib/)
realpathSync(process.argv[1])CLI guard wrapped in try/catch
- See the kernel SKILL.md for the original long-form guidance if you need it
(read-only reference at the kernel path above).
Graduation
This skill is prose. Graduate by defining a deterministic auditor and flipping eval: auto.
Rubric
criteria:
- name: calls_all_required_funcs
kind: deterministic
check: "The skill execution must call getToneGuide(), getBannedPhrases(), and checkTone() at least once, as indicated by logging or code analysis."
- name: matches_typescript_api
kind: deterministic
check: "The implementation of positioning methods in state/lib/positioning.ts must exactly match the signatures defined in the original snappy-positioning kernel (or the provided types in the repo)."
- name: honors_input_contract
kind: deterministic
check: "The skill execution provides valid string inputs for getToneGuide_input, getBannedPhrases_input, and checkTone_input, as specified in the SKILL.md."
- name: creates_log_entry
kind: deterministic
check: "A new row representing the skill's execution outcome must be appended to state/log/pending-eval.ndjson."AGENTS.md- what the AI loads when this skill comes up
positioning - loader
Per-turn rules for the positioning skill. Full reference: state/skills/positioning/SKILL.md. Do not skip these.
Critical Rules
- NEVER em-dash or en-dash in reader-facing prose.
checkTone()blocks them as dead AI tells. - NEVER ship hype words (revolutionize, supercharge, unlock, leverage, seamless), Nx claims ("10x"), "Not X, not Y, Z" trifectas, "Here's the thing", "At the end of the day", or engagement-bait closers ("Agree?", "Thoughts?").
- NEVER open a LinkedIn post with a personal story ("I was…", "Last week I…").
- NEVER include author-scoreboard numbers ("620 endpoints", "14 clients") - Robert cringes; restructure as observations about the work.
- ALWAYS exempt image-prompt frontmatter (
layer_*,metaphor_rationale,image_prompt) from §4a - those go to DALL-E, not a reader. - Watch for the kernel em-dash backfill artifact: literal
,(space-comma-two-spaces) where em-dashes used to be.checkTone()does not catch this; scan the literal string.
Commands
| ui dashboard | state/skills/positioning/resources/ui.openui | |invoke (TS): import { checkTone, requireCitations, getToneGuide, checkFlow } from "../lib/positioning.ts" |invoke (lib): state/lib/voice.ts - same surface as positioning, deterministic auditor |eval log: state/log/pending-eval.ndjson (skill: "positioning") until auditor wired
OpenUI Resource
- Skill-owned OpenUI Lang resource:
state/skills/positioning/resources/ui.openui. Read it before rendering or editing this skill's generated component surface. - Treat this resource as a first-class artifact of the skill, not a generic chat response. Improve it when the skill's user-facing output needs to become richer.
- System resources compose OpenUI primitives and inherit SnappyChat tokens. Use
ui_contract: brandedin SKILL.md only for deliberate platform or client visuals.
Known Pitfalls
- Eval is currently manual (Robert review). Score 0.5 means a draft was rewritten and re-checked; score 1.0 means clean on first try.
- The source-of-truth prose lives in
sources/positioning/voice.md. The enforcement code lives instate/lib/voice.ts. Edit voice.ts to change the gate.
Self-Test
An agent reading this should correctly:
- [ ] Refuse to ship a draft containing an em-dash without flagging it
- [ ] Strip "Agree?" from a LinkedIn post closer
- [ ] Pass image-prompt frontmatter through unchanged
Self-report
If this loader fell short, append a line:
echo "[$(date -u +%FT%TZ)] positioning: <what was missing>" >> state/log/loader-feedback.log
<!-- kernel-ok: historical attribution for the PID-loader pattern. -->
Self-correcting loader (PID feedback)
This is the rule that makes loaders learn. Ported from snappy-kernel, where it demonstrably worked: the snappy-dom-cartographer skill mapped Skool admin UI once, every later ship-agent inherited the full map for free.
Before you finish, do two things:
1. Fix gaps (P - proportional). MANDATORY. If this loader didn't cover your case - if you had to read another file, run an undocumented command, work around a wrong selector, or discover a quirk - you MUST attempt an Edit to this AGENTS.md before you log.
- Default action: edit this file. Surgical. Add the missing line, table
row, or code example where it belongs. No restructuring.
- Only
LOGGEDis allowed when: the fix needs >10 lines, spans multiple
files, or requires a structural rewrite. In that case the state/regen/drain.sh queue picks it up asynchronously.
- "I didn't have time" / "it's minor" / "the next agent will figure it out"
are NOT valid reasons. Minor gaps compound - that's the whole point of this loop.
- Concrete example of a valid P-fix: discover
agent-browser screenshot
takes path positionally not as --output <path>. One line in a table. Edit it in. Do not just log it.
- The goal: the next agent never has to leave the loader.
2. Log the result.
echo "[$(date -u +%FT%TZ)] positioning: <what was missing or fixed> [FIXED|LOGGED]" >> state/log/loader-feedback.log
FIXED= you patched this loader inline (P-fix).LOGGED= too large for inline; the PostToolUse enqueue + Stop-hook drain
will rewrite the loader from scratch on next session-end.
Do not skip this. Every agent run must leave the system better than it found it. The loader is the setpoint; you are the sensor; the gap is the error signal; closing the gap is the correction.
api.ts- the code it can call
#!/usr/bin/env npx tsx
/**
* snappy-positioning/api.ts -- Voice constitution, tone rules, banned phrases.
*
* Reads from local SKILL.md and AGENTS.md. Pure data skill -- no external APIs.
*
* Usage:
* npx tsx api.ts tone # canonical tone rules
* npx tsx api.ts banned # banned phrases list
* npx tsx api.ts check <text> # lint text: banned phrases + rhythm slop
* npx tsx api.ts cite <path-to-draft> # verify transcript citation coverage
*
* Or import as module:
* import { getToneGuide, getBannedPhrases, checkTone, requireCitations }
* from "./positioning.ts";
*
* Drafts for public-facing copy (About, blog, post, email) MUST pass both
* checkTone() AND requireCitations() before being returned by any pod.
*/
import { existsSync, readFileSync, realpathSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
import { env } from "./env.ts";
const SKILL_DIR = dirname(fileURLToPath(import.meta.url));
function readSkillFile(filename: string): string {
const path = join(SKILL_DIR, filename);
if (!existsSync(path)) {
throw new Error(`[snappy-positioning] ${filename} not found at ${path}`);
}
return readFileSync(path, "utf-8");
}
const BANNED_PHRASES: string[] = [
"10x faster", "10x developer", "100x speed", "in minutes",
"the operating system for", "the X for Y", "without the Z", "before you Q",
"at the intersection of", "one-stop shop",
"revolutionize", "revolutionary", "transform", "unleash",
"unlock", "unlock the power of", "supercharge", "empower", "empowering",
"leverage", "synergy", "game changer", "game-changing", "game changer",
"ultimate", "cutting edge", "bleeding edge", "next-gen", "next generation",
"seamless", "seamlessly", "effortless", "effortlessly",
"AI-powered", "AI-native", "agentic-first", "founder-led", "ship-ready",
"vibe coding", "Snappy is",
"feel confident", "feel in control", "feel unstuck",
// Rhythm-slop vocab (post-2026-04-11 About-draft incident).
// These are phrases that appeared ONLY in the slop draft, never in
// the canonical voice constitution, so banning them doesn't false-positive
// on the source-of-truth docs. Canonical phrases ("ship real systems",
// "builder-to-builder", "the thesis is simple") are INTENTIONALLY not
// listed here, they are Robert's voice.
"my stack is opinionated",
"i dog-food everything",
"clear boxes, not black boxes",
// Anti-AI word list, ported from content-engine/reference/anti-ai-writing.md
// (2026-04-11 unify). All flagged as AI-tell vocabulary. Canonical voice.md
// does not use any of these in prose so false-positive risk is low.
"delve", "showcase", "noteworthy", "multifaceted", "tapestry", "beacon",
"meticulous", "intricate", "commendable", "paramount", "commence", "utilize",
"robust", "streamline", "harness", "illuminate", "facilitate", "bolster",
"underscore", "pivotal", "realm", "foster", "landscape", "paradigm",
"ecosystem", "spearhead", "groundbreaking", "transformative", "game-changer",
"elevate", "deep dive", "unpack",
// Anti-AI phrase list (same source).
"in today's fast-paced", "it's worth noting", "here's where it gets interesting",
"here's the kicker", "let's break this down", "let's unpack", "the truth is simple",
"think of it as", "imagine a world where", "in conclusion", "to sum up",
"studies show", "experts say", "it goes without saying",
"importantly,", "interestingly,", "notably,",
"furthermore,", "moreover,", "additionally,",
"despite its challenges", "i'm excited to announce", "without further ado",
// April 2026 anti-AI research additions. Engagement-bait closers, template
// openers, and mini-question intros flagged across LinkedIn slop studies.
"agree?", "thoughts?", "at its core", "whether you're a", "whether you're an",
"the catch?", "your ideas, ai's polish",
];
// Structural rhythm patterns — AI tells that banned-phrase lookup misses.
// These catch the STRUCTURE of paraphrase-slop without banning the canonical
// vocabulary. Each entry is [regex, label]. Case-insensitive.
//
// Patterns here must pass the self-test: `npx tsx api.ts check $(cat AGENTS.md)`
// against the canonical positioning docs MUST return PASS (no rhythm hits).
const RHYTHM_PATTERNS: Array<[RegExp, string]> = [
[/\bnot\s+\w+,\s+not\s+\w+\s*[—-]/i, "Not X, not Y — Z (rhetorical negation trifecta)"],
[/\bif\s+you're\s+(?:a|an)\s+\w+\s+(?:founder|dev|team|builder|engineer)[^.]*stuck\s+between\b/i, "'If you're a [X] stuck between' (AI sales opener)"],
[/\bon\s+your\s+repo,\s+on\s+your\s+\w+\s+problem\b/i, "'on your repo, on your real problem' (parallel-clause slop)"],
[/—\s+that's\s+how\s+you\b/i, "'— that's how you' (AI didactic dash)"],
[/\bnever\s+\w+[,.].{0,40}\balways\b/i, "Never X, always Y (false-symmetry rule)"],
[/\bthe\s+real\s+\w+\s+is\s+(?:simple|that|this)\b/i, "'The real [X] is [reveal]' (AI reveal framing)"],
[/\bhere's\s+the\s+thing\b/i, "'Here's the thing' (AI pivot)"],
[/\bat\s+the\s+end\s+of\s+the\s+day\b/i, "'At the end of the day' (filler)"],
// voice.md Don't list: "No em dashes or en dashes. Ever." Dead AI tell.
// Also enforced by snappy-course/scripts/lint-draft.sh D6 and
// content-engine/reference/anti-ai-writing.md. Kept here so pod-facing
// checkTone() blocks drafts before they ever reach a human review.
[/—/, "em dash — dead AI tell (voice.md: use commas/periods or restructure)"],
[/–/, "en dash — dead AI tell (voice.md: use commas/periods or restructure)"],
// April 2026 research patterns. Mini-question intros, engagement-bait
// closers, template openers, and author-scoreboard numbers.
[/\b(agree|thoughts|right\?|make sense)\?\s*$/im, "engagement-bait closer ('Agree?' / 'Thoughts?') — LinkedIn slop tell"],
[/\bwhether you're (?:a|an)\s+\w+[,\s]+(?:a|an)?\s*\w+[,\s]+or\s+(?:a|an)?\s*\w+/i, "'Whether you're X, Y, or Z' template opener — AI audience-hedge"],
[/\b\d{2,}\+?(?:\s+[\w-]+){0,3}\s+(endpoints|tools|clients|projects|integrations|playbooks|skills|apis|deploys|agents|workflows|automations)\b/i, "author-scoreboard count — numbers-about-author are decoys, restructure as observation about the work"],
[/(?:^|\n)\s*(?:the catch|the twist|the kicker|the surprise|the result|the reality)\?\s*\n/i, "mini-question intro fragment — AI reveal framing"],
// No personal stories/anecdotes in LinkedIn posts. Technical reports only.
// These catch diary-mode openers. The insight must stand without a story wrapper.
[/(?:^|\n)\s*(?:I was |I noticed |Last (?:week|month|year) I |I had a session |I caught an? |I watched an? |I spent |I realized )/i, "personal story opener — lead with the technical insight, not a diary entry"],
];
// --- Public API ---
export function getToneGuide(): {
oneLiner: string;
shortTagline: string;
longTagline: string;
tuningFork: string[];
principles: string[];
doRules: string[];
dontRules: string[];
} {
return {
oneLiner: "Snappy helps developers build and control agents that ship real systems.",
shortTagline: "We build businesses, not demos.",
longTagline: "Faster than vibe coding. Private AI tools to ship real systems while others prompt. We build businesses, not demos.",
tuningFork: [
"You built it. You're stuck. Let's fix that, live on your screen.",
"We open your codebase together, map the architecture, and start fixing what's blocking you.",
"I burn the hours so you don't.",
"Build and control agents to get huge results.",
],
principles: [
"Lead with what happens, not what Snappy is.",
"First person. 'I' by default. 'We' only when literally true.",
"Builder-to-builder. Assume the reader has shipped real software.",
"Earn every adjective. If you can't defend it on a call, delete it.",
"The four reference sentences are the tuning fork.",
],
doRules: [
"Write first person. 'I', 'you', 'we built'. Never marketing third person.",
"Be direct. State the problem, state the fix, stop talking.",
"Builder-to-builder. Assume the reader has shipped real software.",
"Lead with the work. Screens, repos, agents running, commits landing.",
"Short sentences beat clever sentences.",
"Name the tool when it matters -- but the tool is never the hero. The outcome is.",
"Earn every adjective. If you can't defend it on a call, delete it.",
],
dontRules: [
"No hype. No adjective stacking.",
"No vibe coding language as our own. We build and control.",
"No false novelty.",
"No fake urgency.",
"No third-person hero narration about Robert.",
"No personification of Snappy.",
"No 'MCP integration' or 'Xano MCP' as the headline.",
],
};
}
export function getBannedPhrases(): string[] {
return [...BANNED_PHRASES];
}
export function checkTone(text: string): {
pass: boolean;
violations: string[];
} {
const cleaned = text
.replace(/\[source:[^\]]*\]/gi, "")
.replace(/<connective>[\s\S]*?<\/connective>/gi, "");
const lower = cleaned.toLowerCase();
const violations: string[] = [];
for (const phrase of BANNED_PHRASES) {
if (lower.includes(phrase.toLowerCase())) {
violations.push(phrase);
}
}
// Nx pattern (2x, 5x, 100x, etc.)
const nxMatch = text.match(/\b\d+x\b/gi);
if (nxMatch) {
for (const m of nxMatch) {
if (!violations.includes(m)) violations.push(`${m} (Nx claim)`);
}
}
// Structural rhythm patterns — the AI tells banned-phrase lookup misses.
for (const [re, label] of RHYTHM_PATTERNS) {
if (re.test(text)) violations.push(label);
}
return { pass: violations.length === 0, violations };
}
/**
* Drafts produced by mining pods (Krisp → About, blog, post, email) MUST
* cite their sources. Every prose sentence in the final draft is either:
* (a) a verbatim/near-verbatim lift with a citation in the form
* `[source: <meeting-id> ~mm:ss]`, OR
* (b) connective tissue, wrapped in `<connective>...</connective>` tags.
*
* Connective tissue is budgeted at ≤20% of sentences. Anything above is
* paraphrase-slop and gets rejected.
*
* This forces pods to stitch verbatim fragments instead of laundering the
* user's voice through rewriting.
*/
export function requireCitations(draft: string): {
pass: boolean;
totalSentences: number;
citedSentences: number;
connectiveSentences: number;
uncitedSentences: string[];
connectiveRatio: number;
reasons: string[];
} {
// Strip the draft section markers — only check the actual prose body.
// Convention: prose body is whatever is NOT inside fenced code blocks or
// markdown headings.
const stripped = draft
.replace(/```[\s\S]*?```/g, "")
.replace(/^#.*$/gm, "")
.replace(/^---.*$/gm, "");
// Pull out connective-wrapped spans first, count them, then remove them
// so they don't get re-counted in the sentence split.
const connectiveMatches = stripped.match(/<connective>[\s\S]*?<\/connective>/gi) || [];
const connectiveSentences = connectiveMatches.reduce((n, chunk) => {
const inner = chunk.replace(/<\/?connective>/gi, "");
return n + splitSentences(inner).length;
}, 0);
const withoutConnective = stripped.replace(/<connective>[\s\S]*?<\/connective>/gi, "");
const sentences = splitSentences(withoutConnective);
const citeRe = /\[source:\s*[^\]]+?~\s*\d{1,3}:\d{2}[^\]]*\]/i;
const cited: string[] = [];
const uncited: string[] = [];
for (const s of sentences) {
if (citeRe.test(s)) cited.push(s);
else uncited.push(s);
}
const totalSentences = sentences.length + connectiveSentences;
const citedSentences = cited.length;
const connectiveRatio =
totalSentences === 0 ? 0 : connectiveSentences / totalSentences;
const reasons: string[] = [];
if (uncited.length > 0) {
reasons.push(
`${uncited.length} prose sentence(s) lack [source: ...~mm:ss] citation and are not wrapped in <connective>...`,
);
}
if (connectiveRatio > 0.35) {
reasons.push(
`connective tissue ratio ${(connectiveRatio * 100).toFixed(0)}% exceeds 35% budget`,
);
}
return {
pass: reasons.length === 0,
totalSentences,
citedSentences,
connectiveSentences,
uncitedSentences: uncited,
connectiveRatio,
reasons,
};
}
/**
* Flow gate. Catches telegram prose (uniform sentence lengths, zero range)
* that the tone gate misses. Rhythm is controlled by a selectable profile,
* not a single hardcoded target — the writer picks which fingerprint the
* draft should aim for.
*
* Profiles are thresholds, not style rules. A profile answers: "what does
* minimally-varied prose look like for this target?" The default `balanced`
* profile is writer-agnostic — it catches metronome rhythm without
* prescribing any specific stylist. Named profiles (pg, etc.) are opt-in
* when the task explicitly wants that fingerprint.
*
* Adding a profile: measure a corpus, drop the numbers in FLOW_PROFILES.
* pg is grounded in a 30,377-sentence analysis of 215 PG essays from
* HuggingFace (sgoel9/paul_graham_essays, April 2026 run).
*
* Apply only to long-form drafts (≥10 sentences). Taglines, headers, and
* tuning-fork copy are exempt.
*/
export type FlowProfile = {
name: string;
source: string;
stdev: number;
rolling5: number;
lowVarianceCeiling: number;
shortFloor: number;
longFloor: number;
};
export const FLOW_PROFILES: Record<string, FlowProfile> = {
balanced: {
name: "balanced",
source: "writer-agnostic telegram detector; loose floors that catch metronome rhythm without prescribing any one stylist",
stdev: 6.0,
rolling5: 5.5,
lowVarianceCeiling: 0.4,
shortFloor: 0.08,
longFloor: 0.15,
},
pg: {
name: "pg",
source: "Paul Graham corpus, 30377 sentences across 215 essays (HuggingFace sgoel9/paul_graham_essays, April 2026). Measured: stdev 9.79, rolling5 8.42, lowvar 18%, short 15.1%, long 27.9%",
stdev: 7.5,
rolling5: 7.0,
lowVarianceCeiling: 0.3,
shortFloor: 0.1,
longFloor: 0.18,
},
};
export function checkFlow(
text: string,
opts: { minSentences?: number; profile?: string } = {},
): {
pass: boolean;
profile: string;
violations: string[];
stats: {
sentences: number;
meanLength: number;
medianLength: number;
stdev: number;
rolling5Stdev: number;
lowVarianceWindowRatio: number;
shortRatio: number;
longRatio: number;
};
} {
const minSentences = opts.minSentences ?? 10;
const profileName = opts.profile ?? "balanced";
const profile = FLOW_PROFILES[profileName];
if (!profile) {
throw new Error(
`[checkFlow] unknown profile '${profileName}'. Available: ${Object.keys(FLOW_PROFILES).join(", ")}`,
);
}
const stripped = text
.replace(/```[\s\S]*?```/g, "")
.replace(/^#.*$/gm, "")
.replace(/^---[\s\S]*?---/m, "")
.replace(/<\/?connective>/gi, "")
.replace(/\[source:[^\]]*\]/gi, "");
const sentences = splitSentences(stripped);
const lengths = sentences.map((s) => s.split(/\s+/).filter(Boolean).length);
const zeroStats = {
sentences: lengths.length,
meanLength: 0,
medianLength: 0,
stdev: 0,
rolling5Stdev: 0,
lowVarianceWindowRatio: 0,
shortRatio: 0,
longRatio: 0,
};
if (lengths.length < minSentences) {
return { pass: true, profile: profileName, violations: [], stats: zeroStats };
}
const mean = lengths.reduce((a, b) => a + b, 0) / lengths.length;
const sorted = [...lengths].sort((a, b) => a - b);
const median = sorted[Math.floor(sorted.length / 2)];
const variance = lengths.reduce((a, b) => a + (b - mean) ** 2, 0) / lengths.length;
const stdev = Math.sqrt(variance);
// Rolling 5-sentence window stdevs
const windowStdevs: number[] = [];
for (let i = 0; i + 5 <= lengths.length; i++) {
const w = lengths.slice(i, i + 5);
const wMean = w.reduce((a, b) => a + b, 0) / 5;
const wVar = w.reduce((a, b) => a + (b - wMean) ** 2, 0) / 5;
windowStdevs.push(Math.sqrt(wVar));
}
const rolling5Stdev =
windowStdevs.length === 0
? stdev
: windowStdevs.reduce((a, b) => a + b, 0) / windowStdevs.length;
const lowVarianceWindows = windowStdevs.filter((s) => s < 5).length;
const lowVarianceWindowRatio =
windowStdevs.length === 0 ? 0 : lowVarianceWindows / windowStdevs.length;
const shortRatio = lengths.filter((l) => l < 8).length / lengths.length;
const longRatio = lengths.filter((l) => l > 20).length / lengths.length;
const violations: string[] = [];
if (stdev < profile.stdev) {
violations.push(
`stdev ${stdev.toFixed(1)} < ${profile.stdev} floor (profile: ${profile.name}). Vary sentence length more.`,
);
}
if (rolling5Stdev < profile.rolling5) {
violations.push(
`rolling-5 window stdev ${rolling5Stdev.toFixed(1)} < ${profile.rolling5} floor (profile: ${profile.name}). Metronome rhythm; break it up.`,
);
}
if (lowVarianceWindowRatio > profile.lowVarianceCeiling) {
violations.push(
`${(lowVarianceWindowRatio * 100).toFixed(0)}% of 5-sentence windows have stdev<5, ceiling ${(profile.lowVarianceCeiling * 100).toFixed(0)}% (profile: ${profile.name}). Too many flat runs.`,
);
}
if (shortRatio < profile.shortFloor) {
violations.push(
`only ${(shortRatio * 100).toFixed(0)}% of sentences are under 8 words, floor ${(profile.shortFloor * 100).toFixed(0)}% (profile: ${profile.name}). Add short punches for emphasis.`,
);
}
if (longRatio < profile.longFloor) {
violations.push(
`only ${(longRatio * 100).toFixed(0)}% of sentences are over 20 words, floor ${(profile.longFloor * 100).toFixed(0)}% (profile: ${profile.name}). Add flowing clause-joined sentences.`,
);
}
return {
pass: violations.length === 0,
profile: profileName,
violations,
stats: {
sentences: lengths.length,
meanLength: Math.round(mean * 10) / 10,
medianLength: median,
stdev: Math.round(stdev * 100) / 100,
rolling5Stdev: Math.round(rolling5Stdev * 100) / 100,
lowVarianceWindowRatio: Math.round(lowVarianceWindowRatio * 100) / 100,
shortRatio: Math.round(shortRatio * 100) / 100,
longRatio: Math.round(longRatio * 100) / 100,
},
};
}
function splitSentences(text: string): string[] {
return text
.split(/(?<=[.!?])\s+/)
.map((s) => s.trim())
.filter((s) => s.length > 0 && /[A-Za-z]/.test(s));
}
// --- CLI ---
if ((() => { try { return import.meta.url === `file://${realpathSync(process.argv[1])}`; } catch { return false; } })()) {
(async () => {
const [, , cmd, ...args] = process.argv;
switch (cmd) {
case "tone": {
const guide = getToneGuide();
console.log(`One-liner: ${guide.oneLiner}`);
console.log(`Short tagline: ${guide.shortTagline}`);
console.log(`\nTuning fork:`);
for (const s of guide.tuningFork) console.log(` - ${s}`);
console.log(`\nPrinciples:`);
for (const p of guide.principles) console.log(` - ${p}`);
break;
}
case "banned": {
const phrases = getBannedPhrases();
for (const p of phrases) console.log(` - ${p}`);
console.log(`\n${phrases.length} banned phrases total.`);
break;
}
case "check": {
const text = args.join(" ");
if (!text) { console.error("Usage: api.ts check <text>"); process.exit(1); }
const result = checkTone(text);
if (result.pass) {
console.log("PASS -- no banned phrases or rhythm patterns detected.");
} else {
console.log("FAIL -- violations found:");
for (const v of result.violations) console.log(` - ${v}`);
process.exit(1);
}
break;
}
case "cite": {
const path = args[0];
if (!path) { console.error("Usage: api.ts cite <path-to-draft>"); process.exit(1); }
const draft = readFileSync(path, "utf-8");
const result = requireCitations(draft);
console.log(`total sentences: ${result.totalSentences}`);
console.log(`cited (transcript): ${result.citedSentences}`);
console.log(`connective (wrapped): ${result.connectiveSentences}`);
console.log(`connective ratio: ${(result.connectiveRatio * 100).toFixed(1)}% (budget: 20%)`);
if (result.pass) {
console.log("\nPASS -- all prose cited or wrapped, ratio within budget.");
} else {
console.log("\nFAIL:");
for (const r of result.reasons) console.log(` - ${r}`);
if (result.uncitedSentences.length > 0) {
console.log("\nUncited sentences (first 5):");
for (const s of result.uncitedSentences.slice(0, 5)) {
console.log(` - ${s.slice(0, 120)}${s.length > 120 ? "..." : ""}`);
}
}
process.exit(1);
}
break;
}
case "flow": {
let path: string | undefined;
let profileName = "balanced";
for (let i = 0; i < args.length; i++) {
if (args[i] === "--profile" || args[i] === "-p") {
profileName = args[i + 1];
i++;
} else if (!path) {
path = args[i];
}
}
if (!path) {
console.error("Usage: api.ts flow <path-to-draft> [--profile balanced|pg]");
console.error(`Available profiles: ${Object.keys(FLOW_PROFILES).join(", ")}`);
process.exit(1);
}
const draft = readFileSync(path, "utf-8");
const result = checkFlow(draft, { profile: profileName });
const p = FLOW_PROFILES[profileName];
console.log(`profile: ${p.name}`);
console.log(`sentences: ${result.stats.sentences}`);
console.log(`mean length: ${result.stats.meanLength}`);
console.log(`median length: ${result.stats.medianLength}`);
console.log(`stdev: ${result.stats.stdev} (floor: ${p.stdev})`);
console.log(`rolling-5 stdev: ${result.stats.rolling5Stdev} (floor: ${p.rolling5})`);
console.log(`low-variance ratio: ${(result.stats.lowVarianceWindowRatio * 100).toFixed(0)}% (ceiling: ${(p.lowVarianceCeiling * 100).toFixed(0)}%)`);
console.log(`short ratio (<8 w): ${(result.stats.shortRatio * 100).toFixed(0)}% (floor: ${(p.shortFloor * 100).toFixed(0)}%)`);
console.log(`long ratio (>20 w): ${(result.stats.longRatio * 100).toFixed(0)}% (floor: ${(p.longFloor * 100).toFixed(0)}%)`);
if (result.pass) {
console.log(`\nPASS -- flow within '${p.name}' profile thresholds.`);
} else {
console.log("\nFAIL:");
for (const v of result.violations) console.log(` - ${v}`);
process.exit(1);
}
break;
}
default:
console.log("Usage: npx tsx api.ts [tone|banned|check|cite|flow] ...");
}
})();
}
scripts- helper scripts it can run
prose-only skill - 1 inline code block live in SKILL.md above (no state/bin/ sidecar yet).
how we check it- the checks, plus the last 10 runs
| timestamp | verb | score | primary_issue | artifact |
|---|---|---|---|---|
| 2026-04-25 04:11Z | - | 1.00 | - | - |
| 2026-04-21 15:58Z | - | 1.00 | - | - |
| 2026-04-21 15:56Z | - | 1.00 | - | - |
| 2026-04-21 03:53Z | - | 1.00 | - | - |
| 2026-04-25 04:11Z | - | 1.00 | - | - |
| 2026-04-21 15:58Z | - | 1.00 | - | - |
| 2026-04-21 15:56Z | - | 1.00 | - | - |
| 2026-04-21 03:53Z | - | 1.00 | - | - |
| 2026-04-25 04:11Z | - | 1.00 | - | - |
| 2026-04-21 15:58Z | - | 1.00 | - | - |