@open-mercato/cli 0.6.8-develop.7001.1.03608ab252 → 0.6.8-develop.7003.1.24fef49d48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -3
- package/build.mjs +45 -30
- package/dist/agentic/guides/module-facts.json +124 -124
- package/dist/agentic/guides/module-facts.v2.json +124 -124
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/lib/__integration__/TC-INT-008.spec.js +5 -0
- package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
- package/package.json +6 -6
- package/src/lib/__integration__/TC-INT-008.spec.ts +9 -0
- package/src/lib/__tests__/agentic-build-artifacts.test.ts +28 -0
|
@@ -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')\nconst coreVersion = JSON.parse(fs.readFileSync(path.join(packagesRoot, 'core', 'package.json'), 'utf8')).version as string\nconst UNROUTED_PACKAGE_GUIDES = new Set(['cache', 'core', 'events', 'queue', 'search', 'shared', 'ui'])\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, env: NodeJS.ProcessEnv = {}): 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 // Keep the test hermetic: agentic:init runs scripts/install-skills.sh,\n // whose external step (`npx skills add`) needs the network. Local tier\n // symlinks are still installed.\n OM_SKIP_EXTERNAL_SKILLS: '1',\n ...env,\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string, env: NodeJS.ProcessEnv = {}): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd, env)\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 dependencies: { '@open-mercato/core': coreVersion },\n },\n null,\n 2,\n ),\n )\n const moduleEntries = FIXTURE_ENABLED_MODULES\n .map((moduleId) => ` { id: '${moduleId}', from: '@open-mercato/core' },`)\n .join('\\n')\n writeFile(path.join(appDir, 'src', 'modules.ts'), `export const enabledModules = [\\n${moduleEntries}\\n]\\n`)\n return appDir\n}\n\nfunction installFakeFrameworkPackage(appDir: string): string {\n const packageRoot = path.join(appDir, 'node_modules', '@open-mercato', 'core')\n writeFile(path.join(packageRoot, 'package.json'), JSON.stringify({\n name: '@open-mercato/core',\n version: coreVersion,\n type: 'module',\n exports: { '.': './dist/index.js' },\n }))\n writeFile(path.join(packageRoot, 'dist', 'index.js'), 'export {}\\n')\n writeFile(path.join(packageRoot, 'AGENTS.md'), '# Installed core instructions\\n')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n writeFile(path.join(packageRoot, 'src', 'modules', moduleId, 'AGENTS.md'), `# Installed ${moduleId} instructions\\n`)\n writeFile(\n path.join(packageRoot, 'src', 'modules', moduleId, 'data', 'entities.ts'),\n `export class ${moduleId === 'customers' ? 'Person' : 'Sale'} {}\\n`,\n )\n }\n return packageRoot\n}\n\nfunction snapshotTextFiles(rootDir: string): Record<string, string> {\n return Object.fromEntries(\n listRelativeFiles(rootDir).map((relativePath) => [\n relativePath,\n fs.readFileSync(path.join(rootDir, relativePath), 'utf8'),\n ]),\n )\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('scripts/')) {\n return relativePath\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 | null {\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 === 'settings.experimental-hooks-validator.json') {\n return null\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n if (relativePath.includes('gate-evidence.')) return null\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 | null {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'hooks.experimental-hooks-validator.json') {\n return null\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n if (relativePath.includes('gate-evidence.')) return null\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 if (relativePath === 'hooks.json' || relativePath === 'hooks/gate-evidence.mjs') {\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) && !UNROUTED_PACKAGE_GUIDES.has(packageName)) {\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 v1/v2 sidecars and disabled local-reference projection are copied as-is,\n // while installed fact-sheets are filtered to the fixture's enabled modules. The legacy\n // core.<module>.md redirect stubs are no longer\n // emitted (#3754). framework-extension-points.md is likewise generated into\n // dist/agentic/guides by both build.mjs pipelines (#4810) rather than checked in\n // alongside the static conceptual guides, so it needs an explicit entry here.\n collected.add('module-facts.json')\n collected.add('module-facts.v2.json')\n collected.add('reference-module-facts.json')\n collected.add('framework-extension-points.md')\n collected.add('upstream/AGENTS.md')\n collected.add('upstream/BACKWARD_COMPATIBILITY.md')\n collected.add('upstream/manifest.json')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n const moduleFactsRoot = path.join(cliDir, 'dist', 'agentic', 'guides', 'modules', moduleId)\n for (const file of fs.readdirSync(moduleFactsRoot)) {\n if (file.endsWith('.md')) collected.add(normalizePath(path.join('modules', moduleId, file)))\n }\n }\n const referenceFactsRoot = path.join(cliDir, 'dist', 'agentic', 'guides', 'reference-modules')\n for (const file of listRelativeFiles(referenceFactsRoot)) {\n collected.add(normalizePath(path.join('reference-modules', file)))\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'))\n .map(mapClaudeSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor'))\n .map(mapCursorSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\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 for (const relativePath of [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ]) {\n expect(fs.existsSync(path.join(appDir, relativePath))).toBe(false)\n }\n expect(fs.readFileSync(path.join(appDir, '.claude', 'settings.json'), 'utf8')).not.toContain('gate-evidence')\n expect(fs.readFileSync(path.join(appDir, '.cursor', 'hooks.json'), 'utf8')).not.toContain('gate-evidence')\n const defaultManifest = JSON.parse(\n fs.readFileSync(path.join(appDir, '.ai', 'harness', 'manifest.json'), 'utf8'),\n ) as { files: Array<{ path: string }> }\n expect(defaultManifest.files.some((entry) => entry.path.includes('gate-evidence'))).toBe(false)\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/upstream/BACKWARD_COMPATIBILITY.md')\n\n // The Module-Specific Guides marker block is a compact enabled-module ID\n // index (enabled \u2229 bundled) plus one progressively loaded path pattern.\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n expect(agentsSource).toContain(`\\`${moduleId}\\``)\n }\n expect(agentsSource).toContain('`.ai/guides/modules/<id>/index.md`')\n expect(agentsSource.match(/\\.ai\\/guides\\/modules\\//g)).toHaveLength(1)\n expect(agentsSource).not.toContain('`auth`')\n expect(agentsSource).not.toContain('Core CRM capabilities')\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 // om-spec-writing moved to the external open-mercato/skills collection\n // (installed via `yarn install-skills`), so agentic:init must not ship a copy.\n expect(fs.existsSync(path.join(appDir, '.ai', 'skills', 'om-spec-writing'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, 'scripts', 'install-skills.sh'))).toBe(true)\n\n // install-skills.sh (run by agentic:init) installs every local tier skill once,\n // into the canonical .agents/skills/. Codex and Cursor read that directory\n // natively, so they get no skills directory of their own; Claude Code cannot,\n // so it keeps a link layer pointing back at the canonical copy.\n const tiersManifest = JSON.parse(\n fs.readFileSync(path.join(agenticRoot, 'shared', 'ai', 'skills', 'tiers.json'), 'utf8'),\n ) as { default: string[]; tiers: Record<string, { skills: string[] }> }\n const defaultTierSkills = tiersManifest.default.flatMap((tierName) => tiersManifest.tiers[tierName].skills)\n expect(defaultTierSkills.length).toBeGreaterThan(0)\n\n for (const skillName of defaultTierSkills) {\n const canonicalLinkPath = path.join(appDir, '.agents', 'skills', skillName)\n expect(fs.lstatSync(canonicalLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(canonicalLinkPath))).toBe(`../../.ai/skills/${skillName}`)\n\n const claudeLinkPath = path.join(appDir, '.claude', 'skills', skillName)\n expect(fs.lstatSync(claudeLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(claudeLinkPath))).toBe(`../../.agents/skills/${skillName}`)\n }\n\n expect(fs.existsSync(path.join(appDir, '.codex', 'skills'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, '.cursor', 'skills'))).toBe(false)\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n\n test('installs gate-evidence hooks only through the explicit flag or environment opt-in', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-hooks-'))\n\n try {\n const flagAppDir = createStandaloneFixture(path.join(tempRoot, 'flag'))\n runMercato([\n 'agentic:init',\n '--tool=claude-code,codex,cursor',\n '--experimental-hooks-validator',\n ], flagAppDir)\n\n assertPathsExist(flagAppDir, [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ])\n expect(fs.readFileSync(path.join(flagAppDir, '.claude', 'settings.json'), 'utf8')).toContain('gate-evidence')\n expect(fs.readFileSync(path.join(flagAppDir, '.cursor', 'hooks.json'), 'utf8')).toContain('gate-evidence')\n const enabledManifest = JSON.parse(\n fs.readFileSync(path.join(flagAppDir, '.ai', 'harness', 'manifest.json'), 'utf8'),\n ) as { files: Array<{ path: string }> }\n expect(enabledManifest.files.filter((entry) => entry.path.includes('gate-evidence'))).toHaveLength(3)\n\n runMercato([\n 'agentic:init',\n '--tool=claude-code,codex,cursor',\n '--update-harness',\n ], flagAppDir)\n for (const relativePath of [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ]) {\n expect(fs.existsSync(path.join(flagAppDir, relativePath))).toBe(false)\n }\n expect(fs.readFileSync(path.join(flagAppDir, '.claude', 'settings.json'), 'utf8')).not.toContain('gate-evidence')\n expect(fs.readFileSync(path.join(flagAppDir, '.cursor', 'hooks.json'), 'utf8')).not.toContain('gate-evidence')\n\n const envAppDir = createStandaloneFixture(path.join(tempRoot, 'environment'))\n runMercato(['agentic:init', '--tool=codex'], envAppDir, {\n OM_HARNESS_EXPERIMENTAL_HOOKS_VALIDATOR: '1',\n })\n assertPathsExist(envAppDir, [\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n ])\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n\n test('emits a runnable exact-version framework context escape hatch for an installed package', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-framework-context-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const packageRoot = installFakeFrameworkPackage(appDir)\n const resolvedPackageRoot = fs.realpathSync(packageRoot)\n const packageBefore = snapshotTextFiles(packageRoot)\n\n runMercato(['agentic:init', '--tool=codex'], appDir)\n const generatedScript = path.join(appDir, 'scripts', 'framework-context.mjs')\n expect(fs.existsSync(generatedScript)).toBe(true)\n\n const output = runCommand(\n process.execPath,\n [generatedScript, '--module', 'customers', '--query', 'Person', '--json'],\n appDir,\n // The generated standalone helper must not depend on a globally\n // installed ripgrep binary; process.execPath is already absolute.\n { PATH: '', Path: '' },\n )\n const context = JSON.parse(output) as {\n module: string\n package: { name: string; version: string; root: string }\n sourceKind: string\n sourceRoot: string\n materializedSource: string\n instructions: Array<{ kind: string; path: string | null; materializedPath?: string }>\n boundedSearch: { status: string; matches: number; maxMatches: number; result: string }\n warnings: string[]\n }\n\n expect(context.module).toBe('customers')\n expect(context.package).toEqual({ name: '@open-mercato/core', version: coreVersion, root: resolvedPackageRoot })\n expect(context.sourceKind).toBe('source')\n expect(normalizePath(context.sourceRoot)).toBe(normalizePath(path.join(resolvedPackageRoot, 'src', 'modules', 'customers')))\n expect(context.instructions.filter((entry) => entry.path).map((entry) => entry.kind)).toEqual([\n 'standalone-root',\n 'upstream-bc',\n 'package',\n 'module-1',\n 'upstream-root',\n ])\n expect(context.instructions.filter((entry) => entry.path).every((entry) => entry.materializedPath)).toBe(true)\n expect(context.boundedSearch).toMatchObject({ status: 'matched', matches: 1, maxMatches: 200 })\n expect(fs.existsSync(path.join(appDir, context.materializedSource))).toBe(true)\n expect(fs.existsSync(path.join(appDir, context.boundedSearch.result))).toBe(true)\n expect(context.warnings.some((warning) => warning.includes('Generated facts for customers are stale'))).toBe(false)\n expect(snapshotTextFiles(packageRoot)).toEqual(packageBefore)\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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Q,SAAS,KAAK,CAAC,YAAY,QAAQ,SAAS,yCAAyC,CAAC,CAAC,EAAE,KAAK,KAAK;AAClH,aAAO,kBAAkB,WAAW,CAAC,EAAE,QAAQ,aAAa;AAAA,IAC9D,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'\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')\nconst coreVersion = JSON.parse(fs.readFileSync(path.join(packagesRoot, 'core', 'package.json'), 'utf8')).version as string\nconst UNROUTED_PACKAGE_GUIDES = new Set(['cache', 'core', 'events', 'queue', 'search', 'shared', 'ui'])\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, env: NodeJS.ProcessEnv = {}): 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 // Keep the test hermetic: agentic:init runs scripts/install-skills.sh,\n // whose external step (`npx skills add`) needs the network. Local tier\n // symlinks are still installed.\n OM_SKIP_EXTERNAL_SKILLS: '1',\n ...env,\n },\n })\n}\n\nfunction runMercato(args: string[], cwd: string, env: NodeJS.ProcessEnv = {}): string {\n return runCommand(process.execPath, [cliBin, ...args], cwd, env)\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 dependencies: { '@open-mercato/core': coreVersion },\n },\n null,\n 2,\n ),\n )\n const moduleEntries = FIXTURE_ENABLED_MODULES\n .map((moduleId) => ` { id: '${moduleId}', from: '@open-mercato/core' },`)\n .join('\\n')\n writeFile(path.join(appDir, 'src', 'modules.ts'), `export const enabledModules = [\\n${moduleEntries}\\n]\\n`)\n return appDir\n}\n\nfunction installFakeFrameworkPackage(appDir: string): string {\n const packageRoot = path.join(appDir, 'node_modules', '@open-mercato', 'core')\n writeFile(path.join(packageRoot, 'package.json'), JSON.stringify({\n name: '@open-mercato/core',\n version: coreVersion,\n type: 'module',\n exports: { '.': './dist/index.js' },\n }))\n writeFile(path.join(packageRoot, 'dist', 'index.js'), 'export {}\\n')\n writeFile(path.join(packageRoot, 'AGENTS.md'), '# Installed core instructions\\n')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n writeFile(path.join(packageRoot, 'src', 'modules', moduleId, 'AGENTS.md'), `# Installed ${moduleId} instructions\\n`)\n writeFile(\n path.join(packageRoot, 'src', 'modules', moduleId, 'data', 'entities.ts'),\n `export class ${moduleId === 'customers' ? 'Person' : 'Sale'} {}\\n`,\n )\n }\n return packageRoot\n}\n\nfunction snapshotTextFiles(rootDir: string): Record<string, string> {\n return Object.fromEntries(\n listRelativeFiles(rootDir).map((relativePath) => [\n relativePath,\n fs.readFileSync(path.join(rootDir, relativePath), 'utf8'),\n ]),\n )\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('scripts/')) {\n return relativePath\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 | null {\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 === 'settings.experimental-hooks-validator.json') {\n return null\n }\n if (relativePath === 'mcp.json.example') {\n return '.mcp.json.example'\n }\n if (relativePath.startsWith('hooks/')) {\n if (relativePath.includes('gate-evidence.')) return null\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 | null {\n if (relativePath === 'hooks.json') {\n return '.cursor/hooks.json'\n }\n if (relativePath === 'hooks.experimental-hooks-validator.json') {\n return null\n }\n if (relativePath === 'mcp.json.example') {\n return '.cursor/mcp.json.example'\n }\n if (relativePath.startsWith('hooks/') || relativePath.startsWith('rules/')) {\n if (relativePath.includes('gate-evidence.')) return null\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 if (relativePath === 'hooks.json' || relativePath === 'hooks/gate-evidence.mjs') {\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) && !UNROUTED_PACKAGE_GUIDES.has(packageName)) {\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 v1/v2 sidecars and disabled local-reference projection are copied as-is,\n // while installed fact-sheets are filtered to the fixture's enabled modules. The legacy\n // core.<module>.md redirect stubs are no longer\n // emitted (#3754). framework-extension-points.md is likewise generated into\n // dist/agentic/guides by both build.mjs pipelines (#4810) rather than checked in\n // alongside the static conceptual guides, so it needs an explicit entry here.\n collected.add('module-facts.json')\n collected.add('module-facts.v2.json')\n collected.add('reference-module-facts.json')\n collected.add('framework-extension-points.md')\n collected.add('upstream/AGENTS.md')\n collected.add('upstream/BACKWARD_COMPATIBILITY.md')\n collected.add('upstream/manifest.json')\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n const moduleFactsRoot = path.join(cliDir, 'dist', 'agentic', 'guides', 'modules', moduleId)\n for (const file of fs.readdirSync(moduleFactsRoot)) {\n if (file.endsWith('.md')) collected.add(normalizePath(path.join('modules', moduleId, file)))\n }\n }\n const referenceFactsRoot = path.join(cliDir, 'dist', 'agentic', 'guides', 'reference-modules')\n for (const file of listRelativeFiles(referenceFactsRoot)) {\n collected.add(normalizePath(path.join('reference-modules', file)))\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 // dist/ is published, so a staging tree the build forgot to swap in would ship with the package \u2014\n // and a surviving agentic.previous would mean the swap never completed (#5104). beforeAll has run\n // the real build, so this asserts the state a completed build leaves behind.\n test('should leave no staging artifacts behind in dist', () => {\n for (const leftover of ['agentic.staging', 'agentic.previous']) {\n expect(fs.existsSync(path.join(cliDir, 'dist', leftover))).toBe(false)\n }\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'))\n .map(mapClaudeSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\n const cursorOutputs = listRelativeFiles(path.join(agenticRoot, 'cursor'))\n .map(mapCursorSourceToOutput)\n .filter((relativePath): relativePath is string => relativePath !== null)\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 for (const relativePath of [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ]) {\n expect(fs.existsSync(path.join(appDir, relativePath))).toBe(false)\n }\n expect(fs.readFileSync(path.join(appDir, '.claude', 'settings.json'), 'utf8')).not.toContain('gate-evidence')\n expect(fs.readFileSync(path.join(appDir, '.cursor', 'hooks.json'), 'utf8')).not.toContain('gate-evidence')\n const defaultManifest = JSON.parse(\n fs.readFileSync(path.join(appDir, '.ai', 'harness', 'manifest.json'), 'utf8'),\n ) as { files: Array<{ path: string }> }\n expect(defaultManifest.files.some((entry) => entry.path.includes('gate-evidence'))).toBe(false)\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/upstream/BACKWARD_COMPATIBILITY.md')\n\n // The Module-Specific Guides marker block is a compact enabled-module ID\n // index (enabled \u2229 bundled) plus one progressively loaded path pattern.\n for (const moduleId of FIXTURE_ENABLED_MODULES) {\n expect(agentsSource).toContain(`\\`${moduleId}\\``)\n }\n expect(agentsSource).toContain('`.ai/guides/modules/<id>/index.md`')\n expect(agentsSource.match(/\\.ai\\/guides\\/modules\\//g)).toHaveLength(1)\n expect(agentsSource).not.toContain('`auth`')\n expect(agentsSource).not.toContain('Core CRM capabilities')\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 // om-spec-writing moved to the external open-mercato/skills collection\n // (installed via `yarn install-skills`), so agentic:init must not ship a copy.\n expect(fs.existsSync(path.join(appDir, '.ai', 'skills', 'om-spec-writing'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, 'scripts', 'install-skills.sh'))).toBe(true)\n\n // install-skills.sh (run by agentic:init) installs every local tier skill once,\n // into the canonical .agents/skills/. Codex and Cursor read that directory\n // natively, so they get no skills directory of their own; Claude Code cannot,\n // so it keeps a link layer pointing back at the canonical copy.\n const tiersManifest = JSON.parse(\n fs.readFileSync(path.join(agenticRoot, 'shared', 'ai', 'skills', 'tiers.json'), 'utf8'),\n ) as { default: string[]; tiers: Record<string, { skills: string[] }> }\n const defaultTierSkills = tiersManifest.default.flatMap((tierName) => tiersManifest.tiers[tierName].skills)\n expect(defaultTierSkills.length).toBeGreaterThan(0)\n\n for (const skillName of defaultTierSkills) {\n const canonicalLinkPath = path.join(appDir, '.agents', 'skills', skillName)\n expect(fs.lstatSync(canonicalLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(canonicalLinkPath))).toBe(`../../.ai/skills/${skillName}`)\n\n const claudeLinkPath = path.join(appDir, '.claude', 'skills', skillName)\n expect(fs.lstatSync(claudeLinkPath).isSymbolicLink()).toBe(true)\n expect(normalizePath(fs.readlinkSync(claudeLinkPath))).toBe(`../../.agents/skills/${skillName}`)\n }\n\n expect(fs.existsSync(path.join(appDir, '.codex', 'skills'))).toBe(false)\n expect(fs.existsSync(path.join(appDir, '.cursor', 'skills'))).toBe(false)\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n\n test('installs gate-evidence hooks only through the explicit flag or environment opt-in', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-hooks-'))\n\n try {\n const flagAppDir = createStandaloneFixture(path.join(tempRoot, 'flag'))\n runMercato([\n 'agentic:init',\n '--tool=claude-code,codex,cursor',\n '--experimental-hooks-validator',\n ], flagAppDir)\n\n assertPathsExist(flagAppDir, [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ])\n expect(fs.readFileSync(path.join(flagAppDir, '.claude', 'settings.json'), 'utf8')).toContain('gate-evidence')\n expect(fs.readFileSync(path.join(flagAppDir, '.cursor', 'hooks.json'), 'utf8')).toContain('gate-evidence')\n const enabledManifest = JSON.parse(\n fs.readFileSync(path.join(flagAppDir, '.ai', 'harness', 'manifest.json'), 'utf8'),\n ) as { files: Array<{ path: string }> }\n expect(enabledManifest.files.filter((entry) => entry.path.includes('gate-evidence'))).toHaveLength(3)\n\n runMercato([\n 'agentic:init',\n '--tool=claude-code,codex,cursor',\n '--update-harness',\n ], flagAppDir)\n for (const relativePath of [\n '.claude/hooks/gate-evidence.ts',\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n '.cursor/hooks/gate-evidence.mjs',\n ]) {\n expect(fs.existsSync(path.join(flagAppDir, relativePath))).toBe(false)\n }\n expect(fs.readFileSync(path.join(flagAppDir, '.claude', 'settings.json'), 'utf8')).not.toContain('gate-evidence')\n expect(fs.readFileSync(path.join(flagAppDir, '.cursor', 'hooks.json'), 'utf8')).not.toContain('gate-evidence')\n\n const envAppDir = createStandaloneFixture(path.join(tempRoot, 'environment'))\n runMercato(['agentic:init', '--tool=codex'], envAppDir, {\n OM_HARNESS_EXPERIMENTAL_HOOKS_VALIDATOR: '1',\n })\n assertPathsExist(envAppDir, [\n '.codex/hooks.json',\n '.codex/hooks/gate-evidence.mjs',\n ])\n } finally {\n fs.rmSync(tempRoot, { recursive: true, force: true })\n }\n })\n\n test('emits a runnable exact-version framework context escape hatch for an installed package', () => {\n const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-framework-context-'))\n\n try {\n const appDir = createStandaloneFixture(tempRoot)\n const packageRoot = installFakeFrameworkPackage(appDir)\n const resolvedPackageRoot = fs.realpathSync(packageRoot)\n const packageBefore = snapshotTextFiles(packageRoot)\n\n runMercato(['agentic:init', '--tool=codex'], appDir)\n const generatedScript = path.join(appDir, 'scripts', 'framework-context.mjs')\n expect(fs.existsSync(generatedScript)).toBe(true)\n\n const output = runCommand(\n process.execPath,\n [generatedScript, '--module', 'customers', '--query', 'Person', '--json'],\n appDir,\n // The generated standalone helper must not depend on a globally\n // installed ripgrep binary; process.execPath is already absolute.\n { PATH: '', Path: '' },\n )\n const context = JSON.parse(output) as {\n module: string\n package: { name: string; version: string; root: string }\n sourceKind: string\n sourceRoot: string\n materializedSource: string\n instructions: Array<{ kind: string; path: string | null; materializedPath?: string }>\n boundedSearch: { status: string; matches: number; maxMatches: number; result: string }\n warnings: string[]\n }\n\n expect(context.module).toBe('customers')\n expect(context.package).toEqual({ name: '@open-mercato/core', version: coreVersion, root: resolvedPackageRoot })\n expect(context.sourceKind).toBe('source')\n expect(normalizePath(context.sourceRoot)).toBe(normalizePath(path.join(resolvedPackageRoot, 'src', 'modules', 'customers')))\n expect(context.instructions.filter((entry) => entry.path).map((entry) => entry.kind)).toEqual([\n 'standalone-root',\n 'upstream-bc',\n 'package',\n 'module-1',\n 'upstream-root',\n ])\n expect(context.instructions.filter((entry) => entry.path).every((entry) => entry.materializedPath)).toBe(true)\n expect(context.boundedSearch).toMatchObject({ status: 'matched', matches: 1, maxMatches: 200 })\n expect(fs.existsSync(path.join(appDir, context.materializedSource))).toBe(true)\n expect(fs.existsSync(path.join(appDir, context.boundedSearch.result))).toBe(true)\n expect(context.warnings.some((warning) => warning.includes('Generated facts for customers are stale'))).toBe(false)\n expect(snapshotTextFiles(packageRoot)).toEqual(packageBefore)\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,q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AAgB,CAAC,EAAE,KAAK,IAAI;AAC7G,aAAO,QAAQ,aAAa,EAAE,cAAc,EAAE,QAAQ,WAAW,SAAS,GAAG,YAAY,IAAI,CAAC;AAC9F,aAAO,GAAG,WAAW,KAAK,KAAK,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,EAAE,KAAK,IAAI;AAC9E,aAAO,GAAG,WAAW,KAAK,KAAK,QAAQ,QAAQ,cAAc,MAAM,CAAC,CAAC,EAAE,KAAK,IAAI;AAChF,aAAO,QAAQ,SAAS,KAAK,CAAC,YAAY,QAAQ,SAAS,yCAAyC,CAAC,CAAC,EAAE,KAAK,KAAK;AAClH,aAAO,kBAAkB,WAAW,CAAC,EAAE,QAAQ,aAAa;AAAA,IAC9D,UAAE;AACA,SAAG,OAAO,UAAU,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IACtD;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.6.8-develop.
|
|
3
|
+
"version": "0.6.8-develop.7003.1.24fef49d48",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@mikro-orm/decorators": "^7.1.8",
|
|
61
61
|
"@mikro-orm/migrations": "^7.1.8",
|
|
62
62
|
"@mikro-orm/postgresql": "^7.1.8",
|
|
63
|
-
"@open-mercato/queue": "0.6.8-develop.
|
|
64
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
65
|
-
"@open-mercato/telemetry": "0.6.8-develop.
|
|
63
|
+
"@open-mercato/queue": "0.6.8-develop.7003.1.24fef49d48",
|
|
64
|
+
"@open-mercato/shared": "0.6.8-develop.7003.1.24fef49d48",
|
|
65
|
+
"@open-mercato/telemetry": "0.6.8-develop.7003.1.24fef49d48",
|
|
66
66
|
"cross-spawn": "^7.0.6",
|
|
67
67
|
"pg": "8.22.0",
|
|
68
68
|
"semver": "^7.8.5",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"typescript-js": "npm:typescript@6.0.3"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
76
|
+
"@open-mercato/shared": "0.6.8-develop.7003.1.24fef49d48"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
79
|
+
"@open-mercato/shared": "0.6.8-develop.7003.1.24fef49d48",
|
|
80
80
|
"@types/jest": "^30.0.0",
|
|
81
81
|
"jest": "^30.4.2",
|
|
82
82
|
"ts-jest": "^29.4.12"
|
|
@@ -295,6 +295,15 @@ test.describe('TC-INT-008: CLI agentic init mirrors standalone scaffolding asset
|
|
|
295
295
|
ensureCliBuilt()
|
|
296
296
|
})
|
|
297
297
|
|
|
298
|
+
// dist/ is published, so a staging tree the build forgot to swap in would ship with the package —
|
|
299
|
+
// and a surviving agentic.previous would mean the swap never completed (#5104). beforeAll has run
|
|
300
|
+
// the real build, so this asserts the state a completed build leaves behind.
|
|
301
|
+
test('should leave no staging artifacts behind in dist', () => {
|
|
302
|
+
for (const leftover of ['agentic.staging', 'agentic.previous']) {
|
|
303
|
+
expect(fs.existsSync(path.join(cliDir, 'dist', leftover))).toBe(false)
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
|
|
298
307
|
test('should run bootstrap-free and generate the shared, guide, and tool-specific agentic files', () => {
|
|
299
308
|
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-cli-agentic-'))
|
|
300
309
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
const packageRoot = path.resolve(__dirname, '..', '..', '..')
|
|
5
|
+
const distDir = path.join(packageRoot, 'dist')
|
|
6
|
+
|
|
7
|
+
// build.mjs publishes dist/agentic by assembling dist/agentic.staging and swapping it in with two
|
|
8
|
+
// renames (#5104). dist/ ships with the package, so a staging tree the build forgot to swap in would
|
|
9
|
+
// be published, and a surviving dist/agentic.previous would mean the swap never completed. The same
|
|
10
|
+
// invariant is asserted from the Playwright side in __integration__/TC-INT-008.spec.ts, but CI's
|
|
11
|
+
// integration scope skips that suite for a diff confined to packages/cli/**, which is exactly the
|
|
12
|
+
// diff that can break the build script — so the guard also lives here, in the jest suite the
|
|
13
|
+
// affected-package filter always runs for such a diff.
|
|
14
|
+
//
|
|
15
|
+
// The cli `test` script is plain jest and never builds first, so an unbuilt package skips instead of
|
|
16
|
+
// failing a clean local checkout. CI's test job downloads the build-artifacts that prepare's
|
|
17
|
+
// `yarn build:packages` produced, so packages/cli/dist is present there and the assertion always
|
|
18
|
+
// runs against the tree the package would publish.
|
|
19
|
+
const describeBuiltPackage = fs.existsSync(distDir) ? describe : describe.skip
|
|
20
|
+
|
|
21
|
+
describeBuiltPackage('cli build artifacts', () => {
|
|
22
|
+
it.each(['agentic.staging', 'agentic.previous'])(
|
|
23
|
+
'leaves no dist/%s behind after a completed build',
|
|
24
|
+
(leftover) => {
|
|
25
|
+
expect(fs.existsSync(path.join(distDir, leftover))).toBe(false)
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
})
|