diff --git a/apps/web/src/chat/deployable-package.test.ts b/apps/web/src/chat/deployable-package.test.ts index b995608e7..5a8a3f127 100644 --- a/apps/web/src/chat/deployable-package.test.ts +++ b/apps/web/src/chat/deployable-package.test.ts @@ -30,6 +30,13 @@ describe("deployablePackageFromBody", () => { expect(result?.strippedBody).toBe("Here is the package:\n\nPress Deploy."); }); + test("reads a bare filename on the fence's first line", () => { + const body = + `\`\`\`json\npackage.json\n${PACKAGE_JSON}\n\`\`\`\n\n` + + `\`\`\`json\ndefinition.json\n${DEFINITION_JSON}\n\`\`\``; + expect(deployablePackageFromBody(body)?.pkg.name).toBe("Echo"); + }); + test("is null when only one of the two files is present", () => { const body = `package.json\n\`\`\`\n${PACKAGE_JSON}\n\`\`\``; expect(deployablePackageFromBody(body)).toBeNull(); diff --git a/apps/web/src/chat/deployable-package.ts b/apps/web/src/chat/deployable-package.ts index bdbf1167b..83465637f 100644 --- a/apps/web/src/chat/deployable-package.ts +++ b/apps/web/src/chat/deployable-package.ts @@ -119,17 +119,14 @@ function findNamedFencedBlocks(lines: readonly string[]): Map content.trim() !== ""); - const first = contentLines[firstContent] ?? ""; - if (/^\s*(\/\/|#)/.test(first)) { - const fromComment = namedFile(first); - if (fromComment !== null) { - name = fromComment; - contentLines.splice(0, firstContent + 1); - } + const fromFirstLine = namedFile(contentLines[firstContent] ?? ""); + if (fromFirstLine !== null) { + name = fromFirstLine; + contentLines.splice(0, firstContent + 1); } } if (name !== null && !found.has(name)) {