Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Release copy: say exactly what goes into a post, and add nothing unasked
Claude8266f75f603c
diff --git a/client/src/components/musicVideo/PublishKitPanel.jsx b/client/src/components/musicVideo/PublishKitPanel.jsxindex c6a44cc683..e9c843881f 100644--- a/client/src/components/musicVideo/PublishKitPanel.jsx+++ b/client/src/components/musicVideo/PublishKitPanel.jsx@@ -4,6 +4,7 @@ import useProviderModels from '../../hooks/useProviderModels.js';import ProviderModelSelector from '../ProviderModelSelector.jsx';import { copyToClipboard } from '../../lib/clipboard.js';import CoverArtPanel from './CoverArtPanel.jsx';+import { formatCount, formatUsd } from '../../utils/formatters.js';const fmtTime = (sec) => {const s = Math.max(0, Math.floor(sec));@@ -26,6 +27,13 @@ export const PUBLISH_FIELDS = [{ platform: 'stackerNews', label: 'Stacker News', fields: [{ key: 'title', label: 'Title', max: 80 }, { key: 'body', label: 'Body (markdown)', multiline: true }] },];+// What the writer may use beyond the notes and links; mirrors the server's+// DEFAULT_COPY_INCLUDE (song title on, everything else off, no hashtags).+const DEFAULT_INCLUDE = { title: true, lyrics: false, spend: false, chapters: false, hashtags: false };+// Generation spend across the project's production runs, as the server totals it for the draft.+const projectSpend = (project) => (project?.productionRuns || [])+ .reduce((sum, run) => sum + (Number.isFinite(Number(run?.usage?.spentUsd)) ? Number(run.usage.spentUsd) : 0), 0);+const fieldValue = (copy, platform, field) => {const v = copy?.[platform]?.[field.key];if (field.tags) return Array.isArray(v) ? v.join(', ') : '';@@ -74,6 +82,17 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })const [notes, setNotes] = useState(kit.notes || '');const [youtubeUrl, setYoutubeUrl] = useState(kit.links?.youtube || '');const [songUrl, setSongUrl] = useState(kit.links?.song || '');+ const [include, setInclude] = useState({ ...DEFAULT_INCLUDE, ...(kit.draftOptions?.include || {}) });+ const [length, setLength] = useState(kit.draftOptions?.length === 'full' ? 'full' : 'short');+ const lyricLines = (project?.lyricCues || []).filter((c) => typeof c?.text === 'string' && c.text.trim()).length;+ const spend = projectSpend(project);+ const includeRows = [+ { key: 'title', label: 'Song title', detail: project?.name ? `"${project.name}"` : 'no title yet', available: !!project?.name },+ { key: 'lyrics', label: 'Lyrics', detail: lyricLines ? `${formatCount(lyricLines)} timed line${lyricLines === 1 ? '' : 's'}` : 'no timed lyrics', available: lyricLines > 0 },+ { key: 'chapters', label: 'Chapters', detail: kit.chapters?.length ? `${formatCount(kit.chapters.length)} from the kit` : 'from the song sections', available: true },+ { key: 'spend', label: 'Generation spend', detail: spend > 0 ? formatUsd(spend) : 'none recorded', available: spend > 0 },+ { key: 'hashtags', label: 'Hashtags and YouTube tags', detail: 'none are added unless ticked', available: true },+ ];const {providers, selectedProviderId, selectedModel, availableModels, setSelectedProviderId, setSelectedModel,} = useProviderModels({ allowDefault: true, silent: true });@@ -87,6 +106,8 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })...(selectedProviderId ? { providerId: selectedProviderId } : {}),...(selectedModel ? { model: selectedModel } : {}),notes, links,+ include: Object.fromEntries(includeRows.map(({ key, available }) => [key, available && include[key]])),+ length,});return (@@ -166,7 +187,7 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })<section aria-label="Release copy" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs"><h3 className="text-sm font-medium flex items-center gap-1.5"><Sparkles size={14} /> Release copy</h3>- <p className="text-port-text-muted">The draft only states what you give it here, plus the song, its lyrics and its generation spend. Nothing runs until you press Draft.</p>+ <p className="text-port-text-muted">Each post below is exactly what goes out. Write it yourself, or have the writer draft it from your notes, the links and only what you tick under Draft from. Nothing runs until you press Draft.</p><div className="space-y-0.5"><label htmlFor={idFor('notes')} className="text-[11px] text-port-text-muted">Making-of notes (your story, in your words)</label><textarea id={idFor('notes')} value={notes} maxLength={8000} rows={4} onChange={(e) => setNotes(e.target.value)}@@ -184,6 +205,26 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })className="w-full bg-port-bg border border-port-border rounded px-1.5 py-1 text-xs min-h-[44px] sm:min-h-0" /></div></div>+ <fieldset className="space-y-1 rounded border border-port-border p-2">+ <legend className="px-1 text-[11px] font-medium">Draft from (plus your notes and links)</legend>+ {includeRows.map(({ key, label, detail, available }) => (+ <label key={key} htmlFor={idFor(`include-${key}`)} className={`flex items-center gap-2 min-h-[44px] sm:min-h-0 ${available ? '' : 'opacity-50'}`}>+ <input id={idFor(`include-${key}`)} type="checkbox" checked={available && include[key]} disabled={!available || publishKit.drafting}+ onChange={(e) => setInclude((cur) => ({ ...cur, [key]: e.target.checked }))} />+ <span>{label} <span className="text-port-text-muted">· {detail}</span></span>+ </label>+ ))}+ </fieldset>+ <fieldset className="flex flex-wrap items-center gap-x-3 gap-y-1">+ <legend className="text-[11px] text-port-text-muted mb-0.5">Length</legend>+ {[['short', 'A sentence or two'], ['full', 'Full making-of']].map(([value, label]) => (+ <label key={value} htmlFor={idFor(`length-${value}`)} className="flex items-center gap-1.5 min-h-[44px] sm:min-h-0">+ <input id={idFor(`length-${value}`)} type="radio" name={idFor('length')} value={value} checked={length === value}+ disabled={publishKit.drafting} onChange={() => setLength(value)} />+ {label}+ </label>+ ))}+ </fieldset><div className="flex flex-wrap items-end gap-2">{providers.length > 0 && (<ProviderModelSelector providers={providers} selectedProviderId={selectedProviderId} selectedModel={selectedModel}@@ -197,7 +238,7 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })</button></div>{noPlatforms && <p className="text-port-text-muted">Turn on a platform under Where you post to draft its copy.</p>}- {kit.copy && (+ {!noPlatforms && (<div className="space-y-3" key={kit.copyDraftedAt || 'copy'}>{copyFields.map(({ platform, label, fields }) => (<fieldset key={platform} className="space-y-1.5 rounded border border-port-border p-2">diff --git a/client/src/components/musicVideo/PublishKitPanel.test.jsx b/client/src/components/musicVideo/PublishKitPanel.test.jsxindex 9fc362a5d7..bab76fae06 100644--- a/client/src/components/musicVideo/PublishKitPanel.test.jsx+++ b/client/src/components/musicVideo/PublishKitPanel.test.jsx@@ -36,14 +36,39 @@ describe('PublishKitPanel (#9281)', () => {expect(k.build).toHaveBeenCalled();});- it('drafts copy from the notes and only well-formed links', () => {+ it('drafts copy from the notes, only well-formed links and only what is ticked', () => {const k = hook();- render(<PublishKitPanel project={{ id: 'mv-1', renderHistoryId: 'rh-1' }} publishKit={k} />);+ const project = { id: 'mv-1', name: 'Example Song', renderHistoryId: 'rh-1', lyricCues: [{ text: 'a line', startSec: 1 }], productionRuns: [{ usage: { spentUsd: 4.5 } }] };+ render(<PublishKitPanel project={project} publishKit={k} />);fireEvent.change(screen.getByLabelText(/Making-of notes/), { target: { value: 'hummed it in the car' } });fireEvent.change(screen.getByLabelText(/Full video URL/), { target: { value: 'https://example.com/v' } });fireEvent.change(screen.getByLabelText(/Song URL/), { target: { value: 'not a url' } });+ // By default only the song title goes in, kept to a sentence or two, with no hashtags.+ expect(screen.getByLabelText(/Song title/)).toBeChecked();+ expect(screen.getByLabelText(/Hashtags and YouTube tags/)).not.toBeChecked();+ expect(screen.getByLabelText('A sentence or two')).toBeChecked();fireEvent.click(screen.getByRole('button', { name: /Draft copy/ }));- expect(k.draftCopy).toHaveBeenCalledWith({ notes: 'hummed it in the car', links: { youtube: 'https://example.com/v' } });+ const none = { title: true, lyrics: false, chapters: false, spend: false, hashtags: false };+ expect(k.draftCopy).toHaveBeenLastCalledWith({ notes: 'hummed it in the car', links: { youtube: 'https://example.com/v' }, include: none, length: 'short' });++ fireEvent.click(screen.getByLabelText(/Song title/));+ fireEvent.click(screen.getByLabelText(/Lyrics/));+ fireEvent.click(screen.getByLabelText(/Generation spend/));+ fireEvent.click(screen.getByLabelText(/Hashtags and YouTube tags/));+ fireEvent.click(screen.getByLabelText('Full making-of'));+ fireEvent.click(screen.getByRole('button', { name: /Draft copy/ }));+ expect(k.draftCopy).toHaveBeenLastCalledWith(expect.objectContaining({ include: { ...none, title: false, lyrics: true, spend: true, hashtags: true }, length: 'full' }));+ });++ it('cannot tick lyrics or spend the project does not have, and lets you write a post without drafting', () => {+ const k = hook();+ render(<PublishKitPanel project={{ id: 'mv-1', name: 'Example Song', renderHistoryId: 'rh-1' }} publishKit={k} enabledTargets={['x']} />);+ expect(screen.getByLabelText(/Lyrics/)).toBeDisabled();+ expect(screen.getByLabelText(/Generation spend/)).toBeDisabled();+ const hook_ = screen.getByLabelText('Hook post (no links)');+ fireEvent.change(hook_, { target: { value: 'One sentence of my own.' } });+ fireEvent.blur(hook_);+ expect(k.saveCopy).toHaveBeenCalledWith({ x: { hook: 'One sentence of my own.' } });});it('shows the built kit, saves an edited field on blur and picks a thumbnail', () => {diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex d308576f3b..f0beaf0619 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -684,6 +684,9 @@ export const musicVideoPublishCopyDraftSchema = z.object({model: z.string().max(200).nullable().optional(),notes: kitText(8000).optional(),links: z.object({ youtube: z.string().url().max(500), song: z.string().url().max(500) }).partial().strict().optional(),+ // What the draft may use beyond the notes and links; omitted keys keep their defaults (title on, the rest off).+ include: z.object({ title: z.boolean(), lyrics: z.boolean(), spend: z.boolean(), chapters: z.boolean(), hashtags: z.boolean() }).partial().strict().optional(),+ length: z.enum(['short', 'full']).optional(),}).strict();export const musicVideoPublishThumbnailSchema = z.object({ filename: z.string().min(1).max(300) }).strict();diff --git a/server/services/musicVideo/publishKit.js b/server/services/musicVideo/publishKit.jsindex 5e2ab6dcf3..47aa5d7415 100644--- a/server/services/musicVideo/publishKit.js+++ b/server/services/musicVideo/publishKit.js@@ -23,7 +23,7 @@ import { broadcastSse, attachSseClient as attachSse, closeJobAfterDelay } from 'import { getProject, listProjects, mutateProjectRecord } from './projects.js';import { suggestSocialCuts } from './socialCuts.js';import { musicVideoAspect } from '../../lib/musicVideoAspect.js';-import { buildChapters, buildSrt, buildPublishCopyPrompt, parsePublishCopy, PUBLISH_PLATFORMS } from './publishKitText.js';+import { buildChapters, buildSrt, buildPublishCopyPrompt, parsePublishCopy, normalizeCopyOptions, PUBLISH_PLATFORMS } from './publishKitText.js';const jobs = new Map();const projectBuilds = new Map();@@ -242,9 +242,10 @@ function spentUsd(project) {/*** Draft the copy for every platform the director posts to, in ONE provider call they asked for.- * `notes` (their making-of story) is saved with the kit so a redraft reuses it.+ * `notes` (their making-of story) and what they chose to include (`include`,+ * `length`) are saved with the kit so a redraft reuses them.*/-export async function draftPublishKitCopy(projectId, { providerId = null, model = null, notes = '', links = {} } = {}, deps = {}) {+export async function draftPublishKitCopy(projectId, { providerId = null, model = null, notes = '', links = {}, include, length } = {}, deps = {}) {const project = await requireProject(projectId);const { getPublishPlatforms, publishHistory } = await import('./publish/platforms.js');const enabled = deps.platforms || await getPublishPlatforms();@@ -256,12 +257,13 @@ export async function draftPublishKitCopy(projectId, { providerId = null, modelconst { resolveProviderAndModel, runPromptThroughProvider } = deps.runner || await import('../promptRunner.js');const { provider, selectedModel } = await resolveProviderAndModel({ providerId, model });if (!provider) throw kitError(503, 'NO_PROVIDER', 'No AI provider is available to draft the copy');- const prompt = buildPublishCopyPrompt(project, { notes, spentUsd: spentUsd(project), links, platforms, lessons });+ const options = normalizeCopyOptions({ include, length });+ const prompt = buildPublishCopyPrompt(project, { notes, spentUsd: spentUsd(project), links, platforms, lessons, ...options });const { text } = await runPromptThroughProvider({ provider, model: selectedModel, prompt, source: 'music-video-publish-copy' });- const copy = parsePublishCopy(text, platforms);+ const copy = parsePublishCopy(text, platforms, { hashtags: options.include.hashtags });if (!copy) throw kitError(502, 'PUBLISH_COPY_UNPARSEABLE', 'The copy draft came back without usable JSON — try again or another model');return mutateProjectRecord(projectId, (current) => {const kit = projectPublishKit(current);- return { project: { ...current, publishKit: { ...kit, copy: { ...(kit.copy || {}), ...copy }, notes, links: { ...(kit.links || {}), ...links }, copyDraftedAt: new Date().toISOString() } } };+ return { project: { ...current, publishKit: { ...kit, copy: { ...(kit.copy || {}), ...copy }, notes, draftOptions: options, links: { ...(kit.links || {}), ...links }, copyDraftedAt: new Date().toISOString() } } };});}diff --git a/server/services/musicVideo/publishKit.test.js b/server/services/musicVideo/publishKit.test.jsindex b686b6fcb1..ee4f8dacb2 100644--- a/server/services/musicVideo/publishKit.test.js+++ b/server/services/musicVideo/publishKit.test.js@@ -141,7 +141,9 @@ describe('publishing kit copy (#9281)', () => {const { project } = await kit.draftPublishKitCopy(id, { notes: 'made it on a Sunday', links: { youtube: 'https://example.com/v' } }, deps);expect(deps.runner.runPromptThroughProvider).toHaveBeenCalledTimes(1);expect(deps.runner.runPromptThroughProvider.mock.calls[0][0]).toMatchObject({ source: 'music-video-publish-copy' });- expect(project.publishKit).toMatchObject({ notes: 'made it on a Sunday', links: { youtube: 'https://example.com/v' }, copy: { youtube: { title: 'A title' }, x: { hook: 'a hook' } } });+ // Nothing beyond the title is ticked by default, so the model's tags are dropped and the choice is kept for a redraft.+ expect(project.publishKit).toMatchObject({ notes: 'made it on a Sunday', links: { youtube: 'https://example.com/v' }, copy: { youtube: { title: 'A title', tags: [] }, x: { hook: 'a hook' } } });+ expect(project.publishKit.draftOptions).toEqual({ include: { title: true, lyrics: false, spend: false, chapters: false, hashtags: false }, length: 'short' });const edited = await kit.updatePublishKitCopy(id, { x: { hook: 'my own hook' } });expect(edited.project.publishKit.copy.x).toEqual({ hook: 'my own hook', story: 'story' });expect(edited.project.publishKit.copy.youtube.title).toBe('A title');diff --git a/server/services/musicVideo/publishKitText.js b/server/services/musicVideo/publishKitText.jsindex a2db4dbe70..7cc058358e 100644--- a/server/services/musicVideo/publishKitText.js+++ b/server/services/musicVideo/publishKitText.js@@ -117,31 +117,64 @@ const LIMITS = { youtubeTitle: 100, shortsTitle: 100, xHook: 280, redditTitle: 3const str = (v, max) => (typeof v === 'string' && v.trim() ? v.trim().slice(0, max) : '');+/**+ * What the director chose to put in the draft. Nothing beyond the notes and+ * links they typed is included unless they ticked it, and no hashtag or tag+ * appears unless they asked for them. `length: 'short'` keeps every post to a+ * sentence or two.+ */+export const DEFAULT_COPY_INCLUDE = Object.freeze({ title: true, lyrics: false, spend: false, chapters: false, hashtags: false });+export const COPY_LENGTHS = Object.freeze(['short', 'full']);++export function normalizeCopyOptions({ include, length } = {}) {+ const src = include && typeof include === 'object' ? include : {};+ const merged = Object.fromEntries(Object.entries(DEFAULT_COPY_INCLUDE).map(([k, d]) => [k, typeof src[k] === 'boolean' ? src[k] : d]));+ return { include: merged, length: COPY_LENGTHS.includes(length) ? length : 'short' };+}+// The JSON shape each platform's copy takes in the prompt.-const COPY_SPECS = {- youtube: '"youtube":{"title":"<=100 chars","description":"2 short paragraphs + the links given","tags":["8-15 lowercase tags"]}',- shorts: '"shorts":{"title":"<=100 chars, ends with #shorts","description":"1-2 sentences + the full video URL if given"}',- x: '"x":{"hook":"<=280 chars, one surprising claim, no links","story":"the making-of as a long post"}',- tiktok: '"tiktok":{"caption":"1-2 sentences + 4-6 hashtags"}',- instagram: '"instagram":{"caption":"1-2 sentences + 4-6 hashtags"}',- reddit: '"reddit":{"title":"<=300 chars","body":"markdown: what it is, what it cost, how it was made"}',- stackerNews: '"stackerNews":{"title":"<=80 chars","body":"markdown, personal tone"}',-};+function copySpecs({ include, length }) {+ const short = length === 'short';+ const tags = include.hashtags;+ const body = (full) => (short ? '1-2 sentences' : full);+ return {+ youtube: `"youtube":{"title":"<=100 chars","description":"${body('2 short paragraphs')} + the links given"${tags ? ',"tags":["8-15 lowercase tags"]' : ''}}`,+ shorts: `"shorts":{"title":"<=100 chars${tags ? ', ends with #shorts' : ''}","description":"1-2 sentences + the full video URL if given"}`,+ x: `"x":{"hook":"<=280 chars, ${short ? 'one or two sentences' : 'one surprising claim'}, no links","story":"${short ? 'empty string' : 'the making-of as a long post'}"}`,+ tiktok: `"tiktok":{"caption":"1-2 sentences${tags ? ' + 4-6 hashtags' : ''}"}`,+ instagram: `"instagram":{"caption":"1-2 sentences${tags ? ' + 4-6 hashtags' : ''}"}`,+ reddit: `"reddit":{"title":"<=300 chars","body":"${body('markdown: what it is and how it was made')}"}`,+ stackerNews: `"stackerNews":{"title":"<=80 chars","body":"${body('markdown, personal tone')}"}`,+ };+}++// A #word anywhere in the text; markdown headings ("# Heading") have a space and are left alone.+const HASHTAG = /(^|[^\p{L}\p{N}_&])#[\p{L}\p{N}_]+/gu;+/** The text with every hashtag removed and the spacing it leaves tidied. */+export const stripHashtags = (text) => String(text || '')+ .replace(HASHTAG, '$1')+ .replace(/[ \t]+$/gm, '')+ .replace(/[ \t]{2,}/g, ' ')+ .replace(/\n{3,}/g, '\n\n')+ .trim();/**- * The copy prompt. `notes` is the director's own making-of story and- * `spentUsd` the generation spend; both are the facts the copy may claim —- * nothing else about cost or process is invented. `platforms` limits the+ * The copy prompt. `notes` is the director's own making-of story; the song+ * title, lyrics, chapters and `spentUsd` (generation spend) reach the writer+ * only when `include` ticks them, and hashtags/tags only when it ticks+ * `hashtags`. Those are the only facts the copy may claim. `platforms` limits the* draft to where the director posts (#9287); `lessons` are their own ratings* of earlier posts (`{ platform, reception, notes }`), so the copy leans* toward what landed and away from what didn't.*/-export function buildPublishCopyPrompt(project, { notes = '', spentUsd = null, links = {}, platforms = PUBLISH_PLATFORMS, lessons = [] } = {}) {- const lyrics = timedLines(project).map((l) => l.text).join('\n');- const chapters = chaptersText(buildChapters(project));+export function buildPublishCopyPrompt(project, { notes = '', spentUsd = null, links = {}, platforms = PUBLISH_PLATFORMS, lessons = [], include, length } = {}) {+ const options = normalizeCopyOptions({ include, length });+ const { include: inc } = options;+ const lyrics = inc.lyrics ? timedLines(project).map((l) => l.text).join('\n') : '';+ const chapters = inc.chapters ? chaptersText(buildChapters(project)) : '';const facts = [- `Song title: ${project?.name || 'Untitled'}`,- spentUsd != null ? `Video generation spend: $${Number(spentUsd).toFixed(2)}` : null,+ inc.title && project?.name ? `Song title: ${project.name}` : null,+ inc.spend && spentUsd != null ? `Video generation spend: $${Number(spentUsd).toFixed(2)}` : null,links.youtube ? `Full video URL: ${links.youtube}` : null,links.song ? `Song URL: ${links.song}` : null,].filter(Boolean).join('\n');@@ -150,24 +183,33 @@ export function buildPublishCopyPrompt(project, { notes = '', spentUsd = null, l.filter((l) => wanted.includes(l.platform) && (l.reception || l.notes)).map((l) => `- ${l.platform}${l.reception ? ` (${l.reception})` : ''}: ${l.notes || 'no notes'}`).join('\n');+ const specs = copySpecs(options);return [- 'You write release copy for a music video the user made. Write in the first person as the artist: plain, specific, no hype words, no emoji, no hashtags except where a field asks for them.',- 'Use ONLY facts given below. Never invent costs, tools, durations or events.',+ `You write release copy for a music video the user made. Write in the first person as the artist: plain, specific, no hype words, no emoji, ${inc.hashtags ? 'no hashtags except where a field asks for them' : 'no hashtags anywhere'}.`,+ options.length === 'short' ? 'Keep every post to a sentence or two. Leave out anything not needed.' : '',+ 'Use ONLY facts given below. Never invent costs, tools, durations, lyrics, song titles or events, and do not mention anything the artist did not give you.',facts,fenceBlock('Making-of notes from the artist', notes || '(none)', 6000),- fenceBlock('Lyrics', lyrics || '(no timed lyrics)', 4000),+ lyrics ? fenceBlock('Lyrics', lyrics, 4000) : '',chapters ? fenceBlock('Chapters', chapters, 1200) : '',lessonText ? fenceBlock('How the artist rated earlier posts (lean toward what landed, avoid what did not)', lessonText, 3000) : '','Return ONLY a JSON object with exactly these keys:',- `{${wanted.map((p) => COPY_SPECS[p]).join(',\n ')}}`,+ `{${wanted.map((p) => specs[p]).join(',\n ')}}`,].filter(Boolean).join('\n\n');}-/** The model's JSON reply as `{ platform: { field: text } }` for `platforms`, clipped to each platform's limits; null when unusable. */-export function parsePublishCopy(text, platforms = PUBLISH_PLATFORMS) {+/**+ * The model's JSON reply as `{ platform: { field: text } }` for `platforms`,+ * clipped to each platform's limits; null when unusable. Without+ * `hashtags: true` every hashtag the model slipped in is removed and YouTube+ * tags stay empty, so none reaches a post unasked.+ */+export function parsePublishCopy(text, platforms = PUBLISH_PLATFORMS, { hashtags = true } = {}) {const { value } = extractJson(text, { blockType: 'object' });if (!value || typeof value !== 'object' || Array.isArray(value)) return null;- const v = (k) => (value[k] && typeof value[k] === 'object' ? value[k] : {});+ const clean = (fields) => (hashtags || !fields || typeof fields !== 'object' ? fields+ : Object.fromEntries(Object.entries(fields).map(([k, f]) => [k, k === 'tags' ? [] : (typeof f === 'string' ? stripHashtags(f) : f)])));+ const v = (k) => (value[k] && typeof value[k] === 'object' ? clean(value[k]) : {});const all = {youtube: () => ({ title: str(v('youtube').title, LIMITS.youtubeTitle), description: str(v('youtube').description, 5000), tags: (Array.isArray(v('youtube').tags) ? v('youtube').tags : []).map((t) => str(t, 60)).filter(Boolean).slice(0, 20) }),shorts: () => ({ title: str(v('shorts').title, LIMITS.shortsTitle), description: str(v('shorts').description, 5000) }),diff --git a/server/services/musicVideo/publishKitText.test.js b/server/services/musicVideo/publishKitText.test.jsindex f7ceeaa3d7..7f719e8807 100644--- a/server/services/musicVideo/publishKitText.test.js+++ b/server/services/musicVideo/publishKitText.test.js@@ -42,13 +42,39 @@ describe('buildSrt (#9281)', () => {describe('publish copy prompt + parser (#9281)', () => {it('states only the facts it was given', () => {- const withSpend = buildPublishCopyPrompt(project, { notes: 'hummed it in the car', spentUsd: 37.876, links: { youtube: 'https://example.com/v' } });+ const withSpend = buildPublishCopyPrompt(project, { notes: 'hummed it in the car', spentUsd: 37.876, links: { youtube: 'https://example.com/v' }, include: { spend: true } });expect(withSpend).toContain('Video generation spend: $37.88');expect(withSpend).toContain('Full video URL: https://example.com/v');expect(withSpend).toContain('hummed it in the car');expect(buildPublishCopyPrompt(project, {})).not.toContain('spend:');});+ it('leaves out lyrics, spend and hashtags unless the director ticked them', () => {+ const lyricProject = { ...project, name: 'Example Song', lyricCues: [cue('a sung line', 1, 2)] };+ const plain = buildPublishCopyPrompt(lyricProject, { spentUsd: 12 });+ expect(plain).toContain('Song title: Example Song');+ expect(plain).not.toContain('a sung line');+ expect(plain).not.toContain('spend:');+ expect(plain).toContain('no hashtags anywhere');+ expect(plain).toContain('a sentence or two');+ expect(plain).not.toContain('#shorts');+ expect(plain).not.toContain('"tags"');+ const all = buildPublishCopyPrompt(lyricProject, { spentUsd: 12, include: { title: false, lyrics: true, spend: true, hashtags: true }, length: 'full' });+ expect(all).not.toContain('Song title:');+ expect(all).toContain('a sung line');+ expect(all).toContain('#shorts');+ expect(all).toContain('the making-of as a long post');+ });++ it('strips hashtags the model added unasked, keeping markdown headings', () => {+ const reply = JSON.stringify({ tiktok: { caption: 'Made this one slowly. #music #aivideo' }, youtube: { title: 'T', description: '# Heading\nA line #tagged here', tags: ['music'] } });+ const copy = parsePublishCopy(reply, ['tiktok', 'youtube'], { hashtags: false });+ expect(copy.tiktok.caption).toBe('Made this one slowly.');+ expect(copy.youtube.description).toBe('# Heading\nA line here');+ expect(copy.youtube.tags).toEqual([]);+ expect(parsePublishCopy(reply, ['tiktok']).tiktok.caption).toContain('#music');+ });+it('clips each field to its platform limit and rejects an empty or non-JSON reply', () => {const reply = `\`\`\`json\n${JSON.stringify({ youtube: { title: 'T'.repeat(150), tags: ['a', 'b'] }, x: { hook: 'H'.repeat(400), story: 'long' }, stackerNews: { title: 'S'.repeat(120) } })}\n\`\`\``;const copy = parsePublishCopy(reply);