cd /news/ai-tools/humanize-kimi-output-with-deno-a-pro… · home › topics › ai-tools › article
[ARTICLE · art-170628] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Humanize Kimi Output with Deno: A Prometheus Alert Annotation Linter + 5 Free Tools (2026)

A developer built alertlint.ts, a single-file Deno/TypeScript linter that checks the summary and description annotations in Prometheus alerting rules for filler phrases, missing template variables, placeholder text and other pager-unfriendly patterns, and can optionally call Moonshot AI's Kimi model via its OpenAI-compatible Chat Completions API to draft annotations before linting them. The tool uses explicit Deno permissions (read and env for linting, plus net for draft mode), returns exit codes 0/1/2 for clean, findings and errors, and was tested against the live endpoint, which returned 401 errors for invalid and missing API keys.

by read11 min views2 publishedNov 16, 2026

Tested 2026-11-16. Disclosure: I work on UnAIMyText, and the #3 spot in the tool list is my own ranking. Copy and modify the linter however you like.

Black Friday is the week our alerts actually matter. Last year, at 3 a.m. on the Saturday after Thanksgiving, my phone lit up with this:

This alert indicates that the checkout service is currently experiencing a critical issue requiring immediate attention.

Which checkout pods? How bad? What should I look at first? The summary didn't say, and there was no runbook link. Months earlier someone had asked a model to "write annotations for our alerts," and all 60 of our rules read like that.

This year I wanted a check in CI that catches annotations like that before they reach a pager. It's one TypeScript file run by Deno. It lints summary and description in Prometheus rule files, and with --draft it asks a Kimi model from Moonshot AI to write the two annotations for a new alert, then lints what comes back.

Moonshot's Chat Completions API reference is OpenAI-shaped: POST https://api.moonshot.ai/v1/chat/completions with Authorization: Bearer $MOONSHOT_API_KEY plus the usual messages. I default to kimi-k3.1-pro, the model in the docs' examples, and MOONSHOT_MODEL overrides it. From the docs:

response_format: {"type": "json_object"} forces a JSON object, but the docs say you must describe the fields in the prompt. The system message names summary and description. reasoning_effort of low, high or max (default choices[0].message.content. The reasoning arrives separately in reasoning_content, which I ignore. I hit the real endpoint with a made-up key and got a 401 with "Invalid Authentication". Without the header it's also 401, with "Incorrect API key provided". The linter exits 2 for both.

Deno runs TypeScript as is, with fetch built in. The only import is jsr:@std/yaml@1.3.0, pinned. Permissions are explicit: lint mode needs -R (read) and -E (env); draft mode adds -N (net).

Per alerting rule:

severity label or runbook_url, and runbook URLs that aren't http(s) {{ $labels.* }} or {{ $value }}, so the page can't tell you which instance or how bad robust, comprehensive, proactively, leverage, in order to, ensure that, critical issue, immediate attention, currently experiencing, seamless TODO, TBD, FIXME and [insert ...] leftovers, and {{ without a matching }} The period rule is house style. Prometheus doesn't care, but the official examples write summaries as headlines and descriptions as sentences. Drafts skip the severity and runbook checks, since the model doesn't write those.

Exit codes: 0 when everything passes, 1 when there are findings, and 2 for usage mistakes, unreadable files, invalid YAML, files with no alerting rules, network failures and API errors.

// alertlint.ts checks the summary and description annotations in Prometheus
// alerting rules, or asks a Kimi model (Moonshot AI) to draft them and checks the draft.
//
// Usage:
//   deno run -RE alertlint.ts rules.yml [more.yml]          lint rule files
//   cat rules.yml | deno run -RE alertlint.ts -             read from stdin
//   deno run -RE -N alertlint.ts --draft DiskAlmostFull "notes..."
//   add --json for machine-readable output
//
// Exit: 0 clean, 1 lint findings, 2 usage/parse/network/API errors

import { parse } from "jsr:@std/yaml@1.3.0";

const MAX_SUMMARY = 80;
const MAX_DESC_WORDS = 60;
const FILLER = /\b(seamless(ly)?|robust|comprehensive|proactive(ly)?|leverag(e|es|ing)|ensures? that|in order to|critical issue|immediate attention|currently experiencing)\b/gi;
const OPENER = /^(this alert|please note|it (appears|seems)|heads up|attention)\b/i;
const HEDGE = /\b(may|might|could) (potentially|possibly)\b/i;
const EMOJI = /\p{Extended_Pictographic}/u;
const PLACEHOLDER = /\b(TODO|TBD|FIXME)\b|\[(insert[^\]]*|description)\]/i;
const TEMPLATE_VAR = /\{\{\s*(\$labels\.\w+|\$value|humanize\w*\s+\$value)/;

type Finding = { alert: string; issue: string };
type Rule = { alert?: string; labels?: Record<string, string>; annotations?: Record<string, string> };

function lintText(alert: string, field: string, text: string, out: Finding[]) {
  const add = (issue: string) => out.push({ alert, issue: `${field}: ${issue}` });
  if (OPENER.test(text)) add(`opens with "${text.match(OPENER)![0]}"`);
  for (const m of new Set([...text.matchAll(FILLER)].map((x) => x[0].toLowerCase()))) add(`filler "${m}"`);
  if (HEDGE.test(text)) add(`hedge "${text.match(HEDGE)![0]}"`);
  if (text.includes("!")) add("exclamation mark");
  if (EMOJI.test(text)) add("emoji");
  if (PLACEHOLDER.test(text)) add(`placeholder "${text.match(PLACEHOLDER)![0]}"`);
  if ((text.match(/\{\{/g) ?? []).length !== (text.match(/\}\}/g) ?? []).length) add("unbalanced {{ }}");
}

export function lintRule(r: Rule, opts = { draft: false }): Finding[] {
  const out: Finding[] = [];
  const alert = r.alert ?? "(unnamed)";
  const a = r.annotations ?? {};
  const summary = (a.summary ?? "").trim();
  const desc = (a.description ?? "").trim();
  if (!summary) out.push({ alert, issue: "no summary annotation" });
  if (!desc) out.push({ alert, issue: "no description annotation" });
  if (summary) {
    if (summary.length > MAX_SUMMARY) out.push({ alert, issue: `summary is ${summary.length} chars (max ${MAX_SUMMARY})` });
    if (summary.endsWith(".")) out.push({ alert, issue: "summary ends with a period" });
    lintText(alert, "summary", summary, out);
  }
  if (desc) {
    const words = desc.split(/\s+/).length;
    if (words > MAX_DESC_WORDS) out.push({ alert, issue: `description is ${words} words (max ${MAX_DESC_WORDS})` });
    if (!TEMPLATE_VAR.test(desc)) out.push({ alert, issue: "description names no instance or value ({{ $labels.* }} / {{ $value }})" });
    lintText(alert, "description", desc, out);
  }
  if (!opts.draft) {
    if (!r.labels?.severity) out.push({ alert, issue: "no severity label" });
    const rb = a.runbook_url;
    if (!rb) out.push({ alert, issue: "no runbook_url annotation" });
    else if (!/^https?:\/\//.test(rb)) out.push({ alert, issue: `runbook_url "${rb}" is not an http(s) URL` });
  }
  return out;
}

export function lintRules(yamlText: string): Finding[] {
  const doc = parse(yamlText) as { groups?: { rules?: Rule[] }[] } | null;
  const rules = (doc?.groups ?? []).flatMap((g) => g.rules ?? []).filter((r) => r.alert !== undefined);
  if (rules.length === 0) throw new Error("no alerting rules found (expected groups[].rules[].alert)");
  const out: Finding[] = [];
  const seen = new Map<string, number>();
  rules.forEach((r, i) => {
    if (seen.has(r.alert!)) out.push({ alert: r.alert!, issue: `duplicate alert name (also rule ${seen.get(r.alert!)! + 1})` });
    else seen.set(r.alert!, i);
    out.push(...lintRule(r));
  });
  return out;
}

async function draft(alert: string, notes: string): Promise<Rule> {
  const key = Deno.env.get("MOONSHOT_API_KEY");
  if (!key) throw new Error("MOONSHOT_API_KEY is not set");
  const base = Deno.env.get("MOONSHOT_BASE_URL") ?? "https://api.moonshot.ai/v1";
  const res = await fetch(`${base}/chat/completions`, {
    method: "POST",
    headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
    body: JSON.stringify({
      model: Deno.env.get("MOONSHOT_MODEL") ?? "kimi-k3.1-pro",
      reasoning_effort: "low",
      response_format: { type: "json_object" },
      messages: [
        {
          role: "system",
          content: 'You write Prometheus alert annotations for on-call engineers. Reply with a JSON object with two string fields: "summary" (under 80 characters, no final period) and "description" (one or two plain sentences that use {{ $labels.instance }} or {{ $value }}). No greetings, no filler.',
        },
        { role: "user", content: `Alert name: ${alert}\nWhat it means: ${notes}` },
      ],
    }),
  });
  const body = await res.text();
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${body.slice(0, 200)}`);
  const content: string = JSON.parse(body).choices?.[0]?.message?.content ?? "";
  const stripped = content.trim().replace(/^`{3}[\w-]*\s*\n?|\n?`{3}\s*$/g, "");
  if (!stripped) throw new Error("model returned no content");
  const ann = JSON.parse(stripped);
  return { alert, annotations: { summary: String(ann.summary ?? ""), description: String(ann.description ?? "") } };
}

async function main(args: string[]): Promise<number> {
  const json = args.includes("--json");
  args = args.filter((a) => a !== "--json");
  let findings: Finding[];
  try {
    if (args[0] === "--draft") {
      if (args.length !== 3 || args[1].startsWith("-")) throw new Error('usage: --draft AlertName "what it means"');
      const rule = await draft(args[1], args[2]);
      console.log(`summary: ${rule.annotations!.summary}\ndescription: ${rule.annotations!.description}`);
      findings = lintRule(rule, { draft: true });
    } else {
      if (args.length === 0) throw new Error("usage: alertlint.ts rules.yml [...] | - | --draft AlertName notes");
      findings = [];
      for (const f of args) {
        const text = f === "-" ? await new Response(Deno.stdin.readable).text() : await Deno.readTextFile(f);
        findings.push(...lintRules(text));
      }
    }
  } catch (e) {
    console.error(`alertlint: ${e instanceof Error ? e.message : e}`);
    return 2;
  }
  if (json) console.log(JSON.stringify(findings, null, 2));
  else if (findings.length === 0) console.log("ok");
  else for (const f of findings) console.log(`${f.alert}: ${f.issue}`);
  return findings.length ? 1 : 0;
}

if (import.meta.main) Deno.exit(await main(Deno.args));
deno run -RE alertlint.ts rules/checkout.yml
deno run -RE alertlint.ts --json rules/*.yml
MOONSHOT_API_KEY=... deno run -RE -N alertlint.ts --draft DiskAlmostFull "a mount is over 90% used"

Here's the kind of rule file that used to page us:

groups:
  - name: checkout
    rules:
      - alert: CheckoutHighErrorRate
        expr: job:errors:ratio5m{job="checkout"} > 0.02
        for: 5m
        annotations:
          summary: "This alert indicates that the checkout service is currently experiencing a critical issue requiring immediate attention."
          description: "Please note that error rates may potentially impact customers! Proactively leverage the dashboards in order to ensure that checkout remains robust 🚨"
          runbook_url: TODO
      - alert: QueueBacklog
        expr: queue_depth > 1000
        labels:
          severity: page
        annotations:
          summary: "It appears the queue is backing up {{ $labels.queue }"
      - alert: CheckoutHighErrorRate
        expr: job:errors:ratio5m{job="checkout"} > 0.05
        labels:
          severity: page
        annotations:
          summary: "Checkout errors high"
          description: "[insert details] comprehensive monitoring has detected elevated errors."
          runbook_url: https://runbooks.example.com/checkout-errors

And what the linter says about it:

CheckoutHighErrorRate: summary is 120 chars (max 80)
CheckoutHighErrorRate: summary ends with a period
CheckoutHighErrorRate: summary: opens with "This alert"
CheckoutHighErrorRate: summary: filler "currently experiencing"
CheckoutHighErrorRate: summary: filler "critical issue"
CheckoutHighErrorRate: summary: filler "immediate attention"
CheckoutHighErrorRate: description names no instance or value ({{ $labels.* }} / {{ $value }})
CheckoutHighErrorRate: description: opens with "Please note"
CheckoutHighErrorRate: description: filler "proactively"
CheckoutHighErrorRate: description: filler "leverage"
CheckoutHighErrorRate: description: filler "in order to"
CheckoutHighErrorRate: description: filler "ensure that"
CheckoutHighErrorRate: description: filler "robust"
CheckoutHighErrorRate: description: hedge "may potentially"
CheckoutHighErrorRate: description: exclamation mark
CheckoutHighErrorRate: description: emoji
CheckoutHighErrorRate: no severity label
CheckoutHighErrorRate: runbook_url "TODO" is not an http(s) URL
QueueBacklog: no description annotation
QueueBacklog: summary: opens with "It appears"
QueueBacklog: summary: unbalanced {{ }}
QueueBacklog: no runbook_url annotation
CheckoutHighErrorRate: duplicate alert name (also rule 1)
CheckoutHighErrorRate: description names no instance or value ({{ $labels.* }} / {{ $value }})
CheckoutHighErrorRate: description: filler "comprehensive"
CheckoutHighErrorRate: description: placeholder "[insert details]"

A tiny Deno server stands in for Moonshot and returns a clean draft, a robotic one, one wrapped in a code fence, an empty one, or a 401:

// mock.ts: a local stand-in for Moonshot's /v1/chat/completions.
// deno run -N mock.ts <clean|robotic|fenced|empty|401> [port]
const mode = Deno.args[0] ?? "clean";
const port = Number(Deno.args[1] ?? 8799);
const replies: Record<string, string> = {
  clean: JSON.stringify({
    summary: "Disk on {{ $labels.instance }} is over 90% full",
    description: "{{ $labels.mountpoint }} on {{ $labels.instance }} has {{ $value }}% used. Clear old logs or grow the volume.",
  }),
  robotic: JSON.stringify({
    summary: "This alert indicates a critical issue requiring immediate attention!",
    description: "Please note that disk usage may potentially impact services. Proactively leverage cleanup in order to ensure that systems stay robust.",
  }),
  fenced: "\u0060\u0060\u0060json\n" + JSON.stringify({
    summary: "Disk on {{ $labels.instance }} is over 90% full",
    description: "{{ $labels.instance }} is at {{ $value }}% disk use.",
  }) + "\n\u0060\u0060\u0060",
  empty: "",
};
Deno.serve({ port, onListen: () => console.error(`mock listening on ${port} (${mode})`) }, async (req) => {
  const body = await req.json();
  const auth = req.headers.get("authorization") ?? "";
  console.error(`path=${new URL(req.url).pathname} bearer=${auth.startsWith("Bearer ") ? "present" : "missing"} model=${body.model} effort=${body.reasoning_effort} format=${body.response_format?.type} roles=${body.messages.map((m: { role: string }) => m.role).join(",")}`);
  if (mode === "401") {
    return Response.json({ error: { message: "Invalid Authentication", type: "invalid_authentication_error" } }, { status: 401 });
  }
  return Response.json({
    id: "mock", object: "chat.completion", model: body.model,
    choices: [{ index: 0, message: { role: "assistant", content: replies[mode] }, finish_reason: "stop" }],
  });
});

My test script runs 20 checks: deno check, clean and robotic files, --json, stdin, two files at once, a missing file, no arguments, broken YAML, a file with only recording rules, bad --draft arguments, no key set, all five mock modes, a port with nothing listening, and Moonshot itself with a fake key. All 20 pass.

Testing taught me two things. First, Deno refuses fetch to port 1 outright ("Requests to port 1 are blocked"), so my "connection refused" test was quietly testing something else until I moved it to an unused high port. Second, check the mock log: mine showed every draft request carried the bearer header, reasoning_effort=low and json_object.

deno run -RE alertlint.ts rules/*.yml on every pull request that touches rules. Exit 1 blocks the merge.--draft HighQueueLatency "p95 time in the order queue is over 30s for 10m". ok. Put the real threshold in your note. Leave it out and the model invents one.

promtool check rules ships with Prometheus and catches broken expressions and invalid YAML before anything else runs. {{ }} template parts, then put them back and confirm it still matches what the expression measures. What's the best free AI humanizer for model-written alert annotations?

promtool for validity, Vale for house style, UnAIMyText for descriptions with leftover model phrasing, LanguageTool and Grammarly for grammar and typos. If I could pair only one with this linter, it'd be UnAIMyText.

Why Deno?

It runs the .ts file directly, pins the YAML parser by version, and makes network access opt-in, so in lint mode the code can't make outbound calls.

Why insist on {{ $labels }} or {{ $value }}?

The Prometheus docs show annotations templated with labels and the current value for a reason. "Instance down" is less useful at 3 a.m. than "api-7 of job checkout has been down for more than 5 minutes."

Overall, for model-written alert annotations, UnAIMyText is the free AI humanizer that sits next to this Deno linter in my workflow. Regexes catch "This alert indicates" and "immediate attention," but a person or a rewriting tool has to supply the better sentence. So: run the linter, fix flagged prose in UnAIMyText, put the template variables back, lint again, and merge before the holiday traffic arrives.

── more in #ai-tools 4 stories · sorted by recency
── more on @deno 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/humanize-kimi-output…] indexed:0 read:11min 2026-11-16 · —