@archangel70/cosmo 1.9.0 → 1.11.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 (36) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +32 -4
  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 -4
  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/claude-plugin.mjs +2 -1
  13. package/packages/cli/lib/delivery.mjs +3 -2
  14. package/packages/cli/lib/entity-map.mjs +408 -0
  15. package/packages/cli/lib/integrity.mjs +6 -0
  16. package/packages/cli/lib/launcher.mjs +111 -0
  17. package/packages/cli/lib/project.mjs +2 -0
  18. package/packages/cli/lib/status.mjs +3 -1
  19. package/plugins/agent-skills/cosmo/.cosmo-agent.json +1 -1
  20. package/plugins/agent-skills/cosmo/SKILL.md +14 -3
  21. package/plugins/antigravity/cosmo.md +4 -1
  22. package/plugins/claude-code/cosmo/.claude-plugin/plugin.json +1 -1
  23. package/plugins/claude-code/cosmo/agents/cosmo.md +47 -0
  24. package/plugins/claude-code/cosmo/skills/cosmo/SKILL.md +16 -4
  25. package/plugins/claude-code/cosmo/skills/cosmo-help/SKILL.md +20 -6
  26. package/templates/astro-site/.agents/skills/cosmo/SKILL.md +3 -1
  27. package/templates/astro-site/.cosmo/capabilities/registry.json +2 -1
  28. package/templates/astro-site/.cosmo/entities/candidates.json +5 -0
  29. package/templates/astro-site/.cosmo/entities/config.json +28 -0
  30. package/templates/astro-site/.env.example +6 -0
  31. package/templates/astro-site/AGENTS.md +3 -2
  32. package/templates/astro-site/CLAUDE.md +3 -2
  33. package/templates/astro-site/astro.config.mjs +5 -1
  34. package/templates/astro-site/package.json +1 -1
  35. package/templates/astro-site/src/layouts/BaseLayout.astro +3 -0
  36. package/templates/astro-site/src/pages/robots.txt.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable Cosmo changes are recorded here.
4
4
 
5
+ ## 1.11.0 — Evidence-controlled EntityMap
6
+
7
+ - Added optional EntityMap v1.0 generation from the Entity Canon and eligible final Astro content.
8
+ - Added public JSON and HTML companions, page-head, footer, robots.txt, and sitemap discovery.
9
+ - Added deterministic validation for attribution, entity types, stable identifiers, chunks, relationships, source URLs, and review state.
10
+ - Added private, human-reviewed enrichment candidates from Wikidata, Google Knowledge Graph, Google Places, and TextRazor.
11
+ - Kept the feature functional without paid APIs and prevented external matches from overwriting canonical project truth.
12
+ - Added explicit named review before generated output may change from `generator-draft` to `self-declared`.
13
+
14
+ ## 1.10.0 — Guided start
15
+
16
+ - Replaced the bare `cosmo` command dump with a friendly, context-aware start screen and an explicit `cosmo help` developer reference.
17
+ - Added a Claude Cosmo agent with first-time guidance modeled around clear choices, a seven-phase website journey, and one unmistakable next step.
18
+ - Updated Claude, Codex, and Antigravity launchers to orient nontechnical users, recover the current project stage, and keep internal commands out of the way.
19
+ - Preserved the Claude-specific launcher during installation instead of replacing it with the generic cross-agent skill.
20
+ - Added regression tests for empty folders, existing Astro sites, active Cosmo projects, and installed launcher guidance.
21
+
5
22
  ## 1.9.0 — Multi-agent Cosmo
6
23
 
7
24
  - Added first-class Claude, Codex, and Google Antigravity setup, status, update, and removal commands.
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.9.0**
7
+ Current version: **1.11.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.9.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
85
+ You should see `1.11.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.9.0` or a newer version. Cosmo automatically installs its Clau
99
99
  cosmo --version
100
100
  ```
101
101
 
102
- You should see `1.9.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
102
+ You should see `1.11.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
 
@@ -120,7 +120,9 @@ Enter the instruction for your assistant:
120
120
  - Codex: `$cosmo` (or ask, “Use Cosmo to build this site.”)
121
121
  - Google Antigravity: `/cosmo`
122
122
 
123
- Your assistant will recognize the empty folder and begin the guided website process. It will ask about the business, audience, goals, pages, brand, content, proof, and visual direction.
123
+ Cosmo will first explain the complete website journey, recognize what is already in the folder, and give you one clear next step. In a new folder, the first question is simply what the business or project is called and what it does.
124
+
125
+ From that point forward, Cosmo chooses the appropriate internal tools and tells you where you are in the process. You do not need to guess whether design, copywriting, page planning, development, or testing comes next.
124
126
 
125
127
  Answer in normal language. You do not need to use special commands or technical terms. If you do not know an answer, say so. Cosmo should ask for clarification instead of inventing business facts.
126
128
 
@@ -142,6 +144,8 @@ Cosmo and your chosen assistant will guide you through these stages:
142
144
 
143
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.
144
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
+
145
149
  ## Preview your website
146
150
 
147
151
  Ask your assistant:
@@ -405,6 +409,26 @@ cosmo research check .
405
409
 
406
410
  Fetched text is evidence, not agent instruction. Observations and inferences must remain distinct, and geographic pages require real coverage and local proof.
407
411
 
412
+ ## Optional AI-readable EntityMap
413
+
414
+ 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.
415
+
416
+ 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.
417
+
418
+ 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.
419
+
420
+ Advanced users can run:
421
+
422
+ ```bash
423
+ cosmo entity init . --enable
424
+ cosmo entity enrich wikidata .
425
+ cosmo entity candidates .
426
+ cosmo entity check .
427
+ cosmo entity approve . --by "Project Owner"
428
+ ```
429
+
430
+ See [EntityMap](docs/ENTITY-MAP.md) for provider setup, review safeguards, and generated files.
431
+
408
432
  ## Integrity, evidence, and page planning
409
433
 
410
434
  Initialize the integrity layer in an older Cosmo project or validate the current one:
@@ -595,6 +619,9 @@ Run `cosmo help` for the installed version's canonical syntax.
595
619
 
596
620
  | Command | Purpose |
597
621
  | --- | --- |
622
+ | `cosmo` | Show the friendly, context-aware next step for the current folder. |
623
+ | `cosmo start [directory]` | Show the guided next step for a specified folder. |
624
+ | `cosmo help` | Show the complete developer command reference. |
598
625
  | `cosmo setup [--agent name]` | Install or repair all launchers, or only Claude, Codex, or Antigravity. |
599
626
  | `cosmo agent list` | Show supported agents and whether each adapter is ready. |
600
627
  | `cosmo agent install <name|all> [--replace]` | Install or update one or every agent adapter. |
@@ -699,6 +726,7 @@ Browser options are `--no-build` and `--no-lighthouse`. Remote deployment accept
699
726
  | `.cosmo/brand/` | Discovery, Entity Canon, and voice profile. |
700
727
  | `.cosmo/copy/strategy.json` | Approved reader, positioning, voice, proof, and competitive-transition strategy. |
701
728
  | `.cosmo/evidence.json` | Central claim and proof ledger. |
729
+ | `.cosmo/entities/` | EntityMap configuration, optional provider settings, accepted matches, and private candidates. |
702
730
  | `.cosmo/intelligence/` | Active packs, artifacts, and private-package locks. |
703
731
  | `.cosmo/build-plan.json` | Typed page architecture and link graph. |
704
732
  | `.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.9.0",
3
+ "version": "1.11.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,7 +16,9 @@ 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';
21
+ import { launcherGuide } from '../lib/launcher.mjs';
20
22
  import {
21
23
  addIntelligencePack,
22
24
  applyIntelligenceProfile,
@@ -62,10 +64,10 @@ import {
62
64
  workflowSummary,
63
65
  } from '../lib/workflow.mjs';
64
66
 
65
- const VERSION = '1.9.0';
67
+ const VERSION = '1.11.0';
66
68
  const cliDirectory = path.dirname(fileURLToPath(import.meta.url));
67
69
  const templateDirectory = path.resolve(cliDirectory, '../../../templates/astro-site');
68
- const [command = 'help', ...rawArgs] = process.argv.slice(2);
70
+ const [command = 'start', ...rawArgs] = process.argv.slice(2);
69
71
 
70
72
  function projectDirectory(value = '.') {
71
73
  return path.resolve(process.cwd(), value);
@@ -76,13 +78,16 @@ function help() {
76
78
  Cosmo ${VERSION} — local-first Astro site builder
77
79
 
78
80
  Commands
81
+ cosmo Show the guided next step for this folder
82
+ cosmo start [directory] Show the guided next step for another folder
83
+ cosmo help Show the complete developer command reference
79
84
  cosmo setup [--agent claude|codex|antigravity|all]
80
85
  cosmo agent list
81
86
  cosmo agent install <claude|codex|antigravity|all> [--replace]
82
87
  cosmo agent status [claude|codex|antigravity|all]
83
88
  cosmo agent uninstall <claude|codex|antigravity|all>
84
- cosmo init [directory] [--name slug] [--brand name] [--site url] [--profile id]
85
- cosmo adopt [directory] [--name slug] [--brand name] [--site url] [--profile id] [--design-mode mode]
89
+ cosmo init [directory] [--name slug] [--brand name] [--site url] [--profile id] [--entity-map]
90
+ cosmo adopt [directory] [--name slug] [--brand name] [--site url] [--profile id] [--design-mode mode] [--entity-map]
86
91
  cosmo claude install [--replace]
87
92
  cosmo claude status
88
93
  cosmo claude uninstall
@@ -118,6 +123,13 @@ Commands
118
123
  cosmo research init [directory] [--replace]
119
124
  cosmo research capture <source-id> <snapshot> [directory] --kind type --location value [--captured-at date] [--replace]
120
125
  cosmo research check [directory]
126
+ cosmo entity init [directory] [--enable] [--replace]
127
+ cosmo entity build [directory]
128
+ cosmo entity check [directory]
129
+ cosmo entity enrich <wikidata|googleKnowledgeGraph|googlePlaces|textRazor> [directory] [--env-file path]
130
+ cosmo entity candidates [directory]
131
+ cosmo entity accept <candidate-id> [directory] --by name
132
+ cosmo entity approve [directory] --by name
121
133
  cosmo brief create <page-id> [directory] [--replace]
122
134
  cosmo brief create --all [directory] [--replace]
123
135
  cosmo workflow list [directory]
@@ -152,6 +164,11 @@ Commands
152
164
  `);
153
165
  }
154
166
 
167
+ function start(args) {
168
+ const { positional } = parseOptions(args);
169
+ console.log(launcherGuide(projectDirectory(positional[0] ?? '.'), VERSION));
170
+ }
171
+
155
172
  async function init(args) {
156
173
  const { options, positional } = parseOptions(args);
157
174
  const target = projectDirectory(positional[0] ?? '.');
@@ -190,6 +207,7 @@ async function init(args) {
190
207
  const evidenceFile = path.join(target, '.cosmo', 'evidence.json');
191
208
  const evidence = JSON.parse(fs.readFileSync(evidenceFile, 'utf8'));
192
209
  writeJson(evidenceFile, { ...evidence, entityId });
210
+ scaffoldEntityMap(target, { enabled: Boolean(options['entity-map']), replace: true });
193
211
  const planFile = path.join(target, '.cosmo', 'build-plan.json');
194
212
  const plan = JSON.parse(fs.readFileSync(planFile, 'utf8'));
195
213
  for (const page of plan.pages) page.contract.strengthensEntity = entityId;
@@ -309,10 +327,17 @@ function setup(args) {
309
327
  if (failed) process.exitCode = 1;
310
328
  }
311
329
 
330
+ function prepareEntityMap(target) {
331
+ const result = writeEntityMap(target);
332
+ if (!result.report.passed) throw new Error(`EntityMap has ${result.report.summary.blocking} blocking finding(s). Run cosmo entity check .`);
333
+ return result;
334
+ }
335
+
312
336
  async function build(args) {
313
337
  const { positional } = parseOptions(args);
314
338
  const target = projectDirectory(positional[0] ?? '.');
315
339
  readProject(target);
340
+ prepareEntityMap(target);
316
341
  await run('npm', ['run', 'build'], { cwd: target });
317
342
  }
318
343
 
@@ -320,6 +345,7 @@ async function dev(args) {
320
345
  const { positional } = parseOptions(args);
321
346
  const target = projectDirectory(positional[0] ?? '.');
322
347
  readProject(target);
348
+ prepareEntityMap(target);
323
349
  await run('npm', ['run', 'dev'], { cwd: target });
324
350
  }
325
351
 
@@ -327,6 +353,7 @@ async function check(args) {
327
353
  const { options, positional } = parseOptions(args);
328
354
  const target = projectDirectory(positional[0] ?? '.');
329
355
  readProject(target);
356
+ prepareEntityMap(target);
330
357
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
331
358
  const report = auditDist(path.join(target, 'dist'));
332
359
  const reportFile = writeAuditReport(target, report);
@@ -432,6 +459,7 @@ async function browserCheck(args) {
432
459
  const { options, positional } = parseOptions(args);
433
460
  const target = projectDirectory(positional[0] ?? '.');
434
461
  readProject(target);
462
+ prepareEntityMap(target);
435
463
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
436
464
  const server = await staticServer(target);
437
465
  const port = server.address().port;
@@ -465,6 +493,7 @@ function status(args) {
465
493
  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` : ''}`);
466
494
  console.log(` plan: ${result.plan ? `${result.plan.pages} pages · ${result.plan.approved ? 'approved' : 'draft'}` : 'missing'}`);
467
495
  console.log(` generation: ${result.generation ? `${result.generation.pages} pages · ${result.generation.complete ? 'complete' : 'active'}` : 'not started'}`);
496
+ console.log(` entity map: ${result.entityMap.enabled ? 'enabled' : 'disabled'}`);
468
497
  console.log(` qa: ${Object.entries(result.qa).map(([name, report]) => `${name.replace('-check', '')}=${report ? report.status ?? (report.passed ? 'passed' : 'failed') : 'missing'}`).join(' ')}`);
469
498
  console.log(` release: ${result.release?.releaseId ?? 'unavailable'} · ${result.release?.ready ? 'ready' : `${result.release?.blocking ?? '?'} blocking`}`);
470
499
  console.log(` deployment: ${result.deployment ? `${result.deployment.provider}${result.deployment.latest ? ` · last ${result.deployment.latest.status}` : ' · never deployed'}` : 'not configured'}`);
@@ -521,6 +550,65 @@ function researchCommand(args) {
521
550
  throw new Error(`Unknown research command: ${subcommand}`);
522
551
  }
523
552
 
553
+ async function entityCommand(args) {
554
+ const subcommand = args[0] ?? 'check';
555
+ const rest = args.slice(1);
556
+ if (subcommand === 'init') {
557
+ const { options, positional } = parseOptions(rest);
558
+ const result = scaffoldEntityMap(projectDirectory(positional[0] ?? '.'), { enabled: Boolean(options.enable), replace: Boolean(options.replace) });
559
+ console.log(`${result.created ? 'Created' : 'Updated'} EntityMap configuration: ${result.file}`);
560
+ console.log(`EntityMap is ${result.data.enabled ? 'enabled' : 'disabled'}.`);
561
+ return;
562
+ }
563
+ if (subcommand === 'build' || subcommand === 'check') {
564
+ const { positional } = parseOptions(rest);
565
+ const target = projectDirectory(positional[0] ?? '.');
566
+ const result = writeEntityMap(target);
567
+ 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`);
568
+ console.log(`Report: ${result.reportFile}`);
569
+ if (result.jsonFile) console.log(`Published sources: ${result.jsonFile} and ${result.htmlFile}`);
570
+ for (const item of result.report.findings) console.log(` ${item.severity}: ${item.code} — ${item.message}`);
571
+ if (!result.report.passed) process.exitCode = 1;
572
+ return;
573
+ }
574
+ if (subcommand === 'enrich') {
575
+ const { options, positional } = parseOptions(rest);
576
+ if (!positional[0]) throw new Error('Usage: cosmo entity enrich <provider> [directory] [--env-file path]');
577
+ if (options['env-file']) process.loadEnvFile(path.resolve(String(options['env-file'])));
578
+ const result = await enrichEntityMap(projectDirectory(positional[1] ?? '.'), positional[0]);
579
+ console.log(`${result.provider}: ${result.candidates.length} candidates saved for human review.`);
580
+ console.log(`Candidates: ${result.file}`);
581
+ return;
582
+ }
583
+ if (subcommand === 'candidates') {
584
+ const { positional } = parseOptions(rest);
585
+ const target = projectDirectory(positional[0] ?? '.');
586
+ readEntityMapConfig(target);
587
+ const file = path.join(target, '.cosmo', 'entities', 'candidates.json');
588
+ const data = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : { candidates: [] };
589
+ if (!data.candidates.length) console.log('No EntityMap enrichment candidates.');
590
+ for (const item of data.candidates) console.log(`${item.id} ${item.status.padEnd(12)} ${item.provider.padEnd(22)} ${item.entityId} → ${item.matchedName}`);
591
+ return;
592
+ }
593
+ if (subcommand === 'accept') {
594
+ const { options, positional } = parseOptions(rest);
595
+ if (!positional[0]) throw new Error('Usage: cosmo entity accept <candidate-id> [directory] --by name');
596
+ const item = acceptEntityCandidate(projectDirectory(positional[1] ?? '.'), positional[0], options.by);
597
+ console.log(`Accepted ${item.matchedName} for ${item.entityId}; the reviewer and source were recorded.`);
598
+ return;
599
+ }
600
+ if (subcommand === 'approve') {
601
+ const { options, positional } = parseOptions(rest);
602
+ const target = projectDirectory(positional[0] ?? '.');
603
+ const review = approveEntityMap(target, options.by);
604
+ const result = writeEntityMap(target);
605
+ console.log(`EntityMap reviewed by ${review.reviewedBy} at ${review.reviewedAt}.`);
606
+ console.log(`Published ${result.report.summary.entities} approved entities.`);
607
+ return;
608
+ }
609
+ throw new Error(`Unknown entity command: ${subcommand}`);
610
+ }
611
+
524
612
  function intake(args) {
525
613
  const { options, positional } = parseOptions(args);
526
614
  const target = projectDirectory(positional[0] ?? '.');
@@ -906,6 +994,7 @@ function releaseCommand(args) {
906
994
  const { positional } = parseOptions(args.slice(1));
907
995
  const target = projectDirectory(positional[0] ?? '.');
908
996
  if (subcommand === 'check') {
997
+ prepareEntityMap(target);
909
998
  const report = evaluateDelivery(target);
910
999
  const files = writeDeliveryReport(target, report);
911
1000
  console.log(`Delivery: ${report.ready ? 'READY' : 'BLOCKED'}, release ${report.releaseId}, ${report.summary.blocking} blockers`);
@@ -955,6 +1044,7 @@ async function deployCommand(args) {
955
1044
  const { options, positional } = parseOptions(rest);
956
1045
  const target = projectDirectory(positional[0] ?? '.');
957
1046
  readProject(target);
1047
+ prepareEntityMap(target);
958
1048
  if (!options['no-build']) await run('npm', ['run', 'build'], { cwd: target });
959
1049
  await run('npm', ['run', 'preview', '--', '--host', '127.0.0.1'], { cwd: target });
960
1050
  return;
@@ -962,6 +1052,7 @@ async function deployCommand(args) {
962
1052
  if (['preview', 'production'].includes(subcommand)) {
963
1053
  const { options, positional } = parseOptions(rest);
964
1054
  const target = projectDirectory(positional[0] ?? '.');
1055
+ prepareEntityMap(target);
965
1056
  const record = await deployProject(target, subcommand, { build: !options['no-build'], envFile: options['env-file'] });
966
1057
  console.log(`${subcommand === 'production' ? 'Production' : 'Preview'} deployed: ${record.url ?? record.remoteDir ?? 'URL unavailable in provider output'}`);
967
1058
  console.log(`Release: ${record.releaseId}${record.releaseReady ? ' (READY)' : ' (preview of blocked release)'}`);
@@ -986,6 +1077,7 @@ async function deployCommand(args) {
986
1077
 
987
1078
  async function main() {
988
1079
  if (command === 'help' || command === '--help' || command === '-h') return help();
1080
+ if (command === 'start') return start(rawArgs);
989
1081
  if (command === '--version' || command === '-v' || command === 'version') return console.log(VERSION);
990
1082
  if (command === 'setup') return setup(rawArgs);
991
1083
  if (command === 'init') return init(rawArgs);
@@ -1002,6 +1094,7 @@ async function main() {
1002
1094
  if (command === 'doctor') return doctorCommand(rawArgs);
1003
1095
  if (command === 'brand') return brandCommand(rawArgs);
1004
1096
  if (command === 'research') return researchCommand(rawArgs);
1097
+ if (command === 'entity') return entityCommand(rawArgs);
1005
1098
  if (command === 'intake') return intake(rawArgs);
1006
1099
  if (command === 'design' && rawArgs[0] === 'brief') return designBrief(rawArgs.slice(1));
1007
1100
  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
 
@@ -46,7 +46,8 @@ export function installClaudePlugin({ target = claudePluginTarget(), source = de
46
46
 
47
47
  fs.mkdirSync(path.dirname(target), { recursive: true });
48
48
  fs.cpSync(source, target, { recursive: true });
49
- if (fs.existsSync(sharedSkill)) fs.copyFileSync(sharedSkill, path.join(target, 'skills', 'cosmo', 'SKILL.md'));
49
+ const installedSkill = path.join(target, 'skills', 'cosmo', 'SKILL.md');
50
+ if (!fs.existsSync(installedSkill) && fs.existsSync(sharedSkill)) fs.copyFileSync(sharedSkill, installedSkill);
50
51
  const launcher = path.join(target, 'bin', 'cosmo');
51
52
  fs.writeFileSync(launcher, `#!/bin/sh\nexec ${shellQuote(process.execPath)} ${shellQuote(runtimeCli)} "$@"\n`);
52
53
  fs.chmodSync(launcher, 0o755);
@@ -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);