diff --git a/packages/bolt/app/components/editor/codemirror/languages.ts b/packages/bolt/app/components/editor/codemirror/languages.ts index 969dd2b..829221e 100644 --- a/packages/bolt/app/components/editor/codemirror/languages.ts +++ b/packages/bolt/app/components/editor/codemirror/languages.ts @@ -78,6 +78,20 @@ export const supportedLanguages = [ return import('@codemirror/lang-wast').then((module) => module.wast()); }, }), + LanguageDescription.of({ + name: 'Python', + extensions: ['py'], + async load() { + return import('@codemirror/lang-python').then((module) => module.python()); + }, + }), + LanguageDescription.of({ + name: 'C++', + extensions: ['cpp'], + async load() { + return import('@codemirror/lang-cpp').then((module) => module.cpp()); + }, + }), ]; export async function getLanguage(fileName: string) { diff --git a/packages/bolt/app/lib/.server/llm/prompts.ts b/packages/bolt/app/lib/.server/llm/prompts.ts index b193323..d53c0cd 100644 --- a/packages/bolt/app/lib/.server/llm/prompts.ts +++ b/packages/bolt/app/lib/.server/llm/prompts.ts @@ -5,7 +5,18 @@ export const getSystemPrompt = (cwd: string = WORK_DIR) => ` You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices. - You are operating in an environment called WebContainer, an in-browser Node.js runtime that emulates a Linux system to some degree. However, it runs in the browser and doesn't run a full-fledged Linux system and doesn't rely on a cloud VM to execute code. All code is executed in the browser. It does come with a shell that emulates zsh. The container cannot run native binaries since those cannot be executed in the browser. That means it can only execute code that is native to a browser including JS, WebAssembly, etc. The shell comes with a \`python\` binary but it CANNOT rely on 3rd party dependencies and doesn't have \`pip\` support nor networking support. It's LIMITED TO VANILLA Python. The assistant should keep that in mind. + You are operating in an environment called WebContainer, an in-browser Node.js runtime that emulates a Linux system to some degree. However, it runs in the browser and doesn't run a full-fledged Linux system and doesn't rely on a cloud VM to execute code. All code is executed in the browser. It does come with a shell that emulates zsh. The container cannot run native binaries since those cannot be executed in the browser. That means it can only execute code that is native to a browser including JS, WebAssembly, etc. + + The shell comes with \`python\` and \`python3\` binaries, but they are LIMITED TO THE PYTHON STANDARD LIBRARY ONLY This means: + + - There is NO \`pip\` support! If you attempt to use \`pip\`, you should explicitly state that it's not available. + - CRITICAL: Third-party libraries cannot be installed or imported. + - Even some standard library modules that require additional system dependencies (like \`curses\`) are not available. + - Only modules from the core Python standard library can be used. + + Additionally, there is no \`g++\` or any C/C++ compiler available. WebContainer CANNOT run native binaries or compile C/C++ code! + + Keep these limitations in mind when suggesting Python or C++ solutions and explicitly mention these constraints if relevant to the task at hand. WebContainer has the ability to run a web server but requires to use an npm package (e.g., Vite, servor, serve, http-server) or use the Node.js APIs to implement a web server. @@ -116,7 +127,7 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w 11. CRITICAL: Always provide the FULL, updated content of the artifact. This means: - Include ALL code, even if parts are unchanged - - NEVER use placeholders like "// rest of the code remains the same..." or "<- leave original code here ->" + - NEVER use placeholders like "// rest of the code remains the same..." or "<- leave original code here ->" - ALWAYS show the complete, up-to-date file contents when updating files - Avoid any form of truncation or summarization diff --git a/packages/bolt/package.json b/packages/bolt/package.json index 4457c17..31f0c3f 100644 --- a/packages/bolt/package.json +++ b/packages/bolt/package.json @@ -19,11 +19,13 @@ "@ai-sdk/anthropic": "^0.0.30", "@codemirror/autocomplete": "^6.17.0", "@codemirror/commands": "^6.6.0", + "@codemirror/lang-cpp": "^6.0.2", "@codemirror/lang-css": "^6.2.1", "@codemirror/lang-html": "^6.4.9", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-json": "^6.0.1", "@codemirror/lang-markdown": "^6.2.5", + "@codemirror/lang-python": "^6.1.6", "@codemirror/lang-sass": "^6.0.2", "@codemirror/lang-wast": "^6.0.2", "@codemirror/language": "^6.10.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11ad83e..29e79ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: '@codemirror/commands': specifier: ^6.6.0 version: 6.6.0 + '@codemirror/lang-cpp': + specifier: ^6.0.2 + version: 6.0.2 '@codemirror/lang-css': specifier: ^6.2.1 version: 6.2.1(@codemirror/view@6.28.4) @@ -59,6 +62,9 @@ importers: '@codemirror/lang-markdown': specifier: ^6.2.5 version: 6.2.5 + '@codemirror/lang-python': + specifier: ^6.1.6 + version: 6.1.6(@codemirror/view@6.28.4) '@codemirror/lang-sass': specifier: ^6.0.2 version: 6.0.2(@codemirror/view@6.28.4) @@ -526,6 +532,9 @@ packages: '@codemirror/commands@6.6.0': resolution: {integrity: sha512-qnY+b7j1UNcTS31Eenuc/5YJB6gQOzkUoNmJQc0rznwqSRpeaWWpjkWy2C/MPTcePpsKJEM26hXrOXl1+nceXg==} + '@codemirror/lang-cpp@6.0.2': + resolution: {integrity: sha512-6oYEYUKHvrnacXxWxYa6t4puTlbN3dgV662BDfSH8+MfjQjVmP697/KYTDOqpxgerkvoNm7q5wlFMBeX8ZMocg==} + '@codemirror/lang-css@6.2.1': resolution: {integrity: sha512-/UNWDNV5Viwi/1lpr/dIXJNWiwDxpw13I4pTUAsNxZdg6E0mI2kTQb0P2iHczg1Tu+H4EBgJR+hYhKiHKko7qg==} @@ -541,6 +550,9 @@ packages: '@codemirror/lang-markdown@6.2.5': resolution: {integrity: sha512-Hgke565YcO4fd9pe2uLYxnMufHO5rQwRr+AAhFq8ABuhkrjyX8R5p5s+hZUTdV60O0dMRjxKhBLxz8pu/MkUVA==} + '@codemirror/lang-python@6.1.6': + resolution: {integrity: sha512-ai+01WfZhWqM92UqjnvorkxosZ2aq2u28kHvr+N3gu012XqY2CThD67JPMHnGceRfXPDBmn1HnyqowdpF57bNg==} + '@codemirror/lang-sass@6.0.2': resolution: {integrity: sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==} @@ -1135,6 +1147,9 @@ packages: '@lezer/common@1.2.1': resolution: {integrity: sha512-yemX0ZD2xS/73llMZIK6KplkjIjf2EvAHcinDi/TfJ9hS25G0388+ClHt6/3but0oOxinTcQHJLDXh6w1crzFQ==} + '@lezer/cpp@1.1.2': + resolution: {integrity: sha512-macwKtyeUO0EW86r3xWQCzOV9/CF8imJLpJlPv3sDY57cPGeUZ8gXWOWNlJr52TVByMV3PayFQCA5SHEERDmVQ==} + '@lezer/css@1.1.8': resolution: {integrity: sha512-7JhxupKuMBaWQKjQoLtzhGj83DdnZY9MckEOG5+/iLKNK2ZJqKc6hf6uc0HjwCX7Qlok44jBNqZhHKDhEhZYLA==} @@ -1156,6 +1171,9 @@ packages: '@lezer/markdown@1.3.0': resolution: {integrity: sha512-ErbEQ15eowmJUyT095e9NJc3BI9yZ894fjSDtHftD0InkfUBGgnKSU6dvan9jqsZuNHg2+ag/1oyDRxNsENupQ==} + '@lezer/python@1.1.14': + resolution: {integrity: sha512-ykDOb2Ti24n76PJsSa4ZoDF0zH12BSw1LGfQXCYJhJyOGiFTfGaX0Du66Ze72R+u/P35U+O6I9m8TFXov1JzsA==} + '@lezer/sass@1.0.6': resolution: {integrity: sha512-w/RCO2dIzZH1To8p+xjs8cE+yfgGus8NZ/dXeWl/QzHyr+TeBs71qiE70KPImEwvTsmEjoWh0A5SxMzKd5BWBQ==} @@ -5469,6 +5487,11 @@ snapshots: '@codemirror/view': 6.28.4 '@lezer/common': 1.2.1 + '@codemirror/lang-cpp@6.0.2': + dependencies: + '@codemirror/language': 6.10.2 + '@lezer/cpp': 1.1.2 + '@codemirror/lang-css@6.2.1(@codemirror/view@6.28.4)': dependencies: '@codemirror/autocomplete': 6.17.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4)(@lezer/common@1.2.1) @@ -5516,6 +5539,16 @@ snapshots: '@lezer/common': 1.2.1 '@lezer/markdown': 1.3.0 + '@codemirror/lang-python@6.1.6(@codemirror/view@6.28.4)': + dependencies: + '@codemirror/autocomplete': 6.17.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.28.4)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/python': 1.1.14 + transitivePeerDependencies: + - '@codemirror/view' + '@codemirror/lang-sass@6.0.2(@codemirror/view@6.28.4)': dependencies: '@codemirror/lang-css': 6.2.1(@codemirror/view@6.28.4) @@ -5990,6 +6023,12 @@ snapshots: '@lezer/common@1.2.1': {} + '@lezer/cpp@1.1.2': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.0 + '@lezer/lr': 1.4.1 + '@lezer/css@1.1.8': dependencies: '@lezer/common': 1.2.1 @@ -6027,6 +6066,12 @@ snapshots: '@lezer/common': 1.2.1 '@lezer/highlight': 1.2.0 + '@lezer/python@1.1.14': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.0 + '@lezer/lr': 1.4.1 + '@lezer/sass@1.0.6': dependencies: '@lezer/common': 1.2.1