@inkeep/open-knowledge 0.16.1-beta.7 → 0.16.1-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +6 -6
  4. package/dist/constants-DbENhsxl.mjs +2 -0
  5. package/dist/{dist-DvEI00I1.mjs → dist-CdLjGZjc.mjs} +4 -4
  6. package/dist/{dist-Dat97svn.mjs → dist-DHvnq6Ai.mjs} +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/{init-BO9tnd8g.mjs → init-D21pFsMR.mjs} +4 -4
  9. package/dist/init-DkUWx0T-.mjs +1 -0
  10. package/dist/{loader-BicOC80J.mjs → loader-DpizTs6p.mjs} +2 -2
  11. package/dist/loader-T98A78tr.mjs +1 -0
  12. package/dist/{preview-C7YD86Pc.mjs → preview-DMinlQU3.mjs} +2 -2
  13. package/dist/preview-wM1DJuPS.mjs +1 -0
  14. package/dist/public/assets/{index-DJWeEt10.js → index-DSdwUSf0.js} +2 -2
  15. package/dist/public/index.html +1 -1
  16. package/dist/{repair-launch-json-e8LkOdCc.mjs → repair-launch-json-hQzZWJEV.mjs} +2 -2
  17. package/dist/{repair-mcp-configs--EEo_NYX.mjs → repair-mcp-configs-Dk0wiyoG.mjs} +2 -2
  18. package/dist/repair-skills-CPdGe_yS.mjs +1 -0
  19. package/dist/{repair-skills-7PrXw-wL.mjs → repair-skills-DPudTR_l.mjs} +2 -2
  20. package/dist/{src-M3O8DB6m.mjs → src-BzQcpEPg.mjs} +2 -2
  21. package/dist/start-CXtw3XDf.mjs +1 -0
  22. package/dist/{start-jFVdiCIZ.mjs → start-E4_PXpTr.mjs} +2 -2
  23. package/dist/{write-project-skill-DUCFyVhD.mjs → write-project-skill-bJPJ3udE.mjs} +2 -2
  24. package/package.json +1 -1
  25. package/dist/constants-BuOKDREu.mjs +0 -2
  26. package/dist/init-BZtiKpeO.mjs +0 -1
  27. package/dist/loader-Bq5LpCql.mjs +0 -1
  28. package/dist/preview-BPvWgmw3.mjs +0 -1
  29. package/dist/repair-skills-FzkUuF_z.mjs +0 -1
  30. package/dist/start-DCkVhUyE.mjs +0 -1
@@ -1 +1 @@
1
- import{Gr as e,J as t,Sn as n,Xr as r,a as i,an as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,tn as b,u as x,vn as S,wr as C,zt as w}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{$ as T,$n as E,$r as D,$t as O,A as k,Ai as A,An as j,Ar as M,At as N,B as P,Bi as F,Bn as I,Br as L,Bt as R,C as z,Ci as B,Cn as V,Cr as H,Ct as U,D as W,Di as G,Dn as K,Dr as q,Dt as J,E as Y,Ei as X,En as Z,Er as Q,Et as $,F as ee,Fi as te,Fn as ne,Fr as re,Ft as ie,G as ae,Gn as oe,Gr as se,Gt as ce,H as le,Hi as ue,Hn as de,Hr as fe,Ht as pe,I as me,Ii as he,In as ge,Ir as _e,It as ve,J as ye,Jn as be,Jr as xe,Jt as Se,K as Ce,Kn as we,Kr as Te,Kt as Ee,L as De,Li as Oe,Ln as ke,Lr as Ae,Lt as je,M as Me,Mi as Ne,Mn as Pe,Mr as Fe,Mt as Ie,N as Le,Ni as Re,Nn as ze,Nr as Be,Nt as Ve,O as He,Oi as Ue,On as We,Or as Ge,Ot as Ke,P as qe,Pi as Je,Pn as Ye,Pr as Xe,Pt as Ze,Q as Qe,Qn as $e,Qr as et,Qt as tt,R as nt,Ri as rt,Rn as it,Rr as at,Rt as ot,S as st,Si as ct,Sn as lt,Sr as ut,St as dt,T as ft,Ti as pt,Tn as mt,Tr as ht,Tt as gt,U as _t,Ui as vt,Un as yt,Ur as bt,Ut as xt,V as St,Vi as Ct,Vn as wt,Vr as Tt,Vt as Et,W as Dt,Wn as Ot,Wr as kt,Wt as At,X as jt,Xn as Mt,Xr as Nt,Xt as Pt,Y as Ft,Yn as It,Yr as Lt,Yt as Rt,Z as zt,Zn as Bt,Zr as Vt,Zt as Ht,_ as Ut,_i as Wt,_n as Gt,_r as Kt,_t as qt,a as Jt,ai as Yt,an as Xt,ar as Zt,at as Qt,b as $t,bi as en,bn as tn,br as nn,bt as rn,c as an,ci as on,cn as sn,cr as cn,ct as ln,d as un,di as dn,dn as fn,dr as pn,dt as mn,ei as hn,en as gn,er as _n,et as vn,f as yn,fi as bn,fn as xn,fr as Sn,ft as Cn,g as wn,gi as Tn,gn as En,gr as Dn,gt as On,h as kn,hi as An,hn as jn,hr as Mn,ht as Nn,i as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,li as Xn,ln as Zn,lr as Qn,lt as $n,m as er,mi as tr,mn as nr,mr as rr,mt as ir,n as ar,na as or,ni as sr,nn as cr,nr as lr,nt as ur,o as dr,oi as fr,on as pr,or as mr,ot as hr,p as gr,pi as _r,pn as vr,pr as yr,pt as br,q as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ri as Er,rn as Dr,rr as Or,rt as kr,s as Ar,si as jr,sn as Mr,sr as Nr,st as Pr,t as Fr,ta as Ir,ti as Lr,tn as Rr,tr as zr,tt as Br,u as Vr,ui as Hr,un as Ur,ur as Wr,ut as Gr,v as Kr,vi as qr,vn as Jr,vr as Yr,vt as Xr,w as Zr,wi as Qr,wn as $r,wr as ei,wt as ti,x as ni,xi as ri,xn as ii,xr as ai,xt as oi,y as si,yi as ci,yn as li,yr as ui,yt as di,z as fi,zi as pi,zn as mi,zr as hi,zt as gi}from"./dist-DvEI00I1.mjs";export{Fr as AGENT_ID_MAX_LEN,ar as AGENT_ID_RE,Tr as AGENT_WRITE_ORIGIN,Pn as AgentFocusBroadcaster,Jt as AgentPresenceBroadcaster,dr as AgentSessionCapacityError,Ar as AgentSessionManager,an as AutoStartDisabledError,Yn as BacklinkIndex,Vr as CC1Broadcaster,t as CC1_CONTRACT_VERSION,un as CONFIG_FILENAME,yn as CONFLICT_MARKER_RE,gr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,er as ConfigSchema,kn as DEFAULT_CHECKPOINT_RETENTION,wn as DEFAULT_EMBEDDINGS_DIMENSIONS,Ut as DEFAULT_PACK_ID,Kr as EMBEDDINGS_API_KEY_ENV,si as FILE_SYSTEM_WRITER,$t as FILE_WATCHER_ORIGIN,ni as FileEmbeddingsBackend,st as GIT_PREFLIGHT_FAIL_SPAN_NAME,z as GIT_UPSTREAM_WRITER,Ir as GitDirAccessError,Zr as GitNotAvailableError,ft as GitTooOldError,Y as HOCUSPOCUS_AUTH_REJECTION_REASONS,W as HocuspocusAuthRejection,He as HocuspocusAuthTokenSchema,Wn as INSTALLED_AGENTS_SCHEMES,w as LINEAGE_EPOCH_KEY,k as LIVE_DERIVED_INDEX_DEBOUNCE_MS,zn as LOG_MD_TEMPLATE,Me as MANAGED_RENAME_ORIGIN,Le as MAX_AGENT_SESSIONS,qe as MCP_CONNECTION_ID_HEADER,ee as MCP_SERVER_NAME,me as MIN_GIT_VERSION,De as MISSING_OK_CONFIG_MESSAGE,or as MalformedGitPointerError,nt as McpLogger,fi as MissingOkConfigError,P as OBSERVER_SYNC_ORIGIN,St as OK_OKIGNORE_TEMPLATE,b as ORPHAN_MODES,le as PANE_TARGET_TTL_MS,a as PROTOCOL_VERSION,_t as PinoLogger,y as ProcessLockCollisionError,Dt as ProjectGitInitError,ae as ROLLBACK_ORIGIN,Ce as ROOT_GITIGNORE_TEMPLATE,m as RUNTIME_VERSION,xr as SERVICE_WRITER,ye as SKILL_INSTALL_EVENTS_FILE_REL,S as SKILL_STATE_TARGETS,Ft as STARTER_FOLDERS,jt as STARTER_FOLDER_FRONTMATTER_FILENAME,zt as STARTER_PACKS,Qe as STARTER_PACK_IDS,T as STARTER_TEMPLATES,vn as STATE_MANIFEST_FILENAME,_ as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,Br as SeedPrerequisiteError,ur as SeedRootDirError,d as ServerLockCollisionError,kr as SingleFileNotAFileError,Rn as SingleFileNotFoundError,Qt as SingleFileNotMarkdownError,hr as StateManifestError,Pr as TagIndex,ln as UiLockCollisionError,$n as __getShowAllWalkStatsForTesting,Gr as __resetShowAllWalkStatsForTesting,i as acquireProcessLock,h as acquireServerLock,mn as acquireUiLock,Cn as applyAgentMarkdownWrite,br as applyExternalChange,ir as applySeed,Nn as armPaneTarget,On as assertCompatibleStateManifest,qt as assertGitAvailable,Xr as assertNeverDiskEvent,di as attachIdleShutdown,rn as bootServer,oi as buildAndOpenSkill,dt as buildConfigYmlContent,U as buildExecResult,ti as buildSkillZip,gt as buildStarterFolderFrontmatterYaml,$ as buildWipTree,J as classifyEvents,Ke as classifyFsPath,Jn as clearArmedPaneTarget,N as clearContributors,Un as clearEmbeddingsKeyFromAllBackends,Ie as coercePackId,C as colorFromSeed,Ve as commitUpstreamImport,Ze as commitWip,ie as commitWipFromTree,ve as compareSemver,je as containsConflictMarkers,ot as contentHash,gi as contributorCount,R as countShadowObjects,Et as countStaleAgentWipRefs,pe as countWipRefs,xt as createApiExtension,At as createAssetServeMiddleware,ce as createContentFilter,Ee as createContentFilterAsync,wr as createEmbeddingsSecretStore,Se as createEphemeralProjectDir,Rt as createExternalChangeHandler,Pt as createFileLogger,Ht as createLiveDerivedIndexExtension,tt as createMcpHttpHandler,O as createOsProbe,gn as createPersistenceExtension,Rr as createServer,cr as createServerObserverExtension,Dr as createStreamingErrorWriter,In as createTestLogger,Xt as describeStoredEmbeddingsKey,pr as detectClaudeDesktopPresence,Mr as detectGit,sn as detectProjectShape,Zn as emitPreflightFailureSpan,Ur as encodeDocName,fn as encodeFolderRoute,xn as ensureProjectGit,vr as errorResponse,nr as evictStaleTrackerEntries,jn as extractWikiLinksFromMarkdown,En as fallbackPaths,Gt as findEnclosingGitRoot,Jr as findEnclosingProjectRoot,li as flushFileLogger,tn as formatAuthRejectionWire,ii as formatContributors,lt as formatContributorsFrom,V as formatPackRationale,$r as gcCheckpointRefs,mt as getCurrentMcpLogger,Z as getLocalDir,K as getLogFilePath,We as getLogger,Kn as getLogsDir,j as getMeter,Vn as getMetrics,Pe as getTracer,ze as handleCollabSocketError,Ye as handleSpawnCursor,ne as hasGcLogLatch,e as iconFromClientName,ge as incrementCollabSocketFilteredError,ke as incrementServerObserverFire,it as initContent,mi as initShadowRepo,I as initTelemetry,wt as initToleranceTelemetryWriter,de as installPrettyZodErrors,yt as installTestLoggers,Ot as installUserSkill,oe as isAllowedApiOrigin,we as isAllowedWorkspaceHostHeader,Sr as isConfigDoc,be as isHocuspocusAuthRejectionReason,It as isKnownPackId,Mt as isLoopbackAddress,r as isOrphanMode,Bt as isPairedWriteOrigin,$e as isPathWithinDir,v as isProcessAlive,E as isProjectRoot,_n as isSelfWrite,zr as isSystemDoc,lr as isToleranceTelemetryEnabled,o as isValidLockPid,Or as lastKnownHash,Ln as listRescueCheckpoints,Zt as listStarterPacks,mr as loadPrincipal,f as lockFilePath,Nr as loggerFactory,cn as logsCurrentPath,Qn as logsPreviousPath,Wr as makeLazyEmbeddingsKeyStore,pn as mountMcpAndApi,Sn as normalizeFsPath,yr as packageVersionMajorMinor,rr as parseAuthRejectionWire,Mn as parseGitVersion,Dn as parseHocuspocusAuthToken,Kt as parseKeepaliveConnectionId,Yr as pathToDocName,ui as planSeed,nn as prepareSingleFileOpen,ai as readAllTargets,ut as readArmedPaneTarget,H as readBranchFromHead,x as readProcessLock,s as readProcessLockDetailed,ei as readProjectLocalSemanticConfig,c as readServerLock,ht as readServerPackageVersion,Q as readSkillInstallStateSnapshot,q as readStateManifest,Ge as readTargetRecordedAt,qn as readTargetVersion,M as readUiLock,Hn as reconcile,Fe as recordContributor,Be as recordSkillInstallEvent,Xe as registerAllTools,re as registerWrite,g as releaseProcessLock,p as releaseServerLock,_e as releaseUiLock,Ae as removeLastKnownHash,at as resetMetrics,hi as resolveBundledSkillDir,L as resolveContentDir,Tt as resolveCursorBinaryDefault,fe as resolveCursorSpawnInvocation,bt as resolveLockDir,kt as resolvePack,se as resolvePackageVersion,Te as resolveUiInfo,Cr as restoreContributors,xe as restoreLifecycleFromConflictsJson,Lt as rewriteMarkdownLinksForDocumentRename,Nt as rewriteWikiLinksForDocumentRename,Vt as runAuthReposSubprocess,et as runAuthStatusSubprocess,D as runCloneSubprocess,hn as runDeviceFlowSubprocess,Lr as runWithMcpLogger,sr as safeContentPath,Er as safeSubdir,Fn as safetyCheckpoint,Yt as sanitizeClientName,fr as saveInMemoryCheckpoint,jr as saveVersion,on as seedBasenameIndex,Xn as serializeError,Hr as setActiveSpanAttributes,dn as shadowGit,bn as shutdownTelemetry,_r as spansCurrentPath,tr as spansPreviousPath,An as spawnDetached,Tn as splitMarkdownBlocks,Wt as startWatcher,qr as streamingProblemEvent,ci as swapContributors,en as teardownToleranceTelemetryWriter,ri as toBroadcasterKey,ct as tracedAppendFileSync,B as tracedLinkSync,Qr as tracedMkdir,pt as tracedMkdirSync,X as tracedRename,G as tracedRenameSync,Ue as tracedRmSync,Gn as tracedRmdirSync,A as tracedUnlinkSync,Bn as tracedWriteFile,Ne as tracedWriteFileSync,Re as updateLastKnownHash,u as updateProcessLockPort,l as updateServerLockPort,Je as updateUiLockPort,te as validateAgentId,he as validateCloneInputs,Oe as validateSkillZip,rt as withSpan,pi as withSpanSync,F as writeRootGitignoreForNewRepo,Ct as writeStateManifest,ue as writeTargetVersion,vt as writeTracker};
1
+ import{Gr as e,J as t,Sn as n,Xr as r,a as i,an as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,tn as b,u as x,vn as S,wr as C,zt as w}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{$ as T,$n as E,$r as D,$t as O,A as k,Ai as A,An as j,Ar as M,At as N,B as P,Bi as F,Bn as I,Br as L,Bt as R,C as z,Ci as B,Cn as V,Cr as H,Ct as U,D as W,Di as G,Dn as K,Dr as q,Dt as J,E as Y,Ei as X,En as Z,Er as Q,Et as $,F as ee,Fi as te,Fn as ne,Fr as re,Ft as ie,G as ae,Gn as oe,Gr as se,Gt as ce,H as le,Hi as ue,Hn as de,Hr as fe,Ht as pe,I as me,Ii as he,In as ge,Ir as _e,It as ve,J as ye,Jn as be,Jr as xe,Jt as Se,K as Ce,Kn as we,Kr as Te,Kt as Ee,L as De,Li as Oe,Ln as ke,Lr as Ae,Lt as je,M as Me,Mi as Ne,Mn as Pe,Mr as Fe,Mt as Ie,N as Le,Ni as Re,Nn as ze,Nr as Be,Nt as Ve,O as He,Oi as Ue,On as We,Or as Ge,Ot as Ke,P as qe,Pi as Je,Pn as Ye,Pr as Xe,Pt as Ze,Q as Qe,Qn as $e,Qr as et,Qt as tt,R as nt,Ri as rt,Rn as it,Rr as at,Rt as ot,S as st,Si as ct,Sn as lt,Sr as ut,St as dt,T as ft,Ti as pt,Tn as mt,Tr as ht,Tt as gt,U as _t,Ui as vt,Un as yt,Ur as bt,Ut as xt,V as St,Vi as Ct,Vn as wt,Vr as Tt,Vt as Et,W as Dt,Wn as Ot,Wr as kt,Wt as At,X as jt,Xn as Mt,Xr as Nt,Xt as Pt,Y as Ft,Yn as It,Yr as Lt,Yt as Rt,Z as zt,Zn as Bt,Zr as Vt,Zt as Ht,_ as Ut,_i as Wt,_n as Gt,_r as Kt,_t as qt,a as Jt,ai as Yt,an as Xt,ar as Zt,at as Qt,b as $t,bi as en,bn as tn,br as nn,bt as rn,c as an,ci as on,cn as sn,cr as cn,ct as ln,d as un,di as dn,dn as fn,dr as pn,dt as mn,ei as hn,en as gn,er as _n,et as vn,f as yn,fi as bn,fn as xn,fr as Sn,ft as Cn,g as wn,gi as Tn,gn as En,gr as Dn,gt as On,h as kn,hi as An,hn as jn,hr as Mn,ht as Nn,i as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,li as Xn,ln as Zn,lr as Qn,lt as $n,m as er,mi as tr,mn as nr,mr as rr,mt as ir,n as ar,na as or,ni as sr,nn as cr,nr as lr,nt as ur,o as dr,oi as fr,on as pr,or as mr,ot as hr,p as gr,pi as _r,pn as vr,pr as yr,pt as br,q as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ri as Er,rn as Dr,rr as Or,rt as kr,s as Ar,si as jr,sn as Mr,sr as Nr,st as Pr,t as Fr,ta as Ir,ti as Lr,tn as Rr,tr as zr,tt as Br,u as Vr,ui as Hr,un as Ur,ur as Wr,ut as Gr,v as Kr,vi as qr,vn as Jr,vr as Yr,vt as Xr,w as Zr,wi as Qr,wn as $r,wr as ei,wt as ti,x as ni,xi as ri,xn as ii,xr as ai,xt as oi,y as si,yi as ci,yn as li,yr as ui,yt as di,z as fi,zi as pi,zn as mi,zr as hi,zt as gi}from"./dist-CdLjGZjc.mjs";export{Fr as AGENT_ID_MAX_LEN,ar as AGENT_ID_RE,Tr as AGENT_WRITE_ORIGIN,Pn as AgentFocusBroadcaster,Jt as AgentPresenceBroadcaster,dr as AgentSessionCapacityError,Ar as AgentSessionManager,an as AutoStartDisabledError,Yn as BacklinkIndex,Vr as CC1Broadcaster,t as CC1_CONTRACT_VERSION,un as CONFIG_FILENAME,yn as CONFLICT_MARKER_RE,gr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,er as ConfigSchema,kn as DEFAULT_CHECKPOINT_RETENTION,wn as DEFAULT_EMBEDDINGS_DIMENSIONS,Ut as DEFAULT_PACK_ID,Kr as EMBEDDINGS_API_KEY_ENV,si as FILE_SYSTEM_WRITER,$t as FILE_WATCHER_ORIGIN,ni as FileEmbeddingsBackend,st as GIT_PREFLIGHT_FAIL_SPAN_NAME,z as GIT_UPSTREAM_WRITER,Ir as GitDirAccessError,Zr as GitNotAvailableError,ft as GitTooOldError,Y as HOCUSPOCUS_AUTH_REJECTION_REASONS,W as HocuspocusAuthRejection,He as HocuspocusAuthTokenSchema,Wn as INSTALLED_AGENTS_SCHEMES,w as LINEAGE_EPOCH_KEY,k as LIVE_DERIVED_INDEX_DEBOUNCE_MS,zn as LOG_MD_TEMPLATE,Me as MANAGED_RENAME_ORIGIN,Le as MAX_AGENT_SESSIONS,qe as MCP_CONNECTION_ID_HEADER,ee as MCP_SERVER_NAME,me as MIN_GIT_VERSION,De as MISSING_OK_CONFIG_MESSAGE,or as MalformedGitPointerError,nt as McpLogger,fi as MissingOkConfigError,P as OBSERVER_SYNC_ORIGIN,St as OK_OKIGNORE_TEMPLATE,b as ORPHAN_MODES,le as PANE_TARGET_TTL_MS,a as PROTOCOL_VERSION,_t as PinoLogger,y as ProcessLockCollisionError,Dt as ProjectGitInitError,ae as ROLLBACK_ORIGIN,Ce as ROOT_GITIGNORE_TEMPLATE,m as RUNTIME_VERSION,xr as SERVICE_WRITER,ye as SKILL_INSTALL_EVENTS_FILE_REL,S as SKILL_STATE_TARGETS,Ft as STARTER_FOLDERS,jt as STARTER_FOLDER_FRONTMATTER_FILENAME,zt as STARTER_PACKS,Qe as STARTER_PACK_IDS,T as STARTER_TEMPLATES,vn as STATE_MANIFEST_FILENAME,_ as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,Br as SeedPrerequisiteError,ur as SeedRootDirError,d as ServerLockCollisionError,kr as SingleFileNotAFileError,Rn as SingleFileNotFoundError,Qt as SingleFileNotMarkdownError,hr as StateManifestError,Pr as TagIndex,ln as UiLockCollisionError,$n as __getShowAllWalkStatsForTesting,Gr as __resetShowAllWalkStatsForTesting,i as acquireProcessLock,h as acquireServerLock,mn as acquireUiLock,Cn as applyAgentMarkdownWrite,br as applyExternalChange,ir as applySeed,Nn as armPaneTarget,On as assertCompatibleStateManifest,qt as assertGitAvailable,Xr as assertNeverDiskEvent,di as attachIdleShutdown,rn as bootServer,oi as buildAndOpenSkill,dt as buildConfigYmlContent,U as buildExecResult,ti as buildSkillZip,gt as buildStarterFolderFrontmatterYaml,$ as buildWipTree,J as classifyEvents,Ke as classifyFsPath,Jn as clearArmedPaneTarget,N as clearContributors,Un as clearEmbeddingsKeyFromAllBackends,Ie as coercePackId,C as colorFromSeed,Ve as commitUpstreamImport,Ze as commitWip,ie as commitWipFromTree,ve as compareSemver,je as containsConflictMarkers,ot as contentHash,gi as contributorCount,R as countShadowObjects,Et as countStaleAgentWipRefs,pe as countWipRefs,xt as createApiExtension,At as createAssetServeMiddleware,ce as createContentFilter,Ee as createContentFilterAsync,wr as createEmbeddingsSecretStore,Se as createEphemeralProjectDir,Rt as createExternalChangeHandler,Pt as createFileLogger,Ht as createLiveDerivedIndexExtension,tt as createMcpHttpHandler,O as createOsProbe,gn as createPersistenceExtension,Rr as createServer,cr as createServerObserverExtension,Dr as createStreamingErrorWriter,In as createTestLogger,Xt as describeStoredEmbeddingsKey,pr as detectClaudeDesktopPresence,Mr as detectGit,sn as detectProjectShape,Zn as emitPreflightFailureSpan,Ur as encodeDocName,fn as encodeFolderRoute,xn as ensureProjectGit,vr as errorResponse,nr as evictStaleTrackerEntries,jn as extractWikiLinksFromMarkdown,En as fallbackPaths,Gt as findEnclosingGitRoot,Jr as findEnclosingProjectRoot,li as flushFileLogger,tn as formatAuthRejectionWire,ii as formatContributors,lt as formatContributorsFrom,V as formatPackRationale,$r as gcCheckpointRefs,mt as getCurrentMcpLogger,Z as getLocalDir,K as getLogFilePath,We as getLogger,Kn as getLogsDir,j as getMeter,Vn as getMetrics,Pe as getTracer,ze as handleCollabSocketError,Ye as handleSpawnCursor,ne as hasGcLogLatch,e as iconFromClientName,ge as incrementCollabSocketFilteredError,ke as incrementServerObserverFire,it as initContent,mi as initShadowRepo,I as initTelemetry,wt as initToleranceTelemetryWriter,de as installPrettyZodErrors,yt as installTestLoggers,Ot as installUserSkill,oe as isAllowedApiOrigin,we as isAllowedWorkspaceHostHeader,Sr as isConfigDoc,be as isHocuspocusAuthRejectionReason,It as isKnownPackId,Mt as isLoopbackAddress,r as isOrphanMode,Bt as isPairedWriteOrigin,$e as isPathWithinDir,v as isProcessAlive,E as isProjectRoot,_n as isSelfWrite,zr as isSystemDoc,lr as isToleranceTelemetryEnabled,o as isValidLockPid,Or as lastKnownHash,Ln as listRescueCheckpoints,Zt as listStarterPacks,mr as loadPrincipal,f as lockFilePath,Nr as loggerFactory,cn as logsCurrentPath,Qn as logsPreviousPath,Wr as makeLazyEmbeddingsKeyStore,pn as mountMcpAndApi,Sn as normalizeFsPath,yr as packageVersionMajorMinor,rr as parseAuthRejectionWire,Mn as parseGitVersion,Dn as parseHocuspocusAuthToken,Kt as parseKeepaliveConnectionId,Yr as pathToDocName,ui as planSeed,nn as prepareSingleFileOpen,ai as readAllTargets,ut as readArmedPaneTarget,H as readBranchFromHead,x as readProcessLock,s as readProcessLockDetailed,ei as readProjectLocalSemanticConfig,c as readServerLock,ht as readServerPackageVersion,Q as readSkillInstallStateSnapshot,q as readStateManifest,Ge as readTargetRecordedAt,qn as readTargetVersion,M as readUiLock,Hn as reconcile,Fe as recordContributor,Be as recordSkillInstallEvent,Xe as registerAllTools,re as registerWrite,g as releaseProcessLock,p as releaseServerLock,_e as releaseUiLock,Ae as removeLastKnownHash,at as resetMetrics,hi as resolveBundledSkillDir,L as resolveContentDir,Tt as resolveCursorBinaryDefault,fe as resolveCursorSpawnInvocation,bt as resolveLockDir,kt as resolvePack,se as resolvePackageVersion,Te as resolveUiInfo,Cr as restoreContributors,xe as restoreLifecycleFromConflictsJson,Lt as rewriteMarkdownLinksForDocumentRename,Nt as rewriteWikiLinksForDocumentRename,Vt as runAuthReposSubprocess,et as runAuthStatusSubprocess,D as runCloneSubprocess,hn as runDeviceFlowSubprocess,Lr as runWithMcpLogger,sr as safeContentPath,Er as safeSubdir,Fn as safetyCheckpoint,Yt as sanitizeClientName,fr as saveInMemoryCheckpoint,jr as saveVersion,on as seedBasenameIndex,Xn as serializeError,Hr as setActiveSpanAttributes,dn as shadowGit,bn as shutdownTelemetry,_r as spansCurrentPath,tr as spansPreviousPath,An as spawnDetached,Tn as splitMarkdownBlocks,Wt as startWatcher,qr as streamingProblemEvent,ci as swapContributors,en as teardownToleranceTelemetryWriter,ri as toBroadcasterKey,ct as tracedAppendFileSync,B as tracedLinkSync,Qr as tracedMkdir,pt as tracedMkdirSync,X as tracedRename,G as tracedRenameSync,Ue as tracedRmSync,Gn as tracedRmdirSync,A as tracedUnlinkSync,Bn as tracedWriteFile,Ne as tracedWriteFileSync,Re as updateLastKnownHash,u as updateProcessLockPort,l as updateServerLockPort,Je as updateUiLockPort,te as validateAgentId,he as validateCloneInputs,Oe as validateSkillZip,rt as withSpan,pi as withSpanSync,F as writeRootGitignoreForNewRepo,Ct as writeStateManifest,ue as writeTargetVersion,vt as writeTracker};
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{i as e,r as t,t as n}from"./gh-detect-Dv4BrBzE.mjs";import{C as r,E as i,S as a,T as o,_ as s,b as c,d as l,g as u,h as d,i as f,o as p,r as m,s as h,t as g,w as _,x as v,y}from"./init-BO9tnd8g.mjs";import{d as b,f as x,m as S,n as C,p as w,r as T,t as E}from"./src-M3O8DB6m.mjs";import{a as D,c as O,o as k,r as A,s as j,t as M}from"./write-project-skill-DUCFyVhD.mjs";import{n as N}from"./loader-BicOC80J.mjs";import{n as P}from"./preview-C7YD86Pc.mjs";import{n as F,t as I}from"./mcp-migrate-event-D0NrGjvc.mjs";export{A as ALL_EDITOR_IDS,D as EDITOR_LABELS,k as EDITOR_TARGETS,g as LAUNCH_CONFIG_NAME,m as LAUNCH_UI_CHAIN_SENTINEL,f as LAUNCH_UI_CHAIN_V1,c as addOkPathsToGitExclude,M as assertProjectPathSafe,j as buildManagedServerEntry,I as buildMcpConfigMigrateEvent,p as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,h as detectInstalledEditors,v as formatTrackedRemediation,a as getExcludedOkPaths,r as getOkArtifactPaths,O as isEntryUpToDate,N as loadConfig,e as makeLazyProbeTokenStore,b as parseGitHubBlobUrl,x as parseGitHubShareUrl,w as parseGitHubTreeUrl,S as parseGitUrl,P as previewContent,_ as probeTrackedOkPaths,l as readExistingMcpEntry,o as readSharingMode,i as removeOkPathsFromGitExclude,y as resolveProjectRoot,T as runStop,d as scaffoldLaunchJson,F as truncatePriorEntry,C as validateLocalFolderForShare,u as writeEditorMcpConfig,E as writeProjectAiIntegrations,s as writeUserMcpConfigs};
1
+ import{i as e,r as t,t as n}from"./gh-detect-Dv4BrBzE.mjs";import{C as r,E as i,S as a,T as o,_ as s,b as c,d as l,g as u,h as d,i as f,o as p,r as m,s as h,t as g,w as _,x as v,y}from"./init-D21pFsMR.mjs";import{d as b,f as x,m as S,n as C,p as w,r as T,t as E}from"./src-BzQcpEPg.mjs";import{a as D,c as O,o as k,r as A,s as j,t as M}from"./write-project-skill-bJPJ3udE.mjs";import{n as N}from"./loader-DpizTs6p.mjs";import{n as P}from"./preview-DMinlQU3.mjs";import{n as F,t as I}from"./mcp-migrate-event-D0NrGjvc.mjs";export{A as ALL_EDITOR_IDS,D as EDITOR_LABELS,k as EDITOR_TARGETS,g as LAUNCH_CONFIG_NAME,m as LAUNCH_UI_CHAIN_SENTINEL,f as LAUNCH_UI_CHAIN_V1,c as addOkPathsToGitExclude,M as assertProjectPathSafe,j as buildManagedServerEntry,I as buildMcpConfigMigrateEvent,p as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,h as detectInstalledEditors,v as formatTrackedRemediation,a as getExcludedOkPaths,r as getOkArtifactPaths,O as isEntryUpToDate,N as loadConfig,e as makeLazyProbeTokenStore,b as parseGitHubBlobUrl,x as parseGitHubShareUrl,w as parseGitHubTreeUrl,S as parseGitUrl,P as previewContent,_ as probeTrackedOkPaths,l as readExistingMcpEntry,o as readSharingMode,i as removeOkPathsFromGitExclude,y as resolveProjectRoot,T as runStop,d as scaffoldLaunchJson,F as truncatePriorEntry,C as validateLocalFolderForShare,u as writeEditorMcpConfig,E as writeProjectAiIntegrations,s as writeUserMcpConfigs};
@@ -1,4 +1,4 @@
1
- import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{r,t as i}from"./esm-BLMtE3s6.mjs";import{Ar as a,Ft as o,St as s,ln as c,y as l}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{$i as u,$n as d,Bi as f,Gn as p,Kn as m,Rn as h,W as g,Wn as _,Xi as v,Xn as y,fn as b,ia as x,on as S}from"./dist-DvEI00I1.mjs";import"./constants-BuOKDREu.mjs";import{l as C,n as w,o as T,r as E,t as D,u as ee}from"./write-project-skill-DUCFyVhD.mjs";import{t as O}from"./is-object-Cg453afR.mjs";import{i as k,o as A,r as te,s as j,t as M}from"./colors-CBY1ibtz.mjs";import{t as N}from"./preview-C7YD86Pc.mjs";import{execFileSync as ne}from"node:child_process";import{existsSync as P,mkdirSync as re,readFileSync as F,realpathSync as ie,writeFileSync as I}from"node:fs";import L,{dirname as ae,isAbsolute as oe,join as R,relative as z,resolve as B,sep as se}from"node:path";import V from"node:process";import{homedir as ce}from"node:os";import{randomUUID as le}from"node:crypto";import{stripVTControlCharacters as ue,styleText as H}from"node:util";import{AsyncLocalStorage as de,AsyncResource as U}from"node:async_hooks";import{createServer as fe,request as pe}from"node:http";import*as me from"node:readline";import{connect as he}from"node:net";function ge(){return V.platform.startsWith(`win`)?!!V.env.CI||!!V.env.WT_SESSION||!!V.env.TERMINUS_SUBLIME||V.env.ConEmuTask===`{cmd::Cmder}`||V.env.TERM_PROGRAM===`Terminus-Sublime`||V.env.TERM_PROGRAM===`vscode`||V.env.TERM===`xterm-256color`||V.env.TERM===`alacritty`||V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:V.env.TERM!==`linux`}const _e={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ve={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},ye={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},be={..._e,...ve},xe={..._e,...ye},W=ge()?be:xe;Object.entries(ve);var Se=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ce=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),we=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Te=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Ee=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,De=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Oe=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ke=/\t{1,1000}/y,Ae=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,je=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Me=/\p{M}+/gu,Ne={limit:1/0,ellipsis:``},Pe=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Pe(i,Ne,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[je,l],[Ee,0],[De,o],[ke,s],[Ae,c],[Oe,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Me,``)){let t=e.codePointAt(0)||0;if(S=we(t)?2:Te(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Oe?Ce(e.slice(p,n.lastIndex)):n===Ae?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Fe={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Pe(e,Fe,t).width,Ie=`]8;;`,Le=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ie}(?<uri>.*))`,`y`),Re=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ze=e=>`[${e}m`,Be=e=>`${Ie}${e}`,Ve=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ie,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},He=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ue=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Ve(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Ve(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Ve(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>He(e)));let l=s.join(`
1
+ import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{r,t as i}from"./esm-BLMtE3s6.mjs";import{Ar as a,Ft as o,St as s,ln as c,y as l}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{$i as u,$n as d,Bi as f,Gn as p,Kn as m,Rn as h,W as g,Wn as _,Xi as v,Xn as y,fn as b,ia as x,on as S}from"./dist-CdLjGZjc.mjs";import"./constants-DbENhsxl.mjs";import{l as C,n as w,o as T,r as E,t as D,u as ee}from"./write-project-skill-bJPJ3udE.mjs";import{t as O}from"./is-object-Cg453afR.mjs";import{i as k,o as A,r as te,s as j,t as M}from"./colors-CBY1ibtz.mjs";import{t as N}from"./preview-DMinlQU3.mjs";import{execFileSync as ne}from"node:child_process";import{existsSync as P,mkdirSync as re,readFileSync as F,realpathSync as ie,writeFileSync as I}from"node:fs";import L,{dirname as ae,isAbsolute as oe,join as R,relative as z,resolve as B,sep as se}from"node:path";import V from"node:process";import{homedir as ce}from"node:os";import{randomUUID as le}from"node:crypto";import{stripVTControlCharacters as ue,styleText as H}from"node:util";import{AsyncLocalStorage as de,AsyncResource as U}from"node:async_hooks";import{createServer as fe,request as pe}from"node:http";import*as me from"node:readline";import{connect as he}from"node:net";function ge(){return V.platform.startsWith(`win`)?!!V.env.CI||!!V.env.WT_SESSION||!!V.env.TERMINUS_SUBLIME||V.env.ConEmuTask===`{cmd::Cmder}`||V.env.TERM_PROGRAM===`Terminus-Sublime`||V.env.TERM_PROGRAM===`vscode`||V.env.TERM===`xterm-256color`||V.env.TERM===`alacritty`||V.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:V.env.TERM!==`linux`}const _e={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ve={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},ye={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},be={..._e,...ve},xe={..._e,...ye},W=ge()?be:xe;Object.entries(ve);var Se=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const Ce=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),we=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Te=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Ee=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,De=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Oe=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ke=/\t{1,1000}/y,Ae=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,je=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Me=/\p{M}+/gu,Ne={limit:1/0,ellipsis:``},Pe=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Pe(i,Ne,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[je,l],[Ee,0],[De,o],[ke,s],[Ae,c],[Oe,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Me,``)){let t=e.codePointAt(0)||0;if(S=we(t)?2:Te(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Oe?Ce(e.slice(p,n.lastIndex)):n===Ae?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Fe={limit:1/0,ellipsis:``,ellipsisWidth:0},G=(e,t={})=>Pe(e,Fe,t).width,Ie=`]8;;`,Le=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ie}(?<uri>.*))`,`y`),Re=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ze=e=>`[${e}m`,Be=e=>`${Ie}${e}`,Ve=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:G(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=G(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ie,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},He=e=>{let t=e.split(` `),n=t.length;for(;n&&!G(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ue=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=G(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=G(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Ve(s,r,t),c=G(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Ve(s,r,t),c=G(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Ve(s,r,t),c=G(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>He(e)));let l=s.join(`
2
2
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){Le.lastIndex=e+1;let t=Le.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
3
3
  `){a&&(r+=Be(``));let e=i?Re(i):void 0;i&&e&&(r+=ze(e))}else t===`
4
4
  `&&(i&&Re(i)&&(r+=ze(i)),a&&(r+=Be(a)))}return r},We=/\r?\n/;function Ge(e,t,n){return String(e).normalize().split(We).map(e=>Ue(e,t,n)).join(`
@@ -281,7 +281,7 @@ let ii=/^[a-z0-9-_]+$/i;function ai(e){let t=typeof e;if(t===`object`){if(Array.
281
281
  `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function pi(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(ai(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=fi(0,e,``,t,n);return r[r.length-1]===`
282
282
  `?r:r+`
283
283
  `}function mi(e,t){let n=z(t,e);return n.length>0&&!n.startsWith(`..`)&&!oe(n)}const hi=e=>{try{let t=ne(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function gi(e,t={}){let n=t.homeDir??ce(),r=t.gitTopLevel??hi,i=B(e),a;try{a=ie(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(d(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=ae(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&mi(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 $(e,t,n,r,i){let a=`urn:uuid:${le()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=c.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const _i=1e4;function vi(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!y(n))return $(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!m(e.headers.host))return $(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!p(r)?($(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const yi=3e4;function bi(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!y(n)||!m(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!p(r)?(t.destroy(),!0):!1}function xi(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=he({host:r,port:i,timeout:_i});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
284
- `)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Si=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ci(e){let t=e.upstreamTimeoutMs??_i,n=new Set,r=fe((n,r)=>{vi(n,r)||Ti(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{bi(t,r)||xi(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function wi(e,t,n){Ti(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??_i)}function Ti(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Si)delete a[e];e.setTimeout(yi,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${yi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=pe({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Si)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Ei=39847,Di=39848;async function Oi(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function ki(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,clearArmedPaneTarget:c,createAssetServeMiddleware:u,createContentFilter:d,readArmedPaneTarget:f,readServerLock:p,releaseUiLock:m,updateUiLockPort:h}=await import(`./dist-Dat97svn.mjs`),{default:g}=await import(`./build-CCDQyip-.mjs`),{resolveContentDir:_,resolveLockDir:v}=await import(`./dist-Dat97svn.mjs`),y=_(e.config,e.cwd),b=v(e.cwd);i(b,{port:0,worktreeRoot:e.cwd});let x=import.meta.dirname??new URL(`.`,import.meta.url).pathname,S=[r(x,`public`),r(x,`../../app/dist`),r(x,`../../../app/dist`)],C=e.assetDir??S.find(e=>t(e)),w=C?g(C,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,T=t(y)?u({contentFilter:d({projectDir:e.cwd,contentDir:y}),contentSirv:g(y,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:l,blocklistExtensions:s}):null,E=e.port,D=null,ee=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=f(b);if(e&&!/[\r\n]/.test(e)){c(b),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&vi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){c(b),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){D?.();let n=p(b),r=e.headers.host??`localhost:${E}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=f(b),o=JSON.stringify({collabUrl:i,previewUrl:null,port:E,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){D?.();let r=p(b);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}wi(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{T?T(e,t,()=>Ai(t)):Ai(t)});return}if(T){T(e,t,()=>{w?w(e,t):Ai(t)});return}if(w){w(e,t);return}Ai(t)}},O=new Set,k=(e,t,n)=>{if(bi(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=p(b);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}xi(e,t,n,`localhost`,i.port,O)},A=()=>{for(let e of O)try{e.destroy()}catch{}O.clear()},te=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],j=[],M=e.port,N=e=>e instanceof Error&&e.code===`EADDRINUSE`,ne=async()=>{await Promise.all(j.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},P=async e=>{M=e;for(let e of te){let t=n(ee);t.on(`upgrade`,k),j.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(M,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(M=e.port),n()})})}};try{try{await P(e.port)}catch(t){if(e.fallbackToKernel===!0&&N(t))await ne(),await P(0);else throw t}}catch(e){await ne();try{m(b)}catch{}throw e}let re=M;E=re,h(b,re);let F=e.scheduler??a,ie=e.safetyNetMs??432e5,I=null,L=!1,ae=!1,oe=()=>{L||(L=!0,I!==null&&(F.clearTimeout(I),I=null))},R=()=>{if(oe(),!ae){ae=!0;try{m(b)}catch{}}},z=()=>{L||ie<=0||(I!==null&&(F.clearTimeout(I),I=null),I=F.setTimeout(()=>{I=null,console.warn(`[ui] safety-net (${ie}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}A();for(let e of j)try{e.close()}catch{}R()},ie))},B=()=>{L||ie<=0||z()};return D=B,z(),{httpServers:j,port:re,release:R,detachSafetyNet:oe,nudgeSafetyNet:B,drainUpgradeSockets:A}}function Ai(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function ji(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Ei,fallbackToKernel:!0}}async function Mi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-Dat97svn.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ci({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Ni(e){return new i(`ui`).description(`Serve the Open Knowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Ei}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-BktTaA1t.mjs`),{UiLockCollisionError:r}=await import(`./dist-Dat97svn.mjs`),{resolveLockDir:i}=await import(`./dist-Dat97svn.mjs`),a=e(),o=t.host,s;try{s=ji(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await ki({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Oi(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Mi({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Pi(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Pi(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Fi(e){if(!P(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(O(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Ii(e){if(!P(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=ri(t);if(O(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Li(e,t){v(e,`${JSON.stringify(t,null,2)}\n`)}function Ri(e,t){let n=pi(t);v(e,n.endsWith(`
284
+ `)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Si=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ci(e){let t=e.upstreamTimeoutMs??_i,n=new Set,r=fe((n,r)=>{vi(n,r)||Ti(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{bi(t,r)||xi(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function wi(e,t,n){Ti(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??_i)}function Ti(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Si)delete a[e];e.setTimeout(yi,()=>{if(t.headersSent)try{t.end()}catch{}else try{$(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${yi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=pe({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Si)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)$(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)$(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Ei=39847,Di=39848;async function Oi(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function ki(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:r}=await import(`node:path`),{acquireUiLock:i,clearArmedPaneTarget:c,createAssetServeMiddleware:u,createContentFilter:d,readArmedPaneTarget:f,readServerLock:p,releaseUiLock:m,updateUiLockPort:h}=await import(`./dist-DHvnq6Ai.mjs`),{default:g}=await import(`./build-CCDQyip-.mjs`),{resolveContentDir:_,resolveLockDir:v}=await import(`./dist-DHvnq6Ai.mjs`),y=_(e.config,e.cwd),b=v(e.cwd);i(b,{port:0,worktreeRoot:e.cwd});let x=import.meta.dirname??new URL(`.`,import.meta.url).pathname,S=[r(x,`public`),r(x,`../../app/dist`),r(x,`../../../app/dist`)],C=e.assetDir??S.find(e=>t(e)),w=C?g(C,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,T=t(y)?u({contentFilter:d({projectDir:e.cwd,contentDir:y}),contentSirv:g(y,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:l,blocklistExtensions:s}):null,E=e.port,D=null,ee=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=f(b);if(e&&!/[\r\n]/.test(e)){c(b),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&vi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){c(b),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){D?.();let n=p(b),r=e.headers.host??`localhost:${E}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=f(b),o=JSON.stringify({collabUrl:i,previewUrl:null,port:E,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){D?.();let r=p(b);if(!r||r.port<=0){$(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}wi(e,t,{upstreamHost:`localhost`,upstreamPort:r.port});return}if(w&&n?.startsWith(`/assets/`)){w(e,t,()=>{T?T(e,t,()=>Ai(t)):Ai(t)});return}if(T){T(e,t,()=>{w?w(e,t):Ai(t)});return}if(w){w(e,t);return}Ai(t)}},O=new Set,k=(e,t,n)=>{if(bi(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=p(b);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}xi(e,t,n,`localhost`,i.port,O)},A=()=>{for(let e of O)try{e.destroy()}catch{}O.clear()},te=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],j=[],M=e.port,N=e=>e instanceof Error&&e.code===`EADDRINUSE`,ne=async()=>{await Promise.all(j.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},P=async e=>{M=e;for(let e of te){let t=n(ee);t.on(`upgrade`,k),j.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(M,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(M=e.port),n()})})}};try{try{await P(e.port)}catch(t){if(e.fallbackToKernel===!0&&N(t))await ne(),await P(0);else throw t}}catch(e){await ne();try{m(b)}catch{}throw e}let re=M;E=re,h(b,re);let F=e.scheduler??a,ie=e.safetyNetMs??432e5,I=null,L=!1,ae=!1,oe=()=>{L||(L=!0,I!==null&&(F.clearTimeout(I),I=null))},R=()=>{if(oe(),!ae){ae=!0;try{m(b)}catch{}}},z=()=>{L||ie<=0||(I!==null&&(F.clearTimeout(I),I=null),I=F.setTimeout(()=>{I=null,console.warn(`[ui] safety-net (${ie}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}A();for(let e of j)try{e.close()}catch{}R()},ie))},B=()=>{L||ie<=0||z()};return D=B,z(),{httpServers:j,port:re,release:R,detachSafetyNet:oe,nudgeSafetyNet:B,drainUpgradeSockets:A}}function Ai(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function ji(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Ei,fallbackToKernel:!0}}async function Mi(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-DHvnq6Ai.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ci({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function Ni(e){return new i(`ui`).description(`Serve the Open Knowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Ei}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-BktTaA1t.mjs`),{UiLockCollisionError:r}=await import(`./dist-DHvnq6Ai.mjs`),{resolveLockDir:i}=await import(`./dist-DHvnq6Ai.mjs`),a=e(),o=t.host,s;try{s=ji(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await ki({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Oi(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await Mi({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),Pi(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function Pi(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}function Fi(e){if(!P(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(O(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function Ii(e){if(!P(e))return{};let t=F(e,`utf-8`).trim();if(t===``)return{};try{let n=ri(t);if(O(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function Li(e,t){v(e,`${JSON.stringify(t,null,2)}\n`)}function Ri(e,t){let n=pi(t);v(e,n.endsWith(`
285
285
  `)?n:`${n}\n`)}const zi=e=>e!==`project`,Bi=e=>e!==`user`;async function Vi(){let e=await wn({message:`Where should the MCP server be configured?
286
286
  `,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 Hi(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Vi)():`both`}async function Ui(e){return Nr({message:`How do you want to handle Open Knowledge config files (.ok/, .mcp.json, project skills, launch.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 Wi(e){if(e.sharing!==void 0)return e.sharing;let t=_t(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Ui)(t):t}const Gi=`0.0.1`,Ki=`open-knowledge-ui`,qi=[`-y`,`@inkeep/open-knowledge@latest`,`ui`],Ji=`# ok-ui-v1`,Yi=`${Ji}
287
287
  UIPORT="\${PORT:-${Di}}"
@@ -300,6 +300,6 @@ UIPORT="\${PORT:-${Di}}"
300
300
  unset PORT
301
301
  exec node "${C()}" start --ui-port "$UIPORT"`],port:Di,autoPort:!0}:{name:Ki,runtimeExecutable:`/bin/sh`,runtimeArgs:[`-l`,`-c`,Yi],port:Di,autoPort:!0};try{if(D(n,e),!P(n))return re(ae(n),{recursive:!0}),I(n,`${JSON.stringify({version:Gi,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=F(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!O(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>O(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??Gi,configurations:a};return I(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Zi(e,t,n){try{return P(e.detectPath?.(t,n)??ae(e.configPath(t,n)))}catch{return!1}}function Qi(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}if(!i&&!n.skipAvailabilityCheck&&!Zi(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{D(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}let s;try{s=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{re(ae(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let c,l;try{u(`${o}.lock`,()=>{let t=e.format===`toml`?Ii(o):Fi(o),n=t[e.topLevelKey]??{};c=n[a];let r={...t,[e.topLevelKey]:{...n,[a]:s}};e.format===`toml`?Ri(o,r):Li(o,r)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){l=e instanceof Error?e:Error(String(e))}return l?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:l.message,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}function $i(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!P(n)))return{editorId:e.id,label:e.label,path:n}}async function ea(e){let t=ee(e.editors),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Qi(t,``,n,e.home))}function ta(e,t,n,r){let i=na(e,t,n,r);return i.kind===`present`?i.entry:null}function na(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!P(i))return{kind:`absent`};let a;try{a=F(i,`utf-8`)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}if(a.trim()===``)return{kind:`corrupt`,error:`file is empty`};let o;try{o=e.format===`toml`?Ii(i):Fi(i)}catch(e){return{kind:`corrupt`,error:e instanceof Error?e.message:String(e)}}let s=o[e.topLevelKey];if(!O(s))return{kind:`no-entry`};let c=s[e.serverName(t)];return O(c)?{kind:`present`,entry:c}:{kind:`no-entry`}}async function ra(e={}){let t=B(e.cwd??process.cwd()),n=gi(t,{homeDir:e.home}),r=n.projectRoot,i=!P(R(r,`.ok`));n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&console.log(`[ok] Initialized OK at ${r} — opened parent of ${z(r,t)} because it contains a .git folder`);let a={mode:e.devMcp?`dev`:`published`},o=await b(r),s;try{s=h(r,{contentDir:n.defaultContentDir})}catch(t){let n=T.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:o.didInit,rootGitignoreCreated:!1,claudeDesktopDetected:!1,mcpAction:`failed`,mcpPath:n,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let c=!1;if(o.didInit)try{c=f(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}let l=await Hi({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),u=e.editors??sa(r,e.home),d=e.editors??E.filter(e=>T[e].projectConfigPath!==void 0),p=ee(u),m=ee(d),g=e.mcp===!1||l===null,v=Array.from(new Map([...p,...g?[]:m].map(e=>[e.id,e])).values()),y=p.filter(t=>Zi(t,r,e.home)),x=[],C=[],D=new Set;for(let t of v){if(g){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(zi(l)&&p.includes(t)&&x.push(Qi(t,r,a,e.home)),Bi(l)&&m.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Qi(t,r,a,e.home,n);x.push(i),(i.action===`written`||i.action===`overwritten`)&&D.add(n)}}for(let e of m)e.projectSkillPath&&C.push(w(e,r));let O=!g&&l!==null&&Bi(l)?m.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,k=g?[]:y.map(e=>$i(e,r)).filter(e=>e!==void 0).filter(e=>!D.has(e.path)),A=y.some(e=>e.id===`claude`)&&!g?Xi(r,a):void 0,te=await(e.installUserSkill??_)({home:e.home}),j=S({home:e.home}),M=g?`skipped-flag`:`skipped-missing`,N=x.find(e=>e.editorId===`claude`)??x[0]??{action:M,configPath:T.claude.configPath(r,e.home)},ne=await ia({projectRoot:r,desiredMode:await Wi({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:s.created,contentUpdated:s.updated,contentSkipped:s.skipped,editors:x,projectSkills:C,legacyProjectConfigs:k,launchJson:A,skillInstall:te,didGitInit:o.didInit,rootGitignoreCreated:c,claudeDesktopDetected:j,mcpAction:N.action,mcpPath:N.configPath,mcpError:`error`in N?N.error:void 0,projectScopeUnsupportedLabels:O,sharing:ne}}async function ia(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=_t(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=mt(t);if(n===`local-only`){let e=ht(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`}:aa(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=gt(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:aa(t,o,`remove`)}function aa(e,t,n){let r=_t(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function oa(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?z(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=R(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(M(`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(M(`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(M(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(M(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(M(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?z(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${A(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${A(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${te(`FAILED`)}: ${r.error}`);break;case`skipped-flag`:break}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(M(`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?z(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${A(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${A(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${te(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${z(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(M(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${A(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${A(`already installed at current version`)}`);break;case`failed`:n.push(` ${j(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${j(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.claudeDesktopDetected&&(n.push(``),n.push(`Claude Desktop App detected. To enable in Claude Chat & Cowork, run: ${M(`ok install-skill`)}`)),e.preview?(n.push(``),n.push(N(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...la(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${A(`✓`)} ${M(`Next steps:`)}`),n.push(` 1. Open your editor (${k(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${k(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${k(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${k(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${k(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${k(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
302
302
  `)}function sa(e,t){let n=[];for(let r of E)Zi(T[r],e,t)&&n.push(r);return n}function ca(){return new i(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).addOption(new r(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new r(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new r(`--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;try{r=await ra({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n})}catch(e){if(e instanceof g){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
303
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-BPvWgmw3.mjs`),{loadConfig:t}=await import(`./loader-Bq5LpCql.mjs`),{resolveContentDir:n}=await import(`./dist-Dat97svn.mjs`),{config:i}=t(r.projectRoot),a=n(i,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:a})}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${oa(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)})}function la(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
303
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-wM1DJuPS.mjs`),{loadConfig:t}=await import(`./loader-T98A78tr.mjs`),{resolveContentDir:n}=await import(`./dist-DHvnq6Ai.mjs`),{config:i}=t(r.projectRoot),a=n(i,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:a})}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${oa(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)})}function la(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
304
304
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${k(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(j(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${k(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${k(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(j(`Sharing mode unavailable: ${e.reason}.`));return n}}export{dt as A,mt as C,ut as D,gt as E,Ge as F,Se as I,W as L,pt as M,it as N,st as O,Ke as P,vt as S,_t as T,ea as _,ia as a,ht as b,oa as c,ta as d,Hi as f,Qi as g,Xi as h,Yi as i,lt as j,ct as k,la as l,ra as m,qi as n,na as o,Wi as p,Ji as r,sa as s,Ki as t,ca as u,Ni as v,yt as w,bt as x,gi as y};
305
- //# sourceMappingURL=init-BO9tnd8g.mjs.map
305
+ //# sourceMappingURL=init-D21pFsMR.mjs.map
@@ -0,0 +1 @@
1
+ import{m as e}from"./init-D21pFsMR.mjs";export{e as runInit};
@@ -1,4 +1,4 @@
1
- import{Bi as e,Hi as t,ja as n,zi as r}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{Qi as i,Zi as a,m as o}from"./dist-DvEI00I1.mjs";import{t as s}from"./constants-BuOKDREu.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{existsSync as l,readFileSync as u}from"node:fs";import{resolve as d}from"node:path";import{realpath as f}from"node:fs/promises";async function p(e){let t=d(e);try{return await f(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var m=n();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,m.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function v(t){let n=t??process.cwd(),c=[],l=i(`user`,n),u=a({absPath:l}),f={};u.valid&&u.source!==void 0?(f=h(f,u.value),c.push(l)):u.valid;let p=d(n,`.ok`,s),m=g(p);if(m.value!==null){let t=r({value:m.value,file:m.path,source:m.source,doc:m.doc});if(t.length>0)throw Error(t.map(e).join(`
1
+ import{Bi as e,Hi as t,ja as n,zi as r}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import{Qi as i,Zi as a,m as o}from"./dist-CdLjGZjc.mjs";import{t as s}from"./constants-DbENhsxl.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{existsSync as l,readFileSync as u}from"node:fs";import{resolve as d}from"node:path";import{realpath as f}from"node:fs/promises";async function p(e){let t=d(e);try{return await f(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var m=n();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!l(e))return{value:null,path:e,source:null,doc:null};let t;try{t=u(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,m.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function v(t){let n=t??process.cwd(),c=[],l=i(`user`,n),u=a({absPath:l}),f={};u.valid&&u.source!==void 0?(f=h(f,u.value),c.push(l)):u.valid;let p=d(n,`.ok`,s),m=g(p);if(m.value!==null){let t=r({value:m.value,file:m.path,source:m.source,doc:m.doc});if(t.length>0)throw Error(t.map(e).join(`
2
2
 
3
3
  `));f=h(f,m.value),c.push(p)}let v=o.safeParse(f);if(!v.success){let t={code:`SCHEMA_INVALID`,issues:_(v.error.issues,m)};throw Error(e(t))}return{config:v.data,sources:c}}function y(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??v,r=new Map,i=new Map,a=p(e.startupCwd);return async o=>{let s=await p(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{v as n,y as t};
4
- //# sourceMappingURL=loader-BicOC80J.mjs.map
4
+ //# sourceMappingURL=loader-DpizTs6p.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-DpizTs6p.mjs";export{e as loadConfig};
@@ -1,3 +1,3 @@
1
- import{Gt as e}from"./dist-DvEI00I1.mjs";import"./constants-BuOKDREu.mjs";import{existsSync as t,lstatSync as n,readdirSync as r,realpathSync as i,statSync as a}from"node:fs";import{join as o,relative as s}from"node:path";function c(t){let{projectDir:c,contentDir:l,sampleCap:u=5}=t,d=[],f=[];try{n(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=r(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${s(l,e)||`.`}: ${n}`);return}for(let n of t){let t=o(e,n.name);if(n.isSymbolicLink()){let e;try{e=i(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${s(l,t)}`):d.push(`cannot resolve symlink ${s(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=a(e)}catch{continue}if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,n){let r=[],i=s(n,e.contentDir),a=i===``?`./`:`./${i}`;if(r.push(`Content:`),r.push(` Found ${e.totalCount} markdown files in ${a}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;r.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)r.push(` Warning: ${t}`);return r.push(``),t(o(n,`.ok`,`config.yml`))?(r.push(` To adjust scope, add patterns to .okignore at the project root.`),r.push(` To change the content root, edit .ok/config.yml → content.dir.`)):r.push(" Run `open-knowledge init` to scaffold config + .okignore."),r.push(``),r.push(` Re-check anytime: open-knowledge preview`),r.join(`
1
+ import{Gt as e}from"./dist-CdLjGZjc.mjs";import"./constants-DbENhsxl.mjs";import{existsSync as t,lstatSync as n,readdirSync as r,realpathSync as i,statSync as a}from"node:fs";import{join as o,relative as s}from"node:path";function c(t){let{projectDir:c,contentDir:l,sampleCap:u=5}=t,d=[],f=[];try{n(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=r(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${s(l,e)||`.`}: ${n}`);return}for(let n of t){let t=o(e,n.name);if(n.isSymbolicLink()){let e;try{e=i(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${s(l,t)}`):d.push(`cannot resolve symlink ${s(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=a(e)}catch{continue}if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(n.isDirectory()){let e=s(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=s(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,n){let r=[],i=s(n,e.contentDir),a=i===``?`./`:`./${i}`;if(r.push(`Content:`),r.push(` Found ${e.totalCount} markdown files in ${a}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;r.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)r.push(` Warning: ${t}`);return r.push(``),t(o(n,`.ok`,`config.yml`))?(r.push(` To adjust scope, add patterns to .okignore at the project root.`),r.push(` To change the content root, edit .ok/config.yml → content.dir.`)):r.push(" Run `open-knowledge init` to scaffold config + .okignore."),r.push(``),r.push(` Re-check anytime: open-knowledge preview`),r.join(`
2
2
  `)}export{c as n,l as t};
3
- //# sourceMappingURL=preview-C7YD86Pc.mjs.map
3
+ //# sourceMappingURL=preview-DMinlQU3.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-DMinlQU3.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1884,7 +1884,7 @@ Error generating stack: `+e.message+`
1884
1884
  border-bottom: 1px solid CanvasText;
1885
1885
  }
1886
1886
  }
1887
- `;function FW(e){return{...WF({type:e===`dark`?`dark`:`light`,colors:{"sideBar.background":`var(--sidebar)`,"sideBar.foreground":`var(--sidebar-foreground)`,"sideBar.border":`var(--sidebar-border)`,"list.activeSelectionBackground":`var(--sidebar-accent)`,"list.activeSelectionForeground":`var(--sidebar-accent-foreground)`,"list.hoverBackground":`var(--sidebar-hover)`,focusBorder:`var(--color-primary)`,"input.background":`var(--input)`,"input.border":`var(--border)`}}),"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`0.875rem`,"--trees-item-padding-x-override":`0.5rem`,"--trees-padding-inline-override":`0.5rem`,"--trees-border-radius-override":`0.375rem`,"--trees-selected-fg":`var(--color-primary)`,"--truncate-marker-fade-in-duration":`0s`,"--trees-file-icon-color-markdown":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-file-icon-color-image":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-fg-muted":`light-dark(var(--color-gray-400), var(--color-gray-500))`,...MW}}var IW=`data-ok-ext-badge`,LW=`data-ok-ext-row`,RW=`data-ok-fullname-row`,zW=`
1887
+ `;function FW(e){return{...WF({type:e===`dark`?`dark`:`light`,colors:{"sideBar.background":`var(--sidebar)`,"sideBar.foreground":`var(--sidebar-foreground)`,"sideBar.border":`var(--sidebar-border)`,"list.activeSelectionBackground":`var(--sidebar-accent)`,"list.activeSelectionForeground":`var(--sidebar-accent-foreground)`,"list.hoverBackground":`var(--sidebar-hover)`,focusBorder:`var(--color-primary)`,"input.background":`var(--input)`,"input.border":`var(--border)`}}),"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`0.875rem`,"--trees-item-padding-x-override":`0.5rem`,"--trees-padding-inline-override":`0.5rem`,"--trees-border-radius-override":`0.375rem`,"--trees-selected-fg":`var(--color-primary)`,"--truncate-marker-fade-in-duration":`0s`,"--trees-file-icon-color-markdown":`light-dark(var(--color-gray-400), var(--color-gray-500))`,"--trees-fg-muted":`light-dark(var(--color-gray-400), var(--color-gray-500))`,...MW}}var IW=`data-ok-ext-badge`,LW=`data-ok-ext-row`,RW=`data-ok-fullname-row`,zW=`
1888
1888
  [data-item-selected='true'] [data-icon-token='markdown'] {
1889
1889
  color: var(--trees-selected-fg);
1890
1890
  }
@@ -1941,7 +1941,7 @@ Error generating stack: `+e.message+`
1941
1941
  `;function iG(e){sG(e);let t=e.querySelector(`[data-item-rename-input]`);if(!t)return;let n=t.closest(`[data-type="item"]`);if(!n)return;let r=n.dataset.itemPath??``;if(r.endsWith(`/`))return;let i=oM(r);cM(r)&&aG(i),!t.hasAttribute($W)&&(cG(t),t.setAttribute($W,``))}function aG(e){eG=e,tG!==null&&clearTimeout(tG),tG=setTimeout(oG,nG)}function oG(){eG=null,tG!==null&&(clearTimeout(tG),tG=null)}function sG(e){let t=e.querySelectorAll(`[${QW}]`);for(let e of t){if(e.querySelector(`[data-item-rename-input]`))continue;let t=e.getAttribute(QW);if(!t){e.removeAttribute(QW);continue}let n=e.dataset.itemPath??``;if(n.toLowerCase().endsWith(t.toLowerCase())){e.removeAttribute(QW);continue}let r=oM(n);r&&r.toLowerCase()!==t.toLowerCase()&&e.removeAttribute(QW)}if(eG===null)return;let n=e.querySelectorAll(`[data-type="item"][data-item-path]`),r=!1;for(let e of n){let t=e.dataset.itemPath??``;!t||t.endsWith(`/`)||oM(t)||(r=!0,e.getAttribute(`data-item-selected`)===`true`&&e.getAttribute(`data-ok-renaming`)!==eG&&e.setAttribute(QW,eG))}let i=!!e.querySelector(`[data-item-rename-input]`);!r&&!i&&oG()}function cG(e){let t=oM(e.value),n=t?e.value.length-t.length:e.value.length;e.setSelectionRange(0,n)}function lG(e){let t=e.getFocusedPath();t&&e.scrollToPath(t,{offset:`nearest`,focus:!1})}function uG(e){return{selectedFilePath:e,selectedFolderPath:null,navigationPath:e}}function dG(e,t,n={}){if(!e)return uG(t);let r=es(e);if(t&&r!==t)return uG(t);switch(e.kind){case`doc`:return uG(t??e.docName);case`large-file`:return uG(e.docName);case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return t&&n.isKnownDocument?.(t)?uG(t):{selectedFilePath:null,selectedFolderPath:null,navigationPath:null};case`asset`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function fG(e,t){if(!e)return{kind:`none`};let n=t.find(t=>mM(t)===e);if(n&&Ro(n))return{kind:`asset`,path:n.path,hash:Jo(n.path),mediaKind:n.mediaKind};let r=vM(e);return e.endsWith(`/`)?t.some(e=>Zo(e)?e.path===r||e.path.startsWith(`${r}/`):(Ro(e)?e.path:e.docName).startsWith(`${r}/`))?{kind:`folder`,path:r}:{kind:`none`}:t.some(e=>fs(e)&&e.docName===r)?{kind:`document`,path:r}:{kind:`none`}}var pG=`You can restore this file from the Trash.`;function mG(e){let t=pG,n=`Move to Trash`,r=`Moving`;if(e.length===0)return{title:`Are you sure you want to delete the selected items?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r};if(e.length===1){let i=e[0];return i?i.kind===`folder`?{title:`Are you sure you want to delete '${i.name}' and its contents?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete '${i.name}'?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete the selected item?`,detail:t,listedTargets:null,confirmLabel:n,confirmLabelBusy:r}}let i=e.some(e=>e.kind===`folder`),a=e.some(e=>e.kind!==`folder`);return i&&a?{title:`Are you sure you want to delete the following ${e.length} files/directories and their contents?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}:i?{title:`Are you sure you want to delete the following ${e.length} directories and their contents?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}:{title:`Are you sure you want to delete the following ${e.length} files?`,detail:t,listedTargets:e,confirmLabel:n,confirmLabelBusy:r}}function hG(e,t){return e===`web`?null:mG(t)}function gG(e){return e.kind===`folder`?`${e.name}/`:e.kind===`asset`?e.name:e.docExt?`${e.name}${e.docExt}`:e.name}function _G(e,t,n){let r=fG(e,t);if(r.kind===`none`)return null;if(r.kind===`asset`)return{v:1,kind:`asset`,assetPath:r.path,mediaKind:r.mediaKind};if(r.kind===`folder`)return{v:1,kind:`folder`,folderPath:r.path};let i=t.find(e=>fs(e)&&e.docName===r.path);return{v:1,kind:`doc`,docName:r.path,size:i?.size??n?.get(r.path)?.size??null}}var vG=[`not-found`,`permission-denied`,`system-error`,`path-escape`];function yG(e){return typeof e==`string`&&vG.includes(e)?e:`system-error`}function bG(e){switch(e){case`not-found`:return ms._({id:`v41fCm`});case`permission-denied`:return ms._({id:`sJK6pq`});case`system-error`:return ms._({id:`Jqqevv`});case`path-escape`:return ms._({id:`WL6puM`})}}function xG(e){let t=bG(e.reason),n=e.detail;return n?ms._({id:`Z2M5XM`,values:{reason:t,osDetail:n}}):ms._({id:`dTaauv`,values:{reason:t}})}function SG(e){return e.kind===`folder`?`${e.name}/`:e.name}function CG(e){let t=(0,$.c)(34),{failedTargets:n,isSubmitting:r,onDeletePermanently:i,onRetry:a,onCancel:o}=e,c=n.length>1,l=n[0],u=n.length,d;if(t[0]!==u||t[1]!==c||t[2]!==l){let e=l?SG(l):``;d=c?ms._({id:`5qNxOe`,values:{count:u}}):l?`${ms._({id:`E_BHoD`,values:{targetName:e}})}\n${xG(l)}`:ms._({id:`kolRU1`}),t[0]=u,t[1]=c,t[2]=l,t[3]=d}else d=t[3];let f=d,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(Co,{children:(0,Z.jsx)(s,{id:`aOp3hw`})}),t[4]=p):p=t[4];let m;t[5]===f?m=t[6]:(m=(0,Z.jsxs)(Do,{children:[p,(0,Z.jsx)(So,{className:`whitespace-pre-wrap`,children:f})]}),t[5]=f,t[6]=m);let g;t[7]!==n||t[8]!==c?(g=c?(0,Z.jsx)(To,{children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 text-xs`,children:n.map(wG)})}):null,t[7]=n,t[8]=c,t[9]=g):g=t[9];let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(s,{id:`dEgA5A`}),t[10]=_):_=t[10];let v;t[11]!==r||t[12]!==o?(v=(0,Z.jsx)(ci,{variant:`outline`,className:`font-mono uppercase`,onClick:o,disabled:r,"data-testid":`trash-failure-modal-cancel`,children:_}),t[11]=r,t[12]=o,t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{className:`size-4 animate-spin`}),` `,(0,Z.jsx)(s,{id:`mf37rL`})]}):(0,Z.jsx)(s,{id:`6gRgw8`}),t[14]=r,t[15]=y);let b;t[16]!==r||t[17]!==a||t[18]!==y?(b=(0,Z.jsx)(ci,{variant:`outline`,className:`font-mono uppercase`,onClick:a,disabled:r,"data-testid":`trash-failure-modal-retry`,children:y}),t[16]=r,t[17]=a,t[18]=y,t[19]=b):b=t[19];let x;t[20]===r?x=t[21]:(x=r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(h,{className:`size-4 animate-spin`}),` `,(0,Z.jsx)(s,{id:`s3caR3`})]}):(0,Z.jsx)(s,{id:`UBv8UK`}),t[20]=r,t[21]=x);let S;t[22]!==r||t[23]!==i||t[24]!==x?(S=(0,Z.jsx)(ci,{variant:`destructive`,onClick:i,disabled:r,"data-testid":`trash-failure-modal-delete-permanently`,children:x}),t[22]=r,t[23]=i,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==v||t[28]!==b?(C=(0,Z.jsxs)(Eo,{children:[v,b,S]}),t[26]=S,t[27]=v,t[28]=b,t[29]=C):C=t[29];let w;return t[30]!==C||t[31]!==m||t[32]!==g?(w=(0,Z.jsxs)(wo,{className:`sm:max-w-md`,children:[m,g,C]}),t[30]=C,t[31]=m,t[32]=g,t[33]=w):w=t[33],w}function wG(e){return(0,Z.jsxs)(`li`,{"data-testid":`trash-failure-modal-target`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-foreground`,children:SG(e)}),(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:xG(e)})]},e.path)}function TG(e){let t=(0,$.c)(21),{parentDir:n,onSelectTemplate:r,ItemComponent:i}=e,{state:a}=Va(n);if(a.status===`idle`||a.status===`loading`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(s,{id:`Hl89Qd`}),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,Z.jsx)(i,{disabled:!0,className:`text-muted-foreground`,children:e}),t[1]=i,t[2]=n),n}if(a.status===`error`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(s,{id:`AQ-Lfg`}),t[3]=e):e=t[3];let n;return t[4]===i?n=t[5]:(n=(0,Z.jsx)(i,{disabled:!0,className:`text-muted-foreground`,children:e}),t[4]=i,t[5]=n),n}let o,c;if(t[6]!==i||t[7]!==r||t[8]!==a.data.folder.templates_available){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[11]===a.data.folder.templates_available?e=t[12]:(e=a.data.folder.templates_available??[],t[11]=a.data.folder.templates_available,t[12]=e);let n=Mh(e);if(n.length===0){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(s,{id:`iGCs04`}),t[13]=e):e=t[13];let n;t[14]===i?n=t[15]:(n=(0,Z.jsx)(i,{disabled:!0,className:`text-muted-foreground`,children:e}),t[14]=i,t[15]=n),c=n;break bb0}let l;t[16]!==i||t[17]!==r?(l=e=>(0,Z.jsx)(i,{onSelect:()=>r(e.name),children:e.title??e.name},`${e.scope}:${e.source_folder}:${e.name}`),t[16]=i,t[17]=r,t[18]=l):l=t[18],o=n.map(l)}t[6]=i,t[7]=r,t[8]=a.data.folder.templates_available,t[9]=o,t[10]=c}else o=t[9],c=t[10];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[19]===o?l=t[20]:(l=(0,Z.jsx)(Z.Fragment,{children:o}),t[19]=o,t[20]=l),l}function EG(e){return e?.isDirectory()?e:null}function DG(e,t){let n=t.getPath();for(let t of e.getSelectedPaths())t!==n&&e.getItem(t)?.deselect();t.isSelected()||t.select()}function OG(e,t,n,r,i){let a=(0,$.c)(11),o;a[0]!==n||a[1]!==t||a[2]!==e||a[3]!==r?(o=()=>{let i=()=>{queueMicrotask(()=>{r.current=!1})};if(r.current=!0,!t){for(let t of e.getSelectedPaths())e.getItem(t)?.deselect();i();return}let a=n?n.split(`\0`):[];for(let t of a){let n=EG(e.getItem(t));n&&!n.isExpanded()&&n.expand()}let o=e.getItem(t);if(!o){i();return}if(e.getSelectedPaths().length>1&&o.isSelected()){o.focus(),i();return}DG(e,o),o.focus(),i()},a[0]=n,a[1]=t,a[2]=e,a[3]=r,a[4]=o):o=a[4];let s;a[5]!==n||a[6]!==t||a[7]!==e||a[8]!==r||a[9]!==i?(s=[n,t,e,r,i],a[5]=n,a[6]=t,a[7]=e,a[8]=r,a[9]=i,a[10]=s):s=a[10],(0,Q.useEffect)(o,s)}var kG=`open-knowledge:file-tree-menu-action-delete`,AG=`open-knowledge:file-tree-menu-action-rename`,jG=`open-knowledge:file-tree-menu-action-duplicate`;function MG(e){window.dispatchEvent(new CustomEvent(kG,{detail:{target:e}}))}function NG(e){let t=t=>{let n=t.detail;n?.target&&e(n.target)};return window.addEventListener(kG,t),()=>window.removeEventListener(kG,t)}function PG(e){window.dispatchEvent(new CustomEvent(AG,{detail:{target:e}}))}function FG(e){let t=t=>{let n=t.detail;n?.target&&e(n.target)};return window.addEventListener(AG,t),()=>window.removeEventListener(AG,t)}function IG(e){window.dispatchEvent(new CustomEvent(jG,{detail:{target:e}}))}function LG(e){let t=t=>{let n=t.detail;n?.target&&e(n.target)};return window.addEventListener(jG,t),()=>window.removeEventListener(jG,t)}function RG(e,t){let n=!1,r=!1,i=!1;async function a(){if(!i){n=!0;try{await e()}finally{n=!1,i?r=!1:r&&(r=!1,a())}}}return{request(){if(!i){if(n){r=!0,t?.();return}a()}},dispose(){i=!0,r=!1,t?.()}}}var zG={Accept:`application/x-ndjson, application/json`};function BG(e){return!e.ok||!e.body?!1:(e.headers.get(`content-type`)??``).includes(`application/x-ndjson`)}var VG=class extends Error{};function HG(e){return typeof e==`object`&&!!e&&`type`in e}async function UG(e){let t=e.body;if(!t)throw new VG(`Show All Files stream had no response body.`);let n=t.getReader(),r=new TextDecoder,i=[],a=!1,o=``,s=e=>{let t=e.trim();if(t.length===0)return!1;let n;try{n=JSON.parse(t)}catch{return console.warn(`[show-all-stream] dropping unparseable NDJSON line:`,t.slice(0,200)),!1}if(HG(n)){if(n.type===`error`)throw new VG(typeof n.problem?.title==`string`?n.problem.title:`Show All Files stream failed.`);return a=n.truncated===!0,!0}let r=kn.safeParse(n);return r.success?i.push(r.data):console.warn(`[show-all-stream] dropping schema-divergent entry line:`,r.error.issues),!1};try{let e=!1;for(;!e;){let t=await n.read();if(t.done)break;o+=r.decode(t.value,{stream:!0});let i=o.indexOf(`
1942
1942
  `);for(;i!==-1;){let t=s(o.slice(0,i));if(o=o.slice(i+1),t){e=!0;break}i=o.indexOf(`
1943
1943
  `)}}o+=r.decode(),o.includes(`
1944
- `)||s(o)}finally{n.releaseLock()}return{entries:i,truncated:a}}function WG(e,t,n,r=Date.now()){if(n.size===0)return[...e];let i=new Set(e.map(e=>mM(e))),a=[];for(let e of t){let t=mM(e);if(i.has(t)){n.delete(t);continue}let o=n.get(t);if(o!==void 0){if(r-o>5e3){n.delete(t);continue}a.push(e)}}return a.length===0?[...e]:[...e,...a]}function GG(e,t,n,r,i=Date.now()){if(t!==``&&!e.some(e=>mM(e)===t))return[...e];let a=[],o=[];for(let n of e)KG(t,mM(n))?a.push(n):o.push(n);let s=WG(n,a,r,i),c=new Set(s.map(e=>mM(e)).filter(e=>e.endsWith(`/`)));return[...o.filter(e=>{let n=mM(e);if(!n.startsWith(t))return!0;let r=n.slice(t.length),i=r.indexOf(`/`);return i===-1?!0:c.has(t+r.slice(0,i+1))}),...s]}function KG(e,t){if(!t.startsWith(e))return!1;let n=t.slice(e.length);if(n===``)return!1;let r=n.endsWith(`/`)?n.slice(0,-1):n;return r!==``&&!r.includes(`/`)}function qG(e){return e?ms._({id:`wTcjov`}):null}function JG(e){let t=(0,$.c)(29),{_:n}=i(),r=mg(),a=qx();if(r)return null;let{input:o,installStates:c,dispatch:l}=e,u=o===null,d,f,p,m,h,g;if(t[0]!==n||t[1]!==l||t[2]!==o||t[3]!==u||t[4]!==c||t[5]!==a){let e=qG(u),r;t[12]===c?r=t[13]:(r=e=>c[e.id]?.installed===!0,t[12]=c,t[13]=r);let i=_g.filter(r),_;t[14]===c?_=t[15]:(_=_g.some(e=>c[e.id]?.installed==null),t[14]=c,t[15]=_);let v=_,y=i.length>0,b=a!==null,x=!y&&!b;f=ka,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(so,{children:[(0,Z.jsx)(yi,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`O7_W_a`})]}),t[16]=g):g=t[16],d=Ha,p=y?(0,Z.jsxs)(La,{"aria-label":n({id:`BBqGS9`}),children:[(0,Z.jsx)(Ya,{children:(0,Z.jsx)(s,{id:`BBqGS9`})}),i.map(t=>{let r=!u,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(Ea,{disabled:!r,onSelect:()=>{o&&l(t.id,o)},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(Wx,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]}):null,t[17]!==v||t[18]!==x?(m=x?(0,Z.jsx)(Ea,{disabled:!0,"data-testid":`file-tree-open-in-empty`,children:v?(0,Z.jsx)(s,{id:`EcR0fl`}):(0,Z.jsx)(s,{id:`l6OXqI`})}):null,t[17]=v,t[18]=x,t[19]=m):m=t[19],h=b?(0,Z.jsxs)(Z.Fragment,{children:[y?(0,Z.jsx)(no,{}):null,(0,Z.jsxs)(La,{"aria-label":n({id:`ALhMYW`}),children:[(0,Z.jsx)(Ya,{children:(0,Z.jsx)(s,{id:`ALhMYW`})}),(0,Z.jsxs)(Ea,{onSelect:()=>{o!==null&&a.launchInTerminal(o)},disabled:u,"data-testid":`file-tree-open-in-terminal`,"aria-label":n(e?{id:`LtVw4J`,values:{hint:e}}:{id:`AcK_r0`}),children:[(0,Z.jsx)(ru,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`fcgvCA`})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]})]})]}):null,t[0]=n,t[1]=l,t[2]=o,t[3]=u,t[4]=c,t[5]=a,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11];let _;t[20]!==d||t[21]!==p||t[22]!==m||t[23]!==h?(_=(0,Z.jsxs)(d,{children:[p,m,h]}),t[20]=d,t[21]=p,t[22]=m,t[23]=h,t[24]=_):_=t[24];let v;return t[25]!==f||t[26]!==g||t[27]!==_?(v=(0,Z.jsxs)(f,{children:[g,_]}),t[25]=f,t[26]=g,t[27]=_,t[28]=v):v=t[28],v}var YG=v(`HOVER_INTENT_MS`,80),XG=3,ZG=20,QG=new Map,$G=new Set,eK=[],tK=new Map;function nK(e){for(tK.delete(e),tK.set(e,!0);tK.size>ZG;){let e=tK.keys().next().value;if(e===void 0)break;tK.delete(e)}}function rK(e){$G.delete(e),aK()}function iK(e,t){let n=Date.now();le(`ok/sidebar/prewarm-success`,{docName:e,t:n,poolEventId:t}),g(e,t,n)}function aK(){for(;$G.size<XG&&eK.length>0;){let e=eK.shift();if(!e)break;if(!tK.has(e.docName)){$G.add(e.docName),nK(e.docName);try{let t=e.prewarm(e.docName);t&&iK(e.docName,t)}catch(t){le(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{rK(e.docName)}}}}function oK(e,t){if(Ke(e)||tK.has(e))return;let n=QG.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(QG.delete(e),$G.size>=XG){eK.push({docName:e,prewarm:t});return}nK(e),$G.add(e);try{let n=t(e);n&&iK(e,n)}catch(t){le(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{rK(e)}},YG);QG.set(e,{timer:r,prewarm:t})}function sK(e){let t=QG.get(e);t&&(clearTimeout(t.timer),QG.delete(e))}var cK=/\.(md|mdx)$/i;function lK(e){let t=e.match(/^"(.+)" already exists\.$/);return t?t[1]:null}function uK(e){let t=e.match(cK);return t?t[0]:null}function dK(e){window.requestAnimationFrame(()=>{let t=q(e);if(!(!t||t.isDestroyed))try{t.commands.focus()}catch{}})}function fK(e){let t=e.current;t.row?.removeAttribute(TK),t.root?.removeAttribute(EK),e.current={row:null,root:null}}function pK(e,t){let n=e.current;n.row===t.row&&n.root===t.root||(fK(e),t.row?.setAttribute(TK,`true`),t.root?.setAttribute(EK,`true`),e.current={row:t.row,root:t.root})}async function mK(e,t){try{await navigator.clipboard.writeText(e),hs.success(t===`full`?ms._({id:`6_ZOw4`}):ms._({id:`haHgQj`}),{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),hs.error(t===`full`?ms._({id:`vfRlCI`}):ms._({id:`5QGTaA`}))}}var hK=new Set([`agents`,`agent`,`claude`,`skill`]),gK=`ok-file-tree-link-decoration`,_K=`ok-file-tree-agent-decoration`,vK=`ok-file-tree-markdown`,yK=`0 0 48 48`,bK=`<symbol id="${vK}" viewBox="${yK}" fill="none" stroke="currentColor" stroke-width="4.62651" stroke-linecap="round" stroke-linejoin="round"><path d="M3.18066 33.4398V13.5603L12.4337 22.8133L21.6867 13.5603V33.4398"/><path d="M38 13.5L38 33"/><path d="M44.8195 26.5L37.8797 33.4398L30.9399 26.5"/></symbol>`;function xK(e){return e.map(([e,{key:t,...n}])=>`<${e} ${Object.entries(n).map(([e,t])=>`${e}="${t}"`).join(` `)} />`).join(``)}function SK(e,t){return`<symbol id="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${xK(t)}</symbol>`}var CK=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
1944
+ `)||s(o)}finally{n.releaseLock()}return{entries:i,truncated:a}}function WG(e,t,n,r=Date.now()){if(n.size===0)return[...e];let i=new Set(e.map(e=>mM(e))),a=[];for(let e of t){let t=mM(e);if(i.has(t)){n.delete(t);continue}let o=n.get(t);if(o!==void 0){if(r-o>5e3){n.delete(t);continue}a.push(e)}}return a.length===0?[...e]:[...e,...a]}function GG(e,t,n,r,i=Date.now()){if(t!==``&&!e.some(e=>mM(e)===t))return[...e];let a=[],o=[];for(let n of e)KG(t,mM(n))?a.push(n):o.push(n);let s=WG(n,a,r,i),c=new Set(s.map(e=>mM(e)).filter(e=>e.endsWith(`/`)));return[...o.filter(e=>{let n=mM(e);if(!n.startsWith(t))return!0;let r=n.slice(t.length),i=r.indexOf(`/`);return i===-1?!0:c.has(t+r.slice(0,i+1))}),...s]}function KG(e,t){if(!t.startsWith(e))return!1;let n=t.slice(e.length);if(n===``)return!1;let r=n.endsWith(`/`)?n.slice(0,-1):n;return r!==``&&!r.includes(`/`)}function qG(e){return e?ms._({id:`wTcjov`}):null}function JG(e){let t=(0,$.c)(29),{_:n}=i(),r=mg(),a=qx();if(r)return null;let{input:o,installStates:c,dispatch:l}=e,u=o===null,d,f,p,m,h,g;if(t[0]!==n||t[1]!==l||t[2]!==o||t[3]!==u||t[4]!==c||t[5]!==a){let e=qG(u),r;t[12]===c?r=t[13]:(r=e=>c[e.id]?.installed===!0,t[12]=c,t[13]=r);let i=_g.filter(r),_;t[14]===c?_=t[15]:(_=_g.some(e=>c[e.id]?.installed==null),t[14]=c,t[15]=_);let v=_,y=i.length>0,b=a!==null,x=!y&&!b;f=ka,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsxs)(so,{children:[(0,Z.jsx)(yi,{"aria-hidden":`true`}),(0,Z.jsx)(s,{id:`O7_W_a`})]}),t[16]=g):g=t[16],d=Ha,p=y?(0,Z.jsxs)(La,{"aria-label":n({id:`BBqGS9`}),children:[(0,Z.jsx)(Ya,{children:(0,Z.jsx)(s,{id:`BBqGS9`})}),i.map(t=>{let r=!u,{displayName:i}=t,a=n(e?{id:`1ZpfyB`,values:{displayName:i,hint:e}}:{id:`WqLq6M`,values:{displayName:i}});return(0,Z.jsxs)(Ea,{disabled:!r,onSelect:()=>{o&&l(t.id,o)},"data-testid":`file-tree-open-in-${t.id}`,"aria-label":a,children:[(0,Z.jsx)(Wx,{id:t.id,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:t.displayName}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]},t.id)})]}):null,t[17]!==v||t[18]!==x?(m=x?(0,Z.jsx)(Ea,{disabled:!0,"data-testid":`file-tree-open-in-empty`,children:v?(0,Z.jsx)(s,{id:`EcR0fl`}):(0,Z.jsx)(s,{id:`l6OXqI`})}):null,t[17]=v,t[18]=x,t[19]=m):m=t[19],h=b?(0,Z.jsxs)(Z.Fragment,{children:[y?(0,Z.jsx)(no,{}):null,(0,Z.jsxs)(La,{"aria-label":n({id:`ALhMYW`}),children:[(0,Z.jsx)(Ya,{children:(0,Z.jsx)(s,{id:`ALhMYW`})}),(0,Z.jsxs)(Ea,{onSelect:()=>{o!==null&&a.launchInTerminal(o)},disabled:u,"data-testid":`file-tree-open-in-terminal`,"aria-label":n(e?{id:`LtVw4J`,values:{hint:e}}:{id:`AcK_r0`}),children:[(0,Z.jsx)(ru,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:(0,Z.jsx)(s,{id:`fcgvCA`})}),e?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:e}):null]})]})]}):null,t[0]=n,t[1]=l,t[2]=o,t[3]=u,t[4]=c,t[5]=a,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11];let _;t[20]!==d||t[21]!==p||t[22]!==m||t[23]!==h?(_=(0,Z.jsxs)(d,{children:[p,m,h]}),t[20]=d,t[21]=p,t[22]=m,t[23]=h,t[24]=_):_=t[24];let v;return t[25]!==f||t[26]!==g||t[27]!==_?(v=(0,Z.jsxs)(f,{children:[g,_]}),t[25]=f,t[26]=g,t[27]=_,t[28]=v):v=t[28],v}var YG=v(`HOVER_INTENT_MS`,80),XG=3,ZG=20,QG=new Map,$G=new Set,eK=[],tK=new Map;function nK(e){for(tK.delete(e),tK.set(e,!0);tK.size>ZG;){let e=tK.keys().next().value;if(e===void 0)break;tK.delete(e)}}function rK(e){$G.delete(e),aK()}function iK(e,t){let n=Date.now();le(`ok/sidebar/prewarm-success`,{docName:e,t:n,poolEventId:t}),g(e,t,n)}function aK(){for(;$G.size<XG&&eK.length>0;){let e=eK.shift();if(!e)break;if(!tK.has(e.docName)){$G.add(e.docName),nK(e.docName);try{let t=e.prewarm(e.docName);t&&iK(e.docName,t)}catch(t){le(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{rK(e.docName)}}}}function oK(e,t){if(Ke(e)||tK.has(e))return;let n=QG.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(QG.delete(e),$G.size>=XG){eK.push({docName:e,prewarm:t});return}nK(e),$G.add(e);try{let n=t(e);n&&iK(e,n)}catch(t){le(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{rK(e)}},YG);QG.set(e,{timer:r,prewarm:t})}function sK(e){let t=QG.get(e);t&&(clearTimeout(t.timer),QG.delete(e))}var cK=/\.(md|mdx)$/i;function lK(e){let t=e.match(/^"(.+)" already exists\.$/);return t?t[1]:null}function uK(e){let t=e.match(cK);return t?t[0]:null}function dK(e){window.requestAnimationFrame(()=>{let t=q(e);if(!(!t||t.isDestroyed))try{t.commands.focus()}catch{}})}function fK(e){let t=e.current;t.row?.removeAttribute(TK),t.root?.removeAttribute(EK),e.current={row:null,root:null}}function pK(e,t){let n=e.current;n.row===t.row&&n.root===t.root||(fK(e),t.row?.setAttribute(TK,`true`),t.root?.setAttribute(EK,`true`),e.current={row:t.row,root:t.root})}async function mK(e,t){try{await navigator.clipboard.writeText(e),hs.success(t===`full`?ms._({id:`6_ZOw4`}):ms._({id:`haHgQj`}),{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),hs.error(t===`full`?ms._({id:`vfRlCI`}):ms._({id:`5QGTaA`}))}}var hK=new Set([`agents`,`agent`,`claude`,`skill`]),gK=`ok-file-tree-link-decoration`,_K=`ok-file-tree-agent-decoration`,vK=`ok-file-tree-markdown`,yK=`0 0 32 32`,bK=`<symbol id="${vK}" viewBox="${yK}" fill="currentColor"><path d="M26.7075 10.2925L19.7075 3.2925C19.6146 3.19967 19.5042 3.12605 19.3829 3.07586C19.2615 3.02568 19.1314 2.9999 19 3H7C6.46957 3 5.96086 3.21071 5.58579 3.58579C5.21071 3.96086 5 4.46957 5 5V14C5 14.2652 5.10536 14.5196 5.29289 14.7071C5.48043 14.8946 5.73478 15 6 15C6.26522 15 6.51957 14.8946 6.70711 14.7071C6.89464 14.5196 7 14.2652 7 14V5H18V11C18 11.2652 18.1054 11.5196 18.2929 11.7071C18.4804 11.8946 18.7348 12 19 12H25V28C25 28.2652 25.1054 28.5196 25.2929 28.7071C25.4804 28.8946 25.7348 29 26 29C26.2652 29 26.5196 28.8946 26.7071 28.7071C26.8946 28.5196 27 28.2652 27 28V11C27.0001 10.8686 26.9743 10.7385 26.9241 10.6172C26.8739 10.4958 26.8003 10.3854 26.7075 10.2925ZM20 6.41375L23.5863 10H20V6.41375ZM18 18H16C15.7348 18 15.4804 18.1054 15.2929 18.2929C15.1054 18.4804 15 18.7348 15 19V26C15 26.2652 15.1054 26.5196 15.2929 26.7071C15.4804 26.8946 15.7348 27 16 27H18C19.1935 27 20.3381 26.5259 21.182 25.682C22.0259 24.8381 22.5 23.6935 22.5 22.5C22.5 21.3065 22.0259 20.1619 21.182 19.318C20.3381 18.4741 19.1935 18 18 18ZM18 25H17V20H18C18.663 20 19.2989 20.2634 19.7678 20.7322C20.2366 21.2011 20.5 21.837 20.5 22.5C20.5 23.163 20.2366 23.7989 19.7678 24.2678C19.2989 24.7366 18.663 25 18 25ZM13 19V26C13 26.2652 12.8946 26.5196 12.7071 26.7071C12.5196 26.8946 12.2652 27 12 27C11.7348 27 11.4804 26.8946 11.2929 26.7071C11.1054 26.5196 11 26.2652 11 26V22.1725L9.31875 24.5737C9.22652 24.7053 9.10396 24.8126 8.96144 24.8868C8.81892 24.9609 8.66064 24.9996 8.5 24.9996C8.33936 24.9996 8.18108 24.9609 8.03856 24.8868C7.89604 24.8126 7.77348 24.7053 7.68125 24.5737L6 22.1725V26C6 26.2652 5.89464 26.5196 5.70711 26.7071C5.51957 26.8946 5.26522 27 5 27C4.73478 27 4.48043 26.8946 4.29289 26.7071C4.10536 26.5196 4 26.2652 4 26V19C4.00009 18.7874 4.06791 18.5804 4.19363 18.409C4.31935 18.2376 4.49642 18.1107 4.69915 18.0467C4.90188 17.9828 5.11971 17.9851 5.32104 18.0533C5.52236 18.1216 5.6967 18.2522 5.81875 18.4263L8.5 22.2563L11.1812 18.4263C11.3033 18.2522 11.4776 18.1216 11.679 18.0533C11.8803 17.9851 12.0981 17.9828 12.3008 18.0467C12.5036 18.1107 12.6807 18.2376 12.8064 18.409C12.9321 18.5804 12.9999 18.7874 13 19Z"/></symbol>`;function xK(e){return e.map(([e,{key:t,...n}])=>`<${e} ${Object.entries(n).map(([e,t])=>`${e}="${t}"`).join(` `)} />`).join(``)}function SK(e,t){return`<symbol id="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${xK(t)}</symbol>`}var CK=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
1945
1945
  ${SK(gK,D)}
1946
1946
  ${SK(_K,al)}
1947
1947
  ${bK}
@@ -48,7 +48,7 @@
48
48
  -->
49
49
  <script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
50
50
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
51
- <script type="module" crossorigin src="./assets/index-DJWeEt10.js"></script>
51
+ <script type="module" crossorigin src="./assets/index-DSdwUSf0.js"></script>
52
52
  <link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
53
53
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
54
54
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-nBRha8PK.js">
@@ -1,2 +1,2 @@
1
- import{h as e,n as t}from"./init-BO9tnd8g.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{existsSync as r,readFileSync as i}from"node:fs";import{join as a}from"node:path";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=a(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!r(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=i(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
- //# sourceMappingURL=repair-launch-json-e8LkOdCc.mjs.map
1
+ import{h as e,n as t}from"./init-D21pFsMR.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{existsSync as r,readFileSync as i}from"node:fs";import{join as a}from"node:path";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=a(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!r(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=i(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
2
+ //# sourceMappingURL=repair-launch-json-hQzZWJEV.mjs.map
@@ -1,2 +1,2 @@
1
- import{d as e,g as t}from"./init-BO9tnd8g.mjs";import{c as n,o as r,r as i}from"./write-project-skill-DUCFyVhD.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
- //# sourceMappingURL=repair-mcp-configs--EEo_NYX.mjs.map
1
+ import{d as e,g as t}from"./init-D21pFsMR.mjs";import{c as n,o as r,r as i}from"./write-project-skill-bJPJ3udE.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of i){let i=r[o],s=c(()=>i.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:i,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),i.projectConfigPath){let n=i.projectConfigPath,r=c(()=>n(e.projectDir));r!==null&&a.push(l({scope:`project`,editorId:o,target:i,home:void 0,cwd:e.projectDir,configPath:r,configPathOverride:r,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=e(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=t(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
2
+ //# sourceMappingURL=repair-mcp-configs-Dk0wiyoG.mjs.map
@@ -0,0 +1 @@
1
+ import{t as e}from"./repair-skills-DPudTR_l.mjs";export{e as repairSkills};
@@ -1,3 +1,3 @@
1
- import{t as e}from"./esm-BLMtE3s6.mjs";import{Hi as t,Nr as n,Tr as r,kr as i,zr as a}from"./dist-DvEI00I1.mjs";import{i as o,o as s,t as c}from"./write-project-skill-DUCFyVhD.mjs";import{existsSync as l,mkdirSync as u,readFileSync as d,readdirSync as f,rmSync as p,statSync as m,writeFileSync as h}from"node:fs";import{dirname as g,join as _,resolve as v}from"node:path";import{homedir as y}from"node:os";const b=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`}],x=`open-knowledge-discovery`,S=[`.agents`,`skills`,x],C={existsSync:e=>l(e),isDirectory:e=>{try{return m(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>f(e),readFileSync:e=>d(e),writeFileSync:(e,t)=>{h(e,t)},mkdirSync:(e,t)=>{u(e,t)},rmSync:(e,t)=>{p(e,t)}},w={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>a(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>r(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,n)=>t(e,`cli-hosts`,n,`cli-start`),recordEvent:e=>n(e)};function T(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function E(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(g(t),{recursive:!0}),D(e,t,n)}function D(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=_(e,r),a=_(t,r);n.isDirectory(i)?D(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function O(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(o):!1}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of b){let o=_(e,t.hostDir,`skills`,`open-knowledge`),l=_(o,`SKILL.md`),u=n.existsSync(l),d=s[t.editorId]?.projectConfigPath?.(e),f=!u&&O(d,n);if(!u&&!f){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{c(o,e),E(i,o,n);let s=u?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:u?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=_(e,...S),d=n.existsSync(u);try{E(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of b){let i=_(e,t.hostDir),a=_(i,`skills`,x);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{E(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function j(e){let t=e.logger??T,n=e.fs??C,r=e.home??y(),i={...w,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
1
+ import{t as e}from"./esm-BLMtE3s6.mjs";import{Hi as t,Nr as n,Tr as r,kr as i,zr as a}from"./dist-CdLjGZjc.mjs";import{i as o,o as s,t as c}from"./write-project-skill-bJPJ3udE.mjs";import{existsSync as l,mkdirSync as u,readFileSync as d,readdirSync as f,rmSync as p,statSync as m,writeFileSync as h}from"node:fs";import{dirname as g,join as _,resolve as v}from"node:path";import{homedir as y}from"node:os";const b=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`}],x=`open-knowledge-discovery`,S=[`.agents`,`skills`,x],C={existsSync:e=>l(e),isDirectory:e=>{try{return m(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>f(e),readFileSync:e=>d(e),writeFileSync:(e,t)=>{h(e,t)},mkdirSync:(e,t)=>{u(e,t)},rmSync:(e,t)=>{p(e,t)}},w={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>a(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>r(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,n)=>t(e,`cli-hosts`,n,`cli-start`),recordEvent:e=>n(e)};function T(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function E(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(g(t),{recursive:!0}),D(e,t,n)}function D(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=_(e,r),a=_(t,r);n.isDirectory(i)?D(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function O(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(o):!1}catch{return!1}}function k(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of b){let o=_(e,t.hostDir,`skills`,`open-knowledge`),l=_(o,`SKILL.md`),u=n.existsSync(l),d=s[t.editorId]?.projectConfigPath?.(e),f=!u&&O(d,n);if(!u&&!f){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{c(o,e),E(i,o,n);let s=u?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:u?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function A(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=_(e,...S),d=n.existsSync(u);try{E(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of b){let i=_(e,t.hostDir),a=_(i,`skills`,x);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{E(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function j(e){let t=e.logger??T,n=e.fs??C,r=e.home??y(),i={...w,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:k(e.projectDir,i,n,t),user:await A(r,i,n,t)}}function M(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function N(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
2
2
  `)}function P(){return new e(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await j({projectDir:v(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${N(e)}\n`),process.exitCode=M(e)})}export{P as n,j as t};
3
- //# sourceMappingURL=repair-skills-7PrXw-wL.mjs.map
3
+ //# sourceMappingURL=repair-skills-DPudTR_l.mjs.map
@@ -1,7 +1,7 @@
1
- import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import"./gh-detect-Dv4BrBzE.mjs";import{Ur as a,vn as o}from"./dist-DvEI00I1.mjs";import{g as s,h as c}from"./init-BO9tnd8g.mjs";import{n as l,o as u}from"./write-project-skill-DUCFyVhD.mjs";import"./loader-BicOC80J.mjs";import{c as d}from"./colors-CBY1ibtz.mjs";import"./preview-C7YD86Pc.mjs";import{spawnSync as f}from"node:child_process";import{existsSync as p,lstatSync as m,readFileSync as h,readdirSync as g,statSync as ee}from"node:fs";import{basename as te,dirname as _,isAbsolute as v,join as y,relative as b,resolve as x}from"node:path";import{hostname as ne}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!p(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(h(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??ne();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function D(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function O(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,re=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return re.some(t=>t.test(e))}function ie(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return v(e)?e:null}catch{return null}}function ae(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&v(a)?a:null}function oe(e){let t=[];for(let n of e.split(`
1
+ import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-C32FtL5e.mjs";import"./gh-detect-Dv4BrBzE.mjs";import{Ur as a,vn as o}from"./dist-CdLjGZjc.mjs";import{g as s,h as c}from"./init-D21pFsMR.mjs";import{n as l,o as u}from"./write-project-skill-bJPJ3udE.mjs";import"./loader-DpizTs6p.mjs";import{c as d}from"./colors-CBY1ibtz.mjs";import"./preview-DMinlQU3.mjs";import{spawnSync as f}from"node:child_process";import{existsSync as p,lstatSync as m,readFileSync as h,readdirSync as g,statSync as ee}from"node:fs";import{basename as te,dirname as _,isAbsolute as v,join as y,relative as b,resolve as x}from"node:path";import{hostname as ne}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!p(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(h(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??ne();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function D(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function O(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,re=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return re.some(t=>t.test(e))}function ie(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return v(e)?e:null}catch{return null}}function ae(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&v(a)?a:null}function oe(e){let t=[];for(let n of e.split(`
2
2
  `)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&M(a)&&t.push({pid:o,command:a})}return t}function se(e){let t=[],n=e.split(`
3
3
  `);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&M(o)&&t.push({pid:s,command:o})}return t}async function ce(){let e=f(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:A});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=oe(t);if(n.length>0||t.trim()===``)return n}let t=f(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?[]:se(t.stdout)}function le(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=te(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function N(e){let t=f(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function P(e){let t=f(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:A});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function F(e){let t=f(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:A});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
4
4
  `))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function I(e){let t=[],n=e.split(`
5
5
  `);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.split(/\s+/);if(i.length<2)continue;let a=Number.parseInt(i[1]??``,10);Number.isNaN(a)||t.push(a)}return[...new Set(t)]}function L(e){return p(y(e,`server.lock`))||p(y(e,`ui.lock`))}function R(e,t){for(let n of[y(t,`.ok`,`local`),y(t,`.ok`)])p(n)&&L(n)&&e.add(n)}function z(e,t){let n=0,r=(t,i)=>{if(n>=j||(n++,R(e,t),i>=3))return;let a;try{a=g(t)}catch{return}for(let e of a){if(n>=j)return;if(e===`node_modules`||e===`.git`||e===`Library`||e.startsWith(`.`)&&e!==`.ok`)continue;let a=y(t,e),o=!1;try{o=m(a).isDirectory()}catch{continue}o&&r(a,i+1)}};r(t,0)}async function B(){let e=new Set,t=await ce(),n=t.map(e=>F(e.pid)),r=await Promise.all(n);for(let n of t){let t=ie(n.command);t!=null&&p(t)&&e.add(t);let r=ae(n.command);r!=null&&R(e,r)}for(let t of r)t!=null&&R(e,t);let i=f(`lsof`,[`-iTCP`,`-sTCP:LISTEN`,`-nP`],{encoding:`utf-8`,timeout:A});if(i.error==null&&i.stdout){let n=I(i.stdout),r=new Set(t.map(e=>e.pid)),a=n.filter(e=>!r.has(e)).map(e=>F(e)),o=await Promise.all(a);for(let t of o)t!=null&&R(e,t)}(e.size===0||r.some(e=>e===`/`))&&z(e,process.cwd());let a=new Map;for(let t of e)try{let e=await C(t);a.set(e,e)}catch{a.set(t,t)}return[...a.values()]}var V=e(d(),1);function H(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function U(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function W(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:le(r),command:r,isDesktop:H(r)}}function ue(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function G(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&ue(e)?`ui-orphan`:`stale`}const de=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fe(e){switch(e){case`running`:return V.default.green(e);case`desktop`:return V.default.blue(e);case`foreign`:return V.default.cyan(e);case`ui-orphan`:return V.default.magenta(e);case`stale`:return V.default.yellow(e)}}function K(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function pe(e){return`${K(e.server.usage)} | ${K(e.ui?.usage??null)}`}function me(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function he(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=G(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,me(e),pe(e),t,String(n),U(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=fe(G(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=V.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
6
6
  `)}async function q(e={}){let t=e.discover??B,n=e.inspect??w,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:G(e)}));r(JSON.stringify(e,null,2));return}r(he(e.all?s:s.filter(e=>de.has(G(e)))))}function ge(){return new t(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await q({all:t.all===!0||e===`all`,json:t.json===!0})})}const _e=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`]);function ve(e,t,n=o){if(e!==void 0&&!_e.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let J=null;function ye(e){J=e}function be(){return J??process.cwd()}function xe(e,t,n={}){let r=n.isAlive??i,a=[];for(let[n,i]of[[`server`,e],[`ui`,t]])(i.status===`alive`||i.status===`foreign-host`&&r(i.lock.pid))&&a.push({name:n,pid:i.lock.pid,port:i.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>w(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xe(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Se(e,t=i){let n=await B(),r=null;for(let i of n){let n=w(i,`server`),a=w(i,`ui`);if(X(n,t)&&n.lock.port===e||X(a,t)&&a.lock.port===e)return i;r===null&&(X(n,t)&&n.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Ce(e){return new t(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Y({lockDir:a(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await q({});return}if(n===`all`){let e=await B();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=w(n,`server`),r=w(n,`ui`);!X(e,i)&&!X(r,i)||(Z(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Se(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(a(x(be(),n)))})}async function we(e,t){let n,r;try{n=await C(x(e)),r=await C(x(_(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=y(n,`.git`),a;try{a=ee(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await C(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await S(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=v(r)?r:x(n,r);try{o=await C(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=y(await Q(o),`config`),c;try{c=await S(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Ee(c);if(l===null)return{kind:`no-origin`};let u=E(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function Q(e){let t;try{t=(await S(y(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=v(t)?t:x(e,t);try{return await C(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=b(t,e);return n.length>0&&!n.startsWith(`..`)&&!v(n)}function Te(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function Ee(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Te(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return De(r[1])}return null}function De(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Oe=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=s(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=l(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function ke(e,t,n={},r=Oe){let i=[];for(let a of t){let t=u[a];for(let a of r)i.push(a.write(t,e,n))}return i}function Ae(e,t,n={}){return{integrations:ke(e,t,n),claudeLaunchJson:t.includes(`claude`)?c(e,n):void 0}}export{ye as a,B as c,D as d,k as f,w as h,Ce as i,N as l,E as m,we as n,ve as o,O as p,Y as r,ge as s,Ae as t,P as u};
7
- //# sourceMappingURL=src-M3O8DB6m.mjs.map
7
+ //# sourceMappingURL=src-BzQcpEPg.mjs.map
@@ -0,0 +1 @@
1
+ import{_ as e,f as t,r as n}from"./start-E4_PXpTr.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};