@inkeep/open-knowledge 0.39.0-beta.8 → 0.40.0-beta.0
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.
- package/dist/{acp-harness-probe-DjTv5e1A.mjs → acp-harness-probe-Bhi4Llqu.mjs} +2 -2
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +4 -4
- package/dist/assets/skills/write-skill/SKILL.md +1 -1
- package/dist/{banner-_FQsQkvC.mjs → banner--DGfdMN8.mjs} +2 -2
- package/dist/cli.mjs +61 -61
- package/dist/{colors-_gzKDfrv.mjs → colors-BsmVIwfM.mjs} +1 -1
- package/dist/colors-MGDi6UGf.mjs +1 -0
- package/dist/config-schema.json +31 -0
- package/dist/config.project.schema.json +31 -0
- package/dist/constants-C5569GdH.mjs +2 -0
- package/dist/dist-bundle-BT5p_5Yl.mjs +1 -0
- package/dist/{dist-bundle-vlpIc23T.mjs → dist-bundle-CFfKBclM.mjs} +1 -1
- package/dist/fs-traced-BfHcMmET.mjs +1 -0
- package/dist/{fs-traced-vMO6kYgZ.mjs → fs-traced-CyCraqZx.mjs} +3 -3
- package/dist/{git-handle-YzX39hWc.mjs → git-handle-BvHrr8BH.mjs} +2 -2
- package/dist/git-handle-Do3oiyRv.mjs +1 -0
- package/dist/index.d.mts +25 -17
- package/dist/index.mjs +1 -1
- package/dist/init-ByFsxFwA.mjs +1 -0
- package/dist/{init-B_KvF9QQ.mjs → init-ExES21Y6.mjs} +9 -9
- package/dist/{is-object-Bw0-z8qH.mjs → is-object-ByG7RnjH.mjs} +1 -1
- package/dist/{launch-json-removal-DaC6MWYi.mjs → launch-json-removal-DPv1JCcm.mjs} +2 -2
- package/dist/loader-DR445aRM.mjs +1 -0
- package/dist/{loader-DkorwqUF.mjs → loader-ieLA3dNB.mjs} +2 -2
- package/dist/md-manager-DU8cDKTu.mjs +2 -0
- package/dist/native/native-config.darwin-arm64.node +0 -0
- package/dist/native/native-config.darwin-x64.node +0 -0
- package/dist/native/native-config.linux-arm64-gnu.node +0 -0
- package/dist/native/native-config.linux-arm64-musl.node +0 -0
- package/dist/native/native-config.linux-x64-musl.node +0 -0
- package/dist/native/native-config.win32-arm64-msvc.node +0 -0
- package/dist/native/native-config.win32-x64-msvc.node +0 -0
- package/dist/{open-browser-kdF24mgk.mjs → open-browser-DuW0JuiI.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-Bce8FXXe.mjs → preview-BomWJpxb.mjs} +2 -2
- package/dist/preview-CzenDf6w.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-But5j0lr.js → ActivityModeContent-CXKjTMzk.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-oydx_GOA.js → AgentDiffPane-sDXcTCmp.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-BKKe4a6D.js → AgentThreadClientBinder-CpSn5y_B.js} +1 -1
- package/dist/public/assets/CodeMirrorPropInput-BbkcIhWZ.js +3 -0
- package/dist/public/assets/{CopyButton-D0gTyMvW.js → CopyButton-Cbumgow3.js} +1 -1
- package/dist/public/assets/DocumentContext-D8AcgFCE.js +38 -0
- package/dist/public/assets/{EnableSyncConfirmDialog-CbuJxerH.js → EnableSyncConfirmDialog-BS38VGMB.js} +1 -1
- package/dist/public/assets/FeedbackForm-BaEEePNZ.js +1 -0
- package/dist/public/assets/{GraphPanel-CDzcx7vs.js → GraphPanel-YytKkcWc.js} +2 -2
- package/dist/public/assets/{ManagedArtifactProperties-BB3-9OBw.js → ManagedArtifactProperties-CUEp_TTL.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-OqDOF7x4.js → McpConsentDialogBody-55HPQg6h.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-B6KK6qX2.js → MermaidDocEditor-DSOgLfw2.js} +1 -1
- package/dist/public/assets/{PropertyPanel-CinI1G1g.js → PropertyPanel-BCaH4sHq.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-BMOl6KV7.js → ReportBugDialogBody-CclyuUz8.js} +1 -1
- package/dist/public/assets/SettingsDialogBody-D0NhLCiz.js +7 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-CzeHnBZ6.js → ShareBranchSwitchDialog-COlZI5OE.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-DGTKtAY6.js → ShareReceiveDialog-B6PbEmCF.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-BS5BCjjQ.js → ShareReceiveMissDialog-By8esj_5.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-ZkQKiOQc.js → SkillEditorActions-BgwpFpi1.js} +1 -1
- package/dist/public/assets/{SourceEditor-4CJXi9kJ.js → SourceEditor-DxRPfKvz.js} +1 -1
- package/dist/public/assets/{TerminalPanel-DyJkPAsZ.js → TerminalPanel-D-hojFQG.js} +1 -1
- package/dist/public/assets/{TerminalSessionsHost-CaOjEcgq.js → TerminalSessionsHost-41AB3mFJ.js} +2 -2
- package/dist/public/assets/{TerminalWindowApp-C2al62bW.js → TerminalWindowApp-CZ7Efhd5.js} +1 -1
- package/dist/public/assets/ThreadView-Dk1Lkb4i.js +6 -0
- package/dist/public/assets/{TimelineDiffPane-C8Qnc4zA.js → TimelineDiffPane-BdeqO5w9.js} +1 -1
- package/dist/public/assets/{agent-diff-store-D5yp573E.js → agent-diff-store-DZZjM0GE.js} +1 -1
- package/dist/public/assets/{agent-visibility-BUmsS0vL.js → agent-visibility-DPFbzl9a.js} +1 -1
- package/dist/public/assets/auth-state-cache-w1vT3ODb.js +11 -0
- package/dist/public/assets/client-version-CF0d0O9l.js +1 -0
- package/dist/public/assets/{config-provider-BvPGEDTw.js → config-provider-U3uVQf2B.js} +2 -2
- package/dist/public/assets/{dist-DRspkp5n.js → dist-BXtMv5Fj.js} +1 -1
- package/dist/public/assets/{dist-CDKZLcnD.js → dist-DGxOU4wq.js} +98 -98
- package/dist/public/assets/{doc-hash-r2oc1gt-.js → doc-hash-C29Il1da.js} +1 -1
- package/dist/public/assets/documents-events-C3fByfiC.js +1 -0
- package/dist/public/assets/{file-tree-adapter-DOr3Nip1.js → file-tree-adapter-azEoLHfQ.js} +1 -1
- package/dist/public/assets/follow-file-grI1hNx7.js +1 -0
- package/dist/public/assets/index-BxtMW1aW.css +1 -0
- package/dist/public/assets/index-CTYMeNHV.js +2022 -0
- package/dist/public/assets/{keyboard-shortcuts-maIyJzSw.js → keyboard-shortcuts-OXotyOGw.js} +1 -1
- package/dist/public/assets/lint-config-client-DvKzk8M8.js +1 -0
- package/dist/public/assets/{navigation-targets-DhXblHdl.js → navigation-targets-iYhj2VsX.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-DokRsPIe.js → open-managed-artifact-tab-Z57LM2Z4.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-DYgvjLiq.js → pending-receive-nav-store-DG2tvh9-.js} +1 -1
- package/dist/public/assets/{prop-types-IOhQSrD8.js → prop-types-Cl0YMuHg.js} +1 -1
- package/dist/public/assets/{receive-store-BwEPjiP1.js → receive-store-COHKqsBX.js} +1 -1
- package/dist/public/assets/{selection-context-TzGfTWCl.js → selection-context-eU_Qktbs.js} +1 -1
- package/dist/public/assets/separator-Cvkbg_YK.js +1 -0
- package/dist/public/assets/{skill-actions-CzuWC1X5.js → skill-actions-CCrGq1Wm.js} +1 -1
- package/dist/public/assets/{skills-api-CGbwE9vp.js → skills-api-CwVreKtE.js} +1 -1
- package/dist/public/assets/{src-4ThOx6_s.js → src-BlFvgbgm.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-Beex9QTj.js → target-navigation-intent-D6vBZdSf.js} +1 -1
- package/dist/public/assets/{telemetry-impl-C3Xj4Jzm.js → telemetry-impl-Cc4_2Kuv.js} +1 -1
- package/dist/public/assets/{telemetry-startup-mmznflLy.js → telemetry-startup-CusPaTq7.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-C2tfnQr1.js → terminal-launch-events-6XYN8k0p.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-zqEIM46I.js → terminal-telemetry-q3LpCe-1.js} +1 -1
- package/dist/public/assets/thread-client-DyotU42S.js +1 -0
- package/dist/public/assets/typing-burst-detector-QvmBKNOB.js +6 -0
- package/dist/public/assets/use-activity-panel-DvA9ZLA6.js +1 -0
- package/dist/public/assets/{use-apply-config-color-theme-Ccfxcl-K.js → use-apply-config-color-theme-BImxeKNx.js} +2 -2
- package/dist/public/assets/{use-collab-url-Cf1srbbW.js → use-collab-url-CTOu_iWG.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-BpGfJKio.js → use-live-xterm-theme-dAhd07IY.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BEEp7vb7.js → use-terminal-enabled-Bmmmi7AO.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-CJ-IHgH7.js → use-timeline-entry-diff-D6MUvrZG.js} +1 -1
- package/dist/public/assets/{use-workspace-C1D_I03G.js → use-workspace-BtamMVXo.js} +1 -1
- package/dist/public/assets/{workspace-paths-CDfRQ5qH.js → workspace-paths--K9QhxwT.js} +1 -1
- package/dist/public/index.html +45 -45
- package/dist/{repair-launch-json-BDfwi9-9.mjs → repair-launch-json-DdRk9h7e.mjs} +2 -2
- package/dist/{repair-mcp-configs-kCwuW5Ze.mjs → repair-mcp-configs-Bwoyzwk6.mjs} +2 -2
- package/dist/repair-skills-Cdc-D-_T.mjs +1 -0
- package/dist/{repair-skills-BaZcFu4I.mjs → repair-skills-DRI7dgZc.mjs} +2 -2
- package/dist/schemas/v0/config.project.schema.json +31 -0
- package/dist/server-lock-BWzPKU9E.mjs +1 -0
- package/dist/{server-lock-BiAmhJ19.mjs → server-lock-BaFI-pb-.mjs} +2 -2
- package/dist/{sleep-DcENuR74.mjs → sleep-D9-JSiMz.mjs} +24 -24
- package/dist/src-Cp0c_AY8.mjs +22 -0
- package/dist/{src-DhzHOoTy.mjs → src-DSErWJqy.mjs} +1 -1
- package/dist/src-DUna3ewt.mjs +3272 -0
- package/dist/{src-BTo9m5ju.mjs → src-MWQj7voD.mjs} +112 -112
- package/dist/{start-CmXhmoqo.mjs → start-BgYmpGSW.mjs} +2 -2
- package/dist/start-CkPrN2AC.mjs +1 -0
- package/dist/{write-project-skill-Dt58S1kj.mjs → write-project-skill-DeeYFQNz.mjs} +4 -4
- package/package.json +4 -4
- package/dist/colors-CUOU_72x.mjs +0 -1
- package/dist/constants-DtCru_h4.mjs +0 -2
- package/dist/dist-bundle-B-JhpGTG.mjs +0 -1
- package/dist/fs-traced-DOXZOlKx.mjs +0 -1
- package/dist/git-handle-BGt8xT_1.mjs +0 -1
- package/dist/init-C_Z3gBHj.mjs +0 -1
- package/dist/loader-Aakvd0a9.mjs +0 -1
- package/dist/md-manager-DPNbV4Up.mjs +0 -2
- package/dist/preview-8ufWS_Yg.mjs +0 -1
- package/dist/public/assets/CodeMirrorPropInput-Sjp30pzp.js +0 -3
- package/dist/public/assets/DocumentContext-DN3M8p0h.js +0 -38
- package/dist/public/assets/FeedbackForm-MFOBrkxc.js +0 -1
- package/dist/public/assets/SettingsDialogBody-Gk5e3niv.js +0 -7
- package/dist/public/assets/ThreadView-CXI_J3i2.js +0 -4
- package/dist/public/assets/auth-state-cache-CPrBjd7m.js +0 -11
- package/dist/public/assets/client-version-CNNfEvD2.js +0 -1
- package/dist/public/assets/documents-events-DNDUkpJM.js +0 -1
- package/dist/public/assets/download-wdc_OGNY.js +0 -1
- package/dist/public/assets/follow-file-Db721Zx6.js +0 -1
- package/dist/public/assets/index-CJ7E0pG6.css +0 -1
- package/dist/public/assets/index-Lsv_5pDn.js +0 -1995
- package/dist/public/assets/lint-config-client-C7TVN28Z.js +0 -1
- package/dist/public/assets/thread-client-BkoRZOHk.js +0 -1
- package/dist/public/assets/typing-burst-detector-D-Tl1w8f.js +0 -6
- package/dist/public/assets/use-activity-panel-Dth1RWbL.js +0 -1
- package/dist/repair-skills-BunyY3Wb.mjs +0 -1
- package/dist/server-lock-BwO1WEYX.mjs +0 -1
- package/dist/src-BQhUreu4.mjs +0 -22
- package/dist/src-YSGKFci8.mjs +0 -3264
- package/dist/start-Dw3sT0mB.mjs +0 -1
- /package/dist/public/assets/{copy-Dwat-rG5.js → copy-DmfcimOx.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{t}from"./react-JNybMug3.js";import{t as n}from"./compiler-runtime-dQcBxOhn.js";import{$ as r,Q as i,Z as a}from"./dist-CDKZLcnD.js";var o=n(),s=e(t(),1),c=`open-knowledge:lint-config-changed`;function l(){window.dispatchEvent(new CustomEvent(c))}function u(e){let t=()=>e();return window.addEventListener(c,t),()=>window.removeEventListener(c,t)}async function d(e){try{let t=e===void 0?``:`?doc=${encodeURIComponent(e)}`,n=await fetch(`/api/lint/config${t}`);if(!n.ok)return null;let r=await n.json().catch(()=>null),a=i.safeParse(r);return a.success?a.data:(console.warn(`[lint] lint-config response failed schema validation`,a.error.issues),null)}catch{return null}}async function f(e){return(await d(e))?.effective??null}async function p(e){try{let t=e?`?path=${encodeURIComponent(e)}`:``,n=await fetch(`/api/lint/audit${t}`);if(!n.ok)return null;let r=await n.json().catch(()=>null),i=a.safeParse(r);return i.success?i.data:(console.warn(`[lint] audit response failed schema validation`,i.error.issues),null)}catch{return null}}async function m(e){try{let t=await fetch(`/api/lint/fix`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({docName:e})});if(!t.ok){let e=await t.json().catch(()=>null);return{ok:!1,errorDetail:typeof e?.title==`string`?e.title:null}}let n=await t.json().catch(()=>null),i=r.safeParse(n);return i.success?{ok:!0,result:i.data}:(console.warn(`[lint] fix response failed schema validation`,i.error.issues),{ok:!1,errorDetail:null})}catch{return{ok:!1,errorDetail:null}}}async function h(e,t){try{let n=await fetch(`/api/lint/markdownlint-config`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ruleId:e,value:t})});if(!n.ok){let e=await n.json().catch(()=>null);return{ok:!1,errorDetail:typeof e?.title==`string`?e.title:null}}let r=await n.json().catch(()=>null),a=i.safeParse(r);return a.success?{ok:!0,response:a.data}:{ok:!1,errorDetail:null}}catch{return{ok:!1,errorDetail:null}}}function g(e){let t=(0,o.c)(5),[n,r]=(0,s.useState)(null),i,a;t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(null);return}let t=!1,n=()=>{d(e).then(e=>{t||r(e)})};n();let i=u(n);return()=>{t=!0,i()}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,s.useEffect)(i,a);let c;return t[3]===n?c=t[4]:(c={data:n},t[3]=n,t[4]=c),c}function _(){let e=(0,o.c)(4),[t,n]=(0,s.useState)(null),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=!1,t=()=>{d().then(t=>{e||n(t)})};t();let r=u(t);return()=>{e=!0,r()}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,s.useEffect)(r,i);let a;return e[2]===t?a=e[3]:(a={data:t},e[2]=t,e[3]=a),a}export{u as a,h as c,p as i,f as n,g as o,m as r,_ as s,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{t}from"./react-JNybMug3.js";import{t as n}from"./compiler-runtime-dQcBxOhn.js";import{n as r}from"./dist-DwCd6eR-.js";import{t as i}from"./dist-BD3698ve.js";var a=e(t(),1),o=n(),s=64e3;function c(e){if(typeof e!=`object`||!e)return null;let t=e;return t.type===`text`&&typeof t.text==`string`?t.text:null}var l=class{items=[];plan=[];turnActive=!1;tokenUsage=null;terminals={};toolCallIndex=new Map;permissionIndex=new Map;messageIndex=new Map;runtimeConsentIndex=new Map;lastConsentIndex=null;appliedCount=0;dirty=!1;snapshot={items:[],plan:[],turnActive:!1,tokenUsage:null,terminals:{}};sync(e){e.length<this.appliedCount&&this.reset();for(let t=this.appliedCount;t<e.length;t++)this.applyEvent(e[t]);return this.appliedCount=e.length,this.dirty&&=(this.snapshot={items:[...this.items],plan:this.plan,turnActive:this.turnActive,tokenUsage:this.tokenUsage,terminals:{...this.terminals}},!1),this.snapshot}reset(){this.items=[],this.plan=[],this.turnActive=!1,this.tokenUsage=null,this.terminals={},this.toolCallIndex=new Map,this.permissionIndex=new Map,this.messageIndex=new Map,this.runtimeConsentIndex=new Map,this.lastConsentIndex=null,this.appliedCount=0,this.dirty=!0}applyEvent(e){switch(this.dirty=!0,e.kind){case`user_message`:this.items.push({kind:`message`,role:`user`,text:e.content,messageId:`user-${this.items.length}`}),this.messageIndex.clear();break;case`turn_started`:this.turnActive=!0;break;case`turn_ended`:this.turnActive=!1,this.messageIndex.clear();break;case`status`:if(e.status===`exited`&&(this.turnActive=!1),this.lastConsentIndex!==null){let t=this.items[this.lastConsentIndex];t?.kind===`runtime_consent`&&t.install===`running`&&(e.status===`spawning`||e.status===`ready`||e.status===`running`?this.items[this.lastConsentIndex]={...t,install:`done`}:(e.status===`error`||e.status===`exited`)&&(this.items[this.lastConsentIndex]={...t,install:`failed`}))}e.status===`error`&&e.detail?this.items.push({kind:`notice`,text:e.detail,tone:`error`}):e.status===`auth_required`&&e.detail&&this.items.push({kind:`notice`,text:e.detail,tone:`info`});break;case`permission_request`:this.permissionIndex.set(e.requestId,this.items.length),this.items.push({kind:`permission`,requestId:e.requestId,title:e.toolCall.title??`Permission required`,toolKind:e.toolCall.kind??`other`,options:e.options,resolved:null});break;case`permission_resolved`:{let t=this.permissionIndex.get(e.requestId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`permission`)break;this.items[t]={...n,resolved:{optionId:e.optionId,auto:e.auto}};break}case`runtime_consent_request`:this.runtimeConsentIndex.set(e.requestId,this.items.length),this.lastConsentIndex=this.items.length,this.items.push({kind:`runtime_consent`,requestId:e.requestId,runtime:e.runtime,displayName:e.displayName,provides:e.provides,version:e.version,approxSizeMB:e.approxSizeMB,sourceHost:e.sourceHost,agentName:e.agentName,resolved:null,install:null,progress:null});break;case`runtime_consent_resolved`:{let t=this.runtimeConsentIndex.get(e.requestId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`runtime_consent`)break;this.items[t]={...n,resolved:e.decision,install:e.decision===`granted`?`running`:null};break}case`runtime_install_progress`:{if(this.lastConsentIndex===null)break;let t=this.items[this.lastConsentIndex];if(t===void 0||t.kind!==`runtime_consent`)break;this.items[this.lastConsentIndex]={...t,progress:{receivedBytes:e.receivedBytes??0,totalBytes:e.totalBytes??null}};break}case`terminal_created`:this.terminals[e.terminalId]={terminalId:e.terminalId,command:e.command,args:e.args,output:``,truncated:!1,exit:null};break;case`terminal_output`:{let t=this.terminals[e.terminalId];if(t===void 0)break;let n=t.output+e.chunk,r=t.truncated;n.length>s&&(n=n.slice(-s),r=!0),this.terminals[e.terminalId]={...t,output:n,truncated:r};break}case`terminal_exit`:{let t=this.terminals[e.terminalId];if(t===void 0)break;this.terminals[e.terminalId]={...t,exit:{exitCode:e.exitCode,signal:e.signal}};break}case`session_update`:this.applyUpdate(e.update);break;default:break}}pushMessageChunk(e,t,n){let r=`${e}:${t}`,i=this.messageIndex.get(r);if(i!==void 0&&i===this.items.length-1){let e=this.items[i];this.items[i]={...e,text:e.text+n};return}this.messageIndex.set(r,this.items.length),this.items.push({kind:`message`,role:e,text:n,messageId:t})}applyUpdate(e){switch(e.sessionUpdate){case`agent_message_chunk`:{let t=c(e.content);t!==null&&this.pushMessageChunk(`agent`,d(e),t);break}case`agent_thought_chunk`:{let t=c(e.content);t!==null&&this.pushMessageChunk(`thought`,d(e),t);break}case`user_message_chunk`:{let t=c(e.content);t!==null&&this.pushMessageChunk(`user`,d(e),t);break}case`tool_call`:{let t={kind:`tool_call`,toolCallId:e.toolCallId,title:e.title??`Tool call`,toolKind:e.kind??`other`,status:e.status??`pending`,diffs:[],terminalIds:[],content:[],locations:f(e.locations),rawInput:e.rawInput};p(t,e.content),this.toolCallIndex.set(e.toolCallId,this.items.length),this.items.push(t);break}case`tool_call_update`:{let t=this.toolCallIndex.get(e.toolCallId);if(t===void 0)break;let n=this.items[t];if(n.kind!==`tool_call`)break;let r={...n,diffs:[...n.diffs],terminalIds:[...n.terminalIds],content:[...n.content]};e.status&&(r.status=e.status),e.title&&(r.title=e.title),e.locations&&(r.locations=f(e.locations));let i=e.rawInput;i!==void 0&&(r.rawInput=i),p(r,e.content),this.items[t]=r;break}case`plan`:{let t=e.entries;Array.isArray(t)&&(this.plan=t.map(e=>e).filter(e=>typeof e.content==`string`).map(e=>({content:e.content,priority:typeof e.priority==`string`?e.priority:void 0,status:typeof e.status==`string`?e.status:void 0})));break}case`usage_update`:{let t=e;this.tokenUsage={used:typeof t.used==`number`?t.used:void 0,size:typeof t.size==`number`?t.size:void 0};break}default:{let t=e.usage;t!==void 0&&(this.tokenUsage={used:t.used,size:t.size});break}}}};function u(e){let t=e.resolved;if(t===null)return null;if(t.optionId===null)return t.auto?{kind:`dismissed`}:{kind:`denied`,auto:!1,optionName:null};let n=e.options.find(e=>e.optionId===t.optionId);return n===void 0?{kind:`dismissed`}:{kind:n.kind.startsWith(`reject`)?`denied`:`approved`,auto:t.auto,optionName:n.name}}function d(e){let t=e.messageId;return typeof t==`string`?t:`default`}function f(e){return Array.isArray(e)?e.map(e=>e).filter(e=>typeof e.path==`string`).map(e=>({path:e.path,line:typeof e.line==`number`?e.line:void 0})):[]}function p(e,t){if(Array.isArray(t))for(let n of t){let t=n;if(t.type===`diff`&&typeof t.path==`string`&&typeof t.newText==`string`)e.diffs.push({path:t.path,oldText:typeof t.oldText==`string`?t.oldText:null,newText:t.newText});else if(t.type===`terminal`&&typeof t.terminalId==`string`)e.terminalIds.includes(t.terminalId)||e.terminalIds.push(t.terminalId);else if(t.type===`content`){let n=c(t.content);n!==null&&e.content.push(n)}else{let n=c(t);n!==null&&e.content.push(n)}}}var m=500,h=15e3,g=3e4,_=9e4,v=8e3,y=class extends Error{code;constructor(e,t){super(t),this.name=`ThreadResumeError`,this.code=e}},b=class extends Error{constructor(){super(`agent-thread channel is not connected`),this.name=`ThreadChannelUnavailableError`}},x=class{url=null;ws=null;reconnectDelay=m;reconnectTimer=null;threads=new Map;listeners=new Set;pendingCreates=new Map;pendingResumes=new Map;openedArchived=new Set;reqCounter=0;status=`idle`;version=0;setUrl(e){e!==this.url&&(this.url=e,this.teardownSocket(),e===null?this.setStatus(`idle`):this.connect())}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));threadsSnapshot=[];threadsSnapshotVersion=-1;getThreads=()=>(this.threadsSnapshotVersion!==this.version&&(this.threadsSnapshot=[...this.threads.values()].map(e=>e.info).sort((e,t)=>e.createdAt-t.createdAt),this.threadsSnapshotVersion=this.version),this.threadsSnapshot);openTabsSnapshot=[];openTabsSnapshotVersion=-1;getOpenTabs=()=>(this.openTabsSnapshotVersion!==this.version&&(this.openTabsSnapshot=[...this.threads.values()].map(e=>e.info).filter(e=>e.archived!==!0||this.openedArchived.has(e.threadId)).sort((e,t)=>e.createdAt-t.createdAt),this.openTabsSnapshotVersion=this.version),this.openTabsSnapshot);archivedSnapshot=[];archivedSnapshotVersion=-1;getArchivedThreads=()=>(this.archivedSnapshotVersion!==this.version&&(this.archivedSnapshot=[...this.threads.values()].map(e=>e.info).filter(e=>e.archived===!0).sort((e,t)=>t.lastActivityAt-e.lastActivityAt),this.archivedSnapshotVersion=this.version),this.archivedSnapshot);getThread=e=>this.threads.get(e)??null;modelBuilders=new Map;getThreadModel=e=>{let t=this.threads.get(e);if(t===void 0)return null;let n=this.modelBuilders.get(e);return n===void 0&&(n=new l,this.modelBuilders.set(e,n)),n.sync(t.events)};getConnectionStatus=()=>this.status;async createThread(e){this.connectNow(),await this.waitForOpen(v),this.reqCounter+=1;let t=`create-${this.reqCounter}`,n=new Promise((e,n)=>{let r=setTimeout(()=>{this.pendingCreates.delete(t),n(Error(`thread creation timed out`))},g);this.pendingCreates.set(t,{resolve:e,reject:n,timer:r})});return this.send({op:`create`,reqId:t,...e}),n}prompt(e,t){this.reqCounter+=1,this.send({op:`prompt`,threadId:e,reqId:`prompt-${this.reqCounter}`,content:t})}respondPermission(e,t,n){this.send({op:`permission_response`,threadId:e,requestId:t,outcome:n})}respondRuntimeConsent(e,t,n){this.send({op:`runtime_consent_response`,threadId:e,requestId:t,outcome:n})}cancel(e){this.send({op:`cancel`,threadId:e})}setMode(e,t){this.send({op:`set_mode`,threadId:e,modeId:t})}renameThread(e,t){let n=t.trim();n!==``&&this.send({op:`rename`,threadId:e,title:n})}setConfigOption(e,t,n){this.send({op:`set_config_option`,threadId:e,configId:t,value:n})}closeThread(e){let t=this.threads.get(e);if(t?.info.archived===!0){this.send({op:`unsubscribe`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.set(e,{info:t.info,events:[],lastSeq:-1}),this.bump();return}this.send({op:`close`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.delete(e)&&this.bump()}openArchivedThread(e){let t=this.threads.get(e);t===void 0||t.info.archived!==!0||this.openedArchived.has(e)||(this.openedArchived.add(e),this.send({op:`subscribe`,threadId:e,sinceSeq:t.lastSeq+1}),this.bump())}deleteThread(e){this.send({op:`delete`,threadId:e}),this.openedArchived.delete(e),this.modelBuilders.delete(e),this.threads.delete(e)&&this.bump()}async resumeThread(e,t){this.connectNow(),await this.waitForOpen(v),this.reqCounter+=1;let n=`resume-${this.reqCounter}`,r=new Promise((e,t)=>{let r=setTimeout(()=>{this.pendingResumes.delete(n),t(new y(`timeout`,`resume timed out`))},_);this.pendingResumes.set(n,{resolve:e,reject:t,timer:r})});return this.send({op:`resume`,threadId:e,reqId:n,prompt:t}),r}connectNow(){this.url===null||this.ws!==null||(this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectDelay=m,this.connect())}waitForOpen(e){return this.ws!==null&&this.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((t,n)=>{let r=e=>{clearTimeout(a),i(),e?t():n(new b)},i=this.subscribe(()=>{this.ws!==null&&this.ws.readyState===WebSocket.OPEN&&r(!0)}),a=setTimeout(()=>r(!1),e)})}connect(){if(this.url===null)return;this.setStatus(`connecting`);let e;try{e=new WebSocket(this.url)}catch{this.scheduleReconnect();return}this.ws=e,e.onopen=()=>{if(this.ws===e){this.reconnectDelay=m,this.setStatus(`open`),this.send({op:`list`});for(let[e,t]of this.threads)t.info.archived===!0&&!this.openedArchived.has(e)||this.send({op:`subscribe`,threadId:e,sinceSeq:t.lastSeq+1})}},e.onmessage=t=>{if(this.ws!==e||typeof t.data!=`string`)return;let n;try{n=JSON.parse(t.data)}catch{return}this.handleFrame(n)},e.onclose=()=>{this.ws===e&&(this.ws=null,this.setStatus(`closed`),this.scheduleReconnect())},e.onerror=()=>{}}teardownSocket(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);for(let e of this.pendingCreates.values())clearTimeout(e.timer),e.reject(new b);this.pendingCreates.clear();for(let e of this.pendingResumes.values())clearTimeout(e.timer),e.reject(new b);this.pendingResumes.clear();let e=this.ws;if(this.ws=null,e!==null)try{e.close()}catch{}}scheduleReconnect(){if(this.url===null||this.reconnectTimer!==null)return;let e=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*2,h),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}send(e){let t=this.ws;if(!(t===null||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}handleFrame(e){switch(e.op){case`created`:{let t=this.pendingCreates.get(e.reqId);t!==void 0&&(this.pendingCreates.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`threads`:{let t=new Set;for(let n of e.threads){t.add(n.threadId);let e=this.threads.has(n.threadId);this.upsertInfo(n),!e&&n.archived!==!0&&this.send({op:`subscribe`,threadId:n.threadId,sinceSeq:0})}let n=!1;for(let e of Array.from(this.threads.keys()))t.has(e)||(this.threads.delete(e),this.modelBuilders.delete(e),this.openedArchived.delete(e),n=!0);n&&this.bump();return}case`resumed`:{let t=this.pendingResumes.get(e.reqId);t!==void 0&&(this.pendingResumes.delete(e.reqId),clearTimeout(t.timer),t.resolve(e.info)),this.upsertInfo(e.info);return}case`subscribed`:this.upsertInfo(e.info);return;case`info`:this.upsertInfo(e.info);return;case`event`:this.appendEvents(e.threadId,e.seq,[e.event]);return;case`events`:this.appendEvents(e.threadId,e.fromSeq,e.events);return;case`error`:if(e.reqId!==void 0){let t=this.pendingCreates.get(e.reqId);if(t!==void 0){this.pendingCreates.delete(e.reqId),clearTimeout(t.timer),t.reject(Error(e.message));return}let n=this.pendingResumes.get(e.reqId);if(n!==void 0){this.pendingResumes.delete(e.reqId),clearTimeout(n.timer),n.reject(new y(e.code,e.message));return}if(e.reqId.startsWith(`prompt-`)){r.error(i._({id:`XNBGZw`,values:{0:e.message}}));return}}console.warn(`[agent-threads] server error frame:`,e.code,e.message);return;default:return}}appendEvents(e,t,n){let r=this.threads.get(e);if(r===void 0||n.length===0)return;let i=Math.max(r.lastSeq+1-t,0);if(i>=n.length)return;let a=i===0?n:n.slice(i),o=r.info;for(let e of a)o=S(o,e);this.threads.set(e,{info:o,events:[...r.events,...a],lastSeq:t+n.length-1}),this.bump()}upsertInfo(e){let t=this.threads.get(e.threadId);t===void 0?this.threads.set(e.threadId,{info:e,events:[],lastSeq:-1}):e.archived===!0&&t.info.archived!==!0?(this.openedArchived.delete(e.threadId),this.modelBuilders.delete(e.threadId),this.threads.set(e.threadId,{info:e,events:[],lastSeq:-1})):this.threads.set(e.threadId,{...t,info:e}),this.bump()}setStatus(e){this.status!==e&&(this.status=e,this.bump())}bump(){this.version+=1;for(let e of this.listeners)e()}};function S(e,t){switch(t.kind){case`status`:return{...e,status:t.status,lastActivityAt:t.ts};case`title_changed`:return{...e,title:t.title,lastActivityAt:t.ts};default:return{...e,lastActivityAt:t.ts}}}var C=new x;function w(){return C}function T(){return(0,a.useSyncExternalStore)(C.subscribe,C.getOpenTabs,C.getOpenTabs)}function E(){return(0,a.useSyncExternalStore)(C.subscribe,C.getArchivedThreads,C.getArchivedThreads)}function D(e){let t=(0,o.c)(2),n;t[0]===e?n=t[1]:(n=()=>C.getThread(e),t[0]=e,t[1]=n);let r=n;return(0,a.useSyncExternalStore)(C.subscribe,r,r)}function O(e){let t=(0,o.c)(2),n;t[0]===e?n=t[1]:(n=()=>C.getThreadModel(e),t[0]=e,t[1]=n);let r=n;return(0,a.useSyncExternalStore)(C.subscribe,r,r)}function k(){return(0,a.useSyncExternalStore)(C.subscribe,C.getConnectionStatus,C.getConnectionStatus)}function A(e){if(e===null)return null;try{let t=new URL(e);return t.pathname=`/collab/thread`,t.search=``,t.toString()}catch{return null}}export{D as a,E as c,A as i,T as l,y as n,k as o,w as r,O as s,b as t,u};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{t}from"./jsx-runtime-DyiINK0N.js";import{n}from"./DocumentContext-DN3M8p0h.js";import{t as r}from"./react-JNybMug3.js";import{n as i,r as a}from"./dist-DBENJeML.js";import{r as o,t as s}from"./useQuery-NsPxD6kI.js";import{t as c}from"./compiler-runtime-dQcBxOhn.js";import{s as l}from"./createLucideIcon-BUb14crZ.js";import{t as u}from"./button-DHE6Sx02.js";import{n as d,r as f,t as p}from"./collapsible-BIzY37go.js";import{B as m,I as h}from"./CodeMirrorPropInput-Sjp30pzp.js";import{n as g,t as _}from"./toggle-group-CxrQL99E.js";import{Xr as v,fr as y,gt as b,pt as x}from"./dist-CDKZLcnD.js";import{t as S}from"./chevron-right-zaL9JagC.js";import{n as C}from"./CopyButton-D0gTyMvW.js";import{i as w}from"./prop-types-IOhQSrD8.js";import{l as T}from"./workspace-paths-CDfRQ5qH.js";import{t as E}from"./refresh-cw-DSH9Of_0.js";import{t as D}from"./triangle-alert-DpxK7pzx.js";import{t as O}from"./wrench-BDWKT3wQ.js";import{n as k}from"./dist-DwCd6eR-.js";import{t as A}from"./dist-BD3698ve.js";import{i as j}from"./startup-marks-CytO17UM.js";import{a as M,s as N}from"./doc-hash-r2oc1gt-.js";import{t as P}from"./badge-BDZGi1Ks.js";import{a as ee,i as F,n as te,o as ne,r as re,s as ie,t as ae}from"./panel-DLUMbyPl.js";import{t as I}from"./skeleton-CA6hvjst.js";import{i as L,r as R}from"./lint-config-client-C7TVN28Z.js";var z=e(r(),1),B=c(),V=3e4,H=new Map;function U(e){return e?Date.now()-e.rememberedAt>V?null:e.navigation:null}function W(e,t){H.set(e,{navigation:t,rememberedAt:Date.now()})}function G(e){return U(H.get(e))}function K(e){let t=H.get(e);return H.delete(e),U(t)}function q(e){H.delete(e)}function oe(e,t){let n=(0,B.c)(4),r=t===void 0?!1:t,[i,a]=(0,z.useState)(void 0),o=(0,z.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,z.useEffect)(s,c),i}var J=t(),se=300;async function ce(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new m(A._({id:`qAQVSD`}),{cause:e,status:t.status})}if(!t.ok){let e=b.safeParse(n);throw e.success?Error(e.data.title):new m(A._({id:`zlErBl`}),{status:t.status})}let r=x.safeParse(n);if(!r.success)throw new m(A._({id:`XW18jo`}),{status:t.status});return r.data.headings??[]}var le=32,Y=12,X=6,ue=`open-knowledge:outline-nav`;function Z(e){let t=(0,B.c)(2),n;return t[0]===e?n=t[1]:(n=(0,J.jsx)(j,{name:`outline-panel`,children:(0,J.jsx)(de,{...e})}),t[0]=e,t[1]=n),n}function de(e){let t=(0,B.c)(50),{docName:r,isSourceMode:c,className:u}=e,d=u===void 0?``:u,{_:f}=a(),{pages:p,loading:m}=w(),h=o(),{activeProvider:g,activeDocName:_}=n(),v,b;t[0]===r?(v=t[1],b=t[2]):(v=[`page-headings`,r],b=()=>ce(r),t[0]=r,t[1]=v,t[2]=b);let x;t[3]!==r||t[4]!==m||t[5]!==p?(x=!m&&(p.has(r)||y(r)),t[3]=r,t[4]=m,t[5]=p,t[6]=x):x=t[6];let S;t[7]!==v||t[8]!==b||t[9]!==x?(S={queryKey:v,queryFn:b,enabled:x,staleTime:1/0},t[7]=v,t[8]=b,t[9]=x,t[10]=S):S=t[10];let{data:C,isLoading:T,error:E}=s(S),D;t[11]===C?D=t[12]:(D=C===void 0?[]:C,t[11]=C,t[12]=D);let O=D,k,A;t[13]!==_||t[14]!==g||t[15]!==r||t[16]!==h?(k=()=>{if(!g||_!==r)return;let e=g.document,t=null,n=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,h.invalidateQueries({queryKey:[`page-headings`,r]})},se)};return e.on(`update`,n),()=>{e.off(`update`,n),t!==null&&clearTimeout(t)}},A=[g,_,r,h],t[13]=_,t[14]=g,t[15]=r,t[16]=h,t[17]=k,t[18]=A):(k=t[17],A=t[18]),(0,z.useEffect)(k,A);let j;t[19]===O?j=t[20]:(j=O.map(fe),t[19]=O,t[20]=j);let M=oe(j,c),N;t[21]!==M||t[22]!==O?(N=M?O.findIndex(e=>e.slug===M):-1,t[21]=M,t[22]=O,t[23]=N):N=t[23];let P=N,I;t[24]!==r||t[25]!==c?(I=function(e,t){let n={index:e,slug:t,mode:c?`source`:`wysiwyg`};n.mode===`source`&&W(r,{kind:`outline`,detail:n}),window.dispatchEvent(new CustomEvent(ue,{detail:n}))},t[24]=r,t[25]=c,t[26]=I):I=t[26];let L=I,R=((P>=0?O[P].level:1)-1)*Y+(Y-X)/2,V=P*le+(le-X)/2,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,J.jsx)(ie,{children:(0,J.jsx)(i,{id:`dD7NPy`})}),t[27]=H):H=t[27];let U;t[28]!==O.length||t[29]!==T?(U=!T&&(0,J.jsx)(re,{children:O.length}),t[28]=O.length,t[29]=T,t[30]=U):U=t[30];let G;t[31]===U?G=t[32]:(G=(0,J.jsxs)(ne,{children:[H,U]}),t[31]=U,t[32]=G);let K;t[33]!==f||t[34]!==P||t[35]!==M||t[36]!==E||t[37]!==L||t[38]!==O||t[39]!==T||t[40]!==R||t[41]!==V?(K=E?(0,J.jsx)(ee,{className:`px-2`,children:E instanceof Error?E.message:f({id:`GuqOb1`})}):O.length===0&&!T?(0,J.jsx)(F,{className:`px-2`,children:(0,J.jsx)(i,{id:`0BB9ID`})}):(0,J.jsxs)(`nav`,{"aria-label":f({id:`BymzO4`}),className:`relative`,children:[P>=0&&(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:X,height:X,transform:`translate(${R}px, ${V}px)`}}),O.map((e,t)=>{let n=e.slug===M;return(0,J.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>L(t,e.slug),className:l(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*Y+20}px`},title:e.text,children:e.text},t)})]}),t[33]=f,t[34]=P,t[35]=M,t[36]=E,t[37]=L,t[38]=O,t[39]=T,t[40]=R,t[41]=V,t[42]=K):K=t[42];let q;t[43]!==T||t[44]!==K?(q=(0,J.jsx)(te,{className:`px-3 py-2`,"aria-busy":T,children:K}),t[43]=T,t[44]=K,t[45]=q):q=t[45];let Z;return t[46]!==d||t[47]!==G||t[48]!==q?(Z=(0,J.jsxs)(ae,{className:d,children:[G,q]}),t[46]=d,t[47]=G,t[48]=q,t[49]=Z):Z=t[49],Z}function fe(e){return e.slug}function pe(e){let t=(0,B.c)(10),{scope:n,onScopeChange:r}=e,{_:o}=a(),s;t[0]===r?s=t[1]:(s=e=>{e&&r(e)},t[0]=r,t[1]=s);let c;t[2]===o?c=t[3]:(c=o({id:`aBgwis`}),t[2]=o,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,J.jsx)(g,{value:`doc`,className:`flex-1`,"data-testid":`panel-scope-doc`,children:(0,J.jsx)(i,{id:`UpCz01`})}),t[4]=l):l=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,J.jsx)(g,{value:`project`,className:`flex-1`,"data-testid":`panel-scope-project`,children:(0,J.jsx)(i,{id:`e0NrBM`})}),t[5]=u):u=t[5];let d;return t[6]!==n||t[7]!==s||t[8]!==c?(d=(0,J.jsx)(`div`,{className:`shrink-0 px-4 pb-2`,children:(0,J.jsxs)(_,{type:`single`,variant:`segmented`,size:`sm`,spacing:1,value:n,onValueChange:s,"aria-label":c,className:`w-full rounded-md bg-muted p-0.5 dark:bg-background`,children:[l,u]})}),t[6]=n,t[7]=s,t[8]=c,t[9]=d):d=t[9],d}var me=`open-knowledge:lint-nav`;function he(e,t){return e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character}function ge(e){return{line:e.range.start.line+1,column:e.range.start.character+1}}function _e(e){let t=(0,B.c)(19),{diagnostic:n}=e,{_:r}=a(),i=n.severity===`error`?C:D,o=`${n.source}/${n.code}`,s=n.range.start.line+1,c=n.severity===`error`?`text-destructive`:`text-amber-500`,u;t[0]===c?u=t[1]:(u=l(`mt-0.5 size-3.5 shrink-0`,c),t[0]=c,t[1]=u);let d;t[2]!==i||t[3]!==u?(d=(0,J.jsx)(i,{"aria-hidden":`true`,className:u}),t[2]=i,t[3]=u,t[4]=d):d=t[4];let f;t[5]===n.message?f=t[6]:(f=(0,J.jsx)(`span`,{className:`text-foreground`,children:n.message}),t[5]=n.message,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,J.jsxs)(`span`,{className:`flex items-start gap-1.5 text-sm`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==r||t[11]!==s?(m=r({id:`enPTnx`,values:{displayLine:s}}),t[10]=r,t[11]=s,t[12]=m):m=t[12];let h;t[13]!==o||t[14]!==m?(h=(0,J.jsxs)(`span`,{className:`ps-5 font-mono text-xs text-muted-foreground`,children:[o,` · `,m]}),t[13]=o,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==p||t[17]!==h?(g=(0,J.jsxs)(J.Fragment,{children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18],g}function ve(e){return`${e.source}/${e.code}-${e.range.start.line}-${e.range.start.character}-${e.message}`}function ye(e){return e.reduce((e,t)=>e+ +((t.fixes?.length??0)>0),0)}function be(e){let t=(0,B.c)(13),{count:n,disabled:r,onClick:o,children:s}=e,{_:c}=a(),l;t[0]!==c||t[1]!==s||t[2]!==n?(l=s===void 0?c({id:`Izb10l`,values:{count:n}}):void 0,t[0]=c,t[1]=s,t[2]=n,t[3]=l):l=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-3`}),t[4]=d):d=t[4];let f;t[5]!==s||t[6]!==n?(f=s??(0,J.jsx)(i,{id:`5_8TCr`,values:{count:n}}),t[5]=s,t[6]=n,t[7]=f):f=t[7];let p;return t[8]!==r||t[9]!==o||t[10]!==l||t[11]!==f?(p=(0,J.jsxs)(u,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,disabled:r,onClick:o,"aria-label":l,"data-testid":`problems-fix-all`,children:[d,f]}),t[8]=r,t[9]=o,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function xe(e){let t=(0,B.c)(21),{docName:n,diagnostics:r,onFix:o,onFixAll:s,onAskAi:c}=e,{_:l}=a(),[d,f]=(0,z.useState)(`doc`),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={status:`idle`},t[0]=p):p=t[0];let[m,h]=(0,z.useState)(p),[g,_]=(0,z.useState)(null),v=(0,z.useRef)(!0),y,b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>(v.current=!0,()=>{v.current=!1}),b=[],t[1]=y,t[2]=b):(y=t[1],b=t[2]),(0,z.useEffect)(y,b);let x;if(t[3]!==l||t[4]!==m||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==o||t[9]!==s||t[10]!==g||t[11]!==d){let e=[...r].sort(he),a=async function(){h({status:`loading`});let e=await L();v.current&&h(e===null?{status:`failed`}:{status:`loaded`,result:e})},p=m.status===`loaded`?m.result.files.filter(we):[],y=async function(){if(g!==null||p.length===0)return;_({done:0,total:p.length});let e=[];for(let t of p){let n=await R(M(t.file));if(!v.current)return;n.ok||e.push({file:t.file,detail:n.errorDetail}),_(Ce)}if(_(null),e.length>0){let t=e[0];k.error(l({id:`fru3T7`,values:{0:e.length,1:p.length}}),{description:t===void 0?void 0:`${t.file}${t.detail===null?``:` — ${t.detail}`}`})}try{await a()}catch{v.current&&h({status:`failed`})}},b=function(e){f(e),e===`project`&&m.status===`idle`&&a()},S;t[13]===n?S=t[14]:(S=function(e){let t=ge(e);W(n,{kind:`lint`,detail:t}),window.dispatchEvent(new CustomEvent(me,{detail:t}))},t[13]=n,t[14]=S);let C=S,w;t[15]!==n||t[16]!==C?(w=function(e,t){let r=M(e);if(r===n){C(t);return}W(r,{kind:`lint`,detail:ge(t)}),window.location.hash=N(r)},t[15]=n,t[16]=C,t[17]=w):w=t[17];let E=w,D;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsx)(ie,{children:(0,J.jsx)(i,{id:`OXdGnd`})}),t[18]=D):D=t[18];let A=d===`doc`&&e.length>0&&(0,J.jsx)(re,{children:e.length}),j;t[19]===A?j=t[20]:(j=(0,J.jsxs)(ne,{children:[D,A]}),t[19]=A,t[20]=j),x=(0,J.jsxs)(ae,{children:[j,(0,J.jsx)(pe,{scope:d,onScopeChange:b}),d===`doc`?(0,J.jsx)(te,{className:`px-2 py-2`,children:e.length===0?(0,J.jsx)(F,{className:`px-2`,children:(0,J.jsx)(i,{id:`ZI8uvA`})}):(0,J.jsxs)(J.Fragment,{children:[s!==void 0&&(0,J.jsx)(`div`,{className:`flex items-center justify-end gap-2 px-2 pb-1`,children:(0,J.jsx)(be,{count:ye(e),disabled:ye(e)===0,onClick:s})}),(0,J.jsx)(`ul`,{"aria-label":l({id:`OXdGnd`}),className:`flex flex-col gap-0.5`,children:e.map(e=>{let t=e.range.start.line+1,n=o!==void 0&&(e.fixes?.length??0)>0,r=`${e.source}/${e.code}`;return(0,J.jsxs)(`li`,{className:`group relative rounded transition-colors hover:bg-muted`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>C(e),className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left`,title:l({id:`aHPdYV`,values:{displayLine:t}}),children:(0,J.jsx)(_e,{diagnostic:e})}),n||c!==void 0?(0,J.jsxs)(`div`,{className:`absolute bottom-1 right-1 flex items-center gap-1 rounded bg-muted opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none`,children:[n?(0,J.jsxs)(u,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>o?.(e),"aria-label":l({id:`fZj9em`,values:{flatId:r}}),"data-testid":`problems-fix`,children:[(0,J.jsx)(O,{"aria-hidden":`true`,className:`size-3`}),(0,J.jsx)(i,{id:`c4fVUV`})]}):null,c===void 0?null:(0,J.jsxs)(u,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>c(e),"aria-label":l({id:`hh4mVC`,values:{flatId:r}}),"data-testid":`problems-ask-ai`,children:[(0,J.jsx)(T,{"aria-hidden":`true`,className:`size-3`}),(0,J.jsx)(i,{id:`xWEvuo`})]})]}):null]},ve(e))})})]})}):(0,J.jsx)(Ee,{audit:m,onRefresh:()=>void a(),onNavigate:E,fixableCount:p.reduce(Se,0),fixing:g,onFixAll:()=>void y()})]}),t[3]=l,t[4]=m,t[5]=r,t[6]=n,t[7]=c,t[8]=o,t[9]=s,t[10]=g,t[11]=d,t[12]=x}else x=t[12];return x}function Se(e,t){return e+ye(t.diagnostics)}function Ce(e){return e===null?e:{...e,done:e.done+1}}function we(e){return e.diagnostics.some(Te)}function Te(e){return(e.fixes?.length??0)>0}function Ee(e){let t=(0,B.c)(43),{audit:n,onRefresh:r,onNavigate:o,fixableCount:s,fixing:c,onFixAll:l}=e,{_:d}=a(),f=n.status===`loading`||n.status===`idle`,p;t[0]!==n.result||t[1]!==n.status?(p=n.status===`loaded`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{id:`DsDwR-`,values:{0:n.result.errorCount}}),` · `,(0,J.jsx)(i,{id:`W1SI2K`,values:{0:n.result.warningCount}})]}),t[0]=n.result,t[1]=n.status,t[2]=p):p=t[2];let m;t[3]===p?m=t[4]:(m=(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`problems-audit-summary`,children:p}),t[3]=p,t[4]=m);let h;t[5]!==d||t[6]!==c?(h=c===null?null:(0,J.jsx)(`span`,{className:`sr-only`,role:`status`,children:d({id:`gZElfU`,values:{0:c.done,1:c.total}})}),t[5]=d,t[6]=c,t[7]=h):h=t[7];let g=f||c!==null||s===0,_;t[8]===c?_=t[9]:(_=c===null?void 0:(0,J.jsx)(i,{id:`S9t1PI`,values:{0:c.done,1:c.total}}),t[8]=c,t[9]=_);let v;t[10]!==s||t[11]!==l||t[12]!==g||t[13]!==_?(v=(0,J.jsx)(be,{count:s,disabled:g,onClick:l,children:_}),t[10]=s,t[11]=l,t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]===d?y=t[16]:(y=d({id:`WRdYfS`}),t[15]=d,t[16]=y);let b=f||c!==null,x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-3.5`}),t[17]=x):x=t[17];let S;t[18]!==r||t[19]!==y||t[20]!==b?(S=(0,J.jsx)(u,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 text-muted-foreground`,"aria-label":y,"data-testid":`problems-audit-refresh`,disabled:b,onClick:r,children:x}),t[18]=r,t[19]=y,t[20]=b,t[21]=S):S=t[21];let C;t[22]!==S||t[23]!==h||t[24]!==v?(C=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[h,v,S]}),t[22]=S,t[23]=h,t[24]=v,t[25]=C):C=t[25];let w;t[26]!==C||t[27]!==m?(w=(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pb-1`,children:[m,C]}),t[26]=C,t[27]=m,t[28]=w):w=t[28];let T;t[29]!==d||t[30]!==f?(T=f&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,role:`status`,"aria-busy":`true`,"aria-label":d({id:`dx-TwN`}),children:[1,2,3].map(De)}),t[29]=d,t[30]=f,t[31]=T):T=t[31];let D;t[32]===n.status?D=t[33]:(D=n.status===`failed`&&(0,J.jsx)(ee,{className:`px-2 text-xs`,children:(0,J.jsx)(i,{id:`IFezUv`})}),t[32]=n.status,t[33]=D);let O;t[34]!==n.result||t[35]!==n.status||t[36]!==o?(O=n.status===`loaded`&&(0,J.jsx)(Oe,{result:n.result,onNavigate:o}),t[34]=n.result,t[35]=n.status,t[36]=o,t[37]=O):O=t[37];let k;return t[38]!==w||t[39]!==T||t[40]!==D||t[41]!==O?(k=(0,J.jsxs)(te,{className:`px-2 py-2`,"data-testid":`problems-project-scope`,children:[w,T,D,O]}),t[38]=w,t[39]=T,t[40]=D,t[41]=O,t[42]=k):k=t[42],k}function De(e){return(0,J.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2 py-1.5`,children:[(0,J.jsx)(I,{className:`mt-0.5 size-3.5 shrink-0 rounded`}),(0,J.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,J.jsx)(I,{className:`h-3 w-28`}),(0,J.jsx)(I,{className:`h-3 w-40`})]})]},e)}function Oe(e){let t=(0,B.c)(10),{result:n,onNavigate:r}=e,{_:o}=a(),s;t[0]!==o||t[1]!==n.warnings?(s=n.warnings.length>0&&(0,J.jsx)(`ul`,{"aria-label":o({id:`Rsdhj9`}),className:`flex flex-col gap-0.5 pb-1`,children:n.warnings.map(ke)}),t[0]=o,t[1]=n.warnings,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n.fileCount||t[5]!==n.files?(c=n.files.length===0?(0,J.jsx)(F,{className:`px-2`,children:(0,J.jsx)(i,{id:`k_Dqw1`,values:{0:n.fileCount}})}):n.files.map(e=>(0,J.jsx)(Ae,{file:e,onNavigate:r},e.file)),t[3]=r,t[4]=n.fileCount,t[5]=n.files,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function ke(e,t){return(0,J.jsxs)(`li`,{className:`flex items-start gap-1.5 px-2 text-xs`,children:[(0,J.jsx)(D,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-amber-500`}),(0,J.jsx)(`span`,{className:`min-w-0 text-foreground`,children:e})]},`${t}-${e}`)}function Ae(e){let t=(0,B.c)(37),{file:n,onNavigate:r}=e,{_:i}=a(),o,s,c,l,u,m,h,g,_;if(t[0]!==i||t[1]!==n.diagnostics||t[2]!==n.file||t[3]!==r){let e=[...n.diagnostics].sort(he);s=p,h=!0,g=`problems-audit-group`;let a;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(S,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90 motion-reduce:transition-none`}),t[13]=a):a=t[13];let v;t[14]===n.file?v=t[15]:(v=(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,title:n.file,children:n.file}),t[14]=n.file,t[15]=v),_=(0,J.jsxs)(f,{className:`group flex w-full cursor-pointer items-center gap-1.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,children:[a,v,(0,J.jsx)(P,{variant:`gray`,"data-testid":`problems-audit-file-count`,className:`shrink-0`,children:e.length})]}),o=d,m=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[16]!==i||t[17]!==n.file?(c=i({id:`zAJzIg`,values:{0:n.file}}),t[16]=i,t[17]=n.file,t[18]=c):c=t[18],l=`flex flex-col gap-0.5 pb-1 ps-3`;let y;t[19]!==i||t[20]!==n.file||t[21]!==r?(y=e=>{let t=e.range.start.line+1;return(0,J.jsx)(`li`,{children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(n.file,e),className:`flex w-full cursor-pointer flex-col gap-0.5 rounded px-2 py-1.5 text-left transition-colors hover:bg-muted`,title:i({id:`kDwcbW`,values:{0:n.file,displayLine:t}}),children:(0,J.jsx)(_e,{diagnostic:e})})},ve(e))},t[19]=i,t[20]=n.file,t[21]=r,t[22]=y):y=t[22],u=e.map(y),t[0]=i,t[1]=n.diagnostics,t[2]=n.file,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[23]!==c||t[24]!==l||t[25]!==u?(v=(0,J.jsx)(`ul`,{"aria-label":c,className:l,children:u}),t[23]=c,t[24]=l,t[25]=u,t[26]=v):v=t[26];let y;t[27]!==o||t[28]!==m||t[29]!==v?(y=(0,J.jsx)(o,{className:m,children:v}),t[27]=o,t[28]=m,t[29]=v,t[30]=y):y=t[30];let b;return t[31]!==s||t[32]!==h||t[33]!==g||t[34]!==_||t[35]!==y?(b=(0,J.jsxs)(s,{defaultOpen:h,"data-testid":g,children:[_,y]}),t[31]=s,t[32]=h,t[33]=g,t[34]=_,t[35]=y,t[36]=b):b=t[36],b}var je={words:0,chars:0,tokens:0},Me=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,Ne=/[\p{L}\p{N}]/u,Pe=new Set([`text`,`inlineCode`,`code`,`tag`]),Fe=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),Ie=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function Le(e,t){if(!e)return;let n=e.type;if(!Fe.has(n)){if(Pe.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
|
|
2
|
-
`));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)Le(n,t);if(Ie.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
3
|
-
`)&&t.push(`
|
|
4
|
-
`)}}}}function Re(e){try{let t=h().parseToMdast(e),n=[];return Le(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function ze(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))Ne.test(n)&&t++;return t}function Be(e){let t=globalThis.Intl.Segmenter;if(!t)return ze(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function Ve(e){let t=Me.test(e)?1.5:4;return Math.ceil(e.length/t)}function He(e){return e?{words:Me.test(e)?Be(e):ze(e),chars:e.length,tokens:Ve(e)}:{words:0,chars:0,tokens:0}}function Ue(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=v(e);return t.trim()?He(Re(t)):{words:0,chars:0,tokens:0}}function We(e,{isMarkdown:t}){let n=e.trim();return n?He(t?Re(e):n):je}var Q=new Map,$=new Set,Ge=(e,t)=>`${t}:${e}`;function Ke(){for(let e of $)e()}function qe(e,t,n){let r=Ge(e,t);if(n===null){Q.delete(r)&&Ke();return}let i=Q.get(r);i&&i.words===n.words&&i.chars===n.chars&&i.tokens===n.tokens||(Q.set(r,n),Ke())}function Je(e,t){return e===null?null:Q.get(Ge(e,t))??null}function Ye(e){return $.add(e),()=>{$.delete(e)}}function Xe(e){let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.state.doc.textBetween(t,n,`
|
|
5
|
-
`,` `);return i.trim()?We(i,{isMarkdown:!1}):null}function Ze(e){let t=[];for(let n of e.state.selection.ranges)n.empty||t.push(e.state.sliceDoc(n.from,n.to));if(t.length===0)return null;let n=t.join(`
|
|
6
|
-
`);return n.trim()?We(n,{isMarkdown:!0}):null}export{Ye as a,me as c,Z as d,q as f,W as h,Xe as i,xe as l,G as m,qe as n,je as o,K as p,Ze as r,Ue as s,Je as t,ue as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{n as t}from"./DocumentContext-DN3M8p0h.js";import{t as n}from"./react-JNybMug3.js";import{t as r}from"./compiler-runtime-dQcBxOhn.js";import{B as i}from"./CodeMirrorPropInput-Sjp30pzp.js";import{a,gt as o,i as s}from"./dist-CDKZLcnD.js";import{o as c}from"./documents-events-DNDUkpJM.js";import{n as l}from"./agent-presence-DdJtLtJ1.js";import{t as u}from"./lru-string-cache-D19dwCKJ.js";var d=r(),f=e(n(),1),p=500,m=64;async function h(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new i(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=o.safeParse(r);throw e.success?Error(e.data.title):new i(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let a=s.safeParse(r);if(!a.success)throw new i(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:a.error,status:n.status});return a.data}async function g(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&keptCount=${n}`,s=await fetch(r),c;try{c=await s.json()}catch(e){throw new i(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:s.status})}if(!s.ok){let e=o.safeParse(c);throw e.success?Error(e.data.title):new i(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:s.status})}let l=a.safeParse(c);if(!l.success)throw new i(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:l.error,status:s.status});let{diff:u,before:d,after:f}=l.data;return{diff:u,before:d,after:f}}function _(e){let n=(0,d.c)(23),{systemProvider:r}=t(),[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(`idle`),[l,_]=(0,f.useState)(null),b;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=new u(m),n[0]=b):b=n[0];let x=(0,f.useRef)(b),S=(0,f.useRef)(0),C;n[1]===r?C=n[2]:(C=e=>{let t=S.current+=1;s(`loading`),_(null),h(e).then(n=>{if(S.current!==t)return;let i=y(r,e);a({...n,writingDocs:i}),s(`ready`)}).catch(e=>{S.current===t&&(_(e instanceof Error?e.message:String(e)),s(`error`))})},n[1]=r,n[2]=C);let w=C,T;n[3]!==e||n[4]!==w?(T=()=>{if(!e){S.current+=1,a(null),s(`idle`),_(null),x.current.clear();return}x.current.clear(),w(e);let t=null,n=c(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,w(e)},p))});return()=>{t&&clearTimeout(t),n()}},n[3]=e,n[4]=w,n[5]=T):T=n[5];let E;n[6]===e?E=n[7]:(E=[e],n[6]=e,n[7]=E),(0,f.useEffect)(T,E);let D,O;n[8]!==e||n[9]!==r?(D=()=>{if(!e||!r)return;let t=()=>{if(!r.awareness)return;let t=y(r,e);a(e=>!e||v(e.writingDocs,t)?e:{...e,writingDocs:t})},n=r.awareness;if(!n||typeof n.on!=`function`){t();return}n.on(`update`,t),t();let i=setInterval(t,1e3);return()=>{clearInterval(i),typeof n.off==`function`&&n.off(`update`,t)}},O=[e,r],n[8]=e,n[9]=r,n[10]=D,n[11]=O):(D=n[10],O=n[11]),(0,f.useEffect)(D,O);let k;n[12]===e?k=n[13]:(k=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=x.current.get(r);if(i!==void 0)return i;let{diff:a}=await g(e,t,n);return x.current.set(r,a),a},n[12]=e,n[13]=k);let A=k,j;n[14]!==e||n[15]!==w?(j=()=>{e&&w(e)},n[14]=e,n[15]=w,n[16]=j):j=n[16];let M=j,N;return n[17]!==i||n[18]!==l||n[19]!==A||n[20]!==M||n[21]!==o?(N={data:i,status:o,error:l,reload:M,fetchBurstDiff:A},n[17]=i,n[18]=l,n[19]=A,n[20]=M,n[21]=o,n[22]=N):N=n[22],N}function v(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function y(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!l(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}export{_ as n,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./repair-skills-BaZcFu4I.mjs";export{e as repairSkills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,o as t,r as n}from"./server-lock-BiAmhJ19.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
|
package/dist/src-BQhUreu4.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,fa as r}from"./src-BTo9m5ju.mjs";import{Ei as i,ci as a,ct as o,ha as s,hn as c,lt as l,ot as u,st as d}from"./src-YSGKFci8.mjs";import{U as f}from"./sleep-DcENuR74.mjs";import{O as p,P as m}from"./fs-traced-vMO6kYgZ.mjs";import{b as h,u as g,v as _,y as v}from"./server-lock-BiAmhJ19.mjs";import{t as y}from"./yazl-BafwB467.mjs";import{_ as b,g as x,i as S,l as C,x as w}from"./write-project-skill-Dt58S1kj.mjs";import"./acp-harness-probe-DjTv5e1A.mjs";import{D as T,E,S as ee,T as D,_ as O,b as te,o as ne,v as k}from"./init-B_KvF9QQ.mjs";import{n as A}from"./constants-DtCru_h4.mjs";import{t as j}from"./is-object-Bw0-z8qH.mjs";import"./loader-DkorwqUF.mjs";import{c as re}from"./colors-_gzKDfrv.mjs";import"./preview-Bce8FXXe.mjs";import{execSync as M,spawnSync as N}from"node:child_process";import{basename as P,dirname as F,isAbsolute as ie,join as I,relative as ae,resolve as L,sep as oe}from"node:path";import{cpSync as se,createWriteStream as ce,existsSync as R,lstatSync as le,mkdirSync as z,mkdtempSync as ue,readFileSync as B,readdirSync as V,readlinkSync as de,rmSync as H,statSync as fe,writeFileSync as U}from"node:fs";import{arch as pe,freemem as me,homedir as he,hostname as ge,platform as _e,release as ve,tmpdir as ye,totalmem as be,type as xe,uptime as Se}from"node:os";import{realpath as W}from"node:fs/promises";import{createHash as G}from"node:crypto";const Ce=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`}],we=Ce.map(e=>e.name);function Te(e){let t=new Set,n=0;return{redacted:e.split(`
|
|
2
|
-
`).map(e=>{let r=e;for(let{name:e,regex:i,replacement:a}of Ce)i.lastIndex=0,i.test(r)&&(t.add(e),n++,i.lastIndex=0,r=r.replace(i,a));return r}).join(`
|
|
3
|
-
`),patterns:[...t],lineCount:n}}function Ee(){return I(he(),`.ok`,`bug-reports`)}function De(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return I(Ee(),`${t}-bugreport.zip`)}function Oe(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let e=B(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return R(I(e,`.ok`))?G(`sha256`).update(L(e)).digest(`hex`).slice(0,12):null}function ke(){let e={timestamp:new Date().toISOString(),platform:_e(),osType:xe(),osRelease:ve(),hostname:`[redacted]`,uptime:Se(),freeMem:me(),totalMem:be(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=M(`sw_vers -productVersion 2>/dev/null`,a({encoding:`utf8`})).trim()}catch{}try{let t=I(__dirname,`..`,`..`,`package.json`);R(t)&&(e.okVersion=JSON.parse(B(t,`utf8`)).version)}catch{}return e}function Ae(e,t){if(!R(t))return{files:[]};let n=V(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>I(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return B(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function je(e){let n=I(e,`.ok`,`local`);return R(n)?{files:[`server.lock`,`last-spawn-error.log`,t].map(e=>I(n,e)).filter(e=>R(e))}:{files:[]}}function Me(e){let t=I(e,`.ok`,`local`,`logs`);return R(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>I(t,e)).filter(e=>R(e))}:{files:[]}}function Ne(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=Te(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Pe(e){for(let t of e.files)try{Ne({zipfile:e.zipfile,name:`${e.prefix}/${P(t)}`,content:B(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Fe(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??I(he(),`.ok`,`logs`),o=t.projectDir?Oe(t.projectDir,i):null;z(F(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=ke();s.desktop=t.desktop??null;let{files:c}=Ae(o,a),{files:l}=t.projectDir?je(t.projectDir):{files:[]},{files:u}=t.projectDir?Me(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),m=new p;Pe({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),Pe({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),Pe({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=B(e.sourcePath),n=`extra/${e.zipName??P(e.sourcePath)}`;m.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ne({zipfile:m,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let h=JSON.stringify(s,null,2);m.addBuffer(Buffer.from(h,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let g={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};m.addBuffer(Buffer.from(JSON.stringify(g,null,2),`utf8`),`MANIFEST.json`);let _=d.reduce((e,t)=>e+t.lineCount,0),v=[`# Bug Report Bundle`,``,`Generated: ${g.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${g.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${we.join(`, `)}`,_>0?`${_} line(s) were scrubbed across ${d.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
4
|
-
`);m.addBuffer(Buffer.from(v,`utf8`),`README.md`),m.end();let y=ce(r);return m.outputStream.pipe(y),await new Promise((e,t)=>{y.on(`close`,e),y.on(`error`,t)}),i?.info({bundlePath:r,fileCount:f.length,redactionCount:_},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:f,redactions:d,redactedLineCount:_,generatedAt:g.generatedAt}}}var Ie=f(),Le=e(y(),1);const Re=new Set([`doc.name`,`currentDoc`]);function ze(e){return`doc:${G(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function Be(e,t,n){let r=e.docNameMap[n];if(r===void 0){e.docNameMap[n]=t;return}if(r===t)return;let i=e.docNameCollisions[n];i?i.includes(t)||i.push(t):e.docNameCollisions[n]=[t]}function Ve(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=ze(e);return t.originalToHashed.set(e,r),Be(t,e,r),r}function He(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){if(typeof e==`string`)return He(e,t.contentDir);if(Array.isArray(e))return e.map(e=>K(e,t));if(!Ue(e))return e;let n=typeof e.key==`string`&&Re.has(e.key)&&Ue(e.value)&&typeof e.value.stringValue==`string`?e.value.stringValue:null,r={};for(let[i,a]of Object.entries(e))if(n!==null&&i===`value`&&Ue(a)){let e=Ve(n,t);r[i]={...a,stringValue:e}}else Re.has(i)&&typeof a==`string`?r[i]=Ve(a,t):r[i]=K(a,t);return r}function We(e,t){if(t.originalToHashed.size===0)return e;let n=Array.from(t.originalToHashed.entries()).sort(([e],[t])=>t.length-e.length),r=e;for(let[e,t]of n)e.length!==0&&r.includes(e)&&(r=r.split(e).join(t));return r}function Ge(e,t){let n=B(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
5
|
-
`),i=n.split(`
|
|
6
|
-
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=K(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}U(e,r?`${a.join(`
|
|
7
|
-
`)}\n`:a.join(`
|
|
8
|
-
`))}function Ke(e,t){let n=B(e,`utf-8`);if(n.trim().length!==0)try{let r=K(JSON.parse(n),t),i=n.endsWith(`
|
|
9
|
-
`)?`
|
|
10
|
-
`:``;U(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=We(He(n,t.contentDir),t);r!==n&&U(e,r)}}function qe(e,t){let n=B(e,`utf-8`),r=He(n,t.contentDir);r!==n&&U(e,r)}function Je(e){try{return V(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>I(e,t.name))}catch{return[]}}const Ye=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Xe(e){let t={contentDir:e.contentDir,docNameMap:{},originalToHashed:new Map,docNameCollisions:{}};for(let n of[`telemetry`,`logs`,`process`])for(let r of Je(I(e.stagingDir,n)))r.endsWith(`.jsonl`)?Ge(r,t):r.endsWith(`.json`)?Ke(r,t):qe(r,t);for(let n of Je(I(e.stagingDir,`state`))){let e=P(n);n.endsWith(`.jsonl`)?Ge(n,t):Ye.has(e)?Ke(n,t):qe(n,t)}return{docNameMap:t.docNameMap,docNameCollisions:t.docNameCollisions}}const Ze=[`.ok`,`local`,`telemetry`],Qe=[`.ok`,`local`,`logs`],$e=`spans-current.jsonl`,et=`spans-prev.jsonl`,tt=`server-current.jsonl`,nt=`server-prev.jsonl`;function rt(e){return I(e,...Ze,$e)}function it(e){return I(e,...Ze,et)}function at(e){return I(e,...Qe,tt)}function ot(e){return I(e,...Qe,nt)}const st=1e3;async function ct(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(st)});return t.ok?await t.text():null}catch{return null}}async function lt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(st)});return t.ok?await t.text():null}catch{return null}}async function ut(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(st)});return t.ok?await t.text():null}catch{return null}}function dt(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
11
|
-
`)}\n`:null}catch{return null}}function ft(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=N(`git`,[`-C`,t,`log`,`--oneline`,`-50`],a({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function pt(e){let t=I(e,`.git`,`ok`);if(!R(t))return null;let n=N(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],a({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function mt(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function ht(){return{nodeVersion:process.version,platform:_e(),arch:pe()}}function gt(){return process.env.OTEL_SDK_DISABLED===`false`}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _t(e){if(!R(e))return{};let t;try{t=(0,Ie.parse)(B(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q(t))return{};let n=t.telemetry;if(!q(n))return{};let r=n.localSink;return q(r)?r:{}}function vt(e){return typeof e==`boolean`?e:void 0}function yt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function J(e){if(q(e))return yt(e.maxBytes)}function bt(e){let t=_t(p(`project`,e)),n=_t(p(`project-local`,e));return{enabled:vt(n.enabled)??vt(t.enabled)??!0,spansMaxBytes:J(n.spans)??J(t.spans)??52428800,logsMaxBytes:J(n.logs)??J(t.logs)??26214400}}function xt(e){return G(`sha256`).update(e).digest(`hex`)}function St(e){let t=B(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Ct(e){let t=B(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function Y(e,t){return R(e)?(z(F(t),{recursive:!0}),se(e,t),!0):!1}function wt(e){let t=[],n=e=>{let r=V(e,{withFileTypes:!0});for(let i of r){let r=I(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Tt=new Set([`.jsonl`]);function Et(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Tt.has(e.slice(t))}const Dt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ot(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Dt.has(e.slice(t))}function kt(e){let t=[];for(let n of wt(e)){let r=At(e,n);if(!Ot(r))continue;let{redacted:i,patterns:a,lineCount:o}=Te(B(n,`utf-8`));a.length!==0&&(U(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function At(e,t){return ae(e,t).split(oe).join(`/`)}async function jt(e){let r=L(e.contentDir),i=L(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??ct,s=a.fetchAgentEffects??lt,c=a.fetchWatcherRecent??ut,l=a.readShadowHead??ft,u=a.readCheckpointRefs??pt,d=a.now??(()=>new Date),f=a.okVersion??(()=>A),p=a.readDesktopEnv??mt,m=a.readRuntime??ht,h=a.isOtlpPushEnabled??gt,g=ue(I(ye(),`ok-bundle-`));try{z(I(g,`telemetry`),{recursive:!0}),z(I(g,`logs`),{recursive:!0}),z(I(g,`state`),{recursive:!0}),Y(rt(i),I(g,`telemetry`,$e)),Y(it(i),I(g,`telemetry`,et)),Y(at(i),I(g,`logs`,tt)),Y(ot(i),I(g,`logs`,nt));let _=I(i,`.ok`,`local`),v=I(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(R(v)){Y(v,I(g,`state`,`server.lock`));try{let e=B(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await o(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(U(I(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await s(x);t!==null&&U(I(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=dt(n);e!==null&&U(I(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(r);S!==null&&U(I(g,`state`,`shadow-head.txt`),S);let C=u(r);C!==null&&U(I(g,`state`,`checkpoint-refs.txt`),C),Y(I(_,`last-spawn-error.log`),I(g,`state`,`last-spawn-error.log`)),Y(I(_,n),I(g,`state`,n)),Y(I(_,t),I(g,`state`,t));let w=m(),T=p(),E={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T}};U(I(g,`state`,`runtime.json`),`${JSON.stringify(E,null,2)}\n`);let ee=y===`running`?`running
|
|
12
|
-
`:`not-running (${b})\n`;if(U(I(g,`state`,`server-status.txt`),ee),e.processDir&&R(e.processDir)){let t=I(g,`process`);z(t,{recursive:!0}),se(e.processDir,t,{recursive:!0})}let D=null;e.redact===!0&&(D=Xe({stagingDir:g,contentDir:r})),e.note&&U(I(g,`note.txt`),e.note);let O=null;e.scrubSecrets===!0&&(O=kt(g));for(let t of e.extraFiles??[])Y(t.sourcePath,I(g,`extra`,t.zipName??P(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let te=bt(i),ne=wt(g),k=[],A=0,j=0;for(let e of ne){let t=At(g,e),n=fe(e).size,r=Et(t)?St(e):0;k.push({path:t,bytes:n,lines:r}),A+=n,t.startsWith(`telemetry/`)&&Et(t)&&(j+=Ct(e))}let re=D===null?{applied:!1,docNameMapSidecar:null}:Object.keys(D.docNameCollisions).length>0?{applied:!0,docNameMapSidecar:null,docNameCollisions:D.docNameCollisions}:{applied:!0,docNameMapSidecar:null};O!==null&&(re.secretScrub=O);let M={schemaVersion:1,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T},contentDir:{pathSha256:xt(r),absolutePath:D===null?r:`<CONTENT_DIR>`},telemetry:{localSink:te,otlpPushEnabled:h()},redaction:re,serverStatus:y,files:k};U(I(g,`manifest.json`),`${JSON.stringify(M,null,2)}\n`);let N=ne.some(e=>{try{return B(e,`utf-8`).includes(r)}catch{return!1}}),F={totalBytes:A,fileCount:k.length,docNameCount:j,contentDirVisible:N,redacted:D!==null},ie=!1;return{stagingDir:g,manifest:M,summary:F,redactionMapPayload:D===null?null:{docNameMap:D.docNameMap,docNameCollisions:D.docNameCollisions},cleanup:()=>{ie||(ie=!0,H(g,{recursive:!0,force:!0}))}}}catch(e){throw H(g,{recursive:!0,force:!0}),e}}async function Mt(e){let{collected:t,outputPath:n}=e,r=F(n);if(!R(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);if(t.redactionMapPayload!==null){let e=`${P(n,`.zip`)}.docnames.json`,r={...t.manifest,redaction:{...t.manifest.redaction,applied:!0,docNameMapSidecar:e}};U(I(t.stagingDir,`manifest.json`),`${JSON.stringify(r,null,2)}\n`)}let i=new Le.ZipFile,a=wt(t.stagingDir);for(let e of a){let n=At(t.stagingDir,e);i.addFile(e,n)}i.end(),t.redactionMapPayload!==null&&U(I(r,`${P(n,`.zip`)}.docnames.json`),`${JSON.stringify({docNameMap:t.redactionMapPayload.docNameMap,docNameCollisions:t.redactionMapPayload.docNameCollisions},null,2)}\n`,{mode:384});let o=ce(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Nt(e,t){let n=I(e,`.ok`,`config.yml`);if(R(n))try{let t=(0,Ie.parse)(B(n,`utf-8`)),r=j(t)?t.content:void 0,i=j(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return L(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return L(e)}async function Pt(e,t,n){let r=await jt({contentDir:Nt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,deps:{readDesktopEnv:n,logger:e.logger}});try{z(F(e.outputPath),{recursive:!0}),await Mt({collected:r,outputPath:e.outputPath});let n=r.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:Oe(t,e.logger),files:r.manifest.files.map(e=>e.path),redactions:n?.redactions??[],redactedLineCount:n?.redactedLineCount??0,generatedAt:r.manifest.createdAt}}}finally{r.cleanup()}}async function Ft(e){let{projectDir:t}=e,n=e.readDesktopEnv??mt;if(e.level===`full`&&t!==void 0)return Pt(e,t,n);let{zipPath:r,summary:i}=await Fe({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n()});return{zipPath:r,summary:{level:e.level,systemWide:t===void 0,projectSlug:i.projectSlug,files:i.files,redactions:i.redactions,redactedLineCount:i.redactedLineCount,generatedAt:i.generatedAt}}}function X(e,t,n={}){let r=g(e,t);if(!R(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(B(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!v(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??_)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??h())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??ge();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function It(e){return e.replace(/:\d+$/,``)}function Lt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:It(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:It(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:It(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function Rt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`).filter(e=>e.length>0);if(i.length<5||i[2]!==`blob`)return null;let a,o,s,c;try{a=decodeURIComponent(i[0]),o=decodeURIComponent(i[1]),s=decodeURIComponent(i[3]),c=i.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.length===0||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function zt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=r(t.hostname);if(n===null)return null;let i=t.pathname.split(`/`);if(i.length<5||i[0]!==``||i[3]!==`tree`)return null;let a=i.slice(5);a.length===1&&a[0]===``&&a.pop();let o,s,c,l;try{o=decodeURIComponent(i[1]),s=decodeURIComponent(i[2]),c=decodeURIComponent(i[4]),l=a.map(e=>decodeURIComponent(e))}catch{return null}return!o||!s||!c||l.some(e=>e.length===0)?null:{host:n,owner:o,repo:s,branch:c,path:l.join(`/`)}}function Bt(e){let t=Rt(e);if(t)return{kind:`doc`,...t};let n=zt(e);return n?{kind:`folder`,...n}:null}var Z=e(re(),1);const Vt=`# >>> open-knowledge cli >>>`,Ht=`# <<< open-knowledge cli <<<`,Ut=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Wt(e){return I(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const Gt={existsSync:e=>R(e),readFileSync:(e,t)=>B(e,t),lstatSync:e=>le(e),readlinkSync:e=>de(e)};function Kt(e,t=Gt){let n=Wt(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function qt(e){let t=e.replace(Ut,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Jt(e,t,n=Gt){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function Yt(e){return x(e)||b(e)||ee(e)}const Xt=10*1024*1024;function Zt(e,t,n,r){let i=ne(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!Yt(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(H(a,{force:!0}),{kind:`removed`}):e.format===`toml`?en(a,o):e.format===`yaml`?$t(a,e.topLevelKey,o):Qt(a,e.topLevelKey,e.serverMapSubKey,o)}function Qt(e,t,n,r){let i;try{i=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>Xt)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=T(i,O(t,n,r));return o?(m(e,a,{mode:D(e)}),{kind:`removed`}):{kind:`not-present`}}function $t(e,t,n){let r;try{r=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>Xt)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Ie.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=E(a);a.trim()===``||a.endsWith(`
|
|
13
|
-
`)?c.endsWith(`
|
|
14
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
15
|
-
`).replace(/\n/g,`\r
|
|
16
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&m(e,u,{mode:D(e)}),{kind:`removed`}}function en(e,t){let n=te();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=B(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=E(a),s=a.trim()===``||a.endsWith(`
|
|
17
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
18
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
19
|
-
`).replace(/\n/g,`\r
|
|
20
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&m(e,u,{mode:D(e)}),{kind:`removed`}}const tn=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function nn(e,t,n=c){if(e!==void 0&&!tn.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let rn=null;function an(e){rn=e}function on(){return rn??process.cwd()}function sn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function cn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function ln(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:d(r),command:r,isDesktop:sn(r)}}function un(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&un(e)?`ui-orphan`:`stale`}const dn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fn(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`ui-orphan`:return Z.default.magenta(e);case`stale`:return Z.default.yellow(e)}}function pn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function mn(e){return`${pn(e.server.usage)} | ${pn(e.ui?.usage??null)}`}function hn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function gn(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,hn(e),mn(e),t,String(n),cn(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=fn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
21
|
-
`)}async function _n(e={}){let t=e.discover??u,n=e.inspect??X,r=e.log??(e=>console.log(e)),i=e.resolveCommand??o,a=e.resolveUsage??l,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=ln(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(gn(e.all?c:c.filter(e=>dn.has(Q(e)))))}function vn(){return new w(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await _n({all:t.all===!0||e===`all`,json:t.json===!0})})}function yn(e,t,n={}){let r=n.isAlive??_,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function bn(e){let t=e.inspect??(t=>X(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=yn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function xn(e,t=_){let n=await u(),r=null;for(let i of n){let n=X(i,`server`),a=X(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Sn(e){let t=bn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Cn(e){return new w(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=bn({lockDir:i(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await _n({});return}if(n===`all`){let e=await u();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=X(n,`server`),r=X(n,`ui`);!$(e,_)&&!$(r,_)||(Sn(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await xn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Sn(t);return}Sn(i(L(on(),n)))})}function wn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Tn(e,t){let n,i;try{n=await W(L(e)),i=await W(L(F(e)))}catch{return{kind:`not-git`}}if(!En(n,i))return{kind:`symlink-escape`};let a=I(n,`.git`),o;try{o=fe(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await W(a)}catch{return{kind:`not-git`}}if(!En(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let c=s(n);if(c.kind!==`repository`)return{kind:`not-git`};let l=c.repository.readRemoteUrl(`origin`);if(l.kind===`unreadable`)return{kind:`not-git`};if(l.kind===`absent`)return l.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let u=l.url,d=Lt(u);if(d===null)return{kind:`non-github`};let f=r(d.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=d.owner.toLowerCase()===t.owner.toLowerCase(),h=d.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:d.owner,actualRepo:d.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${d.owner}/${d.name}.git`}}function En(e,t){if(e===t)return!0;let n=ae(t,e);return n.length>0&&!n.startsWith(`..`)&&!ie(n)}const Dn=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=k(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=S(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function On(e,t,n={},r=Dn){let i=[];for(let a of t){let t=C[a];for(let a of r)i.push(a.write(t,e,n))}return i}function kn(e,t,n={}){return{integrations:On(e,t,n)}}export{Ft as C,Te as D,De as E,X as S,Mt as T,qt as _,Cn as a,zt as b,an as c,Vt as d,Ut as f,Kt as g,Wt as h,bn as i,nn as l,Jt as m,Tn as n,vn as o,Ht as p,wn as r,on as s,kn as t,Zt as u,Rt as v,jt as w,Lt as x,Bt as y};
|
|
22
|
-
//# sourceMappingURL=src-BQhUreu4.mjs.map
|