@inkeep/open-knowledge 0.50.0-beta.3 → 0.50.0-beta.5
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-C67QIRhp.mjs +3 -0
- package/dist/cli.mjs +38 -38
- package/dist/constants-CHijDPGq.mjs +2 -0
- package/dist/git-handle-Rma56ZDs.mjs +1 -0
- package/dist/{git-handle-Dxwd5VZx.mjs → git-handle-oaKkz-wn.mjs} +2 -2
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +132 -132
- package/dist/init-D90nzFt2.mjs +1 -0
- package/dist/{init-Ro461Kb_.mjs → init-DU6p7L9F.mjs} +4 -4
- package/dist/{launch-json-removal-w-1VYpF4.mjs → launch-json-removal-CZL2haTE.mjs} +2 -2
- package/dist/{loader-BINQ4tTK.mjs → loader-D0Y-7GtO.mjs} +2 -2
- package/dist/loader-DgwfFb4P.mjs +1 -0
- package/dist/md-manager-wsrK03Vr.mjs +2 -0
- package/dist/{open-browser-BeG-Qyr0.mjs → open-browser-S-UcIs_h.mjs} +2 -2
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-CnoSuKSf.mjs → preview-BPAu6Ln2.mjs} +2 -2
- package/dist/preview-DU9aVflr.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BSacDTeg.js → ActivityModeContent-oK0Ukipq.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-rotFtLyt.js → AgentDiffPane-c-eXlgET.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-DcMbo1L-.js → AgentThreadClientBinder-BjgVrGGG.js} +1 -1
- package/dist/public/assets/{ChangedOutsideBadge-VYLHc7SD.js → ChangedOutsideBadge-Tm9eQzQd.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-CdGGv03H.js → CodeMirrorPropInput-D6Vpy6cC.js} +1 -1
- package/dist/public/assets/{DocumentContext-BTVyZC86.js → DocumentContext-BZs9wGsy.js} +10 -10
- package/dist/public/assets/{EditorModeToggle-Dz5xVGpy.js → EditorModeToggle-Dx-H0DAT.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-CLmAu8o9.js → EnableSyncConfirmDialog-Djkj66_G.js} +1 -1
- package/dist/public/assets/FeedbackForm-DK3Eafhu.js +1 -0
- package/dist/public/assets/{GraphPanel-D0ikjJ7b.js → GraphPanel-5y13eIH-.js} +1 -1
- package/dist/public/assets/ImportSkillDialog-BpbNmo53.js +1 -0
- package/dist/public/assets/{LintConfigEditor-Yk4196ji.js → LintConfigEditor-B8UqIDri.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-BoQaa-VP.js +2 -0
- package/dist/public/assets/ManagedArtifactProperties-F3vbLcfn.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-CnYmnzCt.js → McpConsentDialogBody-DmSeUtFh.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-BimLfRlC.js → MermaidDocEditor-yGV5TYvo.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-C-PxBPo3.js → ReportBugDialogBody-B0bj47YU.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-PBcainDT.js → SchemaConfigEditor-OWVRrCyd.js} +1 -1
- package/dist/public/assets/{SessionsHost-CknpEvXW.js → SessionsHost-CldPPD2R.js} +2 -2
- package/dist/public/assets/SettingsDialogBody-B-5j1KKE.js +12 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-E4sJceRx.js → ShareBranchSwitchDialog-295DE9n_.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-CZ8wF8EG.js → ShareReceiveDialog-BbOB46ar.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-Ff2iKkDU.js → ShareReceiveMissDialog-iz73ffK2.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-LZDhvyzV.js → SkillEditBanner-C0motCdk.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-CfZfwviY.js → SkillOriginInline-BKp-kWXv.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CXhDatkg.js → SkillToolbarControls-DnCihwAh.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-B_tRlqt3.js → SlidesToolbarControls-CD_n21A3.js} +1 -1
- package/dist/public/assets/SourceEditor-BuOJMaXx.js +1 -0
- package/dist/public/assets/{TerminalPanel-DnS0vsLe.js → TerminalPanel-CLfRiG4p.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BMu5aZ76.js → TerminalWindowApp-B2TPEGtR.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CbIK48pc.js → TextDocEditor-DmN6Zt5R.js} +1 -1
- package/dist/public/assets/{ThreadView-uIta-Vtw.js → ThreadView-Cn6Viupp.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DPX5EnVl.js → TimelineDiffPane-DzMaO_MM.js} +1 -1
- package/dist/public/assets/{agent-diff-store-9R9YLQTj.js → agent-diff-store-CBfJPWXq.js} +1 -1
- package/dist/public/assets/auth-state-cache-DBVfH7MV.js +11 -0
- package/dist/public/assets/{client-version-Brtmi6Tl.js → client-version-BESEvZR7.js} +1 -1
- package/dist/public/assets/{comment-chips-C-IwbGzt.js → comment-chips-DYqcIz_E.js} +1 -1
- package/dist/public/assets/{config-provider-zCjx6lVk.js → config-provider-DAxeLK4k.js} +3 -3
- package/dist/public/assets/{dist-BBh-Rx_62.js → dist-D1vjmDZ_2.js} +150 -150
- package/dist/public/assets/{doc-paths-PNMXyOQj.js → doc-paths-v_LqWyej.js} +1 -1
- package/dist/public/assets/{documents-events-C930MM9G.js → documents-events-BVk5JL1j.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-D0uVE8rS.js → file-tree-adapter-j4_0rR4k.js} +1 -1
- package/dist/public/assets/{file-tree-utils-D9c8Kaxh.js → file-tree-utils-ChaLadja.js} +1 -1
- package/dist/public/assets/{folder-config-api-DnXS5Q8-.js → folder-config-api-Cyxss03I.js} +1 -1
- package/dist/public/assets/{follow-file-eWlVLAme.js → follow-file-BMJH7ZWv.js} +1 -1
- package/dist/public/assets/globals-CyYdI-wx.css +1 -0
- package/dist/public/assets/i18n-CqChyNE3.js +1 -0
- package/dist/public/assets/{index-BV2vpMYO.js → index-CJ9IqjVe.js} +108 -108
- package/dist/public/assets/{lint-config-client-Dnm7kl-A.js → lint-config-client-CN7WtJJN.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-DjTNNqKF.js → markdownlint-rule-browser-uB5xoBRt.js} +1 -1
- package/dist/public/assets/messages-BTQ6QHGD.js +1 -0
- package/dist/public/assets/messages-C1_vqjO0.js +1 -0
- package/dist/public/assets/messages-CcNmHSRm.js +1 -0
- package/dist/public/assets/messages-CuCFXL8u.js +1 -0
- package/dist/public/assets/messages-D-wGArHz.js +1 -0
- package/dist/public/assets/messages-DCORBVvf.js +1 -0
- package/dist/public/assets/messages-DK20PMTg.js +1 -0
- package/dist/public/assets/messages-DaaRRAol.js +1 -0
- package/dist/public/assets/messages-TrWXqll1.js +1 -0
- package/dist/public/assets/messages-_5gcf9E8.js +1 -0
- package/dist/public/assets/messages-l5kO2Bq5.js +1 -0
- package/dist/public/assets/{navigation-targets-hMP35CWp.js → navigation-targets-BmGfXtLg.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-BXbv1vZH.js → open-managed-artifact-tab-CFg9s1Dl.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-BBGIBWy4.js → pending-receive-nav-store-By3F7IeX.js} +1 -1
- package/dist/public/assets/{prop-types-C8xSIHU7.js → prop-types-BUGU9oYX.js} +1 -1
- package/dist/public/assets/{receive-store-Dy9Hb1sU.js → receive-store-DQ2cxNlN.js} +1 -1
- package/dist/public/assets/{selection-context-C3p_BtW1.js → selection-context-Q2igplxe.js} +1 -1
- package/dist/public/assets/{skill-actions-CQa6AUDr.js → skill-actions-CBlHW4d_.js} +2 -2
- package/dist/public/assets/{skill-scope-q42erPyI.js → skill-scope-CLm-DjVO.js} +1 -1
- package/dist/public/assets/skills-api-Do-yD8Wd.js +1 -0
- package/dist/public/assets/{src-hzPGvn2R.js → src-rGs2GXpJ.js} +1 -1
- package/dist/public/assets/{tag-pill-input-KrIJOPkF.js → tag-pill-input-DLcAHAth.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-BPFSqMEn.js → target-navigation-intent-AJHzhxLh.js} +1 -1
- package/dist/public/assets/{terminal-cli-display-BCPlwXFC.js → terminal-cli-display-DcmUJBJ0.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-BDizFas3.js → terminal-launch-events-DL9JJPUH.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-DGeT-gdl.js → terminal-telemetry-BaIL0R4h.js} +1 -1
- package/dist/public/assets/typing-burst-detector-CPW5PZdn.js +8 -0
- package/dist/public/assets/{uninstall-DSQiimxB.js → uninstall-DEqbq9oi.js} +1 -1
- package/dist/public/assets/{use-activity-panel-iiPv1fFb.js → use-activity-panel-HhWhJyPS.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-BT2P9Cg6.js → use-apply-config-color-theme-dRh7Xul9.js} +1 -1
- package/dist/public/assets/{use-collab-url-ByKwzGpm.js → use-collab-url-CtzTnNTo.js} +1 -1
- package/dist/public/assets/{use-live-xterm-theme-O1QzvrK2.js → use-live-xterm-theme-CEFo40Qe.js} +1 -1
- package/dist/public/assets/{use-open-skill-Dhlxc-5j.js → use-open-skill-Cscl8Yx2.js} +1 -1
- package/dist/public/assets/use-popular-skills-Yh3HxWUQ.js +1 -0
- package/dist/public/assets/{use-settings-route-BvOZe32W.js → use-settings-route-BDWFTRtx.js} +1 -1
- package/dist/public/assets/{use-skill-origin-BWwJ-V8H.js → use-skill-origin-JUAmtC9e.js} +1 -1
- package/dist/public/assets/{use-skills-CCrPufi9.js → use-skills-BmTj83Vv.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CPGBEBb0.js → use-terminal-enabled-BJe4ZzuL.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DBmy_B-o.js → use-timeline-entry-diff-BEA4Wm90.js} +4 -4
- package/dist/public/assets/{use-workspace-B4DagT1C.js → use-workspace-BJfeN9YT.js} +1 -1
- package/dist/public/index.html +47 -47
- package/dist/public/uninstall.html +6 -6
- package/dist/{repair-launch-json-7Sf_hdOn.mjs → repair-launch-json-CMoUKDAg.mjs} +2 -2
- package/dist/{repair-mcp-configs-Cp0KmcwQ.mjs → repair-mcp-configs-BNOodZWo.mjs} +2 -2
- package/dist/repair-skills-BmOui_rF.mjs +1 -0
- package/dist/{repair-skills-Dz6gjuVz.mjs → repair-skills-hf9Efmkp.mjs} +2 -2
- package/dist/{server-lock-_SrmIVon.mjs → server-lock-DEOF_T1n.mjs} +2 -2
- package/dist/server-lock-Rh5J9yH2.mjs +1 -0
- package/dist/{skill-teardown-N2at_ImB.mjs → skill-teardown-B7FIoHkS.mjs} +2 -2
- package/dist/src-DFbDxxC5.mjs +1 -0
- package/dist/src-DiMa3Hqv.mjs +20 -0
- package/dist/src-EOJBnmi7.mjs +1 -0
- package/dist/{src-DexEZ0uX.mjs → src-T22OxNCJ.mjs} +319 -319
- package/dist/{src-BgYGdjBz.mjs → src-v83peLAF.mjs} +121 -121
- package/dist/start-0rwkS2vl.mjs +1 -0
- package/dist/start-BRUIviEZ.mjs +4 -0
- package/dist/{write-project-skill-DirISflr.mjs → write-project-skill-Ds6QPmhs.mjs} +4 -4
- package/package.json +4 -4
- package/dist/acp-harness-probe-BPZnSRO1.mjs +0 -3
- package/dist/constants-C5tLcIHw.mjs +0 -2
- package/dist/git-handle-Bit5ywOl.mjs +0 -1
- package/dist/init-D2t_tZL7.mjs +0 -1
- package/dist/loader-D7taw_Gp.mjs +0 -1
- package/dist/md-manager-DAm5uhV1.mjs +0 -2
- package/dist/preview-DsPcq5nE.mjs +0 -1
- package/dist/public/assets/FeedbackForm-Dp1vjYgK.js +0 -1
- package/dist/public/assets/ImportSkillDialog-aJqzctlX.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CMP-ThxE.js +0 -2
- package/dist/public/assets/ManagedArtifactProperties-DSr3E0As.js +0 -1
- package/dist/public/assets/SettingsDialogBody-B3zf_p67.js +0 -12
- package/dist/public/assets/SourceEditor-pu60EAhW.js +0 -1
- package/dist/public/assets/auth-state-cache-BFy9iIQF.js +0 -11
- package/dist/public/assets/globals-CIRDbOmQ.css +0 -1
- package/dist/public/assets/i18n-CGL69Msh.js +0 -1
- package/dist/public/assets/messages-52Q73NDn.js +0 -1
- package/dist/public/assets/messages-B-LUKCxb.js +0 -1
- package/dist/public/assets/messages-Bjt29O_q.js +0 -1
- package/dist/public/assets/messages-BzwBNPDu.js +0 -1
- package/dist/public/assets/messages-CGjveR2E.js +0 -1
- package/dist/public/assets/messages-CkanzrCR.js +0 -1
- package/dist/public/assets/messages-Cy75Ipbk.js +0 -1
- package/dist/public/assets/messages-D2UntltU.js +0 -1
- package/dist/public/assets/messages-D8H0FnV4.js +0 -1
- package/dist/public/assets/messages-Dl7JEKLk.js +0 -1
- package/dist/public/assets/messages-s-nrsPLp.js +0 -1
- package/dist/public/assets/skills-api-DxH6BgPG.js +0 -1
- package/dist/public/assets/typing-burst-detector-jWGPUNfv.js +0 -8
- package/dist/public/assets/use-skill-directory-_MeqpXal.js +0 -1
- package/dist/repair-skills-kKrHm4Sp.mjs +0 -1
- package/dist/server-lock-DLY6qJ31.mjs +0 -1
- package/dist/src-DBqW6hfs.mjs +0 -20
- package/dist/src-DJHJJDlb.mjs +0 -1
- package/dist/src-DyGBqgiO.mjs +0 -1
- package/dist/start-BqobG-qu.mjs +0 -1
- package/dist/start-DdmHbvgs.mjs +0 -4
- /package/dist/public/assets/{globals-C9aYStL7.js → globals-fH7sZOn9.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,r as t,v as n}from"./start-BRUIviEZ.mjs";export{t as bootStartServer,e as resolveHost,n as startCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Q as e,Y as t}from"./src-v83peLAF.mjs";import{En as n,a as r,ii as i}from"./src-T22OxNCJ.mjs";import{v as a,y as o}from"./write-project-skill-Ds6QPmhs.mjs";import{a as s,c,d as l,i as u,o as d,r as f,t as p}from"./acp-harness-probe-C67QIRhp.mjs";import{n as m}from"./constants-CHijDPGq.mjs";import{spawn as h}from"node:child_process";import{basename as g,join as _,posix as v,resolve as y}from"node:path";import{closeSync as b,existsSync as x,mkdirSync as S,openSync as C}from"node:fs";import{rm as w}from"node:fs/promises";import{setTimeout as T}from"node:timers/promises";function E(e){return v.join(v.dirname(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const D=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function O(e){if(e.platform!==`darwin`||!D.test(e.execPath))return null;let t=E(e.execPath);return e.exists(t)?t:null}function k(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??x,a=r[1];return a?{command:O({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function A(e,t){return e.host??t.HOST??`127.0.0.1`}function j(e,t){return t&&(e===`::`||e===`::1`||e===`[::1]`||e===`localhost`||e===`0.0.0.0`)?{host:`127.0.0.1`,coerced:!0}:{host:e,coerced:!1}}function M(e){let t=g(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var N=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function P(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function F(t){x(t.lockDir)||S(t.lockDir,{recursive:!0});let n=C(_(t.lockDir,e),`w`),r=t.spawn??h,{PORT:i,...a}=process.env,o=k();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{b(n)}catch{}}}function I(e,t,n,r=!1){return e??(n!==void 0||r?void 0:t)}function L(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function R(e,t,n){return e??+(t!=null&&!n)}async function z(e){let t=e.spawn??h,n=k(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=R(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function B(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const V=t;function H(e,t,n=e=>w(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function U(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function W(e){let t=e.sigtermGraceMs??V,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>T(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function G(e){let{destroy:t,...n}=e;return async()=>{await W({...n,reason:`idle-shutdown`}),await t()}}async function K(e){let{config:t,cwd:a,host:o}=e,s=e.skipAutoInit??!1,u=e.skipUiAutoSpawn??!1,d=e.idleThresholdMs??18e5,{existsSync:f,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-EOJBnmi7.mjs`),w=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??a,O=E?r(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!n(a))throw new N(a);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&w.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BNOodZWo.mjs`)).repairMcpConfigs)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-CMoUKDAg.mjs`)).repairLaunchJson)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BmOui_rF.mjs`)).repairSkills)({projectDir:a,reclaimDisableEnv:t,logger:r})}catch(e){w.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,a);!E&&!f(j)&&(m(j,{recursive:!0}),w.info({contentDir:j},`Created content directory`));let M=null,I=null,L=async({lockDir:t})=>{if(M=P({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!u)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];I=F({lockDir:t,cwd:a,spawn:e.spawn,args:n}).pid??null,w.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&w.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},R=e.reactShellDistDir===void 0,z=l(),V=i();{let e=S(E?D:a),t=Date.now(),n=await C(e);n!==`no-drain`&&w.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let W=await _({config:t,contentDir:j,projectDir:E?D:a,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,...e.enableRemote===!0?{enableRemote:!0}:{},quiet:!1,detectGh:c,tokenStore:z,embeddingsKeyStore:V,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>p(e,t),attachUiSibling:R,idleShutdownMs:d,skipAutoInit:!0,...R?{spawnUiSiblingFn:L}:{},idleShutdownHandler:t=>{let n=G({readUiLock:()=>b(W.lockDir),spawnedUiPid:()=>I,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:w});return U(E?H(n,D):n,{log:w,exit:e.idleExit})},log:w,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let K=M,q=null;if(K.action===`skip`)q=K.port>0?K.port:null;else if(!u){let t=e.uiBindTimeoutMs??3e3;q=await B({readUiLock:()=>b(W.lockDir),now:Date.now,sleep:e=>T(e),timeoutMs:t,pollIntervalMs:50}),q===null&&w.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:W.httpServer,destroy:W.destroy,lockDir:W.lockDir,contentDir:j,port:W.port,ready:W.ready,degraded:W.degraded,uiSpawnDecision:M,spawnedUiPid:I,resolvedUiPort:q}}function q(e){if(e===`browser`||e===`app`)return e;throw new o(`--mode must be 'browser' or 'app'`)}function J(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new o(`--ui-port must be a port number between 1 and 65535`);return t}function Y(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function X(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Z(e,t){let n=Y(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner-Be20aAVc.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=t.remote!==void 0&&t.remote!==!1,u=typeof t.remote==`string`?t.remote:void 0,d=u===void 0?e:{...e,remote:{...e.remote,url:u}};process.title=M(c),l&&(typeof d.remote?.url!=`string`||d.remote.url===``)&&(console.error(o("--remote requires a public tunnel URL — pass it (`ok start --remote https://<your-tunnel-host>`) or set remote.url in .ok/config.yml.")),process.exit(78)),l&&console.warn(s([``,`⚠ REMOTE ACCESS ENABLED — no server-side authentication.`,` Anyone who can reach ${d.remote?.url} has FULL control of this`,` knowledge base, including sync, publishing, credentials, and local operations.`,` Restrict who can reach it at the tunnel: ngrok OAuth, Cloudflare Access,`,` Tailscale ACLs, or equivalent edge auth.`,``].join(`
|
|
2
|
+
`)));let f=A(t,process.env),p=j(f,l);p.coerced&&console.warn(`remote access is enabled and ${f} is not an IPv4 loopback bind — tunnels proxy to 127.0.0.1, so binding ${f} would leave the tunnel dialing a dead port. Using 127.0.0.1.`);let h=p.host,g=t.port===void 0?void 0:Number(t.port),_=process.env.PORT?Number(process.env.PORT):void 0,v=t.uiPort===void 0?void 0:Number(t.uiPort);l&&g===void 0&&_!==void 0&&console.warn(`remote access is enabled — ignoring env PORT=${process.env.PORT}; the tunnel's port mapping targets the stable remote port (${d.remote?.port}). Pass --port to override deliberately.`);let b=I(g,_,v,l)??(l?d.remote?.port:void 0);if(v!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-EOJBnmi7.mjs`);if(L(v,e(t(c)))){await z({cwd:c,uiPort:v});return}}let S=t.reactShellDistDir;if(l&&S===void 0){let e=import.meta.dirname??new URL(`.`,import.meta.url).pathname;S=[y(e,`public`),y(e,`../../app/dist`),y(e,`../../../app/dist`)].find(e=>x(e)),S===void 0&&console.warn(`remote access: bundled web UI not found — serving /mcp and /api only over the tunnel.`)}let C;try{C=await K({config:d,cwd:c,host:h,port:b,...v===void 0?{}:{uiPort:v},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...S?{reactShellDistDir:S}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{},...l?{enableRemote:!0}:{}})}catch(e){e instanceof N&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-EOJBnmi7.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.RemoteConfigError&&(console.error(o(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),v!==void 0&&Q(e,t)){await z({cwd:c,uiPort:v});return}let n=$(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let w=!1,T=async e=>{if(w)return;w=!0;let[t,...n]=X(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(C.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-EOJBnmi7.mjs`);await W({readUiLock:()=>n(C.lockDir),spawnedUiPid:()=>C.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await C.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{T(`SIGINT`)}),process.once(`SIGTERM`,()=>{T(`SIGTERM`)});let E=`http://${h}:${C.port}`,D=h===`0.0.0.0`||h===`::`?`http://0.0.0.0:${C.port}`:void 0,O=C.resolvedUiPort,k=O!==null&&O>0?`http://${h}:${O}`:E;console.log(r({name:`open-knowledge`,version:m,localUrl:k,apiUrl:k===E?void 0:E,networkUrl:D,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let P={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};C.ready.then(async()=>{if(C.degraded.length>0){console.log();for(let e of C.degraded){let t=P[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-S-UcIs_h.mjs`);e(k)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function Q(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function $(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=_(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function ee(e){return new a(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,J).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,q).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).option(`--remote [url]`,`Serve through a tunnel: admit requests carrying the tunnel Host with NO server-side auth (anyone who can reach the URL has full control — restrict access at the tunnel with edge auth). Bare --remote uses remote.url from .ok/config.yml; --remote <url> supplies it for this run.`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
3
|
+
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=u(f());if(n.available){s({spawn:h},n);return}console.error(d(n.reason)),process.exit(1)}await Z(n,t)})}export{k as C,U as S,F as _,j as a,$ as b,P as c,Q as d,I as f,L as g,Z as h,G as i,M as l,Y as m,B as n,R as o,A as p,K as r,z as s,N as t,X as u,ee as v,H as x,W as y};
|
|
4
|
+
//# sourceMappingURL=start-BRUIviEZ.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Fo as r,Jo as i,Uo as a,Wo as o}from"./src-v83peLAF.mjs";import{Ir as s,gr as c}from"./src-T22OxNCJ.mjs";import{basename as l,dirname as u,isAbsolute as d,join as f,posix as p,relative as m,resolve as h,sep as g,win32 as _}from"node:path";import{cpSync as ee,existsSync as v,lstatSync as te,mkdirSync as y,readFileSync as ne,realpathSync as b,rmSync as x,statSync as re}from"node:fs";import{homedir as S}from"node:os";var C=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),w=n((e=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),T=n((e=>{let{humanReadableArgName:t}=w();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
2
2
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
3
3
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
4
4
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),E=n((e=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -16,7 +16,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
17
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
18
18
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
19
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:oe,createCommand:se,createArgument:ce,createOption:le,CommanderError:ue,InvalidArgumentError:D,InvalidOptionArgumentError:de,Command:fe,Argument:pe,Option:me,Help:he}=t(n((e=>{let{Argument:t}=w(),{Command:n}=ae(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,O=
|
|
19
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=h,t.useColor=_}));const{program:oe,createCommand:se,createArgument:ce,createOption:le,CommanderError:ue,InvalidArgumentError:D,InvalidOptionArgumentError:de,Command:fe,Argument:pe,Option:me,Help:he}=t(n((e=>{let{Argument:t}=w(),{Command:n}=ae(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default,O=a,k=o,ge=i,A=`node`,j={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},M=`# ok-mcp-v2
|
|
20
20
|
USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
21
21
|
[ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
|
|
22
22
|
BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
@@ -52,5 +52,5 @@ foreach ($d in $dirs) {
|
|
|
52
52
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
|
|
53
53
|
}
|
|
54
54
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
55
|
-
exit 127`,P=`// ok-pi-bridge`,F=`${P}-v1`,I=`ok-pi-managed-extension`;function L(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(F)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=h(e);if(l(t)===`cli.mjs`&&l(u(t))===`dist`)return t;let n=t.split(g),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return f(i.length===0?g:i.join(g),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:A,args:[R(),`mcp`],env:{...j}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{command:`/bin/sh`,args:[`-l`,`-c`,M]}}function _e(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[A,R(),`mcp`],environment:{...j}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,M]}}function ve(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?ye(e,t):!1}function ye(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function be(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?_:p}function Se(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function Ce(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env;if(t===`darwin`)return p.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??_.join(n,`AppData`,`Roaming`);return _.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.cursor`,`mcp.json`)}function we(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(we(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function Te(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(Te(e),`opencode.json`)}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.openclaw`,`openclaw.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.hermes`,`config.yaml`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ae(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function J(e={}){let t=e.platformName??process.platform,n=Ae(e.home??S(),t);return n.find(e=>v(e))||n.find(e=>v(u(e)))||n[0]}const Y={claude:{id:`claude`,label:k.claude,configPath:(e,t)=>Ce({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.claude`),projectConfigPath:e=>f(e,`.mcp.json`),projectSkillPath:e=>f(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:k[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(U({home:t}))},cursor:{id:`cursor`,label:k.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(W({home:t})),projectConfigPath:e=>f(e,`.cursor`,`mcp.json`),projectSkillPath:e=>f(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:k.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(G({home:t})),projectConfigPath:e=>f(e,`.codex`,`config.toml`),projectSkillPath:e=>f(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:k.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(K({home:t})),projectSkillPath:e=>f(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:k.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>i,buildEntry:(e,t)=>_e(t),scope:`global`,detectPath:(e,t)=>u(q({home:t})),projectConfigPath:e=>f(e,`opencode.json`),projectSkillPath:e=>f(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:k.openclaw,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:k.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Oe({home:t}),projectConfigPath:e=>f(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>f(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:k.antigravity,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:k[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:k.hermes,configPath:(e,t)=>De({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>i,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.hermes`),offerOnlyWhenDetected:!0}};function je(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${O.join(`, `)}`);return e.map(e=>Y[e])}function X(e,t){let n;try{n=te(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Z(e,t)}function Me(e,t){Z(e,t)}function Z(e,t){let n;try{n=b(t)}catch{n=h(t)}let r=u(e);for(;r.length>1&&r!==g;){let t;try{t=b(r)}catch(e){if(e.code===`ENOENT`){r=u(r);continue}throw e}let i=m(n,t);if(i===``||!i.startsWith(`..`)&&!d(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t,n){try{if(re(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=s(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Q(a))return!1;let o=a[e.topLevelKey];if(!Q(o))return!1;let c=e.serverMapSubKey?o[e.serverMapSubKey]:o;return Q(c)?Q(c[e.serverName(t)]):!1}function Pe(e,t,n={}){if(e.id!==`copilot`)return!0;try{return Ne(e,t,e.configPath(t,n.home))}catch{return!1}}function $(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Pe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=c(`project`,{checkDesktop:!0}),i=u(r);X(i,t);let a=v(r)?`overwritten`:`written`;return x(i,{recursive:!0,force:!0}),y(u(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}export{je as _,k as a,me as b,P as c,z as d,be as f,Se as g,xe as h,O as i,F as l,ve as m,Me as n,Y as o,L as p,$ as r,ge as s,X as t,I as u,fe as v,D as y};
|
|
56
|
-
//# sourceMappingURL=write-project-skill-
|
|
55
|
+
exit 127`,P=`// ok-pi-bridge`,F=`${P}-v1`,I=`ok-pi-managed-extension`;function L(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(F)}return!1}function R(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=h(e);if(l(t)===`cli.mjs`&&l(u(t))===`dist`)return t;let n=t.split(g),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return f(i.length===0?g:i.join(g),`packages`,`cli`,`dist`,`cli.mjs`)}function z(e={}){return e.mode===`dev`?{command:A,args:[R(),`mcp`],env:{...j}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{command:`/bin/sh`,args:[`-l`,`-c`,M]}}function _e(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[A,R(),`mcp`],environment:{...j}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,N]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,M]}}function ve(e){if(typeof e!=`object`||!e)return!1;let t=e;return B(t,z({mode:`published`,platformName:`darwin`}))||B(t,z({mode:`published`,platformName:`win32`}))}function B(e,t){return Object.keys(e).length===Object.keys(t).length?ye(e,t):!1}function ye(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function V(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function be(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:V(t.args,t.command)}function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&V(r,n)}function H(e){return e===`win32`?_:p}function Se(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env,i=H(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function Ce(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.claude.json`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env;if(t===`darwin`)return p.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??_.join(n,`AppData`,`Roaming`);return _.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.cursor`,`mcp.json`)}function we(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).CODEX_HOME??H(t).join(n,`.codex`)}function G(e={}){return H(e.platformName??process.platform).join(we(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=(e.env??process.env).COPILOT_HOME??H(t).join(n,`.copilot`);return H(t).join(r,`mcp-config.json`)}function Te(e={}){let t=e.platformName??process.platform,n=e.home??S(),r=e.env??process.env,i=H(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return H(e.platformName??process.platform).join(Te(e),`opencode.json`)}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.openclaw`,`openclaw.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.hermes`,`config.yaml`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??S();return(e.env??process.env).PI_CODING_AGENT_DIR??H(t).join(n,`.pi`,`agent`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??S();return H(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ae(e,t){let n=H(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function J(e={}){let t=e.platformName??process.platform,n=Ae(e.home??S(),t);return n.find(e=>v(e))||n.find(e=>v(u(e)))||n[0]}const Y={claude:{id:`claude`,label:k.claude,configPath:(e,t)=>Ce({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.claude`),projectConfigPath:e=>f(e,`.mcp.json`),projectSkillPath:e=>f(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:k[`claude-desktop`],configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(U({home:t}))},cursor:{id:`cursor`,label:k.cursor,configPath:(e,t)=>W({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(W({home:t})),projectConfigPath:e=>f(e,`.cursor`,`mcp.json`),projectSkillPath:e=>f(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:k.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(G({home:t})),projectConfigPath:e=>f(e,`.codex`,`config.toml`),projectSkillPath:e=>f(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:k.copilot,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(K({home:t})),projectSkillPath:e=>f(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:k.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>r,buildEntry:(e,t)=>_e(t),scope:`global`,detectPath:(e,t)=>u(q({home:t})),projectConfigPath:e=>f(e,`opencode.json`),projectSkillPath:e=>f(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:k.openclaw,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:k.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Oe({home:t}),projectConfigPath:e=>f(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>f(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:k.antigravity,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:k[`lm-studio`],configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>u(J({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:k.hermes,configPath:(e,t)=>De({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>r,buildEntry:(e,t)=>z(t),scope:`global`,detectPath:(e,t)=>f(t??S(),`.hermes`),offerOnlyWhenDetected:!0}};function je(e){let t=e.filter(e=>!Object.hasOwn(Y,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${O.join(`, `)}`);return e.map(e=>Y[e])}function X(e,t){let n;try{n=te(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Z(e,t)}function Me(e,t){Z(e,t)}function Z(e,t){let n;try{n=b(t)}catch{n=h(t)}let r=u(e);for(;r.length>1&&r!==g;){let t;try{t=b(r)}catch(e){if(e.code===`ENOENT`){r=u(r);continue}throw e}let i=m(n,t);if(i===``||!i.startsWith(`..`)&&!d(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ne(e,t,n){try{if(re(n).size>10485760)return!1}catch{return!1}let r;try{r=ne(n,`utf-8`)}catch{return!1}let i=[],a=s(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Q(a))return!1;let o=a[e.topLevelKey];if(!Q(o))return!1;let c=e.serverMapSubKey?o[e.serverMapSubKey]:o;return Q(c)?Q(c[e.serverName(t)]):!1}function Pe(e,t,n={}){if(e.id!==`copilot`)return!0;try{return Ne(e,t,e.configPath(t,n.home))}catch{return!1}}function $(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Pe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=c(`project`,{checkDesktop:!0}),i=u(r);X(i,t);let a=v(r)?`overwritten`:`written`;return x(i,{recursive:!0,force:!0}),y(u(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}export{je as _,k as a,me as b,P as c,z as d,be as f,Se as g,xe as h,O as i,F as l,ve as m,Me as n,Y as o,L as p,$ as r,ge as s,X as t,I as u,fe as v,D as y};
|
|
56
|
+
//# sourceMappingURL=write-project-skill-Ds6QPmhs.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.50.0-beta.
|
|
3
|
+
"version": "0.50.0-beta.5",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"ajv-formats": "^3.0.1",
|
|
63
63
|
"tsdown": "^0.21.7",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"@inkeep/open-knowledge-
|
|
65
|
+
"@inkeep/open-knowledge-app": "0.50.0-beta.5",
|
|
66
|
+
"@inkeep/open-knowledge-core": "0.50.0-beta.5",
|
|
66
67
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
67
|
-
"@inkeep/open-knowledge-
|
|
68
|
-
"@inkeep/open-knowledge-server": "0.50.0-beta.3"
|
|
68
|
+
"@inkeep/open-knowledge-server": "0.50.0-beta.5"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build:cli": "rm -rf dist && tsdown",
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./sleep-DVOInM4H.mjs";import{f as t,h as n,o as r}from"./write-project-skill-DirISflr.mjs";import{d as i}from"./init-Ro461Kb_.mjs";import{execFileSync as a}from"node:child_process";import{dirname as o,join as s}from"node:path";import{existsSync as c,mkdirSync as l,readFileSync as u,writeFileSync as d}from"node:fs";import{homedir as f}from"node:os";var p=e();const m=`open-knowledge`;function h(e){try{e()}catch{}}var g=class{backend=`keyring`;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(m,e).getPassword()}catch(t){return h(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return h(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return h(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(m,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(m,e).deletePassword()}catch{}}},_=class{backend=`file`;authFile;constructor(e){this.authFile=e??s(f(),`.ok`,`auth.yml`)}read(){if(!c(this.authFile))return{};try{return(0,p.parse)(u(this.authFile,`utf-8`))??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=o(this.authFile);c(t)||l(t,{recursive:!0,mode:448}),d(this.authFile,(0,p.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},v=class{backend=`keyring`;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function y(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(m,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
|
-
`),h(()=>t?.onBackendSelected?.({backend:`keyring`})),new v(new g(t?.onKeychainRead),new _(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml) — OS keychain unavailable: ${r}\n`),h(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new _(e)}}function b(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (~/.ok/auth.yml)\n`),r(new _(e))},n)});try{return await Promise.race([y(e),r])}catch{return new _(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function x(e){let t=b(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token}}}}function S(e){let t=b(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function C(e,t){let n=[],r=new _(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(m,`__probe__`);let r,a=await new g(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(m,e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}const w=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],T={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function E(e,t={}){let n=t._exec??a,r=t._fileExists??c,i=[`auth`,`token`,...e?[`--hostname`,e]:[]],o=[`gh`,...w.filter(r)];for(let e of o)try{let t=n(e,i,T).toString().trim();if(t.length>0)return{available:!0,token:t}}catch{}return{available:!1}}function D(e,a,o){let s=r[e],c=e===`opencode`?n:t,l=[],u=s.projectConfigPath?.(a);u!==void 0&&l.push({scope:`project`,configPath:u});try{l.push({scope:`user`,configPath:s.configPath(a,o)})}catch{}for(let t of l){let n=i(s,a,o,t.configPath);if(n!==null&&c(n))return{editorId:e,scope:t.scope,configPath:t.configPath}}return null}export{x as a,y as i,E as n,S as o,C as r,D as t};
|
|
3
|
-
//# sourceMappingURL=acp-harness-probe-BPZnSRO1.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./git-handle-Dxwd5VZx.mjs";export{e as createGitInstance};
|
package/dist/init-D2t_tZL7.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./init-Ro461Kb_.mjs";export{e as runInit};
|
package/dist/loader-D7taw_Gp.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-BINQ4tTK.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CnoSuKSf.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-BV2vpMYO.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Tn as n}from"./DocumentContext-BTVyZC86.js";import{t as r}from"./react-f2sANaYj.js";import{n as i,r as a}from"./dist-Nvb76hAm.js";import{t as o}from"./compiler-runtime-BfE3aGVn.js";import{t as s}from"./utils-CPqDy6Hr.js";import{t as c}from"./button-RQ5o7P7w.js";import{a as l,c as ee,i as u,n as d,o as f,s as p,t as m}from"./dialog-O4u6_xiQ.js";import{t as h}from"./label-BT2yjpKR.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as te}from"./select-BaOsrrG7.js";import{n as ne,t as re}from"./radio-group-CmCnommQ.js";import{i as S,n as C,r as w,t as ie}from"./tabs-CjOEhhKP.js";import{t as T}from"./dist-DoS8xGN6.js";import{n as E}from"./dist-Bkx5dDHT2.js";import{t as D}from"./createLucideIcon-BcLKHslE.js";import{t as ae}from"./git-branch-CMN6cdzm.js";import{t as O}from"./folder-CWVPrRtx.js";import{t as oe}from"./loader-circle-BbuX0POi.js";import{n as k,r as A,t as j}from"./use-skill-directory-_MeqpXal.js";import{t as se}from"./input-_CzMpvY9.js";import{f as ce,t as le}from"./skill-scope-q42erPyI.js";import{A as ue,D as de,d as fe,i as M}from"./skills-api-DxH6BgPG.js";import{t as N}from"./skeleton-ColtBPsg.js";import{n as pe,r as P,t as me}from"./input-group-CPKSxoq5.js";var F=D(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),he=o(),I=e(r(),1),L=t(),ge=[`s1`,`s2`,`s3`,`s4`,`s5`,`s6`,`s7`,`s8`],_e=[{label:{id:`f8fH8W`},query:`design`},{label:{id:`-ySLQJ`},query:`git`},{label:{id:`qIJIrD`},query:`test`},{label:{id:`8Uv5e6`},query:`agent`},{label:{id:`UDb2YD`},query:`react`},{label:{id:`TbjyhA`},query:`docs`},{label:{id:`9wQrUU`},query:`refactor`},{label:{id:`HKH-W-`},query:`data`},{label:{id:`43qzxu`},query:`devops`},{label:{id:`a3LDKx`},query:`security`}];function R(e){let t=(0,he.c)(57),{scope:r,onNavigate:o}=e,{_:s}=a(),l;t[0]!==o||t[1]!==r?(l={scope:r,onNavigate:o},t[0]=o,t[1]=r,t[2]=l):l=t[2];let{importedEntry:ee,openResult:u}=j(l),[d,f]=(0,I.useState)(``),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[],t[3]=p):p=t[3];let[m,h]=(0,I.useState)(p),[ne,re]=(0,I.useState)(!1),[S,C]=(0,I.useState)(`idle`),[w,ie]=(0,I.useState)(`relevance`),{skills:T}=k(),E,D;t[4]===d?(E=t[5],D=t[6]):(E=()=>{let e=d.trim();if(e.length<2){h([]),C(`idle`);return}let t=!1;C(`searching`);let n=setTimeout(()=>{de(e).then(e=>{if(!t){if(!e.ok){C(`error`),h([]),re(!1);return}h(e.results),re(e.degraded),C(`idle`)}})},300);return()=>{t=!0,clearTimeout(n)}},D=[d],t[4]=d,t[5]=E,t[6]=D),(0,I.useEffect)(E,D);let ae;t[7]===d?ae=t[8]:(ae=d.trim(),t[7]=d,t[8]=ae);let O=ae,oe;t[9]!==m||t[10]!==w?(oe=w===`installs`?[...m].sort(ye):m,t[9]=m,t[10]=w,t[11]=oe):oe=t[11];let se=oe,ce;t[12]!==ee||t[13]!==u?(ce=e=>(0,L.jsx)(A,{result:e,imported:ee(e),onOpen:()=>u(e)},e.id),t[12]=ee,t[13]=u,t[14]=ce):ce=t[14];let le=ce,ue;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,L.jsx)(pe,{align:`inline-start`,children:(0,L.jsx)(n,{"aria-hidden":`true`})}),t[15]=ue):ue=t[15];let fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>f(e.target.value),t[16]=fe):fe=t[16];let M;t[17]===s?M=t[18]:(M=s({id:`BlLxpG`}),t[17]=s,t[18]=M);let N;t[19]===s?N=t[20]:(N=s({id:`BlLxpG`}),t[19]=s,t[20]=N);let F;t[21]!==d||t[22]!==M||t[23]!==N?(F=(0,L.jsxs)(me,{className:`h-9 flex-1`,children:[ue,(0,L.jsx)(P,{value:d,onChange:fe,placeholder:M,"aria-label":N})]}),t[21]=d,t[22]=M,t[23]=N,t[24]=F):F=t[24];let R;t[25]!==s||t[26]!==O.length||t[27]!==m||t[28]!==w||t[29]!==S?(R=O.length>=2&&S===`idle`&&m.length>0?(0,L.jsxs)(te,{value:w,onValueChange:e=>ie(e),children:[(0,L.jsx)(y,{className:`h-9! w-40 shrink-0`,"aria-label":s({id:`eUFXS1`}),children:(0,L.jsx)(x,{})}),(0,L.jsx)(v,{children:(0,L.jsxs)(b,{children:[(0,L.jsx)(g,{children:s({id:`_HgF9q`})}),(0,L.jsx)(_,{value:`relevance`,children:s({id:`7dZnmw`})}),(0,L.jsx)(_,{value:`installs`,children:s({id:`tc65fD`})})]})})]}):null,t[25]=s,t[26]=O.length,t[27]=m,t[28]=w,t[29]=S,t[30]=R):R=t[30];let z;t[31]!==F||t[32]!==R?(z=(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[F,R]}),t[31]=F,t[32]=R,t[33]=z):z=t[33];let B;t[34]!==s||t[35]!==d?(B=_e.map(e=>{let t=d.trim().split(/\s+/).filter(Boolean),n=t.includes(e.query);return(0,L.jsx)(c,{variant:n?`secondary`:`outline`,size:`sm`,"aria-pressed":n,className:`h-6 shrink-0 rounded-full data-[active=true]:border-foreground/30`,"data-active":n,onClick:()=>f((n?t.filter(t=>t!==e.query):[...t,e.query]).join(` `)),children:s(e.label)},e.query)}),t[34]=s,t[35]=d,t[36]=B):B=t[36];let V;t[37]===B?V=t[38]:(V=(0,L.jsx)(`div`,{className:`flex shrink-0 gap-2 overflow-x-auto scroll-fade-mask-x [scrollbar-width:none]`,children:B}),t[37]=B,t[38]=V);let H;t[39]!==ne||t[40]!==O.length?(H=ne&&O.length>=2?(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:(0,L.jsx)(i,{id:`MBKkUy`})}):null,t[39]=ne,t[40]=O.length,t[41]=H):H=t[41];let U;t[42]!==T||t[43]!==O.length||t[44]!==le||t[45]!==m||t[46]!==se||t[47]!==S?(U=O.length<2?T.length>0?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`font-mono text-2xs uppercase tracking-wider text-muted-foreground`,children:(0,L.jsx)(i,{id:`gL_sdV`})}),(0,L.jsx)(`ul`,{className:`grid grid-cols-1 gap-2.5 sm:grid-cols-2`,children:T.map(le)})]}):null:S===`searching`?(0,L.jsxs)(`div`,{"aria-busy":`true`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:(0,L.jsx)(i,{id:`WRNXKp`})}),(0,L.jsx)(`ul`,{className:`grid grid-cols-1 gap-2.5 sm:grid-cols-2`,"aria-hidden":!0,children:ge.map(ve)})]}):S===`error`?(0,L.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,L.jsx)(i,{id:`yg_6wQ`})}):m.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,L.jsx)(i,{id:`8t9T3-`})}):(0,L.jsx)(`ul`,{className:`grid grid-cols-1 gap-2.5 sm:grid-cols-2`,children:se.map(le)}),t[42]=T,t[43]=O.length,t[44]=le,t[45]=m,t[46]=se,t[47]=S,t[48]=U):U=t[48];let W;t[49]===U?W=t[50]:(W=(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto subtle-scrollbar scroll-fade-mask`,children:U}),t[49]=U,t[50]=W);let G;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,L.jsx)(`p`,{className:`-mb-3.5 shrink-0 text-center text-[11px] text-muted-foreground/80`,children:(0,L.jsx)(i,{id:`fg1U4e`,components:{0:(0,L.jsx)(`a`,{href:`https://skills.sh`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-foreground`})}})}),t[51]=G):G=t[51];let K;return t[52]!==z||t[53]!==V||t[54]!==H||t[55]!==W?(K=(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[z,V,H,W,G]}),t[52]=z,t[53]=V,t[54]=H,t[55]=W,t[56]=K):K=t[56],K}function ve(e){return(0,L.jsx)(N,{className:`h-[72px] rounded-xl`},e)}function ye(e,t){return(t.installs??-1)-(e.installs??-1)}function z(e,t){t.alreadyImported?E.success(e===`upload`?T._({id:`tA2-xC`,values:{0:t.name}}):T._({id:`8AjnFz`,values:{0:t.name}})):t.collisionRenamedFrom?E.success(e===`upload`?T._({id:`EPGePE`,values:{0:t.name,1:t.collisionRenamedFrom}}):T._({id:`C0Ciaj`,values:{0:t.name,1:t.collisionRenamedFrom}})):E.success(e===`upload`?T._({id:`Pg83C9`,values:{0:t.name}}):T._({id:`qFKsNl`,values:{0:t.name}}));for(let e of t.warnings??[])E.warning(e)}var B=`flex items-start justify-between gap-3 rounded-md border p-3 text-sm font-normal transition-colors cursor-pointer`;function V(e){let t=(0,he.c)(122),{defaultScope:n,onOpenChange:r,onImported:o}=e,{_:l}=a(),ee=(0,I.useId)(),u=(0,I.useId)(),p=(0,I.useId)(),m=(0,I.useId)(),g=(0,I.useId)(),b=ce(),[S,C]=(0,I.useState)(n),[w,ie]=(0,I.useState)(`remote`),[T,D]=(0,I.useState)(``),[k,A]=(0,I.useState)(``),[j,de]=(0,I.useState)(null),[N,pe]=(0,I.useState)(!1),[P,me]=(0,I.useState)(null),[ge,_e]=(0,I.useState)(!1),[R,ve]=(0,I.useState)(!1),ye=(0,I.useRef)(null),V,G;t[0]===w?(V=t[1],G=t[2]):(V=()=>{let e=ye.current;e&&(w===`folder`?(e.setAttribute(`webkitdirectory`,``),e.setAttribute(`directory`,``)):(e.removeAttribute(`webkitdirectory`),e.removeAttribute(`directory`)))},G=[w],t[0]=w,t[1]=V,t[2]=G),(0,I.useEffect)(V,G);let K;t[3]===T?K=t[4]:(K=T.trim(),t[3]=T,t[4]=K);let q=K,J=w===`zip`||w===`folder`,be=j?.[0]?.webkitRelativePath?.split(`/`)[0]??``,xe,Se;t[5]!==J||t[6]!==q?(xe=()=>{if(J||q===``){me(null),_e(!1),ve(!1),A(``);return}let e=!1,t=new AbortController;_e(!0),ve(!1);let n=setTimeout(()=>{M(q,t.signal).then(t=>{if(!e){if(_e(!1),!t.ok){me(null),A(``),ve(!0);return}ve(!1),me(t.skills),A(t.skills.length>1?t.skills[0].name:``)}})},500);return()=>{e=!0,t.abort(),clearTimeout(n)}},Se=[q,J],t[5]=J,t[6]=q,t[7]=xe,t[8]=Se):(xe=t[7],Se=t[8]),(0,I.useEffect)(xe,Se);let Ce=!N&&(J?j!==null&&j.length>0:q!==``),we;t[9]!==l||t[10]!==Ce||t[11]!==j||t[12]!==J||t[13]!==o||t[14]!==r||t[15]!==S||t[16]!==k||t[17]!==w||t[18]!==q?(we=async function(){if(!Ce)return;if(pe(!0),J&&j!==null){let e=new FormData;if(w===`zip`)e.append(`file`,j[0]);else for(let t of Array.from(j))e.append(`files`,t,t.webkitRelativePath||t.name);let t=await ue(e,S);if(pe(!1),!t.ok){E.error(l({id:`Z8nach`,values:{0:t.error}}));return}z(`upload`,t),o({scope:S,name:t.name}),r(!1);return}let e=await fe({source:q,...k.trim()===``?{}:{skill:k.trim()},scope:S});if(pe(!1),!e.ok){if(e.skills&&e.skills.length>1){me(e.skills.map(W)),A(e.skills[0]),E.info(l({id:`iYUTsI`}));return}E.error(l({id:`kfL8BJ`,values:{0:e.error}}));return}z(`import`,e),o({scope:S,name:e.name}),r(!1)},t[9]=l,t[10]=Ce,t[11]=j,t[12]=J,t[13]=o,t[14]=r,t[15]=S,t[16]=k,t[17]=w,t[18]=q,t[19]=we):we=t[19];let Te=we,Ee=d,De;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,L.jsx)(i,{id:`aBgwis`}),t[20]=De):De=t[20];let Y;t[21]===m?Y=t[22]:(Y=(0,L.jsx)(h,{htmlFor:m,children:De}),t[21]=m,t[22]=Y);let Oe;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>C(e),t[23]=Oe):Oe=t[23];let ke;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,L.jsx)(x,{}),t[24]=ke):ke=t[24];let X;t[25]===m?X=t[26]:(X=(0,L.jsx)(y,{id:m,className:`w-full`,children:ke}),t[25]=m,t[26]=X);let Z;t[27]===b?Z=t[28]:(Z=le.map(e=>(0,L.jsx)(_,{value:e,children:b[e]},e)),t[27]=b,t[28]=Z);let Ae;t[29]===Z?Ae=t[30]:(Ae=(0,L.jsx)(v,{children:Z}),t[29]=Z,t[30]=Ae);let je;t[31]!==S||t[32]!==X||t[33]!==Ae?(je=(0,L.jsxs)(te,{value:S,onValueChange:Oe,children:[X,Ae]}),t[31]=S,t[32]=X,t[33]=Ae,t[34]=je):je=t[34];let Me;t[35]!==je||t[36]!==Y?(Me=(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Y,je]}),t[35]=je,t[36]=Y,t[37]=Me):Me=t[37];let Ne;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=(0,L.jsx)(i,{id:`wdxz7K`}),t[38]=Ne):Ne=t[38];let Pe;t[39]===u?Pe=t[40]:(Pe=(0,L.jsx)(h,{id:u,children:Ne}),t[39]=u,t[40]=Pe);let Fe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=e=>{ie(e),de(null)},t[41]=Fe):Fe=t[41];let Ie=`${u}-remote`,Le=w===`remote`?`border-primary bg-primary/5`:`border-border hover:bg-muted/40`,Re;t[42]===Le?Re=t[43]:(Re=s(B,Le),t[42]=Le,t[43]=Re);let ze;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,L.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,L.jsx)(ae,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,L.jsx)(i,{id:`qlAIQ1`})]}),t[44]=ze):ze=t[44];let Be;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(Be=(0,L.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[ze,(0,L.jsx)(`span`,{className:`text-1sm text-muted-foreground`,children:(0,L.jsx)(i,{id:`9m4D_h`})})]}),t[45]=Be):Be=t[45];let Ve=`${u}-remote`,He;t[46]===Ve?He=t[47]:(He=(0,L.jsx)(ne,{id:Ve,value:`remote`,className:`mt-0.5`}),t[46]=Ve,t[47]=He);let Ue;t[48]!==Ie||t[49]!==Re||t[50]!==He?(Ue=(0,L.jsxs)(h,{htmlFor:Ie,className:Re,children:[Be,He]}),t[48]=Ie,t[49]=Re,t[50]=He,t[51]=Ue):Ue=t[51];let We=`${u}-zip`,Ge=w===`zip`?`border-primary bg-primary/5`:`border-border hover:bg-muted/40`,Ke;t[52]===Ge?Ke=t[53]:(Ke=s(B,Ge),t[52]=Ge,t[53]=Ke);let qe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,L.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,L.jsx)(F,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,L.jsx)(i,{id:`Fr8JGg`})]}),t[54]=qe):qe=t[54];let Je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Je=(0,L.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[qe,(0,L.jsx)(`span`,{className:`text-1sm text-muted-foreground`,children:(0,L.jsx)(i,{id:`hQjvzi`})})]}),t[55]=Je):Je=t[55];let Ye=`${u}-zip`,Xe;t[56]===Ye?Xe=t[57]:(Xe=(0,L.jsx)(ne,{id:Ye,value:`zip`,className:`mt-0.5`}),t[56]=Ye,t[57]=Xe);let Ze;t[58]!==We||t[59]!==Ke||t[60]!==Xe?(Ze=(0,L.jsxs)(h,{htmlFor:We,className:Ke,children:[Je,Xe]}),t[58]=We,t[59]=Ke,t[60]=Xe,t[61]=Ze):Ze=t[61];let Qe=`${u}-folder`,$e=w===`folder`?`border-primary bg-primary/5`:`border-border hover:bg-muted/40`,et;t[62]===$e?et=t[63]:(et=s(B,$e),t[62]=$e,t[63]=et);let tt;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,L.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,L.jsx)(O,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,L.jsx)(i,{id:`kNqMMd`})]}),t[64]=tt):tt=t[64];let nt;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,L.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[tt,(0,L.jsx)(`span`,{className:`text-1sm text-muted-foreground`,children:(0,L.jsx)(i,{id:`UPWItY`})})]}),t[65]=nt):nt=t[65];let rt=`${u}-folder`,it;t[66]===rt?it=t[67]:(it=(0,L.jsx)(ne,{id:rt,value:`folder`,className:`mt-0.5`}),t[66]=rt,t[67]=it);let at;t[68]!==Qe||t[69]!==et||t[70]!==it?(at=(0,L.jsxs)(h,{htmlFor:Qe,className:et,children:[nt,it]}),t[68]=Qe,t[69]=et,t[70]=it,t[71]=at):at=t[71];let ot;t[72]!==w||t[73]!==u||t[74]!==Ue||t[75]!==Ze||t[76]!==at?(ot=(0,L.jsxs)(re,{value:w,onValueChange:Fe,"aria-labelledby":u,className:`grid-cols-1 gap-2 sm:grid-cols-3 mb-2`,children:[Ue,Ze,at]}),t[72]=w,t[73]=u,t[74]=Ue,t[75]=Ze,t[76]=at,t[77]=ot):ot=t[77];let st=J?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(se,{ref:ye,id:g,"aria-label":l(w===`zip`?{id:`wErce0`}:{id:`VJaBca`}),type:`file`,"data-testid":`skill-upload-input`,accept:w===`zip`?`.zip,.skill`:void 0,onChange:e=>de(e.target.files),className:`sr-only`},w),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>ye.current?.click(),children:w===`zip`?(0,L.jsx)(i,{id:`-yPBXI`}):(0,L.jsx)(i,{id:`TgZOXj`})}),(0,L.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,"data-testid":`skill-upload-filename`,children:j&&j.length>0?w===`folder`?j.length===1?l({id:`BGtzlf`,values:{uploadFolderName:be}}):l({id:`K7NMEc`,values:{0:j.length,uploadFolderName:be}}):j[0].name:(0,L.jsx)(i,{id:`hqCwRf`})})]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(se,{id:ee,"aria-label":l({id:`cLP0Lf`}),"data-testid":`skill-import-source-input`,value:T,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Te()},placeholder:l({id:`gv5w9J`}),className:`font-mono`}),ge||R||P&&P.length===1?(0,L.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:ge?(0,L.jsx)(i,{id:`K4G55s`}):R?(0,L.jsx)(i,{id:`XgqUOy`}):P&&P.length===1?(0,L.jsx)(i,{id:`WpE38V`,values:{0:P[0].name}}):null}):null]}),ct;t[78]!==Pe||t[79]!==ot||t[80]!==st?(ct=(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Pe,ot,st]}),t[78]=Pe,t[79]=ot,t[80]=st,t[81]=ct):ct=t[81];let lt;t[82]!==P||t[83]!==J||t[84]!==k||t[85]!==p?(lt=!J&&P&&P.length>1?(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(h,{htmlFor:p,children:(0,L.jsx)(i,{id:`FCMaBz`})}),(0,L.jsxs)(te,{value:k,onValueChange:A,children:[(0,L.jsx)(y,{id:p,size:`sm`,className:`w-full`,"data-testid":`skill-import-pick`,children:(0,L.jsx)(x,{})}),(0,L.jsx)(v,{children:P.map(U)})]}),(0,L.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,L.jsx)(i,{id:`xtJgSe`})})]}):null,t[82]=P,t[83]=J,t[84]=k,t[85]=p,t[86]=lt):lt=t[86];let ut;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,L.jsx)(`p`,{className:`font-medium text-xs font-mono text-muted-foreground/80 uppercase tracking-wider`,children:(0,L.jsx)(i,{id:`DWJtEo`})}),t[87]=ut):ut=t[87];let dt;t[88]===S?dt=t[89]:(dt=(0,L.jsx)(`li`,{children:S===`project`?(0,L.jsx)(i,{id:`rucNcu`,components:{0:(0,L.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground/80`})}}):(0,L.jsx)(i,{id:`vjW-SM`,components:{0:(0,L.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] text-foreground/80`})}})}),t[88]=S,t[89]=dt);let ft,pt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,L.jsx)(`li`,{children:(0,L.jsx)(i,{id:`tqQBwN`})}),pt=(0,L.jsx)(`li`,{children:(0,L.jsx)(i,{id:`QB-moX`})}),t[90]=ft,t[91]=pt):(ft=t[90],pt=t[91]);let Q;t[92]===dt?Q=t[93]:(Q=(0,L.jsxs)(`div`,{role:`note`,className:`space-y-3`,"data-testid":`skill-import-disclosure`,children:[ut,(0,L.jsxs)(`ul`,{className:`list-disc space-y-2.5 pl-4 text-sm text-muted-foreground marker:text-muted-foreground/50`,children:[dt,ft,pt]})]}),t[92]=dt,t[93]=Q);let mt;t[94]!==Ee||t[95]!==Me||t[96]!==ct||t[97]!==lt||t[98]!==Q?(mt=(0,L.jsxs)(Ee,{className:`flex flex-col gap-6`,children:[Me,ct,lt,Q]}),t[94]=Ee,t[95]=Me,t[96]=ct,t[97]=lt,t[98]=Q,t[99]=mt):mt=t[99];let ht;t[100]===r?ht=t[101]:(ht=()=>r(!1),t[100]=r,t[101]=ht);let gt;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(gt=(0,L.jsx)(i,{id:`dEgA5A`}),t[102]=gt):gt=t[102];let _t;t[103]!==N||t[104]!==ht?(_t=(0,L.jsx)(c,{variant:`outline`,className:`font-mono uppercase`,onMouseDown:H,onClick:ht,disabled:N,children:gt}),t[103]=N,t[104]=ht,t[105]=_t):_t=t[105];let vt=J?`skill-upload-button`:`skill-import-button`,yt;t[106]===Te?yt=t[107]:(yt=()=>void Te(),t[106]=Te,t[107]=yt);let bt=!Ce,xt;t[108]!==N||t[109]!==J?(xt=N?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(oe,{className:`size-4 animate-spin`}),J?(0,L.jsx)(i,{id:`_eguJc`}):(0,L.jsx)(i,{id:`RqSvT0`})]}):J?(0,L.jsx)(i,{id:`ONWvwQ`}):(0,L.jsx)(i,{id:`l3s5ri`}),t[108]=N,t[109]=J,t[110]=xt):xt=t[110];let $;t[111]!==vt||t[112]!==yt||t[113]!==bt||t[114]!==xt?($=(0,L.jsx)(c,{"data-testid":vt,onClick:yt,disabled:bt,children:xt}),t[111]=vt,t[112]=yt,t[113]=bt,t[114]=xt,t[115]=$):$=t[115];let St;t[116]!==_t||t[117]!==$?(St=(0,L.jsxs)(f,{children:[_t,$]}),t[116]=_t,t[117]=$,t[118]=St):St=t[118];let Ct;return t[119]!==mt||t[120]!==St?(Ct=(0,L.jsxs)(L.Fragment,{children:[mt,St]}),t[119]=mt,t[120]=St,t[121]=Ct):Ct=t[121],Ct}function H(e){return e.preventDefault()}function U(e){return(0,L.jsx)(_,{value:e.name,children:e.name},e.name)}function W(e){return{name:e,description:null}}function G(e){let t=(0,he.c)(21),{defaultScope:n,open:r,onOpenChange:a,defaultTab:o,onImported:s}=e,c=o===void 0?`skills-sh`:o,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,L.jsx)(ee,{children:(0,L.jsx)(i,{id:`GBQjiV`})}),t[0]=d):d=t[0];let f;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,L.jsxs)(p,{children:[d,(0,L.jsx)(l,{className:`sr-only`,children:(0,L.jsx)(i,{id:`qTcVwj`})})]}),t[1]=f):f=t[1];let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,L.jsx)(S,{variant:`line`,value:`skills-sh`,children:(0,L.jsx)(i,{id:`8tjQCz`})}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,L.jsxs)(w,{variant:`line`,className:`w-full justify-start gap-4 border-b p-0`,children:[h,(0,L.jsx)(S,{variant:`line`,value:`upload`,children:(0,L.jsx)(i,{id:`ONWvwQ`})})]}),t[3]=g):g=t[3];let _;t[4]===a?_=t[5]:(_=()=>a(!1),t[4]=a,t[5]=_);let v;t[6]!==n||t[7]!==_?(v=(0,L.jsx)(C,{value:`skills-sh`,className:`h-[62vh] min-h-0 flex-none`,children:(0,L.jsx)(R,{scope:n,onNavigate:_})}),t[6]=n,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==n||t[10]!==s||t[11]!==a?(y=(0,L.jsx)(C,{value:`upload`,className:`mt-3 flex min-h-0 flex-1 flex-col gap-6`,children:(0,L.jsx)(V,{defaultScope:n,onOpenChange:a,onImported:s})}),t[9]=n,t[10]=s,t[11]=a,t[12]=y):y=t[12];let b;t[13]!==c||t[14]!==v||t[15]!==y?(b=(0,L.jsxs)(u,{className:`flex max-h-[85vh] flex-col gap-4 sm:max-w-4xl`,children:[f,(0,L.jsxs)(ie,{defaultValue:c,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[g,v,y]})]}),t[13]=c,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==a||t[18]!==r||t[19]!==b?(x=(0,L.jsx)(m,{open:r,onOpenChange:a,children:b}),t[17]=a,t[18]=r,t[19]=b,t[20]=x):x=t[20],x}export{G as ImportSkillDialog};
|