@inkeep/open-knowledge 0.87.2-beta.1 → 0.87.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES.md +1 -0
- package/dist/cli.mjs +75 -75
- package/dist/constants-CjsWLxV4.mjs +1 -0
- package/dist/dist-BB-NSwQc.mjs +2214 -0
- package/dist/dist-BKGJO_91.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-C34FkXTd.mjs → init-BBJX1tEw.mjs} +11 -11
- package/dist/init-C6SuzeQN.mjs +1 -0
- package/dist/{launch-json-removal-hdPm7JJ9.mjs → launch-json-removal-vNqkqnfB.mjs} +1 -1
- package/dist/loader-BJYhNl_Y.mjs +1 -0
- package/dist/{loader-CpVD-p7P.mjs → loader-abngpKg0.mjs} +1 -1
- package/dist/{open-browser-Cv1yuEQw.mjs → open-browser-DWKagh4v.mjs} +1 -1
- package/dist/preview-DhGoOOxK.mjs +1 -0
- package/dist/{preview-D1IEqXE0.mjs → preview-_9prk5GA.mjs} +1 -1
- package/dist/public/assets/{AccountSection-BKI8ful_.js → AccountSection-BCXD7SZC.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-Cs8zvxnL.js → ActivityModeContent-BiulaGM9.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CEOdUsGs.js → AddPropertiesButton-UiasLZDQ.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CzfUNzhW.js → AgentDiffPane-BxnJ3oTx.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-BAyVJFgf.js → AttachmentsSection-C5Sq9Rll.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BbOfR2Hg.js → CodeMirrorPropInput-CiKaTdcp.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-B6i1cLKg.js → ContentRulesSection-Dtu5BXHJ.js} +1 -1
- package/dist/public/assets/{DocumentContext-Ctu-HqT4.js → DocumentContext-CbdZO9O_.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-BxpOZKiM.js → EditorModeToggle-B_Y0Hud7.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CYiYdvF2.js → ExcalidrawDocEditor-DB2r-yaj.js} +1 -1
- package/dist/public/assets/FeedbackForm-DwdxS-5f.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-HOR9EZ2f.js → ImportSkillDialog-BZI83yK9.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-BQvvaJUI.js → LinkPreviewsSection-PSoIWcWo.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CWrXBDG_.js → LintConfigEditor-B4hXoSya.js} +1 -1
- package/dist/public/assets/{LintingSection-BiPYwYIO.js → LintingSection-Db_SW956.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-CadUWUsq.js → ManagedArtifactProperties-D9HOt10R.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-htmBqfrM.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-BxFPCx7g.js → MermaidDocEditor-CDOsMOCI.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-C_JY6CML.js → NetworkAccessSection-DmbCvoj2.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-CFACWxIE.js → PropertyDisplayRow-BEXJg0bS.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-Qg9R2-X0.js → PublishToGitHubDialog-CSObj1A1.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DEecND8S.js → SchemaConfigEditor-DYJLLjlf.js} +1 -1
- package/dist/public/assets/{SearchSection-C5h5t5Bm.js → SearchSection-DqJaDdzF.js} +1 -1
- package/dist/public/assets/{SessionsHost-DrGOAImZ.js → SessionsHost-DOlg6s6y.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-9HsCyl9q.js → SettingsDialogBody-B_JAITG9.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-N7vak44i.js → ShareReceiveMissDialog-CZRdcwHO.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-J3FRPp-3.js → SkillToolbarControls-ZJ66SSuc.js} +1 -1
- package/dist/public/assets/{SourceEditor-DijD2qin.js → SourceEditor-CU6R9E3V.js} +1 -1
- package/dist/public/assets/{SyncSection-TX1SH2IZ.js → SyncSection-Bo3LJcJU.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-i2xTrKQt.js → SyncStatusBadge-Dydd5r0z.js} +1 -1
- package/dist/public/assets/{TerminalSection-DIDjGimp.js → TerminalSection-DkzpJFCN.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-ZDSwFCcn.js → TerminalWindowApp-DLy_hfT4.js} +1 -1
- package/dist/public/assets/{TextDocEditor-BjdRabZO.js → TextDocEditor-i12Zi3JU.js} +1 -1
- package/dist/public/assets/{ThreadView-DJRjCobn.js → ThreadView-Cw5tBHCd.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-KJSvQLix.js → TimelineDiffPane-BV2A8IAW.js} +1 -1
- package/dist/public/assets/{client-version-CEUebx--.js → client-version-C0Jc4JJI.js} +1 -1
- package/dist/public/assets/{comment-chips-D8H8ksVb.js → comment-chips-Mc2Mv-pz.js} +1 -1
- package/dist/public/assets/{config-provider-QVZqDwsb.js → config-provider-CZy-mWdC.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CzYtyHUd.js → doc-undo-manager-1aQQtoK3.js} +1 -1
- package/dist/public/assets/{index-D2cACSaG.js → index-c--If4Yv.js} +7 -7
- package/dist/public/assets/{lint-plugins-CE1v_De9.js → lint-plugins-C_fUmRft.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-T3ZXK0s-.js → pending-receive-nav-store-Bb17fKS7.js} +1 -1
- package/dist/public/assets/{preferred-session-events-D2WKSTxQ.js → preferred-session-events-B2jU9Gzw.js} +1 -1
- package/dist/public/assets/{progress-CMZzr1ER.js → progress-CW3N-5hS.js} +1 -1
- package/dist/public/assets/{selection-context-DFEuubLf.js → selection-context-Dy-Fc0jG.js} +1 -1
- package/dist/public/assets/{src-C8wJZTqQ.js → src-Cep_PKNI.js} +1 -1
- package/dist/public/assets/{telemetry-impl-crprFKOe.js → telemetry-impl-CXoXg4ey.js} +1 -1
- package/dist/public/assets/{telemetry-startup-7Tdxo-4u.js → telemetry-startup-DZ2uqGCJ.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DdtI04xk.js → typing-burst-detector-Dw4u-apo.js} +1 -1
- package/dist/public/assets/{use-activity-panel-2Bs8Bhwk.js → use-activity-panel-CYP7NKHc.js} +1 -1
- package/dist/public/assets/{use-open-skill-B4p8VMLX.js → use-open-skill-D2nS0EB4.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DiTNDooB.js → use-terminal-enabled-C5444lCZ.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-JtbYOyhK.js → use-timeline-entry-diff-B6KJiK5_.js} +1 -1
- package/dist/public/index.html +19 -19
- package/dist/{registry-probes-BiySrvm_.mjs → registry-probes--ag3GT86.mjs} +3 -3
- package/dist/{removal-file-path-DUFtjkkZ.mjs → removal-file-path-Bfn04hQq.mjs} +1 -1
- package/dist/{repair-launch-json-B3uRu9qh.mjs → repair-launch-json-BLf3YgHr.mjs} +1 -1
- package/dist/{repair-mcp-configs-CYq7vfOM.mjs → repair-mcp-configs-D3Y1J0gf.mjs} +1 -1
- package/dist/src-C6N6mOpp.mjs +16 -0
- package/dist/src-Ds42jGaJ.mjs +1 -0
- package/dist/start-BEgiZxiL.mjs +1 -0
- package/dist/{start-CaZG06fC.mjs → start-C8uhecrD.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-DwtiG-TC.mjs +0 -1
- package/dist/dist-B_I6SNFI.mjs +0 -1
- package/dist/dist-WFhah2YJ.mjs +0 -2214
- package/dist/init-Dg1lyv-G.mjs +0 -1
- package/dist/loader-H2SukW6-.mjs +0 -1
- package/dist/preview-DDxcD2r1.mjs +0 -1
- package/dist/public/assets/FeedbackForm-BJ2Oe5Na.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CrGTWjB7.js +0 -1
- package/dist/src-CPB_oYOe.mjs +0 -16
- package/dist/src-Cee3yPhD.mjs +0 -1
- package/dist/start-D4vJF_D3.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Cc as e,Et as t,Ot as n,S as r,X as i,Za as a,ac as o,fc as s,v as c}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{$ as l,$a as u,$i as d,$n as f,$r as p,$t as m,A as h,Aa as g,Ai as _,An as v,Ao as y,Ar as b,As as x,At as S,B as C,Ba as w,Bi as T,Bn as E,Bo as D,Br as O,Bs as k,Bt as A,C as j,Ca as M,Ci as N,Cn as P,Co as F,Cr as I,Ct as L,D as R,Da as z,Di as B,Dn as V,Do as H,Dr as U,Dt as W,E as G,Ea as K,Ei as q,En as J,Eo as Y,Er as X,Et as Z,F as Q,Fa as $,Fi as ee,Fn as te,Fo as ne,Fr as re,Fs as ie,Ft as ae,G as oe,Ga as se,Gi as ce,Gn as le,Go as ue,Gr as de,Gt as fe,H as pe,Ha as me,Hi as he,Hn as ge,Ho as _e,Hr as ve,Hs as ye,Ht as be,I as xe,Ia as Se,Ii as Ce,In as we,Io as Te,Ir as Ee,Is as De,It as Oe,J as ke,Ja as Ae,Ji as je,Jn as Me,Jo as Ne,Jr as Pe,Jt as Fe,K as Ie,Ka as Le,Ki as Re,Kn as ze,Ko as Be,Kr as Ve,Kt as He,L as Ue,La as We,Li as Ge,Ln as Ke,Lo as qe,Lr as Je,Ls as Ye,Lt as Xe,M as Ze,Ma as Qe,Mi as $e,Mn as et,Mo as tt,Mr as nt,Ms as rt,Mt as it,N as at,Na as ot,Ni as st,Nn as ct,No as lt,Nr as ut,Ns as dt,Nt as ft,O as pt,Oa as mt,Oi as ht,On as gt,Oo as _t,Or as vt,Ot as yt,P as bt,Pa as xt,Pi as St,Pn as Ct,Po as wt,Pr as Tt,Ps as Et,Pt as Dt,Q as Ot,Qa as kt,Qi as At,Qn as jt,Qr as Mt,Qt as Nt,R as Pt,Ra as Ft,Ri as It,Rn as Lt,Ro as Rt,Rr as zt,Rt as Bt,S as Vt,Sa as Ht,Si as Ut,Sn as Wt,So as Gt,Sr as Kt,St as qt,T as Jt,Ta as Yt,Ti as Xt,Tn as Zt,To as Qt,Tr as $t,Ts as en,Tt as tn,U as nn,Ua as rn,Ui as an,Un as on,Uo as sn,Ur as cn,Us as ln,Ut as un,V as dn,Va as fn,Vi as pn,Vn as mn,Vo as hn,Vr as gn,Vs as _n,Vt as vn,W as yn,Wa as bn,Wi as xn,Wn as Sn,Wo as Cn,Wr as wn,Wt as Tn,X as En,Xa as Dn,Xi as On,Xn as kn,Xo as An,Xr as jn,Xt as Mn,Y as Nn,Ya as Pn,Yi as Fn,Yn as In,Yo as Ln,Yr as Rn,Yt as zn,Z as Bn,Za as Vn,Zi as Hn,Zn as Un,Zo as Wn,Zr as Gn,Zt as Kn,_ as qn,_a as Jn,_i as Yn,_n as Xn,_o as Zn,_r as Qn,_t as $n,a as er,aa as tr,ai as nr,an as rr,ao as ir,ar,at as or,b as sr,ba as cr,bi as lr,bn as ur,bo as dr,br as fr,bt as pr,c as mr,ca as hr,ci as gr,cn as _r,co as vr,cr as yr,ct as br,d as xr,da as Sr,di as Cr,dn as wr,do as Tr,dr as Er,dt as Dr,ea as Or,ei as kr,en as Ar,eo as jr,er as Mr,et as Nr,f as Pr,fa as Fr,fi as Ir,fn as Lr,fo as Rr,fr as zr,ft as Br,g as Vr,ga as Hr,gi as Ur,gn as Wr,go as Gr,gr as Kr,gt as qr,h as Jr,ha as Yr,hi as Xr,hn as Zr,ho as Qr,hr as $r,ht as ei,i as ti,ia as ni,ii as ri,in as ii,io as ai,ir as oi,it as si,j as ci,ja as li,ji as ui,jn as di,jo as fi,jr as pi,js as mi,jt as hi,k as gi,ka as _i,ki as vi,kn as yi,ko as bi,kr as xi,ks as Si,kt as Ci,l as wi,la as Ti,li as Ei,ln as Di,lo as Oi,lr as ki,lt as Ai,m as ji,ma as Mi,mi as Ni,mn as Pi,mo as Fi,mr as Ii,mt as Li,n as Ri,na as zi,ni as Bi,nn as Vi,no as Hi,nr as Ui,nt as Wi,o as Gi,oa as Ki,oi as qi,on as Ji,oo as Yi,or as Xi,ot as Zi,p as Qi,pa as $i,pi as ea,pn as ta,po as na,pr as ra,pt as ia,q as aa,qa as oa,qi as sa,qn as ca,qo as la,qr as ua,qt as da,r as fa,ra as pa,ri as ma,rn as ha,ro as ga,rr as _a,rt as va,s as ya,sa as ba,si as xa,sn as Sa,so as Ca,sr as wa,st as Ta,t as Ea,ta as Da,ti as Oa,tn as ka,to as Aa,tr as ja,tt as Ma,u as Na,ua as Pa,ui as Fa,un as Ia,uo as La,ur as Ra,ut as za,v as Ba,va as Va,vi as Ha,vn as Ua,vo as Wa,vr as Ga,vt as Ka,w as qa,wa as Ja,wi as Ya,wn as Xa,wo as Za,wr as Qa,ws as $a,wt as eo,x as to,xa as no,xi as ro,xn as io,xo as ao,xr as oo,xt as so,y as co,ya as lo,yi as uo,yn as fo,yo as po,yr as mo,yt as ho,z as go,za as _o,zi as vo,zn as yo,zo as bo,zr as xo,zt as So}from"./dist-BB-NSwQc.mjs";export{Ea as AGENT_ID_MAX_LEN,Ri as AGENT_ID_RE,fa as AGENT_WRITE_ORIGIN,a as AUDIT_EMPTY_SCOPE_WARNING,ti as AcpPermissionStore,er as AcpRegistry,Gi as AcpThreadManager,ya as AgentFocusBroadcaster,mr as AgentPresenceBroadcaster,wi as AgentSessionCapacityError,Na as AgentSessionManager,xr as AutoStartDisabledError,Pr as BUNDLE_IDS,Qi as BUNDLE_SCOPE,ji as BUNDLE_SKILL_NAME,Jr as BacklinkIndex,Vr as CC1Broadcaster,s as CC1_CONTRACT_VERSION,qn as CONCURRENT_REPLACE_WINDOW_MS,Ba as CONFIG_FILENAME,co as CONFLICT_MARKER_RE,sr as CURSOR_BUNDLE_PATHS_BY_PLATFORM,to as ConfigSchema,Vt as ConflictAuthority,j as DEFAULT_CHECKPOINT_RETENTION,qa as DEFAULT_EMBEDDINGS_DIMENSIONS,Jt as DEFAULT_PACK_ID,G as DocumentDurabilityState,R as DocumentDurabilityStateError,pt as EMBEDDINGS_API_KEY_ENV,gi as EPHEMERAL_PROJECT_DIR_PREFIX,h as ExposureConsentError,ci as FEATURED_AGENT_IDS,Ze as FILE_SYSTEM_WRITER,at as FILE_WATCHER_ORIGIN,bt as FileEmbeddingsBackend,Q as FilesystemRootProjectError,xe as GIT_PREFLIGHT_FAIL_SPAN_NAME,Ue as GIT_UPSTREAM_WRITER,$a as GitDirAccessError,Pt as GitNotAvailableError,go as GitTooOldError,C as HOCUSPOCUS_AUTH_REJECTION_REASONS,dn as HocuspocusAuthRejection,pe as HocuspocusAuthTokenSchema,nn as HomeProjectRootError,yn as INSTALLED_AGENTS_SCHEMES,oe as JSON_SCHEMA_DIALECT_2020_12,ye as LINEAGE_EPOCH_KEY,Ie as LIVE_DERIVED_INDEX_DEBOUNCE_MS,aa as LOCK_FILE_ACCESS_REMEDY,ke as MANAGED_RENAME_ORIGIN,Nn as MAX_ACP_THREADS,En as MAX_AGENT_SESSIONS,Bn as MCP_CONNECTION_ID_HEADER,o as MCP_SERVER_NAME,Ot as MIN_EVICTABLE_IDLE_MS,l as MIN_GIT_VERSION,en as MalformedGitPointerError,Nr as McpLogger,Ma as MissingOkConfigError,Wi as OBSERVER_SYNC_ORIGIN,va as OK_OKIGNORE_TEMPLATE,si as ONBOARDING_BUNDLE_IDS,k as ORPHAN_MODES,ln as PROTOCOL_VERSION,Si as PinoLogger,or as ProcessLockCollisionError,Zi as ProcessLockFileError,Ta as ProjectGitInitError,br as ROLLBACK_ORIGIN,Ai as ROOT_GITIGNORE_TEMPLATE,za as RUNTIME_VERSION,Dr as SERVICE_WRITER,Br as SKILL_INSTALL_EVENTS_FILENAME,c as SKILL_STATE_TARGETS,ia as STARTER_FOLDER_FRONTMATTER_FILENAME,Li as STARTER_PACKS,ei as STARTER_PACK_IDS,qr as STATE_MANIFEST_FILENAME,$n as STATE_SCHEMA_VERSION,Ka as SYMLINK_MERGE_MIN_GIT_LABEL,ho as SYMLINK_MERGE_MIN_GIT_VERSION,e as SYSTEM_DOC_NAME,pr as SeedPrerequisiteError,so as SeedRootDirError,qt as ServerAuthorityCollisionError,L as ServerAuthorityRegistryError,eo as ServerLockCollisionError,tn as SingleFileNotAFileError,Z as SingleFileNotFoundError,W as SingleFileNotMarkdownError,yt as SingleFileProjectOverrideError,Ci as StateManifestError,r as TEST_LOOP_CORE_MARKER,S as TEST_LOOP_SERVER_MARKER,hi as TagIndex,it as USER_GLOBAL_BUNDLE_IDS,ft as UnsafeIncomingSymlinkError,Dt as __getShowAllWalkStatsForTesting,ae as __resetShowAllWalkStatsForTesting,Oe as acpThreadStoreRoots,Xe as acpThreadsDir,Bt as acquireProcessLock,So as acquireServerLock,A as applyAgentMarkdownWrite,vn as applyExternalChange,be as applySeed,un as assertCheckoutSymlinksSafe,Tn as assertCompatibleStateManifest,fe as assertGitAvailable,He as assertIncomingSymlinksSafe,da as assertMergeNameResolvesTo,Fe as assertNeverDiskEvent,zn as assertRepoCheckoutSymlinksSafe,Mn as assertSafeProjectRoot,Kn as assessLockHolder,Nt as attachAcpThreadSocket,m as attachCollabClientCounter,Ar as attachIdleShutdown,ka as auditScopeNotFoundTitle,Vi as bindConflictAuthority,ha as bootServer,ii as buildAndOpenSkill,rr as buildConfigYmlContent,Ji as buildExecResult,Sa as buildIngressPolicy,_r as buildOkMcpStdioCommand,Di as buildSkillZip,Ia as buildStarterFolderFrontmatterYaml,wr as buildWipTree,Lr as bundleSkillMdPath,ta as canonicalProjectKey,Pi as canonicalizeForCompare,Zr as classifyEvents,Wr as classifyFsPath,Xn as classifyLockHolder,Ua as clearAllEmbeddingsKeys,fo as coercePackId,ur as collectServerHostSnapshot,t as colorFromSeed,io as commitUpstreamImport,Wt as commitWip,P as commitWipFromTree,Xa as compareSemver,Zt as composeEffectiveLinterConfig,J as composeFrontmatterSchemasConfig,V as containsConflictMarkers,gt as contentHash,yi as contributorCount,v as countShadowObjects,di as countStaleAgentWipRefs,et as countWipRefs,ct as createApiExtension,Ct as createAssetServeMiddleware,te as createCollaborationHost,we as createContentFilter,Ke as createContentFilterAsync,Lt as createEmbeddingsSecretStore,yo as createEphemeralProjectDir,E as createExternalChangeHandler,mn as createFileLogger,ge as createLiveDerivedIndexExtension,on as createMcpHttpHandler,Sn as createOsProbe,le as createPersistenceExtension,ze as createProbeFailureReporter,ca as createServer,Me as createServerObserverExtension,In as createServerProbeResolver,kn as createStreamingErrorWriter,x as createTestLogger,Un as describeStoredEmbeddingsKey,jt as detectClaudeDesktopPresence,f as detectGit,Mr as detectProjectShape,ja as detectUserSkillHosts,Ui as discoverLockDirs,_a as discoverMarkdownlintConfig,oi as emitPreflightFailureSpan,ar as encodeDocName,Xi as encodeFolderRoute,wa as encodeSkillRoute,yr as ensureProjectGit,ki as errorResponse,Ra as evictStaleTrackerEntries,Er as extractHeadings,zr as extractOkBinaryPath,ra as extractWikiLinksFromMarkdown,Ii as fallbackPaths,$r as findEnclosingGitRoot,Kr as findEnclosingProjectRoot,Qn as findNativeMarkdownlintFile,Ga as flushFileLogger,mo as formatAuditBrokenLinkSuppressionLine,fr as formatAuthRejectionWire,oo as formatContributorsFrom,Kt as formatPackRationale,I as gcCheckpointRefs,Qa as getCurrentMcpLogger,$t as getIngressContext,X as getLocalDir,U as getLogFilePath,mi as getLogger,vt as getLogsDir,xi as getMachineId,b as getMeter,pi as getMetrics,nt as getTracer,ut as handleCollabSocketError,Tt as handleSpawnCursor,re as hasForwardingHeaders,Ee as hasGcLogLatch,n as iconFromClientName,Je as incrementCollabSocketFilteredError,zt as incrementServerObserverFire,xo as initContent,O as initShadowRepo,gn as initTelemetry,ve as initToleranceTelemetryWriter,cn as installJsonSchemaDialect,wn as installPrettyZodErrors,rt as installTestLoggers,de as installUserSkill,Ve as isAllowedApiOrigin,ua as isAllowedWorkspaceHostHeader,Pe as isConfigDoc,Rn as isDefunctProcess,jn as isDocInConflict,Gn as isFilesystemRoot,Mt as isHocuspocusAuthRejectionReason,p as isHomeDir,kr as isHostAdmitted,Oa as isKnownPackId,Bi as isLinkIndexExcludedDoc,ma as isLockFromThisMachine,ri as isLockProcessRunning,nr as isLoopbackAddress,qi as isManagedArtifactDoc,xa as isMintedThreadId,gr as isOriginAdmitted,_n as isOrphanMode,Ei as isPairedWriteOrigin,Fa as isPathWithinDir,Cr as isPeerAdmitted,Ir as isProcessAlive,ea as isProjectRoot,Ni as isReservedForUserTree,Xr as isSelfWrite,Ur as isSkillInstallReportEnvOptOut,Yn as isSystemDoc,Ha as isToleranceTelemetryEnabled,uo as isValidLockPid,lr as lastKnownHash,ro as listRescueCheckpoints,Ut as listStarterPacks,N as loadCustomAgents,Ya as loadPrincipal,Xt as lockAdvertisesUi,q as lockBaseUrl,B as lockFilePath,dt as loggerFactory,ht as loginShapedUserinfoUser,Et as logsCurrentPath,ie as logsPreviousPath,vi as machineIdFilePath,_ as makeLazyEmbeddingsKeyStore,ui as markServerLockDraining,$e as missingOkConfigMessage,st as mountMcpAndApi,St as normalizeFsPath,ee as observeReadiness,Ce as packageVersionMajorMinor,Ge as parseAuthRejectionWire,It as parseGitVersion,vo as parseHocuspocusAuthToken,T as parseKeepaliveConnectionId,pn as parseProcessStartToken,he as pathToDocName,an as planSeed,xn as prepareSingleFileOpen,ce as processCommand,Re as processStartToken,sa as processUsage,je as readAgentBrowserTools,Fn as readAllTargets,On as readBundleDecision,Hn as readDeclaredGitHubHosts,At as readOriginCredentialHost,d as readOriginGitHubRepo,Or as readOwnNativeRules,Da as readProcessLock,zi as readProcessLockDetailed,pa as readProcessStart,ni as readProcessState,tr as readProjectHeadState,Ki as readProjectLocalSemanticConfig,ba as readServerLock,hr as readServerPackageVersion,Ti as readSkillInstallStateSnapshot,Pa as readStateManifest,Sr as readTargetRecordedAt,Fr as readTargetVersion,$i as reconcile,Mi as recordContributor,Yr as recordSkillInstallEvent,Hr as recordsLockOwner,Jn as redactShareSubprocessStderr,Va as registerAllTools,lo as registerNativeProcessStartReader,cr as registerWrite,no as releaseProcessLock,Ht as releaseServerLock,M as removeLastKnownHash,Ja as removeLockIfUnchanged,Yt as removeProjectSkillGitignoreBlock,K as reportSkillInstall,z as resetMetrics,mt as resolveAuditScope,_i as resolveBuiltinSkillHosts,i as resolveBundleEnabled,g as resolveBundledSkillDir,li as resolveContentDir,Qe as resolveCursorBinaryDefault,ot as resolveCursorSpawnInvocation,xt as resolveEffectiveLinterConfig,$ as resolveEmbeddingsCredential,Se as resolveGitHubAccountFromUrl,We as resolveGitHubAuthHost,Ft as resolveLockDir,_o as resolveNativeConfigForDoc,w as resolveNativeMarkdownlintConfig,fn as resolvePack,me as resolvePackageVersion,rn as resolveSkillInstallReportSettings,bn as resolveUiInfo,se as restoreContributors,Le as rewriteMarkdownLinksForDocumentRename,oa as rewriteWikiLinksForDocumentRename,Ae as runAuthReposSubprocess,Pn as runAuthStatusSubprocess,Dn as runCloneSubprocess,Vn as runDeviceFlowSubprocess,kt as runWithMcpLogger,u as safeContentPath,jr as safeSubdir,Aa as safetyCheckpoint,Hi as sameGitHubLogin,ga as sanitizeClientName,ai as saveInMemoryCheckpoint,ir as saveVersion,Yi as scanLockProcesses,Ca as seedBasenameIndex,vr as seedEphemeralProjectDir,Oi as serializeError,La as setActiveSpanAttributes,Tr as setupServerObservers,Rr as shadowGit,na as shutdownTelemetry,De as spansCurrentPath,Ye as spansPreviousPath,Fi as spawnDetached,Qr as splitMarkdownBlocks,Gr as startWatcher,Zn as strategiesFor,Wa as streamedChunkOf,po as streamingProblemEvent,dr as swapContributors,ao as teardownToleranceTelemetryWriter,Gt as toBroadcasterKey,F as toProcessLockMetadata,Za as tracedAppendFileSync,Qt as tracedLinkSync,Y as tracedMkdir,H as tracedMkdirSync,_t as tracedRename,bi as tracedRenameSync,y as tracedRmSync,fi as tracedRmdirSync,tt as tracedUnlinkSync,lt as tracedWriteFile,wt as tracedWriteFileSync,ne as trustSystemCertificates,Te as updateLastKnownHash,qe as updateProcessLockPort,Rt as updateServerLockPort,bo as validateAgentId,D as validateCloneInputs,hn as validateSkillZip,_e as waitForServerLockDrain,sn as withHiddenWindowsConsole,Cn as withSpan,ue as withSpanSync,Be as writeBundleDecision,la as writeMarkdownlintRule,Ne as writeRootGitignoreForNewRepo,Ln as writeStateManifest,An as writeTargetVersion,Wn as writeTracker};
|
package/dist/index.mjs
CHANGED
|
@@ -1549,6 +1549,6 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
|
|
|
1549
1549
|
`);re(e,o)}function M9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=A9(JSON.parse(n),t),i=n.endsWith(`
|
|
1550
1550
|
`)?`
|
|
1551
1551
|
`:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}}function N9(e,t){let n=S(e,`utf-8`),r=k9(n,t.contentDirSpellings);r!==n&&re(e,r)}function P9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const xFe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function F9(e){return/\.log\.\d+$/.test(e)}function SFe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||F9(e)}const CFe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function wFe(e){let t={contentDirSpellings:O9(e.contentDir)};for(let n of CFe)for(let r of P9(j(e.stagingDir,n)))SFe(r)?j9(r,t):r.endsWith(`.json`)?M9(r,t):N9(r,t);for(let n of P9(j(e.stagingDir,`state`))){let e=ae(n);n.endsWith(`.jsonl`)?j9(n,t):xFe.has(e)?M9(n,t):N9(n,t)}}const I9=[`.ok`,`local`,`telemetry`],L9=[`.ok`,`local`,`logs`],R9=[`.ok`,`local`,`loss-capture`],z9=`spans-current.jsonl`,B9=`spans-prev.jsonl`,V9=`server-current.jsonl`,H9=`server-prev.jsonl`,U9=`loss-current.jsonl`,W9=`loss-prev.jsonl`;function TFe(e){return j(e,...I9,z9)}function EFe(e){return j(e,...I9,B9)}function DFe(e){return j(e,...L9,V9)}function OFe(e){return j(e,...L9,H9)}function kFe(e){return j(e,...R9,U9)}function AFe(e){return j(e,...R9,W9)}const G9=1e3;async function jFe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function MFe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}async function NFe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(G9)});return t.ok?await t.text():null}catch{return null}}function PFe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
1552
|
-
`)}\n`:null}catch{return null}}function FFe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],R6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function IFe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],R6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function LFe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function RFe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,Ms.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function zFe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return zFe(e.maxBytes)}function BFe(e){let t=J9(CJ(`project`,e)),n=J9(CJ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function VFe(e){return Te(`sha256`).update(e).digest(`hex`)}function HFe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const UFe=[`"doc.name"`,`"docName"`];function WFe(e){let t=S(e,`utf-8`),n=0;for(let e of UFe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,Y5(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const GFe=new Set([`.jsonl`]);function KFe(e){let t=e.lastIndexOf(`.`);return t!==-1&&GFe.has(e.slice(t))}const qFe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function JFe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&qFe.has(e.slice(t))}function YFe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!JFe(r))continue;let{redacted:i,patterns:a,lineCount:o}=_P(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return M(e,t).split(le).join(`/`)}async function XFe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??jFe,a=r.fetchAgentEffects??MFe,o=r.fetchWatcherRecent??NFe,s=r.readShadowHead??FFe,c=r.readCheckpointRefs??IFe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.87.2-beta.
|
|
1552
|
+
`)}\n`:null}catch{return null}}function FFe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],R6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function IFe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],R6({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function K9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function LFe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function RFe(){return process.env.OTEL_SDK_DISABLED===`false`}function q9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J9(e){if(!g(e))return{};let t;try{t=(0,Ms.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!q9(t))return{};let n=t.telemetry;if(!q9(n))return{};let r=n.localSink;return q9(r)?r:{}}function Y9(e){return typeof e==`boolean`?e:void 0}function zFe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X9(e){if(q9(e))return zFe(e.maxBytes)}function BFe(e){let t=J9(CJ(`project`,e)),n=J9(CJ(`project-local`,e));return{enabled:Y9(n.enabled)??Y9(t.enabled)??!0,spansMaxBytes:X9(n.spans)??X9(t.spans)??52428800,logsMaxBytes:X9(n.logs)??X9(t.logs)??26214400}}function VFe(e){return Te(`sha256`).update(e).digest(`hex`)}function HFe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const UFe=[`"doc.name"`,`"docName"`];function WFe(e){let t=S(e,`utf-8`),n=0;for(let e of UFe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z9(e,t){if(!g(e))return!1;try{return v(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,Y5(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Q9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const GFe=new Set([`.jsonl`]);function KFe(e){let t=e.lastIndexOf(`.`);return t!==-1&&GFe.has(e.slice(t))}const qFe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function JFe(e){if(F9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&qFe.has(e.slice(t))}function YFe(e){let t=[];for(let n of Q9(e)){let r=$9(e,n);if(!JFe(r))continue;let{redacted:i,patterns:a,lineCount:o}=_P(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return M(e,t).split(le).join(`/`)}async function XFe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??jFe,a=r.fetchAgentEffects??MFe,o=r.fetchWatcherRecent??NFe,s=r.readShadowHead??FFe,c=r.readCheckpointRefs??IFe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.87.2-beta.2`),d=r.readDesktopEnv??K9,f=r.readLanguage??D9,p=r.readRuntime??LFe,h=r.isOtlpPushEnabled??RFe,_=y(j(xe(),`ok-bundle-`));try{v(j(_,`telemetry`),{recursive:!0}),v(j(_,`logs`),{recursive:!0}),v(j(_,`state`),{recursive:!0}),Z9(TFe(n),j(_,`telemetry`,z9)),Z9(EFe(n),j(_,`telemetry`,B9)),Z9(DFe(n),j(_,`logs`,V9)),Z9(OFe(n),j(_,`logs`,H9));for(let t of e.userLogFiles??[])Z9(t,j(_,`logs`,ae(t)));for(let t of e.userStateFiles??[])Z9(t,j(_,rJ,ae(t)));let y=0;for(let t of e.diagnosticReports?.files??[])Z9(t,j(_,`diagnostic-reports`,ae(t)))&&(y+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){Z9(x,j(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(j(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(j(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=PFe(n);e!==null&&re(j(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(j(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(j(_,`state`,`checkpoint-refs.txt`),D),Z9(kFe(n),j(_,`state`,U9)),Z9(AFe(n),j(_,`state`,W9)),Z9(j(b,`last-spawn-error.log`),j(_,`state`,`last-spawn-error.log`)),Z9(j(b,Nd),j(_,`state`,Nd)),Z9(j(b,Pd),j(_,`state`,Pd)),Z9(j(b,Md),j(_,`state`,Md));let ee=p(),ne=d(),ie=f(),k={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(j(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let oe=C===`running`?`running
|
|
1553
1553
|
`:`not-running (${w})\n`;re(j(_,`state`,`server-status.txt`),oe);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:J5(e.diagnosticReports,y);if(re(j(_,`state`,`diagnostic-reports-status.txt`),`${A}\n`),re(j(_,Q5),y7(e.osTerminationEvidence)),e.processDir&&g(e.processDir)){let t=j(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&wFe({stagingDir:_,contentDir:t}),e.note&&re(j(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=YFe(_));for(let t of e.extraFiles??[]){let e=t.zipName??ae(t.sourcePath);if(!Z9(t.sourcePath,j(_,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=x7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=BFe(n),N=Q9(_),le=[],ue=0,de=0;for(let e of N){let t=$9(_,e),n=te(e).size,r=KFe(t)?HFe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=WFe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:VFe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:le};re(j(_,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=O9(t),me=N.some(e=>{try{let t=S(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:_,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function ZFe(e){let{collected:t,outputPath:n}=e,r=k(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new KDe.ZipFile,a=Q9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function QFe(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,Ms.parse)(S(n,`utf-8`)),r=UJ(t)?t.content:void 0,i=UJ(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return N(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return N(e)}async function $Fe(e,t,n,r,i,a){let o=S7(t,e.logger),s=await XFe({contentDir:QFe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ZNe(o,e.userLogsDir??j(gJ(),`logs`)),...w7(e.cachesDir??j(_e(),`Library`,`Caches`))],userStateFiles:T7(e.bugReportsDir??b7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(k(e.outputPath),{recursive:!0}),await ZFe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function eIe(e){let{projectDir:t}=e,n=e.readDesktopEnv??K9,r=e.readLanguage??D9,i=()=>CNe(e.diagnosticReportsDir??j(_e(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return $Fe(e,t,n,r,i(),await v7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await nPe({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:w7(e.cachesDir??j(_e(),`Library`,`Caches`)),bugReportLedgerFiles:T7(e.bugReportsDir??b7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await v7(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{QJ as ALL_EDITOR_IDS,$J as EDITOR_LABELS,NY as EDITOR_TARGETS,$be as HOSTS_WITH_USER_SKILL_DIR,dNe as LAUNCH_CONFIG_NAME,rFe as PATH_SHIM_BEGIN,aFe as PATH_SHIM_BLOCK_RE,iFe as PATH_SHIM_END,c5 as ProjectPathSafetyError,HMe as addOkPathsToGitExclude,l5 as assertProjectPathSafe,mY as buildManagedServerEntry,zPe as buildMcpConfigDeclineEvent,BPe as buildMcpConfigMigrateEvent,wY as canonicalEntryFor,G5 as classifyExistingMcpEntry,eIe as collectReportBundle,uFe as createCliProbeResolver,kJ as createTokenStore,JNe as defaultBugReportZipPath,Ke as detectGh,Ye as detectGhAccounts,hNe as detectInstalledEditors,CY as droppedManagedKeys,bxe as editorConfigPathDisplay,yxe as editorEntryLocator,OPe as ensurePiBridge,kNe as findJetsamKillSync,C5 as formatTrackedRemediation,GMe as getExcludedOkPaths,x5 as getInstalledSkillProjectionPaths,Qbe as getNativeTomlMcpEditor,b5 as getOkArtifactPaths,fY as isEntryUpToDate,hY as isOwnManagedEntry,eFe as loadConfig,Ebe as makeLazyProbeTokenStore,b7 as okBugReportsDir,y9 as parseGitHubBlobUrl,tFe as parseGitHubShareUrl,b9 as parseGitHubTreeUrl,v9 as parseGitUrl,oFe as pathInstallMarkerPath,DMe as previewContent,gNe as probeOwnManagedEditorMcpEntry,EPe as probePiBridgeState,S5 as probeTrackedOkPaths,U5 as readExistingMcpEntry,WMe as readSharingMode,_P as redactContent,oPe as registerWindowsProcessStartReader,UMe as removeOkPathsFromGitExclude,FPe as removeOwnMcpEntry,RMe as removeProjectSkill,fFe as removeUserGlobalSkillBundle,vFe as removeUserSkill,MMe as resolveProjectRoot,JPe as runStop,f9 as truncatePriorEntry,T9 as userGlobalSkillBundleTargets,_Fe as userSkillPresentAnywhere,nFe as validateLocalFolderForShare,H5 as writeEditorMcpConfig,hFe as writeProjectAiIntegrations,h5 as writeProjectSkill,mNe as writeUserMcpConfigs,gFe as writeUserSkill};
|
|
1554
1554
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Cf as a,Df as o,Ef as s,Ga as c,Jc as l,K as u,Mf as d,Nf as f,Pf as p,Sf as m,Tf as h,V as g,Wa as _,_ as v,_f as y,a as b,df as x,gd as S,jf as C,lf as ee,mf as te,pf as ne,tt as re,uf as ie,vc as ae,vf as oe,yd as se,z as ce,zf as le}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{$r as ue,Aa as de,
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$u as r,Bf as i,Cf as a,Df as o,Ef as s,Ga as c,Jc as l,K as u,Mf as d,Nf as f,Pf as p,Sf as m,Tf as h,V as g,Wa as _,_ as v,_f as y,a as b,df as x,gd as S,jf as C,lf as ee,mf as te,pf as ne,tt as re,uf as ie,vc as ae,vf as oe,yd as se,z as ce,zf as le}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{$r as ue,Aa as de,Ea as fe,F as pe,Gr as me,Jo as he,Ko as ge,Mt as _e,Os as ve,R as ye,Ss as be,Ta as xe,U as Se,Ua as Ce,Uo as we,Xi as Te,Zr as Ee,as as De,cr as Oe,cs as ke,gi as Ae,it as je,ls as Me,m as Ne,mn as Pe,ms as w,os as Fe,pi as Ie,ss as Le,st as Re,tr as ze,z as Be,zr as Ve}from"./dist-BB-NSwQc.mjs";import{i as T,n as E,o as D,r as He,s as O,t as k}from"./colors-r_owlCuY.mjs";import{t as A}from"./is-object-BGze3w87.mjs";import{t as Ue}from"./constants-CjsWLxV4.mjs";import{t as We}from"./preview-_9prk5GA.mjs";import{createRequire as Ge}from"node:module";import{execFileSync as Ke}from"node:child_process";import qe,{basename as Je,dirname as j,isAbsolute as Ye,join as M,posix as Xe,relative as N,resolve as P,sep as F,win32 as Ze}from"node:path";import I from"node:process";import{fileURLToPath as Qe}from"node:url";import{cpSync as $e,existsSync as L,lstatSync as et,mkdirSync as tt,readFileSync as R,readdirSync as nt,readlinkSync as rt,realpathSync as it,rmSync as at,statSync as ot,writeFileSync as st}from"node:fs";import{homedir as z}from"node:os";import{inspect as ct,stripVTControlCharacters as lt,styleText as B}from"node:util";import*as ut from"node:readline";import{AsyncLocalStorage as dt,AsyncResource as ft}from"node:async_hooks";var pt=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})),mt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),ht=n((e=>{let{humanReadableArgName:t}=mt();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})),gt=n((e=>{let{InvalidArgumentError:t}=pt();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
|
|
@@ -321,13 +321,13 @@ exit 127`}const _i=`A dev build writes no MCP launcher for an installed OpenKnow
|
|
|
321
321
|
`,f=l.length===0?``:`${l.join(`
|
|
322
322
|
`)}\n`;try{st(r.path,`${s}${d}${f}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:l,alreadyPresent:u,removed:o}}function fa(e,t){let n=ba(e);if(n.kind!==`ok`)return n.result;if(!L(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>xa(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(sa),i.add(ca);for(let t of ua(e))i.add(t);let a;try{a=R(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
|
|
323
323
|
`),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=[...s];if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
|
|
324
|
-
`);if(u!==a)try{st(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function pa(e){let t=ba(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Ca(n),i=la(e);for(let e of i)if(Sa(r,e))return`local-only`;return r.has(sa)?`local-only`:`shared`}function ma(e){let t=ba(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let r=Ca(n),i=[...la(e),...ua(e)].filter(e=>Sa(r,e)),a=new Set(i),o=[];for(let e of Object.values(x))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===sa||e===ca){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function ha(e,t){let n=[];for(let r of t){let t=P(e,r);if(L(t))try{Ke(`git`,[`ls-files`,`--error-unmatch`,...u([r])],
|
|
325
|
-
`)}function ba(e){let t=
|
|
326
|
-
`)){let e=n.trim();e.length!==0&&t.add(e)}return t}function wa(e,t){return Ta(N(t,e))}function Ta(e){return F===`/`?e:e.split(F).join(`/`)}var Ea=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function Da(e,t){let n;try{n=et(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new Ea(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ka(e,t)}function Oa(e,t){ka(e,t)}function ka(e,t){Aa(e,t)}function Aa(e,t){let n=t,r;try{r=it(n)}catch{r=P(n)}let i=j(e);for(;i.length>1&&i!==F;){let t;try{t=it(i)}catch(e){if(e.code===`ENOENT`){i=j(i);continue}throw e}let n=N(r,t);if(n===``||!n.startsWith(`..`)&&!Ye(n))return;throw new Ea(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ja(e,t){let n=j(t),r=L(t)?`overwritten`:`written`;if(r===`written`&&L(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return at(n,{recursive:!0,force:!0}),tt(j(n),{recursive:!0}),$e(e,n,{recursive:!0}),r}function Ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Na(e,t,n){try{if(ot(n).size>10485760)return!1}catch{return!1}let r;try{r=R(n,`utf-8`)}catch{return!1}let i=[],a=
|
|
324
|
+
`);if(u!==a)try{st(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function pa(e){let t=ba(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!L(t.path))return`shared`;let n;try{n=R(t.path,`utf-8`)}catch{return`shared`}let r=Ca(n),i=la(e);for(let e of i)if(Sa(r,e))return`local-only`;return r.has(sa)?`local-only`:`shared`}function ma(e){let t=ba(e);if(t.kind!==`ok`||!L(t.path))return[];let n;try{n=R(t.path,`utf-8`)}catch{return[]}let r=Ca(n),i=[...la(e),...ua(e)].filter(e=>Sa(r,e)),a=new Set(i),o=[];for(let e of Object.values(x))e!==null&&o.push(e);let s=[];for(let e of r){if(a.has(e))continue;if(e===sa||e===ca){s.push(e);continue}let t=e.replace(/^\//,``).replace(/\/$/,``);o.some(e=>t.startsWith(`${e}/`)&&t.length>e.length+1)&&s.push(e)}return[...i,...s]}function ha(e,t){let n=[];for(let r of t){let t=P(e,r);if(L(t))try{Ke(`git`,[`ls-files`,`--error-unmatch`,...u([r])],we({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}}return{tracked:n}}const ga=/^[\w.\-/]+$/;function _a(e){return process.platform===`win32`?`"${e.replaceAll(`"`,``)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`}function va(e){return ga.test(e)?e:_a(re(e))}function ya(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}-- ${va(e)}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
|
|
325
|
+
`)}function ba(e){let t=ve(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=M(e.path,`info`);return L(n)?{kind:`ok`,path:M(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function xa(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function Sa(e,t){for(let n of xa(t))if(e.has(n))return!0;return!1}function Ca(e){let t=new Set;for(let n of e.split(`
|
|
326
|
+
`)){let e=n.trim();e.length!==0&&t.add(e)}return t}function wa(e,t){return Ta(N(t,e))}function Ta(e){return F===`/`?e:e.split(F).join(`/`)}var Ea=class extends Error{name=`ProjectPathSafetyError`;code=`PROJECT_PATH_SAFETY`};function Da(e,t){let n;try{n=et(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw new Ea(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);ka(e,t)}function Oa(e,t){ka(e,t)}function ka(e,t){Aa(e,t)}function Aa(e,t){let n=t,r;try{r=it(n)}catch{r=P(n)}let i=j(e);for(;i.length>1&&i!==F;){let t;try{t=it(i)}catch(e){if(e.code===`ENOENT`){i=j(i);continue}throw e}let n=N(r,t);if(n===``||!n.startsWith(`..`)&&!Ye(n))return;throw new Ea(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${r}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function ja(e,t){let n=j(t),r=L(t)?`overwritten`:`written`;if(r===`written`&&L(n))throw Error(`Refusing to replace ${n}: it exists but holds no SKILL.md, so it is not a bundle OpenKnowledge wrote. Move it aside and try again.`);return at(n,{recursive:!0,force:!0}),tt(j(n),{recursive:!0}),$e(e,n,{recursive:!0}),r}function Ma(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Na(e,t,n){try{if(ot(n).size>10485760)return!1}catch{return!1}let r;try{r=R(n,`utf-8`)}catch{return!1}let i=[],a=ke(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!Ma(a))return!1;let o=a[e.topLevelKey];if(!Ma(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;if(!Ma(s))return!1;let c=s[e.serverName(t)];return Ma(c)&&c.enabled===!1?!1:Pi(c)||Fi(c)}function Pa(e){let t=S[e]?.satisfiers.find(e=>e.piece===`mcp`&&e.scope===`project`),n=t?.pathId===void 0?null:se(t.pathId);return n===null||n.kind!==`editor-project-config`||n.editor===e?null:$[n.editor]??null}function Fa(e,t,n={}){if(!oe.includes(e.id))return!0;let r=Pa(e.id),i=r?.projectConfigPath?.(t);if(r!==null&&i!==void 0&&Na(r,t,i))return!0;try{return Na(e,t,e.configPath(t,n.home))}catch{return!1}}function Ia(e){let t=new Set(te.filter(e=>e.scope===`project`).map(e=>e.editorId));return e.filter(e=>t.has(e))}function La(e,t){if(Ia(t).length===0)return null;let n=M(e,_,y,`SKILL.md`);try{let t=de(`project`,{checkDesktop:!0});return Da(j(n),e),{editorId:`agents`,label:`.agents hub`,action:ja(t,n),path:n}}catch(e){return{editorId:`agents`,label:`.agents hub`,action:`failed`,path:n,error:e instanceof Error?e.message:String(e)}}}function Ra(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!Fa(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=de(`project`,{checkDesktop:!0});Da(j(r),t);let i=ja(n,r);return{editorId:e.id,label:e.label,action:i,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function za(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=j(n);return L(n)?(Oa(r,t),at(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function Ba(e){switch(e?.code){case`EACCES`:case`EPERM`:return`permission-denied`;case`ELOOP`:return`unresolved-symlink`;case`EISDIR`:case`ENOTDIR`:return`not-a-file`;case`ENOENT`:return`disappeared`;default:return`unreadable`}}function Va(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions, then retry`;case`missing-symlink-target`:return`the symlink target is missing; restore the target or correct the symlink, then retry`;case`unresolved-symlink`:return`the path or symlink could not be resolved; check path permissions and repair any symlink cycle, then retry`;case`not-a-file`:return`the path is not a regular file; restore the intended configuration file, then retry`;case`disappeared`:return`the file disappeared; retry to check its current state`;case`unreadable`:return`the file could not be read; check that the path is accessible, then retry`;default:throw Error(`unhandled configuration file decline reason: ${e}`)}}function Ha(e){for(let t of e.split(`
|
|
327
327
|
`)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function Ua(e){let t=(e.match(/\r\n/g)??[]).length;return t!==0&&t>=(e.match(/\n/g)??[]).length-t}function Wa(e){try{return ot(e).mode&511}catch{return}}function Ga(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
|
|
328
328
|
`)?`\r
|
|
329
329
|
`:`
|
|
330
|
-
`,a=
|
|
330
|
+
`,a=Le(r,t,void 0,{formattingOptions:{...Ha(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${De(r,a)}`;return{text:o,changed:o!==e}}const Ka={icon:{checked:B(`green`,U.circleFilled),unchecked:U.circle,cursor:U.pointer,disabledChecked:B(`green`,U.circleDouble),disabledUnchecked:`-`},style:{disabled:e=>B(`dim`,e),renderSelectedChoices:e=>e.map(e=>e.short).join(`, `),description:e=>B(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${B(`bold`,e)} ${B(`dim`,t)}`).join(B(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be toggled.`}};function qa(e){return!K.isSeparator(e)&&!e.disabled}function Ja(e){return!K.isSeparator(e)}function Ya(e){return!K.isSeparator(e)&&e.checked}function Xa(e){return qa(e)?{...e,checked:!e.checked}:e}function Za(e){return function(t){return qa(t)?{...t,checked:e}:t}}function Qa(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,checkedName:t,disabled:!1,checked:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,checkedName:e.checkedName??t,disabled:e.disabled??!1,checked:e.checked??!1};return e.description&&(n.description=e.description),n})}var $a=hr((e,t)=>{let{pageSize:n=7,loop:r=!0,required:i,validate:a=()=>!0}=e,o={all:`a`,invert:`i`,...e.shortcuts},s=dn(Ka,e.theme),{keybindings:c}=s,[l,u]=H(`idle`),d=fn({status:l,theme:s}),[f,p]=H(Qa(e.choices)),m=pn(()=>{let e=f.findIndex(Ja),t=f.findLastIndex(Ja);if(e===-1)throw new Ut(`[checkbox prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[f]),[h,g]=H(m.first),[_,v]=H();hn(async e=>{if(Rt(e)){let e=f.filter(Ya),n=await a([...e]);i&&!e.length?v(`At least one choice must be selected`):n===!0?(u(`done`),t(e.map(e=>e.value))):v(n||`You must select a valid value`)}else if(Nt(e,c)||Pt(e,c)){if(_&&v(void 0),r||Nt(e,c)&&h!==m.first||Pt(e,c)&&h!==m.last){let t=Nt(e,c)?-1:1,n=h;do n=(n+t+f.length)%f.length;while(!Ja(f[n]));g(n)}}else if(Ft(e)){let e=f[h];e&&!K.isSeparator(e)&&(e.disabled?v(s.i18n.disabledError):(v(void 0),p(f.map((e,t)=>t===h?Xa(e):e))))}else if(e.name===o.all){let e=f.some(e=>qa(e)&&!e.checked);p(f.map(Za(e)))}else if(e.name===o.invert)p(f.map(Xa));else if(Lt(e)){let t=Number(e.name)-1,n=-1,r=f.findIndex(e=>!K.isSeparator(e)&&(n++,n===t)),i=f[r];i&&qa(i)&&(g(r),p(f.map((e,t)=>t===r?Xa(e):e)))}});let y=s.style.message(e.message,l),b,x=Un({items:f,active:h,renderItem({item:e,isActive:t}){if(K.isSeparator(e))return` ${e.separator}`;let n=t?s.icon.cursor:` `;if(e.disabled){let t=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=e.checked?s.icon.disabledChecked:s.icon.disabledUnchecked;return s.style.disabled(`${n}${r} ${e.name} ${t}`)}t&&(b=e.description);let r=e.checked?s.icon.checked:s.icon.unchecked,i=e.checked?e.checkedName:e.name;return(t?s.style.highlight:e=>e)(`${n}${r} ${i}`)},pageSize:n,loop:r});if(l===`done`){let e=f.filter(Ya);return[d,y,s.style.answer(s.style.renderSelectedChoices(e,f))].filter(Boolean).join(` `)}let S=[[`↑↓`,`navigate`],[`space`,`select`]];o.all&&S.push([o.all,`all`]),o.invert&&S.push([o.invert,`invert`]),S.push([`⏎`,`submit`]);let C=s.style.keysHelpTip(S);return`${[[d,y].filter(Boolean).join(` `),x,` `,b?s.style.description(b):``,_?s.style.error(_):``,C].filter(Boolean).join(`
|
|
331
331
|
`).trimEnd()}${ir}`});const eo={icon:{cursor:U.pointer},style:{disabled:e=>B(`dim`,e),description:e=>B(`cyan`,e),keysHelpTip:e=>e.map(([e,t])=>`${B(`bold`,e)} ${B(`dim`,t)}`).join(B(`dim`,` • `))},i18n:{disabledError:`This option is disabled and cannot be selected.`},indexMode:`hidden`};function to(e){return!K.isSeparator(e)&&!e.disabled}function no(e){return!K.isSeparator(e)}function ro(e){return e.map(e=>{if(K.isSeparator(e))return e;if(typeof e!=`object`||!e||!(`value`in e)){let t=String(e);return{value:e,name:t,short:t,disabled:!1}}let t=e.name??String(e.value),n={value:e.value,name:t,short:e.short??t,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var io=hr((e,t)=>{let{loop:n=!0,pageSize:r=7}=e,i=dn(eo,e.theme),{keybindings:a}=i,[o,s]=H(`idle`),c=fn({status:o,theme:i}),l=mn(),u=!a.includes(`vim`),d=pn(()=>ro(e.choices),[e.choices]),f=pn(()=>{let e=d.findIndex(no),t=d.findLastIndex(no);if(e===-1)throw new Ut(`[select prompt] No selectable choices. All choices are disabled.`);return{first:e,last:t}},[d]),p=pn(()=>`default`in e?d.findIndex(t=>to(t)&&t.value===e.default):-1,[e.default,d]),[m,h]=H(p===-1?f.first:p),g=d[m];if(g==null||K.isSeparator(g))throw Error(`Active index does not point to a choice`);let[_,v]=H();hn((e,r)=>{if(clearTimeout(l.current),_&&v(void 0),Rt(e))g.disabled?v(i.i18n.disabledError):(s(`done`),t(g.value));else if(Nt(e,a)||Pt(e,a)){if(r.clearLine(0),n||Nt(e,a)&&m!==f.first||Pt(e,a)&&m!==f.last){let t=Nt(e,a)?-1:1,n=m;do n=(n+t+d.length)%d.length;while(!no(d[n]));h(n)}}else if(Lt(e)&&!Number.isNaN(Number(r.line))){let e=Number(r.line)-1,t=-1,n=d.findIndex(n=>!K.isSeparator(n)&&(t++,t===e)),i=d[n];i!=null&&to(i)&&h(n),l.current=setTimeout(()=>{r.clearLine(0)},700)}else if(It(e))r.clearLine(0);else if(u){let e=r.line.toLowerCase(),t=d.findIndex(t=>K.isSeparator(t)||!to(t)?!1:t.name.toLowerCase().startsWith(e));t!==-1&&h(t),l.current=setTimeout(()=>{r.clearLine(0)},700)}}),$t(()=>()=>{clearTimeout(l.current)},[]);let y=i.style.message(e.message,o),b=i.style.keysHelpTip([[`↑↓`,`navigate`],[`⏎`,`select`]]),x=0,S=Un({items:d,active:m,renderItem({item:e,isActive:t,index:n}){if(K.isSeparator(e))return x++,` ${e.separator}`;let r=t?i.icon.cursor:` `,a=i.indexMode===`number`?`${n+1-x}. `:``;if(e.disabled){let n=typeof e.disabled==`string`?e.disabled:`(disabled)`,r=t?i.icon.cursor:`-`;return i.style.disabled(`${r} ${a}${e.name} ${n}`)}return(t?i.style.highlight:e=>e)(`${r} ${a}${e.name}`)},pageSize:r,loop:n});if(o===`done`)return[c,y,i.style.answer(g.short)].filter(Boolean).join(` `);let{description:C}=g;return`${[[c,y].filter(Boolean).join(` `),S,` `,C?i.style.description(C):``,_?i.style.error(_):``,b].filter(Boolean).join(`
|
|
332
332
|
`).trimEnd()}${ir}`});function ao(e){let t=d(),n=e.split(/\r?\n/,1)[0]??``;if(n===xi(t))return!0;let r=yi(t);return n.startsWith(r)&&/^-v\d+$/.test(n.slice(r.length))}function oo(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&ao(n)}function so(e){return{command:`ok-pi-managed-extension`,args:[e]}}function co(e={}){let t=e.mode===`dev`,n=d(),r=t?xi(n):bi(n),i=`${a(n)}_`,o={unix:Z({...e,platformName:`darwin`}),win32:Z({...e,platformName:`win32`})};return`${r}
|
|
333
333
|
/**
|
|
@@ -672,13 +672,13 @@ export default function okBridge(pi: {
|
|
|
672
672
|
}
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
|
-
`}function lo(e,t){let n=N(
|
|
675
|
+
`}function lo(e,t){let n=N(Pe(t),Pe(e));return n.length>0&&!n.startsWith(`..`)&&!Ye(n)}const uo=e=>{try{let t=Ke(`git`,[`rev-parse`,`--show-toplevel`],we({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function fo(e,t={}){let n=t.homeDir??z(),r=t.gitTopLevel??uo,i=P(e),a;try{a=it(i)}catch{a=i}let o=a,s=0;for(;s<30&&o!==n&&o!==`/`&&o!==``;){if(Ie(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=j(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&lo(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function po(){let e=Zr();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function mo(e){let t=e,n=new Set;for(;;){let r;try{r=et(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=rt(t)}catch(t){return Y(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=Ye(i)?i:M(j(t),i)}}let ho;function go(){return ho===void 0&&(ho=po()),ho}function _o(e,t=go){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){Y(`resolveSymlinkWritePath threw`,e)}return mo(e)}const vo={allowTrailingComma:!0,disallowComments:!1};function yo(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function bo(e){let t=[],n=Me(e,t,vo);return t.some(t=>!yo(t,e))||n?.type!==`object`?null:n}function xo(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&Fe(e)===t&&(n+=1)}return n}function So(e,t){w(e,`${JSON.stringify(t,null,2)}\n`)}function Co(e,t){let n=Gr(t);w(e,n.endsWith(`
|
|
676
676
|
`)?n:`${n}\n`)}function wo(e,t){let n=(0,Kr.stringify)(t);w(e,n.endsWith(`
|
|
677
677
|
`)?n:`${n}\n`)}const To=10485760;function Eo(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>Eo(e,t[n]));if(A(e)&&A(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Eo(e[n],t[n]))}return!1}function Do(e,t,n){return A(e)&&n.every(n=>Eo(e[n],t[n]))}function Oo(e){for(let t of e.split(`
|
|
678
|
-
`)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function ko(e,t,n){return t===void 0?[e,n]:[e,t,n]}function Ao(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function jo(e,t,n){let r=e[t];return n===void 0?r:A(r)?r[n]:void 0}function Mo(e,t,n,r,i,a=!1,o=!1){if(!L(e))return o?{kind:`unchanged`}:(So(e,Ao(t,i,n,r)),{kind:`written`});let s;try{s=R(e,`utf-8`)}catch(e){return Y(`json config read failed`,e),{kind:`declined`,reason:Ba(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(So(e,Ao(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>To)return{kind:`declined`,reason:`oversize`};let c=bo(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(xo(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=jo(
|
|
678
|
+
`)){let e=t.trimStart();if(e.length!==0&&e.length!==t.length)return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function ko(e,t,n){return t===void 0?[e,n]:[e,t,n]}function Ao(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function jo(e,t,n){let r=e[t];return n===void 0?r:A(r)?r[n]:void 0}function Mo(e,t,n,r,i,a=!1,o=!1){if(!L(e))return o?{kind:`unchanged`}:(So(e,Ao(t,i,n,r)),{kind:`written`});let s;try{s=R(e,`utf-8`)}catch(e){return Y(`json config read failed`,e),{kind:`declined`,reason:Ba(e)}}if(s.trim()===``)return o?{kind:`unchanged`}:(So(e,Ao(t,i,n,r)),{kind:`written`});if(Buffer.byteLength(s,`utf-8`)>To)return{kind:`declined`,reason:`oversize`};let c=bo(s);if(!c)return{kind:`declined`,reason:`unparseable`};if(xo(c,t)>1)return{kind:`declined`,reason:`duplicate-container`};let l=jo(Fe(c),t,i),u=A(l)?l[n]:void 0,d=u!==void 0,f=Ri(r);if(d&&a?Ti(u):d&&Do(u,r,f))return{kind:o?`unchanged`:`overwritten`};let p=s.charCodeAt(0)===65279,m=p?s.slice(1):s,h=m.includes(`\r
|
|
679
679
|
`)?`\r
|
|
680
680
|
`:`
|
|
681
|
-
`,g={...Oo(m),eol:h},_=ko(t,i,n),v=m;if(o)for(let e of d?zi(u,r):[]){let t=
|
|
681
|
+
`,g={...Oo(m),eol:h},_=ko(t,i,n),v=m;if(o)for(let e of d?zi(u,r):[]){let t=Le(v,[..._,e],void 0,{formattingOptions:g});v=De(v,t)}else if(d&&!a&&Pi(u))for(let e of f){let t=Le(v,[..._,e],r[e],{formattingOptions:g});v=De(v,t)}else{let e=Le(v,_,r,{formattingOptions:g});v=De(v,e)}let y=`${p?``:``}${v}`;return y!==s&&w(e,y,{mode:Wa(e)}),o&&y===s?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}function No(e,t,n,r,i,a=!1,o=!1){let s=``;if(L(t))try{s=R(t,`utf-8`)}catch(e){return Y(`toml config read failed`,e),{kind:`declined`,reason:Ba(e)}}let c=s.trim()===``;if(c&&o)return{kind:`unchanged`};if(e.backend===`fallback`)return c?(Co(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let l=s.charCodeAt(0)===65279,u=l?s.slice(1):s,d=Ua(u),f=c||u.endsWith(`
|
|
682
682
|
`),p,m=!1;try{let t=Po(e,u,n,r);if(o){let n=u;for(let a of t===void 0?[]:zi(t,i))n=e.removeEntryKey(n,r,a).text;p={text:n,existed:t!==void 0}}else{let n=Fo(t,i,a);m=n.kind===`replace`;let o=m?e.removeEntry(u,r).text:u;if(n.kind===`merge`)for(let t of n.prune)o=e.removeEntryKey(o,r,t).text;p=e.upsertEntry(o,r,i)}}catch(e){return Y(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let h=p.text;f?h.endsWith(`
|
|
683
683
|
`)||(h=`${h}\n`):h=h.replace(/\n+$/,``),d&&(h=h.replace(/\r\n/g,`
|
|
684
684
|
`).replace(/\n/g,`\r
|
|
@@ -687,7 +687,7 @@ export default function okBridge(pi: {
|
|
|
687
687
|
`)||(m=`${m}\n`):m=m.replace(/\n+$/,``),h&&(m=m.replace(/\r\n/g,`
|
|
688
688
|
`).replace(/\n/g,`\r
|
|
689
689
|
`));let g=`${s?``:``}${m}`;return g!==o&&w(e,g,{mode:Wa(e)}),a&&g===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const Lo=e=>e!==`project`,Ro=e=>e!==`user`;async function zo(){let e=await $a({message:`Where should the MCP server be configured?
|
|
690
|
-
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Bo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??zo)():`both`}async function Vo(e){return io({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${C()} config-sharing share\`.`}]})}async function Ho(e){if(e.sharing!==void 0)return e.sharing;let t=pa(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)(t):t}var Uo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Wo=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const Go=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${h} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Ko(e){if(e===void 0||e===!0)return new Set(Ae);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(ve.filter(e=>t.includes(e)))}function qo(e,t,n){let r=P(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Uo(`--content-dir path does not exist: ${r}`):new Uo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Uo(`--content-dir must be a directory: ${r}`);let a=Jo(t),o=Jo(r),s=N(a,o);if(s.startsWith(`..`)||Ye(s))throw new Uo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Jo(e){try{return it(e)}catch{return e}}const Yo=`open-knowledge-ui`;function Xo(e,t,n){try{let r=e.detectPath?.(t,n)??j(e.configPath(t,n));return L(r)}catch{return!1}}function Zo(e,t,n){try{let r=P(j(e.configPath(t,n))),i=P(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+F)}catch{return!1}}function Qo(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!L(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Zo(e,t,r);if(!i&&c&&!Xo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Da(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return es(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(j(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{ze(`${o}.lock`,()=>{let t=_o(o).writePath;if(s||tt(j(t),{recursive:!0}),e.format===`toml`){let r=No(ai(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Io(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Mo(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const $o={pi:co};function es(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=$o[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{ze(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:Wa(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function ts(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function ns(e){let t=oa(e.editors).filter(e=>e.scope===`global`);if(le())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:Go}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Qo(t,``,n,e.home))}function rs(e,t,n,r){let i=as(e,t,n,r);return i.kind===`present`?i.entry:null}function is(e,t,n,r){let i=jo(e,t,r);if(!A(i))return{kind:`no-entry`};let a=i[n];return A(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function as(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(ot(i).size>To)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ba(e)}}let a;try{a=R(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ba(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:so(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ai().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return is(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Kr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:is(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=bo(a);return s?xo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:is(Pe(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function os(e={}){let t=P(e.cwd??process.cwd()),n=fo(t,{homeDir:e.home}),r=n.projectRoot;if(ue(r,e.home??z()))throw new xe(r);if(Te(r))throw new me(r);let i=!L(M(r,`.ok`)),a=n.gitRootPromoted?N(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:qo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${O(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${C()} init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},l=e.devMcp===!0||le();if(l&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Wo(e.scope);let u=await De(r),d;try{d=Ve(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:u.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let f=d.created.includes(Ue),p=!1;if(u.didInit)try{p=ge(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{be(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let m=await Bo({scope:l?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),h=e.editors??fs(r,e.home),g=e.editors??h,_=oa(h),v=oa(g),y=e.mcp===!1||m===null,b=Array.from(new Map([..._,...y?[]:v].map(e=>[e.id,e])).values()),x=_.filter(t=>Xo(t,r,e.home)),S=[],ee=[],te=new Set;for(let t of b){if(y){let n=``;try{n=t.configPath(r,e.home)}catch{}S.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Lo(m)&&_.includes(t)&&t.scope===`global`&&S.push(Qo(t,r,s,e.home)),Ro(m)&&v.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Qo(t,r,s,e.home,n);S.push(i),(i.action===`written`||i.action===`overwritten`)&&te.add(n)}}let ne=new Set;for(let t of v){let n=t.projectSkillPath?.(r);!n||ne.has(n)||(ne.add(n),ee.push(Ra(t,r,{home:e.home})))}let re=La(r,v.map(e=>e.id));re&&ee.push(re);let ie=ee.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ie.length>0){let t=e.home??z();pe({source:c,skills:[Me.project],agents:ie,scope:r},{home:t,enabled:Se(t).enabled})}let ae=!y&&m!==null&&Ro(m)?v.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=y?[]:x.map(e=>ts(e,r)).filter(e=>e!==void 0).filter(e=>!te.has(e.path)),se=e.installUserSkill??he,ce=e.home??z(),de=Ko(e.skills),fe=typeof e.skills!=`string`,ye=!1,Ce=!1,Ee=!1,Oe=!1,Ae=!1,je=!1,Ne=!1,w=[];for(let t of ve){if(!de.has(t))continue;if(ye=!0,fe){let e=await we(ce,Me[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){w.push({bundleId:t,result:`decision-read-failed`}),Ne=!0;continue}if(e.value===!1){w.push({bundleId:t,result:`opted-out`}),je=!0;continue}}await _e(ce,Me[t],!0).catch(()=>{});let n=await se({home:e.home,bundleId:t,force:!0});w.push({bundleId:t,result:n}),n===`installed`?Ce=!0:n===`failed`?Ee=!0:n===`no-hosts`?Ae=!0:Oe=!0}let Pe=Ee?`failed`:Ne?`decision-read-failed`:Ce?`installed`:ye&&Oe?`skip-current`:ye&&Ae?`no-hosts`:je?`opted-out`:`declined`,Fe=Ce?Re(ce).map(e=>e.editorId):[],Ie=Se(ce).enabled&&!ke(),Le=y?`skipped-flag`:`skipped-missing`,ze=S.find(e=>e.editorId===`claude`)??S[0]??{action:Le,configPath:$.claude.configPath(r,e.home)},Be=await ss({projectRoot:r,desiredMode:await Ho({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:d.created,contentUpdated:d.updated,contentSkipped:d.skipped,editors:S,projectSkills:ee,legacyProjectConfigs:oe,skillInstall:Pe,skillBundles:w,skillsRequested:e.skills,skillHosts:Fe,skillInstallsCounted:Ie,didGitInit:u.didInit,rootGitignoreCreated:p,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:f?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:ze.action,mcpPath:ze.configPath,mcpError:`error`in ze?ze.error:void 0,projectScopeUnsupportedLabels:ae,sharing:Be}}async function ss(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=pa(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=la(t);if(n===`local-only`){let e=da(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:cs(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=fa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:cs(t,o,`remove`)}function cs(e,t,n){let r=pa(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ls(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function us(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=M(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(k(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(k(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(k(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(k(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(k(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===f()?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${D(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${D(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${He(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${ls(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}let r=s.dev.mcpServerName;e.editors.some(e=>e.serverName===r&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${r} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(k(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${D(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${D(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${N(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(k(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${E(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${ve.join(`, `)})`)}`),n.push(` ${E(`No user-global skill was installed or removed.`)}`)):(n.push(` ${E(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${E(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${E(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${E(` ${C()} init`)}`),n.push(` ${E(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(k(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Me[e.bundleId].length));for(let i of t){let t=Me[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${D(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${D(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${E(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${O(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${E(`not installed — turned off on this machine; reinstall with ${C()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${O(`${t} not installed — could not read whether it is turned off on this machine; rerun ${C()} init once ${l(v)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${E(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${E(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${O(`Retry with: ${C()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(O(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(O(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${C()} init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(` To scope to just that sub-folder, re-run \`${C()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...hs(e.sharing,t));let u=e=>[`${e}- ${T(`${C()} seed --list-packs`)} — browse the starter packs`,`${e}- ${T(`${C()} seed`)} — scaffold an empty repo`];if(r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${D(`✓`)} ${k(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${k(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
|
|
691
|
-
`)}function ds(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function fs(e,t){let n=[];for(let r of si)r!==`claude-desktop`&&Xo($[r],e,t)&&n.push(r);return n}function ps(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function ms(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&p(process.env);let n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?ps():null;try{let r;try{r=await os({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Uo||e instanceof Wo||e instanceof
|
|
692
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-
|
|
690
|
+
`,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Bo(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??zo)():`both`}async function Vo(e){return io({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:`OK config stays on this machine only; teammates do not see it. Safe escape hatch via \`${C()} config-sharing share\`.`}]})}async function Ho(e){if(e.sharing!==void 0)return e.sharing;let t=pa(e.projectRoot)===`local-only`||e.freshProject===!0?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??Vo)(t):t}var Uo=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}},Wo=class extends Error{constructor(e){super(`A dev MCP entry is written to project config only, never to user-level editor config, so --scope ${e} is not supported with --dev-mcp or OK_CHANNEL=dev. Re-run with --scope project or without --scope.`),this.name=`DevMcpScopeError`}};const Go=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${h} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`;function Ko(e){if(e===void 0||e===!0)return new Set(je);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(_e.filter(e=>t.includes(e)))}function qo(e,t,n){let r=P(n,e),i;try{i=ot(r)}catch(e){let t=e.code;throw t===`ENOENT`?new Uo(`--content-dir path does not exist: ${r}`):new Uo(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new Uo(`--content-dir must be a directory: ${r}`);let a=Jo(t),o=Jo(r),s=N(a,o);if(s.startsWith(`..`)||Ye(s))throw new Uo(`--content-dir must be inside the project root (${t}); got ${r}`);return s===``?`.`:s}function Jo(e){try{return it(e)}catch{return e}}const Yo=`open-knowledge-ui`;function Xo(e,t,n){try{let r=e.detectPath?.(t,n)??j(e.configPath(t,n));return L(r)}catch{return!1}}function Zo(e,t,n){try{let r=P(j(e.configPath(t,n))),i=P(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+F)}catch{return!1}}function Qo(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!L(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Zo(e,t,r);if(!i&&c&&!Xo(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{Da(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return es(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||tt(j(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{be(`${o}.lock`,()=>{let t=_o(o).writePath;if(s||tt(j(t),{recursive:!0}),e.format===`toml`){let r=No(ai(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=Io(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=Mo(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const $o={pi:co};function es(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=$o[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{tt(j(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{be(`${t}.lock`,()=>{let e=null;try{e=R(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}w(t,c,e===null?void 0:{mode:Wa(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function ts(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!L(n)))return{editorId:e.id,label:e.label,path:n}}async function ns(e){let t=oa(e.editors).filter(e=>e.scope===`global`);if(le())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:Go}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>Qo(t,``,n,e.home))}function rs(e,t,n,r){let i=as(e,t,n,r);return i.kind===`present`?i.entry:null}function is(e,t,n,r){let i=jo(e,t,r);if(!A(i))return{kind:`no-entry`};let a=i[n];return A(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function as(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!L(i))return{kind:`absent`};try{if(ot(i).size>To)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:Ba(e)}}let a;try{a=R(i,`utf-8`)}catch(e){return{kind:`decline`,reason:Ba(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:so(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ai().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return is(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Kr.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:is(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=bo(a);return s?xo(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:is(Fe(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function os(e={}){let t=P(e.cwd??process.cwd()),n=fo(t,{homeDir:e.home}),r=n.projectRoot;if(ue(r,e.home??z()))throw new Se(r);if(Ee(r))throw new pe(r);let i=!L(M(r,`.ok`)),a=n.gitRootPromoted?N(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:qo(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${O(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`${C()} init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},l=e.devMcp===!0||le();if(l&&e.mcp!==!1&&e.scope&&e.scope!==`project`)throw new Wo(e.scope);let u=await Oe(r),d;try{d=Ve(r,{contentDir:o})}catch(t){let i=$.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:u.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let f=d.created.includes(Ue),p=!1;if(u.didInit)try{p=he(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{xe(r)===`removed`&&console.warn(`[ok] Removed the OpenKnowledge project-skill lines from .gitignore. The skill is ordinary project content now — commit it if your team wants it on clone.`)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore cleanup at ${r}: ${e instanceof Error?e.message:String(e)}`)}let m=await Bo({scope:l?`project`:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),h=e.editors??fs(r,e.home),g=e.editors??h,_=oa(h),v=oa(g),y=e.mcp===!1||m===null,b=Array.from(new Map([..._,...y?[]:v].map(e=>[e.id,e])).values()),x=_.filter(t=>Xo(t,r,e.home)),S=[],ee=[],te=new Set;for(let t of b){if(y){let n=``;try{n=t.configPath(r,e.home)}catch{}S.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(Lo(m)&&_.includes(t)&&t.scope===`global`&&S.push(Qo(t,r,s,e.home)),Ro(m)&&v.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Qo(t,r,s,e.home,n);S.push(i),(i.action===`written`||i.action===`overwritten`)&&te.add(n)}}let ne=new Set;for(let t of v){let n=t.projectSkillPath?.(r);!n||ne.has(n)||(ne.add(n),ee.push(Ra(t,r,{home:e.home})))}let re=La(r,v.map(e=>e.id));re&&ee.push(re);let ie=ee.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(ie.length>0){let t=e.home??z();fe({source:c,skills:[Ne.project],agents:ie,scope:r},{home:t,enabled:Ce(t).enabled})}let ae=!y&&m!==null&&Ro(m)?v.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,oe=y?[]:x.map(e=>ts(e,r)).filter(e=>e!==void 0).filter(e=>!te.has(e.path)),se=e.installUserSkill??me,ce=e.home??z(),de=Ko(e.skills),ve=typeof e.skills!=`string`,ye=!1,be=!1,we=!1,De=!1,ke=!1,je=!1,Me=!1,Pe=[];for(let t of _e){if(!de.has(t))continue;if(ye=!0,ve){let e=await Te(ce,Ne[t]).then(e=>({ok:!0,value:e}),()=>({ok:!1}));if(!e.ok){Pe.push({bundleId:t,result:`decision-read-failed`}),Me=!0;continue}if(e.value===!1){Pe.push({bundleId:t,result:`opted-out`}),je=!0;continue}}await ge(ce,Ne[t],!0).catch(()=>{});let n=await se({home:e.home,bundleId:t,force:!0});Pe.push({bundleId:t,result:n}),n===`installed`?be=!0:n===`failed`?we=!0:n===`no-hosts`?ke=!0:De=!0}let w=we?`failed`:Me?`decision-read-failed`:be?`installed`:ye&&De?`skip-current`:ye&&ke?`no-hosts`:je?`opted-out`:`declined`,Fe=be?ze(ce).map(e=>e.editorId):[],Ie=Ce(ce).enabled&&!Ae(),Le=y?`skipped-flag`:`skipped-missing`,Re=S.find(e=>e.editorId===`claude`)??S[0]??{action:Le,configPath:$.claude.configPath(r,e.home)},Be=await ss({projectRoot:r,desiredMode:await Ho({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,freshProject:i,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:d.created,contentUpdated:d.updated,contentSkipped:d.skipped,editors:S,projectSkills:ee,legacyProjectConfigs:oe,skillInstall:w,skillBundles:Pe,skillsRequested:e.skills,skillHosts:Fe,skillInstallsCounted:Ie,didGitInit:u.didInit,rootGitignoreCreated:p,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:f?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:Re.action,mcpPath:Re.configPath,mcpError:`error`in Re?Re.error:void 0,projectScopeUnsupportedLabels:ae,sharing:Be}}async function ss(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=pa(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=la(t);if(n===`local-only`){let e=da(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:cs(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=fa(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:cs(t,o,`remove`)}function cs(e,t,n){let r=pa(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:t.removed.length>0?`cleaned`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:t.removed}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function ls(e){switch(e){case`permission-denied`:return`permission denied; check file and parent-directory permissions`;case`unresolved-symlink`:return`could not resolve the path or symlink; check permissions and symlink cycles`;case`not-a-file`:return`config path is not a regular file`;case`disappeared`:return`config disappeared while being read; retry to check its current state`;case`unreadable`:return`could not read the config file; check that the path is accessible`;case`unparseable`:return`config could not be parsed`;case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;case void 0:return`config not readable`;default:throw Error(`unhandled MCP decline reason: ${e}`)}}function us(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=M(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(k(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(k(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0){if(n.push(k(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`)}else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(k(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(k(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?N(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===f()?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${D(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${D(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${He(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${ls(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}let r=s.dev.mcpServerName;e.editors.some(e=>e.serverName===r&&(e.action===`written`||e.action===`overwritten`))&&n.push(` The ${r} entry runs this checkout on this machine only; keep it out of commits.`)}if(e.projectSkills.length>0){n.push(``),n.push(k(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?N(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${D(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${D(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${He(`FAILED`)}: ${r.error}`)}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${N(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall===`declined`)n.push(``),n.push(k(`User-global skills:`)),typeof e.skillsRequested==`string`?(n.push(` ${E(`none installed — --skills "${e.skillsRequested}" names no known skill bundle (known: ${_e.join(`, `)})`)}`),n.push(` ${E(`No user-global skill was installed or removed.`)}`)):(n.push(` ${E(`none installed — skipped for this run (--no-skills)`)}`),n.push(` ${E(`No user-global skill was installed or removed; any already on this`)}`),n.push(` ${E(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${E(` ${C()} init`)}`),n.push(` ${E(`--no-skills covers user-global skills only, not project-local skills.`)}`));else if(e.skillInstall){n.push(``),n.push(k(`User-global skills:`));let t=e.skillBundles??[],r=Math.max(0,...t.map(e=>Ne[e.bundleId].length));for(let i of t){let t=Ne[i.bundleId].padEnd(r);switch(i.result){case`installed`:{let r=(e.skillHosts??[]).map(e=>X[e]??e),i=r.length>0?r.join(`, `):`the shared ~/.agents store`;n.push(` ${t} ${D(`installed for ${i}`)}`);break}case`skip-current`:n.push(` ${t} ${D(`already installed at current version`)}`);break;case`no-hosts`:n.push(` ${t} ${E(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${O(`${t} install failed`)}`);break;case`opted-out`:n.push(` ${t} ${E(`not installed — turned off on this machine; reinstall with ${C()} init --skills ${i.bundleId} or Settings → Skills Studio`)}`);break;case`decision-read-failed`:n.push(` ${O(`${t} not installed — could not read whether it is turned off on this machine; rerun ${C()} init once ${l(v)} is readable`)}`);break;default:i.result}}e.skillInstallsCounted&&t.some(e=>e.result===`installed`)&&(n.push(` ${E(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${E(`Opt out: DO_NOT_TRACK=1, or Settings → User → Preferences.`)}`)),t.some(e=>e.result===`failed`)&&n.push(` ${O(`Retry with: ${C()} repair-skills`)}`)}e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(O(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(O(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`${C()} init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(` To scope to just that sub-folder, re-run \`${C()} init --content-dir .\` from there, or set`),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(We(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...hs(e.sharing,t));let u=e=>[`${e}- ${T(`${C()} seed --list-packs`)} — browse the starter packs`,`${e}- ${T(`${C()} seed`)} — scaffold an empty repo`];if(r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${D(`✓`)} ${k(`Next steps:`)}`),n.push(` 1. Open your editor (${T(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`);let i=3;e.contentScaffoldFailed||(n.push(` ${i++}. (Optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `))),n.push(` ${i}. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}else e.contentScaffoldFailed||(n.push(``),n.push(`${k(`Next steps:`)} (optional) scaffold the starter knowledge-base structure:`),n.push(...u(` `)));return n.join(`
|
|
691
|
+
`)}function ds(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function fs(e,t){let n=[];for(let r of si)r!==`claude-desktop`&&Xo($[r],e,t)&&n.push(r);return n}function ps(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:ct(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function ms(){return new Et(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry (node + packages/cli/dist/cli.mjs, debug logging) in project config only, as the dev channel unless OK_CHANNEL is set`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new Ot(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new Ot(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new Ot(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd();e.devMcp&&p(process.env);let n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?ps():null;try{let r;try{r=await os({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof Uo||e instanceof Wo||e instanceof Se||e instanceof pe){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof ye||e instanceof Be){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof Re){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
|
|
692
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-BJYhNl_Y.mjs`),{resolveContentDir:s}=await import(`./dist-BKGJO_91.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-DhGoOOxK.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(ds(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${us(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function hs(e,t){let n=[];switch(e.kind){case`applied`:return n.push(k(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?(n.push(` ${D(`local-only`)} — appended ${e.appended.length} path(s) to ${k(`${t}/.git/info/exclude`)} (per-clone, not committed).`),e.removed.length>0&&n.push(` cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`)):e.action===`cleaned`?n.push(` ${D(`local-only`)} — already excluded; cleared ${e.removed.length} stale entry(s) left by an older version: ${e.removed.join(`, `)}.`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${D(`local-only`)} — already excluded; nothing to do.`):n.push(` ${D(`local-only`)}`):e.action===`removed`?n.push(` ${D(`shared`)} — removed OK paths from ${k(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${D(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(O(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
693
693
|
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${T(`${C()} config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(O(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${T(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${T(`${C()} config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(O(`Sharing mode unavailable: ${e.reason}.`));return n}}export{Z as $,Ua as A,Ra as B,_o as C,Rt as Ct,io as D,oo as E,Ot as Et,Aa as F,la as G,ya as H,Da as I,fa as J,ha as K,Oa as L,Va as M,Ba as N,$a as O,Ea as P,ci as Q,za as R,Zo as S,H as St,co as T,wt as Tt,ma as U,da as V,ua as W,X,si as Y,$ as Z,Ho as _,hr as _t,ss as a,Ti as at,Qo as b,fn as bt,fs as c,Wi as ct,ms as d,oi as dt,Bi as et,Xo as f,ai as ft,qo as g,Zr as gt,Bo as h,Jr as ht,$o as i,Si as it,Ga as j,Wa as k,us as l,ta as lt,Ko as m,Yr as mt,Wo as n,Vi as nt,ds as o,Ui as ot,rs as p,Y as pt,pa as q,Yo as r,Hi as rt,as as s,Q as st,Uo as t,zi as tt,hs as u,ki as ut,os as v,ir as vt,fo as w,Et as wt,ns as x,dn as xt,ko as y,hn as yt,ja as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-BB-NSwQc.mjs";import{v as e}from"./init-BBJX1tEw.mjs";export{e as runInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ls as e,ms as t,os as n}from"./dist-
|
|
1
|
+
import{ls as e,ms as t,os as n}from"./dist-BB-NSwQc.mjs";import{N as r,j as i,k as a}from"./init-BBJX1tEw.mjs";import{t as o}from"./is-object-BGze3w87.mjs";import{t as s}from"./removal-file-path-Bfn04hQq.mjs";import{join as c}from"node:path";import{readFileSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(o){let f=s(c(o,`.claude`,`launch.json`));if(f.kind!==`ready`)return f;let m=f.path,h;try{h=l(m,`utf-8`)}catch(e){return{kind:`declined`,reason:r(e)}}let g=[],_=e(h,g,u)??void 0;if(g.some(e=>!d(e,h))||_?.type!==`object`)return{kind:`declined`,reason:`unparseable`};let v=n(_).configurations;if(!Array.isArray(v))return{kind:`not-present`};let y=v.findIndex(p);if(y===-1)return{kind:`not-present`};let{text:b,changed:x}=i(h,[`configurations`,y]);return x?(t(m,b,{mode:a(m)}),{kind:`removed`}):{kind:`not-present`}}function p(e){if(!o(e))return!1;let t=e;if(t.name!==`open-knowledge-ui`||!Array.isArray(t.runtimeArgs))return!1;let n=t.runtimeArgs;return t.runtimeExecutable===`/bin/sh`?n.length===3&&n[0]===`-l`&&n[1]===`-c`&&typeof n[2]==`string`&&/^# ok-ui-v[1-9]\d*$/.test(n[2].split(/\r?\n/,1)[0]??``):t.runtimeExecutable===`npx`?m.some(e=>h(n,e)):t.runtimeExecutable===`powershell`&&n.length===4&&n[0]===`-NoProfile`&&n[1]===`-NonInteractive`&&n[2]===`-Command`&&typeof n[3]==`string`&&/^# ok-ui-win-v[1-9]\d*$/.test(n[3].split(/\r?\n/,1)[0]??``)}const m=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge@latest`,`ui`]];function h(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-abngpKg0.mjs";export{e as loadConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$u as e,Ic as t,Pc as n,cl as r,il as i,k as a,nl as o}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{
|
|
1
|
+
import{$u as e,Ic as t,Pc as n,cl as r,il as i,k as a,nl as o}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{bs as s,vs as c,x as l}from"./dist-BB-NSwQc.mjs";import{t as u}from"./is-object-BGze3w87.mjs";import{t as d}from"./constants-CjsWLxV4.mjs";import{resolve as f}from"node:path";import{existsSync as p,readFileSync as m}from"node:fs";import{realpath as h}from"node:fs/promises";var g=e();async function _(e){let t=f(e);try{return await h(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function v(e){if(!p(e))return{value:null,path:e,source:null,doc:null};let t;try{t=m(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,g.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return u(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function y(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=i({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function b(e){let i=e??process.cwd(),u=[],p=[],m=[],h=[],g=s(`user`,i),_=c({absPath:g});p.push(..._.diagnostics),!_.valid&&_.sidelinedTo!==void 0&&m.push({from:g,to:_.sidelinedTo}),_.valid&&_.source!==void 0&&u.push(g);let b=(e,t=!1)=>{let n=v(e);if(n.diagnostic!==void 0&&p.push(n.diagnostic),n.value===null)return{};let i=o({value:n.value,file:n.path,source:n.source,doc:n.doc});p.push(...i),u.push(e);let s=i.length>0?r(n.value):n.value;return t&&h.push(...a({value:s,file:n.path,source:n.source,doc:n.doc})),s},x=f(i,`.ok`,d),S=b(x,!0),C=b(s(`project-local`,i)),w=n(_.value,S,C),T=l.safeParse(w);if(!T.success){let e=v(x),n={code:`SCHEMA_INVALID`,issues:y(T.error.issues,e)};throw Error(t(n))}return{config:T.data,sources:u,diagnostics:p,sidelined:m,ignoredCommittedKeys:h}}function x(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??b,r=new Map,i=new Map,a=_(e.startupCwd);return async o=>{let s=await _(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{b as n,x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Uo as e}from"./dist-
|
|
1
|
+
import{Uo as e}from"./dist-BB-NSwQc.mjs";import{execFile as t}from"node:child_process";const n=new Set([`http:`,`https:`]),r=/[\u0000-\u0020\u007F-\u009F"'`\\&|<>^()$;{}[\]*?!~]/;function i(e,t){console.warn(`Could not auto-open browser (${t}); visit ${e} manually`)}function a(a){let o;try{o=new URL(a)}catch{i(a,`invalid URL`);return}if(!n.has(o.protocol)){i(a,`unsupported scheme '${o.protocol}'`);return}if(r.test(a)){i(a,`URL contains unsafe characters`);return}let s=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,c=process.platform===`win32`?[`/c`,`start`,``,a]:[a];t(s,c,e({}),e=>{e&&console.warn(`Could not auto-open browser (${e.message}); visit ${a} manually`)})}export{a as openBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-_9prk5GA.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Mf as e}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{In as t}from"./dist-
|
|
1
|
+
import{Mf as e}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{In as t}from"./dist-BB-NSwQc.mjs";import"./constants-CjsWLxV4.mjs";import{join as n,relative as r}from"node:path";import{existsSync as i,lstatSync as a,readdirSync as o,realpathSync as s,statSync as c}from"node:fs";function l(e){let{projectDir:i,contentDir:l,sampleCap:u=5}=e,d=[],f=[];try{a(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=t({projectDir:i,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let t;try{t=o(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);d.push(`could not read directory ${r(l,e)||`.`}: ${n}`);return}for(let i of t){let t=n(e,i.name);if(i.isSymbolicLink()){let e;try{e=s(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?d.push(`broken or cyclic symlink: ${r(l,t)}`):d.push(`cannot resolve symlink ${r(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=c(e)}catch{continue}if(n.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(n.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=r(l,t);if(p.isDirExcluded(e))continue;m(t)}else if(i.isFile()){let e=r(l,t);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function u(t,a){let o=[],s=r(a,t.contentDir),c=s===``?`./`:`./${s}`;if(o.push(`Content:`),o.push(` Found ${t.totalCount} markdown files in ${c}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;o.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)o.push(` Warning: ${e}`);o.push(``);let l=n(a,`.ok`,`config.yml`);return i(l)?(o.push(` To adjust scope, add patterns to .okignore at the project root.`),o.push(` To change the content root, edit .ok/config.yml → content.dir.`)):o.push(` Run \`${e().cliCommandNames[1]} init\` to scaffold config + .okignore.`),o.push(``),o.push(` Re-check anytime: ${e().cliCommandNames[1]} preview`),o.join(`
|
|
2
2
|
`)}export{l as n,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-DDAH9fqy.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-i2xTrKQt.js";import{t as p}from"./trash-2-CchZ0T47.js";import{t as m}from"./use-git-sync-status-PkMYmN4D.js";import{t as h}from"./input-BsFOyzfK.js";import{t as g}from"./skeleton-izVZCkjV.js";import{a as _,n as v,t as y}from"./AuthModal-CDv9Ka9d.js";import{t as b}from"./channel-cli-copy-BySq87hR.js";import{n as x}from"./auth-state-cache-Bx6C01Jt.js";import{t as ee}from"./SettingsSectionHeader-BKhNIRp2.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function te(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[m,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,ee]=(0,S.useState)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=new Map,t[2]=w):w=t[2];let T=(0,S.useRef)(w),E=(0,S.useRef)(null),D,te;t[3]===x?(D=t[4],te=t[5]):(D=()=>{x!==null&&(((x.host===null?null:T.current.get(x.host))??E.current)?.focus(),ee(null))},te=[x],t[3]=x,t[4]=D,t[5]=te),(0,S.useEffect)(D,te);let M,N;t[6]===n?(M=t[7],N=t[8]):(M=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=M,t[8]=N),(0,S.useEffect)(M,N);let P;t[9]===a?P=t[10]:(P=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=P);let F=P,I;t[11]!==n||t[12]!==m||t[13]!==d||t[14]!==F?(I=function(e){e.preventDefault();let t=O(m,new Set(d.map(j)));if(!t.ok){v(F(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=m,t[13]=d,t[14]=F,t[15]=I):I=t[15];let ne=I,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),ee({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?T.current.set(e,t):T.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==m||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(h,{ref:E,value:m,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=m,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===m?re=t[38]:(re=m.trim(),t[37]=m,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==ne||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:ne,noValidate:!0,children:[q,Y]}),t[42]=ne,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function j(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??_(),t[0]=n,t[1]=c);let l=c,u=m()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[h,g]=(0,S.useState)(!1),[v,b]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),E=(0,S.useRef)(!1),D;t[3]===l?D=t[4]:(D=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),x(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=D);let O=D,k;t[5]===O?k=t[6]:(k=()=>{O()},t[5]=O,t[6]=k);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=[],t[7]=j):j=t[7],(0,S.useEffect)(k,j);let M;t[8]!==s||t[9]!==O||t[10]!==l?(M=async function(){if(E.current)return;E.current=!0,g(!1),b(!0),T(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await O(),e&&T(e),b(!1),E.current=!1},t[8]=s,t[9]=O,t[10]=l,t[11]=M):M=t[11];let P=M,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(ee,{titleId:`settings-account-title`,title:F,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==w||t[15]!==v||t[16]!==P||t[17]!==O||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(N,{status:f,disconnecting:v,disconnectError:w,onRetry:()=>void O(),onConnect:()=>g(!0),onDisconnect:()=>void P()})]}),t[14]=w,t[15]=v,t[16]=P,t[17]=O,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(te,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(ne,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===O?V=t[30]:(V=e=>{g(e),e||O()},t[29]=O,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===O?W=t[32]:(W=()=>{O()},t[31]=O,t[32]=W);let G;t[33]!==h||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(y,{open:h,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=h,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function N(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(g,{className:`h-4 w-40`}),(0,A.jsx)(g,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(R,{login:n.result.login,host:n.result.host}):(0,A.jsx)(L,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(z,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function P(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function F(e){let t=(0,C.c)(7),{login:n,host:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=b(),t[0]=a):a=t[0];let o=a,s;t[1]!==i||t[2]!==n?(s={login:n,host:i,cliCommand:o},t[1]=i,t[2]=n,t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,A.jsx)(`code`,{translate:`no`})},t[4]=c):c=t[4];let l;return t[5]===s?l=t[6]:(l=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`o8OY2K`,values:s,components:c})}),t[5]=s,t[6]=l),l}var I={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function ne(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??v(),t[0]=n,t[1]=u);let p=u,m=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let _=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),ee=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),[D,O]=(0,S.useState)(``),[k,te]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,ne]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==_||t[7]!==m||t[8]!==b?(G=()=>{if(W.current||m===null||_||!b)return;let e=P(m);e&&(W.current=!0,O(e))},K=[m,_,b],t[6]=_,t[7]=m,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==D||t[13]!==p||t[14]!==j||t[15]!==k?(q=async function(){if(U.current)return;let e=D.trim(),t=k.trim(),n=j.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,ne(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));ne(!1),U.current=!1,r.ok?(M(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=D,t[13]=p,t[14]=j,t[15]=k,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==_||t[22]!==m||t[23]!==b?(X=m!==null&&!_&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=_,t[22]=m,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?ee:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,O(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==D||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(h,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...I,"aria-invalid":$,"aria-describedby":ae,value:D,onChange:oe}),t[30]=D,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===w?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:w,children:le}),t[40]=w,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>te(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==k||t[44]!==T||t[45]!==w?(fe=(0,A.jsx)(h,{id:w,type:`text`,autoComplete:`off`,...I,"aria-describedby":T,value:k,onChange:de}),t[43]=k,t[44]=T,t[45]=w,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===T?me=t[49]:(me=(0,A.jsx)(`p`,{id:T,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=T,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===E?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:E,children:ge}),t[55]=E,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>M(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==j||t[59]!==E?(ye=(0,A.jsx)(h,{id:E,type:`password`,autoComplete:`off`,...I,value:j,onChange:ve}),t[58]=j,t[59]=E,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==N||t[66]!==j||t[67]!==k?(xe=N||!D.trim()||!k.trim()||!j.trim(),t[64]=D,t[65]=N,t[66]=j,t[67]=k,t[68]=xe):xe=t[68];let Se;t[69]===N?Se=t[70]:(Se=N?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=N,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(F,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==ee||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?ee:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=ee,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function L(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function R(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function z(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./label-CvMpFFbN.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./config-errors-DDAH9fqy.js";import{n as l,r as u}from"./constants-github-B7yhDvQc.js";import{f as d,l as f}from"./SyncStatusBadge-Dydd5r0z.js";import{t as p}from"./trash-2-CchZ0T47.js";import{t as m}from"./use-git-sync-status-PkMYmN4D.js";import{t as h}from"./input-BsFOyzfK.js";import{t as g}from"./skeleton-izVZCkjV.js";import{a as _,n as v,t as y}from"./AuthModal-CDv9Ka9d.js";import{t as b}from"./channel-cli-copy-BySq87hR.js";import{n as x}from"./auth-state-cache-Bx6C01Jt.js";import{t as ee}from"./SettingsSectionHeader-BKhNIRp2.js";var S=e(n(),1),C=a(),w=`[a-z0-9](?:[a-z0-9-]*[a-z0-9])?`,T=RegExp(`^${w}(?:\\.${w})*$`),E=/^[a-z][a-z0-9+.-]*:\/\//i;function D(e){if(E.test(e))try{return new URL(e).host}catch{return null}let t=e.split(`/`)[0]??``;return t.slice(t.lastIndexOf(`@`)+1).replace(/:(?!\d+$).*$/,``)}function O(e,t){let n=e.trim();if(n===``)return{ok:!1,reason:`empty`};let r=D(n);if(r===null||r===``)return{ok:!1,reason:`invalid`};let i=u(r);return T.test(i)?i===`github.com`?{ok:!1,reason:`github-com`}:t.has(i)?{ok:!1,reason:`duplicate`}:{ok:!0,host:i}:{ok:!1,reason:`invalid`}}function k(e){let t=e.git?.hosts??{};return Object.entries(t).filter(([,e])=>e?.provider===`github`).map(([e])=>e).sort((e,t)=>e.localeCompare(t))}var A=t();function te(e){let t=(0,C.c)(59),{binding:n}=e,{_:a}=i(),o=(0,S.useId)(),l=(0,S.useId)(),u;t[0]===n?u=t[1]:(u=()=>k(n.current()),t[0]=n,t[1]=u);let[d,f]=(0,S.useState)(u),[m,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(!1),[x,ee]=(0,S.useState)(null),w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=new Map,t[2]=w):w=t[2];let T=(0,S.useRef)(w),E=(0,S.useRef)(null),D,te;t[3]===x?(D=t[4],te=t[5]):(D=()=>{x!==null&&(((x.host===null?null:T.current.get(x.host))??E.current)?.focus(),ee(null))},te=[x],t[3]=x,t[4]=D,t[5]=te),(0,S.useEffect)(D,te);let M,N;t[6]===n?(M=t[7],N=t[8]):(M=()=>n.subscribe(e=>f(k(e))),N=[n],t[6]=n,t[7]=M,t[8]=N),(0,S.useEffect)(M,N);let P;t[9]===a?P=t[10]:(P=function(e){switch(e){case`empty`:return a({id:`cFONFy`});case`invalid`:return a({id:`QsnBxE`});case`github-com`:return a({id:`UK3GW4`});case`duplicate`:return a({id:`DEkRZA`})}},t[9]=a,t[10]=P);let F=P,I;t[11]!==n||t[12]!==m||t[13]!==d||t[14]!==F?(I=function(e){e.preventDefault();let t=O(m,new Set(d.map(j)));if(!t.ok){v(F(t.reason));return}let r=n.patch({git:{hosts:{[t.host]:{provider:`github`}}}});if(!r.ok){v(c(r.error));return}f(k(r.effective)),g(``),v(null),b(!0)},t[11]=n,t[12]=m,t[13]=d,t[14]=F,t[15]=I):I=t[15];let ne=I,L;t[16]!==n||t[17]!==d?(L=function(e){let t=d.indexOf(e),r=d[t+1]??d[t-1]??null,i=n.patch({git:{hosts:{[e]:null}}});if(!i.ok){v(c(i.error));return}f(k(i.effective)),ee({host:r}),v(null),b(!0)},t[16]=n,t[17]=d,t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,A.jsx)(`h4`,{id:`settings-enterprise-hosts-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`J2-D_a`})}),t[19]=z):z=t[19];let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,A.jsx)(r,{id:`PgY2nN`}),t[20]=B):B=t[20];let V;t[21]===o?V=t[22]:(V=(0,A.jsxs)(`div`,{children:[z,(0,A.jsx)(`p`,{id:o,className:`text-1sm text-muted-foreground`,children:B})]}),t[21]=o,t[22]=V);let H;t[23]!==a||t[24]!==R||t[25]!==d?(H=d.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,"data-testid":`settings-enterprise-hosts-list`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,A.jsx)(s,{variant:`ghost`,size:`icon`,className:`size-7`,"aria-label":a({id:`xVMoYb`,values:{host:e}}),ref:t=>{t?T.current.set(e,t):T.current.delete(e)},onClick:()=>R(e),children:(0,A.jsx)(p,{"aria-hidden":`true`})})]},e))}):(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-enterprise-hosts-empty`,children:(0,A.jsx)(r,{id:`HK2eIK`})}),t[23]=a,t[24]=R,t[25]=d,t[26]=H):H=t[26];let U;t[27]===a?U=t[28]:(U=a({id:`Qbf7Q4`}),t[27]=a,t[28]=U);let W=_!==null,G=_===null?o:`${o} ${l}`,K;t[29]===_?K=t[30]:(K=e=>{g(e.target.value),_!==null&&v(null)},t[29]=_,t[30]=K);let q;t[31]!==m||t[32]!==U||t[33]!==W||t[34]!==G||t[35]!==K?(q=(0,A.jsx)(h,{ref:E,value:m,"aria-label":U,placeholder:`github.example.com`,autoComplete:`off`,spellCheck:!1,inputMode:`url`,className:`h-7 flex-1 font-mono text-xs`,"aria-invalid":W,"aria-describedby":G,onChange:K}),t[31]=m,t[32]=U,t[33]=W,t[34]=G,t[35]=K,t[36]=q):q=t[36];let re;t[37]===m?re=t[38]:(re=m.trim(),t[37]=m,t[38]=re);let ie=re===``,J;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsx)(r,{id:`ALFlyF`}),t[39]=J):J=t[39];let Y;t[40]===ie?Y=t[41]:(Y=(0,A.jsx)(s,{type:`submit`,size:`sm`,variant:`secondary`,disabled:ie,className:`h-7 px-2 font-normal text-xs`,children:J}),t[40]=ie,t[41]=Y);let X;t[42]!==ne||t[43]!==q||t[44]!==Y?(X=(0,A.jsxs)(`form`,{className:`flex items-center gap-2 pt-1`,onSubmit:ne,noValidate:!0,children:[q,Y]}),t[42]=ne,t[43]=q,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==_||t[47]!==l?(Z=_===null?null:(0,A.jsx)(`p`,{id:l,role:`alert`,className:`text-1sm text-destructive`,children:_}),t[46]=_,t[47]=l,t[48]=Z):Z=t[48];let Q;t[49]===y?Q=t[50]:(Q=y?(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`3LuFP-`})}):null,t[49]=y,t[50]=Q);let $;t[51]!==H||t[52]!==X||t[53]!==Z||t[54]!==Q?($=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-lg border bg-card p-3`,children:[H,X,Z,Q]}),t[51]=H,t[52]=X,t[53]=Z,t[54]=Q,t[55]=$):$=t[55];let ae;return t[56]!==V||t[57]!==$?(ae=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-enterprise-hosts-title`,className:`space-y-4`,"data-field":`section:enterprise-hosts`,"data-testid":`settings-enterprise-hosts`,children:[V,$]}),t[56]=V,t[57]=$,t[58]=ae):ae=t[58],ae}function j(e){return u(e)}function M(e){let t=(0,C.c)(43),{authQueryTransport:n,authTransport:a,userBinding:o}=e,{_:s}=i(),c;t[0]===n?c=t[1]:(c=n??_(),t[0]=n,t[1]=c);let l=c,u=m()?.remote??null,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={phase:`loading`},t[2]=d):d=t[2];let[f,p]=(0,S.useState)(d),[h,g]=(0,S.useState)(!1),[v,b]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),E=(0,S.useRef)(!1),D;t[3]===l?D=t[4]:(D=async function(){p({phase:`loading`});try{let e=await l.status();p({phase:`loaded`,result:e}),x(e)}catch(e){console.warn(`[AccountSection] GitHub status check failed`,e),p({phase:`check-failed`})}},t[3]=l,t[4]=D);let O=D,k;t[5]===O?k=t[6]:(k=()=>{O()},t[5]=O,t[6]=k);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j=[],t[7]=j):j=t[7],(0,S.useEffect)(k,j);let M;t[8]!==s||t[9]!==O||t[10]!==l?(M=async function(){if(E.current)return;E.current=!0,g(!1),b(!0),T(null);let e=null;try{let t=l.signout?await l.signout():{ok:!1,error:s({id:`8cpOa8`})};t.ok||(e=t.error??s({id:`8cpOa8`}))}catch(t){console.warn(`[AccountSection] GitHub disconnect failed`,t),e=s({id:`8cpOa8`})}await O(),e&&T(e),b(!1),E.current=!1},t[8]=s,t[9]=O,t[10]=l,t[11]=M):M=t[11];let P=M,F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,A.jsx)(r,{id:`MpZRQy`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,A.jsx)(ee,{titleId:`settings-account-title`,title:F,scope:`user`,children:(0,A.jsx)(r,{id:`pd6t3G`})}),t[13]=I):I=t[13];let L;t[14]!==w||t[15]!==v||t[16]!==P||t[17]!==O||t[18]!==f?(L=f.phase===`loaded`&&f.result.unsupportedOrigin!==void 0?null:(0,A.jsxs)(`section`,{"aria-labelledby":`settings-github-account-title`,className:`space-y-4`,"data-field":`section:github-account`,children:[(0,A.jsx)(`h4`,{id:`settings-github-account-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`RkXlPZ`})}),(0,A.jsx)(N,{status:f,disconnecting:v,disconnectError:w,onRetry:()=>void O(),onConnect:()=>g(!0),onDisconnect:()=>void P()})]}),t[14]=w,t[15]=v,t[16]=P,t[17]=O,t[18]=f,t[19]=L):L=t[19];let R;t[20]===o?R=t[21]:(R=(0,A.jsx)(te,{binding:o}),t[20]=o,t[21]=R);let z;t[22]!==a||t[23]!==u?(z=(0,A.jsx)(ne,{authTransport:a,remote:u}),t[22]=a,t[23]=u,t[24]=z):z=t[24];let B;t[25]!==R||t[26]!==z||t[27]!==L?(B=(0,A.jsxs)(`div`,{className:`space-y-8`,children:[L,R,z]}),t[25]=R,t[26]=z,t[27]=L,t[28]=B):B=t[28];let V;t[29]===O?V=t[30]:(V=e=>{g(e),e||O()},t[29]=O,t[30]=V);let H=f.phase===`loaded`?f.result.host:void 0,U=f.phase===`loaded`?f.result.ghAvailable:void 0,W;t[31]===O?W=t[32]:(W=()=>{O()},t[31]=O,t[32]=W);let G;t[33]!==h||t[34]!==a||t[35]!==V||t[36]!==H||t[37]!==U||t[38]!==W?(G=(0,A.jsx)(y,{open:h,onOpenChange:V,transport:a,host:H,ghAvailable:U,onSuccess:W}),t[33]=h,t[34]=a,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G):G=t[39];let K;return t[40]!==B||t[41]!==G?(K=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-account-title`,className:`space-y-5`,"data-testid":`settings-account`,children:[I,B,G]}),t[40]=B,t[41]=G,t[42]=K):K=t[42],K}function N(e){let t=(0,C.c)(8),{status:n,disconnecting:i,disconnectError:a,onRetry:o,onConnect:c,onDisconnect:l}=e,u;return t[0]!==a||t[1]!==i||t[2]!==c||t[3]!==l||t[4]!==o||t[5]!==n.phase||t[6]!==n.result?(u=n.phase===`loading`?(0,A.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-busy":`true`,className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-loading`,children:[(0,A.jsx)(`span`,{className:`sr-only`,children:(0,A.jsx)(r,{id:`IWGfGF`})}),(0,A.jsx)(g,{className:`h-4 w-40`}),(0,A.jsx)(g,{className:`h-8 w-32`})]}):n.phase===`check-failed`?(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-check-failed`,children:[(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`T_wG4n`})}),(0,A.jsx)(s,{variant:`outline`,size:`sm`,onClick:o,children:(0,A.jsx)(r,{id:`KDw4GX`})})]}):n.result.authenticated?n.result.tier===`A`?(0,A.jsx)(R,{login:n.result.login,host:n.result.host}):(0,A.jsx)(L,{login:n.result.login,host:n.result.host,disconnecting:i,error:a,onDisconnect:l}):(0,A.jsx)(z,{onConnect:c}),t[0]=a,t[1]=i,t[2]=c,t[3]=l,t[4]=o,t[5]=n.phase,t[6]=n.result,t[7]=u):u=t[7],u}function P(e){let t=e.split(`/`)[0]??``;return l(t)?t:``}function F(e){let t=(0,C.c)(7),{login:n,host:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=b(),t[0]=a):a=t[0];let o=a,s;t[1]!==i||t[2]!==n?(s={login:n,host:i,cliCommand:o},t[1]=i,t[2]=n,t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c={0:(0,A.jsx)(`code`,{translate:`no`})},t[4]=c):c=t[4];let l;return t[5]===s?l=t[6]:(l=(0,A.jsx)(`p`,{role:`status`,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-success`,children:(0,A.jsx)(r,{id:`o8OY2K`,values:s,components:c})}),t[5]=s,t[6]=l),l}var I={"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0,"data-form-type":`other`};function ne(e){let t=(0,C.c)(89),{authTransport:n,remote:a}=e,{_:c}=i(),u;t[0]===n?u=t[1]:(u=n??v(),t[0]=n,t[1]=u);let p=u,m=a?.label??null,g;t[2]===a?g=t[3]:(g=a?f(a):!1,t[2]=a,t[3]=g);let _=g,y;t[4]===a?y=t[5]:(y=d(a),t[4]=a,t[5]=y);let b=y,x=(0,S.useId)(),ee=(0,S.useId)(),w=(0,S.useId)(),T=(0,S.useId)(),E=(0,S.useId)(),[D,O]=(0,S.useState)(``),[k,te]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,ne]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),U=(0,S.useRef)(!1),W=(0,S.useRef)(!1),G,K;t[6]!==_||t[7]!==m||t[8]!==b?(G=()=>{if(W.current||m===null||_||!b)return;let e=P(m);e&&(W.current=!0,O(e))},K=[m,_,b],t[6]=_,t[7]=m,t[8]=b,t[9]=G,t[10]=K):(G=t[9],K=t[10]),(0,S.useEffect)(G,K);let q;t[11]!==c||t[12]!==D||t[13]!==p||t[14]!==j||t[15]!==k?(q=async function(){if(U.current)return;let e=D.trim(),t=k.trim(),n=j.trim();if(!e||!t||!n)return;if(!l(e)){H(null),B(!0),R(c({id:`rZFxkH`}));return}if(B(!1),!p.hostToken){R(c({id:`iMYFJM`}));return}U.current=!0,ne(!0),R(null),H(null);let r=await p.hostToken(e,t,n).catch(e=>(console.warn(`[AccountSection] storing a host token failed`,e),{ok:!1,login:void 0,error:c({id:`Q5fqMz`})}));ne(!1),U.current=!1,r.ok?(M(``),H({login:r.login||t,host:e})):R(r.error??c({id:`sNeKjP`}))},t[11]=c,t[12]=D,t[13]=p,t[14]=j,t[15]=k,t[16]=q):q=t[16];let re=q,ie;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,A.jsx)(`h4`,{id:`settings-host-tokens-title`,className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`jbhCDS`})}),t[17]=ie):ie=t[17];let J;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,A.jsxs)(`div`,{children:[ie,(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:(0,A.jsx)(r,{id:`-nA68n`})})]}),t[18]=J):J=t[18];let Y;t[19]===re?Y=t[20]:(Y=e=>{e.preventDefault(),re()},t[19]=re,t[20]=Y);let X;t[21]!==_||t[22]!==m||t[23]!==b?(X=m!==null&&!_&&!b?(0,A.jsx)(`p`,{className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-not-https`,children:(0,A.jsx)(r,{id:`OWs-8P`})}):null,t[21]=_,t[22]=m,t[23]=b,t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,A.jsx)(r,{id:`Ai2U7L`}),t[25]=Z):Z=t[25];let Q;t[26]===x?Q=t[27]:(Q=(0,A.jsx)(o,{htmlFor:x,children:Z}),t[26]=x,t[27]=Q);let $=z||void 0,ae=z&&L?ee:void 0,oe;t[28]===z?oe=t[29]:(oe=e=>{W.current=!0,O(e.target.value),z&&(B(!1),R(null))},t[28]=z,t[29]=oe);let se;t[30]!==D||t[31]!==x||t[32]!==$||t[33]!==ae||t[34]!==oe?(se=(0,A.jsx)(h,{id:x,type:`text`,placeholder:`git.example.com`,autoComplete:`off`,...I,"aria-invalid":$,"aria-describedby":ae,value:D,onChange:oe}),t[30]=D,t[31]=x,t[32]=$,t[33]=ae,t[34]=oe,t[35]=se):se=t[35];let ce;t[36]!==Q||t[37]!==se?(ce=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[Q,se]}),t[36]=Q,t[37]=se,t[38]=ce):ce=t[38];let le;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,A.jsx)(r,{id:`7sNhEz`}),t[39]=le):le=t[39];let ue;t[40]===w?ue=t[41]:(ue=(0,A.jsx)(o,{htmlFor:w,children:le}),t[40]=w,t[41]=ue);let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>te(e.target.value),t[42]=de):de=t[42];let fe;t[43]!==k||t[44]!==T||t[45]!==w?(fe=(0,A.jsx)(h,{id:w,type:`text`,autoComplete:`off`,...I,"aria-describedby":T,value:k,onChange:de}),t[43]=k,t[44]=T,t[45]=w,t[46]=fe):fe=t[46];let pe;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,A.jsx)(r,{id:`azrR7I`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`}),2:(0,A.jsx)(`code`,{translate:`no`})}}),t[47]=pe):pe=t[47];let me;t[48]===T?me=t[49]:(me=(0,A.jsx)(`p`,{id:T,className:`text-1sm text-muted-foreground`,"data-testid":`settings-account-host-token-username-hint`,children:pe}),t[48]=T,t[49]=me);let he;t[50]!==ue||t[51]!==fe||t[52]!==me?(he=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[ue,fe,me]}),t[50]=ue,t[51]=fe,t[52]=me,t[53]=he):he=t[53];let ge;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,A.jsx)(r,{id:`SkUcEr`}),t[54]=ge):ge=t[54];let _e;t[55]===E?_e=t[56]:(_e=(0,A.jsx)(o,{htmlFor:E,children:ge}),t[55]=E,t[56]=_e);let ve;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>M(e.target.value),t[57]=ve):ve=t[57];let ye;t[58]!==j||t[59]!==E?(ye=(0,A.jsx)(h,{id:E,type:`password`,autoComplete:`off`,...I,value:j,onChange:ve}),t[58]=j,t[59]=E,t[60]=ye):ye=t[60];let be;t[61]!==_e||t[62]!==ye?(be=(0,A.jsxs)(`div`,{className:`space-y-1`,children:[_e,ye]}),t[61]=_e,t[62]=ye,t[63]=be):be=t[63];let xe;t[64]!==D||t[65]!==N||t[66]!==j||t[67]!==k?(xe=N||!D.trim()||!k.trim()||!j.trim(),t[64]=D,t[65]=N,t[66]=j,t[67]=k,t[68]=xe):xe=t[68];let Se;t[69]===N?Se=t[70]:(Se=N?(0,A.jsx)(r,{id:`1yHVE-`}):(0,A.jsx)(r,{id:`zXZJoN`}),t[69]=N,t[70]=Se);let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,A.jsx)(s,{type:`submit`,"data-testid":`settings-account-host-token-submit`,disabled:xe,children:Se}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;t[74]===V?we=t[75]:(we=V?(0,A.jsx)(F,{login:V.login,host:V.host}):null,t[74]=V,t[75]=we);let Te;t[76]!==L||t[77]!==ee||t[78]!==z?(Te=L?(0,A.jsx)(`p`,{id:z?ee:void 0,role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-host-token-error`,children:L}):null,t[76]=L,t[77]=ee,t[78]=z,t[79]=Te):Te=t[79];let Ee;return t[80]!==X||t[81]!==ce||t[82]!==he||t[83]!==be||t[84]!==Ce||t[85]!==we||t[86]!==Te||t[87]!==Y?(Ee=(0,A.jsxs)(`section`,{"aria-labelledby":`settings-host-tokens-title`,className:`space-y-4`,"data-field":`section:host-tokens`,children:[J,(0,A.jsxs)(`form`,{className:`space-y-3 rounded-lg border bg-card p-3`,"data-testid":`settings-account-host-token`,"aria-labelledby":`settings-host-tokens-title`,autoComplete:`off`,onSubmit:Y,children:[X,ce,he,be,Ce,we,Te]})]}),t[80]=X,t[81]=ce,t[82]=he,t[83]=be,t[84]=Ce,t[85]=we,t[86]=Te,t[87]=Y,t[88]=Ee):Ee=t[88],Ee}function L(e){let t=(0,C.c)(21),{login:n,host:i,disconnecting:a,error:o,onDisconnect:c}=e,l;t[0]!==i||t[1]!==n?(l=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`nxlOpL`})}),t[3]=u):u=t[3];let d;t[4]===l?d=t[5]:(d=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),t[4]=l,t[5]=d);let f;t[6]===a?f=t[7]:(f=a?(0,A.jsx)(r,{id:`rppgXF`}):(0,A.jsx)(r,{id:`-K0AvT`}),t[6]=a,t[7]=f);let p;t[8]!==a||t[9]!==c||t[10]!==f?(p=(0,A.jsx)(s,{variant:`outline`,onClick:c,disabled:a,"aria-describedby":`settings-account-disconnect-caveat`,"data-testid":`settings-account-disconnect`,children:f}),t[8]=a,t[9]=c,t[10]=f,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==p?(m=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[d,p]}),t[12]=d,t[13]=p,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,A.jsx)(`p`,{id:`settings-account-disconnect-caveat`,className:`text-muted-foreground text-1sm`,"data-testid":`settings-account-disconnect-caveat`,children:(0,A.jsx)(r,{id:`msOK6I`})}),t[15]=h):h=t[15];let g;t[16]===o?g=t[17]:(g=o?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,"data-testid":`settings-account-disconnect-error`,children:o}):null,t[16]=o,t[17]=g);let _;return t[18]!==m||t[19]!==g?(_=(0,A.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,"data-testid":`settings-account-connected`,children:[m,h,g]}),t[18]=m,t[19]=g,t[20]=_):_=t[20],_}function R(e){let t=(0,C.c)(6),{login:n,host:i}=e,a;t[0]!==i||t[1]!==n?(a=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`bc7aCh`,values:{host:i,login:n}})}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`UcTm1A`,components:{0:(0,A.jsx)(`code`,{translate:`no`}),1:(0,A.jsx)(`code`,{translate:`no`})}})}),t[3]=o):o=t[3];let s;return t[4]===a?s=t[5]:(s=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-gh-cli`,children:(0,A.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[a,o]})}),t[4]=a,t[5]=s),s}function z(e){let t=(0,C.c)(5),{onConnect:n}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:(0,A.jsx)(r,{id:`S33tz3`})}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[i,(0,A.jsx)(`p`,{className:`text-muted-foreground text-1sm`,children:(0,A.jsx)(r,{id:`9djC8C`})})]}),t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,A.jsx)(r,{id:`5lWFkC`}),t[2]=o):o=t[2];let c;return t[3]===n?c=t[4]:(c=(0,A.jsx)(`div`,{className:`rounded-md border p-3`,"data-testid":`settings-account-disconnected`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[a,(0,A.jsx)(s,{onClick:n,"data-testid":`settings-account-connect`,children:o})]})}),t[3]=n,t[4]=c),c}export{M as AccountSection};
|