@whittlelabs/sifter 0.43.0 → 0.43.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.
Files changed (3) hide show
  1. package/bin.js +70 -246
  2. package/bin.js.map +4 -4
  3. package/package.json +1 -1
package/bin.js CHANGED
@@ -15171,7 +15171,6 @@ var require_code_index = __commonJS({
15171
15171
  };
15172
15172
  Object.defineProperty(exports2, "__esModule", { value: true });
15173
15173
  exports2.CodeIndex = exports2.PathOutsideRootError = void 0;
15174
- exports2.declarationsInSource = declarationsInSource;
15175
15174
  var node_child_process_1 = require("node:child_process");
15176
15175
  var node_fs_1 = require("node:fs");
15177
15176
  var node_path_1 = __importDefault(require("node:path"));
@@ -15252,18 +15251,6 @@ var require_code_index = __commonJS({
15252
15251
  }
15253
15252
  return cap(found, options.limit ?? 100);
15254
15253
  }
15255
- /**
15256
- * How many files mention the name as a whole word: a cheap read of how
15257
- * common it is, from the text alone, before any file is parsed for it.
15258
- */
15259
- async mentions(name2) {
15260
- return (await this.candidates(name2)).length;
15261
- }
15262
- /** The declarations in a file that overlap any of the given line ranges (1-based, inclusive). */
15263
- async symbolsOverlapping(file, ranges) {
15264
- const symbols = await this.outline(file);
15265
- return symbols.filter((s) => ranges.some(([start2, end]) => s.startLine <= end && s.endLine >= start2));
15266
- }
15267
15254
  // ── Listing and confinement ────────────────────────────────────────────
15268
15255
  async list() {
15269
15256
  const files = [];
@@ -15345,9 +15332,6 @@ var require_code_index = __commonJS({
15345
15332
  }
15346
15333
  };
15347
15334
  exports2.CodeIndex = CodeIndex;
15348
- async function declarationsInSource(file, source, wasmDir) {
15349
- return (await analyze(file, source, (0, runtime_1.resolveWasmDir)(wasmDir)))?.symbols ?? [];
15350
- }
15351
15335
  async function analyze(file, source, wasmDir) {
15352
15336
  const spec = (0, languages_1.languageFor)(file);
15353
15337
  if (!spec)
@@ -15508,14 +15492,11 @@ var require_dist2 = __commonJS({
15508
15492
  "../../packages/code-intel/dist/index.js"(exports2) {
15509
15493
  "use strict";
15510
15494
  Object.defineProperty(exports2, "__esModule", { value: true });
15511
- exports2.wasmFiles = exports2.resolveWasmDir = exports2.languageFor = exports2.LANGUAGES = exports2.PathOutsideRootError = exports2.declarationsInSource = exports2.CodeIndex = void 0;
15495
+ exports2.wasmFiles = exports2.resolveWasmDir = exports2.languageFor = exports2.LANGUAGES = exports2.PathOutsideRootError = exports2.CodeIndex = void 0;
15512
15496
  var code_index_1 = require_code_index();
15513
15497
  Object.defineProperty(exports2, "CodeIndex", { enumerable: true, get: function() {
15514
15498
  return code_index_1.CodeIndex;
15515
15499
  } });
15516
- Object.defineProperty(exports2, "declarationsInSource", { enumerable: true, get: function() {
15517
- return code_index_1.declarationsInSource;
15518
- } });
15519
15500
  Object.defineProperty(exports2, "PathOutsideRootError", { enumerable: true, get: function() {
15520
15501
  return code_index_1.PathOutsideRootError;
15521
15502
  } });
@@ -56719,7 +56700,6 @@ var require_overlay = __commonJS({
56719
56700
  Object.defineProperty(exports2, "__esModule", { value: true });
56720
56701
  exports2.overlayModifier = void 0;
56721
56702
  exports2.applyOverlay = applyOverlay;
56722
- exports2.safeDestination = safeDestination;
56723
56703
  exports2.normalizeOrigin = normalizeOrigin;
56724
56704
  exports2.fetchCapped = fetchCapped;
56725
56705
  var fs_1 = require("fs");
@@ -69094,12 +69074,74 @@ var require_reader = __commonJS({
69094
69074
  }
69095
69075
  });
69096
69076
 
69077
+ // ../../packages/realtime-client/dist/progress.js
69078
+ var require_progress2 = __commonJS({
69079
+ "../../packages/realtime-client/dist/progress.js"(exports2) {
69080
+ "use strict";
69081
+ Object.defineProperty(exports2, "__esModule", { value: true });
69082
+ exports2.followProgress = followProgress;
69083
+ var reader_1 = require_reader();
69084
+ function followProgress(options) {
69085
+ const { open, onFrames, onStatus, ...connect } = options;
69086
+ let frames = [];
69087
+ let lastSeq = null;
69088
+ let jobId = null;
69089
+ const take = (incoming, from) => {
69090
+ const restart = from !== void 0 && jobId !== null && from !== jobId;
69091
+ if (from !== void 0)
69092
+ jobId = from;
69093
+ if (restart) {
69094
+ lastSeq = null;
69095
+ frames = [];
69096
+ }
69097
+ const held = new Set(frames.map((frame) => frame.seq));
69098
+ const added = [];
69099
+ for (const frame of incoming) {
69100
+ if (lastSeq === null || frame.seq > lastSeq)
69101
+ lastSeq = frame.seq;
69102
+ if (held.has(frame.seq))
69103
+ continue;
69104
+ held.add(frame.seq);
69105
+ added.push(frame);
69106
+ }
69107
+ if (added.length === 0 && !restart)
69108
+ return;
69109
+ frames = [...frames, ...added].sort((a, b) => a.seq - b.seq);
69110
+ onFrames(frames);
69111
+ };
69112
+ const connection = (0, reader_1.connectStream)({
69113
+ ...connect,
69114
+ open: (_resume, signal) => open(lastSeq === null ? "" : `?after=${lastSeq}${jobId === null ? "" : `&job=${encodeURIComponent(jobId)}`}`, signal),
69115
+ onMessage: (message) => {
69116
+ let event;
69117
+ try {
69118
+ event = JSON.parse(message.data);
69119
+ } catch {
69120
+ return;
69121
+ }
69122
+ if (event.type === "frames" && event.frames?.length) {
69123
+ take(event.frames, event.jobId);
69124
+ } else if (event.type === "status") {
69125
+ onStatus?.("idle");
69126
+ connection.close();
69127
+ }
69128
+ },
69129
+ onStatus: (status) => {
69130
+ if (status !== "stopped")
69131
+ onStatus?.(status);
69132
+ }
69133
+ });
69134
+ return connection;
69135
+ }
69136
+ }
69137
+ });
69138
+
69097
69139
  // ../../packages/realtime-client/dist/index.js
69098
69140
  var require_dist6 = __commonJS({
69099
69141
  "../../packages/realtime-client/dist/index.js"(exports2) {
69100
69142
  "use strict";
69101
69143
  Object.defineProperty(exports2, "__esModule", { value: true });
69102
- exports2.StreamSilentError = exports2.RESYNC = exports2.readEventStream = exports2.connectStream = void 0;
69144
+ exports2.followProgress = exports2.StreamSilentError = exports2.RESYNC = exports2.readEventStream = exports2.connectStream = void 0;
69103
69145
  var reader_1 = require_reader();
69104
69146
  Object.defineProperty(exports2, "connectStream", { enumerable: true, get: function() {
69105
69147
  return reader_1.connectStream;
@@ -69113,6 +69155,10 @@ var require_dist6 = __commonJS({
69113
69155
  Object.defineProperty(exports2, "StreamSilentError", { enumerable: true, get: function() {
69114
69156
  return reader_1.StreamSilentError;
69115
69157
  } });
69158
+ var progress_1 = require_progress2();
69159
+ Object.defineProperty(exports2, "followProgress", { enumerable: true, get: function() {
69160
+ return progress_1.followProgress;
69161
+ } });
69116
69162
  }
69117
69163
  });
69118
69164
 
@@ -73665,219 +73711,6 @@ var require_git = __commonJS({
73665
73711
  }
73666
73712
  });
73667
73713
 
73668
- // ../../packages/shuttle/dist/workspace/impact.js
73669
- var require_impact = __commonJS({
73670
- "../../packages/shuttle/dist/workspace/impact.js"(exports2) {
73671
- "use strict";
73672
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
73673
- return mod && mod.__esModule ? mod : { "default": mod };
73674
- };
73675
- Object.defineProperty(exports2, "__esModule", { value: true });
73676
- exports2.impactModifier = void 0;
73677
- exports2.applyImpact = applyImpact;
73678
- exports2.buildReport = buildReport;
73679
- var fs_1 = require("fs");
73680
- var path_1 = __importDefault(require("path"));
73681
- var code_intel_1 = require_dist2();
73682
- var overlay_1 = require_overlay();
73683
- var LIMITS = {
73684
- changedSymbols: 30,
73685
- usesShown: 8,
73686
- /** A name more files mention than this is too common for a list of its uses to help. */
73687
- commonInFiles: 80,
73688
- /** The report is read into the agent's context: past this it stops adding sections. */
73689
- reportBytes: 16 * 1024,
73690
- /** Work stops here and the report says it is partial; materialization must not eat the job. */
73691
- budgetMs: 6e4
73692
- };
73693
- var REMOVED_KINDS = /* @__PURE__ */ new Set([
73694
- "function",
73695
- "class",
73696
- "interface",
73697
- "type",
73698
- "enum",
73699
- "module",
73700
- "constant",
73701
- "macro"
73702
- ]);
73703
- exports2.impactModifier = { namespace: "impact", apply: applyImpact };
73704
- async function applyImpact(request, runRoot, _options) {
73705
- const result = { written: 0, writtenPaths: [], skipped: [] };
73706
- const parsed = readImpactRequest(request);
73707
- if ("error" in parsed) {
73708
- result.skipped.push({ path: String(request?.output ?? "?"), reason: parsed.error });
73709
- return result;
73710
- }
73711
- const { output, files } = parsed.request;
73712
- const rootReal = await fs_1.promises.realpath(runRoot);
73713
- const dest = (0, overlay_1.safeDestination)(rootReal, output);
73714
- if (!dest) {
73715
- result.skipped.push({ path: output, reason: "path escapes the workspace root" });
73716
- return result;
73717
- }
73718
- const primary = path_1.default.join(runRoot, "primary");
73719
- if ((await fs_1.promises.readdir(primary).catch(() => [])).length === 0) {
73720
- result.skipped.push({ path: output, reason: "no checkout to read: the primary repository did not materialize" });
73721
- return result;
73722
- }
73723
- try {
73724
- const report = await buildReport(runRoot, files);
73725
- await fs_1.promises.mkdir(path_1.default.dirname(dest), { recursive: true });
73726
- const handle2 = await fs_1.promises.open(dest, fs_1.constants.O_WRONLY | fs_1.constants.O_CREAT | fs_1.constants.O_TRUNC | fs_1.constants.O_NOFOLLOW, 420);
73727
- try {
73728
- await handle2.writeFile(report);
73729
- } finally {
73730
- await handle2.close();
73731
- }
73732
- result.written = 1;
73733
- result.writtenPaths.push(output);
73734
- } catch (err2) {
73735
- result.skipped.push({ path: output, reason: err2 instanceof Error ? err2.message : String(err2) });
73736
- }
73737
- return result;
73738
- }
73739
- function readImpactRequest(request) {
73740
- const r = request;
73741
- if (!r || typeof r.output !== "string" || !Array.isArray(r.files)) {
73742
- return { error: "malformed impact request (want { output, files })" };
73743
- }
73744
- const files = [];
73745
- for (const f of r.files) {
73746
- if (!f || typeof f.path !== "string" || !Array.isArray(f.changed))
73747
- continue;
73748
- files.push({
73749
- path: f.path,
73750
- status: typeof f.status === "string" ? f.status : "modified",
73751
- changed: f.changed.filter((c) => Array.isArray(c) && Number.isInteger(c[0]) && Number.isInteger(c[1])),
73752
- removed: Array.isArray(f.removed) ? f.removed.filter((t) => typeof t === "string") : []
73753
- });
73754
- }
73755
- return { request: { output: r.output, files } };
73756
- }
73757
- async function repositoriesOf(runRoot) {
73758
- const repos = ["primary"];
73759
- const context = await fs_1.promises.readdir(path_1.default.join(runRoot, "context"), { withFileTypes: true }).catch(() => []);
73760
- for (const entry of context)
73761
- if (entry.isDirectory())
73762
- repos.push(`context/${entry.name}`);
73763
- return repos;
73764
- }
73765
- function innermostOnly(symbols) {
73766
- return symbols.filter((s) => !symbols.some((o) => o !== s && o.startLine >= s.startLine && o.endLine <= s.endLine && (o.startLine !== s.startLine || o.endLine !== s.endLine)));
73767
- }
73768
- var useLine = (r) => ` - ${r.file}:${r.line} ${r.enclosing ? `in ${r.enclosing.kind} ${r.enclosing.name}` : "at top level"} | ${r.text}`;
73769
- async function buildReport(runRoot, files) {
73770
- const startedAt = Date.now();
73771
- const overBudget = () => Date.now() - startedAt > LIMITS.budgetMs;
73772
- const index = new code_intel_1.CodeIndex({ root: runRoot, repositories: await repositoriesOf(runRoot) });
73773
- let partial = false;
73774
- const removedSections = [];
73775
- for (const file of files) {
73776
- for (const block of file.removed ?? []) {
73777
- const lines = block.split("\n");
73778
- for (const symbol of await (0, code_intel_1.declarationsInSource)(file.path, block)) {
73779
- if (overBudget()) {
73780
- partial = true;
73781
- break;
73782
- }
73783
- const indented = /^\s/.test(lines[symbol.startLine - 1] ?? "");
73784
- if (indented || !REMOVED_KINDS.has(symbol.kind))
73785
- continue;
73786
- if ((await index.definitions(symbol.name, 1)).total > 0)
73787
- continue;
73788
- if (await index.mentions(symbol.name) > LIMITS.commonInFiles)
73789
- continue;
73790
- const uses = await index.references(symbol.name, { limit: LIMITS.usesShown, access: "bare" });
73791
- if (uses.total === 0)
73792
- continue;
73793
- removedSections.push([
73794
- `- ${symbol.kind} \`${symbol.name}\`, removed from primary/${file.path}, is still used ${times(uses.total)}:`,
73795
- ...uses.items.map(useLine),
73796
- ...uses.truncated ? [` - and ${uses.total - uses.items.length} more`] : []
73797
- ].join("\n"));
73798
- }
73799
- }
73800
- }
73801
- const changed = [];
73802
- const seen = /* @__PURE__ */ new Set();
73803
- for (const file of files) {
73804
- if (file.status === "removed" || file.changed.length === 0)
73805
- continue;
73806
- const touched = innermostOnly(await index.symbolsOverlapping(`primary/${file.path}`, file.changed).catch(() => []));
73807
- for (const s of touched) {
73808
- const key = `${s.file}:${s.startLine}:${s.name}`;
73809
- if (!seen.has(key)) {
73810
- seen.add(key);
73811
- changed.push(s);
73812
- }
73813
- }
73814
- }
73815
- if (changed.length > LIMITS.changedSymbols)
73816
- partial = true;
73817
- const changedSections = [];
73818
- const unused = [];
73819
- const common = [];
73820
- for (const symbol of changed.slice(0, LIMITS.changedSymbols)) {
73821
- if (overBudget()) {
73822
- partial = true;
73823
- break;
73824
- }
73825
- const label = `${symbol.kind} \`${symbol.container ? `${symbol.container}.` : ""}${symbol.name}\``;
73826
- if (await index.mentions(symbol.name) > LIMITS.commonInFiles) {
73827
- common.push(label);
73828
- continue;
73829
- }
73830
- const access = symbol.kind === "method" || symbol.kind === "field" ? "member" : "bare";
73831
- const uses = (await index.references(symbol.name, { limit: 500, access })).items.filter((r) => !(r.file === symbol.file && r.line >= symbol.startLine && r.line <= symbol.endLine));
73832
- if (uses.length === 0) {
73833
- unused.push(label);
73834
- continue;
73835
- }
73836
- const shown = uses.slice(0, LIMITS.usesShown);
73837
- changedSections.push([
73838
- `### ${label} (${symbol.file}:${symbol.startLine}-${symbol.endLine})`,
73839
- `Used ${times(uses.length)} outside its own body:`,
73840
- ...shown.map(useLine),
73841
- ...uses.length > shown.length ? [` - and ${uses.length - shown.length} more`] : []
73842
- ].join("\n"));
73843
- }
73844
- const head = [
73845
- "# Change impact",
73846
- "",
73847
- "Computed from the syntax tree of the checkout at the head of this change, before the review began.",
73848
- "A use is an identifier with the same name: two declarations that share a name are not told apart, so read a use before relying on it."
73849
- ];
73850
- const body2 = [
73851
- "## Removed, but still used",
73852
- "",
73853
- removedSections.length ? removedSections.join("\n") : "Nothing the change removed is still used.",
73854
- "",
73855
- "## Changed declarations and where they are used",
73856
- "",
73857
- ...changedSections.length ? [changedSections.join("\n\n"), ""] : [],
73858
- ...unused.length ? [`Changed, with no uses elsewhere: ${unused.join(", ")}.`, ""] : [],
73859
- ...common.length ? [`Changed, with names too common to list uses for (read their callers directly): ${common.join(", ")}.`, ""] : [],
73860
- ...changedSections.length + unused.length + common.length === 0 ? ["The change touches no declaration this could read.", ""] : []
73861
- ].join("\n");
73862
- let text = body2;
73863
- if (Buffer.byteLength(text) > LIMITS.reportBytes) {
73864
- text = `${Buffer.from(text).subarray(0, LIMITS.reportBytes).toString("utf-8").replace(/\n[^\n]*$/, "")}
73865
- `;
73866
- partial = true;
73867
- }
73868
- return [
73869
- ...head,
73870
- ...partial ? ["", "This report is partial: the change touches more than it could cover."] : [],
73871
- "",
73872
- text
73873
- ].join("\n");
73874
- }
73875
- function times(n) {
73876
- return `${n} time${n === 1 ? "" : "s"}`;
73877
- }
73878
- }
73879
- });
73880
-
73881
73714
  // ../../packages/shuttle/dist/workspace/materialize.js
73882
73715
  var require_materialize = __commonJS({
73883
73716
  "../../packages/shuttle/dist/workspace/materialize.js"(exports2) {
@@ -73893,7 +73726,6 @@ var require_materialize = __commonJS({
73893
73726
  var os_1 = __importDefault(require("os"));
73894
73727
  var path_1 = __importDefault(require("path"));
73895
73728
  var git_1 = require_git();
73896
- var impact_1 = require_impact();
73897
73729
  var overlay_1 = require_overlay();
73898
73730
  var materializers = /* @__PURE__ */ new Map();
73899
73731
  var modifiers = /* @__PURE__ */ new Map();
@@ -73905,7 +73737,6 @@ var require_materialize = __commonJS({
73905
73737
  }
73906
73738
  registerMaterializer(git_1.gitMaterializer);
73907
73739
  registerModifier(overlay_1.overlayModifier);
73908
- registerModifier(impact_1.impactModifier);
73909
73740
  async function materializeWorkspace(bag, options = {}) {
73910
73741
  const tmpBase = options.tmpDir ?? os_1.default.tmpdir();
73911
73742
  const runRoot = await fs_1.promises.mkdtemp(path_1.default.join(tmpBase, "shuttle-ws-"));
@@ -73958,7 +73789,7 @@ var require_workspace = __commonJS({
73958
73789
  "../../packages/shuttle/dist/workspace/index.js"(exports2) {
73959
73790
  "use strict";
73960
73791
  Object.defineProperty(exports2, "__esModule", { value: true });
73961
- exports2.applyImpact = exports2.impactModifier = exports2.applyOverlay = exports2.overlayModifier = exports2.buildGitAuthEnv = exports2.gitMaterializer = exports2.registerModifier = exports2.registerMaterializer = exports2.materializeWorkspace = void 0;
73792
+ exports2.applyOverlay = exports2.overlayModifier = exports2.buildGitAuthEnv = exports2.gitMaterializer = exports2.registerModifier = exports2.registerMaterializer = exports2.materializeWorkspace = void 0;
73962
73793
  var materialize_1 = require_materialize();
73963
73794
  Object.defineProperty(exports2, "materializeWorkspace", { enumerable: true, get: function() {
73964
73795
  return materialize_1.materializeWorkspace;
@@ -73983,13 +73814,6 @@ var require_workspace = __commonJS({
73983
73814
  Object.defineProperty(exports2, "applyOverlay", { enumerable: true, get: function() {
73984
73815
  return overlay_1.applyOverlay;
73985
73816
  } });
73986
- var impact_1 = require_impact();
73987
- Object.defineProperty(exports2, "impactModifier", { enumerable: true, get: function() {
73988
- return impact_1.impactModifier;
73989
- } });
73990
- Object.defineProperty(exports2, "applyImpact", { enumerable: true, get: function() {
73991
- return impact_1.applyImpact;
73992
- } });
73993
73817
  }
73994
73818
  });
73995
73819
 
@@ -76421,7 +76245,7 @@ var import_shuttle2 = __toESM(require_dist8());
76421
76245
 
76422
76246
  // src/brand.ts
76423
76247
  var import_shuttle = __toESM(require_dist8());
76424
- var buildVersion = true ? "0.43.0" : pkg.version;
76248
+ var buildVersion = true ? "0.43.2" : pkg.version;
76425
76249
  var AGENT_EXECUTORS = ["claude-code", "codex", "copilot"];
76426
76250
  var sifterBrand = {
76427
76251
  product: {