diff --git a/understand-anything-plugin/skills/understand/file-analyzer-prompt.md b/understand-anything-plugin/skills/understand/file-analyzer-prompt.md index 26df55f..ab95e1d 100644 --- a/understand-anything-plugin/skills/understand/file-analyzer-prompt.md +++ b/understand-anything-plugin/skills/understand/file-analyzer-prompt.md @@ -8,11 +8,13 @@ You are an expert code analyst. Your job is to read source files and produce pre For each file in the batch provided to you, extract structural data via a script, then apply expert judgment to generate summaries, tags, complexity ratings, and semantic edges. You will accomplish this in two phases: first, write and execute a structural extraction script; second, use those results as the foundation for your analysis. +**File categories in this batch:** Each file has a `fileCategory` field indicating its type: `code`, `config`, `docs`, `infra`, `data`, `script`, or `markup`. Adapt your analysis approach accordingly — see the category-specific guidance below. + --- ## Phase 1 -- Structural Extraction Script -Write a script that reads each source file in your batch and extracts deterministic structural information. Choose the best language for this task based on what's available on the system and what the project uses -- Node.js, Python, or bash with grep are all valid choices. +Write a script that reads each file in your batch and extracts deterministic structural information. Choose the best language for this task based on what's available on the system and what the project uses -- Node.js, Python, or bash with grep are all valid choices. ### Script Requirements @@ -21,12 +23,14 @@ Write a script that reads each source file in your batch and extracts determinis { "projectRoot": "/path/to/project", "batchFiles": [ - {"path": "src/index.ts", "language": "typescript", "sizeLines": 150}, - {"path": "src/utils.ts", "language": "typescript", "sizeLines": 80} + {"path": "src/index.ts", "language": "typescript", "sizeLines": 150, "fileCategory": "code"}, + {"path": "README.md", "language": "markdown", "sizeLines": 45, "fileCategory": "docs"}, + {"path": "Dockerfile", "language": "dockerfile", "sizeLines": 22, "fileCategory": "infra"} ], "batchImportData": { "src/index.ts": ["src/utils.ts", "src/config.ts"], - "src/utils.ts": [] + "README.md": [], + "Dockerfile": [] } } ``` @@ -35,7 +39,9 @@ Write a script that reads each source file in your batch and extracts determinis ### What the Script Must Extract (Per File) -For each file in `batchFiles`, read the file content and extract: +The extraction approach depends on the file's `fileCategory`: + +#### For `code` files: **Functions and Methods:** - Name, start line, end line, parameter names @@ -63,6 +69,88 @@ For each file in `batchFiles`, read the file content and extract: - Export count (number of export statements) - Function count, class count +#### For `config` files (YAML, JSON, TOML, XML, .env, etc.): + +**Key Settings:** +- Top-level keys/sections and their nesting depth +- For YAML/JSON: extract top-level keys and one level of nesting +- For `.env` files: extract variable names (not values) +- For `tsconfig.json`, `package.json`: extract notable settings (compiler options, scripts, dependencies) + +**Services Referenced:** +- Database connection strings (identify DB type, not credentials) +- External service URLs or hostnames +- Port numbers + +**Basic Metrics:** +- Total line count, non-empty line count +- Top-level key count + +#### For `docs` files (Markdown, RST, TXT): + +**Sections:** +- Heading hierarchy (h1, h2, h3) with line numbers +- For Markdown: extract `#` headings and their text + +**References:** +- Code file references (paths mentioned in text or code blocks) +- Links to other documentation files + +**Basic Metrics:** +- Total line count, non-empty line count +- Section count, code block count + +#### For `infra` files (Dockerfile, docker-compose, Terraform, Makefile, CI configs): + +**Services/Resources:** +- For Dockerfile: base image, exposed ports, entry point command, build stages +- For docker-compose: service names, images, ports, volume mounts, depends_on +- For Terraform: resource types and names, provider names +- For Makefile: target names +- For CI configs (GitHub Actions, GitLab CI): job/workflow names, triggers + +**Steps/Stages:** +- Build stages in Dockerfiles (FROM ... AS ...) +- CI pipeline stages/jobs +- Makefile targets and their dependencies + +**Basic Metrics:** +- Total line count, non-empty line count +- Stage count / job count / target count + +#### For `data` files (SQL, GraphQL, Protobuf, Prisma): + +**Definitions:** +- For SQL: table names (CREATE TABLE), column names and types, foreign key relationships +- For GraphQL: type definitions, query/mutation names, field lists +- For Protobuf: message names, field names, service definitions +- For Prisma: model names, field names, relations + +**Relationships:** +- Foreign keys and references between tables/types +- Service dependencies + +**Basic Metrics:** +- Total line count, non-empty line count +- Table/type/message count, field count + +#### For `script` files (shell, PowerShell, batch): + +Treat similarly to `code` files: +- Extract function definitions (`function name()` or `name()` in bash) +- Extract significant commands and pipeline operations +- Basic metrics: total lines, non-empty lines, function count + +#### For `markup` files (HTML, CSS, SCSS): + +**Structural Elements:** +- For HTML: major semantic elements (`
`, `