paracosm 0.7.443 → 0.7.450

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/README.md CHANGED
@@ -350,14 +350,28 @@ The dashboard includes a scenario editor where you can write, import, compile, a
350
350
 
351
351
  ### 4. Or run the standalone CLI
352
352
 
353
- After `npm install paracosm -g` you get two binaries:
353
+ After `npm install paracosm -g` you get one umbrella binary with subcommands. Every level supports `--help` / `-h` and a global `--version` / `-v`:
354
354
 
355
355
  ```bash
356
- paracosm # run one leader once; prints turn-by-turn narrative
357
- paracosm-dashboard 6 # start the web dashboard and run a 6-turn sim
356
+ paracosm --help # lists every subcommand
357
+ paracosm --version # prints "paracosm 0.7.x"
358
+
359
+ paracosm run # run a sim against leaders.json
360
+ paracosm run --leader 1 --turns 5 # leader index 1, 5 turns
361
+ paracosm run --name "Reyes" --openness 0.85 --conscientiousness 0.4 --turns 6
362
+ paracosm run --leaders ./my-leaders.json --live # custom roster + live web search
363
+
364
+ paracosm dashboard # SSE dashboard at http://localhost:3456
365
+ paracosm dashboard 6 # auto-launch with 6 turns
366
+
367
+ paracosm compile scenarios/lunar.json --seed-url <url> --max-searches 5
368
+
369
+ paracosm init my-app --domain "Submarine crew of 8" --leaders 3
358
370
  ```
359
371
 
360
- Both CLIs look for `leaders.json` in this order:
372
+ A second back-compat binary `paracosm-dashboard` is shipped as an alias for `paracosm dashboard` so existing scripts and Docker invocations don't break.
373
+
374
+ The CLI looks for `leaders.json` in this order:
361
375
 
362
376
  1. `--leaders <path>` flag (explicit)
363
377
  2. `./leaders.json` in your current directory
@@ -644,11 +658,11 @@ Pass real-world source material into the compiler and Paracosm grounds the scena
644
658
 
645
659
  ```bash
646
660
  # Inline text seed
647
- npx paracosm compile scenarios/lunar.json \
661
+ paracosm compile scenarios/lunar.json \
648
662
  --seed-text "$(cat ./papers/iss-radiation-overview.md)"
649
663
 
650
664
  # URL seed (Firecrawl extracts clean markdown)
651
- npx paracosm compile scenarios/lunar.json \
665
+ paracosm compile scenarios/lunar.json \
652
666
  --seed-url https://ntrs.nasa.gov/citations/20210018970
653
667
  ```
654
668
 
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * CLI: Compile a scenario JSON draft into a runnable ScenarioPackage.
3
+ * Compile a scenario JSON draft. Thin shim around the dispatcher's
4
+ * compile handler so existing `npx tsx src/cli/compile.ts ...` calls
5
+ * still work. Callers on a published install should prefer
6
+ * `paracosm compile`.
4
7
  *
5
- * Usage:
6
- * npx tsx src/cli/compile.ts scenarios/submarine.json
7
- * npx tsx src/cli/compile.ts scenarios/submarine.json --provider anthropic --model claude-sonnet-4-6
8
- * npx tsx src/cli/compile.ts scenarios/submarine.json --no-cache
8
+ * @module paracosm/cli/compile
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=compile.d.ts.map
@@ -1,92 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * CLI: Compile a scenario JSON draft into a runnable ScenarioPackage.
3
+ * Compile a scenario JSON draft. Thin shim around the dispatcher's
4
+ * compile handler so existing `npx tsx src/cli/compile.ts ...` calls
5
+ * still work. Callers on a published install should prefer
6
+ * `paracosm compile`.
4
7
  *
5
- * Usage:
6
- * npx tsx src/cli/compile.ts scenarios/submarine.json
7
- * npx tsx src/cli/compile.ts scenarios/submarine.json --provider anthropic --model claude-sonnet-4-6
8
- * npx tsx src/cli/compile.ts scenarios/submarine.json --no-cache
8
+ * @module paracosm/cli/compile
9
9
  */
10
- import { readFileSync } from 'node:fs';
11
- import { resolve } from 'node:path';
12
- import { compileScenario } from '../engine/compiler/index.js';
13
- import { parseCompileCliOptions } from './compile-cli-options.js';
14
- async function main() {
15
- const rawArgs = process.argv.slice(2);
16
- const options = parseCompileCliOptions(rawArgs);
17
- if (rawArgs.length === 0 || rawArgs.includes('--help') || rawArgs.includes('-h')) {
18
- console.log(`
19
- paracosm compile - Generate runtime hooks for a scenario JSON draft
20
-
21
- Usage:
22
- npx tsx src/cli/compile.ts <scenario.json> [options]
23
-
24
- Options:
25
- --provider <provider> LLM provider: openai | anthropic (default: anthropic)
26
- --model <model> Model name (default: claude-sonnet-4-6)
27
- --no-cache Skip disk cache
28
- --cache-dir <dir> Cache directory (default: .paracosm/cache)
29
- --seed-text <text> Ground the scenario with an inline prompt, brief, or document
30
- --seed-url <url> Ground the scenario with a URL before hook generation
31
- --no-web-search Skip live citation grounding during seed ingestion
32
- --max-searches <n> Cap the number of live grounding searches during seed ingestion
33
- -h, --help Show this help
34
- `);
35
- process.exit(0);
36
- }
37
- if (!options.scenarioPath) {
38
- console.error(' Scenario JSON path required. Run with --help for usage.');
39
- process.exit(1);
40
- }
41
- const jsonPath = resolve(options.scenarioPath);
42
- console.log(`\n Compiling scenario: ${jsonPath}`);
43
- console.log(` Provider: ${options.provider} | Model: ${options.model} | Cache: ${options.cache}`);
44
- if (options.seedUrl) {
45
- console.log(` Seed URL: ${options.seedUrl} | Web search: ${options.webSearch} | Max searches: ${options.maxSearches ?? 5}`);
46
- }
47
- else if (options.seedText) {
48
- console.log(` Seed text: ${Math.min(options.seedText.length, 160)} chars | Web search: ${options.webSearch} | Max searches: ${options.maxSearches ?? 5}`);
49
- }
50
- console.log();
51
- let scenarioJson;
52
- try {
53
- scenarioJson = JSON.parse(readFileSync(jsonPath, 'utf-8'));
54
- }
55
- catch (err) {
56
- console.error(` Error reading ${jsonPath}: ${err}`);
57
- process.exit(1);
58
- }
59
- const scenario = await compileScenario(scenarioJson, {
60
- provider: options.provider,
61
- model: options.model,
62
- cache: options.cache,
63
- cacheDir: options.cacheDir,
64
- seedText: options.seedText,
65
- seedUrl: options.seedUrl,
66
- webSearch: options.webSearch,
67
- maxSearches: options.maxSearches,
68
- onProgress(hookName, status) {
69
- const icons = {
70
- generating: '...',
71
- cached: '(cached)',
72
- done: 'done',
73
- fallback: 'FALLBACK',
74
- };
75
- if (status === 'generating') {
76
- process.stdout.write(` Generating ${hookName}... `);
77
- }
78
- else {
79
- console.log(icons[status] ?? status);
80
- }
81
- },
82
- });
83
- console.log(`\n Scenario compiled: ${scenario.id} v${scenario.version}`);
84
- console.log(` Departments: ${scenario.departments.map(d => d.id).join(', ')}`);
85
- console.log(` Hooks: ${Object.keys(scenario.hooks).filter(k => scenario.hooks[k]).join(', ')}`);
86
- console.log(` Ready for: runSimulation(leader, personnel, { scenario })\n`);
10
+ import { runCompile } from './run-compile.js';
11
+ import { printCommandHelp } from './help.js';
12
+ const argv = process.argv.slice(2);
13
+ if (argv.length === 0 || argv.includes('--help') || argv.includes('-h')) {
14
+ printCommandHelp('compile');
15
+ process.exit(0);
87
16
  }
88
- main().catch((err) => {
89
- console.error('Compile failed:', err);
17
+ runCompile(argv).then((exitCode) => {
18
+ process.exit(exitCode);
19
+ }).catch((err) => {
20
+ process.stderr.write(`Compile failed: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
90
21
  process.exit(1);
91
22
  });
92
23
  //# sourceMappingURL=compile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/cli/compile.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjF,OAAO,CAAC,GAAG,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MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Help text for the paracosm CLI router. Single source of truth so
3
+ * `paracosm --help`, `paracosm run --help`, etc. all stay in sync.
4
+ *
5
+ * @module paracosm/cli/help
6
+ */
7
+ /**
8
+ * Print top-level help to stdout.
9
+ */
10
+ export declare function printTopLevelHelp(): void;
11
+ /**
12
+ * Print help for a specific subcommand. Falls back to top-level help when
13
+ * the command is unknown.
14
+ */
15
+ export declare function printCommandHelp(command: string): void;
16
+ /**
17
+ * Read paracosm's own version from the package.json shipped with the
18
+ * installed package. Looks two directories up from `dist/cli/help.js`
19
+ * (the published location), and one directory up from
20
+ * `src/cli/help.ts` (when running via tsx during development).
21
+ */
22
+ export declare function readPackageVersion(): string;
23
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiIH;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAQtD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAmB3C"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Help text for the paracosm CLI router. Single source of truth so
3
+ * `paracosm --help`, `paracosm run --help`, etc. all stay in sync.
4
+ *
5
+ * @module paracosm/cli/help
6
+ */
7
+ import { readFileSync } from 'node:fs';
8
+ import { resolve, dirname } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ const TOP_LEVEL_HELP = `paracosm <command> [options]
11
+
12
+ A structured world model for AI agents. Compile prompts, briefs, URLs, or
13
+ JSON contracts into typed scenarios. Run HEXACO-personality leaders against
14
+ a deterministic kernel.
15
+
16
+ Commands:
17
+ run Run a simulation against leaders.json
18
+ dashboard Start the SSE web dashboard at http://localhost:3456
19
+ compile <scenario> Compile a scenario draft into runnable hooks (cached)
20
+ init <dir> Scaffold a starter project from a free-text brief
21
+ help [command] Show help for a specific command
22
+ version Print version
23
+
24
+ Global flags:
25
+ --help, -h Show help (works on every subcommand)
26
+ --version, -v Print version
27
+
28
+ Examples:
29
+ paracosm run # default leader, full turns
30
+ paracosm run --leader 1 --turns 5 # leader index 1, 5 turns
31
+ paracosm run --name "Reyes" --openness 0.85 6 # inline HEXACO override
32
+ paracosm dashboard --turns 6 # opens browser dashboard
33
+ paracosm compile scenarios/lunar.json --seed-url <url> # compile + cache
34
+ paracosm init my-app --domain "Submarine crew of 8" # scaffold a project
35
+
36
+ Docs: https://paracosm.agentos.sh/docs
37
+ GitHub: https://github.com/framersai/paracosm
38
+ `;
39
+ const RUN_HELP = `paracosm run [options]
40
+
41
+ Run a simulation against leaders.json (or --leaders <path>) and print
42
+ turn-by-turn narrative to stdout. Saves the full RunArtifact JSON to
43
+ ./output/v3-<archetype>-<timestamp>.json (override with PARACOSM_OUTPUT_DIR).
44
+
45
+ Options:
46
+ --leader <n> Leader index in leaders.json (default: 0)
47
+ --leaders <path> Custom leaders.json path
48
+ --turns <n> Override turn count
49
+ --seed <n> Override seed
50
+ --start-time <n> Override start time / year
51
+ --provider <p> openai | anthropic (defaults to whichever key is set)
52
+ --cost <p> quality | economy (default: quality)
53
+ --live Enable live web search during department analysis
54
+ --name <s> Override leader name
55
+ --archetype <s> Override leader archetype
56
+ --unit <s> Override leader unit
57
+ --instructions <s> Override leader instructions
58
+ --openness <0-1> HEXACO openness override
59
+ --conscientiousness <0-1>
60
+ --extraversion <0-1>
61
+ --agreeableness <0-1>
62
+ --emotionality <0-1>
63
+ --honesty <0-1> HEXACO honesty-humility override
64
+
65
+ Positional turn count: a single trailing number is read as --turns
66
+ paracosm run 5 # equivalent to: paracosm run --turns 5
67
+ `;
68
+ const DASHBOARD_HELP = `paracosm dashboard [turns] [options]
69
+
70
+ Start the SSE web dashboard at http://localhost:3456 (override with PORT).
71
+ The dashboard exposes the Setup, Reports, Library, Branches, Viz, and Chat
72
+ tabs over a streaming connection. Without [turns], waits for setup at
73
+ /sim?tab=settings; with [turns], auto-launches a simulation on boot.
74
+
75
+ Options:
76
+ [turns] Auto-launch with N turns. Omit to wait for setup.
77
+ --leaders <path> Custom leaders.json path
78
+ --seed <n> Override seed
79
+ --start-time <n> Override start time
80
+ --provider <p> openai | anthropic
81
+ --live Enable live web search
82
+
83
+ Environment:
84
+ PORT Dashboard port (default: 3456)
85
+ PARACOSM_ENABLE_SIMULATE_ENDPOINT=true Enable POST /simulate one-shot endpoint
86
+ `;
87
+ const COMPILE_HELP = `paracosm compile <scenario.json> [options]
88
+
89
+ Compile a scenario JSON draft into a runnable ScenarioPackage with generated
90
+ TypeScript hooks. Caches per-hook on (scenario hash + model + schema version)
91
+ so re-runs hit disk. Cost: roughly $0.10 per first compile, free thereafter.
92
+
93
+ Options:
94
+ <scenario.json> Required: path to a scenario JSON draft
95
+ --provider <p> openai | anthropic (default: anthropic)
96
+ --model <m> Model name (default: claude-sonnet-4-6)
97
+ --no-cache Skip disk cache; force regeneration
98
+ --cache-dir <dir> Cache directory (default: .paracosm/cache)
99
+ --seed-text <s> Ground the scenario with an inline brief
100
+ --seed-url <url> Ground the scenario with a URL (Firecrawl extraction)
101
+ --no-web-search Skip live citation grounding during seed ingestion
102
+ --max-searches <n> Cap live grounding searches (default: 5)
103
+ `;
104
+ const INIT_HELP = `paracosm init <dir> --domain <text|url> [options]
105
+
106
+ Scaffold a runnable paracosm project from a free-text brief or a URL.
107
+ Calls compileFromSeed + generateQuickstartLeaders, then writes
108
+ package.json, run.mjs, README.md, .env.example, .gitignore to <dir>.
109
+
110
+ Options:
111
+ <dir> Output directory (default: ./paracosm-app)
112
+ --domain <text|url> Required: seed text or URL describing the scenario
113
+ --mode <m> turn-loop | batch-trajectory | batch-point (default: turn-loop)
114
+ --leaders <n> Number of HEXACO leaders, 2-6 (default: 3)
115
+ --name <s> Project name (default: derived from --domain)
116
+ --force Overwrite a non-empty target directory
117
+
118
+ Example:
119
+ paracosm init my-app --domain "Submarine crew of 8 in deep ocean for 30 days"
120
+ `;
121
+ const HELP_BY_COMMAND = {
122
+ run: RUN_HELP,
123
+ dashboard: DASHBOARD_HELP,
124
+ compile: COMPILE_HELP,
125
+ init: INIT_HELP,
126
+ };
127
+ /**
128
+ * Print top-level help to stdout.
129
+ */
130
+ export function printTopLevelHelp() {
131
+ process.stdout.write(TOP_LEVEL_HELP);
132
+ }
133
+ /**
134
+ * Print help for a specific subcommand. Falls back to top-level help when
135
+ * the command is unknown.
136
+ */
137
+ export function printCommandHelp(command) {
138
+ const text = HELP_BY_COMMAND[command];
139
+ if (text) {
140
+ process.stdout.write(text);
141
+ }
142
+ else {
143
+ process.stdout.write(`Unknown command: ${command}\n\n`);
144
+ process.stdout.write(TOP_LEVEL_HELP);
145
+ }
146
+ }
147
+ /**
148
+ * Read paracosm's own version from the package.json shipped with the
149
+ * installed package. Looks two directories up from `dist/cli/help.js`
150
+ * (the published location), and one directory up from
151
+ * `src/cli/help.ts` (when running via tsx during development).
152
+ */
153
+ export function readPackageVersion() {
154
+ const here = dirname(fileURLToPath(import.meta.url));
155
+ // dist/cli/help.js -> dist/.. -> package root
156
+ // src/cli/help.ts -> src/.. -> package root
157
+ const candidates = [
158
+ resolve(here, '..', '..', 'package.json'),
159
+ resolve(here, '..', 'package.json'),
160
+ ];
161
+ for (const candidate of candidates) {
162
+ try {
163
+ const pkg = JSON.parse(readFileSync(candidate, 'utf-8'));
164
+ if (pkg.name === 'paracosm' && typeof pkg.version === 'string') {
165
+ return pkg.version;
166
+ }
167
+ }
168
+ catch {
169
+ // Try next candidate.
170
+ }
171
+ }
172
+ return 'unknown';
173
+ }
174
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceR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AAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,8CAA8C;IAC9C,8CAA8C;IAC9C,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;KACpC,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAwC,CAAC;YAChG,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC/D,OAAO,GAAG,CAAC,OAAO,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,sBAAsB;QACxB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Subcommand dispatcher for `paracosm <command>`. Lives separately
3
+ * from run.ts so it can be unit-tested without the binary's
4
+ * process-exit path firing.
5
+ *
6
+ * Recognized subcommands:
7
+ * run, dashboard, compile, init, help, version
8
+ *
9
+ * Global flags `--help`/`-h` and `--version`/`-v` short-circuit at
10
+ * any position before subcommand parsing.
11
+ *
12
+ * Back-compat path: when argv has neither a recognized subcommand nor
13
+ * a global flag, dispatch falls through to `run` and the result carries
14
+ * a one-line `deprecation` hint the binary surfaces to stderr.
15
+ *
16
+ * @module paracosm/cli/router
17
+ */
18
+ export interface DispatchResult {
19
+ /** Process exit code returned by the subcommand handler. */
20
+ exitCode: number;
21
+ /** Deprecation message for the binary to print to stderr, if any. */
22
+ deprecation?: string;
23
+ }
24
+ /**
25
+ * Dispatch argv to the appropriate subcommand handler. Pure: no
26
+ * process.exit, no top-level await side effects.
27
+ */
28
+ export declare function dispatch(argv: readonly string[]): Promise<DispatchResult>;
29
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/cli/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA0BH,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA2BD;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAkF/E"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Subcommand dispatcher for `paracosm <command>`. Lives separately
3
+ * from run.ts so it can be unit-tested without the binary's
4
+ * process-exit path firing.
5
+ *
6
+ * Recognized subcommands:
7
+ * run, dashboard, compile, init, help, version
8
+ *
9
+ * Global flags `--help`/`-h` and `--version`/`-v` short-circuit at
10
+ * any position before subcommand parsing.
11
+ *
12
+ * Back-compat path: when argv has neither a recognized subcommand nor
13
+ * a global flag, dispatch falls through to `run` and the result carries
14
+ * a one-line `deprecation` hint the binary surfaces to stderr.
15
+ *
16
+ * @module paracosm/cli/router
17
+ */
18
+ import { printTopLevelHelp, printCommandHelp, readPackageVersion } from './help.js';
19
+ const KNOWN_COMMANDS = new Set([
20
+ 'run',
21
+ 'dashboard',
22
+ 'compile',
23
+ 'init',
24
+ 'help',
25
+ 'version',
26
+ ]);
27
+ /**
28
+ * Sim flags that the legacy `paracosm <flags>` (no subcommand) form
29
+ * accepted. When any of these appear in argv with no subcommand, the
30
+ * router falls through to `run` with a deprecation hint instead of
31
+ * printing help and exiting.
32
+ */
33
+ const LEGACY_RUN_FLAGS = new Set([
34
+ '--leader', '--leaders', '--name', '--archetype', '--unit', '--instructions',
35
+ '--openness', '--conscientiousness', '--extraversion', '--agreeableness',
36
+ '--emotionality', '--honesty', '--turns', '--seed', '--start-time',
37
+ '--provider', '--cost', '--live',
38
+ ]);
39
+ /**
40
+ * Inspect argv for a global short-circuit (`--help`, `-h`,
41
+ * `--version`, `-v`) without consuming positional args.
42
+ */
43
+ function checkGlobalFlags(argv) {
44
+ for (const arg of argv) {
45
+ if (arg === '--help' || arg === '-h')
46
+ return 'help';
47
+ if (arg === '--version' || arg === '-v')
48
+ return 'version';
49
+ }
50
+ return null;
51
+ }
52
+ /**
53
+ * Detect whether legacy bare-command sim invocations were used.
54
+ * Heuristic: argv has no recognized subcommand at index 0, and at
55
+ * least one entry is a known sim flag OR a positional integer.
56
+ */
57
+ function looksLikeLegacyRun(argv) {
58
+ for (const arg of argv) {
59
+ if (LEGACY_RUN_FLAGS.has(arg))
60
+ return true;
61
+ if (/^\d+$/.test(arg))
62
+ return true;
63
+ }
64
+ return false;
65
+ }
66
+ /**
67
+ * Dispatch argv to the appropriate subcommand handler. Pure: no
68
+ * process.exit, no top-level await side effects.
69
+ */
70
+ export async function dispatch(argv) {
71
+ // Global short-circuits first; they win at any position.
72
+ const global = checkGlobalFlags(argv);
73
+ if (global === 'version') {
74
+ process.stdout.write(`paracosm ${readPackageVersion()}\n`);
75
+ return { exitCode: 0 };
76
+ }
77
+ if (global === 'help' && (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h')) {
78
+ printTopLevelHelp();
79
+ return { exitCode: 0 };
80
+ }
81
+ const [command, ...rest] = argv;
82
+ // No args: print help.
83
+ if (!command) {
84
+ printTopLevelHelp();
85
+ return { exitCode: 0 };
86
+ }
87
+ // `--help` / `-h` after a known subcommand: print that command's help.
88
+ const commandHelpFlagPresent = rest.includes('--help') || rest.includes('-h');
89
+ if (KNOWN_COMMANDS.has(command) && commandHelpFlagPresent) {
90
+ printCommandHelp(command);
91
+ return { exitCode: 0 };
92
+ }
93
+ switch (command) {
94
+ case 'help': {
95
+ const target = rest[0];
96
+ if (target) {
97
+ printCommandHelp(target);
98
+ }
99
+ else {
100
+ printTopLevelHelp();
101
+ }
102
+ return { exitCode: 0 };
103
+ }
104
+ case 'version': {
105
+ process.stdout.write(`paracosm ${readPackageVersion()}\n`);
106
+ return { exitCode: 0 };
107
+ }
108
+ case 'run': {
109
+ const { runSim } = await import('./run-sim.js');
110
+ const exitCode = await runSim(rest);
111
+ return { exitCode };
112
+ }
113
+ case 'dashboard': {
114
+ const { runDashboard } = await import('./run-dashboard.js');
115
+ const exitCode = await runDashboard(rest);
116
+ return { exitCode };
117
+ }
118
+ case 'compile': {
119
+ const { runCompile } = await import('./run-compile.js');
120
+ const exitCode = await runCompile(rest);
121
+ return { exitCode };
122
+ }
123
+ case 'init': {
124
+ const { runInit } = await import('./init.js');
125
+ const exitCode = await runInit(rest);
126
+ return { exitCode };
127
+ }
128
+ default:
129
+ // Legacy fallthrough: bare `paracosm --leader 0 6` etc. dispatched
130
+ // to `run` with a deprecation hint. Removal scheduled for 0.8.0.
131
+ if (looksLikeLegacyRun(argv)) {
132
+ const { runSim } = await import('./run-sim.js');
133
+ const exitCode = await runSim(argv);
134
+ return {
135
+ exitCode,
136
+ deprecation: 'bare `paracosm <flags>` is deprecated; use `paracosm run <flags>` instead. Removal in 0.8.0.',
137
+ };
138
+ }
139
+ process.stderr.write(`Unknown command: ${command}\n\n`);
140
+ printTopLevelHelp();
141
+ return { exitCode: 1 };
142
+ }
143
+ }
144
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/cli/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,KAAK;IACL,WAAW;IACX,SAAS;IACT,MAAM;IACN,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG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xD,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Implementation of `paracosm compile`. Extracted from compile.ts so
3
+ * the subcommand router can dispatch to it without process-level side
4
+ * effects firing on import.
5
+ *
6
+ * @module paracosm/cli/run-compile
7
+ */
8
+ /**
9
+ * Compile a scenario JSON draft. Returns a process exit code.
10
+ */
11
+ export declare function runCompile(argv: readonly string[]): Promise<number>;
12
+ //# sourceMappingURL=run-compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-compile.d.ts","sourceRoot":"","sources":["../../src/cli/run-compile.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8DzE"}