@inkeep/open-knowledge 0.85.0-beta.0 → 0.85.0-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.
- package/dist/cli.mjs +58 -58
- package/dist/constants-CEWqiFCf.mjs +1 -0
- package/dist/dist-CqZISrZN.mjs +2212 -0
- package/dist/{dist-Dda0D3aV.mjs → dist-DjEZX3vG.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-8obEC39z.mjs → init-BontxrPQ.mjs} +21 -21
- package/dist/init-BtiXJkEo.mjs +1 -0
- package/dist/{launch-json-removal-gEgkQN8h.mjs → launch-json-removal-CDHWF-ku.mjs} +1 -1
- package/dist/loader-CkxCQRBx.mjs +1 -0
- package/dist/{loader-DWY1RHg1.mjs → loader-DMoA9Hv1.mjs} +1 -1
- package/dist/{md-manager-BGnqyqi1-CKR6E7Rf.mjs → md-manager-BGnqyqi1-dBGkA2rR.mjs} +176 -155
- package/dist/native/native-config.win32-arm64-msvc.node +0 -0
- package/dist/native/native-config.win32-x64-msvc.node +0 -0
- package/dist/native/package.json +1 -1
- package/dist/{open-browser-Bd-Va7d5.mjs → open-browser-CbRl45f4.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-Cf5VnxW_.mjs +1 -0
- package/dist/{preview-BK4eZzn2.mjs → preview-vc6NgNe_.mjs} +1 -1
- package/dist/{registry-probes-SbSR_s99.mjs → registry-probes-Cwx6O6kv.mjs} +3 -3
- package/dist/{removal-file-path-gFE6O5Or.mjs → removal-file-path-D0LbC71-.mjs} +1 -1
- package/dist/{repair-launch-json-QdjFSCpy.mjs → repair-launch-json-sysIcyZL.mjs} +1 -1
- package/dist/{repair-mcp-configs-DGRbJX9u.mjs → repair-mcp-configs-mZrdQ93t.mjs} +1 -1
- package/dist/src-BKnvpIkn.mjs +14 -0
- package/dist/src-DWEbxzXJ.mjs +1 -0
- package/dist/start-Dh1mqp4M.mjs +1 -0
- package/dist/{start-QSvpDCbj.mjs → start-lQOFYtsk.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-CLSFu78r.mjs +0 -1
- package/dist/dist-C8gZeqCx.mjs +0 -2212
- package/dist/init-DNQgK__1.mjs +0 -1
- package/dist/loader-gqcYinvk.mjs +0 -1
- package/dist/preview-DVmWbeys.mjs +0 -1
- package/dist/src-D-5pW72q.mjs +0 -1
- package/dist/src-DnbociwA.mjs +0 -14
- package/dist/start-Da-7M-7H.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dt as e,Qs as t,Tt as n,Wa as r,Y as i,ac as a,hc as o,v as s}from"./md-manager-BGnqyqi1-CKR6E7Rf.mjs";import{$ as c,$a as l,$i as u,$n as d,$r as f,$t as p,A as m,Aa as h,Ai as g,An as _,Ao as v,Ar as y,At as b,B as x,Ba as S,Bi as C,Bn as w,Br as T,Bt as E,C as D,Ca as O,Ci as k,Cn as A,Co as j,Cr as M,Ct as N,D as P,Da as F,Di as I,Dn as L,Do as R,Dr as z,Ds as B,Dt as V,E as H,Ea as U,Ei as W,En as G,Eo as K,Er as q,Es as J,Et as Y,F as X,Fa as Z,Fi as Q,Fn as $,Fo as ee,Fr as te,Ft as ne,G as re,Ga as ie,Gi as ae,Gn as oe,Gr as se,Gt as ce,H as le,Ha as ue,Hi as de,Hn 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,Mo as Ge,Mr as Ke,Mt as qe,N as Je,Na as Ye,Ni as Xe,Nn as Ze,No as Qe,Nr as $e,Nt as et,O as tt,Oa as nt,Oi as rt,On as it,Oo as at,Or as ot,Os as st,Ot as ct,P as lt,Pa as ut,Pi as dt,Pn as ft,Po as pt,Pr as mt,Pt as ht,Q as gt,Qa as _t,Qi as vt,Qn as yt,Qr as bt,Qt as xt,R as St,Ra as Ct,Ri as wt,Rn as Tt,Rr as Et,Rt as Dt,S as Ot,Sa as kt,Si as At,Sn as jt,So as Mt,Sr as Nt,Ss as Pt,St as Ft,T as It,Ta as Lt,Ti as Rt,Tn as zt,To as Bt,Tr as Vt,Ts as Ht,Tt as Ut,U as Wt,Ua as Gt,Ui as Kt,Un as qt,Ur as Jt,Ut as Yt,V as Xt,Va as Zt,Vi as Qt,Vn as $t,Vr as en,Vt as tn,W as nn,Wa as rn,Wi as an,Wn as on,Wr as sn,Wt as cn,X as ln,Xa as un,Xi as dn,Xn as fn,Xr as pn,Xt as mn,Y as hn,Ya as gn,Yi as _n,Yn as vn,Yr as yn,Yt as bn,Z as xn,Za as Sn,Zi as Cn,Zn as wn,Zr as Tn,Zt as En,_ as Dn,_a as On,_i as kn,_n as An,_o as jn,_r as Mn,_s as Nn,_t as Pn,a as Fn,aa as In,ai as Ln,an as Rn,ao as zn,ar as Bn,at as Vn,b as Hn,ba as Un,bi as Wn,bn as Gn,bo as Kn,br as qn,bs as Jn,bt as Yn,c as Xn,ca as Zn,ci as Qn,cn as $n,co as er,cr as tr,ct as nr,d as rr,da as ir,di as ar,dn as or,do as sr,dr as cr,dt as lr,ea as ur,ei as dr,en as fr,eo as pr,er as mr,et as hr,f as gr,fa as _r,fi as vr,fn as yr,fo as br,fr as xr,ft as Sr,g as Cr,ga as wr,gi as Tr,gn as Er,go as Dr,gr as Or,gs as kr,gt as Ar,h as jr,ha as Mr,hi as Nr,hn as Pr,ho as Fr,hr as Ir,hs as Lr,ht as Rr,i as zr,ia as Br,ii as Vr,in as Hr,io as Ur,ir as Wr,it as Gr,j as Kr,ja as qr,ji as Jr,jn as Yr,jo as Xr,jr as Zr,jt as Qr,k as $r,ka as ei,ki as ti,kn as ni,ko as ri,kr as ii,kt as ai,l as oi,la as si,li as ci,ln as li,lo as ui,lr as di,ls as fi,lt as pi,m as mi,ma as hi,mi as gi,mn as _i,mo as vi,mr as yi,ms as bi,mt as xi,n as Si,na as Ci,ni as wi,nn as Ti,no as Ei,nr as Di,nt as Oi,o as ki,oa as Ai,oi as ji,on as Mi,oo as Ni,or as Pi,ot as Fi,p as Ii,pa as Li,pi as Ri,pn as zi,po as Bi,pr as Vi,pt as Hi,q as Ui,qa as Wi,qi as Gi,qn as Ki,qr as qi,qt as Ji,r as Yi,ra as Xi,ri as Zi,rn as Qi,ro as $i,rr as ea,rt as ta,s as na,sa as ra,si as ia,sn as aa,so as oa,sr as sa,st as ca,t as la,ta as ua,ti as da,tn as fa,to as pa,tr as ma,tt as ha,u as ga,ua as _a,ui as va,un as ya,uo as ba,ur as xa,us as Sa,ut as Ca,v as wa,va as Ta,vi as Ea,vn as Da,vo as Oa,vr as ka,vs as Aa,vt as ja,w as Ma,wa as Na,wi as Pa,wn as Fa,wo as Ia,wr as La,wt as Ra,x as za,xa as Ba,xi as Va,xn as Ha,xo as Ua,xr as Wa,xs as Ga,xt as Ka,y as qa,ya as Ja,yi as Ya,yn as Xa,yo as Za,yr as Qa,ys as $a,yt as eo,z as to,za as no,zi as ro,zn as io,zr as ao,zt as oo}from"./dist-C8gZeqCx.mjs";export{la as AGENT_ID_MAX_LEN,Si as AGENT_ID_RE,Yi as AGENT_WRITE_ORIGIN,r as AUDIT_EMPTY_SCOPE_WARNING,zr as AcpPermissionStore,Fn as AcpRegistry,ki as AcpThreadManager,na as AgentFocusBroadcaster,Xn as AgentPresenceBroadcaster,oi as AgentSessionCapacityError,ga as AgentSessionManager,rr as AutoStartDisabledError,gr as BUNDLE_IDS,Ii as BUNDLE_SCOPE,mi as BUNDLE_SKILL_NAME,jr as BacklinkIndex,Cr as CC1Broadcaster,a as CC1_CONTRACT_VERSION,Dn as CONCURRENT_REPLACE_WINDOW_MS,wa as CONFIG_FILENAME,qa as CONFLICT_MARKER_RE,Hn as CURSOR_BUNDLE_PATHS_BY_PLATFORM,za as ConfigSchema,Ot as ConflictAuthority,D as DEFAULT_CHECKPOINT_RETENTION,Ma as DEFAULT_EMBEDDINGS_DIMENSIONS,It as DEFAULT_PACK_ID,H as DocumentDurabilityState,P as DocumentDurabilityStateError,tt as EMBEDDINGS_API_KEY_ENV,$r as EPHEMERAL_PROJECT_DIR_PREFIX,m as ExposureConsentError,Kr as FEATURED_AGENT_IDS,Ve as FILE_SYSTEM_WRITER,Je as FILE_WATCHER_ORIGIN,lt as FileEmbeddingsBackend,X as FilesystemRootProjectError,he as GIT_PREFLIGHT_FAIL_SPAN_NAME,Pe as GIT_UPSTREAM_WRITER,fi as GitDirAccessError,St as GitNotAvailableError,to as GitTooOldError,x as HOCUSPOCUS_AUTH_REJECTION_REASONS,Xt as HocuspocusAuthRejection,le as HocuspocusAuthTokenSchema,Wt as HomeProjectRootError,nn as INSTALLED_AGENTS_SCHEMES,re as JSON_SCHEMA_DIALECT_2020_12,B as LINEAGE_EPOCH_KEY,Oe as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ui as MANAGED_RENAME_ORIGIN,Se as MAX_ACP_THREADS,hn as MAX_AGENT_SESSIONS,ln as MCP_CONNECTION_ID_HEADER,t as MCP_SERVER_NAME,xn as MIN_EVICTABLE_IDLE_MS,gt as MIN_GIT_VERSION,c as MISSING_OK_CONFIG_MESSAGE,Sa as MalformedGitPointerError,hr as McpLogger,ha as MissingOkConfigError,Oi as OBSERVER_SYNC_ORIGIN,ta as OK_OKIGNORE_TEMPLATE,Gr as ONBOARDING_BUNDLE_IDS,Ht as ORPHAN_MODES,st as PROTOCOL_VERSION,bi as PinoLogger,Vn as ProcessLockCollisionError,Fi as ProjectGitInitError,ca as ROLLBACK_ORIGIN,nr as ROOT_GITIGNORE_TEMPLATE,pi as RUNTIME_VERSION,Ca as SERVICE_WRITER,lr as SKILL_INSTALL_EVENTS_FILENAME,s as SKILL_STATE_TARGETS,Sr as STARTER_FOLDER_FRONTMATTER_FILENAME,Hi as STARTER_PACKS,xi as STARTER_PACK_IDS,Rr as STATE_MANIFEST_FILENAME,Ar as STATE_SCHEMA_VERSION,Pn as SYMLINK_MERGE_MIN_GIT_LABEL,ja as SYMLINK_MERGE_MIN_GIT_VERSION,o as SYSTEM_DOC_NAME,eo as SeedPrerequisiteError,Yn as SeedRootDirError,Ka as ServerAuthorityCollisionError,Ft as ServerAuthorityRegistryError,N as ServerLockCollisionError,Ra as SingleFileNotAFileError,Ut as SingleFileNotFoundError,Y as SingleFileNotMarkdownError,V as SingleFileProjectOverrideError,ct as StateManifestError,ai as TagIndex,b as USER_GLOBAL_BUNDLE_IDS,Qr as UnsafeIncomingSymlinkError,qe as __getShowAllWalkStatsForTesting,et as __resetShowAllWalkStatsForTesting,ht as acpThreadStoreRoots,ne as acpThreadsDir,xe as acquireProcessLock,Be as acquireServerLock,Dt as applyAgentMarkdownWrite,oo as applyExternalChange,E as applySeed,tn as assertCheckoutSymlinksSafe,me as assertCompatibleStateManifest,Yt as assertGitAvailable,cn as assertIncomingSymlinksSafe,ce as assertMergeNameResolvesTo,Ne as assertNeverDiskEvent,Ji as assertRepoCheckoutSymlinksSafe,De as assertSafeProjectRoot,bn as attachAcpThreadSocket,mn as attachCollabClientCounter,En as attachIdleShutdown,xt as auditScopeNotFoundTitle,p as bindConflictAuthority,fr as bootServer,fa as buildAndOpenSkill,Ti as buildConfigYmlContent,Qi as buildExecResult,Hr as buildIngressPolicy,Rn as buildOkMcpStdioCommand,Mi as buildSkillZip,aa as buildStarterFolderFrontmatterYaml,$n as buildWipTree,li as bundleSkillMdPath,ya as canonicalProjectKey,or as canonicalizeForCompare,yr as classifyEvents,zi as classifyFsPath,_i as clearAllEmbeddingsKeys,Pr as coercePackId,Er as collectServerHostSnapshot,n as colorFromSeed,An as commitUpstreamImport,Da as commitWip,Xa as commitWipFromTree,Gn as compareSemver,Ha as composeEffectiveLinterConfig,jt as composeFrontmatterSchemasConfig,A as containsConflictMarkers,Fa as contentHash,zt as contributorCount,G as countShadowObjects,L as countStaleAgentWipRefs,it as countWipRefs,ni as createApiExtension,_ as createAssetServeMiddleware,Yr as createCollaborationHost,We as createContentFilter,Ze as createContentFilterAsync,ft as createEmbeddingsSecretStore,$ as createEphemeralProjectDir,ve as createExternalChangeHandler,Le as createFileLogger,Tt as createLiveDerivedIndexExtension,io as createMcpHttpHandler,w as createOsProbe,$t as createPersistenceExtension,fe as createProbeFailureReporter,qt as createServer,on as createServerObserverExtension,oe as createServerProbeResolver,je as createStreamingErrorWriter,Lr as createTestLogger,Ki as describeStoredEmbeddingsKey,Te as detectClaudeDesktopPresence,vn as detectGit,fn as detectProjectShape,wn as detectUserSkillHosts,yt as discoverLockDirs,d as discoverMarkdownlintConfig,mr as emitPreflightFailureSpan,ma as encodeDocName,Di as encodeFolderRoute,ea as encodeSkillRoute,Wr as ensureProjectGit,Bn as errorResponse,Pi as evictStaleTrackerEntries,sa as extractHeadings,tr as extractOkBinaryPath,di as extractWikiLinksFromMarkdown,xa as fallbackPaths,cr as findEnclosingGitRoot,xr as findEnclosingProjectRoot,Vi as findNativeMarkdownlintFile,yi as flushFileLogger,Ir as formatAuditBrokenLinkSuppressionLine,Or as formatAuthRejectionWire,Mn as formatContributorsFrom,ka as formatPackRationale,Qa as gcCheckpointRefs,qn as getCurrentMcpLogger,Wa as getIngressContext,Nt as getLocalDir,M as getLogFilePath,kr as getLogger,La as getLogsDir,Vt as getMachineId,q as getMeter,z as getMetrics,ot as getTracer,ii as handleCollabSocketError,y as handleSpawnCursor,Zr as hasForwardingHeaders,Ke as hasGcLogLatch,e as iconFromClientName,$e as incrementCollabSocketFilteredError,mt as incrementServerObserverFire,te as initContent,be as initShadowRepo,ze as initTelemetry,Et as initToleranceTelemetryWriter,ao as installJsonSchemaDialect,T as installPrettyZodErrors,Nn as installTestLoggers,en as installUserSkill,pe as isAllowedApiOrigin,Jt as isAllowedWorkspaceHostHeader,sn as isConfigDoc,se as isDefunctProcess,Me as isDocInConflict,qi as isFilesystemRoot,Ee as isHocuspocusAuthRejectionReason,yn as isHomeDir,pn as isHostAdmitted,Tn as isKnownPackId,bt as isLinkIndexExcludedDoc,f as isLockProcessRunning,dr as isLoopbackAddress,da as isManagedArtifactDoc,wi as isMintedThreadId,Zi as isOriginAdmitted,J as isOrphanMode,Vr as isPairedWriteOrigin,Ln as isPathWithinDir,ji as isPeerAdmitted,ia as isProcessAlive,Qn as isProjectRoot,ci as isReservedForUserTree,va as isSelfWrite,ar as isSkillInstallReportEnvOptOut,vr as isSystemDoc,Ri as isToleranceTelemetryEnabled,gi as isValidLockPid,Nr as lastKnownHash,Tr as listRescueCheckpoints,kn as listStarterPacks,Ea as loadCustomAgents,Ya as loadPrincipal,Wn as lockAdvertisesUi,Va as lockBaseUrl,At as lockFilePath,Aa as loggerFactory,k as loginShapedUserinfoUser,$a as logsCurrentPath,Jn as logsPreviousPath,Pa as makeLazyEmbeddingsKeyStore,Rt as markServerLockDraining,W as mountMcpAndApi,I as normalizeFsPath,rt as observeReadiness,ti as packageVersionMajorMinor,g as parseAuthRejectionWire,Jr as parseGitVersion,Ue as parseHocuspocusAuthToken,Xe as parseKeepaliveConnectionId,dt as pathToDocName,Q as planSeed,_e as prepareSingleFileOpen,Ie as processCommand,wt as processUsage,ro as readAgentBrowserTools,C as readAllTargets,Qt as readBundleDecision,de as readDeclaredGitHubHosts,Kt as readOriginCredentialHost,an as readOriginGitHubRepo,ae as readOwnNativeRules,Ae as readProcessLock,Gi as readProcessLockDetailed,we as readProcessState,_n as readProjectHeadState,dn as readProjectLocalSemanticConfig,Cn as readServerLock,vt as readServerPackageVersion,u as readSkillInstallStateSnapshot,ur as readStateManifest,ua as readTargetRecordedAt,Ci as readTargetVersion,Xi as reconcile,Br as recordContributor,In as recordSkillInstallEvent,Ai as redactShareSubprocessStderr,ra as registerAllTools,Zn as registerWrite,si as releaseProcessLock,_a as releaseServerLock,ir as removeLastKnownHash,_r as removeProjectSkillGitignoreBlock,Li as reportSkillInstall,hi as resetMetrics,Mr as resolveAuditScope,wr as resolveBuiltinSkillHosts,i as resolveBundleEnabled,On as resolveBundledSkillDir,Ta as resolveContentDir,Ja as resolveCursorBinaryDefault,Un as resolveCursorSpawnInvocation,Ba as resolveEffectiveLinterConfig,kt as resolveEmbeddingsCredential,O as resolveGitHubAccountFromUrl,Na as resolveGitHubAuthHost,Lt as resolveLockDir,U as resolveNativeConfigForDoc,F as resolveNativeMarkdownlintConfig,nt as resolvePack,ei as resolvePackageVersion,h as resolveSkillInstallReportSettings,qr as resolveUiInfo,He as restoreContributors,Ye as rewriteMarkdownLinksForDocumentRename,ut as rewriteWikiLinksForDocumentRename,Z as runAuthReposSubprocess,ge as runAuthStatusSubprocess,Fe as runCloneSubprocess,Ct as runDeviceFlowSubprocess,no as runWithMcpLogger,S as safeContentPath,Zt as safeSubdir,ue as safetyCheckpoint,Gt as sameGitHubLogin,rn as sanitizeClientName,ie as saveInMemoryCheckpoint,ke as saveVersion,Wi as scanLockProcesses,Ce as seedBasenameIndex,gn as seedEphemeralProjectDir,un as serializeError,Sn as setActiveSpanAttributes,_t as setupServerObservers,l as shadowGit,pr as shutdownTelemetry,Ga as spansCurrentPath,Pt as spansPreviousPath,pa as spawnDetached,Ei as splitMarkdownBlocks,$i as startWatcher,Ur as strategiesFor,zn as streamedChunkOf,Ni as streamingProblemEvent,oa as swapContributors,er as teardownToleranceTelemetryWriter,ui as toBroadcasterKey,ba as tracedAppendFileSync,sr as tracedLinkSync,br as tracedMkdir,Bi as tracedMkdirSync,vi as tracedRename,Fr as tracedRenameSync,Dr as tracedRmSync,jn as tracedRmdirSync,Oa as tracedUnlinkSync,Za as tracedWriteFile,Kn as tracedWriteFileSync,Ua as trustSystemCertificates,Mt as updateLastKnownHash,j as updateProcessLockPort,Ia as updateServerLockPort,Bt as validateAgentId,K as validateCloneInputs,R as validateSkillZip,at as waitForServerLockDrain,ri as withHiddenWindowsConsole,v as withSpan,Xr as withSpanSync,Ge as writeBundleDecision,Qe as writeMarkdownlintRule,pt as writeRootGitignoreForNewRepo,ee as writeStateManifest,ye as writeTargetVersion,Re as writeTracker};
|
|
1
|
+
import{Dt as e,Qs as t,Tt as n,Wa as r,Y as i,ac as a,hc as o,v as s}from"./md-manager-BGnqyqi1-dBGkA2rR.mjs";import{$ as c,$a as l,$i as u,$n as d,$r as f,$t as p,A as m,Aa as h,Ai as g,An as _,Ao as v,Ar as y,At as b,B as x,Ba as S,Bi as C,Bn as w,Br as T,Bt as E,C as D,Ca as O,Ci as k,Cn as A,Co as j,Cr as M,Ct as N,D as P,Da as F,Di as I,Dn as L,Do as R,Dr as z,Ds as B,Dt as V,E as H,Ea as U,Ei as W,En as G,Eo as K,Er as q,Es as J,Et as Y,F as X,Fa as Z,Fi as Q,Fn as $,Fo as ee,Fr as te,Ft as ne,G as re,Ga as ie,Gi as ae,Gn as oe,Gr as se,Gt as ce,H as le,Ha as ue,Hi as de,Hn 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,Mo as Ge,Mr as Ke,Mt as qe,N as Je,Na as Ye,Ni as Xe,Nn as Ze,No as Qe,Nr as $e,Nt as et,O as tt,Oa as nt,Oi as rt,On as it,Oo as at,Or as ot,Os as st,Ot as ct,P as lt,Pa as ut,Pi as dt,Pn as ft,Po as pt,Pr as mt,Pt as ht,Q as gt,Qa as _t,Qi as vt,Qn as yt,Qr as bt,Qt as xt,R as St,Ra as Ct,Ri as wt,Rn as Tt,Rr as Et,Rt as Dt,S as Ot,Sa as kt,Si as At,Sn as jt,So as Mt,Sr as Nt,Ss as Pt,St as Ft,T as It,Ta as Lt,Ti as Rt,Tn as zt,To as Bt,Tr as Vt,Ts as Ht,Tt as Ut,U as Wt,Ua as Gt,Ui as Kt,Un as qt,Ur as Jt,Ut as Yt,V as Xt,Va as Zt,Vi as Qt,Vn as $t,Vr as en,Vt as tn,W as nn,Wa as rn,Wi as an,Wn as on,Wr as sn,Wt as cn,X as ln,Xa as un,Xi as dn,Xn as fn,Xr as pn,Xt as mn,Y as hn,Ya as gn,Yi as _n,Yn as vn,Yr as yn,Yt as bn,Z as xn,Za as Sn,Zi as Cn,Zn as wn,Zr as Tn,Zt as En,_ as Dn,_a as On,_i as kn,_n as An,_o as jn,_r as Mn,_s as Nn,_t as Pn,a as Fn,aa as In,ai as Ln,an as Rn,ao as zn,ar as Bn,at as Vn,b as Hn,ba as Un,bi as Wn,bn as Gn,bo as Kn,br as qn,bs as Jn,bt as Yn,c as Xn,ca as Zn,ci as Qn,cn as $n,co as er,cr as tr,ct as nr,d as rr,da as ir,di as ar,dn as or,do as sr,dr as cr,dt as lr,ea as ur,ei as dr,en as fr,eo as pr,er as mr,et as hr,f as gr,fa as _r,fi as vr,fn as yr,fo as br,fr as xr,ft as Sr,g as Cr,ga as wr,gi as Tr,gn as Er,go as Dr,gr as Or,gs as kr,gt as Ar,h as jr,ha as Mr,hi as Nr,hn as Pr,ho as Fr,hr as Ir,hs as Lr,ht as Rr,i as zr,ia as Br,ii as Vr,in as Hr,io as Ur,ir as Wr,it as Gr,j as Kr,ja as qr,ji as Jr,jn as Yr,jo as Xr,jr as Zr,jt as Qr,k as $r,ka as ei,ki as ti,kn as ni,ko as ri,kr as ii,kt as ai,l as oi,la as si,li as ci,ln as li,lo as ui,lr as di,ls as fi,lt as pi,m as mi,ma as hi,mi as gi,mn as _i,mo as vi,mr as yi,ms as bi,mt as xi,n as Si,na as Ci,ni as wi,nn as Ti,no as Ei,nr as Di,nt as Oi,o as ki,oa as Ai,oi as ji,on as Mi,oo as Ni,or as Pi,ot as Fi,p as Ii,pa as Li,pi as Ri,pn as zi,po as Bi,pr as Vi,pt as Hi,q as Ui,qa as Wi,qi as Gi,qn as Ki,qr as qi,qt as Ji,r as Yi,ra as Xi,ri as Zi,rn as Qi,ro as $i,rr as ea,rt as ta,s as na,sa as ra,si as ia,sn as aa,so as oa,sr as sa,st as ca,t as la,ta as ua,ti as da,tn as fa,to as pa,tr as ma,tt as ha,u as ga,ua as _a,ui as va,un as ya,uo as ba,ur as xa,us as Sa,ut as Ca,v as wa,va as Ta,vi as Ea,vn as Da,vo as Oa,vr as ka,vs as Aa,vt as ja,w as Ma,wa as Na,wi as Pa,wn as Fa,wo as Ia,wr as La,wt as Ra,x as za,xa as Ba,xi as Va,xn as Ha,xo as Ua,xr as Wa,xs as Ga,xt as Ka,y as qa,ya as Ja,yi as Ya,yn as Xa,yo as Za,yr as Qa,ys as $a,yt as eo,z as to,za as no,zi as ro,zn as io,zr as ao,zt as oo}from"./dist-CqZISrZN.mjs";export{la as AGENT_ID_MAX_LEN,Si as AGENT_ID_RE,Yi as AGENT_WRITE_ORIGIN,r as AUDIT_EMPTY_SCOPE_WARNING,zr as AcpPermissionStore,Fn as AcpRegistry,ki as AcpThreadManager,na as AgentFocusBroadcaster,Xn as AgentPresenceBroadcaster,oi as AgentSessionCapacityError,ga as AgentSessionManager,rr as AutoStartDisabledError,gr as BUNDLE_IDS,Ii as BUNDLE_SCOPE,mi as BUNDLE_SKILL_NAME,jr as BacklinkIndex,Cr as CC1Broadcaster,a as CC1_CONTRACT_VERSION,Dn as CONCURRENT_REPLACE_WINDOW_MS,wa as CONFIG_FILENAME,qa as CONFLICT_MARKER_RE,Hn as CURSOR_BUNDLE_PATHS_BY_PLATFORM,za as ConfigSchema,Ot as ConflictAuthority,D as DEFAULT_CHECKPOINT_RETENTION,Ma as DEFAULT_EMBEDDINGS_DIMENSIONS,It as DEFAULT_PACK_ID,H as DocumentDurabilityState,P as DocumentDurabilityStateError,tt as EMBEDDINGS_API_KEY_ENV,$r as EPHEMERAL_PROJECT_DIR_PREFIX,m as ExposureConsentError,Kr as FEATURED_AGENT_IDS,Ve as FILE_SYSTEM_WRITER,Je as FILE_WATCHER_ORIGIN,lt as FileEmbeddingsBackend,X as FilesystemRootProjectError,he as GIT_PREFLIGHT_FAIL_SPAN_NAME,Pe as GIT_UPSTREAM_WRITER,fi as GitDirAccessError,St as GitNotAvailableError,to as GitTooOldError,x as HOCUSPOCUS_AUTH_REJECTION_REASONS,Xt as HocuspocusAuthRejection,le as HocuspocusAuthTokenSchema,Wt as HomeProjectRootError,nn as INSTALLED_AGENTS_SCHEMES,re as JSON_SCHEMA_DIALECT_2020_12,B as LINEAGE_EPOCH_KEY,Oe as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ui as MANAGED_RENAME_ORIGIN,Se as MAX_ACP_THREADS,hn as MAX_AGENT_SESSIONS,ln as MCP_CONNECTION_ID_HEADER,t as MCP_SERVER_NAME,xn as MIN_EVICTABLE_IDLE_MS,gt as MIN_GIT_VERSION,c as MISSING_OK_CONFIG_MESSAGE,Sa as MalformedGitPointerError,hr as McpLogger,ha as MissingOkConfigError,Oi as OBSERVER_SYNC_ORIGIN,ta as OK_OKIGNORE_TEMPLATE,Gr as ONBOARDING_BUNDLE_IDS,Ht as ORPHAN_MODES,st as PROTOCOL_VERSION,bi as PinoLogger,Vn as ProcessLockCollisionError,Fi as ProjectGitInitError,ca as ROLLBACK_ORIGIN,nr as ROOT_GITIGNORE_TEMPLATE,pi as RUNTIME_VERSION,Ca as SERVICE_WRITER,lr as SKILL_INSTALL_EVENTS_FILENAME,s as SKILL_STATE_TARGETS,Sr as STARTER_FOLDER_FRONTMATTER_FILENAME,Hi as STARTER_PACKS,xi as STARTER_PACK_IDS,Rr as STATE_MANIFEST_FILENAME,Ar as STATE_SCHEMA_VERSION,Pn as SYMLINK_MERGE_MIN_GIT_LABEL,ja as SYMLINK_MERGE_MIN_GIT_VERSION,o as SYSTEM_DOC_NAME,eo as SeedPrerequisiteError,Yn as SeedRootDirError,Ka as ServerAuthorityCollisionError,Ft as ServerAuthorityRegistryError,N as ServerLockCollisionError,Ra as SingleFileNotAFileError,Ut as SingleFileNotFoundError,Y as SingleFileNotMarkdownError,V as SingleFileProjectOverrideError,ct as StateManifestError,ai as TagIndex,b as USER_GLOBAL_BUNDLE_IDS,Qr as UnsafeIncomingSymlinkError,qe as __getShowAllWalkStatsForTesting,et as __resetShowAllWalkStatsForTesting,ht as acpThreadStoreRoots,ne as acpThreadsDir,xe as acquireProcessLock,Be as acquireServerLock,Dt as applyAgentMarkdownWrite,oo as applyExternalChange,E as applySeed,tn as assertCheckoutSymlinksSafe,me as assertCompatibleStateManifest,Yt as assertGitAvailable,cn as assertIncomingSymlinksSafe,ce as assertMergeNameResolvesTo,Ne as assertNeverDiskEvent,Ji as assertRepoCheckoutSymlinksSafe,De as assertSafeProjectRoot,bn as attachAcpThreadSocket,mn as attachCollabClientCounter,En as attachIdleShutdown,xt as auditScopeNotFoundTitle,p as bindConflictAuthority,fr as bootServer,fa as buildAndOpenSkill,Ti as buildConfigYmlContent,Qi as buildExecResult,Hr as buildIngressPolicy,Rn as buildOkMcpStdioCommand,Mi as buildSkillZip,aa as buildStarterFolderFrontmatterYaml,$n as buildWipTree,li as bundleSkillMdPath,ya as canonicalProjectKey,or as canonicalizeForCompare,yr as classifyEvents,zi as classifyFsPath,_i as clearAllEmbeddingsKeys,Pr as coercePackId,Er as collectServerHostSnapshot,n as colorFromSeed,An as commitUpstreamImport,Da as commitWip,Xa as commitWipFromTree,Gn as compareSemver,Ha as composeEffectiveLinterConfig,jt as composeFrontmatterSchemasConfig,A as containsConflictMarkers,Fa as contentHash,zt as contributorCount,G as countShadowObjects,L as countStaleAgentWipRefs,it as countWipRefs,ni as createApiExtension,_ as createAssetServeMiddleware,Yr as createCollaborationHost,We as createContentFilter,Ze as createContentFilterAsync,ft as createEmbeddingsSecretStore,$ as createEphemeralProjectDir,ve as createExternalChangeHandler,Le as createFileLogger,Tt as createLiveDerivedIndexExtension,io as createMcpHttpHandler,w as createOsProbe,$t as createPersistenceExtension,fe as createProbeFailureReporter,qt as createServer,on as createServerObserverExtension,oe as createServerProbeResolver,je as createStreamingErrorWriter,Lr as createTestLogger,Ki as describeStoredEmbeddingsKey,Te as detectClaudeDesktopPresence,vn as detectGit,fn as detectProjectShape,wn as detectUserSkillHosts,yt as discoverLockDirs,d as discoverMarkdownlintConfig,mr as emitPreflightFailureSpan,ma as encodeDocName,Di as encodeFolderRoute,ea as encodeSkillRoute,Wr as ensureProjectGit,Bn as errorResponse,Pi as evictStaleTrackerEntries,sa as extractHeadings,tr as extractOkBinaryPath,di as extractWikiLinksFromMarkdown,xa as fallbackPaths,cr as findEnclosingGitRoot,xr as findEnclosingProjectRoot,Vi as findNativeMarkdownlintFile,yi as flushFileLogger,Ir as formatAuditBrokenLinkSuppressionLine,Or as formatAuthRejectionWire,Mn as formatContributorsFrom,ka as formatPackRationale,Qa as gcCheckpointRefs,qn as getCurrentMcpLogger,Wa as getIngressContext,Nt as getLocalDir,M as getLogFilePath,kr as getLogger,La as getLogsDir,Vt as getMachineId,q as getMeter,z as getMetrics,ot as getTracer,ii as handleCollabSocketError,y as handleSpawnCursor,Zr as hasForwardingHeaders,Ke as hasGcLogLatch,e as iconFromClientName,$e as incrementCollabSocketFilteredError,mt as incrementServerObserverFire,te as initContent,be as initShadowRepo,ze as initTelemetry,Et as initToleranceTelemetryWriter,ao as installJsonSchemaDialect,T as installPrettyZodErrors,Nn as installTestLoggers,en as installUserSkill,pe as isAllowedApiOrigin,Jt as isAllowedWorkspaceHostHeader,sn as isConfigDoc,se as isDefunctProcess,Me as isDocInConflict,qi as isFilesystemRoot,Ee as isHocuspocusAuthRejectionReason,yn as isHomeDir,pn as isHostAdmitted,Tn as isKnownPackId,bt as isLinkIndexExcludedDoc,f as isLockProcessRunning,dr as isLoopbackAddress,da as isManagedArtifactDoc,wi as isMintedThreadId,Zi as isOriginAdmitted,J as isOrphanMode,Vr as isPairedWriteOrigin,Ln as isPathWithinDir,ji as isPeerAdmitted,ia as isProcessAlive,Qn as isProjectRoot,ci as isReservedForUserTree,va as isSelfWrite,ar as isSkillInstallReportEnvOptOut,vr as isSystemDoc,Ri as isToleranceTelemetryEnabled,gi as isValidLockPid,Nr as lastKnownHash,Tr as listRescueCheckpoints,kn as listStarterPacks,Ea as loadCustomAgents,Ya as loadPrincipal,Wn as lockAdvertisesUi,Va as lockBaseUrl,At as lockFilePath,Aa as loggerFactory,k as loginShapedUserinfoUser,$a as logsCurrentPath,Jn as logsPreviousPath,Pa as makeLazyEmbeddingsKeyStore,Rt as markServerLockDraining,W as mountMcpAndApi,I as normalizeFsPath,rt as observeReadiness,ti as packageVersionMajorMinor,g as parseAuthRejectionWire,Jr as parseGitVersion,Ue as parseHocuspocusAuthToken,Xe as parseKeepaliveConnectionId,dt as pathToDocName,Q as planSeed,_e as prepareSingleFileOpen,Ie as processCommand,wt as processUsage,ro as readAgentBrowserTools,C as readAllTargets,Qt as readBundleDecision,de as readDeclaredGitHubHosts,Kt as readOriginCredentialHost,an as readOriginGitHubRepo,ae as readOwnNativeRules,Ae as readProcessLock,Gi as readProcessLockDetailed,we as readProcessState,_n as readProjectHeadState,dn as readProjectLocalSemanticConfig,Cn as readServerLock,vt as readServerPackageVersion,u as readSkillInstallStateSnapshot,ur as readStateManifest,ua as readTargetRecordedAt,Ci as readTargetVersion,Xi as reconcile,Br as recordContributor,In as recordSkillInstallEvent,Ai as redactShareSubprocessStderr,ra as registerAllTools,Zn as registerWrite,si as releaseProcessLock,_a as releaseServerLock,ir as removeLastKnownHash,_r as removeProjectSkillGitignoreBlock,Li as reportSkillInstall,hi as resetMetrics,Mr as resolveAuditScope,wr as resolveBuiltinSkillHosts,i as resolveBundleEnabled,On as resolveBundledSkillDir,Ta as resolveContentDir,Ja as resolveCursorBinaryDefault,Un as resolveCursorSpawnInvocation,Ba as resolveEffectiveLinterConfig,kt as resolveEmbeddingsCredential,O as resolveGitHubAccountFromUrl,Na as resolveGitHubAuthHost,Lt as resolveLockDir,U as resolveNativeConfigForDoc,F as resolveNativeMarkdownlintConfig,nt as resolvePack,ei as resolvePackageVersion,h as resolveSkillInstallReportSettings,qr as resolveUiInfo,He as restoreContributors,Ye as rewriteMarkdownLinksForDocumentRename,ut as rewriteWikiLinksForDocumentRename,Z as runAuthReposSubprocess,ge as runAuthStatusSubprocess,Fe as runCloneSubprocess,Ct as runDeviceFlowSubprocess,no as runWithMcpLogger,S as safeContentPath,Zt as safeSubdir,ue as safetyCheckpoint,Gt as sameGitHubLogin,rn as sanitizeClientName,ie as saveInMemoryCheckpoint,ke as saveVersion,Wi as scanLockProcesses,Ce as seedBasenameIndex,gn as seedEphemeralProjectDir,un as serializeError,Sn as setActiveSpanAttributes,_t as setupServerObservers,l as shadowGit,pr as shutdownTelemetry,Ga as spansCurrentPath,Pt as spansPreviousPath,pa as spawnDetached,Ei as splitMarkdownBlocks,$i as startWatcher,Ur as strategiesFor,zn as streamedChunkOf,Ni as streamingProblemEvent,oa as swapContributors,er as teardownToleranceTelemetryWriter,ui as toBroadcasterKey,ba as tracedAppendFileSync,sr as tracedLinkSync,br as tracedMkdir,Bi as tracedMkdirSync,vi as tracedRename,Fr as tracedRenameSync,Dr as tracedRmSync,jn as tracedRmdirSync,Oa as tracedUnlinkSync,Za as tracedWriteFile,Kn as tracedWriteFileSync,Ua as trustSystemCertificates,Mt as updateLastKnownHash,j as updateProcessLockPort,Ia as updateServerLockPort,Bt as validateAgentId,K as validateCloneInputs,R as validateSkillZip,at as waitForServerLockDrain,ri as withHiddenWindowsConsole,v as withSpan,Xr as withSpanSync,Ge as writeBundleDecision,Qe as writeMarkdownlintRule,pt as writeRootGitignoreForNewRepo,ee as writeStateManifest,ye as writeTargetVersion,Re as writeTracker};
|
package/dist/index.mjs
CHANGED
|
@@ -1542,6 +1542,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
|
|
|
1542
1542
|
`);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(`
|
|
1543
1543
|
`)?`
|
|
1544
1544
|
`:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const kNe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function ANe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const jNe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function MNe(e){let t={contentDirSpellings:O9(e.contentDir)};for(let n of jNe)for(let r of P9(j(e.stagingDir,n)))ANe(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(j(e.stagingDir,`state`))){let e=ae(n);n.endsWith(`.jsonl`)?j9(n,t):kNe.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 NNe(e){return j(e,...I9,z9)}function PNe(e){return j(e,...I9,B9)}function FNe(e){return j(e,...L9,V9)}function INe(e){return j(e,...L9,H9)}function LNe(e){return j(e,...R9,U9)}function RNe(e){return j(e,...R9,W9)}const G9=1e3;async function zNe(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 BNe(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 VNe(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 HNe(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(`
|
|
1545
|
-
`)}\n`:null}catch{return null}}function UNe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],g8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function WNe(e){let t=j(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/`],g8({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 GNe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function KNe(){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,Ms.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 qNe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return qNe(e.maxBytes)}function JNe(e){let t=J9(rY(`project`,e)),n=J9(rY(`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 YNe(e){return Me(`sha256`).update(e).digest(`hex`)}function XNe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const ZNe=[`"doc.name"`,`"docName"`];function QNe(e){let t=S(e,`utf-8`),n=0;for(let e of ZNe){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(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,a7(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=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const $Ne=new Set([`.jsonl`]);function ePe(e){let t=e.lastIndexOf(`.`);return t!==-1&&$Ne.has(e.slice(t))}const tPe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function nPe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&tPe.has(e.slice(t))}function rPe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!nPe(r))continue;let{redacted:i,patterns:a,lineCount:o}=DP(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 M(e,t).split(le).join(`/`)}async function iPe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??zNe,a=r.fetchAgentEffects??BNe,o=r.fetchWatcherRecent??VNe,s=r.readShadowHead??UNe,c=r.readCheckpointRefs??WNe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.85.0-beta.
|
|
1545
|
+
`)}\n`:null}catch{return null}}function UNe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],g8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function WNe(e){let t=j(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/`],g8({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 GNe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function KNe(){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,Ms.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 qNe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return qNe(e.maxBytes)}function JNe(e){let t=J9(rY(`project`,e)),n=J9(rY(`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 YNe(e){return Me(`sha256`).update(e).digest(`hex`)}function XNe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const ZNe=[`"doc.name"`,`"docName"`];function QNe(e){let t=S(e,`utf-8`),n=0;for(let e of ZNe){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(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,a7(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=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const $Ne=new Set([`.jsonl`]);function ePe(e){let t=e.lastIndexOf(`.`);return t!==-1&&$Ne.has(e.slice(t))}const tPe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function nPe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&tPe.has(e.slice(t))}function rPe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!nPe(r))continue;let{redacted:i,patterns:a,lineCount:o}=DP(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 M(e,t).split(le).join(`/`)}async function iPe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??zNe,a=r.fetchAgentEffects??BNe,o=r.fetchWatcherRecent??VNe,s=r.readShadowHead??UNe,c=r.readCheckpointRefs??WNe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.85.0-beta.2`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??GNe,h=r.isOtlpPushEnabled??KNe,_=y(j(xe(),`ok-bundle-`));try{v(j(_,`telemetry`),{recursive:!0}),v(j(_,`logs`),{recursive:!0}),v(j(_,`state`),{recursive:!0}),Z9(NNe(n),j(_,`telemetry`,z9)),Z9(PNe(n),j(_,`telemetry`,B9)),Z9(FNe(n),j(_,`logs`,V9)),Z9(INe(n),j(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(_,`logs`,ae(t)));for(let t of e.userStateFiles??[])Z9(t,j(_,LJ,ae(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(_,`diagnostic-reports`,ae(t)))&&(y+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,j(_,`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(j(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(j(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=HNe(n);e!==null&&re(j(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(j(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(j(_,`state`,`checkpoint-refs.txt`),D),Z9(LNe(n),j(_,`state`,U9)),Z9(RNe(n),j(_,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(_,`state`,`last-spawn-error.log`)),Z9(j(b,Pd),j(_,`state`,Pd)),Z9(j(b,Fd),j(_,`state`,Fd)),Z9(j(b,Nd),j(_,`state`,Nd));let ee=p(),ne=d(),ie=f(),k={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(j(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let oe=C===`running`?`running
|
|
1546
1546
|
`:`not-running (${w})\n`;re(j(_,`state`,`server-status.txt`),oe);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:i7(e.diagnosticReports,y);if(re(j(_,`state`,`diagnostic-reports-status.txt`),`${A}\n`),re(j(_,c7),S7(e.osTerminationEvidence)),e.processDir&&g(e.processDir)){let t=j(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&MNe({stagingDir:_,contentDir:t}),e.note&&re(j(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=rPe(_));for(let t of e.extraFiles??[]){let e=t.zipName??ae(t.sourcePath);if(!Z9(t.sourcePath,j(_,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=w7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=JNe(n),N=Q9(_),le=[],ue=0,de=0;for(let e of N){let t=$9(_,e),n=te(e).size,r=ePe(t)?XNe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=QNe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:YNe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:le};re(j(_,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=O9(t),me=N.some(e=>{try{let t=S(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:_,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function aPe(e){let{collected:t,outputPath:n}=e,r=k(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 FEe.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 oPe(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,Ms.parse)(S(n,`utf-8`)),r=CY(t)?t.content:void 0,i=CY(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return N(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 N(e)}async function sPe(e,t,n,r,i,a){let o=T7(t,e.logger),s=await iPe({contentDir:oPe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...gMe(o,e.userLogsDir??j(XJ(),`logs`)),...D7(e.cachesDir??j(_e(),`Library`,`Caches`))],userStateFiles:O7(e.bugReportsDir??C7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(k(e.outputPath),{recursive:!0}),await aPe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function cPe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??D9,i=()=>qje(e.diagnosticReportsDir??j(_e(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return sPe(e,t,n,r,i(),await x7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await xMe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:D7(e.cachesDir??j(_e(),`Library`,`Caches`)),bugReportLedgerFiles:O7(e.bugReportsDir??C7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await x7(e.osTerminationEvidenceDeps):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{AY as ALL_EDITOR_IDS,jY as EDITOR_LABELS,sX as EDITOR_TARGETS,Hye as HOSTS_WITH_USER_SKILL_DIR,Fje as LAUNCH_CONFIG_NAME,dNe as PATH_SHIM_BEGIN,pNe as PATH_SHIM_BLOCK_RE,fNe as PATH_SHIM_END,v5 as ProjectPathSafetyError,pje as addOkPathsToGitExclude,y5 as assertProjectPathSafe,UY as buildManagedServerEntry,eNe as buildMcpConfigDeclineEvent,tNe as buildMcpConfigMigrateEvent,t7 as classifyExistingMcpEntry,cPe as collectReportBundle,vNe as createCliProbeResolver,lY as createTokenStore,pMe as defaultBugReportZipPath,Ke as detectGh,Ye as detectGhAccounts,zje as detectInstalledEditors,QY as droppedManagedKeys,lbe as editorConfigPathDisplay,cbe as editorEntryLocator,UMe as ensurePiBridge,N5 as formatTrackedRemediation,gje as getExcludedOkPaths,j5 as getInstalledSkillProjectionPaths,Vye as getNativeTomlMcpEditor,A5 as getOkArtifactPaths,VY as isEntryUpToDate,WY as isOwnManagedEntry,cNe as loadConfig,pye as makeLazyProbeTokenStore,C7 as okBugReportsDir,y9 as parseGitHubBlobUrl,lNe as parseGitHubShareUrl,b9 as parseGitHubTreeUrl,v9 as parseGitUrl,mNe as pathInstallMarkerPath,QAe as previewContent,Bje as probeOwnManagedEditorMcpEntry,VMe as probePiBridgeState,M5 as probeTrackedOkPaths,$5 as readExistingMcpEntry,hje as readSharingMode,DP as redactContent,mje as removeOkPathsFromGitExclude,XMe as removeOwnMcpEntry,lje as removeProjectSkill,bNe as removeUserGlobalSkillBundle,ENe as removeUserSkill,rje as resolveProjectRoot,aNe as runStop,m9 as truncatePriorEntry,T9 as userGlobalSkillBundleTargets,TNe as userSkillPresentAnywhere,uNe as validateLocalFolderForShare,Q5 as writeEditorMcpConfig,CNe as writeProjectAiIntegrations,T5 as writeProjectSkill,Rje as writeUserMcpConfigs,wNe as writeUserSkill};
|
|
1547
1547
|
//# 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{
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{B as r,Bc as i,G as a,Gu as o,La as s,R as c,Ra as l,Tf as u,_ as d,_f as f,a as p,af as m,bf as h,cd as g,dc as _,dd as v,et as y,hf as b,lf as x,mf as S,nf as ee,of as te,rf as ne,tf as re,uf as ie,vf as ae,xf as C}from"./md-manager-BGnqyqi1-dBGkA2rR.mjs";import{Aa as oe,At as se,F as ce,Fr as le,Go as w,Jo as ue,Ko as de,Mo as fe,Po as pe,R as me,U as he,Vi as ge,Vr as _e,Yo as ve,Yr as ye,Zn as be,_a as xe,ci as Se,di as Ce,dn as we,es as T,fa as Te,ir as Ee,it as De,ko as Oe,m as ke,ot as Ae,pa as je,ps as Me,qo as Ne,qr as Pe,ss as Fe,z as Ie}from"./dist-CqZISrZN.mjs";import{i as E,n as D,o as O,r as Le,s as k,t as A}from"./colors-r_owlCuY.mjs";import{t as j}from"./is-object-BGze3w87.mjs";import{t as Re}from"./constants-CEWqiFCf.mjs";import{t as ze}from"./preview-vc6NgNe_.mjs";import{createRequire as Be}from"node:module";import{execFileSync as Ve}from"node:child_process";import He,{basename as Ue,dirname as M,isAbsolute as We,join as N,posix as Ge,relative as P,resolve as F,sep as I,win32 as Ke}from"node:path";import L from"node:process";import{fileURLToPath as qe}from"node:url";import{cpSync as Je,existsSync as R,lstatSync as Ye,mkdirSync as Xe,readFileSync as z,readdirSync as Ze,readlinkSync as Qe,realpathSync as $e,rmSync as et,statSync as tt,writeFileSync as nt}from"node:fs";import{homedir as B}from"node:os";import{inspect as rt,stripVTControlCharacters as it,styleText as V}from"node:util";import*as at from"node:readline";import{AsyncLocalStorage as ot,AsyncResource as st}from"node:async_hooks";var ct=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})),lt=n((e=>{let{InvalidArgumentError:t}=ct();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})),ut=n((e=>{let{humanReadableArgName:t}=lt();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})),dt=n((e=>{let{InvalidArgumentError:t}=ct();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}
|
|
@@ -30,7 +30,7 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
|
|
|
30
30
|
`).pop()??``;var sr=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=``){let n=or(e),r=it(n),i=r;this.rl.line.length>0&&(i=i.slice(0,-this.rl.line.length)),this.rl.setPrompt(i),this.cursorPos=this.rl.getCursorPos();let a=In();e=Fn(e,a),t=Fn(t,a),r.length%a===0&&(e+=`
|
|
31
31
|
`);let o=e+(t?`
|
|
32
32
|
`+t:``),s=Math.floor(r.length/a)-this.cursorPos.rows+(t?ar(t):0);s>0&&(o+=tr(s)),o+=rr(this.cursorPos.cols),this.write(nr(this.extraLinesUnderPrompt)+ir(this.height)+o),this.extraLinesUnderPrompt=s,this.height=ar(o)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(rr(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt(``);let t=nr(this.extraLinesUnderPrompt);t+=e?ir(this.height):`
|
|
33
|
-
`,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},cr=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const lr=globalThis.setImmediate;function ur(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function dr(e){let t=ur();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new zn.default;s.pipe(r.output??process.stdout);let c=at.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new sr(c),{promise:u,resolve:d,reject:f}=cr.withResolver(),p=()=>f(new Ft);if(a){let e=()=>f(new Pt({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(Zn((e,t)=>{f(new It(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new It(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Vt(c,a=>{let m=st.bind(()=>Kt.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=
|
|
33
|
+
`,t+=`\x1B[G`,t+=`\x1B[?25h`,this.write(t),this.rl.close()}},cr=class extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}};const lr=globalThis.setImmediate;function ur(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(e,n)=>{let r=n.slice(1);return t=r,r},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function dr(e){let t=ur();return(n,r={})=>{let{input:i=process.stdin,signal:a}=r,o=new Set,s=new zn.default;s.pipe(r.output??process.stdout);let c=at.createInterface({terminal:!0,input:i,output:s});s.mute();let l=new sr(c),{promise:u,resolve:d,reject:f}=cr.withResolver(),p=()=>f(new Ft);if(a){let e=()=>f(new Pt({cause:a.reason}));if(a.aborted)return e(),Object.assign(u,{cancel:p});a.addEventListener(`abort`,e),o.add(()=>a.removeEventListener(`abort`,e))}o.add(Zn((e,t)=>{f(new It(`User force closed the prompt with ${e} ${t}`))}));let m=()=>f(new It(`User force closed the prompt with SIGINT`));return c.on(`SIGINT`,m),o.add(()=>c.removeListener(`SIGINT`,m)),Vt(c,a=>{let m=st.bind(()=>Kt.clearAll());c.on(`close`,m),o.add(()=>c.removeListener(`close`,m));let h=()=>{let r=()=>l.checkCursorPos();c.input.on(`keypress`,r),o.add(()=>c.input.removeListener(`keypress`,r));let i=null;a(()=>{let r=!1;try{let a=e(n,e=>{r?d(e):i={value:e}});if(a===void 0){let e=t[1]?.getFileName();throw e&&!e.startsWith(`file://`)&&(e=He.resolve(e)),Error(`Prompt functions must return a string.\n at ${e}`)}let[o,s]=typeof a==`string`?[a]:a;l.render(o,s),Kt.run()}catch(e){f(e)}if(r=!0,i!==null){let{value:e}=i;i=null,d(e)}})};return`readableFlowing`in i?lr(h):h(),Object.assign(u.then(e=>(Kt.clearAll(),e),e=>{throw Kt.clearAll(),e}).finally(()=>{o.forEach(e=>e()),l.done({clearContent:!!r.clearPromptOnDone}),s.end()}).then(()=>u),{cancel:p})})}}var K=class{separator=V(`dim`,Array.from({length:15}).join(W.line));type=`separator`;constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`separator`)}};
|
|
34
34
|
/*!
|
|
35
35
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -278,7 +278,7 @@ let Mr=/^[a-z0-9-_]+$/i;function Nr(e){let t=typeof e;if(t===`object`){if(Array.
|
|
|
278
278
|
`)+Br(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=Ir(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 Vr(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Nr(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Br(0,e,``,t,n);return r[r.length-1]===`
|
|
280
280
|
`?r:r+`
|
|
281
|
-
`}var Hr=
|
|
281
|
+
`}var Hr=o();function Ur(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 Wr(e){return!e||typeof e!=`object`?String(e):`${typeof e} keys=[${Object.keys(e).join(`,`)}]`}function Gr(e,t){let n=[],r=new WeakSet,i=t;for(;i instanceof Error&&!r.has(i);)r.add(i),n.push(i.message),i=i.cause;return n.length===0?`${e}: ${Wr(t)}`:`${e}: ${n.reverse().slice(0,5).join(` -> `)}`}function Y(e,t){process.env.OK_DEBUG_NATIVE&&process.stderr.write(`[ok] native-config ${Gr(e,t)}\n`)}const Kr=[`native`,`index.js`];function qr(e={},t=Y){let n=e.moduleUrl??import.meta.url,r=e.requireModule??Be(n);try{let e=M(qe(n));return r(N(e,...Kr))}catch(e){Ur(e)||t(`bundled loader failed to load`,e)}try{return r(`@inkeep/open-knowledge-native-config`)}catch(e){return Ur(e)||t(`workspace addon failed to load`,e),null}}function Jr(){let e=qr();return e&&typeof e.parseTomlToJson==`function`?e:null}function Yr(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return Y(`addon loaded but probe failed`,e),!1}}function Xr(e){if(!j(e))throw Error(`TOML root is not a table`);return e}function Zr(e){return{backend:`native`,parseToObject(t){return Xr(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 Qr(){return{backend:`fallback`,parseToObject(e){return Xr(jr(e))}}}function $r(e=Jr){let t=e();return t&&Yr(t)?Zr(t):Qr()}let ei=null;function ti(){return ei===null&&(ei=$r()),ei}function ni(){let e=ti();return e.backend===`native`?e:void 0}const ri=re,X=ee,ii=m,ai=`node`,oi={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},si=`@inkeep/open-knowledge`;function ci(e){return`${c(`unix-chain`,e.mcpChainTag)}2`}function li(e){return`${c(`windows-chain`,e.mcpChainTag)}1`}function ui(e){let t=f[e],n=`${si}@${t.npmDistTag}`,r=e===`stable`?``:`\nexport ${ae}=${e}`;return`${ci(t)}${r}
|
|
282
282
|
USER_BUNDLE="$HOME/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
|
|
283
283
|
[ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
|
|
284
284
|
BUNDLE="/Applications/${t.productName}.app/Contents/Resources/cli/bin/ok.sh"
|
|
@@ -290,7 +290,7 @@ for d in "$HOME/.nvm/versions/node"/*/bin "$HOME/.fnm/node-versions"/*/installat
|
|
|
290
290
|
[ -f "$d/npx" ] && [ -x "$d/npx" ] && exec "$d/npx" -y ${n} mcp
|
|
291
291
|
done
|
|
292
292
|
echo "OpenKnowledge: install OK Desktop or Node.js 24+, then restart your editor" >&2
|
|
293
|
-
exit 127`}function di(e){let t=
|
|
293
|
+
exit 127`}function di(e){let t=f[e],n=`${si}@${t.npmDistTag}`,r=`${t.cliCommandNames[0]}.cmd`,i=t.npmDistTag===`latest`?si:n,a=e===`stable`?``:`\n$env:${ae} = '${e}'`;return`${li(t)}${a}
|
|
294
294
|
if ($env:PATHEXT -notmatch 'CMD') { $env:PATHEXT = '.COM;.EXE;.BAT;.CMD;' + $env:PATHEXT }
|
|
295
295
|
if ($env:APPDATA) {
|
|
296
296
|
$shim = Join-Path $env:APPDATA 'npm\\${r}'
|
|
@@ -314,22 +314,22 @@ foreach ($d in $dirs) {
|
|
|
314
314
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '${n}' mcp; exit $LASTEXITCODE }
|
|
315
315
|
}
|
|
316
316
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g ${i}), then restart your editor')
|
|
317
|
-
exit 127`}ci(C.stable),ui(`stable`),li(C.stable),di(`stable`);function fi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function pi(e){return`${fi(e)}-v1`}fi(C.stable),pi(C.stable);function mi(e){if(typeof e!=`object`||!e)return!1;let t=m(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return Ci(e,ci(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return Ci(e,li(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return Ci(e,ci(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return Ci(e,li(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(pi(t))}return!1}function hi(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=I(e);if(He(t)===`cli.mjs`&&He(N(t))===`dist`)return t;let n=t.split(Ge),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?Ge:i.join(Ge);return P(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:ai,args:[hi(),`mcp`],env:{...oi}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,di(f())]}:{command:`/bin/sh`,args:[`-l`,`-c`,ui(f())]}}function gi(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ai,hi(),`mcp`],environment:{...oi}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,di(f())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,ui(f())]}}function _i(e){if(typeof e!=`object`||!e)return!1;let t=e;return vi(t,Z({mode:`published`,platformName:`darwin`}))||vi(t,Z({mode:`published`,platformName:`win32`}))}function vi(e,t){return Object.keys(e).length===Object.keys(t).length&&yi(e,t)}function yi(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 bi(e,t){let n=e=>wi(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 xi(e){return e.format===`toml`?ti().backend===`native`:e.format===`json`||e.format===`yaml`}function Si(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function Ci(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function wi(e){return Ci(e,`# ok-mcp`)}function Ti(e){return typeof e==`string`&&(e===si||e.startsWith(`${si}@`))}function Ei(e){if(typeof e!=`object`||!e)return!1;let t=Si(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&wi(t[n+1])?!0:t.some(Ti)}function Di(e){if(typeof e!=`object`||!e)return!1;let t=Si(e);if(t[0]!==ai||t[2]!==`mcp`)return!1;try{return t[1]===hi()}catch{return!1}}const Oi=[`command`,`args`,`env`],ki=[`type`,`command`,`environment`];function Ai(e){return e.type===`local`&&Array.isArray(e.command)?ki:Oi}function ji(e,t){if(typeof e!=`object`||!e)return[];let n=e;return Ai(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Mi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Ni(e,t){return ji(e,t).length>0}function Pi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:bi(t.args,t.command)}function Fi(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`&&bi(r,n)}function Q(e){return e===`win32`?Ke:We}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Li(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function Ri(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return We.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ke.join(n,`AppData`,`Roaming`);return Ke.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function zi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Bi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Vi(e={}){return Q(e.platformName??process.platform).join(Bi(e),`config.toml`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Ui(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Wi(e={}){return Q(e.platformName??process.platform).join(Ui(e),`opencode.json`)}function Gi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Ki(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function qi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function Ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Yi(e,t){let n=Q(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 Xi(e){try{return Ze(e).length>0}catch{return!1}}function Zi(e={}){let t=e.platformName??process.platform,[n,r]=Yi(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:Xi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Li({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>P(t??B(),`.claude`),projectConfigPath:e=>P(e,`.mcp.json`),projectSkillPath:e=>P(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>Ri({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(Ri({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(zi({home:t})),projectConfigPath:e=>P(e,`.cursor`,`mcp.json`),projectSkillPath:e=>P(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Vi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(Vi({home:t})),projectConfigPath:e=>P(e,`.codex`,`config.toml`),projectSkillPath:e=>P(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Hi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(Hi({home:t})),projectSkillPath:e=>P(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>Wi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>w(),buildEntry:(e,t)=>gi(t),scope:`global`,detectPath:(e,t)=>N(Wi({home:t})),projectConfigPath:e=>P(e,`opencode.json`),projectSkillPath:e=>P(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>Gi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>P(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${y(m())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>w(),scope:`project`,detectPath:(e,t)=>qi({home:t}),projectConfigPath:e=>P(e,y(m())),projectSkillPath:e=>P(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>P(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>Zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(Zi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Ki({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>w(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>P(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function Qi(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ri.join(`, `)}`);return e.map(e=>$[e])}const $i=`**/.ok/*`,ea=`!**/${v}/`;function ta(e){let t=[`.ok/`,`.okignore`];for(let n of ri){let r=$[n];r.projectConfigPath&&t.push(ga(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function na(e){let t=P(e,...h);if(!R(t))return[];try{let e=i(z(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=b[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function ra(e,t){let n=sa(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:da(n)};let r=fa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(na(e)),o=[],s=a.size===0?i:i.split(`
|
|
317
|
+
exit 127`}ci(f.stable),ui(`stable`),li(f.stable),di(`stable`);function fi(e){return`// ok-pi-bridge${e.mcpChainTag}`}function pi(e){return`${fi(e)}-v1`}fi(f.stable),pi(f.stable);function mi(e){if(typeof e!=`object`||!e)return!1;let t=h(),n=e;if(n.command===`/bin/sh`){if(!Array.isArray(n.args)||n.args[0]!==`-l`||n.args[1]!==`-c`)return!1;let e=n.args[2];return Ci(e,ci(t))}if(n.command===`powershell`){if(!Array.isArray(n.args)||n.args[0]!==`-NoProfile`||n.args[1]!==`-NonInteractive`||n.args[2]!==`-Command`)return!1;let e=n.args[3];return Ci(e,li(t))}if(n.type===`local`&&Array.isArray(n.command)){if(n.command[0]===`/bin/sh`){if(n.command[1]!==`-l`||n.command[2]!==`-c`)return!1;let e=n.command[3];return Ci(e,ci(t))}if(n.command[0]===`powershell`){if(n.command[1]!==`-NoProfile`||n.command[2]!==`-NonInteractive`||n.command[3]!==`-Command`)return!1;let e=n.command[4];return Ci(e,li(t))}return!1}if(n.command===`ok-pi-managed-extension`){if(!Array.isArray(n.args))return!1;let e=n.args[0];return typeof e==`string`&&e.startsWith(pi(t))}return!1}function hi(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=F(e);if(Ue(t)===`cli.mjs`&&Ue(M(t))===`dist`)return t;let n=t.split(I),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?I:i.join(I);return N(a,`packages`,`cli`,`dist`,`cli.mjs`)}function Z(e={}){return e.mode===`dev`?{command:ai,args:[hi(),`mcp`],env:{...oi}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,di(u())]}:{command:`/bin/sh`,args:[`-l`,`-c`,ui(u())]}}function gi(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[ai,hi(),`mcp`],environment:{...oi}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,di(u())]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,ui(u())]}}function _i(e){if(typeof e!=`object`||!e)return!1;let t=e;return vi(t,Z({mode:`published`,platformName:`darwin`}))||vi(t,Z({mode:`published`,platformName:`win32`}))}function vi(e,t){return Object.keys(e).length===Object.keys(t).length&&yi(e,t)}function yi(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 bi(e,t){let n=e=>wi(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 xi(e){return e.format===`toml`?ti().backend===`native`:e.format===`json`||e.format===`yaml`}function Si(e){return Array.isArray(e.command)?e.command:[e.command,...Array.isArray(e.args)?e.args:[]]}function Ci(e,t){return typeof e==`string`&&e.trimStart().startsWith(t)}function wi(e){return Ci(e,`# ok-mcp`)}function Ti(e){return typeof e==`string`&&(e===si||e.startsWith(`${si}@`))}function Ei(e){if(typeof e!=`object`||!e)return!1;let t=Si(e),n=t.findIndex(e=>e===`-c`||e===`-Command`);return n>=0&&wi(t[n+1])?!0:t.some(Ti)}function Di(e){if(typeof e!=`object`||!e)return!1;let t=Si(e);if(t[0]!==ai||t[2]!==`mcp`)return!1;try{return t[1]===hi()}catch{return!1}}const Oi=[`command`,`args`,`env`],ki=[`type`,`command`,`environment`];function Ai(e){return e.type===`local`&&Array.isArray(e.command)?ki:Oi}function ji(e,t){if(typeof e!=`object`||!e)return[];let n=e;return Ai(t).filter(e=>t[e]===void 0&&n[e]!==void 0)}function Mi(e,t){return e.format===`file`?null:e.buildEntry(t,{})}function Ni(e,t){return ji(e,t).length>0}function Pi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:bi(t.args,t.command)}function Fi(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`&&bi(r,n)}function Q(e){return e===`win32`?Ke:Ge}function Ii(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Li(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.claude.json`)}function Ri(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env;if(t===`darwin`)return Ge.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??Ke.join(n,`AppData`,`Roaming`);return Ke.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function zi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.cursor`,`mcp.json`)}function Bi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).CODEX_HOME??Q(t).join(n,`.codex`)}function Vi(e={}){return Q(e.platformName??process.platform).join(Bi(e),`config.toml`)}function Hi(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=(e.env??process.env).COPILOT_HOME??Q(t).join(n,`.copilot`);return Q(t).join(r,`mcp-config.json`)}function Ui(e={}){let t=e.platformName??process.platform,n=e.home??B(),r=e.env??process.env,i=Q(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 Wi(e={}){return Q(e.platformName??process.platform).join(Ui(e),`opencode.json`)}function Gi(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.openclaw`,`openclaw.json`)}function Ki(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.hermes`,`config.yaml`)}function qi(e={}){let t=e.platformName??process.platform,n=e.home??B();return(e.env??process.env).PI_CODING_AGENT_DIR??Q(t).join(n,`.pi`,`agent`)}function Ji(e={}){let t=e.platformName??process.platform,n=e.home??B();return Q(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Yi(e,t){let n=Q(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 Xi(e){try{return Ze(e).length>0}catch{return!1}}function Zi(e={}){let t=e.platformName??process.platform,[n,r]=Yi(e.home??B(),t),i=[n,r].find(e=>R(e.file));return i?i.file:Xi(r.dir)?r.file:n.file}const $={claude:{id:`claude`,label:X.claude,configPath:(e,t)=>Li({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:X[`claude-desktop`],configPath:(e,t)=>Ri({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Ri({home:t}))},cursor:{id:`cursor`,label:X.cursor,configPath:(e,t)=>zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(zi({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:X.codex,configPath:(e,t)=>Vi({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Vi({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:X.copilot,configPath:(e,t)=>Hi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Hi({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:X.opencode,configPath:(e,t)=>Wi({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>C(),buildEntry:(e,t)=>gi(t),scope:`global`,detectPath:(e,t)=>M(Wi({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:X.openclaw,configPath:(e,t)=>Gi({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:X.pi,configPath:()=>{throw Error(`Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at ${S(h())} (run \`ok init\` in the project).`)},format:`file`,topLevelKey:`mcpServers`,serverName:()=>C(),scope:`project`,detectPath:(e,t)=>qi({home:t}),projectConfigPath:e=>N(e,S(h())),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:X.antigravity,configPath:(e,t)=>Ji({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:X[`lm-studio`],configPath:(e,t)=>Zi({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>M(Zi({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:X.hermes,configPath:(e,t)=>Ki({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>C(),buildEntry:(e,t)=>Z(t),scope:`global`,detectPath:(e,t)=>N(t??B(),`.hermes`),offerOnlyWhenDetected:!0}};function Qi(e){let t=e.filter(e=>!Object.hasOwn($,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${ri.join(`, `)}`);return e.map(e=>$[e])}const $i=`**/.ok/*`,ea=`!**/${_}/`;function ta(e){let t=[`.ok/`,`.okignore`];for(let n of ri){let r=$[n];r.projectConfigPath&&t.push(ga(r.projectConfigPath(e),e))}return t.push(`.claude/launch.json`),Array.from(new Set(t))}function na(e){let t=N(e,...p);if(!R(t))return[];try{let e=r(z(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=ne[e];r&&n.push(`${r}/${t}/`)}return Array.from(new Set(n))}catch{return[]}}function ra(e,t){let n=sa(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:da(n)};let r=fa(e);if(r.kind!==`ok`)return r.result;let i=R(r.path)?z(r.path,`utf-8`):``,a=new Set(na(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=ha(s),l=[],u=[];for(let e of t)ma(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{nt(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function ia(e,t){let n=fa(e);if(n.kind!==`ok`)return n.result;if(!R(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>pa(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add($i),i.add(ea);for(let t of na(e))i.add(t);let a;try{a=z(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{nt(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function aa(e){let t=fa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=ha(n),i=ta(e);for(let e of i)if(ma(r,e))return`local-only`;return r.has($i)?`local-only`:`shared`}function oa(e){let t=fa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=ha(n),i=[...ta(e),...na(e)].filter(e=>ma(r,e)),a=new Set(i),o=[];for(let e of Object.values(
|
|
325
|
-
`)}function fa(e){let t=
|
|
326
|
-
`)){let e=n.trim();e.length!==0&&t.add(e)}return t}function ga(e,t){return _a(
|
|
324
|
+
`);if(u!==a)try{nt(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function aa(e){let t=fa(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!R(t.path))return`shared`;let n;try{n=z(t.path,`utf-8`)}catch{return`shared`}let r=ha(n),i=ta(e);for(let e of i)if(ma(r,e))return`local-only`;return r.has($i)?`local-only`:`shared`}function oa(e){let t=fa(e);if(t.kind!==`ok`||!R(t.path))return[];let n;try{n=z(t.path,`utf-8`)}catch{return[]}let r=ha(n),i=[...ta(e),...na(e)].filter(e=>ma(r,e)),a=new Set(i),o=[];for(let e of Object.values(ne))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===$i||e===ea){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 sa(e,t){let n=[];for(let r of t){let t=F(e,r);if(R(t))try{Ve(`git`,[`ls-files`,`--error-unmatch`,...a([r])],Oe({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const ca=/^[\w.\-/]+$/;function la(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function ua(e){return ca.test(e)?e:la(y(e))}function da(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}-- ${ua(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
|
+
`)}function fa(e){let t=Me(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=N(e.path,`info`);return R(n)?{kind:`ok`,path:N(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 pa(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function ma(e,t){for(let n of pa(t))if(e.has(n))return!0;return!1}function ha(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 ga(e,t){return _a(P(t,e))}function _a(e){return I===`/`?e:e.split(I).join(`/`)}var va=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function ya(e,t){let n;try{n=Ye(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new va(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);xa(e,t)}function ba(e,t){xa(e,t)}function xa(e,t){Sa(e,t)}function Sa(e,t){let n=t,r;try{r=$e(n)}catch{r=F(n)}let i=M(e);for(;i.length>1&&i!==I;){let t;try{t=$e(i)}catch(e){if(e.code===`ENOENT`){i=M(i);continue}throw e}let n=P(r,t);if(n===``||!n.startsWith(`..`)&&!We(n))return;throw new va(`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 Ca(e,t){let n=M(t),r=R(t)?`overwritten`:`written`;if(r===`written`&&R(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 et(n,{recursive:!0,force:!0}),Xe(M(n),{recursive:!0}),Je(e,n,{recursive:!0}),r}function wa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ta(e,t,n){try{if(tt(n).size>10485760)return!1}catch{return!1}let r;try{r=z(n,`utf-8`)}catch{return!1}let i=[],a=ue(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!wa(a))return!1;let o=a[e.topLevelKey];if(!wa(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!wa(s))return!1;let c=s[e.serverName(t)];return wa(c)&&c.enabled===!1?!1:Ei(c)||Di(c)}function Ea(e){let t=g[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:$[n.editor]??null}function Da(e,t,n={}){if(!ie.includes(e.id))return!0;let r=Ea(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&Ta(r,t,i))return!0;try{return Ta(e,t,e.configPath(t,n.home))}catch{return!1}}function Oa(e){let t=new Set(te.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function ka(e,t){if(Oa(t).length===0)return null;let n=N(e,s,x,`SKILL.md`);try{let t=xe(`project`,{checkDesktop:!0});return ya(M(n),e),{editorId:`agents`,label:`.agents hub`,action:Ca(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 Aa(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Da(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=xe(`project`,{checkDesktop:!0});ya(M(r),t);let i=Ca(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 ja(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=M(n);return R(n)?(ba(r,t),et(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 Ma(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 Na(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 Pa(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 Fa(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Ia(e){try{return tt(e).mode&511}catch{return}}function La(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
|
|
328
328
|
`)?`\r
|
|
329
329
|
`:`
|
|
330
|
-
`,a=
|
|
330
|
+
`,a=Ne(r,t,void 0,{formattingOptions:{...Pa(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${w(r,a)}`;return{text:o,changed:o!==e}}const Ra={icon:{checked:V(`green`,W.circleFilled),unchecked:W.circle,cursor:W.pointer,disabledChecked:V(`green`,W.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>V(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function za(e){return!K.isSeparator(e)&&!e.disabled}function Ba(e){return!K.isSeparator(e)}function Va(e){return!K.isSeparator(e)&&e.checked}function Ha(e){return za(e)?{...e,checked:!e.checked}:e}function Ua(e){return function(t){return za(t)?{...t,checked:e}:t}}function Wa(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var Ga=dr((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=on(Ra,e.theme),{keybindings:c}=s,[l,u]=U(`idle`),d=sn({status:l,theme:s}),[f,p]=U(Wa(e.choices)),m=cn(()=>{let e=f.findIndex(Ba),t=f.findLastIndex(Ba);if(e===-1)throw new Rt(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=U(m.first),[_,v]=U();un(async e=>{if(Nt(e)){let e=f.filter(Va),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(Ot(e,c)||kt(e,c)){if(_&&v(void 0),r||Ot(e,c)&&h!==m.first||kt(e,c)&&h!==m.last){let t=Ot(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Ba(f[n]));g(n)}}else if(At(e)){let e=f[h];e&&!K.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Ha(e):e))))}else if(e.name===o.all){let e=f.some(e=>za(e)&&!e.checked);p(f.map(Ua(e)))}else if(e.name===o.invert)p(f.map(Ha));else if(Mt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&za(i)&&(g(r),p(f.map((e,t)=>t===r?Ha(e):e)))}});let y=s.style.message(e.message,l),b,x=Rn({items:f,active:h,renderItem({item:e,isActive:t}){if(K.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Va);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let ee=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,ee].filter(Boolean).join(`
|
|
331
331
|
`).trimEnd()}${er}`});const Ka={icon:{cursor:W.pointer},style:{disabled:e=>V(`dim`,e),description:e=>V(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${V(`bold`,e)} ${V(`dim`,t)}`).join(V(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function qa(e){return!K.isSeparator(e)&&!e.disabled}function Ja(e){return!K.isSeparator(e)}function Ya(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var Xa=dr((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=on(Ka,e.theme),{keybindings:a}=i,[o,s]=U(`idle`),c=sn({status:o,theme:i}),l=ln(),u=!a.includes(`vim`),d=cn(()=>Ya(e.choices),[e.choices]),f=cn(()=>{let e=d.findIndex(Ja),t=d.findLastIndex(Ja);if(e===-1)throw new Rt(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=cn(()=>`default`in e?d.findIndex(t=>qa(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=U(p===-1?f.first:p),g=d[m];if(g==null||K.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=U();un((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Nt(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(Ot(e,a)||kt(e,a)){if(r.clearLine(0),n||Ot(e,a)&&m!==f.first||kt(e,a)&&m!==f.last){let t=Ot(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!Ja(d[n]));h(n)}}else if(Mt(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!K.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&qa(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(jt(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!qa(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),Jt(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Rn({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(K.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:ee}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,ee?i.style.description(ee):``,_?i.style.error(_):``,b].filter(Boolean).join(`
|
|
332
|
-
`).trimEnd()}${er}`});function Za(e){let t=fi(
|
|
332
|
+
`).trimEnd()}${er}`});function Za(e){let t=fi(h());return e.startsWith(t)?Object.values(f).map(fi).every(n=>n.length<=t.length||!e.startsWith(n)):!1}function Qa(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&Za(n)}function $a(e){return{command:`ok-pi-managed-extension`,args:[e]}}function eo(e={}){let t=e.mode===`dev`,n=h(),r=t?`${fi(n)}-dev`:pi(n),i=`${b(n)}_`,a={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
|
|
333
333
|
/**
|
|
334
334
|
* Open Knowledge bridge for Pi — MANAGED FILE, written by \`ok init\`.
|
|
335
335
|
* Hand edits are overwritten whenever OK re-syncs this project; remove it
|
|
@@ -672,22 +672,22 @@ export default function okBridge(pi: {
|
|
|
672
672
|
}
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
|
-
`}function to(e,t){let n=
|
|
676
|
-
`)?n:`${n}\n`)}function go(e,t){let n=(0,Hr.stringify)(t);
|
|
677
|
-
`)?n:`${n}\n`)}const _o=10485760;function vo(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>vo(e,t[n]));if(
|
|
678
|
-
`)){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 xo(e,t,n){return t===void 0?[e,n]:[e,t,n]}function So(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function Co(e,t,n){let r=e[t];return n===void 0?r:
|
|
675
|
+
`}function to(e,t){let n=P(we(t),we(e));return n.length>0&&!n.startsWith(`..`)&&!We(n)}const no=e=>{try{let t=Ve(`git`,[`rev-parse`,`--show-toplevel`],Oe({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function ro(e,t={}){let n=t.homeDir??B(),r=t.gitTopLevel??no,i=F(e),a;try{a=$e(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(Se(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=M(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&to(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function io(){let e=qr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function ao(e){let t=e,n=new Set;for(;;){let r;try{r=Ye(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=Qe(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=We(i)?i:N(M(t),i)}}let oo;function so(){return oo===void 0&&(oo=io()),oo}function co(e,t=so){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Y(`resolveSymlinkWritePath threw`,e)}return ao(e)}const lo={allowTrailingComma:!0,disallowComments:!1};function uo(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function fo(e){let t=[],n=ve(e,t,lo);return t.some(t=>!uo(t,e))||n?.type!==`object`?null:n}function po(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&de(e)===t&&(n+=1)}return n}function mo(e,t){T(e,`${JSON.stringify(t,null,2)}\n`)}function ho(e,t){let n=Vr(t);T(e,n.endsWith(`
|
|
676
|
+
`)?n:`${n}\n`)}function go(e,t){let n=(0,Hr.stringify)(t);T(e,n.endsWith(`
|
|
677
|
+
`)?n:`${n}\n`)}const _o=10485760;function vo(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>vo(e,t[n]));if(j(e)&&j(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&vo(e[n],t[n]))}return!1}function yo(e,t,n){return j(e)&&n.every(n=>vo(e[n],t[n]))}function bo(e){for(let t of e.split(`
|
|
678
|
+
`)){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 xo(e,t,n){return t===void 0?[e,n]:[e,t,n]}function So(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function Co(e,t,n){let r=e[t];return n===void 0?r:j(r)?r[n]:void 0}function wo(e,t,n,r,i,a=!1,o=!1){if(!R(e))return o?{kind:`unchanged`}:(mo(e,So(t,i,n,r)),{kind:`written`});let s;try{s=z(e,`utf-8`)}catch(e){return Y(`json config read failed`,e),{kind:`declined`,reason:Ma(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(mo(e,So(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>_o)return{kind:`declined`,reason:`oversize`};let c=fo(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(po(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=Co(de(c),t,i),u=j(l)?l[n]:void 0,d=u!==void 0,f=Ai(r);if(d&&a?_i(u):d&&yo(u,r,f))return{kind:o?`unchanged`:`overwritten`};let p=s.charCodeAt(0)===65279,m=p?s.slice(1):s,h=m.includes(`\r
|
|
679
679
|
`)?`\r
|
|
680
680
|
`:`
|
|
681
|
-
`,g={...bo(m),eol:h},_=xo(t,i,n),v=m;if(o)for(let e of d?ji(u,r):[]){let t=
|
|
681
|
+
`,g={...bo(m),eol:h},_=xo(t,i,n),v=m;if(o)for(let e of d?ji(u,r):[]){let t=Ne(v,[..._,e],void 0,{formattingOptions:g});v=w(v,t)}else if(d&&!a&&Ei(u))for(let e of f){let t=Ne(v,[..._,e],r[e],{formattingOptions:g});v=w(v,t)}else{let e=Ne(v,_,r,{formattingOptions:g});v=w(v,e)}let y=`${p?``:``}${v}`;return y!==s&&T(e,y,{mode:Ia(e)}),o&&y===s?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}function To(e,t,n,r,i,a=!1,o=!1){let s=``;if(R(t))try{s=z(t,`utf-8`)}catch(e){return Y(`toml config read failed`,e),{kind:`declined`,reason:Ma(e)}}let c=s.trim()===``;if(c&&o)return{kind:`unchanged`};if(e.backend===`fallback`)return c?(ho(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let l=s.charCodeAt(0)===65279,u=l?s.slice(1):s,d=Fa(u),f=c||u.endsWith(`
|
|
682
682
|
`),p,m=!1;try{let t=Eo(e,u,n,r);if(o){let n=u;for(let a of t===void 0?[]:ji(t,i))n=e.removeEntryKey(n,r,a).text;p={text:n,existed:t!==void 0}}else{let n=Do(t,i,a);m=n.kind===`replace`;let o=m?e.removeEntry(u,r).text:u;if(n.kind===`merge`)for(let t of n.prune)o=e.removeEntryKey(o,r,t).text;p=e.upsertEntry(o,r,i)}}catch(e){return Y(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let h=p.text;f?h.endsWith(`
|
|
683
683
|
`)||(h=`${h}\n`):h=h.replace(/\n+$/,``),d&&(h=h.replace(/\r\n/g,`
|
|
684
684
|
`).replace(/\n/g,`\r
|
|
685
|
-
`));let g=`${l?``:``}${h}`;return g!==s&&
|
|
685
|
+
`));let g=`${l?``:``}${h}`;return g!==s&&T(t,g,{mode:Ia(t)}),o&&g===s?{kind:`unchanged`}:{kind:p.existed||m?`overwritten`:`written`}}function Eo(e,t,n,r){if(t.trim()===``)return;let i=e.parseToObject(t)[n],a=j(i)?i[r]:void 0;return j(a)?a:void 0}function Do(e,t,n){return e===void 0||_i(e)?{kind:`merge`,prune:[]}:n||!Ei(e)?{kind:`replace`}:{kind:`merge`,prune:ji(e,t)}}function Oo(e,t,n,r,i=!1,a=!1){let o=``;if(R(e))try{o=z(e,`utf-8`)}catch(e){return Y(`yaml config read failed`,e),{kind:`declined`,reason:Ma(e)}}if(o.trim()===``)return a?{kind:`unchanged`}:(go(e,{[t]:{[n]:r}}),{kind:`written`});if(Buffer.byteLength(o,`utf-8`)>_o)return{kind:`declined`,reason:`oversize`};let s=o.charCodeAt(0)===65279,c=s?o.slice(1):o,l=(0,Hr.parseDocument)(c);if(l.errors.length>0)return{kind:`declined`,reason:`unparseable`};let u=[t,n],d=l.hasIn(u);l.hasIn([t])&&!(0,Hr.isCollection)(l.getIn([t],!0))&&l.deleteIn([t]);let f=l.getIn(u,!0),p=d&&(0,Hr.isCollection)(f)&&(i?_i(f.toJSON()):Ei(f.toJSON()));if(a){if(d&&(0,Hr.isCollection)(f))for(let e of ji(f.toJSON(),r))l.deleteIn([...u,e])}else if(p)for(let e of Ai(r))r[e]===void 0?l.deleteIn([...u,e]):l.setIn([...u,e],l.createNode(r[e]));else l.setIn(u,l.createNode(r));let m=l.toString(),h=Fa(c);c.endsWith(`
|
|
686
686
|
`)?m.endsWith(`
|
|
687
687
|
`)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
|
|
688
688
|
`).replace(/\n/g,`\r
|
|
689
|
-
`));let g=`${s?``:``}${m}`;return g!==o&&
|
|
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 Mo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??jo)():`both`}async function No(e){return Xa({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 Po(e){if(e.sharing!==void 0)return e.sharing;let t=aa(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??No)(t):t}var Fo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Io(e){if(e===void 0||e===!0)return new Set(Ee);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(oe.filter(e=>t.includes(e)))}function Lo(e,t,n){let r=I(n,e),i;try{i=tt(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Fo(`--content-dir path does not exist: ${r}`):new Fo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Fo(`--content-dir must be a directory: ${r}`);let a=Ro(t),o=Ro(r),s=F(a,o);if(s.startsWith(`..`)||Ue(s))throw new Fo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Ro(e){try{return $e(e)}catch{return e}}const zo=`open-knowledge-ui`;function Bo(e,t,n){try{let r=e.detectPath?.(t,n)??N(e.configPath(t,n));return R(r)}catch{return!1}}function Vo(e,t,n){try{let r=I(N(e.configPath(t,n))),i=I(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+Ge)}catch{return!1}}function Ho(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`||!R(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||Vo(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{ya(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||Xe(N(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{Pe(`${o}.lock`,()=>{let t=co(o).writePath;if(s||Xe(N(t),{recursive:!0}),e.format===`toml`){let r=To(ti(),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=Oo(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=wo(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 Uo={pi:eo};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=Uo[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{Xe(N(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{Pe(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}E(t,c,e===null?void 0:{mode:Ia(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 Go(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Ko(e){let t=Qi(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=>Ho(t,``,n,e.home))}function qo(e,t,n,r){let i=Yo(e,t,n,r);return i.kind===`present`?i.entry:null}function Jo(e,t,n,r){let i=Co(e,t,r);if(!M(i))return{kind:`no-entry`};let a=i[n];return M(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Yo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(tt(i).size>_o)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ma(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ma(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:$a(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ti().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Jo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Hr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Jo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=fo(a);return s?po(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Jo(ue(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Xo(e={}){let t=I(e.cwd??process.cwd()),n=ro(t,{homeDir:e.home}),r=n.projectRoot;if(ve(r,e.home??B()))throw new me(r);if(Ne(r))throw new se(r);let i=!R(P(r,`.ok`)),a=n.gitRootPromoted?F(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Lo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${A(`[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 Te(r),l;try{l=ce(r,{contentDir:o})}catch(t){let i=$.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(Le),f=!1;if(c.didInit)try{f=fe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{we(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 Mo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??ns(r,e.home),h=e.editors??m,g=Qi(m),_=Qi(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Bo(t,r,e.home)),x=[],S=[],ee=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(ko(p)&&g.includes(t)&&t.scope===`global`&&x.push(Ho(t,r,s,e.home)),Ao(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ho(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&ee.add(n)}}let C=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||C.has(n)||(C.add(n),S.push(Aa(t,r,{home:e.home})))}let te=ka(r,_.map(e=>e.id));te&&S.push(te);let ne=S.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ne.length>0){let t=e.home??B();Ae({source:d,skills:[Oe.project],agents:ne,scope:r},{home:t,enabled:ae(t).enabled})}let re=!v&&p!==null&&Ao(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ie=v?[]:b.map(e=>Go(e,r)).filter(e=>e!==void 0).filter(e=>!ee.has(e.path)),w=e.installUserSkill??ge,T=e.home??B(),le=Io(e.skills),ue=typeof e.skills!=`string`,pe=!1,_e=!1,be=!1,xe=!1,Ce=!1,E=!1,Ee=!1,De=[];for(let t of oe){if(!le.has(t))continue;if(pe=!0,ue){let e=await he(T,Oe[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){De.push({bundleId:t,result:`decision-read-failed`}),Ee=!0;continue}if(e.value===!1){De.push({bundleId:t,result:`opted-out`}),E=!0;continue}}await de(T,Oe[t],!0).catch(()=>{});let n=await w({home:e.home,bundleId:t,force:!0});De.push({bundleId:t,result:n}),n===`installed`?_e=!0:n===`failed`?be=!0:n===`no-hosts`?Ce=!0:xe=!0}let ke=be?`failed`:Ee?`decision-read-failed`:_e?`installed`:pe&&xe?`skip-current`:pe&&Ce?`no-hosts`:E?`opted-out`:`declined`,je=_e?ye(T).map(e=>e.editorId):[],Me=ae(T).enabled&&!Se(),Pe=v?`skipped-flag`:`skipped-missing`,Fe=x.find(e=>e.editorId===`claude`)??x[0]??{action:Pe,configPath:$.claude.configPath(r,e.home)},D=await Zo({projectRoot:r,desiredMode:await Po({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:x,projectSkills:S,legacyProjectConfigs:ie,skillInstall:ke,skillBundles:De,skillsRequested:e.skills,skillHosts:je,skillInstallsCounted:Me,didGitInit:c.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Fe.action,mcpPath:Fe.configPath,mcpError:`error`in Fe?Fe.error:void 0,projectScopeUnsupportedLabels:re,sharing:D}}async function Zo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=aa(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ta(t);if(n===`local-only`){let e=ra(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`}:Qo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=ia(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Qo(t,o,`remove`)}function Qo(e,t,n){let r=aa(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 $o(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 es(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`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=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 c=P(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(j(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(j(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(j(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(j(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(j(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?F(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===w()?``:` (${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} ${k(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${k(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Ie(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${$o(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(j(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?F(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${k(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${k(`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} ${Ie(`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} ${F(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===`declined`)n.push(``),n.push(j(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${O(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${oe.join(`, `)})`)}`),n.push(` ${O(`No user-global skill was installed or removed.`)}`)):(n.push(` ${O(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${O(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${O(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${O(` ok init`)}`),n.push(` ${O(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(j(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Oe[e.bundleId].length));for(let i of t){let t=Oe[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${k(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${k(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${O(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${A(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${O(`not installed — turned off on this machine; reinstall with ok init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${A(`${t} not installed — could not read whether it is turned off on this machine; rerun ok init once ${a(p)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${O(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${O(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${A(`Retry with: ok repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(A(`⚠ --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(A(`⚠ 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(Re(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...as(e.sharing,t));let l=e=>[`${e}- ${D(`ok seed --list-packs`)} — browse the starter packs`,`${e}- ${D(`ok seed`)} — scaffold an empty repo`];if(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(`${k(`✓`)} ${j(`Next steps:`)}`),n.push(` 1. Open your editor (${D(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...l(` `))),n.push(` ${i}. 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.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${j(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...l(` `)));return n.join(`
|
|
691
|
-
`)}function ts(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 ns(e,t){let n=[];for(let r of ri)r!==`claude-desktop`&&Bo($[r],e,t)&&n.push(r);return n}function rs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:rt(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 is(){return new xt(`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 Ct(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ct(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ct(`--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?rs():null;try{let r;try{r=await Xo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Fo||e instanceof
|
|
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-
|
|
693
|
-
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${
|
|
689
|
+
`));let g=`${s?``:``}${m}`;return g!==o&&T(e,g,{mode:Ia(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const ko=e=>e!==`project`,Ao=e=>e!==`user`;async function jo(){let e=await Ga({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 Mo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??jo)():`both`}async function No(e){return Xa({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 Po(e){if(e.sharing!==void 0)return e.sharing;let t=aa(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??No)(t):t}var Fo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Io(e){if(e===void 0||e===!0)return new Set(De);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(se.filter(e=>t.includes(e)))}function Lo(e,t,n){let r=F(n,e),i;try{i=tt(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Fo(`--content-dir path does not exist: ${r}`):new Fo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Fo(`--content-dir must be a directory: ${r}`);let a=Ro(t),o=Ro(r),s=P(a,o);if(s.startsWith(`..`)||We(s))throw new Fo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Ro(e){try{return $e(e)}catch{return e}}const zo=`open-knowledge-ui`;function Bo(e,t,n){try{let r=e.detectPath?.(t,n)??M(e.configPath(t,n));return R(r)}catch{return!1}}function Vo(e,t,n){try{let r=F(M(e.configPath(t,n))),i=F(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+I)}catch{return!1}}function Ho(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`||!R(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||Vo(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{ya(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||Xe(M(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{Fe(`${o}.lock`,()=>{let t=co(o).writePath;if(s||Xe(M(t),{recursive:!0}),e.format===`toml`){let r=To(ti(),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=Oo(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=wo(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 Uo={pi:eo};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=Uo[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{Xe(M(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{Fe(`${t}.lock`,()=>{let e=null;try{e=z(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Ia(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 Go(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!R(n)))return{editorId:e.id,label:e.label,path:n}}async function Ko(e){let t=Qi(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=>Ho(t,``,n,e.home))}function qo(e,t,n,r){let i=Yo(e,t,n,r);return i.kind===`present`?i.entry:null}function Jo(e,t,n,r){let i=Co(e,t,r);if(!j(i))return{kind:`no-entry`};let a=i[n];return j(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Yo(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!R(i))return{kind:`absent`};try{if(tt(i).size>_o)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ma(e)}}let a;try{a=z(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ma(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:$a(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ti().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Jo(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Hr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Jo(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=fo(a);return s?po(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Jo(de(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Xo(e={}){let t=F(e.cwd??process.cwd()),n=ro(t,{homeDir:e.home}),r=n.projectRoot;if(ye(r,e.home??B()))throw new he(r);if(Pe(r))throw new ce(r);let i=!R(N(r,`.ok`)),a=n.gitRootPromoted?P(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Lo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${k(`[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 Ee(r),u;try{u=le(r,{contentDir:o})}catch(t){let i=$.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(Re),f=!1;if(c.didInit)try{f=pe(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{Te(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 Mo({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),m=e.editors??ns(r,e.home),h=e.editors??m,g=Qi(m),_=Qi(h),v=e.mcp===!1||p===null,y=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),b=g.filter(t=>Bo(t,r,e.home)),x=[],S=[],ee=new Set;for(let t of y){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}x.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(ko(p)&&g.includes(t)&&t.scope===`global`&&x.push(Ho(t,r,s,e.home)),Ao(p)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Ho(t,r,s,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&ee.add(n)}}let te=new Set;for(let t of _){let n=t.projectSkillPath?.(r);!n||te.has(n)||(te.add(n),S.push(Aa(t,r,{home:e.home})))}let ne=ka(r,_.map(e=>e.id));ne&&S.push(ne);let re=S.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(re.length>0){let t=e.home??B();je({source:l,skills:[ke.project],agents:re,scope:r},{home:t,enabled:oe(t).enabled})}let ie=!v&&p!==null&&Ao(p)?_.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ae=v?[]:b.map(e=>Go(e,r)).filter(e=>e!==void 0).filter(e=>!ee.has(e.path)),C=e.installUserSkill??_e,w=e.home??B(),ue=Io(e.skills),de=typeof e.skills!=`string`,me=!1,ve=!1,xe=!1,Se=!1,we=!1,T=!1,De=!1,Oe=[];for(let t of se){if(!ue.has(t))continue;if(me=!0,de){let e=await ge(w,ke[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Oe.push({bundleId:t,result:`decision-read-failed`}),De=!0;continue}if(e.value===!1){Oe.push({bundleId:t,result:`opted-out`}),T=!0;continue}}await fe(w,ke[t],!0).catch(()=>{});let n=await C({home:e.home,bundleId:t,force:!0});Oe.push({bundleId:t,result:n}),n===`installed`?ve=!0:n===`failed`?xe=!0:n===`no-hosts`?we=!0:Se=!0}let Ae=xe?`failed`:De?`decision-read-failed`:ve?`installed`:me&&Se?`skip-current`:me&&we?`no-hosts`:T?`opted-out`:`declined`,Me=ve?be(w).map(e=>e.editorId):[],Ne=oe(w).enabled&&!Ce(),Fe=v?`skipped-flag`:`skipped-missing`,Ie=x.find(e=>e.editorId===`claude`)??x[0]??{action:Fe,configPath:$.claude.configPath(r,e.home)},E=await Zo({projectRoot:r,desiredMode:await Po({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:x,projectSkills:S,legacyProjectConfigs:ae,skillInstall:Ae,skillBundles:Oe,skillsRequested:e.skills,skillHosts:Me,skillInstallsCounted:Ne,didGitInit:c.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Ie.action,mcpPath:Ie.configPath,mcpError:`error`in Ie?Ie.error:void 0,projectScopeUnsupportedLabels:ie,sharing:E}}async function Zo(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=aa(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=ta(t);if(n===`local-only`){let e=ra(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`}:Qo(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=ia(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Qo(t,o,`remove`)}function Qo(e,t,n){let r=aa(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 $o(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 es(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),s=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 c=N(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(A(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(A(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(A(`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(o)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(s)n.push(A(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(A(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?P(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===C()?``:` (${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} ${O(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${O(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${Le(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${$o(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(A(`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?P(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${O(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${O(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${Le(`FAILED`)}: ${r.error}`)}}}if(a&&(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} ${P(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===`declined`)n.push(``),n.push(A(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${D(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${se.join(`, `)})`)}`),n.push(` ${D(`No user-global skill was installed or removed.`)}`)):(n.push(` ${D(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${D(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${D(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${D(` ok init`)}`),n.push(` ${D(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(A(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>ke[e.bundleId].length));for(let a of t){let t=ke[a.bundleId].padEnd(r);switch(a.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${O(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${O(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${D(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${k(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${D(`not installed — turned off on this machine; reinstall with ok init --skills ${a.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${k(`${t} not installed — could not read whether it is turned off on this machine; rerun ok init once ${i(d)} is readable`)}`);break;default:a.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${D(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${D(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${k(`Retry with: ok repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(k(`⚠ --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(k(`⚠ 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(ze(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...as(e.sharing,t));let l=e=>[`${e}- ${E(`ok seed --list-packs`)} — browse the starter packs`,`${e}- ${E(`ok seed`)} — scaffold an empty repo`];if(r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${O(`✓`)} ${A(`Next steps:`)}`),n.push(` 1. Open your editor (${E(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...l(` `))),n.push(` ${i}. 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.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${A(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...l(` `)));return n.join(`
|
|
691
|
+
`)}function ts(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 ns(e,t){let n=[];for(let r of ri)r!==`claude-desktop`&&Bo($[r],e,t)&&n.push(r);return n}function rs(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:rt(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 is(){return new xt(`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 Ct(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ct(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ct(`--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?rs():null;try{let r;try{r=await Xo({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Fo||e instanceof he||e instanceof ce){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof me||e instanceof Ie){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof Ae){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-CkxCQRBx.mjs`),{resolveContentDir:s}=await import(`./dist-DjEZX3vG.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-Cf5VnxW_.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(ts(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${es(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function as(e,t){let n=[];switch(e.kind){case`applied`:return n.push(A(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${O(`local-only`)} — appended ${e.appended.length} path(s) to ${A(`${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(` ${O(`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(` ${O(`local-only`)} — already excluded; nothing to do.`):n.push(` ${O(`local-only`)}`):e.action===`removed`?n.push(` ${O(`shared`)} — removed OK paths from ${A(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${O(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(k(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
693
|
+
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${E(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(k(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${E(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${E(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(k(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Mi as $,La as A,ra as B,ro as C,xt as Ct,Ga as D,Xa as E,ya as F,sa as G,oa as H,ba as I,ri as J,aa as K,ja as L,Ma as M,va as N,Ia as O,Sa as P,Z as Q,Ca as R,co as S,Nt as St,Qa as T,Ct as Tt,na as U,da as V,ta as W,$ as X,X as Y,ii as Z,Xo as _,er as _t,ts as a,Fi as at,Ko as b,on as bt,es as c,qi as ct,Bo as d,ti as dt,ji as et,qo as f,Y as ft,Po as g,dr as gt,Lo as h,qr as ht,Zo as i,_i as it,Na as j,Fa as k,as as l,xi as lt,Mo as m,Wr as mt,zo as n,Pi as nt,Yo as o,Q as ot,Io as p,Gr as pt,ia as q,Uo as r,mi as rt,ns as s,Ii as st,Fo as t,Ni as tt,is as u,ni as ut,xo as v,un as vt,eo as w,yt as wt,Vo as x,U as xt,Ho as y,sn as yt,Aa as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-CqZISrZN.mjs";import{_ as e}from"./init-BontxrPQ.mjs";export{e as runInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ko as e,Yo as t,es as n}from"./dist-
|
|
1
|
+
import{Ko as e,Yo as t,es as n}from"./dist-CqZISrZN.mjs";import{A as r,M as i,O as a}from"./init-BontxrPQ.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-D0LbC71-.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-DMoA9Hv1.mjs";export{e as loadConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ec as e,
|
|
1
|
+
import{Ec as e,Gu as t,Jc as n,O as r,Oc as i,Xc as a,el as o}from"./md-manager-BGnqyqi1-dBGkA2rR.mjs";import{as as s,rs as c,x as l}from"./dist-CqZISrZN.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CEWqiFCf.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=t();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),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=a({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(t){let a=t??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,a),_=c({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,t=!1)=>{let i=v(e);if(i.diagnostic!==void 0&&p.push(i.diagnostic),i.value===null)return{};let a=n({value:i.value,file:i.path,source:i.source,doc:i.doc});p.push(...a),u.push(e);let s=a.length>0?o(i.value):i.value;return t&&h.push(...r({value:s,file:i.path,source:i.source,doc:i.doc})),s},x=f(a,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,a)),w=e(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),t={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(i(t))}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};
|