SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Web fix: Highlighting in terminal (restore linebreaks)
Kilian Liereta87a25cf71e5
diff --git a/sweagent/api/hooks.py b/sweagent/api/hooks.pyindex c49bb827..376d9056 100644--- a/sweagent/api/hooks.py+++ b/sweagent/api/hooks.py@@ -100,17 +100,16 @@ class AgentUpdateHook(AgentHook):def on_sub_action_started(self, *, sub_action: dict):# msg = f"```bash\n{sub_action['action']}\n```"- msg = "$ " + sub_action["action"].strip()+ msg = sub_action["action"].strip()self._sub_action = sub_action["action"].strip()self._wu.up_env(message=msg, thought_idx=self._thought_idx, type_="command")def on_sub_action_executed(self, *, obs: str, done: bool):- # language = ""- # if self._sub_action == "submit":- # language = "diff"- # msg = f"```{language}\n{obs}\n```"+ type_ = "output"+ if self._sub_action == "submit":+ type_ = "diff"msg = obs.strip()- self._wu.up_env(message=msg, thought_idx=self._thought_idx, type_="output")+ self._wu.up_env(message=msg, thought_idx=self._thought_idx, type_=type_)diff --git a/sweagent/frontend/src/components/EnvMessage.js b/sweagent/frontend/src/components/EnvMessage.jsindex 3bbf1020..37aa8f92 100644--- a/sweagent/frontend/src/components/EnvMessage.js+++ b/sweagent/frontend/src/components/EnvMessage.js@@ -5,73 +5,65 @@ import "../static/envMessage.css";import {Prism as SyntaxHighlighter,- PrismLight as SyntaxHighlighterBash} from 'react-syntax-highlighter';-// import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';+import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';import { prism } from 'react-syntax-highlighter/dist/esm/styles/prism';-function capitalizeFirstLetter(str) {- return str[0].toUpperCase() + str.slice(1);- }+SyntaxHighlighter.registerLanguage('bash', bash);const EnvMessage = ({ item, handleMouseEnter, isHighlighted, feedRef}) => {const stepClass = item.step !== null ? `step${item.step}` : '';const highlightClass = isHighlighted ? 'highlight' : '';- const messageTypeClass = "envMessage" + capitalizeFirstLetter(item.type);- const textStyle={- boxShadow: "none",- margin: "0",- overflowY: "hidden",- padding: "0.25em 0.5em 0.75em 0.5em",- }-- const customStyle={- backgroundColor: 'inherit',- }--- const customStyleMerged = {+ const customStyle = {margin: 0,padding: '0 0.5em',overflowX: 'hidden',lineHeight: 'inherit',- ...customStyle,+ backgroundColor: 'transparent',}const codeTagProps = {style: {+ boxShadow: "none",+ margin: "0",+ overflowY: "hidden",+ padding: "0.25em 0.5em 0.75em 0.5em",lineHeight: 'inherit',fontSize: 'inherit',- ...textStyle,}}+ const typeToLanguage = {+ "command": "bash",+ "output": "markdown",+ "diff": "diff",+ }+if (item.type === "command" || item.type === "output") {- const language = item.type === "command" ? "bash" : "markdown";return (<div- className={`message ${item.format} ${stepClass} ${highlightClass} ${messageTypeClass}`}+ className={`message ${stepClass} ${highlightClass}`}onMouseEnter={() => handleMouseEnter(item, feedRef)}>- <div+ <SyntaxHighlightercodeTagProps={codeTagProps}- customStyle={{customStyleMerged, overflow: 'hidden'}}- language={language}- lineProps={{ style: {wordBreak: 'break-word', whiteSpace: 'normal'} }}- style={prism}+ customStyle={{customStyleMerged: customStyle, overflow: 'hidden'}}+ language={typeToLanguage[item.type]}+ // lineProps={{ style: {wordBreak: 'break-word', whiteSpace: 'normal'} }}+ style={{backgroundColor: 'transparent', ...prism}}wrapLines={true}showLineNumbers={false}>{item.message}- </div>+ </SyntaxHighlighter></div>);} else {return (<div- className={`message ${item.format} ${stepClass} ${highlightClass} ${messageTypeClass}`}+ className={`message ${stepClass} ${highlightClass}`}onMouseEnter={() => handleMouseEnter(item, feedRef)}><span>{item.message}</span>