@chosengeneration/light-code 0.59.0 → 0.59.6

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/cli.js CHANGED
@@ -42195,9 +42195,19 @@ async function listModels(http, profile, auth2, signal) {
42195
42195
  function messageOf(error51) {
42196
42196
  return error51 instanceof Error ? error51.message : String(error51);
42197
42197
  }
42198
+ var TEST_CONNECTION_TIMEOUT_MS = 2e4;
42198
42199
  async function testConnection(profile, context, http, signal) {
42199
42200
  const steps = [];
42200
42201
  const finish = () => ({ ok: steps.every((step) => step.status !== "failed"), steps });
42202
+ const deadline = new AbortController();
42203
+ const timer = setTimeout(() => deadline.abort(), TEST_CONNECTION_TIMEOUT_MS);
42204
+ const onOuterAbort = () => deadline.abort();
42205
+ signal?.addEventListener("abort", onOuterAbort);
42206
+ const bounded = deadline.signal;
42207
+ const release = () => {
42208
+ clearTimeout(timer);
42209
+ signal?.removeEventListener("abort", onOuterAbort);
42210
+ };
42201
42211
  if (profile.auth.type === "apigeeMtls") {
42202
42212
  try {
42203
42213
  let expiryNote = "";
@@ -42214,6 +42224,7 @@ async function testConnection(profile, context, http, signal) {
42214
42224
  detail: `Loaded ${loaded?.pfx !== void 0 ? "PFX bundle" : "client certificate and key"}.${expiryNote}`
42215
42225
  });
42216
42226
  } catch (error51) {
42227
+ release();
42217
42228
  steps.push({ step: "certificates", status: "failed", detail: messageOf(error51) });
42218
42229
  steps.push({ step: "token", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
42219
42230
  steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
@@ -42245,16 +42256,28 @@ async function testConnection(profile, context, http, signal) {
42245
42256
  detail: profile.auth.type === "tokenCommand" ? "The token command ran and returned a token." : profile.auth.type === "apiKey" && profile.auth.apiKeyRef.startsWith("env:") ? `Key read from ${profile.auth.apiKeyRef.slice("env:".length)}.` : "Credential resolved from secure storage."
42246
42257
  });
42247
42258
  } catch (error51) {
42259
+ release();
42248
42260
  steps.push({ step: "token", status: "failed", detail: messageOf(error51) });
42249
42261
  steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 no credential." });
42250
42262
  return finish();
42251
42263
  }
42252
42264
  }
42253
- const result = await listModels(http, profile, auth2, signal);
42265
+ const result = await listModels(http, profile, auth2, bounded);
42266
+ release();
42254
42267
  if (result.ids.length > 0) {
42255
42268
  steps.push({ step: "models", status: "ok", detail: `Gateway returned ${result.ids.length} model(s).` });
42269
+ } else if (deadline.signal.aborted && signal?.aborted !== true) {
42270
+ steps.push({
42271
+ step: "models",
42272
+ status: "failed",
42273
+ detail: `No response within ${String(Math.round(TEST_CONNECTION_TIMEOUT_MS / 1e3))}s. The address resolved and the connection was accepted, but nothing came back \u2014 check the base URL path and whether anything is filtering this route.`
42274
+ });
42256
42275
  } else {
42257
- steps.push({ step: "models", status: "failed", detail: result.warning ?? "No models returned." });
42276
+ steps.push({
42277
+ step: "models",
42278
+ status: "note",
42279
+ detail: `${result.warning ?? "No catalogue returned."} This does not by itself mean the connection is broken \u2014 plenty of gateways serve chat completions without publishing /models. Type the model id by hand.`
42280
+ });
42258
42281
  }
42259
42282
  return finish();
42260
42283
  }
@@ -43981,7 +44004,24 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
43981
44004
  ' write it for them \u2014 "checking which gateway the profile points at", not "reading a file".',
43982
44005
  "- Paths are relative to the workspace root. You cannot access anything outside it.",
43983
44006
  "- When the task is complete, call attempt_completion with a summary of what you did.",
43984
- "- If you need information only the user can provide, call ask_followup_question."
44007
+ "- If you need information only the user can provide, call ask_followup_question.",
44008
+ /*
44009
+ * Asked for directly, from real use with a model whose training predates the libraries in
44010
+ * front of it. The failure it addresses is not refusing to answer - it is answering anyway,
44011
+ * from a remembered version of an API, which produces code that looks right and is wrong
44012
+ * against the installed version. The user very often has the page open.
44013
+ *
44014
+ * Phrased as a thing to do rather than a permission, because a model that is unsure is
44015
+ * already reluctant to interrupt, and "you may ask" reads as "prefer not to".
44016
+ */
44017
+ "- **If a library or API is unfamiliar, or the version here does not match what you remember,",
44018
+ " ask the user for documentation rather than guessing.** Say which library and what you need",
44019
+ " to know - a signature, which module something moved to, whether a call is still supported.",
44020
+ " They can paste it, point you at a file or a URL they have already fetched, or tell you the",
44021
+ " house convention. Recalling an API from a version you were trained on produces code that",
44022
+ " looks correct and fails against the one installed, which is far more expensive than asking.",
44023
+ "- Before asking, check what is here: the imports and existing calls in this workspace are",
44024
+ " evidence about the version actually installed, and a skill may already describe it."
43985
44025
  );
43986
44026
  if (options.skills !== void 0 && options.skills.length > 0) {
43987
44027
  lines.push("", options.skills);
@@ -44030,7 +44070,7 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
44030
44070
  lines.push("", "Email:", "- **Always answer questions about email from the index, using search_mail and", " mail_patterns.** That is what it is for. It is fast, it answers questions about time", " and recurrence that a live search cannot, and it does not disturb the running Outlook.", '- **Only search Outlook itself when the user asks you to.** "Check Outlook", "look at my', ' actual mailbox", "is it there now" and anything similar are the instruction to use', " outlook_search. Do not reach for it on your own initiative.", "- If the index has nothing, say so plainly and say when it was last synced. Do not", " quietly fall back to scanning Outlook - a slow live scan that nobody asked for reads", " as the assistant having hung.", "- One exception worth naming: if the user is asking about something that arrived in the", " last few minutes, the index may not have it yet. Say that, and offer to check Outlook", " rather than doing it unasked.", "- **The index holds plain text.** Colours, highlighting and images are not in it. When", " those could carry meaning \u2014 a red line marking a failure, a highlighted cell \u2014 use", " outlook_read_email on the id, which reads the live message and reports the colours.", " Never conclude a message looks fine from indexed text alone.", "- mail_coverage says which folders are indexed and how far back. Check it before saying", " something is not in the mail: an empty search over an unindexed folder looks exactly", " like an empty search over an indexed one.", "- **Use mail_stats for any question with a number in the answer** \u2014 how many alerts per", " folder, per day, per hour, which senders, whether a figure inside the alerts is climbing.", " It counts everything the filters matched. Never count search results by eye: search", " returns a page, so counting what you were shown reports a sample as if it were the total.", "- mail_stats already returns categories, values and detail in the shape show_chart wants.", " Pass it through rather than retyping the numbers, and keep the detail.");
44031
44071
  }
44032
44072
  if (options.expertAvailable === true) {
44033
- lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the ask_expert tool. You CAN talk to", " it. Never tell the user you have no way to reach another model \u2014 you do.", '- **If the user asks you to consult it, do so.** "Ask Claude", "check with the', ' expert", "what does Claude think" and anything similar are direct instructions.', " It is their money and their decision; do not talk them out of it or decide the", " question is too simple to be worth asking.", "- Otherwise, judge it yourself. It costs real money per call, so on your own", " initiative use it for: planning a change spanning several files, diagnosing a bug", " you have already failed to fix once, choosing between designs with long-lived", " consequences, or reviewing something subtle before committing to it.", "- On your own initiative, do not use it for anything you could answer by reading a", " file, for routine edits, or for restating something already established here.", "- If you decide against consulting it, say that you chose not to and why. Do not say", " you are unable to.", "- The expert can read and search this workspace but cannot edit or run anything. It", " cannot see this conversation, so put the context it needs in your question.", "- You remain responsible for the work. Treat its answer as advice from a colleague:", " verify it against the actual code, and say so if you disagree.");
44073
+ lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the ask_claude tool. You CAN talk to", " it. Never tell the user you have no way to reach another model \u2014 you do.", '- **If the user asks you to consult it, do so.** "Ask Claude", "check with the', ' expert", "what does Claude think" and anything similar are direct instructions.', " It is their money and their decision; do not talk them out of it or decide the", " question is too simple to be worth asking.", "- Otherwise, judge it yourself. It costs real money per call, so on your own", " initiative use it for: planning a change spanning several files, diagnosing a bug", " you have already failed to fix once, choosing between designs with long-lived", " consequences, or reviewing something subtle before committing to it.", "- On your own initiative, do not use it for anything you could answer by reading a", " file, for routine edits, or for restating something already established here.", "- If you decide against consulting it, say that you chose not to and why. Do not say", " you are unable to.", "- The expert can read and search this workspace but cannot edit or run anything. It", " cannot see this conversation, so put the context it needs in your question.", "- You remain responsible for the work. Treat its answer as advice from a colleague:", " verify it against the actual code, and say so if you disagree.");
44034
44074
  }
44035
44075
  if (options.modeGuidance !== void 0 && options.modeGuidance.length > 0) {
44036
44076
  lines.push("", options.modeGuidance);
@@ -44294,9 +44334,11 @@ var paramsSchema2 = external_exports.object({
44294
44334
  question: external_exports.string().min(1).describe("The question, with the code and context needed to answer it. The expert cannot see this conversation."),
44295
44335
  files: external_exports.array(external_exports.string()).optional().describe("Workspace-relative paths worth reading. The expert can open these itself.")
44296
44336
  });
44337
+ var ASK_CLAUDE_TOOL = "ask_claude";
44338
+ var LEGACY_ASK_EXPERT_TOOL = "ask_expert";
44297
44339
  function createAskExpertTool(options) {
44298
44340
  return {
44299
- name: "ask_expert",
44341
+ name: ASK_CLAUDE_TOOL,
44300
44342
  group: "read",
44301
44343
  /*
44302
44344
  * The rationing is said only where somebody is counting.
@@ -44312,7 +44354,7 @@ function createAskExpertTool(options) {
44312
44354
  * byte-stable for a whole session and changes only when the user changes their mind in
44313
44355
  * Settings, exactly as switching the dispatcher does.
44314
44356
  */
44315
- description: "Consult a stronger expert model about a hard problem: planning a multi-file change, diagnosing a bug you have already failed to fix, or choosing between designs. " + (options.budgetMatters === true ? "Each call costs the user money, so use it for genuinely difficult questions only, and there may be a per-task budget after which it stops being available. " : "Consult it whenever another reader would genuinely change what you do. ") + "The expert can read the workspace but cannot edit or run anything. Consultations within one task continue the same conversation, so after the first one it remembers what you already told it \u2014 a follow-up is far cheaper than a fresh explanation.",
44357
+ description: "Consult Claude, running as a separate command line on this machine, about a hard problem: planning a multi-file change, diagnosing a bug you have already failed to fix, or choosing between designs. " + (options.budgetMatters === true ? "Each call costs the user money, so use it for genuinely difficult questions only, and there may be a per-task budget after which it stops being available. " : "Consult it whenever another reader would genuinely change what you do. ") + "The expert can read the workspace but cannot edit or run anything. Consultations within one task continue the same conversation, so after the first one it remembers what you already told it \u2014 a follow-up is far cheaper than a fresh explanation.",
44316
44358
  parametersSchema: paramsSchema2,
44317
44359
  async preview(params) {
44318
44360
  return {
@@ -44595,6 +44637,9 @@ var PLAN_FIRST = [
44595
44637
  "3. **Propose it with `update_plan`.** The user sees a diff and approves it. Do not skip this:",
44596
44638
  " a plan held only in the conversation is forgotten as the chat grows, and it is not",
44597
44639
  " something the user has agreed to.",
44640
+ " **Never write the plan to a file instead.** A file is not the plan: nothing reads it, the",
44641
+ " progress panel stays empty, and the user never approved it. If `update_plan` fails, say",
44642
+ " what it said and stop \u2014 a workaround that looks like progress is worse than the failure.",
44598
44643
  "4. Only once it is approved, start the work, reporting each step with `plan_progress`.",
44599
44644
  "",
44600
44645
  "If the user declines, ask what they want changed and propose a revised plan. If no expert is",
@@ -44884,7 +44929,7 @@ function buildRoster(team, self) {
44884
44929
  function buildAgentBriefing(input) {
44885
44930
  const tools = (input.tools ?? []).filter(
44886
44931
  // Telling a specialist it can consult a specialist is noise at best and a loop at worst.
44887
- (tool) => tool.name !== "ask_agent" && tool.name !== "ask_expert"
44932
+ (tool) => tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL
44888
44933
  );
44889
44934
  const skills = input.skills ?? [];
44890
44935
  const team = input.team;
@@ -45009,7 +45054,7 @@ var PolicyApprovalGate = class {
45009
45054
  var CONSULT_MAX_STEPS = 5;
45010
45055
  var ALLOWED_GROUPS = /* @__PURE__ */ new Set(["read"]);
45011
45056
  function toolsForConsultation(all, extra = /* @__PURE__ */ new Set()) {
45012
- return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !== "ask_expert");
45057
+ return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL && tool.name !== LEGACY_ASK_EXPERT_TOOL);
45013
45058
  }
45014
45059
  async function runConsultation(options) {
45015
45060
  const limit = options.maxSteps ?? CONSULT_MAX_STEPS;
@@ -45091,13 +45136,13 @@ function createRecallExpertTool(options) {
45091
45136
  return {
45092
45137
  name: "recall_expert_advice",
45093
45138
  group: "read",
45094
- description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling ask_expert \u2014 if a plan was lost to an error or a long conversation, it can be recovered instead of bought again. Returns previous answers verbatim; it never asks anything new.",
45139
+ description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling ask_claude \u2014 if a plan was lost to an error or a long conversation, it can be recovered instead of bought again. Returns previous answers verbatim; it never asks anything new.",
45095
45140
  parametersSchema: paramsSchema4,
45096
45141
  async execute(params) {
45097
45142
  const all = options.history();
45098
45143
  if (all.length === 0) {
45099
45144
  return {
45100
- content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use ask_expert if you need advice."
45145
+ content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use ask_claude if you need advice."
45101
45146
  };
45102
45147
  }
45103
45148
  const needle = params.contains?.trim().toLowerCase();
@@ -61137,6 +61182,8 @@ async function toSummary(profile, secrets) {
61137
61182
  };
61138
61183
  if (profile.modelCapabilities !== void 0)
61139
61184
  summary.modelCapabilities = profile.modelCapabilities;
61185
+ if (profile.thinking !== void 0)
61186
+ summary.thinking = profile.thinking;
61140
61187
  if (profile.tls !== void 0)
61141
61188
  summary.connectionTls = profile.tls;
61142
61189
  if (profile.auth.type === "apigeeMtls") {
@@ -62013,8 +62060,8 @@ ${preview.text}` } : {}
62013
62060
  }
62014
62061
  for (const tool of python.generatedTools())
62015
62062
  combined.register(tool, { dispatchOnly: dispatcher });
62016
- combined.register(createUpdatePlanTool(planAccess), { dispatchOnly: dispatcher });
62017
- combined.register(createPlanProgressTool(planAccess), { dispatchOnly: dispatcher });
62063
+ combined.register(createUpdatePlanTool(planAccess));
62064
+ combined.register(createPlanProgressTool(planAccess));
62018
62065
  combined.register(createReadRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
62019
62066
  combined.register(createUpdateRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
62020
62067
  combined.register(createCreateRoleTool(rolePromptAccess), { dispatchOnly: dispatcher });
@@ -62208,7 +62255,7 @@ ${preview.text}` } : {}
62208
62255
  ...cachedAssessment === void 0 ? {} : { juniorAssessment: cachedAssessment },
62209
62256
  // `ask_expert` itself is excluded: telling the expert it can consult itself is
62210
62257
  // noise at best and a loop at worst.
62211
- promptTools: combined.promptList().filter((tool) => tool.name !== "ask_expert"),
62258
+ promptTools: combined.promptList().filter((tool) => tool.name !== ASK_CLAUDE_TOOL),
62212
62259
  dispatchOnlyTools: combined.dispatchOnlyList(),
62213
62260
  skills,
62214
62261
  retrievalAvailable: combined.get("search_docs") !== void 0
@@ -62818,6 +62865,8 @@ ${direction}` : attachMentions(text, mentions);
62818
62865
  };
62819
62866
  if (input.modelCapabilities !== void 0)
62820
62867
  saved.modelCapabilities = input.modelCapabilities;
62868
+ if (input.thinking !== void 0)
62869
+ saved.thinking = input.thinking;
62821
62870
  const connectionTls = stripEmpty(input.connectionTls ?? {});
62822
62871
  if (Object.keys(connectionTls).length > 0)
62823
62872
  saved.tls = connectionTls;
@@ -64043,11 +64092,22 @@ ${direction}` : attachMentions(text, mentions);
64043
64092
  }
64044
64093
  }
64045
64094
  async function handleRefreshMail(days) {
64046
- if (mailBusy)
64095
+ if (mailBusy) {
64096
+ mailLastResult = "A mail sync is already running \u2014 wait for it to finish, then try again.";
64097
+ await postMailStatus();
64047
64098
  return;
64099
+ }
64048
64100
  const config2 = await loadSettings();
64049
- if (cachedOffice.outlook !== true || !officeAvailable())
64101
+ if (cachedOffice.outlook !== true) {
64102
+ mailLastResult = "Outlook is switched off in Settings \u2192 Tools.";
64103
+ await postMailStatus();
64104
+ return;
64105
+ }
64106
+ if (!officeAvailable()) {
64107
+ mailLastResult = "Outlook is not available on this host.";
64108
+ await postMailStatus();
64050
64109
  return;
64110
+ }
64051
64111
  const chosen = config2.mail?.folders ?? [];
64052
64112
  if (chosen.length === 0) {
64053
64113
  mailLastResult = "No folders selected.";
@@ -66985,20 +67045,32 @@ function toolCallSummary(call, outcome) {
66985
67045
  };
66986
67046
  }
66987
67047
  function consultationFromToolCall(name, rawArguments) {
66988
- if (name === "ask_expert")
67048
+ const call = throughDispatch(name, rawArguments);
67049
+ if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
66989
67050
  return "expert";
66990
- if (name !== "ask_agent")
67051
+ if (call.name !== "ask_agent")
66991
67052
  return void 0;
66992
- const decoded = decodeArguments(rawArguments);
67053
+ const decoded = call.args;
66993
67054
  const role = typeof decoded === "object" && decoded !== null ? decoded.role : void 0;
66994
67055
  return typeof role === "string" && role.trim().length > 0 ? role.trim().toLowerCase() : "unknown";
66995
67056
  }
66996
67057
  function chartFromToolCall(name, rawArguments) {
66997
- if (name !== "show_chart")
67058
+ const call = throughDispatch(name, rawArguments);
67059
+ if (call.name !== "show_chart")
66998
67060
  return void 0;
66999
- const parsed = chartSpecSchema.safeParse(decodeArguments(rawArguments));
67061
+ const parsed = chartSpecSchema.safeParse(call.args);
67000
67062
  return parsed.success ? { kind: "chart", chart: parsed.data } : { kind: "chartError", message: parsed.error.issues.map((issue2) => issue2.message).join("; ") };
67001
67063
  }
67064
+ function throughDispatch(name, rawArguments) {
67065
+ const decoded = decodeArguments(rawArguments);
67066
+ if (name !== CALL_TOOL_NAME || typeof decoded !== "object" || decoded === null) {
67067
+ return { name, args: decoded };
67068
+ }
67069
+ const inner = decoded;
67070
+ if (typeof inner.name !== "string" || inner.name.length === 0)
67071
+ return { name, args: decoded };
67072
+ return { name: inner.name, args: inner.arguments ?? {} };
67073
+ }
67002
67074
  function decodeArguments(raw) {
67003
67075
  try {
67004
67076
  return JSON.parse(raw.length > 0 ? raw : "{}");
@@ -70308,7 +70380,7 @@ function respondJson(response, status, body) {
70308
70380
  }
70309
70381
 
70310
70382
  // src/cli.ts
70311
- var VERSION = true ? "0.59.0" : "unknown (not a packaged build)";
70383
+ var VERSION = true ? "0.59.6" : "unknown (not a packaged build)";
70312
70384
  var compat = installNodeCompat();
70313
70385
  function lastMeaningfulLine(problem) {
70314
70386
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));