@archangel70/cosmo 1.14.1 → 1.15.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,20 @@
2
2
 
3
3
  All notable Cosmo changes are recorded here.
4
4
 
5
+ ## 1.15.1 — Complete user and command documentation
6
+
7
+ - Expanded the beginner preview instructions to explain local and temporary public review links, their privacy boundary, and the optional Cloudflare helper.
8
+ - Documented the complete EntityMap build, enrichment, candidate-review, acceptance, checking, and approval workflow.
9
+ - Synchronized initialization, adoption, design-agent, intelligence-agent, and workflow-resume syntax with the actual CLI.
10
+ - Completed the documentation index and added platform-specific `cloudflared` installation guidance.
11
+
12
+ ## 1.15.0 — Shared preview tunnels
13
+
14
+ - Added one-command temporary public previews through Cloudflare Quick Tunnels with no account, DNS change, API key, or deployment configuration.
15
+ - Kept Astro bound to loopback, supervised both processes, and made `Ctrl+C` invalidate the public link by stopping the preview and tunnel together.
16
+ - Added beginner-friendly `cloudflared` installation guidance, optional port selection, conversational launcher guidance, and regression coverage.
17
+ - Kept shared previews out of deployment history and production release decisions.
18
+
5
19
  ## 1.14.1 — Wikimedia-safe EntityMap enrichment
6
20
 
7
21
  - Throttled serial Wikidata searches to avoid request spikes on sites with many entities.
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.1**
7
+ Current version: **1.15.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.1` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
85
+ You should see `1.15.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.1` or a newer version. Cosmo automatically installs its Cla
99
99
  cosmo --version
100
100
  ```
101
101
 
102
- You should see `1.14.1` or a newer version. Cosmo automatically installs its Claude, Codex, and Antigravity launchers.
102
+ You should see `1.15.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
 
@@ -164,6 +164,14 @@ cosmo dev .
164
164
 
165
165
  Press Control+C in the terminal when you want to stop the preview.
166
166
 
167
+ To let someone outside your computer view the site temporarily, ask your assistant:
168
+
169
+ ```text
170
+ Share this site with a temporary preview link.
171
+ ```
172
+
173
+ Cosmo will give you a public `trycloudflare.com` address that works only while the preview command is running. Anyone with the address can open it, so do not use it for private or sensitive material. This is a review link, not a production deployment. The first time you use it, Cosmo may ask you to install Cloudflare's free `cloudflared` helper; no Cloudflare account or API key is required.
174
+
167
175
  ## Continue later
168
176
 
169
177
  Cosmo saves its progress inside the website folder. To continue another day:
@@ -236,6 +244,7 @@ npm uninstall --global @archangel70/cosmo
236
244
  | Your assistant does not recognize Cosmo | Restart it, run `cosmo setup`, then use Claude's `/cosmo:cosmo`, Codex's `$cosmo`, or Antigravity's `/cosmo`. |
237
245
  | You opened the wrong folder | Stop before approving changes, create or select the intended website folder, and start again there. |
238
246
  | You do not know how to answer a question | Tell the assistant what you know and ask it to explain what information is missing. |
247
+ | `cloudflared` is required for a shared preview | Install the free Cloudflare helper shown in Cosmo's message, then repeat the preview request. A Cloudflare account is not required. |
239
248
 
240
249
  For additional problems, see [Troubleshooting](#troubleshooting).
241
250
 
@@ -249,7 +258,7 @@ For additional problems, see [Troubleshooting](#troubleshooting).
249
258
  - Built-in research, authority, local-business, editorial, regulated-topic, audience, search, conversion, writing, brand-language, image-direction, and Claude Design capabilities.
250
259
  - Checks for business facts, claims, proof, page purpose, links, accessibility, mobile layouts, and build quality.
251
260
  - Saved project state so any supported agent can continue without relying on the old chat.
252
- - Local previews plus Cloudflare Pages, SFTP, FTPS, and explicitly acknowledged FTP deployment.
261
+ - Local previews, temporary public Cloudflare preview links, plus Cloudflare Pages, SFTP, FTPS, and explicitly acknowledged FTP deployment.
253
262
  - No license key, WordPress installation, hosted Cosmo account, or Cosmo cloud service.
254
263
 
255
264
  ## Contents for advanced users
@@ -258,6 +267,7 @@ For additional problems, see [Troubleshooting](#troubleshooting).
258
267
  - [Profiles and capability packs](#intelligence-profiles-and-capability-packs)
259
268
  - [Claude Design](#claude-design-and-unique-visual-direction)
260
269
  - [Research](#research-workbench)
270
+ - [EntityMap](#optional-ai-readable-entitymap)
261
271
  - [Copy Studio](#copy-studio)
262
272
  - [Integrity and page planning](#integrity-evidence-and-page-planning)
263
273
  - [Page generation](#resumable-page-generation)
@@ -446,12 +456,16 @@ Advanced users can run:
446
456
 
447
457
  ```bash
448
458
  cosmo entity init . --enable
459
+ cosmo entity build .
449
460
  cosmo entity enrich wikidata .
450
461
  cosmo entity candidates .
462
+ cosmo entity accept <candidate-id> . --by "Project Owner"
451
463
  cosmo entity check .
452
464
  cosmo entity approve . --by "Project Owner"
453
465
  ```
454
466
 
467
+ `entity build` compiles the current draft without approving it. Enrichment providers are `wikidata`, `googleKnowledgeGraph`, `googlePlaces`, and `textRazor`; the Google and TextRazor providers read their keys from environment variables or an ignored file passed with `--env-file`. `entity candidates` shows private suggestions, and `entity accept` records one named human decision. Only `entity approve` changes the public map from generator draft to named self-declaration.
468
+
455
469
  See [EntityMap](docs/ENTITY-MAP.md) for provider setup, review safeguards, and generated files.
456
470
 
457
471
  ## Integrity, evidence, and page planning
@@ -564,6 +578,30 @@ Start a production-style local preview:
564
578
  cosmo deploy local .
565
579
  ```
566
580
 
581
+ ### Share a temporary preview
582
+
583
+ To let a client, friend, phone, or another assistant see the site before it is deployed, ask your assistant:
584
+
585
+ > Share this site with a temporary preview link.
586
+
587
+ Or run:
588
+
589
+ ```bash
590
+ cosmo preview share .
591
+ ```
592
+
593
+ Cosmo builds the site, starts a private local preview, and uses Cloudflare Quick Tunnels to print one temporary public HTTPS address. No Cloudflare account, DNS change, deployment setup, or API key is required. The free `cloudflared` application must be installed; when it is missing, Cosmo prints the appropriate installation step.
594
+
595
+ Anyone who has the address can view the preview. The random address stops working as soon as you press `Ctrl+C`. It is for review only: Cosmo does not record it as a deployment, treat it as production, or use it to bypass QA and release approval. Use `--no-build` only when the current `dist` is already correct, and use `--port 4173` only when you need a specific local port.
596
+
597
+ Install `cloudflared` once if Cosmo reports that it is missing:
598
+
599
+ - **Mac:** run `brew install cloudflared` in Terminal.
600
+ - **Windows:** download and run Cloudflare's current 64-bit MSI from the [official cloudflared downloads page](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/#windows).
601
+ - **Linux:** follow the distribution-specific instructions in Cloudflare's [official package repository](https://pkg.cloudflare.com/).
602
+
603
+ After installation, repeat `cosmo preview share .`.
604
+
567
605
  ### Cloudflare Pages
568
606
 
569
607
  Configure a Direct Upload project:
@@ -666,7 +704,7 @@ Run `cosmo help` for the installed version's canonical syntax.
666
704
  | `cosmo build [directory]` | Produce the static Astro build. |
667
705
  | `cosmo --version` | Print the Cosmo version. |
668
706
 
669
- Common `init` and `adopt` options are `--name`, `--brand`, `--site`, and `--profile`; adoption also accepts `--design-mode`.
707
+ Common `init` and `adopt` options are `--name`, `--brand`, `--site`, `--profile`, and `--entity-map`; adoption also accepts `--design-mode`.
670
708
 
671
709
  ### Discovery, design, and research
672
710
 
@@ -675,7 +713,7 @@ Common `init` and `adopt` options are `--name`, `--brand`, `--site`, and `--prof
675
713
  | `cosmo intake [directory] --niche ... --audience ... --goal ...` | Write structured project intake. |
676
714
  | `cosmo brand discover [directory] [--replace]` | Create guided brand discovery. |
677
715
  | `cosmo brand check [directory]` | Validate completed, human-approved discovery. |
678
- | `cosmo design brief [directory]` | Create the creative brief and selected design-pack guidance. |
716
+ | `cosmo design brief [directory] [--agent claude\|codex\|antigravity]` | Create the creative brief and guidance for the selected design agent. |
679
717
  | `cosmo design capture [directory]` | Capture implemented tokens and Astro components. |
680
718
  | `cosmo research init [directory] [--replace]` | Create the research workbench. |
681
719
  | `cosmo research capture <id> <snapshot> [directory] [options]` | Store an attributed, SHA256-bound research snapshot. |
@@ -697,12 +735,19 @@ Additional intake options include `--location`, `--pages`, `--language`, `--desi
697
735
  | `cosmo intelligence apply <profile> [directory]` | Replace the selection with a profile. |
698
736
  | `cosmo intelligence add|remove <pack> [directory]` | Modify the active pack selection. |
699
737
  | `cosmo intelligence scaffold [directory] [--replace]` | Create required selected-pack artifacts. |
700
- | `cosmo intelligence guide <stage> [directory]` | Print stage-specific questions and agent guidance. |
738
+ | `cosmo intelligence guide <stage> [directory] [--agent claude\|codex\|antigravity]` | Print stage-specific questions and guidance for the selected agent. |
701
739
  | `cosmo intelligence check [directory]` | Evaluate selected capabilities against the project. |
702
740
  | `cosmo intelligence import <package> [directory] [--replace]` | Install a declarative private pack. |
703
741
  | `cosmo intelligence installed [directory]` | Show imported package locks. |
704
742
  | `cosmo integrity init [directory] [--replace]` | Add the integrity foundation to an older project. |
705
743
  | `cosmo integrity check [directory] [--allow-missing-briefs]` | Validate entity, voice, evidence, plan, capabilities, and briefs. |
744
+ | `cosmo entity init [directory] [--enable] [--replace]` | Create or update the optional EntityMap configuration. |
745
+ | `cosmo entity build [directory]` | Compile and validate the current EntityMap draft. |
746
+ | `cosmo entity check [directory]` | Rebuild and report EntityMap findings for QA. |
747
+ | `cosmo entity enrich <provider> [directory] [--env-file path]` | Save private enrichment candidates from Wikidata, Google, or TextRazor. |
748
+ | `cosmo entity candidates [directory]` | List private enrichment candidates and their review status. |
749
+ | `cosmo entity accept <candidate-id> [directory] --by name` | Accept one candidate with a named human reviewer. |
750
+ | `cosmo entity approve [directory] --by name` | Record final named review and publish the approved declaration. |
706
751
  | `cosmo plan check [directory]` | Validate the current Build Plan. |
707
752
  | `cosmo brief create <page-id> [directory] [--replace]` | Derive one page brief. |
708
753
  | `cosmo brief create --all [directory] [--replace]` | Derive all planned page briefs. |
@@ -738,6 +783,7 @@ Additional intake options include `--location`, `--pages`, `--language`, `--desi
738
783
  | `cosmo handoff show [directory]` | Display the current handoff. |
739
784
  | `cosmo deploy configure <provider> [directory] [options]` | Configure Cloudflare Pages, SFTP, FTPS, or FTP. |
740
785
  | `cosmo deploy local [directory] [--no-build]` | Run the production build locally. |
786
+ | `cosmo preview share [directory] [--no-build] [--port n]` | Create a temporary public review link that ends when Cosmo stops. |
741
787
  | `cosmo deploy preview|production [directory] [options]` | Deploy review or READY production output. |
742
788
  | `cosmo deploy status|history [directory]` | Inspect deployment configuration and durable history. |
743
789
 
@@ -852,6 +898,7 @@ The neutral starter lives in `templates/astro-site`. Production-pipeline fixture
852
898
  ## Further documentation
853
899
 
854
900
  - [Architecture](docs/ARCHITECTURE.md)
901
+ - [Native Astro adoption](docs/ADOPTION.md)
855
902
  - [Multi-agent setup](docs/MULTI-AGENT.md)
856
903
  - [Claude Code launcher](docs/CLAUDE-LAUNCHER.md)
857
904
  - [Brand discovery](docs/BRAND-DISCOVERY.md)
@@ -865,6 +912,7 @@ The neutral starter lives in `templates/astro-site`. Production-pipeline fixture
865
912
  - [Generation](docs/GENERATION.md)
866
913
  - [Content QA](docs/CONTENT-QA.md)
867
914
  - [Browser QA](docs/BROWSER-QA.md)
915
+ - [EntityMap](docs/ENTITY-MAP.md)
868
916
  - [Operations](docs/OPERATIONS.md)
869
917
  - [Delivery readiness](docs/DELIVERY.md)
870
918
  - [Deployment](docs/DEPLOYMENT.md)
@@ -10,6 +10,18 @@ cosmo deploy local .
10
10
 
11
11
  This builds the project and starts Astro's production preview server on `127.0.0.1`. Pass `--no-build` only when `dist` is already current.
12
12
 
13
+ ## Temporary shared preview
14
+
15
+ ```bash
16
+ cosmo preview share .
17
+ ```
18
+
19
+ This builds the project, binds Astro only to `127.0.0.1`, starts a Cloudflare Quick Tunnel, and prints the generated `trycloudflare.com` address. It requires the free `cloudflared` application but does not require a Cloudflare account, DNS changes, credentials, inbound ports, or deployment configuration. Cosmo detects a missing executable and prints a platform-appropriate installation instruction.
20
+
21
+ The address is public to anyone who has it, random, and available only while the command is running. Press `Ctrl+C` to stop both the local Astro process and the tunnel. Cosmo does not write the address to deployment history, call the session a release, or relax any production gate. Optional flags are `--no-build` for a current build and `--port <number>` for a specific loopback port.
22
+
23
+ Quick Tunnels are for review and testing only. Cloudflare documents a 200-concurrent-request limit and no Server-Sent Events support. Use a durable preview provider or a production deployment for persistent hosting.
24
+
13
25
  ## Cloudflare Pages
14
26
 
15
27
  The first remote adapter uses Cloudflare Pages Direct Upload. Static Astro projects require no Cloudflare Astro adapter: Cosmo builds `dist` and invokes Wrangler's `pages deploy` command.
@@ -110,6 +122,8 @@ Cloudflare Direct Upload projects cannot later be converted to Git integration.
110
122
 
111
123
  Official references:
112
124
 
125
+ - [Cloudflare Quick Tunnels](https://try.cloudflare.com/)
126
+ - [Cloudflare Tunnel development documentation](https://developers.cloudflare.com/tunnel/get-started/#quick-tunnels-development)
113
127
  - [Cloudflare Pages Direct Upload](https://developers.cloudflare.com/pages/get-started/direct-upload/)
114
128
  - [Wrangler Pages commands](https://developers.cloudflare.com/workers/wrangler/commands/pages/)
115
129
  - [Astro deployment to Cloudflare](https://docs.astro.build/en/guides/deploy/cloudflare/)
package/docs/ROADMAP.md CHANGED
@@ -194,6 +194,14 @@ The acceptance pilot completed five generation entries, static and browser QA wi
194
194
  - Private candidate review that prevents external services from overwriting the Entity Canon.
195
195
  - EntityMap conformance, attribution, relationship, source, and freshness checks integrated into release readiness.
196
196
 
197
+ ## Milestone 21 — shared preview tunnels (complete)
198
+
199
+ - One-command temporary public HTTPS previews through Cloudflare Quick Tunnels.
200
+ - No Cloudflare account, DNS change, API key, or durable deployment configuration.
201
+ - Loopback-only Astro binding with supervised preview and tunnel processes.
202
+ - Clean link extraction from structured cloudflared output and beginner-friendly installation guidance.
203
+ - Explicit testing-only boundaries with no deployment history or production-release effect.
204
+
197
205
  ## Later, only when justified
198
206
 
199
207
  - Additional deployment adapters, including Cloudflare Workers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archangel70/cosmo",
3
- "version": "1.14.1",
3
+ "version": "1.15.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",
@@ -41,6 +41,7 @@ import {
41
41
  writeJson,
42
42
  } from '../lib/project.mjs';
43
43
  import { run } from '../lib/process.mjs';
44
+ import { assertCloudflared, sharePreview } from '../lib/shared-preview.mjs';
44
45
  import { updateCosmo } from '../lib/self-update.mjs';
45
46
  import { captureResearchSource, checkResearchWorkbench, scaffoldResearchWorkbench } from '../lib/research.mjs';
46
47
  import { collectProjectStatus } from '../lib/status.mjs';
@@ -65,7 +66,7 @@ import {
65
66
  workflowSummary,
66
67
  } from '../lib/workflow.mjs';
67
68
 
68
- const VERSION = '1.14.1';
69
+ const VERSION = '1.15.1';
69
70
  const cliDirectory = path.dirname(fileURLToPath(import.meta.url));
70
71
  const templateDirectory = path.resolve(cliDirectory, '../../../templates/astro-site');
71
72
  const [command = 'start', ...rawArgs] = process.argv.slice(2);
@@ -137,6 +138,7 @@ Commands
137
138
  cosmo workflow list [directory]
138
139
  cosmo workflow start [directory] [--workflow id]
139
140
  cosmo workflow show [directory]
141
+ cosmo workflow resume [directory]
140
142
  cosmo workflow submit <stage> [directory]
141
143
  cosmo workflow approve <stage> [directory] [--by name]
142
144
  cosmo workflow import <workflow.json> [directory]
@@ -158,6 +160,7 @@ Commands
158
160
  cosmo deploy configure cloudflare-pages [directory] --project name [--production-branch main]
159
161
  cosmo deploy configure sftp|ftps|ftp [directory] --host name --remote-dir path [--preview-remote-dir path]
160
162
  cosmo deploy local [directory] [--no-build]
163
+ cosmo preview share [directory] [--no-build] [--port number]
161
164
  cosmo deploy preview [directory] [--no-build] [--env-file path]
162
165
  cosmo deploy production [directory] [--no-build] [--env-file path]
163
166
  cosmo deploy status [directory]
@@ -1099,6 +1102,22 @@ async function deployCommand(args) {
1099
1102
  throw new Error(`Unknown deploy command: ${subcommand}`);
1100
1103
  }
1101
1104
 
1105
+ async function previewCommand(args) {
1106
+ const subcommand = args[0] ?? 'share';
1107
+ const { options, positional } = parseOptions(args.slice(1));
1108
+ const target = projectDirectory(positional[0] ?? '.');
1109
+ if (subcommand === 'share') {
1110
+ readProject(target);
1111
+ await assertCloudflared();
1112
+ await prepareAndBuild(target, !options['no-build']);
1113
+ console.log('Starting a temporary public preview through Cloudflare...');
1114
+ console.log('No Cloudflare account, DNS changes, or deployment configuration are required.');
1115
+ await sharePreview(target, { port: options.port, cloudflaredCheck: async () => {} });
1116
+ return;
1117
+ }
1118
+ throw new Error(`Unknown preview command: ${subcommand}. Use cosmo preview share.`);
1119
+ }
1120
+
1102
1121
  async function main() {
1103
1122
  if (command === 'help' || command === '--help' || command === '-h') return help();
1104
1123
  if (command === 'start') return start(rawArgs);
@@ -1132,6 +1151,7 @@ async function main() {
1132
1151
  if (command === 'handoff') return handoffCommand(rawArgs);
1133
1152
  if (command === 'release') return releaseCommand(rawArgs);
1134
1153
  if (command === 'deploy') return deployCommand(rawArgs);
1154
+ if (command === 'preview') return previewCommand(rawArgs);
1135
1155
  throw new Error(`Unknown command: ${[command, ...rawArgs].join(' ')}`);
1136
1156
  }
1137
1157
 
@@ -0,0 +1,212 @@
1
+ import http from 'node:http';
2
+ import net from 'node:net';
3
+ import { spawn } from 'node:child_process';
4
+
5
+ const QUICK_TUNNEL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com\b/i;
6
+
7
+ export class SharedPreviewError extends Error {}
8
+
9
+ export function extractQuickTunnelUrl(value) {
10
+ return String(value ?? '').match(QUICK_TUNNEL_PATTERN)?.[0] ?? null;
11
+ }
12
+
13
+ export function quickTunnelArgs(port) {
14
+ return ['tunnel', '--url', `http://127.0.0.1:${port}`, '--output', 'json'];
15
+ }
16
+
17
+ export function cloudflaredInstallHelp(platform = process.platform) {
18
+ const instruction = platform === 'darwin'
19
+ ? 'Install it with Homebrew: brew install cloudflared'
20
+ : platform === 'win32'
21
+ ? 'Install it with Windows Package Manager: winget install --id Cloudflare.cloudflared'
22
+ : 'Install cloudflared from https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/';
23
+ return `Cloudflare shared previews require the free cloudflared application.\n${instruction}\nThen run this command again.`;
24
+ }
25
+
26
+ function executable(command) {
27
+ return process.platform === 'win32' && command === 'npm' ? 'npm.cmd' : command;
28
+ }
29
+
30
+ function waitForExit(child) {
31
+ return new Promise((resolve, reject) => {
32
+ child.once('error', reject);
33
+ child.once('exit', (code, signal) => resolve({ code, signal }));
34
+ });
35
+ }
36
+
37
+ export async function assertCloudflared({ spawnProcess = spawn, platform = process.platform } = {}) {
38
+ let child;
39
+ try {
40
+ child = spawnProcess('cloudflared', ['--version'], { stdio: 'ignore', shell: false });
41
+ const result = await waitForExit(child);
42
+ if (result.code !== 0) throw new Error(`cloudflared exited with code ${result.code}`);
43
+ } catch (error) {
44
+ throw new SharedPreviewError(cloudflaredInstallHelp(platform), { cause: error });
45
+ }
46
+ }
47
+
48
+ export function findAvailablePort(host = '127.0.0.1') {
49
+ return new Promise((resolve, reject) => {
50
+ const server = net.createServer();
51
+ server.unref();
52
+ server.once('error', reject);
53
+ server.listen(0, host, () => {
54
+ const address = server.address();
55
+ const port = typeof address === 'object' && address ? address.port : null;
56
+ server.close((error) => error ? reject(error) : resolve(port));
57
+ });
58
+ });
59
+ }
60
+
61
+ function previewResponds(port) {
62
+ return new Promise((resolve) => {
63
+ const request = http.get({ hostname: '127.0.0.1', port, path: '/', timeout: 1_000 }, (response) => {
64
+ response.resume();
65
+ resolve(true);
66
+ });
67
+ request.once('timeout', () => request.destroy());
68
+ request.once('error', () => resolve(false));
69
+ });
70
+ }
71
+
72
+ export async function waitForPreview(port, { timeoutMs = 30_000, intervalMs = 150 } = {}) {
73
+ const deadline = Date.now() + timeoutMs;
74
+ while (Date.now() < deadline) {
75
+ if (await previewResponds(port)) return;
76
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
77
+ }
78
+ throw new SharedPreviewError(`The local Astro preview did not start on port ${port} within ${Math.round(timeoutMs / 1_000)} seconds.`);
79
+ }
80
+
81
+ function waitForPreviewProcess(child, port, readyCheck) {
82
+ return new Promise((resolve, reject) => {
83
+ const cleanup = () => {
84
+ child.removeListener('error', onError);
85
+ child.removeListener('exit', onExit);
86
+ };
87
+ const onError = (error) => {
88
+ cleanup();
89
+ reject(new SharedPreviewError(`The local Astro preview could not start: ${error.message}`, { cause: error }));
90
+ };
91
+ const onExit = (code) => {
92
+ cleanup();
93
+ reject(new SharedPreviewError(`The local Astro preview stopped before it was ready${code === null ? '' : ` with code ${code}`}.`));
94
+ };
95
+ child.once('error', onError);
96
+ child.once('exit', onExit);
97
+ Promise.resolve(readyCheck(port)).then(() => {
98
+ cleanup();
99
+ resolve();
100
+ }, (error) => {
101
+ cleanup();
102
+ reject(error);
103
+ });
104
+ });
105
+ }
106
+
107
+ function stopChild(child) {
108
+ if (!child || child.exitCode !== null || child.killed) return;
109
+ child.kill('SIGTERM');
110
+ const timer = setTimeout(() => {
111
+ if (child.exitCode === null) child.kill('SIGKILL');
112
+ }, 3_000);
113
+ timer.unref();
114
+ }
115
+
116
+ function mirror(stream, destination) {
117
+ stream?.on('data', (chunk) => destination.write(chunk));
118
+ }
119
+
120
+ export async function sharePreview(projectDir, {
121
+ port,
122
+ spawnProcess = spawn,
123
+ signalSource = process,
124
+ output = process.stdout,
125
+ errorOutput = process.stderr,
126
+ readyCheck = waitForPreview,
127
+ cloudflaredCheck = assertCloudflared,
128
+ urlTimeoutMs = 30_000,
129
+ } = {}) {
130
+ await cloudflaredCheck({ spawnProcess });
131
+ const requestedPort = port ?? await findAvailablePort();
132
+ const previewPort = typeof requestedPort === 'number'
133
+ ? requestedPort
134
+ : /^\d+$/.test(String(requestedPort)) ? Number(requestedPort) : Number.NaN;
135
+ if (!Number.isInteger(previewPort) || previewPort < 1 || previewPort > 65535) {
136
+ throw new SharedPreviewError('Preview port must be a whole number between 1 and 65535.');
137
+ }
138
+
139
+ const preview = spawnProcess(executable('npm'), ['run', 'preview', '--', '--host', '127.0.0.1', '--port', String(previewPort)], {
140
+ cwd: projectDir,
141
+ env: process.env,
142
+ stdio: ['inherit', 'pipe', 'pipe'],
143
+ shell: false,
144
+ });
145
+ mirror(preview.stdout, output);
146
+ mirror(preview.stderr, errorOutput);
147
+
148
+ try {
149
+ await waitForPreviewProcess(preview, previewPort, readyCheck);
150
+ } catch (error) {
151
+ stopChild(preview);
152
+ throw error;
153
+ }
154
+
155
+ const tunnel = spawnProcess('cloudflared', quickTunnelArgs(previewPort), {
156
+ cwd: projectDir,
157
+ env: process.env,
158
+ stdio: ['ignore', 'pipe', 'pipe'],
159
+ shell: false,
160
+ });
161
+
162
+ return new Promise((resolve, reject) => {
163
+ let buffer = '';
164
+ let url = null;
165
+ let stopping = false;
166
+ let settled = false;
167
+
168
+ const finish = (error) => {
169
+ if (settled) return;
170
+ settled = true;
171
+ clearTimeout(urlTimer);
172
+ signalSource.removeListener('SIGINT', shutdown);
173
+ signalSource.removeListener('SIGTERM', shutdown);
174
+ stopChild(preview);
175
+ stopChild(tunnel);
176
+ if (error) reject(error);
177
+ else resolve({ url, port: previewPort });
178
+ };
179
+
180
+ const shutdown = () => {
181
+ stopping = true;
182
+ output.write('\nShared preview stopped. The temporary link no longer works.\n');
183
+ finish();
184
+ };
185
+
186
+ const inspect = (chunk) => {
187
+ buffer = `${buffer}${chunk}`.slice(-16_000);
188
+ const found = extractQuickTunnelUrl(buffer);
189
+ if (!found || url) return;
190
+ url = found;
191
+ output.write(`\nYour temporary preview is ready:\n\n${url}\n\n`);
192
+ output.write('Anyone with this address can view the site. Press Ctrl+C when you are finished sharing.\n');
193
+ output.write('This is a temporary review link, not a production deployment.\n');
194
+ };
195
+
196
+ tunnel.stdout?.on('data', inspect);
197
+ tunnel.stderr?.on('data', inspect);
198
+ const urlTimer = setTimeout(() => finish(new SharedPreviewError('Cloudflare did not provide a temporary preview address within 30 seconds.')), urlTimeoutMs);
199
+ urlTimer.unref();
200
+
201
+ preview.once('error', (error) => finish(new SharedPreviewError(`The local Astro preview could not start: ${error.message}`, { cause: error })));
202
+ tunnel.once('error', (error) => finish(new SharedPreviewError(`${cloudflaredInstallHelp()}\nDetails: ${error.message}`, { cause: error })));
203
+ preview.once('exit', (code) => {
204
+ if (!stopping) finish(new SharedPreviewError(`The local Astro preview stopped unexpectedly${code === null ? '' : ` with code ${code}`}.`));
205
+ });
206
+ tunnel.once('exit', (code) => {
207
+ if (!stopping) finish(new SharedPreviewError(`The Cloudflare shared preview stopped unexpectedly${code === null ? '' : ` with code ${code}`}.`));
208
+ });
209
+ signalSource.once('SIGINT', shutdown);
210
+ signalSource.once('SIGTERM', shutdown);
211
+ });
212
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.14.1"
3
+ "version": "1.15.1"
4
4
  }
@@ -70,6 +70,8 @@ Before page writing in a generated-content project, run `cosmo copy guide <page-
70
70
 
71
71
  Advance generation one state at a time. After two failed repair cycles, leave the page for human review. For release, run the build plus Copy Studio, content, intelligence, integrity, EntityMap when enabled, static, browser, and release checks. Deploy production only when the exact current release reports READY.
72
72
 
73
+ When the user asks to share a temporary preview, run `cosmo preview share .`. Explain that the generated address is public to anyone who has it, works only while the command remains running, and is not a production deployment. A missing `cloudflared` application is an optional-preview setup issue, not a project or release failure; follow Cosmo's displayed installation guidance and never request a Cloudflare API key for a Quick Tunnel.
74
+
73
75
  ## Switching agents
74
76
 
75
77
  Any supported agent may continue the project. Before switching, run appropriate checks and create `cosmo handoff create . --from <current-agent> --to <next-agent> --note "<completed work and open decisions>"`. The receiving agent must recover intent from the repository rather than prior chat history.
@@ -1,4 +1,4 @@
1
- <!-- cosmo-agent-version: 1.14.1 -->
1
+ <!-- cosmo-agent-version: 1.15.1 -->
2
2
  # Cosmo
3
3
 
4
4
  Use the Cosmo website-building workflow in the current workspace.
@@ -19,5 +19,6 @@ First, look for `.agents/skills/cosmo/SKILL.md` and follow it completely when pr
19
19
  - Use `cosmo doctor .` and `cosmo status . --json` to identify the next safe action.
20
20
  - Explain decisions conversationally so the user does not need to know Cosmo commands.
21
21
  - Ask whether a new or adopted project should include the optional AI-readable EntityMap. Never accept enrichment matches or approve it without explicit human review.
22
+ - If the user asks for a temporary public preview, run `cosmo preview share .`; explain that the address is public, works only while the command is running, and is not a deployment.
22
23
 
23
24
  If this is not yet a Cosmo project, guide the user through the smallest set of questions needed to start or adopt it. If it is already managed by Cosmo, continue the active stage and preserve every approved contract and handoff.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosmo",
3
- "version": "1.14.1",
3
+ "version": "1.15.1",
4
4
  "description": "Conversational launcher for starting, adopting, and resuming local-first Cosmo Astro website builds.",
5
5
  "author": {
6
6
  "name": "Cosmo"
@@ -130,6 +130,8 @@ At every stage:
130
130
 
131
131
  For design, explore at least three genuinely distinct directions and preserve the selected direction in repository artifacts. After the page plan is approved, run `cosmo copy brief --all . --replace`, complete each flexible annotated section contract, and obtain approval. Before drafting a page, run `cosmo copy guide <page-id> .` and follow its separate grounding, drafting, evidence, editorial, reader, and final passes. Never imitate a living writer, import private Lyra files, reproduce copyrighted source wording, fabricate reader psychology, or use unsupported attacks on an alternative. For generation, advance one page gate at a time and respect repair limits. For QA, run `cosmo copy check .` with integrity, content, intelligence, EntityMap when enabled, static, and browser checks. For production, require the exact current release to be READY.
132
132
 
133
+ When the user asks to share a temporary preview, run `cosmo preview share .`. Explain that the generated address is public to anyone who has it, works only while the command remains running, and is not a production deployment. A missing `cloudflared` application is an optional-preview setup issue, not a project or release failure; follow Cosmo's displayed installation guidance and never request a Cloudflare API key for a Quick Tunnel.
134
+
133
135
  ## Help mode
134
136
 
135
137
  If the user asks what Cosmo can do, lead with four choices: build a new website, continue a Cosmo website, improve an existing Astro website without converting it, or review/publish a website. Show the simple journey `Discover → Brand → Design → Copy and page plan → Build → Quality checks → Preview and launch`. Mention advanced capabilities only if relevant or requested, and end with one clear question.
@@ -30,4 +30,4 @@ cosmo browser check . --no-build
30
30
  cosmo release check .
31
31
  ```
32
32
 
33
- For deployment work, inspect `cosmo deploy status .` and `.cosmo/deploy/history.jsonl`. Review builds may use `cosmo deploy preview .`; production must use `cosmo deploy production .` after the exact current release reports READY. Keep provider credentials in process environment or a gitignored runtime env file. Never accept an EntityMap enrichment candidate or mark the map reviewed without explicit human approval. Never delete remote files implicitly.
33
+ For deployment work, inspect `cosmo deploy status .` and `.cosmo/deploy/history.jsonl`. A user asking for a temporary public link may use `cosmo preview share .`; make clear that it is public, process-bound, and not a deployment. Durable review builds may use `cosmo deploy preview .`; production must use `cosmo deploy production .` after the exact current release reports READY. Keep provider credentials in process environment or a gitignored runtime env file. Never accept an EntityMap enrichment candidate or mark the map reviewed without explicit human approval. Never delete remote files implicitly.
@@ -27,4 +27,4 @@ cosmo release check .
27
27
  cosmo handoff create . --from claude --to codex --note "Summary of the completed work and any open judgment calls"
28
28
  ```
29
29
 
30
- Use `cosmo deploy preview .` for review. Run `cosmo deploy production .` only after `cosmo release check .` reports READY. Provider credentials may come from process environment or a runtime `--env-file`; never write values into Cosmo config, history, handoffs, or tracked files. Never accept an EntityMap enrichment candidate or mark the map reviewed without explicit human approval.
30
+ Use `cosmo preview share .` when the user wants a temporary public link, and explain that it is public, process-bound, and not a deployment. Use `cosmo deploy preview .` for durable review. Run `cosmo deploy production .` only after `cosmo release check .` reports READY. Provider credentials may come from process environment or a runtime `--env-file`; never write values into Cosmo config, history, handoffs, or tracked files. Never accept an EntityMap enrichment candidate or mark the map reviewed without explicit human approval.
@@ -14,4 +14,4 @@ The initial home and about routes are neutral, `noindex` scaffolds. The build pl
14
14
 
15
15
  The starter uses the `lean` intelligence profile. Run `cosmo intelligence list` to inspect optional profiles and packs, then `cosmo intelligence apply <profile> .` and `cosmo intelligence scaffold .` before starting the workflow when the project needs additional authority, local, editorial, regulated, research, image-direction, or Claude Design gates.
16
16
 
17
- Optional deployment supports Cloudflare Pages, SFTP, FTPS, and acknowledged plain FTP. Copy `.env.example` to `.env.deploy` for local credentials; `.env` variants are ignored and their values must never be committed.
17
+ Run `cosmo preview share .` for an optional temporary public review link; it requires the free `cloudflared` application but no Cloudflare account or API key. Optional durable deployment supports Cloudflare Pages, SFTP, FTPS, and acknowledged plain FTP. Copy `.env.example` to `.env.deploy` for local credentials; `.env` variants are ignored and their values must never be committed.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmo/astro-starter",
3
- "version": "1.14.1",
3
+ "version": "1.15.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {