@a-company/paradigm 1.5.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 (114) hide show
  1. package/README.md +142 -0
  2. package/dist/accept-orchestration-CWZNCGZX.js +188 -0
  3. package/dist/agents-suggest-35LIQKDH.js +83 -0
  4. package/dist/aggregate-W7Q6VIM2.js +88 -0
  5. package/dist/auto-IU7VN55K.js +470 -0
  6. package/dist/beacon-B47XSTL7.js +251 -0
  7. package/dist/chunk-2M6OSOIG.js +1302 -0
  8. package/dist/chunk-4NCFWYGG.js +110 -0
  9. package/dist/chunk-5C4SGQKH.js +705 -0
  10. package/dist/chunk-5GOA7WYD.js +1095 -0
  11. package/dist/chunk-5JGJACDU.js +37 -0
  12. package/dist/chunk-6QC3YGB6.js +114 -0
  13. package/dist/chunk-753RICFF.js +325 -0
  14. package/dist/chunk-AD2LSCHB.js +1595 -0
  15. package/dist/chunk-CHSHON3O.js +669 -0
  16. package/dist/chunk-ELLR7WP6.js +3175 -0
  17. package/dist/chunk-ILOWBJRC.js +12 -0
  18. package/dist/chunk-IRKUEJVW.js +405 -0
  19. package/dist/chunk-MC7XC7XQ.js +533 -0
  20. package/dist/chunk-MO4EEYFW.js +38 -0
  21. package/dist/chunk-MQWH7PFI.js +13366 -0
  22. package/dist/chunk-N6PJAPDE.js +364 -0
  23. package/dist/chunk-PBHIFAL4.js +259 -0
  24. package/dist/chunk-PMXRGPRQ.js +305 -0
  25. package/dist/chunk-PW2EXJQT.js +689 -0
  26. package/dist/chunk-TAP5N3HH.js +245 -0
  27. package/dist/chunk-THFVK5AE.js +148 -0
  28. package/dist/chunk-UM54F7G5.js +1533 -0
  29. package/dist/chunk-UUZ2DMG5.js +185 -0
  30. package/dist/chunk-WS5KM7OL.js +780 -0
  31. package/dist/chunk-YDNKXH4Z.js +2316 -0
  32. package/dist/chunk-YO6DVTL7.js +99 -0
  33. package/dist/claude-SUYNN72C.js +362 -0
  34. package/dist/claude-cli-OF43XAO3.js +276 -0
  35. package/dist/claude-code-PW6SKD2M.js +126 -0
  36. package/dist/claude-code-teams-JLZ5IXB6.js +199 -0
  37. package/dist/constellation-K3CIQCHI.js +225 -0
  38. package/dist/cost-AEK6R7HK.js +174 -0
  39. package/dist/cost-KYXIQ62X.js +93 -0
  40. package/dist/cursor-cli-IHJMPRCW.js +269 -0
  41. package/dist/cursorrules-KI5QWHIX.js +84 -0
  42. package/dist/diff-AJJ5H6HV.js +125 -0
  43. package/dist/dist-7MPIRMTZ-IOQOREMZ.js +10866 -0
  44. package/dist/dist-NHJQVVUW.js +68 -0
  45. package/dist/dist-ZEMSQV74.js +20 -0
  46. package/dist/doctor-6Y6L6HEB.js +11 -0
  47. package/dist/echo-VYZW3OTT.js +248 -0
  48. package/dist/export-R4FJ5NOH.js +38 -0
  49. package/dist/history-EVO3L6SC.js +277 -0
  50. package/dist/hooks-MBWE4ILT.js +12 -0
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +568 -0
  53. package/dist/lint-HXKTWRNO.js +316 -0
  54. package/dist/manual-Y3QOXWYA.js +204 -0
  55. package/dist/mcp.js +14745 -0
  56. package/dist/orchestrate-4ZH5GUQH.js +323 -0
  57. package/dist/probe-OYCP4JYG.js +151 -0
  58. package/dist/promote-Z52ZJTJU.js +181 -0
  59. package/dist/providers-4PGPZEWP.js +104 -0
  60. package/dist/remember-6VZ74B7E.js +77 -0
  61. package/dist/ripple-SBQOSTZD.js +215 -0
  62. package/dist/sentinel-LCFD56OJ.js +43 -0
  63. package/dist/server-F5ITNK6T.js +9846 -0
  64. package/dist/server-T6WIFYRQ.js +16076 -0
  65. package/dist/setup-DF4F3ICN.js +25 -0
  66. package/dist/setup-JHBPZAG7.js +296 -0
  67. package/dist/shift-HKIAP4ZN.js +226 -0
  68. package/dist/snapshot-GTVPRYZG.js +62 -0
  69. package/dist/spawn-BJRQA2NR.js +196 -0
  70. package/dist/summary-H6J6N6PJ.js +140 -0
  71. package/dist/switch-6EANJ7O6.js +232 -0
  72. package/dist/sync-BEOCW7TZ.js +11 -0
  73. package/dist/team-NWP2KJAB.js +32 -0
  74. package/dist/test-MA5TWJQV.js +934 -0
  75. package/dist/thread-JCJVRUQR.js +258 -0
  76. package/dist/triage-ETVXXFMV.js +1880 -0
  77. package/dist/tutorial-L5Q3ZDHK.js +666 -0
  78. package/dist/university-R2WDQLSI.js +40 -0
  79. package/dist/upgrade-5B3YGGC6.js +550 -0
  80. package/dist/validate-F3YHBCRZ.js +39 -0
  81. package/dist/validate-QEEY6KFS.js +64 -0
  82. package/dist/watch-4LT4O6K7.js +123 -0
  83. package/dist/watch-6IIWPWDN.js +111 -0
  84. package/dist/wisdom-LRM4FFCH.js +319 -0
  85. package/package.json +68 -0
  86. package/templates/paradigm/config.yaml +175 -0
  87. package/templates/paradigm/docs/commands.md +727 -0
  88. package/templates/paradigm/docs/decisions/000-template.md +47 -0
  89. package/templates/paradigm/docs/decisions/README.md +26 -0
  90. package/templates/paradigm/docs/error-patterns.md +215 -0
  91. package/templates/paradigm/docs/patterns.md +358 -0
  92. package/templates/paradigm/docs/queries.md +200 -0
  93. package/templates/paradigm/docs/troubleshooting.md +477 -0
  94. package/templates/paradigm/echoes.yaml +25 -0
  95. package/templates/paradigm/prompts/add-feature.md +152 -0
  96. package/templates/paradigm/prompts/add-gate.md +117 -0
  97. package/templates/paradigm/prompts/debug-auth.md +174 -0
  98. package/templates/paradigm/prompts/implement-ftux.md +722 -0
  99. package/templates/paradigm/prompts/implement-sandbox.md +651 -0
  100. package/templates/paradigm/prompts/read-docs.md +84 -0
  101. package/templates/paradigm/prompts/refactor.md +106 -0
  102. package/templates/paradigm/prompts/run-e2e-tests.md +340 -0
  103. package/templates/paradigm/prompts/trace-flow.md +202 -0
  104. package/templates/paradigm/prompts/validate-portals.md +279 -0
  105. package/templates/paradigm/specs/context-tracking.md +200 -0
  106. package/templates/paradigm/specs/context.md +461 -0
  107. package/templates/paradigm/specs/disciplines.md +413 -0
  108. package/templates/paradigm/specs/history.md +339 -0
  109. package/templates/paradigm/specs/logger.md +303 -0
  110. package/templates/paradigm/specs/navigator.md +236 -0
  111. package/templates/paradigm/specs/purpose.md +265 -0
  112. package/templates/paradigm/specs/scan.md +177 -0
  113. package/templates/paradigm/specs/symbols.md +451 -0
  114. package/templates/paradigm/specs/wisdom.md +294 -0
@@ -0,0 +1,550 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ detectIDE,
4
+ loadParadigmFiles,
5
+ syncToIDE
6
+ } from "./chunk-YDNKXH4Z.js";
7
+ import {
8
+ parseParadigmConfig,
9
+ serializeParadigmConfig
10
+ } from "./chunk-YO6DVTL7.js";
11
+ import "./chunk-MO4EEYFW.js";
12
+
13
+ // src/commands/upgrade.ts
14
+ import * as fs from "fs";
15
+ import * as path from "path";
16
+ import { fileURLToPath } from "url";
17
+ import chalk from "chalk";
18
+ import ora from "ora";
19
+ var AVAILABLE_FEATURES = ["scan", "logger", "migrate"];
20
+ function getTemplatesDir() {
21
+ const __filename = fileURLToPath(import.meta.url);
22
+ const __dirname = path.dirname(__filename);
23
+ const possiblePaths = [
24
+ path.join(__dirname, "..", "..", "templates", "paradigm"),
25
+ path.join(__dirname, "..", "templates", "paradigm")
26
+ ];
27
+ for (const p of possiblePaths) {
28
+ if (fs.existsSync(p)) {
29
+ return p;
30
+ }
31
+ }
32
+ return path.join(__dirname, "..", "templates", "paradigm");
33
+ }
34
+ async function upgradeCommand(targetPath, options) {
35
+ const rootDir = targetPath ? path.resolve(targetPath) : process.cwd();
36
+ const projectName = path.basename(rootDir);
37
+ const spinner = ora();
38
+ console.log(chalk.blue("\n\u{1F504} Paradigm Upgrade\n"));
39
+ if (options.fromHorizon) {
40
+ const result = await migrateFromHorizon(rootDir, projectName, options, spinner);
41
+ console.log(chalk.blue("\n\u{1F4CB} Migration Summary\n"));
42
+ const icon = result.status === "added" || result.status === "updated" ? chalk.green("\u2713") : result.status === "skipped" ? chalk.yellow("\u25CB") : chalk.red("\u2717");
43
+ console.log(` ${icon} ${chalk.bold(result.feature)}: ${result.message}`);
44
+ console.log();
45
+ if (result.status === "updated" || result.status === "added") {
46
+ console.log(chalk.blue("Next steps:\n"));
47
+ console.log(chalk.gray(" \u2022 Verify the migration:"));
48
+ console.log(chalk.cyan(" paradigm doctor\n"));
49
+ console.log(chalk.gray(" \u2022 Regenerate IDE files:"));
50
+ console.log(chalk.cyan(" paradigm sync\n"));
51
+ }
52
+ return;
53
+ }
54
+ let features = [];
55
+ if (options.all) {
56
+ features = ["migrate", "scan", "logger"];
57
+ } else if (options.features && options.features.length > 0) {
58
+ features = options.features.filter(
59
+ (f) => AVAILABLE_FEATURES.includes(f)
60
+ );
61
+ } else {
62
+ console.log(chalk.yellow("No features specified. Available upgrades:\n"));
63
+ console.log(chalk.cyan(" migrate") + chalk.gray(" - Migrate from .paradigm file to .paradigm/ directory"));
64
+ console.log(chalk.cyan(" scan") + chalk.gray(" - Add visual discovery (paradigm probe) support"));
65
+ console.log(chalk.cyan(" logger") + chalk.gray(" - Add Paradigm logger specification"));
66
+ console.log(chalk.cyan(" all") + chalk.gray(" - Apply all available upgrades"));
67
+ console.log(chalk.cyan(" --from-horizon") + chalk.gray(" - Migrate from Horizon to Paradigm"));
68
+ console.log();
69
+ console.log(chalk.gray("Usage:"));
70
+ console.log(chalk.gray(" paradigm upgrade --features scan"));
71
+ console.log(chalk.gray(" paradigm upgrade --features logger"));
72
+ console.log(chalk.gray(" paradigm upgrade --all"));
73
+ console.log(chalk.gray(" paradigm upgrade --from-horizon"));
74
+ console.log();
75
+ return;
76
+ }
77
+ const results = [];
78
+ const paradigmPath = path.join(rootDir, ".paradigm");
79
+ const exists = fs.existsSync(paradigmPath);
80
+ const isLegacyFile = exists && fs.statSync(paradigmPath).isFile();
81
+ const isDirectory = exists && fs.statSync(paradigmPath).isDirectory();
82
+ if (features.includes("migrate") || isLegacyFile && options.all) {
83
+ if (isLegacyFile) {
84
+ results.push(await migrateLegacy(rootDir, projectName, options, spinner));
85
+ } else if (isDirectory) {
86
+ results.push({
87
+ feature: "migrate",
88
+ status: "skipped",
89
+ message: "Already using .paradigm/ directory format"
90
+ });
91
+ } else {
92
+ results.push({
93
+ feature: "migrate",
94
+ status: "error",
95
+ message: "No .paradigm found to migrate"
96
+ });
97
+ }
98
+ }
99
+ const paradigmDir = path.join(rootDir, ".paradigm");
100
+ const hasParadigmDir = fs.existsSync(paradigmDir) && fs.statSync(paradigmDir).isDirectory();
101
+ if (!hasParadigmDir && !options.dryRun) {
102
+ if (!isLegacyFile) {
103
+ console.log(chalk.yellow("\u26A0\uFE0F No .paradigm/ directory found."));
104
+ console.log(chalk.gray(" Run `paradigm init` first to initialize Paradigm.\n"));
105
+ return;
106
+ }
107
+ }
108
+ for (const feature of features) {
109
+ if (feature === "migrate") continue;
110
+ switch (feature) {
111
+ case "scan":
112
+ results.push(await upgradeScan(rootDir, projectName, options, spinner));
113
+ break;
114
+ case "logger":
115
+ results.push(await upgradeLogger(rootDir, options, spinner));
116
+ break;
117
+ }
118
+ }
119
+ if (!options.dryRun && results.some((r) => r.status === "added" || r.status === "updated")) {
120
+ spinner.start("Re-syncing IDE files...");
121
+ const files = loadParadigmFiles(rootDir);
122
+ if (files) {
123
+ const detection = detectIDE(rootDir);
124
+ if (detection.detected) {
125
+ const result = syncToIDE(rootDir, detection.detected, files, true);
126
+ if (result.success) {
127
+ spinner.succeed(`IDE files synced (${detection.detected})`);
128
+ } else {
129
+ spinner.warn("Could not sync IDE files");
130
+ }
131
+ } else {
132
+ spinner.info("No IDE detected, run `paradigm sync` to generate IDE files");
133
+ }
134
+ }
135
+ }
136
+ console.log(chalk.blue("\n\u{1F4CB} Upgrade Summary\n"));
137
+ for (const result of results) {
138
+ const icon = result.status === "added" || result.status === "updated" ? chalk.green("\u2713") : result.status === "skipped" ? chalk.yellow("\u25CB") : chalk.red("\u2717");
139
+ console.log(` ${icon} ${chalk.bold(result.feature)}: ${result.message}`);
140
+ }
141
+ console.log();
142
+ const addedFeatures = results.filter((r) => r.status === "added" || r.status === "updated");
143
+ if (addedFeatures.length > 0) {
144
+ console.log(chalk.blue("Next steps:\n"));
145
+ if (addedFeatures.some((f) => f.feature === "scan")) {
146
+ console.log(chalk.gray(" \u2022 Generate the scan index:"));
147
+ console.log(chalk.cyan(" paradigm index\n"));
148
+ }
149
+ if (addedFeatures.some((f) => f.feature === "logger")) {
150
+ console.log(chalk.gray(" \u2022 Review the logger spec:"));
151
+ console.log(chalk.cyan(" .paradigm/specs/logger.md\n"));
152
+ }
153
+ console.log(chalk.gray(" \u2022 Verify setup:"));
154
+ console.log(chalk.cyan(" paradigm doctor\n"));
155
+ }
156
+ }
157
+ async function migrateLegacy(rootDir, projectName, options, spinner) {
158
+ const paradigmFile = path.join(rootDir, ".paradigm");
159
+ const paradigmDir = path.join(rootDir, ".paradigm");
160
+ const templatesDir = getTemplatesDir();
161
+ if (options.dryRun) {
162
+ return {
163
+ feature: "migrate",
164
+ status: "updated",
165
+ message: "Would migrate .paradigm file to .paradigm/ directory"
166
+ };
167
+ }
168
+ spinner.start("Migrating .paradigm file to directory...");
169
+ try {
170
+ const existingContent = fs.readFileSync(paradigmFile, "utf8");
171
+ let existingConfig = null;
172
+ try {
173
+ existingConfig = parseParadigmConfig(existingContent);
174
+ } catch {
175
+ }
176
+ const backupPath = path.join(rootDir, ".paradigm.backup");
177
+ fs.copyFileSync(paradigmFile, backupPath);
178
+ fs.unlinkSync(paradigmFile);
179
+ fs.mkdirSync(paradigmDir, { recursive: true });
180
+ fs.mkdirSync(path.join(paradigmDir, "specs"), { recursive: true });
181
+ fs.mkdirSync(path.join(paradigmDir, "docs"), { recursive: true });
182
+ fs.mkdirSync(path.join(paradigmDir, "prompts"), { recursive: true });
183
+ if (fs.existsSync(templatesDir)) {
184
+ copyTemplates(templatesDir, paradigmDir, projectName);
185
+ } else {
186
+ const config = existingConfig || parseParadigmConfig(`
187
+ version: "1.0"
188
+ project: "${projectName}"
189
+ agent-guidelines:
190
+ overview: |
191
+ This project uses Paradigm for structured AI-assisted development.
192
+ symbol-system:
193
+ "@": { name: Feature, description: User-facing capabilities, owner: purpose, examples: ["@login"] }
194
+ logging:
195
+ enforce: true
196
+ scan:
197
+ enabled: true
198
+ conventions: []
199
+ `);
200
+ fs.writeFileSync(
201
+ path.join(paradigmDir, "config.yaml"),
202
+ serializeParadigmConfig(config),
203
+ "utf8"
204
+ );
205
+ }
206
+ const oldScanIndex = path.join(rootDir, ".paradigm-scan-index.json");
207
+ const newScanIndex = path.join(paradigmDir, "scan-index.json");
208
+ if (fs.existsSync(oldScanIndex)) {
209
+ fs.renameSync(oldScanIndex, newScanIndex);
210
+ }
211
+ spinner.succeed(chalk.green("Migrated to .paradigm/ directory"));
212
+ return {
213
+ feature: "migrate",
214
+ status: "updated",
215
+ message: "Converted to directory format (backup at .paradigm.backup)"
216
+ };
217
+ } catch (err) {
218
+ spinner.fail(chalk.red("Migration failed"));
219
+ return {
220
+ feature: "migrate",
221
+ status: "error",
222
+ message: err.message
223
+ };
224
+ }
225
+ }
226
+ async function upgradeScan(rootDir, projectName, options, spinner) {
227
+ const paradigmDir = path.join(rootDir, ".paradigm");
228
+ const scanIndexPath = path.join(paradigmDir, "scan-index.json");
229
+ const scanSpecPath = path.join(paradigmDir, "specs", "scan.md");
230
+ const templatesDir = getTemplatesDir();
231
+ if (fs.existsSync(scanIndexPath) && fs.existsSync(scanSpecPath) && !options.force) {
232
+ return {
233
+ feature: "scan",
234
+ status: "skipped",
235
+ message: "Already configured (use --force to reconfigure)"
236
+ };
237
+ }
238
+ if (options.dryRun) {
239
+ return {
240
+ feature: "scan",
241
+ status: "added",
242
+ message: "Would add scan spec and index placeholder"
243
+ };
244
+ }
245
+ spinner.start("Setting up paradigm scan...");
246
+ try {
247
+ fs.mkdirSync(path.join(paradigmDir, "specs"), { recursive: true });
248
+ const templateScanSpec = path.join(templatesDir, "specs", "scan.md");
249
+ if (fs.existsSync(templateScanSpec)) {
250
+ fs.copyFileSync(templateScanSpec, scanSpecPath);
251
+ }
252
+ if (!fs.existsSync(scanIndexPath)) {
253
+ const placeholderIndex = {
254
+ $meta: {
255
+ version: "1.0.0",
256
+ project: projectName,
257
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
258
+ paradigmVersion: "0.2.0",
259
+ sources: { purposeFiles: 0, portalFiles: 0, premiseFiles: 0 }
260
+ },
261
+ components: {},
262
+ features: {},
263
+ flows: {},
264
+ state: {},
265
+ gates: {},
266
+ signals: {},
267
+ screens: {},
268
+ symbolMap: {},
269
+ _placeholder: true,
270
+ _message: "Run `paradigm index` to populate this index"
271
+ };
272
+ fs.writeFileSync(scanIndexPath, JSON.stringify(placeholderIndex, null, 2), "utf8");
273
+ }
274
+ spinner.succeed(chalk.green("Scan feature configured"));
275
+ return {
276
+ feature: "scan",
277
+ status: "added",
278
+ message: "Added scan spec and index placeholder"
279
+ };
280
+ } catch (err) {
281
+ spinner.fail(chalk.red("Failed to configure scan"));
282
+ return {
283
+ feature: "scan",
284
+ status: "error",
285
+ message: err.message
286
+ };
287
+ }
288
+ }
289
+ async function upgradeLogger(rootDir, options, spinner) {
290
+ const paradigmDir = path.join(rootDir, ".paradigm");
291
+ const loggerSpecPath = path.join(paradigmDir, "specs", "logger.md");
292
+ const templatesDir = getTemplatesDir();
293
+ if (fs.existsSync(loggerSpecPath) && !options.force) {
294
+ return {
295
+ feature: "logger",
296
+ status: "skipped",
297
+ message: "Already configured (use --force to reconfigure)"
298
+ };
299
+ }
300
+ if (options.dryRun) {
301
+ return {
302
+ feature: "logger",
303
+ status: "added",
304
+ message: "Would add logger specification"
305
+ };
306
+ }
307
+ spinner.start("Setting up logger spec...");
308
+ try {
309
+ fs.mkdirSync(path.join(paradigmDir, "specs"), { recursive: true });
310
+ const templateLoggerSpec = path.join(templatesDir, "specs", "logger.md");
311
+ if (fs.existsSync(templateLoggerSpec)) {
312
+ fs.copyFileSync(templateLoggerSpec, loggerSpecPath);
313
+ } else {
314
+ const minimalSpec = `# Paradigm Logger Specification
315
+
316
+ Use the Paradigm logger instead of raw console.log/print statements.
317
+
318
+ ## API
319
+
320
+ \`\`\`
321
+ log.component('#login-handler').info('Starting login', { email })
322
+ log.component('#database').debug('Query executed', { duration })
323
+ log.gate('^authenticated').warn('Access denied', { userId })
324
+ log.signal('!login-success').info('User authenticated')
325
+ \`\`\`
326
+
327
+ ## Log Levels
328
+
329
+ - \`debug\` - Verbose debugging info
330
+ - \`info\` - General information
331
+ - \`warn\` - Warning conditions
332
+ - \`error\` - Error conditions
333
+
334
+ See full specification for implementation details.
335
+ `;
336
+ fs.writeFileSync(loggerSpecPath, minimalSpec, "utf8");
337
+ }
338
+ spinner.succeed(chalk.green("Logger spec configured"));
339
+ return {
340
+ feature: "logger",
341
+ status: "added",
342
+ message: "Added logger specification"
343
+ };
344
+ } catch (err) {
345
+ spinner.fail(chalk.red("Failed to configure logger"));
346
+ return {
347
+ feature: "logger",
348
+ status: "error",
349
+ message: err.message
350
+ };
351
+ }
352
+ }
353
+ function copyTemplates(src, dest, projectName) {
354
+ const entries = fs.readdirSync(src, { withFileTypes: true });
355
+ for (const entry of entries) {
356
+ const srcPath = path.join(src, entry.name);
357
+ const destPath = path.join(dest, entry.name);
358
+ if (entry.isDirectory()) {
359
+ if (!fs.existsSync(destPath)) {
360
+ fs.mkdirSync(destPath, { recursive: true });
361
+ }
362
+ copyTemplates(srcPath, destPath, projectName);
363
+ } else {
364
+ if (!fs.existsSync(destPath)) {
365
+ let content = fs.readFileSync(srcPath, "utf8");
366
+ content = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
367
+ fs.writeFileSync(destPath, content, "utf8");
368
+ }
369
+ }
370
+ }
371
+ }
372
+ async function migrateFromHorizon(rootDir, _projectName, options, spinner) {
373
+ const horizonDir = path.join(rootDir, ".horizon");
374
+ const paradigmDir = path.join(rootDir, ".paradigm");
375
+ if (!fs.existsSync(horizonDir)) {
376
+ return {
377
+ feature: "from-horizon",
378
+ status: "skipped",
379
+ message: "No .horizon directory found to migrate"
380
+ };
381
+ }
382
+ if (fs.existsSync(paradigmDir) && !options.force) {
383
+ return {
384
+ feature: "from-horizon",
385
+ status: "skipped",
386
+ message: ".paradigm already exists (use --force to overwrite)"
387
+ };
388
+ }
389
+ if (options.dryRun) {
390
+ console.log(chalk.cyan("\nDry run - would perform the following:\n"));
391
+ console.log(chalk.gray(" \u2022 Rename .horizon/ \u2192 .paradigm/"));
392
+ const gateFiles = findFiles(rootDir, "gate.yaml");
393
+ if (gateFiles.length > 0) {
394
+ console.log(chalk.gray(` \u2022 Rename ${gateFiles.length} gate.yaml \u2192 portal.yaml`));
395
+ }
396
+ const dreamFiles = findFiles(rootDir, ".dream");
397
+ if (dreamFiles.length > 0) {
398
+ console.log(chalk.gray(` \u2022 Rename ${dreamFiles.length} .dream \u2192 .premise`));
399
+ }
400
+ console.log(chalk.gray(" \u2022 Update content references (horizon\u2192paradigm, gate\u2192portal, dream\u2192premise)"));
401
+ console.log();
402
+ return {
403
+ feature: "from-horizon",
404
+ status: "updated",
405
+ message: "Would migrate Horizon to Paradigm (dry run)"
406
+ };
407
+ }
408
+ spinner.start("Migrating from Horizon to Paradigm...");
409
+ try {
410
+ if (fs.existsSync(horizonDir)) {
411
+ if (fs.existsSync(paradigmDir)) {
412
+ const backupDir = path.join(rootDir, ".paradigm.backup-" + Date.now());
413
+ fs.renameSync(paradigmDir, backupDir);
414
+ spinner.text = "Backed up existing .paradigm...";
415
+ }
416
+ fs.renameSync(horizonDir, paradigmDir);
417
+ spinner.text = "Renamed .horizon to .paradigm...";
418
+ }
419
+ spinner.text = "Renaming gate.yaml files...";
420
+ const gateFiles = findFiles(rootDir, "gate.yaml");
421
+ for (const gateFile of gateFiles) {
422
+ const dir = path.dirname(gateFile);
423
+ const newPath = path.join(dir, "portal.yaml");
424
+ fs.renameSync(gateFile, newPath);
425
+ let content = fs.readFileSync(newPath, "utf8");
426
+ content = updateContent(content);
427
+ fs.writeFileSync(newPath, content, "utf8");
428
+ }
429
+ spinner.text = "Renaming .dream files...";
430
+ const dreamFiles = findFiles(rootDir, ".dream");
431
+ for (const dreamFile of dreamFiles) {
432
+ const dir = path.dirname(dreamFile);
433
+ const newPath = path.join(dir, ".premise");
434
+ fs.renameSync(dreamFile, newPath);
435
+ let content = fs.readFileSync(newPath, "utf8");
436
+ content = updateContent(content);
437
+ fs.writeFileSync(newPath, content, "utf8");
438
+ }
439
+ spinner.text = "Updating file contents...";
440
+ if (fs.existsSync(paradigmDir)) {
441
+ updateDirectoryContents(paradigmDir);
442
+ }
443
+ const scanIndex = path.join(paradigmDir, "scan-index.json");
444
+ const probeIndex = path.join(paradigmDir, "probe-index.json");
445
+ if (fs.existsSync(scanIndex)) {
446
+ let content = fs.readFileSync(scanIndex, "utf8");
447
+ content = updateContent(content);
448
+ fs.writeFileSync(probeIndex, content, "utf8");
449
+ fs.unlinkSync(scanIndex);
450
+ }
451
+ spinner.text = "Updating .purpose file contents...";
452
+ const purposeFiles = findFiles(rootDir, ".purpose");
453
+ for (const purposeFile of purposeFiles) {
454
+ let content = fs.readFileSync(purposeFile, "utf8");
455
+ const updated = updateContent(content);
456
+ if (updated !== content) {
457
+ fs.writeFileSync(purposeFile, updated, "utf8");
458
+ }
459
+ }
460
+ spinner.text = "Updating IDE instruction files...";
461
+ const ideFiles = [".cursorrules", ".windsurfrules", ".github/copilot-instructions.md"];
462
+ for (const ideFile of ideFiles) {
463
+ const fullPath = path.join(rootDir, ideFile);
464
+ if (fs.existsSync(fullPath)) {
465
+ let content = fs.readFileSync(fullPath, "utf8");
466
+ content = updateContent(content);
467
+ fs.writeFileSync(fullPath, content, "utf8");
468
+ }
469
+ }
470
+ spinner.succeed(chalk.green("Migration complete!"));
471
+ return {
472
+ feature: "from-horizon",
473
+ status: "updated",
474
+ message: `Migrated: ${gateFiles.length} portal files, ${dreamFiles.length} premise files`
475
+ };
476
+ } catch (err) {
477
+ spinner.fail(chalk.red("Migration failed"));
478
+ return {
479
+ feature: "from-horizon",
480
+ status: "error",
481
+ message: err.message
482
+ };
483
+ }
484
+ }
485
+ function findFiles(dir, filename) {
486
+ const results = [];
487
+ const skipDirs = ["node_modules", ".git", "dist", "build", ".paradigm"];
488
+ function walk(currentDir) {
489
+ try {
490
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
491
+ for (const entry of entries) {
492
+ const fullPath = path.join(currentDir, entry.name);
493
+ if (entry.isDirectory()) {
494
+ if (!skipDirs.includes(entry.name) && !entry.name.startsWith(".")) {
495
+ walk(fullPath);
496
+ }
497
+ } else if (entry.name === filename) {
498
+ results.push(fullPath);
499
+ }
500
+ }
501
+ } catch {
502
+ }
503
+ }
504
+ walk(dir);
505
+ return results;
506
+ }
507
+ function updateContent(content) {
508
+ return content.replace(/Horizon/g, "Paradigm").replace(/horizon/g, "paradigm").replace(/Dreamscape/g, "Prism").replace(/dreamscape/g, "prism").replace(/Dream\b/g, "Premise").replace(/dream\b/g, "premise").replace(/\bGate\b/g, "Portal").replace(/\bgate\b/g, "portal").replace(/\bScan\b/g, "Probe").replace(/\bscan\b/g, "probe").replace(/gate\.yaml/g, "portal.yaml").replace(/\.dream\b/g, ".premise").replace(/scan-index\.json/g, "probe-index.json").replace(/\.horizon\//g, ".paradigm/").replace(/\.horizon$/g, ".paradigm").replace(/HORIZON_SYMBOLS/g, "PARADIGM_SYMBOLS");
509
+ }
510
+ function updateDirectoryContents(dir) {
511
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
512
+ for (const entry of entries) {
513
+ const fullPath = path.join(dir, entry.name);
514
+ if (entry.isDirectory()) {
515
+ updateDirectoryContents(fullPath);
516
+ } else if (entry.name.endsWith(".yaml") || entry.name.endsWith(".md") || entry.name.endsWith(".json")) {
517
+ let content = fs.readFileSync(fullPath, "utf8");
518
+ const updated = updateContent(content);
519
+ if (updated !== content) {
520
+ fs.writeFileSync(fullPath, updated, "utf8");
521
+ }
522
+ }
523
+ }
524
+ }
525
+ function getAvailableUpgrades(rootDir) {
526
+ const available = [];
527
+ const paradigmPath = path.join(rootDir, ".paradigm");
528
+ if (!fs.existsSync(paradigmPath)) {
529
+ return available;
530
+ }
531
+ const isLegacyFile = fs.statSync(paradigmPath).isFile();
532
+ if (isLegacyFile) {
533
+ available.push("migrate");
534
+ return available;
535
+ }
536
+ const paradigmDir = paradigmPath;
537
+ const scanIndexPath = path.join(paradigmDir, "scan-index.json");
538
+ if (!fs.existsSync(scanIndexPath)) {
539
+ available.push("scan");
540
+ }
541
+ const loggerSpecPath = path.join(paradigmDir, "specs", "logger.md");
542
+ if (!fs.existsSync(loggerSpecPath)) {
543
+ available.push("logger");
544
+ }
545
+ return available;
546
+ }
547
+ export {
548
+ getAvailableUpgrades,
549
+ upgradeCommand
550
+ };
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatValidationResult,
4
+ parseGateConfig,
5
+ validateGateConfig
6
+ } from "./chunk-IRKUEJVW.js";
7
+ import "./chunk-MO4EEYFW.js";
8
+
9
+ // src/commands/portal/validate.ts
10
+ import * as path from "path";
11
+ import chalk from "chalk";
12
+ import ora from "ora";
13
+ async function gateValidateCommand(configPath) {
14
+ const cwd = process.cwd();
15
+ const absolutePath = path.resolve(cwd, configPath);
16
+ console.log(chalk.blue("\n\u{1F50D} Validating Gate Configuration...\n"));
17
+ const spinner = ora(`Parsing ${configPath}...`).start();
18
+ try {
19
+ const config = await parseGateConfig(absolutePath);
20
+ spinner.succeed("Parsed portal.yaml");
21
+ const result = validateGateConfig(config);
22
+ console.log(chalk.white(`
23
+ Gates: ${config.gates.length}`));
24
+ console.log(chalk.white(`Flows: ${config.flows.length}`));
25
+ console.log(formatValidationResult(result));
26
+ if (!result.valid) {
27
+ process.exit(1);
28
+ }
29
+ console.log("");
30
+ } catch (error) {
31
+ spinner.fail("Validation failed");
32
+ console.log(chalk.red(`Error: ${error.message}
33
+ `));
34
+ process.exit(1);
35
+ }
36
+ }
37
+ export {
38
+ gateValidateCommand
39
+ };
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatValidationResult,
4
+ getAllPurposeFiles,
5
+ validatePurposeFile
6
+ } from "./chunk-PW2EXJQT.js";
7
+ import "./chunk-MO4EEYFW.js";
8
+
9
+ // src/commands/purpose/validate.ts
10
+ import * as path from "path";
11
+ import chalk from "chalk";
12
+ import ora from "ora";
13
+ async function purposeValidateCommand(targetPath) {
14
+ const cwd = process.cwd();
15
+ const absolutePath = path.resolve(cwd, targetPath);
16
+ console.log(chalk.blue("\n\u{1F50D} Validating Purpose Files...\n"));
17
+ const spinner = ora("Finding purpose files...").start();
18
+ try {
19
+ const files = await getAllPurposeFiles(absolutePath);
20
+ spinner.succeed(`Found ${files.length} purpose file(s)`);
21
+ let hasErrors = false;
22
+ let totalWarnings = 0;
23
+ let totalErrors = 0;
24
+ for (const { filePath, data } of files) {
25
+ const relativePath = path.relative(cwd, filePath);
26
+ const result = validatePurposeFile(data, relativePath);
27
+ const errors = result.issues.filter((i) => i.type === "error").length;
28
+ const warnings = result.issues.filter((i) => i.type === "warning").length;
29
+ totalErrors += errors;
30
+ totalWarnings += warnings;
31
+ if (!result.valid) {
32
+ hasErrors = true;
33
+ }
34
+ if (result.issues.length > 0) {
35
+ console.log(chalk.white(`
36
+ ${relativePath}`));
37
+ console.log(formatValidationResult(result));
38
+ } else {
39
+ console.log(chalk.green(` \u2713 ${relativePath}`));
40
+ }
41
+ }
42
+ console.log(chalk.white("\n" + "\u2500".repeat(50)));
43
+ if (hasErrors) {
44
+ console.log(chalk.red(`
45
+ \u274C Validation failed: ${totalErrors} error(s), ${totalWarnings} warning(s)
46
+ `));
47
+ process.exit(1);
48
+ } else if (totalWarnings > 0) {
49
+ console.log(chalk.yellow(`
50
+ \u2713 Valid with ${totalWarnings} warning(s)
51
+ `));
52
+ } else {
53
+ console.log(chalk.green("\n\u2713 All purpose files are valid\n"));
54
+ }
55
+ } catch (error) {
56
+ spinner.fail("Validation failed");
57
+ console.log(chalk.red(`Error: ${error.message}
58
+ `));
59
+ process.exit(1);
60
+ }
61
+ }
62
+ export {
63
+ purposeValidateCommand
64
+ };