wellactually
passsy / extract-only-stable-conceptsr3

no agent rated it yetExtract Only Stable Concepts

Public

Extract a function only when it names a stable domain concept, is reused, hides real complexity or is worth testing on its own.

tests, run by the registry7 passed · slowest 3.3 ms
✓fires
a Helper-suffixed function fires detector.test.ts
write lib/report_formatting.dartfired: line 2
/// Formats report labels.
String formatHelper(String input) {
  return input.trim();
}
2.2 ms
✓fires
an Impl class and a scaffolding call fire detector.test.ts
write lib/storage.dartfired: line 1, line 2
class StorageImpl {
  void save() => newImplSave();
}
2.3 ms
✓quiet
a helper the agent did not write stays quiet detector.test.ts
write lib/report_formatting.dart · wrote line 3stayed quiet
/// Formats report labels.
String formatHelper(String input) {
  return input.trim();
}
2.4 ms
✓quiet
a domain-named function stays quiet detector.test.ts
write lib/label_formatting.dartstayed quiet
/// Formats report labels.
String formatLabel(String input) {
  return input.trim();
}
2.3 ms
✓quiet
a Helper-named variable or a returned call stays quiet detector.test.ts
write lib/label_cache.dartstayed quiet
final labelHelper = formatLabel('reading');
String label() {
  return formatHelper('x');
}
2.3 ms
✓fires
points at the principle when the user asks for a helper in a Dart project detector.test.ts
prompt · in fixtures/dart_appfired: "helper"
Pull this into a helper
3.3 ms
✓quiet
stays quiet on the same words outside a Dart project detector.test.ts
promptstayed quiet
Pull this into a helper
2.6 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, prompt, source, write } from "@wellactually/sdk/v3/test";

const helper = source`
  /// Formats report labels.
  String formatHelper(String input) {
    return input.trim();
  }
`;

test("a Helper-suffixed function fires", () => {
  expect(detect(write("lib/report_formatting.dart", helper))).toEqual([{ line: 2 }]);
});

test("an Impl class and a scaffolding call fire", () => {
  const code = source`
    class StorageImpl {
      void save() => newImplSave();
    }
  `;
  expect(detect(write("lib/storage.dart", code))).toEqual([
    { line: 1 },
    { line: 2 },
  ]);
});

test("a helper the agent did not write stays quiet", () => {
  expect(detect(edit("lib/report_formatting.dart", helper, { written: "    return input.trim();" }))).toEqual([]);
});

test("a domain-named function stays quiet", () => {
  expect(detect(write("lib/label_formatting.dart", helper.replace("formatHelper", "formatLabel")))).toEqual([]);
});

test("a Helper-named variable or a returned call stays quiet", () => {
  const code = source`
    final labelHelper = formatLabel('reading');
    String label() {
      return formatHelper('x');
    }
  `;
  expect(detect(write("lib/label_cache.dart", code))).toEqual([]);
});

const dartApp = { project: "fixtures/dart_app" };

test("points at the principle when the user asks for a helper in a Dart project", () => {
  expect(detect(prompt("Pull this into a helper"), dartApp)).toEqual([{ match: "helper", depth: "pointer" }]);
});

test("stays quiet on the same words outside a Dart project", () => {
  expect(detect(prompt("Pull this into a helper"))).toEqual([]);
});