mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Jules was unable to complete the task in time. Please review the work done so far and provide feedback for Jules to continue.
This commit is contained in:
parent
3021d95e73
commit
ae87589ac3
@ -131,7 +131,8 @@ export const ChatImpl = memo(
|
||||
(project) => project.id === supabaseConn.selectedProjectId,
|
||||
);
|
||||
const supabaseAlert = useStore(workbenchStore.supabaseAlert);
|
||||
const { activeProviders, promptId, autoSelectTemplate, contextOptimizationEnabled } = useSettings();
|
||||
const settings = useSettings(); // Get the whole settings object
|
||||
const { activeProviders, promptId: userSelectedPromptId, autoSelectTemplate, contextOptimizationEnabled } = settings;
|
||||
|
||||
const [model, setModel] = useState(() => {
|
||||
const savedModel = Cookies.get('selectedModel');
|
||||
@ -167,7 +168,20 @@ export const ChatImpl = memo(
|
||||
body: {
|
||||
apiKeys,
|
||||
files,
|
||||
promptId,
|
||||
// Determine effectivePromptId based on model size
|
||||
promptId: (() => {
|
||||
// Placeholder logic for identifying smaller LLMs
|
||||
// TODO: Replace with a more robust way to identify smaller models (e.g., a flag in model metadata)
|
||||
const smallModelKeywords = ['haiku', 'flash', 'mini', 'small', 'lite', 'core']; // Add more as needed
|
||||
const isSmallLLM = smallModelKeywords.some(keyword => model.toLowerCase().includes(keyword));
|
||||
|
||||
if (isSmallLLM) {
|
||||
logger.info(`Using "optimized" prompt for small LLM: ${model}`);
|
||||
return "optimized";
|
||||
}
|
||||
logger.info(`Using user selected prompt: "${userSelectedPromptId}" for LLM: ${model}`);
|
||||
return userSelectedPromptId;
|
||||
})(),
|
||||
contextOptimization: contextOptimizationEnabled,
|
||||
chatMode,
|
||||
supabase: {
|
||||
|
@ -72,7 +72,8 @@ export const Markdown = memo(
|
||||
|
||||
return <CodeBlock code={firstChild.children[0].value} language={language as BundledLanguage} {...rest} />;
|
||||
}
|
||||
|
||||
// Add logging for pre tags not matching the expected structure
|
||||
logger.debug('Markdown.tsx: Encountered <pre> tag that does not conform to expected CodeBlock structure. Node:', node, 'Children:', children);
|
||||
return <pre {...rest}>{children}</pre>;
|
||||
},
|
||||
button: ({ node, children, ...props }) => {
|
||||
|
@ -260,27 +260,27 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
|
||||
6. NEVER use the word "artifact" in responses
|
||||
|
||||
## Development Process
|
||||
7. ALWAYS think and plan comprehensively before providing a solution
|
||||
8. Current working directory: \`${cwd} \` - Use this for all file paths
|
||||
9. Don't use cli scaffolding to steup the project, use cwd as Root of the project
|
||||
11. For nodejs projects ALWAYS install dependencies after writing package.json file
|
||||
7. ALWAYS think and plan comprehensively before providing a solution.
|
||||
8. Current working directory: \`${cwd} \` - Use this for all file paths.
|
||||
9. Don't use CLI scaffolding to set up the project; use \`cwd\` as the root of the project.
|
||||
10. For Node.js projects, ALWAYS install dependencies after writing the \`package.json\` file.
|
||||
|
||||
## Coding Standards
|
||||
10. ALWAYS create smaller, atomic components and modules
|
||||
11. Modularity is PARAMOUNT - Break down functionality into logical, reusable parts
|
||||
12. IMMEDIATELY refactor any file exceeding 250 lines
|
||||
13. ALWAYS plan refactoring before implementation - Consider impacts on the entire system
|
||||
11. ALWAYS create smaller, atomic components and modules.
|
||||
12. Modularity is PARAMOUNT - Break down functionality into logical, reusable parts.
|
||||
13. IMMEDIATELY refactor any file exceeding 250 lines.
|
||||
14. ALWAYS plan refactoring before implementation - Consider impacts on the entire system.
|
||||
|
||||
## Artifact Usage
|
||||
22. Use \`<boltArtifact>\` tags with \`title\` and \`id\` attributes for each project
|
||||
23. Use \`<boltAction>\` tags with appropriate \`type\` attribute:
|
||||
- \`shell\`: For running commands
|
||||
- \`file\`: For writing/updating files (include \`filePath\` attribute)
|
||||
- \`start\`: For starting dev servers (use only when necessary/ or new dependencies are installed)
|
||||
24. Order actions logically - dependencies MUST be installed first
|
||||
25. For Vite project must include vite config and index.html for entry point
|
||||
26. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates
|
||||
27. WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
|
||||
15. Use \`<boltArtifact>\` tags with \`title\` and \`id\` attributes for each project.
|
||||
16. Use \`<boltAction>\` tags with appropriate \`type\` attribute:
|
||||
- \`shell\`: For running commands.
|
||||
- \`file\`: For writing/updating files (include \`filePath\` attribute).
|
||||
- \`start\`: For starting dev servers (use only when necessary or when new dependencies are installed).
|
||||
17. Order actions logically - dependencies MUST be installed first.
|
||||
18. For Vite projects, include \`vite.config.js\` (or \`.ts\`) and an \`index.html\` entry point.
|
||||
19. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates.
|
||||
20. WebContainer CANNOT execute diff or patch editing, so always write your code in full; no partial/diff updates.
|
||||
|
||||
CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.
|
||||
|
||||
|
@ -8,6 +8,7 @@ import { WORK_DIR } from '~/utils/constants';
|
||||
import { computeFileModifications } from '~/utils/diff';
|
||||
import { createScopedLogger } from '~/utils/logger';
|
||||
import { unreachable } from '~/utils/unreachable';
|
||||
import { diffFiles } from '~/utils/diff'; // Moved import to the top
|
||||
import {
|
||||
addLockedFile,
|
||||
removeLockedFile,
|
||||
@ -548,6 +549,27 @@ export class FilesStore {
|
||||
}
|
||||
|
||||
async saveFile(filePath: string, content: string) {
|
||||
// Add Lock Check
|
||||
const lockStatus = this.isFileLocked(filePath);
|
||||
if (lockStatus.locked) {
|
||||
logger.warn(`Attempted to save locked file: ${filePath} (locked by: ${lockStatus.lockedBy}). Save operation aborted.`);
|
||||
// TODO: Implement user-facing notification for skipped writes (locked / no change).
|
||||
return;
|
||||
}
|
||||
|
||||
// Add Diff Check
|
||||
const oldContent = this.getFile(filePath)?.content;
|
||||
if (oldContent !== undefined) { // File exists
|
||||
const diffResult = diffFiles(filePath, oldContent, content);
|
||||
if (diffResult === undefined) { // No changes
|
||||
logger.info(`Content for ${filePath} has not changed. Skipping save.`);
|
||||
// TODO: Implement user-facing notification for skipped writes (locked / no change).
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If oldContent is undefined, it's a new file being "saved" or an existing file whose content was not loaded.
|
||||
// In such cases, we proceed to write. The #modifiedFiles logic will handle it as a new modification.
|
||||
|
||||
const webcontainer = await this.#webcontainer;
|
||||
|
||||
try {
|
||||
@ -557,19 +579,18 @@ export class FilesStore {
|
||||
throw new Error(`EINVAL: invalid file path, write '${relativePath}'`);
|
||||
}
|
||||
|
||||
const oldContent = this.getFile(filePath)?.content;
|
||||
|
||||
if (!oldContent && oldContent !== '') {
|
||||
unreachable('Expected content to be defined');
|
||||
}
|
||||
// Ensure oldContent for #modifiedFiles is fetched before writeFile if it wasn't fetched for diff check
|
||||
// (e.g. if it was a new file, oldContent for diff check would be undefined)
|
||||
const originalContentForModifiedMap = this.getFile(filePath)?.content ?? '';
|
||||
|
||||
await webcontainer.fs.writeFile(relativePath, content);
|
||||
|
||||
if (!this.#modifiedFiles.has(filePath)) {
|
||||
this.#modifiedFiles.set(filePath, oldContent);
|
||||
// Set the original content before the write, or empty if it was new.
|
||||
this.#modifiedFiles.set(filePath, originalContentForModifiedMap);
|
||||
}
|
||||
|
||||
// Get the current lock state before updating
|
||||
// Get the current lock state before updating (this part seems fine)
|
||||
const currentFile = this.files.get()[filePath];
|
||||
const isLocked = currentFile?.type === 'file' ? currentFile.isLocked : false;
|
||||
|
||||
@ -764,6 +785,16 @@ export class FilesStore {
|
||||
}
|
||||
|
||||
async createFile(filePath: string, content: string | Uint8Array = '') {
|
||||
// Add Lock Check using isPathInLockedFolder
|
||||
const currentChatId = getCurrentChatId(); // Assuming getCurrentChatId is accessible here
|
||||
const folderLockStatus = isPathInLockedFolder(currentChatId, filePath);
|
||||
|
||||
if (folderLockStatus.locked) {
|
||||
logger.warn(`Attempted to create file in a locked path: ${filePath} (locked by folder: ${folderLockStatus.lockedBy}). Create operation aborted.`);
|
||||
// TODO: Implement user-facing notification for skipped writes (locked / no change).
|
||||
return false; // Indicate failure
|
||||
}
|
||||
|
||||
const webcontainer = await this.#webcontainer;
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user