@a-company/paradigm 3.1.5 → 3.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 (80) hide show
  1. package/dist/{accept-orchestration-CWZNCGZX.js → accept-orchestration-DIGPJVUR.js} +6 -5
  2. package/dist/{aggregate-W7Q6VIM2.js → aggregate-V4KPR3RW.js} +2 -2
  3. package/dist/{beacon-B47XSTL7.js → beacon-XRXL5KZB.js} +2 -2
  4. package/dist/{chunk-4LGLU2LO.js → chunk-2E2RTBSM.js} +533 -182
  5. package/dist/{chunk-YCLN7WXV.js → chunk-2QNZ6PVD.js} +219 -35
  6. package/dist/{chunk-UM54F7G5.js → chunk-4N6AYEEA.js} +1 -1
  7. package/dist/{chunk-MVXJVRFI.js → chunk-5TUAVVIG.js} +65 -1
  8. package/dist/{chunk-5C4SGQKH.js → chunk-6P4IFIK2.js} +4 -2
  9. package/dist/{chunk-WS5KM7OL.js → chunk-6RNYVBSG.js} +1 -1
  10. package/dist/{chunk-N6PJAPDE.js → chunk-AK5M6KJB.js} +18 -0
  11. package/dist/{chunk-VZ7CXFRZ.js → chunk-CRICL4FQ.js} +1004 -17
  12. package/dist/{chunk-MC7XC7XQ.js → chunk-GZDFVP2N.js} +20 -13
  13. package/dist/chunk-HPC3JAUP.js +42 -0
  14. package/dist/chunk-IRVA7NKV.js +657 -0
  15. package/dist/{chunk-ZPN7MXRA.js → chunk-KFHK6EBI.js} +184 -1
  16. package/dist/{chunk-UUZ2DMG5.js → chunk-KWDTBXP2.js} +1 -1
  17. package/dist/{chunk-DRUDZKIT.js → chunk-M2XMTJHQ.js} +693 -70
  18. package/dist/{chunk-PW2EXJQT.js → chunk-MRENOFTR.js} +24 -1
  19. package/dist/{chunk-QS36NGWV.js → chunk-QHJGB5TV.js} +1 -1
  20. package/dist/chunk-UI3XXVJ6.js +449 -0
  21. package/dist/{chunk-AD2LSCHB.js → chunk-Y4XZWCHK.js} +40 -74
  22. package/dist/{constellation-K3CIQCHI.js → constellation-GNK5DIMH.js} +2 -2
  23. package/dist/{cost-AEK6R7HK.js → cost-AGO5N7DD.js} +1 -1
  24. package/dist/{cursorrules-KI5QWHIX.js → cursorrules-LQFA7M62.js} +2 -2
  25. package/dist/{delete-W67IVTLJ.js → delete-3YXAJ5AA.js} +12 -1
  26. package/dist/{diff-AJJ5H6HV.js → diff-J6C5IHPV.js} +6 -5
  27. package/dist/{dist-2F7NO4H4-KSL6SJIO.js → dist-AG5JNIZU-XSEZ2LLK.js} +28 -3
  28. package/dist/dist-JOHRYQUA.js +7294 -0
  29. package/dist/{dist-NHJQVVUW.js → dist-Q6SAZI7X.js} +2 -2
  30. package/dist/{dist-GPQ4LAY3.js → dist-YP2CO4TG.js} +24 -6
  31. package/dist/{doctor-JBIV5PMN.js → doctor-TQYRF7KK.js} +2 -2
  32. package/dist/{edit-Y7XPYSMK.js → edit-EOMPXOG5.js} +1 -1
  33. package/dist/flow-7JUH6D4H.js +185 -0
  34. package/dist/global-AXILUM5X.js +136 -0
  35. package/dist/{habits-FA65W77Y.js → habits-CHP4EW5H.js} +234 -5
  36. package/dist/{hooks-JKWO44WH.js → hooks-DLZEYHI3.js} +1 -1
  37. package/dist/index.js +125 -100
  38. package/dist/{lint-HXKTWRNO.js → lint-N4LMMEXH.js} +141 -1
  39. package/dist/{list-R3QWW4SC.js → list-JKBJ7ESH.js} +1 -1
  40. package/dist/mcp.js +9273 -6515
  41. package/dist/{orchestrate-4ZH5GUQH.js → orchestrate-FAV64G2R.js} +6 -5
  42. package/dist/{probe-OYCP4JYG.js → probe-X3J2JX62.js} +18 -3
  43. package/dist/{promote-E6NBZ3BK.js → promote-HZH5E5CO.js} +1 -1
  44. package/dist/{providers-4PGPZEWP.js → providers-NQ67LO2Z.js} +1 -1
  45. package/dist/{record-OHQNWOUP.js → record-EECZ3E4I.js} +1 -1
  46. package/dist/{remember-6VZ74B7E.js → remember-3KJZGDUG.js} +1 -1
  47. package/dist/{review-RUHX25A5.js → review-BF26ILZB.js} +1 -1
  48. package/dist/{ripple-SBQOSTZD.js → ripple-JIUAMBLA.js} +2 -2
  49. package/dist/sentinel-ZTL224IG.js +63 -0
  50. package/dist/{server-MV4HNFVF.js → server-MZBYDXJY.js} +4193 -9
  51. package/dist/{setup-DF4F3ICN.js → setup-363IB6MO.js} +1 -1
  52. package/dist/{setup-JHBPZAG7.js → setup-UKJ3VGHI.js} +4 -4
  53. package/dist/{shift-2LQFQP4P.js → shift-KDVYB6CR.js} +16 -13
  54. package/dist/{show-WTOJXUTN.js → show-SAMTXEHG.js} +1 -1
  55. package/dist/{snapshot-GTVPRYZG.js → snapshot-KCMONZAO.js} +2 -2
  56. package/dist/{spawn-BJRQA2NR.js → spawn-EO7B2UM3.js} +2 -2
  57. package/dist/{summary-5SBFO7QK.js → summary-E2PU4UN2.js} +3 -3
  58. package/dist/{switch-6EANJ7O6.js → switch-CC2KACXO.js} +1 -1
  59. package/dist/{sync-5KSTPJ4B.js → sync-5VJPZQNX.js} +2 -2
  60. package/dist/sync-llms-7QDA3ZWC.js +166 -0
  61. package/dist/{team-NWP2KJAB.js → team-6CCNANKE.js} +7 -6
  62. package/dist/{test-MA5TWJQV.js → test-DK2RWLTK.js} +91 -8
  63. package/dist/{thread-JCJVRUQR.js → thread-RNSLADXN.js} +18 -2
  64. package/dist/{timeline-P7BARFLI.js → timeline-TJDVVVA3.js} +1 -1
  65. package/dist/{triage-TBIWJA6R.js → triage-PXMU3RWV.js} +2 -2
  66. package/dist/university-content/courses/para-101.json +2 -1
  67. package/dist/university-content/courses/para-201.json +102 -3
  68. package/dist/university-content/courses/para-301.json +14 -11
  69. package/dist/university-content/courses/para-401.json +57 -3
  70. package/dist/university-content/courses/para-501.json +204 -6
  71. package/dist/university-content/plsat/v3.0.json +808 -3
  72. package/dist/university-content/reference.json +270 -0
  73. package/dist/{upgrade-TIYFQYPO.js → upgrade-RBSE4M6I.js} +1 -1
  74. package/dist/{validate-QEEY6KFS.js → validate-2LTHHORX.js} +1 -1
  75. package/dist/{watch-4LT4O6K7.js → watch-NBPOMOEX.js} +76 -0
  76. package/dist/{watch-2XEYUH43.js → watch-PAEH6MOG.js} +1 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-GWM2WRXL.js +0 -1095
  79. package/dist/sentinel-WB7GIK4V.js +0 -43
  80. /package/dist/{chunk-TAP5N3HH.js → chunk-CCG6KYBT.js} +0 -0
@@ -0,0 +1,657 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ indexCommand
4
+ } from "./chunk-UI3XXVJ6.js";
5
+ import {
6
+ detectDiscipline,
7
+ getDisciplineConfig
8
+ } from "./chunk-CHSHON3O.js";
9
+ import {
10
+ getDefaultPremiseContent
11
+ } from "./chunk-6P4IFIK2.js";
12
+ import {
13
+ getDefaultPurposeContent
14
+ } from "./chunk-MRENOFTR.js";
15
+ import {
16
+ detectIDE,
17
+ loadParadigmFiles,
18
+ syncToIDE
19
+ } from "./chunk-2QNZ6PVD.js";
20
+ import {
21
+ log
22
+ } from "./chunk-4NCFWYGG.js";
23
+
24
+ // src/commands/init.ts
25
+ import * as fs from "fs";
26
+ import * as path from "path";
27
+ import { fileURLToPath } from "url";
28
+ import chalk from "chalk";
29
+ import ora from "ora";
30
+ function countLines(filePath) {
31
+ try {
32
+ const content = fs.readFileSync(filePath, "utf8");
33
+ return content.split("\n").length;
34
+ } catch {
35
+ return 0;
36
+ }
37
+ }
38
+ function detectProjectType(rootDir) {
39
+ const packageJsonPath = path.join(rootDir, "package.json");
40
+ if (fs.existsSync(packageJsonPath)) {
41
+ try {
42
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
43
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
44
+ if (deps["next"]) return "Next.js";
45
+ if (deps["nuxt"]) return "Nuxt";
46
+ if (deps["@angular/core"]) return "Angular";
47
+ if (deps["vue"]) return "Vue";
48
+ if (deps["svelte"]) return "Svelte";
49
+ if (deps["express"]) return "Express";
50
+ if (deps["fastify"]) return "Fastify";
51
+ if (deps["react"] && !deps["next"]) return "React";
52
+ if (deps["typescript"]) return "TypeScript";
53
+ return "Node.js";
54
+ } catch {
55
+ return void 0;
56
+ }
57
+ }
58
+ if (fs.existsSync(path.join(rootDir, "requirements.txt")) || fs.existsSync(path.join(rootDir, "pyproject.toml"))) {
59
+ if (fs.existsSync(path.join(rootDir, "manage.py"))) return "Django";
60
+ if (fs.existsSync(path.join(rootDir, "app.py"))) return "Flask";
61
+ return "Python";
62
+ }
63
+ if (fs.existsSync(path.join(rootDir, "go.mod"))) return "Go";
64
+ if (fs.existsSync(path.join(rootDir, "Cargo.toml"))) return "Rust";
65
+ return void 0;
66
+ }
67
+ function detectExistingIDEFiles(rootDir) {
68
+ const ides = [];
69
+ let totalLines = 0;
70
+ const cursorIDE = { name: "cursor", displayName: "Cursor" };
71
+ const cursorLegacy = path.join(rootDir, ".cursorrules");
72
+ const cursorModernDir = path.join(rootDir, ".cursor", "rules");
73
+ if (fs.existsSync(cursorLegacy)) {
74
+ const lines = countLines(cursorLegacy);
75
+ cursorIDE.legacy = { path: ".cursorrules", lines, type: "legacy" };
76
+ totalLines += lines;
77
+ }
78
+ if (fs.existsSync(cursorModernDir)) {
79
+ const files = fs.readdirSync(cursorModernDir).filter((f) => f.endsWith(".mdc"));
80
+ if (files.length > 0) {
81
+ cursorIDE.modern = files.map((f) => {
82
+ const fullPath = path.join(cursorModernDir, f);
83
+ const lines = countLines(fullPath);
84
+ totalLines += lines;
85
+ return { path: `.cursor/rules/${f}`, lines, type: "modern" };
86
+ });
87
+ }
88
+ }
89
+ if (cursorIDE.legacy || cursorIDE.modern) {
90
+ ides.push(cursorIDE);
91
+ }
92
+ const copilotIDE = { name: "copilot", displayName: "GitHub Copilot" };
93
+ const copilotLegacy = path.join(rootDir, ".github", "copilot-instructions.md");
94
+ const copilotModernDir = path.join(rootDir, ".github", "instructions");
95
+ if (fs.existsSync(copilotLegacy)) {
96
+ const lines = countLines(copilotLegacy);
97
+ copilotIDE.legacy = { path: ".github/copilot-instructions.md", lines, type: "legacy" };
98
+ totalLines += lines;
99
+ }
100
+ if (fs.existsSync(copilotModernDir)) {
101
+ const files = fs.readdirSync(copilotModernDir).filter((f) => f.endsWith(".md"));
102
+ if (files.length > 0) {
103
+ copilotIDE.modern = files.map((f) => {
104
+ const fullPath = path.join(copilotModernDir, f);
105
+ const lines = countLines(fullPath);
106
+ totalLines += lines;
107
+ return { path: `.github/instructions/${f}`, lines, type: "modern" };
108
+ });
109
+ }
110
+ }
111
+ if (copilotIDE.legacy || copilotIDE.modern) {
112
+ ides.push(copilotIDE);
113
+ }
114
+ const windsurfPath = path.join(rootDir, ".windsurfrules");
115
+ if (fs.existsSync(windsurfPath)) {
116
+ const lines = countLines(windsurfPath);
117
+ ides.push({
118
+ name: "windsurf",
119
+ displayName: "Windsurf",
120
+ legacy: { path: ".windsurfrules", lines, type: "legacy" }
121
+ });
122
+ totalLines += lines;
123
+ }
124
+ const claudePath = path.join(rootDir, "CLAUDE.md");
125
+ if (fs.existsSync(claudePath)) {
126
+ const lines = countLines(claudePath);
127
+ ides.push({
128
+ name: "claude",
129
+ displayName: "Claude",
130
+ legacy: { path: "CLAUDE.md", lines, type: "legacy" }
131
+ });
132
+ totalLines += lines;
133
+ }
134
+ const agentsPath = path.join(rootDir, "AGENTS.md");
135
+ if (fs.existsSync(agentsPath)) {
136
+ const lines = countLines(agentsPath);
137
+ ides.push({
138
+ name: "agents",
139
+ displayName: "AGENTS.md",
140
+ legacy: { path: "AGENTS.md", lines, type: "legacy" }
141
+ });
142
+ totalLines += lines;
143
+ }
144
+ const discipline = detectDiscipline(rootDir);
145
+ return {
146
+ ides,
147
+ hasExisting: ides.length > 0,
148
+ totalLines,
149
+ projectType: detectProjectType(rootDir),
150
+ discipline: discipline !== "backend" ? discipline : void 0
151
+ // Only show if non-fallback
152
+ };
153
+ }
154
+ function generateMigrationPrompt(detection, projectName) {
155
+ const lines = [];
156
+ lines.push("# Migrate IDE Instructions to Paradigm Format");
157
+ lines.push("");
158
+ lines.push("## Overview");
159
+ lines.push("");
160
+ lines.push(`Migrate existing IDE instruction files for **${projectName}** to Paradigm's managed, scoped format.`);
161
+ lines.push("");
162
+ lines.push("## Source Files Found");
163
+ lines.push("");
164
+ for (const ide of detection.ides) {
165
+ if (ide.legacy) {
166
+ lines.push(`- \`${ide.legacy.path}\` (${ide.legacy.lines} lines) - ${ide.displayName} ${ide.legacy.type} format`);
167
+ }
168
+ if (ide.modern) {
169
+ for (const file of ide.modern) {
170
+ lines.push(`- \`${file.path}\` (${file.lines} lines) - ${ide.displayName} modern format`);
171
+ }
172
+ }
173
+ }
174
+ lines.push("");
175
+ if (detection.ides.some((i) => i.name === "cursor")) {
176
+ lines.push("## Cursor Migration \u2192 `.cursor/rules/*.mdc`");
177
+ lines.push("");
178
+ lines.push("Split the existing `.cursorrules` into scoped `.mdc` files with YAML frontmatter:");
179
+ lines.push("");
180
+ lines.push("### File Structure");
181
+ lines.push("");
182
+ lines.push("```");
183
+ lines.push(".cursor/rules/");
184
+ lines.push("\u251C\u2500\u2500 project-core.mdc # Always applies - project overview, architecture");
185
+ lines.push("\u251C\u2500\u2500 code-style.mdc # globs: **/*.{ts,tsx,js,jsx} - naming, formatting");
186
+ lines.push("\u251C\u2500\u2500 components.mdc # globs: **/components/**/* - component patterns");
187
+ lines.push("\u251C\u2500\u2500 api-patterns.mdc # globs: **/api/**/* - API conventions");
188
+ lines.push("\u251C\u2500\u2500 testing.mdc # globs: **/*.test.* - testing guidelines");
189
+ lines.push("\u2514\u2500\u2500 custom.mdc # Any project-specific rules");
190
+ lines.push("```");
191
+ lines.push("");
192
+ lines.push("### Frontmatter Format");
193
+ lines.push("");
194
+ lines.push("```yaml");
195
+ lines.push("---");
196
+ lines.push("description: Brief description of what these rules cover");
197
+ lines.push('globs: "**/*.ts" # File pattern (OR use alwaysApply)');
198
+ lines.push("alwaysApply: true # Apply to all files (OR use globs)");
199
+ lines.push("---");
200
+ lines.push("```");
201
+ lines.push("");
202
+ }
203
+ if (detection.ides.some((i) => i.name === "copilot")) {
204
+ lines.push("## Copilot Migration \u2192 `.github/instructions/*.instructions.md`");
205
+ lines.push("");
206
+ lines.push("Split into scoped instruction files with `applyTo` frontmatter:");
207
+ lines.push("");
208
+ lines.push("### File Structure");
209
+ lines.push("");
210
+ lines.push("```");
211
+ lines.push(".github/");
212
+ lines.push("\u251C\u2500\u2500 copilot-instructions.md # Always applies - core rules");
213
+ lines.push("\u2514\u2500\u2500 instructions/");
214
+ lines.push(" \u251C\u2500\u2500 typescript.instructions.md # applyTo: **/*.ts");
215
+ lines.push(" \u251C\u2500\u2500 react.instructions.md # applyTo: **/*.tsx");
216
+ lines.push(" \u251C\u2500\u2500 api.instructions.md # applyTo: **/api/**");
217
+ lines.push(" \u2514\u2500\u2500 testing.instructions.md # applyTo: **/*.test.*");
218
+ lines.push("```");
219
+ lines.push("");
220
+ lines.push("### Frontmatter Format");
221
+ lines.push("");
222
+ lines.push("```yaml");
223
+ lines.push("---");
224
+ lines.push('applyTo: "**/*.ts"');
225
+ lines.push("---");
226
+ lines.push("```");
227
+ lines.push("");
228
+ }
229
+ lines.push("## Migration Steps");
230
+ lines.push("");
231
+ lines.push("1. **Read each source file** and identify logical sections:");
232
+ lines.push(" - Project overview / architecture");
233
+ lines.push(" - Code style / naming conventions");
234
+ lines.push(" - Language-specific patterns");
235
+ lines.push(" - Framework-specific rules");
236
+ lines.push(" - Testing guidelines");
237
+ lines.push(" - API patterns");
238
+ lines.push("");
239
+ lines.push("2. **Create scoped target files** with appropriate frontmatter");
240
+ lines.push("");
241
+ lines.push("3. **Backup originals** by renaming to `.bak`:");
242
+ lines.push(" - `.cursorrules` \u2192 `.cursorrules.bak`");
243
+ lines.push(" - `.github/copilot-instructions.md` \u2192 `.github/copilot-instructions.md.bak`");
244
+ lines.push("");
245
+ lines.push("4. **Verify** the migration by checking that rules apply correctly");
246
+ lines.push("");
247
+ lines.push("## Tips");
248
+ lines.push("");
249
+ lines.push("- **Prefer specific globs** over `alwaysApply` when possible");
250
+ lines.push("- **Keep files focused** - one concern per file");
251
+ lines.push("- **Use descriptive names** that indicate the scope");
252
+ lines.push("- **Paradigm will generate its own rules** - keep custom rules separate");
253
+ lines.push("- After migration, run `paradigm sync` to add Paradigm-managed rules");
254
+ lines.push("");
255
+ lines.push("---");
256
+ lines.push("");
257
+ lines.push("*Generated by `paradigm init --migrate`*");
258
+ return lines.join("\n");
259
+ }
260
+ function getTemplatesDir() {
261
+ const __filename = fileURLToPath(import.meta.url);
262
+ const __dirname = path.dirname(__filename);
263
+ const possiblePaths = [
264
+ path.join(__dirname, "..", "..", "templates", "paradigm"),
265
+ path.join(__dirname, "..", "templates", "paradigm"),
266
+ path.join(__dirname, "..", "..", "src", "templates", "paradigm")
267
+ ];
268
+ for (const p of possiblePaths) {
269
+ if (fs.existsSync(p)) {
270
+ return p;
271
+ }
272
+ }
273
+ return path.join(__dirname, "..", "templates", "paradigm");
274
+ }
275
+ var MCP_SERVED_CONTENT = {
276
+ // Skip entire directories
277
+ directories: ["prompts"],
278
+ // Skip specific files (relative to .paradigm/)
279
+ files: [
280
+ "echoes.yaml",
281
+ "docs/commands.md",
282
+ "docs/queries.md",
283
+ "specs/disciplines.md",
284
+ "specs/scan.md",
285
+ "specs/context-tracking.md"
286
+ ]
287
+ };
288
+ function shouldSkipPath(relativePath) {
289
+ for (const dir of MCP_SERVED_CONTENT.directories) {
290
+ if (relativePath === dir || relativePath.startsWith(dir + "/")) {
291
+ return true;
292
+ }
293
+ }
294
+ if (MCP_SERVED_CONTENT.files.includes(relativePath)) {
295
+ return true;
296
+ }
297
+ return false;
298
+ }
299
+ function copyDir(src, dest, projectName, relativePath = "") {
300
+ if (!fs.existsSync(dest)) {
301
+ fs.mkdirSync(dest, { recursive: true });
302
+ }
303
+ const entries = fs.readdirSync(src, { withFileTypes: true });
304
+ for (const entry of entries) {
305
+ const srcPath = path.join(src, entry.name);
306
+ const destPath = path.join(dest, entry.name);
307
+ const entryRelativePath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
308
+ if (shouldSkipPath(entryRelativePath)) {
309
+ continue;
310
+ }
311
+ if (entry.isDirectory()) {
312
+ copyDir(srcPath, destPath, projectName, entryRelativePath);
313
+ } else {
314
+ let content = fs.readFileSync(srcPath, "utf8");
315
+ content = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName);
316
+ fs.writeFileSync(destPath, content, "utf8");
317
+ }
318
+ }
319
+ }
320
+ function displayDetectionResults(detection, projectName) {
321
+ console.log(chalk.blue("\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
322
+ console.log(chalk.blue("\u2502") + chalk.white.bold(" Welcome to Paradigm ") + chalk.blue("\u2502"));
323
+ console.log(chalk.blue("\u2502") + chalk.gray(" Let's set up your project ") + chalk.blue("\u2502"));
324
+ console.log(chalk.blue("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"));
325
+ console.log(chalk.white(" \u{1F4C1} Project: ") + chalk.cyan(projectName) + (detection.projectType ? chalk.gray(` (${detection.projectType} detected)`) : ""));
326
+ if (detection.discipline) {
327
+ console.log(chalk.white(" \u{1F3AF} Discipline: ") + chalk.cyan(detection.discipline));
328
+ }
329
+ console.log("");
330
+ if (detection.hasExisting) {
331
+ console.log(chalk.white(" \u{1F4C4} Found existing IDE instructions:\n"));
332
+ for (const ide of detection.ides) {
333
+ if (ide.legacy) {
334
+ console.log(chalk.green(" \u2713 ") + chalk.white(ide.legacy.path) + chalk.gray(` (${ide.legacy.lines} lines)`));
335
+ }
336
+ if (ide.modern) {
337
+ for (const file of ide.modern) {
338
+ console.log(chalk.green(" \u2713 ") + chalk.white(file.path) + chalk.gray(` (${file.lines} lines)`));
339
+ }
340
+ }
341
+ }
342
+ console.log("");
343
+ console.log(chalk.gray(` Total: ${detection.totalLines} lines of existing instructions`));
344
+ } else {
345
+ console.log(chalk.gray(" \u{1F4C4} No existing IDE instructions found"));
346
+ }
347
+ console.log("");
348
+ console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
349
+ console.log("");
350
+ }
351
+ function displaySummary(targetIDE, detection) {
352
+ const outputFileMap = {
353
+ cursor: ".cursor/rules/",
354
+ copilot: ".github/instructions/",
355
+ windsurf: ".windsurfrules",
356
+ claude: "CLAUDE.md"
357
+ };
358
+ const outputFile = outputFileMap[targetIDE] || ".cursor/rules/";
359
+ console.log(chalk.blue("\n\u2728 Paradigm initialized!\n"));
360
+ console.log(chalk.white(" Created:"));
361
+ console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
362
+ console.log(chalk.white(" \u{1F4C1} .paradigm/"));
363
+ console.log(chalk.gray(" \u251C\u2500\u2500 config.yaml Configuration"));
364
+ console.log(chalk.gray(" \u251C\u2500\u2500 specs/ Logger, symbols, context"));
365
+ console.log(chalk.gray(" \u2514\u2500\u2500 docs/ Patterns, troubleshooting"));
366
+ console.log(chalk.white(" \u{1F4C4} .premise Project overview"));
367
+ console.log(chalk.white(" \u{1F4C4} .purpose Feature context"));
368
+ console.log(chalk.white(` \u{1F4C4} ${outputFile.padEnd(20)} IDE instructions`));
369
+ console.log("");
370
+ console.log(chalk.gray(" Reference content (prompts, commands, etc.) available via MCP"));
371
+ if (detection.hasExisting) {
372
+ console.log("");
373
+ console.log(chalk.yellow(" \u26A0 Your existing IDE files were preserved."));
374
+ console.log(chalk.gray(" Run `paradigm init --migrate` to get a migration prompt."));
375
+ }
376
+ console.log("");
377
+ console.log(chalk.white(" Next steps:"));
378
+ console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
379
+ console.log(chalk.white(" 1. ") + chalk.gray("Review ") + chalk.cyan(".paradigm/config.yaml"));
380
+ console.log(chalk.white(" 2. ") + chalk.gray("Edit ") + chalk.cyan(".purpose") + chalk.gray(" to define your features"));
381
+ console.log(chalk.white(" 3. ") + chalk.gray("Run ") + chalk.cyan("paradigm beacon") + chalk.gray(" to generate AI context"));
382
+ console.log(chalk.white(" 4. ") + chalk.gray("Run ") + chalk.cyan("paradigm doctor") + chalk.gray(" to verify setup"));
383
+ console.log(chalk.white(" 5. ") + chalk.gray("Run ") + chalk.cyan("paradigm visualize") + chalk.gray(" to see your project"));
384
+ console.log("");
385
+ }
386
+ async function initCommand(options) {
387
+ const cwd = process.cwd();
388
+ const projectName = options.name || path.basename(cwd);
389
+ const spinner = ora();
390
+ const tracker = log.command("init").start("Initializing Paradigm", { project: projectName, quick: !!options.quick });
391
+ const detection = detectExistingIDEFiles(cwd);
392
+ log.operation("detect-ide").debug("IDE detection complete", { hasExisting: detection.hasExisting });
393
+ if (options.migrate) {
394
+ if (!detection.hasExisting) {
395
+ console.log(chalk.yellow("\n No existing IDE instruction files found.\n"));
396
+ console.log(chalk.gray(" Run `paradigm init` to create a fresh setup.\n"));
397
+ return;
398
+ }
399
+ console.log(chalk.blue("\n Migration Prompt\n"));
400
+ console.log(chalk.gray(" Copy the following prompt to an AI agent:\n"));
401
+ console.log(chalk.gray(" \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n"));
402
+ console.log(generateMigrationPrompt(detection, projectName));
403
+ console.log(chalk.gray("\n \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n"));
404
+ return;
405
+ }
406
+ if (options.dryRun) {
407
+ displayDetectionResults(detection, projectName);
408
+ console.log(chalk.white(" Would create (dry run):"));
409
+ console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
410
+ console.log(chalk.cyan(" \u{1F4C1} .paradigm/"));
411
+ console.log(chalk.cyan(" \u251C\u2500\u2500 config.yaml"));
412
+ console.log(chalk.cyan(" \u251C\u2500\u2500 specs/"));
413
+ console.log(chalk.cyan(" \u2514\u2500\u2500 docs/"));
414
+ console.log(chalk.cyan(" \u{1F4C4} .premise"));
415
+ console.log(chalk.cyan(" \u{1F4C4} .purpose"));
416
+ console.log(chalk.cyan(" \u{1F4C1} .cursor/rules/*.mdc"));
417
+ console.log("");
418
+ console.log(chalk.gray(" Reference content (prompts, commands, etc.) served via MCP"));
419
+ console.log(chalk.gray(" Run without --dry-run to create these files.\n"));
420
+ return;
421
+ }
422
+ if (!options.quick) {
423
+ displayDetectionResults(detection, projectName);
424
+ if (detection.hasExisting && !options.force) {
425
+ console.log(chalk.white(" What would you like to do?\n"));
426
+ console.log(chalk.cyan(" paradigm init --migrate"));
427
+ console.log(chalk.gray(" Get an AI-ready prompt to convert your existing rules\n"));
428
+ console.log(chalk.cyan(" paradigm init --force"));
429
+ console.log(chalk.gray(" Create .paradigm/ alongside existing files\n"));
430
+ console.log(chalk.cyan(" paradigm init --dry-run"));
431
+ console.log(chalk.gray(" Preview what would be created\n"));
432
+ }
433
+ }
434
+ const templatesDir = getTemplatesDir();
435
+ const paradigmDir = path.join(cwd, ".paradigm");
436
+ if (fs.existsSync(paradigmDir)) {
437
+ const stat = fs.statSync(paradigmDir);
438
+ if (stat.isFile()) {
439
+ if (!options.force) {
440
+ console.log(chalk.yellow(" \u26A0 Legacy .paradigm file found."));
441
+ console.log(chalk.gray(" Run `paradigm upgrade --all` to migrate.\n"));
442
+ return;
443
+ }
444
+ fs.unlinkSync(paradigmDir);
445
+ } else if (stat.isDirectory() && !options.force) {
446
+ console.log(chalk.yellow(" \u26A0 .paradigm/ already exists (use --force to overwrite)\n"));
447
+ return;
448
+ }
449
+ }
450
+ spinner.start("Creating .paradigm/ directory...");
451
+ try {
452
+ if (!fs.existsSync(paradigmDir)) {
453
+ fs.mkdirSync(paradigmDir, { recursive: true });
454
+ }
455
+ if (fs.existsSync(templatesDir)) {
456
+ copyDir(templatesDir, paradigmDir, projectName);
457
+ if (!fs.existsSync(path.join(paradigmDir, "fixtures.yaml"))) {
458
+ createFixturesTemplate(paradigmDir);
459
+ }
460
+ applyDisciplineToConfig(paradigmDir, cwd);
461
+ spinner.succeed(chalk.green(".paradigm/ created"));
462
+ } else {
463
+ spinner.warn(chalk.yellow("Templates not found, creating minimal structure"));
464
+ createMinimalStructure(paradigmDir, projectName);
465
+ }
466
+ } catch (error) {
467
+ spinner.fail(chalk.red(`Failed: ${error.message}`));
468
+ return;
469
+ }
470
+ const premisePath = path.join(cwd, ".premise");
471
+ if (!fs.existsSync(premisePath) || options.force) {
472
+ spinner.start("Creating .premise...");
473
+ fs.writeFileSync(premisePath, getDefaultPremiseContent(projectName));
474
+ spinner.succeed(chalk.green(".premise created"));
475
+ }
476
+ const purposePath = path.join(cwd, ".purpose");
477
+ if (!fs.existsSync(purposePath) || options.force) {
478
+ spinner.start("Creating .purpose...");
479
+ fs.writeFileSync(purposePath, getDefaultPurposeContent());
480
+ spinner.succeed(chalk.green(".purpose created"));
481
+ }
482
+ const portalPath = path.join(cwd, "portal.yaml");
483
+ if (!fs.existsSync(portalPath)) {
484
+ console.log(chalk.gray(" \u25CB No portal.yaml (optional - create manually if you need gate/auth definitions)"));
485
+ console.log(chalk.gray(" See: https://github.com/a-company/paradigm/blob/main/docs/guides/portals.md"));
486
+ }
487
+ let targetIDE;
488
+ if (options.ide) {
489
+ const validIDEs = ["cursor", "copilot", "windsurf", "claude"];
490
+ targetIDE = validIDEs.includes(options.ide.toLowerCase()) ? options.ide.toLowerCase() : "cursor";
491
+ } else {
492
+ spinner.start("Detecting IDE...");
493
+ const ideDetection = detectIDE(cwd);
494
+ targetIDE = ideDetection.detected || "cursor";
495
+ spinner.succeed(`Using ${chalk.cyan(targetIDE)}`);
496
+ }
497
+ const files = loadParadigmFiles(cwd);
498
+ if (files) {
499
+ spinner.start("Generating IDE instructions...");
500
+ const result = syncToIDE(cwd, targetIDE, files, true);
501
+ if (result.success) {
502
+ spinner.succeed(chalk.green(result.message || "IDE instructions generated"));
503
+ } else {
504
+ spinner.warn(chalk.yellow(result.message));
505
+ }
506
+ }
507
+ if (!options.quick) {
508
+ spinner.start("Creating scan index for MCP tools...");
509
+ try {
510
+ await indexCommand(cwd, { quiet: true });
511
+ spinner.succeed(chalk.green("Scan index created"));
512
+ } catch (error) {
513
+ spinner.warn(chalk.yellow("Could not create scan index: " + error.message));
514
+ console.log(chalk.gray(" Run `paradigm scan` manually after adding .purpose files"));
515
+ }
516
+ }
517
+ displaySummary(targetIDE, detection);
518
+ tracker.success("Paradigm initialized", { project: projectName, ide: targetIDE });
519
+ }
520
+ function applyDisciplineToConfig(paradigmDir, rootDir) {
521
+ const configPath = path.join(paradigmDir, "config.yaml");
522
+ if (!fs.existsSync(configPath)) return;
523
+ const discipline = detectDiscipline(rootDir);
524
+ if (discipline === "auto") return;
525
+ let content = fs.readFileSync(configPath, "utf8");
526
+ content = content.replace(
527
+ /^discipline:\s*auto\b.*$/m,
528
+ `discipline: ${discipline}`
529
+ );
530
+ const config = getDisciplineConfig(discipline);
531
+ const mappingLines = Object.entries(config.symbolMapping).map(([pattern, symbol]) => ` "${pattern}": "${symbol}"`).join("\n");
532
+ content = content.replace(
533
+ / symbol-mapping:\n(?: .*\n)*/,
534
+ ` symbol-mapping:
535
+ ${mappingLines}
536
+ `
537
+ );
538
+ const purposeLines = config.purposeRequired.map((pr) => ` - pattern: "${pr.pattern}"
539
+ depth: ${pr.depth}`).join("\n");
540
+ content = content.replace(
541
+ /purpose-required:\n(?: - pattern:.*\n depth:.*\n)*/,
542
+ `purpose-required:
543
+ ${purposeLines}
544
+ `
545
+ );
546
+ fs.writeFileSync(configPath, content, "utf8");
547
+ }
548
+ function createMinimalStructure(paradigmDir, projectName) {
549
+ fs.mkdirSync(path.join(paradigmDir, "specs"), { recursive: true });
550
+ fs.mkdirSync(path.join(paradigmDir, "docs"), { recursive: true });
551
+ const minimalConfig = `# Paradigm Configuration
552
+ version: "1.0"
553
+ project: "${projectName}"
554
+
555
+ agent-guidelines:
556
+ overview: |
557
+ This project uses Paradigm for structured AI-assisted development.
558
+ how-to-use:
559
+ - Check .paradigm/specs/ for philosophy and patterns
560
+ - Use symbol prefixes: @feature #component ^gate !signal %state $flow
561
+ - Run \`paradigm beacon\` for quick context
562
+ - Run \`paradigm ripple @symbol\` before making changes
563
+
564
+ symbol-system:
565
+ "@":
566
+ name: Feature
567
+ description: User-facing capabilities
568
+ examples: ["@login", "@checkout"]
569
+ "#":
570
+ name: Component
571
+ description: Reusable code units
572
+ examples: ["#Button", "#api-client"]
573
+ "^":
574
+ name: Portal
575
+ description: Authorization gates
576
+ examples: ["^authenticated", "^admin-only"]
577
+ "!":
578
+ name: Signal
579
+ description: Events and side effects
580
+ examples: ["!login-success", "!payment-failed"]
581
+ "%":
582
+ name: State
583
+ description: Application state
584
+ examples: ["%user.authenticated", "%cart.items"]
585
+ "$":
586
+ name: Flow
587
+ description: Multi-step processes
588
+ examples: ["$checkout-flow", "$onboarding"]
589
+
590
+ logging:
591
+ enforce: true
592
+ default-level: debug
593
+
594
+ scan:
595
+ enabled: true
596
+
597
+ conventions:
598
+ - Use kebab-case for symbol IDs
599
+ - ALWAYS use Paradigm logger, NEVER raw console.log/print
600
+ `;
601
+ fs.writeFileSync(path.join(paradigmDir, "config.yaml"), minimalConfig, "utf8");
602
+ createFixturesTemplate(paradigmDir);
603
+ }
604
+ function createFixturesTemplate(paradigmDir) {
605
+ const fixturesTemplate = `# Test Fixtures for Flow Validation
606
+ # Use with paradigm_test_fixtures MCP tool
607
+ version: "1.0"
608
+
609
+ # User fixtures for authentication testing
610
+ users:
611
+ admin:
612
+ id: "user-admin"
613
+ email: "admin@test.com"
614
+ role: "admin"
615
+ token: "Bearer test-admin-token"
616
+ member:
617
+ id: "user-member"
618
+ email: "member@test.com"
619
+ role: "member"
620
+ token: "Bearer test-member-token"
621
+ outsider:
622
+ id: "user-outsider"
623
+ email: "outsider@test.com"
624
+ token: "Bearer test-outsider-token"
625
+
626
+ # Resource fixtures for entity testing
627
+ resources:
628
+ project:
629
+ id: "project-1"
630
+ name: "Test Project"
631
+ members: ["user-member"]
632
+ admins: ["user-admin"]
633
+ task:
634
+ id: "task-1"
635
+ projectId: "project-1"
636
+ title: "Sample Task"
637
+ assignees: ["user-member"]
638
+
639
+ # Payload fixtures for API testing
640
+ payloads:
641
+ createProject:
642
+ name: "New Project"
643
+ description: "Test project description"
644
+ createTask:
645
+ title: "New Task"
646
+ description: "Task description"
647
+ assignees: []
648
+ updateTask:
649
+ title: "Updated Task"
650
+ status: "in-progress"
651
+ `;
652
+ fs.writeFileSync(path.join(paradigmDir, "fixtures.yaml"), fixturesTemplate, "utf8");
653
+ }
654
+
655
+ export {
656
+ initCommand
657
+ };