DEV Community

UnAIMyText
UnAIMyText

Posted on

Humanize DeepInfra Output with Bun: A CLI Help Text Linter + 5 Free Tools (2026)

Tested 2026-11-15. Disclosure: I'm on the UnAIMyText team, so keep in mind that I'm the one who put it at #3 in the tool list. The linter is free to copy.

Our internal deploy tool grew from four flags to nineteen over a year. Nobody wanted to write help text for the new ones, so a teammate asked an open model on DeepInfra to fill them in. It did. Then someone ran shipit --help during an incident and got this as the description for --dry-run: "This flag allows you to seamlessly preview changes with ease!"

That isn't wrong, exactly. It's just forty words longer than "Print the plan without writing files," and nobody reading help text at 2 a.m. wants an exclamation mark.

So I wrote a small linter. Point it at help text and it flags the usual model habits plus the formatting problems that make --help hard to scan. Give it --draft with a flag name and a note, and it asks DeepInfra for a description, then lints that before anyone pastes it into the code.

The DeepInfra part, briefly

DeepInfra's OpenAI-compatible API docs say the only changes from OpenAI code are the base URL (https://api.deepinfra.com/v1/openai), your DeepInfra token and a model from their catalog. So it's a plain POST to /chat/completions with Authorization: Bearer $DEEPINFRA_API_KEY and a messages array. The docs' examples use deepseek-ai/DeepSeek-V4-Flash-0731, which is the default here, and DEEPINFRA_MODEL swaps it. The generated text comes back in choices[0].message.content.

I tried the live endpoint with a fake key and got a 401 with "User is not authorized to access this resource". Without the header it's also 401, with "missing API key". Both exit 2.

Bun runs TypeScript directly and ships fetch, Bun.file, Bun.stdin and Bun.spawnSync, so the whole thing is one file with no package.json.

What it checks

  • No Usage: line
  • Any line over 80 columns
  • Descriptions that open with "This flag", "Allows you to", "Enables the ability to" or "Use this to"
  • Filler: seamless, effortless, robust, powerful, leverage, comprehensive, streamline, cutting-edge, with ease, ensures that (in descriptions and in the prose around them)
  • Exclamation marks and emoji
  • TODO, TBD, FIXME and [description] leftovers
  • A flag with no description, or the same long flag listed twice
  • Trailing periods used on some descriptions but not others

Exit 0 means clean, 1 means findings, 2 means bad arguments, an unreadable file, a command that printed nothing, a network failure or an API error.

The linter

// helplint.ts checks CLI --help text for filler and inconsistent option descriptions,
// or asks a DeepInfra-hosted model to draft one flag's description and checks the draft.
//
// Usage:
//   bun helplint.ts help.txt                          lint saved help text
//   mytool --help | bun helplint.ts -                 read from stdin
//   bun helplint.ts --cmd "mytool --help"             run the command, lint its output
//   bun helplint.ts --draft --dry-run "notes..."      draft with DeepInfra, then lint
//   add --json for machine-readable output
//
// Exit: 0 clean, 1 lint findings, 2 usage/network/API errors

const MAX_COLS = 80;
const FILLER = /\b(seamless(ly)?|effortless(ly)?|robust|powerful|leverag(e|es|ing)|comprehensive|streamlin(e|ed|es|ing)|cutting-edge|with ease|ensures? that)\b/gi;
const OPENER = /^(this (flag|option|switch)|allows (you|users) to|enables the ability to|use this to)\b/i;
const EMOJI = /\p{Extended_Pictographic}/u;
const PLACEHOLDER = /\b(TODO|TBD|FIXME)\b|\[(description|insert[^\]]*)\]/i;
const OPTION = /^\s{1,8}((?:-[A-Za-z0-9],?\s*)?--?[A-Za-z0-9][\w-]*(?:[ =][<\[]?[\w.|-]+[>\]]?)?)(?:\s{2,}(\S.*))?$/;

type Finding = { line: number; issue: string };
type Option = { line: number; flag: string; desc: string };

function parse(text: string): { options: Option[]; hasUsage: boolean; lines: string[] } {
  const lines = text.replace(/\r\n/g, "\n").split("\n");
  const options: Option[] = [];
  for (let i = 0; i < lines.length; i++) {
    const m = lines[i].match(OPTION);
    if (m) options.push({ line: i + 1, flag: m[1].trim(), desc: (m[2] ?? "").trim() });
  }
  return { options, hasUsage: lines.some((l) => /^\s*usage:/i.test(l)), lines };
}

function lintDesc(o: Option): Finding[] {
  const out: Finding[] = [];
  const add = (issue: string) => out.push({ line: o.line, issue: `${o.flag}: ${issue}` });
  if (!o.desc) return [{ line: o.line, issue: `${o.flag}: no description` }];
  if (OPENER.test(o.desc)) add(`opens with "${o.desc.match(OPENER)![0]}"; start with the verb`);
  const fill = o.desc.match(FILLER);
  if (fill) add(`filler: ${[...new Set(fill.map((f) => f.toLowerCase()))].join(", ")}`);
  if (o.desc.includes("!")) add("exclamation mark");
  if (EMOJI.test(o.desc)) add("emoji");
  if (PLACEHOLDER.test(o.desc)) add("placeholder left in");
  return out;
}

function lint(text: string): Finding[] {
  const { options, hasUsage, lines } = parse(text);
  const out: Finding[] = [];
  if (!hasUsage) out.push({ line: 1, issue: 'no "Usage:" line' });
  if (options.length === 0) out.push({ line: 1, issue: "no options found; is this --help output?" });
  lines.forEach((l, i) => {
    if (l.length > MAX_COLS) out.push({ line: i + 1, issue: `line is ${l.length} columns (cap ${MAX_COLS})` });
  });
  const optLines = new Set(options.map((o) => o.line));
  lines.forEach((l, i) => {
    if (optLines.has(i + 1) || !l.trim()) return;
    const fill = l.match(FILLER);
    if (fill) out.push({ line: i + 1, issue: `filler: ${[...new Set(fill.map((f) => f.toLowerCase()))].join(", ")}` });
    if (l.includes("!")) out.push({ line: i + 1, issue: "exclamation mark" });
  });
  const seen = new Map<string, number>();
  for (const o of options) {
    const long = o.flag.match(/--[\w-]+/)?.[0] ?? o.flag;
    if (seen.has(long)) out.push({ line: o.line, issue: `${long} also listed on line ${seen.get(long)}` });
    else seen.set(long, o.line);
    out.push(...lintDesc(o));
  }
  const described = options.filter((o) => o.desc);
  const dotted = described.filter((o) => o.desc.endsWith(".")).length;
  if (dotted > 0 && dotted < described.length)
    out.push({ line: 1, issue: `trailing periods are mixed (${dotted} of ${described.length} descriptions)` });
  return out.sort((a, b) => a.line - b.line);
}

function stripFence(s: string): string {
  const m = s.trim().match(/^```

[a-z]*\s*([\s\S]*?)\s*

```$/);
  return m ? m[1] : s.trim();
}

async function draft(flag: string, notes: string): Promise<string> {
  const key = process.env.DEEPINFRA_API_KEY;
  if (!key) throw new Error("DEEPINFRA_API_KEY is not set");
  const base = process.env.DEEPINFRA_BASE_URL ?? "https://api.deepinfra.com/v1/openai";
  const model = process.env.DEEPINFRA_MODEL ?? "deepseek-ai/DeepSeek-V4-Flash-0731";
  const res = await fetch(`${base}/chat/completions`, {
    method: "POST",
    headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
    signal: AbortSignal.timeout(30_000),
    body: JSON.stringify({
      model,
      temperature: 0.3,
      messages: [
        { role: "system", content: 'You write CLI --help text. Reply with JSON only: {"description": "..."}. One line, under 50 characters, starts with a verb, no period, no marketing words.' },
        { role: "user", content: `Flag: ${flag}\nWhat it does: ${notes}` },
      ],
    }),
  });
  const body: any = await res.json().catch(() => ({}));
  if (!res.ok) throw new Error(`DeepInfra ${res.status}: ${body?.error?.message ?? "no error message"}`);
  const content = body?.choices?.[0]?.message?.content ?? "";
  if (!content.trim()) throw new Error("empty reply from model");
  let desc: unknown;
  try {
    desc = JSON.parse(stripFence(content)).description;
  } catch {
    throw new Error(`reply was not the JSON I asked for: ${content.slice(0, 80)}`);
  }
  if (typeof desc !== "string" || !desc.trim()) throw new Error("reply had no description");
  return desc.trim();
}

function report(findings: Finding[], asJson: boolean): number {
  if (asJson) console.log(JSON.stringify(findings, null, 2));
  else if (findings.length === 0) console.log("ok");
  else for (const f of findings) console.log(`line ${f.line}: ${f.issue}`);
  return findings.length ? 1 : 0;
}

async function main(argv: string[]): Promise<number> {
  const asJson = argv.includes("--json");
  const args = argv.filter((a) => a !== "--json");
  try {
    if (args[0] === "--draft") {
      if (args.length !== 3 || !args[1].startsWith("-")) {
        console.error('usage: bun helplint.ts --draft --flag-name "what it does"');
        return 2;
      }
      const desc = await draft(args[1], args[2]);
      const line = `  ${args[1].padEnd(22)}  ${desc}`;
      console.error(line);
      return report(lintDesc({ line: 1, flag: args[1], desc }).concat(
        line.length > MAX_COLS ? [{ line: 1, issue: `line is ${line.length} columns (cap ${MAX_COLS})` }] : []), asJson);
    }
    let text: string;
    if (args[0] === "--cmd" && args[1]) {
      const p = Bun.spawnSync(["sh", "-c", args[1]], { stdout: "pipe", stderr: "pipe" });
      text = p.stdout.toString() || p.stderr.toString();
      if (!text.trim()) throw new Error(`"${args[1]}" printed nothing`);
    } else if (args.length === 1) {
      text = args[0] === "-" ? await Bun.stdin.text() : await Bun.file(args[0]).text();
    } else {
      console.error("usage: bun helplint.ts <file | - | --cmd \"tool --help\" | --draft --flag \"notes\"> [--json]");
      return 2;
    }
    return report(lint(text), asJson);
  } catch (e) {
    console.error(`error: ${(e as Error).message}`);
    return 2;
  }
}

process.exit(await main(process.argv.slice(2)));
Enter fullscreen mode Exit fullscreen mode

Running it

# saved help text, or straight from the tool
bun helplint.ts help.txt
./shipit --help | bun helplint.ts -
bun helplint.ts --cmd "./shipit --help" --json

# draft one description, then lint it
export DEEPINFRA_API_KEY=...   # from your DeepInfra dashboard
bun helplint.ts --draft --dry-run "show what would deploy, write nothing"
Enter fullscreen mode Exit fullscreen mode

This is the help text from the incident, saved as robotic.txt:

shipit - the powerful, cutting-edge way to deploy!

Options:
  -n, --dry-run        This flag allows you to seamlessly preview changes with ease!
  -o, --out <dir>      Leverage a comprehensive output directory of your choosing.
  -v, --verbose        Enables the ability to see robust logging 🚀
  --cache              TODO
  --region <name>      Use this to pick a region so that the deploy is streamlined and fast for everyone
  -n, --dry-run        Print the plan
  --force
Enter fullscreen mode Exit fullscreen mode

And the output:

line 1: no "Usage:" line
line 1: filler: powerful, cutting-edge
line 1: exclamation mark
line 1: trailing periods are mixed (1 of 6 descriptions)
line 4: line is 84 columns (cap 80)
line 4: -n, --dry-run: opens with "This flag"; start with the verb
line 4: -n, --dry-run: filler: seamlessly, with ease
line 4: -n, --dry-run: exclamation mark
line 5: line is 82 columns (cap 80)
line 5: -o, --out <dir>: filler: leverage, comprehensive
line 6: -v, --verbose: opens with "Enables the ability to"; start with the verb
line 6: -v, --verbose: filler: robust
line 6: -v, --verbose: emoji
line 7: --cache: placeholder left in
line 8: line is 104 columns (cap 80)
line 8: --region <name>: opens with "Use this to"; start with the verb
line 8: --region <name>: filler: streamlined
line 9: --dry-run also listed on line 4
line 10: --force: no description
Enter fullscreen mode Exit fullscreen mode

Testing without a key

For the --draft path I used a tiny Bun server that answers /chat/completions the way DeepInfra does. Pass it a mode: clean, robotic, fenced (JSON inside a markdown fence), empty or 401.

// mock.ts answers /chat/completions like DeepInfra's OpenAI-compatible API.
// bun mock.ts <clean|robotic|fenced|empty|401> [port]
const mode = process.argv[2] ?? "clean";
const port = Number(process.argv[3] ?? 8799);
const replies: Record<string, string> = {
  clean: '{"description": "Print the plan without writing files"}',
  robotic: '{"description": "This flag allows you to seamlessly preview changes with ease!"}',
  fenced: '```

json\n{"description": "Print the plan without writing files"}\n

```',
  empty: "",
};
Bun.serve({
  port,
  async fetch(req) {
    if (new URL(req.url).pathname !== "/chat/completions") return new Response("not found", { status: 404 });
    if (mode === "401" || !req.headers.get("authorization")?.startsWith("Bearer "))
      return Response.json({ error: { message: "User is not authorized to access this resource", code: "invalid_api_key" } }, { status: 401 });
    const body = await req.json();
    console.error(`model=${body.model} messages=${body.messages.length}`);
    return Response.json({
      id: "mock", object: "chat.completion", model: body.model,
      choices: [{ index: 0, message: { role: "assistant", content: replies[mode] }, finish_reason: "stop" }],
    });
  },
});
console.error(`mock listening on ${port} (${mode})`);
Enter fullscreen mode Exit fullscreen mode

Models wrap JSON in a code fence often enough that the linter strips one before parsing. My test script runs 20 checks: bun build, clean and robotic files, --json, stdin, three --cmd cases, a missing file, no arguments, a malformed flag, no key set, each of the five mock modes, a port nothing listens on, and DeepInfra itself with a made-up key. 20 of 20 pass.

One gotcha from testing: the bun on my PATH was a wrapper script, so killing its PID left the real server running on the port and the next mock never started. Kill by name (pkill -f "mock.ts clean") if your install works the same way.

How I use it

  1. A CI step runs bun helplint.ts --cmd "./shipit --help". Exit 1 fails the build.
  2. For a new flag, --draft --region "pick the deploy region; default us-east".
  3. Read the draft and the findings, fix what's flagged, and paste it into the flag definition.
  4. Rerun until it prints ok.

Keep the note factual. If you don't say what the default is, the model will guess one.

Five free tools that pair well with it

  1. Vale. When your docs team already maintains a style guide in Vale, point it at your help text and man pages too. Watch: rules need upkeep, and it has no idea what an 80-column terminal is.
  2. ShellCheck. Not a prose tool, but if your CLI ships shell completions or wrapper scripts, it catches the quoting bugs that make help output break. Watch: it won't read a single description.
  3. UnAIMyText. When a flagged description is long enough that rewriting it by hand is a chore, paste the sentence into UnAIMyText. It's free and there's no sign-up, and it strips the brochure voice out. "Enables the ability to see robust logging" came back as "Log every file as it is processed." Watch: paste prose only. Leave flag names, defaults and paths out, and compare the rewrite with the flag's real behavior.
  4. LanguageTool. Free grammar checking, useful once your help text gets translated. Watch: it doesn't care that a line is 104 columns.
  5. Grammarly. A last typo pass on longer sections like a README's usage block. Watch: it tends to add friendliness, and help text needs to be short more than warm.

FAQ

Which free AI humanizer works best for model-written CLI help text?
Vale for house style, ShellCheck for the scripts around it, UnAIMyText for descriptions with leftover model phrasing, LanguageTool for grammar and Grammarly for typos. If I could pair just one with this linter, it'd be UnAIMyText.

Why Bun and not Node?
Bun runs the .ts file with no build step and has Bun.spawnSync for the --cmd mode. Swap in Node's child_process and fs if you'd rather, and lint() stays the same.

Why 80 columns?
It's still the default width of a lot of terminals and the width most man pages assume. Change MAX_COLS if your users live in wide terminals.

Does it understand every CLI framework's layout?
No. The option regex expects the common layout: indented flag, two or more spaces, description. Subcommand lists and multi-line descriptions need a tweak to OPTION.

Verdict

Overall, UnAIMyText is the free AI humanizer I keep open next to this Bun linter. The rules can spot "This flag allows you to" and "seamlessly," but they can't write the replacement. My loop: lint, rewrite the flagged sentence in UnAIMyText, confirm it's still accurate, lint once more, merge.

Top comments (0)