Initial import of streamline
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { test, expect, describe } from "bun:test";
|
||||
import { signatureOf, categorize } from "../src/tool_gap";
|
||||
|
||||
/**
|
||||
* The normalisation IS the feature: raw commands never repeat (every one carries
|
||||
* a task id, a branch, a device serial), so a signature that doesn't collapse
|
||||
* those produces a ranking where everything has count 1.
|
||||
*/
|
||||
describe("command signatures", () => {
|
||||
const sig = (cmd: string) => signatureOf(cmd)?.signature;
|
||||
|
||||
test("collapses per-task noise onto one signature", () => {
|
||||
const a = sig("adb -s emulator-5554 shell am start -n com.ss.android/.MainActivity");
|
||||
const b = sig("adb -s R5CT30ABCDE shell am start -n com.ss.android/.OtherActivity");
|
||||
expect(a).toBe(b!);
|
||||
});
|
||||
|
||||
test("paths, hashes and long numbers are stripped", () => {
|
||||
expect(sig("ffprobe -v error /Users/fei/bug_workspace/7328764565/evidence/demo-1.mp4"))
|
||||
.toBe(sig("ffprobe -v error /Users/fei/bug_workspace/7301120088/evidence/demo-2.mp4")!);
|
||||
});
|
||||
|
||||
test("short flags are order-insensitive, long flags are kept as intent", () => {
|
||||
expect(sig("ls -la")).toBe(sig("ls -al")!);
|
||||
expect(sig("git log --oneline --graph")).toContain("--graph");
|
||||
});
|
||||
|
||||
test("the head of a pipeline names the intent, not the grep at the end", () => {
|
||||
expect(sig("adb logcat | grep -i crash")).toStartWith("adb");
|
||||
});
|
||||
|
||||
test("env prefixes and sudo are noise", () => {
|
||||
expect(sig("FOO=bar sudo adb devices")).toBe(sig("adb devices")!);
|
||||
});
|
||||
|
||||
test("trivia is dropped rather than ranked", () => {
|
||||
expect(signatureOf("cd /Users/fei/workspace/TikTok")).toBeNull();
|
||||
expect(signatureOf(" ")).toBeNull();
|
||||
expect(signatureOf("# just a comment")).toBeNull();
|
||||
});
|
||||
|
||||
test("categories group the ranking by the kind of work", () => {
|
||||
expect(categorize("adb")).toBe("android");
|
||||
expect(categorize("xcodebuild")).toBe("build");
|
||||
expect(categorize("ffmpeg")).toBe("media");
|
||||
expect(categorize("frida")).toBe("instrument");
|
||||
expect(categorize("weirdtool")).toBe("other");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user