gcf-aif-ext 0.7.1 → 0.7.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/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.2",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-aif-ext",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Game Context Framework for AI Factory",
5
5
  "type": "module",
6
6
  "license": "MIT",