@inkeep/open-knowledge 0.71.2-beta.1 → 0.71.2-beta.2

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 (33) hide show
  1. package/dist/cli.mjs +54 -54
  2. package/dist/constants-CDtlxNjm.mjs +1 -0
  3. package/dist/dist-9e6NmrQK.mjs +2097 -0
  4. package/dist/{dist-B4TxkELG.mjs → dist-DaZTzrgH.mjs} +1 -1
  5. package/dist/index.d.mts +1 -0
  6. package/dist/index.mjs +1 -1
  7. package/dist/{init-Ex7PlJbP.mjs → init-BS8pi6aE.mjs} +7 -7
  8. package/dist/init-BqJ0_3DH.mjs +1 -0
  9. package/dist/{launch-json-removal-Dgdu9kcP.mjs → launch-json-removal-iYhWhAkh.mjs} +1 -1
  10. package/dist/loader-BhG6F89Z.mjs +1 -0
  11. package/dist/{loader-Da_kR2vs.mjs → loader-CEM2DZT5.mjs} +1 -1
  12. package/dist/{md-manager-BGnqyqi1-BKxqDqfk.mjs → md-manager-BGnqyqi1-C0-0a_4T.mjs} +92 -92
  13. package/dist/{open-browser-DqgRF6In.mjs → open-browser-DOj8e8TD.mjs} +1 -1
  14. package/dist/parse-worker.mjs +1 -1
  15. package/dist/{preview-BOTcB8PJ.mjs → preview-BqT0WT0X.mjs} +1 -1
  16. package/dist/preview-C8mnnE3O.mjs +1 -0
  17. package/dist/{registry-probes-CKT5zpL7.mjs → registry-probes-C76k8nXQ.mjs} +2 -2
  18. package/dist/{removal-file-path-xOV2YbGI.mjs → removal-file-path-D62fA-37.mjs} +1 -1
  19. package/dist/{repair-launch-json-DCb8j4os.mjs → repair-launch-json-D05O991w.mjs} +1 -1
  20. package/dist/{repair-mcp-configs-Cvxc0PSE.mjs → repair-mcp-configs-CHfth2Jm.mjs} +1 -1
  21. package/dist/src-B_zXHjLH.mjs +1 -0
  22. package/dist/src-DmJzOo1w.mjs +11 -0
  23. package/dist/{start-C9MnFVTQ.mjs → start-BYKbGiT_.mjs} +3 -3
  24. package/dist/start-CvIALlUf.mjs +1 -0
  25. package/package.json +5 -5
  26. package/dist/constants-CN-OP4lK.mjs +0 -1
  27. package/dist/dist-CjH-Sf5k.mjs +0 -2096
  28. package/dist/init-DkoBLsnN.mjs +0 -1
  29. package/dist/loader-Ciy1lUFM.mjs +0 -1
  30. package/dist/preview-A8NnvAZh.mjs +0 -1
  31. package/dist/src--hXB6oPw.mjs +0 -11
  32. package/dist/src-CemYwu_V.mjs +0 -1
  33. package/dist/start-B-ZEfbkW.mjs +0 -1
@@ -1 +1 @@
1
- import{Ao as e,Sa as t,Un as n,au as r,bo as i,gn as a,ms as o,rl as s,vl as c,xn as l,zt as u}from"./md-manager-BGnqyqi1-BKxqDqfk.mjs";import{$ as d,$a as f,$i as p,$n as m,$r as h,$t as g,A as _,Aa as v,Ai as y,An as b,Ao as x,Ar as S,At as C,B as w,Ba as T,Bi as E,Bn as D,Bo as O,Br as k,Bt as A,C as j,Ca as M,Ci as N,Cn as P,Cr as F,Ct as I,D as L,Da as R,Di as z,Dn as B,Dr as V,Dt as H,E as U,Ea as W,Ei as G,En as K,Er as q,Et as J,F as Y,Fa as X,Fi as Z,Fn as Q,Fo as $,Fr as ee,Ft as te,G as ne,Ga as re,Gi as ie,Gn as ae,Gr as oe,Gt as se,H as ce,Ha as le,Hi as ue,Hn as de,Ho as fe,Hr as pe,Ht as me,I as he,Ia as ge,Ii as _e,In as ve,Io as ye,Ir as be,It as xe,J as Se,Ja as Ce,Ji as we,Jn as Te,Jr as Ee,Jt as De,K as Oe,Ka as ke,Ki as Ae,Kn as je,Kr as Me,Kt as Ne,L as Pe,La as Fe,Li as Ie,Ln as Le,Lo as Re,Lr as ze,Lt as Be,M as Ve,Ma as He,Mi as Ue,Mn as We,Mr as Ge,Mt as Ke,N as qe,Na as Je,Ni as Ye,Nn as Xe,Nr as Ze,Nt as Qe,O as $e,Oa as et,Oi as tt,On as nt,Or as rt,Ot as it,P as at,Pa as ot,Pi as st,Pn as ct,Po as lt,Pr as ut,Pt as dt,Q as ft,Qa as pt,Qi as mt,Qn as ht,Qr as gt,Qt as _t,R as vt,Ra as yt,Ri as bt,Rn as xt,Ro as St,Rr as Ct,Rt as wt,S as Tt,Sa as Et,Si as Dt,Sn as Ot,Sr as kt,St as At,T as jt,Ta as Mt,Ti as Nt,Tn as Pt,Tr as Ft,Tt as It,U as Lt,Ua as Rt,Ui as zt,Un as Bt,Ur as Vt,Ut as Ht,V as Ut,Va as Wt,Vi as Gt,Vn as Kt,Vo as qt,Vr as Jt,Vt as Yt,W as Xt,Wa as Zt,Wi as Qt,Wn as $t,Wr as en,Wt as tn,X as nn,Xa as rn,Xi as an,Xn as on,Xr as sn,Xt as cn,Y as ln,Ya as un,Yi as dn,Yn as fn,Yr as pn,Yt as mn,Z as hn,Za as gn,Zi as _n,Zn as vn,Zr as yn,Zt as bn,_ as xn,_a as Sn,_i as Cn,_n as wn,_r as Tn,_t as En,a as Dn,aa as On,ai as kn,an as An,ao as jn,ar as Mn,at as Nn,b as Pn,ba as Fn,bi as In,bn as Ln,br as Rn,bt as zn,c as Bn,ca as Vn,ci as Hn,cn as Un,cr as Wn,ct as Gn,d as Kn,da as qn,di as Jn,dn as Yn,dr as Xn,dt as Zn,ea as Qn,ei as $n,en as er,eo as tr,er as nr,et as rr,f as ir,fa as ar,fi as or,fn as sr,fr as cr,ft as lr,g as ur,ga as dr,gi as fr,gn as pr,gr as mr,gt as hr,h as gr,ha as _r,hi as vr,hn as yr,hr as br,ht as xr,i as Sr,ia as Cr,ii as wr,in as Tr,io as Er,ir as Dr,it as Or,j as kr,ja as Ar,ji as jr,jn as Mr,jr as Nr,jt as Pr,k as Fr,ka as Ir,ki as Lr,kn as Rr,ko as zr,kr as Br,kt as Vr,l as Hr,la as Ur,li as Wr,ln as Gr,lr as Kr,lt as qr,m as Jr,ma as Yr,mi as Xr,mn as Zr,mr as Qr,mt as $r,n as ei,na as ti,ni,nn as ri,no as ii,nr as ai,nt as oi,o as si,oa as ci,oi as li,on as ui,oo as di,or as fi,ot as pi,p as mi,pa as hi,pi as gi,pn as _i,pr as vi,pt as yi,q as bi,qa as xi,qi as Si,qn as Ci,qr as wi,qt as Ti,r as Ei,ra as Di,ri as Oi,rn as ki,ro as Ai,rr as ji,rt as Mi,s as Ni,sa as Pi,si as Fi,sn as Ii,sr as Li,st as Ri,t as zi,ta as Bi,ti as Vi,tn as Hi,to as Ui,tr as Wi,tt as Gi,u as Ki,ua as qi,ui as Ji,un as Yi,ur as Xi,ut as Zi,v as Qi,va as $i,vi as ea,vn as ta,vr as na,vt as ra,w as ia,wa as aa,wi as oa,wn as sa,wr as ca,wt as la,x as ua,xa as da,xi as fa,xn as pa,xr as ma,xt as ha,y as ga,ya as _a,yi as va,yn as ya,yr as ba,yt as xa,z as Sa,za as Ca,zi as wa,zn as Ta,zo as Ea,zr as Da,zt as Oa}from"./dist-CjH-Sf5k.mjs";export{zi as AGENT_ID_MAX_LEN,ei as AGENT_ID_RE,Ei as AGENT_WRITE_ORIGIN,Sr as AcpPermissionStore,Dn as AcpRegistry,si as AcpThreadManager,Ni as AgentFocusBroadcaster,Bn as AgentPresenceBroadcaster,Hr as AgentSessionCapacityError,Ki as AgentSessionManager,Kn as AutoStartDisabledError,ir as BUNDLE_IDS,mi as BUNDLE_SCOPE,Jr as BUNDLE_SKILL_NAME,gr as BacklinkIndex,ur as CC1Broadcaster,s as CC1_CONTRACT_VERSION,xn as CONFIG_FILENAME,Qi as CONFLICT_MARKER_RE,ga as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pn as ConfigSchema,ua as DEFAULT_CHECKPOINT_RETENTION,Tt as DEFAULT_EMBEDDINGS_DIMENSIONS,j as DEFAULT_PACK_ID,ia as DocumentDurabilityState,jt as DocumentDurabilityStateError,U as EMBEDDINGS_API_KEY_ENV,L as EPHEMERAL_PROJECT_DIR_PREFIX,$e as ExposureConsentError,Fr as FEATURED_AGENT_IDS,_ as FILE_SYSTEM_WRITER,kr as FILE_WATCHER_ORIGIN,Ve as FileEmbeddingsBackend,qe as GIT_PREFLIGHT_FAIL_SPAN_NAME,at as GIT_UPSTREAM_WRITER,zr as GitDirAccessError,Y as GitNotAvailableError,he as GitTooOldError,Pe as HOCUSPOCUS_AUTH_REJECTION_REASONS,vt as HocuspocusAuthRejection,Sa as HocuspocusAuthTokenSchema,w as HomeProjectRootError,Ut as INSTALLED_AGENTS_SCHEMES,ce as JSON_SCHEMA_DIALECT_2020_12,u as LINEAGE_EPOCH_KEY,Lt as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Xt as MANAGED_RENAME_ORIGIN,ne as MAX_ACP_THREADS,Oe as MAX_AGENT_SESSIONS,bi as MCP_CONNECTION_ID_HEADER,r as MCP_SERVER_NAME,Se as MIN_EVICTABLE_IDLE_MS,ln as MIN_GIT_VERSION,nn as MISSING_OK_CONFIG_MESSAGE,x as MalformedGitPointerError,hn as McpLogger,ft as MissingOkConfigError,d as OBSERVER_SYNC_ORIGIN,rr as OK_OKIGNORE_TEMPLATE,Gi as ONBOARDING_BUNDLE_IDS,a as ORPHAN_MODES,l as PROTOCOL_VERSION,lt as PinoLogger,oi as ProcessLockCollisionError,Mi as ProjectGitInitError,Or as ROLLBACK_ORIGIN,Nn as ROOT_GITIGNORE_TEMPLATE,pi as RUNTIME_VERSION,Ri as SERVICE_WRITER,Gn as SKILL_INSTALL_EVENTS_FILE_REL,n as SKILL_STATE_TARGETS,qr as STARTER_FOLDER_FRONTMATTER_FILENAME,Zi as STARTER_PACKS,Zn as STARTER_PACK_IDS,lr as STATE_MANIFEST_FILENAME,yi as STATE_SCHEMA_VERSION,c as SYSTEM_DOC_NAME,$r as SeedPrerequisiteError,xr as SeedRootDirError,hr as ServerLockCollisionError,En as SingleFileNotAFileError,ra as SingleFileNotFoundError,xa as SingleFileNotMarkdownError,zn as SingleFileProjectOverrideError,ha as StateManifestError,At as TagIndex,I as USER_GLOBAL_BUNDLE_IDS,la as __getShowAllWalkStatsForTesting,It as __resetShowAllWalkStatsForTesting,J as acquireProcessLock,H as acquireServerLock,it as applyAgentMarkdownWrite,Vr as applyExternalChange,C as applySeed,Pr as assertCompatibleStateManifest,Ke as assertGitAvailable,Qe as assertNeverDiskEvent,dt as assertNotHomeProjectRoot,te as attachAcpThreadSocket,xe as attachCollabClientCounter,Be as attachIdleShutdown,wt as bootServer,Oa as buildAndOpenSkill,A as buildConfigYmlContent,Yt as buildExecResult,me as buildIngressPolicy,Ht as buildOkMcpStdioCommand,tn as buildSkillZip,se as buildStarterFolderFrontmatterYaml,Ne as buildWipTree,Ti as bundleSkillMdPath,De as canonicalProjectKey,mn as canonicalizeForCompare,cn as classifyEvents,bn as classifyFsPath,_t as clearAllEmbeddingsKeys,g as coercePackId,er as collectServerHostSnapshot,t as colorFromSeed,Hi as commitUpstreamImport,ri as commitWip,ki as commitWipFromTree,Tr as compareSemver,An as composeEffectiveLinterConfig,ui as composeFrontmatterSchemasConfig,Ii as containsConflictMarkers,Un as contentHash,Gr as contributorCount,Yi as countShadowObjects,Yn as countStaleAgentWipRefs,sr as countWipRefs,_i as createApiExtension,Zr as createAssetServeMiddleware,yr as createCollaborationHost,pr as createContentFilter,wn as createContentFilterAsync,ta as createEmbeddingsSecretStore,ya as createEphemeralProjectDir,Ln as createExternalChangeHandler,pa as createFileLogger,Ot as createLiveDerivedIndexExtension,P as createMcpHttpHandler,sa as createOsProbe,Pt as createPersistenceExtension,K as createServer,B as createServerObserverExtension,nt as createServerProbeResolver,Rr as createStreamingErrorWriter,$ as createTestLogger,b as describeStoredEmbeddingsKey,Mr as detectClaudeDesktopPresence,We as detectGit,Xe as detectProjectShape,ct as detectUserSkillHosts,Q as discoverLockDirs,ve as discoverMarkdownlintConfig,Le as emitPreflightFailureSpan,xt as encodeDocName,Ta as encodeFolderRoute,D as encodeSkillRoute,Kt as ensureProjectGit,de as errorResponse,Bt as evictStaleTrackerEntries,$t as extractHeadings,ae as extractOkBinaryPath,je as extractWikiLinksFromMarkdown,Ci as fallbackPaths,Te as findEnclosingGitRoot,fn as findEnclosingProjectRoot,on as findNativeMarkdownlintFile,vn as flushFileLogger,ht as formatAuditBrokenLinkSuppressionLine,m as formatAuthRejectionWire,nr as formatContributorsFrom,Wi as formatPackRationale,ai as gcCheckpointRefs,ji as getCurrentMcpLogger,Dr as getIngressContext,Mn as getLocalDir,fi as getLogFilePath,ye as getLogger,Li as getLogsDir,Wn as getMachineId,Kr as getMeter,Xi as getMetrics,Xn as getTracer,cr as handleCollabSocketError,vi as handleSpawnCursor,Qr as hasForwardingHeaders,br as hasGcLogLatch,i as iconFromClientName,mr as incrementCollabSocketFilteredError,Tn as incrementServerObserverFire,na as initContent,ba as initShadowRepo,Rn as initTelemetry,ma as initToleranceTelemetryWriter,kt as installJsonSchemaDialect,F as installPrettyZodErrors,Re as installTestLoggers,ca as installUserSkill,Ft as isAllowedApiOrigin,q as isAllowedWorkspaceHostHeader,V as isConfigDoc,rt as isHocuspocusAuthRejectionReason,Br as isHomeDir,S as isHostAdmitted,Nr as isKnownPackId,Ge as isLinkIndexExcludedDoc,Ze as isLoopbackAddress,ut as isManagedArtifactDoc,ee as isOriginAdmitted,e as isOrphanMode,be as isPairedWriteOrigin,ze as isPathWithinDir,Ct as isPeerAdmitted,Da as isProcessAlive,k as isProjectRoot,Jt as isReservedForUserTree,pe as isSelfWrite,Vt as isSystemDoc,en as isToleranceTelemetryEnabled,oe as isValidLockPid,Me as lastKnownHash,wi as listRescueCheckpoints,Ee as listStarterPacks,pn as loadCustomAgents,sn as loadPrincipal,yn as lockAdvertisesUi,gt as lockBaseUrl,h as lockFilePath,St as loggerFactory,$n as loginShapedUserinfoUser,Ea as logsCurrentPath,O as logsPreviousPath,Vi as makeLazyEmbeddingsKeyStore,ni as markServerLockDraining,Oi as mountMcpAndApi,wr as normalizeFsPath,kn as observeReadiness,li as originGitHubHost,Fi as packageVersionMajorMinor,Hn as parseAuthRejectionWire,Wr as parseGitVersion,Ji as parseHocuspocusAuthToken,Jn as parseKeepaliveConnectionId,or as pathToDocName,gi as planSeed,Xr as prepareSingleFileOpen,vr as processCommand,fr as processUsage,Cn as readAllTargets,ea as readBundleDecision,va as readOwnNativeRules,In as readProcessLock,fa as readProcessLockDetailed,Dt as readProjectHeadState,N as readProjectLocalSemanticConfig,oa as readServerLock,Nt as readServerPackageVersion,G as readSkillInstallStateSnapshot,z as readStateManifest,tt as readTargetRecordedAt,Lr as readTargetVersion,y as reconcile,jr as recordContributor,Ue as recordSkillInstallEvent,Ye as redactShareSubprocessStderr,st as registerAllTools,Z as registerWrite,_e as releaseProcessLock,Ie as releaseServerLock,bt as removeLastKnownHash,wa as removeProjectSkillGitignoreBlock,E as reportSkillInstall,Gt as resetMetrics,ue as resolveBuiltinSkillHosts,o as resolveBundleEnabled,zt as resolveBundledSkillDir,Qt as resolveContentDir,ie as resolveCursorBinaryDefault,Ae as resolveCursorSpawnInvocation,Si as resolveEffectiveLinterConfig,we as resolveEmbeddingsCredential,dn as resolveGitHubAccountFromUrl,an as resolveLockDir,_n as resolveNativeConfigForDoc,mt as resolveNativeMarkdownlintConfig,p as resolvePack,Qn as resolvePackageVersion,Bi as resolveSkillInstallReportSettings,ti as resolveUiInfo,Di as restoreContributors,Cr as restoreLifecycleFromConflictsJson,On as rewriteMarkdownLinksForDocumentRename,ci as rewriteWikiLinksForDocumentRename,Pi as runAuthReposSubprocess,Vn as runAuthStatusSubprocess,Ur as runCloneSubprocess,qi as runDeviceFlowSubprocess,qn as runWithMcpLogger,ar as safeContentPath,hi as safeSubdir,Yr as safetyCheckpoint,_r as sameGitHubLogin,dr as sanitizeClientName,Sn as saveInMemoryCheckpoint,$i as saveVersion,_a as seedBasenameIndex,Fn as seedEphemeralProjectDir,da as serializeError,Et as setActiveSpanAttributes,M as setupServerObservers,aa as shadowGit,Mt as shutdownTelemetry,qt as spansCurrentPath,fe as spansPreviousPath,W as spawnDetached,R as splitMarkdownBlocks,et as startWatcher,Ir as streamingProblemEvent,v as swapContributors,Ar as teardownToleranceTelemetryWriter,He as toBroadcasterKey,Je as tracedAppendFileSync,ot as tracedLinkSync,X as tracedMkdir,ge as tracedMkdirSync,Fe as tracedRename,yt as tracedRenameSync,Ca as tracedRmSync,T as tracedRmdirSync,Wt as tracedUnlinkSync,le as tracedWriteFile,Rt as tracedWriteFileSync,Zt as trustSystemCertificates,re as updateLastKnownHash,ke as updateProcessLockPort,xi as updateServerLockPort,Ce as validateAgentId,un as validateCloneInputs,rn as validateSkillZip,gn as waitForServerLockDrain,pt as withHiddenWindowsConsole,f as withSpan,tr as withSpanSync,Ui as writeBundleDecision,ii as writeMarkdownlintRule,Ai as writeRootGitignoreForNewRepo,Er as writeStateManifest,jn as writeTargetVersion,di as writeTracker};
1
+ import{Ao as e,Sa as t,Un as n,bo as r,gn as i,il as a,ms as o,ou as s,xn as c,yl as l,zt as u}from"./md-manager-BGnqyqi1-C0-0a_4T.mjs";import{$ as d,$a as f,$i as p,$n as m,$r as h,$t as g,A as _,Aa as v,Ai as y,An as b,Ao as x,Ar as S,At as C,B as w,Ba as T,Bi as E,Bn as D,Bo as O,Br as k,Bt as A,C as j,Ca as M,Ci as N,Cn as P,Cr as F,Ct as I,D as L,Da as R,Di as z,Dn as B,Dr as V,Dt as H,E as U,Ea as W,Ei as G,En as K,Er as q,Et as J,F as Y,Fa as X,Fi as Z,Fn as Q,Fo as $,Fr as ee,Ft as te,G as ne,Ga as re,Gi as ie,Gn as ae,Gr as oe,Gt as se,H as ce,Ha as le,Hi as ue,Hn as de,Ho as fe,Hr as pe,Ht as me,I as he,Ia as ge,Ii as _e,In as ve,Io as ye,Ir as be,It as xe,J as Se,Ja as Ce,Ji as we,Jn as Te,Jr as Ee,Jt as De,K as Oe,Ka as ke,Ki as Ae,Kn as je,Kr as Me,Kt as Ne,L as Pe,La as Fe,Li as Ie,Ln as Le,Lo as Re,Lr as ze,Lt as Be,M as Ve,Ma as He,Mi as Ue,Mn as We,Mr as Ge,Mt as Ke,N as qe,Na as Je,Ni as Ye,Nn as Xe,Nr as Ze,Nt as Qe,O as $e,Oa as et,Oi as tt,On as nt,Or as rt,Ot as it,P as at,Pa as ot,Pi as st,Pn as ct,Po as lt,Pr as ut,Pt as dt,Q as ft,Qa as pt,Qi as mt,Qn as ht,Qr as gt,Qt as _t,R as vt,Ra as yt,Ri as bt,Rn as xt,Ro as St,Rr as Ct,Rt as wt,S as Tt,Sa as Et,Si as Dt,Sn as Ot,Sr as kt,St as At,T as jt,Ta as Mt,Ti as Nt,Tn as Pt,Tr as Ft,Tt as It,U as Lt,Ua as Rt,Ui as zt,Un as Bt,Ur as Vt,Ut as Ht,V as Ut,Va as Wt,Vi as Gt,Vn as Kt,Vo as qt,Vr as Jt,Vt as Yt,W as Xt,Wa as Zt,Wi as Qt,Wn as $t,Wr as en,Wt as tn,X as nn,Xa as rn,Xi as an,Xn as on,Xr as sn,Xt as cn,Y as ln,Ya as un,Yi as dn,Yn as fn,Yr as pn,Yt as mn,Z as hn,Za as gn,Zi as _n,Zn as vn,Zr as yn,Zt as bn,_ as xn,_a as Sn,_i as Cn,_n as wn,_r as Tn,_t as En,a as Dn,aa as On,ai as kn,an as An,ao as jn,ar as Mn,at as Nn,b as Pn,ba as Fn,bi as In,bn as Ln,br as Rn,bt as zn,c as Bn,ca as Vn,ci as Hn,cn as Un,cr as Wn,ct as Gn,d as Kn,da as qn,di as Jn,dn as Yn,dr as Xn,dt as Zn,ea as Qn,ei as $n,en as er,eo as tr,er as nr,et as rr,f as ir,fa as ar,fi as or,fn as sr,fr as cr,ft as lr,g as ur,ga as dr,gi as fr,gn as pr,gr as mr,gt as hr,h as gr,ha as _r,hi as vr,hn as yr,hr as br,ht as xr,i as Sr,ia as Cr,ii as wr,in as Tr,io as Er,ir as Dr,it as Or,j as kr,ja as Ar,ji as jr,jn as Mr,jr as Nr,jt as Pr,k as Fr,ka as Ir,ki as Lr,kn as Rr,ko as zr,kr as Br,kt as Vr,l as Hr,la as Ur,li as Wr,ln as Gr,lr as Kr,lt as qr,m as Jr,ma as Yr,mi as Xr,mn as Zr,mr as Qr,mt as $r,n as ei,na as ti,ni,nn as ri,no as ii,nr as ai,nt as oi,o as si,oa as ci,oi as li,on as ui,oo as di,or as fi,ot as pi,p as mi,pa as hi,pi as gi,pn as _i,pr as vi,pt as yi,q as bi,qa as xi,qi as Si,qn as Ci,qr as wi,qt as Ti,r as Ei,ra as Di,ri as Oi,rn as ki,ro as Ai,rr as ji,rt as Mi,s as Ni,sa as Pi,si as Fi,sn as Ii,sr as Li,st as Ri,t as zi,ta as Bi,ti as Vi,tn as Hi,to as Ui,tr as Wi,tt as Gi,u as Ki,ua as qi,ui as Ji,un as Yi,ur as Xi,ut as Zi,v as Qi,va as $i,vi as ea,vn as ta,vr as na,vt as ra,w as ia,wa as aa,wi as oa,wn as sa,wr as ca,wt as la,x as ua,xa as da,xi as fa,xn as pa,xr as ma,xt as ha,y as ga,ya as _a,yi as va,yn as ya,yr as ba,yt as xa,z as Sa,za as Ca,zi as wa,zn as Ta,zo as Ea,zr as Da,zt as Oa}from"./dist-9e6NmrQK.mjs";export{zi as AGENT_ID_MAX_LEN,ei as AGENT_ID_RE,Ei as AGENT_WRITE_ORIGIN,Sr as AcpPermissionStore,Dn as AcpRegistry,si as AcpThreadManager,Ni as AgentFocusBroadcaster,Bn as AgentPresenceBroadcaster,Hr as AgentSessionCapacityError,Ki as AgentSessionManager,Kn as AutoStartDisabledError,ir as BUNDLE_IDS,mi as BUNDLE_SCOPE,Jr as BUNDLE_SKILL_NAME,gr as BacklinkIndex,ur as CC1Broadcaster,a as CC1_CONTRACT_VERSION,xn as CONFIG_FILENAME,Qi as CONFLICT_MARKER_RE,ga as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pn as ConfigSchema,ua as DEFAULT_CHECKPOINT_RETENTION,Tt as DEFAULT_EMBEDDINGS_DIMENSIONS,j as DEFAULT_PACK_ID,ia as DocumentDurabilityState,jt as DocumentDurabilityStateError,U as EMBEDDINGS_API_KEY_ENV,L as EPHEMERAL_PROJECT_DIR_PREFIX,$e as ExposureConsentError,Fr as FEATURED_AGENT_IDS,_ as FILE_SYSTEM_WRITER,kr as FILE_WATCHER_ORIGIN,Ve as FileEmbeddingsBackend,qe as GIT_PREFLIGHT_FAIL_SPAN_NAME,at as GIT_UPSTREAM_WRITER,zr as GitDirAccessError,Y as GitNotAvailableError,he as GitTooOldError,Pe as HOCUSPOCUS_AUTH_REJECTION_REASONS,vt as HocuspocusAuthRejection,Sa as HocuspocusAuthTokenSchema,w as HomeProjectRootError,Ut as INSTALLED_AGENTS_SCHEMES,ce as JSON_SCHEMA_DIALECT_2020_12,u as LINEAGE_EPOCH_KEY,Lt as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Xt as MANAGED_RENAME_ORIGIN,ne as MAX_ACP_THREADS,Oe as MAX_AGENT_SESSIONS,bi as MCP_CONNECTION_ID_HEADER,s as MCP_SERVER_NAME,Se as MIN_EVICTABLE_IDLE_MS,ln as MIN_GIT_VERSION,nn as MISSING_OK_CONFIG_MESSAGE,x as MalformedGitPointerError,hn as McpLogger,ft as MissingOkConfigError,d as OBSERVER_SYNC_ORIGIN,rr as OK_OKIGNORE_TEMPLATE,Gi as ONBOARDING_BUNDLE_IDS,i as ORPHAN_MODES,c as PROTOCOL_VERSION,lt as PinoLogger,oi as ProcessLockCollisionError,Mi as ProjectGitInitError,Or as ROLLBACK_ORIGIN,Nn as ROOT_GITIGNORE_TEMPLATE,pi as RUNTIME_VERSION,Ri as SERVICE_WRITER,Gn as SKILL_INSTALL_EVENTS_FILE_REL,n as SKILL_STATE_TARGETS,qr as STARTER_FOLDER_FRONTMATTER_FILENAME,Zi as STARTER_PACKS,Zn as STARTER_PACK_IDS,lr as STATE_MANIFEST_FILENAME,yi as STATE_SCHEMA_VERSION,l as SYSTEM_DOC_NAME,$r as SeedPrerequisiteError,xr as SeedRootDirError,hr as ServerLockCollisionError,En as SingleFileNotAFileError,ra as SingleFileNotFoundError,xa as SingleFileNotMarkdownError,zn as SingleFileProjectOverrideError,ha as StateManifestError,At as TagIndex,I as USER_GLOBAL_BUNDLE_IDS,la as __getShowAllWalkStatsForTesting,It as __resetShowAllWalkStatsForTesting,J as acquireProcessLock,H as acquireServerLock,it as applyAgentMarkdownWrite,Vr as applyExternalChange,C as applySeed,Pr as assertCompatibleStateManifest,Ke as assertGitAvailable,Qe as assertNeverDiskEvent,dt as assertNotHomeProjectRoot,te as attachAcpThreadSocket,xe as attachCollabClientCounter,Be as attachIdleShutdown,wt as bootServer,Oa as buildAndOpenSkill,A as buildConfigYmlContent,Yt as buildExecResult,me as buildIngressPolicy,Ht as buildOkMcpStdioCommand,tn as buildSkillZip,se as buildStarterFolderFrontmatterYaml,Ne as buildWipTree,Ti as bundleSkillMdPath,De as canonicalProjectKey,mn as canonicalizeForCompare,cn as classifyEvents,bn as classifyFsPath,_t as clearAllEmbeddingsKeys,g as coercePackId,er as collectServerHostSnapshot,t as colorFromSeed,Hi as commitUpstreamImport,ri as commitWip,ki as commitWipFromTree,Tr as compareSemver,An as composeEffectiveLinterConfig,ui as composeFrontmatterSchemasConfig,Ii as containsConflictMarkers,Un as contentHash,Gr as contributorCount,Yi as countShadowObjects,Yn as countStaleAgentWipRefs,sr as countWipRefs,_i as createApiExtension,Zr as createAssetServeMiddleware,yr as createCollaborationHost,pr as createContentFilter,wn as createContentFilterAsync,ta as createEmbeddingsSecretStore,ya as createEphemeralProjectDir,Ln as createExternalChangeHandler,pa as createFileLogger,Ot as createLiveDerivedIndexExtension,P as createMcpHttpHandler,sa as createOsProbe,Pt as createPersistenceExtension,K as createServer,B as createServerObserverExtension,nt as createServerProbeResolver,Rr as createStreamingErrorWriter,$ as createTestLogger,b as describeStoredEmbeddingsKey,Mr as detectClaudeDesktopPresence,We as detectGit,Xe as detectProjectShape,ct as detectUserSkillHosts,Q as discoverLockDirs,ve as discoverMarkdownlintConfig,Le as emitPreflightFailureSpan,xt as encodeDocName,Ta as encodeFolderRoute,D as encodeSkillRoute,Kt as ensureProjectGit,de as errorResponse,Bt as evictStaleTrackerEntries,$t as extractHeadings,ae as extractOkBinaryPath,je as extractWikiLinksFromMarkdown,Ci as fallbackPaths,Te as findEnclosingGitRoot,fn as findEnclosingProjectRoot,on as findNativeMarkdownlintFile,vn as flushFileLogger,ht as formatAuditBrokenLinkSuppressionLine,m as formatAuthRejectionWire,nr as formatContributorsFrom,Wi as formatPackRationale,ai as gcCheckpointRefs,ji as getCurrentMcpLogger,Dr as getIngressContext,Mn as getLocalDir,fi as getLogFilePath,ye as getLogger,Li as getLogsDir,Wn as getMachineId,Kr as getMeter,Xi as getMetrics,Xn as getTracer,cr as handleCollabSocketError,vi as handleSpawnCursor,Qr as hasForwardingHeaders,br as hasGcLogLatch,r as iconFromClientName,mr as incrementCollabSocketFilteredError,Tn as incrementServerObserverFire,na as initContent,ba as initShadowRepo,Rn as initTelemetry,ma as initToleranceTelemetryWriter,kt as installJsonSchemaDialect,F as installPrettyZodErrors,Re as installTestLoggers,ca as installUserSkill,Ft as isAllowedApiOrigin,q as isAllowedWorkspaceHostHeader,V as isConfigDoc,rt as isHocuspocusAuthRejectionReason,Br as isHomeDir,S as isHostAdmitted,Nr as isKnownPackId,Ge as isLinkIndexExcludedDoc,Ze as isLoopbackAddress,ut as isManagedArtifactDoc,ee as isOriginAdmitted,e as isOrphanMode,be as isPairedWriteOrigin,ze as isPathWithinDir,Ct as isPeerAdmitted,Da as isProcessAlive,k as isProjectRoot,Jt as isReservedForUserTree,pe as isSelfWrite,Vt as isSystemDoc,en as isToleranceTelemetryEnabled,oe as isValidLockPid,Me as lastKnownHash,wi as listRescueCheckpoints,Ee as listStarterPacks,pn as loadCustomAgents,sn as loadPrincipal,yn as lockAdvertisesUi,gt as lockBaseUrl,h as lockFilePath,St as loggerFactory,$n as loginShapedUserinfoUser,Ea as logsCurrentPath,O as logsPreviousPath,Vi as makeLazyEmbeddingsKeyStore,ni as markServerLockDraining,Oi as mountMcpAndApi,wr as normalizeFsPath,kn as observeReadiness,li as originGitHubHost,Fi as packageVersionMajorMinor,Hn as parseAuthRejectionWire,Wr as parseGitVersion,Ji as parseHocuspocusAuthToken,Jn as parseKeepaliveConnectionId,or as pathToDocName,gi as planSeed,Xr as prepareSingleFileOpen,vr as processCommand,fr as processUsage,Cn as readAllTargets,ea as readBundleDecision,va as readOwnNativeRules,In as readProcessLock,fa as readProcessLockDetailed,Dt as readProjectHeadState,N as readProjectLocalSemanticConfig,oa as readServerLock,Nt as readServerPackageVersion,G as readSkillInstallStateSnapshot,z as readStateManifest,tt as readTargetRecordedAt,Lr as readTargetVersion,y as reconcile,jr as recordContributor,Ue as recordSkillInstallEvent,Ye as redactShareSubprocessStderr,st as registerAllTools,Z as registerWrite,_e as releaseProcessLock,Ie as releaseServerLock,bt as removeLastKnownHash,wa as removeProjectSkillGitignoreBlock,E as reportSkillInstall,Gt as resetMetrics,ue as resolveBuiltinSkillHosts,o as resolveBundleEnabled,zt as resolveBundledSkillDir,Qt as resolveContentDir,ie as resolveCursorBinaryDefault,Ae as resolveCursorSpawnInvocation,Si as resolveEffectiveLinterConfig,we as resolveEmbeddingsCredential,dn as resolveGitHubAccountFromUrl,an as resolveLockDir,_n as resolveNativeConfigForDoc,mt as resolveNativeMarkdownlintConfig,p as resolvePack,Qn as resolvePackageVersion,Bi as resolveSkillInstallReportSettings,ti as resolveUiInfo,Di as restoreContributors,Cr as restoreLifecycleFromConflictsJson,On as rewriteMarkdownLinksForDocumentRename,ci as rewriteWikiLinksForDocumentRename,Pi as runAuthReposSubprocess,Vn as runAuthStatusSubprocess,Ur as runCloneSubprocess,qi as runDeviceFlowSubprocess,qn as runWithMcpLogger,ar as safeContentPath,hi as safeSubdir,Yr as safetyCheckpoint,_r as sameGitHubLogin,dr as sanitizeClientName,Sn as saveInMemoryCheckpoint,$i as saveVersion,_a as seedBasenameIndex,Fn as seedEphemeralProjectDir,da as serializeError,Et as setActiveSpanAttributes,M as setupServerObservers,aa as shadowGit,Mt as shutdownTelemetry,qt as spansCurrentPath,fe as spansPreviousPath,W as spawnDetached,R as splitMarkdownBlocks,et as startWatcher,Ir as streamingProblemEvent,v as swapContributors,Ar as teardownToleranceTelemetryWriter,He as toBroadcasterKey,Je as tracedAppendFileSync,ot as tracedLinkSync,X as tracedMkdir,ge as tracedMkdirSync,Fe as tracedRename,yt as tracedRenameSync,Ca as tracedRmSync,T as tracedRmdirSync,Wt as tracedUnlinkSync,le as tracedWriteFile,Rt as tracedWriteFileSync,Zt as trustSystemCertificates,re as updateLastKnownHash,ke as updateProcessLockPort,xi as updateServerLockPort,Ce as validateAgentId,un as validateCloneInputs,rn as validateSkillZip,gn as waitForServerLockDrain,pt as withHiddenWindowsConsole,f as withSpan,tr as withSpanSync,Ui as writeBundleDecision,ii as writeMarkdownlintRule,Ai as writeRootGitignoreForNewRepo,Er as writeStateManifest,jn as writeTargetVersion,di as writeTracker};
package/dist/index.d.mts CHANGED
@@ -10947,6 +10947,7 @@ type OkLocalOpAuthReposResponse = {
10947
10947
  } | {
10948
10948
  ok: false;
10949
10949
  error: string;
10950
+ authenticated?: false;
10950
10951
  };
10951
10952
  type OkEditorActiveTargetSnapshot = {
10952
10953
  readonly kind: 'doc';
package/dist/index.mjs CHANGED
@@ -1531,6 +1531,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
1531
1531
  `);re(e,o)}function M9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
1532
1532
  `)?`
1533
1533
  `:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDir);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDir);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const Eke=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function Dke(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const Oke=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function kke(e){let t={contentDir:e.contentDir};for(let n of Oke)for(let r of P9(N(e.stagingDir,n)))Dke(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(N(e.stagingDir,`state`))){let e=me(n);n.endsWith(`.jsonl`)?j9(n,t):Eke.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function Ake(e){return N(e,...I9,z9)}function jke(e){return N(e,...I9,B9)}function Mke(e){return N(e,...L9,V9)}function Nke(e){return N(e,...L9,H9)}function Pke(e){return N(e,...R9,U9)}function Fke(e){return N(e,...R9,W9)}const G9=1e3;async function Ike(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function Lke(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function Rke(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function zke(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1534
- `)}\n`:null}catch{return null}}function Bke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Vke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Hke(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function Uke(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,rn.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function Wke(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return Wke(e.maxBytes)}function Gke(e){let t=J9(zQ(`project`,e)),n=J9(zQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function Kke(e){return Ne(`sha256`).update(e).digest(`hex`)}function qke(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Jke=[`"doc.name"`,`"docName"`];function Yke(e){let t=S(e,`utf-8`),n=0;for(let e of Jke){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Xke=new Set([`.jsonl`]);function Zke(e){let t=e.lastIndexOf(`.`);return t!==-1&&Xke.has(e.slice(t))}const Qke=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function $ke(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Qke.has(e.slice(t))}function eAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!$ke(r))continue;let{redacted:i,patterns:a,lineCount:o}=DB(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ye(e,t).split(xe).join(`/`)}async function tAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ike,a=r.fetchAgentEffects??Lke,o=r.fetchWatcherRecent??Rke,s=r.readShadowHead??Bke,c=r.readCheckpointRefs??Vke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.71.2-beta.1`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??Hke,h=r.isOtlpPushEnabled??Uke,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Ake(n),N(_,`telemetry`,z9)),Z9(jke(n),N(_,`telemetry`,B9)),Z9(Mke(n),N(_,`logs`,V9)),Z9(Nke(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,sR,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=zke(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(Pke(n),N(_,`state`,U9)),Z9(Fke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Lu),N(_,`state`,Lu)),Z9(N(b,Ru),N(_,`state`,Ru));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1534
+ `)}\n`:null}catch{return null}}function Bke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Vke(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],W6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Hke(){return{nodeVersion:process.version,platform:le(),arch:ae()}}function Uke(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,rn.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function Wke(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return Wke(e.maxBytes)}function Gke(e){let t=J9(zQ(`project`,e)),n=J9(zQ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function Kke(e){return Ne(`sha256`).update(e).digest(`hex`)}function qke(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Jke=[`"doc.name"`,`"docName"`];function Yke(e){let t=S(e,`utf-8`),n=0;for(let e of Jke){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(M(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,w7(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Xke=new Set([`.jsonl`]);function Zke(e){let t=e.lastIndexOf(`.`);return t!==-1&&Xke.has(e.slice(t))}const Qke=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function $ke(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Qke.has(e.slice(t))}function eAe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!$ke(r))continue;let{redacted:i,patterns:a,lineCount:o}=DB(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return ye(e,t).split(xe).join(`/`)}async function tAe(e){let t=be(e.contentDir),n=be(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ike,a=r.fetchAgentEffects??Lke,o=r.fetchWatcherRecent??Rke,s=r.readShadowHead??Bke,c=r.readCheckpointRefs??Vke,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.71.2-beta.2`),d=r.readDesktopEnv??K9,f=r.readLanguage??O9,p=r.readRuntime??Hke,h=r.isOtlpPushEnabled??Uke,_=y(N(A(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),Z9(Ake(n),N(_,`telemetry`,z9)),Z9(jke(n),N(_,`telemetry`,B9)),Z9(Mke(n),N(_,`logs`,V9)),Z9(Nke(n),N(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,N(_,`logs`,me(t)));for(let t of e.userStateFiles??[])Z9(t,N(_,sR,me(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,N(_,`diagnostic-reports`,me(t)))&&(y+=1);let b=N(n,`.ok`,`local`),x=N(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,N(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(N(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(N(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=zke(n);e!==null&&re(N(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(N(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(N(_,`state`,`checkpoint-refs.txt`),D),Z9(Pke(n),N(_,`state`,U9)),Z9(Fke(n),N(_,`state`,W9)),Z9(N(b,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),Z9(N(b,Lu),N(_,`state`,Lu)),Z9(N(b,Ru),N(_,`state`,Ru));let ee=p(),ne=d(),ie=f(),ae={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(N(_,`state`,`runtime.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=C===`running`?`running
1535
1535
  `:`not-running (${w})\n`;re(N(_,`state`,`server-status.txt`),oe);let se=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:C7(e.diagnosticReports,y);if(re(N(_,`state`,`diagnostic-reports-status.txt`),`${se}\n`),e.processDir&&g(e.processDir)){let t=N(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&kke({stagingDir:_,contentDir:t}),e.note&&re(N(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=eAe(_));for(let t of e.extraFiles??[])Z9(t.sourcePath,N(_,`extra`,t.zipName??me(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let le=Gke(n),ue=Q9(_),A=[],j=0,de=0;for(let e of ue){let t=$9(_,e),n=te(e).size,r=Zke(t)?qke(e):0;A.push({path:t,bytes:n,lines:r}),j+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=Yke(e))}let fe={applied:k};ce!==null&&(fe.secretScrub=ce);let pe={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:Kke(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:le,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:A};re(N(_,`manifest.json`),`${JSON.stringify(pe,null,2)}\n`);let M=ue.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:j,fileCount:A.length,docNameCount:de,contentDirVisible:M,redacted:k},ge=!1;return{stagingDir:_,manifest:pe,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function nAe(e){let{collected:t,outputPath:n}=e,r=M(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new wSe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function rAe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,rn.parse)(S(n,`utf-8`)),r=K8(t)?t.content:void 0,i=K8(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return be(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return be(e)}async function iAe(e,t,n,r,i){let a=E7(t,e.logger),o=await tAe({contentDir:rAe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...mOe(a,e.userLogsDir??N(k(),`.ok`,`logs`)),...O7(e.cachesDir??N(k(),`Library`,`Caches`))],userStateFiles:k7(e.bugReportsDir??T7()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(M(e.outputPath),{recursive:!0}),await nAe({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function aAe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??O9,i=()=>uOe(e.diagnosticReportsDir??N(k(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return iAe(e,t,n,r,i());let{zipPath:a,summary:o}=await yOe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:O7(e.cachesDir??N(k(),`Library`,`Caches`)),bugReportLedgerFiles:k7(e.bugReportsDir??T7()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{$8 as ALL_EDITOR_IDS,e5 as EDITOR_LABELS,j5 as EDITOR_TARGETS,PEe as HOSTS_WITH_USER_SKILL_DIR,XDe as LAUNCH_CONFIG_NAME,cke as PATH_SHIM_BEGIN,uke as PATH_SHIM_BLOCK_RE,lke as PATH_SHIM_END,jDe as addOkPathsToGitExclude,R5 as assertProjectPathSafe,f5 as buildManagedServerEntry,QOe as buildMcpConfigDeclineEvent,$Oe as buildMcpConfigMigrateEvent,b7 as classifyExistingMcpEntry,aAe as collectReportBundle,hke as createCliProbeResolver,cn as createTokenStore,dOe as defaultBugReportZipPath,We as detectGh,qe as detectGhAccounts,eOe as detectInstalledEditors,x5 as droppedManagedKeys,eDe as editorConfigPathDisplay,$Ee as editorEntryLocator,VOe as ensurePiBridge,Q5 as formatTrackedRemediation,PDe as getExcludedOkPaths,X5 as getInstalledSkillProjectionPaths,NEe as getNativeTomlMcpEditor,Y5 as getOkArtifactPaths,u5 as isEntryUpToDate,p5 as isOwnManagedEntry,ake as loadConfig,vee as makeLazyProbeTokenStore,T7 as okBugReportsDir,b9 as parseGitHubBlobUrl,oke as parseGitHubShareUrl,x9 as parseGitHubTreeUrl,y9 as parseGitUrl,dke as pathInstallMarkerPath,hDe as previewContent,tOe as probeOwnManagedEditorMcpEntry,zOe as probePiBridgeState,Z5 as probeTrackedOkPaths,v7 as readExistingMcpEntry,NDe as readSharingMode,DB as redactContent,MDe as removeOkPathsFromGitExclude,JOe as removeOwnMcpEntry,DDe as removeProjectSkill,_ke as removeUserGlobalSkillBundle,Cke as removeUserSkill,xDe as resolveProjectRoot,nke as runStop,h9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,Ske as userSkillPresentAnywhere,ske as validateLocalFolderForShare,_7 as writeEditorMcpConfig,bke as writeProjectAiIntegrations,W5 as writeProjectSkill,$De as writeUserMcpConfigs,xke as writeUserSkill};
1536
1536
  //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Xu as i,Zo as a,Zu as o,ad as s,au as c,eu as l,iu as u,jt as d,lu as f,ml as p,nd as m,nl as h,od as g,td as _,ul as v}from"./md-manager-BGnqyqi1-BKxqDqfk.mjs";import{B as y,Bi as b,Br as x,Ct as S,Do as ee,F as C,I as te,No as ne,Pn as re,Qa as ie,Ui as ae,Vn as oe,Yt as se,_o as ce,go as le,ho as ue,kr as de,m as fe,mo as pe,ro as me,rt as he,ta as ge,to as _e,tt as ve,vo as ye,vr as be,wr as xe,xo as w,zi as Se}from"./dist-CjH-Sf5k.mjs";import{i as T,n as E,o as D,r as Ce,s as O,t as k}from"./colors-r_owlCuY.mjs";import{t as A}from"./is-object-BGze3w87.mjs";import{t as we}from"./constants-CN-OP4lK.mjs";import{t as Te}from"./preview-BOTcB8PJ.mjs";import{createRequire as Ee}from"node:module";import{execFileSync as De}from"node:child_process";import Oe,{basename as ke,dirname as j,isAbsolute as Ae,join as M,posix as je,relative as N,resolve as P,sep as F,win32 as Me}from"node:path";import I from"node:process";import{fileURLToPath as Ne}from"node:url";import{cpSync as Pe,existsSync as L,lstatSync as Fe,mkdirSync as Ie,readFileSync as R,readdirSync as Le,readlinkSync as Re,realpathSync as ze,rmSync as Be,statSync as Ve,writeFileSync as He}from"node:fs";import{homedir as z}from"node:os";import*as Ue from"node:readline";import{inspect as We,stripVTControlCharacters as Ge,styleText as B}from"node:util";import{AsyncLocalStorage as Ke,AsyncResource as qe}from"node:async_hooks";var Je=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),Ye=n((e=>{let{InvalidArgumentError:t}=Je();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Xe=n((e=>{let{humanReadableArgName:t}=Ye();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Qu as r,Zo as i,Zu as a,au as o,dl as s,ed as c,hl as l,jt as u,nd as d,od as f,ou as p,rd as m,rl as h,sd as g,tu as _,uu as v}from"./md-manager-BGnqyqi1-C0-0a_4T.mjs";import{B as y,Bi as b,Br as x,Ct as S,Do as ee,F as C,I as te,No as ne,Pn as re,Qa as ie,Ui as ae,Vn as oe,Yt as se,_o as ce,go as le,ho as ue,kr as de,m as fe,mo as pe,ro as me,rt as he,ta as ge,to as _e,tt as ve,vo as ye,vr as be,wr as xe,xo as w,zi as Se}from"./dist-9e6NmrQK.mjs";import{i as T,n as E,o as D,r as Ce,s as O,t as k}from"./colors-r_owlCuY.mjs";import{t as A}from"./is-object-BGze3w87.mjs";import{t as we}from"./constants-CDtlxNjm.mjs";import{t as Te}from"./preview-BqT0WT0X.mjs";import{createRequire as Ee}from"node:module";import{execFileSync as De}from"node:child_process";import Oe,{basename as ke,dirname as j,isAbsolute as Ae,join as M,posix as je,relative as N,resolve as P,sep as F,win32 as Me}from"node:path";import I from"node:process";import{fileURLToPath as Ne}from"node:url";import{cpSync as Pe,existsSync as L,lstatSync as Fe,mkdirSync as Ie,readFileSync as R,readdirSync as Le,readlinkSync as Re,realpathSync as ze,rmSync as Be,statSync as Ve,writeFileSync as He}from"node:fs";import{homedir as z}from"node:os";import*as Ue from"node:readline";import{inspect as We,stripVTControlCharacters as Ge,styleText as B}from"node:util";import{AsyncLocalStorage as Ke,AsyncResource as qe}from"node:async_hooks";var Je=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),Ye=n((e=>{let{InvalidArgumentError:t}=Je();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),Xe=n((e=>{let{humanReadableArgName:t}=Ye();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
2
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
3
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
4
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),Ze=n((e=>{let{InvalidArgumentError:t}=Je();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -278,7 +278,7 @@ let vr=/^[a-z0-9-_]+$/i;function yr(e){let t=typeof e;if(t===`object`){if(Array.
278
278
  `)+Er(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Sr(t[c],e,r,i),a+=`
279
279
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Dr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(yr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Er(0,e,``,t,n);return r[r.length-1]===`
280
280
  `?r:r+`
281
- `}var Or=l();function kr(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 J(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 Ar=[`native`,`index.js`];function jr(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??Ee(t);try{let e=j(Ne(t));return n(M(e,...Ar))}catch(e){kr(e)||J(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return kr(e)||J(`workspace addon failed to load`,e),null}}function Mr(){let e=jr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Nr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return J(`addon loaded but probe failed`,e),!1}}function Pr(e){if(!A(e))throw Error(`TOML root is not a table`);return e}function Fr(e){return{backend:`native`,parseToObject(t){return Pr(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}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Ir(){return{backend:`fallback`,parseToObject(e){return Pr(_r(e))}}}function Lr(e=Mr){let t=e();return t&&Nr(t)?Fr(t):Ir()}let Rr=null;function zr(){return Rr===null&&(Rr=Lr()),Rr}function Br(){let e=zr();return e.backend===`native`?e:void 0}const Vr=i,Y=o,Hr=_,Ur=`node`,Wr={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},Gr=`# ok-mcp-v2`,Kr=`# ok-mcp-v2
281
+ `}var Or=_();function kr(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 J(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 Ar=[`native`,`index.js`];function jr(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??Ee(t);try{let e=j(Ne(t));return n(M(e,...Ar))}catch(e){kr(e)||J(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return kr(e)||J(`workspace addon failed to load`,e),null}}function Mr(){let e=jr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Nr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return J(`addon loaded but probe failed`,e),!1}}function Pr(e){if(!A(e))throw Error(`TOML root is not a table`);return e}function Fr(e){return{backend:`native`,parseToObject(t){return Pr(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}},removeEntryKey(t,n,r){let i=e.removeMcpServerKey(t,n,r);return{text:i.text,existed:i.existed}}}}function Ir(){return{backend:`fallback`,parseToObject(e){return Pr(_r(e))}}}function Lr(e=Mr){let t=e();return t&&Nr(t)?Fr(t):Ir()}let Rr=null;function zr(){return Rr===null&&(Rr=Lr()),Rr}function Br(){let e=zr();return e.backend===`native`?e:void 0}const Vr=a,Y=r,Hr=d,Ur=`node`,Wr={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},Gr=`# ok-mcp-v2`,Kr=`# ok-mcp-v2
282
282
  USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
283
283
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
284
284
  BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
@@ -314,16 +314,16 @@ foreach ($d in $dirs) {
314
314
  if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
315
315
  }
316
316
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
317
- exit 127`,Xr=`// ok-pi-bridge`,Zr=`${Xr}-v1`;function Qr(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return si(e,Gr)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return si(e,qr)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return si(e,Gr)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return si(e,qr)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(Zr)}return!1}function $r(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=P(e);if(ke(t)===`cli.mjs`&&ke(j(t))===`dist`)return t;let n=t.split(F),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?F:i.join(F);return M(a,`packages`,`cli`,`dist`,`cli.mjs`)}function X(e={}){return e.mode===`dev`?{command:Ur,args:[$r(),`mcp`],env:{...Wr}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,Yr]}:{command:`/bin/sh`,args:[`-l`,`-c`,Kr]}}function ei(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[Ur,$r(),`mcp`],environment:{...Wr}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,Yr]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,Kr]}}function ti(e){if(typeof e!=`object`||!e)return!1;let t=e;return ni(t,X({mode:`published`,platformName:`darwin`}))||ni(t,X({mode:`published`,platformName:`win32`}))}function ni(e,t){return Object.keys(e).length===Object.keys(t).length&&ri(e,t)}function ri(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function ii(e,t){let n=e=>ci(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function ai(e){return e.format===`toml`?zr().backend===`native`:e.format===`json`||e.format===`yaml`}function oi(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function si(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function ci(e){return si(e,`# ok-mcp`)}function li(e){return typeof e==`string`&&(e===Jr||e.startsWith(`${Jr}@`))}function ui(e){if(typeof e!=`object`||!e)return!1;let t=oi(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&ci(t[n+1])?!0:t.some(li)}function di(e){if(typeof e!=`object`||!e)return!1;let t=oi(e);if(t[0]!==Ur||t[2]!==`mcp`)return!1;try{return t[1]===$r()}catch{return!1}}const fi=[`command`,`args`,`env`],pi=[`type`,`command`,`environment`];function mi(e){return e.type===`local`&&Array.isArray(e.command)?pi:fi}function hi(e,t){if(typeof e!=`object`||!e)return[];let n=e;return mi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function gi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function _i(e,t){return hi(e,t).length>0}function vi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ii(t.args,t.command)}function yi(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&ii(r,n)}function Z(e){return e===`win32`?Me:je}function bi(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env,i=Z(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function xi(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.claude.json`)}function Si(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env;if(t===`darwin`)return je.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Me.join(n,`AppData`,`Roaming`);return Me.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ci(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.cursor`,`mcp.json`)}function wi(e={}){let t=e.platformName??process.platform,n=e.home??z();return(e.env??process.env).CODEX_HOME??Z(t).join(n,`.codex`)}function Ti(e={}){return Z(e.platformName??process.platform).join(wi(e),`config.toml`)}function Ei(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=(e.env??process.env).COPILOT_HOME??Z(t).join(n,`.copilot`);return Z(t).join(r,`mcp-config.json`)}function Di(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env,i=Z(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Oi(e={}){return Z(e.platformName??process.platform).join(Di(e),`opencode.json`)}function ki(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.openclaw`,`openclaw.json`)}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.hermes`,`config.yaml`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??z();return(e.env??process.env).PI_CODING_AGENT_DIR??Z(t).join(n,`.pi`,`agent`)}function Mi(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ni(e,t){let n=Z(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Pi(e){try{return Le(e).length>0}catch{return!1}}function Fi(e={}){let t=e.platformName??process.platform,[n,r]=Ni(e.home??z(),t),i=[n,r].find(e=>L(e.file));return i?i.file:Pi(r.dir)?r.file:n.file}const Q={claude:{id:`claude`,label:Y.claude,configPath:(e,t)=>xi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.claude`),projectConfigPath:e=>M(e,`.mcp.json`),projectSkillPath:e=>M(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:Y[`claude-desktop`],configPath:(e,t)=>Si({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Si({home:t}))},cursor:{id:`cursor`,label:Y.cursor,configPath:(e,t)=>Ci({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ci({home:t})),projectConfigPath:e=>M(e,`.cursor`,`mcp.json`),projectSkillPath:e=>M(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:Y.codex,configPath:(e,t)=>Ti({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ti({home:t})),projectConfigPath:e=>M(e,`.codex`,`config.toml`),projectSkillPath:e=>M(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:Y.copilot,configPath:(e,t)=>Ei({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ei({home:t})),projectSkillPath:e=>M(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:Y.opencode,configPath:(e,t)=>Oi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>c,buildEntry:(e,t)=>ei(t),scope:`global`,detectPath:(e,t)=>j(Oi({home:t})),projectConfigPath:e=>M(e,`opencode.json`),projectSkillPath:e=>M(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:Y.openclaw,configPath:(e,t)=>ki({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:Y.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>c,scope:`project`,detectPath:(e,t)=>ji({home:t}),projectConfigPath:e=>M(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>M(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:Y.antigravity,configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:Y[`lm-studio`],configPath:(e,t)=>Fi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Fi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:Y.hermes,configPath:(e,t)=>Ai({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>c,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.hermes`),offerOnlyWhenDetected:!0}};function Ii(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Vr.join(`, `)}`);return e.map(e=>Q[e])}const Li=`**/.ok/*`,Ri=`!**/${v}/`;function zi(e){let t=[`.ok/`,`.okignore`];for(let n of Vr){let r=Q[n];r.projectConfigPath&&t.push(Zi(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Bi(e){let t=M(e,...d);if(!L(t))return[];try{let e=a(R(t,`utf-8`));if(!e)return[];let n=[];for(let[t,i]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of i.hosts){let i=r[e];i&&n.push(`${i}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Vi(e,t){let n=Gi(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Ki(n)};let r=qi(e);if(r.kind!==`ok`)return r.result;let i=L(r.path)?R(r.path,`utf-8`):``,a=new Set(Bi(e)),o=[],s=a.size===0?i:i.split(`
317
+ exit 127`,Xr=`// ok-pi-bridge`,Zr=`${Xr}-v1`;function Qr(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return si(e,Gr)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return si(e,qr)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return si(e,Gr)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return si(e,qr)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(Zr)}return!1}function $r(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=P(e);if(ke(t)===`cli.mjs`&&ke(j(t))===`dist`)return t;let n=t.split(F),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r),a=i.length===0?F:i.join(F);return M(a,`packages`,`cli`,`dist`,`cli.mjs`)}function X(e={}){return e.mode===`dev`?{command:Ur,args:[$r(),`mcp`],env:{...Wr}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,Yr]}:{command:`/bin/sh`,args:[`-l`,`-c`,Kr]}}function ei(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[Ur,$r(),`mcp`],environment:{...Wr}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,Yr]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,Kr]}}function ti(e){if(typeof e!=`object`||!e)return!1;let t=e;return ni(t,X({mode:`published`,platformName:`darwin`}))||ni(t,X({mode:`published`,platformName:`win32`}))}function ni(e,t){return Object.keys(e).length===Object.keys(t).length&&ri(e,t)}function ri(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function ii(e,t){let n=e=>ci(e);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`&&e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3])}function ai(e){return e.format===`toml`?zr().backend===`native`:e.format===`json`||e.format===`yaml`}function oi(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function si(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function ci(e){return si(e,`# ok-mcp`)}function li(e){return typeof e==`string`&&(e===Jr||e.startsWith(`${Jr}@`))}function ui(e){if(typeof e!=`object`||!e)return!1;let t=oi(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&ci(t[n+1])?!0:t.some(li)}function di(e){if(typeof e!=`object`||!e)return!1;let t=oi(e);if(t[0]!==Ur||t[2]!==`mcp`)return!1;try{return t[1]===$r()}catch{return!1}}const fi=[`command`,`args`,`env`],pi=[`type`,`command`,`environment`];function mi(e){return e.type===`local`&&Array.isArray(e.command)?pi:fi}function hi(e,t){if(typeof e!=`object`||!e)return[];let n=e;return mi(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function gi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function _i(e,t){return hi(e,t).length>0}function vi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:ii(t.args,t.command)}function yi(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&ii(r,n)}function Z(e){return e===`win32`?Me:je}function bi(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env,i=Z(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA||i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME||i.join(n,`.config`)}function xi(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.claude.json`)}function Si(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env;if(t===`darwin`)return je.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Me.join(n,`AppData`,`Roaming`);return Me.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Ci(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.cursor`,`mcp.json`)}function wi(e={}){let t=e.platformName??process.platform,n=e.home??z();return(e.env??process.env).CODEX_HOME??Z(t).join(n,`.codex`)}function Ti(e={}){return Z(e.platformName??process.platform).join(wi(e),`config.toml`)}function Ei(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=(e.env??process.env).COPILOT_HOME??Z(t).join(n,`.copilot`);return Z(t).join(r,`mcp-config.json`)}function Di(e={}){let t=e.platformName??process.platform,n=e.home??z(),r=e.env??process.env,i=Z(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Oi(e={}){return Z(e.platformName??process.platform).join(Di(e),`opencode.json`)}function ki(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.openclaw`,`openclaw.json`)}function Ai(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.hermes`,`config.yaml`)}function ji(e={}){let t=e.platformName??process.platform,n=e.home??z();return(e.env??process.env).PI_CODING_AGENT_DIR??Z(t).join(n,`.pi`,`agent`)}function Mi(e={}){let t=e.platformName??process.platform,n=e.home??z();return Z(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ni(e,t){let n=Z(t);return[{file:n.join(e,`.lmstudio`,`mcp.json`),dir:n.join(e,`.lmstudio`)},{file:n.join(e,`.cache`,`lm-studio`,`mcp.json`),dir:n.join(e,`.cache`,`lm-studio`)}]}function Pi(e){try{return Le(e).length>0}catch{return!1}}function Fi(e={}){let t=e.platformName??process.platform,[n,r]=Ni(e.home??z(),t),i=[n,r].find(e=>L(e.file));return i?i.file:Pi(r.dir)?r.file:n.file}const Q={claude:{id:`claude`,label:Y.claude,configPath:(e,t)=>xi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.claude`),projectConfigPath:e=>M(e,`.mcp.json`),projectSkillPath:e=>M(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:Y[`claude-desktop`],configPath:(e,t)=>Si({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Si({home:t}))},cursor:{id:`cursor`,label:Y.cursor,configPath:(e,t)=>Ci({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ci({home:t})),projectConfigPath:e=>M(e,`.cursor`,`mcp.json`),projectSkillPath:e=>M(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:Y.codex,configPath:(e,t)=>Ti({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ti({home:t})),projectConfigPath:e=>M(e,`.codex`,`config.toml`),projectSkillPath:e=>M(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:Y.copilot,configPath:(e,t)=>Ei({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Ei({home:t})),projectSkillPath:e=>M(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:Y.opencode,configPath:(e,t)=>Oi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>p,buildEntry:(e,t)=>ei(t),scope:`global`,detectPath:(e,t)=>j(Oi({home:t})),projectConfigPath:e=>M(e,`opencode.json`),projectSkillPath:e=>M(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:Y.openclaw,configPath:(e,t)=>ki({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:Y.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>p,scope:`project`,detectPath:(e,t)=>ji({home:t}),projectConfigPath:e=>M(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>M(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:Y.antigravity,configPath:(e,t)=>Mi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:Y[`lm-studio`],configPath:(e,t)=>Fi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>j(Fi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:Y.hermes,configPath:(e,t)=>Ai({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>p,buildEntry:(e,t)=>X(t),scope:`global`,detectPath:(e,t)=>M(t??z(),`.hermes`),offerOnlyWhenDetected:!0}};function Ii(e){let t=e.filter(e=>!Object.hasOwn(Q,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${Vr.join(`, `)}`);return e.map(e=>Q[e])}const Li=`**/.ok/*`,Ri=`!**/${s}/`;function zi(e){let t=[`.ok/`,`.okignore`];for(let n of Vr){let r=Q[n];r.projectConfigPath&&t.push(Zi(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function Bi(e){let t=M(e,...u);if(!L(t))return[];try{let e=i(R(t,`utf-8`));if(!e)return[];let n=[];for(let[t,r]of Object.entries(e.skills))if(t!==`open-knowledge`)for(let e of r.hosts){let r=c[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function Vi(e,t){let n=Gi(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:Ki(n)};let r=qi(e);if(r.kind!==`ok`)return r.result;let i=L(r.path)?R(r.path,`utf-8`):``,a=new Set(Bi(e)),o=[],s=a.size===0?i:i.split(`
318
318
  `).filter(e=>{let t=e.trim();return!a.has(t)||(o.push(t),!1)}).join(`
319
319
  `),c=Xi(s),l=[],u=[];for(let e of t)Yi(c,e)?u.push(e):l.push(e);if(l.length===0&&o.length===0)return{kind:`updated`,appended:l,alreadyPresent:u,removed:[]};let d=l.length===0||s.length===0||s.endsWith(`
320
320
  `)?``:`
321
321
  `,f=l.length===0?``:`${l.join(`
322
322
  `)}\n`;try{He(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function Hi(e,t){let n=qi(e);if(n.kind!==`ok`)return n.result;if(!L(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>Ji(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(Li),i.add(Ri);for(let t of Bi(e))i.add(t);let a;try{a=R(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
323
323
  `),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=[...s];if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
324
- `);if(u!==a)try{He(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function Ui(e){let t=qi(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Xi(n),i=zi(e);for(let e of i)if(Yi(r,e))return`local-only`;return r.has(Li)?`local-only`:`shared`}function Wi(e){let t=qi(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let i=Xi(n),a=[...zi(e),...Bi(e)].filter(e=>Yi(i,e)),o=new Set(a),s=[];for(let e of Object.values(r))e!==null&&s.push(e);let c=[];for(let e of i){if(o.has(e))continue;if(e===Li||e===Ri){c.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);s.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&c.push(e)}return[...a,...c]}function Gi(e,t){let n=[];for(let r of t){let t=P(e,r);if(L(t))try{De(`git`,[`ls-files`,`--error-unmatch`,`--`,r],ie({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}function Ki(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}${e}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
324
+ `);if(u!==a)try{He(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function Ui(e){let t=qi(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Xi(n),i=zi(e);for(let e of i)if(Yi(r,e))return`local-only`;return r.has(Li)?`local-only`:`shared`}function Wi(e){let t=qi(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let r=Xi(n),i=[...zi(e),...Bi(e)].filter(e=>Yi(r,e)),a=new Set(i),o=[];for(let e of Object.values(c))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===Li||e===Ri){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function Gi(e,t){let n=[];for(let r of t){let t=P(e,r);if(L(t))try{De(`git`,[`ls-files`,`--error-unmatch`,`--`,r],ie({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}function Ki(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}${e}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
325
325
  `)}function qi(e){let t=ne(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=M(e.path,`info`);return L(n)?{kind:`ok`,path:M(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function Ji(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Yi(e,t){for(let n of Ji(t))if(e.has(n))return!0;return!1}function Xi(e){let t=new Set;for(let n of e.split(`
326
- `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function Zi(e,t){return Qi(N(t,e))}function Qi(e){return F===`/`?e:e.split(F).join(`/`)}function $i(e,t){let n;try{n=Fe(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ta(e,t)}function ea(e,t){ta(e,t)}function ta(e,t){na(e,t)}function na(e,t){let n=t,r;try{r=ze(n)}catch{r=P(n)}let i=j(e);for(;i.length>1&&i!==F;){let t;try{t=ze(i)}catch(e){if(e.code===`ENOENT`){i=j(i);continue}throw e}let n=N(r,t);if(n===``||!n.startsWith(`..`)&&!Ae(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ra(e,t){let n=j(t),r=L(t)?`overwritten`:`written`;if(r===`written`&&L(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Be(n,{recursive:!0,force:!0}),Ie(j(n),{recursive:!0}),Pe(e,n,{recursive:!0}),r}function ia(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aa(e,t,n){try{if(Ve(n).size>10485760)return!1}catch{return!1}let r;try{r=R(n,`utf-8`)}catch{return!1}let i=[],a=ce(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!ia(a))return!1;let o=a[e.topLevelKey];if(!ia(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!ia(s))return!1;let c=s[e.serverName(t)];return ia(c)&&c.enabled===!1?!1:ui(c)||di(c)}function oa(e){let t=u[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:f(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:Q[n.editor]??null}function sa(e,t,n={}){if(!g.includes(e.id))return!0;let r=oa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&aa(r,t,i))return!0;try{return aa(e,t,e.configPath(t,n.home))}catch{return!1}}function ca(e){let t=new Set(m.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function la(e,t){if(ca(t).length===0)return null;let n=M(e,h,s,`SKILL.md`);try{let t=ae(`project`,{checkDesktop:!0});return $i(j(n),e),{editorId:`agents`,label:`.agents hub`,action:ra(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function ua(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!sa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=ae(`project`,{checkDesktop:!0});$i(j(r),t);let i=ra(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function da(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=j(n);return L(n)?(ea(r,t),Be(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function fa(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function pa(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function ma(e){for(let t of e.split(`
326
+ `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function Zi(e,t){return Qi(N(t,e))}function Qi(e){return F===`/`?e:e.split(F).join(`/`)}function $i(e,t){let n;try{n=Fe(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ta(e,t)}function ea(e,t){ta(e,t)}function ta(e,t){na(e,t)}function na(e,t){let n=t,r;try{r=ze(n)}catch{r=P(n)}let i=j(e);for(;i.length>1&&i!==F;){let t;try{t=ze(i)}catch(e){if(e.code===`ENOENT`){i=j(i);continue}throw e}let n=N(r,t);if(n===``||!n.startsWith(`..`)&&!Ae(n))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ra(e,t){let n=j(t),r=L(t)?`overwritten`:`written`;if(r===`written`&&L(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return Be(n,{recursive:!0,force:!0}),Ie(j(n),{recursive:!0}),Pe(e,n,{recursive:!0}),r}function ia(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aa(e,t,n){try{if(Ve(n).size>10485760)return!1}catch{return!1}let r;try{r=R(n,`utf-8`)}catch{return!1}let i=[],a=ce(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!ia(a))return!1;let o=a[e.topLevelKey];if(!ia(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!ia(s))return!1;let c=s[e.serverName(t)];return ia(c)&&c.enabled===!1?!1:ui(c)||di(c)}function oa(e){let t=o[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:v(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:Q[n.editor]??null}function sa(e,t,n={}){if(!g.includes(e.id))return!0;let r=oa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&aa(r,t,i))return!0;try{return aa(e,t,e.configPath(t,n.home))}catch{return!1}}function ca(e){let t=new Set(m.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function la(e,t){if(ca(t).length===0)return null;let n=M(e,h,f,`SKILL.md`);try{let t=ae(`project`,{checkDesktop:!0});return $i(j(n),e),{editorId:`agents`,label:`.agents hub`,action:ra(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function ua(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!sa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=ae(`project`,{checkDesktop:!0});$i(j(r),t);let i=ra(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function da(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=j(n);return L(n)?(ea(r,t),Be(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function fa(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function pa(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function ma(e){for(let t of e.split(`
327
327
  `)){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 ha(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function ga(e){try{return Ve(e).mode&511}catch{return}}function _a(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
328
328
  `)?`\r
329
329
  `:`
@@ -687,7 +687,7 @@ export default function okBridge(pi: {
687
687
  `)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
688
688
  `).replace(/\n/g,`\r
689
689
  `));let g=`${s?``:``}${m}`;return g!==o&&w(e,g,{mode:ga(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const lo=e=>e!==`project`,uo=e=>e!==`user`;async function fo(){let e=await Ta({message:`Where should the MCP server be configured?
690
- `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function po(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??fo)():`both`}async function mo(e){return Aa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function ho(e){if(e.sharing!==void 0)return e.sharing;let t=Ui(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??mo)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function go(e){if(e===void 0||e===!0)return new Set(ve);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(S.filter(e=>t.includes(e)))}function _o(e,t,n){let r=P(n,e),i;try{i=Ve(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=vo(t),o=vo(r),s=N(a,o);if(s.startsWith(`..`)||Ae(s))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function vo(e){try{return ze(e)}catch{return e}}const yo=`open-knowledge-ui`;function bo(e,t,n){try{let r=e.detectPath?.(t,n)??j(e.configPath(t,n));return L(r)}catch{return!1}}function xo(e,t,n){try{let r=P(j(e.configPath(t,n))),i=P(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+F)}catch{return!1}}function So(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.pruneOnly===!0;if(s&&(e.format===`file`||!L(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||xo(e,t,r);if(!i&&c&&!bo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{$i(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`}}if(e.format===`file`)return wo(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=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{s||Ie(j(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 u={action:`written`},d;try{ee(`${o}.lock`,()=>{let t=Ua(o).writePath;if(s||Ie(j(t),{recursive:!0}),e.format===`toml`){let r=ao(zr(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=co(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=io(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Co={pi:Fa};function wo(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Co[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{Ie(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ee(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:ga(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function To(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function Eo(e){let t=Ii(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>So(t,``,n,e.home))}function Do(e,t,n,r){let i=ko(e,t,n,r);return i.kind===`present`?i.entry:null}function Oo(e,t,n,r){let i=ro(e,t,r);if(!A(i))return{kind:`no-entry`};let a=i[n];return A(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ko(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(Ve(i).size>Za)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:fa(e)}}let a;try{a=R(i,`utf-8`)}catch(e){return{kind:`decline`,reason:fa(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Pa(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=zr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Oo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Or.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Oo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=Ka(a);return s?qa(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Oo(ue(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ao(e={}){let t=P(e.cwd??process.cwd()),n=Ra(t,{homeDir:e.home}),r=n.projectRoot;if(de(r,e.home??z()))throw new y(r);let i=!L(M(r,`.ok`)),a=n.gitRootPromoted?N(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:_o(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${O(`[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 oe(r),l;try{l=be(r,{contentDir:o})}catch(t){let i=Q.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(we),d=!1;if(c.didInit)try{d=me(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Se(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let f=await po({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??Io(r,e.home),h=e.editors??m,g=Ii(m),_=Ii(h),v=e.mcp===!1||f===null,x=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),ee=g.filter(t=>bo(t,r,e.home)),C=[],te=[],ne=new Set;for(let t of x){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}C.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(lo(f)&&g.includes(t)&&t.scope===`global`&&C.push(So(t,r,s,e.home)),uo(f)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=So(t,r,s,e.home,n);C.push(i),(i.action===`written`||i.action===`overwritten`)&&ne.add(n)}}let ie=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ie.has(n)||(ie.add(n),te.push(ua(t,r,{home:e.home})))}let ae=la(r,_.map(e=>e.id));ae&&te.push(ae);let se=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(se.length>0){let t=e.home??z();b({source:p,skills:[fe.project],agents:se,scope:r},{home:t,enabled:ge(t).enabled})}let ce=!v&&f!==null&&uo(f)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,le=v?[]:ee.map(e=>To(e,r)).filter(e=>e!==void 0).filter(e=>!ne.has(e.path)),ue=e.installUserSkill??xe,pe=e.home??z(),he=go(e.skills),ve=!1,ye=!1,w=!1,T=!1,E=!1;for(let t of S){if(!he.has(t))continue;await _e(pe,fe[t],!0).catch(()=>{}),ve=!0;let n=await ue({home:e.home,bundleId:t,force:!0});n===`installed`?ye=!0:n===`failed`?w=!0:n===`no-hosts`?E=!0:T=!0}let D=w?`failed`:ye?`installed`:ve&&T?`skip-current`:ve&&E?`no-hosts`:`declined`,Ce=ye?re(pe).map(e=>e.editorId):[],k=v?`skipped-flag`:`skipped-missing`,A=C.find(e=>e.editorId===`claude`)??C[0]??{action:k,configPath:Q.claude.configPath(r,e.home)},Te=await jo({projectRoot:r,desiredMode:await ho({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:C,projectSkills:te,legacyProjectConfigs:le,skillInstall:D,skillHosts:Ce,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:A.action,mcpPath:A.configPath,mcpError:`error`in A?A.error:void 0,projectScopeUnsupportedLabels:ce,sharing:Te}}async function jo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Ui(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=zi(t);if(n===`local-only`){let e=Vi(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`}:Mo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Hi(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Mo(t,o,`remove`)}function Mo(e,t,n){let r=Ui(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function No(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;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`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function Po(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`);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 s=M(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(k(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(k(`Content already present at ${s}/`)),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(k(`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(k(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(k(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${D(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${D(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Ce(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${No(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}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(k(`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?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${D(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${D(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${Ce(`FAILED`)}: ${r.error}`)}}}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} ${N(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(k(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>Y[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${D(`installed for ${r}`)}`),n.push(` ${E(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${E(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${D(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${E(`skipped for this run (--no-skills)`)}`),n.push(` ${E(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${E(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${E(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${E(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${O(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${O(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(O(`⚠ --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(O(`⚠ 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(Te(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...zo(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(`${D(`✓`)} ${k(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${T(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${T(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
690
+ `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function po(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??fo)():`both`}async function mo(e){return Aa({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function ho(e){if(e.sharing!==void 0)return e.sharing;let t=Ui(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??mo)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function go(e){if(e===void 0||e===!0)return new Set(ve);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(S.filter(e=>t.includes(e)))}function _o(e,t,n){let r=P(n,e),i;try{i=Ve(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=vo(t),o=vo(r),s=N(a,o);if(s.startsWith(`..`)||Ae(s))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function vo(e){try{return ze(e)}catch{return e}}const yo=`open-knowledge-ui`;function bo(e,t,n){try{let r=e.detectPath?.(t,n)??j(e.configPath(t,n));return L(r)}catch{return!1}}function xo(e,t,n){try{let r=P(j(e.configPath(t,n))),i=P(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+F)}catch{return!1}}function So(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.pruneOnly===!0;if(s&&(e.format===`file`||!L(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||xo(e,t,r);if(!i&&c&&!bo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{$i(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`}}if(e.format===`file`)return wo(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=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{s||Ie(j(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 u={action:`written`},d;try{ee(`${o}.lock`,()=>{let t=Ua(o).writePath;if(s||Ie(j(t),{recursive:!0}),e.format===`toml`){let r=ao(zr(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=co(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=io(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Co={pi:Fa};function wo(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Co[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{Ie(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ee(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:ga(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function To(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function Eo(e){let t=Ii(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>So(t,``,n,e.home))}function Do(e,t,n,r){let i=ko(e,t,n,r);return i.kind===`present`?i.entry:null}function Oo(e,t,n,r){let i=ro(e,t,r);if(!A(i))return{kind:`no-entry`};let a=i[n];return A(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function ko(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(Ve(i).size>Za)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:fa(e)}}let a;try{a=R(i,`utf-8`)}catch(e){return{kind:`decline`,reason:fa(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Pa(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=zr().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Oo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Or.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Oo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=Ka(a);return s?qa(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Oo(ue(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ao(e={}){let t=P(e.cwd??process.cwd()),n=Ra(t,{homeDir:e.home}),r=n.projectRoot;if(de(r,e.home??z()))throw new y(r);let i=!L(M(r,`.ok`)),a=n.gitRootPromoted?N(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:_o(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${O(`[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 oe(r),u;try{u=be(r,{contentDir:o})}catch(t){let i=Q.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 d=u.created.includes(we),f=!1;if(c.didInit)try{f=me(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Se(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await po({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??Io(r,e.home),h=e.editors??m,g=Ii(m),_=Ii(h),v=e.mcp===!1||p===null,x=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),ee=g.filter(t=>bo(t,r,e.home)),C=[],te=[],ne=new Set;for(let t of x){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}C.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(lo(p)&&g.includes(t)&&t.scope===`global`&&C.push(So(t,r,s,e.home)),uo(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=So(t,r,s,e.home,n);C.push(i),(i.action===`written`||i.action===`overwritten`)&&ne.add(n)}}let ie=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||ie.has(n)||(ie.add(n),te.push(ua(t,r,{home:e.home})))}let ae=la(r,_.map(e=>e.id));ae&&te.push(ae);let se=te.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(se.length>0){let t=e.home??z();b({source:l,skills:[fe.project],agents:se,scope:r},{home:t,enabled:ge(t).enabled})}let ce=!v&&p!==null&&uo(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,le=v?[]:ee.map(e=>To(e,r)).filter(e=>e!==void 0).filter(e=>!ne.has(e.path)),ue=e.installUserSkill??xe,pe=e.home??z(),he=go(e.skills),ve=!1,ye=!1,w=!1,T=!1,E=!1;for(let t of S){if(!he.has(t))continue;await _e(pe,fe[t],!0).catch(()=>{}),ve=!0;let n=await ue({home:e.home,bundleId:t,force:!0});n===`installed`?ye=!0:n===`failed`?w=!0:n===`no-hosts`?E=!0:T=!0}let D=w?`failed`:ye?`installed`:ve&&T?`skip-current`:ve&&E?`no-hosts`:`declined`,Ce=ye?re(pe).map(e=>e.editorId):[],k=v?`skipped-flag`:`skipped-missing`,A=C.find(e=>e.editorId===`claude`)??C[0]??{action:k,configPath:Q.claude.configPath(r,e.home)},Te=await jo({projectRoot:r,desiredMode:await ho({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:C,projectSkills:te,legacyProjectConfigs:le,skillInstall:D,skillHosts:Ce,didGitInit:c.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:A.action,mcpPath:A.configPath,mcpError:`error`in A?A.error:void 0,projectScopeUnsupportedLabels:ce,sharing:Te}}async function jo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=Ui(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=zi(t);if(n===`local-only`){let e=Vi(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`}:Mo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=Hi(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Mo(t,o,`remove`)}function Mo(e,t,n){let r=Ui(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function No(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;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`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function Po(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`);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 s=M(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(k(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(k(`Content already present at ${s}/`)),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(k(`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(k(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(k(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${D(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${D(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Ce(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${No(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}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(k(`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?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${D(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${D(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${Ce(`FAILED`)}: ${r.error}`)}}}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} ${N(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(k(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>Y[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${D(`installed for ${r}`)}`),n.push(` ${E(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${E(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${D(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${E(`skipped for this run (--no-skills)`)}`),n.push(` ${E(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${E(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${E(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${E(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${O(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${O(` ok repair-skills`)}`)}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(O(`⚠ --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(O(`⚠ 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(Te(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...zo(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(`${D(`✓`)} ${k(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${T(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${T(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
691
691
  `)}function Fo(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 Io(e,t){let n=[];for(let r of Vr)r!==`claude-desktop`&&bo(Q[r],e,t)&&n.push(r);return n}function Lo(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:We(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 Ro(){return new st(`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)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new lt(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new lt(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new lt(`--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?Lo():null;try{let r;try{r=await Ao({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $||e instanceof y){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof C||e instanceof te){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof he){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.
692
- `),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-Ciy1lUFM.mjs`),{resolveContentDir:s}=await import(`./dist-B4TxkELG.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-A8NnvAZh.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(Fo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Po(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function zo(e,t){let n=[];switch(e.kind){case`applied`:return n.push(k(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${D(`local-only`)} — appended ${e.appended.length} path(s) to ${k(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${D(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${D(`local-only`)} — already excluded; nothing to do.`):n.push(` ${D(`local-only`)}`):e.action===`removed`?n.push(` ${D(`shared`)} — removed OK paths from ${k(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${D(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(O(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
692
+ `),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-BhG6F89Z.mjs`),{resolveContentDir:s}=await import(`./dist-DaZTzrgH.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-C8mnnE3O.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(Fo(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Po(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function zo(e,t){let n=[];switch(e.kind){case`applied`:return n.push(k(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${D(`local-only`)} — appended ${e.appended.length} path(s) to ${k(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${D(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${D(`local-only`)} — already excluded; nothing to do.`):n.push(` ${D(`local-only`)}`):e.action===`removed`?n.push(` ${D(`shared`)} — removed OK paths from ${k(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${D(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(O(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
693
693
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${T(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(O(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${T(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${T(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(O(`Sharing mode unavailable: ${e.reason}.`));return n}}export{hi as $,_a as A,Ki as B,Ra as C,Ta as D,Aa as E,ea as F,Ui as G,Bi as H,da as I,Y as J,Hi as K,ra as L,fa as M,na as N,ga as O,$i as P,gi as Q,ua as R,Ua as S,Na as T,zi as U,Wi as V,Gi as W,Hr as X,Q as Y,X as Z,Ao as _,yt as _t,Fo as a,Z as at,Eo as b,lt as bt,Po as c,ai as ct,bo as d,Zn as dt,_i as et,Do as f,Bn as ft,ho as g,H as gt,_o as h,Gt as ht,jo as i,yi as it,pa as j,ha as k,zo as l,Br as lt,po as m,Kt as mt,yo as n,Qr as nt,ko as o,bi as ot,go as p,Yt as pt,Vr as q,Co as r,ti as rt,Io as s,ji as st,$ as t,vi as tt,Ro as u,zr as ut,to as v,st as vt,Fa as w,xo as x,So as y,at as yt,Vi as z};
@@ -0,0 +1 @@
1
+ import"./dist-9e6NmrQK.mjs";import{_ as e}from"./init-BS8pi6aE.mjs";export{e as runInit};
@@ -1 +1 @@
1
- import{ho as e,vo as t,xo as n}from"./dist-CjH-Sf5k.mjs";import{A as r,M as i,O as a}from"./init-Ex7PlJbP.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-xOV2YbGI.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=e(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
1
+ import{ho as e,vo as t,xo as n}from"./dist-9e6NmrQK.mjs";import{A as r,M as i,O as a}from"./init-BS8pi6aE.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-D62fA-37.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:i(e)}}let g=[],_=t(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=e(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=r(h,[`configurations`,y]);return x?(n(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-CEM2DZT5.mjs";export{e as loadConfig};
@@ -1 +1 @@
1
- import{Ec as e,Ha as t,Nc as n,Uo as r,Wc as i,eu as a,wc as o}from"./md-manager-BGnqyqi1-BKxqDqfk.mjs";import{Co as s,To as c,b as l}from"./dist-CjH-Sf5k.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CN-OP4lK.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=a();async function _(e){let t=f(e);try{return await h(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}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){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(t.doc!==null&&t.source!==null){let e=n({file:t.path,source:t.source,doc:t.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function b(n){let a=n??process.cwd(),u=[],p=[],m=[],h=[],g=c(`user`,a),_=s({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,n=!1)=>{let r=v(e);if(r.diagnostic!==void 0&&p.push(r.diagnostic),r.value===null)return{};let a=o({value:r.value,file:r.path,source:r.source,doc:r.doc});p.push(...a),u.push(e);let s=a.length>0?i(r.value):r.value;return n&&h.push(...t({value:s,file:r.path,source:r.source,doc:r.doc})),s},x=f(a,`.ok`,d),S=b(x,!0),C=b(c(`project-local`,a)),w=r(_.value,S,C),T=l.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
1
+ import{Dc as e,Gc as t,Ha as n,Pc as r,Tc as i,Uo as a,tu as o}from"./md-manager-BGnqyqi1-C0-0a_4T.mjs";import{Co as s,To as c,b as l}from"./dist-9e6NmrQK.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CDtlxNjm.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=o();async function _(e){let t=f(e);try{return await h(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}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=r({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...i,source:e}}return i})}function b(r){let o=r??process.cwd(),u=[],p=[],m=[],h=[],g=c(`user`,o),_=s({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,r=!1)=>{let a=v(e);if(a.diagnostic!==void 0&&p.push(a.diagnostic),a.value===null)return{};let o=i({value:a.value,file:a.path,source:a.source,doc:a.doc});p.push(...o),u.push(e);let s=o.length>0?t(a.value):a.value;return r&&h.push(...n({value:s,file:a.path,source:a.source,doc:a.doc})),s},x=f(o,`.ok`,d),S=b(x,!0),C=b(c(`project-local`,o)),w=a(_.value,S,C),T=l.safeParse(w);if(!T.success){let t=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,t)};throw Error(e(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};