@cnwenf/occ 2.1.265 → 2.1.267

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.
Files changed (2) hide show
  1. package/dist/cli.js +115 -33
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- globalThis.MACRO={"VERSION":"2.1.265","BUILD_TIME":"2026-07-10T09:15:53.803Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
2
+ globalThis.MACRO={"VERSION":"2.1.267","BUILD_TIME":"2026-07-10T11:27:59.433Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
3
3
  // @bun
4
4
  var __create = Object.create;
5
5
  var __getProtoOf = Object.getPrototypeOf;
@@ -190875,6 +190875,36 @@ function isUltracodeEnabled() {
190875
190875
  }
190876
190876
  function enableUltracodeForSession() {
190877
190877
  ultracodeActive = true;
190878
+ ultracodeJustEnabled = true;
190879
+ ultracodeJustDisabled = false;
190880
+ }
190881
+ function disableUltracodeForSession() {
190882
+ if (ultracodeActive || readEnvUltracode()) {
190883
+ ultracodeJustDisabled = true;
190884
+ }
190885
+ ultracodeActive = false;
190886
+ ultracodeJustEnabled = false;
190887
+ }
190888
+ function getUltracodeTurnReminders() {
190889
+ const reminders = [];
190890
+ if (ultracodeJustDisabled) {
190891
+ reminders.push({ content: ULTRACODE_EXIT_REMINDER, isMeta: true });
190892
+ ultracodeJustDisabled = false;
190893
+ return reminders;
190894
+ }
190895
+ if (!isUltracodeEnabled())
190896
+ return reminders;
190897
+ if (ultracodeJustEnabled) {
190898
+ reminders.push({
190899
+ content: ULTRACODE_WORKFLOW_KEYWORD_REQUEST,
190900
+ isMeta: true
190901
+ });
190902
+ reminders.push(getUltracodeReminderObject("full"));
190903
+ ultracodeJustEnabled = false;
190904
+ } else {
190905
+ reminders.push(getUltracodeReminderObject("still"));
190906
+ }
190907
+ return reminders;
190878
190908
  }
190879
190909
  function shouldTriggerUltracodeFromPrompt(input) {
190880
190910
  if (isUltracodeEnabled())
@@ -190883,7 +190913,7 @@ function shouldTriggerUltracodeFromPrompt(input) {
190883
190913
  return false;
190884
190914
  return detectUltracodeKeyword(input);
190885
190915
  }
190886
- var ULTRACODE_KEYWORD = "ultracode", ENABLE_ULTRACODE_DESCRIPTION, ULTRACODE_EFFORT_DESCRIPTION = "xhigh effort + dynamic workflows for maximum thoroughness", ULTRACODE_EFFORT_DISPLAY, ULTRACODE_ACTIVATION_MESSAGE = "ultracode (xhigh effort plus standing dynamic-workflow orchestration) is active for the session. Set per session via the `ultracode` settings key (--settings or apply_flag_settings).", ULTRACODE_REMINDER_FULL = "Ultracode is on: optimize for the most exhaustive, correct answer \u2014 not the fastest or cheapest. Use the Workflow tool on every substantive task; token cost is not a constraint. See the Workflow tool's **Ultracode** section and quality patterns. Solo only on conversational/trivial turns.", ULTRACODE_REMINDER_STILL = "Ultracode is still on \u2014 use the Workflow tool; see its Ultracode section.", ultracodeActive = false;
190916
+ var ULTRACODE_KEYWORD = "ultracode", ENABLE_ULTRACODE_DESCRIPTION, ULTRACODE_EFFORT_DESCRIPTION = "xhigh effort + dynamic workflows for maximum thoroughness", ULTRACODE_EFFORT_DISPLAY, ULTRACODE_ACTIVATION_MESSAGE = "ultracode (xhigh effort plus standing dynamic-workflow orchestration) is active for the session. Set per session via the `ultracode` settings key (--settings or apply_flag_settings).", ULTRACODE_REMINDER_FULL = "Ultracode is on: optimize for the most exhaustive, correct answer \u2014 not the fastest or cheapest. Use the Workflow tool on every substantive task; token cost is not a constraint. See the Workflow tool's **Ultracode** section and quality patterns. Solo only on conversational/trivial turns.", ULTRACODE_REMINDER_STILL = "Ultracode is still on \u2014 use the Workflow tool; see its Ultracode section.", ULTRACODE_WORKFLOW_KEYWORD_REQUEST = 'The user included the keyword "ultracode", opting this turn into multi-agent orchestration \u2014 use the Workflow tool to fulfill the request.', ULTRACODE_EXIT_REMINDER = "Ultracode is off \u2014 the Workflow tool's standard opt-in rule applies again.", ultracodeActive = false, ultracodeJustEnabled = false, ultracodeJustDisabled = false;
190887
190917
  var init_ultracode = __esm(() => {
190888
190918
  ENABLE_ULTRACODE_DESCRIPTION = "Enable ultracode for the session: xhigh effort plus standing dynamic-workflow orchestration. " + "Session-scoped \u2014 typically provided via --settings or the apply_flag_settings control request; " + "interactive toggles never persist it. Requires workflows to be enabled and an xhigh-capable model.";
190889
190919
  ULTRACODE_EFFORT_DISPLAY = `ultracode \xB7 ${ULTRACODE_EFFORT_DESCRIPTION}`;
@@ -190901,10 +190931,8 @@ function setSystemPromptInjection(value) {
190901
190931
  function shouldUseLeanSystemPrompt(model, effort) {
190902
190932
  return shouldUseLeanPrompt(model, effort);
190903
190933
  }
190904
- function getUltracodeSystemReminder() {
190905
- if (!isUltracodeEnabled())
190906
- return null;
190907
- return getUltracodeReminderObject("full");
190934
+ function getUltracodeSystemReminders() {
190935
+ return getUltracodeTurnReminders();
190908
190936
  }
190909
190937
  var MAX_STATUS_CHARS = 2000, systemPromptInjection = null, getGitStatus, getSystemContext, getUserContext;
190910
190938
  var init_context2 = __esm(() => {
@@ -582989,6 +583017,7 @@ var init_bundled = __esm(() => {
582989
583017
  var exports_scriptLoader = {};
582990
583018
  __export(exports_scriptLoader, {
582991
583019
  validateScriptPath: () => validateScriptPath,
583020
+ loadScriptFromSource: () => loadScriptFromSource,
582992
583021
  loadScript: () => loadScript,
582993
583022
  WorkflowScriptError: () => WorkflowScriptError
582994
583023
  });
@@ -583102,23 +583131,16 @@ function extractDefaultExport(body) {
583102
583131
  const expr = m5[2].replace(/;\s*$/, "");
583103
583132
  return { hasDefaultExport: true, defaultExportExpr: expr, body };
583104
583133
  }
583105
- function loadScript(scriptPath) {
583106
- const resolved = validateScriptPath(scriptPath);
583107
- let source2;
583108
- try {
583109
- source2 = readFileSync26(resolved, "utf8");
583110
- } catch (e4) {
583111
- const err2 = e4;
583112
- throw new WorkflowScriptError(`Failed to read workflow script ${scriptPath}: ${err2.message}`);
583113
- }
583134
+ function loadScriptFromSource(source2, scriptPath) {
583135
+ const label = scriptPath ?? "<inline>";
583114
583136
  if (!source2.trim()) {
583115
- throw new WorkflowScriptError(`Workflow script ${scriptPath} is empty`);
583137
+ throw new WorkflowScriptError(`Workflow script ${label} is empty`);
583116
583138
  }
583117
583139
  const { metaJson, bodyStart } = extractMetaStatement(source2);
583118
583140
  const meta3 = parseMeta(metaJson);
583119
583141
  let body = source2.slice(bodyStart).trim();
583120
583142
  if (!body) {
583121
- throw new WorkflowScriptError(`Workflow script ${scriptPath} has no body after \`export const meta\``);
583143
+ throw new WorkflowScriptError(`Workflow script ${label} has no body after \`export const meta\``);
583122
583144
  }
583123
583145
  validateBodyDeterminism(body);
583124
583146
  const { hasDefaultExport, defaultExportExpr, body: cleanedBody } = extractDefaultExport(body);
@@ -583127,10 +583149,24 @@ function loadScript(scriptPath) {
583127
583149
  body: cleanedBody,
583128
583150
  hasDefaultExport,
583129
583151
  defaultExportExpr,
583130
- scriptPath: resolved,
583152
+ scriptPath: scriptPath ?? "<inline>",
583131
583153
  source: source2
583132
583154
  };
583133
583155
  }
583156
+ function loadScript(scriptPath) {
583157
+ const resolved = validateScriptPath(scriptPath);
583158
+ let source2;
583159
+ try {
583160
+ source2 = readFileSync26(resolved, "utf8");
583161
+ } catch (e4) {
583162
+ const err2 = e4;
583163
+ if (err2.code === "ENOENT") {
583164
+ throw new WorkflowScriptError(`Workflow script file not found: ${scriptPath}. ` + "Create the file first (Write tool, or via shell if Write is unavailable), " + "then retry with the same path. The script must begin with " + "`export const meta = { name, description, phases }` and export a default " + "async function: `export default async ({ agent, parallel, pipeline, phase, " + "log, budget, workflow, resolveWorkflow, args }) => { ... }`.");
583165
+ }
583166
+ throw new WorkflowScriptError(`Failed to read workflow script ${scriptPath}: ${err2.message}`);
583167
+ }
583168
+ return loadScriptFromSource(source2, resolved);
583169
+ }
583134
583170
  var WorkflowScriptError;
583135
583171
  var init_scriptLoader = __esm(() => {
583136
583172
  WorkflowScriptError = class WorkflowScriptError extends Error {
@@ -583494,13 +583530,13 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
583494
583530
  };
583495
583531
  const parallel = async (items) => {
583496
583532
  if (!Array.isArray(items)) {
583497
- throw new Error("parallel() requires an array of thunks");
583533
+ throw new Error("parallel() requires an array of thunks or promises");
583498
583534
  }
583499
583535
  if (items.length > WORKFLOW_PARALLEL_MAX_ITEMS) {
583500
583536
  throw new Error(`parallel() accepts at most ${WORKFLOW_PARALLEL_MAX_ITEMS} items; ` + `got ${items.length}`);
583501
583537
  }
583502
583538
  const sem = createSemaphore(concurrency);
583503
- const settled = await Promise.allSettled(items.map((thunk) => sem(() => thunk())));
583539
+ const settled = await Promise.allSettled(items.map((item) => sem(() => typeof item === "function" ? item() : item)));
583504
583540
  const results = [];
583505
583541
  let budgetHits = 0;
583506
583542
  for (const s4 of settled) {
@@ -583568,7 +583604,7 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
583568
583604
  }
583569
583605
  return results;
583570
583606
  };
583571
- const phase = (title) => {
583607
+ const phase = (title, fn) => {
583572
583608
  if (typeof title !== "string") {
583573
583609
  throw new Error("phase() requires a string title");
583574
583610
  }
@@ -583589,6 +583625,9 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
583589
583625
  phase: title,
583590
583626
  agentCount: ctx.counters.agentCount
583591
583627
  });
583628
+ if (typeof fn === "function") {
583629
+ return Promise.resolve(fn());
583630
+ }
583592
583631
  };
583593
583632
  const log3 = (...args) => {
583594
583633
  const msg = args.map((a6) => typeof a6 === "string" ? a6 : JSON.stringify(a6)).join(" ");
@@ -584340,7 +584379,26 @@ function buildWorkflowProgressHandler(runId, seedPhases, emit2, onAgentEvent) {
584340
584379
  });
584341
584380
  };
584342
584381
  }
584343
- var import_react83, inputSchema41, outputSchema37, DESCRIPTION22 = `Run a multi-step workflow from a self-contained JavaScript script. The script runs in a sandboxed vm with access to primitives: agent(prompt, opts?) to spawn a subagent, parallel(items) for concurrent execution (max 4096 items, ~10 concurrent), pipeline(items, ...stages) for streaming, phase(title) to group agents, log(...args) for workflow-scoped logging, budget {total, remaining(), spent()} for token caps, and workflow(nameOrRef) / resolveWorkflow(name) for sub-workflows. Scripts are deterministic for resume (no Date/Math.random/import). Use the Workflow tool on substantive multi-agent tasks.`, WorkflowTool;
584382
+ var import_react83, inputSchema41, outputSchema37, DESCRIPTION22 = `Run a multi-step workflow from a self-contained JavaScript script. The script runs in a sandboxed vm with access to primitives: agent(prompt, opts?) to spawn a subagent, parallel(items) for concurrent execution (max 4096 items, ~10 concurrent), pipeline(items, ...stages) for streaming, phase(title, fn?) to group agents (optional callback form: phase('title', async () => { ...parallel/agent... }) runs fn within the phase and returns its result), log(...args) for workflow-scoped logging, budget {total, remaining(), spent()} for token caps, and workflow(nameOrRef) / resolveWorkflow(name) for sub-workflows. Scripts are deterministic for resume (no Date/Math.random/import). Use the Workflow tool on substantive multi-agent tasks.
584383
+
584384
+ - Ultracode is on for the session (a system-reminder confirms it) \u2014 see **Ultracode** below.
584385
+
584386
+ **Ultracode.** When a system-reminder confirms ultracode is on, that opt-in is standing: author and run a workflow for every substantive task by default. The goal is the most exhaustive, correct answer you can produce \u2014 token cost is not a constraint. For multi-phase work (understand \u2192 design \u2192 implement \u2192 review), that often means several workflows in sequence \u2014 one per phase \u2014 so you stay in the loop between them. The quality patterns below (adversarial verify, multi-modal sweep, completeness critic, loop-until-dry) are the tools; pick what fits the task. Lean toward orchestrating with workflows and adversarially verifying your findings \u2014 unless the work is trivial or already verified. Solo only on conversational turns or trivial mechanical edits. When a reminder says ultracode is off, revert to the opt-in rule above.
584387
+
584388
+ Quality patterns:
584389
+ - Adversarial verify: spawn N independent skeptics per finding, each prompted to REFUTE. Kill if \u2265majority refute. Prevents plausible-but-wrong findings from surviving.
584390
+ - Loop-until-dry: for unknown-size discovery (bugs, issues, edge cases), keep spawning finders until K consecutive rounds return nothing new. Simple counters (while count < N) miss the tail.
584391
+ - Multi-modal sweep: parallel agents each searching a different way (by-container, by-content, by-entity, by-time). Each is blind to what the others surface; useful when one search angle won't find everything.
584392
+ - Completeness critic: a final agent that asks "what's missing \u2014 modality not run, claim unverified, source unread?" What it finds becomes the next round of work.
584393
+ - **Research** \u2014 multi-modal sweep \u2192 deep-read \u2192 synthesize
584394
+
584395
+ Composing patterns \u2014 exhaustive review (find \u2192 dedup vs seen \u2192 diverse-lens panel \u2192 loop-until-dry):
584396
+ while (dry < 2) { // loop-until-dry
584397
+ found = await agent(\`find more in bucket \${bucket}\`) // multi-modal sweep (by bucket)
584398
+ novel = dedupVsSeen(found) // dedup vs seen
584399
+ panel = await parallel(lenses.map(L => agent(\`critique as \${L}\`))) // diverse-lens panel
584400
+ dry = novel.length === 0 ? dry + 1 : 0 // reset on any hit
584401
+ }`, WorkflowTool;
584344
584402
  var init_WorkflowTool = __esm(() => {
584345
584403
  init_v4();
584346
584404
  init_ink2();
@@ -584357,7 +584415,8 @@ var init_WorkflowTool = __esm(() => {
584357
584415
  init_wfProgress();
584358
584416
  import_react83 = __toESM(require_react(), 1);
584359
584417
  inputSchema41 = lazySchema(() => exports_external.object({
584360
- scriptPath: exports_external.string().optional().describe("Absolute path to a self-contained workflow script (.js). The script must begin with `export const meta = { name, description, phases }` and export a default async function receiving { agent, parallel, pipeline, phase, log, budget, workflow, resolveWorkflow, args }. Optional if `name` is provided."),
584418
+ scriptPath: exports_external.string().optional().describe("Absolute path to a self-contained workflow script (.js). The script must begin with `export const meta = { name, description, phases }` and export a default async function receiving { agent, parallel, pipeline, phase, log, budget, workflow, resolveWorkflow, args }. Optional if `name` or `script` is provided."),
584419
+ script: exports_external.string().optional().describe("Self-contained workflow script. Must begin with `export const meta = { name, description, phases }` (pure literal, no computed values) followed by the script body using agent()/parallel()/pipeline()/phase()."),
584361
584420
  args: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Arguments object passed to the workflow as `args`."),
584362
584421
  resumeFromRunId: exports_external.string().regex(/^wf_[a-z0-9-]{6,}$/).optional().describe("Resume a previous workflow run by its run ID (wf_...). Completed agent() calls with unchanged (prompt, opts) return their cached results instantly; only edited or new calls re-run."),
584363
584422
  name: exports_external.string().optional().describe("Name of a predefined workflow (built-in or from .claude/workflows/). Resolves to a self-contained script."),
@@ -584381,7 +584440,9 @@ var init_WorkflowTool = __esm(() => {
584381
584440
  return `${DESCRIPTION22} ${sizeHint} (Per the dynamicWorkflowSize setting \u2014 advisory, not a cap.)`;
584382
584441
  },
584383
584442
  async prompt() {
584384
- return `Use this tool to run a workflow script. The script must start with \`export const meta = { name, description, phases }\` and export a default async function: \`export default async ({ agent, parallel, pipeline, phase, log, budget, workflow, resolveWorkflow, args }) => { ... }\`.`;
584443
+ return `${DESCRIPTION22}
584444
+
584445
+ Use this tool to run a workflow script. The script must start with \`export const meta = { name, description, phases }\` and export a default async function: \`export default async ({ agent, parallel, pipeline, phase, log, budget, workflow, resolveWorkflow, args }) => { ... }\`.`;
584385
584446
  },
584386
584447
  get inputSchema() {
584387
584448
  return inputSchema41();
@@ -584455,6 +584516,12 @@ var init_WorkflowTool = __esm(() => {
584455
584516
  decisionReason: { type: "other", reason: "invalid script path" }
584456
584517
  };
584457
584518
  }
584519
+ } else if (input2.script) {
584520
+ return {
584521
+ behavior: "ask",
584522
+ message: `Run the inline workflow script?`,
584523
+ updatedInput: input2
584524
+ };
584458
584525
  }
584459
584526
  return {
584460
584527
  behavior: "ask",
@@ -584492,20 +584559,21 @@ ${typeof result === "string" ? result : JSON.stringify(result, null, 2)}`
584492
584559
  };
584493
584560
  },
584494
584561
  async call(input2, context7, canUseTool, _parentMessage, onProgress) {
584495
- const { scriptPath: rawScriptPath, args, resumeFromRunId, name: name3, remote } = input2;
584496
- let resolvedScriptPath;
584562
+ const { scriptPath: rawScriptPath, script, args, resumeFromRunId, name: name3, remote } = input2;
584563
+ let loaded;
584497
584564
  if (name3) {
584498
584565
  const found = resolveWorkflowScript(name3);
584499
584566
  if (!found) {
584500
584567
  throw new Error(`Workflow tool: could not resolve workflow "${name3}". Add scripts to .claude/workflows/ (project) or ~/.claude/workflows/ (user).`);
584501
584568
  }
584502
- resolvedScriptPath = found;
584569
+ loaded = loadScript(found);
584503
584570
  } else if (rawScriptPath) {
584504
- resolvedScriptPath = validateScriptPath(rawScriptPath);
584571
+ loaded = loadScript(validateScriptPath(rawScriptPath));
584572
+ } else if (script) {
584573
+ loaded = loadScriptFromSource(script);
584505
584574
  } else {
584506
- throw new Error("Workflow tool requires either `scriptPath` or `name`.");
584575
+ throw new Error("Workflow tool requires one of `script`, `scriptPath`, or `name`.");
584507
584576
  }
584508
- const loaded = loadScript(resolvedScriptPath);
584509
584577
  let runId;
584510
584578
  if (resumeFromRunId) {
584511
584579
  if (!isValidWorkflowRunId(resumeFromRunId)) {
@@ -595990,9 +596058,10 @@ async function* queryLoop(params, consumedCommandUuids) {
595990
596058
  try {
595991
596059
  let streamingFallbackOccured = false;
595992
596060
  queryCheckpoint("query_api_streaming_start");
595993
- const ultracodeReminder = getUltracodeSystemReminder();
595994
- const messagesForApi = ultracodeReminder !== null ? [
595995
- buildHarnessReminderMessage(ultracodeReminder, currentModel),
596061
+ const ultracodeReminders = getUltracodeSystemReminders();
596062
+ const ultracodeMessages = ultracodeReminders.map((r4) => buildHarnessReminderMessage(r4, currentModel));
596063
+ const messagesForApi = ultracodeMessages.length > 0 ? [
596064
+ ...ultracodeMessages,
595996
596065
  ...prependUserContext(messagesForQuery, userContext)
595997
596066
  ] : prependUserContext(messagesForQuery, userContext);
595998
596067
  for await (const message of deps.callModel({
@@ -707832,6 +707901,9 @@ function enableUltracode() {
707832
707901
  function executeEffort(args) {
707833
707902
  const normalized = args.toLowerCase();
707834
707903
  if (normalized === "auto" || normalized === "unset") {
707904
+ if (isUltracodeEnabled()) {
707905
+ disableUltracodeForSession();
707906
+ }
707835
707907
  return unsetEffortLevel();
707836
707908
  }
707837
707909
  if (normalized === "ultracode") {
@@ -707842,6 +707914,9 @@ function executeEffort(args) {
707842
707914
  message: `Invalid argument: ${args}. Valid options are: low, medium, high, max, ultracode, auto`
707843
707915
  };
707844
707916
  }
707917
+ if (isUltracodeEnabled()) {
707918
+ disableUltracodeForSession();
707919
+ }
707845
707920
  return setEffortValue(normalized);
707846
707921
  }
707847
707922
  function ShowCurrentEffort(t0) {
@@ -809078,6 +809153,12 @@ Startup time: ${Math.round(process.uptime() * 1000)}ms
809078
809153
  `);
809079
809154
  process.exit(0);
809080
809155
  }
809156
+ if (typeof inputPrompt === "string" && shouldTriggerUltracodeFromPrompt(inputPrompt)) {
809157
+ enableUltracodeForSession();
809158
+ logEvent2("tengu_ultracode_keyword_triggered", {
809159
+ source: "headless_prompt"
809160
+ });
809161
+ }
809081
809162
  if (feature("DOWNLOAD_USER_SETTINGS") && (isEnvTruthy(process.env.CLAUDE_CODE_REMOTE) || getIsRemoteMode())) {
809082
809163
  downloadUserSettings();
809083
809164
  }
@@ -812024,6 +812105,7 @@ var init_print = __esm(() => {
812024
812105
  init_remoteManagedSettings();
812025
812106
  init_structuredIO();
812026
812107
  init_remoteIO();
812108
+ init_ultracode();
812027
812109
  init_commands5();
812028
812110
  init_streamlinedTransform();
812029
812111
  init_streamJsonStdoutGuard();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnwenf/occ",
3
- "version": "2.1.265",
3
+ "version": "2.1.267",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {