claudekit-cli 3.36.0-dev.15 → 3.36.0-dev.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +107 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12378,6 +12378,30 @@ function findPortableInstallations(registry, item, type, provider, global2) {
12378
12378
  return true;
12379
12379
  });
12380
12380
  }
12381
+ async function updateAppliedManifestVersion(version) {
12382
+ await withRegistryLock(async () => {
12383
+ const registry = await readPortableRegistry();
12384
+ registry.appliedManifestVersion = version;
12385
+ await writePortableRegistry(registry);
12386
+ });
12387
+ }
12388
+ async function removeInstallationsByFilter(predicate) {
12389
+ return withRegistryLock(async () => {
12390
+ const registry = await readPortableRegistry();
12391
+ const removed = [];
12392
+ registry.installations = registry.installations.filter((entry) => {
12393
+ if (predicate(entry)) {
12394
+ removed.push(entry);
12395
+ return false;
12396
+ }
12397
+ return true;
12398
+ });
12399
+ if (removed.length > 0) {
12400
+ await writePortableRegistry(registry);
12401
+ }
12402
+ return removed;
12403
+ });
12404
+ }
12381
12405
  async function syncPortableRegistry() {
12382
12406
  return withRegistryLock(async () => {
12383
12407
  const registry = await readPortableRegistry();
@@ -12934,8 +12958,62 @@ async function installCodexToml(items, provider, portableType, options2) {
12934
12958
  };
12935
12959
  }
12936
12960
  }
12961
+ async function cleanupStaleCodexConfigEntries(options2) {
12962
+ const config = providers[options2.provider];
12963
+ const pathConfig = config.agents;
12964
+ if (!pathConfig)
12965
+ return [];
12966
+ const basePath = options2.global ? pathConfig.globalPath : pathConfig.projectPath;
12967
+ if (!basePath)
12968
+ return [];
12969
+ const agentsDir = resolve(basePath);
12970
+ const configTomlPath = join3(dirname2(agentsDir), "config.toml");
12971
+ if (!existsSync3(configTomlPath))
12972
+ return [];
12973
+ try {
12974
+ return await withCodexTargetLock(configTomlPath, async () => {
12975
+ const existing = await readFile3(configTomlPath, "utf-8");
12976
+ const managedEntries = extractManagedAgentEntries(existing);
12977
+ if (managedEntries.size === 0)
12978
+ return [];
12979
+ const staleSlugs = [];
12980
+ const validEntries = new Map;
12981
+ for (const [slug, entry] of managedEntries) {
12982
+ const tomlPath = join3(agentsDir, `${slug}.toml`);
12983
+ if (existsSync3(tomlPath)) {
12984
+ validEntries.set(slug, entry);
12985
+ } else {
12986
+ staleSlugs.push(slug);
12987
+ }
12988
+ }
12989
+ if (staleSlugs.length === 0)
12990
+ return [];
12991
+ if (validEntries.size === 0) {
12992
+ const analysis = analyzeConfigToml(existing);
12993
+ await writeFile2(configTomlPath, analysis.unmanagedContent, "utf-8");
12994
+ } else {
12995
+ const sortedEntries = [...validEntries.entries()].sort(([a3], [b3]) => a3.localeCompare(b3)).map(([, entry]) => entry);
12996
+ const managedBlock = sortedEntries.join(`
12997
+
12998
+ `);
12999
+ const mergeResult = mergeConfigTomlWithDiagnostics(existing, managedBlock);
13000
+ if (mergeResult.error) {
13001
+ logger.verbose(`[codex-cleanup] Failed to merge config.toml: ${mergeResult.error}`);
13002
+ return [];
13003
+ }
13004
+ await writeFile2(configTomlPath, mergeResult.content, "utf-8");
13005
+ }
13006
+ logger.verbose(`[codex-cleanup] Removed ${staleSlugs.length} stale config.toml entries: ${staleSlugs.join(", ")}`);
13007
+ return staleSlugs;
13008
+ });
13009
+ } catch (error) {
13010
+ logger.verbose(`[codex-cleanup] Failed to clean up config.toml: ${error instanceof Error ? error.message : "Unknown"}`);
13011
+ return [];
13012
+ }
13013
+ }
12937
13014
  var import_proper_lockfile2, SENTINEL_START = "# --- ck-managed-agents-start ---", SENTINEL_END = "# --- ck-managed-agents-end ---", MAX_WINDOWS_PATH_LENGTH = 240;
12938
13015
  var init_codex_toml_installer = __esm(() => {
13016
+ init_logger();
12939
13017
  init_checksum_utils();
12940
13018
  init_fm_to_codex_toml();
12941
13019
  init_converters();
@@ -56009,7 +56087,7 @@ var package_default;
56009
56087
  var init_package = __esm(() => {
56010
56088
  package_default = {
56011
56089
  name: "claudekit-cli",
56012
- version: "3.36.0-dev.15",
56090
+ version: "3.36.0-dev.16",
56013
56091
  description: "CLI tool for bootstrapping and updating ClaudeKit projects",
56014
56092
  type: "module",
56015
56093
  repository: {
@@ -92344,6 +92422,7 @@ init_logger();
92344
92422
  init_agents_discovery();
92345
92423
  init_commands_discovery();
92346
92424
  init_checksum_utils();
92425
+ init_codex_toml_installer();
92347
92426
  init_config_discovery();
92348
92427
 
92349
92428
  // src/commands/portable/conflict-resolver.ts
@@ -92665,6 +92744,7 @@ function displayMigrationSummary(plan, results, options2) {
92665
92744
 
92666
92745
  // src/commands/migrate/migrate-command.ts
92667
92746
  init_portable_installer();
92747
+ init_portable_manifest();
92668
92748
  init_portable_registry();
92669
92749
  init_provider_registry();
92670
92750
  init_reconciler();
@@ -93166,6 +93246,32 @@ async function migrateCommand(options2) {
93166
93246
  }
93167
93247
  }
93168
93248
  }
93249
+ for (const provider of selectedProviders) {
93250
+ const providerConfig = providers[provider];
93251
+ if (providerConfig.agents?.writeStrategy !== "codex-toml")
93252
+ continue;
93253
+ const staleSlugs = await cleanupStaleCodexConfigEntries({
93254
+ global: installGlobally,
93255
+ provider
93256
+ });
93257
+ if (staleSlugs.length > 0) {
93258
+ const staleSlugSet = new Set(staleSlugs.map((s) => `${s}.toml`));
93259
+ const removed = await removeInstallationsByFilter((i) => i.type === "agent" && i.provider === provider && i.global === installGlobally && staleSlugSet.has(basename16(i.path)));
93260
+ for (const entry of removed) {
93261
+ logger.verbose(`[migrate] Cleaned stale registry entry: ${entry.item} (${provider})`);
93262
+ }
93263
+ }
93264
+ }
93265
+ try {
93266
+ const kitRoot = (agentSource ? resolve24(agentSource, "..") : null) ?? (commandSource ? resolve24(commandSource, "..") : null) ?? (skillSource ? resolve24(skillSource, "..") : null) ?? null;
93267
+ const manifest = kitRoot ? await loadPortableManifest(kitRoot) : null;
93268
+ if (manifest?.cliVersion) {
93269
+ await updateAppliedManifestVersion(manifest.cliVersion);
93270
+ logger.verbose(`[migrate] Updated appliedManifestVersion to ${manifest.cliVersion}`);
93271
+ }
93272
+ } catch {
93273
+ logger.debug("[migrate] Failed to update appliedManifestVersion — will retry on next run");
93274
+ }
93169
93275
  installSpinner.stop("Migrate complete");
93170
93276
  displayMigrationSummary(plan, allResults, { color: useColor });
93171
93277
  const failed = allResults.filter((r2) => !r2.success);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudekit-cli",
3
- "version": "3.36.0-dev.15",
3
+ "version": "3.36.0-dev.16",
4
4
  "description": "CLI tool for bootstrapping and updating ClaudeKit projects",
5
5
  "type": "module",
6
6
  "repository": {