Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

Merge branch 'main' into feat/add-exclude-flag

yiziff19a89f586031
diff --cc understand-anything-plugin/agents/project-scanner.md
index 1c00405e,b47bd03a..69d6b62a
--- a/understand-anything-plugin/agents/project-scanner.md
+++ b/understand-anything-plugin/agents/project-scanner.md
@@@ -52,24 -54,16 +54,27 @@@ If the manifest is missing or malformed
Invoke the bundled scan script. It walks the project (preferring `git ls-files`, falling back to a recursive walk for non-git directories), applies `.understandignore` filtering (defaults + user patterns), assigns `language` and `fileCategory` per the canonical tables, counts lines, and writes deterministic JSON. You do not see or maintain those tables — they live in the script.
+If the dispatch prompt includes exclude patterns, append `--exclude "<patterns>"` to the invocation (patterns should be comma-separated; the script splits them internally).
+
+ Resolve the project's data directory once (the legacy `.understand-anything/` when it already exists, otherwise the new `.ua/`) and reuse `$UA_DIR` for every path below:
+
```bash
- mkdir -p $PROJECT_ROOT/.understand-anything/tmp
+ UA_DIR="$PROJECT_ROOT/$([ -d "$PROJECT_ROOT/.understand-anything" ] && echo .understand-anything || echo .ua)"
+ mkdir -p $UA_DIR/tmp
node $PLUGIN_ROOT/skills/understand/scan-project.mjs \
"$PROJECT_ROOT" \
- "$PROJECT_ROOT/.understand-anything/tmp/ua-scan-files.json"
+ "$UA_DIR/tmp/ua-scan-files.json"
```
+With exclude patterns (add the `--exclude` flag after the output path):
+
+```bash
+node $PLUGIN_ROOT/skills/understand/scan-project.mjs \
+ "$PROJECT_ROOT" \
- "$PROJECT_ROOT/.understand-anything/tmp/ua-scan-files.json" \
++ "$UA_DIR/tmp/ua-scan-files.json" \
+ --exclude "tests/*,docs/*"
+```
+
Output JSON shape (you will read this verbatim and merge into the final scan-result):
```json
diff --cc understand-anything-plugin/packages/core/src/ignore-filter.ts
index ae824efb,ec395a93..7f12e362
--- a/understand-anything-plugin/packages/core/src/ignore-filter.ts
+++ b/understand-anything-plugin/packages/core/src/ignore-filter.ts
@@@ -80,11 -81,11 +81,12 @@@ export interface IgnoreFilter
*
* Pattern load order (later entries can override earlier ones via ! negation):
* 1. Hardcoded defaults
- * 2. .understand-anything/.understandignore (if exists)
+ * 2. <ua-dir>/.understandignore (if exists — `.ua/`, or the legacy
+ * `.understand-anything/` when that directory already exists)
* 3. .understandignore at project root (if exists)
+ * 4. CLI --exclude patterns (highest priority)
*/
-export function createIgnoreFilter(projectRoot: string): IgnoreFilter {
+export function createIgnoreFilter(projectRoot: string, extraPatterns: string[] = []): IgnoreFilter {
const ig: Ignore = ignore();
// Layer 1: hardcoded defaults
diff --cc understand-anything-plugin/skills/understand/SKILL.md
index cd02f5fa,99bede1a..168479a7
--- a/understand-anything-plugin/skills/understand/SKILL.md
+++ b/understand-anything-plugin/skills/understand/SKILL.md
@@@ -12,11 -12,10 +12,11 @@@ Analyze the current codebase and produc
- `$ARGUMENTS` may contain:
- `--full` — Force a full rebuild, ignoring any existing graph
- - `--auto-update` — Enable automatic graph updates on commit (writes `autoUpdate: true` to `.understand-anything/config.json`)
- - `--no-auto-update` — Disable automatic graph updates (writes `autoUpdate: false` to `.understand-anything/config.json`)
+ - `--auto-update` — Enable automatic graph updates on commit (writes `autoUpdate: true` to `$UA_DIR/config.json`)
+ - `--no-auto-update` — Disable automatic graph updates (writes `autoUpdate: false` to `$UA_DIR/config.json`)
- `--review` — Run full LLM graph-reviewer instead of inline deterministic validation
- - `--language <lang>` — Generate all textual content (summaries, descriptions, tags, titles, languageNotes, languageLesson) in the specified language. Accepts ISO 639-1 codes (`zh`, `ja`, `ko`, `en`, `es`, `fr`, `de`, etc.) or friendly names (`chinese`, `japanese`, `korean`, `english`, `spanish`, etc.). Locale variants supported: `zh-TW`, `zh-HK`, etc. Defaults to `en` (English). Stores preference in `.understand-anything/config.json` for consistency across incremental updates.
+ - `--language <lang>` — Generate all textual content (summaries, descriptions, tags, titles, languageNotes, languageLesson) in the specified language. Accepts ISO 639-1 codes (`zh`, `ja`, `ko`, `en`, `es`, `fr`, `de`, etc.) or friendly names (`chinese`, `japanese`, `korean`, `english`, `spanish`, etc.). Locale variants supported: `zh-TW`, `zh-HK`, etc. Defaults to `en` (English). Stores preference in `$UA_DIR/config.json` for consistency across incremental updates.
+ - `--exclude <patterns>` — Comma-separated glob patterns for additional files/directories to exclude from analysis (e.g., `--exclude "tests/*,docs/*"`). These patterns take highest priority over built-in defaults and `.understandignore` rules. Supports gitignore syntax including `!` negation.
- A directory path (e.g. `/path/to/repo` or `../other-project`) — Analyze the given directory instead of the current working directory
---
@@@ -157,17 -162,10 +163,17 @@@ Determine whether to run a full analysi
> **Language directive**: Generate all textual content (summaries, descriptions, tags, titles, languageNotes, languageLesson) in **{language}**. Maintain technical accuracy while using natural, native-level phrasing in the target language. Keep technical terms in English when no standard translation exists (e.g., "middleware", "hook", "barrel").
```
- 4. **Check for subdomain knowledge graphs to merge:**
+ 3.7. **Exclude patterns:**
+ - Parse `$ARGUMENTS` for `--exclude <patterns>` flag. If found, extract the comma-separated patterns string.
+ - Split on commas, trim whitespace from each pattern, and filter out empty entries.
+ - Store the patterns as `$EXCLUDE_PATTERNS` (comma-joined for passing to downstream scripts: `"tests/*,docs/*"`).
+ - These patterns take highest priority — they are applied on top of default patterns and `.understandignore` rules. Use `!` prefix to force-include files that would otherwise be excluded.
+ - **Note:** Newly added `--exclude` patterns require a `--full` scan to take effect.
+
+4. **Check for subdomain knowledge graphs to merge:**
- List all `*knowledge-graph*.json` files in `$PROJECT_ROOT/.understand-anything/` **excluding** `knowledge-graph.json` itself (e.g. `frontend-knowledge-graph.json`, `backend-knowledge-graph.json`). If any subdomain graphs exist, run the merge script bundled with this skill (located next to this SKILL.md file — use the skill directory path, not the project root):
+ List all `*knowledge-graph*.json` files in `$UA_DIR/` **excluding** `knowledge-graph.json` itself (e.g. `frontend-knowledge-graph.json`, `backend-knowledge-graph.json`). If any subdomain graphs exist, run the merge script bundled with this skill (located next to this SKILL.md file — use the skill directory path, not the project root):
```bash
- python <SKILL_DIR>/merge-subdomain-graphs.py $PROJECT_ROOT
+ python "<SKILL_DIR>/merge-subdomain-graphs.py" "$PROJECT_ROOT"
```
The script discovers subdomain graphs, loads the existing `knowledge-graph.json` as a base (if present), and merges everything into `knowledge-graph.json` (deduplicating nodes and edges). Report the merge summary to the user, then continue with the merged graph.
@@@ -248,11 -246,9 +254,11 @@@ Pass these parameters in the dispatch p
> Scan this project directory to discover all project files (including non-code files like configs, docs, infrastructure), detect languages and frameworks.
> Project root: `$PROJECT_ROOT`
- > Write output to: `$PROJECT_ROOT/.understand-anything/intermediate/scan-result.json`
+ > Write output to: `$UA_DIR/intermediate/scan-result.json`
+>
+> Exclude patterns (from --exclude CLI flag; pass to scan-project.mjs via --exclude): $EXCLUDE_PATTERNS
- After the subagent completes, read `$PROJECT_ROOT/.understand-anything/intermediate/scan-result.json` to get:
+ After the subagent completes, read `$UA_DIR/intermediate/scan-result.json` to get:
- Project name, description
- Languages, frameworks
- File list with line counts and `fileCategory` per file (`code`, `config`, `docs`, `infra`, `data`, `script`, `markup`)