adyou 0.6.13 → 0.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  // 컨셉·카피 — 브리프 → 컨셉 3~5(혜택·증거·긴급·비교·감성) × 제목 5·본문 5·설명 2·CTA. 규격 검사(specs.checkCopy)를 통과할 때까지 다듬는다.
2
2
  import { z } from 'zod';
3
3
  import { aiAvailable, completeJson } from '../llm.js';
4
- import { checkCopy, ctaFor, fit, GOOGLE_LIMITS, wlen } from './specs.js';
4
+ import { checkCopy, ctaFor, fit, fitWords, GOOGLE_LIMITS, wlen } from './specs.js';
5
5
  const ConceptSchema = z.object({
6
6
  key: z.string().regex(/^[a-z][a-z0-9_]{1,19}$/), name: z.string().optional(), angle: z.string().optional(),
7
7
  headlines: z.array(z.string()).min(1).max(8), bodies: z.array(z.string()).min(1).max(8), descriptions: z.array(z.string()).min(1).max(4),
@@ -36,14 +36,14 @@ export async function generateConcepts(brief, opts) {
36
36
  const fixed = await generateConcepts(brief, { ...opts, feedback: `LANGUAGE_FIX: 직전 답에 한국어가 섞였어요. headlines·bodies·descriptions·videoLines·videoVoice·name·angle 전부 ${brief.language} 로만 다시 써 주세요(브리프·요구사항이 한국어여도 출력은 ${brief.language}).` });
37
37
  return fixed;
38
38
  }
39
- const concepts = out.concepts.slice(0, opts.count).map((c) => ({ ...c, name: (c.name || c.headlines[0] || c.key).trim(), angle: (c.angle || c.descriptions[0] || c.headlines[0] || '').trim(), cta: cta.meta, headlines: c.headlines.map((h) => fit(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean).slice(0, 6), descriptions: c.descriptions.map((d) => fit(d.trim(), GOOGLE_LIMITS.description)).filter(Boolean).slice(0, 3), bodies: c.bodies.map((b) => b.trim()).filter(Boolean).slice(0, 6), videoLines: (c.videoLines || []).map((l) => l.trim()).filter(Boolean).slice(0, 3), videoVoice: c.videoVoice || undefined }));
39
+ const concepts = out.concepts.slice(0, opts.count).map((c) => ({ ...c, name: (c.name || c.headlines[0] || c.key).trim(), angle: (c.angle || c.descriptions[0] || c.headlines[0] || '').trim(), cta: cta.meta, headlines: c.headlines.map((h) => fitWords(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean).slice(0, 6), descriptions: c.descriptions.map((d) => fit(d.trim(), GOOGLE_LIMITS.description)).filter(Boolean).slice(0, 3), bodies: c.bodies.map((b) => b.trim()).filter(Boolean).slice(0, 6), videoLines: (c.videoLines || []).map((l) => l.trim()).filter(Boolean).slice(0, 3), videoVoice: c.videoVoice || undefined }));
40
40
  return concepts;
41
41
  }
42
42
  function fallbackConcepts(brief, opts) {
43
43
  const cta = ctaFor(opts.goal);
44
44
  const uc = opts.userCopy;
45
45
  if (uc && (uc.headlines?.length || uc.bodies?.length)) {
46
- const heads = (uc.headlines || []).map((h) => fit(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean);
46
+ const heads = (uc.headlines || []).map((h) => fitWords(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean);
47
47
  const bodies = (uc.bodies || []).map((b) => b.trim()).filter(Boolean);
48
48
  const descs = (uc.descriptions || []).map((d) => fit(d.trim(), GOOGLE_LIMITS.description)).filter(Boolean);
49
49
  return [{ key: 'mine', name: '내 문구', angle: '광고주가 직접 쓴 문구', cta: cta.meta, theme: 'dark', headlines: heads.length ? heads : [fit(brief.company, GOOGLE_LIMITS.headline)], bodies: bodies.length ? bodies : [brief.offer], descriptions: descs.length ? descs : [fit(brief.offer, GOOGLE_LIMITS.description)], imagePrompt: `Abstract premium background in ${brief.palette.primary}, soft gradients, no text`, videoPrompt: `Slow cinematic push-in on an abstract premium gradient scene in ${brief.palette.primary}, soft light, gentle ambient music. No on-screen text, no subtitles, no logos.`, videoLines: heads.slice(0, 3) }];
@@ -112,7 +112,8 @@ export const textW = (t, fs) => [...t].reduce((n, ch) => n + (ch === ' ' ? 0.3 :
112
112
  /** 헤드라인 줄나눔 — 「오늘의 입술, 틴트 한 / 번」·「나에게 맞는 컬러 / 찾기」처럼 넘치는 자리에서 끊겨 한 어절이 떨어지는 것을 막는다(2026-09-17 사장님).
113
113
  * 규칙: 한 줄에 들어가면 그대로 · 두 줄이면 모든 어절 경계 후보 중 (① 쉼표·물음표·마침표·가운뎃점 뒤 우선 ② 두 줄 길이 균형 ③ 마지막 줄이 한 어절(≤4wlen)이면 강한 벌점 ④ 두 줄 모두 폭 안) 비용 최소 · 세 줄 이상은 뒤에서부터 채워 마지막 줄 고아를 피한다 */
114
114
  export function breakLines(text, fs, maxW, maxLines = 3) {
115
- const raw = String(text || '').trim().split(/\s+/).filter(Boolean);
115
+ // 쉼표·물음표 뒤에 띄어쓰기가 없으면(「분양정보,몇 개」) 어절이 붙어 엉뚱한 자리에서 나뉜다 → 문장부호 뒤 공백 정규화
116
+ const raw = String(text || '').replace(/([,,、!?!?.])(?=[^\s\d,.!?])/g, '$1 ').trim().split(/\s+/).filter(Boolean);
116
117
  // 한 글자 어절(「한」「다」「그」)은 다음 어절과 한 덩어리 — 「틴트 한 / 번」 금지
117
118
  const words = [];
118
119
  for (let i = 0; i < raw.length; i++) {
@@ -14,6 +14,8 @@ export declare const BG_RATIOS: Record<string, {
14
14
  /** 🔴 구글은 한글·전각을 2자로 센다 */
15
15
  export declare function wlen(t: string): number;
16
16
  export declare function fit(t: string, limit: number): string;
17
+ /** 어절 경계에서 한도 안으로 — 헤드라인이 「로드맵이 알」처럼 낱말 중간에서 잘리지 않게(인프런 엔드카드 · 2026-09-17). 띄어쓰기 없으면 fit 으로 */
18
+ export declare function fitWords(t: string, limit: number): string;
17
19
  export declare const GOOGLE_LIMITS: {
18
20
  headline: number;
19
21
  longHeadline: number;
@@ -18,6 +18,21 @@ export const BG_RATIOS = { '1x1': { openai: '1024x1024', aspect: '1:1' }, '4x5':
18
18
  export function wlen(t) { return [...t].reduce((n, ch) => n + ((ch.codePointAt(0) || 0) > 0x2e7f ? 2 : 1), 0); }
19
19
  export function fit(t, limit) { let s = t; while (wlen(s) > limit && s.length)
20
20
  s = s.slice(0, -1); return s.replace(/[\s·,\-—:;]+$/, ''); }
21
+ /** 어절 경계에서 한도 안으로 — 헤드라인이 「로드맵이 알」처럼 낱말 중간에서 잘리지 않게(인프런 엔드카드 · 2026-09-17). 띄어쓰기 없으면 fit 으로 */
22
+ export function fitWords(t, limit) {
23
+ const s = t.trim().replace(/\s+/g, ' ');
24
+ if (wlen(s) <= limit)
25
+ return s;
26
+ if (!s.includes(' '))
27
+ return fit(s, limit);
28
+ let out = '';
29
+ for (const w of s.split(' ')) {
30
+ if (wlen((out + ' ' + w).trim()) > limit)
31
+ break;
32
+ out = (out + ' ' + w).trim();
33
+ }
34
+ return (wlen(out) >= limit * 0.4 ? out : fit(s, limit)).replace(/[\s·,\-—:;]+$/, '');
35
+ }
21
36
  export const GOOGLE_LIMITS = { headline: 30, longHeadline: 90, description: 90, businessName: 25 };
22
37
  /** RDA call_to_action_text는 구글이 정한 영문 문구만 */
23
38
  export const GOOGLE_CTA = ['Apply Now', 'Book Now', 'Contact Us', 'Download', 'Learn More', 'Install', 'Visit Site', 'Shop Now', 'Sign Up', 'Get Quote', 'Subscribe', 'See More'];
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  import { aiAvailable, completeJson } from '../llm.js';
5
5
  import { ctaLabel } from './render.js';
6
6
  import { FORMAT_DESC, genreStyle, PACE, playbookFor, sceneCuts, TONE_WORDS } from './playbook.js';
7
- import { fit, GOOGLE_LIMITS, policyIssues, wlen } from './specs.js';
7
+ import { fit, fitWords, GOOGLE_LIMITS, policyIssues, wlen } from './specs.js';
8
8
  const BoardSchema = z.object({
9
9
  format: z.string(), genre: z.string().optional(), hook: z.string(), captions: z.array(z.string()).min(1).max(5), voice: z.string().optional().nullable(), music: z.string().optional(),
10
10
  // 🔴 kind 는 우리 클립 계획(clipPlan)이 정하므로 모델이 「ugc」「speech」 같은 값을 써도 거절하지 않는다(에어서울 콘티 2회 실패 · 2026-09-17) · sec 도 계획값을 쓴다
@@ -15,7 +15,7 @@ const LANG_NAME = { ko: 'Korean', en: 'English', ja: 'Japanese', 'zh-TW': 'Tradi
15
15
  export const langName = (l) => LANG_NAME[l] || LANG_NAME[l.split('-')[0]] || l;
16
16
  /** 훅 길이 제한 — 한글·전각 12자(wlen 24) · 라틴은 단어 경계에서 자른다(잘린 단어 금지) */
17
17
  export function fitHook(t) {
18
- const s = t.trim().replace(/\s+/g, ' ');
18
+ const s = t.trim().replace(/([,,、!?!?])(?=[^\s\d,.!?])/g, '$1 ').replace(/\s+/g, ' ');
19
19
  if (wlen(s) <= 30)
20
20
  return s;
21
21
  // 🔴 한글도 어절 경계에서 — 글자 단위로 자르면 「현대건설이 짓는, 힐스테이」(힐스테이트 실사고 · 2026-09-17). 한도 15자(wlen 30) · 줄나눔은 렌더가 맡는다
@@ -170,7 +170,7 @@ export async function translateCopy(brief, concept, boards, langs) {
170
170
  t = { headlines: concept.headlines, bodies: concept.bodies, descriptions: concept.descriptions, boards: [] };
171
171
  }
172
172
  }
173
- out[l] = { headlines: t.headlines.map((h) => fit(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean), bodies: t.bodies.map((b) => b.trim()).filter(Boolean), descriptions: t.descriptions.map((d) => fit(d.trim(), GOOGLE_LIMITS.description)).filter(Boolean) };
173
+ out[l] = { headlines: t.headlines.map((h) => fitWords(h.trim(), GOOGLE_LIMITS.headline)).filter(Boolean), bodies: t.bodies.map((b) => b.trim()).filter(Boolean), descriptions: t.descriptions.map((d) => fit(d.trim(), GOOGLE_LIMITS.description)).filter(Boolean) };
174
174
  for (const b of boards) {
175
175
  const tb = t.boards?.find((x) => x.id === b.id);
176
176
  if (tb)
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './core/money.js';
3
3
  export * from './core/llm.js';
4
4
  export * from './core/site.js';
5
5
  export * from './core/brief.js';
6
- export { SIZES, BG_RATIOS, wlen, fit, GOOGLE_LIMITS, GOOGLE_CTA, META_CTA, ctaFor, policyIssues, checkCopy, type Size, type CopyCheck } from './core/creatives/specs.js';
6
+ export { SIZES, BG_RATIOS, wlen, fit, fitWords, GOOGLE_LIMITS, GOOGLE_CTA, META_CTA, ctaFor, policyIssues, checkCopy, type Size, type CopyCheck } from './core/creatives/specs.js';
7
7
  export * from './core/creatives/copy.js';
8
8
  export * from './core/creatives/images.js';
9
9
  export * from './core/creatives/render.js';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export * from './core/money.js';
4
4
  export * from './core/llm.js';
5
5
  export * from './core/site.js';
6
6
  export * from './core/brief.js';
7
- export { SIZES, BG_RATIOS, wlen, fit, GOOGLE_LIMITS, GOOGLE_CTA, META_CTA, ctaFor, policyIssues, checkCopy } from './core/creatives/specs.js';
7
+ export { SIZES, BG_RATIOS, wlen, fit, fitWords, GOOGLE_LIMITS, GOOGLE_CTA, META_CTA, ctaFor, policyIssues, checkCopy } from './core/creatives/specs.js';
8
8
  export * from './core/creatives/copy.js';
9
9
  export * from './core/creatives/images.js';
10
10
  export * from './core/creatives/render.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adyou",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "description": "ADYou — 대행사 없이, 당신이 직접. 사이트 주소 하나로 광고 소재·매체 등록·자동 운영·보고까지: AI 광고 자율주행 CLI + MCP 서버(Meta·Google · 생성은 항상 PAUSED · 승인 뒤 시작)",
5
5
  "type": "module",
6
6
  "license": "MIT",