mirror of
https://github.com/safishamsi/graphify.git
synced 2026-09-23 22:15:46 +00:00
skill: fast path for existing graphs, fix large-corpus gate, fix subfolder output
- Fast path: if graphify-out/graph.json exists and user is asking a question (not an explicit rebuild), skip detect entirely and run graphify query — prevents the skill from refusing large already-built corpora (#930) - Raise FILE_COUNT_UPPER 200 → 500 so typical 200-500 file codebases no longer hit the large-corpus size gate on fresh extraction (#930) - Subdirectory breakdown now strips the scan-root prefix so agent shows relative names (core/, service/) not absolute paths rooted at / (#930) - Document multi-subfolder CLI pattern: graphify extract ./sub/ places graphify-out/ inside each subfolder; skill clobbers single root graphify-out when run on subfolders separately (#930) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
47e65658c7
commit
850c5457da
+1
-1
@@ -33,7 +33,7 @@ VIDEO_EXTENSIONS = {'.mp4', '.mov', '.webm', '.mkv', '.avi', '.m4v', '.mp3', '.w
|
||||
|
||||
CORPUS_WARN_THRESHOLD = 50_000 # words - below this, warn "you may not need a graph"
|
||||
CORPUS_UPPER_THRESHOLD = 500_000 # words - above this, warn about token cost
|
||||
FILE_COUNT_UPPER = 200 # files - above this, warn about token cost
|
||||
FILE_COUNT_UPPER = 500 # files - above this, warn about token cost
|
||||
|
||||
# Parent directories whose contents are always sensitive.
|
||||
# Checked against path.parts[:-1] (parents only) so a root-level file named
|
||||
|
||||
+22
-1
@@ -49,6 +49,8 @@ Drop any folder of code, docs, papers, images, or video into graphify and get a
|
||||
|
||||
If the user invoked `/graphify --help` or `/graphify -h` (with no other arguments), print the contents of the `## Usage` section above verbatim and stop. Do not run any commands, do not detect files, do not default the path to `.`. Just print the Usage block and return.
|
||||
|
||||
**Fast path — existing graph:** Before doing anything else, check whether `graphify-out/graph.json` already exists in the current directory. If it does AND the user's request is a natural-language question about the codebase (e.g. "How does X work?", "What calls Y?", "Trace the data flow through Z") and NOT an explicit rebuild command (`--update`, `--cluster-only`, or a bare path/URL that implies fresh extraction): **skip Steps 1–5 entirely and jump straight to `## For /graphify query`.** Run `graphify query "<question>"` immediately. Do not run detect. Do not check corpus size. Do not ask the user to narrow. The graph is already built — use it.
|
||||
|
||||
If no path was given, use `.` (current directory). Do not ask the user for a path.
|
||||
|
||||
If the path argument starts with `https://github.com/` or `http://github.com/`, treat it as a GitHub URL - run Step 0 before anything else, then continue with the resolved local path.
|
||||
@@ -78,6 +80,25 @@ graphify merge-graphs \
|
||||
|
||||
Graphify clones into `~/.graphify/repos/<owner>/<repo>` and reuses existing clones on repeat runs. Each node in the merged graph carries a `repo` attribute so you can filter by origin.
|
||||
|
||||
**Multiple local subfolders (monorepo or multi-service layout):**
|
||||
|
||||
The skill pipeline writes all intermediate and final outputs to `graphify-out/` in the current working directory. Running the skill on each subfolder separately will clobber the same output dir. Instead, use the CLI directly for each subfolder — it places `graphify-out/` *inside* the scanned path:
|
||||
|
||||
```bash
|
||||
graphify extract ./core/ --backend gemini # → ./core/graphify-out/graph.json
|
||||
graphify extract ./service/ --backend gemini # → ./service/graphify-out/graph.json
|
||||
graphify extract ./platform/ --backend gemini # → ./platform/graphify-out/graph.json
|
||||
|
||||
# Then merge at the project root:
|
||||
graphify merge-graphs \
|
||||
./core/graphify-out/graph.json \
|
||||
./service/graphify-out/graph.json \
|
||||
./platform/graphify-out/graph.json \
|
||||
--out graphify-out/graph.json
|
||||
```
|
||||
|
||||
Once `graphify-out/graph.json` exists, the fast path above takes over: any codebase question runs `graphify query` directly on the merged graph — no re-extraction, no size gate.
|
||||
|
||||
### Step 1 - Ensure graphify is installed
|
||||
|
||||
```bash
|
||||
@@ -148,7 +169,7 @@ Omit any category with 0 files from the summary.
|
||||
Then act on it:
|
||||
- If `total_files` is 0: stop with "No supported files found in [path]."
|
||||
- If `skipped_sensitive` is non-empty: mention file count skipped, not the file names.
|
||||
- If `total_words` > 2,000,000 OR `total_files` > 200: show the warning and the top 5 subdirectories by file count, then ask which subfolder to run on. Wait for the user's answer before proceeding.
|
||||
- If `total_words` > 2,000,000 OR `total_files` > 500: show the warning. Then compute the top 5 subdirectories by file count using **relative paths from INPUT_PATH** (strip the absolute scan-root prefix so you show `core/`, `service/`, not `/home/user/project/core/`), show those, then ask which subfolder to run on. Wait for the user's answer before proceeding.
|
||||
- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.
|
||||
|
||||
### Step 2.5 - Transcribe video / audio files (only if video files detected)
|
||||
|
||||
Reference in New Issue
Block a user