-
Notifications
You must be signed in to change notification settings - Fork 0
fix(routes): review follow-ups from #147/#150 #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises'; | |
| import { join } from 'node:path'; | ||
|
|
||
| import { UsageError, type TargetName } from './options.ts'; | ||
| import { runtimeSpecForFramework } from './framework.ts'; | ||
| import { validatedRuntimeSpecForFramework } from './framework.ts'; | ||
|
|
||
| /** | ||
| * The literal project name every template is written under. Templates stay | ||
|
|
@@ -55,16 +55,20 @@ interface TemplateManifest { | |
| name?: string; | ||
| } | ||
|
|
||
| const rewriteManifest = (contents: string, request: ScaffoldRequest): string => { | ||
| const rewriteManifest = async (contents: string, request: ScaffoldRequest): Promise<string> => { | ||
| const manifest = JSON.parse(contents) as TemplateManifest; | ||
| manifest.name = request.packageName; | ||
| let runtimeSpec: string | undefined; | ||
| for (const section of [manifest.dependencies, manifest.devDependencies]) { | ||
| if (section === undefined) continue; | ||
| for (const [dependency, range] of Object.entries(section)) { | ||
| if (range !== 'workspace:*') continue; | ||
| section[dependency] = dependency === '@agent-bundle/runtime' | ||
| ? runtimeSpecForFramework(request.frameworkSpec) | ||
| : request.frameworkSpec; | ||
| if (dependency === '@agent-bundle/runtime') { | ||
| runtimeSpec ??= await validatedRuntimeSpecForFramework(request.frameworkSpec); | ||
| section[dependency] = runtimeSpec; | ||
| } else { | ||
| section[dependency] = request.frameworkSpec; | ||
| } | ||
| } | ||
| } | ||
| return `${JSON.stringify(manifest, null, 2)}\n`; | ||
|
|
@@ -97,7 +101,7 @@ export const scaffold = async (request: ScaffoldRequest): Promise<readonly strin | |
| continue; | ||
| } | ||
| let contents = (await readFile(source, 'utf8')).replaceAll(placeholderName, request.pluginName); | ||
| if (relativePath === 'package.json') contents = rewriteManifest(contents, request); | ||
| if (relativePath === 'package.json') contents = await rewriteManifest(contents, request); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an MCP template uses a missing or mismatched runtime tarball, this newly awaited validation throws only while Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (relativePath === 'agent-bundle.config.ts') contents = rewriteConfigTargets(contents, request.targets); | ||
| await writeFile(destination, contents); | ||
| emitted.push(relativePath); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
mcp-servertemplate, any explicit--framework-versionother than the exact pkg.pr.new URL or narrowly namedfile:tarball now reaches this throw, including0.1.0and ordinary npm-compatible URLs. Those inputs remain explicitly advertised by bothhelpTextand the package README, and they worked before this commit by reusing the selected spec for the runtime dependency. Either retain support by deriving/configuring the runtime spec or narrow the public option documentation and validation before scaffolding.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #199 (merged as 954a44b). Registry versions, ranges, tags, and npm-compatible URLs are accepted again: any spec that isn't a pkg.pr.new preview URL or
file:tarball is mirrored onto@agent-bundle/runtime, restoring the advertised pre-regression pairing behavior. The UsageError message now documents all accepted forms.