[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111295":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":10,"openIssues":11,"contributorsCount":11,"subscribersCount":11,"size":11,"stars1d":11,"stars7d":11,"stars30d":11,"stars90d":11,"forks30d":11,"starsTrendScore":11,"compositeScore":12,"rankGlobal":8,"rankLanguage":8,"license":13,"archived":14,"fork":14,"defaultBranch":15,"hasWiki":16,"hasPages":14,"topics":17,"createdAt":8,"pushedAt":18,"updatedAt":19,"readmeContent":20,"aiSummary":21,"trendingCount":11,"starSnapshotCount":11,"syncStatus":22,"lastSyncTime":23,"discoverSource":24},111295,"code-master","streaxrxoutlook-coder\u002Fcode-master","streaxrxoutlook-coder",null,"Python",60,0,37,"MIT License",false,"main",true,[],"2026-11-05 11:41:58","2026-11-05 11:49:31","# code-master\n\n本地、确定性的代码情报. 复杂度、依赖、type-2 克隆、上下文预算. 零运行时依赖, 不出网, 同一棵树得到同一份报告.\n\nA local code-intelligence engine. Each number names the paper it comes from, and the report names the cases the scanner does not cover. Python 3.11 or newer. The standard library is the whole runtime.\n\n## Install\n\n```bash\npip install -e .\ncode-master scan .\n```\n\n`pip install -e \".[dev]\"` adds pytest and mypy. CI installs that extra, runs mypy, runs pytest, then runs `code-master scan src`, on Python 3.11, 3.12, and 3.13.\n\n`code-master` exits 0, or 2 when the path does not exist. `NO_COLOR` disables color. `--json` writes schema `code-master.report.v1`. `brief` writes schema `code-master.brief.v1`.\n\n## Commands\n\n| command | the question it answers |\n| --- | --- |\n| `scan` | Where is the control flow dense? McCabe, nesting, Halstead, maintainability. |\n| `graph` | Who depends on whom? Tarjan cycles, PageRank hubs, Martin instability. |\n| `clones` | Which stretches are the same program with the names swapped? |\n| `budget` | What fits in a context window, and what should be read first? |\n| `brief` | One markdown document a reviewer or a model can take whole. |\n\n```bash\ncode-master scan .\ncode-master graph .\ncode-master clones .\ncode-master budget . --window 8000\ncode-master brief . -o BRIEF.md\n```\n\nThe scanner covers Python, JavaScript, TypeScript, Go, Rust, Java, Kotlin, C, C++, C#, Swift, PHP, Ruby, and SQL. Markdown, TOML, YAML, and JSON are budgeted and not measured.\n\n## What it says about itself\n\nThe blocks below are this tree, measured by the tool that ships in it.\n\n### `code-master scan . --top 8`\n\n```text\ncode-master 0.1.0   14 files   2,818 sloc   python   mi median 58.3  mean 61.8\n\nhotspots\n  !   1.03  cc 239  nest 6   mi  51.4  src\u002Fcode_master\u002Fgraph.py\n  !   0.67  cc 284  nest 6   mi  60.9  src\u002Fcode_master\u002Fscan.py\n      0.59  cc 66   nest 7   mi  54.6  src\u002Fcode_master\u002Fclones.py\n      0.27  cc 55   nest 4   mi  46.6  src\u002Fcode_master\u002Fbudget.py\n      0.25  cc 65   nest 4   mi  52.8  src\u002Fcode_master\u002Frender.py\n      0.10  cc 13   nest 3   mi  55.7  examples\u002Fclone_a.py\n     -0.06  cc 10   nest 3   mi  75.9  examples\u002Fclone_b.py\n     -0.27  cc 24   nest 4   mi  47.4  src\u002Fcode_master\u002Fanalyze.py\n\nfunctions\n  cc 40   nest 5   src\u002Fcode_master\u002Fscan.py:906  def _looks_like_function\n  cc 30   nest 5   src\u002Fcode_master\u002Fscan.py:650  def _try_number\n  cc 26   nest 7   src\u002Fcode_master\u002Fclones.py:159  def find_clones\n  cc 26   nest 4   src\u002Fcode_master\u002Fgraph.py:71  def _py_from\n  cc 25   nest 6   src\u002Fcode_master\u002Fgraph.py:135  def _py_import\n  cc 24   nest 4   src\u002Fcode_master\u002Fscan.py:840  def _python_functions\n  cc 21   nest 4   src\u002Fcode_master\u002Frender.py:132  def render_brief\n  cc 20   nest 4   src\u002Fcode_master\u002Fscan.py:453  def _read_py_string\n\ncycles 0   clone runs 43   tokens ~39,759\n```\n\nHow to read it.\n\n- File cyclomatic complexity is McCabe's decision count (IEEE TSE, 1976). An empty file is 0. Any other file is `1 +` the decision tokens outside strings and comments. A function starts at 1. A nested function's decisions count for that function, and still count once for the file.\n- Python nesting is the deepest line's indent, minus the `def` indent, divided by the indent unit (the gcd of the indents, else 4). A statement inside `def` + `for` + `if` is nesting 3. Brace languages use max brace depth inside the function, minus the function's own depth, plus one.\n- Halstead volume and difficulty (1977) are computed on the comment-free token stream. Volume feeds the maintainability index.\n- Maintainability is Coleman, Ash, Lowther, and Oman (IEEE Computer, 1994), on the Visual Studio scale. Natural log, then clamp to 0..100:\n\n```text\nMI_raw = 171 - 5.2·ln(V) - 0.23·G - 16.2·ln(SLOC)\nMI     = clamp(MI_raw · 100 \u002F 171, 0, 100)\n```\n\n  The formula takes one cyclomatic number. The file's MI is the median of its per-function values. The header prints the median and the mean of the file values together. In a skewed tree those two diverge, and a report that shows only one of them is how a number lies.\n\n- The leading figure is a robust z-score **inside this repository**:\n\n```text\nrisk = 0.45·z(CC \u002F SLOC) + 0.25·z(nesting) + 0.20·z(ln SLOC) + 0.10·cloned\nz(x) = 0.6744897501960817 · (x - median) \u002F MAD\n```\n\n  The constant is `1 \u002F Φ⁻¹(0.75)`. `cloned` is 1 when the file appears in a reported run, else 0. When MAD is 0, z is 0. PageRank is absent from the sum: a hub is supposed to be imported. A 1.0 here is a rank inside the tree you pointed at. It does not travel to another repository. See [ADR 0003](docs\u002Fadr\u002F0003-risk-scale-is-the-repo.md).\n\n`graph.py` leads because the import resolver is dense. The import hub is a different file, and it shows up under `graph`.\n\n### `code-master graph . --top 8`\n\n```text\ncode-master 0.1.0   14 files   2,818 sloc   python   mi median 58.3  mean 61.8\n\ninternal edges 29   external edges 37\n\ncycles\n  none\n\nhubs\n  0.2875  src\u002Fcode_master\u002Fmodel.py\n  0.0984  src\u002Fcode_master\u002Fscan.py\n  0.0726  src\u002Fcode_master\u002Fcli.py\n  0.0686  src\u002Fcode_master\u002Fversion.py\n  0.0640  src\u002Fcode_master\u002Fanalyze.py\n  0.0627  src\u002Fcode_master\u002Fbudget.py\n  0.0627  src\u002Fcode_master\u002Fclones.py\n  0.0503  src\u002Fcode_master\u002Fgraph.py\n\ninstability  I = Ce \u002F (Ca + Ce), internal edges only\n  I 1.00  Ca 0   Ce 7   tests\u002Ftest_engine.py\n  I 1.00  Ca 0   Ce 3   src\u002Fcode_master\u002F__init__.py\n  I 1.00  Ca 0   Ce 1   src\u002Fcode_master\u002F__main__.py\n  I 0.71  Ca 2   Ce 5   src\u002Fcode_master\u002Fcli.py\n  I 0.67  Ca 3   Ce 6   src\u002Fcode_master\u002Fanalyze.py\n  I 0.50  Ca 2   Ce 2   src\u002Fcode_master\u002Fgraph.py\n  I 0.50  Ca 1   Ce 1   src\u002Fcode_master\u002Frender.py\n  I 0.40  Ca 3   Ce 2   src\u002Fcode_master\u002Fclones.py\n```\n\nAn edge A → B means A depends on B. Rank flows along that edge, so it collects on the modules other modules import (Page, Brin, Motwani, Winograd, 1999, damping 0.85, dangling mass spread evenly, stop at `1e-12` or 100 steps). `model.py` is that hub. Its risk is not on the hotspot list.\n\nCycles are Tarjan's strongly connected components (SIAM J. Comput., 1972). A component of size one is reported only when the node has a self-loop. This tree has no cycle, and the test suite locks that.\n\nInstability is Martin's `I = Ce \u002F (Ca + Ce)` on internal edges. Abstractness, and the distance to the main sequence, are left uncomputed. A scanner cannot see abstract classes reliably, and half of that pair would be a fake number.\n\n### `code-master clones . --top 4`\n\n```text\ncode-master 0.1.0   14 files   2,818 sloc   python   mi median 58.3  mean 61.8\n\n43 runs\n\n   175 tokens  src\u002Fcode_master\u002Fscan.py:494  ~  src\u002Fcode_master\u002Fscan.py:605\n           ) ID , ID = ID . ID , ID . ID ID . …\n   110 tokens  examples\u002Fclone_a.py:8  ~  examples\u002Fclone_b.py:14\n           def ID ( ID , ID , ID , ID ) : ID = …\n    83 tokens  src\u002Fcode_master\u002Fgraph.py:99  ~  src\u002Fcode_master\u002Fgraph.py:136\n           ID ) ID = LIT while ID \u003C ID : ID = ID [ …\n    70 tokens  src\u002Fcode_master\u002Frender.py:134  ~  src\u002Fcode_master\u002Frender.py:220\n           ID = [ ID for ID in ID . ID if ID . ID …\n```\n\nThe longest run is the tool's own pair of string readers, `_read_py_string` and `_read_quoted`. The duplication stays. A clone detector that cannot see its own copies has nothing to show.\n\nThe second run is planted. `examples\u002Fclone_a.py` (`settle`) and `examples\u002Fclone_b.py` (`reconcile`) share a body and share no names. `code-master clones examples` reports that one pair:\n\n```text\ncode-master 0.1.0   2 files   69 sloc   python   mi median 65.8  mean 65.8\n\n1 runs\n\n   110 tokens  clone_a.py:8  ~  clone_b.py:14\n           def ID ( ID , ID , ID , ID ) : ID = …\n```\n\nFingerprints are winnowing (Schleimer, Wilkerson, Aiken, SIGMOD 2003). Identifiers become `ID`, literals become `LIT`, keywords and operators stay. Each token is FNV-1a 64. k-gram hashes use a polynomial rolling hash modulo 2^64 with odd base `911382323`, so the base is invertible. In every window the rightmost minimum is kept. Defaults are `k = 6`, `w = 8`. A run is kept at `--min-tokens` 24 or more, and only when it contains at least two control-flow keywords, so a repeated table of strings is not a clone. Fingerprints with more than 40 postings are dropped. Overlapping runs on the same file collapse after the length sort: a later run that shares 60% of the shorter span goes.\n\nThe default threshold is sensitive. This tree reports 43 runs. Sort by length. The long runs are the finding. The short ones are echoes of the import parsers and the renderers.\n\n### `code-master budget . --top 8`\n\n```text\ncode-master 0.1.0   14 files   2,818 sloc   python   mi median 58.3  mean 61.8\n\nwindow 8,000   corpus ~39,759\n     8k  exceeds\n    32k  exceeds\n   128k  fits\n   200k  fits\n\nread first\n    3738  readme           README.md\n      18  entry            src\u002Fcode_master\u002F__main__.py\n      49  readme           examples\u002FREADME.md\n      28  context          src\u002Fcode_master\u002Fversion.py\n      70  context          src\u002Fcode_master\u002F__init__.py\n     526  hub              src\u002Fcode_master\u002Fmodel.py\n      45  context          CHANGELOG.md\n    1034  entry            src\u002Fcode_master\u002Fcli.py\n  … 6 more inside the window\n```\n\nThe token estimate is for ranking and for window checks. An ASCII word costs about one token per 3.6 characters, any other ASCII character costs one, and a non-ASCII code point costs one below U+0800 and two otherwise. The reading list pins the shallowest `README.md` that fits the window, then fills by value per token. Value prefers entry points and hubs, adds the risk score, and down-weights tests. The fill is the greedy 0\u002F1 heuristic, so the list is deterministic and the knapsack is approximate.\n\n## Definitions\n\n[docs\u002FALGORITHMS.md](docs\u002FALGORITHMS.md) is the specification. If that file and the code disagree, the code is wrong.\n\n| decision | where |\n| --- | --- |\n| A scanner, because an AST for fourteen languages is fourteen parsers to be wrong about. | [ADR 0001](docs\u002Fadr\u002F0001-scanner-not-parser.md) |\n| The standard library only. pytest and mypy are development extras. The token estimate is not a model tokenizer. | [ADR 0002](docs\u002Fadr\u002F0002-stdlib-only.md) |\n| Risk is scaled by the repository under the cursor. Centrality is a separate report. | [ADR 0003](docs\u002Fadr\u002F0003-risk-scale-is-the-repo.md) |\n\n## Limits\n\nThese are the boundaries of the 0.1.0 scanner. They are also printed at the bottom of every brief.\n\n- Comments and strings do not leak into keyword counts. The scan is still not a parse.\n- Python `match` and `case` are soft keywords and stay identifiers, so structural pattern matching is under-counted.\n- A Rust `match` or a Kotlin `when` counts as one decision, not one per arm.\n- JavaScript regular-expression literals are not lexed. A keyword-shaped ident between slashes can be over-counted.\n- C++ raw strings (`R\"(...)\"`) are not supported.\n- Ruby `?` and `!` stay on the identifier, so `empty?` is not a ternary. `??` is a decision. `?.` is optional chaining and is not one. Rust's `?` is the try operator and is not a decision.\n- Ruby and SQL report nesting 0. Their blocks are not brace-reliable.\n- Clones are type-2. A reordered body is a different program to this detector.\n- A module suffix that maps to two files is left unresolved, rather than guessed.\n- Discover skips `.git`, virtualenvs, `node_modules`, dotfiles, lockfiles, binaries, and files over 400 KB, and it stops at 5,000 files.\n\n## Layout\n\n```text\nsrc\u002Fcode_master\u002F   scanner, graph, clones, budget, render, CLI\ntests\u002F             oracles: rolling hash, winnow, MI, risk weights, the example pair\nexamples\u002F          one type-2 pair, names swapped, structure kept\ndocs\u002F              algorithm specification and three decision records\n```\n\n## License\n\nMIT. Copyright (c) 2026 streaxrxoutlook-coder.\n","code-master 是一个本地化、确定性的开源代码分析工具，用于静态提取代码库的多维情报。它支持 Python、JavaScript、TypeScript 等十余种主流语言，提供复杂度（McCabe\u002F嵌套深度\u002F可维护性）、依赖图（循环检测\u002F不稳定性）、语义克隆识别（type-2 克隆）、上下文窗口预算分配及单文件摘要生成五大核心功能；全部基于标准库运行，零外部依赖、不出网、结果可复现。适用于代码审查提效、大模型上下文预处理、技术债务评估及团队级代码健康度基线建设。",2,"2026-11-24 04:40:42","CREATED_QUERY"]