@intlayer/cli 9.5.7 → 9.5.9-canary.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 (105) hide show
  1. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  2. package/dist/cjs/auth/login.cjs +24 -16
  3. package/dist/cjs/auth/login.cjs.map +1 -1
  4. package/dist/cjs/build.cjs +1 -1
  5. package/dist/cjs/ci.cjs +1 -1
  6. package/dist/cjs/cli.cjs +18 -7
  7. package/dist/cjs/cli.cjs.map +1 -1
  8. package/dist/cjs/config.cjs +1 -1
  9. package/dist/cjs/editor.cjs +1 -1
  10. package/dist/cjs/extract.cjs +5 -5
  11. package/dist/cjs/fill/fill.cjs +2 -2
  12. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
  13. package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
  14. package/dist/cjs/fill/translateDictionary.cjs +1 -1
  15. package/dist/cjs/fill/writeFill.cjs +1 -1
  16. package/dist/cjs/getTargetDictionary.cjs +1 -1
  17. package/dist/cjs/index.cjs +8 -7
  18. package/dist/cjs/init.cjs +65 -147
  19. package/dist/cjs/init.cjs.map +1 -1
  20. package/dist/cjs/initMCP.cjs +1 -25
  21. package/dist/cjs/initMCP.cjs.map +1 -1
  22. package/dist/cjs/initSkills.cjs +36 -27
  23. package/dist/cjs/initSkills.cjs.map +1 -1
  24. package/dist/cjs/listContentDeclaration.cjs +2 -2
  25. package/dist/cjs/liveSync.cjs +4 -4
  26. package/dist/cjs/pull.cjs +4 -4
  27. package/dist/cjs/push/push.cjs +5 -5
  28. package/dist/cjs/pushConfig.cjs +1 -1
  29. package/dist/cjs/reviewDoc/reviewDoc.cjs +3 -3
  30. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +3 -3
  31. package/dist/cjs/reviewDoc/reviewDocLog.cjs +1 -1
  32. package/dist/cjs/searchDoc.cjs +1 -1
  33. package/dist/cjs/test/listMissingTranslations.cjs +1 -1
  34. package/dist/cjs/test/test.cjs +1 -1
  35. package/dist/cjs/translateDoc/translateDoc.cjs +2 -2
  36. package/dist/cjs/translateDoc/translateFile.cjs +2 -2
  37. package/dist/cjs/upgrade.cjs +18 -0
  38. package/dist/cjs/upgrade.cjs.map +1 -0
  39. package/dist/cjs/utils/getOutputFilePath.cjs +1 -1
  40. package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
  41. package/dist/cjs/watch.cjs +1 -1
  42. package/dist/esm/_virtual/_utils_asset.mjs +1 -1
  43. package/dist/esm/auth/login.mjs +23 -15
  44. package/dist/esm/auth/login.mjs.map +1 -1
  45. package/dist/esm/build.mjs +1 -1
  46. package/dist/esm/ci.mjs +1 -1
  47. package/dist/esm/cli.mjs +19 -8
  48. package/dist/esm/cli.mjs.map +1 -1
  49. package/dist/esm/config.mjs +1 -1
  50. package/dist/esm/editor.mjs +1 -1
  51. package/dist/esm/extract.mjs +6 -6
  52. package/dist/esm/extract.mjs.map +1 -1
  53. package/dist/esm/fill/fill.mjs +4 -4
  54. package/dist/esm/fill/fill.mjs.map +1 -1
  55. package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
  56. package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
  57. package/dist/esm/fill/translateDictionary.mjs +1 -1
  58. package/dist/esm/fill/writeFill.mjs +1 -1
  59. package/dist/esm/getTargetDictionary.mjs +1 -1
  60. package/dist/esm/index.mjs +9 -9
  61. package/dist/esm/init.mjs +67 -147
  62. package/dist/esm/init.mjs.map +1 -1
  63. package/dist/esm/initMCP.mjs +3 -25
  64. package/dist/esm/initMCP.mjs.map +1 -1
  65. package/dist/esm/initSkills.mjs +36 -28
  66. package/dist/esm/initSkills.mjs.map +1 -1
  67. package/dist/esm/listContentDeclaration.mjs +2 -2
  68. package/dist/esm/liveSync.mjs +3 -3
  69. package/dist/esm/pull.mjs +4 -4
  70. package/dist/esm/push/push.mjs +7 -7
  71. package/dist/esm/push/push.mjs.map +1 -1
  72. package/dist/esm/pushConfig.mjs +1 -1
  73. package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
  74. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
  75. package/dist/esm/reviewDoc/reviewDocLog.mjs +1 -1
  76. package/dist/esm/searchDoc.mjs +1 -1
  77. package/dist/esm/test/listMissingTranslations.mjs +1 -1
  78. package/dist/esm/test/test.mjs +1 -1
  79. package/dist/esm/translateDoc/translateDoc.mjs +2 -2
  80. package/dist/esm/translateDoc/translateFile.mjs +2 -2
  81. package/dist/esm/upgrade.mjs +17 -0
  82. package/dist/esm/upgrade.mjs.map +1 -0
  83. package/dist/esm/utils/getOutputFilePath.mjs +1 -1
  84. package/dist/esm/utils/getParentPackageJSON.mjs +1 -1
  85. package/dist/esm/watch.mjs +1 -1
  86. package/dist/types/index.d.ts +2 -2
  87. package/dist/types/init.d.ts.map +1 -1
  88. package/dist/types/initMCP.d.ts.map +1 -1
  89. package/dist/types/initSkills.d.ts +11 -1
  90. package/dist/types/initSkills.d.ts.map +1 -1
  91. package/dist/types/upgrade.d.ts +9 -0
  92. package/dist/types/upgrade.d.ts.map +1 -0
  93. package/package.json +10 -10
  94. package/dist/cjs/initBuildOptimization.cjs +0 -80
  95. package/dist/cjs/initBuildOptimization.cjs.map +0 -1
  96. package/dist/cjs/initCompiler.cjs +0 -77
  97. package/dist/cjs/initCompiler.cjs.map +0 -1
  98. package/dist/esm/initBuildOptimization.mjs +0 -79
  99. package/dist/esm/initBuildOptimization.mjs.map +0 -1
  100. package/dist/esm/initCompiler.mjs +0 -76
  101. package/dist/esm/initCompiler.mjs.map +0 -1
  102. package/dist/types/initBuildOptimization.d.ts +0 -19
  103. package/dist/types/initBuildOptimization.d.ts.map +0 -1
  104. package/dist/types/initCompiler.d.ts +0 -20
  105. package/dist/types/initCompiler.d.ts.map +0 -1
@@ -1,23 +1,23 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_pull = require('./pull.cjs');
3
+ const require_extract = require('./extract.cjs');
4
+ const require_editor = require('./editor.cjs');
5
+ const require_liveSync = require('./liveSync.cjs');
2
6
  const require_initInfra = require('./initInfra.cjs');
3
7
  const require_initSkills = require('./initSkills.cjs');
4
8
  const require_init = require('./init.cjs');
5
9
  const require_build = require('./build.cjs');
6
- const require_listProjects = require('./listProjects.cjs');
7
- const require_editor = require('./editor.cjs');
8
- const require_scan = require('./scan.cjs');
9
- const require_cli = require('./cli.cjs');
10
- const require_extract = require('./extract.cjs');
11
10
  const require_bundle = require('./bundle.cjs');
11
+ const require_cli = require('./cli.cjs');
12
12
  const require_test_listMissingTranslations = require('./test/listMissingTranslations.cjs');
13
13
  const require_test_test = require('./test/test.cjs');
14
14
  const require_fill_fill = require('./fill/fill.cjs');
15
15
  const require_listContentDeclaration = require('./listContentDeclaration.cjs');
16
- const require_liveSync = require('./liveSync.cjs');
17
- const require_pull = require('./pull.cjs');
16
+ const require_listProjects = require('./listProjects.cjs');
18
17
  const require_push_push = require('./push/push.cjs');
19
18
  const require_pushConfig = require('./pushConfig.cjs');
20
19
  const require_reviewDoc_reviewDoc = require('./reviewDoc/reviewDoc.cjs');
20
+ const require_scan = require('./scan.cjs');
21
21
  const require_searchDoc = require('./searchDoc.cjs');
22
22
  const require_translateDoc_translateDoc = require('./translateDoc/translateDoc.cjs');
23
23
 
@@ -42,6 +42,7 @@ exports.listMissingTranslationsWithConfig = require_test_listMissingTranslations
42
42
  exports.listProjectsCommand = require_listProjects.listProjectsCommand;
43
43
  exports.liveSync = require_liveSync.liveSync;
44
44
  exports.parseInfraMode = require_initInfra.parseInfraMode;
45
+ exports.promptPlatform = require_initSkills.promptPlatform;
45
46
  exports.pull = require_pull.pull;
46
47
  exports.push = require_push_push.push;
47
48
  exports.pushConfig = require_pushConfig.pushConfig;
package/dist/cjs/init.cjs CHANGED
@@ -1,17 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_auth_login = require('./auth/login.cjs');
4
3
  const require_loadPrompts = require('./loadPrompts.cjs');
5
- const require_initBuildOptimization = require('./initBuildOptimization.cjs');
6
- const require_initCompiler = require('./initCompiler.cjs');
7
4
  const require_initInfra = require('./initInfra.cjs');
8
5
  const require_initSkills = require('./initSkills.cjs');
9
6
  const require_initMCP = require('./initMCP.cjs');
7
+ let node_fs = require("node:fs");
10
8
  let node_path = require("node:path");
11
9
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
12
- let enquirer = require("enquirer");
13
- enquirer = require_runtime.__toESM(enquirer);
14
- let node_fs = require("node:fs");
15
10
 
16
11
  //#region src/init.ts
17
12
  const findProjectRoot = (startDir) => {
@@ -22,58 +17,67 @@ const findProjectRoot = (startDir) => {
22
17
  }
23
18
  return startDir;
24
19
  };
25
- const BASE_INIT_STEP_OPTIONS = [
26
- {
27
- value: "packages",
28
- label: "Install & upgrade packages",
29
- hint: "install missing Intlayer dependencies and upgrade outdated ones"
30
- },
31
- {
32
- value: "githubActions",
33
- label: "CI/CD (GitHub Actions)",
34
- hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
35
- },
36
- {
37
- value: "frameworkSetup",
38
- label: "Framework setup",
39
- hint: "middleware/proxy and providers in layout/page"
40
- },
41
- {
20
+ /**
21
+ * Steps shown but not pre-selected. The infrastructure installer touches the
22
+ * machine (downloads an app, pulls Docker images) rather than the project, so
23
+ * it must be an explicit choice.
24
+ */
25
+ const OPT_IN_INIT_STEPS = ["infra"];
26
+ /** Grouped checkbox entries of the interactive init flow, in display order. */
27
+ const INIT_STEP_GROUPS = {
28
+ Codebase: [
29
+ {
30
+ value: "packages",
31
+ label: "Install & upgrade packages",
32
+ hint: "install missing Intlayer dependencies and upgrade outdated ones"
33
+ },
34
+ {
35
+ value: "projectSetup",
36
+ label: "Project setup",
37
+ hint: "intlayer config, tsconfig, bundler plugin, middleware/proxy and providers in layout/page"
38
+ },
39
+ {
40
+ value: "githubActions",
41
+ label: "CI/CD (GitHub Actions)",
42
+ hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
43
+ }
44
+ ],
45
+ DevTools: [{
42
46
  value: "vscodeExtension",
43
47
  label: "VS Code extension",
44
48
  hint: "recommend the Intlayer extension"
45
- },
46
- {
47
- value: "lsp",
48
- label: "Editor LSP",
49
- hint: "go-to-definition from keys to .content files"
50
- },
51
- {
49
+ }, {
52
50
  value: "eslint",
53
51
  label: "Lint rules (ESLint / oxlint)",
54
52
  hint: "flag hardcoded text and dynamic calls the compiler cannot optimize"
55
- },
56
- {
57
- value: "skills",
58
- label: "AI skills",
59
- hint: "install the Intlayer documentation as agent skills"
60
- },
61
- {
62
- value: "mcp",
63
- label: "MCP server",
64
- hint: "configure the Intlayer MCP server"
65
- }
66
- ];
67
- /**
68
- * Steps that are opt-in: offered in the checkbox but not pre-selected. The
69
- * infrastructure installer touches the machine (downloads an app, pulls
70
- * Docker images) rather than the project, so it must be an explicit choice.
71
- */
72
- const OPT_IN_INIT_STEP_OPTIONS = [{
73
- value: "infra",
74
- label: "Infrastructure (desktop app / self-hosting)",
75
- hint: "install the desktop app, or self-host with Docker (all-in-one or Compose)"
76
- }];
53
+ }],
54
+ "Coding assistant": [
55
+ {
56
+ value: "skills",
57
+ label: "AI skills",
58
+ hint: "install the Intlayer documentation as agent skills"
59
+ },
60
+ {
61
+ value: "mcp",
62
+ label: "MCP server",
63
+ hint: "configure the Intlayer MCP server"
64
+ },
65
+ {
66
+ value: "lsp",
67
+ label: "Editor LSP",
68
+ hint: "go-to-definition from keys to .content files"
69
+ }
70
+ ],
71
+ CMS: [{
72
+ value: "cms",
73
+ label: "CMS",
74
+ hint: "log in through your browser, then store the credentials in your .env"
75
+ }, {
76
+ value: "infra",
77
+ label: "Infrastructure (desktop app / self-hosting)",
78
+ hint: "install the desktop app, or self-host with Docker (all-in-one or Compose)"
79
+ }]
80
+ };
77
81
  /** Locale routing strategies offered by the interactive init flow. */
78
82
  const ROUTING_MODE_OPTIONS = [
79
83
  {
@@ -97,28 +101,6 @@ const ROUTING_MODE_OPTIONS = [
97
101
  hint: "/about?locale=fr"
98
102
  }
99
103
  ];
100
- /**
101
- * Content organization strategies offered by the interactive init flow.
102
- * Drives the `compiler.output` template (autogenerated content: compiler /
103
- * autofill / extract) or the injection of the syncJSON plugin.
104
- */
105
- const CONTENT_STRATEGY_OPTIONS = [
106
- {
107
- value: "per-component",
108
- label: "Per component (default)",
109
- hint: "multilingual .content files co-located with the components"
110
- },
111
- {
112
- value: "centralized",
113
- label: "Centralized folder",
114
- hint: "per-locale JSON dictionaries under /locales/{locale}/{key}.content.json"
115
- },
116
- {
117
- value: "json-namespaces",
118
- label: "JSON namespaces",
119
- hint: "plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin"
120
- }
121
- ];
122
104
  /** Reads the merged dependencies of the project at `root`. */
123
105
  const getProjectDependencies = (root) => {
124
106
  try {
@@ -133,10 +115,6 @@ const getProjectDependencies = (root) => {
133
115
  return {};
134
116
  }
135
117
  };
136
- /** Returns true when the project at `root` depends on Next.js. */
137
- const isNextJsProject = (root) => Boolean(getProjectDependencies(root).next);
138
- /** Returns true when the project at `root` depends on Vite. */
139
- const isViteProject = (root) => Boolean(getProjectDependencies(root).vite);
140
118
  /**
141
119
  * Returns true when the project uses a URL-based router for which a locale
142
120
  * routing strategy is meaningful: Next.js, React Router, or TanStack Router.
@@ -158,23 +136,10 @@ const hasUrlRouting = (root) => {
158
136
  const runInteractiveInit = async (root, baseOptions) => {
159
137
  const p = await require_loadPrompts.loadPrompts();
160
138
  p.intro("Initialize Intlayer");
161
- const stepOptions = [...BASE_INIT_STEP_OPTIONS];
162
- const nextJsProject = isNextJsProject(root);
163
- if (nextJsProject || isViteProject(root)) stepOptions.push({
164
- value: "compiler",
165
- label: "Compiler",
166
- hint: nextJsProject ? "add the Babel compiler config to extract inline content (Next.js)" : "auto-extract inline content at build time (already plugged in on Vite)"
167
- });
168
- if (nextJsProject) stepOptions.push({
169
- value: "buildOptimization",
170
- label: "Bundle optimization",
171
- hint: "choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)"
172
- });
173
- stepOptions.push(...OPT_IN_INIT_STEP_OPTIONS);
174
- const selected = await p.multiselect({
139
+ const selected = await p.groupMultiselect({
175
140
  message: "Select what you want to set up:",
176
- options: stepOptions,
177
- initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),
141
+ options: INIT_STEP_GROUPS,
142
+ initialValues: Object.values(INIT_STEP_GROUPS).flat().map((option) => option.value).filter((step) => !OPT_IN_INIT_STEPS.includes(step)),
178
143
  required: false
179
144
  });
180
145
  if (p.isCancel(selected)) {
@@ -183,7 +148,7 @@ const runInteractiveInit = async (root, baseOptions) => {
183
148
  }
184
149
  const steps = selected;
185
150
  let routingMode;
186
- if (hasUrlRouting(root)) {
151
+ if (steps.includes("projectSetup") && hasUrlRouting(root)) {
187
152
  const selectedRoutingMode = await p.select({
188
153
  message: "Which locale routing strategy do you want?",
189
154
  options: ROUTING_MODE_OPTIONS,
@@ -196,70 +161,23 @@ const runInteractiveInit = async (root, baseOptions) => {
196
161
  routingMode = selectedRoutingMode;
197
162
  }
198
163
  const detectedCompatLibraries = (0, _intlayer_engine_cli.detectCompatI18nLibraries)(getProjectDependencies(root));
199
- const hasCompatLib = detectedCompatLibraries.length > 0;
200
- if (hasCompatLib) p.log.info(`Detected existing i18n ${detectedCompatLibraries.length > 1 ? "libraries" : "library"}: ${detectedCompatLibraries.join(", ")} — the matching Intlayer compat adapter and catalog sync will be set up.`);
201
- let contentStrategy;
202
- if (!hasCompatLib) {
203
- const selectedContentStrategy = await p.select({
204
- message: "How do you want to organize your translated content?",
205
- options: CONTENT_STRATEGY_OPTIONS,
206
- initialValue: "per-component"
207
- });
208
- if (p.isCancel(selectedContentStrategy)) {
209
- p.cancel("Operation cancelled.");
210
- return;
211
- }
212
- contentStrategy = selectedContentStrategy;
213
- }
164
+ if (detectedCompatLibraries.length > 0) p.log.info(`Detected existing i18n ${detectedCompatLibraries.length > 1 ? "libraries" : "library"}: ${detectedCompatLibraries.join(", ")} — the matching Intlayer compat adapter and catalog sync will be set up.`);
214
165
  const options = {
215
166
  ...baseOptions,
216
167
  routingMode,
217
- contentStrategy,
218
168
  noInstallPackages: !steps.includes("packages"),
219
169
  noGitignore: baseOptions?.noGitignore,
220
170
  noGithubActions: baseOptions?.noGithubActions || !steps.includes("githubActions"),
221
- noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("frameworkSetup"),
171
+ noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("projectSetup"),
222
172
  noVscodeExtension: !steps.includes("vscodeExtension"),
223
173
  noLsp: !steps.includes("lsp"),
224
174
  noEslint: !steps.includes("eslint")
225
175
  };
226
176
  await (0, _intlayer_engine_cli.initIntlayer)(root, options);
227
- const needsPlatform = steps.includes("skills") || steps.includes("mcp");
228
- let sharedPlatform;
229
- if (needsPlatform) {
230
- const detectedPlatform = require_initSkills.getDetectedPlatform();
231
- try {
232
- sharedPlatform = (await enquirer.default.prompt({
233
- type: "autocomplete",
234
- name: "platforms",
235
- message: "Which platform are you using? (Type to search)",
236
- multiple: false,
237
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
238
- choices: require_initSkills.PLATFORM_OPTIONS.map((opt) => ({
239
- name: opt.value,
240
- message: opt.label,
241
- hint: opt.hint
242
- }))
243
- })).platforms;
244
- } catch {
245
- p.cancel("Operation cancelled.");
246
- return;
247
- }
248
- }
249
- if (steps.includes("skills")) await require_initSkills.initSkills(root, sharedPlatform);
250
- if (steps.includes("mcp")) await require_initMCP.initMCP(root, sharedPlatform);
251
- if (steps.includes("compiler")) await require_initCompiler.initCompiler(root);
252
- if (steps.includes("buildOptimization")) await require_initBuildOptimization.initBuildOptimization(root);
177
+ const skillsPlatform = steps.includes("skills") ? await require_initSkills.initSkills(root) : void 0;
178
+ if (steps.includes("mcp")) await require_initMCP.initMCP(root, skillsPlatform);
253
179
  if (steps.includes("infra")) await require_initInfra.initInfra();
254
- const shouldSetUpCms = await p.confirm({
255
- message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
256
- initialValue: false
257
- });
258
- if (p.isCancel(shouldSetUpCms)) {
259
- p.cancel("Operation cancelled.");
260
- return;
261
- }
262
- if (shouldSetUpCms) {
180
+ if (steps.includes("cms")) {
263
181
  p.log.info("Opening your browser to log in to the Intlayer CMS...");
264
182
  await require_auth_login.login({
265
183
  exitAfter: false,
@@ -1 +1 @@
1
- {"version":3,"file":"init.cjs","names":["resolve","existsSync","join","readFileSync","loadPrompts","detectCompatI18nLibraries","initIntlayer","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","initSkills","initMCP","initCompiler","initBuildOptimization","initInfra","login","setupCmsCredentials"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n type ContentStrategy,\n detectCompatI18nLibraries,\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initInfra } from './initInfra';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'eslint'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization'\n | 'infra';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'eslint',\n label: 'Lint rules (ESLint / oxlint)',\n hint: 'flag hardcoded text and dynamic calls the compiler cannot optimize',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/**\n * Steps that are opt-in: offered in the checkbox but not pre-selected. The\n * infrastructure installer touches the machine (downloads an app, pulls\n * Docker images) rather than the project, so it must be an explicit choice.\n */\nconst OPT_IN_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'infra',\n label: 'Infrastructure (desktop app / self-hosting)',\n hint: 'install the desktop app, or self-host with Docker (all-in-one or Compose)',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/**\n * Content organization strategies offered by the interactive init flow.\n * Drives the `compiler.output` template (autogenerated content: compiler /\n * autofill / extract) or the injection of the syncJSON plugin.\n */\nconst CONTENT_STRATEGY_OPTIONS: Array<{\n value: ContentStrategy;\n label: string;\n hint: string;\n}> = [\n {\n value: 'per-component',\n label: 'Per component (default)',\n hint: 'multilingual .content files co-located with the components',\n },\n {\n value: 'centralized',\n label: 'Centralized folder',\n hint: 'per-locale JSON dictionaries under /locales/{locale}/{key}.content.json',\n },\n {\n value: 'json-namespaces',\n label: 'JSON namespaces',\n hint: 'plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages, GitHub\n * Actions, VS Code extension, LSP) and runs the dedicated skills/MCP installers\n * for the steps that own their own prompts. The `.gitignore` entry is not\n * offered as a checkbox — it is always added (unless `--no-gitignore` is set).\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n const p = await loadPrompts();\n\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n stepOptions.push(...OPT_IN_INIT_STEP_OPTIONS);\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n // Compat i18n library detection — never asked, always derived from the\n // installed packages. `detectMissingIntlayerPackages` reads the very same\n // dependency map to schedule the compat adapter, the sync plugin and the\n // catalog template, so a project without any of those packages is simply set\n // up on Intlayer alone.\n const detectedCompatLibraries = detectCompatI18nLibraries(\n getProjectDependencies(root)\n );\n const hasCompatLib = detectedCompatLibraries.length > 0;\n\n if (hasCompatLib) {\n p.log.info(\n `Detected existing i18n ${detectedCompatLibraries.length > 1 ? 'libraries' : 'library'}: ${detectedCompatLibraries.join(', ')} — the matching Intlayer compat adapter and catalog sync will be set up.`\n );\n }\n\n // Content organization strategy → drives `compiler.output` (autogenerated\n // content) or the syncJSON plugin injection. A compat library already\n // dictates the catalog layout (its JSON/PO files are synced as-is), so the\n // question is only asked when none is in play.\n let contentStrategy: ContentStrategy | undefined;\n\n if (!hasCompatLib) {\n const selectedContentStrategy = await p.select<ContentStrategy>({\n message: 'How do you want to organize your translated content?',\n options: CONTENT_STRATEGY_OPTIONS,\n initialValue: 'per-component',\n });\n\n if (p.isCancel(selectedContentStrategy)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n contentStrategy = selectedContentStrategy;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n contentStrategy,\n noInstallPackages: !steps.includes('packages'),\n // The `.gitignore` entry is never offered as a checkbox: in interactive\n // mode we always add `.intlayer` to `.gitignore`, only honoring an explicit\n // `--no-gitignore` flag from the command line.\n noGitignore: baseOptions?.noGitignore,\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n noEslint: !steps.includes('eslint'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n // Delegated to the hosted install script, which owns its own menu.\n if (steps.includes('infra')) {\n await initInfra();\n }\n\n // CMS / visual editor is the last step: an opt-in browser login that\n // persists the access-key credentials to `.env` and enables the editor in the\n // config file. Asked last so the browser flow does not interrupt setup.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;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C/B;EACF;CACF;CAEA,IAAI,MAAM,SAAS,QAAQ,GACzB,MAAMC,8BAAW,MAAM,cAAc;CAGvC,IAAI,MAAM,SAAS,KAAK,GACtB,MAAMC,wBAAQ,MAAM,cAAc;CAGpC,IAAI,MAAM,SAAS,UAAU,GAC3B,MAAMC,kCAAa,IAAI;CAGzB,IAAI,MAAM,SAAS,mBAAmB,GACpC,MAAMC,oDAAsB,IAAI;CAIlC,IAAI,MAAM,SAAS,OAAO,GACxB,MAAMC,4BAAU;CAMlB,MAAM,iBAAiB,MAAM,EAAE,QAAQ;EACrC,SACE;EACF,cAAc;CAChB,CAAC;CAED,IAAI,EAAE,SAAS,cAAc,GAAG;EAC9B,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,IAAI,gBAAgB;EAClB,EAAE,IAAI,KAAK,uDAAuD;EAGlE,MAAMC,yBAAM;GACV,WAAW;GACX,gBAAgB,oBAAgBC,0CAAoB,MAAM,WAAW;EACvE,CAAC;CACH;CAEA,EAAE,MAAM,kCAAkC;AAC5C;AAEA,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,oBAAgBhB,mBAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,UAAMM,mCAAa,MAAM,OAAO;AAClC"}
1
+ {"version":3,"file":"init.cjs","names":["resolve","existsSync","join","readFileSync","loadPrompts","detectCompatI18nLibraries","initIntlayer","initSkills","initMCP","initInfra","login","setupCmsCredentials"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n detectCompatI18nLibraries,\n type InitOptions,\n initIntlayer,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/engine/cli';\nimport { login } from './auth/login';\nimport { initInfra } from './initInfra';\nimport { initMCP } from './initMCP';\nimport { initSkills } from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'githubActions'\n | 'projectSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'eslint'\n | 'skills'\n | 'mcp'\n | 'infra'\n | 'cms';\n\n/** A checkbox entry of the interactive init flow. */\ntype InitStepOption = {\n value: InitStep;\n label: string;\n hint: string;\n};\n\n/**\n * Steps shown but not pre-selected. The infrastructure installer touches the\n * machine (downloads an app, pulls Docker images) rather than the project, so\n * it must be an explicit choice.\n */\nconst OPT_IN_INIT_STEPS: InitStep[] = ['infra'];\n\n/** Grouped checkbox entries of the interactive init flow, in display order. */\nconst INIT_STEP_GROUPS: Record<string, InitStepOption[]> = {\n Codebase: [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'projectSetup',\n label: 'Project setup',\n hint: 'intlayer config, tsconfig, bundler plugin, middleware/proxy and providers in layout/page',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)',\n },\n ],\n DevTools: [\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'eslint',\n label: 'Lint rules (ESLint / oxlint)',\n hint: 'flag hardcoded text and dynamic calls the compiler cannot optimize',\n },\n ],\n 'Coding assistant': [\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n ],\n CMS: [\n {\n value: 'cms',\n label: 'CMS',\n hint: 'log in through your browser, then store the credentials in your .env',\n },\n {\n value: 'infra',\n label: 'Infrastructure (desktop app / self-hosting)',\n hint: 'install the desktop app, or self-host with Docker (all-in-one or Compose)',\n },\n ],\n};\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages, GitHub\n * Actions, VS Code extension, LSP) and runs the dedicated skills/MCP installers\n * for the steps that own their own prompts. The `.gitignore` entry is not\n * offered as a checkbox — it is always added (unless `--no-gitignore` is set).\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n const p = await loadPrompts();\n\n p.intro('Initialize Intlayer');\n\n const selected = await p.groupMultiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: INIT_STEP_GROUPS,\n initialValues: Object.values(INIT_STEP_GROUPS)\n .flat()\n .map((option) => option.value)\n .filter((step) => !OPT_IN_INIT_STEPS.includes(step)),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (steps.includes('projectSetup') && hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n // Compat i18n library detection — never asked, always derived from the\n // installed packages. `detectMissingIntlayerPackages` reads the very same\n // dependency map to schedule the compat adapter, the sync plugin and the\n // catalog template, so a project without any of those packages is simply set\n // up on Intlayer alone.\n const detectedCompatLibraries = detectCompatI18nLibraries(\n getProjectDependencies(root)\n );\n const hasCompatLib = detectedCompatLibraries.length > 0;\n\n if (hasCompatLib) {\n p.log.info(\n `Detected existing i18n ${detectedCompatLibraries.length > 1 ? 'libraries' : 'library'}: ${detectedCompatLibraries.join(', ')} — the matching Intlayer compat adapter and catalog sync will be set up.`\n );\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n noInstallPackages: !steps.includes('packages'),\n // The `.gitignore` entry is never offered as a checkbox: in interactive\n // mode we always add `.intlayer` to `.gitignore`, only honoring an explicit\n // `--no-gitignore` flag from the command line.\n noGitignore: baseOptions?.noGitignore,\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('projectSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n noEslint: !steps.includes('eslint'),\n };\n\n await initIntlayer(root, options);\n\n // Skills ask for the platform after the skill selection; MCP reuses it.\n const skillsPlatform = steps.includes('skills')\n ? await initSkills(root)\n : undefined;\n\n if (steps.includes('mcp')) {\n await initMCP(root, skillsPlatform);\n }\n\n // Delegated to the hosted install script, which owns its own menu.\n if (steps.includes('infra')) {\n await initInfra();\n }\n\n // CMS / visual editor runs last: the browser login persists the access-key\n // credentials to `.env` and enables the editor in the config file. Kept last\n // so the browser flow does not interrupt setup.\n if (steps.includes('cms')) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;CAEjB,OAAO,mBAAeA,mBAAQ,YAAY,IAAI,GAAG;EAC/C,QAAIC,wBAAWC,gBAAK,YAAY,cAAc,CAAC,GAC7C,OAAO;EAET,iBAAaF,mBAAQ,YAAY,IAAI;CACvC;CAIA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AAa,MAAM,OAAO;CAGhC,MAAM,iBAAiB,MAAM,SAAS,QAAQ,IAC1C,MAAMC,8BAAW,IAAI,IACrB;CAEJ,IAAI,MAAM,SAAS,KAAK,GACtB,MAAMC,wBAAQ,MAAM,cAAc;CAIpC,IAAI,MAAM,SAAS,OAAO,GACxB,MAAMC,4BAAU;CAMlB,IAAI,MAAM,SAAS,KAAK,GAAG;EACzB,EAAE,IAAI,KAAK,uDAAuD;EAGlE,MAAMC,yBAAM;GACV,WAAW;GACX,gBAAgB,oBAAgBC,0CAAoB,MAAM,WAAW;EACvE,CAAC;CACH;CAEA,EAAE,MAAM,kCAAkC;AAC5C;AAEA,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,oBAAgBX,mBAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,UAAMM,mCAAa,MAAM,OAAO;AAClC"}
@@ -1,40 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_loadPrompts = require('./loadPrompts.cjs');
4
3
  const require_initSkills = require('./initSkills.cjs');
5
4
  const require_init = require('./init.cjs');
6
5
  let node_path = require("node:path");
7
6
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
8
- let enquirer = require("enquirer");
9
- enquirer = require_runtime.__toESM(enquirer);
10
7
 
11
8
  //#region src/initMCP.ts
12
9
  const initMCP = async (projectRoot, preselectedPlatform) => {
13
10
  const p = await require_loadPrompts.loadPrompts();
14
11
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
15
12
  p.intro("Initializing Intlayer MCP Server");
16
- let platform;
17
- if (preselectedPlatform) platform = preselectedPlatform;
18
- else {
19
- const detectedPlatform = require_initSkills.getDetectedPlatform();
20
- try {
21
- platform = (await enquirer.default.prompt({
22
- type: "autocomplete",
23
- name: "platforms",
24
- message: "Which platform are you using? (Type to search)",
25
- multiple: false,
26
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
27
- choices: require_initSkills.PLATFORM_OPTIONS.map((opt) => ({
28
- name: opt.value,
29
- message: opt.label,
30
- hint: opt.hint
31
- }))
32
- })).platforms;
33
- } catch {
34
- p.cancel("Operation cancelled.");
35
- return;
36
- }
37
- }
13
+ const platform = preselectedPlatform ?? await require_initSkills.promptPlatform();
38
14
  if (!platform) {
39
15
  p.cancel("Operation cancelled. No platform selected.");
40
16
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"initMCP.cjs","names":["loadPrompts","findProjectRoot","resolve","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","installMCP"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n type Platform,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const initMCP = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n) => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n let platform: Platform;\n\n if (preselectedPlatform) {\n platform = preselectedPlatform;\n } else {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UAAU,OACrB,aACA,wBACG;CACH,MAAM,IAAI,MAAMA,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,EAAE,MAAM,kCAAkC;CAE1C,IAAI;CAEJ,IAAI,qBACF,WAAW;MACN;EACL,MAAM,mBAAmBC,uCAAoB;EAE7C,IAAI;GAeF,YAAW,MAdY,iBAAS,OAAgC;IAC9D,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,SAAS,mBACLC,+BAAU,QAAQ,gBAAgB,IAClC;IACJ,SAASC,oCAAiB,KAAK,SAAS;KACtC,MAAM,IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;IACZ,EAAE;GACJ,CAAC,EACkB,CAAC;EACtB,QAAQ;GACN,EAAE,OAAO,sBAAsB;GAC/B;EACF;CACF;CAEA,IAAI,CAAC,UAAU;EACb,EAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,YAAa,MAAM,EAAE,OAAO;EAChC,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAI,EAAE,SAAS,SAAS,KAAK,CAAC,WAAW;EACvC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,IAAI,EAAE,QAAQ;CACpB,EAAE,MAAM,2BAA2B;CAEnC,IAAI;EACF,MAAM,SAAS,UAAMC,iCAAW,MAAM,UAAU,SAAS;EAEzD,EAAE,KAAK,oCAAoC;EAE3C,EAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,gCAAgC;EACvC,EAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,6CAA6C;AACvD"}
1
+ {"version":3,"file":"initMCP.cjs","names":["loadPrompts","findProjectRoot","resolve","promptPlatform","installMCP"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n installMCP,\n type MCPTransport,\n type Platform,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { promptPlatform } from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const initMCP = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n) => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n const platform = preselectedPlatform ?? (await promptPlatform());\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;AAUA,MAAa,UAAU,OACrB,aACA,wBACG;CACH,MAAM,IAAI,MAAMA,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,EAAE,MAAM,kCAAkC;CAE1C,MAAM,WAAW,uBAAwB,MAAMC,kCAAe;CAE9D,IAAI,CAAC,UAAU;EACb,EAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,YAAa,MAAM,EAAE,OAAO;EAChC,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAI,EAAE,SAAS,SAAS,KAAK,CAAC,WAAW;EACvC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,IAAI,EAAE,QAAQ;CACpB,EAAE,MAAM,2BAA2B;CAEnC,IAAI;EACF,MAAM,SAAS,UAAMC,iCAAW,MAAM,UAAU,SAAS;EAEzD,EAAE,KAAK,oCAAoC;EAE3C,EAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,gCAAgC;EACvC,EAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,6CAA6C;AACvD"}
@@ -2,11 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_loadPrompts = require('./loadPrompts.cjs');
4
4
  const require_init = require('./init.cjs');
5
+ let node_fs = require("node:fs");
5
6
  let node_path = require("node:path");
6
7
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
8
  let enquirer = require("enquirer");
8
9
  enquirer = require_runtime.__toESM(enquirer);
9
- let node_fs = require("node:fs");
10
10
 
11
11
  //#region src/initSkills.ts
12
12
  const PLATFORM_CHECKS = _intlayer_engine_cli.PLATFORMS.filter((platform) => _intlayer_engine_cli.PLATFORMS_METADATA[platform]?.check).map((platform) => ({
@@ -32,36 +32,38 @@ const getDependencies = (root) => {
32
32
  return {};
33
33
  }
34
34
  };
35
+ /**
36
+ * Asks which AI platform the user is using, preselecting the detected one.
37
+ * Resolves to `undefined` when the prompt is cancelled.
38
+ */
39
+ const promptPlatform = async () => {
40
+ const detectedPlatform = getDetectedPlatform();
41
+ try {
42
+ return (await enquirer.default.prompt({
43
+ type: "autocomplete",
44
+ name: "platform",
45
+ message: "Which platform are you using? (Type to search)",
46
+ multiple: false,
47
+ initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
48
+ choices: PLATFORM_OPTIONS.map((option) => ({
49
+ name: option.value,
50
+ message: option.label,
51
+ hint: option.hint
52
+ }))
53
+ })).platform;
54
+ } catch {
55
+ return;
56
+ }
57
+ };
58
+ /**
59
+ * Installs the Intlayer documentation skills. The skills are picked first, then
60
+ * the platform (unless preselected). Resolves to the platform used, so a
61
+ * following step (e.g. MCP) can reuse it without asking again.
62
+ */
35
63
  const initSkills = async (projectRoot, preselectedPlatform) => {
36
64
  const p = await require_loadPrompts.loadPrompts();
37
65
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
38
66
  p.intro("Initializing Intlayer skills");
39
- let platform;
40
- if (preselectedPlatform) platform = preselectedPlatform;
41
- else {
42
- const detectedPlatform = getDetectedPlatform();
43
- try {
44
- platform = (await enquirer.default.prompt({
45
- type: "autocomplete",
46
- name: "platforms",
47
- message: "Which platforms are you using? (Type to search)",
48
- multiple: false,
49
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
50
- choices: PLATFORM_OPTIONS.map((opt) => ({
51
- name: opt.value,
52
- message: opt.label,
53
- hint: opt.hint
54
- }))
55
- })).platforms;
56
- } catch {
57
- p.cancel("Operation cancelled.");
58
- return;
59
- }
60
- }
61
- if (!platform) {
62
- p.log.warn("No platform selected. Nothing to install.");
63
- return;
64
- }
65
67
  const dependencies = getDependencies(root);
66
68
  const initialValues = (0, _intlayer_engine_cli.getInitialSkills)(dependencies);
67
69
  const selectedSkills = await p.multiselect({
@@ -78,6 +80,11 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
78
80
  p.cancel("Operation cancelled. No skills selected.");
79
81
  return;
80
82
  }
83
+ const platform = preselectedPlatform ?? await promptPlatform();
84
+ if (!platform) {
85
+ p.cancel("Operation cancelled. No platform selected.");
86
+ return;
87
+ }
81
88
  const s = p.spinner();
82
89
  s.start("Installing skills...");
83
90
  try {
@@ -89,10 +96,12 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
89
96
  p.log.error(error instanceof Error ? error.message : String(error));
90
97
  }
91
98
  p.outro("Intlayer skills initialization complete");
99
+ return platform;
92
100
  };
93
101
 
94
102
  //#endregion
95
103
  exports.PLATFORM_OPTIONS = PLATFORM_OPTIONS;
96
104
  exports.getDetectedPlatform = getDetectedPlatform;
97
105
  exports.initSkills = initSkills;
106
+ exports.promptPlatform = promptPlatform;
98
107
  //# sourceMappingURL=initSkills.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"initSkills.cjs","names":["PLATFORMS","PLATFORMS_METADATA","join","existsSync","readFileSync","loadPrompts","findProjectRoot","resolve","getInitialSkills","SKILLS","SKILLS_METADATA","installSkills"],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform]?.check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform]?.check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform]?.label ?? '',\n hint: `(${PLATFORMS_METADATA[platform]?.dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n) => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n let platform: Platform;\n\n if (preselectedPlatform) {\n platform = preselectedPlatform;\n } else {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platforms are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (!platform) {\n p.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,kBACJA,+BAAU,QAAQ,aAAaC,wCAAmB,SAAS,EAAE,KAAK,CAAC,CAAC,KACjE,cAAc;CACb,OAAOA,wCAAmB,SAAS,EAAE,gBAAgB;CACrD;AACF,EACF;AAEF,MAAa,mBAIRD,+BAAU,KAAK,cAAc;CAChC,OAAO;CACP,OAAOC,wCAAmB,SAAS,EAAE,SAAS;CAC9C,MAAM,IAAIA,wCAAmB,SAAS,EAAE,IAAI;AAC9C,EAAE;AAEF,MAAa,4BACX,gBAAgB,MAAM,EAAE,YAAY,MAAM,CAAC,CAAC,EAAE;AAEhD,MAAM,mBAAmB,SAAyC;CAChE,IAAI;EACF,MAAM,sBAAkBC,gBAAK,MAAM,cAAc;EACjD,IAAI,KAACC,oBAAW,eAAe,GAAG,OAAO,CAAC;EAE1C,MAAM,EAAE,eAAe,CAAC,GAAG,kBAAkB,CAAC,MAAM,KAAK,UACvDC,sBAAa,iBAAiB,OAAO,CACvC;EACA,OAAO;GAAE,GAAG;GAAc,GAAG;EAAgB;CAC/C,QAAQ;E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AAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,yCAAyC;AACnD"}
1
+ {"version":3,"file":"initSkills.cjs","names":["PLATFORMS","PLATFORMS_METADATA","join","existsSync","readFileSync","loadPrompts","findProjectRoot","resolve","getInitialSkills","SKILLS","SKILLS_METADATA","installSkills"],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform]?.check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform]?.check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform]?.label ?? '',\n hint: `(${PLATFORMS_METADATA[platform]?.dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/**\n * Asks which AI platform the user is using, preselecting the detected one.\n * Resolves to `undefined` when the prompt is cancelled.\n */\nexport const promptPlatform = async (): Promise<Platform | undefined> => {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platform: Platform }>({\n type: 'autocomplete',\n name: 'platform',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((option) => ({\n name: option.value,\n message: option.label,\n hint: option.hint,\n })),\n });\n\n return response.platform;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Installs the Intlayer documentation skills. The skills are picked first, then\n * the platform (unless preselected). Resolves to the platform used, so a\n * following step (e.g. MCP) can reuse it without asking again.\n */\nexport const initSkills = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n): Promise<Platform | undefined> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const platform = preselectedPlatform ?? (await promptPlatform());\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n\n return platform;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,kBACJA,+BAAU,QAAQ,aAAaC,wCAAmB,SAAS,EAAE,KAAK,CAAC,CAAC,KACjE,cAAc;CACb,OAAOA,wCAAmB,SAAS,EAAE,gBAAgB;CACrD;AACF,EAC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P,OAAO;GACP,MAAMC,qCAAgB;EACxB,EAAE;EACF,UAAU;CACZ,CAAC;CAED,IACE,EAAE,SAAS,cAAc,KACzB,CAAC,kBACA,eAA4B,WAAW,GACxC;EACA,EAAE,OAAO,0CAA0C;EACnD;CACF;CAEA,MAAM,WAAW,uBAAwB,MAAM,eAAe;CAE9D,IAAI,CAAC,UAAU;EACb,EAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,IAAI,EAAE,QAAQ;CACpB,EAAE,MAAM,sBAAsB;CAE9B,IAAI;EACF,MAAM,SAAS,UAAMC,oCAAc,MAAM,UAAU,cAAc;EAEjE,EAAE,KAAK,+BAA+B;EAEtC,EAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,0BAA0B;EACjC,EAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,yCAAyC;CAEjD,OAAO;AACT"}
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let node_path = require("node:path");
3
- let _intlayer_engine_cli = require("@intlayer/engine/cli");
4
3
  let _intlayer_config_logger = require("@intlayer/config/logger");
5
4
  let _intlayer_config_node = require("@intlayer/config/node");
6
- let _intlayer_engine_utils = require("@intlayer/engine/utils");
7
5
  let _intlayer_dictionaries_entry_unmerged = require("@intlayer/dictionaries-entry/unmerged");
6
+ let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
8
8
 
9
9
  //#region src/listContentDeclaration.ts
10
10
  const listContentDeclarationRows = async (options) => {
@@ -1,18 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_IntlayerEventListener = require('./IntlayerEventListener.cjs');
4
- let node_http = require("node:http");
5
4
  let _intlayer_config_colors = require("@intlayer/config/colors");
6
5
  _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
7
6
  let _intlayer_config_logger = require("@intlayer/config/logger");
8
7
  let _intlayer_config_node = require("@intlayer/config/node");
9
- let _intlayer_engine_utils = require("@intlayer/engine/utils");
10
8
  let _intlayer_dictionaries_entry_unmerged = require("@intlayer/dictionaries-entry/unmerged");
11
9
  let _intlayer_engine_build = require("@intlayer/engine/build");
12
- let _intlayer_core_plugins = require("@intlayer/core/plugins");
13
- let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
10
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
11
+ let node_http = require("node:http");
14
12
  let _intlayer_config_package_json = require("@intlayer/config/package.json");
15
13
  _intlayer_config_package_json = require_runtime.__toESM(_intlayer_config_package_json);
14
+ let _intlayer_core_plugins = require("@intlayer/core/plugins");
15
+ let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
16
16
 
17
17
  //#region src/liveSync.ts
18
18
  const writeDictionary = async (dictionary, configuration) => {