@archangel70/cosmo 1.14.0 → 1.14.1

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,13 @@
2
2
 
3
3
  All notable Cosmo changes are recorded here.
4
4
 
5
+ ## 1.14.1 — Wikimedia-safe EntityMap enrichment
6
+
7
+ - Throttled serial Wikidata searches to avoid request spikes on sites with many entities.
8
+ - Added a versioned, descriptive Wikimedia User-Agent with a public support URL and an optional operator-specific contact override.
9
+ - Added bounded HTTP 429 and 503 retries that honor `Retry-After` and otherwise use a Wikimedia-compatible exponential backoff.
10
+ - Added regression coverage for recovery after repeated rate limits and for the bounded failure path.
11
+
5
12
  ## 1.14.0 — Native EntityMap and resilient browser signals
6
13
 
7
14
  - Classified browser console messages explicitly marked as report-only CSP observations as visible, non-blocking warnings while keeping enforced CSP failures critical.
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.14.0**
7
+ Current version: **1.14.1**
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.14.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
85
+ You should see `1.14.1` 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.14.0` or a newer version. Cosmo automatically installs its Cla
99
99
  cosmo --version
100
100
  ```
101
101
 
102
- You should see `1.14.0` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
102
+ You should see `1.14.1` 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
 
@@ -436,6 +436,8 @@ During setup, Cosmo can ask whether you want an EntityMap. If you say yes, it cr
436
436
 
437
437
  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.
438
438
 
439
+ Wikidata requests are automatically serialized and throttled. Cosmo identifies itself with a public support URL, honors Wikimedia's `Retry-After` response, and retries temporary rate limits twice. You can optionally set `COSMO_WIKIMEDIA_CONTACT` in your ignored environment file to identify the site's operator with a current email address or full URL.
440
+
439
441
  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.
440
442
 
441
443
  On an adopted Astro site, EntityMap uses the approved native route inventory and the site's built HTML. It does not require `src/content/pages`, replace hand-authored `.astro` pages, or change the existing design. Home and about represent the Organization, service and service-area routes become Services and Places, and other routes become Concepts unless a reviewed route override supplies a different name or core type.
@@ -61,12 +61,15 @@ Approval records the reviewer and time, then changes the public status to `self-
61
61
 
62
62
  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.
63
63
 
64
+ Cosmo sends Wikidata searches serially with a short delay and identifies the client with its version and public support URL. If Wikidata responds with HTTP 429 or 503, Cosmo honors `Retry-After` and retries twice with exponential backoff when no delay is supplied. For installations that need an operator-specific contact, set `COSMO_WIKIMEDIA_CONTACT` to a current email address or full URL in the local environment; the public Cosmo issue tracker is the safe default.
65
+
64
66
  Provider settings live in `.cosmo/entities/config.json`. Keys belong in a local ignored environment file:
65
67
 
66
68
  ```dotenv
67
69
  COSMO_GOOGLE_KG_API_KEY=
68
70
  COSMO_GOOGLE_PLACES_API_KEY=
69
71
  COSMO_TEXTRAZOR_API_KEY=
72
+ COSMO_WIKIMEDIA_CONTACT=
70
73
  ```
71
74
 
72
75
  Run one provider at a time:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archangel70/cosmo",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
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",
@@ -65,7 +65,7 @@ import {
65
65
  workflowSummary,
66
66
  } from '../lib/workflow.mjs';
67
67
 
68
- const VERSION = '1.14.0';
68
+ const VERSION = '1.14.1';
69
69
  const cliDirectory = path.dirname(fileURLToPath(import.meta.url));
70
70
  const templateDirectory = path.resolve(cliDirectory, '../../../templates/astro-site');
71
71
  const [command = 'start', ...rawArgs] = process.argv.slice(2);
@@ -9,6 +9,13 @@ const SPEC = 'https://entitymap.org/spec/v1.0';
9
9
  const TYPES = new Set(['Concept', 'ProprietaryTerm', 'Methodology', 'Metric', 'Taxonomy', 'Person', 'Organization', 'SoftwareProduct', 'PhysicalProduct', 'Service', 'Platform', 'Place', 'Event', 'Standard', 'Regulation']);
10
10
  const PREDICATES = new Set(['INSTANCE_OF', 'PART_OF', 'INCLUDES', 'DEPENDS_ON', 'REQUIRES', 'MEASURES', 'PRODUCED_BY', 'REGULATED_BY', 'AUTHORED_BY', 'AFFILIATED_WITH', 'COVERS', 'RELATES_TO', 'PRECEDES', 'ENABLES', 'PREVENTS', 'CONFLICTS_WITH', 'DESCRIBED_BY', 'OFFERS', 'IMPROVES', 'DEGRADES', 'LEADS_TO', 'SUITED_FOR', 'TARGETS', 'ACHIEVES']);
11
11
  const TIER_THREE = new Set(['IMPROVES', 'DEGRADES', 'LEADS_TO', 'SUITED_FOR', 'TARGETS', 'ACHIEVES']);
12
+ const WIKIDATA_REQUEST_INTERVAL_MS = 500;
13
+ const WIKIDATA_MAX_RETRIES = 2;
14
+ const WIKIDATA_CONTACT = 'https://github.com/ArchAngel70/cosmo/issues';
15
+ const COSMO_VERSION = (() => {
16
+ try { return JSON.parse(fs.readFileSync(new URL('../../../package.json', import.meta.url), 'utf8')).version; }
17
+ catch { return 'unknown'; }
18
+ })();
12
19
 
13
20
  export const DEFAULT_ENTITY_MAP_CONFIG = {
14
21
  version: 1,
@@ -411,6 +418,26 @@ function candidateId(value) {
411
418
  return `candidate-${crypto.createHash('sha256').update([value.provider, value.entityId, value.externalId, value.uri].join('|')).digest('hex').slice(0, 16)}`;
412
419
  }
413
420
 
421
+ function sleep(milliseconds) {
422
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
423
+ }
424
+
425
+ function wikidataUserAgent() {
426
+ const configured = process.env.COSMO_WIKIMEDIA_CONTACT?.trim();
427
+ const contact = configured && !/[\r\n]/.test(configured) ? configured.slice(0, 500) : WIKIDATA_CONTACT;
428
+ return `Cosmo-EntityMap/${COSMO_VERSION} (${contact})`;
429
+ }
430
+
431
+ function retryAfterMilliseconds(response, attempt) {
432
+ const value = response.headers.get('retry-after')?.trim();
433
+ if (value && /^\d+$/.test(value)) return Number(value) * 1000;
434
+ if (value) {
435
+ const date = Date.parse(value);
436
+ if (Number.isFinite(date)) return Math.max(0, date - Date.now());
437
+ }
438
+ return 5000 * (2 ** attempt);
439
+ }
440
+
414
441
  function entitySubjects(projectDir) {
415
442
  const project = readProject(projectDir).data;
416
443
  const publisher = readJson(path.join(projectDir, '.cosmo', 'brand', 'entity-canon.json'), 'Entity Canon');
@@ -424,12 +451,23 @@ function entitySubjects(projectDir) {
424
451
  return { subjects: [...subjects.values()], pages, config };
425
452
  }
426
453
 
427
- async function enrichWikidata(subjects, fetchImpl) {
454
+ async function enrichWikidata(subjects, fetchImpl, {
455
+ sleepImpl = sleep,
456
+ requestIntervalMs = WIKIDATA_REQUEST_INTERVAL_MS,
457
+ maxRetries = WIKIDATA_MAX_RETRIES,
458
+ } = {}) {
428
459
  const values = [];
429
- for (const subject of subjects) {
460
+ for (const [index, subject] of subjects.entries()) {
461
+ if (index > 0 && requestIntervalMs > 0) await sleepImpl(requestIntervalMs);
430
462
  const url = new URL('https://www.wikidata.org/w/api.php');
431
463
  for (const [key, value] of Object.entries({ action: 'wbsearchentities', search: subject.name, language: 'en', uselang: 'en', format: 'json', limit: '5', origin: '*' })) url.searchParams.set(key, value);
432
- const response = await fetchImpl(url, { headers: { 'user-agent': 'Cosmo EntityMap Builder/1.0' } });
464
+ let response;
465
+ for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
466
+ response = await fetchImpl(url, { headers: { 'user-agent': wikidataUserAgent() } });
467
+ if (![429, 503].includes(response.status)) break;
468
+ if (attempt === maxRetries) throw new Error(`Wikidata returned HTTP ${response.status} after ${maxRetries + 1} attempts. Wait before running enrichment again.`);
469
+ await sleepImpl(retryAfterMilliseconds(response, attempt));
470
+ }
433
471
  if (!response.ok) throw new Error(`Wikidata returned HTTP ${response.status}.`);
434
472
  const body = await response.json();
435
473
  for (const item of body.search ?? []) values.push({ provider: 'wikidata', entityId: subject.entityId, matchedName: item.label, externalId: item.id, uri: item.concepturi ?? `https://www.wikidata.org/wiki/${item.id}`, description: item.description ?? '', score: null });
@@ -480,7 +518,12 @@ async function enrichTextRazor(subjects, pages, key, fetchImpl) {
480
518
  return values;
481
519
  }
482
520
 
483
- export async function enrichEntityMap(projectDir, provider, { fetchImpl = fetch } = {}) {
521
+ export async function enrichEntityMap(projectDir, provider, {
522
+ fetchImpl = fetch,
523
+ sleepImpl = sleep,
524
+ wikidataRequestIntervalMs = WIKIDATA_REQUEST_INTERVAL_MS,
525
+ wikidataMaxRetries = WIKIDATA_MAX_RETRIES,
526
+ } = {}) {
484
527
  const { subjects, pages, config } = entitySubjects(projectDir);
485
528
  const providerConfig = config.providers?.[provider];
486
529
  if (!providerConfig) throw new Error(`Unknown EntityMap provider: ${provider}`);
@@ -488,7 +531,7 @@ export async function enrichEntityMap(projectDir, provider, { fetchImpl = fetch
488
531
  const key = providerConfig.apiKeyEnv ? process.env[providerConfig.apiKeyEnv] : null;
489
532
  if (providerConfig.apiKeyEnv && !key) throw new Error(`Missing ${providerConfig.apiKeyEnv}. Put it in a local environment file; never commit it.`);
490
533
  let raw = [];
491
- if (provider === 'wikidata') raw = await enrichWikidata(subjects, fetchImpl);
534
+ if (provider === 'wikidata') raw = await enrichWikidata(subjects, fetchImpl, { sleepImpl, requestIntervalMs: wikidataRequestIntervalMs, maxRetries: wikidataMaxRetries });
492
535
  if (provider === 'googleKnowledgeGraph') raw = await enrichGoogleKnowledgeGraph(subjects, key, fetchImpl);
493
536
  if (provider === 'googlePlaces') raw = await enrichGooglePlaces(subjects, key, fetchImpl);
494
537
  if (provider === 'textRazor') raw = await enrichTextRazor(subjects, pages, key, fetchImpl);
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.14.0"
3
+ "version": "1.14.1"
4
4
  }
@@ -1,4 +1,4 @@
1
- <!-- cosmo-agent-version: 1.14.0 -->
1
+ <!-- cosmo-agent-version: 1.14.1 -->
2
2
  # Cosmo
3
3
 
4
4
  Use the Cosmo website-building workflow in the current workspace.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Conversational launcher for starting, adopting, and resuming local-first Cosmo Astro website builds.",
5
5
  "author": {
6
6
  "name": "Cosmo"
@@ -7,6 +7,7 @@ COSMO_DEPLOY_PASSWORD=
7
7
  # COSMO_DEPLOY_HOST_FINGERPRINT=SHA256:replace-with-server-fingerprint
8
8
 
9
9
  # Optional EntityMap enrichment. Wikidata works without a key.
10
+ COSMO_WIKIMEDIA_CONTACT=
10
11
  # Enable a provider in .cosmo/entities/config.json before using it.
11
12
  # COSMO_GOOGLE_KG_API_KEY=
12
13
  # COSMO_GOOGLE_PLACES_API_KEY=
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmo/astro-starter",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {