@archangel70/cosmo 1.7.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.
- package/CHANGELOG.md +31 -0
- package/README.md +792 -0
- package/SECURITY.md +15 -0
- package/docs/AGENT-HANDOFF.md +44 -0
- package/docs/ARCHITECTURE-INTELLIGENCE.md +64 -0
- package/docs/ARCHITECTURE.md +97 -0
- package/docs/BRAND-DISCOVERY.md +12 -0
- package/docs/BROWSER-QA.md +40 -0
- package/docs/CLAUDE-LAUNCHER.md +72 -0
- package/docs/CONTENT-QA.md +62 -0
- package/docs/DELIVERY.md +40 -0
- package/docs/DEPLOYMENT.md +119 -0
- package/docs/FIRST-PARTY-CAPABILITIES.md +54 -0
- package/docs/GENERATION.md +81 -0
- package/docs/INTEGRITY.md +75 -0
- package/docs/INTELLIGENCE-PACKS.md +122 -0
- package/docs/OPERATIONS.md +7 -0
- package/docs/PAGE-PRODUCTION.md +81 -0
- package/docs/ROADMAP.md +184 -0
- package/docs/WORKFLOWS.md +71 -0
- package/package.json +97 -0
- package/packages/cli/bin/cosmo.mjs +901 -0
- package/packages/cli/lib/adoption.mjs +72 -0
- package/packages/cli/lib/audit.mjs +145 -0
- package/packages/cli/lib/brand.mjs +60 -0
- package/packages/cli/lib/browser-audit.mjs +177 -0
- package/packages/cli/lib/claude-plugin.mjs +64 -0
- package/packages/cli/lib/content-audit.mjs +184 -0
- package/packages/cli/lib/delivery.mjs +140 -0
- package/packages/cli/lib/deployment.mjs +211 -0
- package/packages/cli/lib/doctor.mjs +42 -0
- package/packages/cli/lib/file-transfer.mjs +143 -0
- package/packages/cli/lib/generation.mjs +319 -0
- package/packages/cli/lib/handoff.mjs +109 -0
- package/packages/cli/lib/integrity.mjs +315 -0
- package/packages/cli/lib/intelligence-audit.mjs +445 -0
- package/packages/cli/lib/intelligence.mjs +331 -0
- package/packages/cli/lib/page-work.mjs +154 -0
- package/packages/cli/lib/plan.mjs +229 -0
- package/packages/cli/lib/process.mjs +45 -0
- package/packages/cli/lib/project.mjs +113 -0
- package/packages/cli/lib/research.mjs +85 -0
- package/packages/cli/lib/status.mjs +46 -0
- package/packages/cli/lib/workflow.mjs +294 -0
- package/plugins/claude-code/cosmo/.claude-plugin/plugin.json +10 -0
- package/plugins/claude-code/cosmo/README.md +25 -0
- package/plugins/claude-code/cosmo/bin/cosmo +11 -0
- package/plugins/claude-code/cosmo/skills/cosmo/SKILL.md +122 -0
- package/plugins/claude-code/cosmo/skills/cosmo-help/SKILL.md +16 -0
- package/scripts/postinstall.mjs +14 -0
- package/templates/astro-site/.cosmo/brand/discovery.json +19 -0
- package/templates/astro-site/.cosmo/brand/entity-canon.json +20 -0
- package/templates/astro-site/.cosmo/brand/voice-profile.json +16 -0
- package/templates/astro-site/.cosmo/build-plan.json +75 -0
- package/templates/astro-site/.cosmo/capabilities/registry.json +21 -0
- package/templates/astro-site/.cosmo/evidence.json +11 -0
- package/templates/astro-site/.cosmo/intelligence/selection.json +5 -0
- package/templates/astro-site/.cosmo/policies/content-integrity.json +22 -0
- package/templates/astro-site/.cosmo/project.json +10 -0
- package/templates/astro-site/.cosmo/work/pages/about/brief.json +49 -0
- package/templates/astro-site/.cosmo/work/pages/home/brief.json +51 -0
- package/templates/astro-site/.cosmo/workflows/default.json +146 -0
- package/templates/astro-site/.env.example +7 -0
- package/templates/astro-site/AGENTS.md +26 -0
- package/templates/astro-site/CLAUDE.md +28 -0
- package/templates/astro-site/DESIGN-DIRECTION.md +9 -0
- package/templates/astro-site/README.md +17 -0
- package/templates/astro-site/astro.config.mjs +16 -0
- package/templates/astro-site/cosmo.config.mjs +12 -0
- package/templates/astro-site/gitignore.template +9 -0
- package/templates/astro-site/package.json +23 -0
- package/templates/astro-site/public/favicon.svg +5 -0
- package/templates/astro-site/src/components/PageView.astro +20 -0
- package/templates/astro-site/src/components/sections/Action.astro +24 -0
- package/templates/astro-site/src/components/sections/Evidence.astro +19 -0
- package/templates/astro-site/src/components/sections/Hero.astro +41 -0
- package/templates/astro-site/src/components/sections/Problem.astro +19 -0
- package/templates/astro-site/src/components/sections/Proof.astro +15 -0
- package/templates/astro-site/src/components/sections/SectionRenderer.astro +22 -0
- package/templates/astro-site/src/components/sections/Solution.astro +19 -0
- package/templates/astro-site/src/components/seo/SeoHead.astro +41 -0
- package/templates/astro-site/src/content/pages/about.md +52 -0
- package/templates/astro-site/src/content/pages/home.md +48 -0
- package/templates/astro-site/src/content.config.ts +133 -0
- package/templates/astro-site/src/env.d.ts +1 -0
- package/templates/astro-site/src/layouts/BaseLayout.astro +57 -0
- package/templates/astro-site/src/pages/[...slug].astro +22 -0
- package/templates/astro-site/src/pages/index.astro +9 -0
- package/templates/astro-site/src/pages/robots.txt.ts +6 -0
- package/templates/astro-site/src/styles/global.css +540 -0
- package/templates/astro-site/src/styles/tokens.css +27 -0
- package/templates/astro-site/tsconfig.json +9 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readIntelligence } from './intelligence.mjs';
|
|
4
|
+
import { pageParentId, pageRelatedIds, readPlan } from './plan.mjs';
|
|
5
|
+
import { readProject, slugify, writeJson } from './project.mjs';
|
|
6
|
+
|
|
7
|
+
export class IntegrityError extends Error {}
|
|
8
|
+
|
|
9
|
+
const ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
10
|
+
const MATURITY = ['synthesized', 'calibrated', 'refined', 'authoritative'];
|
|
11
|
+
const PROVENANCE = ['owned', 'attributed', 'public'];
|
|
12
|
+
const PROOF_STATUS = ['pending', 'verified', 'rejected'];
|
|
13
|
+
const OWNERSHIP = ['measured', 'lived', 'originated', 'accessed', 'staked', 'first', 'corrected', 'documented'];
|
|
14
|
+
|
|
15
|
+
function assert(condition, message) {
|
|
16
|
+
if (!condition) throw new IntegrityError(message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readJson(file, label) {
|
|
20
|
+
assert(fs.existsSync(file), `${label} not found: ${file}`);
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
23
|
+
} catch {
|
|
24
|
+
throw new IntegrityError(`${label} is not valid JSON: ${file}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function assertId(value, label) {
|
|
29
|
+
assert(typeof value === 'string' && ID_PATTERN.test(value), `${label} must be kebab-case.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function assertString(value, label) {
|
|
33
|
+
assert(typeof value === 'string' && value.trim(), `${label} is required.`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function assertStringArray(value, label, { nonEmpty = false } = {}) {
|
|
37
|
+
assert(Array.isArray(value) && value.every((item) => typeof item === 'string' && item.trim()), `${label} must be an array of non-empty strings.`);
|
|
38
|
+
if (nonEmpty) assert(value.length > 0, `${label} must not be empty.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function validateCapabilityRegistry(value) {
|
|
42
|
+
assert(value && typeof value === 'object', 'Capability registry must be an object.');
|
|
43
|
+
assert([1, 2].includes(value.version), 'Capability registry version must be 1 or 2.');
|
|
44
|
+
assertId(value.profile, 'Capability profile');
|
|
45
|
+
if (value.version >= 2) assertStringArray(value.packs, 'Capability packs');
|
|
46
|
+
assert(Array.isArray(value.capabilities) && value.capabilities.length > 0, 'Capability registry must contain capabilities.');
|
|
47
|
+
const ids = new Set();
|
|
48
|
+
for (const capability of value.capabilities) {
|
|
49
|
+
assertId(capability.id, 'Capability id');
|
|
50
|
+
assert(!ids.has(capability.id), `Duplicate capability id: ${capability.id}`);
|
|
51
|
+
ids.add(capability.id);
|
|
52
|
+
assert(Number.isInteger(capability.version) && capability.version > 0, `Capability ${capability.id} needs a positive integer version.`);
|
|
53
|
+
assert(['active', 'optional', 'disabled'].includes(capability.status), `Capability ${capability.id} has an invalid status.`);
|
|
54
|
+
assertStringArray(capability.stages, `Capability ${capability.id} stages`, { nonEmpty: true });
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function validateEntityCanon(value) {
|
|
60
|
+
assert(value && typeof value === 'object', 'Entity Canon must be an object.');
|
|
61
|
+
assert(value.version === 1, 'Entity Canon version must be 1.');
|
|
62
|
+
assertId(value.id, 'Entity id');
|
|
63
|
+
assertString(value.officialName, 'Entity officialName');
|
|
64
|
+
assertStringArray(value.aliases, 'Entity aliases');
|
|
65
|
+
assertString(value.domain, 'Entity domain');
|
|
66
|
+
assertString(value.descriptions?.short, 'Entity descriptions.short');
|
|
67
|
+
assertString(value.descriptions?.long, 'Entity descriptions.long');
|
|
68
|
+
assertString(value.category, 'Entity category');
|
|
69
|
+
for (const key of ['services', 'audiences', 'locations', 'people', 'credentials', 'profiles', 'claims', 'proofVocabulary']) {
|
|
70
|
+
assert(Array.isArray(value[key]), `Entity ${key} must be an array.`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function validateVoiceProfile(value, entity) {
|
|
76
|
+
assert(value && typeof value === 'object', 'Voice profile must be an object.');
|
|
77
|
+
assert(value.version === 1, 'Voice profile version must be 1.');
|
|
78
|
+
assert(value.entityId === entity.id, `Voice profile entityId must be ${entity.id}.`);
|
|
79
|
+
assert(MATURITY.includes(value.maturity), `Voice maturity must be one of: ${MATURITY.join(', ')}.`);
|
|
80
|
+
assertString(value.register, 'Voice register');
|
|
81
|
+
for (const key of ['sources', 'markers', 'weAre', 'weAreNot', 'sentenceStyle', 'preferredVocabulary', 'bannedVocabulary', 'examples', 'appliesTo', 'exceptions']) {
|
|
82
|
+
assert(Array.isArray(value[key]), `Voice ${key} must be an array.`);
|
|
83
|
+
}
|
|
84
|
+
assert(value.markers.length > 0, 'Voice markers must not be empty.');
|
|
85
|
+
assert(value.weAre.length > 0, 'Voice weAre must not be empty.');
|
|
86
|
+
assert(value.weAreNot.length > 0, 'Voice weAreNot must not be empty.');
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function validateEvidenceLedger(value, entity) {
|
|
91
|
+
assert(value && typeof value === 'object', 'Evidence ledger must be an object.');
|
|
92
|
+
assert(value.version === 1, 'Evidence ledger version must be 1.');
|
|
93
|
+
assert(value.entityId === entity.id, `Evidence ledger entityId must be ${entity.id}.`);
|
|
94
|
+
assert(Array.isArray(value.claims), 'Evidence claims must be an array.');
|
|
95
|
+
assert(Array.isArray(value.proofs), 'Evidence proofs must be an array.');
|
|
96
|
+
const proofIds = new Set();
|
|
97
|
+
for (const proof of value.proofs) {
|
|
98
|
+
assertId(proof.id, 'Proof id');
|
|
99
|
+
assert(!proofIds.has(proof.id), `Duplicate proof id: ${proof.id}`);
|
|
100
|
+
proofIds.add(proof.id);
|
|
101
|
+
assertString(proof.title, `Proof ${proof.id} title`);
|
|
102
|
+
assert(PROVENANCE.includes(proof.provenance), `Proof ${proof.id} has invalid provenance.`);
|
|
103
|
+
assert(PROOF_STATUS.includes(proof.status), `Proof ${proof.id} has invalid status.`);
|
|
104
|
+
if (proof.ownership !== undefined) assert(OWNERSHIP.includes(proof.ownership), `Proof ${proof.id} has invalid ownership.`);
|
|
105
|
+
if (proof.status === 'verified') assertString(proof.source, `Verified proof ${proof.id} source`);
|
|
106
|
+
}
|
|
107
|
+
const claimIds = new Set();
|
|
108
|
+
for (const claim of value.claims) {
|
|
109
|
+
assertId(claim.id, 'Claim id');
|
|
110
|
+
assert(!claimIds.has(claim.id), `Duplicate claim id: ${claim.id}`);
|
|
111
|
+
claimIds.add(claim.id);
|
|
112
|
+
assertString(claim.text, `Claim ${claim.id} text`);
|
|
113
|
+
assert(['low', 'medium', 'high'].includes(claim.risk), `Claim ${claim.id} has invalid risk.`);
|
|
114
|
+
assertStringArray(claim.proofIds, `Claim ${claim.id} proofIds`);
|
|
115
|
+
for (const proofId of claim.proofIds) assert(proofIds.has(proofId), `Claim ${claim.id} references unknown proof ${proofId}.`);
|
|
116
|
+
}
|
|
117
|
+
return { ...value, claimIds, proofIds };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function readIntegrity(projectDir) {
|
|
121
|
+
readProject(projectDir);
|
|
122
|
+
const root = path.join(projectDir, '.cosmo');
|
|
123
|
+
const files = {
|
|
124
|
+
capabilities: path.join(root, 'capabilities', 'registry.json'),
|
|
125
|
+
entity: path.join(root, 'brand', 'entity-canon.json'),
|
|
126
|
+
voice: path.join(root, 'brand', 'voice-profile.json'),
|
|
127
|
+
evidence: path.join(root, 'evidence.json'),
|
|
128
|
+
};
|
|
129
|
+
const capabilities = validateCapabilityRegistry(readJson(files.capabilities, 'Capability registry'));
|
|
130
|
+
const entity = validateEntityCanon(readJson(files.entity, 'Entity Canon'));
|
|
131
|
+
const voice = validateVoiceProfile(readJson(files.voice, 'Voice profile'), entity);
|
|
132
|
+
const evidence = validateEvidenceLedger(readJson(files.evidence, 'Evidence ledger'), entity);
|
|
133
|
+
const intelligence = readIntelligence(projectDir);
|
|
134
|
+
if (capabilities.version >= 2) {
|
|
135
|
+
assert(capabilities.profile === intelligence.data.profile, 'Capability profile differs from the intelligence selection.');
|
|
136
|
+
assert(JSON.stringify(capabilities.packs) === JSON.stringify(intelligence.data.packs), 'Capability packs differ from the intelligence selection.');
|
|
137
|
+
for (const manifest of intelligence.manifests) assert(capabilities.capabilities.some((capability) => capability.id === manifest.capability.id && capability.status === 'active'), `Selected intelligence pack ${manifest.id} capability is not active.`);
|
|
138
|
+
}
|
|
139
|
+
return { files, capabilities, entity, voice, evidence, intelligence };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function validatePageBrief(value, page, integrity) {
|
|
143
|
+
assert(value && typeof value === 'object', `Page brief ${page.id} must be an object.`);
|
|
144
|
+
assert(value.version === 1, `Page brief ${page.id} version must be 1.`);
|
|
145
|
+
assert(value.pageId === page.id, `Page brief pageId must be ${page.id}.`);
|
|
146
|
+
const expectedPlanVersion = page.architecture ? 3 : 2;
|
|
147
|
+
assert(value.planVersion === expectedPlanVersion, `Page brief ${page.id} must derive from Plan v${expectedPlanVersion}.`);
|
|
148
|
+
assert(value.route === page.path, `Page brief ${page.id} route does not match the plan.`);
|
|
149
|
+
assert(value.pageType === page.type, `Page brief ${page.id} pageType drifted from the plan.`);
|
|
150
|
+
assert(value.title === page.title, `Page brief ${page.id} title drifted from the plan.`);
|
|
151
|
+
assert(value.primaryTopic === page.primaryTopic, `Page brief ${page.id} primaryTopic drifted from the plan.`);
|
|
152
|
+
assert(value.entityId === page.contract.strengthensEntity, `Page brief ${page.id} entity does not match the plan.`);
|
|
153
|
+
assert(value.entityId === integrity.entity.id, `Page brief ${page.id} must strengthen canonical entity ${integrity.entity.id}.`);
|
|
154
|
+
assertString(value.audienceNeed, `Page brief ${page.id} audienceNeed`);
|
|
155
|
+
assert(['visitor', 'business', 'both'].includes(value.serves), `Page brief ${page.id} has invalid serves value.`);
|
|
156
|
+
assertStringArray(value.claimIds, `Page brief ${page.id} claimIds`, { nonEmpty: true });
|
|
157
|
+
assertStringArray(value.proofIds, `Page brief ${page.id} proofIds`);
|
|
158
|
+
assertStringArray(value.strengthensPages, `Page brief ${page.id} strengthensPages`, { nonEmpty: true });
|
|
159
|
+
assert(JSON.stringify(value.claimIds) === JSON.stringify(page.contract.supportsClaims), `Page brief ${page.id} claimIds drifted from the plan.`);
|
|
160
|
+
assert(JSON.stringify(value.proofIds) === JSON.stringify(page.contract.carriesProof), `Page brief ${page.id} proofIds drifted from the plan.`);
|
|
161
|
+
assert(JSON.stringify(value.strengthensPages) === JSON.stringify(page.contract.strengthensPages), `Page brief ${page.id} strengthensPages drifted from the plan.`);
|
|
162
|
+
assert(value.audienceNeed === page.contract.audienceNeed, `Page brief ${page.id} audienceNeed drifted from the plan.`);
|
|
163
|
+
assert(value.serves === page.contract.serves, `Page brief ${page.id} serves value drifted from the plan.`);
|
|
164
|
+
if (expectedPlanVersion >= 3) {
|
|
165
|
+
assert(value.archetype === page.architecture.archetype, `Page brief ${page.id} archetype drifted from the plan.`);
|
|
166
|
+
assert(value.indexability === page.architecture.indexability, `Page brief ${page.id} indexability drifted from the plan.`);
|
|
167
|
+
assert(JSON.stringify(value.intent) === JSON.stringify(page.architecture.intent), `Page brief ${page.id} intent drifted from the plan.`);
|
|
168
|
+
assert(JSON.stringify(value.intentBoundaries) === JSON.stringify(page.architecture.intentBoundaries), `Page brief ${page.id} intent boundaries drifted from the plan.`);
|
|
169
|
+
assert(JSON.stringify(value.linkRoles) === JSON.stringify(page.links), `Page brief ${page.id} governed links drifted from the plan.`);
|
|
170
|
+
}
|
|
171
|
+
for (const claimId of value.claimIds) {
|
|
172
|
+
assert(integrity.evidence.claimIds.has(claimId), `Page brief ${page.id} references unknown claim ${claimId}.`);
|
|
173
|
+
const claim = integrity.evidence.claims.find((item) => item.id === claimId);
|
|
174
|
+
assert(claim.proofIds.some((proofId) => value.proofIds.includes(proofId)), `Page brief ${page.id} carries no proof that supports claim ${claimId}.`);
|
|
175
|
+
}
|
|
176
|
+
for (const proofId of value.proofIds) assert(integrity.evidence.proofIds.has(proofId), `Page brief ${page.id} references unknown proof ${proofId}.`);
|
|
177
|
+
for (const proofId of value.proofIds) {
|
|
178
|
+
assert(integrity.evidence.claims.some((claim) => value.claimIds.includes(claim.id) && claim.proofIds.includes(proofId)), `Page brief ${page.id} carries proof ${proofId} without a supported claim.`);
|
|
179
|
+
}
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function createPageBrief(projectDir, pageId, { replace = false } = {}) {
|
|
184
|
+
const plan = readPlan(projectDir, { requireApproved: false }).data;
|
|
185
|
+
assert(plan.version >= 2, 'Page briefs require Build Plan v2 or newer.');
|
|
186
|
+
const integrity = readIntegrity(projectDir);
|
|
187
|
+
const page = plan.pages.find((candidate) => candidate.id === pageId);
|
|
188
|
+
assert(page, `Unknown planned page: ${pageId}`);
|
|
189
|
+
const file = path.join(projectDir, '.cosmo', 'work', 'pages', page.id, 'brief.json');
|
|
190
|
+
assert(replace || !fs.existsSync(file), `Page brief already exists: ${file}. Pass --replace to overwrite it.`);
|
|
191
|
+
const brief = {
|
|
192
|
+
version: 1,
|
|
193
|
+
planVersion: plan.version,
|
|
194
|
+
pageId: page.id,
|
|
195
|
+
route: page.path,
|
|
196
|
+
pageType: page.type,
|
|
197
|
+
title: page.title,
|
|
198
|
+
primaryTopic: page.primaryTopic,
|
|
199
|
+
entityId: page.contract.strengthensEntity,
|
|
200
|
+
audienceNeed: page.contract.audienceNeed,
|
|
201
|
+
serves: page.contract.serves,
|
|
202
|
+
claimIds: page.contract.supportsClaims,
|
|
203
|
+
proofIds: page.contract.carriesProof,
|
|
204
|
+
strengthensPages: page.contract.strengthensPages,
|
|
205
|
+
parent: pageParentId(plan, page),
|
|
206
|
+
related: pageRelatedIds(plan, page),
|
|
207
|
+
...(plan.version >= 3 ? {
|
|
208
|
+
archetype: page.architecture.archetype,
|
|
209
|
+
indexability: page.architecture.indexability,
|
|
210
|
+
intent: page.architecture.intent,
|
|
211
|
+
intentBoundaries: page.architecture.intentBoundaries,
|
|
212
|
+
linkRoles: page.links,
|
|
213
|
+
} : {}),
|
|
214
|
+
answerFirstTarget: page.contract.answerFirstTarget ?? '',
|
|
215
|
+
callsToAction: page.contract.callsToAction ?? [],
|
|
216
|
+
sections: [],
|
|
217
|
+
createdAt: new Date().toISOString(),
|
|
218
|
+
};
|
|
219
|
+
validatePageBrief(brief, page, integrity);
|
|
220
|
+
writeJson(file, brief);
|
|
221
|
+
return { file, data: brief };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function checkIntegrity(projectDir, { requireBriefs = true } = {}) {
|
|
225
|
+
const integrity = readIntegrity(projectDir);
|
|
226
|
+
const plan = readPlan(projectDir, { requireApproved: false }).data;
|
|
227
|
+
const warnings = [];
|
|
228
|
+
const briefs = [];
|
|
229
|
+
if (plan.version === 1) {
|
|
230
|
+
warnings.push('Build Plan v1 is compatible but does not enforce page-purpose contracts. Upgrade to v2.');
|
|
231
|
+
} else {
|
|
232
|
+
for (const page of plan.pages) {
|
|
233
|
+
const file = path.join(projectDir, '.cosmo', 'work', 'pages', page.id, 'brief.json');
|
|
234
|
+
if (!fs.existsSync(file)) {
|
|
235
|
+
if (requireBriefs) throw new IntegrityError(`Page brief not found: ${file}`);
|
|
236
|
+
warnings.push(`Page brief missing for ${page.id}.`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
validatePageBrief(readJson(file, `Page brief ${page.id}`), page, integrity);
|
|
240
|
+
briefs.push(file);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
passed: true,
|
|
245
|
+
checkedAt: new Date().toISOString(),
|
|
246
|
+
summary: {
|
|
247
|
+
capabilities: integrity.capabilities.capabilities.length,
|
|
248
|
+
intelligencePacks: integrity.intelligence.data.packs.length,
|
|
249
|
+
claims: integrity.evidence.claims.length,
|
|
250
|
+
proofs: integrity.evidence.proofs.length,
|
|
251
|
+
briefs: briefs.length,
|
|
252
|
+
warnings: warnings.length,
|
|
253
|
+
},
|
|
254
|
+
warnings,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function scaffoldIntegrity(projectDir, { replace = false } = {}) {
|
|
259
|
+
const project = readProject(projectDir).data;
|
|
260
|
+
const entityId = slugify(project.brand ?? project.name);
|
|
261
|
+
const definitions = [
|
|
262
|
+
['capabilities/registry.json', {
|
|
263
|
+
version: 2,
|
|
264
|
+
profile: 'lean',
|
|
265
|
+
packs: [],
|
|
266
|
+
capabilities: [
|
|
267
|
+
{ id: 'entity-canon', version: 1, status: 'active', stages: ['brand', 'plan', 'generate', 'qa'] },
|
|
268
|
+
{ id: 'page-purpose-contract', version: 1, status: 'active', stages: ['homepage', 'plan', 'generate'] },
|
|
269
|
+
{ id: 'audience-integrity', version: 1, status: 'active', stages: ['plan', 'generate', 'qa'] },
|
|
270
|
+
{ id: 'evidence-ledger', version: 1, status: 'active', stages: ['intake', 'brand', 'plan', 'generate', 'qa'] },
|
|
271
|
+
{ id: 'page-brief', version: 1, status: 'active', stages: ['homepage', 'generate'] },
|
|
272
|
+
{ id: 'voice-profile', version: 1, status: 'active', stages: ['brand', 'generate', 'qa'] },
|
|
273
|
+
{ id: 'page-archetypes', version: 1, status: 'active', stages: ['plan', 'generate', 'qa'] },
|
|
274
|
+
{ id: 'intent-governance', version: 1, status: 'active', stages: ['plan', 'generate', 'qa'] },
|
|
275
|
+
{ id: 'governed-links', version: 1, status: 'active', stages: ['plan', 'generate', 'qa'] },
|
|
276
|
+
{ id: 'indexability', version: 1, status: 'active', stages: ['plan', 'generate', 'qa'] },
|
|
277
|
+
{ id: 'page-production-pipeline', version: 1, status: 'active', stages: ['generate', 'qa'] },
|
|
278
|
+
{ id: 'bounded-repair', version: 1, status: 'active', stages: ['generate', 'qa'] },
|
|
279
|
+
{ id: 'semantic-content-qa', version: 1, status: 'active', stages: ['qa'] },
|
|
280
|
+
{ id: 'noncommodity-gate', version: 1, status: 'active', stages: ['generate', 'qa'] },
|
|
281
|
+
],
|
|
282
|
+
}],
|
|
283
|
+
['intelligence/selection.json', { version: 1, profile: 'lean', packs: [] }],
|
|
284
|
+
['brand/entity-canon.json', {
|
|
285
|
+
version: 1,
|
|
286
|
+
id: entityId,
|
|
287
|
+
officialName: project.brand ?? project.name,
|
|
288
|
+
aliases: [],
|
|
289
|
+
domain: project.site ?? 'https://example.com',
|
|
290
|
+
descriptions: { short: 'Complete this canonical brand description.', long: 'Complete this longer canonical entity description before brand approval.' },
|
|
291
|
+
category: 'Complete this category',
|
|
292
|
+
services: [], audiences: [], locations: [], people: [], credentials: [], profiles: [], claims: [], proofVocabulary: [],
|
|
293
|
+
}],
|
|
294
|
+
['brand/voice-profile.json', {
|
|
295
|
+
version: 1,
|
|
296
|
+
entityId,
|
|
297
|
+
maturity: 'synthesized',
|
|
298
|
+
sources: [],
|
|
299
|
+
markers: ['clear', 'specific'],
|
|
300
|
+
weAre: ['evidence-aware'],
|
|
301
|
+
weAreNot: ['generic', 'overstated'],
|
|
302
|
+
register: 'Direct, informed, and human.',
|
|
303
|
+
sentenceStyle: [], preferredVocabulary: [], bannedVocabulary: [], examples: [], appliesTo: ['website'], exceptions: [],
|
|
304
|
+
}],
|
|
305
|
+
['evidence.json', { version: 1, entityId, claims: [], proofs: [] }],
|
|
306
|
+
];
|
|
307
|
+
const files = [];
|
|
308
|
+
for (const [relative, value] of definitions) {
|
|
309
|
+
const file = path.join(projectDir, '.cosmo', relative);
|
|
310
|
+
if (fs.existsSync(file) && !replace) continue;
|
|
311
|
+
writeJson(file, value);
|
|
312
|
+
files.push(file);
|
|
313
|
+
}
|
|
314
|
+
return files;
|
|
315
|
+
}
|