@archangel70/cosmo 1.11.0 → 1.13.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 CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable Cosmo changes are recorded here.
4
4
 
5
+ ## 1.13.0 — Native Astro preservation
6
+
7
+ - Fixed internal-link and sitemap auditing for Astro file-format builds by treating `/route`, `/route/`, and `/route.html` as the same destination without rewriting live URLs.
8
+ - Centralized route derivation so static, browser, and release checks use the same rules.
9
+ - Added a native-preservation workflow for adopted Astro sites that inventories existing pages, components, design, and routes instead of requiring Cosmo Markdown pages or section renderers.
10
+ - Updated release readiness for adopted sites to use the approved native route and design baselines without requiring bulk generation or a replacement design.
11
+ - Updated project status and agent handoffs to report native routes and applicable QA instead of missing generation, Markdown, or integrity artifacts.
12
+ - Made Markdown-specific content QA explicitly non-applicable to preserved native Astro sources rather than claiming to inspect hand-authored `.astro` content.
13
+
14
+ ## 1.12.0 — One-command updates
15
+
16
+ - Added `cosmo update` to install the latest public npm release without requiring users to remember the package name.
17
+ - Refreshes the Claude, Codex, and Antigravity launchers through the normal Cosmo installation process while leaving website projects untouched.
18
+ - Rewrote the beginner update instructions around the new command and retained the npm command as a troubleshooting fallback.
19
+
5
20
  ## 1.11.0 — Evidence-controlled EntityMap
6
21
 
7
22
  - Added optional EntityMap v1.0 generation from the Entity Canon and eligible final Astro content.
package/README.md CHANGED
@@ -4,7 +4,7 @@ Cosmo helps an AI coding assistant build a complete, original Astro website for
4
4
 
5
5
  You do **not** need to know how to code. Cosmo supports Claude Code, Codex, and Google Antigravity.
6
6
 
7
- Current version: **1.11.0**
7
+ Current version: **1.13.0**
8
8
 
9
9
  ## Quick install
10
10
 
@@ -82,7 +82,7 @@ This is the only part of the beginner setup that uses a terminal. It is one inst
82
82
  cosmo --version
83
83
  ```
84
84
 
85
- You should see `1.11.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
85
+ You should see `1.13.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
86
86
 
87
87
  ### On Windows
88
88
 
@@ -99,7 +99,7 @@ You should see `1.11.0` or a newer version. Cosmo automatically installs its Cla
99
99
  cosmo --version
100
100
  ```
101
101
 
102
- You should see `1.11.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
102
+ You should see `1.13.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
103
103
 
104
104
  ## Step 4: create your website folder
105
105
 
@@ -176,7 +176,7 @@ Cosmo will inspect the saved project and continue from the correct stage. You do
176
176
 
177
177
  ## Use Cosmo with an existing website
178
178
 
179
- Cosmo can work with an existing Astro website without deleting its pages.
179
+ Cosmo can work with an existing Astro website without deleting, redesigning, or converting its pages.
180
180
 
181
181
  1. Make a backup or commit the existing website first.
182
182
  2. Open the existing website folder in your chosen assistant.
@@ -184,18 +184,39 @@ Cosmo can work with an existing Astro website without deleting its pages.
184
184
  4. The assistant will identify the Astro project and ask whether you want Cosmo to adopt it.
185
185
  5. Review the inventory before approving changes.
186
186
 
187
- Cosmo will not automatically adopt an unrelated folder or overwrite a folder it does not recognize.
187
+ Adopted sites use a native-preservation workflow. Existing `.astro` pages, components, styles, design, and URL format remain authoritative. Cosmo inventories them and runs QA against the rendered website; it does not require moving pages into `src/content/pages`, using Cosmo section components, or changing file-format URLs such as `/about` backed by `about.html`.
188
+
189
+ Cosmo will not automatically adopt an unrelated folder or overwrite a folder it does not recognize. See [Native Astro adoption](docs/ADOPTION.md) for the preservation workflow and release requirements.
188
190
 
189
191
  ## Update Cosmo
190
192
 
191
193
  When a new version is announced, open Terminal or PowerShell and run:
192
194
 
193
195
  ```bash
194
- npm install --global @archangel70/cosmo@latest
196
+ cosmo update
197
+ ```
198
+
199
+ Cosmo downloads the latest published version and refreshes its Claude, Codex, and Antigravity launchers. Your website projects are not changed. When the update finishes, close and reopen your AI assistant, then confirm the installed version:
200
+
201
+ ```bash
195
202
  cosmo --version
196
203
  ```
197
204
 
198
- Updating Cosmo does not delete your website projects. Each website lives in its own folder.
205
+ ### Updating from Cosmo 1.11.0 or older
206
+
207
+ Older versions do not have the `cosmo update` command yet. Run this longer command one final time:
208
+
209
+ ```bash
210
+ npm install --global @archangel70/cosmo@latest
211
+ ```
212
+
213
+ After that, use `cosmo update` for every future update.
214
+
215
+ If `cosmo update` reports a permissions or npm error, use the original installer as a fallback:
216
+
217
+ ```bash
218
+ npm install --global @archangel70/cosmo@latest
219
+ ```
199
220
 
200
221
  ## Remove Cosmo
201
222
 
@@ -622,6 +643,7 @@ Run `cosmo help` for the installed version's canonical syntax.
622
643
  | `cosmo` | Show the friendly, context-aware next step for the current folder. |
623
644
  | `cosmo start [directory]` | Show the guided next step for a specified folder. |
624
645
  | `cosmo help` | Show the complete developer command reference. |
646
+ | `cosmo update` | Download the latest published Cosmo version and refresh all agent launchers. |
625
647
  | `cosmo setup [--agent name]` | Install or repair all launchers, or only Claude, Codex, or Antigravity. |
626
648
  | `cosmo agent list` | Show supported agents and whether each adapter is ready. |
627
649
  | `cosmo agent install <name|all> [--replace]` | Install or update one or every agent adapter. |
@@ -0,0 +1,41 @@
1
+ # Native Astro adoption
2
+
3
+ Cosmo adopts an existing Astro site in preservation mode. Adoption adds project governance and QA; it does not convert the site to Cosmo's generated Markdown architecture.
4
+
5
+ ## What remains unchanged
6
+
7
+ - Existing files under `src/pages`, including hand-authored `.astro` pages.
8
+ - Existing layouts, components, CSS, design tokens, and visual identity.
9
+ - Astro's configured `build.format`, including file output such as `about.html`.
10
+ - Live URL shapes. `/about`, `/about/`, and `/about.html` are matched as the same internal destination during static auditing, but Cosmo does not rewrite the site's chosen URLs.
11
+
12
+ The adopted project records `sourceModel: "native-astro"`, `designPolicy: "preserve"`, and the detected route format in `.cosmo/project.json`.
13
+
14
+ ## Preservation workflow
15
+
16
+ `cosmo workflow start .` automatically selects the `adopted` workflow for a native Astro project. It records and reviews:
17
+
18
+ 1. Existing-site constraints and goals.
19
+ 2. Existing brand, voice, claims, and evidence.
20
+ 3. The frozen visual baseline.
21
+ 4. Existing page and component architecture.
22
+ 5. The native route inventory and URL format.
23
+ 6. Only changes explicitly authorized by the user.
24
+ 7. Static and browser QA against the rendered build.
25
+
26
+ This workflow never requires `src/content/pages`, `PageView.astro`, `SectionRenderer.astro`, Cosmo section components, or `.cosmo/progress.json`.
27
+
28
+ ## QA and release
29
+
30
+ For native adopted sites, release readiness requires the completed preservation workflow, an approved route inventory and design baseline, intelligence checks, the static HTML audit, and browser QA. Cosmo's Markdown-specific semantic audit reports itself as not applicable rather than pretending it inspected `.astro` page content.
31
+
32
+ Run:
33
+
34
+ ```bash
35
+ cosmo check .
36
+ cosmo browser check .
37
+ cosmo intelligence check .
38
+ cosmo release check .
39
+ ```
40
+
41
+ Cosmo audits the existing output. It does not require switching a file-format site to directory URLs.
@@ -35,6 +35,8 @@ Bulk generation should create validated content entries and references. It shoul
35
35
 
36
36
  The approved `.cosmo/build-plan.json` is the executable inventory. Version 3 declares each page's route, page type, archetype, intent and awareness state, indexability, demand confidence, governed graph relationships, audience need, entity, claim ids, and proof ids. `cosmo plan check` validates either a draft or approved plan and reports that state; generation refuses to start until approval is explicit. Validation rejects duplicate ids, routes, topics, and query patterns; unresolved near-topic collisions; unknown graph references; unsafe content paths; incomplete page-purpose contracts; builder-only pages; invalid link roles; and parent cycles.
37
37
 
38
+ That generated-content architecture applies to new Cosmo builds. Existing Astro sites are adopted with `sourceModel: "native-astro"` and the separate `adopted` workflow. Their `.astro` pages, layouts, components, design system, and URL format remain authoritative; `.cosmo/adoption/route-inventory.json` replaces the Markdown build plan as the release inventory. See [Native Astro adoption](ADOPTION.md).
39
+
38
40
  `.cosmo/progress.json` is a resumable checkpoint ledger, not generated content. Generation progress v2 records `planned → briefed → sourced → outlined → drafted → edited → verified → done`; every transition validates the corresponding page-work artifact. A page can be completed only when its workspace and Markdown agree with Plan v3 and every carried proof is verified with the ledger's source and provenance. The queue stops after three consecutive failures, honors an optional page cap, limits automated repair to two cycles, and refuses to continue when the approved plan changes underneath a run. `.cosmo/generation.jsonl` records append-only transitions and repair escalation.
39
41
 
40
42
  ## Optional intelligence
package/docs/DELIVERY.md CHANGED
@@ -20,6 +20,12 @@ A project is ready only when all of the following are true:
20
20
 
21
21
  The release ID is a portable hash of the project source and durable Cosmo inputs. Editing those inputs changes the release ID and makes older QA reports stale.
22
22
 
23
+ ### Native adopted Astro sites
24
+
25
+ An adopted site that records `sourceModel: "native-astro"` uses its approved native route inventory and frozen-design baseline in place of Cosmo's Markdown Build Plan, design-direction selection, and generation progress. Its release gate requires intelligence, static-site, and browser reports, plus EntityMap when enabled. Integrity, content, and Copy Studio checks are not required because they validate Cosmo-generated content rather than hand-authored `.astro` pages.
26
+
27
+ The static and browser audits preserve the site's existing URL format. For a file-format build, `/about`, `/about/`, and `/about.html` are treated as references to the built `about.html` route; browser QA requests the actual `.html` output.
28
+
23
29
  ## Release sequence
24
30
 
25
31
  ```bash
@@ -36,6 +42,8 @@ cosmo release show .
36
42
 
37
43
  A blocked release still writes the manifest. Each finding includes a concrete repair, so the manifest doubles as the final punch list. Rerun the affected checks after any source change, then run the release check again.
38
44
 
45
+ For native adopted sites, omit `cosmo integrity check` and `cosmo content check`; the adopted workflow and `cosmo status` show the applicable checks automatically.
46
+
39
47
  ## Handoff
40
48
 
41
49
  Run `cosmo handoff create` after release evaluation. The handoff records the current release ID and ready/blocked state and includes the delivery report in its QA inventory. A handoff does not override a blocked release.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archangel70/cosmo",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Local-first, multi-agent Astro website builder for Claude, Codex, Antigravity, and the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -37,6 +37,7 @@
37
37
  "templates/astro-site/src/**",
38
38
  "templates/astro-site/tsconfig.json",
39
39
  "docs/AGENT-HANDOFF.md",
40
+ "docs/ADOPTION.md",
40
41
  "docs/ARCHITECTURE-INTELLIGENCE.md",
41
42
  "docs/ARCHITECTURE.md",
42
43
  "docs/BRAND-DISCOVERY.md",
@@ -41,6 +41,7 @@ import {
41
41
  writeJson,
42
42
  } from '../lib/project.mjs';
43
43
  import { run } from '../lib/process.mjs';
44
+ import { updateCosmo } from '../lib/self-update.mjs';
44
45
  import { captureResearchSource, checkResearchWorkbench, scaffoldResearchWorkbench } from '../lib/research.mjs';
45
46
  import { collectProjectStatus } from '../lib/status.mjs';
46
47
  import { planSummary, readPlan } from '../lib/plan.mjs';
@@ -64,7 +65,7 @@ import {
64
65
  workflowSummary,
65
66
  } from '../lib/workflow.mjs';
66
67
 
67
- const VERSION = '1.11.0';
68
+ const VERSION = '1.13.0';
68
69
  const cliDirectory = path.dirname(fileURLToPath(import.meta.url));
69
70
  const templateDirectory = path.resolve(cliDirectory, '../../../templates/astro-site');
70
71
  const [command = 'start', ...rawArgs] = process.argv.slice(2);
@@ -81,6 +82,7 @@ Commands
81
82
  cosmo Show the guided next step for this folder
82
83
  cosmo start [directory] Show the guided next step for another folder
83
84
  cosmo help Show the complete developer command reference
85
+ cosmo update Install the latest Cosmo version and refresh agent launchers
84
86
  cosmo setup [--agent claude|codex|antigravity|all]
85
87
  cosmo agent list
86
88
  cosmo agent install <claude|codex|antigravity|all> [--replace]
@@ -169,6 +171,14 @@ function start(args) {
169
171
  console.log(launcherGuide(projectDirectory(positional[0] ?? '.'), VERSION));
170
172
  }
171
173
 
174
+ async function update() {
175
+ console.log(`Updating Cosmo ${VERSION} to the latest published version...`);
176
+ await updateCosmo();
177
+ console.log('Cosmo is up to date. Your website projects were not changed.');
178
+ console.log('Claude, Codex, and Antigravity launchers were refreshed during installation.');
179
+ console.log('Close and reopen your AI assistant, then run: cosmo --version');
180
+ }
181
+
172
182
  async function init(args) {
173
183
  const { options, positional } = parseOptions(args);
174
184
  const target = projectDirectory(positional[0] ?? '.');
@@ -234,8 +244,9 @@ function adopt(args) {
234
244
  const result = adoptAstroProject(templateDirectory, target, options);
235
245
  console.log(`Adopted ${result.brand} at ${result.target}`);
236
246
  console.log(`Profile: ${result.profile}`);
247
+ console.log(`Preserved: ${result.pageSources} native Astro page source(s), ${result.routeFormat} URL format, existing design and components`);
237
248
  console.log('Existing Astro source, configuration, dependencies, and public files were preserved.');
238
- console.log('Next: cosmo doctor ., then cosmo workflow start .');
249
+ console.log('Next: cosmo doctor ., then cosmo workflow start . (the native-preservation workflow starts automatically)');
239
250
  }
240
251
 
241
252
  function claudeCommand(args) {
@@ -491,8 +502,9 @@ function status(args) {
491
502
  console.log(` workflow: ${result.workflow ? `${result.workflow.status}${result.workflow.currentStage ? ` at ${result.workflow.currentStage}` : ''}` : 'not started'}`);
492
503
  console.log(` brand: ${result.brandDiscovery}`);
493
504
  console.log(` intelligence: ${result.intelligence.profile} · ${result.intelligence.packs.length ? result.intelligence.packs.join(', ') : 'no selected packs'}${result.intelligence.installedPackages.length ? ` · ${result.intelligence.installedPackages.length} imported` : ''}`);
494
- console.log(` plan: ${result.plan ? `${result.plan.pages} pages · ${result.plan.approved ? 'approved' : 'draft'}` : 'missing'}`);
495
- console.log(` generation: ${result.generation ? `${result.generation.pages} pages · ${result.generation.complete ? 'complete' : 'active'}` : 'not started'}`);
505
+ const nativeAdoption = result.project.sourceModel === 'native-astro';
506
+ console.log(` ${nativeAdoption ? 'routes' : 'plan'}: ${result.plan ? `${result.plan.pages} ${nativeAdoption ? 'routes' : 'pages'} · ${result.plan.approved ? 'approved' : 'draft'}${nativeAdoption ? ` · ${result.plan.routeFormat} format` : ''}` : 'missing'}`);
507
+ console.log(` generation: ${nativeAdoption ? 'not applicable (native Astro source preserved)' : result.generation ? `${result.generation.pages} pages · ${result.generation.complete ? 'complete' : 'active'}` : 'not started'}`);
496
508
  console.log(` entity map: ${result.entityMap.enabled ? 'enabled' : 'disabled'}`);
497
509
  console.log(` qa: ${Object.entries(result.qa).map(([name, report]) => `${name.replace('-check', '')}=${report ? report.status ?? (report.passed ? 'passed' : 'failed') : 'missing'}`).join(' ')}`);
498
510
  console.log(` release: ${result.release?.releaseId ?? 'unavailable'} · ${result.release?.ready ? 'ready' : `${result.release?.blocking ?? '?'} blocking`}`);
@@ -852,7 +864,7 @@ function workflowCommand(args) {
852
864
  if (subcommand === 'start') {
853
865
  const { options, positional } = parseOptions(rest);
854
866
  const target = projectDirectory(positional[0] ?? '.');
855
- startWorkflow(target, String(options.workflow ?? 'default'));
867
+ startWorkflow(target, options.workflow ? String(options.workflow) : undefined);
856
868
  showWorkflow(target);
857
869
  return;
858
870
  }
@@ -1079,6 +1091,7 @@ async function main() {
1079
1091
  if (command === 'help' || command === '--help' || command === '-h') return help();
1080
1092
  if (command === 'start') return start(rawArgs);
1081
1093
  if (command === '--version' || command === '-v' || command === 'version') return console.log(VERSION);
1094
+ if (command === 'update') return update();
1082
1095
  if (command === 'setup') return setup(rawArgs);
1083
1096
  if (command === 'init') return init(rawArgs);
1084
1097
  if (command === 'adopt') return adopt(rawArgs);
@@ -1,7 +1,6 @@
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';
5
4
  import { scaffoldEntityMap } from './entity-map.mjs';
6
5
  import { slugify, writeJson } from './project.mjs';
7
6
 
@@ -28,6 +27,30 @@ function detectsAstro(target) {
28
27
  return config || Boolean(pkg.dependencies?.astro || pkg.devDependencies?.astro);
29
28
  }
30
29
 
30
+ function walkPageSources(directory, root = directory) {
31
+ if (!fs.existsSync(directory)) return [];
32
+ return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
33
+ const file = path.join(directory, entry.name);
34
+ if (entry.isDirectory()) return walkPageSources(file, root);
35
+ return /\.(astro|md|mdx)$/i.test(entry.name) ? [path.relative(root, file).split(path.sep).join('/')] : [];
36
+ });
37
+ }
38
+
39
+ function detectRouteFormat(target) {
40
+ const configName = ['astro.config.mjs', 'astro.config.js', 'astro.config.ts', 'astro.config.cjs'].find((name) => fs.existsSync(path.join(target, name)));
41
+ if (!configName) return 'directory';
42
+ const source = fs.readFileSync(path.join(target, configName), 'utf8');
43
+ return /\bformat\s*:\s*['"]file['"]/i.test(source) ? 'file' : 'directory';
44
+ }
45
+
46
+ function routeFromPageSource(source, routeFormat) {
47
+ const stem = source.replace(/\.(astro|md|mdx)$/i, '');
48
+ if (stem.split('/').some((segment) => segment.includes('['))) return null;
49
+ if (stem === 'index') return '/';
50
+ const route = stem.endsWith('/index') ? `/${stem.slice(0, -'/index'.length)}` : `/${stem}`;
51
+ return routeFormat === 'file' ? route : `${route.replace(/\/$/, '')}/`;
52
+ }
53
+
31
54
  function copyPath(templateDirectory, target, relative) {
32
55
  const source = path.join(templateDirectory, relative);
33
56
  if (!fs.existsSync(source)) return;
@@ -69,13 +92,15 @@ export function adoptAstroProject(templateDirectory, target, options = {}) {
69
92
  const site = String(options.site ?? 'https://example.com').replace(/\/$/, '');
70
93
  const profile = String(options.profile ?? 'growth-site');
71
94
  const designMode = String(options['design-mode'] ?? options.designMode ?? 'hybrid');
95
+ const routeFormat = detectRouteFormat(resolved);
96
+ const pageSources = walkPageSources(path.join(resolved, 'src', 'pages'));
72
97
 
73
98
  fs.mkdirSync(path.join(resolved, '.cosmo'), { recursive: false });
74
99
  for (const relative of GOVERNANCE_PATHS) copyPath(templateDirectory, resolved, relative);
75
100
 
76
101
  const now = new Date().toISOString();
77
102
  writeJson(path.join(resolved, '.cosmo', 'project.json'), {
78
- name, brand, site, stage: 'adoption', designMode, output: 'static', adopted: true, createdAt: now, lastActivity: now,
103
+ name, brand, site, stage: 'adoption', designMode, output: 'static', adopted: true, sourceModel: 'native-astro', designPolicy: 'preserve', routeFormat, workflow: 'adopted', createdAt: now, lastActivity: now,
79
104
  });
80
105
  writeJson(path.join(resolved, '.cosmo', 'build-plan.json'), { version: 3, approved: false, createdAt: now, pages: [] });
81
106
  writeJson(path.join(resolved, '.cosmo', 'evidence.json'), { version: 1, entityId: slugify(brand), claims: [], proofs: [] });
@@ -87,10 +112,18 @@ export function adoptAstroProject(templateDirectory, target, options = {}) {
87
112
  const voice = JSON.parse(fs.readFileSync(voiceFile, 'utf8'));
88
113
  writeJson(voiceFile, { ...voice, entityId: slugify(brand) });
89
114
  applyIntelligenceProfile(resolved, profile);
90
- scaffoldCopyStudio(resolved);
91
115
  scaffoldEntityMap(resolved, { enabled: Boolean(options['entity-map']), replace: true });
116
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'source-inventory.json'), { version: 1, sourceModel: 'native-astro', routeFormat, reviewed: false, pageSources });
117
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'route-inventory.json'), {
118
+ version: 1, routeFormat, approved: false,
119
+ routes: pageSources.map((source) => ({ source: `src/pages/${source}`, path: routeFromPageSource(source, routeFormat), indexability: 'preserve' })),
120
+ });
121
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'design-baseline.json'), { version: 1, policy: 'preserve', approved: false, notes: '' });
122
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'page-baseline.json'), { version: 1, reviewed: false, notes: '' });
123
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'component-baseline.json'), { version: 1, preserveExisting: true, reviewed: false, notes: '' });
124
+ writeJson(path.join(resolved, '.cosmo', 'adoption', 'change-record.json'), { version: 1, reviewed: false, changes: [] });
92
125
 
93
126
  const guides = ['CLAUDE.md', 'AGENTS.md'].map((file) => installAgentGuide(templateDirectory, resolved, file)).filter(Boolean);
94
127
  guides.push(...installAgentAdapters(templateDirectory, resolved));
95
- return { target: resolved, name, brand, site, profile, guides };
128
+ return { target: resolved, name, brand, site, profile, routeFormat, pageSources: pageSources.length, guides };
96
129
  }
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { normalizeRoute, routeForFile } from './routes.mjs';
3
4
 
4
5
  function walk(directory, suffix) {
5
6
  if (!fs.existsSync(directory)) return [];
@@ -13,25 +14,9 @@ function firstMatch(html, pattern) {
13
14
  return html.match(pattern)?.[1]?.trim() ?? '';
14
15
  }
15
16
 
16
- function routeForFile(distDir, file) {
17
- const relative = path.relative(distDir, file).split(path.sep).join('/');
18
- if (relative === 'index.html') return '/';
19
- if (relative.endsWith('/index.html')) return `/${relative.slice(0, -'index.html'.length)}`;
20
- if (relative === 'entitymap.html') return '/entitymap.html';
21
- return `/${relative.replace(/\.html$/, '')}`;
22
- }
23
-
24
- function normalizeRoute(href) {
25
- const pathname = href.split('#')[0].split('?')[0];
26
- if (!pathname) return null;
27
- if (pathname === '/') return '/';
28
- if (/\/[^/]+\.[a-z0-9]+$/i.test(pathname)) return pathname;
29
- return pathname.endsWith('/') ? pathname : `${pathname}/`;
30
- }
31
-
32
17
  export function auditDist(distDir) {
33
18
  const htmlFiles = walk(distDir, '.html');
34
- const routes = new Set(htmlFiles.map((file) => routeForFile(distDir, file)));
19
+ const routes = new Set(htmlFiles.map((file) => normalizeRoute(routeForFile(distDir, file))));
35
20
  const pages = [];
36
21
  const critical = [];
37
22
  const warnings = [];
@@ -119,8 +104,9 @@ export function auditDist(distDir) {
119
104
  }
120
105
  }
121
106
  for (const page of pages) {
122
- if (page.indexable && !sitemapRoutes.has(page.route)) critical.push({ route: page.route, rule: 'sitemap-missing-route' });
123
- if (!page.indexable && sitemapRoutes.has(page.route)) critical.push({ route: page.route, rule: 'sitemap-includes-noindex' });
107
+ const normalizedPageRoute = normalizeRoute(page.route);
108
+ if (page.indexable && !sitemapRoutes.has(normalizedPageRoute)) critical.push({ route: page.route, rule: 'sitemap-missing-route' });
109
+ if (!page.indexable && sitemapRoutes.has(normalizedPageRoute)) critical.push({ route: page.route, rule: 'sitemap-includes-noindex' });
124
110
  }
125
111
  }
126
112
 
@@ -5,6 +5,7 @@ import axe from 'axe-core';
5
5
  import { launch as launchChrome } from 'chrome-launcher';
6
6
  import lighthouse from 'lighthouse';
7
7
  import { chromium } from 'playwright-core';
8
+ import { routeForFile } from './routes.mjs';
8
9
 
9
10
  const VIEWPORTS = [
10
11
  { name: 'mobile', width: 320, height: 900 },
@@ -20,14 +21,6 @@ function walk(directory, suffix) {
20
21
  });
21
22
  }
22
23
 
23
- function routeForFile(distDir, file) {
24
- const relative = path.relative(distDir, file).split(path.sep).join('/');
25
- if (relative === 'index.html') return '/';
26
- if (relative.endsWith('/index.html')) return `/${relative.slice(0, -'index.html'.length)}`;
27
- if (relative === 'entitymap.html') return '/entitymap.html';
28
- return `/${relative.replace(/\.html$/, '')}`;
29
- }
30
-
31
24
  function screenshotName(route, width) {
32
25
  const slug = route === '/' ? 'home' : route.replace(/^\/|\/$/g, '').replace(/[^a-z0-9]+/gi, '-');
33
26
  return `${slug}-${width}.png`;
@@ -131,7 +131,21 @@ function auditPage(projectDir, plan, page, integrity, policy) {
131
131
  }
132
132
 
133
133
  export function auditContent(projectDir) {
134
- readProject(projectDir);
134
+ const project = readProject(projectDir).data;
135
+ if (project.sourceModel === 'native-astro') {
136
+ const checkedAt = new Date().toISOString();
137
+ return {
138
+ version: 1,
139
+ enabled: false,
140
+ sourceModel: 'native-astro',
141
+ passed: true,
142
+ checkedAt,
143
+ summary: { pages: 0, blocking: 0, warnings: 1, bySubstanceTier: { commodity: 0, premium: 0, noncommodity: 0 } },
144
+ policy: '.cosmo/policies/content-integrity.json',
145
+ pages: [],
146
+ findings: [issue('site', 'native-astro-content', 'warning', 'Semantic Markdown content QA is not applicable to this preserved native Astro site.', 'Use the static and browser checks against the rendered HTML; review copy in its existing Astro sources.')],
147
+ };
148
+ }
135
149
  checkIntegrity(projectDir);
136
150
  const plan = readPlan(projectDir, { requireApproved: false }).data;
137
151
  assert(plan.version >= 3, 'Content QA requires Build Plan v3 or newer.');
@@ -43,6 +43,7 @@ function sourceFiles(projectDir) {
43
43
  path.join(projectDir, '.cosmo', 'intelligence'),
44
44
  path.join(projectDir, '.cosmo', 'policies'),
45
45
  path.join(projectDir, '.cosmo', 'work'),
46
+ path.join(projectDir, '.cosmo', 'adoption'),
46
47
  ];
47
48
  const direct = ['.cosmo/project.json', '.cosmo/build-plan.json', '.cosmo/evidence.json', '.cosmo/entities/config.json', 'DESIGN-DIRECTION.md', 'cosmo.config.mjs', 'astro.config.mjs', 'package.json', 'package-lock.json', 'tsconfig.json']
48
49
  .map((relative) => path.join(projectDir, relative))
@@ -64,38 +65,55 @@ function renderDelivery(report) {
64
65
  const blockers = report.findings.length
65
66
  ? report.findings.map((item) => `- **${item.code}:** ${item.message}\n - Fix: ${item.fix}`).join('\n')
66
67
  : '- None.';
67
- return `# Delivery Readiness\n\n- Release: \`${report.releaseId}\`\n- Checked: ${report.checkedAt}\n- Status: **${report.ready ? 'READY' : 'BLOCKED'}**\n- Brand: ${report.project.brand}\n- Site: ${report.project.site}\n- Intelligence: ${report.intelligence.profile}${report.intelligence.packs.length ? ` (${report.intelligence.packs.join(', ')})` : ' (no optional packs)'}\n- Plan: ${report.plan.approved ? 'approved' : 'not approved'}, ${report.plan.pages} pages, ${report.plan.indexable} indexable\n\n## Reports\n\n${reports}\n\n## Blocking findings\n\n${blockers}\n\nThis manifest records local readiness at one source hash. Any later source change requires the relevant checks and release evaluation to run again.\n`;
68
+ const planLine = report.project.sourceModel === 'native-astro'
69
+ ? `Native route inventory: ${report.plan.approved ? 'approved' : 'not approved'}, ${report.plan.pages} routes, URL format ${report.plan.routeFormat ?? 'unknown'}`
70
+ : `Plan: ${report.plan.approved ? 'approved' : 'not approved'}, ${report.plan.pages} pages, ${report.plan.indexable} indexable`;
71
+ return `# Delivery Readiness\n\n- Release: \`${report.releaseId}\`\n- Checked: ${report.checkedAt}\n- Status: **${report.ready ? 'READY' : 'BLOCKED'}**\n- Brand: ${report.project.brand}\n- Site: ${report.project.site}\n- Intelligence: ${report.intelligence.profile}${report.intelligence.packs.length ? ` (${report.intelligence.packs.join(', ')})` : ' (no optional packs)'}\n- ${planLine}\n\n## Reports\n\n${reports}\n\n## Blocking findings\n\n${blockers}\n\nThis manifest records local readiness at one source hash. Any later source change requires the relevant checks and release evaluation to run again.\n`;
68
72
  }
69
73
 
70
74
  export function evaluateDelivery(projectDir) {
71
75
  const project = readProject(projectDir).data;
76
+ const nativeAdoption = project.sourceModel === 'native-astro';
72
77
  const intelligence = readIntelligence(projectDir).data;
73
78
  const findings = [];
74
79
  const inputs = sourceFiles(projectDir);
75
80
  const latestInputMtime = inputs.reduce((latest, file) => Math.max(latest, fs.statSync(file).mtimeMs), 0);
76
81
  let plan = { approved: false, pages: 0, indexable: 0 };
77
- try {
78
- const value = readPlan(projectDir, { requireApproved: false }).data;
79
- plan = { approved: value.approved, pages: value.pages.length, indexable: value.pages.filter((page) => page.architecture?.indexability === 'index').length };
80
- if (!value.approved) findings.push(finding('plan-not-approved', 'The build plan is still a draft.', 'Approve the reviewed plan before release.'));
81
- if (plan.indexable === 0) findings.push(finding('no-indexable-pages', 'The release has no indexable pages.', 'Approve evidence and explicitly index the routes intended for public discovery.'));
82
- } catch (error) {
83
- findings.push(finding('plan-invalid', error.message, 'Repair and approve the build plan.'));
82
+ if (nativeAdoption) {
83
+ const inventory = optionalJson(path.join(projectDir, '.cosmo', 'adoption', 'route-inventory.json'));
84
+ plan = { approved: inventory?.approved === true, pages: Array.isArray(inventory?.routes) ? inventory.routes.length : 0, indexable: null, routeFormat: inventory?.routeFormat ?? project.routeFormat ?? null };
85
+ if (inventory?.invalid || !Array.isArray(inventory?.routes) || inventory.routes.length === 0) findings.push(finding('route-inventory-invalid', 'The native route inventory is missing or invalid.', 'Review the existing Astro routes without converting their source model.'));
86
+ else if (!inventory.approved) findings.push(finding('route-inventory-not-approved', 'The native route inventory is still a draft.', 'Review and approve the preserved routes and URL format.'));
87
+ } else {
88
+ try {
89
+ const value = readPlan(projectDir, { requireApproved: false }).data;
90
+ plan = { approved: value.approved, pages: value.pages.length, indexable: value.pages.filter((page) => page.architecture?.indexability === 'index').length };
91
+ if (!value.approved) findings.push(finding('plan-not-approved', 'The build plan is still a draft.', 'Approve the reviewed plan before release.'));
92
+ if (plan.indexable === 0) findings.push(finding('no-indexable-pages', 'The release has no indexable pages.', 'Approve evidence and explicitly index the routes intended for public discovery.'));
93
+ } catch (error) {
94
+ findings.push(finding('plan-invalid', error.message, 'Repair and approve the build plan.'));
95
+ }
84
96
  }
85
97
 
86
98
  if (!project.site || /example\.com/i.test(project.site)) findings.push(finding('project-site-placeholder', `Project site is still ${project.site || 'unset'}.`, 'Set the production canonical site URL.'));
87
- const directionFile = path.join(projectDir, 'DESIGN-DIRECTION.md');
88
- if (!fs.existsSync(directionFile) || /status:\s*unselected/i.test(fs.readFileSync(directionFile, 'utf8'))) findings.push(finding('design-direction-unapproved', 'The design direction is missing or still unselected.', 'Approve and record the project-owned visual direction before release.'));
99
+ if (nativeAdoption) {
100
+ const baseline = optionalJson(path.join(projectDir, '.cosmo', 'adoption', 'design-baseline.json'));
101
+ if (baseline?.policy !== 'preserve' || baseline?.approved !== true) findings.push(finding('design-baseline-unapproved', 'The existing design has not been approved as the preservation baseline.', 'Review the current design and approve the preserve policy without redesigning it.'));
102
+ } else {
103
+ const directionFile = path.join(projectDir, 'DESIGN-DIRECTION.md');
104
+ if (!fs.existsSync(directionFile) || /status:\s*unselected/i.test(fs.readFileSync(directionFile, 'utf8'))) findings.push(finding('design-direction-unapproved', 'The design direction is missing or still unselected.', 'Approve and record the project-owned visual direction before release.'));
105
+ }
89
106
  const placeholderFiles = inputs.filter((file) => ['.json', '.md', '.mjs'].includes(path.extname(file))).filter((file) => PLACEHOLDER_PATTERN.test(fs.readFileSync(file, 'utf8')));
90
107
  if (placeholderFiles.length) findings.push(finding('placeholder-content-remains', `Placeholder values remain in ${placeholderFiles.map((file) => path.relative(projectDir, file)).join(', ')}.`, 'Replace starter identity, contact, and incomplete canonical values with approved production data.'));
91
108
 
92
109
  const workflow = readWorkflowState(projectDir, { required: false })?.data ?? null;
93
110
  if (!workflow || workflow.status !== 'complete') findings.push(finding('workflow-incomplete', workflow ? `Workflow remains ${workflow.status} at ${workflow.currentStage}.` : 'No completed workflow exists.', 'Complete every required stage and approval.'));
94
111
  const progress = optionalJson(path.join(projectDir, '.cosmo', 'progress.json'));
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.'));
112
+ if (!nativeAdoption && (!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.'));
96
113
 
97
114
  const entityConfig = optionalJson(path.join(projectDir, '.cosmo', 'entities', 'config.json'));
98
- const requiredReports = [...BASE_REQUIRED_REPORTS, ...(fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : []), ...(entityConfig?.enabled ? ['entity-check'] : [])];
115
+ const baseReports = nativeAdoption ? ['intelligence-check', 'site-check', 'browser-check'] : BASE_REQUIRED_REPORTS;
116
+ const requiredReports = [...baseReports, ...(!nativeAdoption && fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : []), ...(entityConfig?.enabled ? ['entity-check'] : [])];
99
117
  const reports = requiredReports.map((name) => {
100
118
  const file = path.join(projectDir, '.cosmo', 'reports', `${name}.json`);
101
119
  const data = optionalJson(file);
@@ -114,11 +132,11 @@ export function evaluateDelivery(projectDir) {
114
132
  releaseId: releaseHash(projectDir, inputs),
115
133
  ready: findings.length === 0,
116
134
  checkedAt: new Date().toISOString(),
117
- project: { name: project.name, brand: project.brand, site: project.site, stage: project.stage },
135
+ project: { name: project.name, brand: project.brand, site: project.site, stage: project.stage, sourceModel: project.sourceModel ?? 'cosmo-content' },
118
136
  intelligence: { profile: intelligence.profile, packs: intelligence.packs },
119
137
  plan,
120
138
  workflow: workflow ? { status: workflow.status, workflowId: workflow.workflowId, currentStage: workflow.currentStage } : null,
121
- generation: progress && !progress.invalid ? { complete: progress.complete, summary: progress.summary ?? null } : null,
139
+ generation: !nativeAdoption && progress && !progress.invalid ? { complete: progress.complete, summary: progress.summary ?? null } : null,
122
140
  reports,
123
141
  summary: { blocking: findings.length },
124
142
  findings,
@@ -49,20 +49,32 @@ function renderMarkdown(handoff) {
49
49
  ? `${handoff.deployment.status} ${handoff.deployment.environment} ${handoff.deployment.url ?? handoff.deployment.remoteDir ?? 'target unavailable'} (${handoff.deployment.releaseId})${handoff.deployment.totalFiles === null ? '' : `; ${handoff.deployment.uploaded} uploaded, ${handoff.deployment.totalFiles} total`}`
50
50
  : 'not attempted';
51
51
  const reports = handoff.reports.map((report) => `- \`${report.path}\`: **${report.status}**${report.critical === null ? '' : ` (${report.critical} critical, ${report.warnings} warnings)`}`).join('\n');
52
- return `# Project Handoff\n\nCreated ${handoff.createdAt} from **${handoff.from}** to **${handoff.to}**.\n\n## Project\n\n- Brand: ${handoff.project.brand}\n- Site: ${handoff.project.site}\n- Project stage: ${handoff.project.stage}\n- Workflow: ${workflow}\n- Intelligence: ${handoff.intelligence.profile}${handoff.intelligence.packs.length ? ` (${handoff.intelligence.packs.join(', ')})` : ' (no optional packs)'}\n- Generation: ${generation}\n- Approved plan: ${handoff.plan ? `v${handoff.plan.version}, ${handoff.plan.pages} pages and ${handoff.plan.links} graph edges` : 'unavailable'}\n- Release: ${handoff.delivery ? `${handoff.delivery.ready ? 'ready' : 'blocked'} (${handoff.delivery.releaseId})` : 'not evaluated'}\n- Deployment: ${deployment}\n\n## Next action\n\n${handoff.nextAction}\n\n## Handoff note\n\n${handoff.note || 'No additional note was supplied.'}\n\n## Latest QA\n\n${reports}\n\n## Repository truth\n\nRead \`BRAND-BRIEF.md\`, \`.cosmo/brand/entity-canon.json\`, \`.cosmo/brand/voice-profile.json\`, \`.cosmo/evidence.json\`, \`.cosmo/intelligence/selection.json\`, every selected pack manifest and artifact, the relevant page brief, \`DESIGN-DIRECTION.md\`, \`.cosmo/build-plan.json\`, \`.cosmo/progress.json\`, \`DELIVERY.md\`, and deployment history when present. Do not infer approval or evidence from this summary; the underlying artifacts remain authoritative.\n`;
52
+ const inventory = handoff.project.sourceModel === 'native-astro'
53
+ ? `Native route inventory: ${handoff.plan ? `v${handoff.plan.version}, ${handoff.plan.pages} routes, ${handoff.plan.routeFormat} format` : 'unavailable'}`
54
+ : `Approved plan: ${handoff.plan ? `v${handoff.plan.version}, ${handoff.plan.pages} pages and ${handoff.plan.links} graph edges` : 'unavailable'}`;
55
+ const repositoryTruth = handoff.project.sourceModel === 'native-astro'
56
+ ? 'Read `BRAND-BRIEF.md`, `.cosmo/project.json`, `.cosmo/adoption/`, `.cosmo/brand/`, `.cosmo/evidence.json`, `.cosmo/intelligence/selection.json`, the native Astro page/component source, `DELIVERY.md`, and deployment history when present. The existing source, design, and URL format remain authoritative.'
57
+ : 'Read `BRAND-BRIEF.md`, `.cosmo/brand/entity-canon.json`, `.cosmo/brand/voice-profile.json`, `.cosmo/evidence.json`, `.cosmo/intelligence/selection.json`, every selected pack manifest and artifact, the relevant page brief, `DESIGN-DIRECTION.md`, `.cosmo/build-plan.json`, `.cosmo/progress.json`, `DELIVERY.md`, and deployment history when present.';
58
+ return `# Project Handoff\n\nCreated ${handoff.createdAt} from **${handoff.from}** to **${handoff.to}**.\n\n## Project\n\n- Brand: ${handoff.project.brand}\n- Site: ${handoff.project.site}\n- Project stage: ${handoff.project.stage}\n- Workflow: ${workflow}\n- Intelligence: ${handoff.intelligence.profile}${handoff.intelligence.packs.length ? ` (${handoff.intelligence.packs.join(', ')})` : ' (no optional packs)'}\n- Generation: ${generation}\n- ${inventory}\n- Release: ${handoff.delivery ? `${handoff.delivery.ready ? 'ready' : 'blocked'} (${handoff.delivery.releaseId})` : 'not evaluated'}\n- Deployment: ${deployment}\n\n## Next action\n\n${handoff.nextAction}\n\n## Handoff note\n\n${handoff.note || 'No additional note was supplied.'}\n\n## Latest QA\n\n${reports}\n\n## Repository truth\n\n${repositoryTruth} Do not infer approval or evidence from this summary; the underlying artifacts remain authoritative.\n`;
53
59
  }
54
60
 
55
61
  export function createHandoff(projectDir, { from = 'claude', to = 'codex', note = '' } = {}) {
56
62
  const project = readProject(projectDir).data;
63
+ const nativeAdoption = project.sourceModel === 'native-astro';
57
64
  const workflow = readWorkflowState(projectDir, { required: false })?.data ?? null;
58
65
  const generation = optionalJson(path.join(projectDir, '.cosmo', 'progress.json'));
59
66
  const intelligence = readIntelligence(projectDir).data;
60
67
  const delivery = optionalJson(path.join(projectDir, '.cosmo', 'reports', 'delivery-check.json'));
61
68
  const deployment = readDeploymentHistory(projectDir).records.at(-1) ?? null;
62
69
  let plan = null;
63
- try {
64
- plan = planSummary(readPlan(projectDir).data);
65
- } catch {}
70
+ if (nativeAdoption) {
71
+ const inventory = optionalJson(path.join(projectDir, '.cosmo', 'adoption', 'route-inventory.json'));
72
+ if (inventory && !inventory.invalid && Array.isArray(inventory.routes)) plan = { version: inventory.version, pages: inventory.routes.length, links: null, routeFormat: inventory.routeFormat, native: true };
73
+ } else {
74
+ try {
75
+ plan = planSummary(readPlan(projectDir).data);
76
+ } catch {}
77
+ }
66
78
  const handoff = {
67
79
  version: 1,
68
80
  createdAt: new Date().toISOString(),
@@ -75,12 +87,13 @@ export function createHandoff(projectDir, { from = 'claude', to = 'codex', note
75
87
  site: project.site,
76
88
  stage: project.stage,
77
89
  designMode: project.designMode,
90
+ sourceModel: project.sourceModel ?? 'cosmo-content',
78
91
  },
79
92
  workflow: workflow ? { status: workflow.status, currentStage: workflow.currentStage, workflowId: workflow.workflowId } : null,
80
93
  intelligence: { profile: intelligence.profile, packs: intelligence.packs },
81
94
  delivery: delivery && !delivery.invalid ? { ready: delivery.ready, releaseId: delivery.releaseId, checkedAt: delivery.checkedAt } : null,
82
95
  deployment: deployment ? { provider: deployment.provider, status: deployment.status, environment: deployment.environment, releaseId: deployment.releaseId, url: deployment.url, remoteDir: deployment.remoteDir ?? null, uploaded: deployment.uploaded ?? null, totalFiles: deployment.totalFiles ?? null, completedAt: deployment.completedAt } : null,
83
- generation: generation && !generation.invalid ? {
96
+ generation: !nativeAdoption && generation && !generation.invalid ? {
84
97
  complete: generation.complete,
85
98
  done: generation.summary?.done ?? 0,
86
99
  total: generation.summary?.total ?? Object.keys(generation.pages ?? {}).length,
@@ -89,7 +102,10 @@ export function createHandoff(projectDir, { from = 'claude', to = 'codex', note
89
102
  stoppedReason: generation.stoppedReason ?? null,
90
103
  } : null,
91
104
  plan,
92
- reports: [reportState(projectDir, 'integrity-check'), reportState(projectDir, 'intelligence-check'), reportState(projectDir, 'content-check'), reportState(projectDir, 'site-check'), reportState(projectDir, 'browser-check'), reportState(projectDir, 'delivery-check')],
105
+ reports: (nativeAdoption
106
+ ? ['intelligence-check', 'site-check', 'browser-check', 'delivery-check']
107
+ : ['integrity-check', 'intelligence-check', 'content-check', 'site-check', 'browser-check', 'delivery-check'])
108
+ .map((name) => reportState(projectDir, name)),
93
109
  };
94
110
  handoff.nextAction = nextAction(handoff.workflow, handoff.generation);
95
111
  const jsonFile = path.join(projectDir, '.cosmo', 'handoff.json');
@@ -0,0 +1,18 @@
1
+ import path from 'node:path';
2
+
3
+ export function routeForFile(distDir, file) {
4
+ const relative = path.relative(distDir, file).split(path.sep).join('/');
5
+ if (relative === 'index.html') return '/';
6
+ if (relative.endsWith('/index.html')) return `/${relative.slice(0, -'index.html'.length)}`;
7
+ return `/${relative}`;
8
+ }
9
+
10
+ export function normalizeRoute(value) {
11
+ let pathname = String(value).split('#')[0].split('?')[0];
12
+ if (!pathname) return null;
13
+ if (!pathname.startsWith('/')) pathname = `/${pathname}`;
14
+ pathname = pathname.replace(/\/{2,}/g, '/');
15
+ pathname = pathname.replace(/\/index\.html$/i, '/').replace(/\.html$/i, '');
16
+ if (pathname !== '/') pathname = pathname.replace(/\/+$/, '');
17
+ return pathname || '/';
18
+ }
@@ -0,0 +1,9 @@
1
+ import { run } from './process.mjs';
2
+
3
+ export const COSMO_PACKAGE = '@archangel70/cosmo';
4
+
5
+ export async function updateCosmo({ runner = run } = {}) {
6
+ const specification = `${COSMO_PACKAGE}@latest`;
7
+ await runner('npm', ['install', '--global', specification]);
8
+ return { packageName: COSMO_PACKAGE, specification };
9
+ }
@@ -14,10 +14,20 @@ export function collectProjectStatus(projectDir) {
14
14
  const workflow = readWorkflowState(projectDir, { required: false })?.data ?? null;
15
15
  const intelligence = readIntelligence(projectDir);
16
16
  const lock = readIntelligenceLock(projectDir).data;
17
- const plan = json(path.join(projectDir, '.cosmo', 'build-plan.json'));
17
+ const plan = project.sourceModel === 'native-astro'
18
+ ? json(path.join(projectDir, '.cosmo', 'adoption', 'route-inventory.json'))
19
+ : json(path.join(projectDir, '.cosmo', 'build-plan.json'));
18
20
  const progress = json(path.join(projectDir, '.cosmo', 'progress.json'));
19
21
  const entityMapEnabled = json(path.join(projectDir, '.cosmo', 'entities', 'config.json'))?.enabled === true;
20
- const reportNames = ['integrity-check', 'content-check', 'intelligence-check', 'site-check', 'browser-check', ...(fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : []), ...(entityMapEnabled ? ['entity-check'] : [])];
22
+ const nativeAdoption = project.sourceModel === 'native-astro';
23
+ const reportNames = [
24
+ ...(nativeAdoption ? [] : ['integrity-check', 'content-check']),
25
+ 'intelligence-check',
26
+ 'site-check',
27
+ 'browser-check',
28
+ ...(!nativeAdoption && fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : []),
29
+ ...(entityMapEnabled ? ['entity-check'] : []),
30
+ ];
21
31
  const qa = Object.fromEntries(reportNames.map((name) => {
22
32
  const report = json(path.join(projectDir, '.cosmo', 'reports', `${name}.json`));
23
33
  return [name, report ? { passed: report.passed, checkedAt: report.checkedAt ?? report.auditedAt ?? null } : null];
@@ -39,8 +49,8 @@ export function collectProjectStatus(projectDir) {
39
49
  version: 1, project, workflow,
40
50
  brandDiscovery: json(path.join(projectDir, '.cosmo', 'brand', 'discovery.json'))?.approved === true ? 'approved' : 'incomplete',
41
51
  intelligence: { profile: intelligence.data.profile, packs: intelligence.data.packs, installedPackages: lock.packages.map((item) => ({ id: item.id, version: item.version })) },
42
- plan: plan ? { version: plan.version, approved: plan.approved, pages: plan.pages?.length ?? 0 } : null,
43
- generation: progress ? { complete: progress.complete, pages: Array.isArray(progress.pages) ? progress.pages.length : Object.keys(progress.pages ?? {}).length } : null,
52
+ plan: plan ? { version: plan.version, approved: plan.approved, pages: (plan.pages ?? plan.routes)?.length ?? 0, sourceModel: project.sourceModel ?? 'cosmo-content', routeFormat: plan.routeFormat ?? null } : null,
53
+ generation: !nativeAdoption && progress ? { complete: progress.complete, pages: Array.isArray(progress.pages) ? progress.pages.length : Object.keys(progress.pages ?? {}).length } : null,
44
54
  entityMap: { enabled: entityMapEnabled },
45
55
  qa, release,
46
56
  deployment: deployment ? { provider: deployment.provider, latest: latestDeployment } : null,
@@ -92,6 +92,7 @@ export function validateWorkflow(value) {
92
92
  assert(value.version === 1, 'Workflow version must be 1.');
93
93
  assert(typeof value.id === 'string' && /^[a-z0-9][a-z0-9-]*$/.test(value.id), 'Workflow id must be kebab-case.');
94
94
  assert(typeof value.name === 'string' && value.name.trim(), 'Workflow name is required.');
95
+ if (value.mode !== undefined) assert(['build', 'adopted'].includes(value.mode), 'Workflow mode must be build or adopted.');
95
96
  assert(Array.isArray(value.stages) && value.stages.length > 0, 'Workflow must contain stages.');
96
97
 
97
98
  const ids = new Set();
@@ -193,11 +194,12 @@ export function readWorkflowState(projectDir, { required = true } = {}) {
193
194
  return { file, data: state };
194
195
  }
195
196
 
196
- export function startWorkflow(projectDir, workflowId = 'default') {
197
- readProject(projectDir);
197
+ export function startWorkflow(projectDir, workflowId) {
198
+ const project = readProject(projectDir).data;
198
199
  const existing = readWorkflowState(projectDir, { required: false });
199
200
  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 selectedWorkflow = workflowId ?? (project.sourceModel === 'native-astro' ? 'adopted' : 'default');
202
+ const { data: workflow } = loadWorkflow(projectDir, selectedWorkflow);
201
203
  const now = new Date().toISOString();
202
204
  const stages = Object.fromEntries(workflow.stages.map((stage, index) => [stage.id, {
203
205
  status: index === 0 ? 'in_progress' : 'pending',
@@ -247,7 +249,7 @@ export function submitStage(projectDir, stageId) {
247
249
  } catch (error) {
248
250
  throw new WorkflowError(error.message);
249
251
  }
250
- if (stageId === 'plan') {
252
+ if (stageId === 'plan' && workflow.mode !== 'adopted') {
251
253
  readPlan(projectDir);
252
254
  checkIntegrity(projectDir);
253
255
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.11.0"
3
+ "version": "1.13.0"
4
4
  }
@@ -48,7 +48,7 @@ Run `cosmo doctor .` and `cosmo status . --json`. Read `HANDOFF.md` when present
48
48
 
49
49
  ## Adopt an Astro site
50
50
 
51
- Inventory the existing Astro configuration, routes, content, source, public files, and build command. Explain that adoption adds Cosmo governance without replacing the site. After explicit confirmation, collect the brand, site URL, capability profile, and design mode, then run `cosmo adopt`, install dependencies if needed, run `cosmo doctor .`, and start discovery. Do not restructure existing code before the user approves a plan.
51
+ Inventory the existing Astro configuration, routes, content, source, public files, build format, and build command. Explain that adoption adds Cosmo governance without replacing the site. After explicit confirmation, collect the brand, site URL, capability profile, and design mode, then run `cosmo adopt`, install dependencies if needed, run `cosmo doctor .`, and start the native-preservation workflow. Existing `.astro` pages, layouts, components, styles, design, and URL format remain authoritative. Never convert an adopted site to `src/content/pages`, `PageView`, `SectionRenderer`, or Cosmo section components unless the user explicitly requests that redesign.
52
52
 
53
53
  ## Create a new site
54
54
 
@@ -66,7 +66,7 @@ For every stage:
66
66
  4. Run the relevant deterministic checks.
67
67
  5. Present approval-stage results and wait for explicit approval.
68
68
 
69
- Before page writing, run `cosmo copy guide <page-id> .`. Keep supplied, observed, inferred, and unknown information distinct. Do not imitate living writers, reproduce source language, fabricate reader psychology, or make unsupported attacks on alternatives. Explore at least three genuinely different visual directions and store the approved choice in `DESIGN-DIRECTION.md`, tokens, components, and Cosmo design artifacts.
69
+ Before page writing in a generated-content project, run `cosmo copy guide <page-id> .`. For a native adopted site, edit its existing source only when authorized and preserve its approved design baseline. Keep supplied, observed, inferred, and unknown information distinct. Do not imitate living writers, reproduce source language, fabricate reader psychology, or make unsupported attacks on alternatives. For new builds, explore at least three genuinely different visual directions and store the approved choice in `DESIGN-DIRECTION.md`, tokens, components, and Cosmo design artifacts.
70
70
 
71
71
  Advance generation one state at a time. After two failed repair cycles, leave the page for human review. For release, run the build plus Copy Studio, content, intelligence, integrity, EntityMap when enabled, static, browser, and release checks. Deploy production only when the exact current release reports READY.
72
72
 
@@ -77,3 +77,5 @@ Any supported agent may continue the project. Before switching, run appropriate
77
77
  ## Help
78
78
 
79
79
  When asked what Cosmo can do, lead with four choices: build a new website, continue a Cosmo website, improve an existing Astro website, or review/publish a website. Show the simple journey `Discover → Brand → Design → Copy and page plan → Build → Quality checks → Preview and launch`. Mention advanced capabilities only if relevant or requested, and end with one clear question.
80
+
81
+ When the user asks to update Cosmo itself, run `cosmo update`. Explain that it updates the global npm package and agent launchers but does not modify website projects. Afterward, ask the user to restart their assistant.
@@ -1,4 +1,4 @@
1
- <!-- cosmo-agent-version: 1.11.0 -->
1
+ <!-- cosmo-agent-version: 1.13.0 -->
2
2
  # Cosmo
3
3
 
4
4
  Use the Cosmo website-building workflow in the current workspace.
@@ -7,6 +7,9 @@ If the user invokes `/cosmo` without a specific task, do not print the command r
7
7
 
8
8
  First, look for `.agents/skills/cosmo/SKILL.md` and follow it completely when present. If it is absent, apply these minimum rules:
9
9
 
10
+ - If the user asks to update Cosmo itself, run `cosmo update`; this refreshes Cosmo and its agent launchers without changing website projects.
11
+ - For an existing Astro site, use native-preservation adoption. Keep its pages, components, design, and URL format; do not force conversion to Cosmo's generated Markdown architecture.
12
+
10
13
  - Run `cosmo --version` and inspect the directory before changing anything.
11
14
  - Resume when `.cosmo/project.json` exists.
12
15
  - Offer adoption when an Astro project exists without `.cosmo/project.json`.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Conversational launcher for starting, adopting, and resuming local-first Cosmo Astro website builds.",
5
5
  "author": {
6
6
  "name": "Cosmo"
@@ -25,7 +25,7 @@ When the user's request is only `cosmo`, do not execute bare `cosmo` and paste i
25
25
 
26
26
  - Empty folder: explain that Cosmo will guide discovery, brand, design, copy, Astro development, QA, and launch. Ask only for the business/project name and what it does.
27
27
  - Existing Cosmo project: recover the saved stage, summarize completed approvals, and state the single next decision or action.
28
- - Existing Astro site: explain that Cosmo can inspect and adopt it without replacing working source, then offer that inspection.
28
+ - Existing Astro site: explain that Cosmo can inspect and adopt it in native-preservation mode without replacing its pages, components, design, or URL format, then offer that inspection.
29
29
  - Other non-empty folder: explain that a new website needs a separate child folder and ask what it should be called.
30
30
 
31
31
  Use a progress line at every transition: `Step N of 7 — <plain-language phase>`, followed by what was completed and what happens next. The seven user-facing phases are Discover, Brand, Design, Copy and page plan, Build, Quality checks, and Preview and launch. Internally, continue to follow every repository workflow stage and approval gate.
@@ -132,4 +132,6 @@ For design, explore at least three genuinely distinct directions and preserve th
132
132
 
133
133
  ## Help mode
134
134
 
135
- If the user asks what Cosmo can do, lead with four choices: build a new website, continue a Cosmo website, improve an existing Astro website, or review/publish a website. Show the simple journey `Discover → Brand → Design → Copy and page plan → Build → Quality checks → Preview and launch`. Mention advanced capabilities only if relevant or requested, and end with one clear question.
135
+ If the user asks what Cosmo can do, lead with four choices: build a new website, continue a Cosmo website, improve an existing Astro website without converting it, or review/publish a website. Show the simple journey `Discover → Brand → Design → Copy and page plan → Build → Quality checks → Preview and launch`. Mention advanced capabilities only if relevant or requested, and end with one clear question.
136
+
137
+ If the user asks to update Cosmo itself, run `cosmo update`. Explain that it updates the global npm package and agent launchers without modifying website projects, then ask the user to restart Claude Code.
@@ -9,12 +9,14 @@ Treat the repository—not previous chat history—as the source of truth. Run `
9
9
 
10
10
  Never invent business facts, audience observations, evidence, research, credentials, testimonials, results, service coverage, or approval. Never weaken a policy or edit runtime state to make a gate pass. Keep secrets in environment variables or an ignored runtime environment file.
11
11
 
12
- If `.cosmo/project.json` is absent, inspect before acting: offer `cosmo adopt` for an existing Astro site, use `cosmo init` only in an empty directory, and never overwrite unrelated files.
12
+ If `.cosmo/project.json` is absent, inspect before acting: offer `cosmo adopt` for an existing Astro site, use `cosmo init` only in an empty directory, and never overwrite unrelated files. Native adopted sites preserve their existing `.astro` pages, components, design, and URL format; never force them into Cosmo's Markdown and section-renderer architecture.
13
13
 
14
14
  For a new project, ask whether the user wants an AI-readable EntityMap. It is optional, works without paid APIs, and must remain `generator-draft` until the user explicitly reviews it. When selected, initialize with `--entity-map`; never accept enrichment candidates or approve the map for the user.
15
15
 
16
- At each stage, read the contract and selected intelligence guidance, explain the immediate decision, create repository-owned artifacts, run the relevant checks, and wait for explicit user approval where required. Use `cosmo copy guide <page-id> .` before page writing. Keep facts, observations, inferences, and unknowns distinct. Explore at least three genuinely different visual directions; Claude Design is optional, and any capable design authority may satisfy the same repository-owned design contract.
16
+ At each stage, read the contract and selected intelligence guidance, explain the immediate decision, create repository-owned artifacts, run the relevant checks, and wait for explicit user approval where required. Use `cosmo copy guide <page-id> .` before page writing in generated-content projects. In a native adoption, work from the existing source and frozen design baseline. Keep facts, observations, inferences, and unknowns distinct. Explore at least three genuinely different visual directions for new builds; Claude Design is optional, and any capable design authority may satisfy the same repository-owned design contract.
17
17
 
18
18
  Advance generation one state at a time. After two unsuccessful repair cycles, leave the page for human review. Run `cosmo entity check .` during QA when EntityMap is enabled. Require the exact release to report READY before production deployment.
19
19
 
20
20
  When switching tools, create a durable handoff with `cosmo handoff create . --from <current-agent> --to <next-agent> --note "<summary and open decisions>"`. The next agent must continue from repository state.
21
+
22
+ If the user asks to update Cosmo itself, run `cosmo update`. It updates the global package and agent launchers, never this website's files. Ask the user to restart their assistant when it finishes.
@@ -0,0 +1,83 @@
1
+ {
2
+ "version": 1,
3
+ "id": "adopted",
4
+ "mode": "adopted",
5
+ "name": "Cosmo native Astro preservation",
6
+ "description": "Govern and verify an existing Astro site without converting its pages, routes, components, or visual system to Cosmo's generated content model.",
7
+ "stages": [
8
+ {
9
+ "id": "intake",
10
+ "type": "core",
11
+ "title": "Existing-site intake",
12
+ "instructions": "Capture the business, audience, goals, maintenance scope, evidence, and constraints. Record design or URL changes as prohibited unless the user explicitly authorizes them.",
13
+ "approval": false,
14
+ "expects": [{ "path": ".cosmo/intake.json", "kind": "json", "requiredKeys": ["version", "business.name", "business.niche", "audience.summary", "goals", "scope.pageTarget", "designMode"], "nonEmptyKeys": ["business.name", "business.niche", "audience.summary", "goals", "designMode"] }]
15
+ },
16
+ {
17
+ "id": "brand",
18
+ "type": "core",
19
+ "title": "Existing brand and evidence",
20
+ "instructions": "Document the brand, voice, claims, and evidence already present. Do not rewrite approved site copy or invent proof.",
21
+ "approval": true,
22
+ "expects": [
23
+ "BRAND-BRIEF.md",
24
+ { "path": ".cosmo/brand/discovery.json", "kind": "json", "requiredKeys": ["version", "approved", "prompts", "synthesis"], "equals": { "approved": true }, "nonEmptyKeys": ["prompts", "synthesis"] },
25
+ { "path": ".cosmo/brand/entity-canon.json", "kind": "json", "requiredKeys": ["version", "id", "officialName", "domain", "descriptions.short", "descriptions.long", "category", "services", "audiences"], "nonEmptyKeys": ["id", "officialName", "domain", "descriptions.short", "descriptions.long", "category"] },
26
+ { "path": ".cosmo/brand/voice-profile.json", "kind": "json", "requiredKeys": ["version", "entityId", "maturity", "markers", "weAre", "weAreNot", "register"], "nonEmptyKeys": ["entityId", "maturity", "markers", "weAre", "weAreNot", "register"] },
27
+ { "path": ".cosmo/evidence.json", "kind": "json", "requiredKeys": ["version", "entityId", "claims", "proofs"] }
28
+ ]
29
+ },
30
+ {
31
+ "id": "design",
32
+ "type": "core",
33
+ "title": "Frozen design baseline",
34
+ "instructions": "Inventory and approve the existing visual system as the preservation baseline. Do not introduce Cosmo components, tokens, or a new design direction.",
35
+ "approval": true,
36
+ "expects": [{ "path": ".cosmo/adoption/design-baseline.json", "kind": "json", "requiredKeys": ["version", "policy", "approved", "notes"], "equals": { "policy": "preserve", "approved": true }, "nonEmptyKeys": ["notes"] }]
37
+ },
38
+ {
39
+ "id": "homepage",
40
+ "type": "core",
41
+ "title": "Existing page baseline",
42
+ "instructions": "Review the existing page-source inventory, including the homepage, without moving pages into src/content or re-rendering them.",
43
+ "approval": true,
44
+ "expects": [{ "path": ".cosmo/adoption/page-baseline.json", "kind": "json", "requiredKeys": ["version", "reviewed", "notes"], "equals": { "reviewed": true }, "nonEmptyKeys": ["notes"] }]
45
+ },
46
+ {
47
+ "id": "template",
48
+ "type": "core",
49
+ "title": "Existing component baseline",
50
+ "instructions": "Review the site's current layouts and components as-is. Reuse its architecture; do not require PageView, SectionRenderer, or Cosmo section components.",
51
+ "approval": true,
52
+ "expects": [{ "path": ".cosmo/adoption/component-baseline.json", "kind": "json", "requiredKeys": ["version", "preserveExisting", "reviewed", "notes"], "equals": { "preserveExisting": true, "reviewed": true }, "nonEmptyKeys": ["notes"] }]
53
+ },
54
+ {
55
+ "id": "plan",
56
+ "type": "core",
57
+ "title": "Existing route inventory",
58
+ "instructions": "Approve the discovered native Astro route inventory and current URL format. Do not replace it with Cosmo Markdown content files or change live URLs merely to satisfy tooling.",
59
+ "approval": true,
60
+ "expects": [{ "path": ".cosmo/adoption/route-inventory.json", "kind": "json", "requiredKeys": ["version", "routeFormat", "approved", "routes"], "equals": { "approved": true }, "nonEmptyKeys": ["routes"] }]
61
+ },
62
+ {
63
+ "id": "generate",
64
+ "type": "core",
65
+ "title": "Scoped maintenance record",
66
+ "instructions": "Record only user-approved changes. An unchanged site is valid; page generation is not required for a native adopted site.",
67
+ "approval": false,
68
+ "expects": [{ "path": ".cosmo/adoption/change-record.json", "kind": "json", "requiredKeys": ["version", "reviewed", "changes"], "equals": { "reviewed": true } }]
69
+ },
70
+ {
71
+ "id": "qa",
72
+ "type": "core",
73
+ "title": "Rendered-site QA",
74
+ "instructions": "Build the unchanged Astro source and run static HTML, link, accessibility, responsive, runtime, intelligence, and browser checks against the rendered output.",
75
+ "approval": true,
76
+ "expects": [
77
+ { "path": ".cosmo/reports/intelligence-check.json", "kind": "json", "requiredKeys": ["passed", "summary.blocking", "summary.warnings"], "equals": { "passed": true } },
78
+ { "path": ".cosmo/reports/site-check.json", "kind": "json", "requiredKeys": ["passed", "summary.pages", "summary.critical"], "equals": { "passed": true } },
79
+ { "path": ".cosmo/reports/browser-check.json", "kind": "json", "requiredKeys": ["passed", "summary.routes", "summary.renders", "summary.critical"], "equals": { "passed": true } }
80
+ ]
81
+ }
82
+ ]
83
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmo/astro-starter",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {