Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

648 B
Raw Blame
import type { CanonicalValue } from "@hypit/protocol";

const BARE = /^[^\s;,\[\]{}"']+$/u;
const NUMBER = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/u;

/** Serialize one canonical value without knowing which component consumes it. */
export function formatRecipeValue(value: CanonicalValue): string {
  if (value === null) return "null";
  if (typeof value === "boolean" || typeof value === "number") return String(value);
  if (typeof value === "string") {
    return BARE.test(value) && value !== "null" && value !== "true" && value !== "false" && !NUMBER.test(value)
      ? value
      : JSON.stringify(value);
  }
  return JSON.stringify(value);
}