Skip to content
170 changes: 169 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
"command": "bizarro-devin.manualPrompt",
"title": "Manually Prompt AI Agent",
"category": "Bizarro Devin"
},
{
"command": "bizarro-devin.ignoreErrors",
"title": "Enable error ignoring for the AI Agent",
"category": "Bizarro Devin"
}
],
"menus": {
Expand Down Expand Up @@ -101,6 +106,7 @@
"play-sound": "^1.1.6",
"replicate": "^0.29.1",
"say": "^0.16.0",
"socket.io": "^4.7.5",
"wavefile": "^11.0.0"
}
}
20 changes: 20 additions & 0 deletions src/commands/ignoreErrors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { getAgent } = require('../lib/agent/Agent');
const Command = require('../lib/command');
const vscode = require('vscode');

class IgnoreErrorsCommand extends Command {
constructor() {
super('bizarro-devin.ignoreErrors');
}

async run() {
const agent = getAgent();
agent.ignoreErrors = !agent.ignoreErrors;

vscode.window.showInformationMessage(
'Error ignoring is now ' + (agent.ignoreErrors ? 'enabled' : 'disabled')
);
}
}

module.exports = IgnoreErrorsCommand;
50 changes: 50 additions & 0 deletions src/commands/setupFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SetupFilesCommand extends Command {
// create index.html
await this.createIndexHtml();
// create sketch.js && opening it
await this.createErrorCatcherFile();
const doc = await createFile('sketch.js');
await doc.open();
}
Expand All @@ -24,13 +25,62 @@ class SetupFilesCommand extends Command {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script
src="https://cdn.socket.io/4.7.5/socket.io.min.js"
integrity="sha384-2huaZvOR9iDzHqslqwpR87isEmrfxqyWOF7hr7BY6KG0+hVKLoEXMPUJw3ynWuhO"
crossorigin="anonymous"
></script>
<script src="errorCatcher.js"></script>
<script src="sketch.js"></script>
</head>
<body>
</body>
</html>`
);
}

async createErrorCatcherFile() {
await createFile(
'errorCatcher.js',
`const socket = io('http://127.0.0.1:4025');

// Capture all errors, credits to https://github.com/processing/p5.js-web-editor/blob/develop/client%2Futils%2FpreviewEntry.js#L65
window.onerror = async function (msg, source, lineNumber, columnNo, error) {
let data;
if (!error) {
data = msg;
} else {
data = \`\${error.name}: \${error.message}\`;
// Remove the host from the resolvedLineNo
const line = \` at \${lineNumber}:\${columnNo}\`;
data = data.concat(line);
}

const errorData = {
msg,
source,
lineNumber,
columnNo,
error,
data,
};

await sendMessage(errorData, 'error');
return false;
};

// Send error to backend
async function sendMessage(data, type) {
socket.emit('message', {
type,
data,
});
}

socket.on('reload', () => window.location.reload());
`
);
}
}

module.exports = SetupFilesCommand;
4 changes: 3 additions & 1 deletion src/extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const CommandLoader = require('./lib/commandLoader');
const { getWebserver } = require('./lib/web/webserver');

const CommandLoader = require('./lib/commandLoader');
require('./lib/web/webserver');
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed

Expand Down
Loading