@archangel70/cosmo 1.7.0 → 1.10.0

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +117 -88
  3. package/docs/AGENT-HANDOFF.md +8 -8
  4. package/docs/ARCHITECTURE.md +3 -3
  5. package/docs/CONTENT-QA.md +2 -0
  6. package/docs/COPY-STUDIO.md +154 -0
  7. package/docs/FIRST-PARTY-CAPABILITIES.md +1 -1
  8. package/docs/GENERATION.md +1 -1
  9. package/docs/INTELLIGENCE-PACKS.md +2 -2
  10. package/docs/MULTI-AGENT.md +69 -0
  11. package/docs/PAGE-PRODUCTION.md +2 -0
  12. package/docs/ROADMAP.md +10 -0
  13. package/package.json +9 -3
  14. package/packages/cli/bin/cosmo.mjs +150 -18
  15. package/packages/cli/lib/adoption.mjs +21 -0
  16. package/packages/cli/lib/agent-adapters.mjs +124 -0
  17. package/packages/cli/lib/claude-plugin.mjs +4 -0
  18. package/packages/cli/lib/copy-studio.mjs +355 -0
  19. package/packages/cli/lib/delivery.mjs +4 -2
  20. package/packages/cli/lib/editorial-guidance.mjs +17 -0
  21. package/packages/cli/lib/generation.mjs +6 -2
  22. package/packages/cli/lib/intelligence-audit.mjs +22 -5
  23. package/packages/cli/lib/intelligence.mjs +14 -2
  24. package/packages/cli/lib/launcher.mjs +111 -0
  25. package/packages/cli/lib/project.mjs +2 -0
  26. package/packages/cli/lib/status.mjs +1 -1
  27. package/plugins/agent-skills/cosmo/.cosmo-agent.json +4 -0
  28. package/plugins/agent-skills/cosmo/SKILL.md +79 -0
  29. package/plugins/antigravity/cosmo.md +19 -0
  30. package/plugins/claude-code/cosmo/.claude-plugin/plugin.json +2 -2
  31. package/plugins/claude-code/cosmo/agents/cosmo.md +45 -0
  32. package/plugins/claude-code/cosmo/skills/cosmo/SKILL.md +16 -4
  33. package/plugins/claude-code/cosmo/skills/cosmo-help/SKILL.md +20 -6
  34. package/scripts/postinstall.mjs +10 -8
  35. package/templates/astro-site/.agents/rules/cosmo.md +3 -0
  36. package/templates/astro-site/.agents/skills/cosmo/SKILL.md +18 -0
  37. package/templates/astro-site/.agents/workflows/cosmo.md +3 -0
  38. package/templates/astro-site/.cosmo/workflows/default.json +15 -2
  39. package/templates/astro-site/AGENTS.md +12 -6
  40. package/templates/astro-site/CLAUDE.md +3 -2
  41. package/templates/astro-site/README.md +1 -1
  42. package/templates/astro-site/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { applyIntelligenceProfile } from './intelligence.mjs';
4
+ import { scaffoldCopyStudio } from './copy-studio.mjs';
4
5
  import { slugify, writeJson } from './project.mjs';
5
6
 
6
7
  const GOVERNANCE_PATHS = [
@@ -11,6 +12,12 @@ const GOVERNANCE_PATHS = [
11
12
  '.cosmo/workflows',
12
13
  ];
13
14
 
15
+ const AGENT_ADAPTERS = [
16
+ '.agents/skills/cosmo/SKILL.md',
17
+ '.agents/rules/cosmo.md',
18
+ '.agents/workflows/cosmo.md',
19
+ ];
20
+
14
21
  function detectsAstro(target) {
15
22
  const config = ['astro.config.mjs', 'astro.config.js', 'astro.config.ts', 'astro.config.cjs'].some((name) => fs.existsSync(path.join(target, name)));
16
23
  const packageFile = path.join(target, 'package.json');
@@ -34,6 +41,18 @@ function installAgentGuide(templateDirectory, target, filename) {
34
41
  return path.relative(target, destination);
35
42
  }
36
43
 
44
+ function installAgentAdapters(templateDirectory, target) {
45
+ return AGENT_ADAPTERS.map((relative) => {
46
+ const source = path.join(templateDirectory, relative);
47
+ if (!fs.existsSync(source)) return null;
48
+ const preferred = path.join(target, relative);
49
+ const destination = fs.existsSync(preferred) ? path.join(target, '.cosmo', 'agent-adapters', relative) : preferred;
50
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
51
+ fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
52
+ return path.relative(target, destination);
53
+ }).filter(Boolean);
54
+ }
55
+
37
56
  export function adoptAstroProject(templateDirectory, target, options = {}) {
38
57
  const resolved = path.resolve(target);
39
58
  if (!fs.existsSync(resolved) || !fs.statSync(resolved).isDirectory()) throw new Error(`Project directory not found: ${resolved}`);
@@ -66,7 +85,9 @@ export function adoptAstroProject(templateDirectory, target, options = {}) {
66
85
  const voice = JSON.parse(fs.readFileSync(voiceFile, 'utf8'));
67
86
  writeJson(voiceFile, { ...voice, entityId: slugify(brand) });
68
87
  applyIntelligenceProfile(resolved, profile);
88
+ scaffoldCopyStudio(resolved);
69
89
 
70
90
  const guides = ['CLAUDE.md', 'AGENTS.md'].map((file) => installAgentGuide(templateDirectory, resolved, file)).filter(Boolean);
91
+ guides.push(...installAgentAdapters(templateDirectory, resolved));
71
92
  return { target: resolved, name, brand, site, profile, guides };
72
93
  }
@@ -0,0 +1,124 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { claudePluginStatus, installClaudePlugin, uninstallClaudePlugin } from './claude-plugin.mjs';
6
+
7
+ const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
8
+ const sharedSkillSource = path.resolve(moduleDirectory, '../../../plugins/agent-skills/cosmo');
9
+ const antigravitySource = path.resolve(moduleDirectory, '../../../plugins/antigravity');
10
+
11
+ export const SUPPORTED_AGENTS = ['claude', 'codex', 'antigravity'];
12
+
13
+ function homeRoot(environmentName, fallback) {
14
+ return process.env[environmentName] ? path.resolve(process.env[environmentName]) : fallback;
15
+ }
16
+
17
+ export function codexSkillTarget() {
18
+ return path.join(homeRoot('COSMO_CODEX_DIR', path.join(os.homedir(), '.agents')), 'skills', 'cosmo');
19
+ }
20
+
21
+ export function antigravityTargets() {
22
+ const root = homeRoot('COSMO_ANTIGRAVITY_DIR', path.join(os.homedir(), '.gemini'));
23
+ return {
24
+ root,
25
+ workflow: path.join(root, 'config', 'global_workflows', 'cosmo.md'),
26
+ };
27
+ }
28
+
29
+ function skillStatus(target) {
30
+ const manifest = path.join(target, '.cosmo-agent.json');
31
+ if (!fs.existsSync(path.join(target, 'SKILL.md')) || !fs.existsSync(manifest)) {
32
+ return { installed: false, target, version: null };
33
+ }
34
+ const data = JSON.parse(fs.readFileSync(manifest, 'utf8'));
35
+ return { installed: true, target, version: data.version ?? null };
36
+ }
37
+
38
+ function installSkill(target, { replace = false } = {}) {
39
+ if (!fs.existsSync(path.join(sharedSkillSource, 'SKILL.md'))) {
40
+ throw new Error(`Cosmo shared agent skill is missing: ${sharedSkillSource}`);
41
+ }
42
+ if (fs.existsSync(target)) {
43
+ if (!replace) throw new Error(`Cosmo is already installed at ${target}. Pass --replace to update it.`);
44
+ if (!skillStatus(target).installed) throw new Error(`Refusing to replace a directory Cosmo does not own: ${target}`);
45
+ fs.rmSync(target, { recursive: true, force: true });
46
+ }
47
+ fs.mkdirSync(path.dirname(target), { recursive: true });
48
+ fs.cpSync(sharedSkillSource, target, { recursive: true });
49
+ return skillStatus(target);
50
+ }
51
+
52
+ function uninstallSkill(target) {
53
+ const status = skillStatus(target);
54
+ if (!status.installed) return { ...status, removed: false };
55
+ fs.rmSync(target, { recursive: true, force: true });
56
+ return { installed: false, target, version: status.version, removed: true };
57
+ }
58
+
59
+ function antigravityStatus() {
60
+ const target = antigravityTargets().workflow;
61
+ if (!fs.existsSync(target)) return { installed: false, target, version: null };
62
+ const content = fs.readFileSync(target, 'utf8');
63
+ const version = content.match(/^<!-- cosmo-agent-version: ([^ ]+) -->/m)?.[1] ?? null;
64
+ return { installed: Boolean(version), target, version };
65
+ }
66
+
67
+ function installAntigravity({ replace = false } = {}) {
68
+ const { workflow: target } = antigravityTargets();
69
+ const source = path.join(antigravitySource, 'cosmo.md');
70
+ if (!fs.existsSync(source)) throw new Error(`Cosmo Antigravity workflow is missing: ${source}`);
71
+ if (fs.existsSync(target) && !replace) throw new Error(`Cosmo is already installed for Antigravity at ${target}. Pass --replace to update it.`);
72
+ if (fs.existsSync(target) && replace && !antigravityStatus().installed) throw new Error(`Refusing to replace a workflow Cosmo does not own: ${target}`);
73
+ fs.mkdirSync(path.dirname(target), { recursive: true });
74
+ fs.copyFileSync(source, target);
75
+ return antigravityStatus();
76
+ }
77
+
78
+ function uninstallAntigravity() {
79
+ const status = antigravityStatus();
80
+ if (!status.installed) return { ...status, removed: false };
81
+ fs.rmSync(status.target, { force: true });
82
+ return { installed: false, target: status.target, version: status.version, removed: true };
83
+ }
84
+
85
+ export function normalizeAgent(value = 'all') {
86
+ const normalized = String(value).trim().toLowerCase().replace(/[-_ ]+/g, '');
87
+ if (normalized === 'all') return 'all';
88
+ if (['claude', 'claudecode'].includes(normalized)) return 'claude';
89
+ if (['codex', 'chatgptcodex'].includes(normalized)) return 'codex';
90
+ if (['antigravity', 'googleantigravity'].includes(normalized)) return 'antigravity';
91
+ throw new Error(`Unknown agent: ${value}. Choose claude, codex, antigravity, or all.`);
92
+ }
93
+
94
+ export function agentStatus(agent) {
95
+ const provider = normalizeAgent(agent);
96
+ if (provider === 'all') return SUPPORTED_AGENTS.map((name) => ({ agent: name, ...agentStatus(name) }));
97
+ if (provider === 'claude') return claudePluginStatus();
98
+ if (provider === 'codex') return skillStatus(codexSkillTarget());
99
+ return antigravityStatus();
100
+ }
101
+
102
+ export function installAgent(agent, { replace = false, validate = true } = {}) {
103
+ const provider = normalizeAgent(agent);
104
+ if (provider === 'all') return SUPPORTED_AGENTS.map((name) => ({ agent: name, ...installAgent(name, { replace, validate }) }));
105
+ if (provider === 'claude') return installClaudePlugin({ replace, validate });
106
+ if (provider === 'codex') return installSkill(codexSkillTarget(), { replace });
107
+ return installAntigravity({ replace });
108
+ }
109
+
110
+ export function uninstallAgent(agent) {
111
+ const provider = normalizeAgent(agent);
112
+ if (provider === 'all') return SUPPORTED_AGENTS.map((name) => ({ agent: name, ...uninstallAgent(name) }));
113
+ if (provider === 'claude') return uninstallClaudePlugin();
114
+ if (provider === 'codex') return uninstallSkill(codexSkillTarget());
115
+ return uninstallAntigravity();
116
+ }
117
+
118
+ export function agentInvocation(agent) {
119
+ const provider = normalizeAgent(agent);
120
+ if (provider === 'claude') return 'type cosmo (fallback: /cosmo:cosmo)';
121
+ if (provider === 'codex') return 'type $cosmo (or ask Codex to use Cosmo)';
122
+ if (provider === 'antigravity') return 'run /cosmo';
123
+ return '';
124
+ }
@@ -6,6 +6,7 @@ import { spawnSync } from 'node:child_process';
6
6
 
7
7
  const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
8
8
  const defaultSource = path.resolve(moduleDirectory, '../../../plugins/claude-code/cosmo');
9
+ const sharedSkill = path.resolve(moduleDirectory, '../../../plugins/agent-skills/cosmo/SKILL.md');
9
10
  const runtimeCli = path.resolve(moduleDirectory, '../bin/cosmo.mjs');
10
11
 
11
12
  function shellQuote(value) {
@@ -39,11 +40,14 @@ export function installClaudePlugin({ target = claudePluginTarget(), source = de
39
40
  }
40
41
  if (fs.existsSync(target)) {
41
42
  if (!replace) throw new Error(`Cosmo is already installed for Claude at ${target}. Pass --replace to update it.`);
43
+ if (!claudePluginStatus(target).installed) throw new Error(`Refusing to replace a Claude directory Cosmo does not own: ${target}`);
42
44
  fs.rmSync(target, { recursive: true, force: true });
43
45
  }
44
46
 
45
47
  fs.mkdirSync(path.dirname(target), { recursive: true });
46
48
  fs.cpSync(source, target, { recursive: true });
49
+ const installedSkill = path.join(target, 'skills', 'cosmo', 'SKILL.md');
50
+ if (!fs.existsSync(installedSkill) && fs.existsSync(sharedSkill)) fs.copyFileSync(sharedSkill, installedSkill);
47
51
  const launcher = path.join(target, 'bin', 'cosmo');
48
52
  fs.writeFileSync(launcher, `#!/bin/sh\nexec ${shellQuote(process.execPath)} ${shellQuote(runtimeCli)} "$@"\n`);
49
53
  fs.chmodSync(launcher, 0o755);
@@ -0,0 +1,355 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { readIntegrity } from './integrity.mjs';
4
+ import { readPlan } from './plan.mjs';
5
+ import { readProject, writeJson } from './project.mjs';
6
+ import { EDITORIAL_REVIEW_GUIDANCE } from './editorial-guidance.mjs';
7
+
8
+ export class CopyStudioError extends Error {}
9
+
10
+ const ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
11
+ const SWITCHING_STATES = ['unknown', 'mobile', 'content', 'committed', 'constrained'];
12
+ const MOTIVATION_LEVELS = ['unknown', 'low', 'high'];
13
+ const ABILITY_LEVELS = ['unknown', 'low', 'high'];
14
+ const CTA_ROLES = ['none', 'context', 'secondary', 'primary'];
15
+
16
+ function copyRoot(projectDir) {
17
+ return path.join(projectDir, '.cosmo', 'copy');
18
+ }
19
+
20
+ function strategyFile(projectDir) {
21
+ return path.join(copyRoot(projectDir), 'strategy.json');
22
+ }
23
+
24
+ function briefFile(projectDir, pageId) {
25
+ return path.join(projectDir, '.cosmo', 'work', 'pages', pageId, 'copy-brief.json');
26
+ }
27
+
28
+ function readJson(file, label) {
29
+ if (!fs.existsSync(file)) throw new CopyStudioError(`${label} not found: ${file}`);
30
+ try {
31
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
32
+ } catch {
33
+ throw new CopyStudioError(`${label} is not valid JSON: ${file}`);
34
+ }
35
+ }
36
+
37
+ function nonEmpty(value) {
38
+ return typeof value === 'string' && Boolean(value.trim());
39
+ }
40
+
41
+ function expectedSwitchingState(motivation, ability) {
42
+ if (motivation === 'unknown' || ability === 'unknown') return 'unknown';
43
+ if (motivation === 'high' && ability === 'high') return 'mobile';
44
+ if (motivation === 'low' && ability === 'high') return 'content';
45
+ if (motivation === 'low' && ability === 'low') return 'committed';
46
+ return 'constrained';
47
+ }
48
+
49
+ function ctaCeiling(funnel) {
50
+ return { awareness: 'context', consideration: 'secondary', decision: 'primary', retention: 'primary' }[funnel] ?? 'secondary';
51
+ }
52
+
53
+ function finding(scope, code, message, fix) {
54
+ return { scope, code, severity: 'blocking', message, fix };
55
+ }
56
+
57
+ function warning(scope, code, message, fix) {
58
+ return { scope, code, severity: 'warning', message, fix };
59
+ }
60
+
61
+ export function hasCopyStudio(projectDir) {
62
+ return fs.existsSync(strategyFile(projectDir));
63
+ }
64
+
65
+ export function scaffoldCopyStudio(projectDir, { replace = false } = {}) {
66
+ const project = readProject(projectDir).data;
67
+ const file = strategyFile(projectDir);
68
+ if (fs.existsSync(file) && !replace) return { file, created: false };
69
+ let discovery = null;
70
+ const discoveryFile = path.join(projectDir, '.cosmo', 'brand', 'discovery.json');
71
+ if (fs.existsSync(discoveryFile)) {
72
+ try { discovery = JSON.parse(fs.readFileSync(discoveryFile, 'utf8')); } catch { discovery = null; }
73
+ }
74
+ writeJson(file, {
75
+ version: 1,
76
+ approved: false,
77
+ audience: {
78
+ primary: discovery?.synthesis?.audience ?? '',
79
+ currentAlternative: '',
80
+ startingBelief: '',
81
+ desiredBelief: '',
82
+ switching: { motivation: 'unknown', ability: 'unknown', state: 'unknown', confidence: 'unknown', evidenceIds: [] },
83
+ },
84
+ positioning: {
85
+ marketEnvironment: 'unknown',
86
+ meaningfulBenefit: '',
87
+ benefitType: 'unknown',
88
+ differentiation: discovery?.synthesis?.differentiation ?? '',
89
+ categoryClass: '',
90
+ proofIds: [],
91
+ },
92
+ competitiveTransition: {
93
+ enabled: false,
94
+ incumbentScope: 'category',
95
+ incumbent: '',
96
+ bindingVulnerability: '',
97
+ vulnerabilityType: 'unknown',
98
+ reframeMode: 'none',
99
+ reframe: '',
100
+ categoryDistinction: '',
101
+ proofBridge: '',
102
+ migrationSupport: '',
103
+ intensity: 'none',
104
+ claimIds: [],
105
+ proofIds: [],
106
+ },
107
+ voice: {
108
+ protagonist: 'customer-as-hero',
109
+ readerLanguage: [],
110
+ techniques: [],
111
+ avoid: [],
112
+ },
113
+ governance: {
114
+ owner: '',
115
+ comparisonPolicy: 'category-only',
116
+ factsMustBePreserved: true,
117
+ noFabricatedClaims: true,
118
+ noManipulation: true,
119
+ approvedAt: null,
120
+ },
121
+ project: { name: project.name, brand: project.brand },
122
+ });
123
+ return { file, created: true };
124
+ }
125
+
126
+ export function readCopyStrategy(projectDir) {
127
+ const file = strategyFile(projectDir);
128
+ return { file, data: readJson(file, 'Copy strategy') };
129
+ }
130
+
131
+ export function scaffoldCopyBrief(projectDir, pageId, { replace = false } = {}) {
132
+ const strategy = readCopyStrategy(projectDir).data;
133
+ const plan = readPlan(projectDir, { requireApproved: false }).data;
134
+ const page = plan.pages.find((candidate) => candidate.id === pageId);
135
+ if (!page) throw new CopyStudioError(`Unknown planned page: ${pageId}`);
136
+ const file = briefFile(projectDir, pageId);
137
+ if (fs.existsSync(file) && !replace) return { file, created: false };
138
+ const intent = page.architecture?.intent ?? {};
139
+ writeJson(file, {
140
+ version: 1,
141
+ pageId,
142
+ status: 'draft',
143
+ reader: {
144
+ audienceNeed: page.contract.audienceNeed,
145
+ startingBelief: strategy.audience?.startingBelief ?? '',
146
+ desiredBelief: strategy.audience?.desiredBelief ?? '',
147
+ awareness: intent.awareness ?? 'unknown',
148
+ switchingState: strategy.audience?.switching?.state ?? 'unknown',
149
+ },
150
+ message: {
151
+ primaryQuestion: intent.primary ?? '',
152
+ job: intent.primary ?? '',
153
+ entryPoint: '',
154
+ angle: '',
155
+ protagonist: strategy.voice?.protagonist ?? 'customer-as-hero',
156
+ framework: 'custom',
157
+ objections: [],
158
+ ctaCeiling: ctaCeiling(intent.funnel),
159
+ },
160
+ positioning: {
161
+ meaningfulBenefit: strategy.positioning?.meaningfulBenefit ?? '',
162
+ differentiation: strategy.positioning?.differentiation ?? '',
163
+ proofIds: [...(page.contract.carriesProof ?? [])],
164
+ },
165
+ competitiveTransition: {
166
+ enabled: strategy.competitiveTransition?.enabled === true,
167
+ reframeMode: strategy.competitiveTransition?.reframeMode ?? 'none',
168
+ reframe: strategy.competitiveTransition?.reframe ?? '',
169
+ proofIds: (strategy.competitiveTransition?.proofIds ?? []).filter((id) => page.contract.carriesProof.includes(id)),
170
+ },
171
+ sections: [
172
+ {
173
+ id: 'answer',
174
+ purpose: 'Answer the reader’s primary question directly.',
175
+ answerFirst: true,
176
+ layerOneTarget: page.contract.answerFirstTarget ?? '',
177
+ layerTwoValue: '',
178
+ wordBudget: 150,
179
+ ctaRole: 'none',
180
+ claimIds: [...(page.contract.supportsClaims ?? [])],
181
+ proofIds: [...(page.contract.carriesProof ?? [])],
182
+ technique: 'direct-answer',
183
+ transition: '',
184
+ },
185
+ {
186
+ id: 'decision',
187
+ purpose: 'Help the reader make the next appropriate decision.',
188
+ answerFirst: false,
189
+ layerOneTarget: '',
190
+ layerTwoValue: '',
191
+ wordBudget: 250,
192
+ ctaRole: ctaCeiling(intent.funnel),
193
+ claimIds: [],
194
+ proofIds: [],
195
+ technique: 'reader-choice',
196
+ transition: '',
197
+ },
198
+ ],
199
+ revision: { owner: '', factsPreserved: true, changeLog: [] },
200
+ });
201
+ return { file, created: true };
202
+ }
203
+
204
+ function validateStrategyValue(value, integrity) {
205
+ const findings = [];
206
+ const add = (code, message, fix) => findings.push(finding('strategy', code, message, fix));
207
+ if (value?.version !== 1) add('strategy-version', 'Copy strategy version must be 1.', 'Regenerate or migrate the strategy.');
208
+ if (value?.approved !== true) add('strategy-unapproved', 'Copy strategy is still a draft.', 'Review the strategy and set approved to true only after human approval.');
209
+ for (const [key, label] of [['primary', 'primary audience'], ['currentAlternative', 'current alternative'], ['startingBelief', 'starting belief'], ['desiredBelief', 'desired belief']]) {
210
+ if (!nonEmpty(value?.audience?.[key])) add(`audience-${key}`, `The ${label} is missing.`, `Define the reader’s ${label}.`);
211
+ }
212
+ const switching = value?.audience?.switching ?? {};
213
+ if (!MOTIVATION_LEVELS.includes(switching.motivation)) add('switching-motivation', 'Switching motivation is invalid.', `Use one of: ${MOTIVATION_LEVELS.join(', ')}.`);
214
+ if (!ABILITY_LEVELS.includes(switching.ability)) add('switching-ability', 'Switching ability is invalid.', `Use one of: ${ABILITY_LEVELS.join(', ')}.`);
215
+ if (!SWITCHING_STATES.includes(switching.state)) add('switching-state', 'Switching state is invalid.', `Use one of: ${SWITCHING_STATES.join(', ')}.`);
216
+ const expected = expectedSwitchingState(switching.motivation, switching.ability);
217
+ if (SWITCHING_STATES.includes(switching.state) && switching.state !== expected) add('switching-state-drift', `Switching state ${switching.state} conflicts with motivation ${switching.motivation} and ability ${switching.ability}.`, `Use ${expected} or revise the underlying assessment.`);
218
+ if (!['unknown', 'inferred', 'observed', 'supplied'].includes(switching.confidence)) add('switching-confidence', 'Switching confidence is invalid.', 'Record unknown, inferred, observed, or supplied.');
219
+ for (const [key, label] of [['meaningfulBenefit', 'meaningful benefit'], ['differentiation', 'credible differentiation'], ['categoryClass', 'category class']]) {
220
+ if (!nonEmpty(value?.positioning?.[key])) add(`positioning-${key}`, `The ${label} is missing.`, `Define the ${label}.`);
221
+ }
222
+ if (!['introductory', 'offensive', 'defensive', 'remedial', 'hybrid'].includes(value?.positioning?.marketEnvironment)) add('market-environment', 'Approved positioning needs a known market environment.', 'Choose introductory, offensive, defensive, remedial, or hybrid.');
223
+ if (!['functional', 'emotional', 'self-expressive'].includes(value?.positioning?.benefitType)) add('benefit-type', 'Approved positioning needs a meaningful benefit type.', 'Choose functional, emotional, or self-expressive.');
224
+ if (!Array.isArray(value?.positioning?.proofIds) || value.positioning.proofIds.length === 0) add('positioning-proof', 'Positioning has no proof bridge.', 'Attach at least one verified proof ID.');
225
+ const verifiedProofs = new Set(integrity.evidence.proofs.filter((proof) => proof.status === 'verified').map((proof) => proof.id));
226
+ const claimIds = integrity.evidence.claimIds;
227
+ for (const id of [...(switching.evidenceIds ?? []), ...(value?.positioning?.proofIds ?? []), ...(value?.competitiveTransition?.proofIds ?? [])]) {
228
+ if (!verifiedProofs.has(id)) add('unverified-proof', `Proof ${id} is missing or not verified.`, 'Verify it in .cosmo/evidence.json before using it in copy strategy.');
229
+ }
230
+ const transition = value?.competitiveTransition ?? {};
231
+ if (transition.enabled === true) {
232
+ if (!['category', 'named'].includes(transition.incumbentScope)) add('transition-scope', 'Competitive transition has an invalid incumbent scope.', 'Choose category or named.');
233
+ if (!['superficial', 'functional', 'structural'].includes(transition.vulnerabilityType)) add('transition-vulnerability-type', 'Competitive transition needs a specific vulnerability type.', 'Choose superficial, functional, or structural.');
234
+ if (!['subtle', 'moderate', 'direct'].includes(transition.intensity)) add('transition-intensity', 'Competitive transition needs a deliberate intensity.', 'Choose subtle, moderate, or direct.');
235
+ for (const [key, label] of [['incumbent', 'current alternative or incumbent'], ['bindingVulnerability', 'binding vulnerability'], ['reframe', 'truthful reframe'], ['categoryDistinction', 'category distinction'], ['proofBridge', 'proof bridge'], ['migrationSupport', 'migration support']]) {
236
+ if (!nonEmpty(transition[key])) add(`transition-${key}`, `Competitive transition needs a ${label}.`, `Define the ${label} without exaggeration or invented evidence.`);
237
+ }
238
+ if (!['question', 'friction'].includes(transition.reframeMode)) add('transition-reframe-mode', 'Competitive transition must use a question or documented friction.', 'Choose question or friction.');
239
+ if (transition.incumbentScope === 'named' && value?.governance?.comparisonPolicy !== 'named-with-proof') add('named-comparison-policy', 'A named alternative requires the named-with-proof comparison policy.', 'Use category-level comparison or explicitly approve evidence-backed named comparison.');
240
+ if (!Array.isArray(transition.claimIds) || transition.claimIds.length === 0 || !Array.isArray(transition.proofIds) || transition.proofIds.length === 0) add('transition-evidence', 'Competitive transition needs approved claim and proof IDs.', 'Attach at least one governed claim and verified proof.');
241
+ for (const id of transition.claimIds ?? []) if (!claimIds.has(id)) add('transition-claim', `Competitive transition references unknown claim ${id}.`, 'Add the claim to the evidence ledger or remove it.');
242
+ }
243
+ if (!nonEmpty(value?.governance?.owner)) add('governance-owner', 'Copy strategy needs a named owner.', 'Record the person accountable for approval.');
244
+ if (!['category-only', 'named-with-proof'].includes(value?.governance?.comparisonPolicy)) add('comparison-policy', 'Comparison policy is invalid.', 'Choose category-only or named-with-proof.');
245
+ if (!nonEmpty(value?.governance?.approvedAt) || Number.isNaN(Date.parse(value.governance.approvedAt))) add('approval-time', 'Approved copy strategy needs a valid approval timestamp.', 'Record approvedAt when the project owner approves the strategy.');
246
+ for (const key of ['factsMustBePreserved', 'noFabricatedClaims', 'noManipulation']) if (value?.governance?.[key] !== true) add(`governance-${key}`, `${key} must remain true.`, 'Restore the ethical safeguard.');
247
+ if (!['customer-as-hero', 'brand-as-guide', 'brand-as-expert', 'hybrid'].includes(value?.voice?.protagonist)) add('voice-protagonist', 'Copy strategy has an invalid protagonist.', 'Choose customer-as-hero, brand-as-guide, brand-as-expert, or hybrid.');
248
+ if (!Array.isArray(value?.voice?.techniques) || value.voice.techniques.length === 0 || value.voice.techniques.some((item) => !nonEmpty(item))) add('voice-techniques', 'Approved strategy needs at least one original voice technique.', 'Describe structural or rhetorical techniques without imitating a named writer.');
249
+ return findings;
250
+ }
251
+
252
+ function validateBriefValue(value, page, strategy, integrity) {
253
+ const findings = [];
254
+ const add = (code, message, fix) => findings.push(finding(page.id, code, message, fix));
255
+ if (value?.version !== 1 || value?.pageId !== page.id) add('brief-identity', `Copy brief must be version 1 for ${page.id}.`, 'Regenerate the page copy brief.');
256
+ if (value?.status !== 'approved') add('brief-unapproved', `Copy brief for ${page.id} is still a draft.`, 'Review it and set status to approved.');
257
+ if (value?.reader?.audienceNeed !== page.contract.audienceNeed) add('audience-drift', `Copy brief audience need drifted from the plan for ${page.id}.`, 'Restore the plan-derived audience need.');
258
+ if (value?.reader?.startingBelief !== strategy.audience?.startingBelief || value?.reader?.desiredBelief !== strategy.audience?.desiredBelief) add('belief-drift', `Copy brief beliefs drifted from the approved strategy for ${page.id}.`, 'Regenerate or align the copy brief with copy strategy.');
259
+ for (const [key, label] of [['primaryQuestion', 'primary question'], ['job', 'page job'], ['entryPoint', 'reader entry point'], ['angle', 'message angle']]) if (!nonEmpty(value?.message?.[key])) add(`message-${key}`, `Copy brief for ${page.id} needs a ${label}.`, `Define the ${label}.`);
260
+ const ceiling = ctaCeiling(page.architecture?.intent?.funnel);
261
+ if (value?.message?.ctaCeiling !== ceiling) add('cta-ceiling-drift', `CTA ceiling for ${page.id} must be ${ceiling}.`, 'Align CTA pressure with the planned funnel stage.');
262
+ if (!Array.isArray(value?.sections) || value.sections.length < 2) add('sections-missing', `Copy brief for ${page.id} needs at least two purposeful sections.`, 'Add an answer-first section and the next useful decision section.');
263
+ const sectionIds = new Set();
264
+ const usedClaims = new Set();
265
+ const usedProofs = new Set();
266
+ let answerFirst = false;
267
+ for (const section of value?.sections ?? []) {
268
+ if (!nonEmpty(section?.id) || !ID_PATTERN.test(section.id) || sectionIds.has(section.id)) add('section-id', `Copy brief for ${page.id} has an invalid or duplicate section ID.`, 'Use unique kebab-case section IDs.');
269
+ sectionIds.add(section?.id);
270
+ if (!nonEmpty(section?.purpose) || !nonEmpty(section?.layerOneTarget)) add('section-contract', `Section ${section?.id ?? '(unknown)'} needs a purpose and Layer 1 target.`, 'Define what the section answers before drafting it.');
271
+ if (!Number.isInteger(section?.wordBudget) || section.wordBudget < 25 || section.wordBudget > 1200) add('word-budget', `Section ${section?.id ?? '(unknown)'} has an invalid word budget.`, 'Use a deliberate budget from 25 to 1200 words.');
272
+ if (!CTA_ROLES.includes(section?.ctaRole)) add('cta-role', `Section ${section?.id ?? '(unknown)'} has an invalid CTA role.`, `Use one of: ${CTA_ROLES.join(', ')}.`);
273
+ if (CTA_ROLES.indexOf(section?.ctaRole) > CTA_ROLES.indexOf(ceiling)) add('cta-pressure', `Section ${section?.id ?? '(unknown)'} exceeds the ${ceiling} CTA ceiling.`, 'Reduce CTA pressure to match reader readiness.');
274
+ if (section?.answerFirst === true) answerFirst = true;
275
+ for (const id of section?.claimIds ?? []) {
276
+ if (!page.contract.supportsClaims.includes(id)) add('unplanned-claim', `Section ${section?.id} uses unplanned claim ${id}.`, 'Use only claims approved for this page.');
277
+ usedClaims.add(id);
278
+ }
279
+ for (const id of section?.proofIds ?? []) {
280
+ if (!page.contract.carriesProof.includes(id)) add('unplanned-proof', `Section ${section?.id} uses unplanned proof ${id}.`, 'Use only proofs approved for this page.');
281
+ if (!integrity.evidence.proofs.some((proof) => proof.id === id && proof.status === 'verified')) add('unverified-page-proof', `Section ${section?.id} uses unverified proof ${id}.`, 'Verify the proof before drafting.');
282
+ usedProofs.add(id);
283
+ }
284
+ }
285
+ if (!answerFirst) add('answer-first-missing', `Copy brief for ${page.id} has no answer-first section.`, 'Mark the self-contained opening answer with answerFirst: true.');
286
+ for (const id of page.contract.supportsClaims) if (!usedClaims.has(id)) add('claim-unplaced', `Copy brief for ${page.id} does not place claim ${id}.`, 'Assign the claim to a section.');
287
+ for (const id of page.contract.carriesProof) if (!usedProofs.has(id)) add('proof-unplaced', `Copy brief for ${page.id} does not place proof ${id}.`, 'Assign the proof beside the claim it supports.');
288
+ if (value?.positioning?.meaningfulBenefit !== strategy.positioning?.meaningfulBenefit || value?.positioning?.differentiation !== strategy.positioning?.differentiation) add('positioning-drift', `Copy brief positioning drifted from the approved strategy for ${page.id}.`, 'Regenerate or align the copy brief with copy strategy.');
289
+ if (value?.message?.protagonist !== strategy.voice?.protagonist) add('protagonist-drift', `Copy brief protagonist drifted from the approved strategy for ${page.id}.`, 'Use the approved project protagonist.');
290
+ if (value?.competitiveTransition?.enabled !== strategy.competitiveTransition?.enabled) add('transition-drift', `Competitive transition setting drifted for ${page.id}.`, 'Align it with the approved project strategy.');
291
+ if (strategy.competitiveTransition?.enabled && (value?.competitiveTransition?.reframeMode !== strategy.competitiveTransition.reframeMode || value?.competitiveTransition?.reframe !== strategy.competitiveTransition.reframe)) add('transition-message-drift', `Competitive transition language drifted for ${page.id}.`, 'Use the approved reframe or revise the project strategy first.');
292
+ if (!nonEmpty(value?.revision?.owner)) add('revision-owner', `Copy brief for ${page.id} needs a revision owner.`, 'Name the person accountable for the final copy.');
293
+ if (value?.revision?.factsPreserved !== true) add('facts-not-preserved', `Copy brief for ${page.id} does not protect approved facts.`, 'Set factsPreserved to true and recheck every edit against evidence.');
294
+ return findings;
295
+ }
296
+
297
+ export function evaluateCopyStudio(projectDir) {
298
+ readProject(projectDir);
299
+ const checkedAt = new Date().toISOString();
300
+ if (!hasCopyStudio(projectDir)) {
301
+ return { version: 1, enabled: false, passed: true, checkedAt, summary: { pages: 0, blocking: 0, warnings: 1 }, findings: [warning('studio', 'copy-studio-disabled', 'Copy Studio is not initialized for this legacy project.', 'Run cosmo copy init to enable it.')] };
302
+ }
303
+ const integrity = readIntegrity(projectDir);
304
+ const strategy = readCopyStrategy(projectDir).data;
305
+ const plan = readPlan(projectDir, { requireApproved: false }).data;
306
+ const findings = validateStrategyValue(strategy, integrity);
307
+ for (const page of plan.pages) {
308
+ const file = briefFile(projectDir, page.id);
309
+ if (!fs.existsSync(file)) findings.push(finding(page.id, 'brief-missing', `Copy brief is missing for ${page.id}.`, `Run cosmo copy brief ${page.id}.`));
310
+ else {
311
+ try { findings.push(...validateBriefValue(readJson(file, `Copy brief for ${page.id}`), page, strategy, integrity)); }
312
+ catch (error) { findings.push(finding(page.id, 'brief-invalid', error.message, `Repair or regenerate the copy brief for ${page.id}.`)); }
313
+ }
314
+ }
315
+ const blocking = findings.filter((item) => item.severity === 'blocking').length;
316
+ const warnings = findings.filter((item) => item.severity === 'warning').length;
317
+ return { version: 1, enabled: true, passed: blocking === 0, checkedAt, strategy: { approved: strategy.approved === true }, pages: plan.pages.map((page) => ({ id: page.id, brief: path.relative(projectDir, briefFile(projectDir, page.id)) })), summary: { pages: plan.pages.length, blocking, warnings }, findings };
318
+ }
319
+
320
+ export function writeCopyStudioReport(projectDir, report) {
321
+ const file = path.join(projectDir, '.cosmo', 'reports', 'copy-check.json');
322
+ writeJson(file, report);
323
+ return file;
324
+ }
325
+
326
+ export function assertCopyStrategy(projectDir) {
327
+ if (!hasCopyStudio(projectDir)) return null;
328
+ const integrity = readIntegrity(projectDir);
329
+ const strategy = readCopyStrategy(projectDir).data;
330
+ const findings = validateStrategyValue(strategy, integrity);
331
+ if (findings.length) throw new CopyStudioError(`Copy strategy is not ready: ${findings[0].message} Run cosmo copy check for the complete report.`);
332
+ return strategy;
333
+ }
334
+
335
+ export function assertCopyBrief(projectDir, pageId) {
336
+ if (!hasCopyStudio(projectDir)) return null;
337
+ const integrity = readIntegrity(projectDir);
338
+ const strategy = assertCopyStrategy(projectDir);
339
+ const plan = readPlan(projectDir, { requireApproved: false }).data;
340
+ const page = plan.pages.find((candidate) => candidate.id === pageId);
341
+ if (!page) throw new CopyStudioError(`Unknown planned page: ${pageId}`);
342
+ const value = readJson(briefFile(projectDir, pageId), `Copy brief for ${pageId}`);
343
+ const findings = validateBriefValue(value, page, strategy, integrity);
344
+ if (findings.length) throw new CopyStudioError(`Copy brief for ${pageId} is not ready: ${findings[0].message} Run cosmo copy check for the complete report.`);
345
+ return value;
346
+ }
347
+
348
+ export function copyGuide(projectDir, pageId) {
349
+ const strategy = assertCopyStrategy(projectDir);
350
+ const brief = assertCopyBrief(projectDir, pageId);
351
+ const plan = readPlan(projectDir, { requireApproved: false }).data;
352
+ const page = plan.pages.find((candidate) => candidate.id === pageId);
353
+ const sections = brief.sections.map((section) => `- ${section.id}: ${section.purpose} Layer 1: ${section.layerOneTarget} Budget: ${section.wordBudget} words. Claims: ${section.claimIds.join(', ') || 'none'}. Proofs: ${section.proofIds.join(', ') || 'none'}. CTA: ${section.ctaRole}.`).join('\n') + `\n\nContextual editorial review\n${EDITORIAL_REVIEW_GUIDANCE}`;
354
+ return `COPY STUDIO — ${page.title} (${page.id})\n\nReader entry point\n- Need: ${brief.reader.audienceNeed}\n- Starts believing: ${brief.reader.startingBelief}\n- Should leave believing: ${brief.reader.desiredBelief}\n- Switching state: ${brief.reader.switchingState}\n- Primary question: ${brief.message.primaryQuestion}\n- Angle: ${brief.message.angle}\n- Protagonist: ${brief.message.protagonist}\n\nPositioning\n- Meaningful benefit: ${brief.positioning.meaningfulBenefit}\n- Credible difference: ${brief.positioning.differentiation}\n- CTA ceiling: ${brief.message.ctaCeiling}\n${strategy.competitiveTransition.enabled ? `- Truthful transition reframe: ${brief.competitiveTransition.reframe}\n- Proof bridge: ${strategy.competitiveTransition.proofBridge}\n- Migration support: ${strategy.competitiveTransition.migrationSupport}\n` : ''}\nAnnotated section contract\n${sections}\n\nWriting sequence\n1. Grounding: read the page plan, evidence ledger, source manifest, voice profile, and this approved brief. Do not invent facts, quotations, experiences, testimonials, statistics, or comparisons.\n2. Draft: open with a self-contained answer, then add useful depth. Let the reader remain the protagonist. Put proof beside the claim it supports. Honor the word budgets and CTA ceiling without forcing a preset page layout.\n3. Evidence pass: verify every factual and comparative statement against approved proof. Attribute outside material. Turn unsupported certainty into a clearly labeled hypothesis or remove it.\n4. Editorial pass: improve sequence, transitions, specificity, rhythm, and redundancy while preserving facts and the approved angle. Do not imitate a living writer or copy source phrasing.\n5. Reader pass: test whether the copy meets the reader at the recorded starting belief, resolves the real objection, and earns the next action without pressure or manipulation.\n6. Final pass: record material changes in revision.changeLog, keep factsPreserved true, run cosmo copy check, then proceed through normal content and browser QA.`;
355
+ }
@@ -6,7 +6,7 @@ import { readPlan } from './plan.mjs';
6
6
  import { readProject, writeJson } from './project.mjs';
7
7
  import { readWorkflowState } from './workflow.mjs';
8
8
 
9
- const REQUIRED_REPORTS = ['integrity-check', 'content-check', 'intelligence-check', 'site-check', 'browser-check'];
9
+ const BASE_REQUIRED_REPORTS = ['integrity-check', 'content-check', 'intelligence-check', 'site-check', 'browser-check'];
10
10
  const PLACEHOLDER_PATTERN = /complete this|replace this placeholder|hello@example\.com|\(000\) 000-0000|tel:\+10000000000/i;
11
11
 
12
12
  function finding(code, message, fix) {
@@ -38,6 +38,7 @@ function sourceFiles(projectDir) {
38
38
  path.join(projectDir, 'src'),
39
39
  path.join(projectDir, 'public'),
40
40
  path.join(projectDir, '.cosmo', 'brand'),
41
+ path.join(projectDir, '.cosmo', 'copy'),
41
42
  path.join(projectDir, '.cosmo', 'capabilities'),
42
43
  path.join(projectDir, '.cosmo', 'intelligence'),
43
44
  path.join(projectDir, '.cosmo', 'policies'),
@@ -93,7 +94,8 @@ export function evaluateDelivery(projectDir) {
93
94
  const progress = optionalJson(path.join(projectDir, '.cosmo', 'progress.json'));
94
95
  if (!progress || progress.invalid || progress.complete !== true) findings.push(finding('generation-incomplete', progress?.invalid ? 'Generation state is invalid.' : 'Generation is missing or incomplete.', 'Finish or reconcile every planned page through the generation pipeline.'));
95
96
 
96
- const reports = REQUIRED_REPORTS.map((name) => {
97
+ const requiredReports = [...BASE_REQUIRED_REPORTS, ...(fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : [])];
98
+ const reports = requiredReports.map((name) => {
97
99
  const file = path.join(projectDir, '.cosmo', 'reports', `${name}.json`);
98
100
  const data = optionalJson(file);
99
101
  let status = 'missing';
@@ -0,0 +1,17 @@
1
+ // Contextual review aids, never an authorship detector or automatic rewrite policy.
2
+ export const EDITORIAL_REVIEW_GUIDANCE = `Editorial priority: facts and evidence > approved page purpose and positioning > brand voice > style preferences.
3
+ Detect before editing: quote the exact passage, name the pattern, explain the concern in context, and suggest the smallest useful change. These observations are not proof of AI authorship or a writing-quality score.
4
+ Make minimum effective edits. Preserve strong sentences, deliberate humor, cadence, uncertainty, terminology, and useful narrative detours. Do not add opinions, statistics, examples, or experiences to make prose feel human.
5
+ Apply the portability test as a human review question: could this sentence describe almost any business? If so, replace filler with an existing verified fact, mechanism, or consequence; otherwise request evidence or remove it. Never invent specificity.
6
+ Review empty introductions, vague praise, unsupported attribution, redundant explanations, repetitive endings, and unnecessary synonym changes. Preserve necessary qualifications and source attribution.
7
+ Keep meaningful positioning contrasts, FAQs, rhetorical questions, fragments, passive constructions, summaries, and punctuation when they serve the reader or approved voice. Do not impose universal word bans, punctuation quotas, or uniform paragraph shapes. Answer-first value does not require every paragraph to use the same structure.
8
+ Style findings are advisory. If an edit could change a claim, qualification, approved angle, CTA, or voice, present it for human review rather than silently applying it. After accepted edits, recheck evidence and copy contracts.
9
+ Record material edits in revision.changeLog with the original passage, revised passage, reason, affected claim/proof IDs, and reviewer. Record intentional exceptions with a rationale. Run cosmo intelligence check when editorial-naturalness is selected; cosmo copy check validates contracts, not prose naturalness.`;
10
+
11
+ export const EDITORIAL_PATTERNS = [
12
+ { id: 'throat-clearing', pattern: /\b(here's the thing|let me be clear|the uncomfortable truth is)\b/gi, suggestion: 'Remove the setup if it adds no voice or context; state the point directly.' },
13
+ { id: 'faux-insight', pattern: /\b(what nobody tells you|the part everyone misses|what most people get wrong)\b/gi, suggestion: 'Check the implied claim about others; retain the substantive point without unsupported exclusivity.' },
14
+ { id: 'importance-puffery', pattern: /\b(stands as a testament|plays a vital role|solidifies its position|underscores its significance)\b/gi, suggestion: 'Use the documented mechanism or consequence, or remove empty praise.' },
15
+ { id: 'interpretive-aside', pattern: /\b(as you can see|that last part matters more than it sounds|this distinction matters)\b/gi, suggestion: 'Keep only if the interpretation adds useful explanation not already apparent.' },
16
+ { id: 'recap-opener', pattern: /\b(in conclusion|to sum up|in summary)\b/gi, suggestion: 'Check whether a recap helps the format; otherwise end with the concrete takeaway or next action.' },
17
+ ];
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { checkIntelligenceStage } from './intelligence.mjs';
5
+ import { assertCopyBrief } from './copy-studio.mjs';
5
6
  import matter from 'gray-matter';
6
7
  import { checkIntegrity, readIntegrity } from './integrity.mjs';
7
8
  import { readPageWork } from './page-work.mjs';
@@ -138,7 +139,7 @@ function productionRequirement(page, status) {
138
139
  const requirements = {
139
140
  planned: { action: 'Validate the plan-derived page brief.', artifact: `.cosmo/work/pages/${page.id}/brief.json` },
140
141
  briefed: { action: 'Complete and validate the source manifest.', artifact: `.cosmo/work/pages/${page.id}/sources.json` },
141
- sourced: { action: 'Complete the claim-and-proof-aware outline.', artifact: `.cosmo/work/pages/${page.id}/outline.json` },
142
+ sourced: { action: 'Use the approved Copy Studio brief to complete the claim-and-proof-aware outline.', artifact: `.cosmo/work/pages/${page.id}/outline.json` },
142
143
  outlined: { action: 'Write the typed content entry.', artifact: page.contentFile },
143
144
  drafted: { action: 'Complete the editorial review report.', artifact: `.cosmo/work/pages/${page.id}/editorial-report.json` },
144
145
  edited: { action: 'Run deterministic page verification.', artifact: page.contentFile },
@@ -218,7 +219,10 @@ export function advancePage(projectDir, pageId) {
218
219
  const from = record.status;
219
220
  const to = nextProductionState(from);
220
221
  if (from === 'planned') checkIntegrity(projectDir);
221
- if (from === 'briefed') readPageWork(projectDir, pageId, 'sources');
222
+ if (from === 'briefed') {
223
+ readPageWork(projectDir, pageId, 'sources');
224
+ assertCopyBrief(projectDir, pageId);
225
+ }
222
226
  if (from === 'sourced') readPageWork(projectDir, pageId, 'outline');
223
227
  if (from === 'outlined') contentExists(projectDir, page);
224
228
  if (from === 'drafted') readPageWork(projectDir, pageId, 'editorial', { repairAttempt: record.repairAttempts });