@pi-stef/catalog 0.3.0 → 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 +10 -4
- package/src/commands/sync.ts +27 -5
- package/src/register.ts +20 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-stef/catalog",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Pi extension for managing skill/package catalogs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,10 +19,16 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@octokit/rest": "^21.0.0",
|
|
22
|
-
"
|
|
22
|
+
"@pi-stef/agent-workflows": "^0.3.0",
|
|
23
|
+
"@pi-stef/atlassian": "^0.3.0",
|
|
24
|
+
"@pi-stef/catalog": "^0.3.0",
|
|
25
|
+
"@pi-stef/figma": "^0.3.0",
|
|
26
|
+
"@pi-stef/paths": "^0.3.0",
|
|
27
|
+
"@pi-stef/team": "^0.3.0",
|
|
28
|
+
"@pi-stef/web": "^0.3.0",
|
|
23
29
|
"@sinclair/typebox": "*",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
30
|
+
"js-yaml": "^4.1.0",
|
|
31
|
+
"zod": "^3.25.62"
|
|
26
32
|
},
|
|
27
33
|
"peerDependencies": {
|
|
28
34
|
"@earendil-works/pi-coding-agent": "*"
|
package/src/commands/sync.ts
CHANGED
|
@@ -111,7 +111,11 @@ export async function syncCommand(
|
|
|
111
111
|
errors: [],
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
// --- 1.
|
|
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
|
-
// ---
|
|
131
|
+
// --- 3. Reconcile --------------------------------------------------------
|
|
128
132
|
// Use pulled catalog if available, otherwise read from disk
|
|
129
|
-
|
|
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
|
}
|
package/src/register.ts
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
SUBCOMMAND_DEFS,
|
|
13
13
|
getAliasMap,
|
|
14
14
|
} from "./commands/definitions.js";
|
|
15
|
-
import { parseSubcommand } from "./commands/dispatch.js";
|
|
16
15
|
import { addCommand, type AddCtx } from "./commands/add.js";
|
|
17
16
|
import { initCommand, type InitContext } from "./commands/init.js";
|
|
18
17
|
import { removeCommand, type RemoveCtx } from "./commands/remove.js";
|
|
@@ -66,9 +65,27 @@ async function handleSubcommand(
|
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
// Parse the raw argument string into structured { positional, flags }
|
|
68
|
+
// Parse the raw argument string into structured { positional, flags }.
|
|
69
|
+
// Note: the subcommand has already been extracted by the /ct handler,
|
|
70
|
+
// so we only parse flags from the remaining args — positional tokens
|
|
71
|
+
// are passed through directly.
|
|
70
72
|
const rawParts = (args ?? "").trim().split(/\s+/).filter(Boolean);
|
|
71
|
-
const
|
|
73
|
+
const flags: Record<string, true | string> = {};
|
|
74
|
+
const positional: string[] = [];
|
|
75
|
+
for (const token of rawParts) {
|
|
76
|
+
if (token.startsWith("--")) {
|
|
77
|
+
const body = token.slice(2);
|
|
78
|
+
const eqIdx = body.indexOf("=");
|
|
79
|
+
if (eqIdx !== -1) {
|
|
80
|
+
flags[body.slice(0, eqIdx)] = body.slice(eqIdx + 1);
|
|
81
|
+
} else {
|
|
82
|
+
flags[body] = true;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
positional.push(token);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const parsed = { subcommand: canonical, flags, positional };
|
|
72
89
|
|
|
73
90
|
switch (canonical) {
|
|
74
91
|
case "add":
|