@archangel70/cosmo 1.10.0 → 1.12.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 (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +48 -5
  3. package/docs/ARCHITECTURE.md +3 -0
  4. package/docs/DELIVERY.md +2 -1
  5. package/docs/ENTITY-MAP.md +87 -0
  6. package/docs/ROADMAP.md +9 -0
  7. package/package.json +5 -2
  8. package/packages/cli/bin/cosmo.mjs +97 -3
  9. package/packages/cli/lib/adoption.mjs +3 -0
  10. package/packages/cli/lib/audit.mjs +16 -0
  11. package/packages/cli/lib/browser-audit.mjs +1 -0
  12. package/packages/cli/lib/delivery.mjs +3 -2
  13. package/packages/cli/lib/entity-map.mjs +408 -0
  14. package/packages/cli/lib/integrity.mjs +6 -0
  15. package/packages/cli/lib/project.mjs +2 -0
  16. package/packages/cli/lib/self-update.mjs +9 -0
  17. package/packages/cli/lib/status.mjs +3 -1
  18. package/plugins/agent-skills/cosmo/.cosmo-agent.json +1 -1
  19. package/plugins/agent-skills/cosmo/SKILL.md +4 -2
  20. package/plugins/antigravity/cosmo.md +4 -1
  21. package/plugins/claude-code/cosmo/.claude-plugin/plugin.json +1 -1
  22. package/plugins/claude-code/cosmo/agents/cosmo.md +2 -0
  23. package/plugins/claude-code/cosmo/skills/cosmo/SKILL.md +6 -3
  24. package/templates/astro-site/.agents/skills/cosmo/SKILL.md +5 -1
  25. package/templates/astro-site/.cosmo/capabilities/registry.json +2 -1
  26. package/templates/astro-site/.cosmo/entities/candidates.json +5 -0
  27. package/templates/astro-site/.cosmo/entities/config.json +28 -0
  28. package/templates/astro-site/.env.example +6 -0
  29. package/templates/astro-site/AGENTS.md +3 -2
  30. package/templates/astro-site/CLAUDE.md +3 -2
  31. package/templates/astro-site/astro.config.mjs +5 -1
  32. package/templates/astro-site/package.json +1 -1
  33. package/templates/astro-site/src/layouts/BaseLayout.astro +3 -0
  34. package/templates/astro-site/src/pages/robots.txt.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable Cosmo changes are recorded here.
4
4
 
5
+ ## 1.12.0 — One-command updates
6
+
7
+ - Added `cosmo update` to install the latest public npm release without requiring users to remember the package name.
8
+ - Refreshes the Claude, Codex, and Antigravity launchers through the normal Cosmo installation process while leaving website projects untouched.
9
+ - Rewrote the beginner update instructions around the new command and retained the npm command as a troubleshooting fallback.
10
+
11
+ ## 1.11.0 — Evidence-controlled EntityMap
12
+
13
+ - Added optional EntityMap v1.0 generation from the Entity Canon and eligible final Astro content.
14
+ - Added public JSON and HTML companions, page-head, footer, robots.txt, and sitemap discovery.
15
+ - Added deterministic validation for attribution, entity types, stable identifiers, chunks, relationships, source URLs, and review state.
16
+ - Added private, human-reviewed enrichment candidates from Wikidata, Google Knowledge Graph, Google Places, and TextRazor.
17
+ - Kept the feature functional without paid APIs and prevented external matches from overwriting canonical project truth.
18
+ - Added explicit named review before generated output may change from `generator-draft` to `self-declared`.
19
+
5
20
  ## 1.10.0 — Guided start
6
21
 
7
22
  - Replaced the bare `cosmo` command dump with a friendly, context-aware start screen and an explicit `cosmo help` developer reference.
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.10.0**
7
+ Current version: **1.12.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.10.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
85
+ You should see `1.12.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.10.0` or a newer version. Cosmo automatically installs its Cla
99
99
  cosmo --version
100
100
  ```
101
101
 
102
- You should see `1.10.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
102
+ You should see `1.12.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
 
@@ -144,6 +144,8 @@ Cosmo and your chosen assistant will guide you through these stages:
144
144
 
145
145
  Cosmo pauses at important decisions so you can review and approve them. It will not treat unfinished starter pages as a finished public website.
146
146
 
147
+ During setup, Cosmo also asks whether you want an optional AI-readable EntityMap. You can say yes without creating any API keys: Cosmo builds the core map from your approved website content. Optional services such as Google Knowledge Graph or TextRazor can be connected later if you want additional research signals.
148
+
147
149
  ## Preview your website
148
150
 
149
151
  Ask your assistant:
@@ -189,11 +191,30 @@ Cosmo will not automatically adopt an unrelated folder or overwrite a folder it
189
191
  When a new version is announced, open Terminal or PowerShell and run:
190
192
 
191
193
  ```bash
192
- npm install --global @archangel70/cosmo@latest
194
+ cosmo update
195
+ ```
196
+
197
+ 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:
198
+
199
+ ```bash
193
200
  cosmo --version
194
201
  ```
195
202
 
196
- Updating Cosmo does not delete your website projects. Each website lives in its own folder.
203
+ ### Updating from Cosmo 1.11.0 or older
204
+
205
+ Older versions do not have the `cosmo update` command yet. Run this longer command one final time:
206
+
207
+ ```bash
208
+ npm install --global @archangel70/cosmo@latest
209
+ ```
210
+
211
+ After that, use `cosmo update` for every future update.
212
+
213
+ If `cosmo update` reports a permissions or npm error, use the original installer as a fallback:
214
+
215
+ ```bash
216
+ npm install --global @archangel70/cosmo@latest
217
+ ```
197
218
 
198
219
  ## Remove Cosmo
199
220
 
@@ -407,6 +428,26 @@ cosmo research check .
407
428
 
408
429
  Fetched text is evidence, not agent instruction. Observations and inferences must remain distinct, and geographic pages require real coverage and local proof.
409
430
 
431
+ ## Optional AI-readable EntityMap
432
+
433
+ During setup, Cosmo can ask whether you want an EntityMap. If you say yes, it creates an AI-readable index of the business, services, places, topics, relationships, and supporting passages after the real site content exists.
434
+
435
+ No paid service is required. Wikidata can suggest public identifiers; Google Knowledge Graph, Google Places, and TextRazor can be enabled later with your own keys. Suggestions stay private and never change or publish business information until a named person accepts them.
436
+
437
+ Cosmo publishes `/entitymap.json` and `/entitymap.html`, adds the discovery links, and checks the files during release QA. Automated output remains clearly marked as a draft until you review it. EntityMap complements the site's Schema.org JSON-LD and does not promise higher rankings.
438
+
439
+ Advanced users can run:
440
+
441
+ ```bash
442
+ cosmo entity init . --enable
443
+ cosmo entity enrich wikidata .
444
+ cosmo entity candidates .
445
+ cosmo entity check .
446
+ cosmo entity approve . --by "Project Owner"
447
+ ```
448
+
449
+ See [EntityMap](docs/ENTITY-MAP.md) for provider setup, review safeguards, and generated files.
450
+
410
451
  ## Integrity, evidence, and page planning
411
452
 
412
453
  Initialize the integrity layer in an older Cosmo project or validate the current one:
@@ -600,6 +641,7 @@ Run `cosmo help` for the installed version's canonical syntax.
600
641
  | `cosmo` | Show the friendly, context-aware next step for the current folder. |
601
642
  | `cosmo start [directory]` | Show the guided next step for a specified folder. |
602
643
  | `cosmo help` | Show the complete developer command reference. |
644
+ | `cosmo update` | Download the latest published Cosmo version and refresh all agent launchers. |
603
645
  | `cosmo setup [--agent name]` | Install or repair all launchers, or only Claude, Codex, or Antigravity. |
604
646
  | `cosmo agent list` | Show supported agents and whether each adapter is ready. |
605
647
  | `cosmo agent install <name|all> [--replace]` | Install or update one or every agent adapter. |
@@ -704,6 +746,7 @@ Browser options are `--no-build` and `--no-lighthouse`. Remote deployment accept
704
746
  | `.cosmo/brand/` | Discovery, Entity Canon, and voice profile. |
705
747
  | `.cosmo/copy/strategy.json` | Approved reader, positioning, voice, proof, and competitive-transition strategy. |
706
748
  | `.cosmo/evidence.json` | Central claim and proof ledger. |
749
+ | `.cosmo/entities/` | EntityMap configuration, optional provider settings, accepted matches, and private candidates. |
707
750
  | `.cosmo/intelligence/` | Active packs, artifacts, and private-package locks. |
708
751
  | `.cosmo/build-plan.json` | Typed page architecture and link graph. |
709
752
  | `.cosmo/work/pages/` | Per-page integrity briefs, Copy Studio briefs, and production artifacts. |
@@ -24,6 +24,7 @@ Cosmo is a local orchestrator and validator. A generated Astro repository remain
24
24
  | Pipeline state | Local `.cosmo/*.json` artifacts |
25
25
  | Entity identity and voice | `.cosmo/brand/entity-canon.json` and `.cosmo/brand/voice-profile.json` |
26
26
  | Claims, proof, and provenance | `.cosmo/evidence.json` |
27
+ | AI-readable entity publication | `.cosmo/entities/config.json`, accepted matches, canonical content, and EntityMap QA |
27
28
  | Page purpose and site graph | Plan v3 architecture contract and its derived page brief |
28
29
  | Optional domain and creative intelligence | `.cosmo/intelligence/selection.json`, selected pack manifests, and completed pack artifacts |
29
30
  | Release deployment | Optional provider config plus the exact READY release ID; provider credentials remain external |
@@ -61,6 +62,8 @@ The seed carries a neutral home/about graph, keeps every route `noindex`, and ma
61
62
 
62
63
  `cosmo content check` validates project-wide semantic contracts: canonical entity id, Plan v3 intent fidelity, governed links, voice boundaries, proof verification and provenance, generic and manipulative language policy, duplicated passages, and qualitative substance tiers. Its rules live in `.cosmo/policies/content-integrity.json`; the output is `.cosmo/reports/content-check.json`.
63
64
 
65
+ When enabled, `cosmo entity check` compiles EntityMap v1.0 from the Entity Canon and eligible final content. External services may suggest identifiers, but their candidates remain non-public until a named reviewer accepts them. The resulting JSON, HTML companion, discovery declarations, and QA report become part of release readiness without replacing Schema.org JSON-LD.
66
+
64
67
  `cosmo check` builds the site and inspects generated HTML for:
65
68
 
66
69
  - Missing or duplicate titles, descriptions, and H1s.
package/docs/DELIVERY.md CHANGED
@@ -14,7 +14,7 @@ A project is ready only when all of the following are true:
14
14
  - The Build Plan is approved and at least one route is explicitly indexable.
15
15
  - The workflow is complete, including every approval.
16
16
  - Generation is complete for the approved inventory.
17
- - Integrity, content, intelligence, static, and browser reports all pass.
17
+ - Integrity, content, intelligence, static, browser, and enabled EntityMap reports all pass.
18
18
  - Every report is newer than the source and portable Cosmo inputs it validates.
19
19
  - The intelligence report was produced for the currently selected packs.
20
20
 
@@ -28,6 +28,7 @@ cosmo integrity check .
28
28
  cosmo check . --no-build
29
29
  cosmo content check .
30
30
  cosmo intelligence check .
31
+ cosmo entity check .
31
32
  cosmo browser check . --no-build
32
33
  cosmo release check .
33
34
  cosmo release show .
@@ -0,0 +1,87 @@
1
+ # EntityMap
2
+
3
+ Cosmo can create an optional [EntityMap v1.0](https://entitymap.org/spec/v1.0) for a finished website. It describes the publisher, subjects, services, places, relationships, and short supporting passages in an AI-readable form.
4
+
5
+ EntityMap is an emerging publisher-assertion standard. It complements Schema.org JSON-LD, sitemaps, and visible content; it does not replace them and Cosmo does not promise a search-ranking benefit.
6
+
7
+ ## Plain-language workflow
8
+
9
+ When beginning a site, the assistant asks whether the user wants an EntityMap. If selected, Cosmo:
10
+
11
+ 1. Reads approved identity from the Entity Canon.
12
+ 2. Reads eligible final pages and their primary topics.
13
+ 3. Selects concise, extractive passages from those pages.
14
+ 4. Builds `/entitymap.json` and `/entitymap.html`.
15
+ 5. adds discovery through the page head, footer, robots.txt, and sitemap.
16
+ 6. Checks attribution, identifiers, types, relationships, URLs, and chunk limits.
17
+ 7. Leaves automated output marked `generator-draft` until the user explicitly reviews it.
18
+
19
+ Only indexable pages are included by default. Set `includeNoindex` only after deciding that publicly accessible noindex pages should be represented.
20
+
21
+ ## Commands for advanced users
22
+
23
+ ```bash
24
+ cosmo entity init . --enable
25
+ cosmo entity build .
26
+ cosmo entity check .
27
+ cosmo entity approve . --by "Project Owner"
28
+ ```
29
+
30
+ Approval records the reviewer and time, then changes the public status to `self-declared`. It never claims third-party certification.
31
+
32
+ ## Optional enrichment
33
+
34
+ Wikidata is enabled by default and does not require a key. Google Knowledge Graph, Google Places, and TextRazor are available but disabled until the user chooses them.
35
+
36
+ Provider settings live in `.cosmo/entities/config.json`. Keys belong in a local ignored environment file:
37
+
38
+ ```dotenv
39
+ COSMO_GOOGLE_KG_API_KEY=
40
+ COSMO_GOOGLE_PLACES_API_KEY=
41
+ COSMO_TEXTRAZOR_API_KEY=
42
+ ```
43
+
44
+ Run one provider at a time:
45
+
46
+ ```bash
47
+ cosmo entity enrich wikidata .
48
+ cosmo entity enrich googleKnowledgeGraph . --env-file .env.local
49
+ cosmo entity enrich googlePlaces . --env-file .env.local
50
+ cosmo entity enrich textRazor . --env-file .env.local
51
+ cosmo entity candidates .
52
+ ```
53
+
54
+ External responses are reduced to candidate identifiers, labels, URLs, descriptions, scores, provider names, and retrieval dates. They do not overwrite the Entity Canon and are not published automatically.
55
+
56
+ After the user confirms a match, record that decision:
57
+
58
+ ```bash
59
+ cosmo entity accept candidate-0123456789abcdef . --by "Project Owner"
60
+ ```
61
+
62
+ Only accepted Wikidata or Wikipedia matches are eligible for a public `sameAs` field. Other accepted provider identifiers remain internal corroboration.
63
+
64
+ ## Accuracy hierarchy
65
+
66
+ Cosmo resolves disagreements in this order:
67
+
68
+ 1. User-confirmed first-party information.
69
+ 2. Official documents and registries.
70
+ 3. Captured primary-source research.
71
+ 4. External knowledge APIs.
72
+ 5. NLP extraction.
73
+ 6. AI inference, which remains a candidate until reviewed.
74
+
75
+ An absent Google or Wikidata result is never treated as proof that a business, person, service, or concept does not exist.
76
+
77
+ ## Repository files
78
+
79
+ | Path | Purpose |
80
+ | --- | --- |
81
+ | `.cosmo/entities/config.json` | Feature status, review record, accepted matches, and provider settings. |
82
+ | `.cosmo/entities/candidates.json` | Private enrichment suggestions and their review state. |
83
+ | `.cosmo/reports/entity-check.json` | Deterministic conformance and integrity report. |
84
+ | `public/entitymap.json` | Generated machine-readable publication. |
85
+ | `public/entitymap.html` | Generated human- and crawler-readable companion. |
86
+
87
+ The two public files are generated artifacts. Edit canonical identity and page content instead of maintaining them by hand.
package/docs/ROADMAP.md CHANGED
@@ -185,6 +185,15 @@ The acceptance pilot completed five generation entries, static and browser QA wi
185
185
  - Backward-compatible Claude commands and durable handoffs between any named agents.
186
186
  - Adapter conformance, starter, adoption, and packed-install smoke coverage.
187
187
 
188
+ ## Milestone 20 — v1.11 evidence-controlled EntityMap (complete)
189
+
190
+ - Optional EntityMap v1.0 generation from canonical identity and eligible final page content.
191
+ - Machine-readable JSON and human-readable HTML companions with head, footer, robots, and sitemap discovery.
192
+ - Draft-versus-reviewed publication status with named human review and no fabricated certification.
193
+ - No-key Wikidata enrichment plus optional Google Knowledge Graph, Google Places, and TextRazor adapters.
194
+ - Private candidate review that prevents external services from overwriting the Entity Canon.
195
+ - EntityMap conformance, attribution, relationship, source, and freshness checks integrated into release readiness.
196
+
188
197
  ## Later, only when justified
189
198
 
190
199
  - Additional deployment adapters, including Cloudflare Workers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archangel70/cosmo",
3
- "version": "1.10.0",
3
+ "version": "1.12.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",
@@ -17,6 +17,7 @@
17
17
  "templates/astro-site/.cosmo/build-plan.json",
18
18
  "templates/astro-site/.cosmo/capabilities/**",
19
19
  "templates/astro-site/.cosmo/evidence.json",
20
+ "templates/astro-site/.cosmo/entities/**",
20
21
  "templates/astro-site/.cosmo/intelligence/selection.json",
21
22
  "templates/astro-site/.cosmo/policies/**",
22
23
  "templates/astro-site/.cosmo/project.json",
@@ -49,6 +50,7 @@
49
50
  "docs/FIRST-PARTY-CAPABILITIES.md",
50
51
  "docs/GENERATION.md",
51
52
  "docs/INTEGRITY.md",
53
+ "docs/ENTITY-MAP.md",
52
54
  "docs/INTELLIGENCE-PACKS.md",
53
55
  "docs/OPERATIONS.md",
54
56
  "docs/PAGE-PRODUCTION.md",
@@ -78,11 +80,12 @@
78
80
  "content:qa": "node packages/cli/bin/cosmo.mjs content check templates/astro-site",
79
81
  "copy:qa": "node packages/cli/bin/cosmo.mjs copy check templates/astro-site",
80
82
  "intelligence:qa": "node packages/cli/bin/cosmo.mjs intelligence check templates/astro-site",
83
+ "entity:qa": "node packages/cli/bin/cosmo.mjs entity check templates/astro-site",
81
84
  "browser:qa": "node packages/cli/bin/cosmo.mjs browser check templates/astro-site",
82
85
  "package:smoke": "node scripts/smoke-package.mjs",
83
86
  "postinstall": "node scripts/postinstall.mjs",
84
87
  "test": "node --test packages/cli/test/*.test.mjs",
85
- "verify": "npm run test && npm run check && npm run integrity:qa && npm run qa && npm run copy:qa && npm run content:qa && npm run intelligence:qa && npm run browser:qa"
88
+ "verify": "npm run test && npm run check && npm run integrity:qa && npm run entity:qa && npm run qa && npm run copy:qa && npm run content:qa && npm run intelligence:qa && npm run browser:qa"
86
89
  },
87
90
  "dependencies": {
88
91
  "axe-core": "^4.13.0",
@@ -16,6 +16,7 @@ import { diagnoseProject } from '../lib/doctor.mjs';
16
16
  import { configureDeployment, deployProject, readDeploymentConfig, readDeploymentHistory } from '../lib/deployment.mjs';
17
17
  import { evaluateIntelligence, writeIntelligenceReport } from '../lib/intelligence-audit.mjs';
18
18
  import { createHandoff, readHandoff } from '../lib/handoff.mjs';
19
+ import { acceptEntityCandidate, approveEntityMap, enrichEntityMap, readEntityMapConfig, scaffoldEntityMap, writeEntityMap } from '../lib/entity-map.mjs';
19
20
  import { checkIntegrity, createPageBrief, scaffoldIntegrity } from '../lib/integrity.mjs';
20
21
  import { launcherGuide } from '../lib/launcher.mjs';
21
22
  import {
@@ -40,6 +41,7 @@ import {
40
41
  writeJson,
41
42
  } from '../lib/project.mjs';
42
43
  import { run } from '../lib/process.mjs';
44
+ import { updateCosmo } from '../lib/self-update.mjs';
43
45
  import { captureResearchSource, checkResearchWorkbench, scaffoldResearchWorkbench } from '../lib/research.mjs';
44
46
  import { collectProjectStatus } from '../lib/status.mjs';
45
47
  import { planSummary, readPlan } from '../lib/plan.mjs';
@@ -63,7 +65,7 @@ import {
63
65
  workflowSummary,
64
66
  } from '../lib/workflow.mjs';
65
67
 
66
- const VERSION = '1.10.0';
68
+ const VERSION = '1.12.0';
67
69
  const cliDirectory = path.dirname(fileURLToPath(import.meta.url));
68
70
  const templateDirectory = path.resolve(cliDirectory, '../../../templates/astro-site');
69
71
  const [command = 'start', ...rawArgs] = process.argv.slice(2);
@@ -80,13 +82,14 @@ Commands
80
82
  cosmo Show the guided next step for this folder
81
83
  cosmo start [directory] Show the guided next step for another folder
82
84
  cosmo help Show the complete developer command reference
85
+ cosmo update Install the latest Cosmo version and refresh agent launchers
83
86
  cosmo setup [--agent claude|codex|antigravity|all]
84
87
  cosmo agent list
85
88
  cosmo agent install <claude|codex|antigravity|all> [--replace]
86
89
  cosmo agent status [claude|codex|antigravity|all]
87
90
  cosmo agent uninstall <claude|codex|antigravity|all>
88
- cosmo init [directory] [--name slug] [--brand name] [--site url] [--profile id]
89
- cosmo adopt [directory] [--name slug] [--brand name] [--site url] [--profile id] [--design-mode mode]
91
+ cosmo init [directory] [--name slug] [--brand name] [--site url] [--profile id] [--entity-map]
92
+ cosmo adopt [directory] [--name slug] [--brand name] [--site url] [--profile id] [--design-mode mode] [--entity-map]
90
93
  cosmo claude install [--replace]
91
94
  cosmo claude status
92
95
  cosmo claude uninstall
@@ -122,6 +125,13 @@ Commands
122
125
  cosmo research init [directory] [--replace]
123
126
  cosmo research capture <source-id> <snapshot> [directory] --kind type --location value [--captured-at date] [--replace]
124
127
  cosmo research check [directory]
128
+ cosmo entity init [directory] [--enable] [--replace]
129
+ cosmo entity build [directory]
130
+ cosmo entity check [directory]
131
+ cosmo entity enrich <wikidata|googleKnowledgeGraph|googlePlaces|textRazor> [directory] [--env-file path]
132
+ cosmo entity candidates [directory]
133
+ cosmo entity accept <candidate-id> [directory] --by name
134
+ cosmo entity approve [directory] --by name
125
135
  cosmo brief create <page-id> [directory] [--replace]
126
136
  cosmo brief create --all [directory] [--replace]
127
137
  cosmo workflow list [directory]
@@ -161,6 +171,14 @@ function start(args) {
161
171
  console.log(launcherGuide(projectDirectory(positional[0] ?? '.'), VERSION));
162
172
  }
163
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
+
164
182
  async function init(args) {
165
183
  const { options, positional } = parseOptions(args);
166
184
  const target = projectDirectory(positional[0] ?? '.');
@@ -199,6 +217,7 @@ async function init(args) {
199
217
  const evidenceFile = path.join(target, '.cosmo', 'evidence.json');
200
218
  const evidence = JSON.parse(fs.readFileSync(evidenceFile, 'utf8'));
201
219
  writeJson(evidenceFile, { ...evidence, entityId });
220
+ scaffoldEntityMap(target, { enabled: Boolean(options['entity-map']), replace: true });
202
221
  const planFile = path.join(target, '.cosmo', 'build-plan.json');
203
222
  const plan = JSON.parse(fs.readFileSync(planFile, 'utf8'));
204
223
  for (const page of plan.pages) page.contract.strengthensEntity = entityId;
@@ -318,10 +337,17 @@ function setup(args) {
318
337
  if (failed) process.exitCode = 1;
319
338
  }
320
339
 
340
+ function prepareEntityMap(target) {
341
+ const result = writeEntityMap(target);
342
+ if (!result.report.passed) throw new Error(`EntityMap has ${result.report.summary.blocking} blocking finding(s). Run cosmo entity check .`);
343
+ return result;
344
+ }
345
+
321
346
  async function build(args) {
322
347
  const { positional } = parseOptions(args);
323
348
  const target = projectDirectory(positional[0] ?? '.');
324
349
  readProject(target);
350
+ prepareEntityMap(target);
325
351
  await run('npm', ['run', 'build'], { cwd: target });
326
352
  }
327
353
 
@@ -329,6 +355,7 @@ async function dev(args) {
329
355
  const { positional } = parseOptions(args);
330
356
  const target = projectDirectory(positional[0] ?? '.');
331
357
  readProject(target);
358
+ prepareEntityMap(target);
332
359
  await run('npm', ['run', 'dev'], { cwd: target });
333
360
  }
334
361
 
@@ -336,6 +363,7 @@ async function check(args) {
336
363
  const { options, positional } = parseOptions(args);
337
364
  const target = projectDirectory(positional[0] ?? '.');
338
365
  readProject(target);
366
+ prepareEntityMap(target);
339
367
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
340
368
  const report = auditDist(path.join(target, 'dist'));
341
369
  const reportFile = writeAuditReport(target, report);
@@ -441,6 +469,7 @@ async function browserCheck(args) {
441
469
  const { options, positional } = parseOptions(args);
442
470
  const target = projectDirectory(positional[0] ?? '.');
443
471
  readProject(target);
472
+ prepareEntityMap(target);
444
473
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
445
474
  const server = await staticServer(target);
446
475
  const port = server.address().port;
@@ -474,6 +503,7 @@ function status(args) {
474
503
  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` : ''}`);
475
504
  console.log(` plan: ${result.plan ? `${result.plan.pages} pages · ${result.plan.approved ? 'approved' : 'draft'}` : 'missing'}`);
476
505
  console.log(` generation: ${result.generation ? `${result.generation.pages} pages · ${result.generation.complete ? 'complete' : 'active'}` : 'not started'}`);
506
+ console.log(` entity map: ${result.entityMap.enabled ? 'enabled' : 'disabled'}`);
477
507
  console.log(` qa: ${Object.entries(result.qa).map(([name, report]) => `${name.replace('-check', '')}=${report ? report.status ?? (report.passed ? 'passed' : 'failed') : 'missing'}`).join(' ')}`);
478
508
  console.log(` release: ${result.release?.releaseId ?? 'unavailable'} · ${result.release?.ready ? 'ready' : `${result.release?.blocking ?? '?'} blocking`}`);
479
509
  console.log(` deployment: ${result.deployment ? `${result.deployment.provider}${result.deployment.latest ? ` · last ${result.deployment.latest.status}` : ' · never deployed'}` : 'not configured'}`);
@@ -530,6 +560,65 @@ function researchCommand(args) {
530
560
  throw new Error(`Unknown research command: ${subcommand}`);
531
561
  }
532
562
 
563
+ async function entityCommand(args) {
564
+ const subcommand = args[0] ?? 'check';
565
+ const rest = args.slice(1);
566
+ if (subcommand === 'init') {
567
+ const { options, positional } = parseOptions(rest);
568
+ const result = scaffoldEntityMap(projectDirectory(positional[0] ?? '.'), { enabled: Boolean(options.enable), replace: Boolean(options.replace) });
569
+ console.log(`${result.created ? 'Created' : 'Updated'} EntityMap configuration: ${result.file}`);
570
+ console.log(`EntityMap is ${result.data.enabled ? 'enabled' : 'disabled'}.`);
571
+ return;
572
+ }
573
+ if (subcommand === 'build' || subcommand === 'check') {
574
+ const { positional } = parseOptions(rest);
575
+ const target = projectDirectory(positional[0] ?? '.');
576
+ const result = writeEntityMap(target);
577
+ console.log(`EntityMap: ${result.report.enabled ? `${result.report.summary.entities} entities, ${result.report.summary.chunks} chunks` : 'disabled'}, ${result.report.summary.blocking} blocking, ${result.report.summary.warnings} warnings`);
578
+ console.log(`Report: ${result.reportFile}`);
579
+ if (result.jsonFile) console.log(`Published sources: ${result.jsonFile} and ${result.htmlFile}`);
580
+ for (const item of result.report.findings) console.log(` ${item.severity}: ${item.code} — ${item.message}`);
581
+ if (!result.report.passed) process.exitCode = 1;
582
+ return;
583
+ }
584
+ if (subcommand === 'enrich') {
585
+ const { options, positional } = parseOptions(rest);
586
+ if (!positional[0]) throw new Error('Usage: cosmo entity enrich <provider> [directory] [--env-file path]');
587
+ if (options['env-file']) process.loadEnvFile(path.resolve(String(options['env-file'])));
588
+ const result = await enrichEntityMap(projectDirectory(positional[1] ?? '.'), positional[0]);
589
+ console.log(`${result.provider}: ${result.candidates.length} candidates saved for human review.`);
590
+ console.log(`Candidates: ${result.file}`);
591
+ return;
592
+ }
593
+ if (subcommand === 'candidates') {
594
+ const { positional } = parseOptions(rest);
595
+ const target = projectDirectory(positional[0] ?? '.');
596
+ readEntityMapConfig(target);
597
+ const file = path.join(target, '.cosmo', 'entities', 'candidates.json');
598
+ const data = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : { candidates: [] };
599
+ if (!data.candidates.length) console.log('No EntityMap enrichment candidates.');
600
+ for (const item of data.candidates) console.log(`${item.id} ${item.status.padEnd(12)} ${item.provider.padEnd(22)} ${item.entityId} → ${item.matchedName}`);
601
+ return;
602
+ }
603
+ if (subcommand === 'accept') {
604
+ const { options, positional } = parseOptions(rest);
605
+ if (!positional[0]) throw new Error('Usage: cosmo entity accept <candidate-id> [directory] --by name');
606
+ const item = acceptEntityCandidate(projectDirectory(positional[1] ?? '.'), positional[0], options.by);
607
+ console.log(`Accepted ${item.matchedName} for ${item.entityId}; the reviewer and source were recorded.`);
608
+ return;
609
+ }
610
+ if (subcommand === 'approve') {
611
+ const { options, positional } = parseOptions(rest);
612
+ const target = projectDirectory(positional[0] ?? '.');
613
+ const review = approveEntityMap(target, options.by);
614
+ const result = writeEntityMap(target);
615
+ console.log(`EntityMap reviewed by ${review.reviewedBy} at ${review.reviewedAt}.`);
616
+ console.log(`Published ${result.report.summary.entities} approved entities.`);
617
+ return;
618
+ }
619
+ throw new Error(`Unknown entity command: ${subcommand}`);
620
+ }
621
+
533
622
  function intake(args) {
534
623
  const { options, positional } = parseOptions(args);
535
624
  const target = projectDirectory(positional[0] ?? '.');
@@ -915,6 +1004,7 @@ function releaseCommand(args) {
915
1004
  const { positional } = parseOptions(args.slice(1));
916
1005
  const target = projectDirectory(positional[0] ?? '.');
917
1006
  if (subcommand === 'check') {
1007
+ prepareEntityMap(target);
918
1008
  const report = evaluateDelivery(target);
919
1009
  const files = writeDeliveryReport(target, report);
920
1010
  console.log(`Delivery: ${report.ready ? 'READY' : 'BLOCKED'}, release ${report.releaseId}, ${report.summary.blocking} blockers`);
@@ -964,6 +1054,7 @@ async function deployCommand(args) {
964
1054
  const { options, positional } = parseOptions(rest);
965
1055
  const target = projectDirectory(positional[0] ?? '.');
966
1056
  readProject(target);
1057
+ prepareEntityMap(target);
967
1058
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
968
1059
  await run('npm', ['run', 'preview', '--', '--host', '127.0.0.1'], { cwd: target });
969
1060
  return;
@@ -971,6 +1062,7 @@ async function deployCommand(args) {
971
1062
  if (['preview', 'production'].includes(subcommand)) {
972
1063
  const { options, positional } = parseOptions(rest);
973
1064
  const target = projectDirectory(positional[0] ?? '.');
1065
+ prepareEntityMap(target);
974
1066
  const record = await deployProject(target, subcommand, { build: !options['no-build'], envFile: options['env-file'] });
975
1067
  console.log(`${subcommand === 'production' ? 'Production' : 'Preview'} deployed: ${record.url ?? record.remoteDir ?? 'URL unavailable in provider output'}`);
976
1068
  console.log(`Release: ${record.releaseId}${record.releaseReady ? ' (READY)' : ' (preview of blocked release)'}`);
@@ -997,6 +1089,7 @@ async function main() {
997
1089
  if (command === 'help' || command === '--help' || command === '-h') return help();
998
1090
  if (command === 'start') return start(rawArgs);
999
1091
  if (command === '--version' || command === '-v' || command === 'version') return console.log(VERSION);
1092
+ if (command === 'update') return update();
1000
1093
  if (command === 'setup') return setup(rawArgs);
1001
1094
  if (command === 'init') return init(rawArgs);
1002
1095
  if (command === 'adopt') return adopt(rawArgs);
@@ -1012,6 +1105,7 @@ async function main() {
1012
1105
  if (command === 'doctor') return doctorCommand(rawArgs);
1013
1106
  if (command === 'brand') return brandCommand(rawArgs);
1014
1107
  if (command === 'research') return researchCommand(rawArgs);
1108
+ if (command === 'entity') return entityCommand(rawArgs);
1015
1109
  if (command === 'intake') return intake(rawArgs);
1016
1110
  if (command === 'design' && rawArgs[0] === 'brief') return designBrief(rawArgs.slice(1));
1017
1111
  if (command === 'design' && rawArgs[0] === 'capture') return designCapture(rawArgs.slice(1));
@@ -2,12 +2,14 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { applyIntelligenceProfile } from './intelligence.mjs';
4
4
  import { scaffoldCopyStudio } from './copy-studio.mjs';
5
+ import { scaffoldEntityMap } from './entity-map.mjs';
5
6
  import { slugify, writeJson } from './project.mjs';
6
7
 
7
8
  const GOVERNANCE_PATHS = [
8
9
  '.cosmo/brand',
9
10
  '.cosmo/capabilities',
10
11
  '.cosmo/intelligence/selection.json',
12
+ '.cosmo/entities',
11
13
  '.cosmo/policies',
12
14
  '.cosmo/workflows',
13
15
  ];
@@ -86,6 +88,7 @@ export function adoptAstroProject(templateDirectory, target, options = {}) {
86
88
  writeJson(voiceFile, { ...voice, entityId: slugify(brand) });
87
89
  applyIntelligenceProfile(resolved, profile);
88
90
  scaffoldCopyStudio(resolved);
91
+ scaffoldEntityMap(resolved, { enabled: Boolean(options['entity-map']), replace: true });
89
92
 
90
93
  const guides = ['CLAUDE.md', 'AGENTS.md'].map((file) => installAgentGuide(templateDirectory, resolved, file)).filter(Boolean);
91
94
  guides.push(...installAgentAdapters(templateDirectory, resolved));
@@ -17,6 +17,7 @@ function routeForFile(distDir, file) {
17
17
  const relative = path.relative(distDir, file).split(path.sep).join('/');
18
18
  if (relative === 'index.html') return '/';
19
19
  if (relative.endsWith('/index.html')) return `/${relative.slice(0, -'index.html'.length)}`;
20
+ if (relative === 'entitymap.html') return '/entitymap.html';
20
21
  return `/${relative.replace(/\.html$/, '')}`;
21
22
  }
22
23
 
@@ -24,6 +25,7 @@ function normalizeRoute(href) {
24
25
  const pathname = href.split('#')[0].split('?')[0];
25
26
  if (!pathname) return null;
26
27
  if (pathname === '/') return '/';
28
+ if (/\/[^/]+\.[a-z0-9]+$/i.test(pathname)) return pathname;
27
29
  return pathname.endsWith('/') ? pathname : `${pathname}/`;
28
30
  }
29
31
 
@@ -126,6 +128,20 @@ export function auditDist(distDir) {
126
128
  if (!fs.existsSync(robotsFile)) warnings.push({ rule: 'missing-robots' });
127
129
  else if (!/^Sitemap:\s*https?:\/\//im.test(fs.readFileSync(robotsFile, 'utf8'))) warnings.push({ rule: 'robots-missing-sitemap' });
128
130
 
131
+ const entityJsonFile = path.join(distDir, 'entitymap.json');
132
+ const entityHtmlFile = path.join(distDir, 'entitymap.html');
133
+ if (fs.existsSync(entityJsonFile)) {
134
+ if (!fs.existsSync(entityHtmlFile)) critical.push({ rule: 'entitymap-html-missing' });
135
+ try {
136
+ const entityMap = JSON.parse(fs.readFileSync(entityJsonFile, 'utf8'));
137
+ if (entityMap.version !== '1.0' || entityMap.schema !== 'https://entitymap.org/spec/v1.0' || !entityMap.publisher?.name || !Array.isArray(entityMap.entities) || entityMap.entities.length === 0) critical.push({ rule: 'entitymap-invalid-root' });
138
+ } catch (error) { critical.push({ rule: 'entitymap-invalid-json', detail: error.message }); }
139
+ if (!fs.existsSync(robotsFile) || !/^EntityMap:\s*https?:\/\//im.test(fs.readFileSync(robotsFile, 'utf8'))) warnings.push({ rule: 'robots-missing-entitymap' });
140
+ for (const file of htmlFiles.filter((item) => item !== entityHtmlFile)) {
141
+ if (!/<link\s+[^>]*rel=["']entitymap["'][^>]*>/i.test(fs.readFileSync(file, 'utf8'))) warnings.push({ route: routeForFile(distDir, file), rule: 'page-missing-entitymap-discovery' });
142
+ }
143
+ } else if (fs.existsSync(entityHtmlFile)) critical.push({ rule: 'entitymap-json-missing' });
144
+
129
145
  if (htmlFiles.length === 0) critical.push({ rule: 'no-html-output' });
130
146
  return {
131
147
  passed: critical.length === 0,
@@ -24,6 +24,7 @@ function routeForFile(distDir, file) {
24
24
  const relative = path.relative(distDir, file).split(path.sep).join('/');
25
25
  if (relative === 'index.html') return '/';
26
26
  if (relative.endsWith('/index.html')) return `/${relative.slice(0, -'index.html'.length)}`;
27
+ if (relative === 'entitymap.html') return '/entitymap.html';
27
28
  return `/${relative.replace(/\.html$/, '')}`;
28
29
  }
29
30
 
@@ -44,7 +44,7 @@ function sourceFiles(projectDir) {
44
44
  path.join(projectDir, '.cosmo', 'policies'),
45
45
  path.join(projectDir, '.cosmo', 'work'),
46
46
  ];
47
- const direct = ['.cosmo/project.json', '.cosmo/build-plan.json', '.cosmo/evidence.json', 'DESIGN-DIRECTION.md', 'cosmo.config.mjs', 'astro.config.mjs', 'package.json', 'package-lock.json', 'tsconfig.json']
47
+ 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
48
  .map((relative) => path.join(projectDir, relative))
49
49
  .filter((file) => fs.existsSync(file));
50
50
  return [...roots.flatMap(filesBelow), ...direct];
@@ -94,7 +94,8 @@ export function evaluateDelivery(projectDir) {
94
94
  const progress = optionalJson(path.join(projectDir, '.cosmo', 'progress.json'));
95
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.'));
96
96
 
97
- const requiredReports = [...BASE_REQUIRED_REPORTS, ...(fs.existsSync(path.join(projectDir, '.cosmo', 'copy', 'strategy.json')) ? ['copy-check'] : [])];
97
+ 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'] : [])];
98
99
  const reports = requiredReports.map((name) => {
99
100
  const file = path.join(projectDir, '.cosmo', 'reports', `${name}.json`);
100
101
  const data = optionalJson(file);