@inkeep/open-knowledge 0.25.0-beta.15 → 0.25.0-beta.16

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 (32) 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/cli.mjs +6 -6
  4. package/dist/constants-DLfnk8-s.mjs +2 -0
  5. package/dist/{dist-BNI6AO8O.mjs → dist-B923c31q.mjs} +5 -5
  6. package/dist/{dist-s-76L6SV.mjs → dist-C1MZNyof.mjs} +1 -1
  7. package/dist/{gh-detect-B3B56f-Q.mjs → gh-detect-C_0kt1kp.mjs} +2 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-DqGkmmfN.mjs +1 -0
  10. package/dist/{init-CeV6DYvh.mjs → init-ICH9ja53.mjs} +4 -4
  11. package/dist/{loader-CRiGx4e0.mjs → loader-Dv5atXyy.mjs} +2 -2
  12. package/dist/loader-SibEgXZ1.mjs +1 -0
  13. package/dist/preview-BIIOpGNN.mjs +1 -0
  14. package/dist/{preview-IaeY2esx.mjs → preview-CQG9jtTU.mjs} +2 -2
  15. package/dist/{repair-launch-json-CS6C6O3X.mjs → repair-launch-json-BmK9QMNQ.mjs} +2 -2
  16. package/dist/{repair-mcp-configs-D-iMOSEE.mjs → repair-mcp-configs-BDNpoQWE.mjs} +2 -2
  17. package/dist/{repair-skills-D5s7VIc5.mjs → repair-skills-Bu_8HPr_.mjs} +2 -2
  18. package/dist/repair-skills-DHq977uN.mjs +1 -0
  19. package/dist/server-lock-LsXsWtim-DBIg_FmA.mjs +1 -0
  20. package/dist/{server-lock-ltHt39S2-CPmTXbVG.mjs → server-lock-ltHt39S2-BMGVBKsW.mjs} +6 -6
  21. package/dist/{src-CZBXfnwD.mjs → src-DnmgOJh8.mjs} +2 -2
  22. package/dist/start-CC5yeIBq.mjs +1 -0
  23. package/dist/{start-DnS2be8Y.mjs → start-S_2D11FR.mjs} +2 -2
  24. package/dist/{write-project-skill-DUum3kyh.mjs → write-project-skill-C02OzQla.mjs} +2 -2
  25. package/package.json +1 -1
  26. package/dist/constants-CS2nL68U.mjs +0 -2
  27. package/dist/init-BliN3ZD6.mjs +0 -1
  28. package/dist/loader-MCBnhFm_.mjs +0 -1
  29. package/dist/preview-0VpHVzuK.mjs +0 -1
  30. package/dist/repair-skills-BUsNTNSG.mjs +0 -1
  31. package/dist/server-lock-LsXsWtim-lsqjSV5C.mjs +0 -1
  32. package/dist/start-IDoCSATt.mjs +0 -1
@@ -1 +1 @@
1
- import{An as e,Ii as t,J as n,Tn as r,Vt as i,a,ai as o,c as s,d as c,f as l,fn as u,g as d,h as f,i as p,ki as m,l as h,m as g,n as _,o as v,on as y,p as b,r as x,s as S,t as C,tn as w,u as T}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";import{$ as E,$i as D,$n as O,$r as k,$t as A,A as j,Ai as M,An as N,Ar as P,At as F,B as I,Bi as L,Bn as R,Br as z,Bt as B,C as V,Ci as H,Cn as U,Cr as W,Ct as G,D as K,Di as q,Dn as J,Dr as Y,Dt as X,E as Z,Ei as Q,En as $,Er as ee,Et as te,F as ne,Fi as re,Fn as ie,Fr as ae,Ft as oe,G as se,Gi as ce,Gn as le,Gr as ue,Gt as de,H as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ii as ve,In as ye,Ir as be,It as xe,J as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ki as Oe,Kn as ke,Kr as Ae,Kt as je,L as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Mi as Re,Mn as ze,Mr as Be,Mt as Ve,N as He,Ni as Ue,Nn as We,Nr as Ge,Nt as Ke,O as qe,Oi as Je,On as Ye,Or as Xe,Ot as Ze,P as Qe,Pi as $e,Pn as et,Pr as tt,Pt as nt,Q as rt,Qi as it,Qn as at,Qr as ot,Qt as st,R as ct,Ri as lt,Rn as ut,Rr as dt,Rt as ft,S as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Ti as yt,Tn as bt,Tr as xt,Tt as St,U as Ct,Ui as wt,Un as Tt,Ur as Et,Ut as Dt,V as Ot,Vi as kt,Vn as At,Vr as jt,Vt as Mt,W as Nt,Wi as Pt,Wn as Ft,Wr as It,Wt as Lt,X as Rt,Xi as zt,Xn as Bt,Xr as Vt,Xt as Ht,Y as Ut,Yi as Wt,Yn as Gt,Yr as Kt,Yt as qt,Z as Jt,Zi as Yt,Zn as Xt,Zr as Zt,Zt as Qt,_ as $t,_a as en,_i as tn,_n as nn,_r as rn,_t as an,a as on,aa as sn,ai as cn,an as ln,ar as un,at as dn,b as fn,bi as pn,bn as mn,br as hn,bt as gn,c as _n,ci as vn,cn as yn,cr as bn,ct as xn,d as Sn,di as Cn,dn as wn,dr as Tn,dt as En,ea as Dn,ei as On,en as kn,er as An,et as jn,f as Mn,fi as Nn,fn as Pn,fr as Fn,ft as In,g as Ln,gi as Rn,gn as zn,gr as Bn,gt as Vn,h as Hn,hi as Un,hn as Wn,hr as Gn,ht as Kn,i as qn,ia as Jn,ii as Yn,in as Xn,ir as Zn,it as Qn,j as $n,ji as er,jn as tr,jr as nr,jt as rr,k as ir,ki as ar,kn as or,kr as sr,kt as cr,l as lr,li as ur,ln as dr,lr as fr,lt as pr,m as mr,mi as hr,mn as gr,mr as _r,mt as vr,n as yr,na as br,ni as xr,nn as Sr,nr as Cr,nt as wr,o as Tr,oi as Er,on as Dr,or as Or,ot as kr,p as Ar,pi as jr,pn as Mr,pr as Nr,pt as Pr,q as Fr,qi as Ir,qn as Lr,qr as Rr,qt as zr,r as Br,ra as Vr,ri as Hr,rn as Ur,rr as Wr,rt as Gr,s as Kr,si as qr,sn as Jr,sr as Yr,st as Xr,t as Zr,ta as Qr,ti as $r,tn as ei,tr as ti,tt as ni,u as ri,ui as ii,un as ai,ur as oi,ut as si,v as ci,va as li,vi as ui,vn as di,vr as fi,vt as pi,w as mi,wi as hi,wn as gi,wr as _i,wt as vi,x as yi,xi as bi,xn as xi,xr as Si,xt as Ci,y as wi,yi as Ti,yn as Ei,yr as Di,yt as Oi,z as ki,zi as Ai,zn as ji,zr as Mi,zt as Ni}from"./dist-BNI6AO8O.mjs";export{Zr as AGENT_ID_MAX_LEN,yr as AGENT_ID_RE,Br as AGENT_WRITE_ORIGIN,qn as AgentFocusBroadcaster,on as AgentPresenceBroadcaster,Tr as AgentSessionCapacityError,Kr as AgentSessionManager,_n as AutoStartDisabledError,lr as BUNDLE_IDS,ri as BUNDLE_SCOPE,Sn as BUNDLE_SKILL_NAME,Mn as BacklinkIndex,Ar as CC1Broadcaster,n as CC1_CONTRACT_VERSION,mr as CONFIG_FILENAME,Hn as CONFLICT_MARKER_RE,Ln as CURSOR_BUNDLE_PATHS_BY_PLATFORM,$t as ConfigSchema,ci as DEFAULT_CHECKPOINT_RETENTION,wi as DEFAULT_EMBEDDINGS_DIMENSIONS,fn as DEFAULT_PACK_ID,yi as EMBEDDINGS_API_KEY_ENV,pt as FILE_SYSTEM_WRITER,V as FILE_WATCHER_ORIGIN,mi as FileEmbeddingsBackend,vt as GIT_PREFLIGHT_FAIL_SPAN_NAME,Z as GIT_UPSTREAM_WRITER,en as GitDirAccessError,K as GitNotAvailableError,qe as GitTooOldError,ir as HOCUSPOCUS_AUTH_REJECTION_REASONS,j as HocuspocusAuthRejection,$n as HocuspocusAuthTokenSchema,Le as INSTALLED_AGENTS_SCHEMES,i as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Qe as LOG_MD_TEMPLATE,ne as MANAGED_RENAME_ORIGIN,_e as MAX_AGENT_SESSIONS,Me as MCP_CONNECTION_ID_HEADER,w as MCP_SERVER_NAME,ct as MIN_GIT_VERSION,ki as MISSING_OK_CONFIG_MESSAGE,li as MalformedGitPointerError,I as McpLogger,Ot as MissingOkConfigError,fe as OBSERVER_SYNC_ORIGIN,Ct as OK_OKIGNORE_TEMPLATE,y as ORPHAN_MODES,Nt as PANE_TARGET_TTL_MS,u as PROTOCOL_VERSION,se as PinoLogger,C as ProcessLockCollisionError,De as ProjectGitInitError,Fr as ROLLBACK_ORIGIN,Se as ROOT_GITIGNORE_TEMPLATE,_ as RUNTIME_VERSION,Ut as SERVICE_WRITER,Rt as SKILL_INSTALL_EVENTS_FILE_REL,r as SKILL_STATE_TARGETS,Jt as STARTER_FOLDERS,rt as STARTER_FOLDER_FRONTMATTER_FILENAME,E as STARTER_PACKS,jn as STARTER_PACK_IDS,ni as STARTER_TEMPLATES,wr as STATE_MANIFEST_FILENAME,x as STATE_SCHEMA_VERSION,e as SYSTEM_DOC_NAME,Gr as SeedPrerequisiteError,Qn as SeedRootDirError,p as ServerLockCollisionError,dn as SingleFileNotAFileError,kr as SingleFileNotFoundError,Xr as SingleFileNotMarkdownError,xn as StateManifestError,pr as TagIndex,si as USER_GLOBAL_BUNDLE_IDS,En as UiLockCollisionError,In as __getShowAllWalkStatsForTesting,Pr as __resetShowAllWalkStatsForTesting,a as acquireProcessLock,v as acquireServerLock,vr as acquireUiLock,Kn as applyAgentMarkdownWrite,Vn as applyExternalChange,an as applySeed,pi as armPaneTarget,Oi as assertCompatibleStateManifest,gn as assertGitAvailable,Ci as assertNeverDiskEvent,_t as attachIdleShutdown,G as bootServer,vi as buildAndOpenSkill,St as buildConfigYmlContent,te as buildExecResult,X as buildSkillZip,Ze as buildStarterFolderFrontmatterYaml,cr as buildWipTree,F as bundleSkillMdPath,rr as classifyEvents,Ve as classifyFsPath,Ke as clearArmedPaneTarget,nt as clearContributors,oe as clearEmbeddingsKeyFromAllBackends,xe as coercePackId,o as colorFromSeed,Ie as commitUpstreamImport,ft as commitWip,Ni as commitWipFromTree,B as compareSemver,Mt as containsConflictMarkers,ge as contentHash,Dt as contributorCount,Lt as countShadowObjects,de as countStaleAgentWipRefs,je as countWipRefs,zr as createApiExtension,Ee as createAssetServeMiddleware,qt as createContentFilter,Ht as createContentFilterAsync,Qt as createEmbeddingsSecretStore,st as createEphemeralProjectDir,A as createExternalChangeHandler,kn as createFileLogger,ei as createLiveDerivedIndexExtension,Sr as createMcpHttpHandler,Ur as createOsProbe,Xn as createPersistenceExtension,ln as createServer,Dr as createServerObserverExtension,Jr as createStreamingErrorWriter,yn as createTestLogger,dr as describeStoredEmbeddingsKey,ai as detectClaudeDesktopPresence,wn as detectGit,Pn as detectProjectShape,Mr as discoverLockDirs,gr as emitPreflightFailureSpan,Wn as encodeDocName,zn as encodeFolderRoute,nn as encodeSkillRoute,di as ensureProjectGit,Ei as errorResponse,mn as evictStaleTrackerEntries,xi as extractOkBinaryPath,ht as extractWikiLinksFromMarkdown,U as fallbackPaths,gi as findEnclosingGitRoot,bt as findEnclosingProjectRoot,$ as flushFileLogger,J as formatAuthRejectionWire,Ye as formatContributors,or as formatContributorsFrom,N as formatPackRationale,tr as gcCheckpointRefs,ze as getCurrentMcpLogger,We as getLocalDir,et as getLogFilePath,ie as getLogger,ye as getLogsDir,Pe as getMeter,ut as getMetrics,ji as getTracer,R as handleCollabSocketError,At as handleSpawnCursor,me as hasGcLogLatch,m as iconFromClientName,Tt as incrementCollabSocketFilteredError,Ft as incrementServerObserverFire,le as initContent,ke as initShadowRepo,Lr as initTelemetry,we as initToleranceTelemetryWriter,Gt as installPrettyZodErrors,Bt as installTestLoggers,Xt as installUserSkill,at as isAllowedApiOrigin,O as isAllowedWorkspaceHostHeader,An as isConfigDoc,ti as isHocuspocusAuthRejectionReason,Cr as isKnownPackId,Wr as isLinkIndexExcludedDoc,Zn as isLoopbackAddress,un as isManagedArtifactDoc,t as isOrphanMode,Or as isPairedWriteOrigin,Yr as isPathWithinDir,S as isProcessAlive,bn as isProjectRoot,fr as isProjectSkillManaged,oi as isReservedForUserTree,Tn as isSelfWrite,Fn as isSystemDoc,Nr as isToleranceTelemetryEnabled,s as isValidLockPid,_r as lastKnownHash,Gn as listRescueCheckpoints,Bn as listStarterPacks,rn as loadPrincipal,h as lockFilePath,fi as loggerFactory,Di as logsCurrentPath,hn as logsPreviousPath,Si as makeLazyEmbeddingsKeyStore,gt as mountMcpAndApi,W as normalizeFsPath,_i as packageVersionMajorMinor,xt as parseAuthRejectionWire,ee as parseGitVersion,Y as parseHocuspocusAuthToken,Xe as parseKeepaliveConnectionId,sr as pathToDocName,P as planSeed,nr as prepareSingleFileOpen,Be as processCommand,Ge as processUsage,tt as readAllTargets,ae as readArmedPaneTarget,be as readBranchFromHead,T as readProcessLock,c as readProcessLockDetailed,Fe as readProjectLocalSemanticConfig,l as readServerLock,dt as readServerPackageVersion,Mi as readSkillInstallStateSnapshot,z as readSkillManagement,jt as readStateManifest,he as readTargetRecordedAt,Et as readTargetVersion,It as readUiLock,ue as reconcile,Ae as recordContributor,Rr as recordSkillInstallEvent,Te as registerAllTools,Kt as registerWrite,b as releaseProcessLock,g as releaseServerLock,Vt as releaseUiLock,Zt as removeLastKnownHash,ot as resetMetrics,k as resolveBundledSkillDir,On as resolveContentDir,$r as resolveCursorBinaryDefault,xr as resolveCursorSpawnInvocation,Hr as resolveLockDir,Yn as resolvePack,cn as resolvePackageVersion,Er as resolveUiInfo,qr as restoreContributors,vn as restoreLifecycleFromConflictsJson,ur as rewriteMarkdownLinksForDocumentRename,ii as rewriteWikiLinksForDocumentRename,Cn as runAuthReposSubprocess,Nn as runAuthStatusSubprocess,jr as runCloneSubprocess,hr as runDeviceFlowSubprocess,Un as runWithMcpLogger,Rn as safeContentPath,tn as safeSubdir,ui as safetyCheckpoint,Ti as sanitizeClientName,pn as saveInMemoryCheckpoint,bi as saveVersion,mt as seedBasenameIndex,H as serializeError,hi as setActiveSpanAttributes,yt as shadowGit,Q as shutdownTelemetry,q as skillManagementPath,Je as spansCurrentPath,ar as spansPreviousPath,M as spawnDetached,er as splitMarkdownBlocks,Re as startWatcher,Ue as streamingProblemEvent,$e as swapContributors,re as teardownToleranceTelemetryWriter,ve as toBroadcasterKey,Ne as tracedAppendFileSync,lt as tracedLinkSync,Ai as tracedMkdir,L as tracedMkdirSync,kt as tracedRename,pe as tracedRenameSync,wt as tracedRmSync,Pt as tracedRmdirSync,ce as tracedUnlinkSync,Oe as tracedWriteFile,Ir as tracedWriteFileSync,Ce as updateLastKnownHash,f as updateProcessLockPort,d as updateServerLockPort,Wt as updateUiLockPort,zt as validateAgentId,Yt as validateCloneInputs,it as validateSkillZip,D as withSpan,Dn as withSpanSync,Qr as writeRootGitignoreForNewRepo,br as writeSkillManagement,Vr as writeStateManifest,Jn as writeTargetVersion,sn as writeTracker};
1
+ import{An as e,Ii as t,J as n,Tn as r,Vt as i,a,ai as o,c as s,d as c,f as l,fn as u,g as d,h as f,i as p,ki as m,l as h,m as g,n as _,o as v,on as y,p as b,r as x,s as S,t as C,tn as w,u as T}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{$ as E,$i as D,$n as O,$r as k,$t as A,A as j,Ai as M,An as N,Ar as P,At as F,B as I,Bi as L,Bn as R,Br as z,Bt as B,C as V,Ci as H,Cn as U,Cr as W,Ct as G,D as K,Di as q,Dn as J,Dr as Y,Dt as X,E as Z,Ei as Q,En as $,Er as ee,Et as te,F as ne,Fi as re,Fn as ie,Fr as ae,Ft as oe,G as se,Gi as ce,Gn as le,Gr as ue,Gt as de,H as fe,Hi as pe,Hn as me,Hr as he,Ht as ge,I as _e,Ii as ve,In as ye,Ir as be,It as xe,J as Se,Ji as Ce,Jn as we,Jr as Te,Jt as Ee,K as De,Ki as Oe,Kn as ke,Kr as Ae,Kt as je,L as Me,Li as Ne,Ln as Pe,Lr as Fe,Lt as Ie,M as Le,Mi as Re,Mn as ze,Mr as Be,Mt as Ve,N as He,Ni as Ue,Nn as We,Nr as Ge,Nt as Ke,O as qe,Oi as Je,On as Ye,Or as Xe,Ot as Ze,P as Qe,Pi as $e,Pn as et,Pr as tt,Pt as nt,Q as rt,Qi as it,Qn as at,Qr as ot,Qt as st,R as ct,Ri as lt,Rn as ut,Rr as dt,Rt as ft,S as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Ti as yt,Tn as bt,Tr as xt,Tt as St,U as Ct,Ui as wt,Un as Tt,Ur as Et,Ut as Dt,V as Ot,Vi as kt,Vn as At,Vr as jt,Vt as Mt,W as Nt,Wi as Pt,Wn as Ft,Wr as It,Wt as Lt,X as Rt,Xi as zt,Xn as Bt,Xr as Vt,Xt as Ht,Y as Ut,Yi as Wt,Yn as Gt,Yr as Kt,Yt as qt,Z as Jt,Zi as Yt,Zn as Xt,Zr as Zt,Zt as Qt,_ as $t,_a as en,_i as tn,_n as nn,_r as rn,_t as an,a as on,aa as sn,ai as cn,an as ln,ar as un,at as dn,b as fn,bi as pn,bn as mn,br as hn,bt as gn,c as _n,ci as vn,cn as yn,cr as bn,ct as xn,d as Sn,di as Cn,dn as wn,dr as Tn,dt as En,ea as Dn,ei as On,en as kn,er as An,et as jn,f as Mn,fi as Nn,fn as Pn,fr as Fn,ft as In,g as Ln,gi as Rn,gn as zn,gr as Bn,gt as Vn,h as Hn,hi as Un,hn as Wn,hr as Gn,ht as Kn,i as qn,ia as Jn,ii as Yn,in as Xn,ir as Zn,it as Qn,j as $n,ji as er,jn as tr,jr as nr,jt as rr,k as ir,ki as ar,kn as or,kr as sr,kt as cr,l as lr,li as ur,ln as dr,lr as fr,lt as pr,m as mr,mi as hr,mn as gr,mr as _r,mt as vr,n as yr,na as br,ni as xr,nn as Sr,nr as Cr,nt as wr,o as Tr,oi as Er,on as Dr,or as Or,ot as kr,p as Ar,pi as jr,pn as Mr,pr as Nr,pt as Pr,q as Fr,qi as Ir,qn as Lr,qr as Rr,qt as zr,r as Br,ra as Vr,ri as Hr,rn as Ur,rr as Wr,rt as Gr,s as Kr,si as qr,sn as Jr,sr as Yr,st as Xr,t as Zr,ta as Qr,ti as $r,tn as ei,tr as ti,tt as ni,u as ri,ui as ii,un as ai,ur as oi,ut as si,v as ci,va as li,vi as ui,vn as di,vr as fi,vt as pi,w as mi,wi as hi,wn as gi,wr as _i,wt as vi,x as yi,xi as bi,xn as xi,xr as Si,xt as Ci,y as wi,yi as Ti,yn as Ei,yr as Di,yt as Oi,z as ki,zi as Ai,zn as ji,zr as Mi,zt as Ni}from"./dist-B923c31q.mjs";export{Zr as AGENT_ID_MAX_LEN,yr as AGENT_ID_RE,Br as AGENT_WRITE_ORIGIN,qn as AgentFocusBroadcaster,on as AgentPresenceBroadcaster,Tr as AgentSessionCapacityError,Kr as AgentSessionManager,_n as AutoStartDisabledError,lr as BUNDLE_IDS,ri as BUNDLE_SCOPE,Sn as BUNDLE_SKILL_NAME,Mn as BacklinkIndex,Ar as CC1Broadcaster,n as CC1_CONTRACT_VERSION,mr as CONFIG_FILENAME,Hn as CONFLICT_MARKER_RE,Ln as CURSOR_BUNDLE_PATHS_BY_PLATFORM,$t as ConfigSchema,ci as DEFAULT_CHECKPOINT_RETENTION,wi as DEFAULT_EMBEDDINGS_DIMENSIONS,fn as DEFAULT_PACK_ID,yi as EMBEDDINGS_API_KEY_ENV,pt as FILE_SYSTEM_WRITER,V as FILE_WATCHER_ORIGIN,mi as FileEmbeddingsBackend,vt as GIT_PREFLIGHT_FAIL_SPAN_NAME,Z as GIT_UPSTREAM_WRITER,en as GitDirAccessError,K as GitNotAvailableError,qe as GitTooOldError,ir as HOCUSPOCUS_AUTH_REJECTION_REASONS,j as HocuspocusAuthRejection,$n as HocuspocusAuthTokenSchema,Le as INSTALLED_AGENTS_SCHEMES,i as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Qe as LOG_MD_TEMPLATE,ne as MANAGED_RENAME_ORIGIN,_e as MAX_AGENT_SESSIONS,Me as MCP_CONNECTION_ID_HEADER,w as MCP_SERVER_NAME,ct as MIN_GIT_VERSION,ki as MISSING_OK_CONFIG_MESSAGE,li as MalformedGitPointerError,I as McpLogger,Ot as MissingOkConfigError,fe as OBSERVER_SYNC_ORIGIN,Ct as OK_OKIGNORE_TEMPLATE,y as ORPHAN_MODES,Nt as PANE_TARGET_TTL_MS,u as PROTOCOL_VERSION,se as PinoLogger,C as ProcessLockCollisionError,De as ProjectGitInitError,Fr as ROLLBACK_ORIGIN,Se as ROOT_GITIGNORE_TEMPLATE,_ as RUNTIME_VERSION,Ut as SERVICE_WRITER,Rt as SKILL_INSTALL_EVENTS_FILE_REL,r as SKILL_STATE_TARGETS,Jt as STARTER_FOLDERS,rt as STARTER_FOLDER_FRONTMATTER_FILENAME,E as STARTER_PACKS,jn as STARTER_PACK_IDS,ni as STARTER_TEMPLATES,wr as STATE_MANIFEST_FILENAME,x as STATE_SCHEMA_VERSION,e as SYSTEM_DOC_NAME,Gr as SeedPrerequisiteError,Qn as SeedRootDirError,p as ServerLockCollisionError,dn as SingleFileNotAFileError,kr as SingleFileNotFoundError,Xr as SingleFileNotMarkdownError,xn as StateManifestError,pr as TagIndex,si as USER_GLOBAL_BUNDLE_IDS,En as UiLockCollisionError,In as __getShowAllWalkStatsForTesting,Pr as __resetShowAllWalkStatsForTesting,a as acquireProcessLock,v as acquireServerLock,vr as acquireUiLock,Kn as applyAgentMarkdownWrite,Vn as applyExternalChange,an as applySeed,pi as armPaneTarget,Oi as assertCompatibleStateManifest,gn as assertGitAvailable,Ci as assertNeverDiskEvent,_t as attachIdleShutdown,G as bootServer,vi as buildAndOpenSkill,St as buildConfigYmlContent,te as buildExecResult,X as buildSkillZip,Ze as buildStarterFolderFrontmatterYaml,cr as buildWipTree,F as bundleSkillMdPath,rr as classifyEvents,Ve as classifyFsPath,Ke as clearArmedPaneTarget,nt as clearContributors,oe as clearEmbeddingsKeyFromAllBackends,xe as coercePackId,o as colorFromSeed,Ie as commitUpstreamImport,ft as commitWip,Ni as commitWipFromTree,B as compareSemver,Mt as containsConflictMarkers,ge as contentHash,Dt as contributorCount,Lt as countShadowObjects,de as countStaleAgentWipRefs,je as countWipRefs,zr as createApiExtension,Ee as createAssetServeMiddleware,qt as createContentFilter,Ht as createContentFilterAsync,Qt as createEmbeddingsSecretStore,st as createEphemeralProjectDir,A as createExternalChangeHandler,kn as createFileLogger,ei as createLiveDerivedIndexExtension,Sr as createMcpHttpHandler,Ur as createOsProbe,Xn as createPersistenceExtension,ln as createServer,Dr as createServerObserverExtension,Jr as createStreamingErrorWriter,yn as createTestLogger,dr as describeStoredEmbeddingsKey,ai as detectClaudeDesktopPresence,wn as detectGit,Pn as detectProjectShape,Mr as discoverLockDirs,gr as emitPreflightFailureSpan,Wn as encodeDocName,zn as encodeFolderRoute,nn as encodeSkillRoute,di as ensureProjectGit,Ei as errorResponse,mn as evictStaleTrackerEntries,xi as extractOkBinaryPath,ht as extractWikiLinksFromMarkdown,U as fallbackPaths,gi as findEnclosingGitRoot,bt as findEnclosingProjectRoot,$ as flushFileLogger,J as formatAuthRejectionWire,Ye as formatContributors,or as formatContributorsFrom,N as formatPackRationale,tr as gcCheckpointRefs,ze as getCurrentMcpLogger,We as getLocalDir,et as getLogFilePath,ie as getLogger,ye as getLogsDir,Pe as getMeter,ut as getMetrics,ji as getTracer,R as handleCollabSocketError,At as handleSpawnCursor,me as hasGcLogLatch,m as iconFromClientName,Tt as incrementCollabSocketFilteredError,Ft as incrementServerObserverFire,le as initContent,ke as initShadowRepo,Lr as initTelemetry,we as initToleranceTelemetryWriter,Gt as installPrettyZodErrors,Bt as installTestLoggers,Xt as installUserSkill,at as isAllowedApiOrigin,O as isAllowedWorkspaceHostHeader,An as isConfigDoc,ti as isHocuspocusAuthRejectionReason,Cr as isKnownPackId,Wr as isLinkIndexExcludedDoc,Zn as isLoopbackAddress,un as isManagedArtifactDoc,t as isOrphanMode,Or as isPairedWriteOrigin,Yr as isPathWithinDir,S as isProcessAlive,bn as isProjectRoot,fr as isProjectSkillManaged,oi as isReservedForUserTree,Tn as isSelfWrite,Fn as isSystemDoc,Nr as isToleranceTelemetryEnabled,s as isValidLockPid,_r as lastKnownHash,Gn as listRescueCheckpoints,Bn as listStarterPacks,rn as loadPrincipal,h as lockFilePath,fi as loggerFactory,Di as logsCurrentPath,hn as logsPreviousPath,Si as makeLazyEmbeddingsKeyStore,gt as mountMcpAndApi,W as normalizeFsPath,_i as packageVersionMajorMinor,xt as parseAuthRejectionWire,ee as parseGitVersion,Y as parseHocuspocusAuthToken,Xe as parseKeepaliveConnectionId,sr as pathToDocName,P as planSeed,nr as prepareSingleFileOpen,Be as processCommand,Ge as processUsage,tt as readAllTargets,ae as readArmedPaneTarget,be as readBranchFromHead,T as readProcessLock,c as readProcessLockDetailed,Fe as readProjectLocalSemanticConfig,l as readServerLock,dt as readServerPackageVersion,Mi as readSkillInstallStateSnapshot,z as readSkillManagement,jt as readStateManifest,he as readTargetRecordedAt,Et as readTargetVersion,It as readUiLock,ue as reconcile,Ae as recordContributor,Rr as recordSkillInstallEvent,Te as registerAllTools,Kt as registerWrite,b as releaseProcessLock,g as releaseServerLock,Vt as releaseUiLock,Zt as removeLastKnownHash,ot as resetMetrics,k as resolveBundledSkillDir,On as resolveContentDir,$r as resolveCursorBinaryDefault,xr as resolveCursorSpawnInvocation,Hr as resolveLockDir,Yn as resolvePack,cn as resolvePackageVersion,Er as resolveUiInfo,qr as restoreContributors,vn as restoreLifecycleFromConflictsJson,ur as rewriteMarkdownLinksForDocumentRename,ii as rewriteWikiLinksForDocumentRename,Cn as runAuthReposSubprocess,Nn as runAuthStatusSubprocess,jr as runCloneSubprocess,hr as runDeviceFlowSubprocess,Un as runWithMcpLogger,Rn as safeContentPath,tn as safeSubdir,ui as safetyCheckpoint,Ti as sanitizeClientName,pn as saveInMemoryCheckpoint,bi as saveVersion,mt as seedBasenameIndex,H as serializeError,hi as setActiveSpanAttributes,yt as shadowGit,Q as shutdownTelemetry,q as skillManagementPath,Je as spansCurrentPath,ar as spansPreviousPath,M as spawnDetached,er as splitMarkdownBlocks,Re as startWatcher,Ue as streamingProblemEvent,$e as swapContributors,re as teardownToleranceTelemetryWriter,ve as toBroadcasterKey,Ne as tracedAppendFileSync,lt as tracedLinkSync,Ai as tracedMkdir,L as tracedMkdirSync,kt as tracedRename,pe as tracedRenameSync,wt as tracedRmSync,Pt as tracedRmdirSync,ce as tracedUnlinkSync,Oe as tracedWriteFile,Ir as tracedWriteFileSync,Ce as updateLastKnownHash,f as updateProcessLockPort,d as updateServerLockPort,Wt as updateUiLockPort,zt as validateAgentId,Yt as validateCloneInputs,it as validateSkillZip,D as withSpan,Dn as withSpanSync,Qr as writeRootGitignoreForNewRepo,br as writeSkillManagement,Vr as writeStateManifest,Jn as writeTargetVersion,sn as writeTracker};
@@ -1,3 +1,3 @@
1
- import{Lo as e}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";import{execFileSync as t}from"node:child_process";import{dirname as n,join as r}from"node:path";import{homedir as i}from"node:os";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";var l=e();const u=`open-knowledge`;function d(e){try{e()}catch{}}var f=class{backend=`keyring`;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(u,e).getPassword()}catch(t){return d(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return d(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return d(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(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{}}},p=class{backend=`file`;authFile;constructor(e){this.authFile=e??r(i(),`.ok`,`auth.yml`)}read(){if(!a(this.authFile))return{};try{return(0,l.parse)(s(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);a(t)||o(t,{recursive:!0,mode:448}),c(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)}},m=class{backend=`keyring`;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function h(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(u,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
1
+ import{Lo as e}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{execFileSync as t}from"node:child_process";import{dirname as n,join as r}from"node:path";import{homedir as i}from"node:os";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";var l=e();const u=`open-knowledge`;function d(e){try{e()}catch{}}var f=class{backend=`keyring`;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(u,e).getPassword()}catch(t){return d(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return d(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return d(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(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{}}},p=class{backend=`file`;authFile;constructor(e){this.authFile=e??r(i(),`.ok`,`auth.yml`)}read(){if(!a(this.authFile))return{};try{return(0,l.parse)(s(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);a(t)||o(t,{recursive:!0,mode:448}),c(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)}},m=class{backend=`keyring`;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function h(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(u,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
2
2
  `),d(()=>t?.onBackendSelected?.({backend:`keyring`})),new m(new f(t?.onKeychainRead),new p(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml) — OS keychain unavailable: ${r}\n`),d(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new p(e)}}function g(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 p(e))},n)});try{return await Promise.race([h(e),r])}catch{return new p(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function _(e){let t=g(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token}}}}function v(e){let t=g(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 y(e,t){let n=[],r=new p(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(u,`__probe__`);let r,a=await new f(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(u,e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}const b=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`];function x(e,n={}){let r=n._exec??t,i=n._fileExists??a,o=[`auth`,`token`,...e?[`--hostname`,e]:[]],s=[`gh`,...b.filter(i)];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{v as a,_ as i,y as n,h as r,x as t};
3
- //# sourceMappingURL=gh-detect-B3B56f-Q.mjs.map
3
+ //# sourceMappingURL=gh-detect-C_0kt1kp.mjs.map
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{i as e,r as t,t as n}from"./gh-detect-B3B56f-Q.mjs";import{F as r,I as i,L as a,M as o,N as s,P as c,a as l,b as u,c as d,i as f,j as p,l as m,n as h,p as g,v as _,w as v,x as y}from"./init-CeV6DYvh.mjs";import{_ as b,d as x,g as S,i as C,l as w,n as T,p as E,r as D,t as O,u as k,v as A,y as j}from"./src-CZBXfnwD.mjs";import{c as M,d as N,l as P,o as F,r as I,s as L,t as R,u as z}from"./write-project-skill-DUum3kyh.mjs";import{n as B}from"./loader-CRiGx4e0.mjs";import{n as V}from"./preview-IaeY2esx.mjs";import{n as H,t as U}from"./mcp-migrate-event-D0NrGjvc.mjs";export{I as ALL_EDITOR_IDS,F as EDITOR_LABELS,L as EDITOR_TARGETS,M as HOSTS_WITH_USER_SKILL_DIR,h as LAUNCH_CONFIG_NAME,f as LAUNCH_UI_CHAIN_SENTINEL,l as LAUNCH_UI_CHAIN_V1,w as PATH_SHIM_BEGIN,k as PATH_SHIM_BLOCK_RE,x as PATH_SHIM_END,p as addOkPathsToGitExclude,R as assertProjectPathSafe,P as buildManagedServerEntry,D as buildMcpConfigDeclineEvent,U as buildMcpConfigMigrateEvent,d as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,m as detectInstalledEditors,o as formatTrackedRemediation,s as getExcludedOkPaths,c as getOkArtifactPaths,z as isEntryUpToDate,N as isOwnManagedEntry,B as loadConfig,e as makeLazyProbeTokenStore,S as parseGitHubBlobUrl,b as parseGitHubShareUrl,A as parseGitHubTreeUrl,j as parseGitUrl,E as pathInstallMarkerPath,V as previewContent,r as probeTrackedOkPaths,g as readExistingMcpEntry,i as readSharingMode,a as removeOkPathsFromGitExclude,v as resolveProjectRoot,C as runStop,_ as scaffoldLaunchJson,H as truncatePriorEntry,T as validateLocalFolderForShare,u as writeEditorMcpConfig,O as writeProjectAiIntegrations,y as writeUserMcpConfigs};
1
+ import{i as e,r as t,t as n}from"./gh-detect-C_0kt1kp.mjs";import{F as r,I as i,L as a,M as o,N as s,P as c,a as l,b as u,c as d,i as f,j as p,l as m,n as h,p as g,v as _,w as v,x as y}from"./init-ICH9ja53.mjs";import{_ as b,d as x,g as S,i as C,l as w,n as T,p as E,r as D,t as O,u as k,v as A,y as j}from"./src-DnmgOJh8.mjs";import{c as M,d as N,l as P,o as F,r as I,s as L,t as R,u as z}from"./write-project-skill-C02OzQla.mjs";import{n as B}from"./loader-Dv5atXyy.mjs";import{n as V}from"./preview-CQG9jtTU.mjs";import{n as H,t as U}from"./mcp-migrate-event-D0NrGjvc.mjs";export{I as ALL_EDITOR_IDS,F as EDITOR_LABELS,L as EDITOR_TARGETS,M as HOSTS_WITH_USER_SKILL_DIR,h as LAUNCH_CONFIG_NAME,f as LAUNCH_UI_CHAIN_SENTINEL,l as LAUNCH_UI_CHAIN_V1,w as PATH_SHIM_BEGIN,k as PATH_SHIM_BLOCK_RE,x as PATH_SHIM_END,p as addOkPathsToGitExclude,R as assertProjectPathSafe,P as buildManagedServerEntry,D as buildMcpConfigDeclineEvent,U as buildMcpConfigMigrateEvent,d as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,m as detectInstalledEditors,o as formatTrackedRemediation,s as getExcludedOkPaths,c as getOkArtifactPaths,z as isEntryUpToDate,N as isOwnManagedEntry,B as loadConfig,e as makeLazyProbeTokenStore,S as parseGitHubBlobUrl,b as parseGitHubShareUrl,A as parseGitHubTreeUrl,j as parseGitUrl,E as pathInstallMarkerPath,V as previewContent,r as probeTrackedOkPaths,g as readExistingMcpEntry,i as readSharingMode,a as removeOkPathsFromGitExclude,v as resolveProjectRoot,C as runStop,_ as scaffoldLaunchJson,H as truncatePriorEntry,T as validateLocalFolderForShare,u as writeEditorMcpConfig,O as writeProjectAiIntegrations,y as writeUserMcpConfigs};
@@ -0,0 +1 @@
1
+ import{_ as e}from"./init-ICH9ja53.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{Ca as r,It as i,Ma as a,Na as o,St as s,Wi as c,gn as l,pi as u,ut as d}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";import{$n as f,D as p,Gn as m,K as h,O as g,Qn as _,Zn as v,ba as y,cr as b,fa as x,ha as S,ir as C,ta as ee,vn as w}from"./dist-BNI6AO8O.mjs";import{r as T,t as E}from"./esm-CsQUg9js.mjs";import{t as te}from"./constants-CS2nL68U.mjs";import{m as D,n as ne,p as re,r as ie,s as ae,t as O}from"./write-project-skill-DUum3kyh.mjs";import{t as k}from"./is-object-Cg453afR.mjs";import{i as A,o as j,r as M,s as N,t as P}from"./colors-8SzMRIVy.mjs";import{t as oe}from"./preview-IaeY2esx.mjs";import{createRequire as F}from"node:module";import{execFileSync as se}from"node:child_process";import ce,{dirname as I,isAbsolute as le,join as L,relative as R,resolve as ue,sep as de}from"node:path";import z from"node:process";import{fileURLToPath as fe}from"node:url";import{homedir as pe}from"node:os";import{existsSync as B,lstatSync as me,mkdirSync as he,readFileSync as V,readlinkSync as ge,realpathSync as _e,statSync as ve,writeFileSync as ye}from"node:fs";import{randomUUID as be}from"node:crypto";import{inspect as xe,stripVTControlCharacters as Se,styleText as H}from"node:util";import{AsyncLocalStorage as Ce,AsyncResource as we}from"node:async_hooks";import{createServer as Te,request as Ee}from"node:http";import*as De from"node:readline";import{connect as Oe}from"node:net";const ke=new Set([`emacs`,`vim`]);function Ae(e){return ke.has(e)}function je(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ae))):[]}const Me=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ne=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Pe=e=>e.name===`space`,Fe=e=>e.name===`backspace`,Ie=e=>`1234567890`.includes(e.name),Le=e=>e.name===`enter`||e.name===`return`;var Re=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},ze=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Be=class extends Error{name=`ExitPromptError`},Ve=class extends Error{name=`HookError`},He=class extends Error{name=`ValidationError`};const Ue=new Ce;function We(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Ge(e,t){let n=We(e);return Ue.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ue.getStore();if(!e)throw new Ve(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Ke(){return U().rl}function qe(e){return we.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Je(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function Ye(){U().handleChange()}const Xe={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Ke());if(r!=null&&typeof r!=`function`)throw new He(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();qe(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Ze(e){return typeof e==`function`}function W(e){return Je(t=>{let n=we.bind(function(e){t.get()!==e&&(t.set(e),Ye())});if(t.initialized)return[t.get(),n];let r=Ze(e)?e():e;return t.set(r),[r,n]})}function Qe(e,t){Je(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&Xe.queue(e),n.set(t)})}function $e(){return z.platform.startsWith(`win`)?!!z.env.CI||!!z.env.WT_SESSION||!!z.env.TERMINUS_SUBLIME||z.env.ConEmuTask===`{cmd::Cmder}`||z.env.TERM_PROGRAM===`Terminus-Sublime`||z.env.TERM_PROGRAM===`vscode`||z.env.TERM===`xterm-256color`||z.env.TERM===`alacritty`||z.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:z.env.TERM!==`linux`}const et={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:`╱`},tt={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:`⅒`},nt={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`},rt={...et,...tt},it={...et,...nt},G=$e()?rt:it;Object.entries(tt);const at={prefix:{idle:H(`blue`,`?`),done:H(`green`,G.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>H(`yellow`,e))},keybindings:[],style:{answer:e=>H(`cyan`,e),message:e=>H(`bold`,e),error:e=>H(`red`,`> ${e}`),defaultAnswer:e=>H(`dim`,`(${e})`),help:e=>H(`dim`,e),highlight:e=>H(`cyan`,e),key:e=>H(`cyan`,H(`bold`,`<${e}>`))}};function ot(){return{...at,keybindings:je()}}function st(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ct(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=st(n)&&st(r)?ct(n,r):r}return t}function lt(...e){return ct(ot(),...e.filter(e=>e!=null))}function ut({status:e=`idle`,theme:t}){let[n,r]=W(!1),[i,a]=W(0),{prefix:o,spinner:s}=lt(t);return Qe(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function dt(e,t){return Je(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function ft(e){return W({current:e})[0]}function pt(e){let t=ft(e);t.current=e,Qe(e=>{let n=!1,r=qe((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var mt=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 ht=(()=>{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}})(),gt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,_t=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,vt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,yt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,bt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,xt=/\t{1,1000}/y,St=/[\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,Ct=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,wt=/\p{M}+/gu,Tt={limit:1/0,ellipsis:``},Et=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Et(i,Tt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ct,l],[vt,0],[yt,o],[xt,s],[St,c],[bt,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(wt,``)){let t=e.codePointAt(0)||0;if(S=gt(t)?2:_t(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===bt?ht(e.slice(p,n.lastIndex)):n===St?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}},Dt={limit:1/0,ellipsis:``,ellipsisWidth:0},K=(e,t={})=>Et(e,Dt,t).width,Ot=`]8;;`,kt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ot}(?<uri>.*))`,`y`),At=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},jt=e=>`[${e}m`,Mt=e=>`${Ot}${e}`,Nt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:K(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=K(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ot,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())},Pt=e=>{let t=e.split(` `),n=t.length;for(;n&&!K(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ft=(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=K(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=K(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(``),Nt(s,r,t),c=K(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Nt(s,r,t),c=K(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Nt(s,r,t),c=K(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Pt(e)));let l=s.join(`
1
+ import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{Ca as r,It as i,Ma as a,Na as o,St as s,Wi as c,gn as l,pi as u,ut as d}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{$n as f,D as p,Gn as m,K as h,O as g,Qn as _,Zn as v,ba as y,cr as b,fa as x,ha as S,ir as C,ta as ee,vn as w}from"./dist-B923c31q.mjs";import{r as T,t as E}from"./esm-CsQUg9js.mjs";import{t as te}from"./constants-DLfnk8-s.mjs";import{m as D,n as ne,p as re,r as ie,s as ae,t as O}from"./write-project-skill-C02OzQla.mjs";import{t as k}from"./is-object-Cg453afR.mjs";import{i as A,o as j,r as M,s as N,t as P}from"./colors-8SzMRIVy.mjs";import{t as oe}from"./preview-CQG9jtTU.mjs";import{createRequire as F}from"node:module";import{execFileSync as se}from"node:child_process";import ce,{dirname as I,isAbsolute as le,join as L,relative as R,resolve as ue,sep as de}from"node:path";import z from"node:process";import{fileURLToPath as fe}from"node:url";import{homedir as pe}from"node:os";import{existsSync as B,lstatSync as me,mkdirSync as he,readFileSync as V,readlinkSync as ge,realpathSync as _e,statSync as ve,writeFileSync as ye}from"node:fs";import{randomUUID as be}from"node:crypto";import{inspect as xe,stripVTControlCharacters as Se,styleText as H}from"node:util";import{AsyncLocalStorage as Ce,AsyncResource as we}from"node:async_hooks";import{createServer as Te,request as Ee}from"node:http";import*as De from"node:readline";import{connect as Oe}from"node:net";const ke=new Set([`emacs`,`vim`]);function Ae(e){return ke.has(e)}function je(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ae))):[]}const Me=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ne=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Pe=e=>e.name===`space`,Fe=e=>e.name===`backspace`,Ie=e=>`1234567890`.includes(e.name),Le=e=>e.name===`enter`||e.name===`return`;var Re=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},ze=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Be=class extends Error{name=`ExitPromptError`},Ve=class extends Error{name=`HookError`},He=class extends Error{name=`ValidationError`};const Ue=new Ce;function We(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Ge(e,t){let n=We(e);return Ue.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ue.getStore();if(!e)throw new Ve(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Ke(){return U().rl}function qe(e){return we.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function Je(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function Ye(){U().handleChange()}const Xe={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Ke());if(r!=null&&typeof r!=`function`)throw new He(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();qe(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Ze(e){return typeof e==`function`}function W(e){return Je(t=>{let n=we.bind(function(e){t.get()!==e&&(t.set(e),Ye())});if(t.initialized)return[t.get(),n];let r=Ze(e)?e():e;return t.set(r),[r,n]})}function Qe(e,t){Je(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&Xe.queue(e),n.set(t)})}function $e(){return z.platform.startsWith(`win`)?!!z.env.CI||!!z.env.WT_SESSION||!!z.env.TERMINUS_SUBLIME||z.env.ConEmuTask===`{cmd::Cmder}`||z.env.TERM_PROGRAM===`Terminus-Sublime`||z.env.TERM_PROGRAM===`vscode`||z.env.TERM===`xterm-256color`||z.env.TERM===`alacritty`||z.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:z.env.TERM!==`linux`}const et={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:`╱`},tt={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:`⅒`},nt={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`},rt={...et,...tt},it={...et,...nt},G=$e()?rt:it;Object.entries(tt);const at={prefix:{idle:H(`blue`,`?`),done:H(`green`,G.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>H(`yellow`,e))},keybindings:[],style:{answer:e=>H(`cyan`,e),message:e=>H(`bold`,e),error:e=>H(`red`,`> ${e}`),defaultAnswer:e=>H(`dim`,`(${e})`),help:e=>H(`dim`,e),highlight:e=>H(`cyan`,e),key:e=>H(`cyan`,H(`bold`,`<${e}>`))}};function ot(){return{...at,keybindings:je()}}function st(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ct(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=st(n)&&st(r)?ct(n,r):r}return t}function lt(...e){return ct(ot(),...e.filter(e=>e!=null))}function ut({status:e=`idle`,theme:t}){let[n,r]=W(!1),[i,a]=W(0),{prefix:o,spinner:s}=lt(t);return Qe(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function dt(e,t){return Je(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function ft(e){return W({current:e})[0]}function pt(e){let t=ft(e);t.current=e,Qe(e=>{let n=!1,r=qe((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var mt=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 ht=(()=>{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}})(),gt=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,_t=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,vt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,yt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,bt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,xt=/\t{1,1000}/y,St=/[\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,Ct=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,wt=/\p{M}+/gu,Tt={limit:1/0,ellipsis:``},Et=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Et(i,Tt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Ct,l],[vt,0],[yt,o],[xt,s],[St,c],[bt,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(wt,``)){let t=e.codePointAt(0)||0;if(S=gt(t)?2:_t(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===bt?ht(e.slice(p,n.lastIndex)):n===St?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}},Dt={limit:1/0,ellipsis:``,ellipsisWidth:0},K=(e,t={})=>Et(e,Dt,t).width,Ot=`]8;;`,kt=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ot}(?<uri>.*))`,`y`),At=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},jt=e=>`[${e}m`,Mt=e=>`${Ot}${e}`,Nt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:K(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=K(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ot,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())},Pt=e=>{let t=e.split(` `),n=t.length;for(;n&&!K(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ft=(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=K(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=K(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(``),Nt(s,r,t),c=K(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Nt(s,r,t),c=K(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Nt(s,r,t),c=K(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Pt(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===`›`){kt.lastIndex=e+1;let t=kt.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+=Mt(``));let e=i?At(i):void 0;i&&e&&(r+=jt(e))}else t===`
4
4
  `&&(i&&At(i)&&(r+=jt(i)),a&&(r+=Mt(a)))}return r},It=/\r?\n/;function Lt(e,t,n){return String(e).normalize().split(It).map(e=>Ft(e,t,n)).join(`
@@ -289,7 +289,7 @@ let Zr=/^[a-z0-9-_]+$/i;function Qr(e){let t=typeof e;if(t===`object`){if(Array.
289
289
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function oi(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Qr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=ai(0,e,``,t,n);return r[r.length-1]===`
290
290
  `?r:r+`
291
291
  `}function si(e,t){let n=R(t,e);return n.length>0&&!n.startsWith(`..`)&&!le(n)}const ci=e=>{try{let t=se(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function li(e,t={}){let n=t.homeDir??pe(),r=t.gitTopLevel??ci,i=ue(e),a;try{a=_e(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(b(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=I(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&si(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}}function ui(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function Q(e,t){if(!process.env.OK_DEBUG_NATIVE)return;let n=t instanceof Error?t.message:String(t);process.stderr.write(`[ok] native-config ${e}: ${n}\n`)}const di=[`native`,`index.js`];function fi(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??F(t);try{return n(L(I(fe(t)),...di))}catch(e){ui(e)||Q(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return ui(e)||Q(`workspace addon failed to load`,e),null}}function pi(){let e=fi();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function mi(e){let t=e,n=new Set;for(;;){let r;try{r=me(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=ge(t)}catch(t){return Q(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=le(i)?i:L(I(t),i)}}let hi;function gi(){return hi===void 0&&(hi=pi()),hi}function _i(e,t=gi){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Q(`resolveSymlinkWritePath threw`,e)}return mi(e)}function vi(){let e=fi();return e&&typeof e.parseTomlToJson==`function`?e:null}function yi(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Q(`addon loaded but probe failed`,e),!1}}function bi(e){if(!k(e))throw Error(`TOML root is not a table`);return e}function xi(e){return{backend:`native`,parseToObject(t){return bi(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}}}}function Si(){return{backend:`fallback`,parseToObject(e){return bi(Xr(e))}}}function Ci(e=vi){let t=e();return t&&yi(t)?xi(t):Si()}let wi=null;function Ti(){return wi===null&&(wi=Ci()),wi}function $(e,t,n,r,i){let a=`urn:uuid:${be()}`;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=l.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 Ei=1e4;function Di(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!C(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!f(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&&!_(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const Oi=3e4;function ki(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!C(n)||!f(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!_(r)?(t.destroy(),!0):!1}function Ai(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=Oe({host:r,port:i,timeout:Ei});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
292
- `)}\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 ji=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Mi(e){let t=e.upstreamTimeoutMs??Ei,n=new Set,r=Te((n,r)=>{Di(n,r)||Pi(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{ki(t,r)||Ai(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 Ni(e,t,n){Pi(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??Ei)}function Pi(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of ji)delete a[e];e.setTimeout(Oi,()=>{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 ${Oi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=Ee({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of ji)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 Fi=39847,Ii=39848;async function Li(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Ri(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:i}=await import(`node:path`),{acquireUiLock:s,clearArmedPaneTarget:c,createAssetServeMiddleware:l,createContentFilter:f,readArmedPaneTarget:p,readServerLock:m,releaseUiLock:h,updateUiLockPort:g}=await import(`./dist-s-76L6SV.mjs`),{default:_}=await import(`./build-gfyDk62R.mjs`),{resolveContentDir:v,resolveLockDir:y}=await import(`./dist-s-76L6SV.mjs`),b=v(e.config,e.cwd),x=y(e.cwd);s(x,{port:0,worktreeRoot:e.cwd});let S=import.meta.dirname??new URL(`.`,import.meta.url).pathname,C=[i(S,`public`),i(S,`../../app/dist`),i(S,`../../../app/dist`)],ee=e.assetDir??C.find(e=>t(e)),w=ee?_(ee,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,T=t(b)?l({contentFilter:f({projectDir:e.cwd,contentDir:b}),contentSirv:_(b,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:r,blocklistExtensions:a}):null,E=e.port,te=null,D=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=p(x);if(e&&!/[\r\n]/.test(e)){c(x),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&Di(e,t))){if(n===`/api/config`&&e.method===`DELETE`){c(x),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){te?.();let n=m(x),r=e.headers.host??`localhost:${E}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=p(x),o=JSON.stringify({collabUrl:i,previewUrl:null,port:E,paneTarget:a});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(o);return}if(n?.startsWith(`/api/`)){te?.();let r=m(x);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}Ni(e,t,{upstreamHost:d,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{T?T(e,t,()=>zi(t)):zi(t)});return}if(T){T(e,t,()=>{w?w(e,t):zi(t)});return}if(w){w(e,t);return}zi(t)}},ne=new Set,re=(e,t,n)=>{if(ki(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=m(x);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}Ai(e,t,n,d,i.port,ne)},ie=()=>{for(let e of ne)try{e.destroy()}catch{}ne.clear()},ae=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],O=[],k=e.port,A=e=>e instanceof Error&&e.code===`EADDRINUSE`,j=async()=>{await Promise.all(O.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},M=async e=>{k=e;for(let e of ae){let t=n(D);t.on(`upgrade`,re),O.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(k,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(k=e.port),n()})})}};try{try{await M(e.port)}catch(t){if(e.fallbackToKernel===!0&&A(t))await j(),await M(0);else throw t}}catch(e){await j();try{h(x)}catch{}throw e}let N=k;E=N,g(x,N);let P=e.scheduler??u,oe=e.safetyNetMs??432e5,F=null,se=!1,ce=!1,I=()=>{se||(se=!0,F!==null&&(P.clearTimeout(F),F=null))},le=()=>{if(I(),!ce){ce=!0;try{h(x)}catch{}}},L=()=>{se||oe<=0||(F!==null&&(P.clearTimeout(F),F=null),F=P.setTimeout(()=>{F=null,console.warn(`[ui] safety-net (${oe}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}ie();for(let e of O)try{e.close()}catch{}le()},oe))},R=()=>{se||oe<=0||L()};return te=R,L(),{httpServers:O,port:N,release:le,detachSafetyNet:I,nudgeSafetyNet:R,drainUpgradeSockets:ie}}function zi(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function Bi(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:Fi,fallbackToKernel:!0}}async function Vi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-s-76L6SV.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 Mi({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Hi(e){return new E(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Fi}, 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-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-s-76L6SV.mjs`),{resolveLockDir:i}=await import(`./dist-s-76L6SV.mjs`),a=e(),o=t.host,s;try{s=Bi(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 Ri({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(),Li(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 Vi({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}`),Ui(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 Ui(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}const Wi={allowTrailingComma:!0,disallowComments:!1};function Gi(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function Ki(e){let t=[],n=ar(e,t,Wi);return t.some(t=>!Gi(t,e))||!n||n.type!==`object`?null:n}function qi(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&or(e)===t&&(n+=1)}return n}function Ji(e,t){x(e,`${JSON.stringify(t,null,2)}\n`)}function Yi(e,t){let n=oi(t);x(e,n.endsWith(`
292
+ `)}\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 ji=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Mi(e){let t=e.upstreamTimeoutMs??Ei,n=new Set,r=Te((n,r)=>{Di(n,r)||Pi(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{ki(t,r)||Ai(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 Ni(e,t,n){Pi(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??Ei)}function Pi(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of ji)delete a[e];e.setTimeout(Oi,()=>{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 ${Oi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=Ee({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of ji)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 Fi=39847,Ii=39848;async function Li(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Ri(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:i}=await import(`node:path`),{acquireUiLock:s,clearArmedPaneTarget:c,createAssetServeMiddleware:l,createContentFilter:f,readArmedPaneTarget:p,readServerLock:m,releaseUiLock:h,updateUiLockPort:g}=await import(`./dist-C1MZNyof.mjs`),{default:_}=await import(`./build-gfyDk62R.mjs`),{resolveContentDir:v,resolveLockDir:y}=await import(`./dist-C1MZNyof.mjs`),b=v(e.config,e.cwd),x=y(e.cwd);s(x,{port:0,worktreeRoot:e.cwd});let S=import.meta.dirname??new URL(`.`,import.meta.url).pathname,C=[i(S,`public`),i(S,`../../app/dist`),i(S,`../../../app/dist`)],ee=e.assetDir??C.find(e=>t(e)),w=ee?_(ee,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,T=t(b)?l({contentFilter:f({projectDir:e.cwd,contentDir:b}),contentSirv:_(b,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:r,blocklistExtensions:a}):null,E=e.port,te=null,D=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=p(x);if(e&&!/[\r\n]/.test(e)){c(x),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&Di(e,t))){if(n===`/api/config`&&e.method===`DELETE`){c(x),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){te?.();let n=m(x),r=e.headers.host??`localhost:${E}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=p(x),o=JSON.stringify({collabUrl:i,previewUrl:null,port:E,paneTarget:a});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(o);return}if(n?.startsWith(`/api/`)){te?.();let r=m(x);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}Ni(e,t,{upstreamHost:d,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{T?T(e,t,()=>zi(t)):zi(t)});return}if(T){T(e,t,()=>{w?w(e,t):zi(t)});return}if(w){w(e,t);return}zi(t)}},ne=new Set,re=(e,t,n)=>{if(ki(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=m(x);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}Ai(e,t,n,d,i.port,ne)},ie=()=>{for(let e of ne)try{e.destroy()}catch{}ne.clear()},ae=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],O=[],k=e.port,A=e=>e instanceof Error&&e.code===`EADDRINUSE`,j=async()=>{await Promise.all(O.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},M=async e=>{k=e;for(let e of ae){let t=n(D);t.on(`upgrade`,re),O.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(k,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(k=e.port),n()})})}};try{try{await M(e.port)}catch(t){if(e.fallbackToKernel===!0&&A(t))await j(),await M(0);else throw t}}catch(e){await j();try{h(x)}catch{}throw e}let N=k;E=N,g(x,N);let P=e.scheduler??u,oe=e.safetyNetMs??432e5,F=null,se=!1,ce=!1,I=()=>{se||(se=!0,F!==null&&(P.clearTimeout(F),F=null))},le=()=>{if(I(),!ce){ce=!0;try{h(x)}catch{}}},L=()=>{se||oe<=0||(F!==null&&(P.clearTimeout(F),F=null),F=P.setTimeout(()=>{F=null,console.warn(`[ui] safety-net (${oe}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}ie();for(let e of O)try{e.close()}catch{}le()},oe))},R=()=>{se||oe<=0||L()};return te=R,L(),{httpServers:O,port:N,release:le,detachSafetyNet:I,nudgeSafetyNet:R,drainUpgradeSockets:ie}}function zi(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function Bi(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:Fi,fallbackToKernel:!0}}async function Vi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-C1MZNyof.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 Mi({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Hi(e){return new E(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Fi}, 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-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-C1MZNyof.mjs`),{resolveLockDir:i}=await import(`./dist-C1MZNyof.mjs`),a=e(),o=t.host,s;try{s=Bi(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 Ri({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(),Li(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 Vi({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}`),Ui(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 Ui(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}const Wi={allowTrailingComma:!0,disallowComments:!1};function Gi(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function Ki(e){let t=[],n=ar(e,t,Wi);return t.some(t=>!Gi(t,e))||!n||n.type!==`object`?null:n}function qi(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&or(e)===t&&(n+=1)}return n}function Ji(e,t){x(e,`${JSON.stringify(t,null,2)}\n`)}function Yi(e,t){let n=oi(t);x(e,n.endsWith(`
293
293
  `)?n:`${n}\n`)}const Xi=10*1024*1024;function Zi(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>Zi(e,t[n]));if(k(e)&&k(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&Zi(e[n],t[n])):!1}return!1}function Qi(e){for(let t of e.split(`
294
294
  `)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function $i(e,t,n){return t===void 0?[e,n]:[e,t,n]}function ea(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function ta(e,t,n){let r=e[t];return n===void 0?r:k(r)?r[n]:void 0}function na(e,t,n,r,i){if(!B(e))return Ji(e,ea(t,i,n,r)),{kind:`written`};let a;try{a=V(e,`utf-8`)}catch(e){return Q(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return Ji(e,ea(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>Xi)return{kind:`declined`,reason:`oversize`};let o=Ki(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(qi(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=ta(or(o),t,i),c=k(s)?s[n]:void 0,l=c!==void 0;if(l&&Zi(c,r))return{kind:`overwritten`};let u=a.charCodeAt(0)===65279,d=u?a.slice(1):a,f=d.includes(`\r
295
295
  `)?`\r
@@ -316,6 +316,6 @@ UIPORT="\${PORT:-${Ii}}"
316
316
  unset PORT
317
317
  exec node "${re()}" start --ui-port "$UIPORT"`],port:Ii,autoPort:!0}:{name:ma,runtimeExecutable:`/bin/sh`,runtimeArgs:[`-l`,`-c`,_a],port:Ii,autoPort:!0};try{if(O(n,e),!B(n))return he(I(n),{recursive:!0}),ye(n,`${JSON.stringify({version:pa,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=V(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!k(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=>k(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??pa,configurations:a};return ye(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 ya(e,t,n){try{return B(e.detectPath?.(t,n)??I(e.configPath(t,n)))}catch{return!1}}function ba(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)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!ya(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{O(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 c;try{c=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{he(I(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 l={action:`written`},u;try{S(`${o}.lock`,()=>{let t=_i(o).writePath;if(he(I(t),{recursive:!0}),e.format===`toml`){let n=ra(Ti(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=na(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function xa(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!B(n)))return{editorId:e.id,label:e.label,path:n}}async function Sa(e){let t=D(e.editors),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>ba(t,``,n,e.home))}function Ca(e,t,n,r){let i=Ta(e,t,n,r);return i.kind===`present`?i.entry:null}function wa(e,t,n,r){let i=ta(e,t,r);if(!k(i))return{kind:`no-entry`};let a=i[n];return k(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Ta(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!B(i))return{kind:`absent`};try{if(ve(i).size>Xi)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=V(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Ti().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return wa(t,e.topLevelKey,o,e.serverMapSubKey)}let s=Ki(a);return s?qi(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:wa(or(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ea(e={}){let t=ue(e.cwd??process.cwd()),n=li(t,{homeDir:e.home}),r=n.projectRoot,i=!B(L(r,`.ok`)),a=n.gitRootPromoted?R(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:da(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${N(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await w(r),l;try{l=m(r,{contentDir:o})}catch(t){let i=ae.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let u=l.created.includes(te),d=!1;if(c.didInit)try{d=ee(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}let f=await sa({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),p=e.editors??Ma(r,e.home),h=e.editors??ie.filter(e=>ae[e].projectConfigPath!==void 0),g=D(p),_=D(h),y=e.mcp===!1||f===null,b=Array.from(new Map([...g,...y?[]:_].map(e=>[e.id,e])).values()),x=g.filter(t=>ya(t,r,e.home)),S=[],C=[],T=new Set;for(let t of b){if(y){let n=``;try{n=t.configPath(r,e.home)}catch{}S.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(ia(f)&&g.includes(t)&&S.push(ba(t,r,s,e.home)),aa(f)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ba(t,r,s,e.home,n);S.push(i),(i.action===`written`||i.action===`overwritten`)&&T.add(n)}}let E=new Set;for(let e of _){let t=e.projectSkillPath?.(r);!t||E.has(t)||(E.add(t),C.push(ne(e,r)))}let re=!y&&f!==null&&aa(f)?_.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,O=y?[]:x.map(e=>xa(e,r)).filter(e=>e!==void 0).filter(e=>!T.has(e.path)),k=x.some(e=>e.id===`claude`)&&!y?va(r,s):void 0,A=await(e.installUserSkill??v)({home:e.home}),j=y?`skipped-flag`:`skipped-missing`,M=S.find(e=>e.editorId===`claude`)??S[0]??{action:j,configPath:ae.claude.configPath(r,e.home)},P=await Da({projectRoot:r,desiredMode:await la({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:S,projectSkills:C,legacyProjectConfigs:O,launchJson:k,skillInstall:A,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:M.action,mcpPath:M.configPath,mcpError:`error`in M?M.error:void 0,projectScopeUnsupportedLabels:re,sharing:P}}async function Da(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Sn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=yn(t);if(n===`local-only`){let e=bn(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Oa(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=xn(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Oa(t,o,`remove`)}function Oa(e,t,n){let r=Sn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ka(e){switch(e){case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;default:return`config not readable`}}function Aa(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)?R(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)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=L(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(P(`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(P(`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(P(`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(P(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(P(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?R(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} ${j(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${j(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${M(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${c}${l}${i} left unchanged (${ka(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}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(P(`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?R(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${j(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${j(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${M(`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} ${R(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(P(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${j(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${j(`already installed at current version`)}`);break;case`failed`:n.push(` ${N(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${N(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(N(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(N(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(oe(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Fa(e.sharing,t)),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(`${j(`✓`)} ${P(`Next steps:`)}`),n.push(` 1. Open your editor (${A(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${A(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${A(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${A(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${A(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${A(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
318
318
  `)}function ja(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Ma(e,t){let n=[];for(let r of ie)ya(ae[r],e,t)&&n.push(r);return n}function Na(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:xe(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Pa(){return new E(`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`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).addOption(new T(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new T(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new T(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Na():null;try{let r;try{r=await Ea({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir})}catch(e){if(e instanceof ua){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof p||e instanceof g){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof h){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
319
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-MCBnhFm_.mjs`),{resolveContentDir:s}=await import(`./dist-s-76L6SV.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-0VpHVzuK.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ja(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Aa(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Fa(e,t){let n=[];switch(e.kind){case`applied`:return n.push(P(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${j(`local-only`)} — appended ${e.appended.length} path(s) to ${P(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${j(`local-only`)} — already excluded; nothing to do.`):n.push(` ${j(`local-only`)}`):e.action===`removed`?n.push(` ${j(`shared`)} — removed OK paths from ${P(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${j(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(N(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
319
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-SibEgXZ1.mjs`),{resolveContentDir:s}=await import(`./dist-C1MZNyof.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-BIIOpGNN.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ja(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Aa(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Fa(e,t){let n=[];switch(e.kind){case`applied`:return n.push(P(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${j(`local-only`)} — appended ${e.appended.length} path(s) to ${P(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${j(`local-only`)} — already excluded; nothing to do.`):n.push(` ${j(`local-only`)}`):e.action===`removed`?n.push(` ${j(`shared`)} — removed OK paths from ${P(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${j(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(N(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
320
320
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${A(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(N(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${A(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${A(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(N(`Sharing mode unavailable: ${e.reason}.`));return n}}export{ar as A,pt as B,Ti as C,dr as D,fr as E,wn as F,lt as H,Sn as I,xn as L,Tn as M,Cn as N,pr as O,yn as P,vn as R,Hi as S,xr as T,W as U,ut as V,Le as W,Ea as _,_a as a,ba as b,Ta as c,Fa as d,Pa as f,la as g,da as h,ga as i,bn as j,or as k,Ma as l,sa as m,ma as n,Da as o,Ca as p,ha as r,ja as s,ua as t,Aa as u,va as v,li as w,Sa as x,$i as y,an as z};
321
- //# sourceMappingURL=init-CeV6DYvh.mjs.map
321
+ //# sourceMappingURL=init-ICH9ja53.mjs.map
@@ -1,4 +1,4 @@
1
- import{Ha as e,Ka as t,Lo as n,Ua as r}from"./server-lock-ltHt39S2-CPmTXbVG.mjs";import{_ as i,ma as a,pa as o}from"./dist-BNI6AO8O.mjs";import{t as s}from"./constants-CS2nL68U.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{resolve as l}from"node:path";import{existsSync as u,readFileSync as d}from"node:fs";import{realpath as f}from"node:fs/promises";async function p(e){let t=l(e);try{return await f(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 m=n();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!u(e))return{value:null,path:e,source:null,doc:null};let t;try{t=d(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,m.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 c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(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 v(t){let n=t??process.cwd(),c=[],u=a(`user`,n),d=o({absPath:u}),f={};d.valid&&d.source!==void 0?(f=h(f,d.value),c.push(u)):d.valid;let p=l(n,`.ok`,s),m=g(p);if(m.value!==null){let t=e({value:m.value,file:m.path,source:m.source,doc:m.doc});if(t.length>0)throw Error(t.map(r).join(`
1
+ import{Ha as e,Ka as t,Lo as n,Ua as r}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";import{_ as i,ma as a,pa as o}from"./dist-B923c31q.mjs";import{t as s}from"./constants-DLfnk8-s.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{resolve as l}from"node:path";import{existsSync as u,readFileSync as d}from"node:fs";import{realpath as f}from"node:fs/promises";async function p(e){let t=l(e);try{return await f(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 m=n();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!u(e))return{value:null,path:e,source:null,doc:null};let t;try{t=d(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,m.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 c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(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 v(t){let n=t??process.cwd(),c=[],u=a(`user`,n),d=o({absPath:u}),f={};d.valid&&d.source!==void 0?(f=h(f,d.value),c.push(u)):d.valid;let p=l(n,`.ok`,s),m=g(p);if(m.value!==null){let t=e({value:m.value,file:m.path,source:m.source,doc:m.doc});if(t.length>0)throw Error(t.map(r).join(`
2
2
 
3
3
  `));f=h(f,m.value),c.push(p)}let v=i.safeParse(f);if(!v.success){let e={code:`SCHEMA_INVALID`,issues:_(v.error.issues,m)};throw Error(r(e))}return{config:v.data,sources:c}}function y(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??v,r=new Map,i=new Map,a=p(e.startupCwd);return async o=>{let s=await p(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{v as n,y as t};
4
- //# sourceMappingURL=loader-CRiGx4e0.mjs.map
4
+ //# sourceMappingURL=loader-Dv5atXyy.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-Dv5atXyy.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-CQG9jtTU.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
1
- import{Yt as e}from"./dist-BNI6AO8O.mjs";import"./constants-CS2nL68U.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{Yt as e}from"./dist-B923c31q.mjs";import"./constants-DLfnk8-s.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-IaeY2esx.mjs.map
3
+ //# sourceMappingURL=preview-CQG9jtTU.mjs.map
@@ -1,2 +1,2 @@
1
- import{r as e,v as t}from"./init-CeV6DYvh.mjs";import{t as n}from"./is-object-Cg453afR.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`],e];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))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-CS6C6O3X.mjs.map
1
+ import{r as e,v as t}from"./init-ICH9ja53.mjs";import{t as n}from"./is-object-Cg453afR.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`],e];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))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-BmK9QMNQ.mjs.map
@@ -1,2 +1,2 @@
1
- import{b as e,p as t}from"./init-CeV6DYvh.mjs";import{r as n,s as r,u as i}from"./write-project-skill-DUum3kyh.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,i=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of n){let n=r[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),n.projectConfigPath){let r=n.projectConfigPath,i=c(()=>r(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(n){let r={scope:n.scope,editorId:n.editorId,configPath:n.configPath},o=t(n.target,n.cwd,n.home,n.configPathOverride);if(o===null)return{...r,outcome:`no-entry`};if(i(o))return{...r,outcome:`canonical`};n.logger(a({scope:n.scope,surface:`cli-repair`,editorId:n.editorId,configPath:n.configPath,priorEntry:o}));let s=e(n.target,n.cwd,{mode:`published`,skipAvailabilityCheck:!0},n.home,n.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return n.logger({event:`mcp-config-repair-write-failed`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return s.action===`declined`?(n.logger({event:`mcp-config-repair-declined`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,reason:s.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs-D-iMOSEE.mjs.map
1
+ import{b as e,p as t}from"./init-ICH9ja53.mjs";import{r as n,s as r,u as i}from"./write-project-skill-C02OzQla.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,i=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of n){let n=r[o],s=c(()=>n.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:n,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),n.projectConfigPath){let r=n.projectConfigPath,i=c(()=>r(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:n,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(n){let r={scope:n.scope,editorId:n.editorId,configPath:n.configPath},o=t(n.target,n.cwd,n.home,n.configPathOverride);if(o===null)return{...r,outcome:`no-entry`};if(i(o))return{...r,outcome:`canonical`};n.logger(a({scope:n.scope,surface:`cli-repair`,editorId:n.editorId,configPath:n.configPath,priorEntry:o}));let s=e(n.target,n.cwd,{mode:`published`,skipAvailabilityCheck:!0},n.home,n.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return n.logger({event:`mcp-config-repair-write-failed`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,error:e}),{...r,outcome:`write-failed`,error:e}}return s.action===`declined`?(n.logger({event:`mcp-config-repair-declined`,scope:n.scope,editorId:n.editorId,configPath:n.configPath,reason:s.declineReason}),{...r,outcome:`declined`}):{...r,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-BDNpoQWE.mjs.map
@@ -1,3 +1,3 @@
1
- import{$r as e,Rr as t,Ur as n,d as r,ia as i,qr as a,ut as o}from"./dist-BNI6AO8O.mjs";import{t as s}from"./esm-CsQUg9js.mjs";import{c,s as l,t as u}from"./write-project-skill-DUum3kyh.mjs";import{dirname as d,join as f,resolve as p}from"node:path";import{homedir as m}from"node:os";import{existsSync as h,mkdirSync as g,readFileSync as _,readdirSync as v,rmSync as y,statSync as b,writeFileSync as x}from"node:fs";const S={existsSync:e=>h(e),isDirectory:e=>{try{return b(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>v(e),readFileSync:e=>_(e),writeFileSync:(e,t)=>{x(e,t)},mkdirSync:(e,t)=>{g(e,t)},rmSync:(e,t)=>{y(e,t)}},C={resolveProjectBundledSkillDir:()=>e(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:t=>e(t,{checkDesktop:!1}),readBundledVersion:()=>t(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>a(e)};function w(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function T(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(d(t),{recursive:!0}),E(e,t,n)}function E(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=f(e,r),a=f(t,r);n.isDirectory(i)?E(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function D(e,t,n,r,i,a){let o=[],s=f(e,`.agents`,`skills`,t),l=r.existsSync(s),u=!1;try{T(n,s,r),u=!0,o.push({kind:`central`,path:s,outcome:l?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:l,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let l of c){let c=f(e,l.hostDir),u=f(c,`skills`,t);if(u===s){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(c)){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}let d=r.existsSync(u);try{T(n,u,r),o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:d,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:o,centralWritten:u}}function O(e,t){if(!e)return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e).toString(`utf8`);return n.includes(`# ok-mcp-v1`)||n.includes(`# ok-mcp-win-v1`)}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of c){let o=f(e,t.hostDir,`skills`,`open-knowledge`),s=f(o,`SKILL.md`),c=n.existsSync(s),d=l[t.editorId]?.projectConfigPath?.(e),p=!c&&O(d,n);if(!c&&!p){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{u(o,e),T(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,i){let a=e=>{t.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let l;try{l=await t.readRecordedVersion(e)}catch(e){i({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),l=null}if(l!==null&&l===c)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let u=[],d=null;for(let e of o)try{u.push({id:e,sourceDir:t.resolveUserBundledSkillDir(e)})}catch(e){d=e instanceof Error?e.message:String(e)}if(u.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:d??`no user-global bundles`}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${d}`}),{outcome:`skipped`,reason:`bundle-missing`};let f=[],p=u.length===o.length;for(let{id:t,sourceDir:a}of u){let o=D(e,r[t],a,n,i,c);f.push(...o.entries),o.centralWritten||(p=!1)}let m=f.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(p&&m){let n=null;try{await t.writeRecordedVersion(e,c),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(e){n=e instanceof Error?e.message:String(e),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:n})}for(let{id:e}of u)a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:n===null?`installed`:`failed`,version:c,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=f.some(e=>e.kind===`host`&&e.outcome===`failed`);a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:c,entries:f}}async function j(e){let t=e.logger??w,n=e.fs??S,r=e.home??m(),i={...C,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
1
+ import{$r as e,Rr as t,Ur as n,d as r,ia as i,qr as a,ut as o}from"./dist-B923c31q.mjs";import{t as s}from"./esm-CsQUg9js.mjs";import{c,s as l,t as u}from"./write-project-skill-C02OzQla.mjs";import{dirname as d,join as f,resolve as p}from"node:path";import{homedir as m}from"node:os";import{existsSync as h,mkdirSync as g,readFileSync as _,readdirSync as v,rmSync as y,statSync as b,writeFileSync as x}from"node:fs";const S={existsSync:e=>h(e),isDirectory:e=>{try{return b(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>v(e),readFileSync:e=>_(e),writeFileSync:(e,t)=>{x(e,t)},mkdirSync:(e,t)=>{g(e,t)},rmSync:(e,t)=>{y(e,t)}},C={resolveProjectBundledSkillDir:()=>e(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:t=>e(t,{checkDesktop:!1}),readBundledVersion:()=>t(),readRecordedVersion:e=>n(e,`cli-hosts`),writeRecordedVersion:(e,t)=>i(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>a(e)};function w(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function T(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(d(t),{recursive:!0}),E(e,t,n)}function E(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=f(e,r),a=f(t,r);n.isDirectory(i)?E(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function D(e,t,n,r,i,a){let o=[],s=f(e,`.agents`,`skills`,t),l=r.existsSync(s),u=!1;try{T(n,s,r),u=!0,o.push({kind:`central`,path:s,outcome:l?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:l,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let l of c){let c=f(e,l.hostDir),u=f(c,`skills`,t);if(u===s){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(c)){o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}let d=r.existsSync(u);try{T(n,u,r),o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:d,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:o,centralWritten:u}}function O(e,t){if(!e)return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e).toString(`utf8`);return n.includes(`# ok-mcp-v1`)||n.includes(`# ok-mcp-win-v1`)}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of c){let o=f(e,t.hostDir,`skills`,`open-knowledge`),s=f(o,`SKILL.md`),c=n.existsSync(s),d=l[t.editorId]?.projectConfigPath?.(e),p=!c&&O(d,n);if(!c&&!p){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{u(o,e),T(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,i){let a=e=>{t.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let l;try{l=await t.readRecordedVersion(e)}catch(e){i({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),l=null}if(l!==null&&l===c)return i({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let u=[],d=null;for(let e of o)try{u.push({id:e,sourceDir:t.resolveUserBundledSkillDir(e)})}catch(e){d=e instanceof Error?e.message:String(e)}if(u.length===0)return i({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:d??`no user-global bundles`}),a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${d}`}),{outcome:`skipped`,reason:`bundle-missing`};let f=[],p=u.length===o.length;for(let{id:t,sourceDir:a}of u){let o=D(e,r[t],a,n,i,c);f.push(...o.entries),o.centralWritten||(p=!1)}let m=f.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(p&&m){let n=null;try{await t.writeRecordedVersion(e,c),i({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(e){n=e instanceof Error?e.message:String(e),i({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:n})}for(let{id:e}of u)a({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:n===null?`installed`:`failed`,version:c,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=f.some(e=>e.kind===`host`&&e.outcome===`failed`);a({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:c,entries:f}}async function j(e){let t=e.logger??w,n=e.fs??S,r=e.home??m(),i={...C,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
2
2
  `)}function P(){return new s(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await j({projectDir:p(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${N(e)}\n`),process.exitCode=M(e)})}export{P as n,j as t};
3
- //# sourceMappingURL=repair-skills-D5s7VIc5.mjs.map
3
+ //# sourceMappingURL=repair-skills-Bu_8HPr_.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-Bu_8HPr_.mjs";export{e as repairSkills};
@@ -0,0 +1 @@
1
+ import{g as e}from"./server-lock-ltHt39S2-BMGVBKsW.mjs";export{e as updateServerLockPort};
@@ -445,9 +445,9 @@ $2`).split(`
445
445
  `),w=v.split(`
446
446
  `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&N4.test(n),a=n===``&&r!==``&&N4.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(E4,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
447
447
  `)!==v.endsWith(`
448
- `)&&n.push(`trailing-newline`),n}const B4=`parse-equivalence`;function V4(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}const H4=/^([ \t]*)\d+([.)])(?=[ \t])/;function U4(e){return e.split(`
449
- `).map(e=>e.replace(H4,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const W4=new Set;function G4(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}function K4(e,t,n){let r=aK(e),i=aK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return W4.size<8&&!W4.has(t)&&(W4.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return V4(a)===V4(i.body)?G4(U4(r.body),U4(a)):!1}const q4={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},J4={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function Y4(e){return J4[e]}function X4(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let Z4=null;function Q4(e){Z4=e}function $4(e,t,n,r){if(!Z4||e.length===0)return;let i=X4(t,n),a=new Date().toISOString();for(let t of e)Z4({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:Y4(t)})}const e3=1e4,t3=`last-spawn-error.log`,n3=/^[a-zA-Z0-9][\w/-]*$/;function r3(e){return e.startsWith(`#`)?e.slice(1):e}function i3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function a3(e){if(!e||e.trim()===``)return[];let{map:t}=q2(e);if(!t)return[];let n=i3(t.tags),r=[];for(let e of n){let t=r3(e);n3.test(t)&&r.push(t)}return r}const o3=[`.ok`,`local`,`installed-skills.json`],s3=P(yG),c3=Ys({hosts:M(k()),scope:s3,scripts:j(),installedAt:Uo()}),l3=Ys({schema:F(1),skills:rc(k(),c3).default({})});function u3(){return{schema:1,skills:{}}}function d3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=l3.safeParse(t);return n.success?n.data:null}const f3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},p3=new WeakMap;function m3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function h3(e){return e.trim().toLowerCase()}const g3=/\.(?:md|mdx)$/;function _3(e,t){if(t!==`page`)return e;let n=e.replace(g3,``);return n.length>0?n:e}function v3(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function y3(e){let t=v3(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function b3(e){let t=gW({schema:f3});return e.length>0&&DW(t,e),t}function x3(e){let t={documents:e};return p3.set(t,b3(e)),t}function S3(e){let t=p3.get(e);if(t)return t;let n=b3(e.documents);return p3.set(e,n),n}function C3(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function w3(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function T3(e,t){let n=h3(t);if(!n)return 0;let r=_3(n,e.kind),i=h3(e.title),a=h3(e.name),o=h3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function E3(e,t){let n=T3(e,t);return n<=0?n:dq(e.path)?n*.5:n}function D3(e){return e===`file`?-60:0}function O3(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function k3(e,t,n,r){return e+t*20+n+D3(r)}function A3(e,t,n,r,i,a){return e===`relevance`?k3(t,n,r,i):O3(t,n,r,i,a)}function j3(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function M3(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function N3(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function P3(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function F3(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function I3(e,t){return h3(t).length<4?0:e===`full_text`?1:0}function L3(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function R3(e){let t=[],n=[],r=[];for(let i of e){let e=L3(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function z3(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=R3(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function B3(e,t,n={}){let r=n.intent??`omnibar`,i=j3(r,n.ranking),a=m3(n.limit),o=new Set(n.scopes??C3(r)),s=e.documents.filter(e=>w3(e,o)),c=h3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=rG(S3(e),{term:c,properties:P3(r),boost:F3(r),tolerance:I3(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>w3(e.document,o)).map(e=>[e.document.id,e.score])),d=N3(s),f=new Map;for(let e of s)E3(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)w3(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=M3(f.values(),u);return z3([...f.values()].map(t=>{let n=Math.max(0,E3(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:A3(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return z3(H3({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function V3(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function H3(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=M3(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,E3(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?A3(o,t,n,s,e.kind,m):k3(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=V3(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=V3(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function U3(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),W3(n)}function W3(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const G3=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),K3=globalThis;K3[G3]===void 0&&(K3[G3]=Ii());const q3=K3[G3],J3=[`.ok`,`skill-state.yml`],Y3=[`claude-cowork`,`cli-hosts`],X3=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],Z3=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,Q3=Ys({version:k().regex(Z3,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(q3,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(q3,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(X3).register(q3,{description:`Install-source surface that recorded this entry.`}).optional()}),$3=Ys({schema:F(1).register(q3,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":Q3.optional(),"cli-hosts":Q3.optional()}).register(q3,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function e6(){return{schema:1,targets:{}}}const t6=`template`;function n6(e){if(e.trim()===``)return{};let t;try{t=(0,Nc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function r6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function i6(e){let{frontmatter:t,body:n}=aK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:sK(t),markdown:n}}function a6(e){let t=e.split(`
450
- `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=n6(n.join(`
451
- `))[t6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
452
- `).replace(/\n+$/,``)}}function o6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=aK(t);if(n===``)return{identity:{},starterContent:t};let i=sK(n),a=a6(i);if(a)return{identity:a.identity,starterContent:r6(a.docFrontmatterText,r)};let{frontmatter:o}=aK(r);if(o!==``)return{identity:n6(i),starterContent:r};let s=n6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:r6(i,r)}}function s6(e,t){let{docFrontmatterText:n,markdown:r}=i6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Nc.stringify)({[t6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function c6(e){return o6(e).starterContent}function l6(){let e=!1,t=``,n=0;return r=>{let i=u6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function u6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const d6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],f6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function p6(e,t=d6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const m6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function h6(e){return e?m6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const g6={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function _6(e){let t=e?.trim();return t?g6[h6(t)]??t:`Agent`}function v6(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const y6=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function b6(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function x6(e){let t=e.trim();return y6.test(t)||t.startsWith(`//`)}function S6(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(x6(n))return{kind:`external`,url:n};let r=v6(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=b6(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function C6(e,t){let n=e.trim();if(!n)return null;if(x6(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=b6(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function w6(e,t){let n=e.trim();if(!n||y6.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function T6(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function E6(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function D6(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function O6(e){return e.split(`/`).filter(e=>e!==``)}function k6(e,t){let n=D6(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function A6(e,t){let n=D6(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:O6(r).length}function j6(e,t){let n=O6(e),r=O6(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function M6(){let e=new Map;function t(t){let n=T6(t);if(n===``)return;let r=E6(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=T6(t),r=E6(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=D6(T6(n)),o=[],s=[];for(let e of i)k6(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=A6(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=A6(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=j6(a,D6(t));for(let r=1;r<e.length;r++){let i=e[r],o=j6(a,D6(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function N6(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function P6(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function F6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function I6(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function L6(){try{let e=l(c(d(import.meta.url)),`..`,`package.json`),t=JSON.parse(v(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const R6=L6(),z6=1;var B6=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function V6(e,t){return l(e,`${t}.lock`)}const H6=new Map;function U6(e){H6.set(e,(H6.get(e)??0)+1)}function W6(e){let t=H6.get(e);return t===void 0||t<=1?(H6.delete(e),!0):(H6.set(e,t-1),!1)}function G6(e,t){try{let n=JSON.parse(v(e,`utf-8`));return n&&typeof n==`object`&&I6(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function K6(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;g(n,{recursive:!0});let a=V6(n,t),o={pid:process.pid,hostname:p(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??R6},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!h(a))try{let e=_(a,`wx`,384);try{x(e,s)}finally{m(e)}return U6(a),q6({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=G6(a,i);if(e){let r=e.hostname===p();if(r&&e.pid===process.pid)return b(a,s,{encoding:`utf-8`,mode:384}),U6(a),q6({lockName:t,lockDir:n,lockPath:a});if(r&&F6(e.pid))throw new B6(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{y(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function q6(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>Z6({lockName:t,lockDir:n}),updatePort:e=>J6({lockName:t,lockDir:n,port:e})}}function J6(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=V6(n,t);if(!h(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(v(a,`utf-8`));if(!e||typeof e!=`object`||!I6(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==p())){o.port=r;try{b(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function Y6(e){let{lockName:t,lockDir:n}=e,r=V6(n,t);if(!h(r))return null;let i;try{let e=JSON.parse(v(r,`utf-8`));if(!e||typeof e!=`object`||!I6(e.pid))return null;i=e}catch{return null}if(i.hostname!==p())return null;if(!F6(i.pid)){try{y(r)}catch{}return null}return i}function X6(e){let{lockName:t,lockDir:n}=e,r=V6(n,t);if(!h(r))return{status:`absent`};let i;try{i=JSON.parse(v(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!I6(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==p())return{status:`stale`,lock:o};if(!F6(o.pid)){try{y(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function Z6(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=V6(n,t);if(W6(i)&&h(i))try{let e=JSON.parse(v(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==p())return;y(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var Q6=class extends B6{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function $6(e,t){try{return K6({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof B6&&e.lockName===`server`?new Q6(e.existing,e.lockPath):e}}function e8(e,t){J6({lockName:`server`,lockDir:e,port:t})}function t8(e){return Y6({lockName:`server`,lockDir:e})}function n8(e){Z6({lockName:`server`,lockDir:e})}export{mG as $,Fs as $a,SG as $i,u2 as $n,o4 as $r,vG as $t,qq as A,_l as Aa,c6 as Ai,uG as An,mn as Ao,t6 as Ar,B$ as At,P2 as B,Dl as Ba,h4 as Bi,Gq as Bn,R0 as Br,l3 as Bt,L$ as C,Gc as Ca,s4 as Ci,G0 as Cn,Wa as Co,g0 as Cr,n1 as Ct,I$ as D,yl as Da,$J as Di,E0 as Dn,cn as Do,u0 as Dr,F0 as Dt,S$ as E,Yc as Ea,ZQ as Ei,Z3 as En,vr as Eo,h0 as Er,P0 as Et,v4 as F,iu as Fa,bG as Fi,v0 as Fn,D as Fo,L0 as Fr,d1 as Ft,k2 as G,Sl as Ga,jG as Gi,Eq as Gn,n0 as Gr,x1 as Gt,M2 as H,tu as Ha,q2 as Hi,yq as Hn,A1 as Hr,$$ as Ht,N$ as I,ru as Ia,KG as Ii,y0 as In,pt as Io,H0 as Ir,o3 as It,dG as J,xl as Ja,o6 as Ji,l2 as Jn,Qq as Jr,b1 as Jt,O2 as K,Xl as Ka,EG as Ki,Oq as Kn,r0 as Kr,S1 as Kt,N2 as L,Ql as La,K4 as Li,S0 as Ln,ft as Lo,U0 as Lr,C0 as Lt,q$ as M,Wc as Ma,b$ as Mi,i1 as Mn,Lt as Mo,M0 as Mr,VG as Mt,Bq as N,Jc as Na,dq as Ni,y2 as Nn,Tt as No,A0 as Nr,o1 as Nt,x$ as O,bl as Oa,nq as Oi,t3 as On,un as Oo,d0 as Or,X$ as Ot,l4 as P,ll as Pa,Rq as Pi,C2 as Pn,O as Po,V0 as Pr,s1 as Pt,fG as Q,El as Qa,p4 as Qi,X0 as Qn,H2 as Qr,_G as Qt,L2 as R,qc as Ra,kq as Ri,_0 as Rn,z0 as Rr,T0 as Rt,C$ as S,I as Sa,a3 as Si,xG as Sn,fa as So,m1 as Sr,zG as St,R$ as T,Cl as Ta,r$ as Ti,Y3 as Tn,ai as To,m0 as Tr,N0 as Tt,D2 as U,Kl as Ua,OG as Ui,wq as Un,j1 as Ur,C1 as Ut,F2 as V,Pl as Va,R4 as Vi,_q as Vn,M1 as Vr,FG as Vt,A2 as W,Ul as Wa,d3 as Wi,Cq as Wn,k1 as Wr,v1 as Wt,gG as X,Ml as Xa,YG as Xi,o2 as Xn,c1 as Xr,h1 as Xt,cG as Y,Fl as Ya,oK as Yi,c2 as Yn,Zq as Yr,y1 as Yt,hG as Z,Tl as Za,f$ as Zi,s2 as Zn,U2 as Zr,_1 as Zt,f6 as _,sK as _a,$4 as _i,Q1 as _n,Zs as _o,e2 as _r,W$ as _t,K6 as a,wG as aa,p6 as ai,N1 as an,j as ao,$0 as ar,W1 as at,D1 as b,db as ba,U3 as bi,i0 as bn,Uo as bo,R1 as br,RG as bt,I6 as c,Q4 as ca,M6 as ci,B4 as cn,tc as co,W0 as cr,U1 as ct,X6 as d,kG as da,x3 as di,BG as dn,A as do,m2 as dr,e3 as dt,t4 as ea,Yq as ei,yG as en,cc as eo,T2 as er,pG as et,t8 as f,d4 as fa,y3 as fi,sG as fn,N as fo,h2 as fr,IG as ft,e8 as g,YQ as ga,_6 as gi,Xq as gn,k as go,p2 as gr,G$ as gt,J6 as h,c4 as ha,Q2 as hi,Kq as hn,rc as ho,f2 as hr,t0 as ht,Q6 as i,v6 as ia,lG as ii,P1 as in,M as io,Q0 as ir,H$ as it,J$ as j,gl as ja,jq as ji,r1 as jn,on as jo,J0 as jr,_$ as jt,F$ as k,vl as ka,h6 as ki,PG as kn,fn as ko,f0 as kr,z$ as kt,V6 as l,oq as la,l6 as li,JG as ln,F as lo,$3 as lr,WG as lt,n8 as m,P6 as ma,z4 as mi,J1 as mn,Mc as mo,O0 as mr,e0 as mt,R6 as n,p$ as na,S6 as ni,PQ as nn,Bs as no,r2 as nr,Uq as nt,$6 as o,B3 as oa,s6 as oi,GG as on,kc as oo,_2 as or,G1 as ot,Z6 as p,aK as pa,q4 as pi,X1 as pn,lc as po,g2 as pr,p1 as pt,E2 as q,ul as qa,k0 as qi,n2 as qn,UG as qr,$q as qt,z6 as r,w6 as ra,C6 as ri,I1 as rn,Hs as ro,i2 as rr,V$ as rt,F6 as s,J2 as sa,q0 as si,u1 as sn,$s as so,v2 as sr,H1 as st,B6 as t,f4 as ta,Lq as ti,qG as tn,P as to,d2 as tr,Vq as tt,Y6 as u,cq as ua,sZ as ui,XG as un,Ys as uo,D0 as ur,ZG as ut,LG as v,lq as va,u3 as vi,$1 as vn,Ws as vo,t2 as vr,K1 as vt,w$ as w,nu as wa,NQ as wi,J3 as wn,Ga as wo,p0 as wr,V1 as wt,O1 as x,tp as xa,N6 as xi,a0 as xn,Vo as xo,eJ as xr,HG as xt,j$ as y,Z2 as ya,e6 as yi,l1 as yn,ys as yo,Z0 as yr,q1 as yt,I2 as z,Kc as za,NG as zi,S2 as zn,B0 as zr,L1 as zt};
453
- //# sourceMappingURL=server-lock-ltHt39S2-CPmTXbVG.mjs.map
448
+ `)&&n.push(`trailing-newline`),n}const B4=`parse-equivalence`;function V4(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function H4(e){return e.replace(/[ \t]+$/gm,``)}const U4=/^([ \t]*)\d+([.)])(?=[ \t])/;function W4(e){return e.split(`
449
+ `).map(e=>e.replace(U4,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const G4=new Set;function K4(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)e[n]===t[r]&&n++;return n===e.length}function q4(e,t,n){let r=aK(e),i=aK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return G4.size<8&&!G4.has(t)&&(G4.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return V4(H4(a))===V4(H4(i.body))?K4(W4(r.body),W4(a)):!1}const J4={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},Y4={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function X4(e){return Y4[e]}function Z4(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let Q4=null;function $4(e){Q4=e}function e3(e,t,n,r){if(!Q4||e.length===0)return;let i=Z4(t,n),a=new Date().toISOString();for(let t of e)Q4({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:X4(t)})}const t3=1e4,n3=`last-spawn-error.log`,r3=/^[a-zA-Z0-9][\w/-]*$/;function i3(e){return e.startsWith(`#`)?e.slice(1):e}function a3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function o3(e){if(!e||e.trim()===``)return[];let{map:t}=q2(e);if(!t)return[];let n=a3(t.tags),r=[];for(let e of n){let t=i3(e);r3.test(t)&&r.push(t)}return r}const s3=[`.ok`,`local`,`installed-skills.json`],c3=P(yG),l3=Ys({hosts:M(k()),scope:c3,scripts:j(),installedAt:Uo()}),u3=Ys({schema:F(1),skills:rc(k(),l3).default({})});function d3(){return{schema:1,skills:{}}}function f3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=u3.safeParse(t);return n.success?n.data:null}const p3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},m3=new WeakMap;function h3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function g3(e){return e.trim().toLowerCase()}const _3=/\.(?:md|mdx)$/;function v3(e,t){if(t!==`page`)return e;let n=e.replace(_3,``);return n.length>0?n:e}function y3(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function b3(e){let t=y3(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function x3(e){let t=gW({schema:p3});return e.length>0&&DW(t,e),t}function S3(e){let t={documents:e};return m3.set(t,x3(e)),t}function C3(e){let t=m3.get(e);if(t)return t;let n=x3(e.documents);return m3.set(e,n),n}function w3(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function T3(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function E3(e,t){let n=g3(t);if(!n)return 0;let r=v3(n,e.kind),i=g3(e.title),a=g3(e.name),o=g3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function D3(e,t){let n=E3(e,t);return n<=0?n:dq(e.path)?n*.5:n}function O3(e){return e===`file`?-60:0}function k3(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function A3(e,t,n,r){return e+t*20+n+O3(r)}function j3(e,t,n,r,i,a){return e===`relevance`?A3(t,n,r,i):k3(t,n,r,i,a)}function M3(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function N3(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function P3(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function F3(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function I3(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function L3(e,t){return g3(t).length<4?0:e===`full_text`?1:0}function R3(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function z3(e){let t=[],n=[],r=[];for(let i of e){let e=R3(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function B3(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=z3(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function V3(e,t,n={}){let r=n.intent??`omnibar`,i=M3(r,n.ranking),a=h3(n.limit),o=new Set(n.scopes??w3(r)),s=e.documents.filter(e=>T3(e,o)),c=g3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=rG(C3(e),{term:c,properties:F3(r),boost:I3(r),tolerance:L3(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>T3(e.document,o)).map(e=>[e.document.id,e.score])),d=P3(s),f=new Map;for(let e of s)D3(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)T3(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=N3(f.values(),u);return B3([...f.values()].map(t=>{let n=Math.max(0,D3(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:j3(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return B3(U3({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function H3(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function U3(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=N3(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,D3(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?j3(o,t,n,s,e.kind,m):A3(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=H3(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=H3(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function W3(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),G3(n)}function G3(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const K3=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),q3=globalThis;q3[K3]===void 0&&(q3[K3]=Ii());const J3=q3[K3],Y3=[`.ok`,`skill-state.yml`],X3=[`claude-cowork`,`cli-hosts`],Z3=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],Q3=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,$3=Ys({version:k().regex(Q3,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(J3,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(J3,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(Z3).register(J3,{description:`Install-source surface that recorded this entry.`}).optional()}),e6=Ys({schema:F(1).register(J3,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":$3.optional(),"cli-hosts":$3.optional()}).register(J3,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function t6(){return{schema:1,targets:{}}}const n6=`template`;function r6(e){if(e.trim()===``)return{};let t;try{t=(0,Nc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function i6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function a6(e){let{frontmatter:t,body:n}=aK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:sK(t),markdown:n}}function o6(e){let t=e.split(`
450
+ `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=r6(n.join(`
451
+ `))[n6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
452
+ `).replace(/\n+$/,``)}}function s6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=aK(t);if(n===``)return{identity:{},starterContent:t};let i=sK(n),a=o6(i);if(a)return{identity:a.identity,starterContent:i6(a.docFrontmatterText,r)};let{frontmatter:o}=aK(r);if(o!==``)return{identity:r6(i),starterContent:r};let s=r6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:i6(i,r)}}function c6(e,t){let{docFrontmatterText:n,markdown:r}=a6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Nc.stringify)({[n6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function l6(e){return s6(e).starterContent}function u6(){let e=!1,t=``,n=0;return r=>{let i=d6(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function d6(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const f6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],p6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function m6(e,t=f6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const h6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function g6(e){return e?h6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const _6={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function v6(e){let t=e?.trim();return t?_6[g6(t)]??t:`Agent`}function y6(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const b6=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function x6(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function S6(e){let t=e.trim();return b6.test(t)||t.startsWith(`//`)}function C6(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(S6(n))return{kind:`external`,url:n};let r=y6(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=x6(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function w6(e,t){let n=e.trim();if(!n)return null;if(S6(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=x6(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function T6(e,t){let n=e.trim();if(!n||b6.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function E6(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function D6(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function O6(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function k6(e){return e.split(`/`).filter(e=>e!==``)}function A6(e,t){let n=O6(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function j6(e,t){let n=O6(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:k6(r).length}function M6(e,t){let n=k6(e),r=k6(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function N6(){let e=new Map;function t(t){let n=E6(t);if(n===``)return;let r=D6(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=E6(t),r=D6(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=O6(E6(n)),o=[],s=[];for(let e of i)A6(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=j6(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=j6(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=M6(a,O6(t));for(let r=1;r<e.length;r++){let i=e[r],o=M6(a,O6(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function P6(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function F6(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function I6(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function L6(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function R6(){try{let e=l(c(d(import.meta.url)),`..`,`package.json`),t=JSON.parse(v(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const z6=R6(),B6=1;var V6=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function H6(e,t){return l(e,`${t}.lock`)}const U6=new Map;function W6(e){U6.set(e,(U6.get(e)??0)+1)}function G6(e){let t=U6.get(e);return t===void 0||t<=1?(U6.delete(e),!0):(U6.set(e,t-1),!1)}function K6(e,t){try{let n=JSON.parse(v(e,`utf-8`));return n&&typeof n==`object`&&L6(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function q6(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;g(n,{recursive:!0});let a=H6(n,t),o={pid:process.pid,hostname:p(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??z6},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!h(a))try{let e=_(a,`wx`,384);try{x(e,s)}finally{m(e)}return W6(a),J6({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=K6(a,i);if(e){let r=e.hostname===p();if(r&&e.pid===process.pid)return b(a,s,{encoding:`utf-8`,mode:384}),W6(a),J6({lockName:t,lockDir:n,lockPath:a});if(r&&I6(e.pid))throw new V6(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{y(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function J6(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>Q6({lockName:t,lockDir:n}),updatePort:e=>Y6({lockName:t,lockDir:n,port:e})}}function Y6(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=H6(n,t);if(!h(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(v(a,`utf-8`));if(!e||typeof e!=`object`||!L6(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==p())){o.port=r;try{b(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function X6(e){let{lockName:t,lockDir:n}=e,r=H6(n,t);if(!h(r))return null;let i;try{let e=JSON.parse(v(r,`utf-8`));if(!e||typeof e!=`object`||!L6(e.pid))return null;i=e}catch{return null}if(i.hostname!==p())return null;if(!I6(i.pid)){try{y(r)}catch{}return null}return i}function Z6(e){let{lockName:t,lockDir:n}=e,r=H6(n,t);if(!h(r))return{status:`absent`};let i;try{i=JSON.parse(v(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!L6(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==p())return{status:`stale`,lock:o};if(!I6(o.pid)){try{y(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function Q6(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=H6(n,t);if(G6(i)&&h(i))try{let e=JSON.parse(v(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==p())return;y(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var $6=class extends V6{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function e8(e,t){try{return q6({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof V6&&e.lockName===`server`?new $6(e.existing,e.lockPath):e}}function t8(e,t){Y6({lockName:`server`,lockDir:e,port:t})}function n8(e){return X6({lockName:`server`,lockDir:e})}function r8(e){Q6({lockName:`server`,lockDir:e})}export{mG as $,Fs as $a,SG as $i,u2 as $n,o4 as $r,vG as $t,qq as A,_l as Aa,l6 as Ai,uG as An,mn as Ao,n6 as Ar,B$ as At,P2 as B,Dl as Ba,h4 as Bi,Gq as Bn,R0 as Br,u3 as Bt,L$ as C,Gc as Ca,s4 as Ci,G0 as Cn,Wa as Co,g0 as Cr,n1 as Ct,I$ as D,yl as Da,$J as Di,E0 as Dn,cn as Do,u0 as Dr,F0 as Dt,S$ as E,Yc as Ea,ZQ as Ei,Q3 as En,vr as Eo,h0 as Er,P0 as Et,v4 as F,iu as Fa,bG as Fi,v0 as Fn,D as Fo,L0 as Fr,d1 as Ft,k2 as G,Sl as Ga,jG as Gi,Eq as Gn,n0 as Gr,x1 as Gt,M2 as H,tu as Ha,q2 as Hi,yq as Hn,A1 as Hr,$$ as Ht,N$ as I,ru as Ia,KG as Ii,y0 as In,pt as Io,H0 as Ir,s3 as It,dG as J,xl as Ja,s6 as Ji,l2 as Jn,Qq as Jr,b1 as Jt,O2 as K,Xl as Ka,EG as Ki,Oq as Kn,r0 as Kr,S1 as Kt,N2 as L,Ql as La,q4 as Li,S0 as Ln,ft as Lo,U0 as Lr,C0 as Lt,q$ as M,Wc as Ma,b$ as Mi,i1 as Mn,Lt as Mo,M0 as Mr,VG as Mt,Bq as N,Jc as Na,dq as Ni,y2 as Nn,Tt as No,A0 as Nr,o1 as Nt,x$ as O,bl as Oa,nq as Oi,n3 as On,un as Oo,d0 as Or,X$ as Ot,l4 as P,ll as Pa,Rq as Pi,C2 as Pn,O as Po,V0 as Pr,s1 as Pt,fG as Q,El as Qa,p4 as Qi,X0 as Qn,H2 as Qr,_G as Qt,L2 as R,qc as Ra,kq as Ri,_0 as Rn,z0 as Rr,T0 as Rt,C$ as S,I as Sa,o3 as Si,xG as Sn,fa as So,m1 as Sr,zG as St,R$ as T,Cl as Ta,r$ as Ti,X3 as Tn,ai as To,m0 as Tr,N0 as Tt,D2 as U,Kl as Ua,OG as Ui,wq as Un,j1 as Ur,C1 as Ut,F2 as V,Pl as Va,R4 as Vi,_q as Vn,M1 as Vr,FG as Vt,A2 as W,Ul as Wa,f3 as Wi,Cq as Wn,k1 as Wr,v1 as Wt,gG as X,Ml as Xa,YG as Xi,o2 as Xn,c1 as Xr,h1 as Xt,cG as Y,Fl as Ya,oK as Yi,c2 as Yn,Zq as Yr,y1 as Yt,hG as Z,Tl as Za,f$ as Zi,s2 as Zn,U2 as Zr,_1 as Zt,p6 as _,sK as _a,e3 as _i,Q1 as _n,Zs as _o,e2 as _r,W$ as _t,q6 as a,wG as aa,m6 as ai,N1 as an,j as ao,$0 as ar,W1 as at,D1 as b,db as ba,W3 as bi,i0 as bn,Uo as bo,R1 as br,RG as bt,L6 as c,$4 as ca,N6 as ci,B4 as cn,tc as co,W0 as cr,U1 as ct,Z6 as d,kG as da,S3 as di,BG as dn,A as do,m2 as dr,t3 as dt,t4 as ea,Yq as ei,yG as en,cc as eo,T2 as er,pG as et,n8 as f,d4 as fa,b3 as fi,sG as fn,N as fo,h2 as fr,IG as ft,t8 as g,YQ as ga,v6 as gi,Xq as gn,k as go,p2 as gr,G$ as gt,Y6 as h,c4 as ha,Q2 as hi,Kq as hn,rc as ho,f2 as hr,t0 as ht,$6 as i,y6 as ia,lG as ii,P1 as in,M as io,Q0 as ir,H$ as it,J$ as j,gl as ja,jq as ji,r1 as jn,on as jo,J0 as jr,_$ as jt,F$ as k,vl as ka,g6 as ki,PG as kn,fn as ko,f0 as kr,z$ as kt,H6 as l,oq as la,u6 as li,JG as ln,F as lo,e6 as lr,WG as lt,r8 as m,F6 as ma,z4 as mi,J1 as mn,Mc as mo,O0 as mr,e0 as mt,z6 as n,p$ as na,C6 as ni,PQ as nn,Bs as no,r2 as nr,Uq as nt,e8 as o,V3 as oa,c6 as oi,GG as on,kc as oo,_2 as or,G1 as ot,Q6 as p,aK as pa,J4 as pi,X1 as pn,lc as po,g2 as pr,p1 as pt,E2 as q,ul as qa,k0 as qi,n2 as qn,UG as qr,$q as qt,B6 as r,T6 as ra,w6 as ri,I1 as rn,Hs as ro,i2 as rr,V$ as rt,I6 as s,J2 as sa,q0 as si,u1 as sn,$s as so,v2 as sr,H1 as st,V6 as t,f4 as ta,Lq as ti,qG as tn,P as to,d2 as tr,Vq as tt,X6 as u,cq as ua,sZ as ui,XG as un,Ys as uo,D0 as ur,ZG as ut,LG as v,lq as va,d3 as vi,$1 as vn,Ws as vo,t2 as vr,K1 as vt,w$ as w,nu as wa,NQ as wi,Y3 as wn,Ga as wo,p0 as wr,V1 as wt,O1 as x,tp as xa,P6 as xi,a0 as xn,Vo as xo,eJ as xr,HG as xt,j$ as y,Z2 as ya,t6 as yi,l1 as yn,ys as yo,Z0 as yr,q1 as yt,I2 as z,Kc as za,NG as zi,S2 as zn,B0 as zr,L1 as zt};
453
+ //# sourceMappingURL=server-lock-ltHt39S2-BMGVBKsW.mjs.map