<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lvyafei2026-coder</title>
    <description>The latest articles on DEV Community by lvyafei2026-coder (@lvyafei2026coder).</description>
    <link>https://dev.to/lvyafei2026coder</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4181063%2Fdd63c848-be62-41b1-aeff-3df087962c0f.jpg</url>
      <title>DEV Community: lvyafei2026-coder</title>
      <link>https://dev.to/lvyafei2026coder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lvyafei2026coder"/>
    <language>en</language>
    <item>
      <title>AI 生成的 PR 越来越多，如何用自动化门禁挡住不靠谱的提交</title>
      <dc:creator>lvyafei2026-coder</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:39:09 +0000</pubDate>
      <link>https://dev.to/lvyafei2026coder/ai-sheng-cheng-de-pr-yue-lai-yue-duo-ru-he-yong-zi-dong-hua-men-jin-dang-zhu-bu-kao-pu-de-ti-jiao-524j</link>
      <guid>https://dev.to/lvyafei2026coder/ai-sheng-cheng-de-pr-yue-lai-yue-duo-ru-he-yong-zi-dong-hua-men-jin-dang-zhu-bu-kao-pu-de-ti-jiao-524j</guid>
      <description>&lt;h1&gt;
  
  
  AI 生成的 PR 越来越多，如何用自动化门禁挡住不靠谱的提交
&lt;/h1&gt;

&lt;p&gt;最近在 Dev.to 上看到一篇讨论度很高的文章：《AI agents open 17 million pull requests a month. I built a gate that rejects the ones that lie.》。作者提到一个很现实的问题：当 AI agent 开始批量提交 PR，代码审查的瓶颈不再是「写代码」，而是「判断这段代码和它的描述是否可信」。评论区里不少人也分享了类似经历——PR 描述写得头头是道，点开 diff 却发现改的文件和说的功能对不上，测试没跑，甚至引入了新的 lint 错误。&lt;/p&gt;

&lt;p&gt;这不是某个团队的特例。只要你在项目里接入了自动修复、依赖升级机器人或者 AI 编码助手，迟早会遇到「提交量上去了，可信度下来了」的阶段。下面是我自己在几个开源项目里踩坑后总结的一套做法，重点不在工具本身，而在把「可信」变成可自动检查的条件。&lt;/p&gt;

&lt;h2&gt;
  
  
  问题拆解：AI 提交为什么容易「说谎」
&lt;/h2&gt;

&lt;p&gt;把问题拆开看，其实有三层：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;描述与 diff 不一致&lt;/strong&gt;。模型倾向于生成听起来合理的总结，但它并不真的「看过」自己改了什么。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;验证缺失&lt;/strong&gt;。很多 agent 提交 PR 时不会跑完整测试，或者只跑了被改动文件相关的子集。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;审查成本转移&lt;/strong&gt;。人类 reviewer 被迫做机械核对，真正需要判断力的部分反而没时间看。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;对应的解法也不是什么黑科技，而是把这三层分别变成流水线里的硬性检查。&lt;/p&gt;

&lt;h2&gt;
  
  
  解法一：用 diff 反查描述
&lt;/h2&gt;

&lt;p&gt;最有效的一步是让 CI 对比 PR 描述里提到的文件/函数名和实际 diff。做法很简单：从 PR body 里提取反引号包裹的标识符，检查它们是否出现在变更文件中。不匹配就要求作者补充说明。这一步能挡掉相当一部分「模板化描述」。&lt;/p&gt;

&lt;h2&gt;
  
  
  解法二：把测试门槛写死
&lt;/h2&gt;

&lt;p&gt;不要依赖 agent 自己声明「已测试」。在 CI 里强制要求：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;全量单元测试通过；&lt;/li&gt;
&lt;li&gt;lint 和类型检查零新增告警；&lt;/li&gt;
&lt;li&gt;覆盖率不低于基线。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;如果 agent 提交的 PR 跑不过，就自动打上 &lt;code&gt;needs-work&lt;/code&gt; 标签并退回，而不是等人来看。&lt;/p&gt;

&lt;h2&gt;
  
  
  解法三：给审查者减负
&lt;/h2&gt;

&lt;p&gt;审查者真正需要的是「这段改动值不值得看」。可以在 PR 里自动附上一段结构化摘要：改了哪些文件、新增/删除多少行、涉及哪些模块、有没有触碰敏感路径（比如 CI 配置、依赖清单）。这类信息用脚本就能生成，不需要模型。&lt;/p&gt;

&lt;h2&gt;
  
  
  一个容易被忽略的点：工具链本身要可信
&lt;/h2&gt;

&lt;p&gt;上面这些检查都依赖脚本和小工具。如果工具本身行为不稳定，门禁就会变成噪音源。我在项目里踩过的坑包括：本地和 CI 环境行为不一致、脚本对空 diff 报错、输出格式随版本变化。后来我的做法是尽量选行为确定、输入输出清晰的命令行工具，并且在 CI 里固定版本。&lt;/p&gt;

&lt;p&gt;如果你也在搭这类自动化门禁，可以看看 &lt;a href="https://devtools.toolara.dev" rel="noopener noreferrer"&gt;Toolara DevTools&lt;/a&gt;。它把常见的开发辅助能力（格式化、diff 分析、文本处理等）做成了可直接调用的在线工具，适合在写 CI 脚本或本地预检时快速验证输入输出，减少「本地能跑、CI 挂掉」的来回折腾。我自己用它来快速检查 diff 片段和生成结构化摘要，省掉了不少写一次性脚本的时间。&lt;/p&gt;

&lt;h2&gt;
  
  
  同类工具对比
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Actions + 自写脚本&lt;/strong&gt;：灵活度最高，适合有维护能力的团队，但需要自己处理边界情况。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Danger JS&lt;/strong&gt;：专注 PR 规则检查，生态成熟，适合已有 JS 工具链的项目。&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Toolara DevTools&lt;/strong&gt;：偏轻量的在线辅助工具集合，适合快速验证和原型阶段，不替代完整 CI 方案。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  小结
&lt;/h2&gt;

&lt;p&gt;AI 提交变多不是问题，问题是审查流程还停留在「靠人看」。把描述一致性、测试门槛、结构化摘要这三件事自动化，审查者就能把精力放回真正需要判断的地方。工具只是手段，关键是让「可信」变成流水线里可执行的检查项。&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devops</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Designing a prompt builder for a text-to-music model: 500 characters, 4 instruments, and a lot of restraint</title>
      <dc:creator>lvyafei2026-coder</dc:creator>
      <pubDate>Tue, 13 Oct 2026 06:05:49 +0000</pubDate>
      <link>https://dev.to/lvyafei2026coder/designing-a-prompt-builder-for-a-text-to-music-model-500-characters-4-instruments-and-a-lot-of-5105</link>
      <guid>https://dev.to/lvyafei2026coder/designing-a-prompt-builder-for-a-text-to-music-model-500-characters-4-instruments-and-a-lot-of-5105</guid>
      <description>&lt;p&gt;&lt;strong&gt;The input box is the product.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the only interface to your model is a single text field, output quality is decided before generation ever starts. Feed a text-to-music model &lt;code&gt;sad song&lt;/code&gt; and you get something generic — it has to guess the genre, the tempo, the instrumentation, whether you wanted vocals at all, and how long the track should be.&lt;/p&gt;

&lt;p&gt;We build a text-to-song tool, and the failure mode we kept running into wasn't "the model is bad". It was "the prompt contained no decisions". So we built a prompt builder: a free, static page that turns a few clicks plus one short idea into a prompt the model can act on.&lt;/p&gt;

&lt;p&gt;Here are the constraints we were working with, and the three decisions that followed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The constraints come first
&lt;/h2&gt;

&lt;p&gt;Before touching the UI, write down what the pipeline actually accepts. Ours:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Constraint&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prompt&lt;/td&gt;
&lt;td&gt;required, 5–500 characters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duration&lt;/td&gt;
&lt;td&gt;10–300 s at API level; 60 s on free tier, 120 s on paid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vocals&lt;/td&gt;
&lt;td&gt;lyrics required unless the request is explicitly instrumental&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;mp3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The 500-character cap is the one that shapes everything else. It's generous for a &lt;em&gt;specification&lt;/em&gt; and tiny for a &lt;em&gt;wish&lt;/em&gt;. Every control you add to the UI eats budget, so the UI has to make decisions &lt;strong&gt;for&lt;/strong&gt; the user instead of exposing raw parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decision 1: a controlled vocabulary, not free text
&lt;/h2&gt;

&lt;p&gt;Rather than let people type adjectives, we defined a fixed vocabulary per dimension: 14 genres, 9 moods, 6 tempo bands, 16 instruments, 5 vocal configurations, 2 lyric languages, 6 intended uses, 4 durations.&lt;/p&gt;

&lt;p&gt;Each option is a triple — an id and two labels — and the English label is literally the phrase the model receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;instrument&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;piano&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warm piano&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                    &lt;span class="na"&gt;zh&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;温暖的钢琴&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;drums&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;punchy live drums&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;             &lt;span class="na"&gt;zh&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;有力的实鼓&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pad&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="na"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lush synth pads&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;               &lt;span class="na"&gt;zh&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;宽广合成器铺底&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vinyl&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="na"&gt;en&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vinyl crackle and tape warmth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;zh&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;黑胶噪点与磁带暖声&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two reasons this beats a textarea:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The phrases are written in the vocabulary these models were trained on.&lt;/strong&gt; "vinyl crackle and tape warmth" carries production meaning; "sad vibes" carries almost none.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The output is stable and translatable.&lt;/strong&gt; Because the phrase is data rather than a string glued together from user input, the same choice can be rendered in a second language without asking the user to write a prompt in it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Decision 2: cap the instruments at four — and say why
&lt;/h2&gt;

&lt;p&gt;Our first version allowed unlimited instrument chips. Prompts ballooned into &lt;em&gt;"piano and acoustic guitar and electric guitar and strings and brass and synth pad and drums and bass"&lt;/em&gt;, and the mixes got muddier rather than richer: every timbre you name competes for the same arrangement space.&lt;/p&gt;

&lt;p&gt;So the cap is four, enforced at selection time rather than at submit time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onInstrumentToggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instruments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instruments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instruments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;MAX_INSTRUMENTS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="c1"&gt;// MAX_INSTRUMENTS = 4&lt;/span&gt;
      &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instruments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;                       &lt;span class="c1"&gt;// drop the oldest, not the newest&lt;/span&gt;
      &lt;span class="nf"&gt;showHint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Up to 4 instruments — we dropped the oldest one to keep the prompt focused.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instruments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The UX detail matters more than the number. Silent truncation reads as a bug; a four-second hint that says &lt;em&gt;which&lt;/em&gt; chip was dropped and &lt;em&gt;why&lt;/em&gt; reads as a rule. Users immediately re-pick instead of filing a complaint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decision 3: a prompt is not a translation
&lt;/h2&gt;

&lt;p&gt;Roughly half of our users write in Chinese. The naive approach — build the English prompt, then translate the template — breaks in three places: clause order, punctuation, and connectors.&lt;/p&gt;

&lt;p&gt;Same configuration, two builders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pop at a slow 75 BPM. Warm piano and a soaring string section. A warm and romantic mood.
Female lead vocals sung in Chinese. Theme: missing someone on a long train ride home.
Written as a personal gift song for someone special, about 120 seconds.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;流行风格，慢板 75 BPM。配器：温暖的钢琴、磅礴弦乐。情绪：温暖浪漫。
女声主唱，中文演唱。主题：在回家的长途列车上思念一个人。
作为送给亲友的定制歌曲，时长约 120 秒。
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things a string-level translation would mangle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Order.&lt;/strong&gt; Chinese groups instruments and mood as labelled fields (&lt;code&gt;配器：&lt;/code&gt;, &lt;code&gt;情绪：&lt;/code&gt;) and puts the theme before the intended use. English reads better as genre → instruments → mood → vocal → theme → use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connectors.&lt;/strong&gt; English needs &lt;code&gt;a, b and c&lt;/code&gt; (plus &lt;code&gt;a&lt;/code&gt; / &lt;code&gt;an&lt;/code&gt; agreement); Chinese uses &lt;code&gt;、&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Punctuation.&lt;/strong&gt; Sentences end with &lt;code&gt;。&lt;/code&gt;, clauses join with &lt;code&gt;，&lt;/code&gt; — not ASCII &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the builder assembles clauses per language, and each vocabulary entry carries both labels. One data structure, two grammars, nothing to keep in sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  Show the budget instead of hiding it
&lt;/h2&gt;

&lt;p&gt;If a limit exists, put it on screen. The builder renders a live counter (&lt;code&gt;184 / 500 characters&lt;/code&gt;) and turns it into a warning once the cap is passed.&lt;/p&gt;

&lt;p&gt;Free text is the only field that can blow the budget, so the idea input is hard-capped at 120 characters — &lt;code&gt;maxLength&lt;/code&gt; on the element &lt;em&gt;and&lt;/em&gt; a &lt;code&gt;slice()&lt;/code&gt; in the state handler, because a pasted string can exceed what &lt;code&gt;maxLength&lt;/code&gt; allows in some browsers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;ideaEl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;maxlength&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MAX_IDEA&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;ideaEl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;idea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ideaEl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MAX_IDEA&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;renderPrompt&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest of the choices are enumerable, so the worst case is computable: four instruments, all phrases at their longest, still lands under the cap. That's the real payoff of a controlled vocabulary — the UI &lt;strong&gt;cannot&lt;/strong&gt; build an invalid prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  No backend at all
&lt;/h2&gt;

&lt;p&gt;The builder is one static page with no server round trip. Pressing &lt;em&gt;Use this prompt&lt;/em&gt; checks whether you're signed in, then either hands the prompt to the app via a query parameter or stashes it in &lt;code&gt;localStorage&lt;/code&gt; and routes through login:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/auth/me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dashboard.html?prompt=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;encodeURIComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pendingPrompt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// survive the signup detour&lt;/span&gt;
      &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;login.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keeping the tool zero-cost is what let us ship it as a standalone free page — and it's the page we're happiest to hand to a stranger, because there's no signup wall in front of the output.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd change next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prune the vocabulary with data.&lt;/strong&gt; The option lists are hand-authored guesses. Counting which chips actually get used (aggregate counts only) would let us delete dead options and keep the four-instrument cap honest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure tags.&lt;/strong&gt; We don't offer &lt;code&gt;[Verse]&lt;/code&gt; / &lt;code&gt;[Chorus]&lt;/code&gt; placement yet, and that's the next big lever on vocal output quality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One tooltip per dimension.&lt;/strong&gt; Most people don't realise that naming a tempo band changes the arrangement more than naming an instrument does.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you want to poke at the builder, it's free and runs entirely in your browser: &lt;strong&gt;&lt;a href="https://music.toolara.dev/prompt-generator.html?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch" rel="noopener noreferrer"&gt;the prompt builder at Toolara Music&lt;/a&gt;&lt;/strong&gt;. It's the front door of &lt;a href="https://music.toolara.dev/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=launch" rel="noopener noreferrer"&gt;Toolara Music&lt;/a&gt;, if you want to hear what the prompts turn into.&lt;/p&gt;




</description>
      <category>ai</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
