Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
fix(web,chatbot): copy GitHub device code on HTTP; rename remaining AgentFlow labels to LoopForge (#99)
Robert062298aa9e71789d
diff --git a/chatbot/src/App.jsx b/chatbot/src/App.jsxindex 646f0049..f590402e 100644--- a/chatbot/src/App.jsx+++ b/chatbot/src/App.jsx@@ -1684,10 +1684,10 @@ export default function App() {<div className="composer-context"><spanclassName="context-pill host-status"- title="对话在 AgentFlow 云端运行"+ title="对话在 LoopForge 云端运行"><HarnessIcon name="server" size={13} interactive={false} />- <span>AgentFlow 云端</span>+ <span>LoopForge 云端</span><iclassName={`connection-dot ${chat.ready ? "online" : ""}`}/>diff --git a/chatbot/src/composer-context.css b/chatbot/src/composer-context.cssindex 4c5c6eca..e21a668b 100644--- a/chatbot/src/composer-context.css+++ b/chatbot/src/composer-context.css@@ -35,7 +35,7 @@color: inherit;}-/* Conversations only run on AgentFlow cloud, so the host is a status label. */+/* Conversations only run on LoopForge cloud, so the host is a status label. */.composer-stack > .composer-context .context-pill.host-status {flex-shrink: 0;cursor: default;diff --git a/chatbot/tests/app-render.test.jsx b/chatbot/tests/app-render.test.jsxindex f6cd893b..2dd2e114 100644--- a/chatbot/tests/app-render.test.jsx+++ b/chatbot/tests/app-render.test.jsx@@ -70,6 +70,15 @@ vi.mock("mermaid", () => ({import App from "../src/App.jsx";describe("App", () => {+ test("labels the conversation host as LoopForge cloud in text and hover hint", () => {+ const view = render(<App />);+ const host = view.container.querySelector(".composer-context .host-status");+ expect(host).toHaveTextContent("LoopForge 云端");+ expect(host).toHaveAttribute("title", "对话在 LoopForge 云端运行");+ expect(view.container.querySelector(".composer-context")).not.toHaveTextContent("AgentFlow");+ view.unmount();+ });+test("hides environments by default and remembers each user's advanced preference", async () => {const previous = { ...chat };const selectSandbox = vi.fn();diff --git a/web/app/access.js b/web/app/access.jsindex 97ea2131..fa4494a0 100644--- a/web/app/access.js+++ b/web/app/access.js@@ -23,7 +23,7 @@ function accessMcpClientSpec(client,base,token){}function accessMcpAgentPrompt(spec,base,token){if(!token||token==='<YOUR_PERSONAL_TOKEN>')return '';- return `按照这个流程安装、初始化并验证好 AgentFlow MCP:\n\n1. 使用 curl 下载 安装流程文件, 禁止使用 fetch:${base}/mcp-setup.txt\n2. 两个占位符替换为:\n API_TOKEN = ${token}\n ENDPOINT = ${base}/mcp`;+ return `按照这个流程安装、初始化并验证好 LoopForge MCP:\n\n1. 使用 curl 下载 安装流程文件, 禁止使用 fetch:${base}/mcp-setup.txt\n2. 两个占位符替换为:\n API_TOKEN = ${token}\n ENDPOINT = ${base}/mcp`;}function accessAgentSetup(prompt){const attr=prompt?`data-copy-agent-prompt="${encodeURIComponent(prompt)}"`:'data-create-token-first';@@ -79,7 +79,7 @@ function renderAccessGuide(){const body=$('#accessBody'),base=getPublicBaseURL(),token=state.revealedToken||'<YOUR_PERSONAL_TOKEN>';const mainCode=`export AGENTFLOW_URL=${base}\nexport AGENTFLOW_TOKEN='${token}'\n\ncurl -sS -H \"Authorization: Bearer $AGENTFLOW_TOKEN\" \\\n \"$AGENTFLOW_URL/api/issues\"`;const checkCode=`curl -sS -H \"Authorization: Bearer $AGENTFLOW_TOKEN\" \\\n \"$AGENTFLOW_URL/api/health\"`;- body.innerHTML=`<div class=\"access-grid\"><div class=\"access-card\"><div class=\"access-card-title\"><i>API</i>通过 REST API 调用 AgentFlow</div><div class=\"access-step\"><span>1</span><b>设置地址和个人 Token</b></div>${accessCode('Shell',mainCode)}<div class=\"access-step\"><span>2</span><b>验证连通</b><small>返回 JSON 即接入成功</small></div>${accessCode('连通性自检',checkCode)}<div class=\"access-note\"><b>Token 不要提交到代码仓库。</b>建议通过 CI Secret 或环境变量保存。</div></div><div class=\"access-card\"><div class=\"access-card-title\"><i>↗</i>接口契约</div><div class=\"access-note\" style=\"margin-top:0\">REST API 与 MCP 使用同一个个人 Token。完整请求结构以 OpenAPI 契约为准。</div><a class=\"button ghost small\" href=\"/api/openapi.yaml\" target=\"_blank\" rel=\"noopener\">打开 OpenAPI 契约 →</a></div></div>`;+ body.innerHTML=`<div class=\"access-grid\"><div class=\"access-card\"><div class=\"access-card-title\"><i>API</i>通过 REST API 调用 LoopForge</div><div class=\"access-step\"><span>1</span><b>设置地址和个人 Token</b></div>${accessCode('Shell',mainCode)}<div class=\"access-step\"><span>2</span><b>验证连通</b><small>返回 JSON 即接入成功</small></div>${accessCode('连通性自检',checkCode)}<div class=\"access-note\"><b>Token 不要提交到代码仓库。</b>建议通过 CI Secret 或环境变量保存。</div></div><div class=\"access-card\"><div class=\"access-card-title\"><i>↗</i>接口契约</div><div class=\"access-note\" style=\"margin-top:0\">REST API 与 MCP 使用同一个个人 Token。完整请求结构以 OpenAPI 契约为准。</div><a class=\"button ghost small\" href=\"/api/openapi.yaml\" target=\"_blank\" rel=\"noopener\">打开 OpenAPI 契约 →</a></div></div>`;body.querySelectorAll('[data-copy-access]').forEach(b=>b.onclick=()=>copyText(decodeURIComponent(b.dataset.copyAccess),'配置已复制'));}// 最小接入配置:引导配好 CodeBuddy API Key 与工蜂 Git Token,配好即可运行。diff --git a/web/app/github-connect.js b/web/app/github-connect.jsindex 20d4bedf..61ee33dc 100644--- a/web/app/github-connect.js+++ b/web/app/github-connect.js@@ -20,6 +20,27 @@ async function hydrateGitHubConnections(root=document){}}+// The async Clipboard API only exists in secure contexts, so installs opened as+// http://SERVER_IP fall back to copying from a hidden field inside the dialog.+async function copyGitHubDeviceCode(value,trigger){+ if(navigator.clipboard&&window.isSecureContext){try{await navigator.clipboard.writeText(value);return true}catch{}}+ const field=document.createElement('textarea');+ field.value=value;field.readOnly=true;field.tabIndex=-1;field.setAttribute('aria-hidden','true');+ field.style.cssText='position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0';+ (trigger?.parentNode||document.body).append(field);+ field.focus({preventScroll:true});field.select();+ let copied=false;+ try{copied=document.execCommand('copy')}catch{copied=false}+ field.remove();+ trigger?.focus?.({preventScroll:true});+ return copied;+}++function selectGitHubDeviceCode(code){+ const range=document.createRange();range.selectNodeContents(code);+ const selection=window.getSelection();selection.removeAllRanges();selection.addRange(range);+}+async function startGitHubConnect(host){if(host.dataset.busy==='true')return;if(host.dataset.enabled!=='true'){await hydrateGitHubConnections(host);return}@@ -61,8 +82,12 @@ async function startGitHubConnect(host){const instruction=document.createElement('p');instruction.textContent='复制授权码,然后在 GitHub 确认:';const code=document.createElement('strong');code.className='github-device-code';code.textContent=flow.userCode;instruction.append(code);const copy=document.createElement('button');copy.type='button';copy.className='button ghost small';copy.textContent='复制授权码';- copy.onclick=async()=>{try{await navigator.clipboard.writeText(flow.userCode);copy.textContent='已复制'}catch{copy.textContent='请选中授权码复制'}};- const link=document.createElement('a');link.href='https://github.com/login/device';link.target='_blank';link.rel='noopener noreferrer';link.className='button primary small';link.textContent='复制并前往 GitHub 授权';link.onclick=()=>{navigator.clipboard?.writeText(flow.userCode).then(()=>{copy.textContent='已复制'},()=>{})};+ const copyCode=async trigger=>{+ if(await copyGitHubDeviceCode(flow.userCode,trigger)){copy.textContent='已复制';return}+ selectGitHubDeviceCode(code);copy.textContent='已选中,按 Ctrl/⌘+C 复制';+ };+ copy.onclick=()=>copyCode(copy);+ const link=document.createElement('a');link.href='https://github.com/login/device';link.target='_blank';link.rel='noopener noreferrer';link.className='button primary small';link.textContent='复制并前往 GitHub 授权';link.onclick=()=>{void copyCode(link)};const cancel=document.createElement('button');cancel.type='button';cancel.className='button ghost small';cancel.textContent='取消';cancel.onclick=()=>{finish();status.replaceChildren()};status.append(instruction,copy,link,cancel);timer=setTimeout(poll,Math.max(5,flow.interval)*1000);diff --git a/web/mcp-setup.txt b/web/mcp-setup.txtindex ae111ea3..bf76930e 100644--- a/web/mcp-setup.txt+++ b/web/mcp-setup.txt@@ -1,10 +1,10 @@-# AgentFlow MCP — 安装 / 初始化 / 验证+# LoopForge MCP — 安装 / 初始化 / 验证接入指南:<https://loopforge.example.com/#/guide>**适用范围**:Cursor、Claude Code、CodeBuddy、Codex。请根据当前运行的 Agent 自动选择对应配置,不要反问用户使用哪个客户端。-**目标**:把 AgentFlow 作为名为 `agentflow` 的 Streamable HTTP MCP 服务接入当前客户端,并确认能正常返回工具清单。+**目标**:把 LoopForge 作为名为 `agentflow` 的 Streamable HTTP MCP 服务接入当前客户端,并确认能正常返回工具清单。**安全原则**:@@ -107,7 +107,7 @@ codex mcp list## 通用连通验证-客户端配置完成后,使用下面的请求验证 AgentFlow 能返回 MCP 工具清单:+客户端配置完成后,使用下面的请求验证 LoopForge 能返回 MCP 工具清单:```bashAPI_TOKEN="<API_TOKEN>"diff --git a/web/syntax_test.go b/web/syntax_test.goindex e07ac17a..13f505f9 100644--- a/web/syntax_test.go+++ b/web/syntax_test.go@@ -551,6 +551,8 @@ assert.equal(prompt, '');const readyPrompt = accessMcpAgentPrompt(codex, base, 'afp_test_token');assert.ok(readyPrompt.includes('使用 curl 下载 安装流程文件, 禁止使用 fetch:http://loopforge.example.com/mcp-setup.txt'));assert.ok(!readyPrompt.includes('当前客户端'));+assert.ok(readyPrompt.includes('验证好 LoopForge MCP'));+assert.ok(!readyPrompt.includes('AgentFlow'));assert.ok(readyPrompt.includes('API_TOKEN = afp_test_token'));assert.ok(readyPrompt.includes('ENDPOINT = http://loopforge.example.com/mcp'));assert.ok(code.includes('async function createQuickAccessPrompt('));@@ -575,6 +577,9 @@ func TestMCPSetupInstructionsAreEmbedded(t *testing.T) {t.Fatalf("MCP setup instructions are missing %q", want)}}+ if strings.Contains(text, "AgentFlow") {+ t.Fatal("MCP setup instructions should name the product LoopForge, not AgentFlow")+ }embedSource, err := os.ReadFile("embed.go")if err != nil {t.Fatal(err)diff --git a/webtest/tests/github-connect.test.mjs b/webtest/tests/github-connect.test.mjsindex 4d1e3d12..e2b77653 100644--- a/webtest/tests/github-connect.test.mjs+++ b/webtest/tests/github-connect.test.mjs@@ -29,6 +29,69 @@ test('GitHub connection displays a PIN, honors slow polling, and stores the connassert.deepEqual(call.body, { flowId: 'opaque-flow' });});+async function openDeviceCode(t, { secure, execResult = true }) {+ const app = await loadApp();+ t.after(app.close);+ app.router.get('/api/auth/github', { enabled: true });+ app.router.post('/api/auth/github/device', { flowId: 'opaque-flow', userCode: 'ABCD-EFGH', expiresIn: 900, interval: 5 });+ Object.defineProperty(app.window, 'isSecureContext', { configurable: true, value: secure });+ const clipboardWrites = [], execCalls = [];+ Object.defineProperty(app.window.navigator, 'clipboard', { configurable: true, value: { writeText: async (value) => { clipboardWrites.push(value); } } });+ app.document.execCommand = (command) => {+ const active = app.document.activeElement;+ execCalls.push({ command, value: active?.value, selected: active?.value?.slice(active.selectionStart, active.selectionEnd), inStatus: !!active?.closest?.('[data-github-status]') });+ return execResult;+ };+ app.evaluate(`+ state.currentUser={id:1,loginName:'owner'};+ const host=document.createElement('div');host.id='github-copy-test';host.innerHTML=githubConnectHTML();document.body.append(host);+ window.setTimeout=()=>0;+ `);+ const host = app.document.querySelector('#github-copy-test');+ await app.evaluate('hydrateGitHubConnections(document)');+ host.querySelector('[data-github-start]').click();+ await settle(5);+ const copy = [...host.querySelectorAll('button')].find((button) => button.textContent === '复制授权码');+ const link = host.querySelector('a[href="https://github.com/login/device"]');+ link.addEventListener('click', (event) => event.preventDefault());+ return { app, host, copy, link, clipboardWrites, execCalls };+}++test('GitHub device code copies over plain HTTP where the Clipboard API is unavailable', async (t) => {+ const { app, host, copy, link, clipboardWrites, execCalls } = await openDeviceCode(t, { secure: false });+ copy.click();+ await settle(3);+ assert.equal(copy.textContent, '已复制');+ assert.deepEqual(execCalls, [{ command: 'copy', value: 'ABCD-EFGH', selected: 'ABCD-EFGH', inStatus: true }]);+ assert.deepEqual(clipboardWrites, []);+ assert.equal(host.querySelector('textarea'), null);+ assert.equal(app.document.activeElement, copy);+ copy.textContent = '复制授权码';+ link.click();+ await settle(3);+ assert.equal(execCalls.length, 2);+ assert.equal(execCalls[1].value, 'ABCD-EFGH');+ assert.equal(copy.textContent, '已复制');+});++test('GitHub device code is selected for manual copy when the browser refuses to copy', async (t) => {+ const { app, copy, execCalls } = await openDeviceCode(t, { secure: false, execResult: false });+ copy.click();+ await settle(3);+ assert.equal(execCalls.length, 1);+ assert.match(copy.textContent, /已选中/);+ assert.equal(app.window.getSelection().toString(), 'ABCD-EFGH');+});++test('GitHub device code uses the Clipboard API in secure contexts', async (t) => {+ const { copy, clipboardWrites, execCalls } = await openDeviceCode(t, { secure: true });+ copy.click();+ await settle(3);+ assert.equal(copy.textContent, '已复制');+ assert.deepEqual(clipboardWrites, ['ABCD-EFGH']);+ assert.deepEqual(execCalls, []);+});+test('GitHub repository picker loads pages, filters names, and fills the actual default branch', async (t) => {const app = await loadApp();t.after(app.close);