sproutkit-code 0.18.0 → 0.19.0

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/index.js +61 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -93841,7 +93841,7 @@ var require_auto_mode = __commonJS({
93841
93841
  exports2.startAutoJob = startAutoJob2;
93842
93842
  exports2.pauseAutoJob = pauseAutoJob;
93843
93843
  exports2.resumeAutoJob = resumeAutoJob;
93844
- exports2.cancelAutoJob = cancelAutoJob;
93844
+ exports2.cancelAutoJob = cancelAutoJob2;
93845
93845
  exports2.getAutoJobStatus = getAutoJobStatus;
93846
93846
  var db_1 = require_db();
93847
93847
  var builder_1 = require_builder();
@@ -94045,7 +94045,7 @@ var require_auto_mode = __commonJS({
94045
94045
  activeJob.resume();
94046
94046
  return activeJob.snapshot();
94047
94047
  }
94048
- function cancelAutoJob() {
94048
+ function cancelAutoJob2() {
94049
94049
  if (!activeJob)
94050
94050
  return null;
94051
94051
  activeJob.cancel();
@@ -94597,7 +94597,7 @@ var require_package2 = __commonJS({
94597
94597
  "package.json"(exports2, module2) {
94598
94598
  module2.exports = {
94599
94599
  name: "sproutkit-code",
94600
- version: "0.18.0",
94600
+ version: "0.19.0",
94601
94601
  description: "Sproutkit in your terminal \u2014 find leads, build sites, run outreach, all via chat.",
94602
94602
  bin: {
94603
94603
  sproutkit: "./dist/index.js"
@@ -94652,6 +94652,7 @@ var getDb = db.getDb;
94652
94652
  var chatWithTools = chat.chatWithTools;
94653
94653
  var runTool = chatTools.runTool;
94654
94654
  var startAutoJob = autoMode.startAutoJob;
94655
+ var cancelAutoJob = autoMode.cancelAutoJob;
94655
94656
  var provisionCmsForLead = cms.provisionCmsForLead;
94656
94657
  var generatePreset = bookingPreset.generatePreset;
94657
94658
  var deployBookingOnly = builder.deployBookingOnly;
@@ -94814,6 +94815,40 @@ function closeTty() {
94814
94815
  rl?.close();
94815
94816
  rl = null;
94816
94817
  }
94818
+ function onStopRequested(onStop) {
94819
+ let stopped = false;
94820
+ const stdin = process.stdin;
94821
+ const wasRaw = !!stdin.isTTY && stdin.isRaw;
94822
+ const handler = (buf) => {
94823
+ const s = buf.toString();
94824
+ if (s === "q" || s === "Q" || s === "\x1B" || s === "") {
94825
+ if (!stopped) {
94826
+ stopped = true;
94827
+ onStop?.();
94828
+ }
94829
+ }
94830
+ };
94831
+ if (stdin.isTTY) {
94832
+ try {
94833
+ stdin.setRawMode(true);
94834
+ stdin.resume();
94835
+ stdin.on("data", handler);
94836
+ } catch {
94837
+ }
94838
+ }
94839
+ return {
94840
+ stopped: () => stopped,
94841
+ release: () => {
94842
+ if (!stdin.isTTY) return;
94843
+ try {
94844
+ stdin.removeListener("data", handler);
94845
+ stdin.setRawMode(wasRaw);
94846
+ stdin.pause();
94847
+ } catch {
94848
+ }
94849
+ }
94850
+ };
94851
+ }
94817
94852
  function say(msg = "") {
94818
94853
  process.stdout.write(msg + "\n");
94819
94854
  }
@@ -95843,7 +95878,12 @@ async function cmdPipeline(argv) {
95843
95878
  `Pipeline for ${targets.length} client${targets.length === 1 ? "" : "s"} (${concurrency} at a time)`,
95844
95879
  targets.map((t) => rowFor(t, "queued"))
95845
95880
  );
95881
+ say(c.dim(" Press q to stop after the current clients finish."));
95846
95882
  }
95883
+ const stop = json ? null : onStopRequested(() => {
95884
+ say(c.amber("\n Stopping \u2014 finishing current clients, not starting new ones\u2026"));
95885
+ });
95886
+ let cancelled = 0;
95847
95887
  const results = [];
95848
95888
  const queue = [...targets];
95849
95889
  async function runOne(t) {
@@ -95880,12 +95920,20 @@ async function cmdPipeline(argv) {
95880
95920
  }
95881
95921
  const workers = Array.from({ length: Math.min(concurrency, queue.length) }, async () => {
95882
95922
  for (; ; ) {
95923
+ if (stop?.stopped()) {
95924
+ for (const t of queue.splice(0)) {
95925
+ board?.update(rowFor(t, "skipped", "stopped"));
95926
+ cancelled++;
95927
+ }
95928
+ return;
95929
+ }
95883
95930
  const next = queue.shift();
95884
95931
  if (!next) return;
95885
95932
  await runOne(next);
95886
95933
  }
95887
95934
  });
95888
95935
  await Promise.all(workers);
95936
+ stop?.release();
95889
95937
  board?.stop();
95890
95938
  autoSync();
95891
95939
  const ok = results.filter((r) => r.ok).length;
@@ -95897,7 +95945,7 @@ async function cmdPipeline(argv) {
95897
95945
  }
95898
95946
  say();
95899
95947
  say(
95900
- c.green(` Pipeline done \u2014 ${ok} client${ok === 1 ? "" : "s"} built + outreach prepared`) + (failed ? c.red(`, ${failed} failed`) : "") + c.dim(` (concurrency ${concurrency}).`)
95948
+ c.green(` Pipeline ${cancelled ? "stopped" : "done"} \u2014 ${ok} client${ok === 1 ? "" : "s"} built + outreach prepared`) + (failed ? c.red(`, ${failed} failed`) : "") + (cancelled ? c.amber(`, ${cancelled} not started`) : "") + c.dim(` (concurrency ${concurrency}).`)
95901
95949
  );
95902
95950
  say(c.dim(" Open the message links above, or check emailed leads in your Contacted column."));
95903
95951
  say();
@@ -96033,6 +96081,10 @@ async function cmdBuildAll(argv) {
96033
96081
  }
96034
96082
  const concurrency = Math.min(Math.max(Number(flags.concurrency ?? 3), 1), 4);
96035
96083
  const board = json ? null : new StatusBoard();
96084
+ const stop = json ? null : onStopRequested(() => {
96085
+ say(c.amber("\n Stopping \u2014 finishing in-flight builds, not starting new ones\u2026"));
96086
+ cancelAutoJob();
96087
+ });
96036
96088
  const stateToRow = (l) => ({
96037
96089
  key: l.leadId,
96038
96090
  label: `#${l.leadId} ${l.name}`,
@@ -96048,6 +96100,7 @@ async function cmdBuildAll(argv) {
96048
96100
  board.set(snap2.leads.map(stateToRow));
96049
96101
  board.stop();
96050
96102
  }
96103
+ stop?.release();
96051
96104
  if (json) emitJson(snap2);
96052
96105
  else {
96053
96106
  say();
@@ -96068,7 +96121,10 @@ async function cmdBuildAll(argv) {
96068
96121
  placesKey: getSetting("places_key"),
96069
96122
  emit
96070
96123
  });
96071
- if (board) board.start(`Building ${leadIds.length} sites (up to ${concurrency} at once)`, snap.leads.map(stateToRow));
96124
+ if (board) {
96125
+ board.start(`Building ${leadIds.length} sites (up to ${concurrency} at once)`, snap.leads.map(stateToRow));
96126
+ say(c.dim(" Press q to stop after the current builds finish."));
96127
+ }
96072
96128
  });
96073
96129
  }
96074
96130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sproutkit-code",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Sproutkit in your terminal — find leads, build sites, run outreach, all via chat.",
5
5
  "bin": {
6
6
  "sproutkit": "./dist/index.js"