@nodii/dev 0.6.48 → 0.6.50

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/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 { PICKER_MODEL, PICKER_MODEL_DIGEST, STALE_PIN_HINT, inspectOllama } from "./gather.js";
8
+ import { PICKER_CONTEXT, PICKER_MODEL, PICKER_MODEL_DIGEST, STALE_PIN_HINT, inspectOllama } from "./gather.js";
9
9
  import { hookDiagnostics } from "./hook-doctor.js";
10
10
 
11
11
  /**
@@ -275,9 +275,16 @@ export async function doctorCommand(deps = {}) {
275
275
  }));
276
276
  else if (!picker.modelInstalled) checks.push(missing("picker_model", `${PICKER_MODEL} is not installed`, "nodii-dev setup --yes", { model: PICKER_MODEL }));
277
277
  else checks.push(missing("picker_model", `${PICKER_MODEL} digest is ${picker.digest ?? "unknown"}; this CLI pins ${PICKER_MODEL_DIGEST}; ${STALE_PIN_HINT}`, "nodii-dev setup --yes", { model: PICKER_MODEL, digest: picker.digest ?? null, requiredDigest: PICKER_MODEL_DIGEST }));
278
+ // Gather loads the picker at an explicit num_ctx; a copy resident at another
279
+ // context (Ollama's default is the model's full window) holds far more memory.
280
+ const context = picker.loadedContext ?? null;
281
+ if (context === null) checks.push(ok("picker_context", `${PICKER_MODEL} not loaded; Gather loads it with num_ctx ${PICKER_CONTEXT}`, { model: PICKER_MODEL, context: null, requiredContext: PICKER_CONTEXT }));
282
+ else if (context === PICKER_CONTEXT) checks.push(ok("picker_context", `${PICKER_MODEL} loaded with num_ctx ${PICKER_CONTEXT}`, { model: PICKER_MODEL, context, requiredContext: PICKER_CONTEXT }));
283
+ else checks.push(missing("picker_context", `${PICKER_MODEL} is loaded with context ${context}, not ${PICKER_CONTEXT}; the next lane gather reloads it`, `ollama stop ${PICKER_MODEL}`, { model: PICKER_MODEL, context, requiredContext: PICKER_CONTEXT }));
278
284
  } catch (error) {
279
285
  checks.push(missing("ollama", error?.message ?? "Ollama is unavailable", "nodii-dev setup --yes", { code: error?.code ?? null }));
280
286
  checks.push(cannot("picker_model", `needs local Ollama; expected ${PICKER_MODEL}`, { model: PICKER_MODEL }));
287
+ checks.push(cannot("picker_context", `needs local Ollama; expected num_ctx ${PICKER_CONTEXT}`, { model: PICKER_MODEL, requiredContext: PICKER_CONTEXT }));
281
288
  }
282
289
 
283
290
  // 10. Runtime hooks: present, accepted by that runtime, and observed firing.
package/dist/gather.js CHANGED
@@ -113,12 +113,14 @@ const bareDigest = (digest) => typeof digest === "string" ? digest.replace(/^sha
113
113
 
114
114
  export async function inspectOllama(options = {}) {
115
115
  const pin = options.model ?? PINNED;
116
- const [version, tags] = await Promise.all([
116
+ const [version, tags, ps] = await Promise.all([
117
117
  jsonRequest("/api/version", options),
118
118
  jsonRequest("/api/tags", options),
119
+ jsonRequest("/api/ps", options),
119
120
  ]);
120
121
  const model = (tags.models ?? []).find((x) => x?.name === pin.name || x?.model === pin.name) ?? null;
121
122
  return {
123
+ loadedContext: residentContext(ps, pin.name),
122
124
  available: true,
123
125
  version: String(version.version ?? "unknown"),
124
126
  model: pin.name,
@@ -148,8 +150,12 @@ export async function requirePicker(options = {}) {
148
150
  */
149
151
  export async function warmPicker(options = {}) {
150
152
  const status = await requirePicker(options);
153
+ const model = (options.model ?? PINNED).name;
154
+ // Ollama keeps the context a model was loaded with; a later num_ctx does not
155
+ // reload it (hub-58: resident at 262144). Unload a wrong-context copy first.
156
+ if (status.loadedContext !== null && status.loadedContext !== PICKER_CONTEXT) await unloadPicker(model, options);
151
157
  const started = Date.now();
152
- const payload = await jsonRequest("/api/generate", { ...options, timeoutMs: options.timeoutMs ?? PICKER_WARM_TIMEOUT_MS, body: { model: (options.model ?? PINNED).name, prompt: "", stream: false } });
158
+ const payload = await jsonRequest("/api/generate", { ...options, timeoutMs: options.timeoutMs ?? PICKER_WARM_TIMEOUT_MS, body: { model, prompt: "", stream: false, options: { num_ctx: PICKER_CONTEXT } } });
153
159
  return { ...status, latency: pickLatency(payload, Date.now() - started) };
154
160
  }
155
161
 
@@ -506,6 +512,12 @@ export async function modelLoaded(model, options = {}) {
506
512
  return (ps.models ?? []).some((x) => x?.name === model || x?.model === model);
507
513
  }
508
514
 
515
+ /** The context length Ollama holds the model at (/api/ps), or null when it is not resident. */
516
+ function residentContext(ps, model) {
517
+ const loaded = (ps.models ?? []).find((x) => x?.name === model || x?.model === model);
518
+ return loaded ? (loaded.context_length ?? 0) : null;
519
+ }
520
+
509
521
  const tags = (clause) => {
510
522
  const repos = clause.repos ?? [];
511
523
  const steps = clause.steps ?? [];
@@ -92,7 +92,7 @@ export const doneCheckRecorded = (lane) =>
92
92
  || (lane?.steps ?? []).some((step) => step.stepKey === "dev_check" && step.state === "done")
93
93
  || FINISHED_LANE.has(lane?.status);
94
94
 
95
- /** A lane is BLOCKED by a blocked step (`lane step --block`) or a latest heartbeat note that says so. */
95
+ /** A lane is BLOCKED by a blocked step (`lane step --block`) or a latest heartbeat note that starts "blocked" or "WAITING:" (AGENT-HARNESS-46). */
96
96
  export const laneBlocked = (lane) => Boolean(laneBlockedReason(lane));
97
97
 
98
98
  /** Why a lane is BLOCKED, or null (the same rule Dev applies to a run's exit). */
@@ -101,7 +101,7 @@ export function laneBlockedReason(lane) {
101
101
  if (step) return `Lane step ${step.side}/${step.stepKey} is blocked.`;
102
102
  const heartbeat = (lane?.events ?? []).filter((event) => event.type === "heartbeat").at(-1);
103
103
  const note = String(heartbeat?.metadata?.note ?? "");
104
- return /^\s*blocked\b/i.test(note) ? `Lane heartbeat: ${note.slice(0, 500)}` : null;
104
+ return /^\s*blocked\b/i.test(note) || /^\s*WAITING\s*:/.test(note) ? `Lane heartbeat: ${note.slice(0, 500)}` : null;
105
105
  }
106
106
 
107
107
  /** The step a lane that stopped early goes back to (hub-58, NODII-DEV-CLI-8/9). */
package/dist/lanes.js CHANGED
@@ -657,10 +657,20 @@ export async function laneCommand(action, args, flags, { request = devRequest, c
657
657
  return { payload, human: `${ref}: subagent quota set to ${quota}.` };
658
658
  }
659
659
  if (action === "resume") {
660
+ // AGENT-HARNESS-46: --override resumes a lane the two-deaths rule stopped;
661
+ // Dev allows it only after a `lane amend`, and keeps the reason on the run.
662
+ if (flags.override && flags.reason === undefined)
663
+ throw new CliError("USAGE", "lane resume --override needs --reason TEXT.", 2);
664
+ if (!flags.override && flags.reason !== undefined)
665
+ throw new CliError("USAGE", "--reason goes with --override.", 2);
666
+ if (Array.isArray(flags.reason)) throw new CliError("USAGE", "Give --reason once.", 2);
667
+ const overrideReason = typeof flags.reason === "string" ? flags.reason.trim() : "";
668
+ if (flags.override && !overrideReason) throw new CliError("USAGE", "--reason needs TEXT: why resuming the amended lane is safe.", 2);
669
+ if (overrideReason.length > 2_000) throw new CliError("USAGE", `--reason is ${overrideReason.length} characters; Dev keeps at most 2,000.`, 2);
660
670
  const payload = await request(
661
671
  "POST",
662
672
  `/api/v1/lanes/${encode(id)}/resume`,
663
- via,
673
+ flags.override ? { override: true, reason: overrideReason, ...via } : via,
664
674
  );
665
675
  let launched;
666
676
  try {
@@ -686,7 +696,8 @@ export async function laneCommand(action, args, flags, { request = devRequest, c
686
696
  const continuation = next
687
697
  ? `${next.side}/${next.step}`
688
698
  : "the lane's next unfinished step";
689
- return `${ref}: resumed fresh run ${runId} as PID ${launched.pid}; continuing ${continuation} from ${checkpoint}.`;
699
+ const override = response.data.run.resumeOverrideReason;
700
+ return `${ref}: resumed fresh run ${runId} as PID ${launched.pid}; continuing ${continuation} from ${checkpoint}.${override ? ` Override past the two-deaths stop recorded ("${override}"); the death count restarts.` : ""}`;
690
701
  },
691
702
  };
692
703
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.48",
3
+ "version": "0.6.50",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {