@whittlelabs/sifter 0.43.1 → 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 +3 -245
  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");
@@ -73731,219 +73711,6 @@ var require_git = __commonJS({
73731
73711
  }
73732
73712
  });
73733
73713
 
73734
- // ../../packages/shuttle/dist/workspace/impact.js
73735
- var require_impact = __commonJS({
73736
- "../../packages/shuttle/dist/workspace/impact.js"(exports2) {
73737
- "use strict";
73738
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
73739
- return mod && mod.__esModule ? mod : { "default": mod };
73740
- };
73741
- Object.defineProperty(exports2, "__esModule", { value: true });
73742
- exports2.impactModifier = void 0;
73743
- exports2.applyImpact = applyImpact;
73744
- exports2.buildReport = buildReport;
73745
- var fs_1 = require("fs");
73746
- var path_1 = __importDefault(require("path"));
73747
- var code_intel_1 = require_dist2();
73748
- var overlay_1 = require_overlay();
73749
- var LIMITS = {
73750
- changedSymbols: 30,
73751
- usesShown: 8,
73752
- /** A name more files mention than this is too common for a list of its uses to help. */
73753
- commonInFiles: 80,
73754
- /** The report is read into the agent's context: past this it stops adding sections. */
73755
- reportBytes: 16 * 1024,
73756
- /** Work stops here and the report says it is partial; materialization must not eat the job. */
73757
- budgetMs: 6e4
73758
- };
73759
- var REMOVED_KINDS = /* @__PURE__ */ new Set([
73760
- "function",
73761
- "class",
73762
- "interface",
73763
- "type",
73764
- "enum",
73765
- "module",
73766
- "constant",
73767
- "macro"
73768
- ]);
73769
- exports2.impactModifier = { namespace: "impact", apply: applyImpact };
73770
- async function applyImpact(request, runRoot, _options) {
73771
- const result = { written: 0, writtenPaths: [], skipped: [] };
73772
- const parsed = readImpactRequest(request);
73773
- if ("error" in parsed) {
73774
- result.skipped.push({ path: String(request?.output ?? "?"), reason: parsed.error });
73775
- return result;
73776
- }
73777
- const { output, files } = parsed.request;
73778
- const rootReal = await fs_1.promises.realpath(runRoot);
73779
- const dest = (0, overlay_1.safeDestination)(rootReal, output);
73780
- if (!dest) {
73781
- result.skipped.push({ path: output, reason: "path escapes the workspace root" });
73782
- return result;
73783
- }
73784
- const primary = path_1.default.join(runRoot, "primary");
73785
- if ((await fs_1.promises.readdir(primary).catch(() => [])).length === 0) {
73786
- result.skipped.push({ path: output, reason: "no checkout to read: the primary repository did not materialize" });
73787
- return result;
73788
- }
73789
- try {
73790
- const report = await buildReport(runRoot, files);
73791
- await fs_1.promises.mkdir(path_1.default.dirname(dest), { recursive: true });
73792
- 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);
73793
- try {
73794
- await handle2.writeFile(report);
73795
- } finally {
73796
- await handle2.close();
73797
- }
73798
- result.written = 1;
73799
- result.writtenPaths.push(output);
73800
- } catch (err2) {
73801
- result.skipped.push({ path: output, reason: err2 instanceof Error ? err2.message : String(err2) });
73802
- }
73803
- return result;
73804
- }
73805
- function readImpactRequest(request) {
73806
- const r = request;
73807
- if (!r || typeof r.output !== "string" || !Array.isArray(r.files)) {
73808
- return { error: "malformed impact request (want { output, files })" };
73809
- }
73810
- const files = [];
73811
- for (const f of r.files) {
73812
- if (!f || typeof f.path !== "string" || !Array.isArray(f.changed))
73813
- continue;
73814
- files.push({
73815
- path: f.path,
73816
- status: typeof f.status === "string" ? f.status : "modified",
73817
- changed: f.changed.filter((c) => Array.isArray(c) && Number.isInteger(c[0]) && Number.isInteger(c[1])),
73818
- removed: Array.isArray(f.removed) ? f.removed.filter((t) => typeof t === "string") : []
73819
- });
73820
- }
73821
- return { request: { output: r.output, files } };
73822
- }
73823
- async function repositoriesOf(runRoot) {
73824
- const repos = ["primary"];
73825
- const context = await fs_1.promises.readdir(path_1.default.join(runRoot, "context"), { withFileTypes: true }).catch(() => []);
73826
- for (const entry of context)
73827
- if (entry.isDirectory())
73828
- repos.push(`context/${entry.name}`);
73829
- return repos;
73830
- }
73831
- function innermostOnly(symbols) {
73832
- 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)));
73833
- }
73834
- var useLine = (r) => ` - ${r.file}:${r.line} ${r.enclosing ? `in ${r.enclosing.kind} ${r.enclosing.name}` : "at top level"} | ${r.text}`;
73835
- async function buildReport(runRoot, files) {
73836
- const startedAt = Date.now();
73837
- const overBudget = () => Date.now() - startedAt > LIMITS.budgetMs;
73838
- const index = new code_intel_1.CodeIndex({ root: runRoot, repositories: await repositoriesOf(runRoot) });
73839
- let partial = false;
73840
- const removedSections = [];
73841
- for (const file of files) {
73842
- for (const block of file.removed ?? []) {
73843
- const lines = block.split("\n");
73844
- for (const symbol of await (0, code_intel_1.declarationsInSource)(file.path, block)) {
73845
- if (overBudget()) {
73846
- partial = true;
73847
- break;
73848
- }
73849
- const indented = /^\s/.test(lines[symbol.startLine - 1] ?? "");
73850
- if (indented || !REMOVED_KINDS.has(symbol.kind))
73851
- continue;
73852
- if ((await index.definitions(symbol.name, 1)).total > 0)
73853
- continue;
73854
- if (await index.mentions(symbol.name) > LIMITS.commonInFiles)
73855
- continue;
73856
- const uses = await index.references(symbol.name, { limit: LIMITS.usesShown, access: "bare" });
73857
- if (uses.total === 0)
73858
- continue;
73859
- removedSections.push([
73860
- `- ${symbol.kind} \`${symbol.name}\`, removed from primary/${file.path}, is still used ${times(uses.total)}:`,
73861
- ...uses.items.map(useLine),
73862
- ...uses.truncated ? [` - and ${uses.total - uses.items.length} more`] : []
73863
- ].join("\n"));
73864
- }
73865
- }
73866
- }
73867
- const changed = [];
73868
- const seen = /* @__PURE__ */ new Set();
73869
- for (const file of files) {
73870
- if (file.status === "removed" || file.changed.length === 0)
73871
- continue;
73872
- const touched = innermostOnly(await index.symbolsOverlapping(`primary/${file.path}`, file.changed).catch(() => []));
73873
- for (const s of touched) {
73874
- const key = `${s.file}:${s.startLine}:${s.name}`;
73875
- if (!seen.has(key)) {
73876
- seen.add(key);
73877
- changed.push(s);
73878
- }
73879
- }
73880
- }
73881
- if (changed.length > LIMITS.changedSymbols)
73882
- partial = true;
73883
- const changedSections = [];
73884
- const unused = [];
73885
- const common = [];
73886
- for (const symbol of changed.slice(0, LIMITS.changedSymbols)) {
73887
- if (overBudget()) {
73888
- partial = true;
73889
- break;
73890
- }
73891
- const label = `${symbol.kind} \`${symbol.container ? `${symbol.container}.` : ""}${symbol.name}\``;
73892
- if (await index.mentions(symbol.name) > LIMITS.commonInFiles) {
73893
- common.push(label);
73894
- continue;
73895
- }
73896
- const access = symbol.kind === "method" || symbol.kind === "field" ? "member" : "bare";
73897
- 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));
73898
- if (uses.length === 0) {
73899
- unused.push(label);
73900
- continue;
73901
- }
73902
- const shown = uses.slice(0, LIMITS.usesShown);
73903
- changedSections.push([
73904
- `### ${label} (${symbol.file}:${symbol.startLine}-${symbol.endLine})`,
73905
- `Used ${times(uses.length)} outside its own body:`,
73906
- ...shown.map(useLine),
73907
- ...uses.length > shown.length ? [` - and ${uses.length - shown.length} more`] : []
73908
- ].join("\n"));
73909
- }
73910
- const head = [
73911
- "# Change impact",
73912
- "",
73913
- "Computed from the syntax tree of the checkout at the head of this change, before the review began.",
73914
- "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."
73915
- ];
73916
- const body2 = [
73917
- "## Removed, but still used",
73918
- "",
73919
- removedSections.length ? removedSections.join("\n") : "Nothing the change removed is still used.",
73920
- "",
73921
- "## Changed declarations and where they are used",
73922
- "",
73923
- ...changedSections.length ? [changedSections.join("\n\n"), ""] : [],
73924
- ...unused.length ? [`Changed, with no uses elsewhere: ${unused.join(", ")}.`, ""] : [],
73925
- ...common.length ? [`Changed, with names too common to list uses for (read their callers directly): ${common.join(", ")}.`, ""] : [],
73926
- ...changedSections.length + unused.length + common.length === 0 ? ["The change touches no declaration this could read.", ""] : []
73927
- ].join("\n");
73928
- let text = body2;
73929
- if (Buffer.byteLength(text) > LIMITS.reportBytes) {
73930
- text = `${Buffer.from(text).subarray(0, LIMITS.reportBytes).toString("utf-8").replace(/\n[^\n]*$/, "")}
73931
- `;
73932
- partial = true;
73933
- }
73934
- return [
73935
- ...head,
73936
- ...partial ? ["", "This report is partial: the change touches more than it could cover."] : [],
73937
- "",
73938
- text
73939
- ].join("\n");
73940
- }
73941
- function times(n) {
73942
- return `${n} time${n === 1 ? "" : "s"}`;
73943
- }
73944
- }
73945
- });
73946
-
73947
73714
  // ../../packages/shuttle/dist/workspace/materialize.js
73948
73715
  var require_materialize = __commonJS({
73949
73716
  "../../packages/shuttle/dist/workspace/materialize.js"(exports2) {
@@ -73959,7 +73726,6 @@ var require_materialize = __commonJS({
73959
73726
  var os_1 = __importDefault(require("os"));
73960
73727
  var path_1 = __importDefault(require("path"));
73961
73728
  var git_1 = require_git();
73962
- var impact_1 = require_impact();
73963
73729
  var overlay_1 = require_overlay();
73964
73730
  var materializers = /* @__PURE__ */ new Map();
73965
73731
  var modifiers = /* @__PURE__ */ new Map();
@@ -73971,7 +73737,6 @@ var require_materialize = __commonJS({
73971
73737
  }
73972
73738
  registerMaterializer(git_1.gitMaterializer);
73973
73739
  registerModifier(overlay_1.overlayModifier);
73974
- registerModifier(impact_1.impactModifier);
73975
73740
  async function materializeWorkspace(bag, options = {}) {
73976
73741
  const tmpBase = options.tmpDir ?? os_1.default.tmpdir();
73977
73742
  const runRoot = await fs_1.promises.mkdtemp(path_1.default.join(tmpBase, "shuttle-ws-"));
@@ -74024,7 +73789,7 @@ var require_workspace = __commonJS({
74024
73789
  "../../packages/shuttle/dist/workspace/index.js"(exports2) {
74025
73790
  "use strict";
74026
73791
  Object.defineProperty(exports2, "__esModule", { value: true });
74027
- 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;
74028
73793
  var materialize_1 = require_materialize();
74029
73794
  Object.defineProperty(exports2, "materializeWorkspace", { enumerable: true, get: function() {
74030
73795
  return materialize_1.materializeWorkspace;
@@ -74049,13 +73814,6 @@ var require_workspace = __commonJS({
74049
73814
  Object.defineProperty(exports2, "applyOverlay", { enumerable: true, get: function() {
74050
73815
  return overlay_1.applyOverlay;
74051
73816
  } });
74052
- var impact_1 = require_impact();
74053
- Object.defineProperty(exports2, "impactModifier", { enumerable: true, get: function() {
74054
- return impact_1.impactModifier;
74055
- } });
74056
- Object.defineProperty(exports2, "applyImpact", { enumerable: true, get: function() {
74057
- return impact_1.applyImpact;
74058
- } });
74059
73817
  }
74060
73818
  });
74061
73819
 
@@ -76487,7 +76245,7 @@ var import_shuttle2 = __toESM(require_dist8());
76487
76245
 
76488
76246
  // src/brand.ts
76489
76247
  var import_shuttle = __toESM(require_dist8());
76490
- var buildVersion = true ? "0.43.1" : pkg.version;
76248
+ var buildVersion = true ? "0.43.2" : pkg.version;
76491
76249
  var AGENT_EXECUTORS = ["claude-code", "codex", "copilot"];
76492
76250
  var sifterBrand = {
76493
76251
  product: {