@codua/codeoutline-win32-x64 0.3.2 → 0.3.6

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.
Files changed (103) hide show
  1. package/DISTRIBUTION.md +26 -1
  2. package/README.md +39 -4
  3. package/README.zh-CN.md +30 -3
  4. package/bin/xnet.exe +0 -0
  5. package/build-info.json +1 -1
  6. package/codeoutline +1 -1
  7. package/codeoutline.cmd +1 -0
  8. package/editors/codeoutline.vsix +0 -0
  9. package/editors/zed/extension.wasm +0 -0
  10. package/package.json +1 -1
  11. package/scripts/codeoutline/{automatic_events.lua → analysis/automatic_events.lua} +4 -4
  12. package/scripts/codeoutline/{cpp_bindings.lua → analysis/cpp/cpp_bindings.lua} +7 -7
  13. package/scripts/codeoutline/{cpp_implementations.lua → analysis/cpp/cpp_implementations.lua} +3 -3
  14. package/scripts/codeoutline/{cpp_includes.lua → analysis/cpp/cpp_includes.lua} +3 -3
  15. package/scripts/codeoutline/{cpp_macros.lua → analysis/cpp/cpp_macros.lua} +3 -3
  16. package/scripts/codeoutline/{cpp_receivers.lua → analysis/cpp/cpp_receivers.lua} +7 -7
  17. package/scripts/codeoutline/{cpp_types.lua → analysis/cpp/cpp_types.lua} +5 -5
  18. package/scripts/codeoutline/{csharp_bindings.lua → analysis/csharp/csharp_bindings.lua} +1 -1
  19. package/scripts/codeoutline/{dispatch_aliases.lua → analysis/dispatch_aliases.lua} +3 -3
  20. package/scripts/codeoutline/{foreign.lua → analysis/foreign.lua} +2 -2
  21. package/scripts/codeoutline/{function_values.lua → analysis/function_values.lua} +2 -2
  22. package/scripts/codeoutline/analysis/go/go_frameworks.lua +327 -0
  23. package/scripts/codeoutline/{go_methods.lua → analysis/go/go_methods.lua} +2 -2
  24. package/scripts/codeoutline/{go_modules.lua → analysis/go/go_modules.lua} +2 -2
  25. package/scripts/codeoutline/{graph.lua → analysis/graph.lua} +53 -47
  26. package/scripts/codeoutline/{implementations.lua → analysis/implementations.lua} +16 -9
  27. package/scripts/codeoutline/{indirect.lua → analysis/indirect.lua} +71 -13
  28. package/scripts/codeoutline/{js_evidence.lua → analysis/js/js_evidence.lua} +4 -3
  29. package/scripts/codeoutline/{js_resolution.lua → analysis/js/js_resolution.lua} +2 -2
  30. package/scripts/codeoutline/{js_workspace.lua → analysis/js/js_workspace.lua} +2 -2
  31. package/scripts/codeoutline/{ts_implementations.lua → analysis/js/ts_implementations.lua} +3 -3
  32. package/scripts/codeoutline/{foreign_lua.lua → analysis/lua/foreign_lua.lua} +3 -3
  33. package/scripts/codeoutline/{lua_bindings.lua → analysis/lua/lua_bindings.lua} +97 -11
  34. package/scripts/codeoutline/{lua_callback_loops.lua → analysis/lua/lua_callback_loops.lua} +1 -1
  35. package/scripts/codeoutline/{ordinary_bindings.lua → analysis/ordinary_bindings.lua} +45 -21
  36. package/scripts/codeoutline/{python_bindings.lua → analysis/python/python_bindings.lua} +2 -2
  37. package/scripts/codeoutline/analysis/receivers.lua +547 -0
  38. package/scripts/codeoutline/{rust_packages.lua → analysis/rust/rust_packages.lua} +2 -2
  39. package/scripts/codeoutline/analysis/rust/rust_resolution.lua +609 -0
  40. package/scripts/codeoutline/{shared_events.lua → analysis/shared_events.lua} +3 -3
  41. package/scripts/codeoutline/{static_dispatch.lua → analysis/static_dispatch.lua} +5 -5
  42. package/scripts/codeoutline/{type_uses.lua → analysis/type_uses.lua} +1 -1
  43. package/scripts/codeoutline/cli.lua +1 -1
  44. package/scripts/codeoutline/command.lua +236 -19
  45. package/scripts/codeoutline/{cpp_fragments.lua → indexing/cpp_fragments.lua} +4 -4
  46. package/scripts/codeoutline/{index.lua → indexing/index.lua} +12 -12
  47. package/scripts/codeoutline/{parse_pool.lua → indexing/parse_pool.lua} +1 -1
  48. package/scripts/codeoutline/{agent_config.lua → install/agent_config.lua} +21 -1
  49. package/scripts/codeoutline/{agent_install.lua → install/agent_install.lua} +105 -10
  50. package/scripts/codeoutline/{editor_install.lua → install/editor_install.lua} +36 -6
  51. package/scripts/codeoutline/lang/c.lua +2 -2
  52. package/scripts/codeoutline/lang/cpp.lua +2 -2
  53. package/scripts/codeoutline/lang/csharp.lua +2 -2
  54. package/scripts/codeoutline/lang/go.lua +2 -2
  55. package/scripts/codeoutline/lang/java.lua +2 -2
  56. package/scripts/codeoutline/lang/js.lua +2 -2
  57. package/scripts/codeoutline/lang/kotlin.lua +4 -2
  58. package/scripts/codeoutline/lang/lua.lua +3 -3
  59. package/scripts/codeoutline/lang/python.lua +2 -2
  60. package/scripts/codeoutline/lang/rust.lua +3 -3
  61. package/scripts/codeoutline/main.lua +9 -9
  62. package/scripts/codeoutline/{common.lua → parsing/common.lua} +22 -17
  63. package/scripts/codeoutline/{language_detect.lua → parsing/language_detect.lua} +1 -1
  64. package/scripts/codeoutline/{parse.lua → parsing/parse.lua} +4 -4
  65. package/scripts/codeoutline/{http.lua → protocol/http.lua} +1 -1
  66. package/scripts/codeoutline/{lsp.lua → protocol/lsp.lua} +4 -4
  67. package/scripts/codeoutline/{mcp.lua → protocol/mcp.lua} +9 -9
  68. package/scripts/codeoutline/{affected.lua → query/affected.lua} +6 -6
  69. package/scripts/codeoutline/{callers.lua → query/callers.lua} +9 -9
  70. package/scripts/codeoutline/{completion.lua → query/completion.lua} +37 -49
  71. package/scripts/codeoutline/{definition_candidates.lua → query/definition_candidates.lua} +6 -6
  72. package/scripts/codeoutline/{documents.lua → query/documents.lua} +4 -4
  73. package/scripts/codeoutline/{explore.lua → query/explore.lua} +85 -25
  74. package/scripts/codeoutline/{external_headers.lua → query/external_headers.lua} +6 -6
  75. package/scripts/codeoutline/{navigation.lua → query/navigation.lua} +53 -54
  76. package/scripts/codeoutline/{on_demand.lua → query/on_demand.lua} +6 -6
  77. package/scripts/codeoutline/{query_report.lua → query/query_report.lua} +9 -5
  78. package/scripts/codeoutline/{search_ranking.lua → query/search_ranking.lua} +10 -7
  79. package/scripts/codeoutline/{type_hierarchy.lua → query/type_hierarchy.lua} +11 -11
  80. package/scripts/codeoutline/{type_references.lua → query/type_references.lua} +17 -17
  81. package/scripts/codeoutline/{index_worker.lua → runtime/index_worker.lua} +10 -10
  82. package/scripts/codeoutline/{parse_worker.lua → runtime/parse_worker.lua} +2 -2
  83. package/scripts/codeoutline/{update_worker.lua → runtime/update_worker.lua} +1 -1
  84. package/scripts/codeoutline/service.lua +11 -11
  85. package/scripts/codeoutline/update_sequence.lua +1 -1
  86. package/scripts/codeoutline/version.lua +1 -1
  87. package/scripts/codeoutline/rust_resolution.lua +0 -301
  88. /package/scripts/codeoutline/{lua_literal.lua → analysis/lua/lua_literal.lua} +0 -0
  89. /package/scripts/codeoutline/{resolution.lua → analysis/resolution.lua} +0 -0
  90. /package/scripts/codeoutline/{cargo_toml.lua → analysis/rust/cargo_toml.lua} +0 -0
  91. /package/scripts/codeoutline/{type_bases.lua → analysis/type_bases.lua} +0 -0
  92. /package/scripts/codeoutline/{cache_repairs.lua → indexing/cache_repairs.lua} +0 -0
  93. /package/scripts/codeoutline/{daemon.lua → install/daemon.lua} +0 -0
  94. /package/scripts/codeoutline/{install_prompt.lua → install/install_prompt.lua} +0 -0
  95. /package/scripts/codeoutline/{xscan.lua → parsing/xscan.lua} +0 -0
  96. /package/scripts/codeoutline/{lsp_trace.lua → protocol/lsp_trace.lua} +0 -0
  97. /package/scripts/codeoutline/{coverage.lua → query/coverage.lua} +0 -0
  98. /package/scripts/codeoutline/{query_filters.lua → query/query_filters.lua} +0 -0
  99. /package/scripts/codeoutline/{idle_gc.lua → runtime/idle_gc.lua} +0 -0
  100. /package/scripts/codeoutline/{control.lua → shared/control.lua} +0 -0
  101. /package/scripts/codeoutline/{path.lua → shared/path.lua} +0 -0
  102. /package/scripts/codeoutline/{rules.lua → shared/rules.lua} +0 -0
  103. /package/scripts/codeoutline/{text.lua → shared/text.lua} +0 -0
@@ -118,7 +118,7 @@ function M.collect(r, T)
118
118
  end
119
119
  local declaration_prefixes = {}
120
120
  for index, n in ipairs(r.nodes) do
121
- if index % 128 == 0 then require('codeoutline.control').check() end
121
+ if index % 128 == 0 then require('codeoutline.shared.control').check() end
122
122
  local ni = n.type_token
123
123
  if ni and (callable[n.kind] or containers[n.kind] or n.kind == 'typedef') then
124
124
  local a = n.ti
@@ -5,7 +5,7 @@ local source = debug.getinfo(1, 'S').source:sub(2):gsub('\\', '/')
5
5
  local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'), 'cannot locate installed scripts')
6
6
  package.path = scripts .. '/?.lua;' .. package.path
7
7
  local svc = require('codeoutline.service')
8
- local explore = require('codeoutline.explore')
8
+ local explore = require('codeoutline.query.explore')
9
9
 
10
10
  local argv = {}
11
11
  if type(arg) == 'table' then
@@ -6,7 +6,9 @@ package.path = scripts .. '/?.lua;' .. package.path
6
6
  local version = require('codeoutline.version')
7
7
  local help = [[CodeOutline - code exploration tool and LSP server, powered by Lua
8
8
 
9
- Code exploration (code_explore): agents use the MCP tool codeoutline_explore
9
+ Agents are AI coding tools such as Claude Code, Codex and Cursor Agent.
10
+ MCP connects agents to CodeOutline; LSP connects editors to CodeOutline.
11
+ Code exploration: agents use the MCP tool codeoutline_explore
10
12
  to query symbols, line-numbered source, call paths and callers/callees.
11
13
  Use codeoutline explore for code exploration from a terminal.
12
14
 
@@ -23,10 +25,11 @@ You can also register the URL manually:
23
25
  claude mcp add --transport http codeoutline --scope user http://127.0.0.1:19876/mcp
24
26
 
25
27
  Usage:
26
- codeoutline install [--yes] [--target auto|all|none|IDS] [--location global|local] [--port PORT] [--editors all|none|vscode,cursor,zed]
27
- codeoutline agents [--list] [--target auto|all|none|IDS] [--location global|local] [--port PORT] [--remove] [--force]
28
+ codeoutline install [--yes] [--target auto|all|none|IDS] [--location global|local] [--project PATH] [--port PORT] [--editors all|none|vscode,cursor,zed] [--force] [--list] [--print ID]
29
+ codeoutline agents [--list] [--yes] [--target auto|all|none|IDS] [--location global|local] [--project PATH] [--port PORT] [--remove] [--force] [--print ID]
28
30
  codeoutline editors [--list] [--editors all|none|vscode,cursor,zed]
29
31
  codeoutline uninstall [--port PORT] [--project PATH] [--service-only] [--purge]
32
+ codeoutline remove [--port PORT] [--project PATH]
30
33
  codeoutline daemon [--port PORT]
31
34
  codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
32
35
  codeoutline lsp --stdio [--project PATH]
@@ -71,7 +74,7 @@ Agent MCP setup (independent of LSP clients):
71
74
  codeoutline agents --list show detection and config paths only
72
75
  codeoutline agents --target all configure all detected agents
73
76
  codeoutline agents --print codex print config only, without writing files
74
- codeoutline agents --target cursor --remove remove only CodeOutline's MCP entry
77
+ codeoutline agents --target cursor --remove remove CodeOutline's agent configuration
75
78
  Targets: claude, cursor, codex, gemini, opencode, hermes, kiro, antigravity,
76
79
  copilot-vscode, copilot-cli, copilot-jetbrains.
77
80
  all and auto select detected targets; comma-separated ids select explicitly.
@@ -81,6 +84,10 @@ Antigravity, Hermes, Copilot CLI and Copilot JetBrains support global scope only
81
84
  while install also starts the service. Restart agents after configuration.
82
85
  Existing unrelated settings are preserved; original files get .codeoutline.bak
83
86
  backups. Different existing codeoutline settings require --force to replace.
87
+ For Claude, Codex, Gemini and OpenCode, setup also adds a usage instruction block.
88
+ Existing CodeGraph blocks are archived as adjacent codegraph.md files; removal
89
+ restores them only to their original files while the CodeGraph CLI is on PATH.
90
+ Other instructions remain.
84
91
  CODEOUTLINE_AGENTS=auto|all|none|IDS selects agents for unattended npm installs.
85
92
  Without an explicit selection or terminal, global npm configures detected agents.
86
93
  Set CODEOUTLINE_AGENTS=none and CODEOUTLINE_EDITORS=none to skip integrations.
@@ -91,6 +98,8 @@ stops it, removes its login entry, user-level MCP registrations and editor clien
91
98
  --project also removes MCP entries from that project; --service-only keeps integrations.
92
99
  --purge additionally removes ~/.codeoutline data after cleanup succeeds.
93
100
  Run uninstall before npm uninstall -g codeoutline; npm has no uninstall hooks.
101
+ For npm global installations, remove performs full cleanup with --purge, then
102
+ removes the npm package after the runtime exits. Cleanup failures keep the package.
94
103
  daemon is the service itself.
95
104
  editors detects VS Code, Cursor and Zed and offers optional LSP client installation.
96
105
  Use --editors or CODEOUTLINE_EDITORS to select clients without a prompt.
@@ -101,6 +110,183 @@ Project defaults to the working directory for one-shot commands.
101
110
  doctor reports JSON diagnostics and exits nonzero on a failed check.
102
111
  ]]
103
112
 
113
+ local command_help = {
114
+ install = { 'Configure agents and editor clients, start the shared MCP service and register login startup.', [[
115
+ --target auto|all selects detected agents; none skips agents; IDS is a comma-separated list.
116
+ --yes selects detected agents without prompts; editors default to none unless selected.
117
+ --editors all|none|vscode,cursor,zed selects editor LSP clients independently.
118
+ --location global|local selects agent configuration scope (default global).
119
+ --project PATH selects the project for local configuration (default working directory).
120
+ --port PORT selects the shared MCP endpoint and service port (default 19876).
121
+ --force replaces conflicting CodeOutline agent entries; unrelated settings remain.
122
+ --list only lists agents; --print ID (alias --print-config) only prints an agent config.
123
+ MCP lets AI agents explore code; LSP provides editor navigation and completion.
124
+ With no explicit selections, a terminal prompts for each detected application.
125
+ Global npm background setup configures detected applications automatically.
126
+ Example: codeoutline install --target codex,claude --editors vscode
127
+ ]] },
128
+ agents = { 'Connect AI coding agents to the shared CodeOutline MCP service.', [[
129
+ codeoutline_explore returns symbols, line-numbered source and call relationships.
130
+ This command edits agent configuration and supported usage instructions; it does not start the service.
131
+ --list shows detected agents and config paths without editing files.
132
+ --target auto|all selects detected agents; none skips setup; IDS selects comma-separated ids.
133
+ --yes selects detected agents without prompts.
134
+ --location global|local selects scope; --project PATH selects the local project.
135
+ --port PORT selects the MCP endpoint (default 19876).
136
+ --print ID (alias --print-config) prints config without writing files.
137
+ --remove removes CodeOutline MCP entries and its supported usage instruction blocks.
138
+ --force replaces conflicting CodeOutline entries; unrelated settings remain.
139
+ Targets: claude,cursor,codex,gemini,opencode,hermes,kiro,antigravity,
140
+ copilot-vscode,copilot-cli,copilot-jetbrains.
141
+ Hermes, Antigravity and Copilot CLI/JetBrains support global scope only.
142
+ Example: codeoutline agents --target codex --location local --project .
143
+ ]] },
144
+ editors = { 'Install optional CodeOutline LSP extensions for VS Code, Cursor and Zed.', [[
145
+ LSP provides symbols, definitions, references, hover, call hierarchy, completion and signature help.
146
+ --list shows detected editors without installing extensions.
147
+ --editors all installs for detected editors; none skips installation.
148
+ --editors vscode,cursor,zed selects a comma-separated set of editors.
149
+ Without a selection, a terminal prompts for each detected editor.
150
+ Reload VS Code/Cursor or restart Zed afterward. Agent MCP setup is independent.
151
+ Example: codeoutline editors --editors vscode,cursor
152
+ ]] },
153
+ uninstall = { 'Stop the shared service and remove startup registration, agent integrations and editor clients.', [[
154
+ --port PORT selects the service port (default 19876).
155
+ --project PATH also removes agent configuration and supported usage instructions from that project.
156
+ --service-only keeps agent integrations and editor clients.
157
+ Also removes codeoutline.* settings from VS Code/Cursor user settings and named profiles.
158
+ --purge also deletes default ~/.codeoutline data after cleanup succeeds.
159
+ The npm package remains installed; run npm uninstall -g codeoutline afterward.
160
+ For a single full-cleanup command on global npm installations, use codeoutline remove.
161
+ Custom data directories and unnamed project scopes require separate cleanup.
162
+ Example: codeoutline uninstall --project . --purge
163
+ ]] },
164
+ remove = { 'Clean up a global npm installation, delete default user data and uninstall the npm package.', [[
165
+ --port PORT selects the service port (default 19876).
166
+ --project PATH also removes agent configuration and supported usage instructions from that project.
167
+ Stops the service, removes startup registration and integrations, and purges ~/.codeoutline.
168
+ Also removes codeoutline.* settings from VS Code/Cursor user settings and named profiles.
169
+ Only after successful cleanup and runtime exit does the launcher run npm uninstall -g codeoutline.
170
+ Cleanup failure keeps the package for retry; npm failure returns a nonzero exit status.
171
+ Requires the global npm launcher; native/local installations should use uninstall instead.
172
+ Custom data directories and unnamed project scopes require separate cleanup.
173
+ Example: codeoutline remove --project .
174
+ ]] },
175
+ daemon = { 'Run the shared background MCP HTTP service in the current process.', [[
176
+ --port PORT selects the listening port (default 19876).
177
+ Normally started by codeoutline install or the registered login entry.
178
+ Use install to configure integrations and startup; daemon runs the service itself.
179
+ Example: codeoutline daemon --port 19876
180
+ ]] },
181
+ serve = { 'Run an MCP server over stdio or HTTP for AI tools.', [[
182
+ Choose exactly one of --stdio or --http.
183
+ --project PATH selects the default project (default working directory).
184
+ --host HOST and --port PORT configure HTTP listening (defaults 127.0.0.1 and 19876).
185
+ --allow-root PATH restricts accessible project roots; repeat for multiple roots.
186
+ Local HTTP without --allow-root can serve projects anywhere on the machine.
187
+ Stdio and remote HTTP default to the selected project or working directory.
188
+ --allow-host HOST and --allow-origin ORIGIN add permitted HTTP hosts/origins; repeat as needed.
189
+ Remote HTTP requires CODEOUTLINE_TOKEN with at least 16 bytes.
190
+ Example: codeoutline serve --stdio --project .
191
+ Example: codeoutline serve --http --port 19876 --allow-root C:/src
192
+ ]] },
193
+ lsp = { 'Run the Language Server Protocol server for an editor client over stdio.', [[
194
+ --stdio is required; --project PATH selects the initial project (default working directory).
195
+ Provides symbols, definitions, references, hover, call hierarchy, completion and signature help.
196
+ Normally started by an editor extension; use codeoutline editors to install bundled clients.
197
+ This server runs separately from the shared MCP HTTP service.
198
+ Example: codeoutline lsp --stdio --project .
199
+ ]] },
200
+ explore = { 'Find symbols or files and return source with line numbers and relevant call paths.', [[
201
+ --query QUERY is required; accepts symbol names, file paths and code terms.
202
+ Queries can use lang:LANG and path:PATH filters; quote queries containing spaces.
203
+ --project PATH selects the project (default working directory).
204
+ --budget BYTES bounds the output size. Results report applicable coverage limits.
205
+ Example: codeoutline explore --project . --query "Session.save" --budget 16000
206
+ Example: codeoutline explore --query "lang:lua path:scripts Session"
207
+ ]] },
208
+ callers = { 'Trace callers of a symbol through bounded reverse call paths.', [[
209
+ --query SYMBOL is required; --project PATH defaults to the working directory.
210
+ --depth N limits caller traversal (default 3, range 1-8).
211
+ --max-nodes N limits returned graph nodes (default 200, range 1-2000).
212
+ --budget BYTES bounds output size. Reported paths are analysis evidence, not proof of runtime execution.
213
+ Example: codeoutline callers --query Session.save --depth 2
214
+ ]] },
215
+ affected = { 'Find code potentially affected by changed files using bounded caller traversal.', [[
216
+ Provide --file FILE (repeatable), --files-from PATH, or both.
217
+ --files-from - reads standard input; lists contain one path per line (maximum 64 KiB).
218
+ Paths must resolve inside the selected project; --project PATH defaults to the working directory.
219
+ --depth N limits traversal (default 3, range 1-8).
220
+ --max-nodes N limits graph nodes (default 200, range 1-2000).
221
+ --budget BYTES bounds output size. Results are potential impact, not guaranteed runtime effects.
222
+ Example: codeoutline affected --project . --file src/session.lua --depth 2
223
+ Example: codeoutline affected --files-from changes.txt
224
+ ]] },
225
+ ['type-hierarchy'] = { 'Inspect ancestors and descendants of a type, including inheritance and implementations.', [[
226
+ --query TYPE is required; --project PATH defaults to the working directory.
227
+ --direction both|ancestors|descendants selects traversal direction (default both).
228
+ --depth N limits traversal (default 8, range 1-32).
229
+ --max-nodes N limits graph nodes (default 200, range 1-2000).
230
+ --budget BYTES bounds output size. Coverage depends on language support and available source evidence.
231
+ Example: codeoutline type-hierarchy --query BaseService --direction descendants
232
+ ]] },
233
+ ['type-references'] = { 'Find explicit source uses of a type with resolved identity where supported.', [[
234
+ --query TYPE is required; --project PATH defaults to the working directory.
235
+ --max-nodes N limits results (default 200, range 1-2000).
236
+ --budget BYTES bounds output size. Language and coverage limits are reported in results.
237
+ These are type uses, rather than every textual occurrence of the name.
238
+ Example: codeoutline type-references --query Session --max-nodes 100
239
+ ]] },
240
+ status = { 'Refresh the project index and print its current status as JSON.', [[
241
+ --project PATH selects the project (default working directory).
242
+ Reports file/symbol counts, languages, generation, refresh statistics, scanner and cache information.
243
+ May create or update the project index cache; this is not a service health check.
244
+ Example: codeoutline status --project .
245
+ ]] },
246
+ rebuild = { 'Rebuild the basic project index from source, bypassing the existing cache, and print JSON status.', [[
247
+ --project PATH selects the project (default working directory).
248
+ Use after cache problems or when a fresh base index is needed; ordinary queries refresh incrementally.
249
+ Detailed semantic analysis still runs on demand rather than being collected by a full rebuild.
250
+ Example: codeoutline rebuild --project .
251
+ ]] },
252
+ doctor = { 'Check the local runtime, project access, scanner and cache write access; print JSON diagnostics.', [[
253
+ --project PATH selects the project (default working directory).
254
+ Checks runtime APIs, GBK conversion availability, file enumeration and cache directory writes.
255
+ Exits nonzero when a check fails; unavailable GBK conversion is a warning.
256
+ This checks local prerequisites, not editor connections or a deployed service.
257
+ Example: codeoutline doctor --project .
258
+ ]] },
259
+ update = { 'Check for or install a verified CodeOutline runtime update.', [[
260
+ --check queries available updates without installing them.
261
+ --channel CHANNEL selects the release channel (default CODEOUTLINE_UPDATE_CHANNEL or stable).
262
+ Without --check, downloads, validates and activates the update; prints JSON and exits nonzero on failure.
263
+ This updates the runtime through CodeOutline's updater, not npm package dependencies.
264
+ Example: codeoutline update --check
265
+ Example: codeoutline update --channel stable
266
+ ]] },
267
+ }
268
+
269
+ local function render_help(command)
270
+ if command_help[command] then
271
+ local entry, usages = command_help[command], {}
272
+ local prefix = ' codeoutline ' .. command .. ' '
273
+ for line in assert(help:match('Usage:\n(.-)\n\n')):gmatch('[^\n]+') do
274
+ if line:sub(1, #prefix) == prefix then
275
+ usages[#usages + 1] = line
276
+ end
277
+ end
278
+ return 'codeoutline ' .. command .. ' - ' .. entry[1] .. '\n\nUsage:\n'
279
+ .. table.concat(usages, '\n') .. '\n\n' .. entry[2]
280
+ .. '\nRun codeoutline --help for all commands and setup notes.\n'
281
+ end
282
+ local lines = {}
283
+ for name in ('install agents editors uninstall remove daemon serve lsp explore callers affected type-hierarchy type-references status rebuild doctor update'):gmatch('%S+') do
284
+ lines[#lines + 1] = ' ' .. name .. ': ' .. command_help[name][1]
285
+ end
286
+ return help .. '\nCommands:\n' .. table.concat(lines, '\n')
287
+ .. '\n\nUse codeoutline <command> --help for options and examples.\n'
288
+ end
289
+
104
290
  local function parse(args)
105
291
  local clean = {}
106
292
  for _, value in ipairs(args) do
@@ -126,7 +312,8 @@ local function parse(args)
126
312
  ['allow-root'] = true, ['allow-host'] = true, ['allow-origin'] = true },
127
313
  daemon = { port = true }, install = { port = true, npm = true, editors = true, target = true, yes = true,
128
314
  location = true, project = true, force = true, list = true, print = true, ['print-config'] = true },
129
- uninstall = { port = true, project = true, ['service-only'] = true, purge = true },
315
+ uninstall = { port = true, project = true, ['service-only'] = true, purge = true, npm = true },
316
+ remove = { port = true, project = true },
130
317
  agents = { target = true, yes = true, location = true, project = true, port = true, list = true,
131
318
  ['print-config'] = true, print = true, remove = true, force = true },
132
319
  editors = { list = true, editors = true },
@@ -192,7 +379,7 @@ local function doctor(root)
192
379
  end)
193
380
  local idx
194
381
  check('project', function()
195
- idx = require('codeoutline.index').open(root)
382
+ idx = require('codeoutline.indexing.index').open(root)
196
383
  return idx.root
197
384
  end)
198
385
  check('enumerator', function()
@@ -221,19 +408,24 @@ end
221
408
 
222
409
  local function run()
223
410
  local command, options = parse(arg or {})
224
- if command == '--help' or command == '-h' or options.help then io.write(help); return 0 end
411
+ if command == '--help' or command == '-h' or options.help then io.write(render_help(command)); return 0 end
225
412
  if command == '--version' then io.write(version, '\n'); return 0 end
226
413
  if command == 'update' then
227
414
  return require('codeoutline.updater').run(options.check and 'check' or 'update', options)
228
415
  end
229
416
  if command == 'editors' then
230
- return require('codeoutline.editor_install').run(os.getenv('CODEOUTLINE_INITIAL') or install, options)
417
+ return require('codeoutline.install.editor_install').run(os.getenv('CODEOUTLINE_INITIAL') or install, options)
231
418
  end
232
419
  if command == 'agents' or command == 'install' and (options.list or options.print or options['print-config']) then
233
- return require('codeoutline.agent_install').run(options)
420
+ return require('codeoutline.install.agent_install').run(options)
234
421
  end
235
- if command == 'daemon' or command == 'install' or command == 'uninstall' then
236
- local daemon = require('codeoutline.daemon')
422
+ if command == 'remove' then
423
+ assert(os.getenv('CODEOUTLINE_REMOVE_READY'), 'remove requires the npm launcher; use uninstall --purge for a native installation')
424
+ assert(not os.getenv('CODEOUTLINE_REMOVE_ERROR'), os.getenv('CODEOUTLINE_REMOVE_ERROR'))
425
+ options.purge = true
426
+ end
427
+ if command == 'daemon' or command == 'install' or command == 'uninstall' or command == 'remove' then
428
+ local daemon = require('codeoutline.install.daemon')
237
429
  local port = tonumber(options.port or daemon.PORT)
238
430
  assert(port and port % 1 == 0 and port >= 1 and port <= 65535, 'invalid --port')
239
431
  if command == 'daemon' then
@@ -244,6 +436,23 @@ local function run()
244
436
  -- service, and nothing here may fail the installation.
245
437
  local npm = options.npm
246
438
  if npm and os.getenv('npm_config_global') ~= 'true' then return 0 end
439
+ if npm and command == 'uninstall' then
440
+ if os.getenv('CODEOUTLINE_REMOVE_CLEANED') == '1' then return 0 end
441
+ if os.getenv('npm_lifecycle_event') ~= 'preuninstall' then return 0 end
442
+ local npm_command = os.getenv('npm_command')
443
+ if npm_command == '' then npm_command = nil end
444
+ if not npm_command then
445
+ -- npm 6 supplies argv rather than npm_command. During an
446
+ -- upgrade its preuninstall hook must not remove integrations.
447
+ local ok, argv = pcall(xutils.json_unpack, os.getenv('npm_config_argv') or '')
448
+ for _, item in ipairs(ok and type(argv) == 'table' and type(argv.original) == 'table' and argv.original or {}) do
449
+ if item == 'uninstall' or item == 'un' or item == 'remove' or item == 'rm' or item == 'r' or item == 'unlink' then
450
+ npm_command = 'uninstall'; break
451
+ end
452
+ end
453
+ end
454
+ if npm_command ~= 'uninstall' and npm_command ~= 'run-script' then return 0 end
455
+ end
247
456
  local function say(text) io.write(text, '\n'); io.stdout:flush() end
248
457
  local status = 0
249
458
  local integrations_ok = true
@@ -256,8 +465,8 @@ local function run()
256
465
  end
257
466
  if automatic then say('Global npm setup: installing detected integrations by default. Use --foreground-scripts for per-application choices.') end
258
467
  options.installing = true
259
- say('Step 1/2: AI tools - code_explore over MCP')
260
- local agent_ok, agent_result = pcall(require('codeoutline.agent_install').run, options)
468
+ say('Step 1/2: AI agents - codeoutline_explore over MCP')
469
+ local agent_ok, agent_result = pcall(require('codeoutline.install.agent_install').run, options)
261
470
  if not agent_ok then io.stderr:write('codeoutline: ', tostring(agent_result), '\n') end
262
471
  if not agent_ok or agent_result ~= 0 then integrations_ok = false end
263
472
  if not npm and not agent_ok then return 1 end
@@ -265,15 +474,16 @@ local function run()
265
474
  local editor_selection = options.editors or os.getenv('CODEOUTLINE_EDITORS')
266
475
  if editor_selection == '' then editor_selection = nil end
267
476
  local editor_options = { editors = editor_selection or (automatic and 'all' or options.yes and 'none' or nil) }
268
- local ok, result = pcall(require('codeoutline.editor_install').run, os.getenv('CODEOUTLINE_INITIAL') or install, editor_options)
477
+ local ok, result = pcall(require('codeoutline.install.editor_install').run, os.getenv('CODEOUTLINE_INITIAL') or install, editor_options)
269
478
  if not ok then io.stderr:write('codeoutline: ', tostring(result), '\n') end
270
479
  if not ok or result ~= 0 then integrations_ok = false end
271
480
  if not npm then status = ok and result or 1 end
481
+ say('To fully uninstall a global npm installation, run codeoutline remove (also deletes default user data). npm uninstall alone leaves the service and integrations behind.')
272
482
  if npm and os.getenv('CODEOUTLINE_AUTOSTART') == '0' then return 0 end
273
483
  end
274
484
  local function attempt(fn, ...)
275
485
  local ok, err = pcall(fn, ...)
276
- if not ok then io.stderr:write('codeoutline: ', tostring(err), '\n'); status = npm and 0 or 1 end
486
+ if not ok then io.stderr:write('codeoutline: ', tostring(err), '\n'); status = npm and command == 'install' and 0 or 1 end
277
487
  return ok and err
278
488
  end
279
489
  -- Launchers name the installation they belong to; unlike an installed
@@ -288,14 +498,14 @@ local function run()
288
498
  return {
289
499
  __init = function()
290
500
  assert(xnet.init()); xtimer.init(16)
291
- if command == 'uninstall' then
501
+ if command == 'uninstall' or command == 'remove' then
292
502
  for _, removed in ipairs(attempt(daemon.unregister) or {}) do say('removed login entry ' .. removed) end
293
503
  daemon.stop(port, 10000, function(stopped)
294
504
  say(stopped and 'service on port ' .. port .. ' stopped' or 'service on port ' .. port .. ' is still running')
295
505
  if not stopped then status = 1 end
296
506
  if not options['service-only'] then
297
- if attempt(function() return require('codeoutline.agent_install').remove(options) end) ~= 0 then status = 1 end
298
- if attempt(function() return require('codeoutline.editor_install').remove() end) ~= 0 then status = 1 end
507
+ if attempt(function() return require('codeoutline.install.agent_install').remove(options) end) ~= 0 then status = 1 end
508
+ if attempt(function() return require('codeoutline.install.editor_install').remove() end) ~= 0 then status = 1 end
299
509
  end
300
510
  if options.purge and status == 0 then
301
511
  attempt(function()
@@ -311,7 +521,14 @@ local function run()
311
521
  say('removed CodeOutline user data; custom cache/update directories require separate cleanup')
312
522
  end)
313
523
  end
314
- if status == 0 then say('Cleanup completed. Run npm uninstall -g codeoutline to remove the npm package.') end
524
+ if status == 0 then
525
+ if command == 'remove' then
526
+ local ready = assert(io.open(os.getenv('CODEOUTLINE_REMOVE_READY'), 'wb'))
527
+ assert(ready:write('ready\n')); assert(ready:close())
528
+ say('Cleanup completed. Removing the npm global package after the runtime exits...')
529
+ elseif npm then say('Uninstall hook cleanup completed.')
530
+ else say('Cleanup completed. Run npm uninstall -g codeoutline to remove the npm package.') end
531
+ end
315
532
  finish(status)
316
533
  end)
317
534
  return
@@ -1,8 +1,8 @@
1
1
  -- Include-driven admission of unknown suffixes from the normal file listing.
2
- local paths = require('codeoutline.path')
3
- local parse = require('codeoutline.parse')
4
- local includes = require('codeoutline.cpp_includes')
5
- local control = require('codeoutline.control')
2
+ local paths = require('codeoutline.shared.path')
3
+ local parse = require('codeoutline.parsing.parse')
4
+ local includes = require('codeoutline.analysis.cpp.cpp_includes')
5
+ local control = require('codeoutline.shared.control')
6
6
  local M = { MAX_FILES = 4096, MAX_BYTES = 67108864, MAX_DEPTH = 32 }
7
7
  local function c_family(rec) return rec and (rec.language == 'c' or rec.language == 'cpp') end
8
8
 
@@ -1,7 +1,7 @@
1
1
  -- index.lua — per-project symbol index: which files exist, what each one
2
2
  -- defines and calls, kept fresh incrementally and cached on disk.
3
3
  --
4
- -- local index = require('codeoutline.index')
4
+ -- local index = require('codeoutline.indexing.index')
5
5
  -- local idx = index.open('C:/src/proj') -- loads the cache if present
6
6
  -- local stats = idx:refresh() -- reparses only changed files
7
7
  -- idx:save()
@@ -14,12 +14,12 @@
14
14
  -- Tools that restore an older mtime at the same size are not detected by a
15
15
  -- full refresh; a watcher reports them.
16
16
 
17
- local ci = require('codeoutline.parse')
18
- local paths = require('codeoutline.path')
19
- local control = require('codeoutline.control')
20
- local graph = require('codeoutline.graph')
21
- local pool = require('codeoutline.parse_pool')
22
- local fragments = require('codeoutline.cpp_fragments')
17
+ local ci = require('codeoutline.parsing.parse')
18
+ local paths = require('codeoutline.shared.path')
19
+ local control = require('codeoutline.shared.control')
20
+ local graph = require('codeoutline.analysis.graph')
21
+ local pool = require('codeoutline.indexing.parse_pool')
22
+ local fragments = require('codeoutline.indexing.cpp_fragments')
23
23
 
24
24
  local M = {}
25
25
  local INDEX_PARSE = { ranges = false, omit_signatures = true }
@@ -35,8 +35,8 @@ end
35
35
  -- rebuilds stale caches instead of silently reusing old parse results.
36
36
  M.VERSION = (function()
37
37
  local parts = {}
38
- for _, m in ipairs({ 'xscan', 'text', 'common', 'type_uses', 'indirect', 'dispatch_aliases', 'static_dispatch', 'js_evidence', 'python_bindings', 'cpp_bindings', 'cpp_types', 'csharp_bindings', 'lua_bindings', 'foreign', 'foreign_lua', 'parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
39
- 'cpp_receivers', 'cpp_macros', 'cpp_includes', 'cpp_fragments', 'language_detect', 'go_methods', 'function_values', 'implementations', 'cpp_implementations', 'ts_implementations', 'type_bases', 'automatic_events', 'shared_events', 'lua_callback_loops', 'lang.java', 'lang.kotlin', 'lang.go', 'lang.js', 'lang.csharp', 'lang.rust' }) do
38
+ for _, m in ipairs({ 'parsing.xscan', 'shared.text', 'parsing.common', 'analysis.receivers', 'analysis.type_uses', 'analysis.indirect', 'analysis.dispatch_aliases', 'analysis.static_dispatch', 'analysis.js.js_evidence', 'analysis.python.python_bindings', 'analysis.cpp.cpp_bindings', 'analysis.cpp.cpp_types', 'analysis.csharp.csharp_bindings', 'analysis.lua.lua_bindings', 'analysis.foreign', 'analysis.lua.foreign_lua', 'parsing.parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
39
+ 'analysis.cpp.cpp_receivers', 'analysis.cpp.cpp_macros', 'analysis.cpp.cpp_includes', 'indexing.cpp_fragments', 'parsing.language_detect', 'analysis.go.go_methods', 'analysis.go.go_frameworks', 'analysis.function_values', 'analysis.implementations', 'analysis.cpp.cpp_implementations', 'analysis.js.ts_implementations', 'analysis.type_bases', 'analysis.automatic_events', 'analysis.shared_events', 'analysis.lua.lua_callback_loops', 'lang.java', 'lang.kotlin', 'lang.go', 'lang.js', 'lang.csharp', 'lang.rust' }) do
40
40
  local file = package.searchpath and package.searchpath('codeoutline.' .. m, package.path)
41
41
  local h = file and io.open(file, 'rb')
42
42
  if h then parts[#parts + 1] = h:read('a'); h:close() end
@@ -173,7 +173,7 @@ function Index:load()
173
173
  destination[rec.path] = rec
174
174
  end
175
175
  for _, rec in ipairs(t.files) do validate(rec, records) end
176
- local patches = require('codeoutline.cache_repairs').load(self.cache_path, envelope.sha256, M.VERSION, paths.key(self.root))
176
+ local patches = require('codeoutline.indexing.cache_repairs').load(self.cache_path, envelope.sha256, M.VERSION, paths.key(self.root))
177
177
  local valid, applied = pcall(function()
178
178
  local result = {}
179
179
  for path, rec in pairs(patches) do
@@ -210,7 +210,7 @@ function Index:save()
210
210
  return false, 'runtime requires cmsgpack, xcompress, temp_file and replace_file'
211
211
  end
212
212
  if self.repair_only and self.cache_hash then
213
- local ok, err = require('codeoutline.cache_repairs').save(self.cache_path, self.cache_hash,
213
+ local ok, err = require('codeoutline.indexing.cache_repairs').save(self.cache_path, self.cache_hash,
214
214
  M.VERSION, paths.key(self.root), self.repair_records)
215
215
  if ok then
216
216
  self.saved_generation, self.encoding_dirty, self.repair_only = self.generation, false, false
@@ -268,7 +268,7 @@ end
268
268
  -- Symbol tables over the records, built on first use and then kept current
269
269
  -- by commit(). Hosts that never resolve names do not pay for them.
270
270
  function Index:symbols()
271
- local ctx = require('codeoutline.lua_bindings').context(self)
271
+ local ctx = require('codeoutline.analysis.lua.lua_bindings').context(self)
272
272
  if not self.symbol_tables or table.concat(self.symbol_tables.lua_global_export_tables, '\0')
273
273
  ~= table.concat(ctx.global_export_tables, '\0') then
274
274
  self.symbol_tables = graph.build(self, ctx)
@@ -13,7 +13,7 @@
13
13
  -- by size (largest first onto the least-loaded thread) and posted in chunks,
14
14
  -- so results stream back and a cancelled pass stops within a chunk.
15
15
 
16
- local control = require('codeoutline.control')
16
+ local control = require('codeoutline.shared.control')
17
17
 
18
18
  local M = {}
19
19
  M.THREADS = package.config:sub(1, 1) == '\\' and 8 or 6
@@ -1,4 +1,4 @@
1
- -- Small, lossless JSON/JSONC editor for MCP entries. No reserialization of
1
+ -- Small, lossless JSON/JSONC editor for MCP entries and editor settings. No reserialization of
2
2
  -- surrounding settings: comments, key order and unrelated bytes survive.
3
3
  local M = {}
4
4
  local function encode(value) return assert(xutils.json_pack(value)) end
@@ -136,6 +136,26 @@ function M.has(text, path)
136
136
  return true
137
137
  end
138
138
 
139
+ -- Editor settings also allow language-specific override objects. Only inspect
140
+ -- those containers, never unrelated nested objects that happen to use our name.
141
+ function M.remove_editor_settings(text)
142
+ if text == '' then return text, false end
143
+ local root, paths = parse(text), {}
144
+ local function collect(node, parent)
145
+ for key, child in pairs(node.children) do
146
+ if key:match('^codeoutline%.') then
147
+ paths[#paths + 1] = parent and { parent, key } or { key }
148
+ elseif not parent and key:match('^%[.*%]$') and child.kind == '{' then
149
+ collect(child, key)
150
+ end
151
+ end
152
+ end
153
+ collect(root)
154
+ table.sort(paths, function(a, b) return table.concat(a, '\0') < table.concat(b, '\0') end)
155
+ for _, path in ipairs(paths) do text = M.json(text, path, {}, true, false) end
156
+ return text, #paths > 0
157
+ end
158
+
139
159
  -- TOML keeps all unrelated tables verbatim. Reject ambiguous inline/dotted
140
160
  -- definitions rather than risk producing a duplicate table.
141
161
  function M.toml(text, url, remove, force)