Skip to content

feat(build): opt out of .gitignore and .ignore writes (#148) - #156

Merged
shhdwi merged 1 commit into
trailhq:mainfrom
Frankie-Xu:feat/148-ignore-file-control
Aug 27, 2026
Merged

feat(build): opt out of .gitignore and .ignore writes (#148)#156
shhdwi merged 1 commit into
trailhq:mainfrom
Frankie-Xu:feat/148-ignore-file-control

Conversation

@Frankie-Xu

Copy link
Copy Markdown
Contributor

Summary

  • Add GRAFT_NO_GITIGNORE=1 to skip writing /graft/ into the repo's .gitignore during graft build (including hook-triggered builds that inherit env).
  • Add GRAFT_NO_IGNORE=1 to skip writing .ignore (the ripgrep re-admit file). Default behavior is unchanged; both are opt-in disable switches using the same truthy parsing as GRAFT_NO_REFRESH.
  • Add matching CLI flags: graft build --no-gitignore and graft build --no-ignore.
  • Document the env vars in .env.example.

Closes #148

Notes

  • If you disable .ignore writes, ripgrep will honor .gitignore and won't search graft/ cards unless you manage search exclusions yourself (e.g. keep a hand-written .ignore, or use rg -uu).
  • Global core.excludesfile detection is intentionally out of scope here — a good follow-up if users want automatic skip without env vars.

Test plan

  • npm run build && npm test — all green
  • node --import tsx --test test/context.test.ts — new unit + CLI integration tests pass
  • Existing ensureGitignored / ensureSearchable tests unchanged (default path)

Made with Cursor

@Frankie-Xu
Frankie-Xu force-pushed the feat/148-ignore-file-control branch from ebc2d66 to e18eac0 Compare August 21, 2026 07:48
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Rebased on current main (73f81e5) to resolve a conflict in src/cli.ts: the new --allow-partial deep-pass warning block (#127) landed next to the build footer this PR touches. Resolution keeps both — the footer message is now gated on GRAFT_NO_GITIGNORE as before, with the #127 block intact after it.

Local verification on the rebased head e18eac0:

@Frankie-Xu
Frankie-Xu force-pushed the feat/148-ignore-file-control branch from e18eac0 to 8869309 Compare August 24, 2026 10:29
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (177591e) to clear the conflict in src/cli.ts. Resolution keeps both: telemetry's buildStartedAt and the --no-gitignore / --no-ignore env-flag wiring at the top of the build action.

npm run build && npm test — 865/865.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Frankie-Xu
Frankie-Xu force-pushed the feat/148-ignore-file-control branch from 8869309 to 6b18fd9 Compare August 24, 2026 16:11
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Still the #148 opt-out: GRAFT_NO_GITIGNORE / GRAFT_NO_IGNORE (and --no-gitignore / --no-ignore) skip writing those files during graft build. Rebased onto current main (ee1ef03) after the 8/24 merge wave left this hanging.

npm run build OK. npm test 917/918 (#148 context tests 27/27; leftover is the same viz --tabs vs missing gitignored graft/ that #206 fixes).

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

2 areas changed → 2 areas can be affected. 4 dependent symbols, depth 2.
Tests: 1 area updated its tests.

flowchart TB
  A0(("Workspace Build Graph<br/>3 symbols"))
  A1(("Graph Engine<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0,A1 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Workspace Build Graph 3 src/graph/build.ts:L147-L403 buildGraph — calls, depth 1 Node File Context
Graph Engine 1 src/engine.ts:L86-L95 graph — calls, depth 2 Node File Context
All 4 dependent symbols, grouped by area

Workspace Build Graph — 3 symbols in 3 files

  • src/graph/build.ts:L147-L403 — buildGraph (calls, depth 1)
    364: // (`ensureGitignored` writes `.gitignore`, which a read has no business doing),
  • src/graph/workspace-cli.ts:L46-L81 — runWorkspaceBuild (calls, depth 1)
    78: ensureGitignored(root, contextDirFor(root, opts.override));
  • src/graph/refresh.ts:L150-L223 — ensureFreshGraph (calls, depth 2)

Graph Engine — 1 symbol in 1 file

  • src/engine.ts:L86-L95 — graph (calls, depth 2)
Test signal per changed area — 1 ✓ · 1 –

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • Node File Context — 2 of 3 reached · 1 test file changed here: test/context.test.ts
    • not reached: envTruthy
  • CLI — no function, method or class changed here
29 test suites also reference this code

31 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/ask-index.test.ts
  • test/ask.test.ts
  • test/container-extract.test.ts
  • test/covers.test.ts
  • test/generic-extract.test.ts
  • test/graph-go.test.ts
  • test/graph-incremental.test.ts
  • test/graph-invariants.test.ts
  • test/graph-java.test.ts
  • test/graph-languages.test.ts
  • test/graph-php.test.ts
  • test/graph-posix-paths.test.ts
  • test/graph-python.test.ts
  • test/graph-r-classes.test.ts
  • test/graph-r-phase3.test.ts
  • test/graph-r-phase4.test.ts
  • test/graph-r-phase5.test.ts
  • test/graph-r.test.ts
  • test/graph-references.test.ts
  • test/graph-refresh.test.ts
  • …9 more

⚠️ 1 changed file not in the graph (.env.example) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 4 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@shhdwi

shhdwi commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Verified locally on top of current main (clean merge; build clean).

Fixes #148: adds --no-gitignore / --no-ignore flags and GRAFT_NO_GITIGNORE / GRAFT_NO_IGNORE env vars (truthy-parsed, guarded at the top of ensureGitignored/ensureSearchable). Before/after in fresh git repos:

  • Default build → writes the graft/ block to .gitignore and writes .ignore.
  • --no-gitignore --no-ignore (or the env vars) → neither file is created, the graph still builds, and the footer switches to "add it to your gitignore if you want it untracked."

context.test.ts 30/30 (new no-op + CLI-integration tests). Fixes #148. Merging.

@shhdwi
shhdwi merged commit 02d766d into trailhq:main Aug 27, 2026
4 of 7 checks passed
github-actions Bot added a commit that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to opt out of graft writing .gitignore / .ignore (respect a global git ignore)

2 participants