Skip to content

Commit 271ee0a

Browse files
safishamsiclaude
andcommitted
Fix #188: collect_files() now respects .graphifyignore; fix #195: skill.md requires general-purpose subagent type for extraction dispatch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0e45308 commit 271ee0a

8 files changed

Lines changed: 43 additions & 19 deletions

File tree

graphify/extract.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ def extract(paths: list[Path]) -> dict:
26682668
}
26692669

26702670

2671-
def collect_files(target: Path, *, follow_symlinks: bool = False) -> list[Path]:
2671+
def collect_files(target: Path, *, follow_symlinks: bool = False, root: Path | None = None) -> list[Path]:
26722672
if target.is_file():
26732673
return [target]
26742674
_EXTENSIONS = {
@@ -2678,12 +2678,20 @@ def collect_files(target: Path, *, follow_symlinks: bool = False) -> list[Path]:
26782678
".lua", ".toc", ".zig", ".ps1",
26792679
".m", ".mm",
26802680
}
2681+
from graphify.detect import _load_graphifyignore, _is_ignored
2682+
ignore_root = root if root is not None else target
2683+
patterns = _load_graphifyignore(ignore_root)
2684+
2685+
def _ignored(p: Path) -> bool:
2686+
return bool(patterns and _is_ignored(p, ignore_root, patterns))
2687+
26812688
if not follow_symlinks:
26822689
results: list[Path] = []
26832690
for ext in sorted(_EXTENSIONS):
26842691
results.extend(
26852692
p for p in target.rglob(f"*{ext}")
26862693
if not any(part.startswith(".") for part in p.parts)
2694+
and not _ignored(p)
26872695
)
26882696
return sorted(results)
26892697
# Walk with symlink following + cycle detection
@@ -2701,7 +2709,7 @@ def collect_files(target: Path, *, follow_symlinks: bool = False) -> list[Path]:
27012709
continue
27022710
for fname in filenames:
27032711
p = dp / fname
2704-
if p.suffix in _EXTENSIONS and not fname.startswith("."):
2712+
if p.suffix in _EXTENSIONS and not fname.startswith(".") and not _ignored(p):
27052713
results.append(p)
27062714
return sorted(results)
27072715

graphify/skill-codex.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ Output exactly this JSON (no other text):
305305
**Step B3 - Collect, cache, and merge**
306306

307307
Wait for all subagents. For each result:
308-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
308+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
309+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
310+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
309311
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
310312

311-
If more than half the chunks failed, stop and tell the user.
313+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
312314

313315
Save new results to cache:
314316
```bash

graphify/skill-copilot.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,12 @@ Output exactly this JSON (no other text):
301301
**Step B3 - Collect, cache, and merge**
302302

303303
Wait for all subagents. For each result:
304-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
304+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
305+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
306+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
305307
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
306308

307-
If more than half the chunks failed, stop and tell the user.
309+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
308310

309311
Save new results to cache:
310312
```bash

graphify/skill-droid.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ Output exactly this JSON (no other text):
302302
**Step B3 - Collect, cache, and merge**
303303

304304
Wait for all subagents. For each result:
305-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
305+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
306+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
307+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
306308
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
307309

308-
If more than half the chunks failed, stop and tell the user.
310+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
309311

310312
Save new results to cache:
311313
```bash

graphify/skill-opencode.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,12 @@ Output exactly this JSON (no other text):
301301
**Step B3 - Collect, cache, and merge**
302302

303303
Wait for all subagents. For each result:
304-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
304+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
305+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
306+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
305307
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
306308

307-
If more than half the chunks failed, stop and tell the user.
309+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
308310

309311
Save new results to cache:
310312
```bash

graphify/skill-trae.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,12 @@ Accumulate nodes/edges/hyperedges across all results and write to `.graphify_sem
298298
**Step B3 - Collect, cache, and merge**
299299

300300
Wait for all subagents. For each result:
301-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
301+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
302+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
303+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
302304
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
303305

304-
If more than half the chunks failed, stop and tell the user.
306+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
305307

306308
Save new results to cache:
307309
```bash

graphify/skill-windows.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,12 @@ Output exactly this JSON (no other text):
291291
**Step B3 - Collect, cache, and merge**
292292

293293
Wait for all subagents. For each result:
294-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
294+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
295+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
296+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
295297
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
296298

297-
If more than half the chunks failed, stop and tell the user.
299+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
298300

299301
Save new results to cache:
300302
```powershell

graphify/skill.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@ Load files from `graphify-out/.graphify_uncached.txt`. Split into chunks of 20-2
238238

239239
Call the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.
240240

241+
**IMPORTANT - subagent type:** Always use `subagent_type="general-purpose"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.
242+
241243
Concrete example for 3 chunks:
242244
```
243-
[Agent tool call 1: files 1-15]
244-
[Agent tool call 2: files 16-30]
245-
[Agent tool call 3: files 31-45]
245+
[Agent tool call 1: files 1-15, subagent_type="general-purpose"]
246+
[Agent tool call 2: files 16-30, subagent_type="general-purpose"]
247+
[Agent tool call 3: files 31-45, subagent_type="general-purpose"]
246248
```
247249
All three in one message. Not three separate messages.
248250

@@ -304,10 +306,12 @@ Output exactly this JSON (no other text):
304306
**Step B3 - Collect, cache, and merge**
305307

306308
Wait for all subagents. For each result:
307-
- If a subagent returned valid JSON with `nodes` and `edges`, include it and save each file's nodes/edges to the cache
309+
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
310+
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
311+
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
308312
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
309313

310-
If more than half the chunks failed, stop and tell the user.
314+
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
311315

312316
Save new results to cache:
313317
```bash

0 commit comments

Comments
 (0)