@kb-labs/cli-commands 2.27.0 → 2.29.0

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.
@@ -1,5 +1,5 @@
1
- import { d as CommandManifest, A as AvailabilityCheck, R as RegisteredCommand, D as DiscoveryResult } from '../discover-Be0ez3AR.js';
2
- export { b as CacheFile, c as CommandLookupResult, e as CommandModule, f as CommandType, F as FlagDefinition, G as GlobalFlags, g as PackageCacheEntry, P as ProductGroup, _ as __test, h as discoverManifests, i as discoverManifestsByNamespace, j as findCommand, k as findCommandWithType, r as registry, l as resetInProcCache } from '../discover-Be0ez3AR.js';
1
+ import { d as CommandManifest, A as AvailabilityCheck, R as RegisteredCommand, D as DiscoveryResult } from '../discover-DhqYgS-M.js';
2
+ export { b as CacheFile, c as CommandLookupResult, e as CommandModule, f as CommandType, F as FlagDefinition, G as GlobalFlags, g as PackageCacheEntry, P as ProductGroup, _ as __test, h as discoverManifests, i as discoverManifestsByNamespace, j as findCommand, k as findCommandWithType, r as registry, l as resetInProcCache } from '../discover-DhqYgS-M.js';
3
3
  import { ILogger } from '@kb-labs/core-platform';
4
4
  import '@kb-labs/plugin-contracts';
5
5
 
@@ -320,6 +320,15 @@ async function computePluginsStateHash(cwd) {
320
320
  return "";
321
321
  }
322
322
  }
323
+ async function computeMarketplaceLockHash(cwd) {
324
+ const lockPath = path2.join(cwd, ".kb", "marketplace.lock");
325
+ try {
326
+ const content = await promises.readFile(lockPath, "utf8");
327
+ return createHash("sha256").update(content).digest("hex");
328
+ } catch {
329
+ return "";
330
+ }
331
+ }
323
332
  async function detectNewWorkspacePackages(cwd, cachedPackages) {
324
333
  if (!cachedPackages) {
325
334
  return true;
@@ -541,6 +550,30 @@ async function discoverWorkspace(cwd) {
541
550
  }
542
551
  }
543
552
  }
553
+ const localPluginPattern = path2.join(
554
+ ".kb",
555
+ "plugins",
556
+ "*",
557
+ "packages",
558
+ "*-entry",
559
+ PACKAGE_JSON
560
+ );
561
+ const localPluginFiles = await glob(localPluginPattern, {
562
+ cwd,
563
+ absolute: false,
564
+ ignore: ["**/node_modules/**"]
565
+ });
566
+ for (const pkgFile of localPluginFiles) {
567
+ const pkgRoot = path2.dirname(path2.join(cwd, pkgFile));
568
+ const pkg = await readPackageJson(path2.join(cwd, pkgFile));
569
+ if (!pkg) {
570
+ continue;
571
+ }
572
+ const manifestInfo = await findManifestPath(pkgRoot, pkg);
573
+ if (manifestInfo.path) {
574
+ packageInfos.push({ pkgRoot, pkg, manifestPath: manifestInfo.path });
575
+ }
576
+ }
544
577
  const loadPromises = packageInfos.map(async ({ pkgRoot, pkg, manifestPath }) => {
545
578
  const pkgStart = Date.now();
546
579
  try {
@@ -809,6 +842,11 @@ async function loadCache(cwd) {
809
842
  log("debug", "Cache invalidated: .kb/plugins.json changed");
810
843
  return null;
811
844
  }
845
+ const currentMarketplaceLockHash = await computeMarketplaceLockHash(cwd);
846
+ if (currentMarketplaceLockHash && cache.marketplaceLockHash && cache.marketplaceLockHash !== currentMarketplaceLockHash) {
847
+ log("debug", "Cache invalidated: .kb/marketplace.lock changed");
848
+ return null;
849
+ }
812
850
  const parsedCache = cache;
813
851
  parsedCache.ttlMs = parsedCache.ttlMs ?? DISK_CACHE_TTL_MS;
814
852
  for (const entry of Object.values(parsedCache.packages)) {
@@ -906,6 +944,7 @@ async function saveCache(cwd, results) {
906
944
  const lockfileHash = await computeLockfileHash(cwd);
907
945
  const configHash = await computeConfigHash(cwd);
908
946
  const pluginsStateHash = await computePluginsStateHash(cwd);
947
+ const marketplaceLockHash = await computeMarketplaceLockHash(cwd);
909
948
  if (lockfileHash) {
910
949
  stateHasher.update(lockfileHash);
911
950
  }
@@ -915,6 +954,9 @@ async function saveCache(cwd, results) {
915
954
  if (pluginsStateHash) {
916
955
  stateHasher.update(pluginsStateHash);
917
956
  }
957
+ if (marketplaceLockHash) {
958
+ stateHasher.update(marketplaceLockHash);
959
+ }
918
960
  const cache = {
919
961
  version: process.version,
920
962
  cliVersion: process.env.CLI_VERSION || "0.1.0",
@@ -924,6 +966,7 @@ async function saveCache(cwd, results) {
924
966
  lockfileHash: lockfileHash || void 0,
925
967
  configHash: configHash || void 0,
926
968
  pluginsStateHash: pluginsStateHash || void 0,
969
+ marketplaceLockHash: marketplaceLockHash || void 0,
927
970
  packages
928
971
  };
929
972
  try {
@@ -1180,6 +1223,7 @@ function checkCollision(manifest, existing, currentSource, namespace) {
1180
1223
  }
1181
1224
  function preflightManifests(discoveryResults, logger) {
1182
1225
  const log2 = logger ?? platform.logger;
1226
+ const logLevel = getLogLevel();
1183
1227
  const valid = [];
1184
1228
  const skipped = [];
1185
1229
  for (const result of discoveryResults) {
@@ -1197,6 +1241,10 @@ function preflightManifests(discoveryResults, logger) {
1197
1241
  reason
1198
1242
  });
1199
1243
  log2.warn(`Preflight skipped manifest ${manifestId}: ${reason}`);
1244
+ if (logLevel === "debug") {
1245
+ process.stderr.write(`[debug][preflight] skipped ${manifestId} (${result.source}): ${reason}
1246
+ `);
1247
+ }
1200
1248
  }
1201
1249
  }
1202
1250
  if (allowed.length > 0) {