@inkeep/open-knowledge 0.8.0-beta.14 → 0.8.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/{chunk-HWBSOZZR-CFFhOzgy.mjs → chunk-HWBSOZZR-B0-Qfe0T.mjs} +3 -3
  4. package/dist/cli.d.mts +7 -1
  5. package/dist/cli.mjs +45 -42
  6. package/dist/constants-Bdd0BBBE.mjs +2 -0
  7. package/dist/{dist-lSCD8oz8.mjs → dist-D4zoOvWC.mjs} +16 -20
  8. package/dist/dist-LiBfDl2k.mjs +1 -0
  9. package/dist/{flag-coverage-QT4N2Z44-CQ2g5NLf.mjs → flag-coverage-QT4N2Z44-g6MqLsWy.mjs} +2 -2
  10. package/dist/{gh-detect-CmRIH7je.mjs → gh-detect-jLwJ9bOe.mjs} +2 -2
  11. package/dist/index.mjs +1 -1
  12. package/dist/{init-CJL4wRMl.mjs → init-CL8mchva.mjs} +13 -13
  13. package/dist/init-Cn4QQisC.mjs +1 -0
  14. package/dist/{js-exec-M6UR76J5-BssUQ3SC.mjs → js-exec-M6UR76J5-D6BVeQcA.mjs} +4 -4
  15. package/dist/loader-Bd8DLr1D.mjs +1 -0
  16. package/dist/{loader-2O0Sr-YE.mjs → loader-CD9Cf-je.mjs} +3 -3
  17. package/dist/preview-DnjgfpXJ.mjs +1 -0
  18. package/dist/{preview-DyHTxXSv.mjs → preview-DvYf3kcu.mjs} +2 -2
  19. package/dist/{python3-AUFTPCU6-BSuL_Nsg.mjs → python3-AUFTPCU6-CcfVkAVy.mjs} +3 -3
  20. package/dist/{repair-launch-json-1v32GZcd.mjs → repair-launch-json-Dhq_x0b3.mjs} +2 -2
  21. package/dist/{repair-mcp-configs-CZXWhNQh.mjs → repair-mcp-configs-DOuR37tP.mjs} +2 -2
  22. package/dist/repair-skills-7pBVTbub.mjs +1 -0
  23. package/dist/{repair-skills-B4l2j5St.mjs → repair-skills-B9jE33Ah.mjs} +2 -2
  24. package/dist/{sqlite3-56UMWEY3-B0OUvEvJ.mjs → sqlite3-56UMWEY3-DN8JOqf2.mjs} +1 -1
  25. package/dist/{src-y5EY2iT_.mjs → src-Cbymbi2A.mjs} +2 -2
  26. package/dist/start-C1b3Km0h.mjs +1 -0
  27. package/dist/{start-CRTxDu_v.mjs → start-yi64RGnp.mjs} +2 -2
  28. package/dist/{write-project-skill-BH_iLvg3.mjs → write-project-skill-DCqIN5fH.mjs} +2 -2
  29. package/package.json +4 -1
  30. package/dist/constants-C3I7xExN.mjs +0 -2
  31. package/dist/dist-B1bXj22d.mjs +0 -1
  32. package/dist/init-BhCtH30A.mjs +0 -1
  33. package/dist/loader-CHO2rfjC.mjs +0 -1
  34. package/dist/preview-C6Lu126-.mjs +0 -1
  35. package/dist/repair-skills-K6DWb3wZ.mjs +0 -1
  36. package/dist/start-bIed-lZx.mjs +0 -1
@@ -0,0 +1 @@
1
+ import{$ as e,$n as t,$t as n,A as r,An as i,Ar as a,At as o,B as s,Bn as c,Br as l,Bt as u,C as d,Cn as f,Cr as p,Ct as m,D as h,Dn as g,Dr as _,Dt as v,E as y,En as b,Er as x,Et as S,F as C,Fn as w,Fr as T,Ft as E,G as D,Gn as O,Gr as k,Gt as A,H as j,Hn as M,Hr as N,Ht as P,I as F,In as I,Ir as L,It as R,J as z,Jn as B,Jt as V,K as H,Kn as U,Kt as W,L as G,Ln as K,Lr as q,Lt as J,M as Y,Mn as X,Mr as Z,Mt as Q,N as $,Nn as ee,Nr as te,Nt as ne,O as re,On as ie,Or as ae,Ot as oe,P as se,Pn as ce,Pr as le,Pt as ue,Q as de,Qn as fe,Qt as pe,R as me,Rn as he,Rr as ge,Rt as _e,S as ve,Si as ye,Sn as be,Sr as xe,St as Se,T as Ce,Tn as we,Tr as Te,Tt as Ee,U as De,Un as Oe,Ur as ke,Ut as Ae,V as je,Vn as Me,Vr as Ne,Vt as Pe,W as Fe,Wn as Ie,Wr as Le,Wt as Re,X as ze,Xn as Be,Xt as Ve,Y as He,Yn as Ue,Yt as We,Z as Ge,Zn as Ke,Zt as qe,_ as Je,_n as Ye,_r as Xe,_t as Ze,a as Qe,an as $e,ar as et,at as tt,b as nt,bn as rt,br as it,bt as at,c as ot,cn as st,cr as ct,ct as lt,d as ut,dn as dt,dr as ft,dt as pt,en as mt,er as ht,et as gt,f as _t,fn as vt,fr as yt,ft as bt,g as xt,gi as St,gn as Ct,gr as wt,gt as Tt,h as Et,hn as Dt,hr as Ot,ht as kt,i as At,ii as jt,in as Mt,ir as Nt,it as Pt,j as Ft,jn as It,jr as Lt,jt as Rt,k as zt,kn as Bt,kr as Vt,kt as Ht,l as Ut,ln as Wt,lr as Gt,lt as Kt,m as qt,mi as Jt,mn as Yt,mr as Xt,mt as Zt,n as Qt,nn as $t,nr as en,nt as tn,o as nn,on as rn,or as an,ot as on,p as sn,pn as cn,pr as ln,pt as un,q as dn,qn as fn,qt as pn,r as mn,ri as hn,rn as gn,rr as _n,rt as vn,s as yn,si as bn,sn as xn,sr as Sn,st as Cn,t as wn,tn as Tn,tr as En,tt as Dn,u as On,un as kn,ur as An,ut as jn,v as Mn,vi as Nn,vn as Pn,vr as Fn,vt as In,w as Ln,wi as Rn,wn as zn,wr as Bn,wt as Vn,x as Hn,xn as Un,xr as Wn,xt as Gn,y as Kn,yi as qn,yn as Jn,yr as Yn,yt as Xn,z as Zn,zn as Qn,zr as $n,zt as er}from"./dist-D4zoOvWC.mjs";import{_ as tr,a as nr,c as rr,d as ir,f as ar,g as or,i as sr,l as cr,m as lr,n as ur,o as dr,p as fr,r as pr,s as mr,t as hr,u as gr}from"./server-lock-BniQ3qki-C_0QTo_r.mjs";export{wn as AGENT_ID_MAX_LEN,Qt as AGENT_ID_RE,mn as AGENT_WRITE_ORIGIN,At as AgentFocusBroadcaster,Qe as AgentPresenceBroadcaster,nn as AgentSessionCapacityError,yn as AgentSessionManager,ot as BacklinkIndex,Ut as CC1Broadcaster,bn as CC1_CONTRACT_VERSION,On as CONFLICT_MARKER_RE,ut as CURSOR_BUNDLE_PATHS_BY_PLATFORM,_t as ConfigSchema,sn as DEFAULT_CHECKPOINT_RETENTION,qt as DEFAULT_PACK_ID,Et as FILE_SYSTEM_WRITER,xt as FILE_WATCHER_ORIGIN,Je as GIT_UPSTREAM_WRITER,hn as GitDirAccessError,Mn as HOCUSPOCUS_AUTH_REJECTION_REASONS,Kn as HocuspocusAuthRejection,nt as HocuspocusAuthTokenSchema,Hn as INSTALLED_AGENTS_SCHEMES,ve as LIVE_DERIVED_INDEX_DEBOUNCE_MS,d as LOG_MD_TEMPLATE,Ln as MANAGED_RENAME_ORIGIN,Ce as MAX_AGENT_SESSIONS,y as MCP_CONNECTION_ID_HEADER,h as MCP_SERVER_NAME,re as MISSING_OK_CONFIG_MESSAGE,jt as MalformedGitPointerError,zt as McpLogger,r as MissingOkConfigError,Ft as OBSERVER_SYNC_ORIGIN,Jt as ORPHAN_MODES,Y as PinoLogger,hr as ProcessLockCollisionError,$ as ProjectGitInitError,se as ROLLBACK_ORIGIN,ur as RUNTIME_VERSION,C as SERVICE_WRITER,F as SKILL_INSTALL_EVENTS_FILE_REL,St as SKILL_STATE_TARGETS,G as STARTER_FOLDERS,me as STARTER_FOLDER_FRONTMATTER_FILENAME,Zn as STARTER_PACKS,s as STARTER_PACK_IDS,je as STARTER_TEMPLATES,j as STATE_MANIFEST_FILENAME,pr as STATE_SCHEMA_VERSION,Nn as SYSTEM_DOC_NAME,De as SeedPrerequisiteError,Fe as SeedRootDirError,sr as ServerLockCollisionError,D as StateManifestError,H as TagIndex,dn as UiLockCollisionError,nr as acquireProcessLock,dr as acquireServerLock,z as acquireUiLock,He as applyAgentMarkdownWrite,ze as applyExternalChange,Ge as applySeed,de as assertCompatibleStateManifest,e as assertNeverDiskEvent,gt as attachIdleShutdown,Dn as bootServer,tn as buildAndOpenSkill,vn as buildExecResult,Pt as buildInstructions,tt as buildSkillZip,on as buildStarterFolderFrontmatterYaml,Cn as buildWipTree,lt as classifyEvents,Kt as classifyFsPath,jn as clearContributors,pt as coercePackId,qn as colorFromSeed,bt as commitUpstreamImport,un as commitWip,Zt as commitWipFromTree,kt as containsConflictMarkers,Tt as contentHash,Ze as contributorCount,In as createApiExtension,Xn as createAssetServeMiddleware,at as createContentFilter,Gn as createContentFilterAsync,Se as createExternalChangeHandler,m as createFileLogger,Vn as createLiveDerivedIndexExtension,Ee as createMcpHttpHandler,S as createOsProbe,v as createPersistenceExtension,oe as createServer,Ht as createServerObserverExtension,o as createStreamingErrorWriter,Rt as createTestLogger,Q as detectClaudeDesktopPresence,ne as detectProjectShape,ue as ensureProjectGit,E as errorResponse,R as evictStaleTrackerEntries,J as extractWikiLinksFromMarkdown,_e as findEnclosingGitRoot,er as findEnclosingProjectRoot,u as formatAuthRejectionWire,Pe as formatContributors,P as formatContributorsFrom,Ae as gcCheckpointRefs,Re as getCurrentMcpLogger,A as getLocalDir,W as getLogFilePath,pn as getLogger,V as getLogsDir,We as getMeter,Ve as getMetrics,qe as getTracer,pe as handleCollabSocketError,n as handleSpawnCursor,ye as iconFromClientName,mt as incrementCollabSocketFilteredError,Tn as incrementServerObserverFire,$t as initShadowRepo,gn as initTelemetry,Mt as installPrettyZodErrors,$e as installTestLoggers,rn as installUserSkill,xn as isAllowedApiOrigin,st as isAllowedWorkspaceHostHeader,Wt as isConfigDoc,kn as isHocuspocusAuthRejectionReason,dt as isKnownPackId,vt as isLoopbackAddress,Rn as isOrphanMode,cn as isPairedWriteOrigin,Yt as isPathWithinDir,mr as isProcessAlive,Dt as isProjectRoot,Ct as isSelfWrite,Ye as isSystemDoc,rr as isValidLockPid,Pn as lastKnownHash,Jn as listRescueCheckpoints,rt as listStarterPacks,Un as loadPrincipal,cr as lockFilePath,be as loggerFactory,f as mountMcpAndApi,zn as normalizeFsPath,we as parseAuthRejectionWire,b as parseHocuspocusAuthToken,g as parseKeepaliveConnectionId,ie as pathToDocName,Bt as planSeed,i as readAllTargets,It as readBranchFromHead,gr as readProcessLock,ir as readProcessLockDetailed,ar as readServerLock,X as readServerPackageVersion,ee as readSkillInstallStateSnapshot,ce as readStateManifest,w as readTargetRecordedAt,I as readTargetVersion,K as readUiLock,he as reconcile,Qn as recordContributor,c as recordSkillInstallEvent,Me as registerAllTools,M as registerWrite,fr as releaseProcessLock,lr as releaseServerLock,Oe as releaseUiLock,Ie as removeLastKnownHash,O as resetMetrics,U as resolveBundledSkillDir,fn as resolveContentDir,B as resolveCursorBinaryDefault,Ue as resolveCursorSpawnInvocation,Be as resolveLockDir,Ke as resolvePack,fe as resolvePackageVersion,t as restoreContributors,ht as restoreLifecycleFromConflictsJson,En as rewriteMarkdownLinksForDocumentRename,en as rewriteWikiLinksForDocumentRename,_n as runAuthReposSubprocess,Nt as runAuthStatusSubprocess,et as runCloneSubprocess,an as runDeviceFlowSubprocess,Sn as runWithMcpLogger,ct as safeContentPath,Gt as safeSubdir,An as safetyCheckpoint,ft as sanitizeClientName,yt as saveInMemoryCheckpoint,ln as saveVersion,Xt as seedBasenameIndex,Ot as serializeError,wt as setActiveSpanAttributes,Xe as shadowGit,Fn as shutdownTelemetry,Yn as spawnDetached,it as splitMarkdownBlocks,Wn as startWatcher,xe as streamingProblemEvent,p as swapContributors,Bn as toBroadcasterKey,Te as tracedAppendFileSync,x as tracedLinkSync,_ as tracedMkdir,ae as tracedMkdirSync,Vt as tracedRename,a as tracedRenameSync,Lt as tracedRmSync,Z as tracedRmdirSync,te as tracedUnlinkSync,le as tracedWriteFile,T as tracedWriteFileSync,L as updateLastKnownHash,or as updateProcessLockPort,tr as updateServerLockPort,q as updateUiLockPort,ge as validateAgentId,$n as validateCloneInputs,l as validateSkillZip,Ne as withSpan,N as withSpanSync,ke as writeStateManifest,Le as writeTargetVersion,k as writeTracker};
@@ -1,2 +1,2 @@
1
- import"./chunk-YNYSPYQ5-Dq-BWW-f.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import"./chunk-A5O5YHGN-DQP-O5US.mjs";import"./chunk-24IMIIXA-_PX4ITYZ.mjs";import{i as e,n as t}from"./chunk-VOBGTVA6-BT7gUxqf.mjs";import{t as n}from"./chunk-OARHFVLG-DGpNgI6K.mjs";import{n as r}from"./chunk-QJ7O6ZN3-BH67tCjg.mjs";import{n as i}from"./chunk-ALLTKNUZ-BMiTDN50.mjs";import{n as ee,r as te}from"./chunk-D6CWQ5DW-BudNEuOo.mjs";import{n as a}from"./chunk-TXBZCHCQ-l48TczF5.mjs";import{n as o}from"./chunk-4GTNDTRF-_OVmXcJ-.mjs";import{t as s}from"./chunk-LL3S3NLB-DxXgE3kY.mjs";import{n as c}from"./chunk-LWEGUNWT-BALY4RLC.mjs";import{n as l}from"./chunk-Z7JVV2SM-BzR-yvwK.mjs";import{n as u}from"./chunk-NUYSJFDK-BVw8oahq.mjs";import{t as d}from"./chunk-SDNKECQQ-C3GEf3VZ.mjs";import{t as f}from"./chunk-D7MEQ3VN-Csvth_Ss.mjs";import{n as p}from"./chunk-TLSUDHID-6EWOySH2.mjs";import{t as m}from"./chunk-4Q4SM6WR-DDQRsilN.mjs";import{n as h}from"./chunk-RPNGRAAP-BughPjdR.mjs";import{n as g}from"./chunk-GCTKCWKD-Deqi1D_N.mjs";import{n as _,r as v}from"./chunk-NAERJDUW-B3fduMx2.mjs";import{n as y}from"./chunk-VJFXDYWH-IiUXkKX0.mjs";import{t as b}from"./chunk-YFG2CMIF-CVDz5Fsh.mjs";import{n as x}from"./chunk-CR5AFCPT-BBd9E4Jo.mjs";import"./chunk-J642UCRS-D2hPh3Cf.mjs";import{t as S}from"./chunk-LPQPILI2-8E8WwnE3.mjs";import{t as C}from"./chunk-BRGMQKJV-Dr9Z7G7y.mjs";import"./chunk-SYMJJMQ4-0QtKvQIP.mjs";import"./chunk-7TSDKFEO-a-GUGBTu.mjs";import"./chunk-BBXLRYSX-Cxoye6wj.mjs";import{n as w}from"./chunk-XORM457F-BAW3OKIy.mjs";import"./chunk-F55TLFGB-CezmwFJN.mjs";import{t as T}from"./chunk-UNYNJIFU-BbdoO4yb.mjs";import{r as E}from"./chunk-HWBSOZZR-CFFhOzgy.mjs";import{n as D}from"./chunk-MDLLFABN-oBQf6bGE.mjs";import{n as O}from"./chunk-MLXIYONF-CQ5Q9uTP.mjs";import{n as k}from"./chunk-A65PWWJC-D7J5l9eq.mjs";import{t as A}from"./chunk-MHTUABJP-dKmK6Hw7.mjs";import{n as j}from"./chunk-4HHKTUW3-Dm69hDaZ.mjs";import{n as M}from"./chunk-HJQJAYMS-Ci3vsKQW.mjs";import{n as N}from"./chunk-PP6PSHAB-DMC_XCfO.mjs";import{i as P,n as F,o as I}from"./chunk-LTZRCH7N-GAjTFNwG.mjs";import{t as L}from"./chunk-YTNYSM6T-KUvMCIKS.mjs";import{t as R}from"./chunk-Z6LRHWXI-CF_r-CgG.mjs";import{n as z}from"./chunk-A7A2DBEE-PLfkXLI4.mjs";import{t as B}from"./chunk-APT7OOP2-CXHnSuct.mjs";import{n as V}from"./chunk-XKQRETAK-cVWA9gEB.mjs";import{n as H}from"./chunk-5V6VZH6T-BCr5_GDF.mjs";import{n as U,r as W}from"./chunk-R6QSAL5T-CtbJTvt9.mjs";import{n as G}from"./chunk-YCFVLTST-PFJX6AMj.mjs";import{t as K}from"./chunk-GOV5EKKI-DNFJiYJI.mjs";import{t as q}from"./chunk-XVDPCNWR-CtK-Xs2O.mjs";import{n as J}from"./chunk-NCNPKYJZ-BFGan4lR.mjs";import{t as ne}from"./chunk-TOMNU26N-BjLxRX8P.mjs";import{t as Y}from"./chunk-PYSFUGCK-CY7pclEB.mjs";import{t as X}from"./chunk-VYOJP4TV-BvibOnKG.mjs";import{t as Z}from"./chunk-MYE6AGBJ-B4pRo9ma.mjs";import{t as re}from"./chunk-A7ICOL4V-Drb3XsEL.mjs";import{t as ie}from"./chunk-55VFSPNA-DVZfQAzN.mjs";import{n as ae}from"./chunk-WKFATFPP-DCZdrA8x.mjs";import{n as oe}from"./chunk-JVPRLUMK-DnQCNjpq.mjs";import{t as se}from"./chunk-62RKD26F-Xy18vjr1.mjs";import{t as ce}from"./chunk-QCDB2VPH-D1RuXtOm.mjs";import{t as le}from"./chunk-F23WWYKW-DST0dB7V.mjs";import{n as ue}from"./chunk-D4J545R4-C8nMOauR.mjs";import{t as de}from"./chunk-DCAAORBQ-BdrR5ttw.mjs";import{n as fe}from"./chunk-GXVXFKBA-993FoPmq.mjs";import{n as pe}from"./chunk-5QVNJEHU-BvsipSFW.mjs";import"./chunk-VLGZJRPG-B678hnuU.mjs";import{a as me,n as he,o as ge}from"./chunk-YS3AZT3J-DRSVwRFh.mjs";import{n as _e}from"./chunk-NYQYO467-nPa6J2DD.mjs";import{n as ve}from"./chunk-OL3S66CO-DtsweltN.mjs";import{t as ye}from"./chunk-KMEYNNUA-DfdK88O_.mjs";import{t as be}from"./chunk-MIZPJHVH-BPfxJ3C2.mjs";import{n as xe}from"./chunk-A4JSPFCI-D3-Pg2lq.mjs";import{t as Q}from"./chunk-PBXLG62G-Ci7A7XGA.mjs";import{t as Se}from"./chunk-A4HU7SVR-hefV_YmW.mjs";import{t as Ce}from"./chunk-HJWBQKYG-UZig4wUt.mjs";import{t as we}from"./chunk-64BAICW3-CTJNEx4Q.mjs";import{n as Te}from"./chunk-T56QNPHK-DjHqXy9T.mjs";import{n as Ee}from"./chunk-V7TAPXDL-CnKUp2df.mjs";import{n as De}from"./chunk-MDDMCKUK-DD6paciv.mjs";import{t as Oe}from"./chunk-OCS6LSEM-WwUGJ0am.mjs";import{n as ke}from"./chunk-OCLXQMOG-Bktk24jL.mjs";var Ae=[g,a,Te,Ee,De,Oe,ke,be,u,xe,Q,o,Se,Ce,we,de,fe,pe,ge,he,me,_e,ve,n,ye,ae,l,d,oe,se,ce,le,ue,y,Y,X,Z,c,re,ie,S,i,m,q,h,_,v,e,t,J,ne,W,U,s,te,ee,G,r,p,f,K,L,R,z,b,B,V,H,x,D,O,k,A,j,M,N,P,F,I,C,w,T,E];function je(){return Ae}var $=new Map;for(let e of je())$.set(e.name,new Set(e.flags.map(e=>e.flag)));function Me(e,t,n){let r=$.get(t);if(!(!r||r.size===0))for(let i of n)r.has(i)&&e.hit(`cmd:flag:${t}:${i}`)}export{Me as emitFlagCoverage};
2
- //# sourceMappingURL=flag-coverage-QT4N2Z44-CQ2g5NLf.mjs.map
1
+ import"./chunk-YNYSPYQ5-Dq-BWW-f.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import"./chunk-A5O5YHGN-DQP-O5US.mjs";import"./chunk-24IMIIXA-_PX4ITYZ.mjs";import{i as e,n as t}from"./chunk-VOBGTVA6-BT7gUxqf.mjs";import{t as n}from"./chunk-OARHFVLG-DGpNgI6K.mjs";import{n as r}from"./chunk-QJ7O6ZN3-BH67tCjg.mjs";import{n as i}from"./chunk-ALLTKNUZ-BMiTDN50.mjs";import{n as ee,r as te}from"./chunk-D6CWQ5DW-BudNEuOo.mjs";import{n as a}from"./chunk-TXBZCHCQ-l48TczF5.mjs";import{n as o}from"./chunk-4GTNDTRF-_OVmXcJ-.mjs";import{t as s}from"./chunk-LL3S3NLB-DxXgE3kY.mjs";import{n as c}from"./chunk-LWEGUNWT-BALY4RLC.mjs";import{n as l}from"./chunk-Z7JVV2SM-BzR-yvwK.mjs";import{n as u}from"./chunk-NUYSJFDK-BVw8oahq.mjs";import{t as d}from"./chunk-SDNKECQQ-C3GEf3VZ.mjs";import{t as f}from"./chunk-D7MEQ3VN-Csvth_Ss.mjs";import{n as p}from"./chunk-TLSUDHID-6EWOySH2.mjs";import{t as m}from"./chunk-4Q4SM6WR-DDQRsilN.mjs";import{n as h}from"./chunk-RPNGRAAP-BughPjdR.mjs";import{n as g}from"./chunk-GCTKCWKD-Deqi1D_N.mjs";import{n as _,r as v}from"./chunk-NAERJDUW-B3fduMx2.mjs";import{n as y}from"./chunk-VJFXDYWH-IiUXkKX0.mjs";import{t as b}from"./chunk-YFG2CMIF-CVDz5Fsh.mjs";import{n as x}from"./chunk-CR5AFCPT-BBd9E4Jo.mjs";import"./chunk-J642UCRS-D2hPh3Cf.mjs";import{t as S}from"./chunk-LPQPILI2-8E8WwnE3.mjs";import{t as C}from"./chunk-BRGMQKJV-Dr9Z7G7y.mjs";import"./chunk-SYMJJMQ4-0QtKvQIP.mjs";import"./chunk-7TSDKFEO-a-GUGBTu.mjs";import"./chunk-BBXLRYSX-Cxoye6wj.mjs";import{n as w}from"./chunk-XORM457F-BAW3OKIy.mjs";import"./chunk-F55TLFGB-CezmwFJN.mjs";import{t as T}from"./chunk-UNYNJIFU-BbdoO4yb.mjs";import{r as E}from"./chunk-HWBSOZZR-B0-Qfe0T.mjs";import{n as D}from"./chunk-MDLLFABN-oBQf6bGE.mjs";import{n as O}from"./chunk-MLXIYONF-CQ5Q9uTP.mjs";import{n as k}from"./chunk-A65PWWJC-D7J5l9eq.mjs";import{t as A}from"./chunk-MHTUABJP-dKmK6Hw7.mjs";import{n as j}from"./chunk-4HHKTUW3-Dm69hDaZ.mjs";import{n as M}from"./chunk-HJQJAYMS-Ci3vsKQW.mjs";import{n as N}from"./chunk-PP6PSHAB-DMC_XCfO.mjs";import{i as P,n as F,o as I}from"./chunk-LTZRCH7N-GAjTFNwG.mjs";import{t as L}from"./chunk-YTNYSM6T-KUvMCIKS.mjs";import{t as R}from"./chunk-Z6LRHWXI-CF_r-CgG.mjs";import{n as z}from"./chunk-A7A2DBEE-PLfkXLI4.mjs";import{t as B}from"./chunk-APT7OOP2-CXHnSuct.mjs";import{n as V}from"./chunk-XKQRETAK-cVWA9gEB.mjs";import{n as H}from"./chunk-5V6VZH6T-BCr5_GDF.mjs";import{n as U,r as W}from"./chunk-R6QSAL5T-CtbJTvt9.mjs";import{n as G}from"./chunk-YCFVLTST-PFJX6AMj.mjs";import{t as K}from"./chunk-GOV5EKKI-DNFJiYJI.mjs";import{t as q}from"./chunk-XVDPCNWR-CtK-Xs2O.mjs";import{n as J}from"./chunk-NCNPKYJZ-BFGan4lR.mjs";import{t as ne}from"./chunk-TOMNU26N-BjLxRX8P.mjs";import{t as Y}from"./chunk-PYSFUGCK-CY7pclEB.mjs";import{t as X}from"./chunk-VYOJP4TV-BvibOnKG.mjs";import{t as Z}from"./chunk-MYE6AGBJ-B4pRo9ma.mjs";import{t as re}from"./chunk-A7ICOL4V-Drb3XsEL.mjs";import{t as ie}from"./chunk-55VFSPNA-DVZfQAzN.mjs";import{n as ae}from"./chunk-WKFATFPP-DCZdrA8x.mjs";import{n as oe}from"./chunk-JVPRLUMK-DnQCNjpq.mjs";import{t as se}from"./chunk-62RKD26F-Xy18vjr1.mjs";import{t as ce}from"./chunk-QCDB2VPH-D1RuXtOm.mjs";import{t as le}from"./chunk-F23WWYKW-DST0dB7V.mjs";import{n as ue}from"./chunk-D4J545R4-C8nMOauR.mjs";import{t as de}from"./chunk-DCAAORBQ-BdrR5ttw.mjs";import{n as fe}from"./chunk-GXVXFKBA-993FoPmq.mjs";import{n as pe}from"./chunk-5QVNJEHU-BvsipSFW.mjs";import"./chunk-VLGZJRPG-B678hnuU.mjs";import{a as me,n as he,o as ge}from"./chunk-YS3AZT3J-DRSVwRFh.mjs";import{n as _e}from"./chunk-NYQYO467-nPa6J2DD.mjs";import{n as ve}from"./chunk-OL3S66CO-DtsweltN.mjs";import{t as ye}from"./chunk-KMEYNNUA-DfdK88O_.mjs";import{t as be}from"./chunk-MIZPJHVH-BPfxJ3C2.mjs";import{n as xe}from"./chunk-A4JSPFCI-D3-Pg2lq.mjs";import{t as Q}from"./chunk-PBXLG62G-Ci7A7XGA.mjs";import{t as Se}from"./chunk-A4HU7SVR-hefV_YmW.mjs";import{t as Ce}from"./chunk-HJWBQKYG-UZig4wUt.mjs";import{t as we}from"./chunk-64BAICW3-CTJNEx4Q.mjs";import{n as Te}from"./chunk-T56QNPHK-DjHqXy9T.mjs";import{n as Ee}from"./chunk-V7TAPXDL-CnKUp2df.mjs";import{n as De}from"./chunk-MDDMCKUK-DD6paciv.mjs";import{t as Oe}from"./chunk-OCS6LSEM-WwUGJ0am.mjs";import{n as ke}from"./chunk-OCLXQMOG-Bktk24jL.mjs";var Ae=[g,a,Te,Ee,De,Oe,ke,be,u,xe,Q,o,Se,Ce,we,de,fe,pe,ge,he,me,_e,ve,n,ye,ae,l,d,oe,se,ce,le,ue,y,Y,X,Z,c,re,ie,S,i,m,q,h,_,v,e,t,J,ne,W,U,s,te,ee,G,r,p,f,K,L,R,z,b,B,V,H,x,D,O,k,A,j,M,N,P,F,I,C,w,T,E];function je(){return Ae}var $=new Map;for(let e of je())$.set(e.name,new Set(e.flags.map(e=>e.flag)));function Me(e,t,n){let r=$.get(t);if(!(!r||r.size===0))for(let i of n)r.has(i)&&e.hit(`cmd:flag:${t}:${i}`)}export{Me as emitFlagCoverage};
2
+ //# sourceMappingURL=flag-coverage-QT4N2Z44-g6MqLsWy.mjs.map
@@ -1,4 +1,4 @@
1
- import{Li as e}from"./dist-lSCD8oz8.mjs";import{execFileSync as t}from"node:child_process";import{dirname as n,join as r}from"node:path";import{existsSync as i,mkdirSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{homedir as c}from"node:os";var l=e();const u=`open-knowledge`;var d=class{backend=`keyring`;async get(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{let n=new t(u,e).getPassword();return n==null?null:JSON.parse(n)}catch{return null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(u,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(u,e).deletePassword()}catch{}}},f=class{backend=`file`;authFile;constructor(e){this.authFile=e??r(c(),`.ok`,`auth.yml`)}read(){if(!i(this.authFile))return{};try{return(0,l.parse)(o(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=n(this.authFile);i(t)||a(t,{recursive:!0,mode:448}),s(this.authFile,(0,l.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)}};async function p(e){try{let{Entry:e}=await import(`@napi-rs/keyring`);return new e(u,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
1
+ import{Vi as e}from"./dist-D4zoOvWC.mjs";import{execFileSync as t}from"node:child_process";import{dirname as n,join as r}from"node:path";import{existsSync as i,mkdirSync as a,readFileSync as o,writeFileSync as s}from"node:fs";import{homedir as c}from"node:os";var l=e();const u=`open-knowledge`;var d=class{backend=`keyring`;async get(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{let n=new t(u,e).getPassword();return n==null?null:JSON.parse(n)}catch{return null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(u,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(u,e).deletePassword()}catch{}}},f=class{backend=`file`;authFile;constructor(e){this.authFile=e??r(c(),`.ok`,`auth.yml`)}read(){if(!i(this.authFile))return{};try{return(0,l.parse)(o(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=n(this.authFile);i(t)||a(t,{recursive:!0,mode:448}),s(this.authFile,(0,l.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)}};async function p(e){try{let{Entry:e}=await import(`@napi-rs/keyring`);return new e(u,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
2
2
  `),new d}catch{return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml)
3
3
  `),new f(e)}}function m(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 f(e))},n)});try{return await Promise.race([p(e),r])}catch{return new f(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function h(e){let t=m(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token}}}}function g(e){let t=m(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 _(e,t){let n=[],r=new f(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(u,`__probe__`);let r=new d;await r.get(e)!=null&&(await r.clear(e),n.push(`keychain`))}catch{}return{touched:n}}const v=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`];function y(e,n={}){let r=n._exec??t,a=n._fileExists??i,o=[`auth`,`token`,...e?[`--hostname`,e]:[]],s=[`gh`,...v.filter(a)];for(let e of s)try{let t=r(e,o,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3}).toString().trim();if(t.length>0)return{available:!0,token:t}}catch{}return{available:!1}}export{g as a,h as i,_ as n,p as r,y as t};
4
- //# sourceMappingURL=gh-detect-CmRIH7je.mjs.map
4
+ //# sourceMappingURL=gh-detect-jLwJ9bOe.mjs.map
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{i as e,r as t,t as n}from"./gh-detect-CmRIH7je.mjs";import{d as r,f as i,g as a,h as o,i as s,m as c,r as l,s as u,t as d,u as f,v as p,y as m}from"./init-CJL4wRMl.mjs";import{i as h,n as g,r as _,t as v}from"./src-y5EY2iT_.mjs";import{n as y}from"./loader-2O0Sr-YE.mjs";import{n as b}from"./preview-DyHTxXSv.mjs";export{c as ALL_EDITOR_IDS,o as EDITOR_LABELS,a as EDITOR_TARGETS,d as LAUNCH_CONFIG_NAME,l as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,s as detectInstalledEditors,m as initContent,y as loadConfig,e as makeLazyProbeTokenStore,_ as parseGitHubBlobUrl,h as parseGitUrl,b as previewContent,u as readExistingMcpEntry,p as resolveProjectRoot,f as scaffoldLaunchJson,g as validateLocalFolderForShare,r as writeEditorMcpConfig,v as writeProjectAiIntegrations,i as writeUserMcpConfigs};
1
+ import{i as e,r as t,t as n}from"./gh-detect-jLwJ9bOe.mjs";import{d as r,f as i,g as a,h as o,i as s,m as c,r as l,s as u,t as d,u as f,v as p,y as m}from"./init-CL8mchva.mjs";import{i as h,n as g,r as _,t as v}from"./src-Cbymbi2A.mjs";import{n as y}from"./loader-CD9Cf-je.mjs";import{n as b}from"./preview-DvYf3kcu.mjs";export{c as ALL_EDITOR_IDS,o as EDITOR_LABELS,a as EDITOR_TARGETS,d as LAUNCH_CONFIG_NAME,l as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,s as detectInstalledEditors,m as initContent,y as loadConfig,e as makeLazyProbeTokenStore,_ as parseGitHubBlobUrl,h as parseGitUrl,b as previewContent,u as readExistingMcpEntry,p as resolveProjectRoot,f as scaffoldLaunchJson,g as validateLocalFolderForShare,r as writeEditorMcpConfig,v as writeProjectAiIntegrations,i as writeUserMcpConfigs};
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{D as a,Jr as o,N as s,Nt as c,Si as l,Zr as u,an as d,ci as f,di as p,fn as m,gi as h,in as g,jt as _,li as v,ln as y,ni as b,rn as x,si as S,ti as C,xi as w}from"./dist-lSCD8oz8.mjs";import{n as ee,t as T}from"./constants-C3I7xExN.mjs";import{t as E}from"./is-object-BXWpSxBI.mjs";import{i as D,o as O,r as k,s as A,t as j}from"./colors-D0wh7lK1.mjs";import{t as te}from"./preview-DyHTxXSv.mjs";import{n as ne,t as M}from"./write-project-skill-BH_iLvg3.mjs";import{execFileSync as re}from"node:child_process";import N,{basename as P,dirname as F,isAbsolute as ie,join as I,posix as ae,relative as L,resolve as R,sep as oe,win32 as se}from"node:path";import{existsSync as z,lstatSync as ce,mkdirSync as le,readFileSync as ue,realpathSync as de,writeFileSync as fe}from"node:fs";import B from"node:process";import{homedir as V}from"node:os";import{AsyncLocalStorage as pe,AsyncResource as me}from"node:async_hooks";import{stripVTControlCharacters as he,styleText as H}from"node:util";import*as ge from"node:readline";import{randomUUID as _e}from"node:crypto";import{createServer as ve,request as ye}from"node:http";import{connect as be}from"node:net";function xe(){return B.platform.startsWith(`win`)?!!B.env.CI||!!B.env.WT_SESSION||!!B.env.TERMINUS_SUBLIME||B.env.ConEmuTask===`{cmd::Cmder}`||B.env.TERM_PROGRAM===`Terminus-Sublime`||B.env.TERM_PROGRAM===`vscode`||B.env.TERM===`xterm-256color`||B.env.TERM===`alacritty`||B.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:B.env.TERM!==`linux`}const Se={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},Ce={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},we={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Te={...Se,...Ce},Ee={...Se,...we},U=xe()?Te:Ee;Object.entries(Ce);var De=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Oe=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),ke=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ae=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,je=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Me=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ne=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Pe=/\t{1,1000}/y,Fe=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Ie=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Le=/\p{M}+/gu,Re={limit:1/0,ellipsis:``},ze=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?ze(i,Re,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ie,l],[je,0],[Me,o],[Pe,s],[Fe,c],[Ne,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Le,``)){let t=e.codePointAt(0)||0;if(S=ke(t)?2:Ae(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Ne?Oe(e.slice(p,n.lastIndex)):n===Fe?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Be={limit:1/0,ellipsis:``,ellipsisWidth:0},W=(e,t={})=>ze(e,Be,t).width,Ve=`]8;;`,He=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ve}(?<uri>.*))`,`y`),Ue=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},We=e=>`[${e}m`,Ge=e=>`${Ve}${e}`,Ke=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:W(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=W(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ve,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},qe=e=>{let t=e.split(` `),n=t.length;for(;n&&!W(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Je=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=W(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=W(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Ke(s,r,t),c=W(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Ke(s,r,t),c=W(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Ke(s,r,t),c=W(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>qe(e)));let l=s.join(`
1
+ import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./esm-CEs3LWY3.mjs";import{D as a,Ei as o,Mt as s,N as c,Pt as l,Qr as u,Ti as d,ai as f,bi as p,cn as m,di as h,fi as g,fn as _,hi as v,hn as y,oi as b,on as x,pi as S,sn as C,ti as w}from"./dist-D4zoOvWC.mjs";import{n as ee,t as T}from"./constants-Bdd0BBBE.mjs";import{t as E}from"./is-object-BXWpSxBI.mjs";import{i as D,o as O,r as k,s as A,t as j}from"./colors-D0wh7lK1.mjs";import{t as te}from"./preview-DvYf3kcu.mjs";import{n as ne,t as M}from"./write-project-skill-DCqIN5fH.mjs";import{execFileSync as re}from"node:child_process";import ie,{basename as N,dirname as P,isAbsolute as ae,join as F,posix as oe,relative as I,resolve as L,sep as se,win32 as ce}from"node:path";import{existsSync as R,lstatSync as le,mkdirSync as ue,readFileSync as z,realpathSync as de,writeFileSync as fe}from"node:fs";import B from"node:process";import{homedir as V}from"node:os";import{AsyncLocalStorage as pe,AsyncResource as me}from"node:async_hooks";import{stripVTControlCharacters as he,styleText as H}from"node:util";import*as ge from"node:readline";import{randomUUID as _e}from"node:crypto";import{createServer as ve,request as ye}from"node:http";import{connect as be}from"node:net";function xe(){return B.platform.startsWith(`win`)?!!B.env.CI||!!B.env.WT_SESSION||!!B.env.TERMINUS_SUBLIME||B.env.ConEmuTask===`{cmd::Cmder}`||B.env.TERM_PROGRAM===`Terminus-Sublime`||B.env.TERM_PROGRAM===`vscode`||B.env.TERM===`xterm-256color`||B.env.TERM===`alacritty`||B.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:B.env.TERM!==`linux`}const Se={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},Ce={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},we={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Te={...Se,...Ce},Ee={...Se,...we},U=xe()?Te:Ee;Object.entries(Ce);var De=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Oe=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),ke=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ae=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,je=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Me=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Ne=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Pe=/\t{1,1000}/y,Fe=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Ie=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Le=/\p{M}+/gu,Re={limit:1/0,ellipsis:``},ze=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?ze(i,Re,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ie,l],[je,0],[Me,o],[Pe,s],[Fe,c],[Ne,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Le,``)){let t=e.codePointAt(0)||0;if(S=ke(t)?2:Ae(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Ne?Oe(e.slice(p,n.lastIndex)):n===Fe?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Be={limit:1/0,ellipsis:``,ellipsisWidth:0},W=(e,t={})=>ze(e,Be,t).width,Ve=`]8;;`,He=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ve}(?<uri>.*))`,`y`),Ue=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},We=e=>`[${e}m`,Ge=e=>`${Ve}${e}`,Ke=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:W(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=W(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ve,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},qe=e=>{let t=e.split(` `),n=t.length;for(;n&&!W(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Je=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=W(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=W(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Ke(s,r,t),c=W(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Ke(s,r,t),c=W(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Ke(s,r,t),c=W(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>qe(e)));let l=s.join(`
2
2
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){He.lastIndex=e+1;let t=He.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
3
3
  `){a&&(r+=Ge(``));let e=i?Ue(i):void 0;i&&e&&(r+=We(e))}else t===`
4
4
  `&&(i&&Ue(i)&&(r+=We(i)),a&&(r+=Ge(a)))}return r},Ye=/\r?\n/;function Xe(e,t,n){return String(e).normalize().split(Ye).map(e=>Je(e,t,n)).join(`
@@ -12,7 +12,7 @@ import{i as e,o as t,t as n}from"./chunk-FK9Q3tQk.mjs";import{r,t as i}from"./es
12
12
  `).pop()??``;var Qt=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=``){let n=he(Zt(e)),r=n;this.rl.line.length>0&&(r=r.slice(0,-this.rl.line.length)),this.rl.setPrompt(r),this.cursorPos=this.rl.getCursorPos();let i=qt();e=Kt(e,i),t=Kt(t,i),n.length%i===0&&(e+=`
13
13
  `);let a=e+(t?`
14
14
  `+t:``),o=Math.floor(n.length/i)-this.cursorPos.rows+(t?Xt(t):0);o>0&&(a+=pt(o)),a+=ht(this.cursorPos.cols),this.write(mt(this.extraLinesUnderPrompt)+_t(this.height)+a),this.extraLinesUnderPrompt=o,this.height=Xt(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(ht(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=mt(this.extraLinesUnderPrompt);t+=e?_t(this.height):`
15
- `,t+=ft,this.write(t),this.rl.close()}},$t=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}},en=t(Ze(),1);const tn=globalThis.setImmediate;function nn(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function rn(e){let t=nn();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new en.default;s.pipe(r.output??process.stdout);let c=ge.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new Qt(c),{promise:u,resolve:d,reject:f}=$t.withResolver(),p=()=>f(new wt);if(a){let e=()=>f(new Ct({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(ct((e,t)=>{f(new Tt(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Tt(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),At(c,a=>{let m=me.bind(()=>q.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=N.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),q.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?tn(h):h(),Object.assign(u.then(e=>(q.clearAll(),e),e=>{throw q.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var Y=class{separator=H(`dim`,Array.from({length:15}).join(U.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};const an={icon:{checked:H(`green`,U.circleFilled),unchecked:U.circle,cursor:U.pointer,disabledChecked:H(`green`,U.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>H(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>H(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${H(`bold`,e)} ${H(`dim`,t)}`).join(H(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`},keybindings:[]};function on(e){return!Y.isSeparator(e)&&!e.disabled}function sn(e){return!Y.isSeparator(e)}function cn(e){return!Y.isSeparator(e)&&e.checked}function ln(e){return on(e)?{...e,checked:!e.checked}:e}function un(e){return function(t){return on(t)?{...t,checked:e}:t}}function dn(e){return e.map(e=>{if(Y.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var fn=rn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=Bt(an,e.theme),{keybindings:c}=s,[l,u]=J(`idle`),d=Vt({status:l,theme:s}),[f,p]=J(dn(e.choices)),m=Ht(()=>{let e=f.findIndex(sn),t=f.findLastIndex(sn);if(e===-1)throw new Dt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=J(m.first),[_,v]=J();Wt(async e=>{if(St(e)){let e=f.filter(cn),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(vt(e,c)||yt(e,c)){if(_&&v(void 0),r||vt(e,c)&&h!==m.first||yt(e,c)&&h!==m.last){let t=vt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!sn(f[n]));g(n)}}else if(bt(e)){let e=f[h];e&&!Y.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?ln(e):e))))}else if(e.name===o.all){let e=f.some(e=>on(e)&&!e.checked);p(f.map(un(e)))}else if(e.name===o.invert)p(f.map(ln));else if(xt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>Y.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&on(i)&&(g(r),p(f.map((e,t)=>t===r?ln(e):e)))}});let y=s.style.message(e.message,l),b,x=Yt({items:f,active:h,renderItem({item:e,isActive:t}){if(Y.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(cn);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let C=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,C].filter(Boolean).join(`
15
+ `,t+=ft,this.write(t),this.rl.close()}},$t=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}},en=t(Ze(),1);const tn=globalThis.setImmediate;function nn(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function rn(e){let t=nn();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new en.default;s.pipe(r.output??process.stdout);let c=ge.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new Qt(c),{promise:u,resolve:d,reject:f}=$t.withResolver(),p=()=>f(new wt);if(a){let e=()=>f(new Ct({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(ct((e,t)=>{f(new Tt(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new Tt(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),At(c,a=>{let m=me.bind(()=>q.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=ie.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),q.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?tn(h):h(),Object.assign(u.then(e=>(q.clearAll(),e),e=>{throw q.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var Y=class{separator=H(`dim`,Array.from({length:15}).join(U.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};const an={icon:{checked:H(`green`,U.circleFilled),unchecked:U.circle,cursor:U.pointer,disabledChecked:H(`green`,U.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>H(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>H(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${H(`bold`,e)} ${H(`dim`,t)}`).join(H(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`},keybindings:[]};function on(e){return!Y.isSeparator(e)&&!e.disabled}function sn(e){return!Y.isSeparator(e)}function cn(e){return!Y.isSeparator(e)&&e.checked}function ln(e){return on(e)?{...e,checked:!e.checked}:e}function un(e){return function(t){return on(t)?{...t,checked:e}:t}}function dn(e){return e.map(e=>{if(Y.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var fn=rn((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=Bt(an,e.theme),{keybindings:c}=s,[l,u]=J(`idle`),d=Vt({status:l,theme:s}),[f,p]=J(dn(e.choices)),m=Ht(()=>{let e=f.findIndex(sn),t=f.findLastIndex(sn);if(e===-1)throw new Dt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=J(m.first),[_,v]=J();Wt(async e=>{if(St(e)){let e=f.filter(cn),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(vt(e,c)||yt(e,c)){if(_&&v(void 0),r||vt(e,c)&&h!==m.first||yt(e,c)&&h!==m.last){let t=vt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!sn(f[n]));g(n)}}else if(bt(e)){let e=f[h];e&&!Y.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?ln(e):e))))}else if(e.name===o.all){let e=f.some(e=>on(e)&&!e.checked);p(f.map(un(e)))}else if(e.name===o.invert)p(f.map(ln));else if(xt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>Y.isSeparator(e)?!1:(n++,n===t)),i=f[r];i&&on(i)&&(g(r),p(f.map((e,t)=>t===r?ln(e):e)))}});let y=s.style.message(e.message,l),b,x=Yt({items:f,active:h,renderItem({item:e,isActive:t}){if(Y.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(cn);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let C=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,C].filter(Boolean).join(`
16
16
  `).trimEnd()}${dt}`});
17
17
  /*!
18
18
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -262,7 +262,7 @@ let Ln=/^[a-z0-9-_]+$/i;function Rn(e){let t=typeof e;if(t===`object`){if(Array.
262
262
  `)+Gn(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Vn(t[c],e,r,i),a+=`
263
263
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Kn(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Rn(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Gn(0,e,``,t,n);return r[r.length-1]===`
264
264
  `?r:r+`
265
- `}function qn(e,t){let n;try{n=ce(e)}catch(e){if(e.code===`ENOENT`)return;throw e}if(n.isSymbolicLink())throw Error(`Refusing to follow symlink at ${t} (${e}). An untrusted upstream may have committed this symlink to redirect writes outside the project. Remove the symlink and re-run.`)}function Jn(e){return/^[A-Za-z0-9._\-/]+$/.test(e)?e:JSON.stringify(e)}function Yn(e,t){let n=`# yaml-language-server: $schema=https://unpkg.com/@inkeep/open-knowledge@latest/dist/schemas/${w}/config.project.schema.json
265
+ `}function qn(e,t){let n;try{n=le(e)}catch(e){if(e.code===`ENOENT`)return;throw e}if(n.isSymbolicLink())throw Error(`Refusing to follow symlink at ${t} (${e}). An untrusted upstream may have committed this symlink to redirect writes outside the project. Remove the symlink and re-run.`)}function Jn(e){return/^[A-Za-z0-9._\-/]+$/.test(e)?e:JSON.stringify(e)}function Yn(e,t){let n=`# yaml-language-server: $schema=https://unpkg.com/@inkeep/open-knowledge@latest/dist/schemas/${d}/config.project.schema.json
266
266
  # Open Knowledge — project configuration
267
267
  #
268
268
  # This file overrides built-in defaults for this project. Every key below
@@ -368,15 +368,15 @@ let Ln=/^[a-z0-9-_]+$/i;function Rn(e){let t=typeof e;if(t===`object`){if(Array.
368
368
  # description: Canonical knowledge committed after a team decision. Produced by the \`consolidate\` tool with a \`supersedes:\` chain tying back to the research that preceded it.
369
369
  # tags: [article, canonical, layer-consolidate]
370
370
  `,r=t?.contentDir;return r===void 0||r===`.`?n:n.replace(`# content:
371
- # dir: .`,`content:\n dir: ${Jn(r)}`)}function Xn(e,t,n){return qn(e,n),z(e)?!1:(fe(e,t,`utf-8`),!0)}function Zn(e,t){if(qn(e,`.ok/.gitignore`),!z(e))return fe(e,t,`utf-8`),`created`;let n=t.split(`
372
- `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)),r=ue(e,`utf-8`),i=new Set(r.split(`
371
+ # dir: .`,`content:\n dir: ${Jn(r)}`)}function Xn(e,t,n){return qn(e,n),R(e)?!1:(fe(e,t,`utf-8`),!0)}function Zn(e,t){if(qn(e,`.ok/.gitignore`),!R(e))return fe(e,t,`utf-8`),`created`;let n=t.split(`
372
+ `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)),r=z(e,`utf-8`),i=new Set(r.split(`
373
373
  `).map(e=>e.trim())),a=n.filter(e=>!i.has(e));return a.length===0?`unchanged`:(fe(e,`${r}${r.length===0||r.endsWith(`
374
374
  `)?``:`
375
375
  `}${a.join(`
376
376
  `)}\n`,`utf-8`),`updated`)}const Qn=`# .ok/local/ holds per-machine runtime state. Anything inside is
377
377
  # machine-local and never committed. New runtime files (caches, locks,
378
378
  # manifests, telemetry, error logs) are auto-ignored — no edit needed here.
379
- ${l}/
379
+ ${o}/
380
380
 
381
381
  # Per-machine runtime state at the .ok/ root. Contains PII (principal email,
382
382
  # UUID), hostnames, and absolute filesystem paths — never commit. The only
@@ -388,7 +388,7 @@ server.lock
388
388
  ui.lock
389
389
  sync-state.json
390
390
  last-spawn-error.log
391
- `;function $n(e,t){let n=R(e,`.ok`),r=[],i=[],a=[];qn(n,`.ok/`),le(n,{recursive:!0});let o=Zn(I(n,`.gitignore`),Qn);return o===`created`?r.push(`.gitignore`):o===`updated`?i.push(`.gitignore`):a.push(`.gitignore`),Xn(I(n,`config.yml`),Yn(ee,{contentDir:t?.contentDir}),`.ok/config.yml`)?r.push(T):a.push(T),Xn(I(e,`.okignore`),`# .okignore — paths to exclude from the Open Knowledge document index.
391
+ `;function $n(e,t){let n=L(e,`.ok`),r=[],i=[],a=[];qn(n,`.ok/`),ue(n,{recursive:!0});let o=Zn(F(n,`.gitignore`),Qn);return o===`created`?r.push(`.gitignore`):o===`updated`?i.push(`.gitignore`):a.push(`.gitignore`),Xn(F(n,`config.yml`),Yn(ee,{contentDir:t?.contentDir}),`.ok/config.yml`)?r.push(T):a.push(T),Xn(F(e,`.okignore`),`# .okignore — paths to exclude from the Open Knowledge document index.
392
392
  # Uses gitignore syntax (parsed by the \`ignore\` npm library), evaluated
393
393
  # alongside .gitignore in a single ignore-lib instance.
394
394
  #
@@ -400,10 +400,10 @@ last-spawn-error.log
400
400
  # drafts/ # exclude a directory
401
401
  # *.draft.md # exclude files matching a pattern
402
402
  # !keep.md # re-include a file .gitignore excluded
403
- `,`.okignore`)?r.push(`.okignore`):a.push(`.okignore`),{created:r,updated:i,skipped:a}}function er(e,t){let n=L(t,e);return n.length>0&&!n.startsWith(`..`)&&!ie(n)}const tr=e=>{try{let t=re(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function nr(e,t={}){let n=t.homeDir??V(),r=t.gitTopLevel??tr,i=R(e),a;try{a=de(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(m(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=F(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&er(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}const rr=C,ir=S,ar=[`-y`,`@inkeep/open-knowledge@latest`,`mcp`],or={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function sr(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=R(e);if(P(t)===`cli.mjs`&&P(F(t))===`dist`)return t;let n=t.split(oe),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 I(i.length===0?oe:i.join(oe),`packages`,`cli`,`dist`,`cli.mjs`)}function cr(e={}){return e.mode===`dev`?{command:`node`,args:[sr(),`mcp`],env:{...or}}:{command:`npx`,args:[...ar]}}function lr(e){return e===`win32`?se:ae}function ur(e={}){let t=e.platformName??process.platform,n=e.home??V();return lr(t).join(n,`.claude.json`)}function dr(e={}){let t=e.platformName??process.platform,n=e.home??V(),r=e.env??process.env;if(t===`darwin`)return ae.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??se.join(n,`AppData`,`Roaming`);return se.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function fr(e={}){let t=e.platformName??process.platform,n=e.home??V();return lr(t).join(n,`.cursor`,`mcp.json`)}function pr(e={}){let t=e.platformName??process.platform,n=e.home??V();return(e.env??process.env).CODEX_HOME??lr(t).join(n,`.codex`)}function mr(e={}){return lr(e.platformName??process.platform).join(pr(e),`config.toml`)}function hr(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>hr(e,t[n]));if(E(e)&&E(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>hr(e[n],t[n]))}return!1}function gr(e,t){return Object.entries(t).every(([t,n])=>hr(e[t],n))}function _r(e,t){return{...e,...t}}function vr(e){return{...e,isCompatible(t,n,r){return gr(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return _r(t,e.buildEntry(n,r))}}}const Q={claude:vr({id:`claude`,label:ir.claude,configPath:(e,t)=>ur({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>I(t??V(),`.claude`),projectConfigPath:e=>I(e,`.mcp.json`),projectSkillPath:e=>I(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)}),"claude-desktop":vr({id:`claude-desktop`,label:ir[`claude-desktop`],configPath:(e,t)=>dr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>F(dr({home:t}))}),cursor:vr({id:`cursor`,label:ir.cursor,configPath:(e,t)=>fr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>F(fr({home:t})),projectConfigPath:e=>I(e,`.cursor`,`mcp.json`),projectSkillPath:e=>I(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)}),codex:vr({id:`codex`,label:ir.codex,configPath:(e,t)=>mr({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>F(mr({home:t})),projectConfigPath:e=>I(e,`.codex`,`config.toml`),projectSkillPath:e=>I(e,`.agents`,`skills`,`open-knowledge`,`SKILL.md`)})};function yr(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${rr.join(`, `)}`);return e.map(e=>Q[e])}function $(e,t,n,r,i){let a=`urn:uuid:${_e()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=p.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const br=1e4;function xr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!y(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!d(e.headers.host))return $(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!g(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const Sr=3e4;function Cr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!y(n)||!d(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!g(r)?(t.destroy(),!0):!1}function wr(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=be({host:r,port:i,timeout:br});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
404
- `)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Tr=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Er(e){let t=e.upstreamTimeoutMs??br,n=new Set,r=ve((n,r)=>{xr(n,r)||Or(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Cr(t,r)||wr(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function Dr(e,t,n){Or(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??br)}function Or(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Tr)delete a[e];e.setTimeout(Sr,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${Sr/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=ye({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Tr)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const kr=39847,Ar=39848;async function jr(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Mr(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,createAssetServeMiddleware:a,createContentFilter:o,readServerLock:s,releaseUiLock:c,updateUiLockPort:l}=await import(`./dist-B1bXj22d.mjs`),{default:u}=await import(`./build-GAD37AZK.mjs`),{resolveContentDir:d,resolveLockDir:p}=await import(`./dist-B1bXj22d.mjs`),m=d(e.config,e.cwd),g=p(e.cwd);i(g,{port:0,worktreeRoot:e.cwd});let _=import.meta.dirname??new URL(`.`,import.meta.url).pathname,y=[r(_,`public`),r(_,`../../app/dist`),r(_,`../../../app/dist`)].find(e=>t(e)),x=y?u(y,{single:!0,gzip:!0,immutable:!0,extensions:[]}):null,S=t(m)?a({contentFilter:o({projectDir:e.cwd,contentDir:m}),contentSirv:u(m,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:v,assetExtensions:b,blocklistExtensions:f}):null,C=e.port,w=null,ee=(e,t)=>{let n=e.url?.split(`?`)[0];if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&xr(e,t))){if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){w?.();let n=s(g),r=e.headers.host??`localhost:${C}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=JSON.stringify({collabUrl:i,previewUrl:null,port:C});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(a);return}if(n?.startsWith(`/api/`)){w?.();let r=s(g);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}Dr(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(x&&n?.startsWith(`/assets/`)){x(e,t,()=>{S?S(e,t,()=>Nr(t,n)):Nr(t,n)});return}if(S){S(e,t,()=>{x?x(e,t):Nr(t,n)});return}if(x){x(e,t);return}Nr(t,n)}},T=new Set,E=(e,t,n)=>{if(Cr(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=s(g);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}wr(e,t,n,`localhost`,i.port,T)},D=()=>{for(let e of T)try{e.destroy()}catch{}T.clear()},O=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],k=[],A=e.port,j=e=>e instanceof Error&&e.code===`EADDRINUSE`,te=async()=>{await Promise.all(k.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},ne=async e=>{A=e;for(let e of O){let t=n(ee);t.on(`upgrade`,E),k.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(A,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(A=e.port),n()})})}};try{try{await ne(e.port)}catch(t){if(e.fallbackToKernel===!0&&j(t))await te(),await ne(0);else throw t}}catch(e){await te();try{c(g)}catch{}throw e}let M=A;C=M,l(g,M);let re=e.scheduler??h,N=e.safetyNetMs??432e5,P=null,F=!1,ie=!1,I=()=>{F||(F=!0,P!==null&&(re.clearTimeout(P),P=null))},ae=()=>{if(I(),!ie){ie=!0;try{c(g)}catch{}}},L=()=>{F||N<=0||(P!==null&&(re.clearTimeout(P),P=null),P=re.setTimeout(()=>{P=null,console.warn(`[ui] safety-net (${N}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}D();for(let e of k)try{e.close()}catch{}ae()},N))},R=()=>{F||N<=0||L()};return w=R,L(),{httpServers:k,port:M,release:ae,detachSafetyNet:I,nudgeSafetyNet:R,drainUpgradeSockets:D}}function Nr(e,t){$(e,404,`urn:ok:error:not-found`,`Resource not found.`,t===void 0?void 0:`Path: ${t}`)}function Pr(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:kr,fallbackToKernel:!0}}async function Fr(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-B1bXj22d.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Er({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Ir(e){return new i(`ui`).description(`Serve the Open Knowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${kr}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-Dl3c2q5r.mjs`),{UiLockCollisionError:r}=await import(`./dist-B1bXj22d.mjs`),{resolveLockDir:i}=await import(`./dist-B1bXj22d.mjs`),a=e(),o=t.host,s;try{s=Pr(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await Mr({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),jr(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Fr({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Lr(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Lr(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Rr(e){if(!z(e))return{};let t=ue(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(E(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function zr(e){if(!z(e))return{};let t=ue(e,`utf-8`).trim();if(t===``)return{};try{let n=In(t);if(E(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Br(e,t){o(e,`${JSON.stringify(t,null,2)}\n`)}function Vr(e,t){let n=Kn(t);o(e,n.endsWith(`
403
+ `,`.okignore`)?r.push(`.okignore`):a.push(`.okignore`),{created:r,updated:i,skipped:a}}function er(e,t){let n=I(t,e);return n.length>0&&!n.startsWith(`..`)&&!ae(n)}const tr=e=>{try{let t=re(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function nr(e,t={}){let n=t.homeDir??V(),r=t.gitTopLevel??tr,i=L(e),a;try{a=de(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(y(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=P(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&er(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}const rr=f,ir=h,ar=[`-y`,`@inkeep/open-knowledge@latest`,`mcp`],or={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function sr(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=L(e);if(N(t)===`cli.mjs`&&N(P(t))===`dist`)return t;let n=t.split(se),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?se:i.join(se),`packages`,`cli`,`dist`,`cli.mjs`)}function cr(e={}){return e.mode===`dev`?{command:`node`,args:[sr(),`mcp`],env:{...or}}:{command:`npx`,args:[...ar]}}function lr(e){return e===`win32`?ce:oe}function ur(e={}){let t=e.platformName??process.platform,n=e.home??V();return lr(t).join(n,`.claude.json`)}function dr(e={}){let t=e.platformName??process.platform,n=e.home??V(),r=e.env??process.env;if(t===`darwin`)return oe.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??ce.join(n,`AppData`,`Roaming`);return ce.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function fr(e={}){let t=e.platformName??process.platform,n=e.home??V();return lr(t).join(n,`.cursor`,`mcp.json`)}function pr(e={}){let t=e.platformName??process.platform,n=e.home??V();return(e.env??process.env).CODEX_HOME??lr(t).join(n,`.codex`)}function mr(e={}){return lr(e.platformName??process.platform).join(pr(e),`config.toml`)}function hr(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>hr(e,t[n]));if(E(e)&&E(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>hr(e[n],t[n]))}return!1}function gr(e,t){return Object.entries(t).every(([t,n])=>hr(e[t],n))}function _r(e,t){return{...e,...t}}function vr(e){return{...e,isCompatible(t,n,r){return gr(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return _r(t,e.buildEntry(n,r))}}}const Q={claude:vr({id:`claude`,label:ir.claude,configPath:(e,t)=>ur({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>F(t??V(),`.claude`),projectConfigPath:e=>F(e,`.mcp.json`),projectSkillPath:e=>F(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)}),"claude-desktop":vr({id:`claude-desktop`,label:ir[`claude-desktop`],configPath:(e,t)=>dr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>P(dr({home:t}))}),cursor:vr({id:`cursor`,label:ir.cursor,configPath:(e,t)=>fr({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>P(fr({home:t})),projectConfigPath:e=>F(e,`.cursor`,`mcp.json`),projectSkillPath:e=>F(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)}),codex:vr({id:`codex`,label:ir.codex,configPath:(e,t)=>mr({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>a,buildEntry:(e,t)=>cr(t),scope:`global`,detectPath:(e,t)=>P(mr({home:t})),projectConfigPath:e=>F(e,`.codex`,`config.toml`),projectSkillPath:e=>F(e,`.agents`,`skills`,`open-knowledge`,`SKILL.md`)})};function yr(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${rr.join(`, `)}`);return e.map(e=>Q[e])}function $(e,t,n,r,i){let a=`urn:uuid:${_e()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=v.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const br=1e4;function xr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!_(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!m(e.headers.host))return $(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!C(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const Sr=3e4;function Cr(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!_(n)||!m(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!C(r)?(t.destroy(),!0):!1}function wr(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=be({host:r,port:i,timeout:br});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
404
+ `)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Tr=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Er(e){let t=e.upstreamTimeoutMs??br,n=new Set,r=ve((n,r)=>{xr(n,r)||Or(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Cr(t,r)||wr(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function Dr(e,t,n){Or(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??br)}function Or(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Tr)delete a[e];e.setTimeout(Sr,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${Sr/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=ye({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Tr)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const kr=39847,Ar=39848;async function jr(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Mr(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,createAssetServeMiddleware:a,createContentFilter:o,readServerLock:s,releaseUiLock:c,updateUiLockPort:l}=await import(`./dist-LiBfDl2k.mjs`),{default:u}=await import(`./build-GAD37AZK.mjs`),{resolveContentDir:d,resolveLockDir:f}=await import(`./dist-LiBfDl2k.mjs`),m=d(e.config,e.cwd),h=f(e.cwd);i(h,{port:0,worktreeRoot:e.cwd});let _=import.meta.dirname??new URL(`.`,import.meta.url).pathname,v=[r(_,`public`),r(_,`../../app/dist`),r(_,`../../../app/dist`)].find(e=>t(e)),y=v?u(v,{single:!0,gzip:!0,immutable:!0,extensions:[]}):null,x=t(m)?a({contentFilter:o({projectDir:e.cwd,contentDir:m}),contentSirv:u(m,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:S,assetExtensions:b,blocklistExtensions:g}):null,C=e.port,w=null,ee=(e,t)=>{let n=e.url?.split(`?`)[0];if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&xr(e,t))){if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){w?.();let n=s(h),r=e.headers.host??`localhost:${C}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=JSON.stringify({collabUrl:i,previewUrl:null,port:C});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(a);return}if(n?.startsWith(`/api/`)){w?.();let r=s(h);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}Dr(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(y&&n?.startsWith(`/assets/`)){y(e,t,()=>{x?x(e,t,()=>Nr(t,n)):Nr(t,n)});return}if(x){x(e,t,()=>{y?y(e,t):Nr(t,n)});return}if(y){y(e,t);return}Nr(t,n)}},T=new Set,E=(e,t,n)=>{if(Cr(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=s(h);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}wr(e,t,n,`localhost`,i.port,T)},D=()=>{for(let e of T)try{e.destroy()}catch{}T.clear()},O=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],k=[],A=e.port,j=e=>e instanceof Error&&e.code===`EADDRINUSE`,te=async()=>{await Promise.all(k.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},ne=async e=>{A=e;for(let e of O){let t=n(ee);t.on(`upgrade`,E),k.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(A,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(A=e.port),n()})})}};try{try{await ne(e.port)}catch(t){if(e.fallbackToKernel===!0&&j(t))await te(),await ne(0);else throw t}}catch(e){await te();try{c(h)}catch{}throw e}let M=A;C=M,l(h,M);let re=e.scheduler??p,ie=e.safetyNetMs??432e5,N=null,P=!1,ae=!1,F=()=>{P||(P=!0,N!==null&&(re.clearTimeout(N),N=null))},oe=()=>{if(F(),!ae){ae=!0;try{c(h)}catch{}}},I=()=>{P||ie<=0||(N!==null&&(re.clearTimeout(N),N=null),N=re.setTimeout(()=>{N=null,console.warn(`[ui] safety-net (${ie}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}D();for(let e of k)try{e.close()}catch{}oe()},ie))},L=()=>{P||ie<=0||I()};return w=L,I(),{httpServers:k,port:M,release:oe,detachSafetyNet:F,nudgeSafetyNet:L,drainUpgradeSockets:D}}function Nr(e,t){$(e,404,`urn:ok:error:not-found`,`Resource not found.`,t===void 0?void 0:`Path: ${t}`)}function Pr(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:kr,fallbackToKernel:!0}}async function Fr(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-LiBfDl2k.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Er({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Ir(e){return new i(`ui`).description(`Serve the Open Knowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${kr}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-Dl3c2q5r.mjs`),{UiLockCollisionError:r}=await import(`./dist-LiBfDl2k.mjs`),{resolveLockDir:i}=await import(`./dist-LiBfDl2k.mjs`),a=e(),o=t.host,s;try{s=Pr(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await Mr({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),jr(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Fr({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Lr(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Lr(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Rr(e){if(!R(e))return{};let t=z(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(E(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function zr(e){if(!R(e))return{};let t=z(e,`utf-8`).trim();if(t===``)return{};try{let n=In(t);if(E(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Br(e,t){u(e,`${JSON.stringify(t,null,2)}\n`)}function Vr(e,t){let n=Kn(t);u(e,n.endsWith(`
405
405
  `)?n:`${n}\n`)}const Hr=e=>e!==`project`,Ur=e=>e!==`user`;async function Wr(){let e=await fn({message:`Where should the MCP server be configured?
406
- `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Gr(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Wr)():`both`}const Kr=`0.0.1`,qr=`open-knowledge-ui`,Jr=[`-y`,`@inkeep/open-knowledge@latest`,`ui`];function Yr(e,t={}){let n=I(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:qr,runtimeExecutable:`node`,runtimeArgs:[sr(),`ui`],port:Ar,autoPort:!0}:{name:qr,runtimeExecutable:`npx`,runtimeArgs:[...Jr],port:Ar,autoPort:!0};try{if(M(n,e),!z(n))return le(F(n),{recursive:!0}),fe(n,`${JSON.stringify({version:Kr,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=ue(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!E(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>E(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??Kr,configurations:a};return fe(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Xr(e,t,n){try{return z(e.detectPath?.(t,n)??F(e.configPath(t,n)))}catch{return!1}}function Zr(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Xr(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{M(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{le(F(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let c,l;try{u(`${o}.lock`,()=>{let t=e.format===`toml`?zr(o):Rr(o),n=t[e.topLevelKey]??{};c=n[a];let r={...t,[e.topLevelKey]:{...n,[a]:s}};e.format===`toml`?Vr(o,r):Br(o,r)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){l=e instanceof Error?e:Error(String(e))}return l?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:l.message,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Qr(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!z(n)))return{editorId:e.id,label:e.label,path:n}}async function $r(e){let t=yr(e.editors),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Zr(t,``,n,e.home))}function ei(e,t,n,r){let i=ti(e,t,n,r);return i.kind===`present`?i.entry:null}function ti(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!z(i))return{kind:`absent`};let a;try{a=ue(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?zr(i):Rr(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!E(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return E(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function ni(e={}){let t=R(e.cwd??process.cwd()),n=nr(t,{homeDir:e.home}),r=n.projectRoot,i=!z(I(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${L(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await c(r),s;try{s=$n(r,{contentDir:n.defaultContentDir})}catch(t){let n=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`}}let l=await Gr({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??ii(r,e.home),d=e.editors??rr.filter(e=>Q[e].projectConfigPath!==void 0),f=yr(u),p=yr(d),m=e.mcp===!1||l===null,h=Array.from(new Map([...f,...m?[]:p].map(e=>[e.id,e])).values()),g=f.filter(t=>Xr(t,r,e.home)),v=[],y=[],b=new Set;for(let t of h){if(m){let n=``;try{n=t.configPath(r,e.home)}catch{}v.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Hr(l)&&f.includes(t)&&v.push(Zr(t,r,a,e.home)),Ur(l)&&p.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Zr(t,r,a,e.home,n);v.push(i),(i.action===`written`||i.action===`overwritten`)&&b.add(n)}}for(let e of p)e.projectSkillPath&&y.push(ne(e,r));let S=!m&&l!==null&&Ur(l)?p.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,C=m?[]:g.map(e=>Qr(e,r)).filter(e=>e!==void 0).filter(e=>!b.has(e.path)),w=g.some(e=>e.id===`claude`)&&!m?Yr(r,a):void 0,ee=await(e.installUserSkill??x)({home:e.home}),T=_({home:e.home}),E=m?`skipped-flag`:`skipped-missing`,D=v.find(e=>e.editorId===`claude`)??v[0]??{action:E,configPath:Q.claude.configPath(r,e.home)};return{projectRoot:r,contentCreated:s.created,contentUpdated:s.updated,contentSkipped:s.skipped,editors:v,projectSkills:y,legacyProjectConfigs:C,launchJson:w,skillInstall:ee,didGitInit:o.didInit,claudeDesktopDetected:T,mcpAction:D.action,mcpPath:D.configPath,mcpError:`error`in D?D.error:void 0,projectScopeUnsupportedLabels:S}}function ri(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?L(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let c=I(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(j(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(j(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(j(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(j(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(j(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?L(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${O(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${O(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${k(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(j(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?L(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${k(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${L(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(j(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${O(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`failed`:n.push(` ${A(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${A(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${j(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(te(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${j(`Next steps:`)}`),n.push(` 1. Open your editor (${D(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${D(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${D(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${D(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${D(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${D(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
407
- `)}function ii(e,t){let n=[];for(let r of rr)Xr(Q[r],e,t)&&n.push(r);return n}function ai(){return new i(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).action(async e=>{let t=process.cwd(),n;try{n=await ni({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope})}catch(e){if(e instanceof s){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
408
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-C6Lu126-.mjs`),{loadConfig:t}=await import(`./loader-CHO2rfjC.mjs`),{resolveContentDir:r}=await import(`./dist-B1bXj22d.mjs`),{config:i}=t(n.projectRoot),a=r(i,n.projectRoot);n.preview=e({projectDir:n.projectRoot,contentDir:a})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${ri(n,n.projectRoot)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{U as A,ht as C,Ze as D,ct as E,Xe as O,ft as S,_t as T,ar as _,ri as a,mt as b,Gr as c,Zr as d,$r as f,Q as g,ir as h,ii as i,De as k,ni as l,rr as m,Jr as n,ai as o,Ir as p,ti as r,ei as s,qr as t,Yr as u,nr as v,pt as w,dt as x,$n as y};
409
- //# sourceMappingURL=init-CJL4wRMl.mjs.map
406
+ `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Gr(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Wr)():`both`}const Kr=`0.0.1`,qr=`open-knowledge-ui`,Jr=[`-y`,`@inkeep/open-knowledge@latest`,`ui`];function Yr(e,t={}){let n=F(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:qr,runtimeExecutable:`node`,runtimeArgs:[sr(),`ui`],port:Ar,autoPort:!0}:{name:qr,runtimeExecutable:`npx`,runtimeArgs:[...Jr],port:Ar,autoPort:!0};try{if(M(n,e),!R(n))return ue(P(n),{recursive:!0}),fe(n,`${JSON.stringify({version:Kr,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=z(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!E(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>E(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??Kr,configurations:a};return fe(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Xr(e,t,n){try{return R(e.detectPath?.(t,n)??P(e.configPath(t,n)))}catch{return!1}}function Zr(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Xr(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{M(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{ue(P(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let c,l;try{w(`${o}.lock`,()=>{let t=e.format===`toml`?zr(o):Rr(o),n=t[e.topLevelKey]??{};c=n[a];let r={...t,[e.topLevelKey]:{...n,[a]:s}};e.format===`toml`?Vr(o,r):Br(o,r)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){l=e instanceof Error?e:Error(String(e))}return l?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:l.message,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function Qr(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function $r(e){let t=yr(e.editors),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Zr(t,``,n,e.home))}function ei(e,t,n,r){let i=ti(e,t,n,r);return i.kind===`present`?i.entry:null}function ti(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?zr(i):Rr(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!E(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return E(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function ni(e={}){let t=L(e.cwd??process.cwd()),n=nr(t,{homeDir:e.home}),r=n.projectRoot,i=!R(F(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${I(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await l(r),c;try{c=$n(r,{contentDir:n.defaultContentDir})}catch(t){let n=Q.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`}}let u=await Gr({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),d=e.editors??ii(r,e.home),f=e.editors??rr.filter(e=>Q[e].projectConfigPath!==void 0),p=yr(d),m=yr(f),h=e.mcp===!1||u===null,g=Array.from(new Map([...p,...h?[]:m].map(e=>[e.id,e])).values()),_=p.filter(t=>Xr(t,r,e.home)),v=[],y=[],b=new Set;for(let t of g){if(h){let n=``;try{n=t.configPath(r,e.home)}catch{}v.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Hr(u)&&p.includes(t)&&v.push(Zr(t,r,a,e.home)),Ur(u)&&m.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Zr(t,r,a,e.home,n);v.push(i),(i.action===`written`||i.action===`overwritten`)&&b.add(n)}}for(let e of m)e.projectSkillPath&&y.push(ne(e,r));let S=!h&&u!==null&&Ur(u)?m.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,C=h?[]:_.map(e=>Qr(e,r)).filter(e=>e!==void 0).filter(e=>!b.has(e.path)),w=_.some(e=>e.id===`claude`)&&!h?Yr(r,a):void 0,ee=await(e.installUserSkill??x)({home:e.home}),T=s({home:e.home}),E=h?`skipped-flag`:`skipped-missing`,D=v.find(e=>e.editorId===`claude`)??v[0]??{action:E,configPath:Q.claude.configPath(r,e.home)};return{projectRoot:r,contentCreated:c.created,contentUpdated:c.updated,contentSkipped:c.skipped,editors:v,projectSkills:y,legacyProjectConfigs:C,launchJson:w,skillInstall:ee,didGitInit:o.didInit,claudeDesktopDetected:T,mcpAction:D.action,mcpPath:D.configPath,mcpError:`error`in D?D.error:void 0,projectScopeUnsupportedLabels:S}}function ri(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?I(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`);let c=F(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(j(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(j(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(j(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(j(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(j(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?I(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${O(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${O(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${k(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(j(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?I(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${k(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${I(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(j(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${O(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${O(`already installed at current version`)}`);break;case`failed`:n.push(` ${A(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${A(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${j(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(te(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${j(`Next steps:`)}`),n.push(` 1. Open your editor (${D(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${D(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${D(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${D(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${D(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${D(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
407
+ `)}function ii(e,t){let n=[];for(let r of rr)Xr(Q[r],e,t)&&n.push(r);return n}function ai(){return new i(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).action(async e=>{let t=process.cwd(),n;try{n=await ni({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope})}catch(e){if(e instanceof c){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
408
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-DnjgfpXJ.mjs`),{loadConfig:t}=await import(`./loader-Bd8DLr1D.mjs`),{resolveContentDir:r}=await import(`./dist-LiBfDl2k.mjs`),{config:i}=t(n.projectRoot),a=r(i,n.projectRoot);n.preview=e({projectDir:n.projectRoot,contentDir:a})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${ri(n,n.projectRoot)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{U as A,ht as C,Ze as D,ct as E,Xe as O,ft as S,_t as T,ar as _,ri as a,mt as b,Gr as c,Zr as d,$r as f,Q as g,ir as h,ii as i,De as k,ni as l,rr as m,Jr as n,ai as o,Ir as p,ti as r,ei as s,qr as t,Yr as u,nr as v,pt as w,dt as x,$n as y};
409
+ //# sourceMappingURL=init-CL8mchva.mjs.map
@@ -0,0 +1 @@
1
+ import{l as e}from"./init-CL8mchva.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import"./chunk-R6VWJ2ZL-DSqbA7Rj.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import{t as e}from"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-DQP-O5US.mjs";import{r}from"./chunk-OJDRYQWQ-D4lSWh0K.mjs";import{n as i,t as a}from"./chunk-3THT3N7L-DrzOuTpA.mjs";import{t as o}from"./chunk-44UOCSGV-BbZqjKvt.mjs";import{t as s}from"./chunk-74CEPOFO-D1bzz49u.mjs";import{n as c,t as l}from"./chunk-I57KEIP3-C9JW7Nfp.mjs";import{fileURLToPath as u}from"node:url";import{AsyncLocalStorage as d}from"node:async_hooks";import{Worker as f}from"node:worker_threads";import{randomBytes as p}from"node:crypto";var m=1e4,h=6e4,g=new d,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
1
+ import"./chunk-R6VWJ2ZL-DSqbA7Rj.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import{t as e}from"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-DQP-O5US.mjs";import{r}from"./chunk-OJDRYQWQ-D4lSWh0K.mjs";import{n as i,t as a}from"./chunk-3THT3N7L-DrzOuTpA.mjs";import{t as o}from"./chunk-44UOCSGV-BbZqjKvt.mjs";import{t as s}from"./chunk-74CEPOFO-D1bzz49u.mjs";import{n as c,t as l}from"./chunk-I57KEIP3-C9JW7Nfp.mjs";import{fileURLToPath as u}from"node:url";import{AsyncLocalStorage as d}from"node:async_hooks";import{randomBytes as f}from"node:crypto";import{Worker as p}from"node:worker_threads";var m=1e4,h=6e4,g=new d,_=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
2
2
 
3
3
  Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
4
4
 
@@ -85,8 +85,8 @@ Limits:
85
85
  Engine: QuickJS (compiled to WebAssembly)
86
86
  `;function v(e){let t={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e[n];if(r===`-m`||r===`--module`){t.isModule=!0;continue}if(r===`--strip-types`){t.stripTypes=!0;continue}if(r===`-c`)return n+1>=e.length?{stdout:``,stderr:`js-exec: option requires an argument -- 'c'
87
87
  `,exitCode:2}:(t.code=e[n+1],t.scriptArgs=e.slice(n+2),t);if(r===`--version`||r===`-V`)return t.showVersion=!0,t;if(r.startsWith(`-`)&&r!==`-`&&r!==`--`)return{stdout:``,stderr:`js-exec: unrecognized option '${r}'
88
- `,exitCode:2};if(r===`--`)return n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)),t;if(!r.startsWith(`-`))return t.scriptFile=r,t.scriptArgs=e.slice(n+1),t}return t}var y=null,b=null,x=[],S=null,C=u(new URL(`./worker.js`,import.meta.url));function w(){for(;x.length>0&&x[0].canceled;)x.shift();if(S||x.length===0)return;let e=x.shift();e&&(S=e,E().postMessage(S.input))}function T(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function E(){if(b&&=(t(b),null),y)return y;let n=e.runTrusted(()=>new f(C));return y=n,n.on(`message`,e=>{if(y===n){if(S){let t=T(e,S.input.protocolToken);S.resolve(t),S=null}x.length>0?w():D()}}),n.on(`error`,e=>{if(y===n){if(S){let t=a(o(e));S.resolve({success:!1,error:t}),S=null}for(let e of x)e.resolve({success:!1,error:`Worker crashed`});x.length=0,y=null}}),n.on(`exit`,()=>{y===n&&(y=null,S&&=(S.resolve({success:!1,error:`Worker exited unexpectedly`}),null),x.length>0&&w())}),n}function D(){b=n(()=>{y&&!S&&x.length===0&&(y.terminate(),y=null)},5e3)}async function O(e,t,n,r=[],i,a,o){return g.getStore()?{stdout:``,stderr:`js-exec: recursive invocation is not supported
89
- `,exitCode:1}:k(e,t,n,r,i,a,o)}async function k(e,i,s,u=[],d,f,_){let v=c(),b=i.exec,C=b?(e,t)=>g.run(!0,()=>b(e,t)):void 0,T=new l(v,i.fs,i.cwd,`js-exec`,i.fetch,i.limits?.maxOutputSize??0,C),E=i.limits?.maxJsTimeoutMs??m,D=i.fetch?Math.max(E,h):E,O={protocolToken:p(16).toString(`hex`),sharedBuffer:v,jsCode:e,cwd:i.cwd,env:r(i.env),args:u,scriptPath:s,bootstrapCode:d,isModule:f,stripTypes:_,timeoutMs:D},k,A=new Promise(e=>{k=e}),j={input:O,resolve:()=>{}},M=n(()=>{if(S===j){let e=y;e&&(y=null,e.terminate()),S=null,w()}else j.canceled=!0,S||w();j.resolve({success:!1,error:`Execution timeout: exceeded ${D}ms limit`})},D);j.resolve=e=>{t(M),k(e)},x.push(j),w();let[N,P]=await Promise.all([T.run(D),A.catch(e=>({success:!1,error:a(o(e))}))]);return!P.success&&P.error?{stdout:N.stdout,stderr:`${N.stderr}js-exec: ${a(P.error)}
88
+ `,exitCode:2};if(r===`--`)return n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)),t;if(!r.startsWith(`-`))return t.scriptFile=r,t.scriptArgs=e.slice(n+1),t}return t}var y=null,b=null,x=[],S=null,C=u(new URL(`./worker.js`,import.meta.url));function w(){for(;x.length>0&&x[0].canceled;)x.shift();if(S||x.length===0)return;let e=x.shift();e&&(S=e,E().postMessage(S.input))}function T(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function E(){if(b&&=(t(b),null),y)return y;let n=e.runTrusted(()=>new p(C));return y=n,n.on(`message`,e=>{if(y===n){if(S){let t=T(e,S.input.protocolToken);S.resolve(t),S=null}x.length>0?w():D()}}),n.on(`error`,e=>{if(y===n){if(S){let t=a(o(e));S.resolve({success:!1,error:t}),S=null}for(let e of x)e.resolve({success:!1,error:`Worker crashed`});x.length=0,y=null}}),n.on(`exit`,()=>{y===n&&(y=null,S&&=(S.resolve({success:!1,error:`Worker exited unexpectedly`}),null),x.length>0&&w())}),n}function D(){b=n(()=>{y&&!S&&x.length===0&&(y.terminate(),y=null)},5e3)}async function O(e,t,n,r=[],i,a,o){return g.getStore()?{stdout:``,stderr:`js-exec: recursive invocation is not supported
89
+ `,exitCode:1}:k(e,t,n,r,i,a,o)}async function k(e,i,s,u=[],d,p,_){let v=c(),b=i.exec,C=b?(e,t)=>g.run(!0,()=>b(e,t)):void 0,T=new l(v,i.fs,i.cwd,`js-exec`,i.fetch,i.limits?.maxOutputSize??0,C),E=i.limits?.maxJsTimeoutMs??m,D=i.fetch?Math.max(E,h):E,O={protocolToken:f(16).toString(`hex`),sharedBuffer:v,jsCode:e,cwd:i.cwd,env:r(i.env),args:u,scriptPath:s,bootstrapCode:d,isModule:p,stripTypes:_,timeoutMs:D},k,A=new Promise(e=>{k=e}),j={input:O,resolve:()=>{}},M=n(()=>{if(S===j){let e=y;e&&(y=null,e.terminate()),S=null,w()}else j.canceled=!0,S||w();j.resolve({success:!1,error:`Execution timeout: exceeded ${D}ms limit`})},D);j.resolve=e=>{t(M),k(e)},x.push(j),w();let[N,P]=await Promise.all([T.run(D),A.catch(e=>({success:!1,error:a(o(e))}))]);return!P.success&&P.error?{stdout:N.stdout,stderr:`${N.stderr}js-exec: ${a(P.error)}
90
90
  `,exitCode:N.exitCode||1}:N}var A={name:`js-exec`,async execute(e,t){if(s(e))return{stdout:_,stderr:``,exitCode:0};let n=v(e);if(`exitCode`in n)return n;if(n.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
91
91
  `,stderr:``,exitCode:0};let r,a;if(n.code!==null)r=n.code,a=`-c`;else if(n.scriptFile!==null){let e=t.fs.resolvePath(t.cwd,n.scriptFile);if(!await t.fs.exists(e))return{stdout:``,stderr:`js-exec: can't open file '${n.scriptFile}': No such file or directory
92
92
  `,exitCode:2};try{r=await t.fs.readFile(e),a=e}catch(e){return{stdout:``,stderr:`js-exec: can't open file '${n.scriptFile}': ${i(e.message)}
@@ -94,4 +94,4 @@ Limits:
94
94
  `,exitCode:2};let o=n.isModule,c=n.stripTypes;a&&a!==`-c`&&a!==`<stdin>`&&((a.endsWith(`.mjs`)||a.endsWith(`.mts`)||a.endsWith(`.ts`))&&(o=!0),(a.endsWith(`.ts`)||a.endsWith(`.mts`))&&(c=!0)),!o&&/\bawait\s+[\w([`]/.test(r)&&(o=!0);let l=t.jsBootstrapCode;return O(r,t,a,n.scriptArgs,l,o,c)}},j={name:`node`,async execute(){return{stdout:``,stderr:`node: this sandbox uses js-exec instead of node
95
95
 
96
96
  ${_}`,exitCode:1}}};export{A as jsExecCommand,j as nodeStubCommand};
97
- //# sourceMappingURL=js-exec-M6UR76J5-BssUQ3SC.mjs.map
97
+ //# sourceMappingURL=js-exec-M6UR76J5-D6BVeQcA.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CD9Cf-je.mjs";export{e as loadConfig};
@@ -1,4 +1,4 @@
1
- import{Li as e,Xr as t,Yr as n,_i as r,f as i,wi as a}from"./dist-lSCD8oz8.mjs";import{t as o}from"./constants-C3I7xExN.mjs";import{t as s}from"./is-object-BXWpSxBI.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{realpath as d}from"node:fs/promises";async function f(e){let t=c(e);try{return await d(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var p=e();function m(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];s(a)&&s(i)?n[r]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,p.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return s(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let t=e.value;if(!s(t))return[];let n=t.content;if(!s(n))return[];let r=[];for(let t of g)if(t in n){let n=[`content`,t],i;e.doc!==null&&e.source!==null&&(i=a({file:e.path,source:e.source,doc:e.doc,path:n})),r.push({code:`REMOVED_KEY`,path:n,redirect:_(t),...i===void 0?{}:{source:i}})}return r}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=a({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(e){let a=e??process.cwd(),s=[],l=t(`user`,a),u=n({absPath:l}),d={};u.valid&&u.source!==void 0?(d=m(d,u.value),s.push(l)):u.valid;let f=c(a,`.ok`,o),p=h(f);if(p.value!==null){let e=v(p);if(e.length>0)throw Error(e.map(r).join(`
1
+ import{$r as e,Oi as t,Vi as n,ei as r,f as i,xi as a}from"./dist-D4zoOvWC.mjs";import{t as o}from"./constants-Bdd0BBBE.mjs";import{t as s}from"./is-object-BXWpSxBI.mjs";import{resolve as c}from"node:path";import{existsSync as l,readFileSync as u}from"node:fs";import{realpath as d}from"node:fs/promises";async function f(e){let t=c(e);try{return await d(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var p=n();function m(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];s(a)&&s(i)?n[r]=m(i,a):a!==void 0&&(n[r]=a)}return n}function h(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,p.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return s(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}const g=[`include`,`exclude`];function _(e){let t="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.";return e===`exclude`?[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,t].join(` `):[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,t].join(` `)}function v(e){let n=e.value;if(!s(n))return[];let r=n.content;if(!s(r))return[];let i=[];for(let n of g)if(n in r){let r=[`content`,n],a;e.doc!==null&&e.source!==null&&(a=t({file:e.path,source:e.source,doc:e.doc,path:r})),i.push({code:`REMOVED_KEY`,path:r,redirect:_(n),...a===void 0?{}:{source:a}})}return i}function y(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(t){let n=t??process.cwd(),s=[],l=r(`user`,n),u=e({absPath:l}),d={};u.valid&&u.source!==void 0?(d=m(d,u.value),s.push(l)):u.valid;let f=c(n,`.ok`,o),p=h(f);if(p.value!==null){let e=v(p);if(e.length>0)throw Error(e.map(a).join(`
2
2
 
3
- `));d=m(d,p.value),s.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]),x(d,[`preview`,`baseUrl`],"preview URLs now resolve only to the running UI process — start one with `ok ui`");let g=i.safeParse(d);if(!g.success){let e={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(r(e))}return{config:g.data,sources:s}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!s(r))return;r=r[t[e]]}if(!s(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,S as t};
4
- //# sourceMappingURL=loader-2O0Sr-YE.mjs.map
3
+ `));d=m(d,p.value),s.push(f)}x(d,[`upload`,`maxBytes`],`streaming uploads have no user-facing cap`),x(d,[`github`,`oauthAppClientId`],`use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID env var instead`),x(d,[`server`,`host`],`use the --host flag or HOST env var instead`),x(d,[`server`,`openOnAgentEdit`]),x(d,[`mcp`,`autoStart`],`to disable auto-start, set OK_MCP_AUTOSTART=0`),x(d,[`mcp`,`tools`,`read_document`,`historyDepth`]),x(d,[`mcp`,`tools`,`grep`,`maxResults`]),x(d,[`mcp`,`tools`,`search`,`maxResults`]),x(d,[`preview`,`baseUrl`],"preview URLs now resolve only to the running UI process — start one with `ok ui`");let g=i.safeParse(d);if(!g.success){let e={code:`SCHEMA_INVALID`,issues:y(g.error.issues,p)};throw Error(a(e))}return{config:g.data,sources:s}}function x(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){if(!s(r))return;r=r[t[e]]}if(!s(r))return;let i=t[t.length-1];if(r[i]===void 0)return;let a=t.join(`.`);console.warn(`[config] ${a} is no longer user-configurable; ${n??`the value is hardcoded in @inkeep/open-knowledge-core`}. Remove the key to silence this warning.`)}function S(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=f(e.startupCwd);return async o=>{let s=await f(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,S as t};
4
+ //# sourceMappingURL=loader-CD9Cf-je.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-DvYf3kcu.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
1
- import{bt as e}from"./dist-lSCD8oz8.mjs";import"./constants-C3I7xExN.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{bt as e}from"./dist-D4zoOvWC.mjs";import"./constants-Bdd0BBBE.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
3
- //# sourceMappingURL=preview-DyHTxXSv.mjs.map
3
+ //# sourceMappingURL=preview-DvYf3kcu.mjs.map
@@ -1,7 +1,7 @@
1
- import"./chunk-R6VWJ2ZL-DSqbA7Rj.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import{t as e}from"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-DQP-O5US.mjs";import{r}from"./chunk-OJDRYQWQ-D4lSWh0K.mjs";import{n as i}from"./chunk-24IMIIXA-_PX4ITYZ.mjs";import{n as a,t as o}from"./chunk-3THT3N7L-DrzOuTpA.mjs";import{t as s}from"./chunk-44UOCSGV-BbZqjKvt.mjs";import{r as c,t as l}from"./chunk-74CEPOFO-D1bzz49u.mjs";import{n as u,t as d}from"./chunk-I57KEIP3-C9JW7Nfp.mjs";import{fileURLToPath as f}from"node:url";import{Worker as p}from"node:worker_threads";import{randomBytes as m}from"node:crypto";var h=1e4,g=6e4,_={name:`python3`,summary:`Execute Python code via CPython Emscripten`,usage:`python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]`,description:[`Execute Python code using CPython compiled to WebAssembly via Emscripten.`,``,`This command runs Python in an isolated environment with access to`,`the virtual filesystem. Standard library modules are available.`],options:[`-c CODE Execute CODE as Python script`,`-m MODULE Run library module as a script`,`--version Show Python version`,`--help Show this help`],examples:[`python3 -c "print(1 + 2)"`,`python3 -c "import sys; print(sys.version)"`,`python3 script.py`,`python3 script.py arg1 arg2`,`echo 'print("hello")' | python3`],notes:[`CPython runs in WebAssembly, so execution may be slower than native Python.`,`Standard library modules are available (no pip install).`,`Maximum execution time is 30 seconds by default.`]};function v(e){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(e.length===0)return t;let n=e.findIndex(e=>!e.startsWith(`-`)||e===`-`||e===`--`);for(let r=0;r<(n===-1?e.length:n);r++){let n=e[r];if(n===`-c`)return r+1>=e.length?{stdout:``,stderr:`python3: option requires an argument -- 'c'
1
+ import"./chunk-R6VWJ2ZL-DSqbA7Rj.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";import"./chunk-DXB73IDG-DfmyzFzL.mjs";import{t as e}from"./chunk-5QMZ5MUS-SLhNX8t9.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-DQP-O5US.mjs";import{r}from"./chunk-OJDRYQWQ-D4lSWh0K.mjs";import{n as i}from"./chunk-24IMIIXA-_PX4ITYZ.mjs";import{n as a,t as o}from"./chunk-3THT3N7L-DrzOuTpA.mjs";import{t as s}from"./chunk-44UOCSGV-BbZqjKvt.mjs";import{r as c,t as l}from"./chunk-74CEPOFO-D1bzz49u.mjs";import{n as u,t as d}from"./chunk-I57KEIP3-C9JW7Nfp.mjs";import{fileURLToPath as f}from"node:url";import{randomBytes as p}from"node:crypto";import{Worker as m}from"node:worker_threads";var h=1e4,g=6e4,_={name:`python3`,summary:`Execute Python code via CPython Emscripten`,usage:`python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]`,description:[`Execute Python code using CPython compiled to WebAssembly via Emscripten.`,``,`This command runs Python in an isolated environment with access to`,`the virtual filesystem. Standard library modules are available.`],options:[`-c CODE Execute CODE as Python script`,`-m MODULE Run library module as a script`,`--version Show Python version`,`--help Show this help`],examples:[`python3 -c "print(1 + 2)"`,`python3 -c "import sys; print(sys.version)"`,`python3 script.py`,`python3 script.py arg1 arg2`,`echo 'print("hello")' | python3`],notes:[`CPython runs in WebAssembly, so execution may be slower than native Python.`,`Standard library modules are available (no pip install).`,`Maximum execution time is 30 seconds by default.`]};function v(e){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(e.length===0)return t;let n=e.findIndex(e=>!e.startsWith(`-`)||e===`-`||e===`--`);for(let r=0;r<(n===-1?e.length:n);r++){let n=e[r];if(n===`-c`)return r+1>=e.length?{stdout:``,stderr:`python3: option requires an argument -- 'c'
2
2
  `,exitCode:2}:(t.code=e[r+1],t.scriptArgs=e.slice(r+2),t);if(n===`-m`)return r+1>=e.length?{stdout:``,stderr:`python3: option requires an argument -- 'm'
3
3
  `,exitCode:2}:(t.module=e[r+1],t.scriptArgs=e.slice(r+2),t);if(n===`--version`||n===`-V`)return t.showVersion=!0,t;if(n.startsWith(`-`)&&n!==`-`)return{stdout:``,stderr:`python3: unrecognized option '${n}'
4
- `,exitCode:2}}if(n!==-1){let r=e[n];r===`--`?n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)):(t.scriptFile=r,t.scriptArgs=e.slice(n+1))}return t}var y=new WeakMap;function b(e){let t=y.get(e);return t||(t={executionQueue:[],isExecuting:!1},y.set(e,t)),t}var x=f(new URL(`./worker.js`,import.meta.url));function S(){return m(16).toString(`hex`)}function C(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:n.type===`security-violation`?{success:!1,error:`Security violation: ${typeof n.violation?.type==`string`?n.violation.type:`unknown`}`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function w(t){if(t.isExecuting||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0].canceled;)t.executionQueue.shift();if(t.executionQueue.length===0)return;let n=t.executionQueue.shift();if(!n)return;t.isExecuting=!0;let r;try{r=e.runTrusted(()=>new p(x,{workerData:n.input}))}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t);return}n.workerRef&&(n.workerRef.current=r);let a=i(n.requireDefenseContext,`python3`,`worker message callback`,e=>{n.resolve(C(e,n.input.protocolToken)),t.isExecuting=!1,r.terminate(),w(t)}),c=i(n.requireDefenseContext,`python3`,`worker error callback`,e=>{let r=o(s(e));n.resolve({success:!1,error:r}),t.isExecuting=!1,w(t)}),l=i(n.requireDefenseContext,`python3`,`worker exit callback`,()=>{t.isExecuting&&(n.resolve({success:!1,error:`Worker exited unexpectedly`}),t.isExecuting=!1,w(t))});r.on(`message`,e=>{try{a(e)}catch(e){let i=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(i)}),t.isExecuting=!1,r.terminate(),w(t)}}),r.on(`error`,e=>{try{c(e)}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}}),r.on(`exit`,()=>{try{l()}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}})}async function T(e,a,c,l=[]){let f=u(),p=new d(f,a.fs,a.cwd,`python3`,a.fetch,a.limits?.maxOutputSize??0),m=a.limits?.maxPythonTimeoutMs??h,_=a.fetch?Math.max(m,g):m,v=b(a.fs),y={protocolToken:S(),sharedBuffer:f,pythonCode:e,cwd:a.cwd,env:r(a.env),args:l,scriptPath:c,timeoutMs:_},x={current:null},C=new Promise(e=>{let r={input:y,resolve:()=>{},workerRef:x,requireDefenseContext:a.requireDefenseContext},s=i(a.requireDefenseContext,`python3`,`worker timeout callback`,()=>{x.current?x.current.terminate():r.canceled=!0,e({success:!1,error:`Execution timeout: exceeded ${_}ms limit`})}),c=n(()=>{try{s()}catch(t){e({success:!1,error:o(t instanceof Error?t.message:String(t))})}},_);r.resolve=n=>{t(c),e(n)},v.executionQueue.push(r),w(v)}),[T,E]=await Promise.all([p.run(_).catch(e=>({stdout:``,stderr:`python3: bridge error: ${o(s(e))}
4
+ `,exitCode:2}}if(n!==-1){let r=e[n];r===`--`?n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)):(t.scriptFile=r,t.scriptArgs=e.slice(n+1))}return t}var y=new WeakMap;function b(e){let t=y.get(e);return t||(t={executionQueue:[],isExecuting:!1},y.set(e,t)),t}var x=f(new URL(`./worker.js`,import.meta.url));function S(){return p(16).toString(`hex`)}function C(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:n.type===`security-violation`?{success:!1,error:`Security violation: ${typeof n.violation?.type==`string`?n.violation.type:`unknown`}`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function w(t){if(t.isExecuting||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0].canceled;)t.executionQueue.shift();if(t.executionQueue.length===0)return;let n=t.executionQueue.shift();if(!n)return;t.isExecuting=!0;let r;try{r=e.runTrusted(()=>new m(x,{workerData:n.input}))}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t);return}n.workerRef&&(n.workerRef.current=r);let a=i(n.requireDefenseContext,`python3`,`worker message callback`,e=>{n.resolve(C(e,n.input.protocolToken)),t.isExecuting=!1,r.terminate(),w(t)}),c=i(n.requireDefenseContext,`python3`,`worker error callback`,e=>{let r=o(s(e));n.resolve({success:!1,error:r}),t.isExecuting=!1,w(t)}),l=i(n.requireDefenseContext,`python3`,`worker exit callback`,()=>{t.isExecuting&&(n.resolve({success:!1,error:`Worker exited unexpectedly`}),t.isExecuting=!1,w(t))});r.on(`message`,e=>{try{a(e)}catch(e){let i=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(i)}),t.isExecuting=!1,r.terminate(),w(t)}}),r.on(`error`,e=>{try{c(e)}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}}),r.on(`exit`,()=>{try{l()}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}})}async function T(e,a,c,l=[]){let f=u(),p=new d(f,a.fs,a.cwd,`python3`,a.fetch,a.limits?.maxOutputSize??0),m=a.limits?.maxPythonTimeoutMs??h,_=a.fetch?Math.max(m,g):m,v=b(a.fs),y={protocolToken:S(),sharedBuffer:f,pythonCode:e,cwd:a.cwd,env:r(a.env),args:l,scriptPath:c,timeoutMs:_},x={current:null},C=new Promise(e=>{let r={input:y,resolve:()=>{},workerRef:x,requireDefenseContext:a.requireDefenseContext},s=i(a.requireDefenseContext,`python3`,`worker timeout callback`,()=>{x.current?x.current.terminate():r.canceled=!0,e({success:!1,error:`Execution timeout: exceeded ${_}ms limit`})}),c=n(()=>{try{s()}catch(t){e({success:!1,error:o(t instanceof Error?t.message:String(t))})}},_);r.resolve=n=>{t(c),e(n)},v.executionQueue.push(r),w(v)}),[T,E]=await Promise.all([p.run(_).catch(e=>({stdout:``,stderr:`python3: bridge error: ${o(s(e))}
5
5
  `,exitCode:1})),C.catch(e=>({success:!1,error:o(s(e))}))]);if(!E.success&&E.error){let e=o(E.error);return{stdout:T.stdout,stderr:`${T.stderr}python3: ${e}
6
6
  `,exitCode:T.exitCode||1}}return T}var E={name:`python3`,async execute(e,t){if(l(e))return c(_);let n=v(e);if(`exitCode`in n)return n;if(n.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
7
7
  `,stderr:``,exitCode:0};let r,i;if(n.code!==null)r=n.code,i=`-c`;else if(n.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(n.module))return{stdout:``,stderr:`python3: No module named '${n.module.slice(0,200)}'
@@ -9,4 +9,4 @@ import"./chunk-R6VWJ2ZL-DSqbA7Rj.mjs";import"./chunk-CWQS3NFK-BQ5SUtd7.mjs";impo
9
9
  `,exitCode:2};try{r=await t.fs.readFile(e),i=n.scriptFile}catch(e){let t=a(e.message);return{stdout:``,stderr:`python3: can't open file '${n.scriptFile}': ${t}
10
10
  `,exitCode:2}}}else if(t.stdin.trim())r=t.stdin,i=`<stdin>`;else return{stdout:``,stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
11
11
  `,exitCode:2};return T(r,t,i,n.scriptArgs)}},D={name:`python`,async execute(e,t){return E.execute(e,t)}};export{E as python3Command,D as pythonCommand};
12
- //# sourceMappingURL=python3-AUFTPCU6-BSuL_Nsg.mjs.map
12
+ //# sourceMappingURL=python3-AUFTPCU6-CcfVkAVy.mjs.map
@@ -1,2 +1,2 @@
1
- import{n as e,u as t}from"./init-CJL4wRMl.mjs";import{t as n}from"./is-object-BXWpSxBI.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`]];function s(t){if(t.runtimeExecutable!==`npx`||!Array.isArray(t.runtimeArgs))return`preserved`;if(c(t.runtimeArgs,e))return`canonical`;for(let e of o)if(c(t.runtimeArgs,e))return`legacy-bare`;return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(e){let o=e.logger??u,c=r(e.projectDir,`.claude`,`launch.json`);if(e.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=t(e.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-1v32GZcd.mjs.map
1
+ import{n as e,u as t}from"./init-CL8mchva.mjs";import{t as n}from"./is-object-BXWpSxBI.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`]];function s(t){if(t.runtimeExecutable!==`npx`||!Array.isArray(t.runtimeArgs))return`preserved`;if(c(t.runtimeArgs,e))return`canonical`;for(let e of o)if(c(t.runtimeArgs,e))return`legacy-bare`;return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(e){let o=e.logger??u,c=r(e.projectDir,`.claude`,`launch.json`);if(e.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=t(e.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-Dhq_x0b3.mjs.map
@@ -1,2 +1,2 @@
1
- import{_ as e,d as t,g as n,m as r,s as i}from"./init-CJL4wRMl.mjs";import{homedir as a}from"node:os";function o(t){return t.command===`npx`&&Array.isArray(t.args)&&s(t.args,e)?`canonical`:`needs-rewrite`}function s(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function c(e){let t=e.logger??f,i=e.home??a(),o=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:o,repairedCount:0};for(let a of r){let r=n[a],s=l(()=>r.configPath(``,i));if(s!==null&&o.push(u({scope:`user`,editorId:a,target:r,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),r.projectConfigPath){let n=r.projectConfigPath,i=l(()=>n(e.projectDir));i!==null&&o.push(u({scope:`project`,editorId:a,target:r,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:o,repairedCount:o.filter(e=>e.outcome===`repaired`).length}}function l(e){try{return e()}catch{return null}}function u(e){let n={scope:e.scope,editorId:e.editorId,configPath:e.configPath},r=i(e.target,e.cwd,e.home,e.configPathOverride);if(r===null)return{...n,outcome:`no-entry`};if(o(r)===`canonical`)return{...n,outcome:`canonical`};let a=d(r),s=t(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let t=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:t}),{...n,outcome:`write-failed`,error:t}}return e.logger({event:`mcp-config-reclaim`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,priorCommand:a.priorCommand,priorArgs:a.priorArgs}),{...n,outcome:`repaired`}}function d(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function f(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{c as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-CZXWhNQh.mjs.map
1
+ import{_ as e,d as t,g as n,m as r,s as i}from"./init-CL8mchva.mjs";import{homedir as a}from"node:os";function o(t){return t.command===`npx`&&Array.isArray(t.args)&&s(t.args,e)?`canonical`:`needs-rewrite`}function s(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function c(e){let t=e.logger??f,i=e.home??a(),o=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:o,repairedCount:0};for(let a of r){let r=n[a],s=l(()=>r.configPath(``,i));if(s!==null&&o.push(u({scope:`user`,editorId:a,target:r,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),r.projectConfigPath){let n=r.projectConfigPath,i=l(()=>n(e.projectDir));i!==null&&o.push(u({scope:`project`,editorId:a,target:r,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:o,repairedCount:o.filter(e=>e.outcome===`repaired`).length}}function l(e){try{return e()}catch{return null}}function u(e){let n={scope:e.scope,editorId:e.editorId,configPath:e.configPath},r=i(e.target,e.cwd,e.home,e.configPathOverride);if(r===null)return{...n,outcome:`no-entry`};if(o(r)===`canonical`)return{...n,outcome:`canonical`};let a=d(r),s=t(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let t=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:t}),{...n,outcome:`write-failed`,error:t}}return e.logger({event:`mcp-config-reclaim`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,priorCommand:a.priorCommand,priorArgs:a.priorArgs}),{...n,outcome:`repaired`}}function d(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function f(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{c as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-DOuR37tP.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-B9jE33Ah.mjs";export{e as repairSkills};