@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +792 -0
  3. package/SECURITY.md +15 -0
  4. package/docs/AGENT-HANDOFF.md +44 -0
  5. package/docs/ARCHITECTURE-INTELLIGENCE.md +64 -0
  6. package/docs/ARCHITECTURE.md +97 -0
  7. package/docs/BRAND-DISCOVERY.md +12 -0
  8. package/docs/BROWSER-QA.md +40 -0
  9. package/docs/CLAUDE-LAUNCHER.md +72 -0
  10. package/docs/CONTENT-QA.md +62 -0
  11. package/docs/DELIVERY.md +40 -0
  12. package/docs/DEPLOYMENT.md +119 -0
  13. package/docs/FIRST-PARTY-CAPABILITIES.md +54 -0
  14. package/docs/GENERATION.md +81 -0
  15. package/docs/INTEGRITY.md +75 -0
  16. package/docs/INTELLIGENCE-PACKS.md +122 -0
  17. package/docs/OPERATIONS.md +7 -0
  18. package/docs/PAGE-PRODUCTION.md +81 -0
  19. package/docs/ROADMAP.md +184 -0
  20. package/docs/WORKFLOWS.md +71 -0
  21. package/package.json +97 -0
  22. package/packages/cli/bin/cosmo.mjs +901 -0
  23. package/packages/cli/lib/adoption.mjs +72 -0
  24. package/packages/cli/lib/audit.mjs +145 -0
  25. package/packages/cli/lib/brand.mjs +60 -0
  26. package/packages/cli/lib/browser-audit.mjs +177 -0
  27. package/packages/cli/lib/claude-plugin.mjs +64 -0
  28. package/packages/cli/lib/content-audit.mjs +184 -0
  29. package/packages/cli/lib/delivery.mjs +140 -0
  30. package/packages/cli/lib/deployment.mjs +211 -0
  31. package/packages/cli/lib/doctor.mjs +42 -0
  32. package/packages/cli/lib/file-transfer.mjs +143 -0
  33. package/packages/cli/lib/generation.mjs +319 -0
  34. package/packages/cli/lib/handoff.mjs +109 -0
  35. package/packages/cli/lib/integrity.mjs +315 -0
  36. package/packages/cli/lib/intelligence-audit.mjs +445 -0
  37. package/packages/cli/lib/intelligence.mjs +331 -0
  38. package/packages/cli/lib/page-work.mjs +154 -0
  39. package/packages/cli/lib/plan.mjs +229 -0
  40. package/packages/cli/lib/process.mjs +45 -0
  41. package/packages/cli/lib/project.mjs +113 -0
  42. package/packages/cli/lib/research.mjs +85 -0
  43. package/packages/cli/lib/status.mjs +46 -0
  44. package/packages/cli/lib/workflow.mjs +294 -0
  45. package/plugins/claude-code/cosmo/.claude-plugin/plugin.json +10 -0
  46. package/plugins/claude-code/cosmo/README.md +25 -0
  47. package/plugins/claude-code/cosmo/bin/cosmo +11 -0
  48. package/plugins/claude-code/cosmo/skills/cosmo/SKILL.md +122 -0
  49. package/plugins/claude-code/cosmo/skills/cosmo-help/SKILL.md +16 -0
  50. package/scripts/postinstall.mjs +14 -0
  51. package/templates/astro-site/.cosmo/brand/discovery.json +19 -0
  52. package/templates/astro-site/.cosmo/brand/entity-canon.json +20 -0
  53. package/templates/astro-site/.cosmo/brand/voice-profile.json +16 -0
  54. package/templates/astro-site/.cosmo/build-plan.json +75 -0
  55. package/templates/astro-site/.cosmo/capabilities/registry.json +21 -0
  56. package/templates/astro-site/.cosmo/evidence.json +11 -0
  57. package/templates/astro-site/.cosmo/intelligence/selection.json +5 -0
  58. package/templates/astro-site/.cosmo/policies/content-integrity.json +22 -0
  59. package/templates/astro-site/.cosmo/project.json +10 -0
  60. package/templates/astro-site/.cosmo/work/pages/about/brief.json +49 -0
  61. package/templates/astro-site/.cosmo/work/pages/home/brief.json +51 -0
  62. package/templates/astro-site/.cosmo/workflows/default.json +146 -0
  63. package/templates/astro-site/.env.example +7 -0
  64. package/templates/astro-site/AGENTS.md +26 -0
  65. package/templates/astro-site/CLAUDE.md +28 -0
  66. package/templates/astro-site/DESIGN-DIRECTION.md +9 -0
  67. package/templates/astro-site/README.md +17 -0
  68. package/templates/astro-site/astro.config.mjs +16 -0
  69. package/templates/astro-site/cosmo.config.mjs +12 -0
  70. package/templates/astro-site/gitignore.template +9 -0
  71. package/templates/astro-site/package.json +23 -0
  72. package/templates/astro-site/public/favicon.svg +5 -0
  73. package/templates/astro-site/src/components/PageView.astro +20 -0
  74. package/templates/astro-site/src/components/sections/Action.astro +24 -0
  75. package/templates/astro-site/src/components/sections/Evidence.astro +19 -0
  76. package/templates/astro-site/src/components/sections/Hero.astro +41 -0
  77. package/templates/astro-site/src/components/sections/Problem.astro +19 -0
  78. package/templates/astro-site/src/components/sections/Proof.astro +15 -0
  79. package/templates/astro-site/src/components/sections/SectionRenderer.astro +22 -0
  80. package/templates/astro-site/src/components/sections/Solution.astro +19 -0
  81. package/templates/astro-site/src/components/seo/SeoHead.astro +41 -0
  82. package/templates/astro-site/src/content/pages/about.md +52 -0
  83. package/templates/astro-site/src/content/pages/home.md +48 -0
  84. package/templates/astro-site/src/content.config.ts +133 -0
  85. package/templates/astro-site/src/env.d.ts +1 -0
  86. package/templates/astro-site/src/layouts/BaseLayout.astro +57 -0
  87. package/templates/astro-site/src/pages/[...slug].astro +22 -0
  88. package/templates/astro-site/src/pages/index.astro +9 -0
  89. package/templates/astro-site/src/pages/robots.txt.ts +6 -0
  90. package/templates/astro-site/src/styles/global.css +540 -0
  91. package/templates/astro-site/src/styles/tokens.css +27 -0
  92. package/templates/astro-site/tsconfig.json +9 -0
@@ -0,0 +1,294 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { evaluateIntelligence, writeIntelligenceReport } from './intelligence-audit.mjs';
4
+ import { checkIntelligenceStage } from './intelligence.mjs';
5
+ import { checkBrandDiscovery } from './brand.mjs';
6
+ import { checkIntegrity } from './integrity.mjs';
7
+ import { readPlan } from './plan.mjs';
8
+ import { readProject, slugify, writeJson } from './project.mjs';
9
+
10
+ export const CORE_STAGE_IDS = ['intake', 'brand', 'design', 'homepage', 'template', 'plan', 'generate', 'qa'];
11
+ const STAGE_STATUSES = ['pending', 'in_progress', 'awaiting_approval', 'completed'];
12
+
13
+ export class WorkflowError extends Error {}
14
+
15
+ function assert(condition, message) {
16
+ if (!condition) throw new WorkflowError(message);
17
+ }
18
+
19
+ function safeArtifactPath(projectDir, artifact) {
20
+ assert(typeof artifact === 'string' && artifact.length > 0, 'Artifact paths must be non-empty strings.');
21
+ assert(!path.isAbsolute(artifact), `Artifact path must be relative: ${artifact}`);
22
+ const resolved = path.resolve(projectDir, artifact);
23
+ const root = `${path.resolve(projectDir)}${path.sep}`;
24
+ assert(resolved.startsWith(root), `Artifact path escapes the project: ${artifact}`);
25
+ return resolved;
26
+ }
27
+
28
+ function expectationPath(expectation) {
29
+ return typeof expectation === 'string' ? expectation : expectation?.path;
30
+ }
31
+
32
+ function validateExpectationShape(stageId, expectation) {
33
+ if (typeof expectation === 'string') {
34
+ assert(expectation.length > 0, `Stage ${stageId} has an invalid artifact path.`);
35
+ assert(!path.isAbsolute(expectation) && !expectation.split(/[\\/]/).includes('..'), `Stage ${stageId} has an unsafe artifact path: ${expectation}`);
36
+ return;
37
+ }
38
+ assert(expectation && typeof expectation === 'object', `Stage ${stageId} has an invalid artifact expectation.`);
39
+ assert(typeof expectation.path === 'string' && expectation.path.length > 0, `Stage ${stageId} has an invalid artifact path.`);
40
+ assert(!path.isAbsolute(expectation.path) && !expectation.path.split(/[\\/]/).includes('..'), `Stage ${stageId} has an unsafe artifact path: ${expectation.path}`);
41
+ assert(['file', 'json'].includes(expectation.kind), `Stage ${stageId} artifact ${expectation.path} must have kind file or json.`);
42
+ if (expectation.requiredKeys !== undefined) {
43
+ assert(Array.isArray(expectation.requiredKeys) && expectation.requiredKeys.every((key) => typeof key === 'string'), `Stage ${stageId} artifact ${expectation.path} has invalid requiredKeys.`);
44
+ }
45
+ if (expectation.nonEmptyKeys !== undefined) {
46
+ assert(Array.isArray(expectation.nonEmptyKeys) && expectation.nonEmptyKeys.every((key) => typeof key === 'string'), `Stage ${stageId} artifact ${expectation.path} has invalid nonEmptyKeys.`);
47
+ }
48
+ if (expectation.equals !== undefined) {
49
+ assert(expectation.equals && typeof expectation.equals === 'object' && !Array.isArray(expectation.equals), `Stage ${stageId} artifact ${expectation.path} has invalid equals constraints.`);
50
+ }
51
+ }
52
+
53
+ function valueAtPath(value, keyPath) {
54
+ return keyPath.split('.').reduce((current, key) => current?.[key], value);
55
+ }
56
+
57
+ function checkArtifact(projectDir, expectation) {
58
+ const contract = typeof expectation === 'string' ? { path: expectation, kind: 'file' } : expectation;
59
+ const file = safeArtifactPath(projectDir, contract.path);
60
+ if (!fs.existsSync(file)) return `missing ${contract.path}`;
61
+ if (!fs.statSync(file).isFile()) return `not a file ${contract.path}`;
62
+ if (fs.statSync(file).size === 0) return `empty ${contract.path}`;
63
+ if (contract.kind !== 'json') return null;
64
+ let data;
65
+ try {
66
+ data = JSON.parse(fs.readFileSync(file, 'utf8'));
67
+ } catch {
68
+ return `invalid JSON ${contract.path}`;
69
+ }
70
+ for (const key of contract.requiredKeys ?? []) {
71
+ if (valueAtPath(data, key) === undefined) return `${contract.path} missing key ${key}`;
72
+ }
73
+ for (const key of contract.nonEmptyKeys ?? []) {
74
+ const value = valueAtPath(data, key);
75
+ const nonEmpty = typeof value === 'string'
76
+ ? value.trim().length > 0
77
+ : Array.isArray(value)
78
+ ? value.length > 0
79
+ : value && typeof value === 'object'
80
+ ? Object.keys(value).length > 0
81
+ : value !== undefined && value !== null;
82
+ if (!nonEmpty) return `${contract.path} requires a non-empty ${key}`;
83
+ }
84
+ for (const [key, expected] of Object.entries(contract.equals ?? {})) {
85
+ if (valueAtPath(data, key) !== expected) return `${contract.path} requires ${key}=${JSON.stringify(expected)}`;
86
+ }
87
+ return null;
88
+ }
89
+
90
+ export function validateWorkflow(value) {
91
+ assert(value && typeof value === 'object', 'Workflow must be a JSON object.');
92
+ assert(value.version === 1, 'Workflow version must be 1.');
93
+ assert(typeof value.id === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(value.id), 'Workflow id must be kebab-case.');
94
+ assert(typeof value.name === 'string' && value.name.trim(), 'Workflow name is required.');
95
+ assert(Array.isArray(value.stages) && value.stages.length > 0, 'Workflow must contain stages.');
96
+
97
+ const ids = new Set();
98
+ for (const stage of value.stages) {
99
+ assert(stage && typeof stage === 'object', 'Each workflow stage must be an object.');
100
+ assert(typeof stage.id === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(stage.id), 'Stage ids must be kebab-case.');
101
+ assert(!ids.has(stage.id), `Duplicate workflow stage: ${stage.id}`);
102
+ ids.add(stage.id);
103
+ assert(typeof stage.title === 'string' && stage.title.trim(), `Stage ${stage.id} needs a title.`);
104
+ assert(typeof stage.instructions === 'string' && stage.instructions.trim(), `Stage ${stage.id} needs instructions.`);
105
+ assert(['core', 'custom'].includes(stage.type), `Stage ${stage.id} must have type core or custom.`);
106
+ assert(typeof stage.approval === 'boolean', `Stage ${stage.id} must declare approval true or false.`);
107
+ assert(Array.isArray(stage.expects), `Stage ${stage.id} must declare an expects array.`);
108
+ for (const artifact of stage.expects) {
109
+ validateExpectationShape(stage.id, artifact);
110
+ }
111
+ }
112
+
113
+ const coreOrder = value.stages.filter((stage) => stage.type === 'core').map((stage) => stage.id);
114
+ assert(JSON.stringify(coreOrder) === JSON.stringify(CORE_STAGE_IDS), `Core stages must appear exactly once in this order: ${CORE_STAGE_IDS.join(', ')}`);
115
+ return value;
116
+ }
117
+
118
+ export function workflowsDirectory(projectDir) {
119
+ return path.join(projectDir, '.cosmo', 'workflows');
120
+ }
121
+
122
+ export function listWorkflows(projectDir) {
123
+ const directory = workflowsDirectory(projectDir);
124
+ if (!fs.existsSync(directory)) return [];
125
+ return fs.readdirSync(directory)
126
+ .filter((entry) => entry.endsWith('.json'))
127
+ .map((entry) => {
128
+ const file = path.join(directory, entry);
129
+ try {
130
+ const workflow = validateWorkflow(JSON.parse(fs.readFileSync(file, 'utf8')));
131
+ return { id: workflow.id, name: workflow.name, file, stages: workflow.stages.length, valid: true };
132
+ } catch (error) {
133
+ return { id: entry.replace(/\.json$/, ''), name: entry, file, valid: false, error: error.message };
134
+ }
135
+ })
136
+ .sort((a, b) => a.id.localeCompare(b.id));
137
+ }
138
+
139
+ export function loadWorkflow(projectDir, id = 'default') {
140
+ const file = path.join(workflowsDirectory(projectDir), `${slugify(id)}.json`);
141
+ assert(fs.existsSync(file), `Workflow not found: ${id}`);
142
+ return { file, data: validateWorkflow(JSON.parse(fs.readFileSync(file, 'utf8'))) };
143
+ }
144
+
145
+ export function importWorkflow(projectDir, sourceFile) {
146
+ readProject(projectDir);
147
+ const source = path.resolve(sourceFile);
148
+ assert(fs.existsSync(source) && fs.statSync(source).isFile(), `Workflow file not found: ${source}`);
149
+ const workflow = validateWorkflow(JSON.parse(fs.readFileSync(source, 'utf8')));
150
+ const destination = path.join(workflowsDirectory(projectDir), `${workflow.id}.json`);
151
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
152
+ writeJson(destination, workflow);
153
+ return { workflow, destination };
154
+ }
155
+
156
+ function stateFile(projectDir) {
157
+ return path.join(projectDir, '.cosmo', 'workflow-state.json');
158
+ }
159
+
160
+ function activityFile(projectDir) {
161
+ return path.join(projectDir, '.cosmo', 'activity.jsonl');
162
+ }
163
+
164
+ function appendActivity(projectDir, event) {
165
+ const file = activityFile(projectDir);
166
+ fs.mkdirSync(path.dirname(file), { recursive: true });
167
+ fs.appendFileSync(file, `${JSON.stringify({ at: new Date().toISOString(), ...event })}\n`);
168
+ }
169
+
170
+ function saveState(projectDir, state, event) {
171
+ state.updatedAt = new Date().toISOString();
172
+ writeJson(stateFile(projectDir), state);
173
+ const project = readProject(projectDir);
174
+ writeJson(project.file, {
175
+ ...project.data,
176
+ stage: state.status === 'complete' ? 'complete' : state.currentStage,
177
+ workflow: state.workflowId,
178
+ lastActivity: state.updatedAt,
179
+ });
180
+ if (event) appendActivity(projectDir, event);
181
+ return state;
182
+ }
183
+
184
+ export function readWorkflowState(projectDir, { required = true } = {}) {
185
+ const file = stateFile(projectDir);
186
+ if (!fs.existsSync(file)) {
187
+ if (required) throw new WorkflowError('No active workflow. Run cosmo workflow start first.');
188
+ return null;
189
+ }
190
+ const state = JSON.parse(fs.readFileSync(file, 'utf8'));
191
+ assert(state.version === 1, 'Workflow state version is unsupported.');
192
+ assert(['active', 'complete'].includes(state.status), 'Workflow state has an invalid status.');
193
+ return { file, data: state };
194
+ }
195
+
196
+ export function startWorkflow(projectDir, workflowId = 'default') {
197
+ readProject(projectDir);
198
+ const existing = readWorkflowState(projectDir, { required: false });
199
+ assert(!existing || existing.data.status === 'complete', `Workflow ${existing?.data.workflowId} is already active at ${existing?.data.currentStage}.`);
200
+ const { data: workflow } = loadWorkflow(projectDir, workflowId);
201
+ const now = new Date().toISOString();
202
+ const stages = Object.fromEntries(workflow.stages.map((stage, index) => [stage.id, {
203
+ status: index === 0 ? 'in_progress' : 'pending',
204
+ submittedAt: null,
205
+ approvedAt: null,
206
+ }]));
207
+ const state = {
208
+ version: 1,
209
+ workflowId: workflow.id,
210
+ workflowName: workflow.name,
211
+ status: 'active',
212
+ currentStage: workflow.stages[0].id,
213
+ startedAt: now,
214
+ updatedAt: now,
215
+ stages,
216
+ };
217
+ return saveState(projectDir, state, { event: 'workflow.started', workflowId: workflow.id, stage: state.currentStage });
218
+ }
219
+
220
+ function advance(projectDir, workflow, state, event) {
221
+ const currentIndex = workflow.stages.findIndex((stage) => stage.id === state.currentStage);
222
+ const next = workflow.stages[currentIndex + 1];
223
+ if (!next) {
224
+ state.currentStage = null;
225
+ state.status = 'complete';
226
+ return saveState(projectDir, state, { ...event, workflowComplete: true });
227
+ }
228
+ state.currentStage = next.id;
229
+ state.stages[next.id].status = 'in_progress';
230
+ return saveState(projectDir, state, { ...event, nextStage: next.id });
231
+ }
232
+
233
+ export function submitStage(projectDir, stageId) {
234
+ const stateRecord = readWorkflowState(projectDir);
235
+ const state = stateRecord.data;
236
+ assert(state.status === 'active', 'Workflow is already complete.');
237
+ assert(stageId === state.currentStage, `Current stage is ${state.currentStage}, not ${stageId}.`);
238
+ const { data: workflow } = loadWorkflow(projectDir, state.workflowId);
239
+ const stage = workflow.stages.find((item) => item.id === stageId);
240
+ const failures = stage.expects.map((artifact) => checkArtifact(projectDir, artifact)).filter(Boolean);
241
+ assert(failures.length === 0, `Stage ${stageId} failed its artifact contract:\n${failures.map((item) => `- ${item}`).join('\n')}`);
242
+ if (stage.expects.some((artifact) => expectationPath(artifact) === '.cosmo/brand/discovery.json')) {
243
+ try { checkBrandDiscovery(projectDir); } catch (error) { throw new WorkflowError(error.message); }
244
+ }
245
+ try {
246
+ checkIntelligenceStage(projectDir, stageId);
247
+ } catch (error) {
248
+ throw new WorkflowError(error.message);
249
+ }
250
+ if (stageId === 'plan') {
251
+ readPlan(projectDir);
252
+ checkIntegrity(projectDir);
253
+ }
254
+ if (stageId === 'qa') {
255
+ const intelligenceReport = evaluateIntelligence(projectDir);
256
+ writeIntelligenceReport(projectDir, intelligenceReport);
257
+ assert(intelligenceReport.passed, `Stage qa failed intelligence evaluation:\n${intelligenceReport.packs.flatMap((pack) => pack.findings.filter((finding) => finding.severity === 'blocking').map((finding) => `- ${pack.id}: ${finding.message}`)).join('\n')}`);
258
+ }
259
+ state.stages[stageId].submittedAt = new Date().toISOString();
260
+ if (stage.approval) {
261
+ state.stages[stageId].status = 'awaiting_approval';
262
+ return saveState(projectDir, state, { event: 'stage.submitted', stage: stageId, artifacts: stage.expects.map(expectationPath) });
263
+ }
264
+ state.stages[stageId].status = 'completed';
265
+ return advance(projectDir, workflow, state, { event: 'stage.completed', stage: stageId, artifacts: stage.expects.map(expectationPath) });
266
+ }
267
+
268
+ export function approveStage(projectDir, stageId, approver = 'operator') {
269
+ const state = readWorkflowState(projectDir).data;
270
+ assert(state.status === 'active', 'Workflow is already complete.');
271
+ assert(stageId === state.currentStage, `Current stage is ${state.currentStage}, not ${stageId}.`);
272
+ assert(state.stages[stageId].status === 'awaiting_approval', `Stage ${stageId} is not awaiting approval.`);
273
+ const { data: workflow } = loadWorkflow(projectDir, state.workflowId);
274
+ state.stages[stageId].status = 'completed';
275
+ state.stages[stageId].approvedAt = new Date().toISOString();
276
+ state.stages[stageId].approvedBy = approver;
277
+ return advance(projectDir, workflow, state, { event: 'stage.approved', stage: stageId, approver });
278
+ }
279
+
280
+ export function workflowSummary(projectDir) {
281
+ const state = readWorkflowState(projectDir).data;
282
+ const workflow = loadWorkflow(projectDir, state.workflowId).data;
283
+ const current = workflow.stages.find((stage) => stage.id === state.currentStage) ?? null;
284
+ return {
285
+ state,
286
+ workflow,
287
+ current,
288
+ position: current ? workflow.stages.findIndex((stage) => stage.id === current.id) + 1 : workflow.stages.length,
289
+ };
290
+ }
291
+
292
+ export function assertKnownStageStatus(status) {
293
+ assert(STAGE_STATUSES.includes(status), `Unknown stage status: ${status}`);
294
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "cosmo",
3
+ "version": "1.1.0",
4
+ "description": "Conversational launcher for starting, adopting, and resuming local-first Cosmo Astro website builds.",
5
+ "author": {
6
+ "name": "Cosmo"
7
+ },
8
+ "license": "UNLICENSED",
9
+ "keywords": ["astro", "website-builder", "claude", "cosmo"]
10
+ }
@@ -0,0 +1,25 @@
1
+ # Cosmo for Claude Code
2
+
3
+ This plugin makes `cosmo` a natural-language launcher inside Claude Code. Claude automatically invokes the skill when the user types `cosmo`; `/cosmo:cosmo` is the explicit fallback.
4
+
5
+ Install Cosmo and this launcher together:
6
+
7
+ ```bash
8
+ npm install --global @archangel70/cosmo
9
+ ```
10
+
11
+ Use `cosmo setup` if the automatic launcher installation needs to be repaired.
12
+
13
+ Restart Claude Code, open an empty directory, existing Cosmo project, or existing Astro site, and type:
14
+
15
+ ```text
16
+ cosmo
17
+ ```
18
+
19
+ For development, load it directly:
20
+
21
+ ```bash
22
+ claude --plugin-dir ./plugins/claude-code/cosmo
23
+ ```
24
+
25
+ The launcher is local-only. It stores build state in the project and does not require a Cosmo account, Lyra, Sonic, or a hosted service.
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+ plugin_bin_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
3
+ repository_cli="$plugin_bin_dir/../../../../packages/cli/bin/cosmo.mjs"
4
+ if [ -f "$repository_cli" ]; then
5
+ exec node "$repository_cli" "$@"
6
+ fi
7
+ if [ -n "${COSMO_CLI_PATH:-}" ] && [ -f "$COSMO_CLI_PATH" ]; then
8
+ exec node "$COSMO_CLI_PATH" "$@"
9
+ fi
10
+ echo "Cosmo CLI runtime was not found. Repair it with: cosmo setup" >&2
11
+ exit 1
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: cosmo
3
+ description: Start or resume a Cosmo Astro website build. Invoke whenever the user says "cosmo" by itself, asks Cosmo to build a site, wants to continue a Cosmo project, or wants to bring an existing Astro site under Cosmo management.
4
+ argument-hint: [new|resume|adopt|status|help]
5
+ ---
6
+
7
+ # Cosmo conversational launcher
8
+
9
+ You are the conversational front door to Cosmo. Turn a short request such as `cosmo` into the correct repository-owned workflow. Do not require the user to know CLI commands.
10
+
11
+ ## Non-negotiable operating rules
12
+
13
+ - The repository is the source of truth; never rely on prior chat state when local state exists.
14
+ - Never overwrite a non-empty directory with `cosmo init`.
15
+ - Never invent brand facts, evidence, service coverage, audience observations, credentials, testimonials, results, research, or approval.
16
+ - Never mark an artifact approved on the user's behalf. Present approval-stage work and wait for explicit approval.
17
+ - Never bypass a failed gate by weakening the policy or editing runtime state directly.
18
+ - Use Claude Design as independent creative authority when selected; the starter is not a house style.
19
+ - Keep credentials in environment variables or an ignored runtime env file.
20
+ - Explain the next decision in plain language; do not dump the whole internal pipeline on a new user.
21
+
22
+ ## Step 1: verify the local launcher
23
+
24
+ Run:
25
+
26
+ ```bash
27
+ cosmo --version
28
+ ```
29
+
30
+ If unavailable, explain that the Cosmo Claude plugin is active but its bundled CLI shim is not. Ask the user to repair it with `cosmo setup`. Do not improvise project files by hand.
31
+
32
+ ## Step 2: classify the current directory
33
+
34
+ Inspect, without mutating:
35
+
36
+ 1. `.cosmo/project.json` exists → **existing Cosmo project**.
37
+ 2. No Cosmo project, but `package.json` declares Astro or `astro.config.*` exists → **existing Astro site**.
38
+ 3. Directory is empty (ignoring `.git`) → **new site here**.
39
+ 4. Non-empty and neither Cosmo nor Astro → **new site needs a child directory**; ask for its name/path.
40
+
41
+ If `$ARGUMENTS` clearly requests `new`, `resume`, `adopt`, `status`, or `help`, honor it when safe. Never treat `new` as permission to overwrite.
42
+
43
+ ## Existing Cosmo project
44
+
45
+ Immediately run:
46
+
47
+ ```bash
48
+ cosmo doctor .
49
+ cosmo status . --json
50
+ ```
51
+
52
+ Then read, when present: `HANDOFF.md`, `.cosmo/project.json`, `.cosmo/workflow-state.json`, `.cosmo/intelligence/selection.json`, current selected pack manifests/artifacts, `.cosmo/brand/discovery.json`, `BRAND-BRIEF.md`, `DESIGN-DIRECTION.md`, `.cosmo/build-plan.json`, and the current page workspace.
53
+
54
+ - If the user requested only status, summarize the current stage, blockers, and exact next action.
55
+ - If no workflow exists, offer to start the default workflow, then run `cosmo workflow start .` after confirmation.
56
+ - If a workflow is active, run `cosmo workflow resume .` and `cosmo intelligence guide <current-stage> .`; continue the current stage.
57
+ - If workflow is complete, inspect release and deployment status and ask what work they want performed.
58
+ - When continuing after another agent, preserve the handoff and approved contracts.
59
+
60
+ ## Existing Astro site
61
+
62
+ Explain that Cosmo can adopt the project without replacing its source files. First run a read-only inventory of `package.json`, Astro config, `src/`, `public/`, existing routes/content, and current build command. Report any obvious blocker.
63
+
64
+ After the user confirms adoption, run:
65
+
66
+ ```bash
67
+ cosmo adopt . --brand "<brand>" --site "<canonical-or-placeholder-url>" --profile <profile>
68
+ npm install
69
+ cosmo doctor .
70
+ cosmo workflow start .
71
+ cosmo brand discover .
72
+ ```
73
+
74
+ Start intake and inventory before proposing structural rewrites. Existing code remains in place until an approved design/plan explicitly changes it.
75
+
76
+ ## New site
77
+
78
+ Collect only the decisions needed to initialize:
79
+
80
+ 1. Target directory, brand/project name, and canonical URL if known.
81
+ 2. Business/niche, primary audience, primary site goal, genuine location scope, and approximate justified page count.
82
+ 3. Design mode: Claude-led, Claude Design-led, or hybrid.
83
+ 4. Capability profile. Recommend rather than asking the user to understand the catalog:
84
+ - `growth-site`: best general default for a business/lead-generation site.
85
+ - `search-authority`: research-led authority/content site.
86
+ - `local-authority`: defensible location strategy.
87
+ - `regulated-authority`: higher-risk subject with named review.
88
+ - `brand-led`: independent art direction and branded-language work.
89
+ - `lean`: smallest contract surface.
90
+
91
+ Confirm the initialization summary, then run:
92
+
93
+ ```bash
94
+ cosmo init <target> --name <slug> --brand "<brand>" --site "<url>" --profile <profile>
95
+ cd <target> && npm install
96
+ cosmo doctor <target>
97
+ cosmo workflow start <target>
98
+ cosmo brand discover <target>
99
+ cosmo intake <target> --niche "<niche>" --audience "<audience>" --goal "<goal>" --location "<location>" --pages <count> --design-mode <mode>
100
+ cosmo workflow submit intake <target>
101
+ cosmo intelligence scaffold <target>
102
+ cosmo intelligence guide brand <target>
103
+ ```
104
+
105
+ Then conduct brand discovery conversationally. Ask a small coherent group of questions at a time, record the answers in `.cosmo/brand/discovery.json`, synthesize the brand inputs, and present them for explicit human approval. Do not set `approved: true` until the user approves.
106
+
107
+ ## Stage behavior
108
+
109
+ At every stage:
110
+
111
+ 1. Read the stage contract and selected pack guidance.
112
+ 2. State the immediate outcome and decisions needed.
113
+ 3. Create or edit repository-owned artifacts.
114
+ 4. Run the relevant deterministic checks.
115
+ 5. Present approval-stage results and wait.
116
+ 6. Submit and approve only through Cosmo CLI commands.
117
+
118
+ For design, explore at least three genuinely distinct directions and preserve the selected direction in repository artifacts. For generation, advance one page gate at a time and respect repair limits. For QA, run integrity, content, intelligence, static, and browser checks. For production, require the exact current release to be READY.
119
+
120
+ ## Help mode
121
+
122
+ If the user asks what Cosmo can do, summarize new builds, Astro adoption, workflow resume, first-party intelligence profiles, Claude Design handoff, research snapshots, production QA, Claude-to-Codex handoff, and Cloudflare/SFTP/FTPS/FTP deployment. Keep the answer concise and offer to start or resume.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: cosmo-help
3
+ description: Show the Cosmo Claude launcher capabilities and quick-start choices. Use when the user asks for Cosmo help or what Cosmo can do.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Cosmo help
8
+
9
+ Explain that the user can type `cosmo` to start. Present these choices:
10
+
11
+ - Build a new Astro site with guided intake and brand discovery.
12
+ - Adopt an existing Astro site without replacing its source code.
13
+ - Resume an existing Cosmo workflow from repository state.
14
+ - Inspect status, QA, release readiness, or deployment.
15
+
16
+ Mention the explicit commands `/cosmo:cosmo` and `/cosmo:cosmo-help` as fallbacks. Do not make the user learn the underlying CLI unless they ask.
@@ -0,0 +1,14 @@
1
+ import { installClaudePlugin } from '../packages/cli/lib/claude-plugin.mjs';
2
+
3
+ const globalInstall = process.env.npm_config_global === 'true' || process.env.COSMO_POSTINSTALL_FORCE === '1';
4
+
5
+ if (globalInstall) {
6
+ try {
7
+ const result = installClaudePlugin({ replace: true, validate: false });
8
+ console.log(`Cosmo is ready for Claude at ${result.target}`);
9
+ console.log('Restart Claude, open a website folder, and type: cosmo');
10
+ } catch (error) {
11
+ console.warn(`Cosmo installed, but automatic Claude setup could not finish: ${error.message}`);
12
+ console.warn('After resolving the issue, run: cosmo setup');
13
+ }
14
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": 1,
3
+ "brand": "Cosmo Studio",
4
+ "approved": false,
5
+ "prompts": [
6
+ { "id": "ideal-customer", "question": "Who is the ideal customer, specifically?", "answer": "" },
7
+ { "id": "customer-moment", "question": "What is happening when they begin looking for help?", "answer": "" },
8
+ { "id": "category-fear", "question": "What do they distrust or fear about this category?", "answer": "" },
9
+ { "id": "alternatives", "question": "Which alternatives and competitors do they compare?", "answer": "" },
10
+ { "id": "differentiation", "question": "What can this brand credibly do or say that those alternatives cannot?", "answer": "" },
11
+ { "id": "contrary-belief", "question": "What useful belief does this brand hold that competitors usually do not?", "answer": "" },
12
+ { "id": "admired-brands", "question": "Which brands are admired, and for which precise qualities?", "answer": "" },
13
+ { "id": "brand-person", "question": "If this brand were a person, how would it behave and speak?", "answer": "" },
14
+ { "id": "anti-positioning", "question": "What should this brand never look, sound, or feel like?", "answer": "" },
15
+ { "id": "operating-values", "question": "Which values change real decisions rather than decorate a page?", "answer": "" },
16
+ { "id": "desired-feeling", "question": "What should a visitor feel in the first five seconds?", "answer": "" }
17
+ ],
18
+ "synthesis": { "audience": "", "position": "", "differentiation": "", "voice": "", "antiPositioning": [], "values": [], "desiredFeeling": "" }
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": 1,
3
+ "id": "cosmo-studio",
4
+ "officialName": "Cosmo Studio",
5
+ "aliases": [],
6
+ "domain": "https://example.com",
7
+ "descriptions": {
8
+ "short": "Complete this canonical project description after discovery.",
9
+ "long": "Replace this placeholder with the approved description of the project, its audience, its differentiated position, and the evidence that supports it."
10
+ },
11
+ "category": "Complete this project category",
12
+ "services": [],
13
+ "audiences": [],
14
+ "locations": [],
15
+ "people": [],
16
+ "credentials": [],
17
+ "profiles": [],
18
+ "claims": [],
19
+ "proofVocabulary": []
20
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 1,
3
+ "entityId": "cosmo-studio",
4
+ "maturity": "synthesized",
5
+ "sources": [],
6
+ "markers": ["clear", "specific"],
7
+ "weAre": ["evidence-aware", "direct"],
8
+ "weAreNot": ["generic", "overstated"],
9
+ "register": "Replace this with the approved project voice after discovery.",
10
+ "sentenceStyle": [],
11
+ "preferredVocabulary": [],
12
+ "bannedVocabulary": ["guaranteed", "effortless"],
13
+ "examples": [],
14
+ "appliesTo": ["website"],
15
+ "exceptions": []
16
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "version": 3,
3
+ "approved": false,
4
+ "createdAt": "2026-08-28T00:00:00.000Z",
5
+ "pages": [
6
+ {
7
+ "id": "home",
8
+ "path": "/",
9
+ "type": "home",
10
+ "title": "Cosmo Studio | Project Website",
11
+ "primaryTopic": "project website overview",
12
+ "contentFile": "src/content/pages/home.md",
13
+ "architecture": {
14
+ "archetype": "hub",
15
+ "indexability": "noindex",
16
+ "intent": {
17
+ "primary": "Introduce the project and direct visitors to its background",
18
+ "funnel": "awareness",
19
+ "awareness": "unaware",
20
+ "queryPatterns": ["project website overview"],
21
+ "demandConfidence": "unknown"
22
+ },
23
+ "intentBoundaries": []
24
+ },
25
+ "links": [
26
+ { "target": "about", "role": "supporting", "reason": "Provides the background and trust context that the overview cannot establish yet.", "anchorIntent": "Learn about the project" }
27
+ ],
28
+ "contract": {
29
+ "strengthensEntity": "cosmo-studio",
30
+ "supportsClaims": ["approved-project-positioning"],
31
+ "carriesProof": ["approved-brand-brief"],
32
+ "strengthensPages": ["about"],
33
+ "audienceNeed": "Understand what this project is and where to find its supporting context.",
34
+ "serves": "both",
35
+ "answerFirstTarget": "Replace this starter copy after project discovery and positioning are approved.",
36
+ "callsToAction": ["about"]
37
+ },
38
+ "data": {}
39
+ },
40
+ {
41
+ "id": "about",
42
+ "path": "/about/",
43
+ "type": "standard",
44
+ "title": "About the Cosmo Studio Project",
45
+ "primaryTopic": "project background and trust",
46
+ "contentFile": "src/content/pages/about.md",
47
+ "architecture": {
48
+ "archetype": "trust",
49
+ "indexability": "noindex",
50
+ "intent": {
51
+ "primary": "Explain the project's approved background and reasons to trust it",
52
+ "funnel": "consideration",
53
+ "awareness": "problem-aware",
54
+ "queryPatterns": ["project background and trust"],
55
+ "demandConfidence": "unknown"
56
+ },
57
+ "intentBoundaries": []
58
+ },
59
+ "links": [
60
+ { "target": "home", "role": "parent", "reason": "Returns background and trust context to the project overview.", "anchorIntent": "Return to the project overview" }
61
+ ],
62
+ "contract": {
63
+ "strengthensEntity": "cosmo-studio",
64
+ "supportsClaims": ["approved-project-background"],
65
+ "carriesProof": ["approved-brand-brief"],
66
+ "strengthensPages": ["home"],
67
+ "audienceNeed": "Understand the people, experience, and evidence behind this project.",
68
+ "serves": "visitor",
69
+ "answerFirstTarget": "Replace this starter copy with approved, evidence-backed project background.",
70
+ "callsToAction": ["home"]
71
+ },
72
+ "data": {}
73
+ }
74
+ ]
75
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "version": 2,
3
+ "profile": "lean",
4
+ "packs": [],
5
+ "capabilities": [
6
+ { "id": "entity-canon", "version": 1, "status": "active", "stages": ["brand", "plan", "generate", "qa"] },
7
+ { "id": "page-purpose-contract", "version": 1, "status": "active", "stages": ["homepage", "plan", "generate"] },
8
+ { "id": "audience-integrity", "version": 1, "status": "active", "stages": ["plan", "generate", "qa"] },
9
+ { "id": "evidence-ledger", "version": 1, "status": "active", "stages": ["intake", "brand", "plan", "generate", "qa"] },
10
+ { "id": "page-brief", "version": 1, "status": "active", "stages": ["homepage", "generate"] },
11
+ { "id": "voice-profile", "version": 1, "status": "active", "stages": ["brand", "generate", "qa"] },
12
+ { "id": "page-archetypes", "version": 1, "status": "active", "stages": ["plan", "generate", "qa"] },
13
+ { "id": "intent-governance", "version": 1, "status": "active", "stages": ["plan", "generate", "qa"] },
14
+ { "id": "governed-links", "version": 1, "status": "active", "stages": ["plan", "generate", "qa"] },
15
+ { "id": "indexability", "version": 1, "status": "active", "stages": ["plan", "generate", "qa"] },
16
+ { "id": "page-production-pipeline", "version": 1, "status": "active", "stages": ["generate", "qa"] },
17
+ { "id": "bounded-repair", "version": 1, "status": "active", "stages": ["generate", "qa"] },
18
+ { "id": "semantic-content-qa", "version": 1, "status": "active", "stages": ["qa"] },
19
+ { "id": "noncommodity-gate", "version": 1, "status": "active", "stages": ["generate", "qa"] }
20
+ ]
21
+ }