@nodii/dev 0.6.65 → 0.6.67
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/dist/core.js +1 -1
- package/dist/design.js +1 -1
- package/dist/doctor.js +8 -5
- package/dist/gather.js +28 -11
- package/dist/review.js +55 -4
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.67";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/design.js
CHANGED
|
@@ -133,7 +133,7 @@ export async function fetchNodes(figmaGet, fileKey, nodeIds) {
|
|
|
133
133
|
const nodes = {};
|
|
134
134
|
// A whole page is a large document: fetch pages one per call.
|
|
135
135
|
for (const part of chunks(ids, nodeIds.length ? IDS_PER_CALL : 1)) {
|
|
136
|
-
const response = await figmaGet(`/files/${encodeURIComponent(fileKey)}/nodes?ids=${encodeURIComponent(part.join(","))}`);
|
|
136
|
+
const response = await figmaGet(`/files/${encodeURIComponent(fileKey)}/nodes?ids=${encodeURIComponent(part.join(","))}&geometry=omit`);
|
|
137
137
|
for (const id of part) nodes[id] = response.nodes?.[id] ?? null;
|
|
138
138
|
}
|
|
139
139
|
return nodes;
|
package/dist/doctor.js
CHANGED
|
@@ -5,7 +5,7 @@ import { devRequest, encode, isOAuthConfig, query, setAuthProvider } from "./cor
|
|
|
5
5
|
import { OAuthAuthProvider, decodeClaims, loadRefreshToken } from "./oauth.js";
|
|
6
6
|
import { inferGitContext, repoName } from "./lanes.js";
|
|
7
7
|
import { figmaFileKey, figmaLockCheck, holdsSet, notRegisteredHint, scopeText } from "./figma.js";
|
|
8
|
-
import { EMBED_MODEL, EMBED_MODEL_DIGEST, EMBED_PIN, PICKER_CONTEXT, PICKER_MODEL,
|
|
8
|
+
import { EMBED_MODEL, EMBED_MODEL_DIGEST, EMBED_PIN, PICKER_CONTEXT, PICKER_MODEL, PICKER_MODEL_DIGESTS, STALE_PIN_HINT, inspectOllama, pickerBuild, pinnedDigests } from "./gather.js";
|
|
9
9
|
import { hookDiagnostics } from "./hook-doctor.js";
|
|
10
10
|
import { hostBootedAt } from "./host.js";
|
|
11
11
|
import { listAccounts } from "./accounts.js";
|
|
@@ -272,12 +272,15 @@ export async function doctorCommand(deps = {}) {
|
|
|
272
272
|
try {
|
|
273
273
|
const picker = await (deps.ollamaInspector ?? inspectOllama)();
|
|
274
274
|
checks.push(ok("ollama", `version ${picker.version} at the local Gather endpoint`, { version: picker.version }));
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
// Two registry builds of gemma4:12b are accepted; say which one is installed.
|
|
276
|
+
if (picker.modelInstalled && picker.modelMatches) {
|
|
277
|
+
const build = pickerBuild(picker.digest);
|
|
278
|
+
checks.push(ok("picker_model", `${PICKER_MODEL} installed${picker.digest ? ` (${picker.digest}${build ? `, the ${build.build}` : ""})` : ""}`, {
|
|
279
|
+
model: PICKER_MODEL, digest: picker.digest ?? null, build: build?.build ?? null, size: picker.size ?? null,
|
|
278
280
|
}));
|
|
281
|
+
}
|
|
279
282
|
else if (!picker.modelInstalled) checks.push(missing("picker_model", `${PICKER_MODEL} is not installed`, "nodii-dev setup --yes", { model: PICKER_MODEL }));
|
|
280
|
-
else checks.push(missing("picker_model", `${PICKER_MODEL} digest is ${picker.digest ?? "unknown"}; this CLI pins ${
|
|
283
|
+
else checks.push(missing("picker_model", `${PICKER_MODEL} digest is ${picker.digest ?? "unknown"}; this CLI pins ${pinnedDigests()}; ${STALE_PIN_HINT}`, "nodii-dev setup --yes", { model: PICKER_MODEL, digest: picker.digest ?? null, acceptedDigests: PICKER_MODEL_DIGESTS }));
|
|
281
284
|
// Gather loads the picker at an explicit num_ctx; a copy resident at another
|
|
282
285
|
// context (Ollama's default is the model's full window) holds far more memory.
|
|
283
286
|
const context = picker.loadedContext ?? null;
|
package/dist/gather.js
CHANGED
|
@@ -9,16 +9,25 @@ import { CliError } from "./core.js";
|
|
|
9
9
|
const execFileAsync = promisify(execFile);
|
|
10
10
|
|
|
11
11
|
export const PICKER_MODEL = "gemma4:12b";
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
12
|
+
// gemma4:12b has two registry builds under the same tag, and the picker accepts
|
|
13
|
+
// either (NODII-DEV-CLI-33). The registry chooses the manifest by User-Agent and
|
|
14
|
+
// client, so two Macs pulling the same tag can land different digests:
|
|
15
|
+
// - c7597fc9…: the MLX nvfp4 build Ollama on Apple silicon pulled at the hub-58
|
|
16
|
+
// re-pin (NODII-DEV-CLI-11). It has no structured output (pickDocuments).
|
|
17
|
+
// - 6114515d…: the build a fresh M5 Mac with Ollama 0.32.15 pulls (nodii-clis #113).
|
|
18
|
+
// Any other digest is refused (PICKER_MODEL_VERSION_MISMATCH).
|
|
19
|
+
export const PICKER_MODEL_BUILDS = [
|
|
20
|
+
{ digest: "sha256:c7597fc90b86aff6965317f37dd5465402284e26382d9b4bf2dfe3ef1491f4b6", build: "MLX nvfp4 build (hub-58 pin)" },
|
|
21
|
+
{ digest: "sha256:6114515d63c17436a7c0417d82820ac65ad643e2806c5a3c89cb62846436ed0b", build: "build a fresh M5 with Ollama 0.32.15 pulls (nodii-clis #113)" },
|
|
22
|
+
];
|
|
23
|
+
export const PICKER_MODEL_DIGESTS = PICKER_MODEL_BUILDS.map((x) => x.digest);
|
|
24
|
+
// The first accepted build; tests and fakes install this one.
|
|
25
|
+
export const PICKER_MODEL_DIGEST = PICKER_MODEL_DIGESTS[0];
|
|
17
26
|
// E4B and 26B are compared in Gather tuning only; each is pinned the same way
|
|
18
27
|
// (public registry tag + manifest digest) and never pulled by setup.
|
|
19
28
|
export const TUNING_MODELS = {
|
|
20
29
|
"gemma-e4b": { name: "gemma4:e4b", digest: "sha256:dc35e8d9c6061baa6f0fa870975ab6932e2542b579b13ea0f199fa4bb7300c9c" },
|
|
21
|
-
"gemma-12b": { name: PICKER_MODEL, digest: PICKER_MODEL_DIGEST },
|
|
30
|
+
"gemma-12b": { name: PICKER_MODEL, digest: PICKER_MODEL_DIGEST, digests: PICKER_MODEL_DIGESTS },
|
|
22
31
|
"gemma-26b": { name: "gemma4:26b", digest: "sha256:001e5dafc3c77684c2307ebc6ab8e336e10c9b18eca52acf547d72fc83c3ca8c" },
|
|
23
32
|
};
|
|
24
33
|
// The section embedding pin (Dev's GATHER_EMBEDDING_*): `setup` pulls it,
|
|
@@ -113,10 +122,18 @@ async function jsonRequest(path, { baseUrl = ollamaUrl(), fetchImpl = fetch, tim
|
|
|
113
122
|
return payload;
|
|
114
123
|
}
|
|
115
124
|
|
|
116
|
-
const PINNED = { name: PICKER_MODEL, digest: PICKER_MODEL_DIGEST };
|
|
125
|
+
const PINNED = { name: PICKER_MODEL, digest: PICKER_MODEL_DIGEST, digests: PICKER_MODEL_DIGESTS };
|
|
117
126
|
// Ollama's /api/tags reports the manifest digest as bare hex; the pin carries
|
|
118
127
|
// the registry's `sha256:` form. Compare them without the algorithm prefix.
|
|
119
128
|
const bareDigest = (digest) => typeof digest === "string" ? digest.replace(/^sha256:/, "") : null;
|
|
129
|
+
// A pin names one digest, or an allowlist of registry builds of the same tag.
|
|
130
|
+
const pinDigests = (pin) => pin.digests ?? [pin.digest];
|
|
131
|
+
/** The accepted digest(s) of a pin, for messages: "X" or "X or Y". */
|
|
132
|
+
export const pinnedDigests = (pin = PINNED) => pinDigests(pin).join(" or ");
|
|
133
|
+
/** The accepted gemma4:12b build a digest is, or null when it is not one of them. */
|
|
134
|
+
export function pickerBuild(digest) {
|
|
135
|
+
return PICKER_MODEL_BUILDS.find((x) => bareDigest(x.digest) === bareDigest(digest)) ?? null;
|
|
136
|
+
}
|
|
120
137
|
|
|
121
138
|
export async function inspectOllama(options = {}) {
|
|
122
139
|
const pin = options.model ?? PINNED;
|
|
@@ -134,7 +151,7 @@ export async function inspectOllama(options = {}) {
|
|
|
134
151
|
version: String(version.version ?? "unknown"),
|
|
135
152
|
model: pin.name,
|
|
136
153
|
modelInstalled: Boolean(model),
|
|
137
|
-
modelMatches: Boolean(model?.digest) &&
|
|
154
|
+
modelMatches: Boolean(model?.digest) && pinDigests(pin).some((digest) => bareDigest(digest) === bareDigest(model.digest)),
|
|
138
155
|
digest: model?.digest ?? null,
|
|
139
156
|
size: model?.size ?? null,
|
|
140
157
|
details: model?.details ?? null,
|
|
@@ -149,7 +166,7 @@ export async function requirePicker(options = {}) {
|
|
|
149
166
|
if (!status.modelInstalled)
|
|
150
167
|
throw new CliError("PICKER_MODEL_MISSING", `Local Gather picker is missing ${pin.name}. ${fix} to pull it.`, 1, status);
|
|
151
168
|
if (!status.modelMatches)
|
|
152
|
-
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `Local ${pin.name} is ${status.digest ?? "an unknown digest"}; this CLI pins ${pin
|
|
169
|
+
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `Local ${pin.name} is ${status.digest ?? "an unknown digest"}; this CLI pins ${pinnedDigests(pin)}. ${fix} to pull it; ${STALE_PIN_HINT}`, 1, status);
|
|
153
170
|
return status;
|
|
154
171
|
}
|
|
155
172
|
|
|
@@ -590,7 +607,7 @@ export async function setupOllama({ check = false, inspect = inspectOllama, exec
|
|
|
590
607
|
return { changed: embed.changed, ...current, embed };
|
|
591
608
|
}
|
|
592
609
|
if (check && current.modelInstalled)
|
|
593
|
-
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `${PICKER_MODEL} digest is ${current.digest ?? "unknown"}; this CLI pins ${
|
|
610
|
+
throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `${PICKER_MODEL} digest is ${current.digest ?? "unknown"}; this CLI pins ${pinnedDigests()}. Run \`nodii-dev setup --yes\` to pull it; ${STALE_PIN_HINT}`, 1, current);
|
|
594
611
|
if (check) throw new CliError("PICKER_MODEL_MISSING", `${PICKER_MODEL} is not installed.`, 1, current);
|
|
595
612
|
} catch (error) {
|
|
596
613
|
if (check || !["PICKER_UNAVAILABLE", "PICKER_MODEL_MISSING"].includes(error?.code)) throw error;
|
|
@@ -603,7 +620,7 @@ export async function setupOllama({ check = false, inspect = inspectOllama, exec
|
|
|
603
620
|
const ready = await inspect();
|
|
604
621
|
if (!ready.modelInstalled) throw new CliError("PICKER_MODEL_MISSING", `Ollama pull finished but ${PICKER_MODEL} is not installed.`, 1, ready);
|
|
605
622
|
// A fresh pull is what the registry serves now, so a mismatch here is a stale pin.
|
|
606
|
-
if (!ready.modelMatches) throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `The Ollama registry serves ${PICKER_MODEL} at ${ready.digest ?? "an unknown digest"}, but this CLI pins ${
|
|
623
|
+
if (!ready.modelMatches) throw new CliError("PICKER_MODEL_VERSION_MISMATCH", `The Ollama registry serves ${PICKER_MODEL} at ${ready.digest ?? "an unknown digest"}, but this CLI pins ${pinnedDigests()}: the pin is stale, so pulling again will not help. Update nodii-dev to a release with the current pin.`, 1, { ...ready, stalePin: true });
|
|
607
624
|
const embed = await setupEmbedModel({ check, inspect, exec });
|
|
608
625
|
return { changed: [PICKER_MODEL, ...embed.changed], ...ready, embed };
|
|
609
626
|
}
|
package/dist/review.js
CHANGED
|
@@ -26,6 +26,8 @@ export const MAX_DIFF_CHARS = 600_000;
|
|
|
26
26
|
export const CODE_NOT_REQUIRED = { decision: "DEC-0085" };
|
|
27
27
|
const PASSING = { rules: ["CLEAN"], figma: ["CLEAN", "NOT_APPLICABLE"], code: ["CLEAN", "NOT_REQUIRED"] };
|
|
28
28
|
const UNAVAILABLE = "REVIEWER_UNAVAILABLE";
|
|
29
|
+
// Figma errors that mean Figma was not reachable in time, not that the design failed.
|
|
30
|
+
const FIGMA_OUTAGE = ["FIGMA_TIMEOUT", "FIGMA_UNREACHABLE", "FIGMA_RATE_LIMITED"];
|
|
29
31
|
|
|
30
32
|
class ReviewerError extends Error {
|
|
31
33
|
constructor(outcome, message) {
|
|
@@ -353,9 +355,47 @@ export function boundaryFrames(figma, surfaces) {
|
|
|
353
355
|
});
|
|
354
356
|
}
|
|
355
357
|
|
|
356
|
-
/**
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
/**
|
|
359
|
+
* MW2-38.3: the nodes of the change sets a lane's agent holds in each
|
|
360
|
+
* boundary file Dev registers as the design system. Returns
|
|
361
|
+
* { fileKey: { changeSets: [id], nodes: [nodeId] } } for files with at least
|
|
362
|
+
* one node. Dev's holderAgentId filter is checked again here, because a Dev
|
|
363
|
+
* without it ignores the parameter and lists every set on the file. Items the
|
|
364
|
+
* lane withdrew are left out; rejected items stay in until withdrawn. A
|
|
365
|
+
* removed item's node is gone from Figma, so there is nothing to check.
|
|
366
|
+
*/
|
|
367
|
+
export async function laneChangeSetNodes(request, agentId, fileKeys) {
|
|
368
|
+
if (!agentId || !fileKeys.length) return {};
|
|
369
|
+
const files = (await request("GET", "/api/v1/design/files")).data ?? [];
|
|
370
|
+
const ds = new Set(files.filter((file) => file.kind === "design-system").map((file) => file.fileKey));
|
|
371
|
+
const scoped = {};
|
|
372
|
+
for (const fileKey of [...new Set(fileKeys)].filter((key) => ds.has(key))) {
|
|
373
|
+
const rows = (await request("GET", `/api/v1/design/change-sets?holderAgentId=${encodeURIComponent(agentId)}&fileKey=${encodeURIComponent(fileKey)}&limit=500`)).data ?? [];
|
|
374
|
+
const held = rows.filter((row) => row.holder?.agent?.id === agentId && row.fileKey === fileKey && row.state !== "abandoned");
|
|
375
|
+
const nodes = new Set();
|
|
376
|
+
const changeSets = [];
|
|
377
|
+
for (const row of held) {
|
|
378
|
+
const set = (await request("GET", `/api/v1/design/change-sets/${encodeURIComponent(row.id)}`)).data;
|
|
379
|
+
const live = (set?.items ?? []).filter((item) => item.decision !== "withdrawn" && item.change !== "removed" && item.figmaNodeId);
|
|
380
|
+
if (!live.length) continue;
|
|
381
|
+
changeSets.push(row.id);
|
|
382
|
+
for (const item of live) nodes.add(item.figmaNodeId);
|
|
383
|
+
}
|
|
384
|
+
if (nodes.size) scoped[fileKey] = { changeSets, nodes: [...nodes] };
|
|
385
|
+
}
|
|
386
|
+
return scoped;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* DEV-REV-9, design-check part: designCheck on every boundary frame; per-state
|
|
391
|
+
* frame comparison is Q-162. A boundary file with held change-set nodes
|
|
392
|
+
* (MW2-38.3, from laneChangeSetNodes) is checked on those nodes only, never
|
|
393
|
+
* as the whole file.
|
|
394
|
+
*/
|
|
395
|
+
export async function figmaFindings(figma, { catalog, check, changeSets = {} }) {
|
|
396
|
+
const scopedFrames = Object.entries(changeSets).flatMap(([fileKey, scoped]) => scoped.nodes.map((nodeId) => ({ fileKey, nodeId, state: "default" })));
|
|
397
|
+
const rest = figma.filter((file) => !changeSets[file.fileKey]);
|
|
398
|
+
const frames = [...scopedFrames, ...boundaryFrames(rest, rest.some((file) => file.componentSetKeys?.length) ? await catalog() : [])];
|
|
359
399
|
const findings = [];
|
|
360
400
|
const versions = new Set();
|
|
361
401
|
for (const frame of frames) {
|
|
@@ -378,6 +418,7 @@ export async function figmaFindings(figma, { catalog, check }) {
|
|
|
378
418
|
frames: frames.map((frame) => ({ fileKey: frame.fileKey, nodeId: frame.nodeId, state: frame.state, frameUrl: frame.nodeId ? frameUrl(frame.fileKey, frame.nodeId) : `https://www.figma.com/design/${frame.fileKey}` })),
|
|
379
419
|
libraryVersions: [...versions],
|
|
380
420
|
frameComparison: "not_built",
|
|
421
|
+
...(scopedFrames.length ? { changeSets: Object.entries(changeSets).map(([fileKey, scoped]) => ({ fileKey, ids: scoped.changeSets, nodes: scoped.nodes.length })), rule: "MW2-38.3" } : {}),
|
|
381
422
|
},
|
|
382
423
|
};
|
|
383
424
|
}
|
|
@@ -480,10 +521,20 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
|
|
|
480
521
|
} else {
|
|
481
522
|
const boundary = freeze.boundaries.figma;
|
|
482
523
|
try {
|
|
524
|
+
let changeSets;
|
|
525
|
+
try { changeSets = await laneChangeSetNodes(request, lane.agentId, boundary.map((file) => file.fileKey)); }
|
|
526
|
+
catch (error) {
|
|
527
|
+
throw new ReviewerError(UNAVAILABLE, `the lane's change sets could not be read from Dev (${error?.code ?? "ERROR"}: ${error?.message ?? error}), so the Figma check cannot be scoped to their nodes (MW2-38.3) and did not fall back to the whole file`);
|
|
528
|
+
}
|
|
483
529
|
let checked;
|
|
484
|
-
try { checked = await figmaFindings(boundary, { catalog, check: designCheck }); }
|
|
530
|
+
try { checked = await figmaFindings(boundary, { catalog, check: designCheck, changeSets }); }
|
|
485
531
|
catch (error) {
|
|
486
532
|
if (error instanceof ReviewerError) throw error;
|
|
533
|
+
// A Figma outage (a read past its clock, no answer, rate limited) means
|
|
534
|
+
// the check did not run: recorded as not run with the reason, never as
|
|
535
|
+
// a failure, so an outage never blocks a push.
|
|
536
|
+
if (FIGMA_OUTAGE.includes(error?.code))
|
|
537
|
+
throw new ReviewerError(UNAVAILABLE, `not run: Figma did not answer the design check (${error.code}: ${error?.message ?? error}); nothing was checked, so rerun nodii-dev lane check once Figma answers`);
|
|
487
538
|
throw new ReviewerError(["FIGMA_TOKEN_REQUIRED", "DS_CATALOG_UNAVAILABLE"].includes(error?.code) ? UNAVAILABLE : "CRASH", `design check failed (${error?.code ?? "ERROR"}: ${error?.message ?? error})`);
|
|
488
539
|
}
|
|
489
540
|
figma = round("figma", checked.findings, checked.inputs);
|