@shawnstack/quickforge 1.6.9 → 1.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +452 -452
  2. package/dist/assets/AgentProfilesPage-CvoB0OId.js +1 -0
  3. package/dist/assets/ChatPanelHost-Cyi1yi_P.js +244 -0
  4. package/dist/assets/{PluginsPage-C5OClNdT.js → PluginsPage-B_4nlPca.js} +1 -1
  5. package/dist/assets/{ScheduledTasksPage-yT10oaaM.js → ScheduledTasksPage-Zbsuo8o6.js} +2 -2
  6. package/dist/assets/{SettingsWorkspacePage-DuXwIeLd.js → SettingsWorkspacePage-BtgkwIKN.js} +358 -293
  7. package/dist/assets/{SharedConversationPage-ClpUSa0F.js → SharedConversationPage-B5FS3eSl.js} +1 -1
  8. package/dist/assets/TerminalDock-CiJCmyqg.js +2 -0
  9. package/dist/assets/WorkspaceInspector-C9HyQIvF.js +13 -0
  10. package/dist/assets/index-BFKildY3.js +63 -0
  11. package/dist/assets/index-CsKSKUn-.css +3 -0
  12. package/dist/assets/{mcp-servers-dialog-DC2Zfojn.js → mcp-servers-dialog-BPk4a4nW.js} +2 -2
  13. package/dist/assets/{skills-dialog-Mnj8fZwq.js → skills-dialog-DcxeFWSt.js} +1 -1
  14. package/dist/index.html +4 -4
  15. package/package.json +1 -1
  16. package/server/agent-manager.mjs +45 -3
  17. package/server/approval-store.mjs +4 -0
  18. package/server/global-memory.mjs +168 -0
  19. package/server/index.mjs +7 -0
  20. package/server/project-config.mjs +3 -0
  21. package/server/routes/backup.mjs +135 -48
  22. package/server/routes/memory.mjs +26 -0
  23. package/server/routes/tools.mjs +5 -3
  24. package/server/routes/workspace.mjs +56 -0
  25. package/server/system-prompt.mjs +22 -0
  26. package/server/tools/definitions.mjs +14 -0
  27. package/server/tools/index.mjs +6 -0
  28. package/server/utils/platform.mjs +4 -4
  29. package/dist/assets/AgentProfilesPage-5eqU0Cjk.js +0 -1
  30. package/dist/assets/ChatPanelHost-BNFeNRy-.js +0 -244
  31. package/dist/assets/TerminalDock-BmL-FeKv.js +0 -2
  32. package/dist/assets/WorkspaceInspector-yH23pXpj.js +0 -13
  33. package/dist/assets/index-Qof73j0o.css +0 -3
  34. package/dist/assets/index-_ut7awrd.js +0 -63
@@ -1,5 +1,5 @@
1
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,C as n,D as r,Rt as i,Vt as a,a as o,g as s,st as c,x as l,y as u}from"./icons-C7j5jdKo.js";import{n as d}from"./react-vendor-VqdnQHHS.js";import{V as f,b as p,ct as m,lt as h,pt as g,st as _}from"./index-_ut7awrd.js";var v=e(a(),1),y=d();function b(e){return e===`connected`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-destructive/12 text-destructive`:e===`disabled`?`bg-muted text-muted-foreground`:`bg-amber-500/12 text-amber-700 dark:text-amber-300`}var x=12;function S({server:e,toggling:n,reconnecting:i,onToggle:a,onEdit:s,onDelete:c,onReconnect:l}){let d=e.tools?.slice(0,x)??[],f=e.toolCount??e.tools?.length??0,p=Math.max(0,f-d.length),_=e.enabled&&e.status!==`connected`;return(0,y.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.name}),(0,y.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-[11px]`,b(e.status)),children:e.status||`unknown`}),(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:g(`mcpToolsCount`,{count:f})})]}),(0,y.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground/65`,children:e.transport===`stdio`?`${e.command} ${(e.args||[]).join(` `)}`:e.url}),e.error?(0,y.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:e.error}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:n,className:h(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>a(e),title:e.enabled?g(`pauseTask`):g(`enable`),children:(0,y.jsx)(`span`,{className:h(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-5`:`translate-x-0`)})}),_?(0,y.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>l(e.name),disabled:i,"aria-label":g(`mcpReconnectServer`),title:g(`mcpReconnectServer`),children:i?(0,y.jsx)(t,{className:`size-4 animate-spin`}):(0,y.jsx)(u,{className:`size-4`})}):null,(0,y.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>s(e),"aria-label":g(`editTask`),title:g(`editTask`),children:(0,y.jsx)(r,{className:`size-4`})}),(0,y.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-destructive`,onClick:()=>c(e.name),"aria-label":g(`delete`),title:g(`delete`),children:(0,y.jsx)(o,{className:`size-4`})})]})]}),d.length>0?(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[d.map(e=>(0,y.jsx)(`span`,{className:`rounded-md bg-muted/28 px-1.5 py-0.5 text-[11px] text-muted-foreground/75`,title:e.quickForgeName,children:e.name},e.quickForgeName)),p>0?(0,y.jsx)(`span`,{className:`rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/55`,children:g(`mcpMoreTools`,{count:p})}):null]}):null]})}function C(){return{name:``,transport:`stdio`,command:``,args:[],url:``,cwd:``,env:{}}}function w(e){return{name:e.name,transport:e.transport,command:e.command,args:e.args||[],url:e.url||``,cwd:e.cwd||``,env:e.env||{}}}function T(e){return(e||[]).join(`
1
+ import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{B as t,C as n,D as r,Rt as i,Vt as a,a as o,g as s,st as c,x as l,y as u}from"./icons-C7j5jdKo.js";import{n as d}from"./react-vendor-VqdnQHHS.js";import{H as f,ct as p,dt as m,ht as h,ut as g,x as _}from"./index-BFKildY3.js";var v=e(a(),1),y=d();function b(e){return e===`connected`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-destructive/12 text-destructive`:e===`disabled`?`bg-muted text-muted-foreground`:`bg-amber-500/12 text-amber-700 dark:text-amber-300`}var x=12;function S({server:e,toggling:n,reconnecting:i,onToggle:a,onEdit:s,onDelete:c,onReconnect:l}){let d=e.tools?.slice(0,x)??[],f=e.toolCount??e.tools?.length??0,p=Math.max(0,f-d.length),_=e.enabled&&e.status!==`connected`;return(0,y.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.name}),(0,y.jsx)(`span`,{className:m(`rounded-full px-2 py-0.5 text-[11px]`,b(e.status)),children:e.status||`unknown`}),(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:h(`mcpToolsCount`,{count:f})})]}),(0,y.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground/65`,children:e.transport===`stdio`?`${e.command} ${(e.args||[]).join(` `)}`:e.url}),e.error?(0,y.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:e.error}):null]}),(0,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:n,className:m(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>a(e),title:e.enabled?h(`pauseTask`):h(`enable`),children:(0,y.jsx)(`span`,{className:m(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-5`:`translate-x-0`)})}),_?(0,y.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>l(e.name),disabled:i,"aria-label":h(`mcpReconnectServer`),title:h(`mcpReconnectServer`),children:i?(0,y.jsx)(t,{className:`size-4 animate-spin`}):(0,y.jsx)(u,{className:`size-4`})}):null,(0,y.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>s(e),"aria-label":h(`editTask`),title:h(`editTask`),children:(0,y.jsx)(r,{className:`size-4`})}),(0,y.jsx)(g,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-destructive`,onClick:()=>c(e.name),"aria-label":h(`delete`),title:h(`delete`),children:(0,y.jsx)(o,{className:`size-4`})})]})]}),d.length>0?(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[d.map(e=>(0,y.jsx)(`span`,{className:`rounded-md bg-muted/28 px-1.5 py-0.5 text-[11px] text-muted-foreground/75`,title:e.quickForgeName,children:e.name},e.quickForgeName)),p>0?(0,y.jsx)(`span`,{className:`rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/55`,children:h(`mcpMoreTools`,{count:p})}):null]}):null]})}function C(){return{name:``,transport:`stdio`,command:``,args:[],url:``,cwd:``,env:{}}}function w(e){return{name:e.name,transport:e.transport,command:e.command,args:e.args||[],url:e.url||``,cwd:e.cwd||``,env:e.env||{}}}function T(e){return(e||[]).join(`
2
2
  `)}function E(e){return Object.entries(e||{}).map(([e,t])=>`${e}=${t}`).join(`
3
3
  `)}function D(e){return e.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean)}function O(e){let t={};for(let n of e.split(`
5
- `)){let e=n.trim();if(!e)continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&(t[i]=a)}return t}function k(e){let t={type:e.transport||`stdio`};e.transport===`stdio`?(t.command=e.command||``,t.args=e.args||[],e.cwd&&(t.cwd=e.cwd),e.env&&Object.keys(e.env).length>0&&(t.env=e.env)):(t.url=e.url||``,e.env&&Object.keys(e.env).length>0&&(t.headers=e.env));let n=e.name||`server`;return JSON.stringify({mcpServers:{[n]:t}},null,2)}function A(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function j(e){let t;try{t=JSON.parse(e)}catch{throw Error(g(`mcpInvalidJson`))}if(!A(t))throw Error(g(`mcpInvalidConfigJson`));let n=``,r=null;if(A(t.mcpServers)){let e=Object.entries(t.mcpServers);if(e.length===0)throw Error(g(`mcpEmptyConfigJson`));let[i,a]=e[0];n=i,A(a)&&(r=a)}else r=t;if(!r)throw Error(g(`mcpInvalidConfigJson`));let i=String(r.transport||r.type||`stdio`);if(![`stdio`,`http`,`sse`].includes(i))throw Error(g(`mcpInvalidTransport`,{name:n||`server`}));let a=r.env??r.headers??{};return{name:n,transport:i,command:String(r.command||``),args:Array.isArray(r.args)?r.args:[],url:String(r.url||``),cwd:String(r.cwd||``),env:A(a)?a:{}}}var M=`mb-1 block text-xs text-muted-foreground/72`,N=`min-h-20 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,P=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm outline-none focus:border-ring`;function F({value:e,onChange:t,isEdit:n,disabled:r}){let i=e.transport===`stdio`,a=n=>t({...e,...n});return(0,y.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground/60`,children:g(n?`mcpEditServer`:`mcpAddServer`)}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-name`,children:g(`mcpServerName`)}),(0,y.jsx)(p,{id:`mcp-server-name`,value:e.name,onChange:e=>a({name:e.target.value}),placeholder:g(`mcpNamePlaceholder`),disabled:n||r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-transport`,children:g(`mcpTransport`)}),(0,y.jsxs)(`select`,{id:`mcp-server-transport`,className:P,value:e.transport,onChange:e=>a({transport:e.target.value}),disabled:r,children:[(0,y.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,y.jsx)(`option`,{value:`http`,children:`http`}),(0,y.jsx)(`option`,{value:`sse`,children:`sse`})]})]}),i?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-command`,children:g(`mcpCommand`)}),(0,y.jsx)(p,{id:`mcp-server-command`,value:e.command,onChange:e=>a({command:e.target.value}),placeholder:g(`mcpCommandPlaceholder`),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-args`,children:g(`mcpArgs`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-args`,className:N,value:T(e.args),onChange:e=>a({args:D(e.target.value)}),spellCheck:!1,disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-cwd`,children:g(`mcpCwd`)}),(0,y.jsx)(p,{id:`mcp-server-cwd`,value:e.cwd,onChange:e=>a({cwd:e.target.value}),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-env`,children:g(`mcpEnv`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-env`,className:N,value:E(e.env),onChange:e=>a({env:O(e.target.value)}),spellCheck:!1,disabled:r})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-url`,children:g(`mcpUrl`)}),(0,y.jsx)(p,{id:`mcp-server-url`,value:e.url,onChange:e=>a({url:e.target.value}),placeholder:g(`mcpUrlPlaceholder`),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-headers`,children:g(`mcpHeaders`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-headers`,className:N,value:E(e.env),onChange:e=>a({env:O(e.target.value)}),spellCheck:!1,disabled:r})]})]})]})}async function I(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function L({active:e=!0,className:r}){let[a,o]=(0,v.useState)([]),[u,d]=(0,v.useState)(!1),[p,b]=(0,v.useState)(!1),[x,T]=(0,v.useState)(new Set),[E,D]=(0,v.useState)(null),[O,A]=(0,v.useState)(``),[M,N]=(0,v.useState)(!1),[P,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(C),[B,V]=(0,v.useState)(`form`),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(``),K=(0,v.useCallback)(e=>{o(e?.servers??[])},[]),q=(0,v.useCallback)(async()=>{d(!0),A(``);try{K(await I(await fetch(`/api/mcp/servers`)))}catch(e){A(e instanceof Error?e.message:g(`mcpLoadFailed`))}finally{d(!1)}},[K]);if((0,v.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{q()},0);return()=>window.clearTimeout(t)},[e,q]),!e)return null;let J=e=>{e===`json`&&(U(k(R)),G(``)),V(e)},Y=()=>{L(null),z(C()),V(`form`),N(!0),A(``)},X=e=>{let t=w(e);L(e),z(t),U(k(t)),G(``),V(`form`),N(!0),A(``)},Z=()=>{N(!1),L(null),U(``),G(``),A(``)},Q=e=>{z(e)},ee=e=>{U(e);try{let t=j(e);z(e=>({...t,name:t.name||e.name})),G(``)}catch(e){G(e instanceof Error?e.message:g(`mcpInvalidJson`))}},te=async()=>{if(!p){if(W&&B===`json`){A(W);return}b(!0),A(``);try{K(await I(await fetch(`/api/mcp/servers`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({server:{...R,enabled:P?.enabled??!0}})}))),Z()}catch(e){A(e instanceof Error?e.message:g(`mcpSaveFailed`))}finally{b(!1)}}},ne=async e=>{if(await f({description:g(`mcpDeleteConfirm`,{name:e}),confirmLabel:g(`confirmDelete`),cancelLabel:g(`cancel`),variant:`destructive`})){A(``);try{K(await I(await fetch(`/api/mcp/servers/${encodeURIComponent(e)}`,{method:`DELETE`})))}catch(e){A(e instanceof Error?e.message:g(`mcpDeleteFailed`))}}},re=async e=>{if(!x.has(e.name)){T(t=>new Set(t).add(e.name)),A(``);try{K(await I(await fetch(`/api/mcp/servers/${encodeURIComponent(e.name)}/enabled`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})})))}catch(e){A(e instanceof Error?e.message:g(`mcpSaveFailed`))}finally{T(t=>{let n=new Set(t);return n.delete(e.name),n})}}},ie=async()=>{d(!0),A(``);try{K(await I(await fetch(`/api/mcp/reconnect`,{method:`POST`})))}catch(e){A(e instanceof Error?e.message:g(`mcpReconnectFailed`))}finally{d(!1)}},ae=async e=>{if(!E){D(e),A(``);try{K(await I(await fetch(`/api/mcp/reconnect/${encodeURIComponent(e)}`,{method:`POST`})))}catch(e){A(e instanceof Error?e.message:g(`mcpReconnectFailed`))}finally{D(null)}}},$=!!P,oe=!!R.name.trim()&&!!(R.transport===`stdio`?R.command.trim():R.url.trim());return M?(0,y.jsxs)(`div`,{className:h(`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,r),children:[(0,y.jsx)(`div`,{className:`border-b border-border px-6 py-5`,children:(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,onClick:Z,children:[(0,y.jsx)(i,{className:`size-4`}),g(`mcpConfiguredServers`)]}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-foreground/90`,children:g($?`mcpEditServer`:`mcpAddServer`)})]})}),O?(0,y.jsx)(`div`,{className:`m-6 mb-0 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:O}):null,(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,y.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,y.jsxs)(`div`,{className:`flex border-b border-border`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>J(`form`),className:h(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,B===`form`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,y.jsx)(s,{className:`size-3.5`}),g(`mcpTabServer`)]}),(0,y.jsxs)(`button`,{type:`button`,onClick:()=>J(`json`),className:h(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,B===`json`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,y.jsx)(c,{className:`size-3.5`}),g(`mcpTabJson`)]})]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:B===`form`?(0,y.jsx)(F,{value:R,onChange:Q,isEdit:$,disabled:p}):(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`textarea`,{className:`min-h-96 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,value:H,onChange:e=>ee(e.target.value),spellCheck:!1}),W?(0,y.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:W}):null,(0,y.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-foreground/90`,children:[g(`mcpTabJson`),(0,y.jsx)(_,{label:g(`mcpImportConfigDescription`)})]})]})}),(0,y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border pt-3`,children:[(0,y.jsx)(m,{type:`button`,variant:`outline`,size:`sm`,onClick:Z,disabled:p,children:g(`cancel`)}),(0,y.jsxs)(m,{type:`button`,size:`sm`,onClick:()=>{te()},disabled:p||!oe,children:[p?(0,y.jsx)(t,{className:`mr-1.5 size-3.5 animate-spin`}):null,g(`save`)]})]})]})})]}):(0,y.jsxs)(`div`,{className:h(`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,r),children:[(0,y.jsx)(`div`,{className:`border-b border-border px-6 py-5`,children:(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,y.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:g(`mcpConfiguredServers`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:Y,children:[(0,y.jsx)(n,{className:`mr-1.5 size-3.5`}),g(`mcpAddServer`)]}),(0,y.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:ie,disabled:u,children:[u?(0,y.jsx)(t,{className:`mr-1.5 size-3.5 animate-spin`}):(0,y.jsx)(l,{className:`mr-1.5 size-3.5`}),g(`mcpReconnect`)]})]})]})}),O?(0,y.jsx)(`div`,{className:`m-6 mb-0 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:O}):null,(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,y.jsx)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:u&&a.length===0?(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border py-8 text-sm text-muted-foreground`,children:[(0,y.jsx)(t,{className:`size-4 animate-spin`}),g(`loading`)]}):a.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/15 p-4 text-sm text-muted-foreground/72`,children:g(`mcpNoServersDescription`)}):a.map(e=>(0,y.jsx)(S,{server:e,toggling:x.has(e.name),reconnecting:E===e.name,onToggle:e=>{re(e)},onEdit:X,onDelete:e=>{ne(e)},onReconnect:e=>{ae(e)}},e.name))})})]})}export{L as McpServersPanel};
5
+ `)){let e=n.trim();if(!e)continue;let r=e.indexOf(`=`);if(r<=0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&(t[i]=a)}return t}function k(e){let t={type:e.transport||`stdio`};e.transport===`stdio`?(t.command=e.command||``,t.args=e.args||[],e.cwd&&(t.cwd=e.cwd),e.env&&Object.keys(e.env).length>0&&(t.env=e.env)):(t.url=e.url||``,e.env&&Object.keys(e.env).length>0&&(t.headers=e.env));let n=e.name||`server`;return JSON.stringify({mcpServers:{[n]:t}},null,2)}function A(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function j(e){let t;try{t=JSON.parse(e)}catch{throw Error(h(`mcpInvalidJson`))}if(!A(t))throw Error(h(`mcpInvalidConfigJson`));let n=``,r=null;if(A(t.mcpServers)){let e=Object.entries(t.mcpServers);if(e.length===0)throw Error(h(`mcpEmptyConfigJson`));let[i,a]=e[0];n=i,A(a)&&(r=a)}else r=t;if(!r)throw Error(h(`mcpInvalidConfigJson`));let i=String(r.transport||r.type||`stdio`);if(![`stdio`,`http`,`sse`].includes(i))throw Error(h(`mcpInvalidTransport`,{name:n||`server`}));let a=r.env??r.headers??{};return{name:n,transport:i,command:String(r.command||``),args:Array.isArray(r.args)?r.args:[],url:String(r.url||``),cwd:String(r.cwd||``),env:A(a)?a:{}}}var M=`mb-1 block text-xs text-muted-foreground/72`,N=`min-h-20 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,P=`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm outline-none focus:border-ring`;function F({value:e,onChange:t,isEdit:n,disabled:r}){let i=e.transport===`stdio`,a=n=>t({...e,...n});return(0,y.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground/60`,children:h(n?`mcpEditServer`:`mcpAddServer`)}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-name`,children:h(`mcpServerName`)}),(0,y.jsx)(_,{id:`mcp-server-name`,value:e.name,onChange:e=>a({name:e.target.value}),placeholder:h(`mcpNamePlaceholder`),disabled:n||r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-transport`,children:h(`mcpTransport`)}),(0,y.jsxs)(`select`,{id:`mcp-server-transport`,className:P,value:e.transport,onChange:e=>a({transport:e.target.value}),disabled:r,children:[(0,y.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,y.jsx)(`option`,{value:`http`,children:`http`}),(0,y.jsx)(`option`,{value:`sse`,children:`sse`})]})]}),i?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-command`,children:h(`mcpCommand`)}),(0,y.jsx)(_,{id:`mcp-server-command`,value:e.command,onChange:e=>a({command:e.target.value}),placeholder:h(`mcpCommandPlaceholder`),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-args`,children:h(`mcpArgs`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-args`,className:N,value:T(e.args),onChange:e=>a({args:D(e.target.value)}),spellCheck:!1,disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-cwd`,children:h(`mcpCwd`)}),(0,y.jsx)(_,{id:`mcp-server-cwd`,value:e.cwd,onChange:e=>a({cwd:e.target.value}),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-env`,children:h(`mcpEnv`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-env`,className:N,value:E(e.env),onChange:e=>a({env:O(e.target.value)}),spellCheck:!1,disabled:r})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-url`,children:h(`mcpUrl`)}),(0,y.jsx)(_,{id:`mcp-server-url`,value:e.url,onChange:e=>a({url:e.target.value}),placeholder:h(`mcpUrlPlaceholder`),disabled:r})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:M,htmlFor:`mcp-server-headers`,children:h(`mcpHeaders`)}),(0,y.jsx)(`textarea`,{id:`mcp-server-headers`,className:N,value:E(e.env),onChange:e=>a({env:O(e.target.value)}),spellCheck:!1,disabled:r})]})]})]})}async function I(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function L({active:e=!0,className:r}){let[a,o]=(0,v.useState)([]),[u,d]=(0,v.useState)(!1),[_,b]=(0,v.useState)(!1),[x,T]=(0,v.useState)(new Set),[E,D]=(0,v.useState)(null),[O,A]=(0,v.useState)(``),[M,N]=(0,v.useState)(!1),[P,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(C),[B,V]=(0,v.useState)(`form`),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(``),K=(0,v.useCallback)(e=>{o(e?.servers??[])},[]),q=(0,v.useCallback)(async()=>{d(!0),A(``);try{K(await I(await fetch(`/api/mcp/servers`)))}catch(e){A(e instanceof Error?e.message:h(`mcpLoadFailed`))}finally{d(!1)}},[K]);if((0,v.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{q()},0);return()=>window.clearTimeout(t)},[e,q]),!e)return null;let J=e=>{e===`json`&&(U(k(R)),G(``)),V(e)},Y=()=>{L(null),z(C()),V(`form`),N(!0),A(``)},X=e=>{let t=w(e);L(e),z(t),U(k(t)),G(``),V(`form`),N(!0),A(``)},Z=()=>{N(!1),L(null),U(``),G(``),A(``)},Q=e=>{z(e)},ee=e=>{U(e);try{let t=j(e);z(e=>({...t,name:t.name||e.name})),G(``)}catch(e){G(e instanceof Error?e.message:h(`mcpInvalidJson`))}},te=async()=>{if(!_){if(W&&B===`json`){A(W);return}b(!0),A(``);try{K(await I(await fetch(`/api/mcp/servers`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({server:{...R,enabled:P?.enabled??!0}})}))),Z()}catch(e){A(e instanceof Error?e.message:h(`mcpSaveFailed`))}finally{b(!1)}}},ne=async e=>{if(await f({description:h(`mcpDeleteConfirm`,{name:e}),confirmLabel:h(`confirmDelete`),cancelLabel:h(`cancel`),variant:`destructive`})){A(``);try{K(await I(await fetch(`/api/mcp/servers/${encodeURIComponent(e)}`,{method:`DELETE`})))}catch(e){A(e instanceof Error?e.message:h(`mcpDeleteFailed`))}}},re=async e=>{if(!x.has(e.name)){T(t=>new Set(t).add(e.name)),A(``);try{K(await I(await fetch(`/api/mcp/servers/${encodeURIComponent(e.name)}/enabled`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})})))}catch(e){A(e instanceof Error?e.message:h(`mcpSaveFailed`))}finally{T(t=>{let n=new Set(t);return n.delete(e.name),n})}}},ie=async()=>{d(!0),A(``);try{K(await I(await fetch(`/api/mcp/reconnect`,{method:`POST`})))}catch(e){A(e instanceof Error?e.message:h(`mcpReconnectFailed`))}finally{d(!1)}},ae=async e=>{if(!E){D(e),A(``);try{K(await I(await fetch(`/api/mcp/reconnect/${encodeURIComponent(e)}`,{method:`POST`})))}catch(e){A(e instanceof Error?e.message:h(`mcpReconnectFailed`))}finally{D(null)}}},$=!!P,oe=!!R.name.trim()&&!!(R.transport===`stdio`?R.command.trim():R.url.trim());return M?(0,y.jsxs)(`div`,{className:m(`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,r),children:[(0,y.jsx)(`div`,{className:`border-b border-border px-6 py-5`,children:(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,onClick:Z,children:[(0,y.jsx)(i,{className:`size-4`}),h(`mcpConfiguredServers`)]}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-foreground/90`,children:h($?`mcpEditServer`:`mcpAddServer`)})]})}),O?(0,y.jsx)(`div`,{className:`m-6 mb-0 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:O}):null,(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,y.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,y.jsxs)(`div`,{className:`flex border-b border-border`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>J(`form`),className:m(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,B===`form`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,y.jsx)(s,{className:`size-3.5`}),h(`mcpTabServer`)]}),(0,y.jsxs)(`button`,{type:`button`,onClick:()=>J(`json`),className:m(`flex flex-1 items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors`,B===`json`?`border-b-2 border-primary text-foreground/90 -mb-px`:`text-muted-foreground/60 hover:text-foreground/85`),children:[(0,y.jsx)(c,{className:`size-3.5`}),h(`mcpTabJson`)]})]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:B===`form`?(0,y.jsx)(F,{value:R,onChange:Q,isEdit:$,disabled:_}):(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`textarea`,{className:`min-h-96 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,value:H,onChange:e=>ee(e.target.value),spellCheck:!1}),W?(0,y.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:W}):null,(0,y.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-foreground/90`,children:[h(`mcpTabJson`),(0,y.jsx)(p,{label:h(`mcpImportConfigDescription`)})]})]})}),(0,y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border pt-3`,children:[(0,y.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:Z,disabled:_,children:h(`cancel`)}),(0,y.jsxs)(g,{type:`button`,size:`sm`,onClick:()=>{te()},disabled:_||!oe,children:[_?(0,y.jsx)(t,{className:`mr-1.5 size-3.5 animate-spin`}):null,h(`save`)]})]})]})})]}):(0,y.jsxs)(`div`,{className:m(`flex min-h-0 flex-1 flex-col overflow-hidden bg-background`,r),children:[(0,y.jsx)(`div`,{className:`border-b border-border px-6 py-5`,children:(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,y.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:h(`mcpConfiguredServers`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(g,{type:`button`,variant:`ghost`,size:`sm`,onClick:Y,children:[(0,y.jsx)(n,{className:`mr-1.5 size-3.5`}),h(`mcpAddServer`)]}),(0,y.jsxs)(g,{type:`button`,variant:`ghost`,size:`sm`,onClick:ie,disabled:u,children:[u?(0,y.jsx)(t,{className:`mr-1.5 size-3.5 animate-spin`}):(0,y.jsx)(l,{className:`mr-1.5 size-3.5`}),h(`mcpReconnect`)]})]})]})}),O?(0,y.jsx)(`div`,{className:`m-6 mb-0 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:O}):null,(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,y.jsx)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:u&&a.length===0?(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border py-8 text-sm text-muted-foreground`,children:[(0,y.jsx)(t,{className:`size-4 animate-spin`}),h(`loading`)]}):a.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/15 p-4 text-sm text-muted-foreground/72`,children:h(`mcpNoServersDescription`)}):a.map(e=>(0,y.jsx)(S,{server:e,toggling:x.has(e.name),reconnecting:E===e.name,onToggle:e=>{re(e)},onEdit:X,onDelete:e=>{ne(e)},onReconnect:e=>{ae(e)}},e.name))})})]})}export{L as McpServersPanel};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-DWdDZTNf.js";import{B as n,It as r,Rt as i,Vt as a,_ as o,n as s}from"./icons-C7j5jdKo.js";import{n as c}from"./react-vendor-VqdnQHHS.js";import{lt as l,pt as u,st as d}from"./index-_ut7awrd.js";var f=t({SkillsDialog:()=>_,SkillsManagerPanel:()=>g}),p=e(a(),1),m=c();async function h(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function g({active:e=!0,scope:t,project:a,embedded:c=!1,onClose:f,onSaved:g}){let[_,v]=(0,p.useState)([]),[y,b]=(0,p.useState)(()=>new Set),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)([]),[T,E]=(0,p.useState)(!1),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(``),j=t===`project`,[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[I,L]=(0,p.useState)(!1),[R,z]=(0,p.useState)(``),B=(0,p.useCallback)(()=>{N(null),F(null),z(``)},[]),V=(0,p.useCallback)(()=>{B(),f?.()},[f,B]);(0,p.useEffect)(()=>{if(!e||j&&!a)return;let t=!1;return(async()=>{E(!0),A(``);try{let e=j?`/api/skills?projectId=${encodeURIComponent(a.id)}`:`/api/skills?scope=global`,n=await h(await fetch(e));if(t)return;v(Array.isArray(n.skills)?n.skills:[]),b(new Set(Array.isArray(n.selectedSkills)?n.selectedSkills:[])),w(Array.isArray(n.searchPaths)?n.searchPaths:[])}catch(e){t||A(e instanceof Error?e.message:u(`failedToLoadSkills`))}finally{t||E(!1)}})(),()=>{t=!0}},[e,a,j]),(0,p.useEffect)(()=>{if(!e||c)return;let t=e=>{e.key===`Escape`&&(M?B():D||V())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,V,c,D,M,B]);let H=(0,p.useMemo)(()=>{let e=x.trim().toLowerCase();return e?_.filter(t=>[t.name,t.displayName,t.description,t.source,t.compatibility,t.allowedTools,...t.tags??[],...t.triggers??[]].filter(Boolean).join(` `).toLowerCase().includes(e)):_},[x,_]),U=async e=>{N(e),F(null),z(``),L(!0);try{let t=new URLSearchParams({name:e});j&&a?(t.set(`scope`,`project`),t.set(`projectId`,a.id)):t.set(`scope`,`global`),F(await h(await fetch(`/api/skills/content?${t}`)))}catch(e){z(e instanceof Error?e.message:u(`failedToReadSkill`))}finally{L(!1)}};if(!e||j&&!a)return null;let W=e=>{if(D)return;let t=new Set(y);t.has(e)?t.delete(e):t.add(e),b(t),G(t)},G=async e=>{O(!0),A(``);try{let n=await h(await fetch(j?`/api/skills/project`:`/api/skills/global`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(j?{projectId:a.id,selectedSkills:[...e]}:{selectedSkills:[...e]})}));g({scope:t,project:j?n.projects?.find(e=>e.id===a.id)??{...a,skills:n.selectedSkills}:void 0,projects:n.projects,selectedSkills:n.selectedSkills})}catch(e){b(y),A(e instanceof Error?e.message:u(`failedToSaveSkills`))}finally{O(!1)}},K=u(j?`projectSkills`:`globalSkills`),q=j?u(`projectSkillsDescription`,{project:a.name}):u(`globalSkillsDescription`),J=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`quickforge-settings-divider p-3`,children:(0,m.jsxs)(`div`,{className:`quickforge-settings-inline-field`,children:[(0,m.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`}),(0,m.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),placeholder:u(`searchSkills`),className:`quickforge-settings-input`,disabled:T||D})]})}),k?(0,m.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:k}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsx)(`span`,{className:`quickforge-settings-row-title`,children:u(`availableSkills`)}),(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:u(`selectedSkillsCount`,{count:y.size})})]}),(0,m.jsx)(`div`,{className:c?``:`max-h-[46vh] overflow-y-auto`,children:T?(0,m.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,m.jsx)(n,{className:`size-4 animate-spin`}),u(`loading`)]}):H.length===0?(0,m.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:u(`noMatchingSkills`)}):H.map(e=>{let t=y.has(e.name);return(0,m.jsxs)(`div`,{className:l(`quickforge-settings-list-item`,t&&`bg-muted/12`),children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,m.jsx)(`div`,{className:`quickforge-settings-row-title`,children:e.displayName||e.name}),e.description?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[e.source?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.source}):null,e.compatibility?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.compatibility}):null,e.allowedTools?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.allowedTools}):null,e.tags?.slice(0,5).map(e=>(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,m.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":D?`true`:`false`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:t,disabled:D,onChange:()=>W(e.name),"aria-label":t?`Disable ${e.name}`:`Enable ${e.name}`}),(0,m.jsx)(`span`,{"aria-hidden":`true`})]}),(0,m.jsx)(`button`,{type:`button`,className:`quickforge-settings-icon-action`,onClick:()=>void U(e.name),disabled:D||I,title:u(`readSkill`),"aria-label":`${u(`readSkill`)}: ${e.displayName||e.name}`,children:(0,m.jsx)(r,{className:`size-4`})})]})]},e.name)})})]}),Y=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`quickforge-settings-button quickforge-settings-button-secondary`,onClick:B,disabled:I,children:[(0,m.jsx)(i,{className:`mr-2 size-4`}),u(`backToSkillList`)]}),(0,m.jsx)(`div`,{className:`quickforge-settings-row-main min-w-0`,children:(0,m.jsx)(`div`,{className:`quickforge-settings-row-title truncate`,children:P?.displayName||P?.name||M})})]}),(0,m.jsx)(`div`,{className:`p-4`,children:I?(0,m.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,m.jsx)(n,{className:`size-4 animate-spin`}),u(`loading`)]}):R?(0,m.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:R}):P?(0,m.jsxs)(m.Fragment,{children:[P.description?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description mb-3`,children:P.description}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-meta mb-3`,children:[P.version?(0,m.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[`v`,P.version]}):null,P.source?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.source}):null,P.compatibility?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.compatibility}):null,P.allowedTools?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.allowedTools}):null,P.license?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.license}):null,P.tags?.map(e=>(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e},e))]}),P.triggers?.length?(0,m.jsxs)(`div`,{className:`quickforge-settings-row-description mb-3`,children:[`Triggers: `,P.triggers.join(`, `)]}):null,P.instructions?(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-md border border-border bg-muted/30 px-4 py-3 font-mono text-sm leading-6 text-foreground/80`,children:P.instructions}):(0,m.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:u(`noSkillContent`)})]}):null})]});return c?(0,m.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,m.jsx)(`section`,{className:`quickforge-settings-section`,"aria-label":K,children:M?Y:(0,m.jsxs)(m.Fragment,{children:[C.length?(0,m.jsx)(`div`,{className:`px-5 pt-4`,children:(0,m.jsxs)(`span`,{className:`quickforge-settings-row-description break-all`,children:[u(`skillSearchPaths`),`: `,C.join(` · `)]})}):null,J]})})}):(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!D&&V()},children:(0,m.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-quickforge`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[K,(0,m.jsx)(d,{label:q})]}),(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:q}),C.length?(0,m.jsxs)(`div`,{className:`quickforge-settings-row-description break-all`,children:[u(`skillSearchPaths`),`: `,C.join(` · `)]}):null]}),(0,m.jsx)(`button`,{type:`button`,className:`quickforge-settings-icon-action`,onClick:V,disabled:D,"aria-label":u(`close`),children:(0,m.jsx)(s,{className:`size-4`})})]}),(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:M?Y:J})]})})}function _({open:e,scope:t,project:n,onOpenChange:r,onSaved:i}){return(0,m.jsx)(g,{active:e,scope:t,project:n,onClose:()=>r(!1),onSaved:i})}export{f as n,_ as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-DWdDZTNf.js";import{B as n,It as r,Rt as i,Vt as a,_ as o,n as s}from"./icons-C7j5jdKo.js";import{n as c}from"./react-vendor-VqdnQHHS.js";import{ct as l,dt as u,ht as d}from"./index-BFKildY3.js";var f=t({SkillsDialog:()=>_,SkillsManagerPanel:()=>g}),p=e(a(),1),m=c();async function h(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function g({active:e=!0,scope:t,project:a,embedded:c=!1,onClose:f,onSaved:g}){let[_,v]=(0,p.useState)([]),[y,b]=(0,p.useState)(()=>new Set),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)([]),[T,E]=(0,p.useState)(!1),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(``),j=t===`project`,[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[I,L]=(0,p.useState)(!1),[R,z]=(0,p.useState)(``),B=(0,p.useCallback)(()=>{N(null),F(null),z(``)},[]),V=(0,p.useCallback)(()=>{B(),f?.()},[f,B]);(0,p.useEffect)(()=>{if(!e||j&&!a)return;let t=!1;return(async()=>{E(!0),A(``);try{let e=j?`/api/skills?projectId=${encodeURIComponent(a.id)}`:`/api/skills?scope=global`,n=await h(await fetch(e));if(t)return;v(Array.isArray(n.skills)?n.skills:[]),b(new Set(Array.isArray(n.selectedSkills)?n.selectedSkills:[])),w(Array.isArray(n.searchPaths)?n.searchPaths:[])}catch(e){t||A(e instanceof Error?e.message:d(`failedToLoadSkills`))}finally{t||E(!1)}})(),()=>{t=!0}},[e,a,j]),(0,p.useEffect)(()=>{if(!e||c)return;let t=e=>{e.key===`Escape`&&(M?B():D||V())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,V,c,D,M,B]);let H=(0,p.useMemo)(()=>{let e=x.trim().toLowerCase();return e?_.filter(t=>[t.name,t.displayName,t.description,t.source,t.compatibility,t.allowedTools,...t.tags??[],...t.triggers??[]].filter(Boolean).join(` `).toLowerCase().includes(e)):_},[x,_]),U=async e=>{N(e),F(null),z(``),L(!0);try{let t=new URLSearchParams({name:e});j&&a?(t.set(`scope`,`project`),t.set(`projectId`,a.id)):t.set(`scope`,`global`),F(await h(await fetch(`/api/skills/content?${t}`)))}catch(e){z(e instanceof Error?e.message:d(`failedToReadSkill`))}finally{L(!1)}};if(!e||j&&!a)return null;let W=e=>{if(D)return;let t=new Set(y);t.has(e)?t.delete(e):t.add(e),b(t),G(t)},G=async e=>{O(!0),A(``);try{let n=await h(await fetch(j?`/api/skills/project`:`/api/skills/global`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(j?{projectId:a.id,selectedSkills:[...e]}:{selectedSkills:[...e]})}));g({scope:t,project:j?n.projects?.find(e=>e.id===a.id)??{...a,skills:n.selectedSkills}:void 0,projects:n.projects,selectedSkills:n.selectedSkills})}catch(e){b(y),A(e instanceof Error?e.message:d(`failedToSaveSkills`))}finally{O(!1)}},K=d(j?`projectSkills`:`globalSkills`),q=j?d(`projectSkillsDescription`,{project:a.name}):d(`globalSkillsDescription`),J=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`quickforge-settings-divider p-3`,children:(0,m.jsxs)(`div`,{className:`quickforge-settings-inline-field`,children:[(0,m.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/60`}),(0,m.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),placeholder:d(`searchSkills`),className:`quickforge-settings-input`,disabled:T||D})]})}),k?(0,m.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:k}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsx)(`span`,{className:`quickforge-settings-row-title`,children:d(`availableSkills`)}),(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-info`,children:d(`selectedSkillsCount`,{count:y.size})})]}),(0,m.jsx)(`div`,{className:c?``:`max-h-[46vh] overflow-y-auto`,children:T?(0,m.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,m.jsx)(n,{className:`size-4 animate-spin`}),d(`loading`)]}):H.length===0?(0,m.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`noMatchingSkills`)}):H.map(e=>{let t=y.has(e.name);return(0,m.jsxs)(`div`,{className:u(`quickforge-settings-list-item`,t&&`bg-muted/12`),children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item-main`,children:[(0,m.jsx)(`div`,{className:`quickforge-settings-row-title`,children:e.displayName||e.name}),e.description?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:e.description}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-meta`,children:[e.source?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.source}):null,e.compatibility?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.compatibility}):null,e.allowedTools?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e.allowedTools}):null,e.tags?.slice(0,5).map(e=>(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`quickforge-settings-list-item-actions`,onClick:e=>e.stopPropagation(),children:[(0,m.jsxs)(`label`,{className:`quickforge-settings-switch`,"aria-disabled":D?`true`:`false`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:t,disabled:D,onChange:()=>W(e.name),"aria-label":t?`Disable ${e.name}`:`Enable ${e.name}`}),(0,m.jsx)(`span`,{"aria-hidden":`true`})]}),(0,m.jsx)(`button`,{type:`button`,className:`quickforge-settings-icon-action`,onClick:()=>void U(e.name),disabled:D||I,title:d(`readSkill`),"aria-label":`${d(`readSkill`)}: ${e.displayName||e.name}`,children:(0,m.jsx)(r,{className:`size-4`})})]})]},e.name)})})]}),Y=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`quickforge-settings-button quickforge-settings-button-secondary`,onClick:B,disabled:I,children:[(0,m.jsx)(i,{className:`mr-2 size-4`}),d(`backToSkillList`)]}),(0,m.jsx)(`div`,{className:`quickforge-settings-row-main min-w-0`,children:(0,m.jsx)(`div`,{className:`quickforge-settings-row-title truncate`,children:P?.displayName||P?.name||M})})]}),(0,m.jsx)(`div`,{className:`p-4`,children:I?(0,m.jsxs)(`div`,{className:`quickforge-settings-empty-row inline-flex items-center gap-2`,children:[(0,m.jsx)(n,{className:`size-4 animate-spin`}),d(`loading`)]}):R?(0,m.jsx)(`div`,{className:`quickforge-settings-alert quickforge-settings-warning-attached`,children:R}):P?(0,m.jsxs)(m.Fragment,{children:[P.description?(0,m.jsx)(`div`,{className:`quickforge-settings-row-description mb-3`,children:P.description}):null,(0,m.jsxs)(`div`,{className:`quickforge-settings-meta mb-3`,children:[P.version?(0,m.jsxs)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:[`v`,P.version]}):null,P.source?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.source}):null,P.compatibility?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.compatibility}):null,P.allowedTools?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.allowedTools}):null,P.license?(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:P.license}):null,P.tags?.map(e=>(0,m.jsx)(`span`,{className:`quickforge-settings-badge quickforge-settings-badge-muted`,children:e},e))]}),P.triggers?.length?(0,m.jsxs)(`div`,{className:`quickforge-settings-row-description mb-3`,children:[`Triggers: `,P.triggers.join(`, `)]}):null,P.instructions?(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-md border border-border bg-muted/30 px-4 py-3 font-mono text-sm leading-6 text-foreground/80`,children:P.instructions}):(0,m.jsx)(`div`,{className:`quickforge-settings-empty-row`,children:d(`noSkillContent`)})]}):null})]});return c?(0,m.jsx)(`div`,{className:`quickforge-settings-stack`,children:(0,m.jsx)(`section`,{className:`quickforge-settings-section`,"aria-label":K,children:M?Y:(0,m.jsxs)(m.Fragment,{children:[C.length?(0,m.jsx)(`div`,{className:`px-5 pt-4`,children:(0,m.jsxs)(`span`,{className:`quickforge-settings-row-description break-all`,children:[d(`skillSearchPaths`),`: `,C.join(` · `)]})}):null,J]})})}):(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!D&&V()},children:(0,m.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-quickforge`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-toolbar`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-main`,children:[(0,m.jsxs)(`div`,{className:`quickforge-settings-row-title`,children:[K,(0,m.jsx)(l,{label:q})]}),(0,m.jsx)(`div`,{className:`quickforge-settings-row-description`,children:q}),C.length?(0,m.jsxs)(`div`,{className:`quickforge-settings-row-description break-all`,children:[d(`skillSearchPaths`),`: `,C.join(` · `)]}):null]}),(0,m.jsx)(`button`,{type:`button`,className:`quickforge-settings-icon-action`,onClick:V,disabled:D,"aria-label":d(`close`),children:(0,m.jsx)(s,{className:`size-4`})})]}),(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:M?Y:J})]})})}function _({open:e,scope:t,project:n,onOpenChange:r,onSaved:i}){return(0,m.jsx)(g,{active:e,scope:t,project:n,onClose:()=>r(!1),onSaved:i})}export{f as n,_ as t};
package/dist/index.html CHANGED
@@ -11,7 +11,7 @@
11
11
  <meta name="apple-mobile-web-app-title" content="QuickForge" />
12
12
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
13
13
  <title>速构 QuickForge</title>
14
- <script type="module" crossorigin src="/assets/index-_ut7awrd.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-BFKildY3.js"></script>
15
15
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-DWdDZTNf.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/pi-ai-Cr3rpCXT.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/lit-vendor-Dr3cpBGF.js">
@@ -20,9 +20,9 @@
20
20
  <link rel="modulepreload" crossorigin href="/assets/icons-C7j5jdKo.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-VqdnQHHS.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/logger-B65Akg8A.js">
23
- <link rel="modulepreload" crossorigin href="/assets/index-_ut7awrd.js">
24
- <link rel="modulepreload" crossorigin href="/assets/skills-dialog-Mnj8fZwq.js">
25
- <link rel="stylesheet" crossorigin href="/assets/index-Qof73j0o.css">
23
+ <link rel="modulepreload" crossorigin href="/assets/index-BFKildY3.js">
24
+ <link rel="modulepreload" crossorigin href="/assets/skills-dialog-DcxeFWSt.js">
25
+ <link rel="stylesheet" crossorigin href="/assets/index-CsKSKUn-.css">
26
26
  </head>
27
27
  <body>
28
28
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shawnstack/quickforge",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "AI chat application with Agent access modes for local workspace tools. React + Vite + Tailwind CSS frontend, local Node.js storage server.",
5
5
  "keywords": [
6
6
  "ai",
@@ -5,7 +5,7 @@ import path from 'node:path'
5
5
  import { Agent } from '@earendil-works/pi-agent-core'
6
6
  import { streamSimpleWithAiHttpLogging } from './ai-http-logger.mjs'
7
7
  import { loadSkillToolContext, abortRunningCommand } from './tools/index.mjs'
8
- import { createSkillTools, workspaceTools } from './tools/definitions.mjs'
8
+ import { createSkillTools, globalMemoryTool, workspaceTools } from './tools/definitions.mjs'
9
9
  import { createMcpToolDefinitions, isMcpToolName } from './mcp/registry.mjs'
10
10
  import { createPluginToolDefinitions, isPluginToolName } from './plugins/registry.mjs'
11
11
  import {
@@ -28,6 +28,7 @@ import {
28
28
  import { projectContextFromId, defaultGlobalWorkspaceContext, readProjectConfig } from './project-config.mjs'
29
29
  import { ensureStorage, readStore, atomicUpdate, atomicSessionMetadataUpdate, readSessionValue, writeSessionValue, deleteSessionValue, tempAgentsDir } from './storage.mjs'
30
30
  import { logger } from './utils/logger.mjs'
31
+ import { getGlobalMemoryRevision, isGlobalMemoryEnabled } from './global-memory.mjs'
31
32
  import { buildSystemPrompt, generateAiTitle, generateTitle } from './session-utils.mjs'
32
33
  import { restoreReasoningContentInPayload } from './reasoning-cache.mjs'
33
34
  import {
@@ -111,6 +112,10 @@ async function createServerTools(projectId, projectContext, skillsContext, inclu
111
112
  .filter(isAllowed)
112
113
  .map((definition) => wrapToolDefinition(definition, toolContext, toolPermissions))
113
114
 
115
+ if (!allowedTools && await isGlobalMemoryEnabled()) {
116
+ tools.push(wrapToolDefinition(globalMemoryTool, toolContext, toolPermissions))
117
+ }
118
+
114
119
  if (includeWorkspaceTools && projectContext) {
115
120
  const definitions = workspaceTools.filter((definition) => includeSubagentTool || definition.name !== 'run_subagent')
116
121
  tools.push(...definitions
@@ -132,13 +137,21 @@ async function createServerTools(projectId, projectContext, skillsContext, inclu
132
137
  }
133
138
 
134
139
  async function rebuildSessionTools(session) {
140
+ const profileToolNames = Array.isArray(session.agentProfile?.allowedTools) ? session.agentProfile.allowedTools : null
135
141
  session.agent.state.tools = await createServerTools(
136
142
  session.projectId,
137
143
  session.projectContext,
138
144
  sessionSkillsContext(session),
139
145
  !!session.projectContext,
140
146
  createCommandToolPermissions(session),
141
- { parentSessionId: session.sessionId },
147
+ session.agentProfile
148
+ ? {
149
+ allowedToolNames: profileToolNames,
150
+ includeSubagentTool: false,
151
+ includeMcpTools: false,
152
+ parentSessionId: session.sessionId,
153
+ }
154
+ : { parentSessionId: session.sessionId },
142
155
  )
143
156
  }
144
157
 
@@ -1314,6 +1327,28 @@ export function touchSession(sessionId) {
1314
1327
  return false
1315
1328
  }
1316
1329
 
1330
+ function agentProfileSystemPrompt(agentProfile) {
1331
+ return agentProfile?.systemPrompt
1332
+ ? `\n\n<agent_profile_instructions>\nAgent Profile: ${agentProfile.label || agentProfile.name}\n${agentProfile.systemPrompt}\n</agent_profile_instructions>`
1333
+ : ''
1334
+ }
1335
+
1336
+ async function resolvedSessionSystemPrompt(projectId, agentProfile) {
1337
+ return `${await buildSystemPrompt(projectId)}${agentProfileSystemPrompt(agentProfile)}`
1338
+ }
1339
+
1340
+ async function refreshMemoryState(session) {
1341
+ const memoryEnabled = await isGlobalMemoryEnabled()
1342
+ const memoryRevision = memoryEnabled ? await getGlobalMemoryRevision() : null
1343
+ if (session.memoryEnabled === memoryEnabled && session.memoryRevision === memoryRevision) return
1344
+ session.memoryEnabled = memoryEnabled
1345
+ session.memoryRevision = memoryRevision
1346
+ if (session.managedSystemPrompt !== false) {
1347
+ session.agent.state.systemPrompt = await resolvedSessionSystemPrompt(session.projectId, session.agentProfile)
1348
+ }
1349
+ await rebuildSessionTools(session)
1350
+ }
1351
+
1317
1352
  /**
1318
1353
  * Create or retrieve an Agent for a session.
1319
1354
  * If the session already has a running agent, return it.
@@ -1368,7 +1403,7 @@ export async function createAgent(sessionId, config = {}) {
1368
1403
  globalSkillNames: projectConfig.globalSkills,
1369
1404
  projectSkillNames: configuredProject?.skills,
1370
1405
  }
1371
- const profileSystemPrompt = agentProfile?.systemPrompt ? `\n\n<agent_profile_instructions>\nAgent Profile: ${agentProfile.label || agentProfile.name}\n${agentProfile.systemPrompt}\n</agent_profile_instructions>` : ''
1406
+ const profileSystemPrompt = agentProfileSystemPrompt(agentProfile)
1372
1407
  const resolvedSystemPrompt = systemPrompt ?? `${await buildSystemPrompt(projectId)}${profileSystemPrompt}`
1373
1408
 
1374
1409
  let resolvedAgentProfile = agentProfile
@@ -1429,6 +1464,8 @@ export async function createAgent(sessionId, config = {}) {
1429
1464
  }
1430
1465
  }
1431
1466
 
1467
+ const initialMemoryEnabled = await isGlobalMemoryEnabled()
1468
+ const initialMemoryRevision = initialMemoryEnabled ? await getGlobalMemoryRevision() : null
1432
1469
  let session
1433
1470
  const agent = new Agent({
1434
1471
  initialState: {
@@ -1455,6 +1492,7 @@ export async function createAgent(sessionId, config = {}) {
1455
1492
  const isSkillTool = toolName === 'activate_skill' || toolName === 'read_skill_resource'
1456
1493
  if (isSkillTool) return undefined
1457
1494
  if (profileToolNames && !profileToolNames.includes(toolName)) return { block: true, reason: `Agent profile ${agentProfile.name} is not allowed to use ${toolName}.` }
1495
+ if (toolName === 'manage_global_memory') return undefined
1458
1496
  if (toolName === 'run_subagent') {
1459
1497
  const requested = context.args?.subagent
1460
1498
  const policy = requested && typeof requested === 'object' ? normalizeCapabilityPolicy(requested.capabilityPolicy || 'readonly-research', Array.isArray(requested.tools) ? requested.tools : []) : null
@@ -1517,6 +1555,9 @@ export async function createAgent(sessionId, config = {}) {
1517
1555
  stateVersion: 0,
1518
1556
  lastAutoCompactAt: null,
1519
1557
  lastAutoCompactRejected: null,
1558
+ memoryEnabled: initialMemoryEnabled,
1559
+ memoryRevision: initialMemoryRevision,
1560
+ managedSystemPrompt: systemPrompt == null,
1520
1561
  /** Track active SSE connections. Only one SSE stream allowed per session to prevent
1521
1562
  * connection-pool exhaustion when two browser tabs load the same session. */
1522
1563
  sseConnected: false,
@@ -1864,6 +1905,7 @@ export async function runPrompt(sessionId, message, selectedCapabilities = [], p
1864
1905
  throw Object.assign(new Error('Generation is still running. Stop it or wait until it finishes.'), { statusCode: 409 })
1865
1906
  }
1866
1907
 
1908
+ await refreshMemoryState(session)
1867
1909
  resetIdleTimer(session)
1868
1910
 
1869
1911
  // Build user message
@@ -22,6 +22,7 @@ export const commandRestrictedTools = new Set([
22
22
  'edit_file',
23
23
  'run_command',
24
24
  'run_subagent',
25
+ 'manage_global_memory',
25
26
  ])
26
27
 
27
28
  export const planAllowedTools = new Set([
@@ -99,6 +100,9 @@ export function commandToolPermissionError(session, toolName) {
99
100
  if ((toolName === 'write_file' || toolName === 'edit_file') && permissions.allowEdit === false) {
100
101
  return `Command /${session.activeCommandName} does not allow editing files.`
101
102
  }
103
+ if (toolName === 'manage_global_memory' && permissions.allowEdit === false) {
104
+ return `Command /${session.activeCommandName} does not allow editing global memory.`
105
+ }
102
106
  return null
103
107
  }
104
108
 
@@ -0,0 +1,168 @@
1
+ import { createHash, randomUUID } from 'node:crypto'
2
+ import { promises as fs } from 'node:fs'
3
+ import path from 'node:path'
4
+ import { dataDir, readStore } from './storage.mjs'
5
+
6
+ export const GLOBAL_MEMORY_SETTINGS_KEY = 'memory-settings'
7
+ export const GLOBAL_MEMORY_FILE_NAME = 'MEMORY.md'
8
+ export const DEFAULT_GLOBAL_MEMORY_SETTINGS = { enabled: true }
9
+
10
+ const MAX_MEMORY_FILE_BYTES = 16 * 1024
11
+
12
+ let memoryWriteQueue = Promise.resolve()
13
+
14
+ export function normalizeGlobalMemorySettings(value) {
15
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return { ...DEFAULT_GLOBAL_MEMORY_SETTINGS }
16
+ return { enabled: value.enabled !== false }
17
+ }
18
+
19
+ export async function readGlobalMemorySettings() {
20
+ const settings = await readStore('settings')
21
+ return normalizeGlobalMemorySettings(settings?.[GLOBAL_MEMORY_SETTINGS_KEY])
22
+ }
23
+
24
+ export async function isGlobalMemoryEnabled() {
25
+ return (await readGlobalMemorySettings()).enabled
26
+ }
27
+
28
+ export function globalMemoryFilePath(baseDir = dataDir) {
29
+ return path.join(baseDir, GLOBAL_MEMORY_FILE_NAME)
30
+ }
31
+
32
+ function requestError(message, statusCode = 400) {
33
+ const error = new Error(message)
34
+ error.statusCode = statusCode
35
+ return error
36
+ }
37
+
38
+ export function containsSensitiveMemory(value) {
39
+ const text = String(value || '')
40
+ const patterns = [
41
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----/i,
42
+ /\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|AKIA[A-Z0-9]{16})\b/,
43
+ /\bauthorization\s*:\s*bearer\s+\S+/i,
44
+ /\bcookie\s*:\s*\S+/i,
45
+ /\b(?:api[ _-]?key|access[ _-]?token|refresh[ _-]?token|password|passwd|secret)\s*(?:is|是|为|:|=)\s*\S{8,}/i,
46
+ /(?:^|\n)\s*[A-Z][A-Z0-9_]{2,}\s*=\s*[^\s]{8,}(?:\n|$)/,
47
+ ]
48
+ return patterns.some((pattern) => pattern.test(text))
49
+ }
50
+
51
+ function validateGlobalMemoryMarkdown(markdown) {
52
+ if (typeof markdown !== 'string') throw requestError('Memory Markdown is required.')
53
+ if (Buffer.byteLength(markdown, 'utf8') > MAX_MEMORY_FILE_BYTES) throw requestError('Global memory exceeds the size limit.')
54
+ if (containsSensitiveMemory(markdown)) throw requestError('Sensitive credentials or secrets cannot be stored in global memory.')
55
+ return markdown
56
+ }
57
+
58
+ export async function getGlobalMemoryRevision(options = {}) {
59
+ const file = globalMemoryFilePath(options.dataDir)
60
+ try {
61
+ const content = await fs.readFile(file)
62
+ return createHash('sha256').update(content).digest('hex')
63
+ } catch (error) {
64
+ if (error?.code === 'ENOENT') return null
65
+ throw error
66
+ }
67
+ }
68
+
69
+ export async function readGlobalMemory(options = {}) {
70
+ const file = globalMemoryFilePath(options.dataDir)
71
+ try {
72
+ const markdown = await fs.readFile(file, 'utf8')
73
+ return { file, markdown }
74
+ } catch (error) {
75
+ if (error?.code === 'ENOENT') return { file, markdown: '' }
76
+ throw error
77
+ }
78
+ }
79
+
80
+ export async function readGlobalMemoryDocument(options = {}) {
81
+ const memory = await readGlobalMemory(options)
82
+ return {
83
+ enabled: options.enabled === undefined ? await isGlobalMemoryEnabled() : options.enabled,
84
+ markdown: memory.markdown,
85
+ path: '~/.quickforge/MEMORY.md',
86
+ }
87
+ }
88
+
89
+ async function writeGlobalMemoryMarkdown(markdown, options = {}) {
90
+ const file = globalMemoryFilePath(options.dataDir)
91
+ await fs.mkdir(path.dirname(file), { recursive: true })
92
+ const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`
93
+ await fs.writeFile(temporary, markdown, 'utf8')
94
+ await fs.rename(temporary, file)
95
+ return file
96
+ }
97
+
98
+ function withMemoryWriteLock(operation) {
99
+ const result = memoryWriteQueue.then(operation, operation)
100
+ memoryWriteQueue = result.catch(() => undefined)
101
+ return result
102
+ }
103
+
104
+ async function assertMemoryEnabled(options) {
105
+ const enabled = options.enabled === undefined ? await isGlobalMemoryEnabled() : options.enabled
106
+ if (!enabled) throw requestError('Global memory is disabled in Settings.', 403)
107
+ }
108
+
109
+ export async function saveGlobalMemoryDocument(markdown, options = {}) {
110
+ await assertMemoryEnabled(options)
111
+ const validated = validateGlobalMemoryMarkdown(markdown)
112
+ return withMemoryWriteLock(async () => {
113
+ const file = await writeGlobalMemoryMarkdown(validated, options)
114
+ return {
115
+ enabled: true,
116
+ markdown: validated,
117
+ path: '~/.quickforge/MEMORY.md',
118
+ file,
119
+ chars: validated.length,
120
+ }
121
+ })
122
+ }
123
+
124
+ export async function readGlobalMemoryPrompt(options = {}) {
125
+ if (options.enabled === false) return null
126
+ if (options.enabled === undefined && !(await isGlobalMemoryEnabled())) return null
127
+ const memory = await readGlobalMemory(options)
128
+ return {
129
+ source: '~/.quickforge/MEMORY.md',
130
+ content: memory.markdown.trim() || null,
131
+ enabled: true,
132
+ }
133
+ }
134
+
135
+ export async function manageGlobalMemory(params = {}, options = {}) {
136
+ await assertMemoryEnabled(options)
137
+ const action = String(params.action || '').trim().toLowerCase()
138
+
139
+ if (action === 'read') {
140
+ const memory = await readGlobalMemory(options)
141
+ return {
142
+ content: memory.markdown || 'Global user memory is empty.',
143
+ details: {
144
+ action,
145
+ status: memory.markdown ? 'loaded' : 'empty',
146
+ markdown: memory.markdown,
147
+ chars: memory.markdown.length,
148
+ path: '~/.quickforge/MEMORY.md',
149
+ },
150
+ }
151
+ }
152
+
153
+ if (action === 'write') {
154
+ const saved = await saveGlobalMemoryDocument(params.markdown, options)
155
+ return {
156
+ content: 'Global user memory saved.',
157
+ details: {
158
+ action,
159
+ status: 'saved',
160
+ markdown: saved.markdown,
161
+ chars: saved.chars,
162
+ path: saved.path,
163
+ },
164
+ }
165
+ }
166
+
167
+ throw requestError('Memory action must be read or write.')
168
+ }
package/server/index.mjs CHANGED
@@ -14,6 +14,7 @@ import { handleProjectApi } from './routes/project.mjs'
14
14
  import { handleFilesystemApi, setActiveWorkspaceRootForFilesystem } from './routes/filesystem.mjs'
15
15
  import { handleToolApi, handleGetTools } from './routes/tools.mjs'
16
16
  import { handleInstructionsApi } from './routes/instructions.mjs'
17
+ import { handleMemoryApi } from './routes/memory.mjs'
17
18
  import { handleSkillsApi } from './routes/skills.mjs'
18
19
  import { handleAgentApi } from './routes/agent.mjs'
19
20
  import { handleAgentProfilesApi } from './routes/agent-profiles.mjs'
@@ -312,6 +313,12 @@ async function handleApi(req, res, url) {
312
313
  return
313
314
  }
314
315
 
316
+ // Global user memory
317
+ if (pathname === '/api/memory') {
318
+ await handleMemoryApi(req, res)
319
+ return
320
+ }
321
+
315
322
  // Agent profiles
316
323
  if (pathname === '/api/agent-profiles' || pathname.startsWith('/api/agent-profiles/')) {
317
324
  await handleAgentProfilesApi(req, res, url)
@@ -6,6 +6,7 @@ import { existsSync, promises as fs } from 'node:fs'
6
6
  import { ensureProjectCache, readProjectConfigData, atomicProjectConfigUpdate, dataDir, readStore, atomicUpdate } from './storage.mjs'
7
7
  import { setWorkspaceRoot, assertDirectory } from './utils/workspace.mjs'
8
8
  import { loadSelectedGlobalSkills, loadSelectedProjectSkills, mergeSkills } from './skills.mjs'
9
+ import { readGlobalMemoryPrompt } from './global-memory.mjs'
9
10
 
10
11
  let defaultWorkspaceRoot = ''
11
12
 
@@ -403,6 +404,7 @@ export async function buildInstructionsPayload(projectId) {
403
404
  ? await loadSelectedProjectSkills(project.skills, project.path)
404
405
  : []
405
406
  const activeSkills = mergeSkills(globalSkills, projectSkills)
407
+ const globalMemory = await readGlobalMemoryPrompt()
406
408
  const stripRuntimeFields = ({ rootDir: _rootDir, instructions: _instructions, location: _location, ...skill }) => skill
407
409
 
408
410
  return {
@@ -417,6 +419,7 @@ export async function buildInstructionsPayload(projectId) {
417
419
  project: projectInstructions,
418
420
  globalSources: globalInstructionSources,
419
421
  projectSources: projectInstructionSources,
422
+ globalMemory,
420
423
  globalSkills: globalSkills.map(stripRuntimeFields),
421
424
  projectSkills: projectSkills.map(stripRuntimeFields),
422
425
  skills: activeSkills.map(stripRuntimeFields),