@inkeep/open-knowledge 0.40.0-beta.1 → 0.40.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-CI5eMrtp.mjs → acp-harness-probe-DR1ZKGnH.mjs} +2 -2
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +7 -7
- package/dist/constants-BJzJKgN0.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/init-BNoSqnre.mjs +1 -0
- package/dist/{init-DqAj6DLP.mjs → init-CRqHukN0.mjs} +3 -3
- package/dist/{launch-json-removal-DMBq4-k5.mjs → launch-json-removal-D2RKDIfa.mjs} +2 -2
- package/dist/loader-3kHXROAa.mjs +1 -0
- package/dist/{loader-CuzKavqN.mjs → loader-B2FwNLO-.mjs} +2 -2
- package/dist/{open-browser-D3OpxES8.mjs → open-browser-B_gopYWU.mjs} +2 -2
- package/dist/{preview-DNAkJMSB.mjs → preview-2zt9BjS6.mjs} +2 -2
- package/dist/preview-rVAd6E5r.mjs +1 -0
- package/dist/{repair-launch-json-tt6Tjedd.mjs → repair-launch-json-C3uqYkeS.mjs} +2 -2
- package/dist/{repair-mcp-configs-Bn1d1oSd.mjs → repair-mcp-configs-i7dMnghP.mjs} +2 -2
- package/dist/repair-skills-DJ7FOTZZ.mjs +1 -0
- package/dist/{repair-skills-BVXDXZaA.mjs → repair-skills-P9l196Qv.mjs} +2 -2
- package/dist/{src-DVrFd0vk.mjs → src-7LOBasfG.mjs} +316 -316
- package/dist/{src-DQTDRmqk.mjs → src-CgblAAT9.mjs} +1 -1
- package/dist/{src-VT3q7v5V.mjs → src-Dj-HA_-C.mjs} +2 -2
- package/dist/start-Br97vCln.mjs +1 -0
- package/dist/{start-BQRik_0l.mjs → start-CcMTV_IU.mjs} +2 -2
- package/dist/{write-project-skill-SrjlunKm.mjs → write-project-skill-Cm0CAVv2.mjs} +2 -2
- package/package.json +5 -5
- package/dist/constants-CkXW_O1Z.mjs +0 -2
- package/dist/init-BG8F8jyV.mjs +0 -1
- package/dist/loader-48vYo7np.mjs +0 -1
- package/dist/preview-hDB5CK12.mjs +0 -1
- package/dist/repair-skills-D7MJ6bSo.mjs +0 -1
- package/dist/start-3HnyNbf6.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,Da as t,La as n,Ta as r,Ya as i,d as a,da as o,l as s,la as c,ua as l,y as u}from"./src-IQdx1yfl.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,Ir as ie,It as ae,J as oe,Ji as se,Jn as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kt as pe,L as me,Li as he,Ln as ge,Lr as _e,Lt as ve,M as ye,Mi as be,Mn as xe,Mr as Se,Mt as Ce,N as we,Ni as Te,Nn as Ee,Nr as De,Nt as Oe,O as ke,Oi as Ae,On as je,Or as Me,Ot as Ne,P as Pe,Pi as Fe,Pn as Ie,Pr as Le,Pt as Re,Q as ze,Qi as Be,Qn as Ve,Qr as He,Qt as Ue,R as We,Ri as Ge,Rn as Ke,Rr as qe,Rt as Je,S as Ye,Si as Xe,Sn as Ze,Sr as Qe,St as $e,T as et,Ti as tt,Tn as nt,Tr as rt,Tt as it,U as at,Ui as ot,Un as st,Ur as ct,Ut as lt,V as ut,Vi as dt,Vn as ft,Vr as pt,Vt as mt,W as ht,Wi as gt,Wn as _t,Wr as vt,Wt as yt,X as bt,Xi as xt,Xn as St,Xr as Ct,Xt as wt,Y as Tt,Yi as Et,Yn as Dt,Yt as Ot,Z as kt,Zi as At,Zn as jt,Zr as Mt,Zt as Nt,_ as Pt,_i as Ft,_n as It,_r as Lt,a as Rt,aa as zt,ai as Bt,an as Vt,ar as Ht,at as Ut,b as Wt,bi as Gt,bn as Kt,br as qt,bt as Jt,c as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,ct as en,d as tn,da as nn,di as rn,dn as an,dr as on,dt as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fi as mn,fn as hn,fr as gn,ft as _n,g as vn,gi as yn,gn as bn,gr as xn,h as Sn,hi as Cn,hn as wn,hr as Tn,i as En,ia as Dn,ii as On,in as kn,ir as An,it as jn,j as Mn,ji as Nn,jn as Pn,jr as Fn,jt as In,k as Ln,ki as Rn,kn as zn,kr as Bn,kt as Vn,l as Hn,la as Un,li as Wn,ln as Gn,lr as Kn,lt as qn,m as Jn,mi as Yn,mn as Xn,mr as Zn,n as Qn,na as $n,ni as er,nn as tr,nr,nt as rr,o as ir,oa as ar,oi as or,on as sr,or as cr,ot as lr,p as ur,pi as dr,pn as fr,pr,q as mr,qi as hr,qn as gr,qt as _r,r as vr,ra as yr,ri as br,rn as xr,rr as Sr,rt as Cr,s as wr,sa as Tr,si as Er,sn as Dr,sr as Or,st as kr,t as Ar,ta as jr,ti as Mr,tn as Nr,tr as Pr,tt as Fr,u as Ir,ua as Lr,ui as Rr,un as zr,ur as Br,ut as Vr,v as Hr,vi as Ur,vn as Wr,vr as Gr,w as Kr,wi as qr,wn as Jr,wr as Yr,wt as Xr,x as Zr,xi as Qr,xn as $r,xr as ei,xt as ti,y as ni,yi as ri,yn as ii,yr as ai,yt as oi,z as si,zi as ci,zn as li,zr as ui,zt as di}from"./src-DVrFd0vk.mjs";import{C as fi,E as pi,T as mi,_ as hi,b as gi,c as _i,d as vi,g as yi,i as bi,l as xi,m as Si,n as Ci,p as wi,s as Ti,t as Ei,u as Di,v as Oi,w as ki,x as Ai,y as ji}from"./fs-traced-PoaSX4-V.mjs";import{a as Mi,d as Ni,f as Pi,i as Fi,l as Ii,n as Li,r as Ri,t as zi,u as Bi}from"./logger-B7Z8XO-z.mjs";import{_ as Vi,a as Hi,b as Ui,c as Wi,f as Gi,g as Ki,h as qi,i as Ji,l as Yi,m as Xi,n as Zi,o as Qi,p as $i,r as ea,s as ta,t as na,u as ra,v as ia,y as aa}from"./server-lock-DWsOY8Sf.mjs";export{$n as AGENT_ID_MAX_LEN,yr as AGENT_ID_RE,ne as AGENT_WRITE_ORIGIN,Un as AcpPermissionStore,ar as AcpRegistry,Te as AcpThreadManager,Nn as AgentFocusBroadcaster,_ as AgentPresenceBroadcaster,he as AgentSessionCapacityError,Ge as AgentSessionManager,Jt as AutoStartDisabledError,Fn as BUNDLE_IDS,Se as BUNDLE_SCOPE,De as BUNDLE_SKILL_NAME,jt as BacklinkIndex,q as CC1Broadcaster,t as CC1_CONTRACT_VERSION,Dr as CONFIG_FILENAME,fe as CONFLICT_MARKER_RE,ln as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,Pn as DEFAULT_CHECKPOINT_RETENTION,Cn as DEFAULT_EMBEDDINGS_DIMENSIONS,Je as DEFAULT_PACK_ID,K as DocumentDurabilityState,yn as EMBEDDINGS_API_KEY_ENV,Tr as FEATURED_AGENT_IDS,xe as FILE_SYSTEM_WRITER,St as FILE_WATCHER_ORIGIN,Rr as FileEmbeddingsBackend,tr as GIT_PREFLIGHT_FAIL_SPAN_NAME,Ee as GIT_UPSTREAM_WRITER,Lr as GitDirAccessError,An as GitNotAvailableError,Ht as GitTooOldError,ti as HOCUSPOCUS_AUTH_REJECTION_REASONS,$e as HocuspocusAuthRejection,A as HocuspocusAuthTokenSchema,or as INSTALLED_AGENTS_SCHEMES,r as LINEAGE_EPOCH_KEY,X as LIVE_DERIVED_INDEX_DEBOUNCE_MS,di as LOG_MD_TEMPLATE,Vn as MANAGED_RENAME_ORIGIN,Fe as MAX_ACP_THREADS,ci as MAX_AGENT_SESSIONS,sn as MCP_CONNECTION_ID_HEADER,c as MCP_SERVER_NAME,S as MIN_EVICTABLE_IDLE_MS,cr as MIN_GIT_VERSION,ue as MISSING_OK_CONFIG_MESSAGE,nn as MalformedGitPointerError,Cr as McpLogger,mr as MissingOkConfigError,V as OBSERVER_SYNC_ORIGIN,Qt as OK_OKIGNORE_TEMPLATE,l as ORPHAN_MODES,i as PROTOCOL_VERSION,zi as PinoLogger,Wi as ProcessLockCollisionError,Hn as ProjectGitInitError,b as ROLLBACK_ORIGIN,Gn as ROOT_GITIGNORE_TEMPLATE,Ki as RUNTIME_VERSION,Ie as SERVICE_WRITER,z as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,T as STARTER_FOLDERS,mt as STARTER_FOLDER_FRONTMATTER_FILENAME,ee as STARTER_PACKS,lt as STARTER_PACK_IDS,yt as STARTER_TEMPLATES,I as STATE_MANIFEST_FILENAME,Vi as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,wt as SeedPrerequisiteError,Nt as SeedRootDirError,na as ServerLockCollisionError,Ar as SingleFileNotAFileError,Qn as SingleFileNotFoundError,vr as SingleFileNotMarkdownError,j as StateManifestError,et as TagIndex,Le as USER_GLOBAL_BUNDLE_IDS,p as UiLockCollisionError,In as __getShowAllWalkStatsForTesting,Ce as __resetShowAllWalkStatsForTesting,Yi as acquireProcessLock,Zi as acquireServerLock,dn as acquireUiLock,dt as applyAgentMarkdownWrite,zn as applyExternalChange,ve as applySeed,ke as assertCompatibleStateManifest,Or as assertGitAvailable,It as assertNeverDiskEvent,be as attachAcpThreadSocket,oi as attachIdleShutdown,Hr as bootServer,xn as buildAndOpenSkill,zr as buildConfigYmlContent,ze as buildExecResult,H as buildOkMcpStdioCommand,Me as buildSkillZip,Y as buildStarterFolderFrontmatterYaml,U as buildWipTree,W as bundleSkillMdPath,Wr as classifyEvents,Ei as classifyFsPath,Ft as clearContributors,rn as clearEmbeddingsKeyFromAllBackends,pe as coercePackId,s as colorFromSeed,re as commitUpstreamImport,ge as commitWip,Ke as commitWipFromTree,$t as compareSemver,qe as composeEffectiveLinterConfig,gr as containsConflictMarkers,ii as contentHash,Ur as contributorCount,We as countShadowObjects,si as countStaleAgentWipRefs,x as countWipRefs,Oe as createApiExtension,M as createAssetServeMiddleware,Ct as createContentFilter,Mt as createContentFilterAsync,mn as createEmbeddingsSecretStore,En as createEphemeralProjectDir,v as createExternalChangeHandler,pn as createFileLogger,at as createLiveDerivedIndexExtension,bt as createMcpHttpHandler,Er as createOsProbe,Pe as createPersistenceExtension,E as createServer,ye as createServerObserverExtension,Z as createStreamingErrorWriter,Li as createTestLogger,dr as describeStoredEmbeddingsKey,vn as detectClaudeDesktopPresence,Kn as detectGit,Ln as detectProjectShape,lr as discoverLockDirs,pt as discoverMarkdownlintConfig,xr as emitPreflightFailureSpan,d as encodeDocName,fn as encodeFolderRoute,Fr as encodeSkillRoute,Ir as ensureProjectGit,an as ensureProjectSkillGitignore,ot as errorResponse,Kt as evictStaleTrackerEntries,kr as extractOkBinaryPath,Ve as extractWikiLinksFromMarkdown,Br as fallbackPaths,tn as findEnclosingGitRoot,wn as findEnclosingProjectRoot,$ as findNativeMarkdownlintFile,ur as flushFileLogger,Xr as formatAuthRejectionWire,ri as formatContributors,Gt as formatContributorsFrom,G as formatPackRationale,li as gcCheckpointRefs,jn as getCurrentMcpLogger,qr as getLocalDir,Jn as getLogFilePath,Ri as getLogger,Sn as getLogsDir,Ui as getMachineId,ji as getMeter,At as getMetrics,gi as getTracer,Be as handleCollabSocketError,Mr as handleSpawnCursor,ut as hasGcLogLatch,a as iconFromClientName,f as incrementCollabSocketFilteredError,cn as incrementServerObserverFire,hn as initContent,C as initShadowRepo,Ai as initTelemetry,Wt as initToleranceTelemetryWriter,Vr as installPrettyZodErrors,Fi as installTestLoggers,Lt as installUserSkill,Rn as isAllowedApiOrigin,Ue as isAllowedWorkspaceHostHeader,de as isConfigDoc,it as isHocuspocusAuthRejectionReason,_r as isKnownPackId,hr as isLinkIndexExcludedDoc,h as isLoopbackAddress,se as isManagedArtifactDoc,o as isOrphanMode,te as isPairedWriteOrigin,er as isPathWithinDir,ia as isProcessAlive,bn as isProjectRoot,gn as isProjectSkillManaged,Et as isReservedForUserTree,$r as isSelfWrite,xt as isSystemDoc,Zr as isToleranceTelemetryEnabled,aa as isValidLockPid,Ze as lastKnownHash,ft as listRescueCheckpoints,le as listStarterPacks,Xt as loadCustomAgents,we as loadPrincipal,ra as lockFilePath,Mi as loggerFactory,Ii as logsCurrentPath,Bi as logsPreviousPath,Yn as makeLazyEmbeddingsKeyStore,ea as markServerLockDraining,oe as mountMcpAndApi,Ci as normalizeFsPath,ie as originGitHubHost,fr as packageVersionMajorMinor,B as parseAuthRejectionWire,on as parseGitVersion,F as parseHocuspocusAuthToken,Tt as parseKeepaliveConnectionId,O as pathToDocName,ae as planSeed,Rt as prepareSingleFileOpen,en as processCommand,qn as processUsage,Gr as readAllTargets,ai as readBundleDecision,ct as readOwnNativeRules,Gi as readProcessLock,$i as readProcessLockDetailed,ht as readProjectHeadState,Wn as readProjectLocalSemanticConfig,Ji as readServerLock,qt as readServerPackageVersion,ei as readSkillInstallStateSnapshot,pr as readSkillManagement,g as readStateManifest,Qe as readTargetRecordedAt,k as readTargetVersion,Pr as readUiLock,ce as reconcile,Qr as recordContributor,P as recordSkillInstallEvent,kt as registerAllTools,Jr as registerWrite,Xi as releaseProcessLock,Hi as releaseServerLock,nr as releaseUiLock,nt as removeLastKnownHash,jr as resetMetrics,e as resolveBundleEnabled,Bn as resolveBundledSkillDir,tt as resolveContentDir,br as resolveCursorBinaryDefault,On as resolveCursorSpawnInvocation,ui as resolveEffectiveLinterConfig,L as resolveLockDir,w as resolveNativeConfigForDoc,vt as resolveNativeMarkdownlintConfig,Ot as resolvePack,wr as resolvePackageVersion,rr as resolveUiInfo,Xe as restoreContributors,ni as restoreLifecycleFromConflictsJson,He as rewriteMarkdownLinksForDocumentRename,m as rewriteWikiLinksForDocumentRename,kn as runAuthReposSubprocess,Vt as runAuthStatusSubprocess,un as runCloneSubprocess,sr as runDeviceFlowSubprocess,Ut as runWithMcpLogger,Ae as safeContentPath,Re as safeSubdir,Q as safetyCheckpoint,_n as sanitizeClientName,st as saveInMemoryCheckpoint,_t as saveVersion,Ne as seedBasenameIndex,ir as serializeError,fi as setActiveSpanAttributes,me as setupServerObservers,J as shadowGit,ki as shutdownTelemetry,Zn as skillManagementPath,Ni as spansCurrentPath,Pi as spansPreviousPath,Bt as spawnDetached,Dt as splitMarkdownBlocks,R as startWatcher,gt as streamingProblemEvent,D as swapContributors,Ye as teardownToleranceTelemetryWriter,Dn as toBroadcasterKey,bi as tracedAppendFileSync,Ti as tracedLinkSync,_i as tracedMkdir,xi as tracedMkdirSync,Di as tracedRename,vi as tracedRenameSync,wi as tracedRmSync,Si as tracedRmdirSync,yi as tracedUnlinkSync,hi as tracedWriteFile,Oi as tracedWriteFileSync,Kr as trustSystemCertificates,Yt as untrackTrackedProjectSkillProjection,N as updateLastKnownHash,qi as updateProcessLockPort,Qi as updateServerLockPort,Sr as updateUiLockPort,zt as validateAgentId,Nr as validateCloneInputs,y as validateSkillZip,ta as waitForServerLockDrain,Zt as withHiddenWindowsConsole,mi as withSpan,pi as withSpanSync,Yr as writeBundleDecision,_e as writeMarkdownlintRule,Xn as writeRootGitignoreForNewRepo,Tn as writeSkillManagement,Mn as writeStateManifest,rt as writeTargetVersion,je as writeTracker};
|
|
1
|
+
import{C as e,Da as t,La as n,Ta as r,Ya as i,d as a,da as o,l as s,la as c,ua as l,y as u}from"./src-IQdx1yfl.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,Ir as ie,It as ae,J as oe,Ji as se,Jn as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kt as pe,L as me,Li as he,Ln as ge,Lr as _e,Lt as ve,M as ye,Mi as be,Mn as xe,Mr as Se,Mt as Ce,N as we,Ni as Te,Nn as Ee,Nr as De,Nt as Oe,O as ke,Oi as Ae,On as je,Or as Me,Ot as Ne,P as Pe,Pi as Fe,Pn as Ie,Pr as Le,Pt as Re,Q as ze,Qi as Be,Qn as Ve,Qr as He,Qt as Ue,R as We,Ri as Ge,Rn as Ke,Rr as qe,Rt as Je,S as Ye,Si as Xe,Sn as Ze,Sr as Qe,St as $e,T as et,Ti as tt,Tn as nt,Tr as rt,Tt as it,U as at,Ui as ot,Un as st,Ur as ct,Ut as lt,V as ut,Vi as dt,Vn as ft,Vr as pt,Vt as mt,W as ht,Wi as gt,Wn as _t,Wr as vt,Wt as yt,X as bt,Xi as xt,Xn as St,Xr as Ct,Xt as wt,Y as Tt,Yi as Et,Yn as Dt,Yt as Ot,Z as kt,Zi as At,Zn as jt,Zr as Mt,Zt as Nt,_ as Pt,_i as Ft,_n as It,_r as Lt,a as Rt,aa as zt,ai as Bt,an as Vt,ar as Ht,at as Ut,b as Wt,bi as Gt,bn as Kt,br as qt,bt as Jt,c as Yt,ca as Xt,ci as Zt,cn as Qt,cr as $t,ct as en,d as tn,da as nn,di as rn,dn as an,dr as on,dt as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fi as mn,fn as hn,fr as gn,ft as _n,g as vn,gi as yn,gn as bn,gr as xn,h as Sn,hi as Cn,hn as wn,hr as Tn,i as En,ia as Dn,ii as On,in as kn,ir as An,it as jn,j as Mn,ji as Nn,jn as Pn,jr as Fn,jt as In,k as Ln,ki as Rn,kn as zn,kr as Bn,kt as Vn,l as Hn,la as Un,li as Wn,ln as Gn,lr as Kn,lt as qn,m as Jn,mi as Yn,mn as Xn,mr as Zn,n as Qn,na as $n,ni as er,nn as tr,nr,nt as rr,o as ir,oa as ar,oi as or,on as sr,or as cr,ot as lr,p as ur,pi as dr,pn as fr,pr,q as mr,qi as hr,qn as gr,qt as _r,r as vr,ra as yr,ri as br,rn as xr,rr as Sr,rt as Cr,s as wr,sa as Tr,si as Er,sn as Dr,sr as Or,st as kr,t as Ar,ta as jr,ti as Mr,tn as Nr,tr as Pr,tt as Fr,u as Ir,ua as Lr,ui as Rr,un as zr,ur as Br,ut as Vr,v as Hr,vi as Ur,vn as Wr,vr as Gr,w as Kr,wi as qr,wn as Jr,wr as Yr,wt as Xr,x as Zr,xi as Qr,xn as $r,xr as ei,xt as ti,y as ni,yi as ri,yn as ii,yr as ai,yt as oi,z as si,zi as ci,zn as li,zr as ui,zt as di}from"./src-7LOBasfG.mjs";import{C as fi,E as pi,T as mi,_ as hi,b as gi,c as _i,d as vi,g as yi,i as bi,l as xi,m as Si,n as Ci,p as wi,s as Ti,t as Ei,u as Di,v as Oi,w as ki,x as Ai,y as ji}from"./fs-traced-PoaSX4-V.mjs";import{a as Mi,d as Ni,f as Pi,i as Fi,l as Ii,n as Li,r as Ri,t as zi,u as Bi}from"./logger-B7Z8XO-z.mjs";import{_ as Vi,a as Hi,b as Ui,c as Wi,f as Gi,g as Ki,h as qi,i as Ji,l as Yi,m as Xi,n as Zi,o as Qi,p as $i,r as ea,s as ta,t as na,u as ra,v as ia,y as aa}from"./server-lock-DWsOY8Sf.mjs";export{$n as AGENT_ID_MAX_LEN,yr as AGENT_ID_RE,ne as AGENT_WRITE_ORIGIN,Un as AcpPermissionStore,ar as AcpRegistry,Te as AcpThreadManager,Nn as AgentFocusBroadcaster,_ as AgentPresenceBroadcaster,he as AgentSessionCapacityError,Ge as AgentSessionManager,Jt as AutoStartDisabledError,Fn as BUNDLE_IDS,Se as BUNDLE_SCOPE,De as BUNDLE_SKILL_NAME,jt as BacklinkIndex,q as CC1Broadcaster,t as CC1_CONTRACT_VERSION,Dr as CONFIG_FILENAME,fe as CONFLICT_MARKER_RE,ln as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Pt as ConfigSchema,Pn as DEFAULT_CHECKPOINT_RETENTION,Cn as DEFAULT_EMBEDDINGS_DIMENSIONS,Je as DEFAULT_PACK_ID,K as DocumentDurabilityState,yn as EMBEDDINGS_API_KEY_ENV,Tr as FEATURED_AGENT_IDS,xe as FILE_SYSTEM_WRITER,St as FILE_WATCHER_ORIGIN,Rr as FileEmbeddingsBackend,tr as GIT_PREFLIGHT_FAIL_SPAN_NAME,Ee as GIT_UPSTREAM_WRITER,Lr as GitDirAccessError,An as GitNotAvailableError,Ht as GitTooOldError,ti as HOCUSPOCUS_AUTH_REJECTION_REASONS,$e as HocuspocusAuthRejection,A as HocuspocusAuthTokenSchema,or as INSTALLED_AGENTS_SCHEMES,r as LINEAGE_EPOCH_KEY,X as LIVE_DERIVED_INDEX_DEBOUNCE_MS,di as LOG_MD_TEMPLATE,Vn as MANAGED_RENAME_ORIGIN,Fe as MAX_ACP_THREADS,ci as MAX_AGENT_SESSIONS,sn as MCP_CONNECTION_ID_HEADER,c as MCP_SERVER_NAME,S as MIN_EVICTABLE_IDLE_MS,cr as MIN_GIT_VERSION,ue as MISSING_OK_CONFIG_MESSAGE,nn as MalformedGitPointerError,Cr as McpLogger,mr as MissingOkConfigError,V as OBSERVER_SYNC_ORIGIN,Qt as OK_OKIGNORE_TEMPLATE,l as ORPHAN_MODES,i as PROTOCOL_VERSION,zi as PinoLogger,Wi as ProcessLockCollisionError,Hn as ProjectGitInitError,b as ROLLBACK_ORIGIN,Gn as ROOT_GITIGNORE_TEMPLATE,Ki as RUNTIME_VERSION,Ie as SERVICE_WRITER,z as SKILL_INSTALL_EVENTS_FILE_REL,u as SKILL_STATE_TARGETS,T as STARTER_FOLDERS,mt as STARTER_FOLDER_FRONTMATTER_FILENAME,ee as STARTER_PACKS,lt as STARTER_PACK_IDS,yt as STARTER_TEMPLATES,I as STATE_MANIFEST_FILENAME,Vi as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,wt as SeedPrerequisiteError,Nt as SeedRootDirError,na as ServerLockCollisionError,Ar as SingleFileNotAFileError,Qn as SingleFileNotFoundError,vr as SingleFileNotMarkdownError,j as StateManifestError,et as TagIndex,Le as USER_GLOBAL_BUNDLE_IDS,p as UiLockCollisionError,In as __getShowAllWalkStatsForTesting,Ce as __resetShowAllWalkStatsForTesting,Yi as acquireProcessLock,Zi as acquireServerLock,dn as acquireUiLock,dt as applyAgentMarkdownWrite,zn as applyExternalChange,ve as applySeed,ke as assertCompatibleStateManifest,Or as assertGitAvailable,It as assertNeverDiskEvent,be as attachAcpThreadSocket,oi as attachIdleShutdown,Hr as bootServer,xn as buildAndOpenSkill,zr as buildConfigYmlContent,ze as buildExecResult,H as buildOkMcpStdioCommand,Me as buildSkillZip,Y as buildStarterFolderFrontmatterYaml,U as buildWipTree,W as bundleSkillMdPath,Wr as classifyEvents,Ei as classifyFsPath,Ft as clearContributors,rn as clearEmbeddingsKeyFromAllBackends,pe as coercePackId,s as colorFromSeed,re as commitUpstreamImport,ge as commitWip,Ke as commitWipFromTree,$t as compareSemver,qe as composeEffectiveLinterConfig,gr as containsConflictMarkers,ii as contentHash,Ur as contributorCount,We as countShadowObjects,si as countStaleAgentWipRefs,x as countWipRefs,Oe as createApiExtension,M as createAssetServeMiddleware,Ct as createContentFilter,Mt as createContentFilterAsync,mn as createEmbeddingsSecretStore,En as createEphemeralProjectDir,v as createExternalChangeHandler,pn as createFileLogger,at as createLiveDerivedIndexExtension,bt as createMcpHttpHandler,Er as createOsProbe,Pe as createPersistenceExtension,E as createServer,ye as createServerObserverExtension,Z as createStreamingErrorWriter,Li as createTestLogger,dr as describeStoredEmbeddingsKey,vn as detectClaudeDesktopPresence,Kn as detectGit,Ln as detectProjectShape,lr as discoverLockDirs,pt as discoverMarkdownlintConfig,xr as emitPreflightFailureSpan,d as encodeDocName,fn as encodeFolderRoute,Fr as encodeSkillRoute,Ir as ensureProjectGit,an as ensureProjectSkillGitignore,ot as errorResponse,Kt as evictStaleTrackerEntries,kr as extractOkBinaryPath,Ve as extractWikiLinksFromMarkdown,Br as fallbackPaths,tn as findEnclosingGitRoot,wn as findEnclosingProjectRoot,$ as findNativeMarkdownlintFile,ur as flushFileLogger,Xr as formatAuthRejectionWire,ri as formatContributors,Gt as formatContributorsFrom,G as formatPackRationale,li as gcCheckpointRefs,jn as getCurrentMcpLogger,qr as getLocalDir,Jn as getLogFilePath,Ri as getLogger,Sn as getLogsDir,Ui as getMachineId,ji as getMeter,At as getMetrics,gi as getTracer,Be as handleCollabSocketError,Mr as handleSpawnCursor,ut as hasGcLogLatch,a as iconFromClientName,f as incrementCollabSocketFilteredError,cn as incrementServerObserverFire,hn as initContent,C as initShadowRepo,Ai as initTelemetry,Wt as initToleranceTelemetryWriter,Vr as installPrettyZodErrors,Fi as installTestLoggers,Lt as installUserSkill,Rn as isAllowedApiOrigin,Ue as isAllowedWorkspaceHostHeader,de as isConfigDoc,it as isHocuspocusAuthRejectionReason,_r as isKnownPackId,hr as isLinkIndexExcludedDoc,h as isLoopbackAddress,se as isManagedArtifactDoc,o as isOrphanMode,te as isPairedWriteOrigin,er as isPathWithinDir,ia as isProcessAlive,bn as isProjectRoot,gn as isProjectSkillManaged,Et as isReservedForUserTree,$r as isSelfWrite,xt as isSystemDoc,Zr as isToleranceTelemetryEnabled,aa as isValidLockPid,Ze as lastKnownHash,ft as listRescueCheckpoints,le as listStarterPacks,Xt as loadCustomAgents,we as loadPrincipal,ra as lockFilePath,Mi as loggerFactory,Ii as logsCurrentPath,Bi as logsPreviousPath,Yn as makeLazyEmbeddingsKeyStore,ea as markServerLockDraining,oe as mountMcpAndApi,Ci as normalizeFsPath,ie as originGitHubHost,fr as packageVersionMajorMinor,B as parseAuthRejectionWire,on as parseGitVersion,F as parseHocuspocusAuthToken,Tt as parseKeepaliveConnectionId,O as pathToDocName,ae as planSeed,Rt as prepareSingleFileOpen,en as processCommand,qn as processUsage,Gr as readAllTargets,ai as readBundleDecision,ct as readOwnNativeRules,Gi as readProcessLock,$i as readProcessLockDetailed,ht as readProjectHeadState,Wn as readProjectLocalSemanticConfig,Ji as readServerLock,qt as readServerPackageVersion,ei as readSkillInstallStateSnapshot,pr as readSkillManagement,g as readStateManifest,Qe as readTargetRecordedAt,k as readTargetVersion,Pr as readUiLock,ce as reconcile,Qr as recordContributor,P as recordSkillInstallEvent,kt as registerAllTools,Jr as registerWrite,Xi as releaseProcessLock,Hi as releaseServerLock,nr as releaseUiLock,nt as removeLastKnownHash,jr as resetMetrics,e as resolveBundleEnabled,Bn as resolveBundledSkillDir,tt as resolveContentDir,br as resolveCursorBinaryDefault,On as resolveCursorSpawnInvocation,ui as resolveEffectiveLinterConfig,L as resolveLockDir,w as resolveNativeConfigForDoc,vt as resolveNativeMarkdownlintConfig,Ot as resolvePack,wr as resolvePackageVersion,rr as resolveUiInfo,Xe as restoreContributors,ni as restoreLifecycleFromConflictsJson,He as rewriteMarkdownLinksForDocumentRename,m as rewriteWikiLinksForDocumentRename,kn as runAuthReposSubprocess,Vt as runAuthStatusSubprocess,un as runCloneSubprocess,sr as runDeviceFlowSubprocess,Ut as runWithMcpLogger,Ae as safeContentPath,Re as safeSubdir,Q as safetyCheckpoint,_n as sanitizeClientName,st as saveInMemoryCheckpoint,_t as saveVersion,Ne as seedBasenameIndex,ir as serializeError,fi as setActiveSpanAttributes,me as setupServerObservers,J as shadowGit,ki as shutdownTelemetry,Zn as skillManagementPath,Ni as spansCurrentPath,Pi as spansPreviousPath,Bt as spawnDetached,Dt as splitMarkdownBlocks,R as startWatcher,gt as streamingProblemEvent,D as swapContributors,Ye as teardownToleranceTelemetryWriter,Dn as toBroadcasterKey,bi as tracedAppendFileSync,Ti as tracedLinkSync,_i as tracedMkdir,xi as tracedMkdirSync,Di as tracedRename,vi as tracedRenameSync,wi as tracedRmSync,Si as tracedRmdirSync,yi as tracedUnlinkSync,hi as tracedWriteFile,Oi as tracedWriteFileSync,Kr as trustSystemCertificates,Yt as untrackTrackedProjectSkillProjection,N as updateLastKnownHash,qi as updateProcessLockPort,Qi as updateServerLockPort,Sr as updateUiLockPort,zt as validateAgentId,Nr as validateCloneInputs,y as validateSkillZip,ta as waitForServerLockDrain,Zt as withHiddenWindowsConsole,mi as withSpan,pi as withSpanSync,Yr as writeBundleDecision,_e as writeMarkdownlintRule,Xn as writeRootGitignoreForNewRepo,Tn as writeSkillManagement,Mn as writeStateManifest,rt as writeTargetVersion,je as writeTracker};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ma as r}from"./src-IQdx1yfl.mjs";import{Ei as i,ci as a,ct as o,ha as s,hn as c,lt as l,ot as u,st as d}from"./src-
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ma as r}from"./src-IQdx1yfl.mjs";import{Ei as i,ci as a,ct as o,ha as s,hn as c,lt as l,ot as u,st as d}from"./src-7LOBasfG.mjs";import{G as f}from"./sleep-CnRgOMGV.mjs";import{O as p,P as m}from"./fs-traced-PoaSX4-V.mjs";import{b as h,u as g,v as _,y as v}from"./server-lock-DWsOY8Sf.mjs";import{t as y}from"./yazl-BafwB467.mjs";import{_ as b,g as x,i as S,l as C,x as w}from"./write-project-skill-Cm0CAVv2.mjs";import{c as T}from"./colors-BsmVIwfM.mjs";import"./acp-harness-probe-DR1ZKGnH.mjs";import{D as ee,E,S as D,T as O,_ as te,b as ne,o as k,v as A}from"./init-CRqHukN0.mjs";import{n as re}from"./constants-BJzJKgN0.mjs";import{t as j}from"./is-object-ByG7RnjH.mjs";import"./loader-B2FwNLO-.mjs";import"./preview-2zt9BjS6.mjs";import{execSync as ie,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,isAbsolute as ae,join as F,relative as oe,resolve as I,sep as se}from"node:path";import{cpSync as ce,createWriteStream as le,existsSync as L,lstatSync as ue,mkdirSync as R,mkdtempSync as de,readFileSync as z,readdirSync as B,readlinkSync as fe,rmSync as V,statSync as pe,writeFileSync as H}from"node:fs";import{arch as me,freemem as he,homedir as ge,hostname as _e,platform as ve,release as ye,tmpdir as be,totalmem as xe,type as Se,uptime as Ce}from"node:os";import{realpath as U}from"node:fs/promises";import{createHash as W}from"node:crypto";var G=f();const we=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Te(e,t,n=c){if(e!==void 0&&!we.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ee=null;function De(e){Ee=e}function Oe(){return Ee??process.cwd()}const ke=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`}],Ae=ke.map(e=>e.name);function je(e){let t=new Set,n=0;return{redacted:e.split(`
|
|
2
2
|
`).map(e=>{let r=e;for(let{name:e,regex:i,replacement:a}of ke)i.lastIndex=0,i.test(r)&&(t.add(e),n++,i.lastIndex=0,r=r.replace(i,a));return r}).join(`
|
|
3
3
|
`),patterns:[...t],lineCount:n}}function Me(){return F(ge(),`.ok`,`bug-reports`)}function Ne(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`);return F(Me(),`${t}-bugreport.zip`)}function Pe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return L(F(e,`.ok`))?W(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Fe(){let e={timestamp:new Date().toISOString(),platform:ve(),osType:Se(),osRelease:ye(),hostname:`[redacted]`,uptime:Ce(),freeMem:he(),totalMem:xe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,a({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}function Ie(e,t){if(!L(t))return{files:[]};let n=B(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(e&&n.length>0){let t=n.filter(t=>{try{return z(t,`utf8`).includes(`"project":"${e}"`)}catch{return!0}});t.length>0&&(n=t)}return{files:n}}function Le(e){let n=F(e,`.ok`,`local`);return L(n)?{files:[`server.lock`,`last-spawn-error.log`,t].map(e=>F(n,e)).filter(e=>L(e))}:{files:[]}}function Re(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function ze(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=je(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Be(e){for(let t of e.files)try{ze({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Ve(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??F(ge(),`.ok`,`logs`),o=t.projectDir?Pe(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Fe();s.desktop=t.desktop??null;let{files:c}=Ie(o,a),{files:l}=t.projectDir?Le(t.projectDir):{files:[]},{files:u}=t.projectDir?Re(t.projectDir):{files:[]};i?.info({logFileCount:c.length,lockFileCount:l.length,localSinkFileCount:u.length},`files collected`);let d=[],f=[],{ZipFile:p}=await import(`./yazl-vwTkB7U0.mjs`).then(t=>e(t.default,1)),m=new p;Be({zipfile:m,files:c,prefix:`logs`,redact:n,bundleFiles:f,redactions:d,logger:i}),Be({zipfile:m,files:l,prefix:`lockdir`,redact:n,bundleFiles:f,redactions:d,logger:i}),Be({zipfile:m,files:u,prefix:`local-logs`,redact:n,bundleFiles:f,redactions:d,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;m.addBuffer(t,n),f.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ze({zipfile:m,name:`note.txt`,content:t.note,redact:n,bundleFiles:f,redactions:d});let h=JSON.stringify(s,null,2);m.addBuffer(Buffer.from(h,`utf8`),`sysinfo.json`),f.push(`sysinfo.json`);let g={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:f,redactions:d,sysinfo:s};m.addBuffer(Buffer.from(JSON.stringify(g,null,2),`utf8`),`MANIFEST.json`);let _=d.reduce((e,t)=>e+t.lineCount,0),v=[`# Bug Report Bundle`,``,`Generated: ${g.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${g.disciplineVersion}`,``,`## Contents`,``,...f.map(e=>`- ${e}`),``,`## Privacy`,``,...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Ae.join(`, `)}`,_>0?`${_} line(s) were scrubbed across ${d.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
|
|
4
4
|
`);m.addBuffer(Buffer.from(v,`utf8`),`README.md`),m.end();let y=le(r);return m.outputStream.pipe(y),await new Promise((e,t)=>{y.on(`close`,e),y.on(`error`,t)}),i?.info({bundlePath:r,fileCount:f.length,redactionCount:_},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:f,redactions:d,redactedLineCount:_,generatedAt:g.generatedAt}}}var He=e(y(),1),K=e(T(),1);const Ue=new Set([`doc.name`,`currentDoc`]);function We(e){return`doc:${W(`sha256`).update(e).digest(`hex`).slice(0,8)}`}function Ge(e,t,n){let r=e.docNameMap[n];if(r===void 0){e.docNameMap[n]=t;return}if(r===t)return;let i=e.docNameCollisions[n];i?i.includes(t)||i.push(t):e.docNameCollisions[n]=[t]}function Ke(e,t){let n=t.originalToHashed.get(e);if(n!==void 0)return n;let r=We(e);return t.originalToHashed.set(e,r),Ge(t,e,r),r}function qe(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return qe(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Je(e))return e;let n=typeof e.key==`string`&&Ue.has(e.key)&&Je(e.value)&&typeof e.value.stringValue==`string`?e.value.stringValue:null,r={};for(let[i,a]of Object.entries(e))if(n!==null&&i===`value`&&Je(a)){let e=Ke(n,t);r[i]={...a,stringValue:e}}else Ue.has(i)&&typeof a==`string`?r[i]=Ke(a,t):r[i]=q(a,t);return r}function Ye(e,t){if(t.originalToHashed.size===0)return e;let n=Array.from(t.originalToHashed.entries()).sort(([e],[t])=>t.length-e.length),r=e;for(let[e,t]of n)e.length!==0&&r.includes(e)&&(r=r.split(e).join(t));return r}function Xe(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
@@ -19,4 +19,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{F as t,I as n,ma as r}from"./src
|
|
|
19
19
|
`).replace(/\n/g,`\r
|
|
20
20
|
`));let u=`${i?``:``}${l}`;return u!==r&&m(e,u,{mode:O(e)}),{kind:`removed`}}function sn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function cn(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 ln(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:d(r),command:r,isDesktop:sn(r)}}function un(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&un(e)?`ui-orphan`:`stale`}const dn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function pn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function mn(e){return`${pn(e.server.usage)} | ${pn(e.ui?.usage??null)}`}function hn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function gn(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=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,hn(e),mn(e),t,String(n),cn(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=fn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
21
21
|
`)}async function _n(e={}){let t=e.discover??u,n=e.inspect??Z,r=e.log??(e=>console.log(e)),i=e.resolveCommand??o,a=e.resolveUsage??l,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=ln(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&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(gn(e.all?c:c.filter(e=>dn.has(Q(e)))))}function vn(){return new w(`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 _n({all:t.all===!0||e===`all`,json:t.json===!0})})}function yn(e,t,n={}){let r=n.isAlive??_,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function bn(e){let t=e.inspect??(t=>Z(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=yn(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 $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function xn(e,t=_){let n=await u(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Sn(e){let t=bn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Cn(e){return new w(`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=bn({lockDir:i(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 _n({});return}if(n===`all`){let e=await u();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=Z(n,`server`),r=Z(n,`ui`);!$(e,_)&&!$(r,_)||(Sn(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 xn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Sn(t);return}Sn(i(I(Oe(),n)))})}function wn(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Tn(e,t){let n,i;try{n=await U(I(e)),i=await U(I(P(e)))}catch{return{kind:`not-git`}}if(!En(n,i))return{kind:`symlink-escape`};let a=F(n,`.git`),o;try{o=pe(a)}catch{return{kind:`not-git`}}if(o.isDirectory()){let e;try{e=await U(a)}catch{return{kind:`not-git`}}if(!En(e,n))return{kind:`symlink-escape`}}else if(!o.isFile())return{kind:`not-git`};let c=s(n);if(c.kind!==`repository`)return{kind:`not-git`};let l=c.repository.readRemoteUrl(`origin`);if(l.kind===`unreadable`)return{kind:`not-git`};if(l.kind===`absent`)return l.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let u=l.url,d=Ht(u);if(d===null)return{kind:`non-github`};let f=r(d.hostname);if(f===null)return{kind:`non-github`};let p=f===t.host.toLowerCase(),m=d.owner.toLowerCase()===t.owner.toLowerCase(),h=d.name.toLowerCase()===t.repo.toLowerCase();return!p&&m&&h?{kind:`wrong-host`,actualHost:f}:!p||!m||!h?{kind:`wrong-repo`,actualOwner:d.owner,actualRepo:d.name}:{kind:`ok`,gitRemoteUrl:`https://${f}/${d.owner}/${d.name}.git`}}function En(e,t){if(e===t)return!0;let n=oe(t,e);return n.length>0&&!n.startsWith(`..`)&&!ae(n)}const Dn=[{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=A(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`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{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 r=S(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function On(e,t,n={},r=Dn){let i=[];for(let a of t){let t=C[a];for(let a of r)i.push(a.write(t,e,n))}return i}function kn(e,t,n={}){return{integrations:On(e,t,n)}}export{Ne as C,Te as D,De as E,Lt as S,Oe as T,Wt as _,Cn as a,Bt as b,Kt as c,$t as d,Yt as f,Gt as g,Ut as h,bn as i,Jt as l,Qt as m,Tn as n,vn as o,Zt as p,wn as r,nn as s,kn as t,qt as u,Ht as v,je as w,It as x,Z as y};
|
|
22
|
-
//# sourceMappingURL=src-
|
|
22
|
+
//# sourceMappingURL=src-Dj-HA_-C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,f as t,r as n}from"./start-CcMTV_IU.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{L as e,P as t}from"./src-IQdx1yfl.mjs";import{a as n,ci as r,gn as i,mi as a}from"./src-DVrFd0vk.mjs";import{S as o,x as s}from"./write-project-skill-SrjlunKm.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-CI5eMrtp.mjs";import{n as d}from"./constants-CkXW_O1Z.mjs";import{spawn as f}from"node:child_process";import{basename as p,dirname as m,join as h,win32 as g}from"node:path";import{closeSync as _,existsSync as v,mkdirSync as y,openSync as b,statSync as x}from"node:fs";import{homedir as S}from"node:os";import{rm as C}from"node:fs/promises";import{setTimeout as w}from"node:timers/promises";function T(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function E(e,t,n={}){let i=(n.spawn??f)(e,[...t],r({detached:!0,stdio:`ignore`,env:T(n.env??process.env)}));return i.unref(),i}const D=`OpenKnowledge.app`,O=`/Applications/${D}`;function k(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return x(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function A(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(j(e,O))return O;let t=h(e.homeDir??S(),`Applications`,D);return j(e,t)?t:null}function j(e,t){return M(e,h(t,`Contents`,`MacOS`,`OpenKnowledge`))}function M(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const N=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of N){let r=g.join(t,`Programs`,n,`OpenKnowledge.exe`);if(M(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return M(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?A(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){E(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}E(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h(m(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const B=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ee(e){if(e.platform!==`darwin`||!B.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function V(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??v,a=r[1];return a?{command:ee({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function te(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var U=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function W(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function G(t){v(t.lockDir)||y(t.lockDir,{recursive:!0});let n=b(h(t.lockDir,e),`w`),r=t.spawn??f,{PORT:i,...a}=process.env,o=V();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{_(n)}catch{}}}function K(e,t,n){return e??(n===void 0?t:void 0)}function q(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function J(e,t,n){return e??+(t!=null&&!n)}async function Y(e){let t=e.spawn??f,n=V(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=J(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function X(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const ne=t;function Z(e,t,n=e=>C(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let t=e.sigtermGraceMs??ne,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>w(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function re(e){let{destroy:t,...n}=e;return async()=>{await $({...n,reason:`idle-shutdown`}),await t()}}async function ie(e){let{config:t,cwd:r,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-DQTDRmqk.mjs`),T=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??r,O=E?n(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!i(r))throw new U(r);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&T.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Bn1d1oSd.mjs`)).repairMcpConfigs)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-tt6Tjedd.mjs`)).repairLaunchJson)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-D7MJ6bSo.mjs`)).repairSkills)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,r);!E&&!p(j)&&(m(j,{recursive:!0}),T.info({contentDir:j},`Created content directory`));let M=null,N=null,P=async({lockDir:t})=>{if(M=W({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=G({lockDir:t,cwd:r,spawn:e.spawn,args:n}).pid??null,T.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&T.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},F=e.reactShellDistDir===void 0,I=c(),L=a();{let e=S(E?D:r),t=Date.now(),n=await C(e);n!==`no-drain`&&T.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let R=await _({config:t,contentDir:j,projectDir:E?D:r,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:l,tokenStore:I,embeddingsKeyStore:L,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:F,idleShutdownMs:f,skipAutoInit:!0,...F?{spawnUiSiblingFn:P}:{},idleShutdownHandler:t=>{let n=re({readUiLock:()=>b(R.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:T});return Q(E?Z(n,D):n,{log:T,exit:e.idleExit})},log:T,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let z=M,B=null;if(z.action===`skip`)B=z.port>0?z.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;B=await X({readUiLock:()=>b(R.lockDir),now:Date.now,sleep:e=>w(e),timeoutMs:t,pollIntervalMs:50}),B===null&&T.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:R.httpServer,destroy:R.destroy,lockDir:R.lockDir,contentDir:j,port:R.port,ready:R.ready,degraded:R.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:B}}function ae(e){if(e===`browser`||e===`app`)return e;throw new o(`--mode must be 'browser' or 'app'`)}function oe(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new o(`--ui-port must be a port number between 1 and 65535`);return t}function se(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function ce(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function le(e,t){let n=se(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=e;process.title=H(c);let u=te(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=K(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-DQTDRmqk.mjs`);if(q(m,e(t(c)))){await Y({cwd:c,uiPort:m});return}}let g;try{g=await ie({config:l,cwd:c,host:u,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof U&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-DQTDRmqk.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&ue(e,t)){await Y({cwd:c,uiPort:m});return}let n=de(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=ce(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(g.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-DQTDRmqk.mjs`);await $({readUiLock:()=>n(g.lockDir),spawnedUiPid:()=>g.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${u}:${g.port}`,b=u===`0.0.0.0`||u===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${u}:${x}`:y;console.log(r({name:`open-knowledge`,version:d,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-D3OpxES8.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function ue(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function de(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=h(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function fe(e){return new s(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,oe).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ae).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
1
|
+
import{L as e,P as t}from"./src-IQdx1yfl.mjs";import{a as n,ci as r,gn as i,mi as a}from"./src-7LOBasfG.mjs";import{S as o,x as s}from"./write-project-skill-Cm0CAVv2.mjs";import{a as c,n as l,t as u}from"./acp-harness-probe-DR1ZKGnH.mjs";import{n as d}from"./constants-BJzJKgN0.mjs";import{spawn as f}from"node:child_process";import{basename as p,dirname as m,join as h,win32 as g}from"node:path";import{closeSync as _,existsSync as v,mkdirSync as y,openSync as b,statSync as x}from"node:fs";import{homedir as S}from"node:os";import{rm as C}from"node:fs/promises";import{setTimeout as w}from"node:timers/promises";function T(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function E(e,t,n={}){let i=(n.spawn??f)(e,[...t],r({detached:!0,stdio:`ignore`,env:T(n.env??process.env)}));return i.unref(),i}const D=`OpenKnowledge.app`,O=`/Applications/${D}`;function k(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return x(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function A(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(j(e,O))return O;let t=h(e.homeDir??S(),`Applications`,D);return j(e,t)?t:null}function j(e,t){return M(e,h(t,`Contents`,`MacOS`,`OpenKnowledge`))}function M(e,t){try{let n=e.statSync(t);return n&&typeof n.isFile==`function`?n.isFile():!1}catch{return!1}}const N=[`@inkeepopen-knowledge-desktop`,`OpenKnowledge`];function P(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&/\\OpenKnowledge\.exe$/i.test(e.execPath))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of N){let r=g.join(t,`Programs`,n,`OpenKnowledge.exe`);if(M(e,r))return r}return null}function F(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&e.execPath.endsWith(`/openknowledge`))return e.execPath;let t=`/opt/OpenKnowledge/openknowledge`;return M(e,t)?t:null}function I(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?A(e):e.platform===`win32`?P(e):F(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function L(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),r===`darwin`){E(`open`,[`-b`,`com.inkeep.open-knowledge`],{spawn:e.spawn});return}let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}E(i,[],{spawn:e.spawn})}function R(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function z(e){return h(m(e),`..`,`Frameworks`,`OpenKnowledge Server.app`,`Contents`,`MacOS`,`OpenKnowledge Helper`)}const B=/\/[^/]+\.app\/Contents\/MacOS\/[^/]+$/;function ee(e){if(e.platform!==`darwin`||!B.test(e.execPath))return null;let t=z(e.execPath);return e.exists(t)?t:null}function V(e={}){let t=e.execPath??process.execPath,n=e.platform??process.platform,r=e.argv??process.argv,i=e.exists??v,a=r[1];return a?{command:ee({execPath:t,platform:n,exists:i})??t,prefixArgs:[a]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx -y @inkeep/open-knowledge@latest\`. This re-introduces the registry-fetch surface that re-exec was fixing. Observed argv: ${JSON.stringify(r)}`),{command:`npx`,prefixArgs:[`-y`,`@inkeep/open-knowledge@latest`]})}function te(e,t){return e.host??t.HOST??`127.0.0.1`}function H(e){let t=p(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var U=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function W(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function G(t){v(t.lockDir)||y(t.lockDir,{recursive:!0});let n=b(h(t.lockDir,e),`w`),r=t.spawn??f,{PORT:i,...a}=process.env,o=V();try{let e=r(o.command,[...o.prefixArgs,...t.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,n],windowsHide:!0,cwd:t.cwd,env:{...a,ELECTRON_RUN_AS_NODE:`1`}});return e.unref(),e}finally{try{_(n)}catch{}}}function K(e,t,n){return e??(n===void 0?t:void 0)}function q(e,t){return e!==void 0&&t!==null&&t.port>0&&t.draining!==!0}function J(e,t,n){return e??+(t!=null&&!n)}async function Y(e){let t=e.spawn??f,n=V(),{PORT:r,...i}=process.env,a=t(n.command,[...n.prefixArgs,`ui`,`--port`,String(e.uiPort)],{cwd:e.cwd,stdio:`inherit`,windowsHide:!0,env:{...i,ELECTRON_RUN_AS_NODE:`1`}}),o=!1,s=e=>{o=!0;try{a.kill(e)}catch{}},c=()=>s(`SIGINT`),l=()=>s(`SIGTERM`);process.once(`SIGINT`,c),process.once(`SIGTERM`,l),await new Promise(e=>{a.on(`exit`,(t,n)=>{process.exitCode=J(t,n,o),e()}),a.on(`error`,t=>{console.error(`[start] connect fallback: failed to spawn ok ui — ${t instanceof Error?t.message:String(t)}`),process.exitCode=1,e()})}),process.removeListener(`SIGINT`,c),process.removeListener(`SIGTERM`,l)}async function X(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}const ne=t;function Z(e,t,n=e=>C(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function $(e){let t=e.sigtermGraceMs??ne,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>w(e)),i=e.reason??`teardown`;try{let a=e.readUiLock(),o=e.spawnedUiPid();if(a&&e.isAlive(a.pid)&&a.pid!==o)e.log?.info({pid:a.pid,port:a.port,spawnedUiPid:o},`${i}: ui.lock holder is not our spawned sibling — leaving it alone`);else if(a&&e.isAlive(a.pid))try{e.killPid(a.pid,`SIGTERM`),e.log?.info({pid:a.pid,port:a.port},`${i}: SIGTERM UI sibling`);let o=Date.now()+t;for(;Date.now()<o&&e.isAlive(a.pid);)await r(n);if(e.isAlive(a.pid))try{e.killPid(a.pid,`SIGKILL`),e.log?.warn({pid:a.pid,graceMs:t},`${i}: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:a.pid,err:t},`${i}: SIGKILL failed`)}}catch(t){e.log?.warn({pid:a.pid,err:t},`${i}: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t},`${i}: UI lookup failed; proceeding`)}}function re(e){let{destroy:t,...n}=e;return async()=>{await $({...n,reason:`idle-shutdown`}),await t()}}async function ie(e){let{config:t,cwd:r,host:o}=e,s=e.skipAutoInit??!1,d=e.skipUiAutoSpawn??!1,f=e.idleThresholdMs??18e5,{existsSync:p,mkdirSync:m}=await import(`node:fs`),{basename:h,dirname:g}=await import(`node:path`),{bootServer:_,getLogger:v,isProcessAlive:y,readUiLock:b,resolveContentDir:x,resolveLockDir:S,waitForServerLockDrain:C}=await import(`./src-CgblAAT9.mjs`),T=e.log??v(`start`),E=e.singleFile!==void 0,D=e.projectDir??r,O=E?n(e.singleFile).canonicalFilePath:void 0,k=O?g(O):void 0,A=O?h(O):void 0;if(!E){if(!s&&!i(r))throw new U(r);let t=process.env.OK_RECLAIM_DISABLE??null,n=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&T.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-i7dMnghP.mjs`)).repairMcpConfigs)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-C3uqYkeS.mjs`)).repairLaunchJson)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-DJ7FOTZZ.mjs`)).repairSkills)({projectDir:r,reclaimDisableEnv:t,logger:n})}catch(e){T.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let j=k??x(t,r);!E&&!p(j)&&(m(j,{recursive:!0}),T.info({contentDir:j},`Created content directory`));let M=null,N=null,P=async({lockDir:t})=>{if(M=W({uiLock:b(t),isAlive:y}),M.action===`spawn`&&!d)try{let n=e.uiPort===void 0?void 0:[`ui`,`--port`,String(e.uiPort)];N=G({lockDir:t,cwd:r,spawn:e.spawn,args:n}).pid??null,T.info({reason:M.reason,uiPort:e.uiPort},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else M.action===`skip`&&T.info({port:M.port,pid:M.pid},`UI already running at port ${M.port}`)},F=e.reactShellDistDir===void 0,I=c(),L=a();{let e=S(E?D:r),t=Date.now(),n=await C(e);n!==`no-drain`&&T.info({event:`start-waited-for-draining-predecessor`,outcome:n,waitedMs:Date.now()-t,drainLockDir:e},n===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}let R=await _({config:t,contentDir:j,projectDir:E?D:r,contentRoot:E?void 0:t.content.dir,port:e.port,host:o,quiet:!1,detectGh:l,tokenStore:I,embeddingsKeyStore:L,...E?{ephemeral:!0,singleDocRelPath:A,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>u(e,t),attachUiSibling:F,idleShutdownMs:f,skipAutoInit:!0,...F?{spawnUiSiblingFn:P}:{},idleShutdownHandler:t=>{let n=re({readUiLock:()=>b(R.lockDir),spawnedUiPid:()=>N,isAlive:y,killPid:(e,t)=>{process.kill(e,t)},destroy:t,log:T});return Q(E?Z(n,D):n,{log:T,exit:e.idleExit})},log:T,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}});M||={action:`skip`,reason:`alive`,pid:0,port:0};let z=M,B=null;if(z.action===`skip`)B=z.port>0?z.port:null;else if(!d){let t=e.uiBindTimeoutMs??3e3;B=await X({readUiLock:()=>b(R.lockDir),now:Date.now,sleep:e=>w(e),timeoutMs:t,pollIntervalMs:50}),B===null&&T.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:R.httpServer,destroy:R.destroy,lockDir:R.lockDir,contentDir:j,port:R.port,ready:R.ready,degraded:R.degraded,uiSpawnDecision:M,spawnedUiPid:N,resolvedUiPort:B}}function ae(e){if(e===`browser`||e===`app`)return e;throw new o(`--mode must be 'browser' or 'app'`)}function oe(e){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<1||t>65535)throw new o(`--ui-port must be a port number between 1 and 65535`);return t}function se(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function ce(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function le(e,t){let n=se(process.env);n!==null&&(process.env.OK_CONSOLE_LEVEL=n);let{renderBanner:r}=await import(`./banner--DGfdMN8.mjs`),{accent:i,dim:a,error:o,warning:s}=await import(`./colors-MGDi6UGf.mjs`),c=process.cwd(),l=e;process.title=H(c);let u=te(t,process.env),f=t.port===void 0?void 0:Number(t.port),p=process.env.PORT?Number(process.env.PORT):void 0,m=t.uiPort===void 0?void 0:Number(t.uiPort),h=K(f,p,m);if(m!==void 0){let{readServerLock:e,resolveLockDir:t}=await import(`./src-CgblAAT9.mjs`);if(q(m,e(t(c)))){await Y({cwd:c,uiPort:m});return}}let g;try{g=await ie({config:l,cwd:c,host:u,port:h,...m===void 0?{}:{uiPort:m},...t.serveContentAssets===void 0?{}:{serveContentAssets:t.serveContentAssets},...t.reactShellDistDir?{reactShellDistDir:t.reactShellDistDir}:{},...t.singleFile?{singleFile:t.singleFile}:{},...t.projectDir?{projectDir:t.projectDir}:{}})}catch(e){e instanceof U&&(console.error(o(e.message)),process.exit(1));let t=await import(`./src-CgblAAT9.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(o(e.message)),process.exit(1)),m!==void 0&&ue(e,t)){await Y({cwd:c,uiPort:m});return}let n=de(e,c,t);n!==null&&(console.error(o(n)),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let _=!1,v=async e=>{if(_)return;_=!0;let[t,...n]=ce(e);console.log(i(`\n${t}`));for(let e of n)console.log(a(` ${e}`));if(g.spawnedUiPid!==null)try{let{getLogger:e,isProcessAlive:t,readUiLock:n}=await import(`./src-CgblAAT9.mjs`);await $({readUiLock:()=>n(g.lockDir),spawnedUiPid:()=>g.spawnedUiPid,isAlive:t,killPid:(e,t)=>process.kill(e,t),log:e(`start`),reason:`shutdown`})}catch(e){console.error(`${o(`ui sibling teardown failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`)}try{await g.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{v(`SIGINT`)}),process.once(`SIGTERM`,()=>{v(`SIGTERM`)});let y=`http://${u}:${g.port}`,b=u===`0.0.0.0`||u===`::`?`http://0.0.0.0:${g.port}`:void 0,x=g.resolvedUiPort,S=x!==null&&x>0?`http://${u}:${x}`:y;console.log(r({name:`open-knowledge`,version:d,localUrl:S,apiUrl:S===y?void 0:y,networkUrl:b,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let C={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};g.ready.then(async()=>{if(g.degraded.length>0){console.log();for(let e of g.degraded){let t=C[e]??`${e} (check server logs for details)`;console.warn(` ${s(`⚠`)} ${s(e)}: ${a(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-B_gopYWU.mjs`);e(S)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function ue(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function de(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=h(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`OpenKnowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function fe(e){return new s(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`--ui-port <port>`,`Pin the ok ui sibling to <port> and connect (not exit) if a server already runs here — the worktree-preview recipe path`,oe).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ae).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path> (suppresses ok ui sibling)`).option(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).option(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
|
|
2
2
|
`),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.uiPort!==void 0&&e.push(`--ui-port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=I(k());if(n.available){L({spawn:f},n);return}console.error(R(n.reason)),process.exit(1)}await le(n,t)})}export{k as C,E,V as S,L as T,fe as _,J as a,Z as b,H as c,K as d,te as f,G as g,q as h,re as i,ce as l,le as m,X as n,Y as o,se as p,ie as r,W as s,U as t,ue as u,$ as v,I as w,Q as x,de as y};
|
|
3
|
-
//# sourceMappingURL=start-
|
|
3
|
+
//# sourceMappingURL=start-CcMTV_IU.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{_a as r,ba as i,ga as a,la as o}from"./src-IQdx1yfl.mjs";import{Jr as s,Nr as c,Pr as l,kr as u}from"./src-
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{_a as r,ba as i,ga as a,la as o}from"./src-IQdx1yfl.mjs";import{Jr as s,Nr as c,Pr as l,kr as u}from"./src-7LOBasfG.mjs";import{basename as d,dirname as f,isAbsolute as p,join as m,posix as h,relative as g,resolve as _,sep as v,win32 as y}from"node:path";import{cpSync as ee,existsSync as b,lstatSync as te,mkdirSync as ne,readFileSync as re,realpathSync as x,rmSync as S,statSync as ie}from"node:fs";import{homedir as C}from"node:os";var w=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),T=n((e=>{let{InvalidArgumentError:t}=w();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),E=n((e=>{let{humanReadableArgName:t}=T();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
2
2
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
3
3
|
`+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
|
|
4
4
|
`)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),D=n((e=>{let{InvalidArgumentError:t}=w();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -53,4 +53,4 @@ foreach ($d in $dirs) {
|
|
|
53
53
|
}
|
|
54
54
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
55
55
|
exit 127`,F=`// ok-pi-bridge`,I=`${F}-v1`,ve=`ok-pi-managed-extension`;function ye(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(I)}return!1}function L(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=_(e);if(d(t)===`cli.mjs`&&d(f(t))===`dist`)return t;let n=t.split(v),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return m(i.length===0?v:i.join(v),`packages`,`cli`,`dist`,`cli.mjs`)}function R(e={}){return e.mode===`dev`?{command:j,args:[L(),`mcp`],env:{...M}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,P]}:{command:`/bin/sh`,args:[`-l`,`-c`,N]}}function be(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[j,L(),`mcp`],environment:{...M}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,P]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,N]}}function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;return z(t,R({mode:`published`,platformName:`darwin`}))||z(t,R({mode:`published`,platformName:`win32`}))}function z(e,t){return Object.keys(e).length===Object.keys(t).length?Se(e,t):!1}function Se(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function B(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function Ce(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:B(t.args,t.command)}function we(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&B(r,n)}function V(e){return e===`win32`?y:h}function Te(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=e.env??process.env,i=V(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function Ee(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.claude.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=e.env??process.env;if(t===`darwin`)return h.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??y.join(n,`AppData`,`Roaming`);return y.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.cursor`,`mcp.json`)}function De(e={}){let t=e.platformName??process.platform,n=e.home??C();return(e.env??process.env).CODEX_HOME??V(t).join(n,`.codex`)}function W(e={}){return V(e.platformName??process.platform).join(De(e),`config.toml`)}function G(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=(e.env??process.env).COPILOT_HOME??V(t).join(n,`.copilot`);return V(t).join(r,`mcp-config.json`)}function Oe(e={}){let t=e.platformName??process.platform,n=e.home??C(),r=e.env??process.env,i=V(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function K(e={}){return V(e.platformName??process.platform).join(Oe(e),`opencode.json`)}function ke(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.openclaw`,`openclaw.json`)}function Ae(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.hermes`,`config.yaml`)}function je(e={}){let t=e.platformName??process.platform,n=e.home??C();return(e.env??process.env).PI_CODING_AGENT_DIR??V(t).join(n,`.pi`,`agent`)}function Me(e={}){let t=e.platformName??process.platform,n=e.home??C();return V(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function Ne(e,t){let n=V(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function q(e={}){let t=e.platformName??process.platform,n=Ne(e.home??C(),t);return n.find(e=>b(e))||n.find(e=>b(f(e)))||n[0]}const J={claude:{id:`claude`,label:k.claude,configPath:(e,t)=>Ee({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>m(t??C(),`.claude`),projectConfigPath:e=>m(e,`.mcp.json`),projectSkillPath:e=>m(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:k[`claude-desktop`],configPath:(e,t)=>H({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>f(H({home:t}))},cursor:{id:`cursor`,label:k.cursor,configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>f(U({home:t})),projectConfigPath:e=>m(e,`.cursor`,`mcp.json`),projectSkillPath:e=>m(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:k.codex,configPath:(e,t)=>W({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>f(W({home:t})),projectConfigPath:e=>m(e,`.codex`,`config.toml`),projectSkillPath:e=>m(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:k.copilot,configPath:(e,t)=>G({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>f(G({home:t})),projectSkillPath:e=>m(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:k.opencode,configPath:(e,t)=>K({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>o,buildEntry:(e,t)=>be(t),scope:`global`,detectPath:(e,t)=>f(K({home:t})),projectConfigPath:e=>m(e,`opencode.json`),projectSkillPath:e=>m(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:k.openclaw,configPath:(e,t)=>ke({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>m(t??C(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:k.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>je({home:t}),projectConfigPath:e=>m(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>m(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:k.antigravity,configPath:(e,t)=>Me({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>m(t??C(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:k[`lm-studio`],configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>f(q({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:k.hermes,configPath:(e,t)=>Ae({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>o,buildEntry:(e,t)=>R(t),scope:`global`,detectPath:(e,t)=>m(t??C(),`.hermes`),offerOnlyWhenDetected:!0}};function Pe(e){let t=e.filter(e=>!Object.hasOwn(J,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${O.join(`, `)}`);return e.map(e=>J[e])}function Y(e){let t=[];for(let n of l){let r=c[n];t.push({path:m(e,`.agents`,`skills`,r),bundleId:n,scope:`central`});for(let i of A)t.push({path:m(e,i.hostDir,`skills`,r),bundleId:n,scope:`host`,hostDir:i.hostDir})}return t}function Fe(e,t){let n=[];for(let r of Y(e))if(r.bundleId===t)try{S(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function X(e,t){let n;try{n=te(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);Q(e,t)}function Z(e,t){Q(e,t)}function Q(e,t){let n;try{n=x(t)}catch{n=_(t)}let r=f(e);for(;r.length>1&&r!==v;){let t;try{t=x(r)}catch(e){if(e.code===`ENOENT`){r=f(r);continue}throw e}let i=g(n,t);if(i===``||!i.startsWith(`..`)&&!p(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ie(e,t,n){try{if(ie(n).size>10485760)return!1}catch{return!1}let r;try{r=re(n,`utf-8`)}catch{return!1}let i=[],a=s(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!$(a))return!1;let o=a[e.topLevelKey];if(!$(o))return!1;let c=e.serverMapSubKey?o[e.serverMapSubKey]:o;return $(c)?$(c[e.serverName(t)]):!1}function Le(e,t,n={}){if(e.id!==`copilot`)return!0;try{return Ie(e,t,e.configPath(t,n.home))}catch{return!1}}function Re(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Le(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=u(`project`,{checkDesktop:!0}),i=f(r);X(i,t);let a=b(r)?`overwritten`:`written`;return S(i,{recursive:!0,force:!0}),ne(f(i),{recursive:!0}),ee(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function ze(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=f(n);return b(n)?(Z(r,t),S(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{ge as C,fe as S,xe as _,Fe as a,Pe as b,k as c,F as d,I as f,ye as g,Ce as h,Re as i,J as l,R as m,Z as n,Y as o,ve as p,ze as r,O as s,X as t,A as u,we as v,me as x,Te as y};
|
|
56
|
-
//# sourceMappingURL=write-project-skill-
|
|
56
|
+
//# sourceMappingURL=write-project-skill-Cm0CAVv2.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.40.0-beta.
|
|
3
|
+
"version": "0.40.0-beta.2",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"ajv-formats": "^3.0.1",
|
|
62
62
|
"tsdown": "^0.21.7",
|
|
63
63
|
"typescript": "^5.9.3",
|
|
64
|
-
"@inkeep/open-knowledge-app": "0.40.0-beta.
|
|
65
|
-
"@inkeep/open-knowledge-core": "0.40.0-beta.
|
|
66
|
-
"@inkeep/open-knowledge-
|
|
67
|
-
"@inkeep/open-knowledge-
|
|
64
|
+
"@inkeep/open-knowledge-app": "0.40.0-beta.2",
|
|
65
|
+
"@inkeep/open-knowledge-core": "0.40.0-beta.2",
|
|
66
|
+
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
67
|
+
"@inkeep/open-knowledge-server": "0.40.0-beta.2"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build:cli": "tsdown",
|
package/dist/init-BG8F8jyV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./init-DqAj6DLP.mjs";export{e as runInit};
|
package/dist/loader-48vYo7np.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-CuzKavqN.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-DNAkJMSB.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./repair-skills-BVXDXZaA.mjs";export{e as repairSkills};
|
package/dist/start-3HnyNbf6.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,f as t,r as n}from"./start-BQRik_0l.mjs";export{n as bootStartServer,t as resolveHost,e as startCommand};
|