@codua/codeoutline-win32-x64 0.3.9 → 0.5.0

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
@@ -543,6 +543,50 @@ local text, info = service.explore('C:/src/project', 'Session.save', { budget =
543
543
 
544
544
  `get`, `explore`, and `status` refresh automatically; `forget` clears only the in-memory index, and `rebuild` reindexes without the disk cache. `service.configure` adjusts the resident project count and idle timeout. When embedding on Android, the host must call `xutils_android_init(JavaVM*)` once before starting worker threads; otherwise GBK conversion reports an error.
545
545
 
546
+ ### Disk BM25 search
547
+
548
+ MCP `codeoutline_explore` automatically queues a BM25 snapshot for the
549
+ refreshed project when the snapshot is missing or stale. When the usual
550
+ symbol and file lookup finds nothing, Explore uses BM25 candidates with the
551
+ same filters and returns its usual source and relationship context. While
552
+ a snapshot is being built, a miss reports `bm25.state = "building"`
553
+ in the structured MCP result.
554
+
555
+ The BM25 fallback matches any query term by default. Pass `bm25Match: "all"`
556
+ to require all tokenized terms in the same function. This option applies
557
+ only to the fallback. The equivalent Lua search option is `match = 'all'`.
558
+ Before taking the top results, the search prioritizes complete literal
559
+ matches and boosts terms separated by fewer words within the same indexed
560
+ field. Queries can still match terms spread across fields.
561
+ Terms from names such as `cache_finish` can also match the file path or
562
+ filename. Pass `prefix = 'cache'` to the Lua search API to boost matching
563
+ qualifiers, filenames, and directory components before the result limit.
564
+ F12 supplies the receiver of a member lookup as this optional hint.
565
+
566
+ The editor's F12 uses the regular LSP definition lookup first. On a miss,
567
+ it searches the entire project's BM25 snapshot for the identifier or string
568
+ at the cursor, with all terms required. CodeOutline verifies declaration
569
+ candidates and exact string matches against the source or editor draft.
570
+ For strings, F12 skips the occurrence at the cursor and other direct string
571
+ arguments to the same named call. It lists equality comparisons before other
572
+ exact matches.
573
+ If the snapshot is missing or stale, the miss starts a background build.
574
+ Retry F12 after the build finishes.
575
+
576
+ ```lua
577
+ local bm25 = require('codeoutline.bm25.index')
578
+ local idx = service.refresh(project_path)
579
+ bm25.build(idx, bm25_path)
580
+ local hits = bm25.search(idx, bm25_path, 'load cache', { path = 'src', limit = 20 })
581
+ ```
582
+
583
+ Build the snapshot once and reuse it for searches. Pass the refreshed base
584
+ index to both functions. After the base records change, searches report a
585
+ stale snapshot until it is rebuilt. Results contain `symbol`, `path`,
586
+ `start_line`, `end_line`, and `score`. The optional `path` filters by file or
587
+ directory and `limit` defaults to 20. Builds reuse a configured and bound
588
+ index worker pool, with a serial fallback for standalone Lua callers.
589
+
546
590
  ## Origin and license
547
591
 
548
592
  The code was extracted from Codua and uses the `codeoutline.*` namespace. CodeOutline is licensed under [BSD-2-Clause](LICENSE); third-party notices are in [THIRD_PARTY.md](docs/THIRD_PARTY.md).
package/README.zh-CN.md CHANGED
@@ -342,6 +342,39 @@ local text, info = service.explore('C:/src/project', 'Session.save', { budget =
342
342
 
343
343
  `get`、`explore`、`status` 自动刷新;`forget` 只清除内存索引,`rebuild` 绕过磁盘缓存完整重建;`service.configure` 可调整驻留项目数与空闲时间。嵌入 Android 时,宿主须在启动工作线程前调用一次 `xutils_android_init(JavaVM*)`,否则 GBK 转换会明确报错。
344
344
 
345
+ ### 磁盘 BM25 搜索
346
+
347
+ MCP 的 `codeoutline_explore` 在刷新项目基础索引后,会在后台生成缺失或过期的 BM25
348
+ 快照。原来的符号和文件查找均无命中时,Explore 用 BM25 补充候选,沿用查询过滤条件,
349
+ 并照常返回源码和调用关系。构建期间遇到零命中,结构化结果会报告
350
+ `bm25.state = "building"`,可以稍后重试。
351
+
352
+ BM25 回退默认允许命中任意查询词。传入 `bm25Match: "all"` 时,只保留同一函数里
353
+ 命中全部分词的候选。这个选项只作用于 BM25 回退,对应 Lua 查询选项 `match = 'all'`。
354
+ 截取前几名之前,优先排序完整字面匹配,并按同一索引字段内的词距加分。
355
+ 分词也可以分散命中多个字段,保留原有 BM25 分数。
356
+ 例如 `cache_finish` 拆出的词也能命中文件名或路径。Lua 查询接口可传入
357
+ `prefix = 'cache'`,在截取结果之前为匹配的符号前缀、文件名和目录段加分。
358
+ F12 回退查找成员时会自动把接收者名称作为这项提示。
359
+
360
+ 编辑器 F12 优先使用原有的 LSP 定义查找。零命中时,将光标下的标识符或字符串交给
361
+ 整个项目的 BM25 快照做分词交集,再用当前源码或编辑器草稿验证声明候选和字符串位置。
362
+ 查找字符串时,F12 跳过光标所在位置,以及同一个调用名下作为直接参数出现的匹配,
363
+ 并把等值比较排在其他完整匹配之前。
364
+ 快照缺失或过期时,零命中会触发后台构建,构建完成后可再次按 F12。
365
+
366
+ ```lua
367
+ local bm25 = require('codeoutline.bm25.index')
368
+ local idx = service.refresh(project_path)
369
+ bm25.build(idx, bm25_path)
370
+ local hits = bm25.search(idx, bm25_path, 'load cache', { path = 'src', limit = 20 })
371
+ ```
372
+
373
+ 索引生成后可重复查询。两个接口都接收刷新过的基础索引。基础记录变化后,查询会提示
374
+ 快照过期,直到重新生成。结果返回 `symbol`、`path`、`start_line`、`end_line` 和
375
+ `score`。可用 `path` 按目录或文件过滤,`limit` 默认是 20。生成时复用已配置并
376
+ 绑定的索引线程池,独立 Lua 调用可以串行生成。
377
+
345
378
  ## 来源与许可
346
379
 
347
380
  代码提取自 Codua,命名空间为 `codeoutline.*`。项目采用 [BSD-2-Clause](LICENSE),第三方依赖声明见 [第三方说明](docs/THIRD_PARTY.md)。
package/bin/xnet.exe CHANGED
Binary file
package/build-info.json CHANGED
@@ -1 +1 @@
1
- {"target":"win32-x64","runtimeCommit":"be18042e9091379bf45624771a4e8819d2709f84","version":"0.3.9","lua":"LuaJIT 2.1.1774896198","sourceCommit":"d13c133a8a1edaed1a306b8e3d9efe136ad2782e","sourceDirty":false,"releaseReady":true,"note":"Release build from a clean checkout","sha256":{"scripts/codeoutline/query/affected.lua":"7fe6ae466b314957f39ceb8fcc1f0a5339d523c86f99ce5735599a2477865b72","scripts/codeoutline/analysis/type_uses.lua":"eb1ee73f0a3cb67ef3b92ed1a8b7222fbc26137f743e466338e180b416ea12cb","scripts/codeoutline/analysis/graph.lua":"70eed1852ca77615de7530947b1278a83ae38e04d1a26930251bc506de357541","scripts/codeoutline/lang/cpp.lua":"e13eaf1882cddb20a7a651d13136e06ca42c482cf7ac53de38bf82fdda786727","scripts/codeoutline/query/callers.lua":"b1870f2d08c2274ce743d513560ce9329e16236399e065027685dbf8694c82ab","scripts/codeoutline/analysis/python/python_bindings.lua":"ec4217f77345282a5522696c1b53e3886fb0e9a45736c10613fcb0fd4f016160","scripts/codeoutline/cli.lua":"28b058bbb3c86d9e6a7603c52ef62eacc8978af6c2201e61bfb8100bc79be4b2","scripts/codeoutline/analysis/implementations.lua":"ffcd7288eae967c5628c85b8e55d93c826b30524956212dccca7d150ac7ac3be","scripts/codeoutline/query/completion.lua":"ff2c4102b9a73042f84e823e13ce685aa1d164ee84765db513da2b8ae515e763","scripts/codeoutline/analysis/receivers.lua":"3b2d09cab61dac5549e96fb007d0538661391c1d4f25573d1872221d8c7b2d3c","scripts/codeoutline/command.lua":"3e85c469d3f4eabeb9bae662c6fa6daf46eccb47886f40feb7406a7f486bc553","bin/xnet.exe":"951c9f93e538f4679f23192aebab200bf6c0cb5768311fd0b14c7ee5ffb84f85","scripts/codeoutline/lang/java.lua":"3c6b2d844202cbe988644e94090be76e7f8a2a906f4412aefcbd06e9fb56a01b","scripts/codeoutline/analysis/resolution.lua":"ec137a38abfdcb7f366861a123480a3b3125a76acf7399a784f8fb207e833d0b","scripts/codeoutline/query/definition_candidates.lua":"eeb78de0c92e11729d84d4e338cba9424e73e8616bb251c533a4c2e5a201bf8a","scripts/codeoutline/lang/js.lua":"ff326c9ef41deb5ec7f961a556350b69c4b601a176d696114a2096d5118c2379","scripts/codeoutline/query/documents.lua":"1ed27cb6f805c1ff9acbc070f16e582b71c4a330c5539fb3d7b8ed4150c82bdf","codeoutline":"1909247ba17be9d0fe14d689ea7c1c955013b5b79f05336e2161b6f161c4c394","scripts/codeoutline/analysis/js/js_evidence.lua":"523913dcadb37ec433b31103c12218c383001851b7cf965cf4505065917d8afe","scripts/codeoutline/lang/kotlin.lua":"8b5dabbbede62bf0a1376414f7424e6dd3a248739cc015c2364d143901230d86","codeoutline.cmd":"52ee46a6010ff1161369e50df76e96beed2d6152f8c8e5095f73bc0b60a7629b","scripts/codeoutline/query/explore.lua":"04c670153afe4a2052a06ff9f21bec197ac82faaba53a7bd3335c93d31469544","scripts/codeoutline/analysis/rust/cargo_toml.lua":"78f4f8bcf14f8db80bdac9fc2568988372d3cca222f82b34708f5330c00c8771","scripts/codeoutline/version.lua":"3c66db508542c89884cb96cb7cdcf504f7e9dd94b75b0c4f8a83962e5e7065c3","scripts/codeoutline/lang/lua.lua":"813efafda42e27d0bc9b4bdbf1e9e481ec8b834a6127db54e1ed56e61f7d5626","scripts/codeoutline/analysis/js/js_resolution.lua":"427a4656216878487e9c11a02faa4f6c4240fb00b126ec298479a45c12f3ecce","scripts/codeoutline/query/external_headers.lua":"9b8d8a87a67839d4da1d5eced619d7c54431dbff32b07d505ea54350bdc2de3b","scripts/xupgate/common.lua":"e449f64c92e4ef46d0c9f4c815aacb38866392cbc3502544d3a1985f9dc4f978","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/lang/python.lua":"a0b2b64fe42e585ec922304d3b8ecd6c679a97fecfe1bc56014f1556558c9387","editors/codeoutline.vsix":"c33d53057e8ee1b8fed04898843b74157bd079a8d1ddf0b09dbb27c550a8f95d","scripts/codeoutline/analysis/js/js_workspace.lua":"230df95605e0ce47a940f425611d426eaa3d4de262736e3dfe3bd1f15db956b4","scripts/codeoutline/indexing/index.lua":"459a02dd0c436df968703b74b9fb4624b6fdb4adfffc2383c7abbdb683ef6160","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","scripts/codeoutline/lang/rust.lua":"45d0a9c535d674b31990ba1052f97b2da2a98565a68294937429f443ac1c8da5","DISTRIBUTION.md":"7f1b6d02bd3fa71a7d02cbd57bebd82fbd930d96c1cb32a5f15764466c88ef12","scripts/codeoutline/query/on_demand.lua":"7faf5e4d5f21ca73903903703178d9d983c98d1ddb30d9ca5656bbae676e1f1a","scripts/codeoutline/analysis/js/ts_implementations.lua":"2e92afd3b76a3dab73b99d7900dd357d37b9749a11c5bc11946e0d62d39e7be8","README.zh-CN.md":"d84d8534c4715bb3e92a3928989e0611c17a34b1bee8d812f1b2afb3760a3126","scripts/codeoutline/main.lua":"9f884e383721888af68fd41f3dfdd816e65e4d569346664e390ee086a4b55fa3","README.md":"eac24ff9da12607b720c41059355498351fdd22a8dad1db400333a28f5dc83a3","scripts/codeoutline/query/query_filters.lua":"dfaac210f8ebf53d0e4515866b0128a77ff77cb0c8d7d558b71a4eaf9f2b32ef","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/query/navigation.lua":"a2c444ea0408f528c366674997cd71b1e22691a32150e6f590a3fab1d5dbfeb4","scripts/codeoutline/indexing/cache_repairs.lua":"7e31a6118c3e991382ae2751a8b1d4913bcbf4e24d35f56253f46e156e8420a5","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/codeoutline/query/query_report.lua":"f53c24c48f3f94dd17c7f0be5501865aff0af73d926f27e03d9849c168996462","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/analysis/cpp/cpp_macros.lua":"fa79cd9ea652be2a921f930d0ec21dcfc1d61b15e0ea2cd22ad4141eeb4e9552","scripts/codeoutline/query/search_ranking.lua":"153987a2915c48516b8dca10121b8efa2b116af8cf82200243e45f1fd5feffb4","scripts/codeoutline/parsing/common.lua":"6c883bb69827fd9e88e35f7ecc380f43e3a839fbea127e46ad6923c44beeb590","scripts/codeoutline/analysis/automatic_events.lua":"2d81c3e943964680e13b6005b823f05637c31891f3759fec7074e14d20b7f150","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/analysis/cpp/cpp_receivers.lua":"4f9bea5325d0ccd3ddfe5117bf8891408d41988bdc94d6a388363624b64df0f3","scripts/codeoutline/query/type_hierarchy.lua":"e5ccfa85ac63c636f50d33310274559624c08954e1f77a197ff941d799669b37","scripts/codeoutline/parsing/language_detect.lua":"4c9fd0fcd270cfd123e9e9d0bcc2f3635cd19a8784098a03cee6bce5ac593e8c","scripts/codeoutline/runtime/index_worker.lua":"0bfbf38fe9cb6e8a92b958028c6df9970575f881330dd4568a621463d20497b8","editors/zed/extension.toml":"2c5e28806d71e03b0c421d35b8a9aa9e1d428038417aebd7bdf3c871b22d93f4","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/analysis/cpp/cpp_types.lua":"18e68635a30f86a8975cc556839ed2be961685353dec290749fd169d3049cf16","scripts/codeoutline/parsing/parse.lua":"81dacf0f07440f1a7516732c39251d0d7f07cef77f7d8f9f25bdacd96c7919a0","scripts/xupgate/http_client.lua":"e910132b82779969926f959fc876da4aa4807559f91d1d01d32b263f1784e01d","scripts/codeoutline/indexing/parse_pool.lua":"5a35dad6a6a44a2dccd793a694e65e5a2bdb621911d56bdb32375ce8295889d8","scripts/xupgate/client.lua":"88d8ccdd54282257d233af714fad22abc7af4b9ad65882f58330cc8814461985","editors/zed/extension.wasm":"9d96fc4cff01cc0a354240325d7b6596cba1e6c5e4fedd4d2ecb3f31caa4dfec","scripts/codeoutline/parsing/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","scripts/codeoutline/update_sequence.lua":"3e6f9b2707439adb92c6db6aa550c225676ae7de6b9e7f20bf897bbbf07e0b57","scripts/codeoutline/analysis/cpp/cpp_bindings.lua":"06adeb3b4a56d97555b6e4bd775de8dd1c9d2331474b670d53188d4fbe4b3b0c","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/analysis/csharp/csharp_bindings.lua":"722c8fb2b133bbe09179293b068967fe70e7a2e8942380068a04a97b1283a43d","scripts/codeoutline/shared/text.lua":"56ee63c7b4cc63fe12d8ecd5b99410281463cdba8ca112f484e402ca6dfc5b90","scripts/codeoutline/runtime/idle_gc.lua":"2025b037b593b5e19714b6e283c8a0490146e591de795988a543a161277714f1","scripts/codeoutline/lang/go.lua":"027afb44a9c3a92aa74b9af230d8571963183697529fd41fe915ffa831f3e8da","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/analysis/cpp/cpp_implementations.lua":"87d637812626672f44226e245f94d675e209a83e4cd2d6b2a320ed9d60a6a3d0","scripts/codeoutline/install/agent_config.lua":"041e1736f7be060b9eac9f3ced0b20f50854d94af2cddfa22c5d3868f3fc1681","scripts/codeoutline/analysis/dispatch_aliases.lua":"05f3b06d7d890089b8e18a2e849df9a5ec433bce5312a22d80b7be417e614373","scripts/codeoutline/protocol/http.lua":"bd558939df95e4a908551f43ca5bf0eb68d7a16b8eb20b1b4076a5ece20956b7","scripts/codeoutline/analysis/indirect.lua":"38e15056251400f840604af29fb3ddacac7915d2cf1c2bf7870d481497cc8831","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/analysis/cpp/cpp_includes.lua":"7a2de73f528a608eb89aea0f5fe8d18b3ef51d6e9966106af0ecd41f03304d07","scripts/codeoutline/install/agent_install.lua":"32409b49dd1e8436169f334587b4994c9d6868ed3ff5c4eaed09b4b3b8ca12c4","scripts/codeoutline/analysis/foreign.lua":"4c8fdbe398f2b43be861ce0e4915916956c1fb2af6c10c5c04a9654e8aac2bf2","scripts/codeoutline/protocol/lsp.lua":"f236c0407dc8b479c883cd526a19dca61efd999926e70d564d299c3972074224","keys/update-ca.crt":"45b509a584e187fdedb666f2d8df9039f36e6bde86170b2426e583721ff42b42","scripts/codeoutline/runtime/parse_worker.lua":"4cb620924fbe43d0f9a411c689060575220c0b2947d09fba266fe552ad003cfe","scripts/codeoutline/install/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/runtime/update_worker.lua":"9557e5207e440fccf15e8255b3fb1c8933ad33d1f352c19987fb825f7db45706","scripts/codeoutline/analysis/function_values.lua":"d10bc4a2a82a90a611daf3c2bb26c41da43543f7831711bd4b0c311ad5569d80","scripts/codeoutline/query/type_references.lua":"9119a2c55b2ae825190ac50d97d6a4cacacd33a707cd1e98b532c4a7d02e4a0c","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/install/editor_install.lua":"a69f5e123f7fbdb58fe2da691c744c0668a11ccd88f17a98167038c80a5d4cff","scripts/codeoutline/service.lua":"795797bf7d3b329e67fff5b3d8bd9ab2681dfb2472f7d9a8236756bea67c0c56","scripts/codeoutline/protocol/mcp.lua":"1e65df410d6cede3cc0fb227ea406a5e7e178d425b5ed861f73d8b748fbdbae7","scripts/codeoutline/analysis/rust/rust_resolution.lua":"2b9ec789243cda63107a721e8d907faa3d3d5c18f21a69b634db4deac9e586ee","scripts/codeoutline/analysis/lua/lua_bindings.lua":"8fa65c14a7da95ec2d3ded2484807481123216af05c9ba8c70c929d4d4b0490d","scripts/codeoutline/install/install_prompt.lua":"588c90cd2955756b13a96e1f0d17145a51eda239c9cf179d5eac195532ee9f49","scripts/codeoutline/query/coverage.lua":"3a4a0e5f5ea8b7ea4a0be62c7c1a202153cf0c5c3423f78b100aecbb39513d5e","scripts/codeoutline/protocol/lsp_trace.lua":"41e6e67866eb6c862cf11337a637a94505f62a29533a9dbd6226d3b801444597","scripts/codeoutline/analysis/lua/foreign_lua.lua":"c217da78314febeff5d20c9d7e9f68e25089d1e76f4350405d83af494deac3dc","scripts/codeoutline/analysis/go/go_frameworks.lua":"2f2a692a6dbda384abf32af0750bb40e99f1bc3e83f039215f0eaf750cf77f65","scripts/codeoutline/analysis/lua/lua_callback_loops.lua":"2b28f338ebc23c8a6543fad61e932ceaee409512b69a71711d385fcc0bdafd4c","scripts/codeoutline/analysis/ordinary_bindings.lua":"ec9f3609650f2ec05dd429e178118a4dded9b6c40cfecdd5efcdeb5e0bb2ad94","scripts/codeoutline/analysis/rust/rust_packages.lua":"c6886a77017bf039499d93027b28bd354599875a5d3705f622ea3366512432e8","scripts/codeoutline/shared/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/analysis/lua/lua_literal.lua":"5fdd90a872988622337410c7e516d41b789ce4326c4aa6dddcd61998fe5aef90","scripts/codeoutline/analysis/static_dispatch.lua":"9940f4c4317e8f5345a9f39178fac639278bc186265a72369f1be808bdeebd29","scripts/codeoutline/analysis/go/go_methods.lua":"71832a6b8941a6b6f9155c59cec2da7c33108a132608cdaa2cd85076c4e241cf","scripts/codeoutline/analysis/shared_events.lua":"88fb64d66e6d41da3beeaeff86f6357b5a8ceae16003ba194aaa01171e4874f1","scripts/codeoutline/lang/csharp.lua":"93762ccefd326fb04fcc5c5dd73821241216e9374de2abbe9e4f53fe5af1c160","scripts/codeoutline/shared/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/indexing/cpp_fragments.lua":"6be4c3f89c234b6982235981d9f128875790acd5d22f80fe11290bb99af903a3","scripts/codeoutline/analysis/type_bases.lua":"470fdcfffc3ded8bd3c9608db6128539757c91692bc714173dbb1bcdf8344e36","scripts/codeoutline/analysis/go/go_modules.lua":"432dc66435fe93fbc2a7d1aa4212ae03ad5454effd18ffb3e06c2eca6a169aab","scripts/codeoutline/lang/c.lua":"f341d250a09a937d8548657991bdeac0aec8de26b7d056292709126ee999c6f1","scripts/codeoutline/shared/rules.lua":"d2a6ead429ead37d491c7eacdbcc9fa6579fcd1a7749af1345050938f0c1b5a8"},"updateSequence":28,"runtimeBuild":"4f732f99896571583bf36c62f9e00127fdffe245f43bacd27ee38e08d9cd1298"}
1
+ {"runtimeCommit":"0a54bdf10c492cf109faf4f8d031e328b01e517a","runtimeBuild":"4f732f99896571583bf36c62f9e00127fdffe245f43bacd27ee38e08d9cd1298","lua":"LuaJIT 2.1.1774896198","sourceCommit":"7ec34831609eac6fe8cc888fac5cf584d6f1ac4f","sourceDirty":false,"releaseReady":true,"note":"Release build from a clean checkout","version":"0.5.0","target":"win32-x64","updateSequence":29,"sha256":{"scripts/codeoutline/analysis/cpp/cpp_implementations.lua":"87d637812626672f44226e245f94d675e209a83e4cd2d6b2a320ed9d60a6a3d0","scripts/codeoutline/query/type_hierarchy.lua":"e5ccfa85ac63c636f50d33310274559624c08954e1f77a197ff941d799669b37","codeoutline.cmd":"52ee46a6010ff1161369e50df76e96beed2d6152f8c8e5095f73bc0b60a7629b","scripts/codeoutline/install/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/analysis/receivers.lua":"3b2d09cab61dac5549e96fb007d0538661391c1d4f25573d1872221d8c7b2d3c","scripts/codeoutline/analysis/cpp/cpp_includes.lua":"7a2de73f528a608eb89aea0f5fe8d18b3ef51d6e9966106af0ecd41f03304d07","scripts/codeoutline/install/editor_install.lua":"a69f5e123f7fbdb58fe2da691c744c0668a11ccd88f17a98167038c80a5d4cff","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/analysis/rust/rust_resolution.lua":"2b9ec789243cda63107a721e8d907faa3d3d5c18f21a69b634db4deac9e586ee","scripts/codeoutline/analysis/resolution.lua":"ec137a38abfdcb7f366861a123480a3b3125a76acf7399a784f8fb207e833d0b","scripts/codeoutline/analysis/cpp/cpp_macros.lua":"fa79cd9ea652be2a921f930d0ec21dcfc1d61b15e0ea2cd22ad4141eeb4e9552","scripts/codeoutline/install/install_prompt.lua":"588c90cd2955756b13a96e1f0d17145a51eda239c9cf179d5eac195532ee9f49","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/analysis/shared_events.lua":"88fb64d66e6d41da3beeaeff86f6357b5a8ceae16003ba194aaa01171e4874f1","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/analysis/cpp/cpp_receivers.lua":"4f9bea5325d0ccd3ddfe5117bf8891408d41988bdc94d6a388363624b64df0f3","scripts/codeoutline/runtime/bm25_worker.lua":"9d1d67b4e4f238e5a142ceb0c6164eab9828447ff93a7643398b0ab26a2dc1d3","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/codeoutline/analysis/static_dispatch.lua":"9940f4c4317e8f5345a9f39178fac639278bc186265a72369f1be808bdeebd29","scripts/codeoutline/analysis/rust/cargo_toml.lua":"78f4f8bcf14f8db80bdac9fc2568988372d3cca222f82b34708f5330c00c8771","scripts/codeoutline/analysis/cpp/cpp_types.lua":"18e68635a30f86a8975cc556839ed2be961685353dec290749fd169d3049cf16","scripts/codeoutline/runtime/idle_gc.lua":"2025b037b593b5e19714b6e283c8a0490146e591de795988a543a161277714f1","scripts/codeoutline/query/affected.lua":"7fe6ae466b314957f39ceb8fcc1f0a5339d523c86f99ce5735599a2477865b72","codeoutline":"1909247ba17be9d0fe14d689ea7c1c955013b5b79f05336e2161b6f161c4c394","scripts/codeoutline/analysis/type_bases.lua":"470fdcfffc3ded8bd3c9608db6128539757c91692bc714173dbb1bcdf8344e36","editors/zed/extension.wasm":"7393ede118d7e4cff6a0eed8dbf270e17842a6eb816780624d56c53bc3f5775a","scripts/codeoutline/analysis/rust/rust_packages.lua":"c6886a77017bf039499d93027b28bd354599875a5d3705f622ea3366512432e8","editors/zed/extension.toml":"2c5e28806d71e03b0c421d35b8a9aa9e1d428038417aebd7bdf3c871b22d93f4","scripts/codeoutline/query/callers.lua":"b1870f2d08c2274ce743d513560ce9329e16236399e065027685dbf8694c82ab","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/analysis/type_uses.lua":"eb1ee73f0a3cb67ef3b92ed1a8b7222fbc26137f743e466338e180b416ea12cb","scripts/codeoutline/lang/c.lua":"f341d250a09a937d8548657991bdeac0aec8de26b7d056292709126ee999c6f1","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","scripts/codeoutline/query/completion.lua":"ff2c4102b9a73042f84e823e13ce685aa1d164ee84765db513da2b8ae515e763","README.zh-CN.md":"d7fc04e2bfd091003da1e6656c2f8ca4f789afd62b15650163261e2279cf0f9c","DISTRIBUTION.md":"7f1b6d02bd3fa71a7d02cbd57bebd82fbd930d96c1cb32a5f15764466c88ef12","scripts/codeoutline/lang/go.lua":"027afb44a9c3a92aa74b9af230d8571963183697529fd41fe915ffa831f3e8da","scripts/codeoutline/lang/cpp.lua":"e13eaf1882cddb20a7a651d13136e06ca42c482cf7ac53de38bf82fdda786727","scripts/codeoutline/query/coverage.lua":"9934631a8e1a4c3f43b9c380891092dffa4a8b3460d1ab4765febd5d9534e002","README.md":"8e7a61baf63b4f331183989c617fcda8ffe936f89acb03af3394e809d05f3440","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/java.lua":"3c6b2d844202cbe988644e94090be76e7f8a2a906f4412aefcbd06e9fb56a01b","scripts/codeoutline/lang/csharp.lua":"93762ccefd326fb04fcc5c5dd73821241216e9374de2abbe9e4f53fe5af1c160","scripts/codeoutline/analysis/foreign.lua":"4c8fdbe398f2b43be861ce0e4915916956c1fb2af6c10c5c04a9654e8aac2bf2","editors/codeoutline.vsix":"fb920d4d9e509ac4b3d5acc07ba717f7dc582385ce2f56e1ecf31932c04a4e5e","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/lang/js.lua":"ff326c9ef41deb5ec7f961a556350b69c4b601a176d696114a2096d5118c2379","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/query/documents.lua":"1ed27cb6f805c1ff9acbc070f16e582b71c4a330c5539fb3d7b8ed4150c82bdf","scripts/codeoutline/analysis/function_values.lua":"d10bc4a2a82a90a611daf3c2bb26c41da43543f7831711bd4b0c311ad5569d80","scripts/codeoutline/bm25/collect.lua":"eafbc9b62fa2a1acb3d82bc07242c85d7cb07ddc1fd6e20467c2333b56db463e","scripts/codeoutline/lang/kotlin.lua":"8b5dabbbede62bf0a1376414f7424e6dd3a248739cc015c2364d143901230d86","keys/update-ca.crt":"45b509a584e187fdedb666f2d8df9039f36e6bde86170b2426e583721ff42b42","scripts/codeoutline/query/explore.lua":"08368a8261826e78a0be3d5c2a9de1122c137be5621d0d64a0073fe9f788de75","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","scripts/codeoutline/runtime/parse_worker.lua":"5e8bf3d7d7598e5cab96ec3de3bc679935a16e1f26c310e2801db4f18ce6dc49","scripts/codeoutline/lang/lua.lua":"813efafda42e27d0bc9b4bdbf1e9e481ec8b834a6127db54e1ed56e61f7d5626","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/query/external_headers.lua":"9b8d8a87a67839d4da1d5eced619d7c54431dbff32b07d505ea54350bdc2de3b","scripts/codeoutline/shared/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/analysis/python/python_bindings.lua":"ec4217f77345282a5522696c1b53e3886fb0e9a45736c10613fcb0fd4f016160","scripts/codeoutline/analysis/go/go_frameworks.lua":"2f2a692a6dbda384abf32af0750bb40e99f1bc3e83f039215f0eaf750cf77f65","scripts/codeoutline/bm25/snapshot.lua":"3961aef3d338997fa1d2730b0194b77adc79441e39434b9a7fbb59e6b13ef9c6","scripts/codeoutline/query/navigation.lua":"7bdefe9b4b015019dc13c37d462f9dfcf61cd81448562ff2e555ba531c52eea9","scripts/codeoutline/shared/rules.lua":"d2a6ead429ead37d491c7eacdbcc9fa6579fcd1a7749af1345050938f0c1b5a8","scripts/codeoutline/analysis/js/ts_implementations.lua":"2e92afd3b76a3dab73b99d7900dd357d37b9749a11c5bc11946e0d62d39e7be8","scripts/codeoutline/lang/rust.lua":"45d0a9c535d674b31990ba1052f97b2da2a98565a68294937429f443ac1c8da5","scripts/codeoutline/protocol/mcp.lua":"d838de7d18a9de2ec2643ffb18733268c072afbe5250c1c16ee43cdf63d2c9f7","scripts/codeoutline/analysis/go/go_methods.lua":"71832a6b8941a6b6f9155c59cec2da7c33108a132608cdaa2cd85076c4e241cf","scripts/codeoutline/cli.lua":"28b058bbb3c86d9e6a7603c52ef62eacc8978af6c2201e61bfb8100bc79be4b2","scripts/codeoutline/runtime/index_worker.lua":"d48dc89d87a767b3412b81c65db6c24a7419acbb29ee2517965132048963af36","scripts/codeoutline/main.lua":"2ff4131d73c19aa525e476f9fd1ebe61d9346accf467adc9f5e374196d06e31b","scripts/codeoutline/service.lua":"48352bbf214c5044f01595332bed959f3a6b27b3731b0a664a1edcad3b31e60b","scripts/codeoutline/query/query_filters.lua":"fd2a3bfccccf1892af737f7a785d8920765fb2986aea07f8b27a4aa45f9f83a0","scripts/codeoutline/analysis/go/go_modules.lua":"432dc66435fe93fbc2a7d1aa4212ae03ad5454effd18ffb3e06c2eca6a169aab","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/command.lua":"3e85c469d3f4eabeb9bae662c6fa6daf46eccb47886f40feb7406a7f486bc553","scripts/codeoutline/shared/text.lua":"56ee63c7b4cc63fe12d8ecd5b99410281463cdba8ca112f484e402ca6dfc5b90","scripts/codeoutline/shared/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/update_sequence.lua":"13e67c411d38afbe786d04ccee575e70be5e1eeb50484c1e711d53fcbb62de0c","scripts/codeoutline/analysis/graph.lua":"70eed1852ca77615de7530947b1278a83ae38e04d1a26930251bc506de357541","scripts/codeoutline/runtime/update_worker.lua":"9557e5207e440fccf15e8255b3fb1c8933ad33d1f352c19987fb825f7db45706","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/parsing/common.lua":"6c883bb69827fd9e88e35f7ecc380f43e3a839fbea127e46ad6923c44beeb590","scripts/codeoutline/version.lua":"79509300798f95d9deceb6790d707d8fd968dff0cac0fb6db13b409dbae7cc87","scripts/codeoutline/query/type_references.lua":"9119a2c55b2ae825190ac50d97d6a4cacacd33a707cd1e98b532c4a7d02e4a0c","scripts/codeoutline/analysis/implementations.lua":"ffcd7288eae967c5628c85b8e55d93c826b30524956212dccca7d150ac7ac3be","scripts/codeoutline/analysis/lua/foreign_lua.lua":"c217da78314febeff5d20c9d7e9f68e25089d1e76f4350405d83af494deac3dc","scripts/codeoutline/lang/python.lua":"a0b2b64fe42e585ec922304d3b8ecd6c679a97fecfe1bc56014f1556558c9387","scripts/codeoutline/parsing/language_detect.lua":"4c9fd0fcd270cfd123e9e9d0bcc2f3635cd19a8784098a03cee6bce5ac593e8c","scripts/codeoutline/bm25/automatic.lua":"00b2350d252f31f25436b336ea4148fda7f2a6f98d7530d5194dae9e1bf30a0e","scripts/codeoutline/query/on_demand.lua":"7faf5e4d5f21ca73903903703178d9d983c98d1ddb30d9ca5656bbae676e1f1a","scripts/codeoutline/analysis/indirect.lua":"8b0082ed3bce139fa88654a7c1a1cacd8b3fe4909e8125f3ed6bae87876c8508","scripts/codeoutline/indexing/cpp_fragments.lua":"6be4c3f89c234b6982235981d9f128875790acd5d22f80fe11290bb99af903a3","scripts/codeoutline/analysis/lua/lua_bindings.lua":"71e4ce84fa8a1aea4173054f646e9a6509226e6b5d30b1a43014808283af417a","scripts/codeoutline/query/definition_candidates.lua":"015a04dcb69f99c4b944e21612847c681d695a5e55484d3a5ec1bdede12af9a1","scripts/xupgate/client.lua":"88d8ccdd54282257d233af714fad22abc7af4b9ad65882f58330cc8814461985","scripts/codeoutline/protocol/lsp_trace.lua":"41e6e67866eb6c862cf11337a637a94505f62a29533a9dbd6226d3b801444597","scripts/codeoutline/indexing/index.lua":"459a02dd0c436df968703b74b9fb4624b6fdb4adfffc2383c7abbdb683ef6160","scripts/codeoutline/parsing/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","scripts/codeoutline/analysis/automatic_events.lua":"2d81c3e943964680e13b6005b823f05637c31891f3759fec7074e14d20b7f150","scripts/codeoutline/protocol/lsp.lua":"71cdd08ece3ed32e9bce6d27472ce436f44e80eafea859063fbf842ac6c12912","scripts/xupgate/common.lua":"e449f64c92e4ef46d0c9f4c815aacb38866392cbc3502544d3a1985f9dc4f978","bin/xnet.exe":"03956591bd2545fee0f23ee2c65fa4c5435116a4cf26511811d8538364eacc26","scripts/codeoutline/parsing/parse.lua":"81dacf0f07440f1a7516732c39251d0d7f07cef77f7d8f9f25bdacd96c7919a0","scripts/codeoutline/analysis/js/js_evidence.lua":"523913dcadb37ec433b31103c12218c383001851b7cf965cf4505065917d8afe","scripts/codeoutline/analysis/lua/lua_literal.lua":"5fdd90a872988622337410c7e516d41b789ce4326c4aa6dddcd61998fe5aef90","scripts/xupgate/http_client.lua":"e910132b82779969926f959fc876da4aa4807559f91d1d01d32b263f1784e01d","scripts/codeoutline/analysis/lua/lua_callback_loops.lua":"2b28f338ebc23c8a6543fad61e932ceaee409512b69a71711d385fcc0bdafd4c","scripts/codeoutline/bm25/index.lua":"8d9053f2317dadac99f056d3d7b24366ca5f2cb51c66f4a380a3e042d51c56f6","scripts/codeoutline/analysis/js/js_resolution.lua":"427a4656216878487e9c11a02faa4f6c4240fb00b126ec298479a45c12f3ecce","scripts/codeoutline/protocol/http.lua":"bd558939df95e4a908551f43ca5bf0eb68d7a16b8eb20b1b4076a5ece20956b7","scripts/codeoutline/analysis/ordinary_bindings.lua":"ec9f3609650f2ec05dd429e178118a4dded9b6c40cfecdd5efcdeb5e0bb2ad94","scripts/codeoutline/indexing/parse_pool.lua":"eb12c135a02691091bb950bdfd189e008b58b01a52e0d2dab6bf63d2bd26191d","scripts/codeoutline/indexing/cache_repairs.lua":"7e31a6118c3e991382ae2751a8b1d4913bcbf4e24d35f56253f46e156e8420a5","scripts/codeoutline/query/query_report.lua":"f53c24c48f3f94dd17c7f0be5501865aff0af73d926f27e03d9849c168996462","scripts/codeoutline/install/agent_config.lua":"041e1736f7be060b9eac9f3ced0b20f50854d94af2cddfa22c5d3868f3fc1681","scripts/codeoutline/analysis/cpp/cpp_bindings.lua":"06adeb3b4a56d97555b6e4bd775de8dd1c9d2331474b670d53188d4fbe4b3b0c","scripts/codeoutline/analysis/js/js_workspace.lua":"230df95605e0ce47a940f425611d426eaa3d4de262736e3dfe3bd1f15db956b4","scripts/codeoutline/analysis/dispatch_aliases.lua":"05f3b06d7d890089b8e18a2e849df9a5ec433bce5312a22d80b7be417e614373","scripts/codeoutline/query/search_ranking.lua":"153987a2915c48516b8dca10121b8efa2b116af8cf82200243e45f1fd5feffb4","scripts/codeoutline/analysis/csharp/csharp_bindings.lua":"722c8fb2b133bbe09179293b068967fe70e7a2e8942380068a04a97b1283a43d","scripts/codeoutline/install/agent_install.lua":"32409b49dd1e8436169f334587b4994c9d6868ed3ff5c4eaed09b4b3b8ca12c4"}}
Binary file
Binary file
package/package.json CHANGED
@@ -1 +1 @@
1
- {"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"version":"0.3.9","os":["win32"],"name":"@codua/codeoutline-win32-x64","publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","files":["bin/","lib/","keys/","scripts/","editors/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"]}
1
+ {"os":["win32"],"license":"BSD-2-Clause","name":"@codua/codeoutline-win32-x64","version":"0.5.0","files":["bin/","lib/","keys/","scripts/","editors/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"cpu":["x64","arm64"],"repository":{"type":"git","url":"git+https://github.com/1dao/codeoutline.git"},"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64"}
@@ -100,6 +100,22 @@ function M.candidate(rec, call)
100
100
  return false
101
101
  end
102
102
 
103
+ -- A resolved Lua literal, including one assigned to a local alias, must
104
+ -- occur in the file. Scan tokens only if escapes can hide its spelling.
105
+ function M.has_lua_literal(source, literals)
106
+ for name in pairs(literals) do
107
+ if source:find(name, 1, true) then return true end
108
+ end
109
+ if not source:find('\\', 1, true) then return false end
110
+ local T = require('codeoutline.lang.lua').lang:tokenize(source)
111
+ local decode = require('codeoutline.analysis.lua.lua_literal').decode
112
+ for i = 1, T.n do
113
+ if i % 4096 == 0 then control.check() end
114
+ if T.k[i] == 'str' and literals[decode(T:text(i))] then return true end
115
+ end
116
+ return false
117
+ end
118
+
103
119
  function M.query(G, rules, report)
104
120
  rules = rules_for(G, rules)
105
121
  if #rules == 0 then return { outgoing = function() return {} end, incoming = function() return {} end } end
@@ -124,20 +140,10 @@ function M.query(G, rules, report)
124
140
  -- Target rules can only obtain a literal command from this file. Reject
125
141
  -- broad module hints before scope/registry analysis, but decode escaped
126
142
  -- Lua literals so aliases and alternate spellings remain candidates.
127
- if literals and rec.language == 'lua' then
128
- local relevant = false
129
- for name in pairs(literals) do if source:find(name, 1, true) then relevant = true; break end end
130
- if not relevant and source:find('\\', 1, true) then
131
- local T = require('codeoutline.lang.lua').lang:tokenize(source)
132
- local decode = require('codeoutline.analysis.lua.lua_literal').decode
133
- for i = 1, T.n do
134
- if i % 4096 == 0 then control.check() end
135
- if T.k[i] == 'str' and literals[decode(T:text(i))] then relevant = true; break end
136
- end
137
- end
143
+ if literals and rec.language == 'lua' and not M.has_lua_literal(source, literals) then
138
144
  -- Do not cache negatives: later incoming calls can request other
139
145
  -- targets within this same query, and outgoing needs all sites.
140
- if not relevant then return {} end
146
+ return {}
141
147
  end
142
148
  local parsed = assert(require('codeoutline.parsing.parse').parse(rec.path, source,
143
149
  { ranges = false, dispatch = names, dispatch_only = true, language = rec.language }))
@@ -42,6 +42,29 @@ local function binding_at(bindings, name, token)
42
42
  return best
43
43
  end
44
44
 
45
+ -- If this receiver can be used as a table, a named guard followed by
46
+ -- "and require(...)" can only have produced the module on the right.
47
+ local function guarded_require(T, bindings, first)
48
+ local last = first
49
+ if T.k[first] == 'id' then
50
+ while (T:text(last + 1) == '.' or T:text(last + 1) == ':') and T.k[last + 2] == 'id' do
51
+ last = last + 2
52
+ end
53
+ if T:text(last + 1) == '(' then last = T.m[last + 1] end
54
+ elseif T:text(first) == '(' then
55
+ last = T.m[first]
56
+ else return nil end
57
+ if not last or T:text(last + 1) ~= 'and' then return nil end
58
+ local loader = last + 2
59
+ if T:text(loader) ~= 'require' or binding_at(bindings, 'require', loader - 1) then return nil end
60
+ local open = loader + 1
61
+ local parenthesized = T:text(open) == '('
62
+ local arg = parenthesized and open + 1 or open
63
+ local close = parenthesized and T.m[open] or arg
64
+ if parenthesized and close ~= arg + 1 or not value_end(T, close + 1) then return nil end
65
+ return literal(T, arg)
66
+ end
67
+
45
68
  -- A nil-initialized local can receive a module in a sibling if block. Keep
46
69
  -- possible imports at later uses, and stop on a write we cannot model. Only the
47
70
  -- last write of each branch survives; sibling branches keep their source order.
@@ -211,6 +234,9 @@ function M.collect(r, T, bm)
211
234
  end
212
235
  end
213
236
  end
237
+ elseif details and next == '=' then
238
+ local path = guarded_require(T, bindings, i + 2)
239
+ if path then hint, imported = 'lua-guard:' .. path, true end
214
240
  end
215
241
  -- Keep ordinary local function/table lookup; block unknown imported receivers.
216
242
  add(T:text(i), i, scopes[i], hint, imported, finish)
@@ -658,6 +684,8 @@ local function module_target(G, imp, ctx)
658
684
  end
659
685
 
660
686
  local function imported_target(G, rec, hint, ctx)
687
+ local guarded = hint:match('^lua%-guard:(.+)$')
688
+ if guarded then return module_target(G, { kind = 'require', path = guarded }, ctx) end
661
689
  local index = tonumber(hint:match('^lua:(%d+)$'))
662
690
  if index then
663
691
  local imp = (rec.lua_imports or EMPTY)[index]
@@ -0,0 +1,100 @@
1
+ -- Foreground coordinator. The lexical index is built in a separate Lua state
2
+ -- from the saved base snapshot, never in the foreground request coroutine.
3
+ local snapshot = require('codeoutline.bm25.snapshot')
4
+ local control = require('codeoutline.shared.control')
5
+ local M = {worker_id = 6}
6
+ local queue, active, failure = {}, nil, nil
7
+ local lookup, next_lookup = nil, 0
8
+
9
+ local function enqueue(index, file, stamp, repair)
10
+ if index:needs_save() then return 'unavailable' end
11
+ if active and active.file == file and active.stamp == stamp then return 'building' end
12
+ if failure and failure.file == file and failure.stamp == stamp and xtimer.now_ms() < failure.retry then
13
+ return 'unavailable'
14
+ end
15
+ local item = {root = index.root, cache = index.cache_path, file = file, stamp = stamp, repair = repair}
16
+ for i, pending in ipairs(queue) do
17
+ if pending.file == file then
18
+ if pending.stamp ~= stamp or repair then queue[i] = item end
19
+ return 'building'
20
+ end
21
+ end
22
+ -- A wide burst of projects should not reserve a full build for each one.
23
+ if #queue >= 8 then return 'unavailable' end
24
+ queue[#queue + 1] = item
25
+ return 'building'
26
+ end
27
+
28
+ function M.prepare(index)
29
+ local file = index.cache_path .. '.bm25'
30
+ local stamp = snapshot.stamp(index)
31
+ if not snapshot.current(file, stamp) then enqueue(index, file, stamp) end
32
+ return function(query, accept, match)
33
+ local current = snapshot.stamp(index)
34
+ if not snapshot.current(file, current) then return nil, enqueue(index, file, current) end
35
+ local ok, result = pcall(require('codeoutline.bm25.index').search, index, file, query,
36
+ {limit = 20, accept = accept, match = match})
37
+ if ok then return result, 'searched' end
38
+ if control.is_interrupted(result) then error(result, 0) end
39
+ -- The header may have changed after the quick check, or a block may
40
+ -- be corrupt. Regenerate and preserve the original zero-match result.
41
+ return nil, enqueue(index, file, current, true)
42
+ end
43
+ end
44
+
45
+ function M.definition(index, query, deadline, prefix)
46
+ local file = index.cache_path .. '.bm25'
47
+ local stamp = snapshot.stamp(index)
48
+ if not snapshot.current(file, stamp) then
49
+ return nil, enqueue(index, file, stamp) == 'building' and 'bm25_building' or true
50
+ end
51
+ local now = xtimer.now_ms()
52
+ if active or lookup or now >= deadline then return nil, true end
53
+ next_lookup = next_lookup + 1
54
+ -- Let a cold header warm in the background after F12 returns.
55
+ local work_until = now + 2000
56
+ local posted = xthread.post(M.worker_id, 'bm25_lookup', xthread.current_id(), next_lookup,
57
+ {root = index.root, stamp = stamp, file = file, query = query, deadline = work_until, prefix = prefix})
58
+ if not posted then return nil, true end
59
+ lookup = {token = next_lookup, wait_until = math.min(now + 180, deadline), work_until = work_until}
60
+ local ok, result = coroutine.yield()
61
+ control.check()
62
+ if ok then return result, false end
63
+ if type(result) == 'string' and (result:find('corrupt BM25', 1, true)
64
+ or result:find('invalid BM25', 1, true)) then
65
+ return nil, enqueue(index, file, stamp, true) == 'building' and 'bm25_building' or true
66
+ end
67
+ return nil, true
68
+ end
69
+
70
+ function M.receive_lookup(token)
71
+ if not lookup or lookup.token ~= token then return false end
72
+ local waiting = lookup.wait_until ~= nil
73
+ lookup = nil
74
+ return waiting
75
+ end
76
+
77
+ function M.expire_lookup()
78
+ if not lookup then return false end
79
+ local now = xtimer.now_ms()
80
+ local expired = lookup.wait_until and now >= lookup.wait_until
81
+ if expired then lookup.wait_until = nil end
82
+ if now >= lookup.work_until then lookup = nil end
83
+ return expired
84
+ end
85
+
86
+ function M.pump()
87
+ if active or lookup or #queue == 0 then return end
88
+ local item = table.remove(queue, 1)
89
+ local posted = xthread.post(M.worker_id, 'bm25_build', xthread.current_id(), item)
90
+ if posted then active = item
91
+ else failure = {file = item.file, stamp = item.stamp, retry = xtimer.now_ms() + 1000} end
92
+ end
93
+
94
+ function M.finish(file, stamp, ok)
95
+ if not active or active.file ~= file or active.stamp ~= stamp then return end
96
+ if not ok then failure = {file = file, stamp = stamp, retry = xtimer.now_ms() + 1000} end
97
+ active = nil
98
+ end
99
+
100
+ return M
@@ -0,0 +1,148 @@
1
+ -- Internal lexical document extraction. Base index records stay unchanged.
2
+ local control = require('codeoutline.shared.control')
3
+ local M = { weights = {3, 2, 1, 1} }
4
+
5
+ local stop_words = {}
6
+ for word in ([[
7
+ a an and are as at be by can could do does during for from had has have how
8
+ i if in is it of on or that the their them this to was were when where which
9
+ who will with would you your
10
+ ]]):gmatch('%S+') do
11
+ stop_words[word] = true
12
+ end
13
+
14
+ local function scan_words(text, visit)
15
+ text = text:gsub('([A-Z])([A-Z][a-z])', '%1 %2')
16
+ text = text:gsub('([a-z0-9])([A-Z])', '%1 %2'):lower()
17
+ local ordinal = 0
18
+ for group in text:gmatch('[a-z0-9]+') do
19
+ local pos = 1
20
+ while pos <= #group do
21
+ local token = group:match('^[a-z]+', pos) or group:match('^[0-9]+', pos)
22
+ pos = pos + #token
23
+ ordinal = ordinal + 1
24
+ if not stop_words[token] then
25
+ local ending = token:sub(-2)
26
+ if #token > 4 and token:sub(-1) == 's'
27
+ and ending ~= 'ss' and ending ~= 'us' and ending ~= 'is' then
28
+ token = token:sub(1, -2)
29
+ end
30
+ if visit(token, ordinal) == false then return end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ function M.tokenize(text)
37
+ local counts, length = {}, 0
38
+ scan_words(text, function(word)
39
+ counts[word] = (counts[word] or 0) + 1
40
+ length = length + 1
41
+ end)
42
+ return counts, length
43
+ end
44
+
45
+ -- Smallest window containing every query term, regardless of order.
46
+ -- Positions count stop words so that skipping them does not shrink a gap.
47
+ function M.gap(text, query, needed)
48
+ local words, positions, counts = {}, {}, {}
49
+ local left, distinct, best = 1, 0, nil
50
+ scan_words(text, function(word, position)
51
+ if not query[word] then return end
52
+ local right = #words + 1
53
+ words[right], positions[right] = word, position
54
+ if not counts[word] or counts[word] == 0 then distinct = distinct + 1 end
55
+ counts[word] = (counts[word] or 0) + 1
56
+ while distinct == needed do
57
+ local gap = position - positions[left] + 1 - needed
58
+ if not best or gap < best then best = gap end
59
+ if best == 0 then return false end
60
+ local first = words[left]
61
+ counts[first] = counts[first] - 1
62
+ if counts[first] == 0 then distinct = distinct - 1 end
63
+ left = left + 1
64
+ end
65
+ end)
66
+ return best
67
+ end
68
+
69
+ local function line_offsets(source)
70
+ local offsets, pos = {1}, 1
71
+ while true do
72
+ local eol = source:find('\n', pos, true)
73
+ if not eol then return offsets end
74
+ pos = eol + 1
75
+ offsets[#offsets + 1] = pos
76
+ end
77
+ end
78
+
79
+ -- Scan only the lexical gap above the declaration. The tokenizer excludes
80
+ -- comments but keeps string spans, including Lua long strings.
81
+ local function leading_lua_doc(tokens, start, previous_end)
82
+ local gap = tokens.src:sub(previous_end + 1, start - 1)
83
+ if not gap:find('--', 1, true) then return '' end
84
+ local comments, pos, standalone = {}, 1, previous_end == 0
85
+ while pos <= #gap do
86
+ local space = gap:match('^%s*', pos)
87
+ pos = pos + #space
88
+ local _, breaks = space:gsub('\n', '')
89
+ if breaks > 1 then comments = {} end
90
+ if breaks > 0 then standalone = true end
91
+ if pos > #gap then break end
92
+ if gap:sub(pos, pos + 1) ~= '--' then return '' end
93
+ local _, open_end, equals = gap:find('^%-%-%[(=*)%[', pos)
94
+ local first, last
95
+ if open_end then
96
+ local close_start, close_end = gap:find(']' .. equals .. ']', open_end + 1, true)
97
+ if not close_start then return '' end
98
+ first, last, pos = open_end + 1, close_start - 1, close_end + 1
99
+ else
100
+ local eol = gap:find('\n', pos, true) or #gap + 1
101
+ first, last, pos = pos + 2, eol - 1, eol
102
+ end
103
+ if standalone then comments[#comments + 1] = gap:sub(first, last) end
104
+ standalone = false
105
+ end
106
+ return table.concat(comments, '\n'):sub(1, 512)
107
+ end
108
+
109
+ function M.file(abs, rel, size, crc, language, documents)
110
+ control.check()
111
+ local file = assert(io.open(abs, 'rb'))
112
+ local raw = file:read(size + 1) or ''
113
+ assert(file:close())
114
+ local actual = xcompress and xcompress.crc32 and xcompress.crc32(raw) or xutils.sha256_hex(raw)
115
+ assert(#raw == size and actual == crc, 'source changed during BM25 build: ' .. rel)
116
+ -- The tokenizer only indexes ASCII. Retaining raw bytes if decoding is
117
+ -- unavailable keeps ASCII terms and the base index's line coordinates.
118
+ local source = xutils.to_utf8(raw) or raw
119
+ if source:sub(1, 3) == '\239\187\191' then source = source:sub(4) end
120
+ local offsets = line_offsets(source)
121
+ local tokens = language == 'lua' and require('codeoutline.lang.lua').lang:tokenize(source)
122
+ local totals, encoded, comment_count = {0, 0, 0, 0}, {}, 0
123
+ local token = 1
124
+ for i, document in ipairs(documents) do
125
+ if i % 128 == 0 then control.check() end
126
+ local id, name, line, end_line = table.unpack(document)
127
+ local first = assert(offsets[line], 'invalid BM25 source line: ' .. rel)
128
+ local last = math.min((offsets[end_line + 1] or #source + 1) - 1,
129
+ (offsets[line + 40] or #source + 1) - 1, first + 2047)
130
+ local doc = ''
131
+ if tokens then
132
+ while token <= tokens.n and tokens.s[token] < first do token = token + 1 end
133
+ doc = leading_lua_doc(tokens, first, tokens.e[token - 1] or 0)
134
+ if doc:find('%S') then comment_count = comment_count + 1 end
135
+ end
136
+ local fields = {}
137
+ local body = source:sub(first, last)
138
+ for field, value in ipairs({name, rel, body, doc}) do
139
+ local terms, length = M.tokenize(value)
140
+ fields[field] = {terms, length}
141
+ totals[field] = totals[field] + length
142
+ end
143
+ encoded[i] = {id, fields, body, doc}
144
+ end
145
+ return {status = 'parsed', terms = cmsgpack.pack(encoded), totals = totals, comments = comment_count}
146
+ end
147
+
148
+ return M