[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BZX27KN8YVNREP7MH4R80H":3,"skill-same:01M7BZX27KN8YVNREP7MH4R80H":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7BZX27KN8YVNREP7MH4R80H","source-analysis",null,"Layer 1 skill for source code analysis — 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.","zak-keown\u002Fmoe","zak-keown","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F320717241?v=4","01M7BZFXME0NW6TQX0H7AZM2KS","01M7BZFXN32VR0JN5AATRD53H4",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe-backstory\u002F.claude-plugin\u002Fskills\u002Fsource-analysis\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: source-analysis\ndescription: Layer 1 skill for source code analysis — 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\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 bundle-splitter; 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 infrastructure (bundle-splitter). Phases 6-7 produce behavioral analysis (chunk-analyzer, function-analyzer) and are shape-neutral. Phase 8 is optional targeted extraction (targeted-extractor).\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\nThe chunk-analyzer agent runs 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\nThe function-analyzer agent runs once per significant function or method. Each invocation 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. This phase is driven by the targeted-extractor agent.\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, agent=chunk-analyzer -->\n```\n\n### Layer 1 Agents -- Single Source\n\nTargeted-extractor, chunk-analyzer, and function-analyzer are Layer 1 agents. They examine 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 agents 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** -- chunk-analyzer processes one chunk. function-analyzer processes one function. Stay focused.\n9. **Be targeted in exploration** -- the targeted-extractor stays 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 agents and verification.\n","# Source Analysis Methodology\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 bundle-splitter; 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 infrastructure (bundle-splitter). Phases 6-7 produce behavioral analysis (chunk-analyzer, function-analyzer) and are shape-neutral. Phase 8 is optional targeted extraction (targeted-extractor).\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\nThe chunk-analyzer agent runs 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\nThe function-analyzer agent runs once per significant function or method. Each invocation 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. This phase is driven by the targeted-extractor agent.\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, agent=chunk-analyzer -->\n```\n\n### Layer 1 Agents -- Single Source\n\nTargeted-extractor, chunk-analyzer, and function-analyzer are Layer 1 agents. They examine 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 agents 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** -- chunk-analyzer processes one chunk. function-analyzer processes one function. Stay focused.\n9. **Be targeted in exploration** -- the targeted-extractor stays 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 agents and verification.\n",{"name":5,"description":7},"main","728894f3f85fbd4e788f015ddfd72bb6155d5dd5","plugins\u002Fmoe-backstory\u002F.claude-plugin\u002Fskills\u002Fsource-analysis",1,"https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe","https:\u002F\u002Fgithub.com\u002Fzak-keown","2026-09-05 06:29:06",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add zak-keown\u002Fmoe --skill source-analysis",{"tool":36,"command":37},"bunx","bunx skills add zak-keown\u002Fmoe --skill source-analysis",{"tool":39,"command":40},"pnpm","pnpm dlx skills add zak-keown\u002Fmoe --skill source-analysis","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe-backstory\u002F.claude-plugin\u002Fskills\u002Fsource-analysis\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M7C1Z5362Y8NVRZ69HWP0ZD0","write-skill","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fwrite-skill\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":18},"01M7C1YZ9966WK9R6ZRPCGWF3G","write-plan","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fwrite-plan\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M7C1YMR4SJD7BPBBPXZCVGVH","write-clearly","Apply Strunk's timeless writing rules to ANY prose humans will read—documentation, commit messages, error messages, explanations, reports, or UI text. Makes your writing clearer, stronger, and more professional.","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fwrite-clearly\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7C1YH9805YSM0N20VQAVSXF","windows-vm","Create, manage, or connect to a headless Windows 11 VM running in Docker with SSH access. Use when the user wants to spin up, stop, restart, or SSH into a Windows VM.","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fwindows-vm\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7C1YD87SCNEJ2C9B8HFR2NQ","verify-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating MRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fverify-completion\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M7C1YARDEHT0TJ9BRG30ZCF4","using-moe","Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions","https:\u002F\u002Fgithub.com\u002Fzak-keown\u002Fmoe\u002Fblob\u002Fmain\u002Fplugins\u002Fmoe\u002Fskills\u002Fusing-moe\u002FSKILL.md",[],[]]