Background:
- People trying to bring their existing project (local machine, github, other cloud, etc) realize they can’t use the prototyper interface, only the code view, which uses a different model.
- With time the prototyper context memory gets huge and this ends up causing some troubles:
- Slow Speeds
- Frequent VM locks (Infinite Loading - reset needed)
- Uncomplete interactions
- Reduced Context Precision
- Old code being randomly and frequently reintroduced
- Additional errors like exceeding input token
Why Clearing the Context Is Good
- Not only you’ll reduce quite a bit of suffering from the above problems, but also
- The Prototyper will just work better: he’ll produce longer codes with less errors, while doing it faster!
- We help Google by removing an unnecessary burden from their servers and by doing that we help all users from firebase studio having a better experience.
Related Topics
What I’ll Show Here
The procedure shown in this topic does the following:
- clears the ENTIRE context from the Prototyper.
- Bypasses the Protype creation stage, making the Prototyper ready to work from the get go.
WARNING PROTOTYPER CONTEXT WILL BE DELETE it won’t remember previous interaction.
Firebase studio has 2 context files capra-context and capra-thread, we’ll clear both.
##################################################
IMPORTANT TIP: Before clearing your context, do the following:
##################################################
Create the following structure in your project:
context/PROJECT_CONTEXT_HISTORY.md (this is where the context summary will be placed)
context/PROJECT_CONTEXT_INSTRUCTIONS.md (how to use the files from context dir)
context/PROJECT_PROGRESS.md (project progress - done - working - next features)
context/1st.md (initialization prompt)
Explain to the prototyper what you’re doing: you want to clear his context and still have a way for him to remember the main points of your current interaction.
The prompt would look something like this:
I'll reset your context memory, so we need to make sure you can have some context from our current interaction. I created a dir named context in our project folder, there you'll find some files. Create a throughout summary from our conversation with all the important aspects from the project, objectives, things that we done, things that we'll do and any other information you thing is important. And write it to context/PROJECT_CONTEXT_HISTORY.md then create a progress from our project: DONE, WORKING, NEXT inside PROJECT_PROGRESS.md then create instructions for you on how these files should be updated and used on subsequence sessions and write it to PROJECT_INSTRUCTIONS and also create a initialization prompt that I'll give you on our next session to get you to know the codebase, and read the project context files and write it to 1st.md The whole idea of this is to create a system that will allow some general persistence from your context between sessions, you should update this files regularly along our interactions, specially when something major is achieved or discussed.
Something in those lines, it’s a basic prompt engineering you’ll be doing, you could either use the prompt I gave above, but ideally make one more detailed and according to your liking on how you want this to be done.
NOW LET’S CLEAR THE CONTEXT
With an existing codebase loaded (either a ongoing project, loaded from github, uploaded, etc), do this Steps:
-
Access the code view interface by clicking the <> button (top right conner)
-
Open the terminal
-
A new window where you can type commands will be displayed
-
Click inside the terminal to start typing the following commands, press enter after each one.
-
First let’s backup your existing context to a dir named context_backup copy and paste the following command:
timestamp=$(date +%Y%m%d%H%M%S); mkdir -p "/home/user/studio/context/context_backup/" && cp "/home/user/.idx/ai/capra-context-state.json" "/home/user/studio/context/context_backup/capra-context-state-${timestamp}.json" && cp "/home/user/.idx/ai/capra-thread.json" "/home/user/studio/context/context_backup/capra-thread-${timestamp}.json"
- Add the backup folder to .gitignore
# prototyper
/context/context_backup
- Now let’s clear capra-thread
/clear
- Let’s edit the capra-context
code /home/user/.idx/ai/capra-context-state.json
- Delete all capra-context contents
- Paste the following code there
{
"currentProposalObject": {
"appName": "YOUR_APP_NAME",
"coreFeatures": [
{
"name": "Existing Project Core",
"description": "Details to be determined by codebase scan.",
"categories": ["ui"]
}
],
"uiStyleGuidelines": [
{
"category": "layout",
"description": "Awaiting codebase scan for details."
}
]
},
"agentHistories": {
"app-prototyping-agent:proposal-agent": [],
"app-prototyping-agent:edit-app-agent": [
{
"role": "model",
"content": [
{
"text": "I'm ready to work on your project. Please let me know what you'd like to do."
}
]
}
]
},
"currentState": "edit-app"
}
- Inside the code you just pasted there’s a variable appName, replace the YOUR_APP_NAME for the name of your app
- Wait around 30s just to make sure the auto-save will happen and to avoid the old capra-context being pulled from cache
- Time to RESET your project VM, go to:
https://studio.firebase.google.com/
Click Reset
And That’s is it!
Now your project VM will boot up and you should see the prototyper ready to work on it with the context completely blank.
IF your context is still showing, probably the capra-context file was reverted by the server, just repeat steps 8-13. You can also try to manually save it and wait for a bit more.
DO NOT do anything after saving the capra-context file, just go straight to the firebase studio url and reset the VM.