[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74PSM425CT2N1DHBM5FWN6A":3,"skill-same:01M74PSM425CT2N1DHBM5FWN6A":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M74PSM425CT2N1DHBM5FWN6A","excavate-source-analysis",null,"Source code analysis methodology — decompose any codebase into analyzable units, extract behavioral claims with provenance. Supports three target shapes (source tree, bundle, decompiled binary), with per-language grep patterns and analysis templates.","cmetech\u002Fotto-cli","cmetech","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118027304?v=4","01M74PNNHCP8T9GH9NWAWHK66N","Corey Ellis","01M74PNNJ1JR5BJQG3JK95RVFT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fexcavate-source-analysis\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: excavate-source-analysis\ndescription: Source code analysis methodology — decompose any codebase into analyzable units, extract behavioral claims with provenance. Supports three target shapes (source tree, bundle, decompiled binary), with per-language grep patterns and analysis templates.\n---\n\n# Source Analysis Methodology\n\nYou are a general-purpose worker. You were dispatched with a role and told to Read this skill, then produce the behavioral analysis described below.\n\nExtract behavioral intelligence from source code. Decompose the codebase into analyzable units, then systematically analyze each unit for behavioral claims with full provenance.\n\n## When to Use This Mode\n\nSource analysis activates when:\n- The discovery inventory identifies source code files at the target path\n- Any source code needs behavioral analysis (any language, bundled or not)\n- Decompiled output exists at `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F`\n\n## General Approach\n\nSource analysis takes three shapes depending on what the target looks like:\n\n- **Source tree** — a repository with a package manifest and conventional directory layout (Python, Rust, Go, Swift, Java, Node\u002FTS, C++, etc.). Follow the **Source Tree Pipeline** below.\n- **Bundle** — a single-file minified or packed artifact (JavaScript bundle, Electron asar, webpack\u002Fesbuild output). Follow the **Bundle Pipeline** below.\n- **Decompiled binary** — a compiled artifact where source isn't directly available. Decompile first via the **Decompilation Path**, then analyze the decompiled output using whichever of the above shapes fits.\n\nRegardless of shape, the pipeline follows the same logical steps:\n\n1. **Assess the source.** What language? How is it organized? How large is it?\n2. **Decompose into analyzable units.** Use the language's natural boundaries (modules, packages, files) when they exist. Split bundled artifacts into chunks when they don't.\n3. **Analyze each unit exhaustively.** Read every line. Identify every function, method, class. Understand what each does behaviorally.\n4. **Extract behavioral specifications.** Write what the code DOES (observable behavior), not how it's structured (implementation details). Every claim gets a provenance citation.\n\nPhases 6-8 (per-unit analysis, per-function deep analysis, targeted extraction) are shape-agnostic and apply to all three paths.\n\n## Decompilation Path\n\nWhen source code isn't directly available, decompile binaries into structured source before analysis.\n\n### Language-Specific Decompilation Tools\n\n| Language\u002FPlatform | Tools | Notes |\n|-------------------|-------|-------|\n| JVM (Java, Kotlin) | cfr, procyon, fernflower | cfr is standalone JAR; fernflower is IntelliJ's built-in decompiler |\n| .NET (C#, F#) | ilspy, dotPeek CLI | ilspy has a command-line mode suitable for automation |\n| Python (.pyc, .pyo) | uncompyle6, decompyle3 | decompyle3 targets Python 3.7+; uncompyle6 covers older versions |\n| JavaScript (bundled\u002Fobfuscated) | js-beautify | Also covered by the Bundle Pipeline below |\n| Native (x86, ARM, etc.) | ghidra headless, radare2 | Produces pseudocode, not true source; useful for behavioral extraction but lower fidelity |\n\n### Process\n\n1. **Identify binary type.** Determine the platform and format (JAR, DLL, .pyc, ELF, Mach-O, etc.).\n2. **Check tool availability.** Verify the appropriate decompiler is installed and accessible. If tools are unavailable, warn and fall back to binary analysis (strings, symbols, imports\u002Fexports).\n3. **Decompile to workspace.** Output decompiled source to `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F`. Preserve directory structure from the binary where possible (e.g., Java package paths).\n4. **Treat decompiled output as structured source.** Once decompiled, analyze using the same General Approach above — each decompiled file is an analyzable unit.\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fdecompiled\n\n# Example: JVM with cfr\njava -jar cfr.jar target.jar --outputdir workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n\n# Example: Python with uncompyle6\nuncompyle6 -o workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F target.pyc\n\n# Example: .NET with ilspy\nilspycmd target.dll -o workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n\n# Example: Native with Ghidra headless\nanalyzeHeadless \u002Ftmp\u002Fghidra_project proj -import target.bin -postScript ExportDecompiled.java workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n```\n\n### Quality Notes\n\nDecompiled code differs from original source in predictable ways:\n\n- **Variable and parameter names are lost.** Decompilers generate synthetic names (e.g., `var1`, `a0`). Focus on behavioral patterns, not identifier semantics.\n- **Comments are lost.** All inline documentation is gone. Rely on string constants, API calls, and control flow for behavioral understanding.\n- **Control flow may be less readable.** Optimized bytecode can decompile into awkward `goto`-style structures or deeply nested conditionals.\n\nThese limitations are acceptable for behavioral extraction. The goal is to understand what the code does, not to recover the original source.\n\n## Source Tree Pipeline\n\nSource tree analysis is the common path for Python, Rust, Go, Swift, Java, C++, and similar languages that ship as a repository rather than a single compiled artifact. The target is a directory with a package manifest and a conventional source layout.\n\nThe Source Tree Pipeline defines Phases ST1-ST3 (survey, enumeration, and unit preparation). After ST3, control flows into the shape-neutral Phases 6-8 shared with the Bundle Pipeline.\n\n```dot\ndigraph source_tree_analysis {\n    rankdir=TB;\n\n    \"Start (source tree)\" [shape=doublecircle];\n    \"Phase ST1: Manifest discovery\" [shape=box];\n    \"Phase ST2: Module enumeration\" [shape=box];\n    \"Phase ST3: Prepare for per-unit analysis\" [shape=box];\n    \"→ Phase 6 (shape-neutral)\" [shape=box, style=filled, fillcolor=\"#f0f0f0\"];\n\n    \"Start (source tree)\" -> \"Phase ST1: Manifest discovery\";\n    \"Phase ST1: Manifest discovery\" -> \"Phase ST2: Module enumeration\";\n    \"Phase ST2: Module enumeration\" -> \"Phase ST3: Prepare for per-unit analysis\";\n    \"Phase ST3: Prepare for per-unit analysis\" -> \"→ Phase 6 (shape-neutral)\";\n}\n```\n\n### Phase ST1: Manifest Discovery\n\nIdentify the package manifest and read it. The manifest names the package, declares dependencies, and lists the source roots.\n\n| Language | Manifest | Source roots |\n|----------|----------|--------------|\n| Python | `pyproject.toml`, `setup.py`, `setup.cfg` | `src\u002F`, `\u003Cpackage>\u002F`, or top-level modules |\n| Rust | `Cargo.toml` (+ workspace `Cargo.toml`) | `src\u002F`, each crate's `src\u002F` |\n| Go | `go.mod` | Module root and every directory with `.go` files |\n| Swift | `Package.swift`, `*.xcodeproj\u002Fproject.pbxproj` | `Sources\u002F\u003Ctarget>\u002F` per target |\n| Java\u002FKotlin | `pom.xml`, `build.gradle`, `build.gradle.kts` | `src\u002Fmain\u002Fjava\u002F`, `src\u002Fmain\u002Fkotlin\u002F` |\n| C#\u002FF# | `*.csproj`, `*.fsproj` | project-relative source directories |\n| C\u002FC++ | `CMakeLists.txt`, `Makefile`, `meson.build` | varies; often `src\u002F` and `include\u002F` |\n| Node (non-bundled) | `package.json` | `src\u002F`, `lib\u002F`, `index.js` |\n\nWrite the survey to `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fsurvey.md`:\n\n```markdown\n# Source Tree Survey\n\n**Language:** \u003Cprimary>\n**Manifest:** \u003Cpath>\n**Package name:** \u003Cfrom manifest>\n**Source roots:** \u003Clist>\n**Dependency count:** \u003Ccount>\n**Line count by language:** \u003Ctable>\n```\n\n### Phase ST2: Module Enumeration\n\nWalk the source roots and produce a module list. A \"module\" in this pipeline is whatever the language's natural unit of organization is — a Python package, a Rust module\u002Fcrate, a Go package, a Swift target, a Java package. Don't invent your own boundaries; use the language's.\n\n```bash\n# Python: every directory with __init__.py plus every top-level .py file\nfind \u003Csource-root> -name '__init__.py' -exec dirname {} \\;\nfind \u003Csource-root> -maxdepth 1 -name '*.py' -not -name '__init__.py'\n\n# Rust: every directory with a mod.rs or every file in src\u002F\nfind \u003Ccrate>\u002Fsrc -name '*.rs'\n\n# Go: every directory with at least one .go file\nfind \u003Csource-root> -name '*.go' -exec dirname {} \\; | sort -u\n\n# Swift: every directory under Sources\u002F\nfind Sources -mindepth 2 -maxdepth 2 -type d\n\n# Java\u002FKotlin: every directory with .java or .kt files\nfind src\u002Fmain -name '*.java' -o -name '*.kt' -exec dirname {} \\; | sort -u\n```\n\nWrite the module inventory to `workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fmodule-manifest.json`:\n\n```json\n{\n  \"modules\": [\n    {\"path\": \"src\u002Fparser\", \"files\": 7, \"lines\": 1240, \"language\": \"rust\"},\n    {\"path\": \"src\u002Fhttp\", \"files\": 4, \"lines\": 680, \"language\": \"rust\"}\n  ]\n}\n```\n\n### Phase ST3: Prepare for Per-Unit Analysis\n\nOnce Phases ST1-ST2 have produced the survey and module manifest, each module is ready to be treated as the analyzable unit for the shape-neutral Phase 6. The analysis unit differs by target shape: in a bundle, the unit is a chunk from the split; in a source tree, it's a module as the language defines it. Both produce the same per-unit output format.\n\nPhases 6-8 (Per-Unit Analysis, Per-Function Deep Analysis, Targeted Extraction), described later in this skill, apply from here on.\n\n---\n\n## Bundle Pipeline\n\nThe Bundle Pipeline defines Phases B1-B5 (bundle-specific decomposition). After B5, control flows into the shape-neutral Phases 6-8 shared with the Source Tree Pipeline.\n\n```dot\ndigraph bundle_pipeline {\n    rankdir=TB;\n\n    \"Start (bundle target)\" [shape=doublecircle];\n    \"Phase B1: Beautify bundle\" [shape=box];\n    \"Phase B2: Find module boundaries\" [shape=box];\n    \"Phase B3: Extract chunks\" [shape=box];\n    \"Phase B4: Extract functions\" [shape=box];\n    \"Phase B5: Extract strings\" [shape=box];\n    \"→ Phase 6 (shape-neutral)\" [shape=box, style=filled, fillcolor=\"#f0f0f0\"];\n\n    \"Start (bundle target)\" -> \"Phase B1: Beautify bundle\";\n    \"Phase B1: Beautify bundle\" -> \"Phase B2: Find module boundaries\";\n    \"Phase B2: Find module boundaries\" -> \"Phase B3: Extract chunks\";\n    \"Phase B3: Extract chunks\" -> \"Phase B4: Extract functions\";\n    \"Phase B4: Extract functions\" -> \"Phase B5: Extract strings\";\n    \"Phase B5: Extract strings\" -> \"→ Phase 6 (shape-neutral)\";\n}\n```\n\nPhases B1-B5 are bundle decomposition. Phases 6-7 produce behavioral analysis and are shape-neutral. Phase 8 is optional targeted extraction.\n\nFor non-bundled targets, run the Source Tree Pipeline's Phases ST1-ST3 instead of this section's B1-B5, then flow into the same shape-neutral Phases 6-8.\n\n## Phase B1: Bundle Preparation\n\n### 1.1 Beautify if Needed\n\nCheck if the bundle is minified by comparing line count to byte count. A file with few lines but many bytes is minified.\n\n```bash\nLINE_COUNT=$(wc -l \u003C \"$BUNDLE\")\nBYTE_COUNT=$(wc -c \u003C \"$BUNDLE\")\nif [ \"$LINE_COUNT\" -lt 100 ] && [ \"$BYTE_COUNT\" -gt 100000 ]; then\n  echo \"Minified - needs beautification\"\n  mkdir -p workspace\u002Fraw\u002Fsource\n  BEAUTIFIED=\"workspace\u002Fraw\u002Fsource\u002Ftarget.js\"\n  if [ ! -f \"$BEAUTIFIED\" ]; then\n    npx js-beautify --type js -f \"$BUNDLE\" -o \"$BEAUTIFIED\"\n  fi\n  TARGET=\"$BEAUTIFIED\"\nelse\n  TARGET=\"$BUNDLE\"\nfi\n```\n\nAlways check for an existing beautified version before re-beautifying. Multiple agents may operate on the same bundle.\n\n### 1.2 Initial Survey\n\n```bash\n# Size and line count\nls -lh \"$TARGET\"\nwc -l \"$TARGET\"\n\n# Detect bundler type\nhead -100 \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fbundle-header.txt\ngrep -m1 \"webpack\\|esbuild\\|rollup\\|parcel\" \"$TARGET\" || echo \"Unknown bundler\"\n```\n\nWrite the survey to `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fsurvey.md`.\n\n## Phase B2: Find Module Boundaries\n\n### 2.1 Bundler-Specific Markers\n\n#### Webpack\n\n```bash\n# Module ID markers\ngrep -n \"^\u002F\\*\\*\\*\\*\\*\\*\u002F \\\"\" \"$TARGET\" > manifests\u002Fwebpack-modules.txt\n\n# Export declarations\ngrep -n \"__webpack_require__\\.d\\|__webpack_exports__\" \"$TARGET\" | head -100 > manifests\u002Fwebpack-exports.txt\n```\n\n#### esbuild\n\n```bash\n# esbuild source comments\ngrep -n \"^\u002F\u002F \" \"$TARGET\" | grep -v \"^\u002F\u002F $\" > manifests\u002Fesbuild-markers.txt\n```\n\n#### Generic IIFE Boundaries\n\n```bash\n# Function expression boundaries\ngrep -n \"^(function\\|^!function\\|^var [a-z]* = function\" \"$TARGET\" > manifests\u002Fiife-boundaries.txt\n```\n\n### 2.2 Heuristic Boundaries\n\nWhen no bundler-specific markers are found, fall back to heuristics:\n\n```bash\n# Long comment separators\ngrep -n \"^\u002F\\*\\*\\*\\*\\*\\*\\*\\*\" \"$TARGET\" > manifests\u002Fseparator-comments.txt\n\n# Export clusters\ngrep -n \"^exports\\.\\|^module\\.exports\" \"$TARGET\" > manifests\u002Fexport-points.txt\n\n# Large gaps (blank lines often separate modules)\nawk 'NF==0 {if(++blank>=3) print NR\": --- blank section ---\"} NF>0 {blank=0}' \"$TARGET\" | head -100\n```\n\n## Phase B3: Extract Chunks\n\n### 3.1 Split by Module Markers\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fchunks\n\n# Webpack-style split\ncsplit -f workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk- -n 4 \"$TARGET\" '\u002F^\\\u002F\\*\\*\\*\\*\\*\\*\\\u002F\u002F' '{*}' 2>\u002Fdev\u002Fnull\n\n# Fall back to line-count splitting if no clear markers\nif [ $(ls workspace\u002Fraw\u002Fsource\u002Fchunks\u002F | wc -l) -lt 5 ]; then\n  rm workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*\n  split -l 2000 \"$TARGET\" workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-\nfi\n\n# Rename to .js\nfor f in workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-*; do\n  [ \"${f%.js}\" = \"$f\" ] && mv \"$f\" \"${f}.js\"\ndone\n```\n\n### 3.2 Generate Chunk Manifest\n\n```bash\necho '{\"chunks\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n\nfor chunk in workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*.js; do\n  name=$(basename \"$chunk\")\n  lines=$(wc -l \u003C \"$chunk\")\n  size=$(wc -c \u003C \"$chunk\")\n\n  # Extract first meaningful identifier\n  first_func=$(grep -oP \"function [a-zA-Z_][a-zA-Z0-9_]*\" \"$chunk\" | head -1)\n  first_class=$(grep -oP \"class [a-zA-Z_][a-zA-Z0-9_]*\" \"$chunk\" | head -1)\n\n  echo \"  {\\\"file\\\": \\\"$name\\\", \\\"lines\\\": $lines, \\\"bytes\\\": $size, \\\"first_func\\\": \\\"$first_func\\\", \\\"first_class\\\": \\\"$first_class\\\"},\"\ndone >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n```\n\n## Phase B4: Extract Functions\n\n### 4.1 Find Function Definitions\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Ffunctions\n\n# Named functions\ngrep -n \"function [a-zA-Z_][a-zA-Z0-9_]*\\s*(\" \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\n\n# Arrow function assignments\ngrep -n \"const [a-zA-Z_][a-zA-Z0-9_]* = (\" \"$TARGET\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\ngrep -n \"const [a-zA-Z_][a-zA-Z0-9_]* = async\" \"$TARGET\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\n```\n\n### 4.2 Extract Individual Functions\n\nExtract each significant function (more than 10 lines) to its own file:\n\n```bash\ncat > \u002Ftmp\u002Fextract_funcs.js \u003C\u003C 'EOF'\nconst fs = require('fs');\nconst code = fs.readFileSync(process.argv[2], 'utf8');\n\nconst funcPattern = \u002Ffunction\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([^)]*\\)\\s*\\{\u002Fg;\nlet match;\nlet funcId = 0;\nconst outDir = process.argv[3] || 'workspace\u002Fraw\u002Fsource\u002Ffunctions';\n\nwhile ((match = funcPattern.exec(code)) !== null) {\n  const name = match[1];\n  const start = match.index;\n  let depth = 1;\n  let i = code.indexOf('{', start) + 1;\n  while (depth > 0 && i \u003C code.length) {\n    if (code[i] === '{') depth++;\n    if (code[i] === '}') depth--;\n    i++;\n  }\n  const funcCode = code.slice(start, i);\n  if (funcCode.split('\\n').length > 10) {\n    fs.writeFileSync(\n      `${outDir}\u002Ffunc-${String(funcId++).padStart(4, '0')}-${name}.js`,\n      funcCode\n    );\n  }\n}\nEOF\nnode \u002Ftmp\u002Fextract_funcs.js \"$TARGET\" workspace\u002Fraw\u002Fsource\u002Ffunctions\n```\n\n### 4.3 Generate Function Manifest\n\n```bash\necho '{\"functions\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n\nfor func in workspace\u002Fraw\u002Fsource\u002Ffunctions\u002F*.js; do\n  name=$(basename \"$func\" .js)\n  lines=$(wc -l \u003C \"$func\")\n  params=$(grep -oP \"function[^(]*\\([^)]*\\)\" \"$func\" | head -1)\n  echo \"  {\\\"file\\\": \\\"$name\\\", \\\"lines\\\": $lines, \\\"signature\\\": \\\"$params\\\"},\"\ndone >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n```\n\n## Phase B5: String Extraction\n\n### 5.1 Catalog All Strings\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fmanifests\n\n# Extract all strings with line numbers (minimum 5 chars)\ngrep -noP '\"[^\"]{5,}\"' \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt\n\n# Categorize\ngrep -P '\"https?:\u002F\u002F' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-urls.txt\ngrep -P '\"[A-Z][A-Z_]{3,}\"' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-constants.txt\ngrep -P '\"--[a-z]' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-cli-flags.txt\ngrep -P '\"Error|Failed|Warning' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-errors.txt\n```\n\n### 5.2 Map Strings to Chunks\n\n```bash\necho '{\"string_locations\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n\nfor chunk in workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*.js; do\n  name=$(basename \"$chunk\")\n  echo \"  {\\\"chunk\\\": \\\"$name\\\", \\\"strings\\\": [\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n  grep -oP '\"[^\"]{10,}\"' \"$chunk\" | head -20 | while read str; do\n    echo \"    $str,\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n  done\n  echo \"  ]},\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\ndone\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n```\n\n## Phase 6: Per-Unit Analysis (all source shapes)\n\nRun this analysis once per analyzable unit. What counts as a \"unit\" depends on target shape:\n- **Bundle target:** a chunk file from Phase 3, e.g. `workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-0042.js`\n- **Source tree:** a source file or small module from Phase 3, e.g. `src\u002Fparser\u002Flexer.py` or `src\u002Fhttp\u002Fhandler.go`\n- **Decompiled binary:** a decompiled source file from the Decompilation Path\n\n`$UNIT` in the examples below is the path to the unit being analyzed. Grep patterns use conventions common in several languages; adjust to the target language's idioms.\n\n### Exhaustive Reading Requirement (CRITICAL)\n\n**You MUST read every single line of the unit. No exceptions.**\n\n- Do NOT skim. Do NOT skip sections that \"look like boilerplate.\"\n- The grep patterns below are for INDEXING, not for UNDERSTANDING.\n- After running greps, you MUST read the full unit file.\n- Every routine (function, method, class) must be identified and catalogued.\n- Every line must be accounted for.\n\n**Verification checklist before writing analysis:**\n- [ ] I read the ENTIRE unit, not just samples\n- [ ] I identified EVERY function\u002Fmethod\u002Fclass in the unit\n- [ ] I understand what EVERY section of code does\n\n### 6.1 Initial Survey (Then Read in Full)\n\n```bash\nwc -l \"$UNIT\"            # Know the size\nhead -50 \"$UNIT\"         # Get oriented\ntail -20 \"$UNIT\"         # See the end\ncat \"$UNIT\"              # READ THE ENTIRE FILE\n```\n\n### 6.2 Identify Behaviors\n\n```bash\n# Domain indicators (informative strings are clues in any language)\ngrep -oE '\"[a-zA-Z]{5,}\"' \"$UNIT\" | sort | uniq -c | sort -rn | head -20\n\n# Error messages\ngrep -oE '\"[^\"]*[Ee]rror[^\"]*\"' \"$UNIT\" | sort -u\n\n# Common action verbs in method\u002Ffunction invocations\ngrep -oE '\\.(read|write|send|receive|parse|validate|handle|process|create|delete|update)\\(' \"$UNIT\" | sort | uniq -c\n```\n\n### 6.3 Catalog Capabilities\n\nUse language-appropriate declaration patterns. Read the matches; don't rely on the grep counts alone.\n\n```bash\n# JavaScript \u002F TypeScript\ngrep -oE \"function [a-zA-Z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"(const|let|var) [a-zA-Z_][a-zA-Z0-9_]* = (async )?(function|\\()\" \"$UNIT\"\ngrep -oE \"class [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"exports\\.[a-zA-Z_]+|export (const|function|class|default)\" \"$UNIT\"\n\n# Python\ngrep -oE \"^(async )?def [a-zA-Z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"^class [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Go\ngrep -oE \"^func (\\([^)]+\\) )?[A-Za-z_][A-Za-z0-9_]*\" \"$UNIT\"\ngrep -oE \"^type [A-Z][a-zA-Z0-9_]* \" \"$UNIT\"\n\n# Rust\ngrep -oE \"^(pub )?fn [a-z_][a-z0-9_]*\" \"$UNIT\"\ngrep -oE \"^(pub )?(struct|enum|trait) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Swift\ngrep -oE \"^(public |private |internal )?func [a-z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"^(public |private |internal )?(class|struct|enum|protocol|actor) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Java \u002F Kotlin\ngrep -oE \"^(public |private )?(class|interface|enum) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n```\n\n### 6.4 Find Dependencies\n\n```bash\n# JavaScript \u002F TypeScript\ngrep -oE \"require\\(['\\\"][^'\\\"]+['\\\"]\\)|from ['\\\"][^'\\\"]+['\\\"]\" \"$UNIT\"\n\n# Python\ngrep -oE \"^(from [a-zA-Z_][a-zA-Z0-9_.]* )?import [a-zA-Z_][a-zA-Z0-9_., ]*\" \"$UNIT\"\n\n# Rust\ngrep -oE \"^use [a-zA-Z_][a-zA-Z0-9_:]+\" \"$UNIT\"\n\n# Swift\ngrep -oE \"^import [A-Z][A-Za-z0-9_]*\" \"$UNIT\"\n\n# Java \u002F Kotlin\ngrep -oE \"^import [a-z][a-zA-Z0-9_.]+\" \"$UNIT\"\n\n# Go: import blocks span multiple lines; read them from the file header\nhead -50 \"$UNIT\" | awk '\u002F^import [(\\\"]\u002F,\u002F^\\)$\u002F'\n```\n\n### 6.5 Data Flow\n\nLook for I\u002FO, state mutations, and event\u002Fsignal interaction. The specific idioms vary by language and framework:\n\n```bash\n# I\u002FO operations — common verbs across many languages\ngrep -nE \"\\.(read|write|get|set|load|save|fetch|send)\\b\" \"$UNIT\" | head -20\n\n# Event \u002F signal \u002F pub-sub shapes (varies by language and framework):\n#   Node EventEmitter:         .on('name', ...), .emit('name', ...)\n#   Python pyee \u002F blinker:      .connect(...), .send(...)\n#   Rust tokio \u002F crossbeam:    .notify(...), .subscribe(...)\n#   Swift NotificationCenter:  .post(name:...), .addObserver(...)\n#   Generic pub\u002Fsub:            .publish(...), .subscribe(...), .dispatch(...)\ngrep -nE \"\\.(on|emit|connect|notify|subscribe|publish|post|dispatch)\\(\" \"$UNIT\" | head -20\n```\n\n### 6.6 Output Template\n\nWrite the analysis to a path that mirrors the unit's origin:\n- Bundle target → `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002F\u003Cchunk-name>.md`\n- Source tree → `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002F\u003Cmodule-or-file-path>.md`\n\n```markdown\n# Unit Analysis: \u003Cunit name>\n\n## Behavioral Summary\n[1-2 sentences: What does this unit DO from a user\u002Fsystem perspective?]\n\n## Key Behaviors Identified\n\n### [Behavior 1 Name]\n- **What it does**: [behavioral description]\n- **Inputs**: [what it accepts]\n- **Outputs**: [what it produces]\n- **Evidence**: [function names, strings that indicate this]\n\n### [Behavior 2 Name]\n- **What it does**: [behavioral description]\n- **Inputs**: [what it accepts]\n- **Outputs**: [what it produces]\n- **Evidence**: [function names, strings that indicate this]\n\n## Data Handled\n- Reads: [what data it reads]\n- Writes: [what data it writes]\n- Transforms: [what transformations it performs]\n\n## Error Conditions\n- [Error 1]: \"[exact error message]\" - when [condition]\n- [Error 2]: \"[exact error message]\" - when [condition]\n\n## Dependencies\n- External: [third-party packages or libraries]\n- Internal: [other units it references]\n\n## Domain Indicators\nKey strings that reveal purpose:\n[informative strings]\n\n## Module Guess\nThis unit likely belongs to the **[module name]** module because:\n- [reason 1]\n- [reason 2]\n\n## Needs Deep Dive?\n- [ ] Yes - complex behavior requiring full spec\n- [ ] No - utility code, can be summarized\n\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| [behavioral claim] | \u003Cunit>:{line} | inferred |\n```\n\n## Phase 7: Per-Function Deep Analysis (all source shapes)\n\nRun this deep analysis once per significant function or method. Each pass analyzes a single routine exhaustively. `$FUNC` is the path to a file containing the routine:\n- **Bundle target:** an extracted-function file from Phase B4, e.g. `workspace\u002Fraw\u002Fsource\u002Ffunctions\u002Ffunc-0007-parseConfig.js`.\n- **Source tree:** either the containing source file (if small) or a single-routine extraction. For long source files, slice out the routine into a tmp file before analysis so that greps scope to the routine and not to the whole module.\n- **Decompiled binary:** same options as source tree — decompiled code lives on disk as files, so treat it accordingly.\n\n### Exhaustive Reading Requirement (CRITICAL)\n\n**You MUST read every single line of the function. No exceptions.**\n\n- Do NOT skim. Read every statement.\n- The grep patterns help you INDEX what you find -- they are NOT a substitute for reading.\n- Every line of code must be understood.\n- Every conditional branch must be traced.\n- Every side effect must be identified.\n\n**Verification checklist before writing analysis:**\n- [ ] I read the ENTIRE function, line by line\n- [ ] I understand what EVERY statement does\n- [ ] I traced EVERY conditional branch\n- [ ] I identified EVERY side effect\n\n### 7.1 Identify Signature and Parameters\n\nRead the routine's first lines; the signature is in the declaration. Common shapes:\n- JavaScript\u002FTypeScript: `function name(params)`, `const name = (params) =>`, `async name(params) {`\n- Python: `def name(params):`, `async def name(params):`\n- Go: `func name(params) returns`, `func (receiver) name(params) returns`\n- Rust: `fn name(params) -> Return`, `pub fn name\u003CT>(params) -> Return`\n- Swift: `func name(params) -> Return`, `public func name(params) async throws -> Return`\n- Java\u002FKotlin: `public Return name(params)`, `fun name(params): Return`\n\n### 7.2 Trace Data Flow\n\n```bash\n# Parameter identifiers (lowercase tokens are often variables\u002Fparams)\ngrep -oE '\\b[a-z][a-zA-Z0-9_]*\\b' \"$FUNC\" | sort | uniq -c | sort -rn | head -20\n\n# Return points\ngrep -nE \"^\\s*return\\b\" \"$FUNC\"\n\n# Call sites (invocations — reads across most languages)\ngrep -oE \"[a-zA-Z_][a-zA-Z0-9_]*\\s*\\(\" \"$FUNC\" | sort | uniq -c | sort -rn | head -20\n```\n\n### 7.3 Identify Side Effects\n\nIdioms are language-specific; adapt:\n\n```bash\n# File I\u002FO — common names across languages\ngrep -nE \"\\b(read|write|open|close|unlink|remove|mkdir|makedirs|rename)_?[A-Za-z]*\\(\" \"$FUNC\"\n\n# Network I\u002FO\ngrep -nE \"\\b(fetch|request|Get|Post|Send|httpGet|urlopen|reqwest|URLSession)\\b\" \"$FUNC\"\n\n# State mutations\ngrep -nE \"\\.(set|push|append|insert|splice|extend|add|update)\\(|^\\s*[a-zA-Z_][a-zA-Z0-9_.]*\\s*=[^=]\" \"$FUNC\"\n\n# Logging\ngrep -nE \"\\b(console\\.|log\\.|logger\\.|println!|eprintln!|log\\.Printf|logrus\\.|zap\\.)\" \"$FUNC\"\n```\n\n### 7.4 Error Handling\n\nIdioms differ by language — error values in Go and Rust; exceptions in Python, Java, JavaScript, Swift:\n\n```bash\n# Exception-based (JS\u002FPython\u002FJava\u002FSwift)\ngrep -nE \"\\b(throw|raise)\\b\" \"$FUNC\"\ngrep -cE \"\\b(try|catch|except|finally)\\b\" \"$FUNC\"\n\n# Error-value-based (Go, Rust)\ngrep -nE \"\\breturn .*err\\b|\\\\?$|\\\\?;\" \"$FUNC\"\ngrep -nE \"\\bif err != nil\\b|\\\\bResult\u003C|\\\\bOption\u003C\" \"$FUNC\"\n\n# Guard clauses \u002F precondition checks\ngrep -nE \"\\bif\\s+(err|e|not|!|.*is None|.*== nil)\\b\" \"$FUNC\"\n```\n\n### 7.5 Control Flow\n\n```bash\n# Conditionals\ngrep -c \"if (\" \"$FUNC\"\ngrep -c \"else\" \"$FUNC\"\n\n# Loops\ngrep -c \"for (\\|while (\\|\\.forEach\\|\\.map\\|\\.filter\" \"$FUNC\"\n\n# Early returns\ngrep -n \"return\" \"$FUNC\" | head -10\n```\n\n### 7.6 Output Template\n\nWrite to `workspace\u002Fraw\u002Fsource\u002Ffunctions\u002F\u003Cmodule-or-unit>\u002F\u003Cfunction-name>.md`:\n\n```markdown\n# Function: [name]\n\n## Signature\n[function signature with parameters]\n\n## Purpose\n[1-2 sentences: What does this function do?]\n\n## Parameters\n| Name | Inferred Type | Purpose |\n|------|---------------|---------|\n| param1 | string | [what it's used for] |\n\n## Return Value\n- Type: [inferred]\n- Description: [what it returns]\n\n## Behavior\n\n### Normal Path\n1. [First thing it does]\n2. [Second thing it does]\n3. [Returns X]\n\n### Error Paths\n- If [condition]: throws [error] \u002F returns [value]\n- If [condition]: [behavior]\n\n## Side Effects\n- [ ] Modifies parameters\n- [ ] Writes to files\n- [ ] Makes network calls\n- [ ] Mutates external state\n- [ ] Logs output\n\nDetails:\n- [specific side effect 1]\n- [specific side effect 2]\n\n## Dependencies\nCalls these functions:\n- `funcName()` - [purpose]\n- `otherFunc()` - [purpose]\n\n## Key Strings\n[strings that reveal purpose]\n\n## Complexity\n- Lines: [X]\n- Conditionals: [X]\n- Loops: [X]\n- Nested depth: [estimate]\n\n## Behavioral Specification\n\n**Given:** [preconditions]\n**When:** function is called with [inputs]\n**Then:** [outputs and side effects]\n\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| [behavioral claim] | \u003Cfunction-file>:{line} | inferred |\n```\n\n## Phase 8: Targeted Module Extraction\n\nWhen you need focused analysis of a specific component of the target (e.g., \"HTTP parser\", \"error handling\", \"configuration loader\"), rather than analyzing everything in depth. In a bundle, the component is a module identified in Phase B2. In a source tree, it's a named package or directory. In a decompiled binary, it's whichever decompiled files correspond to the focus area. \n\n### 8.1 Scope Assessment\n\nGet a rough sense of how much code relates to the focus area:\n\n```bash\n# Count matches for focus-related terms\ngrep -c \"$FOCUS_TERMS\" \"$TARGET\"\n\n# Find which line ranges contain clusters of matches\ngrep -n \"$FOCUS_TERMS\" \"$TARGET\" | awk -F: '{print int($1\u002F100)*100}' | sort -n | uniq -c | sort -rn | head -20\n```\n\nThis reveals which 100-line regions are most relevant.\n\n### 8.2 String Constant Discovery\n\nStrings are NEVER minified and reveal the most about behavior:\n\n```bash\ngrep -oE '\"[^\"]{3,80}\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fstrings.md`.\n\n### 8.3 Identifier Discovery\n\nNamed identifiers (functions, classes, properties) often survive minification:\n\n```bash\n# Named functions\ngrep -oE \"function [a-zA-Z_]\\w*\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Property assignments (method definitions)\ngrep -oE \"\\.[a-zA-Z_]\\w*\\s*=\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Class definitions\ngrep -oE \"class [a-zA-Z_]\\w*\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fidentifiers.md`.\n\n### 8.4 Code Section Extraction\n\nFor each cluster of focus-area matches, extract surrounding code with enough context to understand the logic (50-100 lines around matches):\n\n```bash\ngrep -n \"$FOCUS_TERM\" \"$TARGET\" | head -30 | while read match; do\n  LINE=$(echo \"$match\" | cut -d: -f1)\n  START=$((LINE - 50))\n  END=$((LINE + 50))\n  [ \"$START\" -lt 1 ] && START=1\n  sed -n \"${START},${END}p\" \"$TARGET\"\n  echo \"--- END EXTRACT (lines $START-$END) ---\"\ndone\n```\n\nFor each extracted section, read and understand it, then write a summary to `$OUTPUT_DIR\u002Fsections\u002Fsection-NNN.md` with:\n- Line range in beautified file\n- What this section does (behavioral description)\n- Key identifiers and strings found\n- Connections to other sections\n- Open questions\n\n### 8.5 URL and API Endpoint Extraction\n\n```bash\ngrep -oE '\"https?:\u002F\u002F[^\"]*\"' \"$TARGET\" | sort -u\ngrep -oE '\"wss?:\u002F\u002F[^\"]*\"' \"$TARGET\" | sort -u\ngrep -oE '\"\u002F[a-z][a-z0-9\u002F._-]*\"' \"$TARGET\" | grep -v '\\.(js|css|html|png|svg)' | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fendpoints.md`.\n\n### 8.6 Data Structure Extraction\n\n```bash\n# Object literals with focus-area properties\ngrep -oE '\\{[^{}]{10,200}\\}' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | head -30\n\n# Property chains revealing structure\ngrep -oE '\\.\\w+\\.\\w+\\.\\w+' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort | uniq -c | sort -rn | head -30\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fdata-structures.md`.\n\n### 8.7 Error Messages and States Extraction\n\n```bash\n# Error strings\ngrep -oE '\"[^\"]*[Ee]rror[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\ngrep -oE '\"[^\"]*[Ff]ail[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Status\u002Fstate strings\ngrep -oE '\"[^\"]*[Ss]tatus[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Ferrors-and-states.md`.\n\n### 8.8 Contextual Analysis\n\nAfter extraction, read the extracted sections and produce a synthesis covering:\n\n- **Connection map** -- which sections reference each other; trace call flows and data flows between sections\n- **State machine** -- if the module manages state, document the states and transitions observed\n- **Protocol\u002Fmessage catalog** -- if the module involves communication, catalog all message types, their fields, and when they are sent\u002Freceived\n- **Configuration points** -- what settings, constants, or configuration values affect this module's behavior\n\nWrite synthesis to `$OUTPUT_DIR\u002Fanalysis.md`.\n\n### 8.9 Findings Report\n\nWrite comprehensive findings to `$OUTPUT_DIR\u002Ffindings.md`:\n\n```markdown\n# Targeted Extractor Findings: [Focus Area]\n\n## Target\n- Source: [path or module identifier]\n- Focus: [area]\n\n## Summary\n[2-3 paragraph overview of what was found]\n\n## Key Components\n### [Component 1]\n- Purpose: [what it does]\n- Location: [file:line range or module\u002Fpackage path]\n- Key identifiers: [list]\n- Key strings: [list]\n\n## Data Model\n[Key data structures and their fields]\n\n## Protocol \u002F API\n[If applicable: endpoints, message types, wire format]\n\n## State Management\n[If applicable: states, transitions, persistence]\n\n## Configuration\n[Settings that affect behavior]\n\n## Error Conditions\n[What can go wrong and how it's handled]\n\n## Open Questions\n[Things that need further investigation]\n\n## Cross-References\n[How this component relates to others in the target]\n```\n\n## Provenance Rules\n\n### Source Type\n\nAll claims from source code analysis use `source=source-code`:\n\n```markdown\n- Sessions expire after 30 minutes of inactivity\n  \u003C!-- cite: source=source-code, ref=workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fchunk-0011.md:34, confidence=inferred -->\n```\n\n### Single-Source Analysis\n\nWhen analysis draws on a single source (the source code), Confidence is typically `inferred` because there is only one source to draw from.\n\n### Confidence Levels\n\n- **confirmed** -- exact literal or API call visible in source, OR corroborated by a second independent source (e.g., runtime observation agrees with source reading)\n- **inferred** -- derived from code logic; single authoritative source provides direct evidence\n- **assumed** -- based on naming convention, comment text, or structural reasoning; not verified against observable behavior\n\n### Cite As You Go\n\nEvery behavioral claim gets an inline citation immediately after the claim. Do NOT batch citations at the end of analysis. The moment you write a behavioral assertion, the very next thing you write is the `\u003C!-- cite: -->` comment.\n\n### Key Claims Table\n\nEnd each analysis file with a Key Claims table:\n\n```markdown\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| Handles session timeout at 30 min | \u003Cunit>:145 | inferred |\n| Uses AES-256-GCM for encryption | \u003Cunit>:302 | confirmed |\n| Salt length is a fixed 16 bytes | \u003Cfunction-file>:{line} | inferred |\n```\n\nThis table is how downstream verification agents trace claims back to source.\n\n## Output Structure\n\nOutput layout varies by target shape.\n\n### Bundle target\n\n```\nworkspace\u002Fraw\u002Fsource\u002F\n    target.js                    # Original (beautified) bundle\n    chunks\u002F                      # Split modules\n        chunk-0001.js\n        chunk-0002.js\n        ...\n    functions\u002F                   # Extracted individual functions (>10 lines each)\n        func-0001-processMessage.js\n        func-0002-handleRequest.js\n        ...\n    manifests\u002F                   # Inventories\n        chunk-manifest.json\n        function-manifest.json\n        string-manifest.json\n        strings-raw.txt\n        strings-urls.txt\n        strings-constants.txt\n        strings-cli-flags.txt\n        strings-errors.txt\n        function-locations.txt\n    analysis\u002F                    # Per-chunk behavioral analysis\n        survey.md\n        chunk-0001.md\n        chunk-0002.md\n        ...\n        functions\u002F               # Per-function behavioral analysis\n            func-0001.md\n            func-0002.md\n            ...\n    exploration\u002F                 # Targeted explorations by focus area\n        {focus-area}\u002F\n            strings.md\n            identifiers.md\n            sections\u002F\n                section-001.md\n                section-002.md\n                ...\n            endpoints.md\n            data-structures.md\n            errors-and-states.md\n            analysis.md\n            findings.md\n```\n\n### Source tree target\n\n```\nworkspace\u002Fraw\u002Fsource\u002F\n    manifests\u002F\n        module-manifest.json     # List of modules, files, lines, language\n    analysis\u002F                    # Per-module behavioral analysis\n        survey.md\n        \u003Cmodule-path-1>.md       # e.g. src-parser-lexer.md\n        \u003Cmodule-path-2>.md\n        ...\n    functions\u002F                   # Per-function analyses, grouped by module\n        \u003Cmodule-path>\u002F\n            \u003Cfunction-name>.md\n            ...\n    exploration\u002F                 # Targeted explorations by focus area\n        {focus-area}\u002F\n            findings.md\n```\n\nThe module-path convention flattens the source tree into filenames (e.g., `src\u002Fparser\u002Flexer.py` → `src-parser-lexer.md`) so the analysis directory stays flat and greppable.\n\n### Decompiled binary target\n\nDecompiled binaries are handled by first writing decompiled source to `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F` (preserving the decompiler's output layout), then running the shape-appropriate pipeline above: if the decompiled output is a single large file, treat it as a bundle; if the decompiler produced a tree of files, treat it as a source tree.\n\n## Rules\n\n1. **WRITE AS YOU GO** -- every finding goes to a file immediately. Do not accumulate findings in your head. Use the Write tool the moment you have something to record.\n2. **Focus on BEHAVIOR not IMPLEMENTATION** -- write \"handles authentication\" not \"calls authLib.verify()\". Describe what the code DOES, not how it is structured.\n3. **No raw source code excerpts longer than one line** -- behavioral output must not contain multi-line code snippets. Single-line references are acceptable as evidence.\n4. **Flag behavioral complexity** -- note what needs deep-dive analysis. Mark chunks and functions that exhibit complex state management, protocol handling, or multi-step workflows.\n5. **Reuse beautified code** -- before beautifying, check if a beautified version already exists at `workspace\u002Fraw\u002Fsource\u002Ftarget.js`. Multiple workers share this file.\n6. **Exhaustive reading is mandatory** -- grep patterns are for indexing, not understanding. After running greps, you MUST read the full source. Every function, method, class, and code path must be identified.\n7. **Cite as you go** -- every behavioral claim gets an inline `\u003C!-- cite: -->` comment immediately after the claim. Never defer citation to a later step.\n8. **One chunk\u002Ffunction per invocation** -- process one chunk or one function per pass. Stay focused.\n9. **Be targeted in exploration** -- stay focused on the requested component. Do not analyze the entire target when only one component is needed.\n10. **Note line numbers** -- in the beautified file, so sections can be found again by downstream workers and verification.\n","# Source Analysis Methodology\n\nYou are a general-purpose worker. You were dispatched with a role and told to Read this skill, then produce the behavioral analysis described below.\n\nExtract behavioral intelligence from source code. Decompose the codebase into analyzable units, then systematically analyze each unit for behavioral claims with full provenance.\n\n## When to Use This Mode\n\nSource analysis activates when:\n- The discovery inventory identifies source code files at the target path\n- Any source code needs behavioral analysis (any language, bundled or not)\n- Decompiled output exists at `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F`\n\n## General Approach\n\nSource analysis takes three shapes depending on what the target looks like:\n\n- **Source tree** — a repository with a package manifest and conventional directory layout (Python, Rust, Go, Swift, Java, Node\u002FTS, C++, etc.). Follow the **Source Tree Pipeline** below.\n- **Bundle** — a single-file minified or packed artifact (JavaScript bundle, Electron asar, webpack\u002Fesbuild output). Follow the **Bundle Pipeline** below.\n- **Decompiled binary** — a compiled artifact where source isn't directly available. Decompile first via the **Decompilation Path**, then analyze the decompiled output using whichever of the above shapes fits.\n\nRegardless of shape, the pipeline follows the same logical steps:\n\n1. **Assess the source.** What language? How is it organized? How large is it?\n2. **Decompose into analyzable units.** Use the language's natural boundaries (modules, packages, files) when they exist. Split bundled artifacts into chunks when they don't.\n3. **Analyze each unit exhaustively.** Read every line. Identify every function, method, class. Understand what each does behaviorally.\n4. **Extract behavioral specifications.** Write what the code DOES (observable behavior), not how it's structured (implementation details). Every claim gets a provenance citation.\n\nPhases 6-8 (per-unit analysis, per-function deep analysis, targeted extraction) are shape-agnostic and apply to all three paths.\n\n## Decompilation Path\n\nWhen source code isn't directly available, decompile binaries into structured source before analysis.\n\n### Language-Specific Decompilation Tools\n\n| Language\u002FPlatform | Tools | Notes |\n|-------------------|-------|-------|\n| JVM (Java, Kotlin) | cfr, procyon, fernflower | cfr is standalone JAR; fernflower is IntelliJ's built-in decompiler |\n| .NET (C#, F#) | ilspy, dotPeek CLI | ilspy has a command-line mode suitable for automation |\n| Python (.pyc, .pyo) | uncompyle6, decompyle3 | decompyle3 targets Python 3.7+; uncompyle6 covers older versions |\n| JavaScript (bundled\u002Fobfuscated) | js-beautify | Also covered by the Bundle Pipeline below |\n| Native (x86, ARM, etc.) | ghidra headless, radare2 | Produces pseudocode, not true source; useful for behavioral extraction but lower fidelity |\n\n### Process\n\n1. **Identify binary type.** Determine the platform and format (JAR, DLL, .pyc, ELF, Mach-O, etc.).\n2. **Check tool availability.** Verify the appropriate decompiler is installed and accessible. If tools are unavailable, warn and fall back to binary analysis (strings, symbols, imports\u002Fexports).\n3. **Decompile to workspace.** Output decompiled source to `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F`. Preserve directory structure from the binary where possible (e.g., Java package paths).\n4. **Treat decompiled output as structured source.** Once decompiled, analyze using the same General Approach above — each decompiled file is an analyzable unit.\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fdecompiled\n\n# Example: JVM with cfr\njava -jar cfr.jar target.jar --outputdir workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n\n# Example: Python with uncompyle6\nuncompyle6 -o workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F target.pyc\n\n# Example: .NET with ilspy\nilspycmd target.dll -o workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n\n# Example: Native with Ghidra headless\nanalyzeHeadless \u002Ftmp\u002Fghidra_project proj -import target.bin -postScript ExportDecompiled.java workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F\n```\n\n### Quality Notes\n\nDecompiled code differs from original source in predictable ways:\n\n- **Variable and parameter names are lost.** Decompilers generate synthetic names (e.g., `var1`, `a0`). Focus on behavioral patterns, not identifier semantics.\n- **Comments are lost.** All inline documentation is gone. Rely on string constants, API calls, and control flow for behavioral understanding.\n- **Control flow may be less readable.** Optimized bytecode can decompile into awkward `goto`-style structures or deeply nested conditionals.\n\nThese limitations are acceptable for behavioral extraction. The goal is to understand what the code does, not to recover the original source.\n\n## Source Tree Pipeline\n\nSource tree analysis is the common path for Python, Rust, Go, Swift, Java, C++, and similar languages that ship as a repository rather than a single compiled artifact. The target is a directory with a package manifest and a conventional source layout.\n\nThe Source Tree Pipeline defines Phases ST1-ST3 (survey, enumeration, and unit preparation). After ST3, control flows into the shape-neutral Phases 6-8 shared with the Bundle Pipeline.\n\n```dot\ndigraph source_tree_analysis {\n    rankdir=TB;\n\n    \"Start (source tree)\" [shape=doublecircle];\n    \"Phase ST1: Manifest discovery\" [shape=box];\n    \"Phase ST2: Module enumeration\" [shape=box];\n    \"Phase ST3: Prepare for per-unit analysis\" [shape=box];\n    \"→ Phase 6 (shape-neutral)\" [shape=box, style=filled, fillcolor=\"#f0f0f0\"];\n\n    \"Start (source tree)\" -> \"Phase ST1: Manifest discovery\";\n    \"Phase ST1: Manifest discovery\" -> \"Phase ST2: Module enumeration\";\n    \"Phase ST2: Module enumeration\" -> \"Phase ST3: Prepare for per-unit analysis\";\n    \"Phase ST3: Prepare for per-unit analysis\" -> \"→ Phase 6 (shape-neutral)\";\n}\n```\n\n### Phase ST1: Manifest Discovery\n\nIdentify the package manifest and read it. The manifest names the package, declares dependencies, and lists the source roots.\n\n| Language | Manifest | Source roots |\n|----------|----------|--------------|\n| Python | `pyproject.toml`, `setup.py`, `setup.cfg` | `src\u002F`, `\u003Cpackage>\u002F`, or top-level modules |\n| Rust | `Cargo.toml` (+ workspace `Cargo.toml`) | `src\u002F`, each crate's `src\u002F` |\n| Go | `go.mod` | Module root and every directory with `.go` files |\n| Swift | `Package.swift`, `*.xcodeproj\u002Fproject.pbxproj` | `Sources\u002F\u003Ctarget>\u002F` per target |\n| Java\u002FKotlin | `pom.xml`, `build.gradle`, `build.gradle.kts` | `src\u002Fmain\u002Fjava\u002F`, `src\u002Fmain\u002Fkotlin\u002F` |\n| C#\u002FF# | `*.csproj`, `*.fsproj` | project-relative source directories |\n| C\u002FC++ | `CMakeLists.txt`, `Makefile`, `meson.build` | varies; often `src\u002F` and `include\u002F` |\n| Node (non-bundled) | `package.json` | `src\u002F`, `lib\u002F`, `index.js` |\n\nWrite the survey to `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fsurvey.md`:\n\n```markdown\n# Source Tree Survey\n\n**Language:** \u003Cprimary>\n**Manifest:** \u003Cpath>\n**Package name:** \u003Cfrom manifest>\n**Source roots:** \u003Clist>\n**Dependency count:** \u003Ccount>\n**Line count by language:** \u003Ctable>\n```\n\n### Phase ST2: Module Enumeration\n\nWalk the source roots and produce a module list. A \"module\" in this pipeline is whatever the language's natural unit of organization is — a Python package, a Rust module\u002Fcrate, a Go package, a Swift target, a Java package. Don't invent your own boundaries; use the language's.\n\n```bash\n# Python: every directory with __init__.py plus every top-level .py file\nfind \u003Csource-root> -name '__init__.py' -exec dirname {} \\;\nfind \u003Csource-root> -maxdepth 1 -name '*.py' -not -name '__init__.py'\n\n# Rust: every directory with a mod.rs or every file in src\u002F\nfind \u003Ccrate>\u002Fsrc -name '*.rs'\n\n# Go: every directory with at least one .go file\nfind \u003Csource-root> -name '*.go' -exec dirname {} \\; | sort -u\n\n# Swift: every directory under Sources\u002F\nfind Sources -mindepth 2 -maxdepth 2 -type d\n\n# Java\u002FKotlin: every directory with .java or .kt files\nfind src\u002Fmain -name '*.java' -o -name '*.kt' -exec dirname {} \\; | sort -u\n```\n\nWrite the module inventory to `workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fmodule-manifest.json`:\n\n```json\n{\n  \"modules\": [\n    {\"path\": \"src\u002Fparser\", \"files\": 7, \"lines\": 1240, \"language\": \"rust\"},\n    {\"path\": \"src\u002Fhttp\", \"files\": 4, \"lines\": 680, \"language\": \"rust\"}\n  ]\n}\n```\n\n### Phase ST3: Prepare for Per-Unit Analysis\n\nOnce Phases ST1-ST2 have produced the survey and module manifest, each module is ready to be treated as the analyzable unit for the shape-neutral Phase 6. The analysis unit differs by target shape: in a bundle, the unit is a chunk from the split; in a source tree, it's a module as the language defines it. Both produce the same per-unit output format.\n\nPhases 6-8 (Per-Unit Analysis, Per-Function Deep Analysis, Targeted Extraction), described later in this skill, apply from here on.\n\n---\n\n## Bundle Pipeline\n\nThe Bundle Pipeline defines Phases B1-B5 (bundle-specific decomposition). After B5, control flows into the shape-neutral Phases 6-8 shared with the Source Tree Pipeline.\n\n```dot\ndigraph bundle_pipeline {\n    rankdir=TB;\n\n    \"Start (bundle target)\" [shape=doublecircle];\n    \"Phase B1: Beautify bundle\" [shape=box];\n    \"Phase B2: Find module boundaries\" [shape=box];\n    \"Phase B3: Extract chunks\" [shape=box];\n    \"Phase B4: Extract functions\" [shape=box];\n    \"Phase B5: Extract strings\" [shape=box];\n    \"→ Phase 6 (shape-neutral)\" [shape=box, style=filled, fillcolor=\"#f0f0f0\"];\n\n    \"Start (bundle target)\" -> \"Phase B1: Beautify bundle\";\n    \"Phase B1: Beautify bundle\" -> \"Phase B2: Find module boundaries\";\n    \"Phase B2: Find module boundaries\" -> \"Phase B3: Extract chunks\";\n    \"Phase B3: Extract chunks\" -> \"Phase B4: Extract functions\";\n    \"Phase B4: Extract functions\" -> \"Phase B5: Extract strings\";\n    \"Phase B5: Extract strings\" -> \"→ Phase 6 (shape-neutral)\";\n}\n```\n\nPhases B1-B5 are bundle decomposition. Phases 6-7 produce behavioral analysis and are shape-neutral. Phase 8 is optional targeted extraction.\n\nFor non-bundled targets, run the Source Tree Pipeline's Phases ST1-ST3 instead of this section's B1-B5, then flow into the same shape-neutral Phases 6-8.\n\n## Phase B1: Bundle Preparation\n\n### 1.1 Beautify if Needed\n\nCheck if the bundle is minified by comparing line count to byte count. A file with few lines but many bytes is minified.\n\n```bash\nLINE_COUNT=$(wc -l \u003C \"$BUNDLE\")\nBYTE_COUNT=$(wc -c \u003C \"$BUNDLE\")\nif [ \"$LINE_COUNT\" -lt 100 ] && [ \"$BYTE_COUNT\" -gt 100000 ]; then\n  echo \"Minified - needs beautification\"\n  mkdir -p workspace\u002Fraw\u002Fsource\n  BEAUTIFIED=\"workspace\u002Fraw\u002Fsource\u002Ftarget.js\"\n  if [ ! -f \"$BEAUTIFIED\" ]; then\n    npx js-beautify --type js -f \"$BUNDLE\" -o \"$BEAUTIFIED\"\n  fi\n  TARGET=\"$BEAUTIFIED\"\nelse\n  TARGET=\"$BUNDLE\"\nfi\n```\n\nAlways check for an existing beautified version before re-beautifying. Multiple agents may operate on the same bundle.\n\n### 1.2 Initial Survey\n\n```bash\n# Size and line count\nls -lh \"$TARGET\"\nwc -l \"$TARGET\"\n\n# Detect bundler type\nhead -100 \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fbundle-header.txt\ngrep -m1 \"webpack\\|esbuild\\|rollup\\|parcel\" \"$TARGET\" || echo \"Unknown bundler\"\n```\n\nWrite the survey to `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fsurvey.md`.\n\n## Phase B2: Find Module Boundaries\n\n### 2.1 Bundler-Specific Markers\n\n#### Webpack\n\n```bash\n# Module ID markers\ngrep -n \"^\u002F\\*\\*\\*\\*\\*\\*\u002F \\\"\" \"$TARGET\" > manifests\u002Fwebpack-modules.txt\n\n# Export declarations\ngrep -n \"__webpack_require__\\.d\\|__webpack_exports__\" \"$TARGET\" | head -100 > manifests\u002Fwebpack-exports.txt\n```\n\n#### esbuild\n\n```bash\n# esbuild source comments\ngrep -n \"^\u002F\u002F \" \"$TARGET\" | grep -v \"^\u002F\u002F $\" > manifests\u002Fesbuild-markers.txt\n```\n\n#### Generic IIFE Boundaries\n\n```bash\n# Function expression boundaries\ngrep -n \"^(function\\|^!function\\|^var [a-z]* = function\" \"$TARGET\" > manifests\u002Fiife-boundaries.txt\n```\n\n### 2.2 Heuristic Boundaries\n\nWhen no bundler-specific markers are found, fall back to heuristics:\n\n```bash\n# Long comment separators\ngrep -n \"^\u002F\\*\\*\\*\\*\\*\\*\\*\\*\" \"$TARGET\" > manifests\u002Fseparator-comments.txt\n\n# Export clusters\ngrep -n \"^exports\\.\\|^module\\.exports\" \"$TARGET\" > manifests\u002Fexport-points.txt\n\n# Large gaps (blank lines often separate modules)\nawk 'NF==0 {if(++blank>=3) print NR\": --- blank section ---\"} NF>0 {blank=0}' \"$TARGET\" | head -100\n```\n\n## Phase B3: Extract Chunks\n\n### 3.1 Split by Module Markers\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fchunks\n\n# Webpack-style split\ncsplit -f workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk- -n 4 \"$TARGET\" '\u002F^\\\u002F\\*\\*\\*\\*\\*\\*\\\u002F\u002F' '{*}' 2>\u002Fdev\u002Fnull\n\n# Fall back to line-count splitting if no clear markers\nif [ $(ls workspace\u002Fraw\u002Fsource\u002Fchunks\u002F | wc -l) -lt 5 ]; then\n  rm workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*\n  split -l 2000 \"$TARGET\" workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-\nfi\n\n# Rename to .js\nfor f in workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-*; do\n  [ \"${f%.js}\" = \"$f\" ] && mv \"$f\" \"${f}.js\"\ndone\n```\n\n### 3.2 Generate Chunk Manifest\n\n```bash\necho '{\"chunks\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n\nfor chunk in workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*.js; do\n  name=$(basename \"$chunk\")\n  lines=$(wc -l \u003C \"$chunk\")\n  size=$(wc -c \u003C \"$chunk\")\n\n  # Extract first meaningful identifier\n  first_func=$(grep -oP \"function [a-zA-Z_][a-zA-Z0-9_]*\" \"$chunk\" | head -1)\n  first_class=$(grep -oP \"class [a-zA-Z_][a-zA-Z0-9_]*\" \"$chunk\" | head -1)\n\n  echo \"  {\\\"file\\\": \\\"$name\\\", \\\"lines\\\": $lines, \\\"bytes\\\": $size, \\\"first_func\\\": \\\"$first_func\\\", \\\"first_class\\\": \\\"$first_class\\\"},\"\ndone >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fchunk-manifest.json\n```\n\n## Phase B4: Extract Functions\n\n### 4.1 Find Function Definitions\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Ffunctions\n\n# Named functions\ngrep -n \"function [a-zA-Z_][a-zA-Z0-9_]*\\s*(\" \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\n\n# Arrow function assignments\ngrep -n \"const [a-zA-Z_][a-zA-Z0-9_]* = (\" \"$TARGET\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\ngrep -n \"const [a-zA-Z_][a-zA-Z0-9_]* = async\" \"$TARGET\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-locations.txt\n```\n\n### 4.2 Extract Individual Functions\n\nExtract each significant function (more than 10 lines) to its own file:\n\n```bash\ncat > \u002Ftmp\u002Fextract_funcs.js \u003C\u003C 'EOF'\nconst fs = require('fs');\nconst code = fs.readFileSync(process.argv[2], 'utf8');\n\nconst funcPattern = \u002Ffunction\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([^)]*\\)\\s*\\{\u002Fg;\nlet match;\nlet funcId = 0;\nconst outDir = process.argv[3] || 'workspace\u002Fraw\u002Fsource\u002Ffunctions';\n\nwhile ((match = funcPattern.exec(code)) !== null) {\n  const name = match[1];\n  const start = match.index;\n  let depth = 1;\n  let i = code.indexOf('{', start) + 1;\n  while (depth > 0 && i \u003C code.length) {\n    if (code[i] === '{') depth++;\n    if (code[i] === '}') depth--;\n    i++;\n  }\n  const funcCode = code.slice(start, i);\n  if (funcCode.split('\\n').length > 10) {\n    fs.writeFileSync(\n      `${outDir}\u002Ffunc-${String(funcId++).padStart(4, '0')}-${name}.js`,\n      funcCode\n    );\n  }\n}\nEOF\nnode \u002Ftmp\u002Fextract_funcs.js \"$TARGET\" workspace\u002Fraw\u002Fsource\u002Ffunctions\n```\n\n### 4.3 Generate Function Manifest\n\n```bash\necho '{\"functions\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n\nfor func in workspace\u002Fraw\u002Fsource\u002Ffunctions\u002F*.js; do\n  name=$(basename \"$func\" .js)\n  lines=$(wc -l \u003C \"$func\")\n  params=$(grep -oP \"function[^(]*\\([^)]*\\)\" \"$func\" | head -1)\n  echo \"  {\\\"file\\\": \\\"$name\\\", \\\"lines\\\": $lines, \\\"signature\\\": \\\"$params\\\"},\"\ndone >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Ffunction-manifest.json\n```\n\n## Phase B5: String Extraction\n\n### 5.1 Catalog All Strings\n\n```bash\nmkdir -p workspace\u002Fraw\u002Fsource\u002Fmanifests\n\n# Extract all strings with line numbers (minimum 5 chars)\ngrep -noP '\"[^\"]{5,}\"' \"$TARGET\" > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt\n\n# Categorize\ngrep -P '\"https?:\u002F\u002F' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-urls.txt\ngrep -P '\"[A-Z][A-Z_]{3,}\"' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-constants.txt\ngrep -P '\"--[a-z]' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-cli-flags.txt\ngrep -P '\"Error|Failed|Warning' workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-raw.txt > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstrings-errors.txt\n```\n\n### 5.2 Map Strings to Chunks\n\n```bash\necho '{\"string_locations\": [' > workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n\nfor chunk in workspace\u002Fraw\u002Fsource\u002Fchunks\u002F*.js; do\n  name=$(basename \"$chunk\")\n  echo \"  {\\\"chunk\\\": \\\"$name\\\", \\\"strings\\\": [\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n  grep -oP '\"[^\"]{10,}\"' \"$chunk\" | head -20 | while read str; do\n    echo \"    $str,\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n  done\n  echo \"  ]},\" >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\ndone\n\necho ']}' >> workspace\u002Fraw\u002Fsource\u002Fmanifests\u002Fstring-manifest.json\n```\n\n## Phase 6: Per-Unit Analysis (all source shapes)\n\nRun this analysis once per analyzable unit. What counts as a \"unit\" depends on target shape:\n- **Bundle target:** a chunk file from Phase 3, e.g. `workspace\u002Fraw\u002Fsource\u002Fchunks\u002Fchunk-0042.js`\n- **Source tree:** a source file or small module from Phase 3, e.g. `src\u002Fparser\u002Flexer.py` or `src\u002Fhttp\u002Fhandler.go`\n- **Decompiled binary:** a decompiled source file from the Decompilation Path\n\n`$UNIT` in the examples below is the path to the unit being analyzed. Grep patterns use conventions common in several languages; adjust to the target language's idioms.\n\n### Exhaustive Reading Requirement (CRITICAL)\n\n**You MUST read every single line of the unit. No exceptions.**\n\n- Do NOT skim. Do NOT skip sections that \"look like boilerplate.\"\n- The grep patterns below are for INDEXING, not for UNDERSTANDING.\n- After running greps, you MUST read the full unit file.\n- Every routine (function, method, class) must be identified and catalogued.\n- Every line must be accounted for.\n\n**Verification checklist before writing analysis:**\n- [ ] I read the ENTIRE unit, not just samples\n- [ ] I identified EVERY function\u002Fmethod\u002Fclass in the unit\n- [ ] I understand what EVERY section of code does\n\n### 6.1 Initial Survey (Then Read in Full)\n\n```bash\nwc -l \"$UNIT\"            # Know the size\nhead -50 \"$UNIT\"         # Get oriented\ntail -20 \"$UNIT\"         # See the end\ncat \"$UNIT\"              # READ THE ENTIRE FILE\n```\n\n### 6.2 Identify Behaviors\n\n```bash\n# Domain indicators (informative strings are clues in any language)\ngrep -oE '\"[a-zA-Z]{5,}\"' \"$UNIT\" | sort | uniq -c | sort -rn | head -20\n\n# Error messages\ngrep -oE '\"[^\"]*[Ee]rror[^\"]*\"' \"$UNIT\" | sort -u\n\n# Common action verbs in method\u002Ffunction invocations\ngrep -oE '\\.(read|write|send|receive|parse|validate|handle|process|create|delete|update)\\(' \"$UNIT\" | sort | uniq -c\n```\n\n### 6.3 Catalog Capabilities\n\nUse language-appropriate declaration patterns. Read the matches; don't rely on the grep counts alone.\n\n```bash\n# JavaScript \u002F TypeScript\ngrep -oE \"function [a-zA-Z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"(const|let|var) [a-zA-Z_][a-zA-Z0-9_]* = (async )?(function|\\()\" \"$UNIT\"\ngrep -oE \"class [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"exports\\.[a-zA-Z_]+|export (const|function|class|default)\" \"$UNIT\"\n\n# Python\ngrep -oE \"^(async )?def [a-zA-Z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"^class [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Go\ngrep -oE \"^func (\\([^)]+\\) )?[A-Za-z_][A-Za-z0-9_]*\" \"$UNIT\"\ngrep -oE \"^type [A-Z][a-zA-Z0-9_]* \" \"$UNIT\"\n\n# Rust\ngrep -oE \"^(pub )?fn [a-z_][a-z0-9_]*\" \"$UNIT\"\ngrep -oE \"^(pub )?(struct|enum|trait) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Swift\ngrep -oE \"^(public |private |internal )?func [a-z_][a-zA-Z0-9_]*\" \"$UNIT\"\ngrep -oE \"^(public |private |internal )?(class|struct|enum|protocol|actor) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n\n# Java \u002F Kotlin\ngrep -oE \"^(public |private )?(class|interface|enum) [A-Z][a-zA-Z0-9_]*\" \"$UNIT\"\n```\n\n### 6.4 Find Dependencies\n\n```bash\n# JavaScript \u002F TypeScript\ngrep -oE \"require\\(['\\\"][^'\\\"]+['\\\"]\\)|from ['\\\"][^'\\\"]+['\\\"]\" \"$UNIT\"\n\n# Python\ngrep -oE \"^(from [a-zA-Z_][a-zA-Z0-9_.]* )?import [a-zA-Z_][a-zA-Z0-9_., ]*\" \"$UNIT\"\n\n# Rust\ngrep -oE \"^use [a-zA-Z_][a-zA-Z0-9_:]+\" \"$UNIT\"\n\n# Swift\ngrep -oE \"^import [A-Z][A-Za-z0-9_]*\" \"$UNIT\"\n\n# Java \u002F Kotlin\ngrep -oE \"^import [a-z][a-zA-Z0-9_.]+\" \"$UNIT\"\n\n# Go: import blocks span multiple lines; read them from the file header\nhead -50 \"$UNIT\" | awk '\u002F^import [(\\\"]\u002F,\u002F^\\)$\u002F'\n```\n\n### 6.5 Data Flow\n\nLook for I\u002FO, state mutations, and event\u002Fsignal interaction. The specific idioms vary by language and framework:\n\n```bash\n# I\u002FO operations — common verbs across many languages\ngrep -nE \"\\.(read|write|get|set|load|save|fetch|send)\\b\" \"$UNIT\" | head -20\n\n# Event \u002F signal \u002F pub-sub shapes (varies by language and framework):\n#   Node EventEmitter:         .on('name', ...), .emit('name', ...)\n#   Python pyee \u002F blinker:      .connect(...), .send(...)\n#   Rust tokio \u002F crossbeam:    .notify(...), .subscribe(...)\n#   Swift NotificationCenter:  .post(name:...), .addObserver(...)\n#   Generic pub\u002Fsub:            .publish(...), .subscribe(...), .dispatch(...)\ngrep -nE \"\\.(on|emit|connect|notify|subscribe|publish|post|dispatch)\\(\" \"$UNIT\" | head -20\n```\n\n### 6.6 Output Template\n\nWrite the analysis to a path that mirrors the unit's origin:\n- Bundle target → `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002F\u003Cchunk-name>.md`\n- Source tree → `workspace\u002Fraw\u002Fsource\u002Fanalysis\u002F\u003Cmodule-or-file-path>.md`\n\n```markdown\n# Unit Analysis: \u003Cunit name>\n\n## Behavioral Summary\n[1-2 sentences: What does this unit DO from a user\u002Fsystem perspective?]\n\n## Key Behaviors Identified\n\n### [Behavior 1 Name]\n- **What it does**: [behavioral description]\n- **Inputs**: [what it accepts]\n- **Outputs**: [what it produces]\n- **Evidence**: [function names, strings that indicate this]\n\n### [Behavior 2 Name]\n- **What it does**: [behavioral description]\n- **Inputs**: [what it accepts]\n- **Outputs**: [what it produces]\n- **Evidence**: [function names, strings that indicate this]\n\n## Data Handled\n- Reads: [what data it reads]\n- Writes: [what data it writes]\n- Transforms: [what transformations it performs]\n\n## Error Conditions\n- [Error 1]: \"[exact error message]\" - when [condition]\n- [Error 2]: \"[exact error message]\" - when [condition]\n\n## Dependencies\n- External: [third-party packages or libraries]\n- Internal: [other units it references]\n\n## Domain Indicators\nKey strings that reveal purpose:\n[informative strings]\n\n## Module Guess\nThis unit likely belongs to the **[module name]** module because:\n- [reason 1]\n- [reason 2]\n\n## Needs Deep Dive?\n- [ ] Yes - complex behavior requiring full spec\n- [ ] No - utility code, can be summarized\n\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| [behavioral claim] | \u003Cunit>:{line} | inferred |\n```\n\n## Phase 7: Per-Function Deep Analysis (all source shapes)\n\nRun this deep analysis once per significant function or method. Each pass analyzes a single routine exhaustively. `$FUNC` is the path to a file containing the routine:\n- **Bundle target:** an extracted-function file from Phase B4, e.g. `workspace\u002Fraw\u002Fsource\u002Ffunctions\u002Ffunc-0007-parseConfig.js`.\n- **Source tree:** either the containing source file (if small) or a single-routine extraction. For long source files, slice out the routine into a tmp file before analysis so that greps scope to the routine and not to the whole module.\n- **Decompiled binary:** same options as source tree — decompiled code lives on disk as files, so treat it accordingly.\n\n### Exhaustive Reading Requirement (CRITICAL)\n\n**You MUST read every single line of the function. No exceptions.**\n\n- Do NOT skim. Read every statement.\n- The grep patterns help you INDEX what you find -- they are NOT a substitute for reading.\n- Every line of code must be understood.\n- Every conditional branch must be traced.\n- Every side effect must be identified.\n\n**Verification checklist before writing analysis:**\n- [ ] I read the ENTIRE function, line by line\n- [ ] I understand what EVERY statement does\n- [ ] I traced EVERY conditional branch\n- [ ] I identified EVERY side effect\n\n### 7.1 Identify Signature and Parameters\n\nRead the routine's first lines; the signature is in the declaration. Common shapes:\n- JavaScript\u002FTypeScript: `function name(params)`, `const name = (params) =>`, `async name(params) {`\n- Python: `def name(params):`, `async def name(params):`\n- Go: `func name(params) returns`, `func (receiver) name(params) returns`\n- Rust: `fn name(params) -> Return`, `pub fn name\u003CT>(params) -> Return`\n- Swift: `func name(params) -> Return`, `public func name(params) async throws -> Return`\n- Java\u002FKotlin: `public Return name(params)`, `fun name(params): Return`\n\n### 7.2 Trace Data Flow\n\n```bash\n# Parameter identifiers (lowercase tokens are often variables\u002Fparams)\ngrep -oE '\\b[a-z][a-zA-Z0-9_]*\\b' \"$FUNC\" | sort | uniq -c | sort -rn | head -20\n\n# Return points\ngrep -nE \"^\\s*return\\b\" \"$FUNC\"\n\n# Call sites (invocations — reads across most languages)\ngrep -oE \"[a-zA-Z_][a-zA-Z0-9_]*\\s*\\(\" \"$FUNC\" | sort | uniq -c | sort -rn | head -20\n```\n\n### 7.3 Identify Side Effects\n\nIdioms are language-specific; adapt:\n\n```bash\n# File I\u002FO — common names across languages\ngrep -nE \"\\b(read|write|open|close|unlink|remove|mkdir|makedirs|rename)_?[A-Za-z]*\\(\" \"$FUNC\"\n\n# Network I\u002FO\ngrep -nE \"\\b(fetch|request|Get|Post|Send|httpGet|urlopen|reqwest|URLSession)\\b\" \"$FUNC\"\n\n# State mutations\ngrep -nE \"\\.(set|push|append|insert|splice|extend|add|update)\\(|^\\s*[a-zA-Z_][a-zA-Z0-9_.]*\\s*=[^=]\" \"$FUNC\"\n\n# Logging\ngrep -nE \"\\b(console\\.|log\\.|logger\\.|println!|eprintln!|log\\.Printf|logrus\\.|zap\\.)\" \"$FUNC\"\n```\n\n### 7.4 Error Handling\n\nIdioms differ by language — error values in Go and Rust; exceptions in Python, Java, JavaScript, Swift:\n\n```bash\n# Exception-based (JS\u002FPython\u002FJava\u002FSwift)\ngrep -nE \"\\b(throw|raise)\\b\" \"$FUNC\"\ngrep -cE \"\\b(try|catch|except|finally)\\b\" \"$FUNC\"\n\n# Error-value-based (Go, Rust)\ngrep -nE \"\\breturn .*err\\b|\\\\?$|\\\\?;\" \"$FUNC\"\ngrep -nE \"\\bif err != nil\\b|\\\\bResult\u003C|\\\\bOption\u003C\" \"$FUNC\"\n\n# Guard clauses \u002F precondition checks\ngrep -nE \"\\bif\\s+(err|e|not|!|.*is None|.*== nil)\\b\" \"$FUNC\"\n```\n\n### 7.5 Control Flow\n\n```bash\n# Conditionals\ngrep -c \"if (\" \"$FUNC\"\ngrep -c \"else\" \"$FUNC\"\n\n# Loops\ngrep -c \"for (\\|while (\\|\\.forEach\\|\\.map\\|\\.filter\" \"$FUNC\"\n\n# Early returns\ngrep -n \"return\" \"$FUNC\" | head -10\n```\n\n### 7.6 Output Template\n\nWrite to `workspace\u002Fraw\u002Fsource\u002Ffunctions\u002F\u003Cmodule-or-unit>\u002F\u003Cfunction-name>.md`:\n\n```markdown\n# Function: [name]\n\n## Signature\n[function signature with parameters]\n\n## Purpose\n[1-2 sentences: What does this function do?]\n\n## Parameters\n| Name | Inferred Type | Purpose |\n|------|---------------|---------|\n| param1 | string | [what it's used for] |\n\n## Return Value\n- Type: [inferred]\n- Description: [what it returns]\n\n## Behavior\n\n### Normal Path\n1. [First thing it does]\n2. [Second thing it does]\n3. [Returns X]\n\n### Error Paths\n- If [condition]: throws [error] \u002F returns [value]\n- If [condition]: [behavior]\n\n## Side Effects\n- [ ] Modifies parameters\n- [ ] Writes to files\n- [ ] Makes network calls\n- [ ] Mutates external state\n- [ ] Logs output\n\nDetails:\n- [specific side effect 1]\n- [specific side effect 2]\n\n## Dependencies\nCalls these functions:\n- `funcName()` - [purpose]\n- `otherFunc()` - [purpose]\n\n## Key Strings\n[strings that reveal purpose]\n\n## Complexity\n- Lines: [X]\n- Conditionals: [X]\n- Loops: [X]\n- Nested depth: [estimate]\n\n## Behavioral Specification\n\n**Given:** [preconditions]\n**When:** function is called with [inputs]\n**Then:** [outputs and side effects]\n\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| [behavioral claim] | \u003Cfunction-file>:{line} | inferred |\n```\n\n## Phase 8: Targeted Module Extraction\n\nWhen you need focused analysis of a specific component of the target (e.g., \"HTTP parser\", \"error handling\", \"configuration loader\"), rather than analyzing everything in depth. In a bundle, the component is a module identified in Phase B2. In a source tree, it's a named package or directory. In a decompiled binary, it's whichever decompiled files correspond to the focus area. \n\n### 8.1 Scope Assessment\n\nGet a rough sense of how much code relates to the focus area:\n\n```bash\n# Count matches for focus-related terms\ngrep -c \"$FOCUS_TERMS\" \"$TARGET\"\n\n# Find which line ranges contain clusters of matches\ngrep -n \"$FOCUS_TERMS\" \"$TARGET\" | awk -F: '{print int($1\u002F100)*100}' | sort -n | uniq -c | sort -rn | head -20\n```\n\nThis reveals which 100-line regions are most relevant.\n\n### 8.2 String Constant Discovery\n\nStrings are NEVER minified and reveal the most about behavior:\n\n```bash\ngrep -oE '\"[^\"]{3,80}\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fstrings.md`.\n\n### 8.3 Identifier Discovery\n\nNamed identifiers (functions, classes, properties) often survive minification:\n\n```bash\n# Named functions\ngrep -oE \"function [a-zA-Z_]\\w*\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Property assignments (method definitions)\ngrep -oE \"\\.[a-zA-Z_]\\w*\\s*=\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Class definitions\ngrep -oE \"class [a-zA-Z_]\\w*\" \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fidentifiers.md`.\n\n### 8.4 Code Section Extraction\n\nFor each cluster of focus-area matches, extract surrounding code with enough context to understand the logic (50-100 lines around matches):\n\n```bash\ngrep -n \"$FOCUS_TERM\" \"$TARGET\" | head -30 | while read match; do\n  LINE=$(echo \"$match\" | cut -d: -f1)\n  START=$((LINE - 50))\n  END=$((LINE + 50))\n  [ \"$START\" -lt 1 ] && START=1\n  sed -n \"${START},${END}p\" \"$TARGET\"\n  echo \"--- END EXTRACT (lines $START-$END) ---\"\ndone\n```\n\nFor each extracted section, read and understand it, then write a summary to `$OUTPUT_DIR\u002Fsections\u002Fsection-NNN.md` with:\n- Line range in beautified file\n- What this section does (behavioral description)\n- Key identifiers and strings found\n- Connections to other sections\n- Open questions\n\n### 8.5 URL and API Endpoint Extraction\n\n```bash\ngrep -oE '\"https?:\u002F\u002F[^\"]*\"' \"$TARGET\" | sort -u\ngrep -oE '\"wss?:\u002F\u002F[^\"]*\"' \"$TARGET\" | sort -u\ngrep -oE '\"\u002F[a-z][a-z0-9\u002F._-]*\"' \"$TARGET\" | grep -v '\\.(js|css|html|png|svg)' | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fendpoints.md`.\n\n### 8.6 Data Structure Extraction\n\n```bash\n# Object literals with focus-area properties\ngrep -oE '\\{[^{}]{10,200}\\}' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | head -30\n\n# Property chains revealing structure\ngrep -oE '\\.\\w+\\.\\w+\\.\\w+' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort | uniq -c | sort -rn | head -30\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Fdata-structures.md`.\n\n### 8.7 Error Messages and States Extraction\n\n```bash\n# Error strings\ngrep -oE '\"[^\"]*[Ee]rror[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\ngrep -oE '\"[^\"]*[Ff]ail[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n\n# Status\u002Fstate strings\ngrep -oE '\"[^\"]*[Ss]tatus[^\"]*\"' \"$TARGET\" | grep -i \"$FOCUS_PATTERN\" | sort -u\n```\n\nWrite immediately to `$OUTPUT_DIR\u002Ferrors-and-states.md`.\n\n### 8.8 Contextual Analysis\n\nAfter extraction, read the extracted sections and produce a synthesis covering:\n\n- **Connection map** -- which sections reference each other; trace call flows and data flows between sections\n- **State machine** -- if the module manages state, document the states and transitions observed\n- **Protocol\u002Fmessage catalog** -- if the module involves communication, catalog all message types, their fields, and when they are sent\u002Freceived\n- **Configuration points** -- what settings, constants, or configuration values affect this module's behavior\n\nWrite synthesis to `$OUTPUT_DIR\u002Fanalysis.md`.\n\n### 8.9 Findings Report\n\nWrite comprehensive findings to `$OUTPUT_DIR\u002Ffindings.md`:\n\n```markdown\n# Targeted Extractor Findings: [Focus Area]\n\n## Target\n- Source: [path or module identifier]\n- Focus: [area]\n\n## Summary\n[2-3 paragraph overview of what was found]\n\n## Key Components\n### [Component 1]\n- Purpose: [what it does]\n- Location: [file:line range or module\u002Fpackage path]\n- Key identifiers: [list]\n- Key strings: [list]\n\n## Data Model\n[Key data structures and their fields]\n\n## Protocol \u002F API\n[If applicable: endpoints, message types, wire format]\n\n## State Management\n[If applicable: states, transitions, persistence]\n\n## Configuration\n[Settings that affect behavior]\n\n## Error Conditions\n[What can go wrong and how it's handled]\n\n## Open Questions\n[Things that need further investigation]\n\n## Cross-References\n[How this component relates to others in the target]\n```\n\n## Provenance Rules\n\n### Source Type\n\nAll claims from source code analysis use `source=source-code`:\n\n```markdown\n- Sessions expire after 30 minutes of inactivity\n  \u003C!-- cite: source=source-code, ref=workspace\u002Fraw\u002Fsource\u002Fanalysis\u002Fchunk-0011.md:34, confidence=inferred -->\n```\n\n### Single-Source Analysis\n\nWhen analysis draws on a single source (the source code), Confidence is typically `inferred` because there is only one source to draw from.\n\n### Confidence Levels\n\n- **confirmed** -- exact literal or API call visible in source, OR corroborated by a second independent source (e.g., runtime observation agrees with source reading)\n- **inferred** -- derived from code logic; single authoritative source provides direct evidence\n- **assumed** -- based on naming convention, comment text, or structural reasoning; not verified against observable behavior\n\n### Cite As You Go\n\nEvery behavioral claim gets an inline citation immediately after the claim. Do NOT batch citations at the end of analysis. The moment you write a behavioral assertion, the very next thing you write is the `\u003C!-- cite: -->` comment.\n\n### Key Claims Table\n\nEnd each analysis file with a Key Claims table:\n\n```markdown\n## Key Claims\n\n| Claim | Source Location | Confidence |\n|-------|----------------|------------|\n| Handles session timeout at 30 min | \u003Cunit>:145 | inferred |\n| Uses AES-256-GCM for encryption | \u003Cunit>:302 | confirmed |\n| Salt length is a fixed 16 bytes | \u003Cfunction-file>:{line} | inferred |\n```\n\nThis table is how downstream verification agents trace claims back to source.\n\n## Output Structure\n\nOutput layout varies by target shape.\n\n### Bundle target\n\n```\nworkspace\u002Fraw\u002Fsource\u002F\n    target.js                    # Original (beautified) bundle\n    chunks\u002F                      # Split modules\n        chunk-0001.js\n        chunk-0002.js\n        ...\n    functions\u002F                   # Extracted individual functions (>10 lines each)\n        func-0001-processMessage.js\n        func-0002-handleRequest.js\n        ...\n    manifests\u002F                   # Inventories\n        chunk-manifest.json\n        function-manifest.json\n        string-manifest.json\n        strings-raw.txt\n        strings-urls.txt\n        strings-constants.txt\n        strings-cli-flags.txt\n        strings-errors.txt\n        function-locations.txt\n    analysis\u002F                    # Per-chunk behavioral analysis\n        survey.md\n        chunk-0001.md\n        chunk-0002.md\n        ...\n        functions\u002F               # Per-function behavioral analysis\n            func-0001.md\n            func-0002.md\n            ...\n    exploration\u002F                 # Targeted explorations by focus area\n        {focus-area}\u002F\n            strings.md\n            identifiers.md\n            sections\u002F\n                section-001.md\n                section-002.md\n                ...\n            endpoints.md\n            data-structures.md\n            errors-and-states.md\n            analysis.md\n            findings.md\n```\n\n### Source tree target\n\n```\nworkspace\u002Fraw\u002Fsource\u002F\n    manifests\u002F\n        module-manifest.json     # List of modules, files, lines, language\n    analysis\u002F                    # Per-module behavioral analysis\n        survey.md\n        \u003Cmodule-path-1>.md       # e.g. src-parser-lexer.md\n        \u003Cmodule-path-2>.md\n        ...\n    functions\u002F                   # Per-function analyses, grouped by module\n        \u003Cmodule-path>\u002F\n            \u003Cfunction-name>.md\n            ...\n    exploration\u002F                 # Targeted explorations by focus area\n        {focus-area}\u002F\n            findings.md\n```\n\nThe module-path convention flattens the source tree into filenames (e.g., `src\u002Fparser\u002Flexer.py` → `src-parser-lexer.md`) so the analysis directory stays flat and greppable.\n\n### Decompiled binary target\n\nDecompiled binaries are handled by first writing decompiled source to `workspace\u002Fraw\u002Fsource\u002Fdecompiled\u002F` (preserving the decompiler's output layout), then running the shape-appropriate pipeline above: if the decompiled output is a single large file, treat it as a bundle; if the decompiler produced a tree of files, treat it as a source tree.\n\n## Rules\n\n1. **WRITE AS YOU GO** -- every finding goes to a file immediately. Do not accumulate findings in your head. Use the Write tool the moment you have something to record.\n2. **Focus on BEHAVIOR not IMPLEMENTATION** -- write \"handles authentication\" not \"calls authLib.verify()\". Describe what the code DOES, not how it is structured.\n3. **No raw source code excerpts longer than one line** -- behavioral output must not contain multi-line code snippets. Single-line references are acceptable as evidence.\n4. **Flag behavioral complexity** -- note what needs deep-dive analysis. Mark chunks and functions that exhibit complex state management, protocol handling, or multi-step workflows.\n5. **Reuse beautified code** -- before beautifying, check if a beautified version already exists at `workspace\u002Fraw\u002Fsource\u002Ftarget.js`. Multiple workers share this file.\n6. **Exhaustive reading is mandatory** -- grep patterns are for indexing, not understanding. After running greps, you MUST read the full source. Every function, method, class, and code path must be identified.\n7. **Cite as you go** -- every behavioral claim gets an inline `\u003C!-- cite: -->` comment immediately after the claim. Never defer citation to a later step.\n8. **One chunk\u002Ffunction per invocation** -- process one chunk or one function per pass. Stay focused.\n9. **Be targeted in exploration** -- stay focused on the requested component. Do not analyze the entire target when only one component is needed.\n10. **Note line numbers** -- in the beautified file, so sections can be found again by downstream workers and verification.\n",{"name":5,"description":7},"main","e62d23e713a36a0570f7f5c3ee69868b1131e548","src\u002Fresources\u002Fskills\u002Fexcavate-source-analysis","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli","https:\u002F\u002Fgithub.com\u002Fcmetech","https:\u002F\u002Fwww.cmetech.io","Corey Ellis is a seasoned data engineer with over 20 years of experience in the field. He is the founder of CME Technologies LLC.","2026-06-17 22:50:56",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add cmetech\u002Fotto-cli --skill excavate-source-analysis",{"tool":38,"command":39},"bunx","bunx skills add cmetech\u002Fotto-cli --skill excavate-source-analysis",{"tool":41,"command":42},"pnpm","pnpm dlx skills add cmetech\u002Fotto-cli --skill excavate-source-analysis","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fexcavate-source-analysis\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M74PWE6AVSD8RDS1M3Q6TH95","write-milestone-brief","Synthesize the current conversation into a milestone brief (PRD). Writes to `M###-CONTEXT.md` by default, or files a GitHub issue only with explicit user confirmation. Use when asked to \"turn this into a PRD\", \"draft a milestone brief\", \"capture this context\", \"write it up\", or when enough has been discussed to commit the plan to paper. Does not interview — it synthesizes what is already known.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fwrite-milestone-brief\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M74PWB6CEEQPGS9HRQY4QQPZ","write-docs","Collaborative document authoring workflow for proposals, technical specs, decision docs, README sections, ADRs, and long-form prose that must work for fresh readers. Use when asked to \"write the docs\", \"draft a proposal\", \"write a spec\", \"write an RFC\", \"write the README\", or when a document needs to be understandable by someone without this session's context. Three stages: gather context, iterate on structure, reader-test for a stranger.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fwrite-docs\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M74PW7SJQ8H516MDBQ7WV1BN","web-quality-audit","Comprehensive web quality audit covering performance, accessibility, SEO, and best practices. Use when asked to \"audit my site\", \"review web quality\", \"run lighthouse audit\", \"check page quality\", or \"optimize my website\".","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fweb-quality-audit\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M74PW5JAA6D34Z8QBN1HQ014","web-design-guidelines","Review UI code for Web Interface Guidelines compliance. Use when asked to \"review my UI\", \"check accessibility\", \"audit design\", \"review UX\", or \"check my site against best practices\".","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fweb-design-guidelines\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M74PW1YP2Y03GMDYD443BVHQ","verify-before-complete","Block completion claims until verification evidence has been produced in the current message. Use before marking a task\u002Fslice\u002Fmilestone complete, before creating a commit or PR, before saying \"it works\" or \"tests pass\", and any time you are about to claim work is done. The rule is: evidence before claims, always — running the verification must happen now, not \"earlier in the session\". Fresh output or no claim.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fverify-before-complete\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M74PVXR5GE8HE55YWEG7ENBP","userinterface-wiki","UI\u002FUX best practices for web interfaces. Use when reviewing animations, CSS, audio, typography, UX patterns, prefetching, or icon implementations. Covers 11 categories from animation principles to typography. Outputs file:line findings.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fuserinterface-wiki\u002FSKILL.md",[],[]]