Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
fix(trail): a teammate's headline file is their code, not CHANGELOG.md
Rushabh Nagdaaa631b715d53
diff --git a/src/cloud/onboarding.ts b/src/cloud/onboarding.tsindex dce735c8..e52dbdab 100644--- a/src/cloud/onboarding.ts+++ b/src/cloud/onboarding.ts@@ -312,6 +312,38 @@ export function notProductCode(path: string): boolean {return NOT_PRODUCT_DIR.test(p) || NOT_PRODUCT_FILE.test(p);}+/** Docs and config: prose, data and settings files, and the folders that hold them. */+const DOC_OR_CONFIG_FILE = new RegExp(+ [+ "\\.(md|mdx|markdown|rst|adoc|txt|json|jsonc|ya?ml|toml|ini|cfg|conf|env|lock|xml|csv|svg|png|jpe?g|gif|ico)$",+ "(^|/)(readme|changelog|changes|history|license|licence|notice|authors|contributors|codeowners|security)$",+ "(^|/)(makefile|dockerfile|procfile|go\\.mod|go\\.sum)$",+ // Dotfiles: .gitignore, .eslintrc.js, .env.local.+ "(^|/)\\.[^/]+$",+ ].join("|"),+ "i",+);+const DOC_OR_CONFIG_DIR = /(^|\/)(docs?|\.github|\.circleci|\.vscode|\.idea)\//i;++/** Whether a repo path is docs or config rather than code. */+export function docOrConfig(path: string): boolean {+ const p = path.split("\\").join("/");+ return DOC_OR_CONFIG_DIR.test(p) || DOC_OR_CONFIG_FILE.test(p);+}++/**+ * A teammate's files with the one worth naming first: product code (by the+ * same rules as the tokens lookup), then other code (tests, fixtures,+ * vendored, generated), then docs and config. Every file stays; only the+ * order changes, and within each kind it's git's. The page says a teammate+ * "is changing" the first one, which shouldn't be CHANGELOG.md when they+ * also change client.go.+ */+export function headlineOrder(files: string[]): string[] {+ const rank = (f: string) => (docOrConfig(f) ? 2 : notProductCode(f) ? 1 : 0);+ return files.map((f, i) => ({ f, i, r: rank(f) })).sort((a, b) => a.r - b.r || a.i - b.i).map((x) => x.f);+}+/*** One real lookup on the code map, as an agent would make it: a question* about the repo's most central symbol (most incoming edges) outside tests,@@ -533,7 +565,7 @@ export function teammatesFromGit(const [name = "", email = ""] = (git(repo, ["log", "-1", "--format=%aN%x09%aE", b.ref]) ?? "").trim().split("\t");if (!name || BOT.test(name)) continue;if ((me && email.toLowerCase() === me) || (myName && name.toLowerCase() === myName)) continue;- const files = b.files.filter((f) => !ownPath(f) && where.has(f));+ const files = headlineOrder(b.files.filter((f) => !ownPath(f) && where.has(f)));if (files.length === 0) continue;const commits = Number((git(repo, ["rev-list", "--count", `${cache.base}..${b.ref}`]) ?? "").trim());const conflict = conflictLine(repo, cache.base, b.ref, files, opts.learnings ?? []);diff --git a/test/trail-connect.test.ts b/test/trail-connect.test.tsindex fb0ff88f..0088044b 100644--- a/test/trail-connect.test.ts+++ b/test/trail-connect.test.ts@@ -17,6 +17,8 @@ import {claimConnectCode,conflictLine,connectAgain,+ docOrConfig,+ headlineOrder,notProductCode,offlineLine,learningTerms,@@ -379,6 +381,35 @@ test("a conflict needs the branch to change a name the learning is about, not juassert.deepEqual(learningTerms({ ...rule, title: "x", body: "", touches: ["client.go#Client.Do"] }), ["Do"]);});+test("docs and config are told apart from code", () => {+ for (const p of ["CHANGELOG.md", "README", "docs/setup.ts", "package.json", "go.mod", "go.sum", ".github/workflows/ci.yml", ".gitignore", ".eslintrc.js", "config/app.yaml", "Cargo.lock", "LICENSE", "Makefile", "Dockerfile", "assets/logo.svg"])+ assert.ok(docOrConfig(p), p);+ for (const p of ["client.go", "src/history.ts", "pkg/security/scan.go", "src/config.ts", "src/readme_parser.py", "cmd/docker.go"]) assert.ok(!docOrConfig(p), p);+});++test("a teammate's files lead with product code, then other code, then docs and config, and none is dropped", () => {+ const files = ["CHANGELOG.md", "client_test.go", "client.go", "package.json", "backoff.go", "test/helpers.ts"];+ assert.deepEqual(headlineOrder(files), ["client.go", "backoff.go", "client_test.go", "test/helpers.ts", "CHANGELOG.md", "package.json"]);+ assert.deepEqual(headlineOrder(["CHANGELOG.md", "README.md"]), ["CHANGELOG.md", "README.md"], "docs only: docs it is, in git's order");+ assert.deepEqual(headlineOrder([]), []);+});++test("the file a teammate is shown changing is their code, not CHANGELOG.md, unless docs are all they touched", () => {+ const { clone } = team();+ const me = clone("rushabh", "Rushabh Nagda");+ const kumar = clone("kumar", "Kumar S");+ const priya = clone("priya", "Priya R");+ pushBranch(me, "rushabh/notes", { "client.go": "package retry\n\n// mine\nconst defaultRetryMax = 4\n", "CHANGELOG.md": "# Changes\n- mine\n" }, "Mine");+ git(me, "checkout", "-q", "main");+ // git lists CHANGELOG.md before client.go: capitals sort first.+ pushBranch(kumar, "kumar/retry", { "CHANGELOG.md": "# Changes\n- retry 10\n", "client.go": "package retry\n\nconst defaultRetryMax = 10\n" }, "Raise defaultRetryMax to 10");+ pushBranch(priya, "priya/changelog", { "CHANGELOG.md": "# Changes\n- tidy\n" }, "Tidy the changelog");+ git(me, "fetch", "-q", "origin");+ const got = teammatesFromGit(me);+ assert.deepEqual(got.find((t) => t.branch === "kumar/retry")?.files, ["client.go", "CHANGELOG.md"]);+ assert.deepEqual(got.find((t) => t.branch === "priya/changelog")?.files, ["CHANGELOG.md"]);+});+/* a connection made by --connect ------------------------------------------- */test("a machine connected by --connect never syncs learnings or records searches, and is never asked to add a repo", () => {