gcf-aif-ext 0.7.1 → 0.7.3

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/extension.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
3
3
  "name": "gcf-aif-ext",
4
- "version": "0.7.1",
4
+ "version": "0.7.3",
5
5
  "description": "Game Context Framework for AI Factory",
6
6
  "skills": [
7
7
  "skills/gcf-init",
package/lib/board.js CHANGED
@@ -132,8 +132,28 @@ const SCALARS = [
132
132
  'effort',
133
133
  ];
134
134
 
135
- // Ranked items first, lower rank sooner; the unranked keep their file order after them.
136
- const byPriority = (a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity);
135
+ /**
136
+ * Ranked items first, lower rank sooner. The unranked follow in dependency order: what can run
137
+ * now first, each item after every open item it depends on; file order breaks a tie.
138
+ */
139
+ function inRunOrder(items) {
140
+ const byId = new Map(items.map((i) => [i.id, i]));
141
+ const depth = new Map();
142
+ const depthOf = (i) => {
143
+ if (depth.has(i.id)) return depth.get(i.id);
144
+ depth.set(i.id, 0); // a depends cycle stops here
145
+ const open = i.depends.map((d) => byId.get(d)).filter(Boolean);
146
+ depth.set(i.id, open.length ? 1 + Math.max(...open.map(depthOf)) : 0);
147
+
148
+ return depth.get(i.id);
149
+ };
150
+
151
+ // Two unranked items give NaN (Infinity - Infinity), which falls through to the depth.
152
+ return items.sort(
153
+ (a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity) || depthOf(a) - depthOf(b),
154
+ );
155
+ }
156
+
137
157
  const LISTS = ['children', 'system', 'depends'];
138
158
 
139
159
  /** One item of the board. */
@@ -174,7 +194,7 @@ export async function board(projectDir) {
174
194
  const verified = verifiedOf(projectDir);
175
195
  const items = [];
176
196
  for (const c of ledger.items) items.push(await itemOf(projectDir, c, verified));
177
- items.sort(byPriority);
197
+ inRunOrder(items);
178
198
 
179
199
  const config = await readConfig(root);
180
200
  const live = await readLive(root);
package/lib/integrate.js CHANGED
@@ -302,6 +302,8 @@ export async function integrate(projectDir, ids = []) {
302
302
  throw new Error(`integrate runs in the main checkout on its branch, not on ${branch}`);
303
303
 
304
304
  return withMainLock(projectDir, async () => {
305
+ // Nothing to merge leaves main alone: a run's first integrate must not refuse a dirty tree.
306
+ if (!ids.length && !verifiedBranches(projectDir).length) return [];
305
307
  if (git(projectDir, ['status', '--porcelain', '--untracked-files=no', '--', '.', METRICS]).out)
306
308
  throw new Error('main has uncommitted changes: commit or stash them before integrating');
307
309
  commitMetrics(projectDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-aif-ext",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Game Context Framework for AI Factory",
5
5
  "type": "module",
6
6
  "license": "MIT",