@specdest/devkit 0.4.4 → 0.4.5

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": "@specdest/devkit",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "specdest": "src/cli.js"
@@ -76,7 +76,10 @@ async function cachedManifest(source, entry, canonicalCheckRoot, checkerRuntimeR
76
76
 
77
77
  async function canonicalContext(projectRoot, source, options = {}) {
78
78
  const catalog = await source.catalog({ refresh: options.refresh ?? false });
79
- const stack = await detectProjectStack(projectRoot);
79
+ const detectedStack = await detectProjectStack(projectRoot);
80
+ const installedState = await readInstalledState(projectRoot);
81
+ const requestedStacks = (installedState.requested ?? []).filter((id) => id.startsWith('stack-'));
82
+ const stack = detectedStack ?? (requestedStacks.length === 1 ? requestedStacks[0] : null);
80
83
  const profile = await readRuleProfile(projectRoot);
81
84
  assertKnownRuleOverrides(catalog.entries ?? [], profile);
82
85
  const projectType = resolveProjectType(stack, profile);
@@ -130,7 +133,7 @@ async function refreshInstalledRevision(projectRoot, id, revision) {
130
133
  await writeInstalledState(projectRoot, state);
131
134
  }
132
135
 
133
- async function cleanupCanonicalInstallState(projectRoot, catalogEntries) {
136
+ async function cleanupCanonicalInstallState(projectRoot, catalogEntries, applicableIds) {
134
137
  const installedState = await readInstalledState(projectRoot);
135
138
  const catalogRules = new Set(
136
139
  (catalogEntries ?? []).filter((entry) => entry.kind === 'rule').map((entry) => entry.id),
@@ -140,7 +143,8 @@ async function cleanupCanonicalInstallState(projectRoot, catalogEntries) {
140
143
  );
141
144
  const removed = [];
142
145
  for (const id of Object.keys(installedState.installed)) {
143
- if (catalogRules.has(id) || requestedStacks.has(id)) continue;
146
+ if (requestedStacks.has(id)) continue;
147
+ if (catalogRules.has(id) && applicableIds.has(id)) continue;
144
148
  delete installedState.installed[id];
145
149
  removed.push(id);
146
150
  }
@@ -212,19 +216,7 @@ export async function canonicalSync(projectRoot, source) {
212
216
  }
213
217
  }
214
218
  const applicableIds = new Set(applicable.map((entry) => entry.id));
215
- const catalogRules = new Map(
216
- (catalog.entries ?? []).filter((entry) => entry.kind === 'rule').map((entry) => [entry.id, entry]),
217
- );
218
- for (const id of Object.keys(current.installed).filter((installedId) => !applicableIds.has(installedId))) {
219
- const entry = catalogRules.get(id);
220
- if (!entry) continue;
221
- const prepared = await cachedManifest(source, entry, canonicalCheckRoot, checkerRuntimeRoot);
222
- for (const copy of prepared.manifest.copies ?? []) {
223
- const target = String(copy.target ?? copy.path ?? '');
224
- if (target.startsWith('.agents/skills/')) allowedSkillFiles.add(target);
225
- }
226
- }
227
- const removed = await cleanupCanonicalInstallState(projectRoot, catalog.entries ?? []);
219
+ const removed = await cleanupCanonicalInstallState(projectRoot, catalog.entries ?? [], applicableIds);
228
220
  await cleanupCanonicalSkillTree(projectRoot, allowedSkillFiles);
229
221
  return { stack, projectType, applicable: applicable.length, changed, removed };
230
222
  }
@@ -237,13 +229,6 @@ export async function canonicalCheck(projectRoot, source, options = {}) {
237
229
  refresh: options.refresh ?? false,
238
230
  });
239
231
  const byId = new Map(applicable.map((entry) => [entry.id, entry]));
240
- const catalogRules = new Map(
241
- (catalog.entries ?? []).filter((entry) => entry.kind === 'rule').map((entry) => [entry.id, entry]),
242
- );
243
- for (const id of Object.keys(current.installed)) {
244
- const entry = catalogRules.get(id);
245
- if (entry && !byId.has(id)) byId.set(id, entry);
246
- }
247
232
  const results = {};
248
233
  const groups = new Map();
249
234
  const executor = options.executor ?? execute;