@open-mercato/cli 0.6.6-develop.6383.1.27fcc83455 → 0.6.6-develop.6385.1.9a81faa5f0

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 (35) hide show
  1. package/.turbo/turbo-build.log +11 -0
  2. package/build.mjs +70 -2
  3. package/dist/agentic/guides/core.auth.md +3 -0
  4. package/dist/agentic/guides/core.catalog.md +3 -0
  5. package/dist/agentic/guides/core.currencies.md +3 -0
  6. package/dist/agentic/guides/core.customer_accounts.md +3 -0
  7. package/dist/agentic/guides/core.customers.md +3 -0
  8. package/dist/agentic/guides/core.data_sync.md +3 -0
  9. package/dist/agentic/guides/core.integrations.md +3 -0
  10. package/dist/agentic/guides/core.sales.md +3 -0
  11. package/dist/agentic/guides/core.workflows.md +3 -0
  12. package/dist/agentic/guides/module-facts.json +2073 -0
  13. package/dist/agentic/guides/modules/auth.md +64 -0
  14. package/dist/agentic/guides/modules/catalog.md +70 -0
  15. package/dist/agentic/guides/modules/currencies.md +50 -0
  16. package/dist/agentic/guides/modules/customer_accounts.md +76 -0
  17. package/dist/agentic/guides/modules/customers.md +115 -0
  18. package/dist/agentic/guides/modules/data_sync.md +49 -0
  19. package/dist/agentic/guides/modules/integrations.md +49 -0
  20. package/dist/agentic/guides/modules/sales.md +109 -0
  21. package/dist/agentic/guides/modules/workflows.md +73 -0
  22. package/dist/lib/__integration__/TC-INT-008.spec.js +29 -1
  23. package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
  24. package/dist/lib/agentic-setup.js +87 -0
  25. package/dist/lib/agentic-setup.js.map +2 -2
  26. package/dist/lib/worker-job-handler.js +13 -1
  27. package/dist/lib/worker-job-handler.js.map +2 -2
  28. package/dist/mercato.js +4 -1
  29. package/dist/mercato.js.map +2 -2
  30. package/package.json +5 -5
  31. package/src/lib/__integration__/TC-INT-008.spec.ts +41 -1
  32. package/src/lib/__tests__/worker-job-handler.test.ts +28 -0
  33. package/src/lib/agentic-setup.ts +129 -0
  34. package/src/lib/worker-job-handler.ts +13 -1
  35. package/src/mercato.ts +4 -1
@@ -4,6 +4,7 @@ import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
+ import { MODULE_FACTS_ALLOWLIST } from "../generators/module-facts.js";
7
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
9
  const repoRoot = path.resolve(__dirname, "..", "..", "..", "..", "..");
9
10
  const cliDir = path.join(repoRoot, "packages", "cli");
@@ -13,6 +14,7 @@ const cliIntegrationRunnerPath = path.join(cliDir, "src", "lib", "testing", "int
13
14
  const standaloneTemplatePackageJsonPath = path.join(repoRoot, "packages", "create-app", "template", "package.json.template");
14
15
  const agenticRoot = path.join(repoRoot, "packages", "create-app", "agentic");
15
16
  const packagesRoot = path.join(repoRoot, "packages");
17
+ const FIXTURE_ENABLED_MODULES = ["customers", "sales"];
16
18
  function normalizePath(value) {
17
19
  return value.split(path.sep).join("/");
18
20
  }
@@ -50,7 +52,11 @@ function createStandaloneFixture(rootDir) {
50
52
  2
51
53
  )
52
54
  );
53
- writeFile(path.join(appDir, "src", "modules.ts"), "export const enabledModules = []\n");
55
+ const moduleEntries = FIXTURE_ENABLED_MODULES.map((moduleId) => ` { id: '${moduleId}' },`).join("\n");
56
+ writeFile(path.join(appDir, "src", "modules.ts"), `export const enabledModules = [
57
+ ${moduleEntries}
58
+ ]
59
+ `);
54
60
  return appDir;
55
61
  }
56
62
  function listRelativeFiles(rootDir) {
@@ -139,6 +145,14 @@ function readPlaywrightConfigPathFromCliRunner() {
139
145
  }
140
146
  function expectedGuideOutputNames() {
141
147
  const collected = /* @__PURE__ */ new Set();
148
+ const staticGuidesRoot = path.join(agenticRoot, "guides");
149
+ if (fs.existsSync(staticGuidesRoot)) {
150
+ for (const entry of fs.readdirSync(staticGuidesRoot, { withFileTypes: true })) {
151
+ if (entry.isFile() && entry.name.endsWith(".md")) {
152
+ collected.add(entry.name);
153
+ }
154
+ }
155
+ }
142
156
  for (const packageName of fs.readdirSync(packagesRoot)) {
143
157
  const packageGuide = path.join(packagesRoot, packageName, "agentic", "standalone-guide.md");
144
158
  if (fs.existsSync(packageGuide)) {
@@ -155,6 +169,16 @@ function expectedGuideOutputNames() {
155
169
  }
156
170
  }
157
171
  }
172
+ collected.add("module-facts.json");
173
+ for (const moduleId of FIXTURE_ENABLED_MODULES) {
174
+ collected.add(normalizePath(path.join("modules", `${moduleId}.md`)));
175
+ }
176
+ for (const moduleId of MODULE_FACTS_ALLOWLIST) {
177
+ const legacyGuideSource = path.join(packagesRoot, "core", "src", "modules", moduleId, "agentic", "standalone-guide.md");
178
+ if (!fs.existsSync(legacyGuideSource)) {
179
+ collected.add(`core.${moduleId}.md`);
180
+ }
181
+ }
158
182
  return Array.from(collected).sort();
159
183
  }
160
184
  function assertPathsExist(appDir, relativePaths) {
@@ -187,6 +211,10 @@ test.describe("TC-INT-008: CLI agentic init mirrors standalone scaffolding asset
187
211
  const agentsSource = fs.readFileSync(path.join(appDir, "AGENTS.md"), "utf8");
188
212
  expect(agentsSource).toContain("<!-- CODEX_ENFORCEMENT_RULES_START -->");
189
213
  expect(agentsSource).toContain(".ai/guides/core.md");
214
+ for (const moduleId of FIXTURE_ENABLED_MODULES) {
215
+ expect(agentsSource).toContain(`.ai/guides/modules/${moduleId}.md`);
216
+ }
217
+ expect(agentsSource).not.toContain(".ai/guides/modules/auth.md");
190
218
  const specsReadmeSource = fs.readFileSync(path.join(appDir, ".ai", "specs", "README.md"), "utf8");
191
219
  expect(specsReadmeSource).toContain("sample-store");
192
220
  const cursorRulesSource = fs.readFileSync(path.join(appDir, ".cursor", "rules", "open-mercato.mdc"), "utf8");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/__integration__/TC-INT-008.spec.ts"],
4
- "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliDir = path.join(repoRoot, 'packages', 'cli')\nconst cliBin = path.join(cliDir, 'dist', 'bin.js')\nconst cliBuildScript = path.join(cliDir, 'build.mjs')\nconst cliIntegrationRunnerPath = path.join(cliDir, 'src', 'lib', 'testing', 'integration.ts')\nconst standaloneTemplatePackageJsonPath = path.join(repoRoot, 'packages', 'create-app', 'template', 'package.json.template')\nconst agenticRoot = path.join(repoRoot, 'packages', 'create-app', 'agentic')\nconst packagesRoot = path.join(repoRoot, 'packages')\n\nfunction normalizePath(value: string): string {\n return value.split(path.sep).join('/')\n}\n\nfunction runCommand(command: string, args: string[], cwd: string): string {\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction ensureCliBuilt(): void {\n runCommand(process.execPath, [cliBuildScript], cliDir)\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n const appDir = path.join(rootDir, 'sample-store')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: 'sample-store',\n private: true,\n },\n null,\n 2,\n ),\n )\n writeFile(path.join(appDir, 'src', 'modules.ts'), 'export const enabledModules = []\\n')\n return appDir\n}\n\nfunction listRelativeFiles(rootDir: string): string[] {\n if (!fs.existsSync(rootDir)) {\n return []\n }\n\n const collected: string[] = []\n for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {\n const absolutePath = path.join(rootDir, entry.name)\n if (entry.isDirectory()) {\n for (const nestedPath of listRelativeFiles(absolutePath)) {\n collected.push(path.join(entry.name, nestedPath))\n }\n continue\n }\n if (entry.isFile()) {\n collected.push(entry.name)\n }\n }\n\n return collected.map(normalizePath).sort()\n}\n\nfunction mapSharedSourceToOutput(relativePath: string): string {\n if (relativePath === 'AGENTS.md.template') {\n return 'AGENTS.md'\n }\n\n if (!relativePath.startsWith('ai/')) {\n throw new Error(`Unexpected shared source path: ${relativePath}`)\n }\n\n return normalizePath(path.join('.ai', relativePath.slice('ai/'.length)))\n}\n\nfunction mapClaudeSourceToOutput(relativePath: string): string {\n if (relativePath === 'CLAUDE.md.template') {\n return 'CLAUDE.md'\n }\n if (relativePath === 'settings.json') {\n return '.claude/settings.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n return normalizePath(path.join('.claude', relativePath))\n }\n\n throw new Error(`Unexpected Claude source path: ${relativePath}`)\n}\n\nfunction mapCursorSourceToOutput(relativePath: string): string {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n return normalizePath(path.join('.cursor', relativePath))\n }\n\n throw new Error(`Unexpected Cursor source path: ${relativePath}`)\n}\n\nfunction mapCodexSourceToOutput(relativePath: string): string | null {\n if (relativePath === 'mcp.json.example') {\n return '.codex/mcp.json.example'\n }\n if (relativePath === 'enforcement-rules.md') {\n return null\n }\n\n throw new Error(`Unexpected Codex source path: ${relativePath}`)\n}\n\nfunction readPlaywrightConfigPathFromTemplate(): string {\n const packageTemplate = JSON.parse(fs.readFileSync(standaloneTemplatePackageJsonPath, 'utf8')) as {\n scripts?: Record<string, string>\n }\n const integrationScript = packageTemplate.scripts?.['test:integration']\n if (!integrationScript) {\n throw new Error('Standalone template is missing the test:integration script')\n }\n\n const configPathMatch = integrationScript.match(/--config\\s+([^\\s]+)/)\n if (!configPathMatch?.[1]) {\n throw new Error('Standalone template test:integration script is missing --config')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction readPlaywrightConfigPathFromCliRunner(): string {\n const integrationRunnerSource = fs.readFileSync(cliIntegrationRunnerPath, 'utf8')\n const configPathMatch = integrationRunnerSource.match(/const PLAYWRIGHT_INTEGRATION_CONFIG_PATH = '([^']+)'/)\n if (!configPathMatch?.[1]) {\n throw new Error('CLI integration runner is missing PLAYWRIGHT_INTEGRATION_CONFIG_PATH')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction expectedGuideOutputNames(): string[] {\n const collected = new Set<string>()\n\n for (const packageName of fs.readdirSync(packagesRoot)) {\n const packageGuide = path.join(packagesRoot, packageName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(packageGuide)) {\n collected.add(`${packageName}.md`)\n }\n\n const modulesRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n if (!fs.existsSync(modulesRoot)) {\n continue\n }\n\n for (const moduleName of fs.readdirSync(modulesRoot)) {\n const moduleGuide = path.join(modulesRoot, moduleName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(moduleGuide)) {\n collected.add(`${packageName}.${moduleName}.md`)\n }\n }\n }\n\n return Array.from(collected).sort()\n}\n\nfunction assertPathsExist(appDir: string, relativePaths: string[]): void {\n const missingPaths = relativePaths.filter((relativePath) => !fs.existsSync(path.join(appDir, relativePath)))\n expect(missingPaths).toEqual([])\n}\n\ntest.describe('TC-INT-008: CLI agentic init mirrors standalone scaffolding assets', () => {\n test.beforeAll(() => {\n ensureCliBuilt()\n })\n\n test('should run bootstrap-free and generate the shared, guide, and tool-specific agentic files', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const standalonePlaywrightConfigPath = readPlaywrightConfigPathFromTemplate()\n const cliPlaywrightConfigPath = readPlaywrightConfigPathFromCliRunner()\n const commandOutput = runMercato(['agentic:init', '--tool=claude-code,codex,cursor'], appDir)\n\n expect(cliPlaywrightConfigPath).toBe(standalonePlaywrightConfigPath)\n expect(commandOutput).toContain('Agentic setup complete:')\n expect(fs.existsSync(path.join(appDir, '.mercato', 'generated'))).toBe(false)\n\n const sharedOutputs = listRelativeFiles(path.join(agenticRoot, 'shared')).map(mapSharedSourceToOutput)\n const claudeOutputs = listRelativeFiles(path.join(agenticRoot, 'claude-code')).map(mapClaudeSourceToOutput)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor')).map(mapCursorSourceToOutput)\n const codexOutputs = listRelativeFiles(path.join(agenticRoot, 'codex'))\n .map(mapCodexSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n\n expect(sharedOutputs).toContain(standalonePlaywrightConfigPath)\n assertPathsExist(appDir, [...sharedOutputs, ...claudeOutputs, ...cursorOutputs, ...codexOutputs])\n expect(fs.existsSync(path.join(appDir, standalonePlaywrightConfigPath))).toBe(true)\n\n const generatedGuideNames = listRelativeFiles(path.join(appDir, '.ai', 'guides'))\n expect(generatedGuideNames).toEqual(expectedGuideOutputNames())\n\n const agentsSource = fs.readFileSync(path.join(appDir, 'AGENTS.md'), 'utf8')\n expect(agentsSource).toContain('<!-- CODEX_ENFORCEMENT_RULES_START -->')\n expect(agentsSource).toContain('.ai/guides/core.md')\n\n const specsReadmeSource = fs.readFileSync(path.join(appDir, '.ai', 'specs', 'README.md'), 'utf8')\n expect(specsReadmeSource).toContain('sample-store')\n\n const cursorRulesSource = fs.readFileSync(path.join(appDir, '.cursor', 'rules', 'open-mercato.mdc'), 'utf8')\n expect(cursorRulesSource).toContain('sample-store')\n\n const specWritingSkillSource = fs.readFileSync(\n path.join(appDir, '.ai', 'skills', 'om-spec-writing', 'SKILL.md'),\n 'utf8',\n )\n expect(specWritingSkillSource).toContain('sample-store')\n\n for (const toolDir of ['.claude', '.codex', '.cursor']) {\n const skillsLinkPath = path.join(appDir, toolDir, 'skills')\n expect(fs.lstatSync(skillsLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(skillsLinkPath))).toBe('../.ai/skills')\n }\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM,MAAM,MAAM,MAAM,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,KAAK;AACpD,MAAM,SAAS,KAAK,KAAK,QAAQ,QAAQ,QAAQ;AACjD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,WAAW;AACpD,MAAM,2BAA2B,KAAK,KAAK,QAAQ,OAAO,OAAO,WAAW,gBAAgB;AAC5F,MAAM,oCAAoC,KAAK,KAAK,UAAU,YAAY,cAAc,YAAY,uBAAuB;AAC3H,MAAM,cAAc,KAAK,KAAK,UAAU,YAAY,cAAc,SAAS;AAC3E,MAAM,eAAe,KAAK,KAAK,UAAU,UAAU;AAEnD,SAAS,cAAc,OAAuB;AAC5C,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;AAEA,SAAS,WAAW,SAAiB,MAAgB,KAAqB;AACxE,SAAO,aAAa,SAAS,MAAM;AAAA,IACjC;AAAA,IACA,UAAU;AAAA,IACV,KAAK;AAAA,MACH,GAAG,QAAQ;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEA,SAAS,WAAW,MAAgB,KAAqB;AACvD,SAAO,WAAW,QAAQ,UAAU,CAAC,QAAQ,GAAG,IAAI,GAAG,GAAG;AAC5D;AAEA,SAAS,UAAU,UAAkB,SAAuB;AAC1D,KAAG,UAA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iBAAiB,EAAE,UAAU,cAAc;AAElD,YAAM,oBAAoB,GAAG,aAAa,KAAK,KAAK,QAAQ,WAAW,SAAS,kBAAkB,GAAG,MAAM;AAC3G,aAAO,iBAAiB,EAAE,UAAU,cAAc;AAElD,YAAM,yBAAyB,GAAG;AAAA,QAChC,KAAK,KAAK,QAAQ,OAAO,UAAU,mBAAmB,UAAU;AAAA,QAChE;AAAA,MACF;AACA,aAAO,sBAAsB,EAAE,UAAU,cAAc;AAEvD,iBAAW,WAAW,CAAC,WAAW,UAAU,SAAS,GAAG;AACtD,cAAM,iBAAiB,KAAK,KAAK,QAAQ,SAAS,QAAQ;AAC1D,eAAO,GAAG,UAAU,cAAc,EAAE,eAAe,CAAC,EAAE,KAAK,IAAI;AAC/D,eAAO,cAAc,GAAG,aAAa,cAAc,CAAC,CAAC,EAAE,KAAK,eAAe;AAAA,MAC7E;AAAA,IACF,UAAE;AACA,SAAG,OAAO,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACtD;AAAA,EACF,CAAC;AACH,CAAC;",
4
+ "sourcesContent": ["import { expect, test } from '@playwright/test'\nimport { execFileSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { MODULE_FACTS_ALLOWLIST } from '../generators/module-facts'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst repoRoot = path.resolve(__dirname, '..', '..', '..', '..', '..')\nconst cliDir = path.join(repoRoot, 'packages', 'cli')\nconst cliBin = path.join(cliDir, 'dist', 'bin.js')\nconst cliBuildScript = path.join(cliDir, 'build.mjs')\nconst cliIntegrationRunnerPath = path.join(cliDir, 'src', 'lib', 'testing', 'integration.ts')\nconst standaloneTemplatePackageJsonPath = path.join(repoRoot, 'packages', 'create-app', 'template', 'package.json.template')\nconst agenticRoot = path.join(repoRoot, 'packages', 'create-app', 'agentic')\nconst packagesRoot = path.join(repoRoot, 'packages')\n\n// Modules the standalone fixture enables in src/modules.ts. Both are on the\n// fact-sheet allowlist, so agentic:init must ship exactly their fact-sheets\n// (enabled \u2229 allowlist \u2014 spec D6) and list them in the AGENTS.md marker block.\nconst FIXTURE_ENABLED_MODULES = ['customers', 'sales']\n\nfunction normalizePath(value: string): string {\n return value.split(path.sep).join('/')\n}\n\nfunction runCommand(command: string, args: string[], cwd: string): string {\n return execFileSync(command, args, {\n cwd,\n encoding: 'utf8',\n env: {\n ...process.env,\n FORCE_COLOR: '0',\n NODE_NO_WARNINGS: '1',\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd)\n}\n\nfunction writeFile(filePath: string, content: string): void {\n fs.mkdirSync(path.dirname(filePath), { recursive: true })\n fs.writeFileSync(filePath, content)\n}\n\nfunction ensureCliBuilt(): void {\n runCommand(process.execPath, [cliBuildScript], cliDir)\n}\n\nfunction createStandaloneFixture(rootDir: string): string {\n const appDir = path.join(rootDir, 'sample-store')\n writeFile(\n path.join(appDir, 'package.json'),\n JSON.stringify(\n {\n name: 'sample-store',\n private: true,\n },\n null,\n 2,\n ),\n )\n const moduleEntries = FIXTURE_ENABLED_MODULES.map((moduleId) => ` { id: '${moduleId}' },`).join('\\n')\n writeFile(path.join(appDir, 'src', 'modules.ts'), `export const enabledModules = [\\n${moduleEntries}\\n]\\n`)\n return appDir\n}\n\nfunction listRelativeFiles(rootDir: string): string[] {\n if (!fs.existsSync(rootDir)) {\n return []\n }\n\n const collected: string[] = []\n for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {\n const absolutePath = path.join(rootDir, entry.name)\n if (entry.isDirectory()) {\n for (const nestedPath of listRelativeFiles(absolutePath)) {\n collected.push(path.join(entry.name, nestedPath))\n }\n continue\n }\n if (entry.isFile()) {\n collected.push(entry.name)\n }\n }\n\n return collected.map(normalizePath).sort()\n}\n\nfunction mapSharedSourceToOutput(relativePath: string): string {\n if (relativePath === 'AGENTS.md.template') {\n return 'AGENTS.md'\n }\n\n if (!relativePath.startsWith('ai/')) {\n throw new Error(`Unexpected shared source path: ${relativePath}`)\n }\n\n return normalizePath(path.join('.ai', relativePath.slice('ai/'.length)))\n}\n\nfunction mapClaudeSourceToOutput(relativePath: string): string {\n if (relativePath === 'CLAUDE.md.template') {\n return 'CLAUDE.md'\n }\n if (relativePath === 'settings.json') {\n return '.claude/settings.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n return normalizePath(path.join('.claude', relativePath))\n }\n\n throw new Error(`Unexpected Claude source path: ${relativePath}`)\n}\n\nfunction mapCursorSourceToOutput(relativePath: string): string {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n return normalizePath(path.join('.cursor', relativePath))\n }\n\n throw new Error(`Unexpected Cursor source path: ${relativePath}`)\n}\n\nfunction mapCodexSourceToOutput(relativePath: string): string | null {\n if (relativePath === 'mcp.json.example') {\n return '.codex/mcp.json.example'\n }\n if (relativePath === 'enforcement-rules.md') {\n return null\n }\n\n throw new Error(`Unexpected Codex source path: ${relativePath}`)\n}\n\nfunction readPlaywrightConfigPathFromTemplate(): string {\n const packageTemplate = JSON.parse(fs.readFileSync(standaloneTemplatePackageJsonPath, 'utf8')) as {\n scripts?: Record<string, string>\n }\n const integrationScript = packageTemplate.scripts?.['test:integration']\n if (!integrationScript) {\n throw new Error('Standalone template is missing the test:integration script')\n }\n\n const configPathMatch = integrationScript.match(/--config\\s+([^\\s]+)/)\n if (!configPathMatch?.[1]) {\n throw new Error('Standalone template test:integration script is missing --config')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction readPlaywrightConfigPathFromCliRunner(): string {\n const integrationRunnerSource = fs.readFileSync(cliIntegrationRunnerPath, 'utf8')\n const configPathMatch = integrationRunnerSource.match(/const PLAYWRIGHT_INTEGRATION_CONFIG_PATH = '([^']+)'/)\n if (!configPathMatch?.[1]) {\n throw new Error('CLI integration runner is missing PLAYWRIGHT_INTEGRATION_CONFIG_PATH')\n }\n\n return normalizePath(configPathMatch[1])\n}\n\nfunction expectedGuideOutputNames(): string[] {\n const collected = new Set<string>()\n\n // Static conceptual guides checked into create-app (e.g. module-system.md) are\n // bundled into dist/agentic/guides by the CLI build and copied wholesale.\n const staticGuidesRoot = path.join(agenticRoot, 'guides')\n if (fs.existsSync(staticGuidesRoot)) {\n for (const entry of fs.readdirSync(staticGuidesRoot, { withFileTypes: true })) {\n if (entry.isFile() && entry.name.endsWith('.md')) {\n collected.add(entry.name)\n }\n }\n }\n\n for (const packageName of fs.readdirSync(packagesRoot)) {\n const packageGuide = path.join(packagesRoot, packageName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(packageGuide)) {\n collected.add(`${packageName}.md`)\n }\n\n const modulesRoot = path.join(packagesRoot, packageName, 'src', 'modules')\n if (!fs.existsSync(modulesRoot)) {\n continue\n }\n\n for (const moduleName of fs.readdirSync(modulesRoot)) {\n const moduleGuide = path.join(modulesRoot, moduleName, 'agentic', 'standalone-guide.md')\n if (fs.existsSync(moduleGuide)) {\n collected.add(`${packageName}.${moduleName}.md`)\n }\n }\n }\n\n // Generated fact-sheet artifacts (spec 2026-06-27-ts-morph-module-fact-sheets):\n // the module-facts.json sidecar is copied as-is, fact-sheets are filtered to the\n // fixture's enabled modules, and every allowlisted module whose hand-written\n // core.<module>.md guide no longer exists gets a legacy redirect stub.\n collected.add('module-facts.json')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n collected.add(normalizePath(path.join('modules', `${moduleId}.md`)))\n }\n for (const moduleId of MODULE_FACTS_ALLOWLIST) {\n const legacyGuideSource = path.join(packagesRoot, 'core', 'src', 'modules', moduleId, 'agentic', 'standalone-guide.md')\n if (!fs.existsSync(legacyGuideSource)) {\n collected.add(`core.${moduleId}.md`)\n }\n }\n\n return Array.from(collected).sort()\n}\n\nfunction assertPathsExist(appDir: string, relativePaths: string[]): void {\n const missingPaths = relativePaths.filter((relativePath) => !fs.existsSync(path.join(appDir, relativePath)))\n expect(missingPaths).toEqual([])\n}\n\ntest.describe('TC-INT-008: CLI agentic init mirrors standalone scaffolding assets', () => {\n test.beforeAll(() => {\n ensureCliBuilt()\n })\n\n test('should run bootstrap-free and generate the shared, guide, and tool-specific agentic files', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const standalonePlaywrightConfigPath = readPlaywrightConfigPathFromTemplate()\n const cliPlaywrightConfigPath = readPlaywrightConfigPathFromCliRunner()\n const commandOutput = runMercato(['agentic:init', '--tool=claude-code,codex,cursor'], appDir)\n\n expect(cliPlaywrightConfigPath).toBe(standalonePlaywrightConfigPath)\n expect(commandOutput).toContain('Agentic setup complete:')\n expect(fs.existsSync(path.join(appDir, '.mercato', 'generated'))).toBe(false)\n\n const sharedOutputs = listRelativeFiles(path.join(agenticRoot, 'shared')).map(mapSharedSourceToOutput)\n const claudeOutputs = listRelativeFiles(path.join(agenticRoot, 'claude-code')).map(mapClaudeSourceToOutput)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor')).map(mapCursorSourceToOutput)\n const codexOutputs = listRelativeFiles(path.join(agenticRoot, 'codex'))\n .map(mapCodexSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n\n expect(sharedOutputs).toContain(standalonePlaywrightConfigPath)\n assertPathsExist(appDir, [...sharedOutputs, ...claudeOutputs, ...cursorOutputs, ...codexOutputs])\n expect(fs.existsSync(path.join(appDir, standalonePlaywrightConfigPath))).toBe(true)\n\n const generatedGuideNames = listRelativeFiles(path.join(appDir, '.ai', 'guides'))\n expect(generatedGuideNames).toEqual(expectedGuideOutputNames())\n\n const agentsSource = fs.readFileSync(path.join(appDir, 'AGENTS.md'), 'utf8')\n expect(agentsSource).toContain('<!-- CODEX_ENFORCEMENT_RULES_START -->')\n expect(agentsSource).toContain('.ai/guides/core.md')\n\n // The Module-Specific Guides marker block lists exactly the enabled modules'\n // fact-sheets (enabled \u2229 allowlist), not the full bundled set.\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n expect(agentsSource).toContain(`.ai/guides/modules/${moduleId}.md`)\n }\n expect(agentsSource).not.toContain('.ai/guides/modules/auth.md')\n\n const specsReadmeSource = fs.readFileSync(path.join(appDir, '.ai', 'specs', 'README.md'), 'utf8')\n expect(specsReadmeSource).toContain('sample-store')\n\n const cursorRulesSource = fs.readFileSync(path.join(appDir, '.cursor', 'rules', 'open-mercato.mdc'), 'utf8')\n expect(cursorRulesSource).toContain('sample-store')\n\n const specWritingSkillSource = fs.readFileSync(\n path.join(appDir, '.ai', 'skills', 'om-spec-writing', 'SKILL.md'),\n 'utf8',\n )\n expect(specWritingSkillSource).toContain('sample-store')\n\n for (const toolDir of ['.claude', '.codex', '.cursor']) {\n const skillsLinkPath = path.join(appDir, toolDir, 'skills')\n expect(fs.lstatSync(skillsLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(skillsLinkPath))).toBe('../.ai/skills')\n }\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AAEvC,MAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,MAAM,WAAW,KAAK,QAAQ,WAAW,MAAM,MAAM,MAAM,MAAM,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,KAAK;AACpD,MAAM,SAAS,KAAK,KAAK,QAAQ,QAAQ,QAAQ;AACjD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,WAAW;AACpD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YAAM,eAAe,GAAG,aAAa,KAAK,KAAK,QAAQ,WAAW,GAAG,MAAM;AAC3E,aAAO,YAAY,EAAE,UAAU,wCAAwC;AACvE,aAAO,YAAY,EAAE,UAAU,oBAAoB;AAInD,iBAAW,YAAY,yBAAyB;AAC9C,eAAO,YAAY,EAAE,UAAU,sBAAsB,QAAQ,KAAK;AAAA,MACpE;AACA,aAAO,YAAY,EAAE,IAAI,UAAU,4BAA4B;AAE/D,YAAM,oBAAoB,GAAG,aAAa,KAAK,KAAK,QAAQ,OAAO,SAAS,WAAW,GAAG,MAAM;AAChG,aAAO,iBAAiB,EAAE,UAAU,cAAc;AAElD,YAAM,oBAAoB,GAAG,aAAa,KAAK,KAAK,QAAQ,WAAW,SAAS,kBAAkB,GAAG,MAAM;AAC3G,aAAO,iBAAiB,EAAE,UAAU,cAAc;AAElD,YAAM,yBAAyB,GAAG;AAAA,QAChC,KAAK,KAAK,QAAQ,OAAO,UAAU,mBAAmB,UAAU;AAAA,QAChE;AAAA,MACF;AACA,aAAO,sBAAsB,EAAE,UAAU,cAAc;AAEvD,iBAAW,WAAW,CAAC,WAAW,UAAU,SAAS,GAAG;AACtD,cAAM,iBAAiB,KAAK,KAAK,QAAQ,SAAS,QAAQ;AAC1D,eAAO,GAAG,UAAU,cAAc,EAAE,eAAe,CAAC,EAAE,KAAK,IAAI;AAC/D,eAAO,cAAc,GAAG,aAAa,cAAc,CAAC,CAAC,EAAE,KAAK,eAAe;AAAA,MAC7E;AAAA,IACF,UAAE;AACA,SAAG,OAAO,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACtD;AAAA,EACF,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, lstatSync, unlinkSync, readdirSync } from "node:fs";
2
2
  import { join, dirname, basename } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
+ import { Project, SyntaxKind } from "ts-morph";
4
5
  const __dirname = dirname(fileURLToPath(import.meta.url));
5
6
  const AGENTIC_DIR = join(__dirname, "..", "agentic");
6
7
  const GUIDES_DIR = join(AGENTIC_DIR, "guides");
@@ -22,10 +23,84 @@ function copyFile(srcDir, srcRelative, destPath) {
22
23
  ensureDir(destPath);
23
24
  copyFileSync(srcPath, destPath);
24
25
  }
26
+ function readEnabledModuleIds(modulesPath) {
27
+ if (!existsSync(modulesPath)) return [];
28
+ try {
29
+ const project = new Project({ useInMemoryFileSystem: true });
30
+ const sourceFile = project.createSourceFile("modules.ts", readFileSync(modulesPath, "utf-8"));
31
+ const declaration = sourceFile.getVariableDeclaration("enabledModules");
32
+ const arrayLiteral = declaration?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression);
33
+ if (!arrayLiteral) return [];
34
+ const ids = [];
35
+ for (const element of arrayLiteral.getElements()) {
36
+ const objectLiteral = element.asKind(SyntaxKind.ObjectLiteralExpression);
37
+ if (!objectLiteral) continue;
38
+ const idProperty = objectLiteral.getProperty("id")?.asKind(SyntaxKind.PropertyAssignment);
39
+ const idValue = idProperty?.getInitializerIfKind(SyntaxKind.StringLiteral)?.getLiteralValue();
40
+ if (idValue) ids.push(idValue);
41
+ }
42
+ return ids;
43
+ } catch {
44
+ return [];
45
+ }
46
+ }
47
+ function selectModuleFactSheets(targetDir, modulesSubdir) {
48
+ const available = existsSync(modulesSubdir) ? readdirSync(modulesSubdir).filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, "")) : [];
49
+ if (available.length === 0) return [];
50
+ const enabled = new Set(readEnabledModuleIds(join(targetDir, "src", "modules.ts")));
51
+ const selected = available.filter((moduleId) => enabled.has(moduleId));
52
+ return selected.length > 0 ? selected : available;
53
+ }
54
+ const MODULE_GUIDES_START = "<!-- om:module-guides:start -->";
55
+ const MODULE_GUIDES_END = "<!-- om:module-guides:end -->";
56
+ function readModuleGuideLabels(guidesDir) {
57
+ const factsPath = join(guidesDir, "module-facts.json");
58
+ if (!existsSync(factsPath)) return {};
59
+ try {
60
+ const parsed = JSON.parse(readFileSync(factsPath, "utf-8"));
61
+ const labels = {};
62
+ for (const [moduleId, entry] of Object.entries(parsed)) {
63
+ const label = entry && typeof entry.description === "string" && entry.description || entry && typeof entry.title === "string" && entry.title || "";
64
+ if (label) labels[moduleId] = label;
65
+ }
66
+ return labels;
67
+ } catch {
68
+ return {};
69
+ }
70
+ }
71
+ function renderModuleGuidesBlock(selected, labels) {
72
+ if (selected.length === 0) return "_No module fact-sheets are bundled for this app._";
73
+ const rows = selected.map((moduleId) => {
74
+ const label = labels[moduleId] ?? `Use the ${moduleId} module`;
75
+ return `| ${label} | \`.ai/guides/modules/${moduleId}.md\` |`;
76
+ });
77
+ return ["| Task | Load |", "|---|---|", ...rows].join("\n");
78
+ }
79
+ function injectModuleGuides(agentsMdPath, selected, labels = {}) {
80
+ if (!existsSync(agentsMdPath)) return;
81
+ const content = readFileSync(agentsMdPath, "utf-8");
82
+ const startIndex = content.indexOf(MODULE_GUIDES_START);
83
+ const endIndex = content.indexOf(MODULE_GUIDES_END);
84
+ if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {
85
+ console.warn(
86
+ `[agentic] Module-Specific Guides markers (${MODULE_GUIDES_START} \u2026 ${MODULE_GUIDES_END}) not found in ${agentsMdPath}; the per-module guide list was not generated.`
87
+ );
88
+ return;
89
+ }
90
+ const before = content.slice(0, startIndex + MODULE_GUIDES_START.length);
91
+ const after = content.slice(endIndex);
92
+ const next = `${before}
93
+ ${renderModuleGuidesBlock(selected, labels)}
94
+ ${after}`;
95
+ if (next !== content) writeFileSync(agentsMdPath, next);
96
+ }
25
97
  function generateShared(config) {
26
98
  const { targetDir } = config;
27
99
  const srcDir = join(AGENTIC_DIR, "shared");
100
+ const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, "modules"));
101
+ const moduleGuideLabels = readModuleGuideLabels(GUIDES_DIR);
28
102
  writeTemplate(srcDir, "AGENTS.md.template", join(targetDir, "AGENTS.md"), config);
103
+ injectModuleGuides(join(targetDir, "AGENTS.md"), selectedModules, moduleGuideLabels);
29
104
  writeTemplate(srcDir, "ai/specs/README.md", join(targetDir, ".ai", "specs", "README.md"), config);
30
105
  copyFile(srcDir, "ai/specs/SPEC-000-template.md", join(targetDir, ".ai", "specs", "SPEC-000-template.md"));
31
106
  copyFile(srcDir, "ai/lessons.md", join(targetDir, ".ai", "lessons.md"));
@@ -202,6 +277,18 @@ function generateShared(config) {
202
277
  ensureDir(destPath);
203
278
  copyFileSync(srcPath, destPath);
204
279
  }
280
+ const moduleFactsPath = join(GUIDES_DIR, "module-facts.json");
281
+ if (existsSync(moduleFactsPath)) {
282
+ const destPath = join(guidesDestDir, "module-facts.json");
283
+ ensureDir(destPath);
284
+ copyFileSync(moduleFactsPath, destPath);
285
+ }
286
+ const modulesSubdir = join(GUIDES_DIR, "modules");
287
+ for (const moduleId of selectedModules) {
288
+ const destPath = join(guidesDestDir, "modules", `${moduleId}.md`);
289
+ ensureDir(destPath);
290
+ copyFileSync(join(modulesSubdir, `${moduleId}.md`), destPath);
291
+ }
205
292
  }
206
293
  }
207
294
  function generateClaudeCode(config) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/agentic-setup.ts"],
4
- "sourcesContent": ["/**\n * Agentic setup for the CLI `agentic:init` command.\n *\n * Source files live in packages/create-app/agentic/ and are copied\n * to packages/cli/dist/agentic/ during build (see build.mjs).\n * This module reads those files at runtime \u2014 no embedded string constants.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, lstatSync, unlinkSync, readdirSync } from 'node:fs'\nimport { join, dirname, basename } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), __dirname is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst AGENTIC_DIR = join(__dirname, '..', 'agentic')\nconst GUIDES_DIR = join(AGENTIC_DIR, 'guides')\n\ntype AskFn = (question: string) => Promise<string>\n\ninterface AgenticSetupOptions {\n tool?: string\n force?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\n// \u2500\u2500\u2500 Helpers \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction resolvePlaceholders(content: string, config: AgenticConfig): string {\n return content.replace(/\\{\\{PROJECT_NAME\\}\\}/g, config.projectName)\n}\n\nfunction ensureDir(filePath: string): void {\n const dir = dirname(filePath)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n}\n\nfunction writeTemplate(srcDir: string, srcRelative: string, destPath: string, config: AgenticConfig): void {\n const srcPath = join(srcDir, srcRelative)\n const content = readFileSync(srcPath, 'utf-8')\n ensureDir(destPath)\n writeFileSync(destPath, resolvePlaceholders(content, config))\n}\n\nfunction copyFile(srcDir: string, srcRelative: string, destPath: string): void {\n const srcPath = join(srcDir, srcRelative)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n}\n\n// \u2500\u2500\u2500 Generators \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction generateShared(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n\n // AGENTS.md\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n\n // .ai/ structure\n writeTemplate(srcDir, 'ai/specs/README.md', join(targetDir, '.ai', 'specs', 'README.md'), config)\n copyFile(srcDir, 'ai/specs/SPEC-000-template.md', join(targetDir, '.ai', 'specs', 'SPEC-000-template.md'))\n copyFile(srcDir, 'ai/lessons.md', join(targetDir, '.ai', 'lessons.md'))\n\n // .ai/skills/\n writeTemplate(\n srcDir,\n 'ai/skills/om-spec-writing/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'SKILL.md'),\n config,\n )\n copyFile(\n srcDir,\n 'ai/skills/om-spec-writing/references/spec-template.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'references', 'spec-template.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-spec-writing/references/spec-checklist.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'references', 'spec-checklist.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/references/ui-components.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'references', 'ui-components.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-code-review/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-code-review', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-code-review/references/review-checklist.md',\n join(targetDir, '.ai', 'skills', 'om-code-review', 'references', 'review-checklist.md'),\n )\n copyFile(srcDir, 'ai/skills/om-integration-builder/SKILL.md', join(targetDir, '.ai', 'skills', 'om-integration-builder', 'SKILL.md'))\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/references/adapter-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'references', 'adapter-contracts.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/references/extension-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'references', 'extension-contracts.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/naming-conventions.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'naming-conventions.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/navigation-patterns.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'navigation-patterns.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/references/diagnostic-commands.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'references', 'diagnostic-commands.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-eject-and-customize/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-eject-and-customize', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'references', 'mikro-orm-cheatsheet.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-implement-spec/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-implement-spec', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-integration-tests/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-integration-tests', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-help/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/skills-catalog.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'skills-catalog.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/workflow-sequences.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'workflow-sequences.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-auto-upgrade-0.4.10-to-0.5.0/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-auto-upgrade-0.4.10-to-0.5.0', 'SKILL.md'),\n )\n\n for (const autoSkill of [\n 'om-auto-create-pr',\n 'om-auto-continue-pr',\n 'om-auto-create-pr-loop',\n 'om-auto-continue-pr-loop',\n 'om-auto-review-pr',\n 'om-auto-fix-github',\n 'om-prepare-issue',\n ]) {\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/SKILL.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'SKILL.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', autoSkill, 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/STANDALONE.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'STANDALONE.md'),\n )\n }\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-trim-unused-modules/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-trim-unused-modules', 'SKILL.md'),\n )\n\n copyFile(srcDir, 'ai/qa/tests/playwright.config.ts', join(targetDir, '.ai', 'qa', 'tests', 'playwright.config.ts'))\n\n if (existsSync(GUIDES_DIR)) {\n const guidesDestDir = join(targetDir, '.ai', 'guides')\n for (const file of readdirSync(GUIDES_DIR)) {\n if (!file.endsWith('.md')) continue\n const srcPath = join(GUIDES_DIR, file)\n const destPath = join(guidesDestDir, file)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n }\n }\n}\n\nfunction generateClaudeCode(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'claude-code')\n\n writeTemplate(srcDir, 'CLAUDE.md.template', join(targetDir, 'CLAUDE.md'), config)\n copyFile(srcDir, 'settings.json', join(targetDir, '.claude', 'settings.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.ts', join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.mcp.json.example'))\n\n // Symlink .claude/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.claude', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCodex(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'codex')\n\n const agentsPath = join(targetDir, 'AGENTS.md')\n if (existsSync(agentsPath)) {\n const enforcement = readFileSync(join(srcDir, 'enforcement-rules.md'), 'utf-8')\n let agents = readFileSync(agentsPath, 'utf-8')\n const MARKER_START = '<!-- CODEX_ENFORCEMENT_RULES_START -->'\n const MARKER_END = '<!-- CODEX_ENFORCEMENT_RULES_END -->'\n\n if (agents.includes(MARKER_START)) {\n const startIdx = agents.indexOf(MARKER_START)\n const endIdx = agents.indexOf(MARKER_END)\n if (endIdx !== -1) {\n agents = agents.slice(0, startIdx) + enforcement + agents.slice(endIdx + MARKER_END.length)\n }\n } else {\n const firstNewline = agents.indexOf('\\n')\n if (firstNewline !== -1) {\n agents = agents.slice(0, firstNewline + 1) + '\\n' + enforcement + '\\n' + agents.slice(firstNewline + 1)\n } else {\n agents = agents + '\\n\\n' + enforcement\n }\n }\n writeFileSync(agentsPath, agents)\n }\n\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.codex', 'mcp.json.example'))\n\n // Symlink .codex/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.codex', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCursor(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'cursor')\n\n writeTemplate(srcDir, 'rules/open-mercato.mdc', join(targetDir, '.cursor', 'rules', 'open-mercato.mdc'), config)\n copyFile(srcDir, 'rules/entity-guard.mdc', join(targetDir, '.cursor', 'rules', 'entity-guard.mdc'))\n copyFile(srcDir, 'rules/generated-guard.mdc', join(targetDir, '.cursor', 'rules', 'generated-guard.mdc'))\n copyFile(srcDir, 'hooks.json', join(targetDir, '.cursor', 'hooks.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.mjs', join(targetDir, '.cursor', 'hooks', 'entity-migration-check.mjs'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.cursor', 'mcp.json.example'))\n\n // Symlink .cursor/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.cursor', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction ensureSkillsLink(linkPath: string, target: string): void {\n ensureDir(linkPath)\n if (existsSync(linkPath) && !lstatSync(linkPath).isSymbolicLink()) {\n return\n }\n if (lstatSync(linkPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n unlinkSync(linkPath)\n }\n symlinkSync(target, linkPath)\n}\n\n// \u2500\u2500\u2500 Wizard \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst TOOLS = [\n { key: '1', label: 'Claude Code (Anthropic)', id: 'claude-code' },\n { key: '2', label: 'Codex (OpenAI)', id: 'codex' },\n { key: '3', label: 'Cursor (Anysphere)', id: 'cursor' },\n { key: '4', label: 'Multiple tools (select individually)', id: 'multiple' },\n { key: '5', label: 'Skip \u2014 set up manually later', id: 'skip' },\n] as const\n\nconst SELECTABLE = TOOLS.filter((t) => t.id !== 'multiple' && t.id !== 'skip')\n\nasync function promptSelection(ask: AskFn): Promise<string[]> {\n console.log('')\n console.log('\uD83E\uDD16 Agentic workflow setup')\n console.log('')\n console.log(' Which AI coding tool will you use with this project?')\n console.log('')\n for (const tool of TOOLS) {\n console.log(` ${tool.key}. ${tool.label}`)\n }\n console.log('')\n\n const answer = (await ask(' Enter number(s) separated by comma [1]: ')).trim() || '1'\n\n if (answer === '5') return ['skip']\n\n if (answer === '4') {\n const selected: string[] = []\n for (const tool of SELECTABLE) {\n const yn = await ask(` Include ${tool.label}? [y/N]: `)\n if (yn.toLowerCase() === 'y' || yn.toLowerCase() === 'yes') {\n selected.push(tool.id)\n }\n }\n return selected.length > 0 ? selected : ['skip']\n }\n\n const keys = answer.split(',').map((s) => s.trim())\n const ids: string[] = []\n for (const key of keys) {\n const tool = TOOLS.find((t) => t.key === key)\n if (tool && tool.id !== 'multiple' && tool.id !== 'skip') {\n ids.push(tool.id)\n }\n }\n return ids.length > 0 ? ids : ['skip']\n}\n\nexport async function runAgenticSetup(\n targetDir: string,\n ask: AskFn,\n options?: AgenticSetupOptions,\n): Promise<void> {\n let selectedIds: string[]\n\n if (options?.tool) {\n selectedIds = options.tool.split(',').map((t) => t.trim())\n } else {\n selectedIds = await promptSelection(ask)\n }\n\n if (selectedIds.includes('skip')) {\n console.log('')\n console.log(' Skipped agentic setup.')\n console.log('')\n return\n }\n\n const config: AgenticConfig = {\n projectName: basename(targetDir),\n targetDir,\n }\n\n generateShared(config)\n if (selectedIds.includes('claude-code')) generateClaudeCode(config)\n if (selectedIds.includes('codex')) generateCodex(config)\n if (selectedIds.includes('cursor')) generateCursor(config)\n\n console.log('')\n console.log(' Agentic setup complete:')\n if (selectedIds.includes('claude-code')) {\n console.log(' \u2713 Claude Code \u2014 CLAUDE.md, .claude/hooks/, .mcp.json.example')\n }\n if (selectedIds.includes('codex')) {\n console.log(' \u2713 Codex \u2014 AGENTS.md enforcement rules, .codex/mcp.json.example')\n }\n if (selectedIds.includes('cursor')) {\n console.log(' \u2713 Cursor \u2014 .cursor/rules/, .cursor/hooks/, .cursor/mcp.json.example')\n }\n console.log('')\n}\n"],
5
- "mappings": "AAQA,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,aAAa,WAAW,YAAY,mBAAmB;AAClI,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAE9B,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,cAAc,KAAK,WAAW,MAAM,SAAS;AACnD,MAAM,aAAa,KAAK,aAAa,QAAQ;AAgB7C,SAAS,oBAAoB,SAAiB,QAA+B;AAC3E,SAAO,QAAQ,QAAQ,yBAAyB,OAAO,WAAW;AACpE;AAEA,SAAS,UAAU,UAAwB;AACzC,QAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAI,CAAC,WAAW,GAAG,EAAG,WAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAC1D;AAEA,SAAS,cAAc,QAAgB,aAAqB,UAAkB,QAA6B;AACzG,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,QAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,YAAU,QAAQ;AAClB,gBA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-app/agentic/ and are copied\n * to packages/cli/dist/agentic/ during build (see build.mjs).\n * This module reads those files at runtime \u2014 no embedded string constants.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, lstatSync, unlinkSync, readdirSync } from 'node:fs'\nimport { join, dirname, basename } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { Project, SyntaxKind } from 'ts-morph'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), __dirname is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst AGENTIC_DIR = join(__dirname, '..', 'agentic')\nconst GUIDES_DIR = join(AGENTIC_DIR, 'guides')\n\ntype AskFn = (question: string) => Promise<string>\n\ninterface AgenticSetupOptions {\n tool?: string\n force?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\n// \u2500\u2500\u2500 Helpers \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction resolvePlaceholders(content: string, config: AgenticConfig): string {\n return content.replace(/\\{\\{PROJECT_NAME\\}\\}/g, config.projectName)\n}\n\nfunction ensureDir(filePath: string): void {\n const dir = dirname(filePath)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n}\n\nfunction writeTemplate(srcDir: string, srcRelative: string, destPath: string, config: AgenticConfig): void {\n const srcPath = join(srcDir, srcRelative)\n const content = readFileSync(srcPath, 'utf-8')\n ensureDir(destPath)\n writeFileSync(destPath, resolvePlaceholders(content, config))\n}\n\nfunction copyFile(srcDir: string, srcRelative: string, destPath: string): void {\n const srcPath = join(srcDir, srcRelative)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n}\n\n// \u2500\u2500\u2500 Module fact-sheet selection (mirrors packages/create-app/src/setup/tools/shared.ts) \u2500\u2500\n\n// AST-parse the static `enabledModules` array literal in the app's src/modules.ts\n// and collect each entry's `id`. Only the static literal is read (conditional\n// .push()/spread entries are intentionally not seen \u2014 see spec D6).\nfunction readEnabledModuleIds(modulesPath: string): string[] {\n if (!existsSync(modulesPath)) return []\n try {\n const project = new Project({ useInMemoryFileSystem: true })\n const sourceFile = project.createSourceFile('modules.ts', readFileSync(modulesPath, 'utf-8'))\n const declaration = sourceFile.getVariableDeclaration('enabledModules')\n const arrayLiteral = declaration?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression)\n if (!arrayLiteral) return []\n const ids: string[] = []\n for (const element of arrayLiteral.getElements()) {\n const objectLiteral = element.asKind(SyntaxKind.ObjectLiteralExpression)\n if (!objectLiteral) continue\n const idProperty = objectLiteral.getProperty('id')?.asKind(SyntaxKind.PropertyAssignment)\n const idValue = idProperty?.getInitializerIfKind(SyntaxKind.StringLiteral)?.getLiteralValue()\n if (idValue) ids.push(idValue)\n }\n return ids\n } catch {\n return []\n }\n}\n\n// Resolve which per-module fact-sheets to ship: the intersection of the bundled\n// fact-sheets (the D5 allowlist, materialized by build.mjs) with the app's enabled\n// modules. Falls back to the full bundled set when the enabled set cannot be read\n// (R5 \u2014 degraded, never empty).\nfunction selectModuleFactSheets(targetDir: string, modulesSubdir: string): string[] {\n const available = existsSync(modulesSubdir)\n ? readdirSync(modulesSubdir)\n .filter((file) => file.endsWith('.md'))\n .map((file) => file.replace(/\\.md$/, ''))\n : []\n if (available.length === 0) return []\n const enabled = new Set(readEnabledModuleIds(join(targetDir, 'src', 'modules.ts')))\n const selected = available.filter((moduleId) => enabled.has(moduleId))\n return selected.length > 0 ? selected : available\n}\n\nconst MODULE_GUIDES_START = '<!-- om:module-guides:start -->'\nconst MODULE_GUIDES_END = '<!-- om:module-guides:end -->'\n\n// Read each module's guide label from the bundled `module-facts.json` (emitted by\n// build.mjs from the generator's extraction of each module's own `metadata`). The\n// label falls back description \u2192 title \u2192 generic, so the CLI never re-declares\n// specific module names or descriptions. A missing/malformed sidecar degrades to an\n// empty map (generic labels), never a throw.\nfunction readModuleGuideLabels(guidesDir: string): Record<string, string> {\n const factsPath = join(guidesDir, 'module-facts.json')\n if (!existsSync(factsPath)) return {}\n try {\n const parsed = JSON.parse(readFileSync(factsPath, 'utf-8')) as Record<\n string,\n { description?: unknown; title?: unknown }\n >\n const labels: Record<string, string> = {}\n for (const [moduleId, entry] of Object.entries(parsed)) {\n const label =\n (entry && typeof entry.description === 'string' && entry.description) ||\n (entry && typeof entry.title === 'string' && entry.title) ||\n ''\n if (label) labels[moduleId] = label\n }\n return labels\n } catch {\n return {}\n }\n}\n\nfunction renderModuleGuidesBlock(selected: string[], labels: Record<string, string>): string {\n if (selected.length === 0) return '_No module fact-sheets are bundled for this app._'\n const rows = selected.map((moduleId) => {\n const label = labels[moduleId] ?? `Use the ${moduleId} module`\n return `| ${label} | \\`.ai/guides/modules/${moduleId}.md\\` |`\n })\n return ['| Task | Load |', '|---|---|', ...rows].join('\\n')\n}\n\n// Regenerate the marker-delimited Module-Specific Guides block in the written\n// AGENTS.md from the selected module set. Replaces strictly between the markers so\n// surrounding prose is untouched and repeat runs are idempotent.\nfunction injectModuleGuides(\n agentsMdPath: string,\n selected: string[],\n labels: Record<string, string> = {},\n): void {\n if (!existsSync(agentsMdPath)) return\n const content = readFileSync(agentsMdPath, 'utf-8')\n const startIndex = content.indexOf(MODULE_GUIDES_START)\n const endIndex = content.indexOf(MODULE_GUIDES_END)\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n console.warn(\n `[agentic] Module-Specific Guides markers (${MODULE_GUIDES_START} \u2026 ${MODULE_GUIDES_END}) not found in ${agentsMdPath}; the per-module guide list was not generated.`,\n )\n return\n }\n const before = content.slice(0, startIndex + MODULE_GUIDES_START.length)\n const after = content.slice(endIndex)\n const next = `${before}\\n${renderModuleGuidesBlock(selected, labels)}\\n${after}`\n if (next !== content) writeFileSync(agentsMdPath, next)\n}\n\n// \u2500\u2500\u2500 Generators \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction generateShared(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n\n // Resolve which per-module fact-sheets this app gets (enabled \u2229 bundled allowlist).\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n const moduleGuideLabels = readModuleGuideLabels(GUIDES_DIR)\n\n // AGENTS.md\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n injectModuleGuides(join(targetDir, 'AGENTS.md'), selectedModules, moduleGuideLabels)\n\n // .ai/ structure\n writeTemplate(srcDir, 'ai/specs/README.md', join(targetDir, '.ai', 'specs', 'README.md'), config)\n copyFile(srcDir, 'ai/specs/SPEC-000-template.md', join(targetDir, '.ai', 'specs', 'SPEC-000-template.md'))\n copyFile(srcDir, 'ai/lessons.md', join(targetDir, '.ai', 'lessons.md'))\n\n // .ai/skills/\n writeTemplate(\n srcDir,\n 'ai/skills/om-spec-writing/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'SKILL.md'),\n config,\n )\n copyFile(\n srcDir,\n 'ai/skills/om-spec-writing/references/spec-template.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'references', 'spec-template.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-spec-writing/references/spec-checklist.md',\n join(targetDir, '.ai', 'skills', 'om-spec-writing', 'references', 'spec-checklist.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-backend-ui-design/references/ui-components.md',\n join(targetDir, '.ai', 'skills', 'om-backend-ui-design', 'references', 'ui-components.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-code-review/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-code-review', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-code-review/references/review-checklist.md',\n join(targetDir, '.ai', 'skills', 'om-code-review', 'references', 'review-checklist.md'),\n )\n copyFile(srcDir, 'ai/skills/om-integration-builder/SKILL.md', join(targetDir, '.ai', 'skills', 'om-integration-builder', 'SKILL.md'))\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/references/adapter-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'references', 'adapter-contracts.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', 'om-integration-builder', 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n 'ai/skills/om-integration-builder/STANDALONE.md',\n join(targetDir, '.ai', 'skills', 'om-integration-builder', 'STANDALONE.md'),\n )\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-system-extension/references/extension-contracts.md',\n join(targetDir, '.ai', 'skills', 'om-system-extension', 'references', 'extension-contracts.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/naming-conventions.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'naming-conventions.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-module-scaffold/references/navigation-patterns.md',\n join(targetDir, '.ai', 'skills', 'om-module-scaffold', 'references', 'navigation-patterns.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-troubleshooter/references/diagnostic-commands.md',\n join(targetDir, '.ai', 'skills', 'om-troubleshooter', 'references', 'diagnostic-commands.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-eject-and-customize/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-eject-and-customize', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-data-model-design/references/mikro-orm-cheatsheet.md',\n join(targetDir, '.ai', 'skills', 'om-data-model-design', 'references', 'mikro-orm-cheatsheet.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-implement-spec/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-implement-spec', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-integration-tests/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-integration-tests', 'SKILL.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-help/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'SKILL.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/skills-catalog.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'skills-catalog.md'),\n )\n copyFile(\n srcDir,\n 'ai/skills/om-help/references/workflow-sequences.md',\n join(targetDir, '.ai', 'skills', 'om-help', 'references', 'workflow-sequences.md'),\n )\n\n copyFile(\n srcDir,\n 'ai/skills/om-auto-upgrade-0.4.10-to-0.5.0/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-auto-upgrade-0.4.10-to-0.5.0', 'SKILL.md'),\n )\n\n for (const autoSkill of [\n 'om-auto-create-pr',\n 'om-auto-continue-pr',\n 'om-auto-create-pr-loop',\n 'om-auto-continue-pr-loop',\n 'om-auto-review-pr',\n 'om-auto-fix-github',\n 'om-prepare-issue',\n ]) {\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/SKILL.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'SKILL.md'),\n )\n if (existsSync(join(srcDir, 'ai', 'skills', autoSkill, 'STANDALONE.md'))) {\n copyFile(\n srcDir,\n `ai/skills/${autoSkill}/STANDALONE.md`,\n join(targetDir, '.ai', 'skills', autoSkill, 'STANDALONE.md'),\n )\n }\n }\n\n copyFile(\n srcDir,\n 'ai/skills/om-trim-unused-modules/SKILL.md',\n join(targetDir, '.ai', 'skills', 'om-trim-unused-modules', 'SKILL.md'),\n )\n\n copyFile(srcDir, 'ai/qa/tests/playwright.config.ts', join(targetDir, '.ai', 'qa', 'tests', 'playwright.config.ts'))\n\n // Package & conceptual guides are copied wholesale (framework-wide). Per-module\n // fact-sheets (.ai/guides/modules/<module>.md) are filtered to the app's enabled\n // module set; the combined module-facts.json sidecar is copied as-is.\n if (existsSync(GUIDES_DIR)) {\n const guidesDestDir = join(targetDir, '.ai', 'guides')\n for (const file of readdirSync(GUIDES_DIR)) {\n if (!file.endsWith('.md')) continue\n const srcPath = join(GUIDES_DIR, file)\n const destPath = join(guidesDestDir, file)\n ensureDir(destPath)\n copyFileSync(srcPath, destPath)\n }\n\n const moduleFactsPath = join(GUIDES_DIR, 'module-facts.json')\n if (existsSync(moduleFactsPath)) {\n const destPath = join(guidesDestDir, 'module-facts.json')\n ensureDir(destPath)\n copyFileSync(moduleFactsPath, destPath)\n }\n\n const modulesSubdir = join(GUIDES_DIR, 'modules')\n for (const moduleId of selectedModules) {\n const destPath = join(guidesDestDir, 'modules', `${moduleId}.md`)\n ensureDir(destPath)\n copyFileSync(join(modulesSubdir, `${moduleId}.md`), destPath)\n }\n }\n}\n\nfunction generateClaudeCode(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'claude-code')\n\n writeTemplate(srcDir, 'CLAUDE.md.template', join(targetDir, 'CLAUDE.md'), config)\n copyFile(srcDir, 'settings.json', join(targetDir, '.claude', 'settings.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.ts', join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.mcp.json.example'))\n\n // Symlink .claude/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.claude', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCodex(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'codex')\n\n const agentsPath = join(targetDir, 'AGENTS.md')\n if (existsSync(agentsPath)) {\n const enforcement = readFileSync(join(srcDir, 'enforcement-rules.md'), 'utf-8')\n let agents = readFileSync(agentsPath, 'utf-8')\n const MARKER_START = '<!-- CODEX_ENFORCEMENT_RULES_START -->'\n const MARKER_END = '<!-- CODEX_ENFORCEMENT_RULES_END -->'\n\n if (agents.includes(MARKER_START)) {\n const startIdx = agents.indexOf(MARKER_START)\n const endIdx = agents.indexOf(MARKER_END)\n if (endIdx !== -1) {\n agents = agents.slice(0, startIdx) + enforcement + agents.slice(endIdx + MARKER_END.length)\n }\n } else {\n const firstNewline = agents.indexOf('\\n')\n if (firstNewline !== -1) {\n agents = agents.slice(0, firstNewline + 1) + '\\n' + enforcement + '\\n' + agents.slice(firstNewline + 1)\n } else {\n agents = agents + '\\n\\n' + enforcement\n }\n }\n writeFileSync(agentsPath, agents)\n }\n\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.codex', 'mcp.json.example'))\n\n // Symlink .codex/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.codex', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction generateCursor(config: AgenticConfig): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'cursor')\n\n writeTemplate(srcDir, 'rules/open-mercato.mdc', join(targetDir, '.cursor', 'rules', 'open-mercato.mdc'), config)\n copyFile(srcDir, 'rules/entity-guard.mdc', join(targetDir, '.cursor', 'rules', 'entity-guard.mdc'))\n copyFile(srcDir, 'rules/generated-guard.mdc', join(targetDir, '.cursor', 'rules', 'generated-guard.mdc'))\n copyFile(srcDir, 'hooks.json', join(targetDir, '.cursor', 'hooks.json'))\n copyFile(srcDir, 'hooks/entity-migration-check.mjs', join(targetDir, '.cursor', 'hooks', 'entity-migration-check.mjs'))\n copyFile(srcDir, 'mcp.json.example', join(targetDir, '.cursor', 'mcp.json.example'))\n\n // Symlink .cursor/skills \u2192 ../.ai/skills\n ensureSkillsLink(join(targetDir, '.cursor', 'skills'), join('..', '.ai', 'skills'))\n}\n\nfunction ensureSkillsLink(linkPath: string, target: string): void {\n ensureDir(linkPath)\n if (existsSync(linkPath) && !lstatSync(linkPath).isSymbolicLink()) {\n return\n }\n if (lstatSync(linkPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n unlinkSync(linkPath)\n }\n symlinkSync(target, linkPath)\n}\n\n// \u2500\u2500\u2500 Wizard \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst TOOLS = [\n { key: '1', label: 'Claude Code (Anthropic)', id: 'claude-code' },\n { key: '2', label: 'Codex (OpenAI)', id: 'codex' },\n { key: '3', label: 'Cursor (Anysphere)', id: 'cursor' },\n { key: '4', label: 'Multiple tools (select individually)', id: 'multiple' },\n { key: '5', label: 'Skip \u2014 set up manually later', id: 'skip' },\n] as const\n\nconst SELECTABLE = TOOLS.filter((t) => t.id !== 'multiple' && t.id !== 'skip')\n\nasync function promptSelection(ask: AskFn): Promise<string[]> {\n console.log('')\n console.log('\uD83E\uDD16 Agentic workflow setup')\n console.log('')\n console.log(' Which AI coding tool will you use with this project?')\n console.log('')\n for (const tool of TOOLS) {\n console.log(` ${tool.key}. ${tool.label}`)\n }\n console.log('')\n\n const answer = (await ask(' Enter number(s) separated by comma [1]: ')).trim() || '1'\n\n if (answer === '5') return ['skip']\n\n if (answer === '4') {\n const selected: string[] = []\n for (const tool of SELECTABLE) {\n const yn = await ask(` Include ${tool.label}? [y/N]: `)\n if (yn.toLowerCase() === 'y' || yn.toLowerCase() === 'yes') {\n selected.push(tool.id)\n }\n }\n return selected.length > 0 ? selected : ['skip']\n }\n\n const keys = answer.split(',').map((s) => s.trim())\n const ids: string[] = []\n for (const key of keys) {\n const tool = TOOLS.find((t) => t.key === key)\n if (tool && tool.id !== 'multiple' && tool.id !== 'skip') {\n ids.push(tool.id)\n }\n }\n return ids.length > 0 ? ids : ['skip']\n}\n\nexport async function runAgenticSetup(\n targetDir: string,\n ask: AskFn,\n options?: AgenticSetupOptions,\n): Promise<void> {\n let selectedIds: string[]\n\n if (options?.tool) {\n selectedIds = options.tool.split(',').map((t) => t.trim())\n } else {\n selectedIds = await promptSelection(ask)\n }\n\n if (selectedIds.includes('skip')) {\n console.log('')\n console.log(' Skipped agentic setup.')\n console.log('')\n return\n }\n\n const config: AgenticConfig = {\n projectName: basename(targetDir),\n targetDir,\n }\n\n generateShared(config)\n if (selectedIds.includes('claude-code')) generateClaudeCode(config)\n if (selectedIds.includes('codex')) generateCodex(config)\n if (selectedIds.includes('cursor')) generateCursor(config)\n\n console.log('')\n console.log(' Agentic setup complete:')\n if (selectedIds.includes('claude-code')) {\n console.log(' \u2713 Claude Code \u2014 CLAUDE.md, .claude/hooks/, .mcp.json.example')\n }\n if (selectedIds.includes('codex')) {\n console.log(' \u2713 Codex \u2014 AGENTS.md enforcement rules, .codex/mcp.json.example')\n }\n if (selectedIds.includes('cursor')) {\n console.log(' \u2713 Cursor \u2014 .cursor/rules/, .cursor/hooks/, .cursor/mcp.json.example')\n }\n console.log('')\n}\n"],
5
+ "mappings": "AAQA,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,aAAa,WAAW,YAAY,mBAAmB;AAClI,SAAS,MAAM,SAAS,gBAAgB;AACxC,SAAS,qBAAqB;AAC9B,SAAS,SAAS,kBAAkB;AAEpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,cAAc,KAAK,WAAW,MAAM,SAAS;AACnD,MAAM,aAAa,KAAK,aAAa,QAAQ;AAgB7C,SAAS,oBAAoB,SAAiB,QAA+B;AAC3E,SAAO,QAAQ,QAAQ,yBAAyB,OAAO,WAAW;AACpE;AAEA,SAAS,UAAU,UAAwB;AACzC,QAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAI,CAAC,WAAW,GAAG,EAAG,WAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAC1D;AAEA,SAAS,cAAc,QAAgB,aAAqB,UAAkB,QAA6B;AACzG,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,QAAM,UAAU,aAAa,SAAS,OAAO;AAC7C,YAAU,QAAQ;AAClB,gBAAc,UAAU,oBAAoB,SAAS,MAAM,CAAC;AAC9D;AAEA,SAAS,SAAS,QAAgB,aAAqB,UAAwB;AAC7E,QAAM,UAAU,KAAK,QAAQ,WAAW;AACxC,YAAU,QAAQ;AAClB,eAAa,SAAS,QAA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c,MAAM;AACvD,MAAI,YAAY,SAAS,QAAQ,EAAG,gBAAe,MAAM;AAEzD,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,4BAA4B;AACxC,MAAI,YAAY,SAAS,aAAa,GAAG;AACvC,YAAQ,IAAI,2EAAiE;AAAA,EAC/E;AACA,MAAI,YAAY,SAAS,OAAO,GAAG;AACjC,YAAQ,IAAI,6EAAmE;AAAA,EACjF;AACA,MAAI,YAAY,SAAS,QAAQ,GAAG;AAClC,YAAQ,IAAI,kFAAwE;AAAA,EACtF;AACA,UAAQ,IAAI,EAAE;AAChB;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,21 @@
1
+ import {
2
+ inferModuleIdFromResourceId,
3
+ withModuleResourceUsage
4
+ } from "@open-mercato/shared/lib/modules/resource-usage";
1
5
  function createPerJobWorkerHandler(workers, createContainer) {
2
6
  return async (job, ctx) => {
3
7
  const container = await createContainer();
4
8
  try {
5
9
  for (const worker of workers) {
6
- await worker.handler(job, { ...ctx, resolve: container.resolve.bind(container) });
10
+ await withModuleResourceUsage(
11
+ {
12
+ moduleId: worker.moduleId ?? inferModuleIdFromResourceId(worker.id),
13
+ surface: "worker",
14
+ operation: worker.id,
15
+ resourceId: worker.id
16
+ },
17
+ () => worker.handler(job, { ...ctx, resolve: container.resolve.bind(container) })
18
+ );
7
19
  }
8
20
  } finally {
9
21
  try {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/worker-job-handler.ts"],
4
- "sourcesContent": ["import type { JobContext, JobHandler } from '@open-mercato/queue'\nimport type { ModuleWorker } from '@open-mercato/shared/modules/registry'\n\nexport type WorkerJobContainer = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport type WorkerJobContainerFactory = () => Promise<WorkerJobContainer>\n\ntype ClearableEntityManager = {\n clear?: () => void\n}\n\n/**\n * Builds a queue job handler that isolates every job in its own request\n * container, instead of sharing a single process-wide `EntityManager` fork\n * across all concurrent jobs.\n *\n * Under the async (BullMQ) strategy jobs run with real concurrency, so a\n * shared EM would interleave unit-of-work flushes between unrelated jobs and\n * never release its identity map. Creating one container per job removes both\n * the cross-job flush race and the unbounded identity-map growth, while\n * keeping the `ctx.resolve` contract and DI keys unchanged. See issue #2970.\n */\nexport function createPerJobWorkerHandler(\n workers: ModuleWorker[],\n createContainer: WorkerJobContainerFactory,\n): JobHandler {\n return async (job, ctx: JobContext) => {\n const container = await createContainer()\n try {\n for (const worker of workers) {\n await worker.handler(job, { ...ctx, resolve: container.resolve.bind(container) })\n }\n } finally {\n try {\n const em = container.resolve('em') as ClearableEntityManager | null\n em?.clear?.()\n } catch {\n // Best-effort: clearing the identity map is a memory optimization and\n // must never mask a job's own outcome.\n }\n }\n }\n}\n"],
5
- "mappings": "AAwBO,SAAS,0BACd,SACA,iBACY;AACZ,SAAO,OAAO,KAAK,QAAoB;AACrC,UAAM,YAAY,MAAM,gBAAgB;AACxC,QAAI;AACF,iBAAW,UAAU,SAAS;AAC5B,cAAM,OAAO,QAAQ,KAAK,EAAE,GAAG,KAAK,SAAS,UAAU,QAAQ,KAAK,SAAS,EAAE,CAAC;AAAA,MAClF;AAAA,IACF,UAAE;AACA,UAAI;AACF,cAAM,KAAK,UAAU,QAAQ,IAAI;AACjC,YAAI,QAAQ;AAAA,MACd,QAAQ;AAAA,MAGR;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type { JobContext, JobHandler } from '@open-mercato/queue'\nimport type { ModuleWorker } from '@open-mercato/shared/modules/registry'\nimport {\n inferModuleIdFromResourceId,\n withModuleResourceUsage,\n} from '@open-mercato/shared/lib/modules/resource-usage'\n\nexport type WorkerJobContainer = {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport type WorkerJobContainerFactory = () => Promise<WorkerJobContainer>\n\ntype ClearableEntityManager = {\n clear?: () => void\n}\n\n/**\n * Builds a queue job handler that isolates every job in its own request\n * container, instead of sharing a single process-wide `EntityManager` fork\n * across all concurrent jobs.\n *\n * Under the async (BullMQ) strategy jobs run with real concurrency, so a\n * shared EM would interleave unit-of-work flushes between unrelated jobs and\n * never release its identity map. Creating one container per job removes both\n * the cross-job flush race and the unbounded identity-map growth, while\n * keeping the `ctx.resolve` contract and DI keys unchanged. See issue #2970.\n */\nexport function createPerJobWorkerHandler(\n workers: ModuleWorker[],\n createContainer: WorkerJobContainerFactory,\n): JobHandler {\n return async (job, ctx: JobContext) => {\n const container = await createContainer()\n try {\n for (const worker of workers) {\n await withModuleResourceUsage(\n {\n moduleId: worker.moduleId ?? inferModuleIdFromResourceId(worker.id),\n surface: 'worker',\n operation: worker.id,\n resourceId: worker.id,\n },\n () => worker.handler(job, { ...ctx, resolve: container.resolve.bind(container) }),\n )\n }\n } finally {\n try {\n const em = container.resolve('em') as ClearableEntityManager | null\n em?.clear?.()\n } catch {\n // Best-effort: clearing the identity map is a memory optimization and\n // must never mask a job's own outcome.\n }\n }\n }\n}\n"],
5
+ "mappings": "AAEA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAuBA,SAAS,0BACd,SACA,iBACY;AACZ,SAAO,OAAO,KAAK,QAAoB;AACrC,UAAM,YAAY,MAAM,gBAAgB;AACxC,QAAI;AACF,iBAAW,UAAU,SAAS;AAC5B,cAAM;AAAA,UACJ;AAAA,YACE,UAAU,OAAO,YAAY,4BAA4B,OAAO,EAAE;AAAA,YAClE,SAAS;AAAA,YACT,WAAW,OAAO;AAAA,YAClB,YAAY,OAAO;AAAA,UACrB;AAAA,UACA,MAAM,OAAO,QAAQ,KAAK,EAAE,GAAG,KAAK,SAAS,UAAU,QAAQ,KAAK,SAAS,EAAE,CAAC;AAAA,QAClF;AAAA,MACF;AAAA,IACF,UAAE;AACA,UAAI;AACF,cAAM,KAAK,UAAU,QAAQ,IAAI;AACjC,YAAI,QAAQ;AAAA,MACd,QAAQ;AAAA,MAGR;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/mercato.js CHANGED
@@ -52,7 +52,10 @@ function getRegisteredCliWorkers(modules = getCliModules()) {
52
52
  const allWorkers = [];
53
53
  for (const mod of modules) {
54
54
  if (mod.workers) {
55
- allWorkers.push(...mod.workers);
55
+ allWorkers.push(...mod.workers.map((worker) => ({
56
+ ...worker,
57
+ moduleId: worker.moduleId ?? mod.id
58
+ })));
56
59
  }
57
60
  }
58
61
  return allWorkers;