@codua/codeoutline-win32-x64 0.2.1 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,6 +56,7 @@ Three tools are provided:
56
56
  | Tool | Purpose |
57
57
  | --- | --- |
58
58
  | `codeoutline_explore` | Query source, call paths, and callers/callees by symbol or file name (`query`; optional `projectPath`, `budget`) |
59
+ | `codeoutline_callers` | [Find recursive callers and affected files](docs/CALLERS.md) for an exact symbol/qualified name (`query`; optional `projectPath`, `depth` default 3, `max_nodes` default 200, `budget`) |
59
60
  | `codeoutline_status` | Refresh and report index, cache, scanner, and parser statistics |
60
61
  | `codeoutline_rebuild` | Rebuild fully, bypassing the cache |
61
62
 
package/bin/xnet.exe CHANGED
Binary file
package/build-info.json CHANGED
@@ -1 +1 @@
1
- {"target":"win32-x64","note":"Release build from a clean checkout","updateSequence":11,"releaseReady":true,"sha256":{"codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","scripts/codeoutline/lang/lua.lua":"784df7e7895cc7d9f56598d6485664f8ce55abc6374ae0bcc22ba7738439726e","scripts/codeoutline/graph.lua":"361091b354be3fc890d5e8b1a334fbf4daa3ee463fbb5ea5053c75ed66271163","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","README.md":"f858e6acadfb3f7d07e166c5b3c76dc3a3a2140edee6853e95aabe6d39026fc2","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","scripts/codeoutline/service.lua":"537b7ef657fc122a85ddf7275e242d225efc65d5316bf863cd3f3132657d3b3e","README.zh-CN.md":"fea0ffb9835e1b78925b1aa0a6a3019591e376d23e94da5b4f58773601e2d7da","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/index.lua":"dbe88bc5f60b8230e2b69f31c5ffc86e02caea3fb4022ea49ee6210ae2b6a440","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","scripts/codeoutline/lsp.lua":"b9c9df2a790344bb8bdc48bd024e912b012750e3bfdbe37750de5add989385da","scripts/codeoutline/index_worker.lua":"8d34748ce1d74384f8f4cf89bfd7a27dcfb6c4d51b6b4936aa9d232814194a8a","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/command.lua":"7a0a623b5e965449638938549be8587f9c9490b2a7653877e089a0cc1bb1071c","scripts/codeoutline/lua_bindings.lua":"3f781dfa3d88b0ff4446eb956a861098411873805f5b54536814900a8febad5f","scripts/codeoutline/indirect.lua":"c715b87261d5ad30a84af78ab8dcc468390ab0ea896dce88f8651f7f850be091","scripts/codeoutline/update_sequence.lua":"b73b8749b7b726c05d6931405c2a86f88b908f24cdb40390c2f0e744fbaad162","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","scripts/codeoutline/common.lua":"dda47a9143ee61086781befc046df24a7317faf9c3fe9a8fd9fbf7b28dd8ed0e","scripts/codeoutline/main.lua":"fff7b1577ab85625714c841773eee07b028fccd86aa9743f15a7ad5fd7a7353b","scripts/codeoutline/js_evidence.lua":"ddb9f8a4f22b1f7fd397a75c6c5660d434133b5148dbf396586bb5b443161776","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/lang/csharp.lua":"4bfa8555955c7de98ea12d36ee6f7d817c40cb87e77350fe2af4783517190a3d","scripts/codeoutline/completion.lua":"dde4a55ccbc4824f68d7f4c48efd57bddca9c1b371bff2398d85f2930bd53d92","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/js_resolution.lua":"76be5143d2d5ff5b381c1cde0c1039fa26cb035f309a0aba7c3683efdcdd4b58","scripts/codeoutline/version.lua":"3a5f21a9e5dfaf64c4bb7bc7fc581297a5e0f0b3c07742edc758f884740b2c98","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","bin/xnet.exe":"8785c409c74e33a2f464ee8589193c0e2a1e708b9f2cc2099e74d5f80c53cd23","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/navigation.lua":"5e51ca4a0020607fc45e30209eba4d3cd6089fbc21304e49bd308c60e1cd4899","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/parse.lua":"cf325eb88e4ac89bdd6a0cbe33fa97f9df9c657f5685febbb7004c77cdd2749c","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/documents.lua":"320a7d40fd5c0fef03a18df586848059a65c0f4e7ab4b218e9e84561eb5a7007","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","scripts/codeoutline/lang/kotlin.lua":"cefaad1c412cb42ea6b2027ad9f81ad38d8d821f05c1cfde7f89c600d745a708","scripts/codeoutline/explore.lua":"83cf6f5be4d97a929444b58d6ce741cd31a27342438b64cb06daf3d6e1362942","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3"},"runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13","runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","lua":"LuaJIT 2.1.1774896198","version":"0.2.1","sourceCommit":"c5aa041e8a886ac11b3e695f86cb9ec94b4e1760","sourceDirty":false}
1
+ {"target":"win32-x64","lua":"LuaJIT 2.1.1774896198","sourceCommit":"ed96402bbd84f392f4d98a53467ace4b9af4042d","sourceDirty":false,"version":"0.2.4","note":"Release build from a clean checkout","releaseReady":true,"updateSequence":13,"sha256":{"scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","scripts/codeoutline/update_sequence.lua":"bce1625b261d4cbe8d9ed46deaaa4ba0e51188a28eadb29d40a2eb38c7887a86","scripts/codeoutline/index.lua":"b4bd637a5e4c573738ec4e9477ba5090949e7d5b9a35a968d3d4731540ae1630","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/codeoutline/index_worker.lua":"ad6b300fcca6f2eadb0373179d1c5c3321319a3ab0cae3d9a8996ce760e55671","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/codeoutline/version.lua":"98080592a13c231e3d35fc5b8d8c35406cbb6d9c759d2cc6a786ee489c02d900","scripts/codeoutline/indirect.lua":"6bb422611b82ee370b29c5e1eafa25753fa5e4f722b5f2dcda99ad21a7d55a1e","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","scripts/codeoutline/js_evidence.lua":"ddb9f8a4f22b1f7fd397a75c6c5660d434133b5148dbf396586bb5b443161776","README.md":"b58cd12615dd7b796c3a3e8ce86ec0adb36a92f7d32025eed1fb78a843616fcf","README.zh-CN.md":"fea0ffb9835e1b78925b1aa0a6a3019591e376d23e94da5b4f58773601e2d7da","scripts/codeoutline/js_resolution.lua":"76be5143d2d5ff5b381c1cde0c1039fa26cb035f309a0aba7c3683efdcdd4b58","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","bin/xnet.exe":"e3011f838676974c8b534ed53f18b299d5b08ede9d00a6c8744a0c1aa9de62f8","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/callers.lua":"d5b11e92bd32a823f1d198a6e7b4dca73e15daa4713762cf29d1062f26ec20d6","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","scripts/codeoutline/main.lua":"0e1731a4e931ed8cc3ec42c537bb61c22094c3462fe7c20ed49ed7831ce71bd4","scripts/codeoutline/command.lua":"e4bd7698e03dbca3728084454a2e9a4b1a9902e76c3d69b85107ffac80981716","scripts/codeoutline/mcp.lua":"d68f3648a31befeabb846faae3e13efe4f8c7406f6d9b14a1fab6c77014c6b50","scripts/codeoutline/common.lua":"481731dbaeeb937d516e11031f1bef7d1237eaa0999f372ebc3c22fd1ab1898f","scripts/codeoutline/navigation.lua":"032532577b225d31aad9df7a4667b6e082d6612b234acc2079297d33c6b594a3","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/parse.lua":"52eadb0b4b5bb5db2f6064170414377c5a23e2b24b3409ae00b9969273076435","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","scripts/codeoutline/documents.lua":"320a7d40fd5c0fef03a18df586848059a65c0f4e7ab4b218e9e84561eb5a7007","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/explore.lua":"f4e378d300d2ff8dc30ea59a1c8d13f7371e9e49352f203272b420d09f0df240","scripts/codeoutline/lua_bindings.lua":"0ceac2704b3bb2d9b88b6840617d6030d725546ec4b0e19f3ce52aa5be590adb","scripts/codeoutline/lang/lua.lua":"f50a169549475d5d71f8af920feeb82797e8f24ccfe0c3f416abc5a32e942713","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/query_report.lua":"7b6c5e5aae8bcebd10612e360ee7e4cd0f0795f7594479d54e074e50fd6b97bc","scripts/codeoutline/foreign.lua":"ac5b3868430b4f2f8b5182d86e45305b71fa3ffd9a7f5ce034ac49f31e047008","scripts/codeoutline/lang/kotlin.lua":"cefaad1c412cb42ea6b2027ad9f81ad38d8d821f05c1cfde7f89c600d745a708","scripts/codeoutline/lsp.lua":"5403311a9fd5cdc85bcbe158c35d5f1515d279f8374fc41d1f0c694a629ba824","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/lang/csharp.lua":"4bfa8555955c7de98ea12d36ee6f7d817c40cb87e77350fe2af4783517190a3d","scripts/codeoutline/service.lua":"91ac502048f8e5be4521284ca77f45af1a8f6421aff59c41361c88015a531b03","scripts/codeoutline/foreign_lua.lua":"035e8f38408e3bd9a6923a8551c5c37780496f74720862ad1b45ca820c0c364a","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/graph.lua":"1e07b86bb47aebce50658fc4f6e691e48e92436803939e5d395676fc6e4fec3b","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3","scripts/codeoutline/completion.lua":"4781d195e543a56d0e52cd1e54d451cb4a02dafab60e772daee7b1fad58e6b2c","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c"},"runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","os":["win32"],"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"name":"@codua/codeoutline-win32-x64","version":"0.2.1","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"]}
1
+ {"name":"@codua/codeoutline-win32-x64","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"version":"0.2.4","publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","repository":{"type":"git","url":"git+https://github.com/1dao/codeoutline.git"},"os":["win32"]}
@@ -0,0 +1,116 @@
1
+ -- Reverse BFS over query-owned relationships. No persistent impact graph.
2
+ local graph = require('codeoutline.graph')
3
+ local control = require('codeoutline.control')
4
+ local text = require('codeoutline.text')
5
+ local M = {}
6
+
7
+ function M.validate(query, opts)
8
+ require('codeoutline.explore').validate(query, opts)
9
+ opts = opts or {}
10
+ for _, item in ipairs({ { 'depth', 3, 8 }, { 'max_nodes', 200, 2000 } }) do
11
+ local value = opts[item[1]]
12
+ if value == nil then value = item[2] end
13
+ assert(type(value) == 'number' and value % 1 == 0 and value >= 1 and value <= item[3],
14
+ item[1] .. ' must be an integer between 1 and ' .. item[3])
15
+ end
16
+ end
17
+
18
+ function M.run(symbols, idx, query, opts)
19
+ M.validate(query, opts)
20
+ opts = opts or {}
21
+ local depth, cap = opts.depth or 3, opts.max_nodes or 200
22
+ local budget = require('codeoutline.explore').validate(query, opts)
23
+ local Q = graph.query(symbols, opts)
24
+ local result = { targets = {}, callers = {}, files = {}, depth = depth,
25
+ node_limit_reached = false, depth_limit_reached = false }
26
+ local function describe(id)
27
+ return { id = id, name = Q.nodes[id].qualified, file = Q.files[Q.node_file[id]].path, line = Q.nodes[id].line }
28
+ end
29
+ local candidates = symbols.by_qualified[query] or symbols.by_name[query] or {}
30
+ local ordered = {}
31
+ for _, id in ipairs(candidates) do ordered[#ordered + 1] = id end
32
+ table.sort(ordered, function(a, b) return graph.before(Q, a, b) end)
33
+ local frontier, seen, next_hop = {}, {}, {}
34
+ for _, id in ipairs(ordered) do
35
+ if #frontier >= cap then result.node_limit_reached = true; break end
36
+ frontier[#frontier + 1] = id; seen[id] = true
37
+ result.targets[#result.targets + 1] = describe(id)
38
+ end
39
+ local files = {}
40
+ for level = 1, depth do
41
+ if #frontier == 0 then break end
42
+ control.check()
43
+ Q:load_incoming(frontier) -- one project reference scan per layer
44
+ local pending, links = {}, {}
45
+ for _, dst in ipairs(frontier) do
46
+ local edges = Q.inn[dst] or {}
47
+ for i = 1, #edges, graph.EDGE do
48
+ if i % 384 == 1 then control.check() end
49
+ local src = edges[i]
50
+ if not seen[src] and not links[src] then
51
+ links[src] = { target = dst, line = edges[i + 1], kind = edges[i + 2] }
52
+ pending[#pending + 1] = src
53
+ end
54
+ end
55
+ end
56
+ table.sort(pending, function(a, b) return graph.before(Q, a, b) end)
57
+ frontier = {}
58
+ for _, src in ipairs(pending) do
59
+ if #result.callers >= cap then result.node_limit_reached = true; break end
60
+ seen[src], next_hop[src] = true, links[src]
61
+ frontier[#frontier + 1] = src
62
+ local entry = describe(src)
63
+ entry.depth, entry.path = level, {}
64
+ local current = src
65
+ while next_hop[current] do
66
+ local hop = describe(current)
67
+ local edge = next_hop[current]
68
+ hop.call_line, hop.kind = edge.line, edge.kind
69
+ entry.path[#entry.path + 1] = hop
70
+ current = edge.target
71
+ end
72
+ entry.path[#entry.path + 1] = describe(current)
73
+ result.callers[#result.callers + 1] = entry
74
+ files[entry.file] = true
75
+ end
76
+ if level == depth and #frontier > 0 then result.depth_limit_reached = true end
77
+ if result.node_limit_reached then break end
78
+ end
79
+ for file in pairs(files) do result.files[#result.files + 1] = file end
80
+ table.sort(result.files)
81
+ -- Source validation may repair encodings and invalidate IDs: retry the query.
82
+ local paths = {}
83
+ for _, target in ipairs(result.targets) do paths[target.file] = true end
84
+ for _, file in ipairs(result.files) do paths[file] = true end
85
+ local changed = false
86
+ for path in pairs(paths) do
87
+ local source, repaired = idx:query_source(path)
88
+ assert(source, 'cannot read source: ' .. path)
89
+ changed = changed or repaired
90
+ end
91
+ if changed then return nil, { encoding_retry = true } end
92
+ local lines = { string.format('Matched %d target(s); %d potential callers in %d files, searched up to %d levels.',
93
+ #result.targets, #result.callers, #result.files, depth),
94
+ 'Static potential impact; each caller has one shortest path. This is not proof of runtime execution or complete impact coverage.' }
95
+ if #result.targets == 0 then lines[#lines + 1] = 'No exact symbol matched; use a symbol name or qualified name.' end
96
+ if #result.targets > 1 then lines[#lines + 1] = 'Multiple definitions matched; results cover the listed targets.' end
97
+ if result.node_limit_reached then lines[#lines + 1] = 'Node limit reached; targets or callers were omitted.' end
98
+ if result.depth_limit_reached then lines[#lines + 1] = 'Depth limit reached; callers beyond this depth were not checked.' end
99
+ for _, target in ipairs(result.targets) do
100
+ lines[#lines + 1] = string.format('Target: %s (%s:%d)', target.name, target.file, target.line)
101
+ end
102
+ for _, entry in ipairs(result.callers) do
103
+ local path = {}
104
+ for _, hop in ipairs(entry.path) do
105
+ path[#path + 1] = string.format('%s (%s:%d)%s', hop.name, hop.file, hop.call_line or hop.line,
106
+ hop.kind and ' [' .. hop.kind .. ']' or '')
107
+ end
108
+ lines[#lines + 1] = string.format('Depth %d: %s', entry.depth, table.concat(path, ' -> '))
109
+ end
110
+ if #result.files > 0 then lines[#lines + 1] = 'Affected caller files:\n' .. table.concat(result.files, '\n') end
111
+ local output, cut = text.limit(table.concat(lines, '\n'), budget, result.node_limit_reached)
112
+ result.truncated, result.query_stats = cut, Q.stats
113
+ return output, result
114
+ end
115
+
116
+ return M
@@ -19,6 +19,7 @@ Usage:
19
19
  codeoutline lsp --stdio [--project PATH]
20
20
  codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
21
21
  codeoutline explore --project PATH --query QUERY [--budget BYTES]
22
+ codeoutline callers --project PATH --query SYMBOL [--depth 3] [--max-nodes 200] [--budget BYTES]
22
23
  codeoutline status [--project PATH]
23
24
  codeoutline rebuild [--project PATH]
24
25
  codeoutline doctor [--project PATH]
@@ -60,6 +61,7 @@ local function parse(args)
60
61
  ['allow-root'] = true, ['allow-host'] = true, ['allow-origin'] = true },
61
62
  daemon = { port = true }, install = { port = true, npm = true }, uninstall = { port = true },
62
63
  explore = { project = true, query = true, budget = true },
64
+ callers = { project = true, query = true, budget = true, depth = true, ['max-nodes'] = true },
63
65
  update = { check = true, channel = true },
64
66
  status = { project = true }, rebuild = { project = true }, doctor = { project = true },
65
67
  }
@@ -237,11 +239,13 @@ local function run()
237
239
  local root = options.project or '.'
238
240
  if command == 'doctor' then return doctor(root) end
239
241
  local svc = require('codeoutline.service')
240
- if command == 'explore' then
241
- assert(options.query, 'explore requires --query')
242
+ if command == 'explore' or command == 'callers' then
243
+ assert(options.query, command .. ' requires --query')
242
244
  local budget
243
245
  if options.budget then budget = assert(tonumber(options.budget), '--budget must be a number') end
244
- local text = svc.explore(root, options.query, { budget = budget })
246
+ local depth = options.depth and assert(tonumber(options.depth), '--depth must be a number')
247
+ local max_nodes = options['max-nodes'] and assert(tonumber(options['max-nodes']), '--max-nodes must be a number')
248
+ local text = svc[command](root, options.query, { budget = budget, depth = depth, max_nodes = max_nodes })
245
249
  io.write(text, '\n')
246
250
  else
247
251
  io.write(xutils.json_pack(svc[command](root)), '\n')
@@ -24,7 +24,8 @@ local text = require('codeoutline.text')
24
24
 
25
25
  function M.new(path, language, opts)
26
26
  return { path = path, language = language, nodes = {}, refs = {}, imports = {},
27
- ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch }
27
+ ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch,
28
+ dispatch_only = opts and opts.dispatch_only }
28
29
  end
29
30
 
30
31
  -- Collapse a token span into a one-line signature.
@@ -131,7 +132,17 @@ end
131
132
 
132
133
  -- Drop parser-internal fields so the result is plain data.
133
134
  function M.finish(r, T)
135
+ if T and (r.language == 'c' or r.language == 'cpp') then
136
+ require('codeoutline.foreign').collect(r, T)
137
+ end
134
138
  M.assign_refs(r)
139
+ -- Query-only parse: preserve normal declaration/call attribution, but do
140
+ -- not build binding evidence or compact records that will be discarded.
141
+ if r.dispatch_only then
142
+ require('codeoutline.indirect').collect(r, T)
143
+ r.dispatch_only, r.collect_dispatch = nil, nil
144
+ return r
145
+ end
135
146
  if T then require('codeoutline.js_evidence').collect(r, T) end
136
147
  if T then require('codeoutline.indirect').collect(r, T) end
137
148
  r.collect_dispatch = nil
@@ -211,7 +211,7 @@ local function parameters(T, a, b, language, out)
211
211
  end
212
212
 
213
213
  -- Initializer starting at token j: a type name, a module path, or a call chain.
214
- local function initializer(T, j, stop)
214
+ local function initializer(T, j, stop, language)
215
215
  if not j or j > stop then return {} end
216
216
  if kw(T, j, 'new') or (T.k[j] == 'id' and text_of(T, j) == 'new') then
217
217
  local k, last = j + 1, nil
@@ -226,6 +226,21 @@ local function initializer(T, j, stop)
226
226
  local k = is(T, j + 1, '(') and j + 2 or j + 1
227
227
  if T.k[k] == 'str' then return { module = text_of(T, k):gsub('^[%a]*["\'%[=]+', ''):gsub('["\'%]=]+$', '') } end
228
228
  end
229
+ if language == 'lua' and T.k[j] == 'id' then
230
+ -- Lua `*import` loaders: `ks.import('path.lua')`, `skynet_import 'path.lua'`.
231
+ local k = j
232
+ while is(T, k + 1, '.') and T.k[k + 2] == 'id' do k = k + 2 end
233
+ local name = text_of(T, k)
234
+ if name:sub(-6) == 'import' then
235
+ local a = is(T, k + 1, '(') and k + 2 or k + 1
236
+ if T.k[a] == 'str' and (not is(T, k + 1, '(') or is(T, a + 1, ')')) then
237
+ local path = text_of(T, a):gsub('^[%a]*["\'%[=]+', ''):gsub('["\'%]=]+$', '')
238
+ local parts = {}
239
+ for x = j, k, 2 do parts[#parts + 1] = text_of(T, x) end
240
+ return { module = path, module_kind = table.concat(parts, '.') }
241
+ end
242
+ end
243
+ end
229
244
  local chain, k = {}, j
230
245
  while k <= stop and (T.k[k] == 'id' or (T.k[k] == 'kw' and SELF[text_of(T, k)])) do
231
246
  local item = { name = text_of(T, k) }
@@ -262,9 +277,10 @@ local function declarations(T, a, b, language, skip, out)
262
277
  local entry = { name = text_of(T, name_tok), type = normalize(type), at = name_tok }
263
278
  if init then
264
279
  local stop = statement_end(init)
265
- local value = initializer(T, init, stop)
280
+ local value = initializer(T, init, stop, language)
266
281
  entry.type = entry.type or normalize(value.type)
267
282
  entry.module, entry.chain = value.module, value.chain
283
+ entry.module_kind = value.module_kind
268
284
  end
269
285
  out[#out + 1] = entry
270
286
  end
@@ -382,8 +398,10 @@ local function module_aliases(T, language)
382
398
  local out = {}
383
399
  for i = 1, T.n do
384
400
  if language == 'lua' and kw(T, i, 'local') and T.k[i + 1] == 'id' and is(T, i + 2, '=') then
385
- local value = initializer(T, i + 3, math.min(T.n, i + 6))
386
- if value.module then out[text_of(T, i + 1)] = { kind = 'require', path = value.module } end
401
+ local value = initializer(T, i + 3, math.min(T.n, i + 8), 'lua')
402
+ if value.module then
403
+ out[text_of(T, i + 1)] = { kind = value.module_kind or 'require', path = value.module }
404
+ end
387
405
  elseif language == 'python' and kw(T, i, 'import') then
388
406
  local from, k = nil, i - 1
389
407
  while k >= 1 and T.k[k] ~= 'nl' and not kw(T, k, 'from') do k = k - 1 end
@@ -591,19 +609,43 @@ function Completion:assigned(name)
591
609
  end
592
610
 
593
611
  -- Top-level members of module files.
594
- function Completion:module_members(files)
612
+ function Completion:module_members(files, module_name)
595
613
  local out = {}
596
614
  for _, g in ipairs(files) do
597
615
  if self:expired() then break end
598
616
  local rec = self.V.files[g]
599
617
  local language = rec.language
618
+ local native = rec.foreign_exports and rec.foreign_exports[self.language]
619
+ if native then
620
+ for name, n in pairs(native[module_name] or {}) do
621
+ local node = rec.nodes[n]
622
+ out[#out + 1] = { name = name, kind = node.kind, node = node, file = g }
623
+ end
624
+ end
600
625
  local exported
626
+ local lua_contract = language == 'lua' and rec.lua_exports and next(rec.lua_exports) ~= nil
601
627
  if language == 'lua' then
602
- -- The table a Lua module returns names its members.
603
- local _, T = full(self.V, g)
604
- if T then
605
- for i = T.n - 1, 1, -1 do
606
- if kw(T, i, 'return') and T.k[i + 1] == 'id' then exported = text_of(T, i + 1); break end
628
+ -- The verified module contract names the returned table's members.
629
+ exported = rec.lua_owner
630
+ if not exported and not lua_contract then
631
+ local _, T = full(self.V, g)
632
+ if T then
633
+ for i = T.n - 1, 1, -1 do
634
+ if kw(T, i, 'return') and T.k[i + 1] == 'id' then exported = text_of(T, i + 1); break end
635
+ end
636
+ end
637
+ end
638
+ if not exported and lua_contract then
639
+ -- Return-less `__exports` contract: the recorded exports are the members.
640
+ for name, n in pairs(rec.lua_exports) do
641
+ local node = rec.nodes[n]
642
+ if node then out[#out + 1] = { name = name, kind = node.kind, node = node, file = g } end
643
+ end
644
+ elseif not exported then
645
+ for _, node in ipairs(rec.nodes) do
646
+ if not node.parent and not node.qualified:find('[%.:]') then
647
+ out[#out + 1] = { name = node.name, kind = node.kind, node = node, file = g }
648
+ end
607
649
  end
608
650
  end
609
651
  end
@@ -611,7 +653,8 @@ function Completion:module_members(files)
611
653
  if exported then
612
654
  local member = node.qualified:match('^' .. exported:gsub('%p', '%%%0') .. '[%.:]([%w_]+)$')
613
655
  if member then out[#out + 1] = { name = member, kind = node.kind, node = node, file = g } end
614
- elseif not node.parent and not node.qualified:find('[%.:]') and (language ~= 'go' or node.name:match('^%u')) then
656
+ elseif not native and language ~= 'lua' and not node.parent and not node.qualified:find('[%.:]')
657
+ and (language ~= 'go' or node.name:match('^%u')) then
615
658
  out[#out + 1] = { name = node.name, kind = node.kind, node = node, file = g }
616
659
  end
617
660
  end
@@ -729,7 +772,7 @@ function Completion:receiver(item, depth)
729
772
  local entry = find_local(self:locals(), name)
730
773
  if entry then
731
774
  if entry.module then
732
- return { modules = import_files(self.V, self.f, { kind = 'require', path = entry.module }) }
775
+ return { modules = import_files(self.V, self.f, { kind = entry.module_kind or 'require', path = entry.module }), module_name = entry.module }
733
776
  elseif entry.type then
734
777
  local ids = self:types(entry.type)
735
778
  if #ids > 0 then return { types = ids } end
@@ -743,7 +786,11 @@ function Completion:receiver(item, depth)
743
786
  local alias = self.aliases[name]
744
787
  if alias then
745
788
  local files = import_files(self.V, self.f, alias)
746
- if #files > 0 then return { modules = files } end
789
+ if #files > 0 then return { modules = files, module_name = alias.path } end
790
+ end
791
+ if self.language == 'lua' and not entry then
792
+ local files = require('codeoutline.lua_bindings').native_modules(self.V, name, self.V.js_context.lua)
793
+ if #files > 0 then return { modules = files, module_name = name } end
747
794
  end
748
795
  local ids = self:types(name)
749
796
  if #ids > 0 then return { types = ids, static = true } end
@@ -755,7 +802,7 @@ end
755
802
 
756
803
  function Completion:entries(target)
757
804
  if not target then return {} end
758
- if target.modules then return self:module_members(target.modules) end
805
+ if target.modules then return self:module_members(target.modules, target.module_name) end
759
806
  if target.owner then
760
807
  local out = target.local_only and {} or self:owned(target.owner, graph.family(self.language))
761
808
  for _, entry in ipairs(self:assigned(target.owner)) do out[#out + 1] = entry end
@@ -811,8 +858,9 @@ end
811
858
 
812
859
  local function item_for(entry, language)
813
860
  local node = entry.node
861
+ local foreign = node and require('codeoutline.foreign').signature(node, language, entry.name)
814
862
  return { label = entry.name, kind = ITEM[entry.kind] or 6,
815
- detail = node and (node.sig or (node.type and (node.type .. ' ' .. entry.name))) or entry.detail }
863
+ detail = foreign and foreign.label or (node and (node.sig or (node.type and (node.type .. ' ' .. entry.name))) or entry.detail) }
816
864
  end
817
865
 
818
866
  -- Completion items at the cursor of req.uri.
@@ -234,9 +234,10 @@ local function path_between(G, a, b, depth)
234
234
  end
235
235
  end
236
236
  frontier = next_frontier
237
- if #frontier == 0 or #frontier > 20000 then break end
237
+ if #frontier == 0 then return nil end
238
+ if #frontier > 20000 then return nil, true end
238
239
  end
239
- return nil
240
+ return nil, #frontier > 0
240
241
  end
241
242
 
242
243
  local file_cache = {}
@@ -245,7 +246,7 @@ local function file_lines(idx, rel)
245
246
  local lines = file_cache[key]
246
247
  if lines then return lines end
247
248
  lines = {}
248
- local src = idx:query_source(rel)
249
+ local src = assert(idx:query_source(rel), 'cannot read source: ' .. rel)
249
250
  if src then
250
251
  for line in (src .. '\n'):gmatch('([^\n]*)\n') do lines[#lines + 1] = (line:gsub('\r$', '')) end
251
252
  end
@@ -293,7 +294,7 @@ local function node_block(G, idx, id, full)
293
294
  render_range(lines, b - M.CUT_TAIL + 1, b, out)
294
295
  end
295
296
  end
296
- return table.concat(out, '\n')
297
+ return table.concat(out, '\n'), span > full
297
298
  end
298
299
 
299
300
  local function label(G, id)
@@ -307,7 +308,10 @@ function M.run(G, idx, query, opts)
307
308
  control.check()
308
309
  opts = opts or {}
309
310
  local budget = M.validate(query, opts)
310
- G = graph.query(G, opts)
311
+ local query_opts = {}
312
+ for key, value in pairs(opts) do query_opts[key] = value end
313
+ query_opts.explain = true
314
+ G = graph.query(G, query_opts)
311
315
  file_cache = {}
312
316
  local ranked, named_files = find_seeds(G, query)
313
317
 
@@ -334,10 +338,12 @@ function M.run(G, idx, query, opts)
334
338
 
335
339
  -- Spine: nodes on call paths between seeds.
336
340
  local flows, spine, on_spine = {}, {}, {}
341
+ local path_limited = false
337
342
  for _, a in ipairs(seeds) do
338
343
  for _, b in ipairs(seeds) do
339
344
  if a ~= b then
340
- local p = path_between(G, a, b, M.PATH_DEPTH)
345
+ local p, limited = path_between(G, a, b, M.PATH_DEPTH)
346
+ path_limited = path_limited or limited or false
341
347
  if p then
342
348
  local names = {}
343
349
  for _, id in ipairs(p) do
@@ -429,11 +435,21 @@ function M.run(G, idx, query, opts)
429
435
  end
430
436
  end
431
437
  for f in pairs(selected) do
432
- local _, repaired = idx:query_source(G.files[f].path)
438
+ local path = G.files[f].path -- a decoding repair replaces this file ID
439
+ local source, repaired = idx:query_source(path)
440
+ assert(source, 'cannot read source: ' .. path)
433
441
  changed = repaired or changed
434
442
  end
435
443
  if changed then return nil, { encoding_retry = true } end
436
444
 
445
+ local evidence_text = require('codeoutline.query_report').render(G.report, G)
446
+ local evidence_budget = math.min(4096, math.floor(budget / 4))
447
+ local evidence_cut = #evidence_text > evidence_budget
448
+ if evidence_budget >= 256 then
449
+ emit(text.limit(evidence_text, evidence_budget, G.report.truncated))
450
+ else evidence_cut = #G.report.entries > 0 end
451
+ omitted = omitted or evidence_cut or G.report.truncated or #flows > M.LIST_CAP
452
+
437
453
  local reserve = math.floor(budget * 0.15) -- keep room for sections 3-4
438
454
  for _, f in ipairs(file_order) do
439
455
  local rec = G.files[f]
@@ -454,7 +470,8 @@ function M.run(G, idx, query, opts)
454
470
  end
455
471
  for _, item in ipairs(items) do
456
472
  if not shown[item.id] then
457
- local block = node_block(G, idx, item.id, item.full)
473
+ local block, source_cut = node_block(G, idx, item.id, item.full)
474
+ omitted = omitted or source_cut
458
475
  local need = #block + (wrote_header and 0 or #header + 1) + 1
459
476
  if used + need < budget - reserve then
460
477
  if not wrote_header then emit(header); wrote_header = true end
@@ -480,6 +497,7 @@ function M.run(G, idx, query, opts)
480
497
  seen_in[src] = true
481
498
  callers[#callers + 1] = string.format('%s (%s:%d)', G.nodes[src].name, G.files[G.node_file[src]].path, inn[i + 1])
482
499
  .. (inn[i + 2]:match('^indirect:') and (' [' .. inn[i + 2] .. ']') or '')
500
+ elseif not seen_in[src] then omitted = true
483
501
  end
484
502
  end
485
503
  for i = 1, #out, graph.EDGE do
@@ -488,6 +506,7 @@ function M.run(G, idx, query, opts)
488
506
  seen_out[dst] = true
489
507
  callees[#callees + 1] = G.nodes[dst].name .. ' (' .. graph.where(G, dst) .. ')'
490
508
  .. (out[i + 2]:match('^indirect:') and (' [' .. out[i + 2] .. ']') or '')
509
+ elseif not seen_out[dst] then omitted = true
491
510
  end
492
511
  end
493
512
  if #callers > 0 or #callees > 0 then
@@ -523,9 +542,17 @@ function M.run(G, idx, query, opts)
523
542
  table.insert(parts, 1, 'Call-path expansion limit reached; relationships are incomplete.')
524
543
  omitted = true
525
544
  end
545
+ if path_limited then
546
+ table.insert(parts, 1, 'Call-path search reached its depth/frontier limit; no path found is not proof of no runtime connection.')
547
+ end
548
+ if evidence_cut or G.report.truncated then
549
+ table.insert(parts, 1, 'Relationship explanations omitted due to evidence/output limits.')
550
+ end
526
551
  local result, truncated = text.limit(table.concat(parts, '\n'), budget, omitted or #pointers > 0)
527
552
  return result, { seeds = seeds, spine = spine, shown = shown, flows = flows, truncated = truncated,
528
- relationships_incomplete = G.incomplete or false, query_stats = G.stats }
553
+ relationships_incomplete = G.incomplete or false, query_stats = G.stats,
554
+ evidence = G.report.entries, evidence_truncated = evidence_cut or G.report.truncated,
555
+ path_search_limited = path_limited, evidence_scope = G.report.scope }
529
556
  end
530
557
 
531
558
  return M
@@ -0,0 +1,60 @@
1
+ -- Language-neutral native exports. Adapters supply registration evidence and
2
+ -- guest parameters; implementation nodes retain their original host signature.
3
+ local M = {}
4
+
5
+ function M.register(rec, language, module, exports)
6
+ rec.foreign_exports = rec.foreign_exports or {}
7
+ rec.foreign_exports[language] = rec.foreign_exports[language] or {}
8
+ rec.foreign_exports[language][module] = exports
9
+ end
10
+
11
+ function M.exports(rec, language, module)
12
+ return rec.foreign_exports and rec.foreign_exports[language] and rec.foreign_exports[language][module]
13
+ end
14
+
15
+ function M.collect(rec, T)
16
+ require('codeoutline.foreign_lua').collect(rec, T)
17
+ end
18
+
19
+ function M.modules(G, language, name, ctx)
20
+ ctx = ctx or {}
21
+ if not ctx.foreign then
22
+ ctx.foreign = {}
23
+ local seen = {}
24
+ local function add(f)
25
+ if seen[f] then return end
26
+ seen[f] = true
27
+ for lang, modules in pairs(G.files[f].foreign_exports or {}) do
28
+ ctx.foreign[lang] = ctx.foreign[lang] or {}
29
+ for module in pairs(modules) do
30
+ local names = ctx.foreign[lang]
31
+ names[module] = names[module] or {}
32
+ table.insert(names[module], f)
33
+ end
34
+ end
35
+ end
36
+ for _, f in ipairs(G.file_order or {}) do add(f) end
37
+ for _, f in ipairs(G.new_files or {}) do add(f) end
38
+ end
39
+ return (ctx.foreign[language] or {})[name] or {}
40
+ end
41
+
42
+ -- Parameter labels are structured data, never reparsed as host-language code.
43
+ function M.signature(node, language, name)
44
+ local contract = node.foreign_signatures and node.foreign_signatures[language]
45
+ if not contract then return nil end
46
+ local labels, parameters = {}, {}
47
+ for i, p in ipairs(contract.parameters) do
48
+ local label = (p.name or ('arg' .. i)) .. (p.optional and '?' or '') .. ':' .. (p.type or 'unknown')
49
+ if p.default then label = label .. ' = ' .. p.default end
50
+ labels[#labels + 1] = label
51
+ parameters[#parameters + 1] = { label = label }
52
+ end
53
+ if contract.unknown_tail then
54
+ labels[#labels + 1] = '...:unknown'
55
+ parameters[#parameters + 1] = { label = '...:unknown' }
56
+ end
57
+ return { label = (name or node.name) .. '(' .. table.concat(labels, ', ') .. ')', parameters = parameters }
58
+ end
59
+
60
+ return M