frontmcp 1.3.0 → 1.4.1
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/README.md +38 -29
- package/package.json +10 -12
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js +1 -0
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js.map +1 -1
- package/src/commands/build/exec/runner-script.js +16 -4
- package/src/commands/build/exec/runner-script.js.map +1 -1
- package/src/commands/dev/dev.d.ts +16 -0
- package/src/commands/dev/dev.js +35 -1
- package/src/commands/dev/dev.js.map +1 -1
- package/src/commands/scaffold/create.js +8 -8
- package/src/commands/scaffold/create.js.map +1 -1
- package/src/core/tsconfig.d.ts +20 -0
- package/src/core/tsconfig.js +41 -2
- package/src/core/tsconfig.js.map +1 -1
package/src/core/tsconfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/core/tsconfig.ts"],"names":[],"mappings":";;;AAiCA,8BAUC;AAED,0DAQC;AAMD,wDAwBC;AAED,0BAiBC;;AAtGD,mDAA6B;AAC7B,qCAA6B;AAC7B,2CAAkE;AAErD,QAAA,yBAAyB,GAAG;IACvC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,MAAM;CAChB,CAAC;AAEE,QAAA,oBAAoB,GAAG;IAClC,eAAe,EAAE;QACf,MAAM,EAAE,iCAAyB,CAAC,MAAM;QACxC,MAAM,EAAE,iCAAyB,CAAC,MAAM;QACxC,qBAAqB,EAAE,iCAAyB,CAAC,qBAAqB;QACtE,sBAAsB,EAAE,iCAAyB,CAAC,sBAAsB;QACxE,mBAAmB,EAAE,iCAAyB,CAAC,mBAAmB;QAClE,gBAAgB,EAAE,iCAAyB,CAAC,gBAAgB;QAC5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C,+CAA+C,CAAC,CAAC;;QACjH,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IAE1E,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AACxB,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,OAAgB;IAC5C,MAAM,GAAG,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,IAAA,gBAAQ,EAAsB,YAAY,CAAC,CAAC;IAEnE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,IAAA,UAAC,EAAC,QAAQ,EAAE,6CAA6C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;QACnH,MAAM,IAAA,iBAAS,EAAC,YAAY,EAAE,4BAAoB,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,IAAA,UAAC,EAAC,OAAO,EAAE,2DAA2D,CAAC,CAAC,CAAC;QACrF,OAAO;IACT,CAAC;IAED,IAAI,MAAM,GAAG,SAAS,CAAC,4BAA2B,EAAE,QAAQ,CAAC,CAAC;IAC9D,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,IAAA,iBAAS,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,IAAA,UAAC,EAAC,OAAO,EAAE,8EAA8E,CAAC,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["import * as path from 'path';\nimport { c } from './colors';\nimport { fileExists, readJSON, writeJSON } from '@frontmcp/utils';\n\nexport const REQUIRED_DECORATOR_FIELDS = {\n target: 'es2021',\n module: 'esnext',\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n strictFunctionTypes: true,\n moduleResolution: 'node',\n} as const;\n\nexport const RECOMMENDED_TSCONFIG = {\n compilerOptions: {\n target: REQUIRED_DECORATOR_FIELDS.target,\n module: REQUIRED_DECORATOR_FIELDS.module,\n emitDecoratorMetadata: REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata,\n experimentalDecorators: REQUIRED_DECORATOR_FIELDS.experimentalDecorators,\n strictFunctionTypes: REQUIRED_DECORATOR_FIELDS.strictFunctionTypes,\n moduleResolution: REQUIRED_DECORATOR_FIELDS.moduleResolution,\n strict: true,\n esModuleInterop: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n outDir: 'dist',\n rootDir: 'src',\n types: ['node', '@types/jest', '@frontmcp/testing'],\n },\n include: ['src/**/*'],\n} as const;\n\nexport function deepMerge<T extends Record<string, any>, U extends Record<string, any>>(base: T, patch: U): T & U {\n const out: Record<string, any> = { ...base };\n for (const [k, v] of Object.entries(patch)) {\n if (v && typeof v === 'object' && !Array.isArray(v)) {\n out[k] = deepMerge(base[k] ?? {}, v as Record<string, any>);\n } else {\n out[k] = v;\n }\n }\n return out as T & U;\n}\n\nexport function ensureRequiredTsOptions(obj: Record<string, any>): Record<string, any> {\n const next = { ...obj };\n next.compilerOptions = { ...(next.compilerOptions || {}) };\n next.compilerOptions.target = REQUIRED_DECORATOR_FIELDS.target;\n next.compilerOptions.module = REQUIRED_DECORATOR_FIELDS.module;\n next.compilerOptions.emitDecoratorMetadata = REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata;\n next.compilerOptions.experimentalDecorators = REQUIRED_DECORATOR_FIELDS.experimentalDecorators;\n return next;\n}\n\nfunction normalizeStr(x: unknown): string | undefined {\n return typeof x === 'string' ? x.toLowerCase() : undefined;\n}\n\nexport function checkRequiredTsOptions(compilerOptions: Record<string, any> | undefined) {\n const issues: string[] = [];\n const ok: string[] = [];\n\n const target = normalizeStr(compilerOptions?.target);\n const moduleVal = normalizeStr(compilerOptions?.module);\n const edm = compilerOptions?.emitDecoratorMetadata;\n const ed = compilerOptions?.experimentalDecorators;\n\n if (target === REQUIRED_DECORATOR_FIELDS.target)\n ok.push(`compilerOptions.target = \"${REQUIRED_DECORATOR_FIELDS.target}\"`);\n else issues.push(`compilerOptions.target should be \"${REQUIRED_DECORATOR_FIELDS.target}\"`);\n\n if (moduleVal === REQUIRED_DECORATOR_FIELDS.module)\n ok.push(`compilerOptions.module = \"${REQUIRED_DECORATOR_FIELDS.module}\"`);\n else issues.push(`compilerOptions.module should be \"${REQUIRED_DECORATOR_FIELDS.module}\"`);\n\n if (edm === REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata) ok.push(`compilerOptions.emitDecoratorMetadata = true`);\n else issues.push(`compilerOptions.emitDecoratorMetadata should be true`);\n\n if (ed === REQUIRED_DECORATOR_FIELDS.experimentalDecorators) ok.push(`compilerOptions.experimentalDecorators = true`);\n else issues.push(`compilerOptions.experimentalDecorators should be true`);\n\n return { ok, issues };\n}\n\nexport async function runInit(baseDir?: string): Promise<void> {\n const cwd = baseDir ?? process.cwd();\n const tsconfigPath = path.join(cwd, 'tsconfig.json');\n const existing = await readJSON<Record<string, any>>(tsconfigPath);\n\n if (!existing) {\n console.log(c('yellow', `tsconfig.json not found — creating one in ${path.relative(process.cwd(), cwd) || '.'}.`));\n await writeJSON(tsconfigPath, RECOMMENDED_TSCONFIG);\n console.log(c('green', '✅ Created tsconfig.json with required decorator settings.'));\n return;\n }\n\n let merged = deepMerge(RECOMMENDED_TSCONFIG as any, existing);\n merged = ensureRequiredTsOptions(merged);\n\n await writeJSON(tsconfigPath, merged);\n console.log(c('green', '✅ tsconfig.json verified and updated (required decorator settings enforced).'));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/core/tsconfig.ts"],"names":[],"mappings":";;;AA6CA,8BAUC;AAED,0DAQC;AASD,oDAiBC;AAMD,wDAwBC;AAED,0BA8BC;;AAzJD,mDAA6B;AAE7B,2CAAkE;A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;IAEzC,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1F,MAAM,GAAG,kBAAkB,CAAC;IAE5B,MAAM,IAAA,iBAAS,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,IAAA,UAAC,EAAC,OAAO,EAAE,8EAA8E,CAAC,CAAC,CAAC;IACxG,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CACT,IAAA,UAAC,EACC,MAAM,EACN,qDAAqD,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;YACjF,sFAAsF;YACtF,8DAA8D,CACjE,CACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { fileExists, readJSON, writeJSON } from '@frontmcp/utils';\n\nimport { c } from './colors';\n\nexport const REQUIRED_DECORATOR_FIELDS = {\n target: 'es2021',\n module: 'esnext',\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n strictFunctionTypes: true,\n moduleResolution: 'node',\n} as const;\n\n/**\n * Filename suffixes for tool UI widget source files that ship to the browser.\n * These are bundled separately by `@frontmcp/uipack` (esbuild) at render time,\n * not by the server-side `tsc --noEmit` pass. We exclude them from the server\n * typecheck so widget-only TS settings (`jsx`, React types) aren't required at\n * the project level (issue #445).\n */\nexport const WIDGET_FILE_PATTERNS = ['**/*.widget.tsx', '**/*.widget.jsx'] as const;\n\nexport const RECOMMENDED_TSCONFIG = {\n compilerOptions: {\n target: REQUIRED_DECORATOR_FIELDS.target,\n module: REQUIRED_DECORATOR_FIELDS.module,\n emitDecoratorMetadata: REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata,\n experimentalDecorators: REQUIRED_DECORATOR_FIELDS.experimentalDecorators,\n strictFunctionTypes: REQUIRED_DECORATOR_FIELDS.strictFunctionTypes,\n moduleResolution: REQUIRED_DECORATOR_FIELDS.moduleResolution,\n strict: true,\n esModuleInterop: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n sourceMap: true,\n outDir: 'dist',\n rootDir: 'src',\n types: ['node', '@types/jest', '@frontmcp/testing'],\n },\n include: ['src/**/*'],\n exclude: [...WIDGET_FILE_PATTERNS],\n} as const;\n\nexport function deepMerge<T extends Record<string, any>, U extends Record<string, any>>(base: T, patch: U): T & U {\n const out: Record<string, any> = { ...base };\n for (const [k, v] of Object.entries(patch)) {\n if (v && typeof v === 'object' && !Array.isArray(v)) {\n out[k] = deepMerge(base[k] ?? {}, v as Record<string, any>);\n } else {\n out[k] = v;\n }\n }\n return out as T & U;\n}\n\nexport function ensureRequiredTsOptions(obj: Record<string, any>): Record<string, any> {\n const next = { ...obj };\n next.compilerOptions = { ...(next.compilerOptions || {}) };\n next.compilerOptions.target = REQUIRED_DECORATOR_FIELDS.target;\n next.compilerOptions.module = REQUIRED_DECORATOR_FIELDS.module;\n next.compilerOptions.emitDecoratorMetadata = REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata;\n next.compilerOptions.experimentalDecorators = REQUIRED_DECORATOR_FIELDS.experimentalDecorators;\n return next;\n}\n\n/**\n * Ensure `tsconfig.exclude` contains the widget-file glob patterns so server\n * typecheck skips browser-side `.widget.tsx` / `.widget.jsx` files (issue #445).\n *\n * Preserves any existing exclude entries. Returns a new object — does not\n * mutate `obj`.\n */\nexport function ensureWidgetExcludes(obj: Record<string, unknown>): {\n result: Record<string, unknown>;\n added: string[];\n} {\n const next: Record<string, unknown> = { ...obj };\n const rawExclude = next['exclude'];\n const existing: unknown[] = Array.isArray(rawExclude) ? rawExclude : [];\n const seen = new Set(existing.filter((v): v is string => typeof v === 'string'));\n const added: string[] = [];\n for (const pattern of WIDGET_FILE_PATTERNS) {\n if (!seen.has(pattern)) {\n seen.add(pattern);\n added.push(pattern);\n }\n }\n next['exclude'] = [...existing.filter((v): v is string => typeof v === 'string'), ...added];\n return { result: next, added };\n}\n\nfunction normalizeStr(x: unknown): string | undefined {\n return typeof x === 'string' ? x.toLowerCase() : undefined;\n}\n\nexport function checkRequiredTsOptions(compilerOptions: Record<string, any> | undefined) {\n const issues: string[] = [];\n const ok: string[] = [];\n\n const target = normalizeStr(compilerOptions?.target);\n const moduleVal = normalizeStr(compilerOptions?.module);\n const edm = compilerOptions?.emitDecoratorMetadata;\n const ed = compilerOptions?.experimentalDecorators;\n\n if (target === REQUIRED_DECORATOR_FIELDS.target)\n ok.push(`compilerOptions.target = \"${REQUIRED_DECORATOR_FIELDS.target}\"`);\n else issues.push(`compilerOptions.target should be \"${REQUIRED_DECORATOR_FIELDS.target}\"`);\n\n if (moduleVal === REQUIRED_DECORATOR_FIELDS.module)\n ok.push(`compilerOptions.module = \"${REQUIRED_DECORATOR_FIELDS.module}\"`);\n else issues.push(`compilerOptions.module should be \"${REQUIRED_DECORATOR_FIELDS.module}\"`);\n\n if (edm === REQUIRED_DECORATOR_FIELDS.emitDecoratorMetadata) ok.push(`compilerOptions.emitDecoratorMetadata = true`);\n else issues.push(`compilerOptions.emitDecoratorMetadata should be true`);\n\n if (ed === REQUIRED_DECORATOR_FIELDS.experimentalDecorators) ok.push(`compilerOptions.experimentalDecorators = true`);\n else issues.push(`compilerOptions.experimentalDecorators should be true`);\n\n return { ok, issues };\n}\n\nexport async function runInit(baseDir?: string): Promise<void> {\n const cwd = baseDir ?? process.cwd();\n const tsconfigPath = path.join(cwd, 'tsconfig.json');\n const existing = await readJSON<Record<string, any>>(tsconfigPath);\n\n if (!existing) {\n console.log(c('yellow', `tsconfig.json not found — creating one in ${path.relative(process.cwd(), cwd) || '.'}.`));\n await writeJSON(tsconfigPath, RECOMMENDED_TSCONFIG);\n console.log(c('green', '✅ Created tsconfig.json with required decorator settings.'));\n return;\n }\n\n let merged = deepMerge(RECOMMENDED_TSCONFIG as any, existing);\n merged = ensureRequiredTsOptions(merged);\n\n const { result: withWidgetExcludes, added: addedExcludes } = ensureWidgetExcludes(merged);\n merged = withWidgetExcludes;\n\n await writeJSON(tsconfigPath, merged);\n console.log(c('green', '✅ tsconfig.json verified and updated (required decorator settings enforced).'));\n if (addedExcludes.length > 0) {\n console.log(\n c(\n 'gray',\n ` Added widget-file excludes to tsconfig.exclude (${addedExcludes.join(', ')}) — ` +\n `'.widget.tsx' / '.widget.jsx' files are bundled separately by uipack at render time ` +\n `and don't need to satisfy the server typecheck (issue #445).`,\n ),\n );\n }\n}\n"]}
|