diff --git a/graphify/detect.py b/graphify/detect.py index 69b4ee3b1..441432f33 100644 --- a/graphify/detect.py +++ b/graphify/detect.py @@ -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 diff --git a/graphify/skill.md b/graphify/skill.md index 9401f2fee..2c8fc5b4e 100644 --- a/graphify/skill.md +++ b/graphify/skill.md @@ -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 ""` 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//` 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)