stop-wasting-tokens 2.1.0 → 2.2.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.
package/dist/cli.mjs CHANGED
@@ -35873,7 +35873,7 @@ async function pickPort(opts) {
35873
35873
 
35874
35874
  // packages/cli/src/commands/version.ts
35875
35875
  init_esm_shims();
35876
- var CURRENT_VERSION = "2.1.0" ;
35876
+ var CURRENT_VERSION = "2.2.0" ;
35877
35877
  function versionHandler(version = CURRENT_VERSION) {
35878
35878
  return (_parsed, io) => {
35879
35879
  io.stdout.write(`swt ${version}
@@ -40551,7 +40551,16 @@ var SnapshotSchema = external_exports.object({
40551
40551
  * The .default(true) shim was a v1.6.6 protective measure that's no
40552
40552
  * longer load-bearing.
40553
40553
  */
40554
- is_initialized: external_exports.boolean()
40554
+ is_initialized: external_exports.boolean(),
40555
+ /**
40556
+ * True when the daemon's cwd has source files / a project structure but
40557
+ * no `.swt-planning/` yet (e.g., user ran `swt` inside an existing repo
40558
+ * that's never been touched by SWT). Lets the SPA show a brownfield-
40559
+ * aware InitScreen instead of the pure-greenfield "name a fresh project"
40560
+ * variant. Optional for back-compat with v2.1.x daemons that don't emit
40561
+ * it; clients should default to false.
40562
+ */
40563
+ brownfield_detected: external_exports.boolean().optional()
40555
40564
  });
40556
40565
 
40557
40566
  // packages/dashboard-core/src/schemas/events.ts
@@ -41566,9 +41575,40 @@ function registerInitRoute(app, cwd, onInitialized, getSnapshot = () => null) {
41566
41575
  // packages/dashboard/src/server/routes/snapshot.ts
41567
41576
  init_esm_shims();
41568
41577
 
41578
+ // packages/dashboard/src/server/lib/detect-brownfield.ts
41579
+ init_esm_shims();
41580
+ var IGNORED_NAMES = /* @__PURE__ */ new Set([
41581
+ "node_modules",
41582
+ "dist",
41583
+ "build",
41584
+ "coverage",
41585
+ "__pycache__",
41586
+ ".next",
41587
+ ".venv",
41588
+ "target",
41589
+ // Rust
41590
+ "vendor",
41591
+ // Go / PHP
41592
+ "Thumbs.db"
41593
+ ]);
41594
+ function detectBrownfield(cwd) {
41595
+ let entries;
41596
+ try {
41597
+ entries = readdirSync(cwd);
41598
+ } catch {
41599
+ return false;
41600
+ }
41601
+ for (const name of entries) {
41602
+ if (name.startsWith(".")) continue;
41603
+ if (IGNORED_NAMES.has(name)) continue;
41604
+ return true;
41605
+ }
41606
+ return false;
41607
+ }
41608
+
41569
41609
  // packages/dashboard/src/server/snapshot/empty.ts
41570
41610
  init_esm_shims();
41571
- function emptySnapshot() {
41611
+ function emptySnapshot(brownfield = false) {
41572
41612
  return {
41573
41613
  schema_version: "1",
41574
41614
  generated_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -41578,15 +41618,17 @@ function emptySnapshot() {
41578
41618
  active_agent: null,
41579
41619
  recent_events: [],
41580
41620
  cost_summary: null,
41581
- is_initialized: false
41621
+ is_initialized: false,
41622
+ brownfield_detected: brownfield
41582
41623
  };
41583
41624
  }
41584
41625
 
41585
41626
  // packages/dashboard/src/server/routes/snapshot.ts
41586
- function registerSnapshotRoute(app, getSnapshotter) {
41627
+ function registerSnapshotRoute(app, getSnapshotter, cwd) {
41628
+ const brownfield = detectBrownfield(cwd);
41587
41629
  app.get("/api/snapshot", (c) => {
41588
41630
  const snapshotter = getSnapshotter();
41589
- const snapshot = snapshotter ? snapshotter.current() : emptySnapshot();
41631
+ const snapshot = snapshotter ? snapshotter.current() : emptySnapshot(brownfield);
41590
41632
  return c.json(snapshot);
41591
41633
  });
41592
41634
  }
@@ -42774,12 +42816,12 @@ function createApp(opts = {}) {
42774
42816
  void greenfieldWatcher.close();
42775
42817
  });
42776
42818
  }
42777
- registerSnapshotRoute(app, () => snapshotter);
42819
+ const cwd = projectRoot ?? process.cwd();
42820
+ registerSnapshotRoute(app, () => snapshotter, cwd);
42778
42821
  if (projectRoot) {
42779
42822
  registerArtifactRoute(app, projectRoot);
42780
42823
  registerUatCheckpointRoute(app, projectRoot);
42781
42824
  }
42782
- const cwd = projectRoot ?? process.cwd();
42783
42825
  registerInitRoute(
42784
42826
  app,
42785
42827
  cwd,