@pi-stef/catalog 0.3.1 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-stef/catalog",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Pi extension for managing skill/package catalogs.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -111,7 +111,11 @@ export async function syncCommand(
111
111
  errors: [],
112
112
  };
113
113
 
114
- // --- 1. Pull remote catalog (into memory only) ---------------------------
114
+ // --- 1. Read local catalog BEFORE pulling --------------------------------
115
+ // We need this to detect local-only packages that haven't been pushed yet.
116
+ const localCatalogBeforePull = readCatalog(ctx.home);
117
+
118
+ // --- 2. Pull remote catalog (into memory only) ---------------------------
115
119
  let remoteCatalog = false;
116
120
  let pulledData: { catalog: CatalogYaml; lock: LockFile } | undefined;
117
121
  try {
@@ -124,9 +128,24 @@ export async function syncCommand(
124
128
  summary.errors.push(message);
125
129
  }
126
130
 
127
- // --- 2. Reconcile --------------------------------------------------------
131
+ // --- 3. Reconcile --------------------------------------------------------
128
132
  // Use pulled catalog if available, otherwise read from disk
129
- const catalog = pulledData ? pulledData.catalog : readCatalog(ctx.home);
133
+ let catalog = pulledData ? pulledData.catalog : readCatalog(ctx.home);
134
+
135
+ // Merge local-only packages into the catalog.
136
+ // When a user adds a package locally (ct add) and then syncs, the pull
137
+ // would overwrite their addition. Detect local packages not in the remote
138
+ // and merge them back so they get pushed.
139
+ let hasLocalOnlyPackages = false;
140
+ if (pulledData) {
141
+ for (const [key, pkg] of Object.entries(localCatalogBeforePull.packages)) {
142
+ if (!(key in catalog.packages)) {
143
+ catalog.packages[key] = pkg;
144
+ hasLocalOnlyPackages = true;
145
+ }
146
+ }
147
+ }
148
+
130
149
  const installed = scanInstalled(ctx.home);
131
150
 
132
151
  // Build catalog entries for reconcile
@@ -206,7 +225,7 @@ export async function syncCommand(
206
225
  const hasGist = readCachedGistId(ctx.home) !== undefined;
207
226
  const localHasPackages = Object.keys(catalog.packages).length > 0;
208
227
 
209
- if (force || summary.actionCount > 0 || (!hasGist && localHasPackages)) {
228
+ if (force || summary.actionCount > 0 || hasLocalOnlyPackages || (!hasGist && localHasPackages)) {
210
229
  try {
211
230
  const updatedCatalog = readCatalog(ctx.home);
212
231
  const updatedLock = readLock(ctx.home);
@@ -237,7 +256,7 @@ export async function syncCommand(
237
256
  }
238
257
  }
239
258
 
240
- if (summary.actionCount === 0 && summary.errors.length === 0 && !force) {
259
+ if (summary.actionCount === 0 && summary.errors.length === 0 && !force && !hasLocalOnlyPackages) {
241
260
  ctx.ui.notify("Catalog already up to date.", "info");
242
261
  return;
243
262
  }
@@ -247,6 +266,9 @@ export async function syncCommand(
247
266
  if (summary.pulled) {
248
267
  parts.push("Pulled remote catalog.");
249
268
  }
269
+ if (hasLocalOnlyPackages) {
270
+ parts.push("Merged local-only packages.");
271
+ }
250
272
  if (plan.installs.length > 0) {
251
273
  parts.push(`${plan.installs.length} install(s): ${plan.installs.map((a) => a.key).join(", ")}`);
252
274
  }