@open-mercato/cli 0.6.8-develop.6931.1.4a1e1c786b → 0.6.8-develop.6940.1.177ea30c6e
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 +65 -1
- package/build.mjs +57 -7
- package/dist/agentic/guides/backend-ui.md +7 -1
- package/dist/agentic/guides/module-facts.json +565 -224
- package/dist/agentic/guides/module-facts.v2.json +122933 -0
- package/dist/agentic/guides/modules/ai_assistant.md +2 -2
- package/dist/agentic/guides/modules/api_docs.md +2 -2
- package/dist/agentic/guides/modules/api_keys.md +2 -2
- package/dist/agentic/guides/modules/attachments.md +2 -2
- package/dist/agentic/guides/modules/audit_logs.md +2 -2
- package/dist/agentic/guides/modules/auth.md +2 -2
- package/dist/agentic/guides/modules/business_rules.md +2 -2
- package/dist/agentic/guides/modules/catalog.md +11 -4
- package/dist/agentic/guides/modules/channel_gmail.md +2 -2
- package/dist/agentic/guides/modules/channel_imap.md +2 -2
- package/dist/agentic/guides/modules/checkout.md +8 -2
- package/dist/agentic/guides/modules/communication_channels.md +6 -6
- package/dist/agentic/guides/modules/configs.md +2 -2
- package/dist/agentic/guides/modules/content.md +2 -2
- package/dist/agentic/guides/modules/currencies.md +2 -2
- package/dist/agentic/guides/modules/customer_accounts.md +2 -2
- package/dist/agentic/guides/modules/customers.md +8 -8
- package/dist/agentic/guides/modules/dashboards.md +12 -12
- package/dist/agentic/guides/modules/data_sync.md +4 -4
- package/dist/agentic/guides/modules/design_system.md +2 -2
- package/dist/agentic/guides/modules/dictionaries.md +2 -2
- package/dist/agentic/guides/modules/directory.md +2 -2
- package/dist/agentic/guides/modules/entities.md +3 -3
- package/dist/agentic/guides/modules/eudr.md +3 -3
- package/dist/agentic/guides/modules/events.md +2 -2
- package/dist/agentic/guides/modules/feature_toggles.md +2 -2
- package/dist/agentic/guides/modules/gateway_stripe.md +2 -2
- package/dist/agentic/guides/modules/generators.md +2 -2
- package/dist/agentic/guides/modules/inbox_ops.md +2 -2
- package/dist/agentic/guides/modules/integrations.md +5 -2
- package/dist/agentic/guides/modules/messages.md +2 -2
- package/dist/agentic/guides/modules/notifications.md +2 -2
- package/dist/agentic/guides/modules/onboarding.md +2 -2
- package/dist/agentic/guides/modules/payment_gateways.md +7 -3
- package/dist/agentic/guides/modules/perspectives.md +2 -2
- package/dist/agentic/guides/modules/planner.md +2 -2
- package/dist/agentic/guides/modules/portal.md +2 -2
- package/dist/agentic/guides/modules/progress.md +2 -2
- package/dist/agentic/guides/modules/query_index.md +2 -2
- package/dist/agentic/guides/modules/record_locks.md +3 -3
- package/dist/agentic/guides/modules/resources.md +2 -2
- package/dist/agentic/guides/modules/sales.md +13 -4
- package/dist/agentic/guides/modules/scheduler.md +2 -2
- package/dist/agentic/guides/modules/search.md +4 -4
- package/dist/agentic/guides/modules/security.md +3 -3
- package/dist/agentic/guides/modules/shipping_carriers.md +2 -2
- package/dist/agentic/guides/modules/sso.md +2 -2
- package/dist/agentic/guides/modules/staff.md +7 -4
- package/dist/agentic/guides/modules/storage_s3.md +2 -2
- package/dist/agentic/guides/modules/sync_akeneo.md +4 -4
- package/dist/agentic/guides/modules/sync_excel.md +2 -2
- package/dist/agentic/guides/modules/system_status_overlays.md +2 -2
- package/dist/agentic/guides/modules/translations.md +2 -2
- package/dist/agentic/guides/modules/webhooks.md +2 -2
- package/dist/agentic/guides/modules/wms.md +31 -4
- package/dist/agentic/guides/modules/workflows.md +2 -2
- package/dist/agentic/guides/reference-module-facts.json +8335 -0
- package/dist/agentic/guides/reference-modules/example.md +489 -0
- package/dist/agentic/guides/spec-delivery.md +34 -0
- package/dist/agentic/guides/testing-debugging.md +2 -1
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +3 -2
- package/dist/agentic/guides/upstream/manifest.json +2 -2
- package/dist/agentic/shared/AGENTS.md.template +10 -14
- package/dist/agentic/shared/ai/harness/README.md +4 -4
- package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
- package/dist/agentic/shared/ai/harness/cases.json +11350 -5088
- package/dist/agentic/shared/ai/harness/cases.schema.json +70 -7
- package/dist/agentic/shared/ai/harness/design-system-inventory.json +6697 -0
- package/dist/agentic/shared/ai/harness/fixtures/index.json +3 -1
- package/dist/agentic/shared/ai/harness/fixtures/seeds.json +4 -0
- package/dist/agentic/shared/ai/harness/knowledge-change.schema.json +228 -0
- package/dist/agentic/shared/ai/harness/release-matrix.json +9 -4
- package/dist/agentic/shared/ai/harness/result.schema.json +60 -0
- package/dist/agentic/shared/ai/harness/routing-response.schema.json +10 -0
- package/dist/agentic/shared/ai/harness/source-link-inventory.json +3231 -0
- package/dist/agentic/shared/ai/harness/validators.json +8 -4
- package/dist/agentic/shared/ai/harness/writable-ast-oracles.mjs +5 -2
- package/dist/agentic/shared/ai/harness/writable-behavior-oracles.mjs +3 -0
- package/dist/agentic/shared/ai/harness/writable-spec-oracles.mjs +879 -0
- package/dist/agentic/shared/ai/skills/om-auto-upgrade-0.6.7-to-0.7.0/SKILL.md +102 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/crud-surfaces.md +15 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/frontend-and-design-system.md +6 -0
- package/dist/agentic/shared/ai/skills/om-backend-ui-design/references/page-and-navigation.md +4 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/integrity-and-concurrency.md +2 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/migration-workflow.md +2 -0
- package/dist/agentic/shared/ai/skills/om-data-model-design/references/schema-design.md +3 -1
- package/dist/agentic/shared/ai/skills/om-eject-and-customize/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-eject-and-customize/references/decision-and-procedure.md +2 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/SKILL.md +2 -0
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-template.md +3 -3
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/case-workflow.md +1 -1
- package/dist/agentic/shared/ai/skills/om-evolve-harness/references/knowledge-change.md +133 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-integration-builder/references/provider-families.md +11 -0
- package/dist/agentic/shared/ai/skills/om-judge-agent-session/references/judge-workflow.md +1 -1
- package/dist/agentic/shared/ai/skills/om-module-scaffold/SKILL.md +2 -2
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/api-and-domain.md +14 -1
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/data-and-migrations.md +2 -0
- package/dist/agentic/shared/ai/skills/om-module-scaffold/references/module-surfaces.md +19 -0
- package/dist/agentic/shared/ai/skills/om-share-this-session/scripts/prepare-share-bundle.mjs +1 -4
- package/dist/agentic/shared/ai/skills/om-system-extension/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/extension-branches.md +24 -0
- package/dist/agentic/shared/ai/skills/om-system-extension/references/unified-overrides.md +3 -1
- package/dist/agentic/shared/ai/skills/om-troubleshooter/SKILL.md +1 -0
- package/dist/agentic/shared/ai/skills/om-troubleshooter/references/diagnosis-map.md +13 -0
- package/dist/agentic/shared/ai/skills/tiers.json +2 -1
- package/dist/agentic/shared/ai/specs/2026-08-06-reference-module-activation.md +248 -0
- package/dist/agentic/shared/scripts/agent-harness-tool-server.mjs +39 -2
- package/dist/agentic/shared/scripts/design-source-contract.mjs +108 -0
- package/dist/agentic/shared/scripts/evaluate-agent-harness.mjs +935 -28
- package/dist/agentic/shared/scripts/framework-context.mjs +4 -1
- package/dist/agentic/shared/scripts/run-agent-harness-release.mjs +1 -1
- package/dist/agentic/shared/scripts/validate-knowledge-change.mjs +1511 -0
- package/dist/lib/__integration__/TC-INT-008.spec.js +1 -0
- package/dist/lib/__integration__/TC-INT-008.spec.js.map +2 -2
- package/dist/lib/agentic-setup.js +9 -1
- package/dist/lib/agentic-setup.js.map +2 -2
- package/dist/lib/generators/module-extension-facts.js +93 -26
- package/dist/lib/generators/module-extension-facts.js.map +3 -3
- package/dist/lib/generators/module-facts-discovery.js +23 -0
- package/dist/lib/generators/module-facts-discovery.js.map +2 -2
- package/dist/lib/generators/module-facts.js +969 -41
- package/dist/lib/generators/module-facts.js.map +2 -2
- package/dist/lib/generators/module-override-targets.js +35 -11
- package/dist/lib/generators/module-override-targets.js.map +2 -2
- package/dist/lib/generators/module-registry.js +105 -2
- package/dist/lib/generators/module-registry.js.map +2 -2
- package/dist/lib/resolver.js +5 -0
- package/dist/lib/resolver.js.map +2 -2
- package/dist/lib/testing/integration-discovery.js +34 -0
- package/dist/lib/testing/integration-discovery.js.map +2 -2
- package/dist/lib/testing/integration.js +0 -2
- package/dist/lib/testing/integration.js.map +2 -2
- package/dist/mercato.js +4 -4
- package/dist/mercato.js.map +2 -2
- package/package.json +6 -6
- package/src/lib/__integration__/TC-INT-008.spec.ts +4 -2
- package/src/lib/__tests__/resolve-environment.test.ts +18 -0
- package/src/lib/agentic-setup.ts +10 -2
- package/src/lib/generators/__tests__/helpers/override-target-diagnostic-fixtures.ts +150 -0
- package/src/lib/generators/__tests__/module-extension-facts.test.ts +290 -0
- package/src/lib/generators/__tests__/module-facts.bc-guard.test.ts +72 -7
- package/src/lib/generators/__tests__/module-facts.computed-di-token.test.ts +88 -0
- package/src/lib/generators/__tests__/module-facts.example-fact-coverage.test.ts +502 -0
- package/src/lib/generators/__tests__/module-facts.local-reference.test.ts +414 -0
- package/src/lib/generators/__tests__/module-facts.search-entity-id.test.ts +151 -0
- package/src/lib/generators/__tests__/module-facts.source-links.test.ts +42 -1
- package/src/lib/generators/__tests__/module-override-targets.diagnostic-wiring.test.ts +92 -0
- package/src/lib/generators/__tests__/module-override-targets.test.ts +24 -0
- package/src/lib/generators/__tests__/module-override-targets.unknown-mode.test.ts +117 -0
- package/src/lib/generators/__tests__/module-subset.test.ts +60 -0
- package/src/lib/generators/module-extension-facts.ts +181 -25
- package/src/lib/generators/module-facts-discovery.ts +46 -0
- package/src/lib/generators/module-facts.ts +1330 -86
- package/src/lib/generators/module-override-targets.ts +70 -26
- package/src/lib/generators/module-registry.ts +135 -2
- package/src/lib/resolver.ts +6 -1
- package/src/lib/testing/__tests__/integration-discovery.test.ts +35 -0
- package/src/lib/testing/integration-discovery.ts +50 -0
- package/src/lib/testing/integration.ts +0 -2
- package/src/mercato.ts +3 -3
|
@@ -209,6 +209,7 @@ function expectedGuideOutputNames() {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
collected.add("module-facts.json");
|
|
212
|
+
collected.add("module-facts.v2.json");
|
|
212
213
|
collected.add("framework-extension-points.md");
|
|
213
214
|
collected.add("upstream/AGENTS.md");
|
|
214
215
|
collected.add("upstream/BACKWARD_COMPATIBILITY.md");
|
|
@@ -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): 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 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 {\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) && !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 module-facts.json sidecar is copied as-is and fact-sheets are filtered to the\n // fixture's enabled modules. The legacy 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('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 collected.add(normalizePath(path.join('modules', `${moduleId}.md`)))\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/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>.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('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,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;AACnD,MAAM,cAAc,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,cAAc,QAAQ,cAAc,GAAG,MAAM,CAAC,EAAE;AACzG,MAAM,0BAA0B,oBAAI,IAAI,CAAC,SAAS,QAAQ,UAAU,SAAS,UAAU,UAAU,IAAI,CAAC;AAKtG,MAAM,0BAA0B,CAAC,aAAa,OAAO;AAErD,SAAS,cAAc,OAAuB;AAC5C,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;AAEA,SAAS,WAAW,SAAiB,MAAgB,KAAa,MAAyB,CAAC,GAAW;AAC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IAAI,GAAG,WAAW,IAAI,UAAU,KAAK;AAAA,MACjD;AAAA,IACF;AAAA,EACF;
|
|
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): 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 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 {\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) && !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 module-facts.json and corrected module-facts.v2.json sidecars are copied\n // as-is and 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('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 collected.add(normalizePath(path.join('modules', `${moduleId}.md`)))\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/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>.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('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,IAAI;AACrE,MAAM,SAAS,KAAK,KAAK,UAAU,YAAY,KAAK;AACpD,MAAM,SAAS,KAAK,KA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join(targetDir, "scripts"))
|
|
302
302
|
]);
|
|
303
303
|
for (const file of readdirSync(GUIDES_DIR)) {
|
|
304
|
-
if (file.endsWith(".md") || file === "module-facts.json"
|
|
304
|
+
if (file.endsWith(".md") || file === "module-facts.json" || file === "module-facts.v2.json") {
|
|
305
|
+
paths.add(join(targetDir, ".ai", "guides", file));
|
|
306
|
+
}
|
|
305
307
|
}
|
|
306
308
|
for (const file of listFiles(join(GUIDES_DIR, "upstream"))) {
|
|
307
309
|
paths.add(join(targetDir, ".ai", "guides", "upstream", relative(join(GUIDES_DIR, "upstream"), file)));
|
|
@@ -445,6 +447,12 @@ function generateShared(config) {
|
|
|
445
447
|
ensureDir(destPath);
|
|
446
448
|
copyFileSync(moduleFactsPath, destPath);
|
|
447
449
|
}
|
|
450
|
+
const moduleFactsV2Path = join(GUIDES_DIR, "module-facts.v2.json");
|
|
451
|
+
if (existsSync(moduleFactsV2Path)) {
|
|
452
|
+
const destPath = join(guidesDestDir, "module-facts.v2.json");
|
|
453
|
+
ensureDir(destPath);
|
|
454
|
+
copyFileSync(moduleFactsV2Path, destPath);
|
|
455
|
+
}
|
|
448
456
|
copyTree(join(GUIDES_DIR, "upstream"), join(guidesDestDir, "upstream"), config);
|
|
449
457
|
const modulesSubdir = join(GUIDES_DIR, "modules");
|
|
450
458
|
for (const moduleId of selectedModules) {
|
|
@@ -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 {\n chmodSync,\n copyFileSync,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n realpathSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { spawnSync } from 'node:child_process'\nimport { tmpdir } from 'node:os'\nimport { join, dirname, basename, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { Project, SyntaxKind } from 'ts-morph'\n\nconst moduleDir = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), moduleDir is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst bundledAgenticDir = join(moduleDir, '..', 'agentic')\nconst AGENTIC_DIR = existsSync(bundledAgenticDir)\n ? bundledAgenticDir\n : join(moduleDir, '..', '..', '..', 'create-app', '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 updateHarness?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\ninterface HarnessManifestFile {\n path: string\n sha256: string\n source: string\n userEditable: boolean\n}\n\ninterface HarnessManifest {\n version: number\n generator: string\n files: HarnessManifestFile[]\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): { parsed: boolean; ids: string[] } {\n if (!existsSync(modulesPath)) return { parsed: false, ids: [] }\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 { parsed: false, ids: [] }\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 { parsed: true, ids }\n } catch {\n return { parsed: false, ids: [] }\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 parsed = readEnabledModuleIds(join(targetDir, 'src', 'modules.ts'))\n if (!parsed.parsed) return available\n const enabled = new Set(parsed.ids)\n const selected = available.filter((moduleId) => enabled.has(moduleId))\n return selected\n}\n\nconst MODULE_GUIDES_START = '<!-- om:module-guides:start -->'\nconst MODULE_GUIDES_END = '<!-- om:module-guides:end -->'\n\n// The generated standalone root must stay well under Codex's 32 KiB\n// project_doc_max_bytes so a routed chain (root + guide + skill) still fits.\nexport const STANDALONE_ROOT_TARGET_BYTES = 12 * 1024\n\nexport type ModuleGuidesRenderOptions = {\n // Emit the O(1) pointer form instead of enumerating every id. The inline index\n // is the better prompt, so callers only ask for this when the enumerated one\n // would push the root past its byte target.\n compact?: boolean\n}\n\nexport function renderModuleGuidesBlock(\n selected: string[],\n options: ModuleGuidesRenderOptions = {},\n): string {\n if (selected.length === 0) return '_No module fact-sheets are bundled for this app._'\n const index = options.compact\n ? `Enabled module facts: ${selected.length} sheets bundled, too many to index inline \u2014 list the module facts directory to see which modules have one.`\n : `Enabled module facts: ${selected.map((moduleId) => `\\`${moduleId}\\``).join(',')}.`\n return [\n index,\n '',\n 'Load `.ai/guides/modules/<id>.md` only for a named or targeted installed module/host; never preload all module facts.',\n ].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 options: ModuleGuidesRenderOptions = {},\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, options)}\\n${after}`\n if (next !== content) writeFileSync(agentsMdPath, next)\n}\n\n// Last step of harness generation: every tool generator has finished patching\n// AGENTS.md, so this is the only point where the final root size is known. The\n// enumerated module index is the one block that grows with the app, so it is\n// also the one that sheds bytes when the root would otherwise blow its target.\nexport function enforceRootInstructionBudget(\n agentsMdPath: string,\n selected: string[],\n maxBytes: number = STANDALONE_ROOT_TARGET_BYTES,\n): boolean {\n if (!existsSync(agentsMdPath)) return false\n if (Buffer.byteLength(readFileSync(agentsMdPath)) <= maxBytes) return false\n injectModuleGuides(agentsMdPath, selected, { compact: true })\n return true\n}\n\nconst TEXT_EXTENSIONS = new Set(['.cjs', '.json', '.md', '.mdc', '.mjs', '.sh', '.ts', '.txt'])\n\nfunction isTextAsset(path: string): boolean {\n const dot = path.lastIndexOf('.')\n return dot === -1 || TEXT_EXTENSIONS.has(path.slice(dot))\n}\n\nfunction listFiles(root: string): string[] {\n if (!existsSync(root)) return []\n const files: string[] = []\n for (const entry of readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n const absolute = join(root, entry.name)\n if (entry.isDirectory()) files.push(...listFiles(absolute))\n else if (entry.isFile()) files.push(absolute)\n }\n return files\n}\n\nfunction copyTree(sourceRoot: string, destinationRoot: string, config: AgenticConfig): void {\n for (const sourcePath of listFiles(sourceRoot)) {\n const destinationPath = join(destinationRoot, relative(sourceRoot, sourcePath))\n ensureDir(destinationPath)\n if (isTextAsset(sourcePath)) {\n writeFileSync(destinationPath, resolvePlaceholders(readFileSync(sourcePath, 'utf8'), config))\n } else {\n copyFileSync(sourcePath, destinationPath)\n }\n if (process.platform !== 'win32') chmodSync(destinationPath, statSync(sourcePath).mode & 0o777)\n }\n}\n\nfunction hashFile(path: string): string {\n return createHash('sha256').update(readFileSync(path)).digest('hex')\n}\n\nfunction canonicalHarnessRoot(root: string): string {\n const resolved = resolve(root)\n if (!existsSync(resolved)) {\n throw new Error(`Harness root must be an existing directory: ${resolved}`)\n }\n const canonical = realpathSync(resolved)\n const entry = lstatSync(canonical, { throwIfNoEntry: false })\n if (!entry || !entry.isDirectory()) {\n throw new Error(`Harness root must be an existing directory: ${resolved}`)\n }\n return canonical\n}\n\n/**\n * Validate a managed path without following any link below the canonical app\n * root. A lexical containment check alone is insufficient: `app/.ai -> /tmp`\n * would otherwise make an apparently safe update write outside the app.\n */\nfunction assertManagedPath(root: string, path: string, options: { leaf?: 'file' | 'any' } = {}): void {\n const absolutePath = resolve(path)\n const normalizedRelative = relative(root, absolutePath)\n if (\n normalizedRelative === '..' ||\n normalizedRelative.startsWith(`..${sep}`)\n ) {\n throw new Error(`Harness-managed path escapes its root: ${absolutePath}`)\n }\n if (normalizedRelative === '') return\n\n const components = normalizedRelative.split(sep).filter(Boolean)\n let current = root\n for (let index = 0; index < components.length; index += 1) {\n current = join(current, components[index])\n const entry = lstatSync(current, { throwIfNoEntry: false })\n if (!entry) return\n if (entry.isSymbolicLink()) {\n throw new Error(`Harness-managed path contains a symbolic-link component: ${current}`)\n }\n const isLeaf = index === components.length - 1\n if (!isLeaf && !entry.isDirectory()) {\n throw new Error(`Harness-managed path component is not a directory: ${current}`)\n }\n if (isLeaf && options.leaf === 'file' && !entry.isFile()) {\n throw new Error(`Harness-managed file is not a regular file: ${current}`)\n }\n }\n}\n\nfunction ensureManagedParent(root: string, filePath: string): void {\n const parent = dirname(filePath)\n const normalizedRelative = relative(root, parent)\n if (normalizedRelative === '..' || normalizedRelative.startsWith(`..${sep}`)) {\n throw new Error(`Harness-managed path escapes its root: ${filePath}`)\n }\n let current = root\n for (const component of normalizedRelative.split(sep).filter(Boolean)) {\n assertManagedPath(root, current)\n current = join(current, component)\n const entry = lstatSync(current, { throwIfNoEntry: false })\n if (!entry) mkdirSync(current)\n const created = lstatSync(current, { throwIfNoEntry: false })\n if (!created || created.isSymbolicLink() || !created.isDirectory()) {\n throw new Error(`Harness-managed path component is not a real directory: ${current}`)\n }\n }\n}\n\nfunction harnessGeneratorId(): string {\n try {\n const upstream = JSON.parse(readFileSync(join(GUIDES_DIR, 'upstream', 'manifest.json'), 'utf8')) as {\n generator?: unknown\n }\n const generator = typeof upstream.generator === 'string' ? upstream.generator : ''\n const version = generator.slice(generator.lastIndexOf('@') + 1)\n if (version && version !== generator) return `open-mercato-agentic@${version}`\n } catch {\n // Source-mode tests may not have built upstream snapshots yet.\n }\n return 'open-mercato-agentic@unknown'\n}\n\nfunction externalSkillNames(targetDir: string): Set<string> {\n try {\n const tiers = JSON.parse(readFileSync(join(targetDir, '.ai', 'skills', 'tiers.json'), 'utf8')) as {\n external?: { skills?: unknown }\n }\n return new Set(Array.isArray(tiers.external?.skills) ? tiers.external.skills.filter((name): name is string => typeof name === 'string') : [])\n } catch {\n return new Set()\n }\n}\n\nfunction atomicCopyFile(sourcePath: string, destinationPath: string, managedRoot?: string): void {\n if (managedRoot) {\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n ensureManagedParent(managedRoot, destinationPath)\n } else {\n ensureDir(destinationPath)\n }\n const temporaryPath = `${destinationPath}.tmp-${process.pid}-${Date.now()}`\n try {\n if (managedRoot) assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n copyFileSync(sourcePath, temporaryPath)\n if (process.platform !== 'win32') chmodSync(temporaryPath, statSync(sourcePath).mode & 0o777)\n if (managedRoot) {\n assertManagedPath(managedRoot, dirname(destinationPath))\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n }\n renameSync(temporaryPath, destinationPath)\n } finally {\n if (!managedRoot || !lstatSync(temporaryPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n rmSync(temporaryPath, { force: true })\n }\n }\n}\n\nfunction atomicWriteFile(destinationPath: string, content: string, managedRoot?: string): void {\n if (managedRoot) {\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n ensureManagedParent(managedRoot, destinationPath)\n } else {\n ensureDir(destinationPath)\n }\n const temporaryPath = `${destinationPath}.tmp-${process.pid}-${Date.now()}`\n try {\n if (managedRoot) assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n writeFileSync(temporaryPath, content)\n if (managedRoot) {\n assertManagedPath(managedRoot, dirname(destinationPath))\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n }\n renameSync(temporaryPath, destinationPath)\n } finally {\n if (!managedRoot || !lstatSync(temporaryPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n rmSync(temporaryPath, { force: true })\n }\n }\n}\n\nfunction resolveManifestPath(root: string, relativePath: string): string | null {\n if (!relativePath || relativePath.includes('\\0')) return null\n const absolutePath = resolve(root, relativePath)\n const normalizedRelative = relative(root, absolutePath)\n if (\n normalizedRelative === '' ||\n normalizedRelative === '..' ||\n normalizedRelative.startsWith(`..${sep}`)\n ) {\n return null\n }\n return absolutePath\n}\n\nfunction normalizeManifestRelativePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nfunction readHarnessManifest(manifestPath: string): HarnessManifest | null {\n if (!existsSync(manifestPath)) return null\n try {\n const parsed = JSON.parse(readFileSync(manifestPath, 'utf8')) as Partial<HarnessManifest>\n if (\n typeof parsed.version !== 'number' ||\n typeof parsed.generator !== 'string' ||\n !Array.isArray(parsed.files)\n ) {\n return null\n }\n const files: HarnessManifestFile[] = []\n for (const entry of parsed.files) {\n if (\n !entry ||\n typeof entry.path !== 'string' ||\n typeof entry.sha256 !== 'string' ||\n !/^[a-f0-9]{64}$/.test(entry.sha256) ||\n typeof entry.source !== 'string' ||\n typeof entry.userEditable !== 'boolean'\n ) {\n return null\n }\n files.push({ ...entry, path: normalizeManifestRelativePath(entry.path) })\n }\n return { version: parsed.version, generator: parsed.generator, files }\n } catch {\n return null\n }\n}\n\nfunction targetPathsForTree(sourceRoot: string, destinationRoot: string): string[] {\n return listFiles(sourceRoot).map((sourcePath) => join(destinationRoot, relative(sourceRoot, sourcePath)))\n}\n\nfunction finalizeHarnessManifest(config: AgenticConfig, selectedTools: string[]): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n const paths = new Set<string>([\n join(targetDir, 'AGENTS.md'),\n ...targetPathsForTree(join(srcDir, 'ai'), join(targetDir, '.ai')),\n ...targetPathsForTree(join(srcDir, 'scripts'), join(targetDir, 'scripts')),\n ])\n for (const file of readdirSync(GUIDES_DIR)) {\n if (file.endsWith('.md') || file === 'module-facts.json') paths.add(join(targetDir, '.ai', 'guides', file))\n }\n for (const file of listFiles(join(GUIDES_DIR, 'upstream'))) {\n paths.add(join(targetDir, '.ai', 'guides', 'upstream', relative(join(GUIDES_DIR, 'upstream'), file)))\n }\n for (const moduleId of selectedModules) paths.add(join(targetDir, '.ai', 'guides', 'modules', `${moduleId}.md`))\n if (selectedTools.includes('claude-code')) {\n paths.add(join(targetDir, 'CLAUDE.md'))\n paths.add(join(targetDir, '.claude', 'settings.json'))\n paths.add(join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n paths.add(join(targetDir, '.mcp.json.example'))\n }\n if (selectedTools.includes('codex')) paths.add(join(targetDir, '.codex', 'mcp.json.example'))\n if (selectedTools.includes('cursor')) {\n for (const file of listFiles(join(AGENTIC_DIR, 'cursor'))) {\n const rel = relative(join(AGENTIC_DIR, 'cursor'), file)\n paths.add(join(targetDir, '.cursor', rel))\n }\n }\n const manifestPath = join(targetDir, '.ai', 'harness', 'manifest.json')\n const externalSkills = externalSkillNames(targetDir)\n paths.delete(manifestPath)\n const files = [...paths]\n .filter((path) => existsSync(path))\n .sort((left, right) => left.localeCompare(right))\n .map((path) => {\n const relativePath = normalizeManifestRelativePath(relative(targetDir, path))\n const skillName = relativePath.match(/^\\.ai\\/skills\\/([^/]+)\\//)?.[1]\n return {\n path: relativePath,\n sha256: hashFile(path),\n source: skillName ? (externalSkills.has(skillName) ? 'external-override' : 'local-skill') : 'generated',\n userEditable:\n relativePath === 'AGENTS.md'\n || relativePath === '.ai/agentic.config.json'\n || relativePath === '.ai/lessons.md'\n || relativePath.startsWith('.ai/lessons/'),\n }\n })\n atomicWriteFile(\n manifestPath,\n `${JSON.stringify({ version: 1, generator: harnessGeneratorId(), files }, null, 2)}\\n`,\n )\n}\n\n/**\n * Publish a fully generated harness candidate using the previous ownership\n * manifest as the only source of ownership. Modified owned files and exact-path\n * collisions with unknown files stay untouched; their candidate is written next\n * to them as `<path>.incoming` for explicit review.\n */\nexport type HarnessUpdateConflict = { path: string; candidate: string | null }\n\nfunction preserveIncomingCandidate(\n targetRoot: string,\n destinationPath: string,\n sourcePath: string,\n relativePath: string,\n): string {\n for (let suffix = 1; ; suffix += 1) {\n const label = suffix === 1 ? '.incoming' : `.incoming.${suffix}`\n const candidatePath = `${destinationPath}${label}`\n assertManagedPath(targetRoot, candidatePath, { leaf: 'file' })\n if (!existsSync(candidatePath)) {\n atomicCopyFile(sourcePath, candidatePath, targetRoot)\n return `${relativePath}${label}`\n }\n if (hashFile(candidatePath) === hashFile(sourcePath)) return `${relativePath}${label}`\n }\n}\n\nexport function applyHarnessUpdate(\n targetDir: string,\n stagingDir: string,\n options: { force?: boolean } = {},\n): HarnessUpdateConflict[] {\n const targetRoot = canonicalHarnessRoot(targetDir)\n const stagingRoot = canonicalHarnessRoot(stagingDir)\n const targetManifestPath = join(targetRoot, '.ai', 'harness', 'manifest.json')\n const stagingManifestPath = join(stagingRoot, '.ai', 'harness', 'manifest.json')\n assertManagedPath(targetRoot, targetManifestPath, { leaf: 'file' })\n assertManagedPath(stagingRoot, stagingManifestPath, { leaf: 'file' })\n const candidateManifest = readHarnessManifest(stagingManifestPath)\n if (!candidateManifest) {\n throw new Error('Generated harness candidate has a missing or invalid ownership manifest.')\n }\n\n const previousManifest = readHarnessManifest(targetManifestPath)\n const previousFiles = new Map(previousManifest?.files.map((entry) => [entry.path, entry]) ?? [])\n const candidatePaths = new Set(candidateManifest.files.map((entry) => entry.path))\n const candidates: Array<{\n entry: HarnessManifestFile\n sourcePath: string\n destinationPath: string\n }> = []\n\n // Validate the complete candidate before writing anything into the app.\n for (const entry of candidateManifest.files) {\n const sourcePath = resolveManifestPath(stagingRoot, entry.path)\n const destinationPath = resolveManifestPath(targetRoot, entry.path)\n if (sourcePath) assertManagedPath(stagingRoot, sourcePath, { leaf: 'file' })\n if (destinationPath) assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n if (!sourcePath || !destinationPath || !existsSync(sourcePath) || hashFile(sourcePath) !== entry.sha256) {\n throw new Error(`Generated harness candidate is invalid for ${JSON.stringify(entry.path)}.`)\n }\n candidates.push({ entry, sourcePath, destinationPath })\n }\n\n const conflicts: HarnessUpdateConflict[] = []\n for (const { entry, sourcePath, destinationPath } of candidates) {\n if (options.force) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n if (!existsSync(destinationPath)) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n\n const currentHash = hashFile(destinationPath)\n const previousEntry = previousFiles.get(entry.path)\n if (currentHash === entry.sha256 || (previousEntry && currentHash === previousEntry.sha256)) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n\n const candidate = preserveIncomingCandidate(targetRoot, destinationPath, sourcePath, entry.path)\n conflicts.push({ path: entry.path, candidate })\n }\n\n const retainedRetiredEntries: HarnessManifestFile[] = []\n for (const previousEntry of previousManifest?.files ?? []) {\n if (candidatePaths.has(previousEntry.path)) continue\n const destinationPath = resolveManifestPath(targetRoot, previousEntry.path)\n if (!destinationPath || !existsSync(destinationPath)) continue\n assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n let unchanged = false\n try {\n unchanged = hashFile(destinationPath) === previousEntry.sha256\n } catch {\n // A user may replace a generated file with another filesystem object.\n // Preserve it and retain the ownership tombstone for a later review.\n }\n if (unchanged) {\n assertManagedPath(targetRoot, dirname(destinationPath))\n assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n rmSync(destinationPath, { force: true })\n } else {\n retainedRetiredEntries.push(previousEntry)\n conflicts.push({ path: previousEntry.path, candidate: null })\n }\n }\n\n // The candidate hashes deliberately remain in the manifest for conflicts. If\n // the user accepts an .incoming file, a later update can recognize it as an\n // unmodified owned file. Until then the hash mismatch keeps preserving it.\n const finalManifest: HarnessManifest = {\n ...candidateManifest,\n files: [...candidateManifest.files, ...retainedRetiredEntries],\n }\n atomicWriteFile(targetManifestPath, `${JSON.stringify(finalManifest, null, 2)}\\n`, targetRoot)\n return conflicts\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\n // One recursive mapping mirrors create-app's shared emitter.\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n copyTree(join(srcDir, 'ai'), join(targetDir, '.ai'), config)\n copyTree(join(srcDir, 'scripts'), join(targetDir, 'scripts'), config)\n\n // Routed 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\n copyTree(join(GUIDES_DIR, 'upstream'), join(guidesDestDir, 'upstream'), config)\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 injectModuleGuides(join(targetDir, 'AGENTS.md'), selectedModules)\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 // The installer exclusively owns Claude's per-skill compatibility links.\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 // No .codex/skills directory: Codex reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\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 // No .cursor/skills directory: Cursor reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\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\nfunction persistedAgentSelection(targetDir: string): string[] | null {\n const selectableIds = SELECTABLE.map((tool) => tool.id)\n const tiersPath = join(targetDir, '.ai', 'skills', 'tiers.json')\n try {\n const tiers = JSON.parse(readFileSync(tiersPath, 'utf8')) as { agents?: { ignore?: unknown } }\n if (Array.isArray(tiers.agents?.ignore)\n && tiers.agents.ignore.every((id): id is string => typeof id === 'string')) {\n const ignored = new Set(tiers.agents.ignore)\n return selectableIds.filter((id) => !ignored.has(id))\n }\n } catch {\n // Fall through to the ownership manifest and existing generated assets.\n }\n\n const manifest = readHarnessManifest(join(targetDir, '.ai', 'harness', 'manifest.json'))\n const owned = new Set(manifest?.files.map((entry) => entry.path) ?? [])\n const selected = SELECTABLE.filter((tool) => {\n if (tool.id === 'claude-code') {\n return owned.has('CLAUDE.md') || owned.has('.claude/settings.json')\n || existsSync(join(targetDir, 'CLAUDE.md')) || existsSync(join(targetDir, '.claude', 'settings.json'))\n }\n if (tool.id === 'codex') {\n return owned.has('.codex/mcp.json.example') || existsSync(join(targetDir, '.codex', 'mcp.json.example'))\n }\n return owned.has('.cursor/hooks.json') || existsSync(join(targetDir, '.cursor', 'hooks.json'))\n }).map((tool) => tool.id)\n return selected.length > 0 ? selected : null\n}\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 if (options?.updateHarness) {\n selectedIds = persistedAgentSelection(targetDir) ?? await promptSelection(ask)\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 const stagingDir = mkdtempSync(join(tmpdir(), 'open-mercato-harness-'))\n try {\n const modulesSourcePath = join(targetDir, 'src', 'modules.ts')\n const modulesCandidatePath = join(stagingDir, 'src', 'modules.ts')\n if (existsSync(modulesSourcePath)) {\n ensureDir(modulesCandidatePath)\n copyFileSync(modulesSourcePath, modulesCandidatePath)\n }\n\n const stagingConfig: AgenticConfig = {\n projectName: config.projectName,\n targetDir: stagingDir,\n }\n generateHarness(stagingConfig, selectedIds)\n const conflicts = applyHarnessUpdate(targetDir, stagingDir, {\n force: options?.force,\n })\n if (conflicts.length > 0) {\n console.warn('')\n console.warn(' \u26A0 Preserved locally modified harness files:')\n for (const conflict of conflicts) {\n const detail = conflict.candidate\n ? `candidate: ${conflict.candidate}`\n : 'retired asset kept because it has local changes'\n console.warn(` \u2022 ${conflict.path} (${detail})`)\n }\n }\n } finally {\n rmSync(stagingDir, { recursive: true, force: true })\n }\n\n installSkills(targetDir)\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 console.log(' .ai/agentic.config.json ships preconfigured (GitHub tracker, labels off);')\n console.log(' run /om-setup-agent-pipeline in your agent CLI to tailor labels, QA gate,')\n console.log(' tracker, or validation commands. Re-run `yarn install-skills` anytime to')\n console.log(' refresh the external open-mercato/skills subset.')\n console.log('')\n}\n\nfunction generateHarness(config: AgenticConfig, selectedIds: string[]): void {\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 enforceGeneratedRootBudget(config)\n\n persistAgentSelection(config.targetDir, selectedIds)\n finalizeHarnessManifest(config, selectedIds)\n}\n\n/** Run after every tool generator has patched AGENTS.md, before the manifest is hashed. */\nfunction enforceGeneratedRootBudget(\n config: AgenticConfig,\n maxBytes: number = STANDALONE_ROOT_TARGET_BYTES,\n): boolean {\n const { targetDir } = config\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n return enforceRootInstructionBudget(join(targetDir, 'AGENTS.md'), selectedModules, maxBytes)\n}\n\n/**\n * Persist the agent selection so later `yarn install-skills` runs keep honoring\n * it: agents the user did not pick go into `agents.ignore` in tiers.json and\n * never get a skills directory of their own.\n */\nfunction persistAgentSelection(targetDir: string, selectedIds: string[]): void {\n const manifestPath = join(targetDir, '.ai', 'skills', 'tiers.json')\n if (!existsSync(manifestPath)) return\n const ignore = SELECTABLE.map((tool) => tool.id).filter((id) => !selectedIds.includes(id))\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as Record<string, unknown>\n if (ignore.length > 0) {\n manifest.agents = { ignore }\n } else {\n delete manifest.agents\n }\n writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\nfunction installSkills(targetDir: string): void {\n const installScript = join(targetDir, 'scripts', 'install-skills.mjs')\n if (!existsSync(installScript)) return\n console.log('')\n console.log(' Installing agent skills (local tiers + external open-mercato/skills subset)...')\n const result = spawnSync(process.execPath, [installScript], {\n cwd: targetDir,\n stdio: 'inherit',\n env: { ...process.env, OM_SKILLS_OUTPUT_INDENT: '3' },\n })\n if (result.error || result.status !== 0) {\n console.log(' \u26A0 Skill installation did not complete; run `yarn install-skills` inside the app when online.')\n }\n}\n"],
|
|
5
|
-
"mappings": "AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,MAAM,SAAS,UAAU,UAAU,SAAS,WAAW;AAChE,SAAS,qBAAqB;AAC9B,SAAS,SAAS,kBAAkB;AAEpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,oBAAoB,KAAK,WAAW,MAAM,SAAS;AACzD,MAAM,cAAc,WAAW,iBAAiB,IAC5C,oBACA,KAAK,WAAW,MAAM,MAAM,MAAM,cAAc,SAAS;AAC7D,MAAM,aAAa,KAAK,aAAa,QA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AAC7F;AAOA,SAAS,sBAAsB,WAAmB,aAA6B;AAC7E,QAAM,eAAe,KAAK,WAAW,OAAO,UAAU,YAAY;AAClE,MAAI,CAAC,WAAW,YAAY,EAAG;AAC/B,QAAM,SAAS,WAAW,IAAI,CAAC,SAAS,KAAK,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,SAAS,EAAE,CAAC;AACzF,QAAM,WAAW,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;AAC/D,MAAI,OAAO,SAAS,GAAG;AACrB,aAAS,SAAS,EAAE,OAAO;AAAA,EAC7B,OAAO;AACL,WAAO,SAAS;AAAA,EAClB;AACA,gBAAc,cAAc,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA,CAAI;AACtE;AAEA,SAAS,cAAc,WAAyB;AAC9C,QAAM,gBAAgB,KAAK,WAAW,WAAW,oBAAoB;AACrE,MAAI,CAAC,WAAW,aAAa,EAAG;AAChC,UAAQ,IAAI,EAAE;AACd,UAAQ,IAAI,mFAAmF;AAC/F,QAAM,SAAS,UAAU,QAAQ,UAAU,CAAC,aAAa,GAAG;AAAA,IAC1D,KAAK;AAAA,IACL,OAAO;AAAA,IACP,KAAK,EAAE,GAAG,QAAQ,KAAK,yBAAyB,IAAI;AAAA,EACtD,CAAC;AACD,MAAI,OAAO,SAAS,OAAO,WAAW,GAAG;AACvC,YAAQ,IAAI,sGAAiG;AAAA,EAC/G;AACF;",
|
|
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 {\n chmodSync,\n copyFileSync,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n realpathSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { spawnSync } from 'node:child_process'\nimport { tmpdir } from 'node:os'\nimport { join, dirname, basename, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { Project, SyntaxKind } from 'ts-morph'\n\nconst moduleDir = dirname(fileURLToPath(import.meta.url))\n// In the built output (dist/lib/agentic-setup.js), moduleDir is dist/lib/.\n// agentic/ is copied to dist/agentic/ by build.mjs.\nconst bundledAgenticDir = join(moduleDir, '..', 'agentic')\nconst AGENTIC_DIR = existsSync(bundledAgenticDir)\n ? bundledAgenticDir\n : join(moduleDir, '..', '..', '..', 'create-app', '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 updateHarness?: boolean\n}\n\ninterface AgenticConfig {\n projectName: string\n targetDir: string\n}\n\ninterface HarnessManifestFile {\n path: string\n sha256: string\n source: string\n userEditable: boolean\n}\n\ninterface HarnessManifest {\n version: number\n generator: string\n files: HarnessManifestFile[]\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): { parsed: boolean; ids: string[] } {\n if (!existsSync(modulesPath)) return { parsed: false, ids: [] }\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 { parsed: false, ids: [] }\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 { parsed: true, ids }\n } catch {\n return { parsed: false, ids: [] }\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 parsed = readEnabledModuleIds(join(targetDir, 'src', 'modules.ts'))\n if (!parsed.parsed) return available\n const enabled = new Set(parsed.ids)\n const selected = available.filter((moduleId) => enabled.has(moduleId))\n return selected\n}\n\nconst MODULE_GUIDES_START = '<!-- om:module-guides:start -->'\nconst MODULE_GUIDES_END = '<!-- om:module-guides:end -->'\n\n// The generated standalone root must stay well under Codex's 32 KiB\n// project_doc_max_bytes so a routed chain (root + guide + skill) still fits.\nexport const STANDALONE_ROOT_TARGET_BYTES = 12 * 1024\n\nexport type ModuleGuidesRenderOptions = {\n // Emit the O(1) pointer form instead of enumerating every id. The inline index\n // is the better prompt, so callers only ask for this when the enumerated one\n // would push the root past its byte target.\n compact?: boolean\n}\n\nexport function renderModuleGuidesBlock(\n selected: string[],\n options: ModuleGuidesRenderOptions = {},\n): string {\n if (selected.length === 0) return '_No module fact-sheets are bundled for this app._'\n const index = options.compact\n ? `Enabled module facts: ${selected.length} sheets bundled, too many to index inline \u2014 list the module facts directory to see which modules have one.`\n : `Enabled module facts: ${selected.map((moduleId) => `\\`${moduleId}\\``).join(',')}.`\n return [\n index,\n '',\n 'Load `.ai/guides/modules/<id>.md` only for a named or targeted installed module/host; never preload all module facts.',\n ].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 options: ModuleGuidesRenderOptions = {},\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, options)}\\n${after}`\n if (next !== content) writeFileSync(agentsMdPath, next)\n}\n\n// Last step of harness generation: every tool generator has finished patching\n// AGENTS.md, so this is the only point where the final root size is known. The\n// enumerated module index is the one block that grows with the app, so it is\n// also the one that sheds bytes when the root would otherwise blow its target.\nexport function enforceRootInstructionBudget(\n agentsMdPath: string,\n selected: string[],\n maxBytes: number = STANDALONE_ROOT_TARGET_BYTES,\n): boolean {\n if (!existsSync(agentsMdPath)) return false\n if (Buffer.byteLength(readFileSync(agentsMdPath)) <= maxBytes) return false\n injectModuleGuides(agentsMdPath, selected, { compact: true })\n return true\n}\n\nconst TEXT_EXTENSIONS = new Set(['.cjs', '.json', '.md', '.mdc', '.mjs', '.sh', '.ts', '.txt'])\n\nfunction isTextAsset(path: string): boolean {\n const dot = path.lastIndexOf('.')\n return dot === -1 || TEXT_EXTENSIONS.has(path.slice(dot))\n}\n\nfunction listFiles(root: string): string[] {\n if (!existsSync(root)) return []\n const files: string[] = []\n for (const entry of readdirSync(root, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {\n const absolute = join(root, entry.name)\n if (entry.isDirectory()) files.push(...listFiles(absolute))\n else if (entry.isFile()) files.push(absolute)\n }\n return files\n}\n\nfunction copyTree(sourceRoot: string, destinationRoot: string, config: AgenticConfig): void {\n for (const sourcePath of listFiles(sourceRoot)) {\n const destinationPath = join(destinationRoot, relative(sourceRoot, sourcePath))\n ensureDir(destinationPath)\n if (isTextAsset(sourcePath)) {\n writeFileSync(destinationPath, resolvePlaceholders(readFileSync(sourcePath, 'utf8'), config))\n } else {\n copyFileSync(sourcePath, destinationPath)\n }\n if (process.platform !== 'win32') chmodSync(destinationPath, statSync(sourcePath).mode & 0o777)\n }\n}\n\nfunction hashFile(path: string): string {\n return createHash('sha256').update(readFileSync(path)).digest('hex')\n}\n\nfunction canonicalHarnessRoot(root: string): string {\n const resolved = resolve(root)\n if (!existsSync(resolved)) {\n throw new Error(`Harness root must be an existing directory: ${resolved}`)\n }\n const canonical = realpathSync(resolved)\n const entry = lstatSync(canonical, { throwIfNoEntry: false })\n if (!entry || !entry.isDirectory()) {\n throw new Error(`Harness root must be an existing directory: ${resolved}`)\n }\n return canonical\n}\n\n/**\n * Validate a managed path without following any link below the canonical app\n * root. A lexical containment check alone is insufficient: `app/.ai -> /tmp`\n * would otherwise make an apparently safe update write outside the app.\n */\nfunction assertManagedPath(root: string, path: string, options: { leaf?: 'file' | 'any' } = {}): void {\n const absolutePath = resolve(path)\n const normalizedRelative = relative(root, absolutePath)\n if (\n normalizedRelative === '..' ||\n normalizedRelative.startsWith(`..${sep}`)\n ) {\n throw new Error(`Harness-managed path escapes its root: ${absolutePath}`)\n }\n if (normalizedRelative === '') return\n\n const components = normalizedRelative.split(sep).filter(Boolean)\n let current = root\n for (let index = 0; index < components.length; index += 1) {\n current = join(current, components[index])\n const entry = lstatSync(current, { throwIfNoEntry: false })\n if (!entry) return\n if (entry.isSymbolicLink()) {\n throw new Error(`Harness-managed path contains a symbolic-link component: ${current}`)\n }\n const isLeaf = index === components.length - 1\n if (!isLeaf && !entry.isDirectory()) {\n throw new Error(`Harness-managed path component is not a directory: ${current}`)\n }\n if (isLeaf && options.leaf === 'file' && !entry.isFile()) {\n throw new Error(`Harness-managed file is not a regular file: ${current}`)\n }\n }\n}\n\nfunction ensureManagedParent(root: string, filePath: string): void {\n const parent = dirname(filePath)\n const normalizedRelative = relative(root, parent)\n if (normalizedRelative === '..' || normalizedRelative.startsWith(`..${sep}`)) {\n throw new Error(`Harness-managed path escapes its root: ${filePath}`)\n }\n let current = root\n for (const component of normalizedRelative.split(sep).filter(Boolean)) {\n assertManagedPath(root, current)\n current = join(current, component)\n const entry = lstatSync(current, { throwIfNoEntry: false })\n if (!entry) mkdirSync(current)\n const created = lstatSync(current, { throwIfNoEntry: false })\n if (!created || created.isSymbolicLink() || !created.isDirectory()) {\n throw new Error(`Harness-managed path component is not a real directory: ${current}`)\n }\n }\n}\n\nfunction harnessGeneratorId(): string {\n try {\n const upstream = JSON.parse(readFileSync(join(GUIDES_DIR, 'upstream', 'manifest.json'), 'utf8')) as {\n generator?: unknown\n }\n const generator = typeof upstream.generator === 'string' ? upstream.generator : ''\n const version = generator.slice(generator.lastIndexOf('@') + 1)\n if (version && version !== generator) return `open-mercato-agentic@${version}`\n } catch {\n // Source-mode tests may not have built upstream snapshots yet.\n }\n return 'open-mercato-agentic@unknown'\n}\n\nfunction externalSkillNames(targetDir: string): Set<string> {\n try {\n const tiers = JSON.parse(readFileSync(join(targetDir, '.ai', 'skills', 'tiers.json'), 'utf8')) as {\n external?: { skills?: unknown }\n }\n return new Set(Array.isArray(tiers.external?.skills) ? tiers.external.skills.filter((name): name is string => typeof name === 'string') : [])\n } catch {\n return new Set()\n }\n}\n\nfunction atomicCopyFile(sourcePath: string, destinationPath: string, managedRoot?: string): void {\n if (managedRoot) {\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n ensureManagedParent(managedRoot, destinationPath)\n } else {\n ensureDir(destinationPath)\n }\n const temporaryPath = `${destinationPath}.tmp-${process.pid}-${Date.now()}`\n try {\n if (managedRoot) assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n copyFileSync(sourcePath, temporaryPath)\n if (process.platform !== 'win32') chmodSync(temporaryPath, statSync(sourcePath).mode & 0o777)\n if (managedRoot) {\n assertManagedPath(managedRoot, dirname(destinationPath))\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n }\n renameSync(temporaryPath, destinationPath)\n } finally {\n if (!managedRoot || !lstatSync(temporaryPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n rmSync(temporaryPath, { force: true })\n }\n }\n}\n\nfunction atomicWriteFile(destinationPath: string, content: string, managedRoot?: string): void {\n if (managedRoot) {\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n ensureManagedParent(managedRoot, destinationPath)\n } else {\n ensureDir(destinationPath)\n }\n const temporaryPath = `${destinationPath}.tmp-${process.pid}-${Date.now()}`\n try {\n if (managedRoot) assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n writeFileSync(temporaryPath, content)\n if (managedRoot) {\n assertManagedPath(managedRoot, dirname(destinationPath))\n assertManagedPath(managedRoot, destinationPath, { leaf: 'file' })\n assertManagedPath(managedRoot, temporaryPath, { leaf: 'file' })\n }\n renameSync(temporaryPath, destinationPath)\n } finally {\n if (!managedRoot || !lstatSync(temporaryPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n rmSync(temporaryPath, { force: true })\n }\n }\n}\n\nfunction resolveManifestPath(root: string, relativePath: string): string | null {\n if (!relativePath || relativePath.includes('\\0')) return null\n const absolutePath = resolve(root, relativePath)\n const normalizedRelative = relative(root, absolutePath)\n if (\n normalizedRelative === '' ||\n normalizedRelative === '..' ||\n normalizedRelative.startsWith(`..${sep}`)\n ) {\n return null\n }\n return absolutePath\n}\n\nfunction normalizeManifestRelativePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nfunction readHarnessManifest(manifestPath: string): HarnessManifest | null {\n if (!existsSync(manifestPath)) return null\n try {\n const parsed = JSON.parse(readFileSync(manifestPath, 'utf8')) as Partial<HarnessManifest>\n if (\n typeof parsed.version !== 'number' ||\n typeof parsed.generator !== 'string' ||\n !Array.isArray(parsed.files)\n ) {\n return null\n }\n const files: HarnessManifestFile[] = []\n for (const entry of parsed.files) {\n if (\n !entry ||\n typeof entry.path !== 'string' ||\n typeof entry.sha256 !== 'string' ||\n !/^[a-f0-9]{64}$/.test(entry.sha256) ||\n typeof entry.source !== 'string' ||\n typeof entry.userEditable !== 'boolean'\n ) {\n return null\n }\n files.push({ ...entry, path: normalizeManifestRelativePath(entry.path) })\n }\n return { version: parsed.version, generator: parsed.generator, files }\n } catch {\n return null\n }\n}\n\nfunction targetPathsForTree(sourceRoot: string, destinationRoot: string): string[] {\n return listFiles(sourceRoot).map((sourcePath) => join(destinationRoot, relative(sourceRoot, sourcePath)))\n}\n\nfunction finalizeHarnessManifest(config: AgenticConfig, selectedTools: string[]): void {\n const { targetDir } = config\n const srcDir = join(AGENTIC_DIR, 'shared')\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n const paths = new Set<string>([\n join(targetDir, 'AGENTS.md'),\n ...targetPathsForTree(join(srcDir, 'ai'), join(targetDir, '.ai')),\n ...targetPathsForTree(join(srcDir, 'scripts'), join(targetDir, 'scripts')),\n ])\n for (const file of readdirSync(GUIDES_DIR)) {\n if (file.endsWith('.md') || file === 'module-facts.json' || file === 'module-facts.v2.json') {\n paths.add(join(targetDir, '.ai', 'guides', file))\n }\n }\n for (const file of listFiles(join(GUIDES_DIR, 'upstream'))) {\n paths.add(join(targetDir, '.ai', 'guides', 'upstream', relative(join(GUIDES_DIR, 'upstream'), file)))\n }\n for (const moduleId of selectedModules) paths.add(join(targetDir, '.ai', 'guides', 'modules', `${moduleId}.md`))\n if (selectedTools.includes('claude-code')) {\n paths.add(join(targetDir, 'CLAUDE.md'))\n paths.add(join(targetDir, '.claude', 'settings.json'))\n paths.add(join(targetDir, '.claude', 'hooks', 'entity-migration-check.ts'))\n paths.add(join(targetDir, '.mcp.json.example'))\n }\n if (selectedTools.includes('codex')) paths.add(join(targetDir, '.codex', 'mcp.json.example'))\n if (selectedTools.includes('cursor')) {\n for (const file of listFiles(join(AGENTIC_DIR, 'cursor'))) {\n const rel = relative(join(AGENTIC_DIR, 'cursor'), file)\n paths.add(join(targetDir, '.cursor', rel))\n }\n }\n const manifestPath = join(targetDir, '.ai', 'harness', 'manifest.json')\n const externalSkills = externalSkillNames(targetDir)\n paths.delete(manifestPath)\n const files = [...paths]\n .filter((path) => existsSync(path))\n .sort((left, right) => left.localeCompare(right))\n .map((path) => {\n const relativePath = normalizeManifestRelativePath(relative(targetDir, path))\n const skillName = relativePath.match(/^\\.ai\\/skills\\/([^/]+)\\//)?.[1]\n return {\n path: relativePath,\n sha256: hashFile(path),\n source: skillName ? (externalSkills.has(skillName) ? 'external-override' : 'local-skill') : 'generated',\n userEditable:\n relativePath === 'AGENTS.md'\n || relativePath === '.ai/agentic.config.json'\n || relativePath === '.ai/lessons.md'\n || relativePath.startsWith('.ai/lessons/'),\n }\n })\n atomicWriteFile(\n manifestPath,\n `${JSON.stringify({ version: 1, generator: harnessGeneratorId(), files }, null, 2)}\\n`,\n )\n}\n\n/**\n * Publish a fully generated harness candidate using the previous ownership\n * manifest as the only source of ownership. Modified owned files and exact-path\n * collisions with unknown files stay untouched; their candidate is written next\n * to them as `<path>.incoming` for explicit review.\n */\nexport type HarnessUpdateConflict = { path: string; candidate: string | null }\n\nfunction preserveIncomingCandidate(\n targetRoot: string,\n destinationPath: string,\n sourcePath: string,\n relativePath: string,\n): string {\n for (let suffix = 1; ; suffix += 1) {\n const label = suffix === 1 ? '.incoming' : `.incoming.${suffix}`\n const candidatePath = `${destinationPath}${label}`\n assertManagedPath(targetRoot, candidatePath, { leaf: 'file' })\n if (!existsSync(candidatePath)) {\n atomicCopyFile(sourcePath, candidatePath, targetRoot)\n return `${relativePath}${label}`\n }\n if (hashFile(candidatePath) === hashFile(sourcePath)) return `${relativePath}${label}`\n }\n}\n\nexport function applyHarnessUpdate(\n targetDir: string,\n stagingDir: string,\n options: { force?: boolean } = {},\n): HarnessUpdateConflict[] {\n const targetRoot = canonicalHarnessRoot(targetDir)\n const stagingRoot = canonicalHarnessRoot(stagingDir)\n const targetManifestPath = join(targetRoot, '.ai', 'harness', 'manifest.json')\n const stagingManifestPath = join(stagingRoot, '.ai', 'harness', 'manifest.json')\n assertManagedPath(targetRoot, targetManifestPath, { leaf: 'file' })\n assertManagedPath(stagingRoot, stagingManifestPath, { leaf: 'file' })\n const candidateManifest = readHarnessManifest(stagingManifestPath)\n if (!candidateManifest) {\n throw new Error('Generated harness candidate has a missing or invalid ownership manifest.')\n }\n\n const previousManifest = readHarnessManifest(targetManifestPath)\n const previousFiles = new Map(previousManifest?.files.map((entry) => [entry.path, entry]) ?? [])\n const candidatePaths = new Set(candidateManifest.files.map((entry) => entry.path))\n const candidates: Array<{\n entry: HarnessManifestFile\n sourcePath: string\n destinationPath: string\n }> = []\n\n // Validate the complete candidate before writing anything into the app.\n for (const entry of candidateManifest.files) {\n const sourcePath = resolveManifestPath(stagingRoot, entry.path)\n const destinationPath = resolveManifestPath(targetRoot, entry.path)\n if (sourcePath) assertManagedPath(stagingRoot, sourcePath, { leaf: 'file' })\n if (destinationPath) assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n if (!sourcePath || !destinationPath || !existsSync(sourcePath) || hashFile(sourcePath) !== entry.sha256) {\n throw new Error(`Generated harness candidate is invalid for ${JSON.stringify(entry.path)}.`)\n }\n candidates.push({ entry, sourcePath, destinationPath })\n }\n\n const conflicts: HarnessUpdateConflict[] = []\n for (const { entry, sourcePath, destinationPath } of candidates) {\n if (options.force) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n if (!existsSync(destinationPath)) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n\n const currentHash = hashFile(destinationPath)\n const previousEntry = previousFiles.get(entry.path)\n if (currentHash === entry.sha256 || (previousEntry && currentHash === previousEntry.sha256)) {\n atomicCopyFile(sourcePath, destinationPath, targetRoot)\n continue\n }\n\n const candidate = preserveIncomingCandidate(targetRoot, destinationPath, sourcePath, entry.path)\n conflicts.push({ path: entry.path, candidate })\n }\n\n const retainedRetiredEntries: HarnessManifestFile[] = []\n for (const previousEntry of previousManifest?.files ?? []) {\n if (candidatePaths.has(previousEntry.path)) continue\n const destinationPath = resolveManifestPath(targetRoot, previousEntry.path)\n if (!destinationPath || !existsSync(destinationPath)) continue\n assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n let unchanged = false\n try {\n unchanged = hashFile(destinationPath) === previousEntry.sha256\n } catch {\n // A user may replace a generated file with another filesystem object.\n // Preserve it and retain the ownership tombstone for a later review.\n }\n if (unchanged) {\n assertManagedPath(targetRoot, dirname(destinationPath))\n assertManagedPath(targetRoot, destinationPath, { leaf: 'file' })\n rmSync(destinationPath, { force: true })\n } else {\n retainedRetiredEntries.push(previousEntry)\n conflicts.push({ path: previousEntry.path, candidate: null })\n }\n }\n\n // The candidate hashes deliberately remain in the manifest for conflicts. If\n // the user accepts an .incoming file, a later update can recognize it as an\n // unmodified owned file. Until then the hash mismatch keeps preserving it.\n const finalManifest: HarnessManifest = {\n ...candidateManifest,\n files: [...candidateManifest.files, ...retainedRetiredEntries],\n }\n atomicWriteFile(targetManifestPath, `${JSON.stringify(finalManifest, null, 2)}\\n`, targetRoot)\n return conflicts\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\n // One recursive mapping mirrors create-app's shared emitter.\n writeTemplate(srcDir, 'AGENTS.md.template', join(targetDir, 'AGENTS.md'), config)\n copyTree(join(srcDir, 'ai'), join(targetDir, '.ai'), config)\n copyTree(join(srcDir, 'scripts'), join(targetDir, 'scripts'), config)\n\n // Routed 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 v1 and corrected v2 module-facts sidecars are 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 moduleFactsV2Path = join(GUIDES_DIR, 'module-facts.v2.json')\n if (existsSync(moduleFactsV2Path)) {\n const destPath = join(guidesDestDir, 'module-facts.v2.json')\n ensureDir(destPath)\n copyFileSync(moduleFactsV2Path, destPath)\n }\n\n copyTree(join(GUIDES_DIR, 'upstream'), join(guidesDestDir, 'upstream'), config)\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 injectModuleGuides(join(targetDir, 'AGENTS.md'), selectedModules)\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 // The installer exclusively owns Claude's per-skill compatibility links.\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 // No .codex/skills directory: Codex reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\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 // No .cursor/skills directory: Cursor reads the canonical .agents/skills/,\n // which scripts/install-skills.sh populates.\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\nfunction persistedAgentSelection(targetDir: string): string[] | null {\n const selectableIds = SELECTABLE.map((tool) => tool.id)\n const tiersPath = join(targetDir, '.ai', 'skills', 'tiers.json')\n try {\n const tiers = JSON.parse(readFileSync(tiersPath, 'utf8')) as { agents?: { ignore?: unknown } }\n if (Array.isArray(tiers.agents?.ignore)\n && tiers.agents.ignore.every((id): id is string => typeof id === 'string')) {\n const ignored = new Set(tiers.agents.ignore)\n return selectableIds.filter((id) => !ignored.has(id))\n }\n } catch {\n // Fall through to the ownership manifest and existing generated assets.\n }\n\n const manifest = readHarnessManifest(join(targetDir, '.ai', 'harness', 'manifest.json'))\n const owned = new Set(manifest?.files.map((entry) => entry.path) ?? [])\n const selected = SELECTABLE.filter((tool) => {\n if (tool.id === 'claude-code') {\n return owned.has('CLAUDE.md') || owned.has('.claude/settings.json')\n || existsSync(join(targetDir, 'CLAUDE.md')) || existsSync(join(targetDir, '.claude', 'settings.json'))\n }\n if (tool.id === 'codex') {\n return owned.has('.codex/mcp.json.example') || existsSync(join(targetDir, '.codex', 'mcp.json.example'))\n }\n return owned.has('.cursor/hooks.json') || existsSync(join(targetDir, '.cursor', 'hooks.json'))\n }).map((tool) => tool.id)\n return selected.length > 0 ? selected : null\n}\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 if (options?.updateHarness) {\n selectedIds = persistedAgentSelection(targetDir) ?? await promptSelection(ask)\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 const stagingDir = mkdtempSync(join(tmpdir(), 'open-mercato-harness-'))\n try {\n const modulesSourcePath = join(targetDir, 'src', 'modules.ts')\n const modulesCandidatePath = join(stagingDir, 'src', 'modules.ts')\n if (existsSync(modulesSourcePath)) {\n ensureDir(modulesCandidatePath)\n copyFileSync(modulesSourcePath, modulesCandidatePath)\n }\n\n const stagingConfig: AgenticConfig = {\n projectName: config.projectName,\n targetDir: stagingDir,\n }\n generateHarness(stagingConfig, selectedIds)\n const conflicts = applyHarnessUpdate(targetDir, stagingDir, {\n force: options?.force,\n })\n if (conflicts.length > 0) {\n console.warn('')\n console.warn(' \u26A0 Preserved locally modified harness files:')\n for (const conflict of conflicts) {\n const detail = conflict.candidate\n ? `candidate: ${conflict.candidate}`\n : 'retired asset kept because it has local changes'\n console.warn(` \u2022 ${conflict.path} (${detail})`)\n }\n }\n } finally {\n rmSync(stagingDir, { recursive: true, force: true })\n }\n\n installSkills(targetDir)\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 console.log(' .ai/agentic.config.json ships preconfigured (GitHub tracker, labels off);')\n console.log(' run /om-setup-agent-pipeline in your agent CLI to tailor labels, QA gate,')\n console.log(' tracker, or validation commands. Re-run `yarn install-skills` anytime to')\n console.log(' refresh the external open-mercato/skills subset.')\n console.log('')\n}\n\nfunction generateHarness(config: AgenticConfig, selectedIds: string[]): void {\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 enforceGeneratedRootBudget(config)\n\n persistAgentSelection(config.targetDir, selectedIds)\n finalizeHarnessManifest(config, selectedIds)\n}\n\n/** Run after every tool generator has patched AGENTS.md, before the manifest is hashed. */\nfunction enforceGeneratedRootBudget(\n config: AgenticConfig,\n maxBytes: number = STANDALONE_ROOT_TARGET_BYTES,\n): boolean {\n const { targetDir } = config\n const selectedModules = selectModuleFactSheets(targetDir, join(GUIDES_DIR, 'modules'))\n return enforceRootInstructionBudget(join(targetDir, 'AGENTS.md'), selectedModules, maxBytes)\n}\n\n/**\n * Persist the agent selection so later `yarn install-skills` runs keep honoring\n * it: agents the user did not pick go into `agents.ignore` in tiers.json and\n * never get a skills directory of their own.\n */\nfunction persistAgentSelection(targetDir: string, selectedIds: string[]): void {\n const manifestPath = join(targetDir, '.ai', 'skills', 'tiers.json')\n if (!existsSync(manifestPath)) return\n const ignore = SELECTABLE.map((tool) => tool.id).filter((id) => !selectedIds.includes(id))\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8')) as Record<string, unknown>\n if (ignore.length > 0) {\n manifest.agents = { ignore }\n } else {\n delete manifest.agents\n }\n writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`)\n}\n\nfunction installSkills(targetDir: string): void {\n const installScript = join(targetDir, 'scripts', 'install-skills.mjs')\n if (!existsSync(installScript)) return\n console.log('')\n console.log(' Installing agent skills (local tiers + external open-mercato/skills subset)...')\n const result = spawnSync(process.execPath, [installScript], {\n cwd: targetDir,\n stdio: 'inherit',\n env: { ...process.env, OM_SKILLS_OUTPUT_INDENT: '3' },\n })\n if (result.error || result.status !== 0) {\n console.log(' \u26A0 Skill installation did not complete; run `yarn install-skills` inside the app when online.')\n }\n}\n"],
|
|
5
|
+
"mappings": "AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,MAAM,SAAS,UAAU,UAAU,SAAS,WAAW;AAChE,SAAS,qBAAqB;AAC9B,SAAS,SAAS,kBAAkB;AAEpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAGxD,MAAM,oBAAoB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