@ordewell/core 0.4.0 → 0.4.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/dist/index.mjs CHANGED
@@ -4184,6 +4184,14 @@ ${tail}`;
4184
4184
 
4185
4185
  ${blocks.join("\n\n")}`;
4186
4186
  }
4187
+ function augmentPromptWithPriorOutputs(task, allTasks) {
4188
+ const basePrompt = task.prompt ?? "";
4189
+ const outputs = collectDirectDependencyOutputs(task, allTasks);
4190
+ if (outputs.length === 0) return basePrompt;
4191
+ return `${renderPriorOutputs(outputs)}
4192
+
4193
+ ${basePrompt}`;
4194
+ }
4187
4195
  function planMapStatus(task, isCurrent) {
4188
4196
  if (isCurrent) return "NOW";
4189
4197
  if (task.status === "completed") return "done";
@@ -10164,7 +10172,11 @@ var HeadlessSession = class extends AbstractTerminalSession {
10164
10172
  spawnImpl;
10165
10173
  process = null;
10166
10174
  outputBuffer = "";
10175
+ get isStarted() {
10176
+ return this.process !== null;
10177
+ }
10167
10178
  start(launch, cwd, resolvedPath, env) {
10179
+ if (this.exited || this.process) return;
10168
10180
  this.process = this.spawnImpl(launch.file, launch.args, {
10169
10181
  env: withPath(process.env, resolvedPath, env),
10170
10182
  stdio: ["pipe", "pipe", "pipe"],
@@ -10193,6 +10205,7 @@ Process error: ${err.message}
10193
10205
  }
10194
10206
  kill() {
10195
10207
  killTree(this.process);
10208
+ if (!this.process) this.baseHandleExit(-1);
10196
10209
  }
10197
10210
  getOutput() {
10198
10211
  return this.outputBuffer;
@@ -10208,6 +10221,8 @@ var HeadlessRunner = class extends AbstractRunner {
10208
10221
  hasScriptCmd;
10209
10222
  resolvePath;
10210
10223
  launchDeps;
10224
+ /** Session shape when the caller names none; the VS Code runner overrides it to interactive. */
10225
+ defaultHeadless = true;
10211
10226
  constructor(deps = {}) {
10212
10227
  super();
10213
10228
  this.spawnImpl = deps.spawnImpl ?? nodeSpawn2;
@@ -10215,9 +10230,12 @@ var HeadlessRunner = class extends AbstractRunner {
10215
10230
  this.resolvePath = deps.resolvePath ?? augmentedPath;
10216
10231
  this.launchDeps = { resolvePath: this.resolvePath, ...deps.launchDeps };
10217
10232
  }
10218
- async spawn(opts) {
10219
- const id = `ordewell-${opts.taskId.slice(0, 8)}`;
10220
- const session = new HeadlessSession(id, opts.taskId, this.spawnImpl);
10233
+ createSession(id, taskId) {
10234
+ return new HeadlessSession(id, taskId, this.spawnImpl);
10235
+ }
10236
+ /** Everything up to, but not including, spawning — so a surface that owns its own child reaches the same decisions. */
10237
+ async prepareLaunch(opts) {
10238
+ const headless = opts.headless ?? this.defaultHeadless;
10221
10239
  const invocation = buildRunnerInvocation({
10222
10240
  runner: opts.runner,
10223
10241
  prompt: opts.prompt,
@@ -10225,21 +10243,27 @@ var HeadlessRunner = class extends AbstractRunner {
10225
10243
  thinkingEffort: opts.thinkingEffort,
10226
10244
  modelVariants: opts.modelVariants,
10227
10245
  mode: opts.mode,
10228
- headless: opts.headless ?? true,
10246
+ headless,
10229
10247
  registry: opts.registry
10230
10248
  });
10231
10249
  const manifest = opts.registry?.get(opts.runner)?.manifest;
10232
- const requiresTty = manifest?.runner.requiresTty === true && this.hasScriptCmd();
10233
- const modeStr = opts.mode === "plan" ? "plan" : "build";
10234
- console.error(`[headless] Starting ${opts.runner} [${modeStr}] (${opts.modelId || "default"}) for task ${opts.taskId.slice(0, 8)}${requiresTty ? " (PTY)" : ""}`);
10250
+ const pty = (manifest?.runner.requiresTty === true || !headless) && this.hasScriptCmd();
10235
10251
  const resolvedPath = await this.resolvePath();
10236
- const { command, args } = requiresTty ? wrapWithPty(invocation.command, invocation.args) : { command: invocation.command, args: invocation.args };
10237
- session.start(
10238
- await planDirectLaunch(command, args, this.launchDeps),
10239
- opts.cwd,
10252
+ const { command, args } = pty ? wrapWithPty(invocation.command, invocation.args) : { command: invocation.command, args: invocation.args };
10253
+ return {
10254
+ launch: await planDirectLaunch(command, args, this.launchDeps),
10240
10255
  resolvedPath,
10241
- invocation.env
10242
- );
10256
+ env: invocation.env,
10257
+ pty
10258
+ };
10259
+ }
10260
+ async spawn(opts) {
10261
+ const id = `ordewell-${opts.taskId.slice(0, 8)}`;
10262
+ const session = this.createSession(id, opts.taskId);
10263
+ const prepared = await this.prepareLaunch(opts);
10264
+ const modeStr = opts.mode === "plan" ? "plan" : "build";
10265
+ console.error(`[headless] Starting ${opts.runner} [${modeStr}] (${opts.modelId || "default"}) for task ${opts.taskId.slice(0, 8)}${prepared.pty ? " (PTY)" : ""}`);
10266
+ session.start(prepared.launch, opts.cwd, prepared.resolvedPath, prepared.env);
10243
10267
  this.registerSession(id, session);
10244
10268
  return session;
10245
10269
  }
@@ -11207,6 +11231,14 @@ var SettingsService = class {
11207
11231
  }
11208
11232
  this.persist();
11209
11233
  }
11234
+ getEnabledRunners() {
11235
+ return this.getAll().enabledRunners;
11236
+ }
11237
+ setEnabledRunners(ids) {
11238
+ this.getAll();
11239
+ this.cache.enabledRunners = [...ids];
11240
+ this.persist();
11241
+ }
11210
11242
  load() {
11211
11243
  try {
11212
11244
  if (fs8.existsSync(this.filePath)) {
@@ -11224,6 +11256,9 @@ var SettingsService = class {
11224
11256
  if (raw.modelAllowlist !== void 0) {
11225
11257
  settings.modelAllowlist = raw.modelAllowlist;
11226
11258
  }
11259
+ if (Array.isArray(raw.enabledRunners)) {
11260
+ settings.enabledRunners = raw.enabledRunners.map(String);
11261
+ }
11227
11262
  return settings;
11228
11263
  }
11229
11264
  } catch {
@@ -11266,6 +11301,7 @@ export {
11266
11301
  GREP_DEFAULT_HEAD_LIMIT,
11267
11302
  GeminiService,
11268
11303
  HeadlessRunner,
11304
+ HeadlessSession,
11269
11305
  JSON_REPAIR_INSTRUCTION,
11270
11306
  LineBuffer,
11271
11307
  ModelCatalog,
@@ -11301,6 +11337,7 @@ export {
11301
11337
  addTaskToPlan,
11302
11338
  applyHeadLimit,
11303
11339
  applyTaskOps,
11340
+ augmentPromptWithPriorOutputs,
11304
11341
  augmentedPath,
11305
11342
  buildConversationSystemPrompt,
11306
11343
  buildFallbackGrepArgs,
@@ -11333,7 +11370,9 @@ export {
11333
11370
  clearResearchShellCache,
11334
11371
  clearState,
11335
11372
  coerceAssignments,
11373
+ collectDirectDependencyOutputs,
11336
11374
  collectProviderCredentials,
11375
+ composeAugmentedPrompt,
11337
11376
  configuredProviders,
11338
11377
  createAiService,
11339
11378
  createEmptyPlan,
@@ -11400,6 +11439,8 @@ export {
11400
11439
  reEmitTaskOpsPrompt,
11401
11440
  referencePattern,
11402
11441
  removeTaskFromPlan,
11442
+ renderPlanMap,
11443
+ renderPriorOutputs,
11403
11444
  renumberTasks,
11404
11445
  repairLoop,
11405
11446
  researchShellWarning,
@@ -11429,6 +11470,7 @@ export {
11429
11470
  stripModelNoise,
11430
11471
  stripModelPrefix,
11431
11472
  stripTrailingCommas,
11473
+ summarizeOutput,
11432
11474
  summarizeToolCall,
11433
11475
  taskOpsRejectedPrompt,
11434
11476
  textHasTaskOps,