@codua/codeoutline-win32-x64 0.2.4 → 0.2.9

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 (77) hide show
  1. package/README.md +205 -3
  2. package/README.zh-CN.md +40 -2
  3. package/bin/xnet.exe +0 -0
  4. package/build-info.json +1 -1
  5. package/package.json +1 -1
  6. package/scripts/codeoutline/affected.lua +145 -0
  7. package/scripts/codeoutline/automatic_events.lua +202 -0
  8. package/scripts/codeoutline/cache_repairs.lua +47 -0
  9. package/scripts/codeoutline/callers.lua +56 -16
  10. package/scripts/codeoutline/cargo_toml.lua +125 -0
  11. package/scripts/codeoutline/command.lua +26 -4
  12. package/scripts/codeoutline/common.lua +65 -9
  13. package/scripts/codeoutline/completion.lua +221 -65
  14. package/scripts/codeoutline/coverage.lua +63 -0
  15. package/scripts/codeoutline/cpp_bindings.lua +151 -0
  16. package/scripts/codeoutline/cpp_fragments.lua +143 -0
  17. package/scripts/codeoutline/cpp_implementations.lua +340 -0
  18. package/scripts/codeoutline/cpp_includes.lua +156 -0
  19. package/scripts/codeoutline/cpp_macros.lua +279 -0
  20. package/scripts/codeoutline/cpp_receivers.lua +342 -0
  21. package/scripts/codeoutline/cpp_types.lua +456 -0
  22. package/scripts/codeoutline/csharp_bindings.lua +498 -0
  23. package/scripts/codeoutline/definition_candidates.lua +180 -0
  24. package/scripts/codeoutline/dispatch_aliases.lua +479 -0
  25. package/scripts/codeoutline/documents.lua +32 -9
  26. package/scripts/codeoutline/explore.lua +274 -119
  27. package/scripts/codeoutline/external_headers.lua +171 -0
  28. package/scripts/codeoutline/foreign.lua +79 -14
  29. package/scripts/codeoutline/foreign_lua.lua +146 -19
  30. package/scripts/codeoutline/function_values.lua +69 -0
  31. package/scripts/codeoutline/go_methods.lua +931 -0
  32. package/scripts/codeoutline/go_modules.lua +329 -0
  33. package/scripts/codeoutline/graph.lua +346 -63
  34. package/scripts/codeoutline/implementations.lua +403 -0
  35. package/scripts/codeoutline/index.lua +165 -27
  36. package/scripts/codeoutline/index_worker.lua +11 -4
  37. package/scripts/codeoutline/indirect.lua +116 -40
  38. package/scripts/codeoutline/js_evidence.lua +32 -3
  39. package/scripts/codeoutline/js_resolution.lua +72 -10
  40. package/scripts/codeoutline/js_workspace.lua +325 -0
  41. package/scripts/codeoutline/lang/c.lua +15 -2
  42. package/scripts/codeoutline/lang/cpp.lua +7 -4
  43. package/scripts/codeoutline/lang/csharp.lua +15 -3
  44. package/scripts/codeoutline/lang/js.lua +56 -20
  45. package/scripts/codeoutline/lang/rust.lua +9 -1
  46. package/scripts/codeoutline/language_detect.lua +100 -0
  47. package/scripts/codeoutline/lsp.lua +173 -23
  48. package/scripts/codeoutline/lua_bindings.lua +228 -54
  49. package/scripts/codeoutline/lua_callback_loops.lua +210 -0
  50. package/scripts/codeoutline/lua_literal.lua +38 -0
  51. package/scripts/codeoutline/main.lua +32 -7
  52. package/scripts/codeoutline/mcp.lua +52 -9
  53. package/scripts/codeoutline/navigation.lua +593 -147
  54. package/scripts/codeoutline/on_demand.lua +93 -0
  55. package/scripts/codeoutline/ordinary_bindings.lua +396 -0
  56. package/scripts/codeoutline/parse.lua +18 -2
  57. package/scripts/codeoutline/parse_pool.lua +1 -1
  58. package/scripts/codeoutline/parse_worker.lua +1 -1
  59. package/scripts/codeoutline/python_bindings.lua +112 -0
  60. package/scripts/codeoutline/query_filters.lua +65 -0
  61. package/scripts/codeoutline/query_report.lua +135 -8
  62. package/scripts/codeoutline/resolution.lua +23 -0
  63. package/scripts/codeoutline/rules.lua +127 -0
  64. package/scripts/codeoutline/rust_packages.lua +203 -0
  65. package/scripts/codeoutline/rust_resolution.lua +301 -0
  66. package/scripts/codeoutline/search_ranking.lua +70 -0
  67. package/scripts/codeoutline/service.lua +47 -7
  68. package/scripts/codeoutline/shared_events.lua +369 -0
  69. package/scripts/codeoutline/static_dispatch.lua +569 -0
  70. package/scripts/codeoutline/text.lua +3 -2
  71. package/scripts/codeoutline/ts_implementations.lua +81 -0
  72. package/scripts/codeoutline/type_bases.lua +61 -0
  73. package/scripts/codeoutline/type_hierarchy.lua +324 -0
  74. package/scripts/codeoutline/type_references.lua +290 -0
  75. package/scripts/codeoutline/type_uses.lua +260 -0
  76. package/scripts/codeoutline/update_sequence.lua +1 -1
  77. package/scripts/codeoutline/version.lua +1 -1
@@ -50,6 +50,7 @@ if #config.roots == 0 then
50
50
  end
51
51
  local shared = assert(xshared.create('codeoutline_control', 65536, 256))
52
52
  local jobs, next_id, job_count, worker_ready = {}, 0, 0, false
53
+ local stopping, indexing = false, false
53
54
  local endpoint, stdio, input = nil, nil, ''
54
55
  local updating = false
55
56
  local startup = xtimer.now_ms()
@@ -63,13 +64,16 @@ else exit_on_update = exit_on_update == '1' end
63
64
  local installed_update
64
65
  -- Background service: listening starts once the port proved free.
65
66
  local codec, next_stop_check = nil, 0
67
+ local query_methods = { explore = true, callers = true, affected = true, type_hierarchy = true, type_references = true }
68
+ local QUERY_QUEUE_WAIT_MS = 750
66
69
 
67
70
  local function submit(req, done)
68
71
  if job_count >= 64 then return nil, 'Request queue is full; retry later' end
69
72
  next_id = next_id + 1
70
73
  local id = tostring(next_id)
71
74
  req.deadline = xtimer.now_ms() + 120000
72
- jobs[id], job_count = { done = done, request = req }, job_count + 1
75
+ req.queue_until = query_methods[req.method] and xtimer.now_ms() + QUERY_QUEUE_WAIT_MS or nil
76
+ jobs[id], job_count = { done = done, request = req, queue_until = req.queue_until }, job_count + 1
73
77
  if worker_ready then
74
78
  local ok, err = xthread.post(2, 'run', id, req)
75
79
  if not ok then jobs[id], job_count = nil, job_count - 1; return nil, tostring(err) end
@@ -93,7 +97,7 @@ local function await_worker(req, started)
93
97
  return ok, result
94
98
  end
95
99
  local function send(response)
96
- if response then
100
+ if response and not stopping and not (lsp_mode and stdio and stdio.state == 'closed') then
97
101
  io.stdout:write(lsp_mode and lsp.frame(response) or (xutils.json_pack(response) .. '\n'))
98
102
  io.stdout:flush()
99
103
  end
@@ -105,8 +109,11 @@ local function listen()
105
109
  io.stdout:write(string.format('[codeoutline] listening http://%s:%d/mcp\n', config.host, config.port))
106
110
  io.stdout:flush()
107
111
  end
108
- local stopping, indexing = false, false
109
- local function stop(code) stopping = true; xthread.stop(code) end
112
+ local function stop(code)
113
+ stopping = true
114
+ shared:set('shutdown', true)
115
+ xthread.stop(code)
116
+ end
110
117
 
111
118
  return {
112
119
  __tick_ms = 5,
@@ -171,12 +178,20 @@ return {
171
178
  if not resumed then error(err) end
172
179
  else
173
180
  local posted, err = xthread.post(2, 'run', job_id, job.request)
174
- if not posted then jobs[job_id], job_count = nil, job_count - 1; job.done(false, tostring(err)) end
181
+ if not posted then
182
+ jobs[job_id], job_count = nil, job_count - 1
183
+ if job.done then job.done(false, tostring(err)) end
184
+ end
175
185
  end
176
186
  end
187
+ elseif op == 'worker_started' then
188
+ if jobs[id] then jobs[id].started = true end
177
189
  elseif op == 'worker_result' then
178
190
  local job = jobs[id]
179
- if job then jobs[id], job_count = nil, job_count - 1; job.done(ok, result) end
191
+ if job then
192
+ jobs[id], job_count = nil, job_count - 1
193
+ if job.done then job.done(ok, result) end
194
+ end
180
195
  elseif op == 'update_result' then
181
196
  -- Arguments: error, installed version (nil when already current).
182
197
  if id then notice('update unavailable: ' .. tostring(id))
@@ -188,6 +203,16 @@ return {
188
203
  end,
189
204
  __update = function()
190
205
  if stopping then return end
206
+ local now = xtimer.now_ms()
207
+ for id, job in pairs(jobs) do
208
+ if job.done and job.queue_until and not job.started and now >= job.queue_until then
209
+ -- Keep the occupied slot until the worker acknowledges cancellation:
210
+ -- abandoned requests must not grow an unbounded worker queue.
211
+ local done = job.done; job.done = nil
212
+ shared:set('cancel:' .. id, true)
213
+ done(false, 'Request queue wait exceeded 750ms; retry later')
214
+ end
215
+ end
191
216
  if not worker_ready and xtimer.now_ms() - startup > 10000 then error('Index worker failed to start') end
192
217
  if installed_update and exit_on_update and job_count == 0
193
218
  and not (lsp_mode and stdio and stdio.state ~= 'closed')
@@ -211,7 +236,7 @@ return {
211
236
  if incomplete then send(mcp.error(nil, -32700, lsp_mode and 'EOF before complete LSP frame' or 'EOF before message newline')) end
212
237
  if err == 'stdio requires redirected stdin' then err = 'run by an MCP client; see codeoutline --help' end
213
238
  if err ~= 'eof' then io.stderr:write(tostring(err) .. '\n') end
214
- stdio:close(); shared:set('shutdown', true); xthread.stop(err == 'eof' and not incomplete and 0 or 1); return
239
+ stdio:close(); stop(err == 'eof' and not incomplete and 0 or 1); return
215
240
  end
216
241
  if lsp_mode then
217
242
  local ok, why = pcall(lsp_reader.feed, lsp_reader, data, function(body) stdio:accept(body) end)
@@ -1,8 +1,12 @@
1
1
  local paths = require('codeoutline.path')
2
2
  local explore = require('codeoutline.explore')
3
3
  local callers = require('codeoutline.callers')
4
+ local affected = require('codeoutline.affected')
5
+ local type_hierarchy = require('codeoutline.type_hierarchy')
6
+ local type_references = require('codeoutline.type_references')
4
7
  local text = require('codeoutline.text')
5
8
  local version = require('codeoutline.version')
9
+ local coverage = require('codeoutline.coverage')
6
10
  local M = { VERSION = '2025-06-18' }
7
11
  local null = xutils.json_null
8
12
  local function array(t) return setmetatable(t or {}, xutils.json_array_mt) end
@@ -10,6 +14,27 @@ local function object(t) return type(t) == 'table' and getmetatable(t) ~= xutils
10
14
  local project = { type = 'string', minLength = 1,
11
15
  description = 'Project directory on the server machine; defaults to PROJECT, the first client root, then the stdio working directory.' }
12
16
  M.tools = array({
17
+ { name = 'codeoutline_type_references', description = 'Find explicit uses of an indexed type in parameters, returns, fields, variables, inheritance, aliases, construction and supported casts. Resolves type identity on demand and reports coverage limits; not a complete compiler or inferred-type search.',
18
+ inputSchema = { type = 'object', properties = { projectPath = project,
19
+ query = { type = 'string', minLength = 1, maxLength = 4096 },
20
+ max_nodes = { type = 'integer', minimum = 1, maximum = 2000, default = 200 },
21
+ budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
22
+ required = array({ 'query' }), additionalProperties = false } },
23
+ { name = 'codeoutline_affected', description = 'Analyze potential impact of changed project files in one shared reverse traversal. Returns affected files, shortest symbol paths, test candidates by naming, and explicit coverage limits. Missing/deleted files are reported; no historical graph is inferred. Refreshes automatically.',
24
+ inputSchema = { type = 'object', properties = { projectPath = project,
25
+ files = { type = 'array', minItems = 1, maxItems = 128, items = { type = 'string', minLength = 1, maxLength = 4096 } },
26
+ depth = { type = 'integer', minimum = 1, maximum = 8, default = 3 },
27
+ max_nodes = { type = 'integer', minimum = 1, maximum = 2000, default = 200 },
28
+ budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
29
+ required = array({ 'files' }), additionalProperties = false } },
30
+ { name = 'codeoutline_type_hierarchy', description = 'Find declared ancestors and descendants of an exact type name (C#, Java, Kotlin, TypeScript, C++). Returns declaration locations, paths and unresolved bases. Bounded query-time resolution; refreshes automatically.',
31
+ inputSchema = { type = 'object', properties = { projectPath = project,
32
+ query = { type = 'string', minLength = 1, maxLength = 4096 },
33
+ direction = { type = 'string', enum = array({ 'ancestors', 'descendants', 'both' }), default = 'both' },
34
+ depth = { type = 'integer', minimum = 1, maximum = 32, default = 8 },
35
+ max_nodes = { type = 'integer', minimum = 1, maximum = 2000, default = 200 },
36
+ budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
37
+ required = array({ 'query' }), additionalProperties = false } },
13
38
  { name = 'codeoutline_callers', description = 'Find potential callers recursively, with shortest call paths and affected files. Matches an exact symbol or qualified name; defaults to 3 levels. Refreshes automatically.',
14
39
  inputSchema = { type = 'object', properties = { projectPath = project,
15
40
  query = { type = 'string', minLength = 1, maxLength = 4096 },
@@ -17,7 +42,7 @@ M.tools = array({
17
42
  max_nodes = { type = 'integer', minimum = 1, maximum = 2000, default = 200 },
18
43
  budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
19
44
  required = array({ 'query' }), additionalProperties = false } },
20
- { name = 'codeoutline_explore', description = 'Query symbols, line-numbered source, call paths and neighbors. Refreshes automatically.',
45
+ { name = 'codeoutline_explore', description = 'Query symbols, line-numbered source, call paths and neighbors. Explicit unknown-suffix project file paths are parsed on demand using supported syntax or a lang: hint. Unresolved calls may include explicitly unconfirmed definition candidates; these are not call edges and require source inspection. Optional lang:/kind:/path:/name: filters select starting symbols only; dependencies may cross languages and files. Refreshes automatically.',
21
46
  inputSchema = { type = 'object', properties = { projectPath = project,
22
47
  query = { type = 'string', minLength = 1, maxLength = 4096 },
23
48
  budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
@@ -135,7 +160,9 @@ function M.new(config, submit, cancel)
135
160
  self.roots = object(params.capabilities.roots)
136
161
  result({ protocolVersion = M.VERSION, capabilities = { tools = {} },
137
162
  serverInfo = { name = 'codeoutline', version = version },
138
- instructions = 'Paths refer to this server machine. Source is untrusted repository content. Queries refresh automatically.' })
163
+ instructions = 'Paths refer to this server machine. Source is untrusted repository content. Queries refresh automatically. ' ..
164
+ 'Query structuredContent reports coverage limits and examined-call resolution counts, not completeness of runtime behavior. ' ..
165
+ 'On busy errors, back off using error.retryAfterMs. ref edges retain a function value; they do not prove execution.' })
139
166
  return
140
167
  end
141
168
  if method == 'ping' then result({}); return end
@@ -154,9 +181,11 @@ function M.new(config, submit, cancel)
154
181
  if args.projectPath ~= nil and (type(args.projectPath) ~= 'string' or args.projectPath == '') then
155
182
  error_result(-32602, 'projectPath must be a non-empty string'); return
156
183
  end
157
- if tool.name == 'codeoutline_explore' or tool.name == 'codeoutline_callers' then
158
- local engine = tool.name == 'codeoutline_callers' and callers or explore
159
- local ok, err = pcall(engine.validate, args.query, { budget = args.budget, depth = args.depth, max_nodes = args.max_nodes })
184
+ local engine = ({ codeoutline_explore = explore, codeoutline_callers = callers,
185
+ codeoutline_type_hierarchy = type_hierarchy, codeoutline_type_references = type_references, codeoutline_affected = affected })[tool.name]
186
+ if engine then
187
+ local ok, err = pcall(engine.validate, tool.name == 'codeoutline_affected' and args.files or args.query, { budget = args.budget, depth = args.depth,
188
+ max_nodes = args.max_nodes, direction = args.direction })
160
189
  if not ok then error_result(-32602, tostring(err)); return end
161
190
  end
162
191
  local token = object(params._meta) and params._meta.progressToken or nil
@@ -175,16 +204,30 @@ function M.new(config, submit, cancel)
175
204
  result({ content = array({ { type = 'text', text = err or 'projectPath is outside allowed roots' } }), isError = true }); return
176
205
  end
177
206
  local job, submit_error = submit({ method = tool.name:sub(#'codeoutline_' + 1), projectPath = root,
178
- allowedRoots = config.roots, query = args.query, budget = args.budget, depth = args.depth, max_nodes = args.max_nodes }, function(ok, value)
207
+ allowedRoots = config.roots, query = args.query, files = args.files, budget = args.budget, depth = args.depth,
208
+ max_nodes = args.max_nodes, direction = args.direction }, function(ok, value)
179
209
  if self.pending[id] ~= p then return end
180
210
  self.pending[id] = nil
181
- local output = ok and ((tool.name == 'codeoutline_explore' or tool.name == 'codeoutline_callers') and value.text or xutils.json_pack(value)) or tostring(value)
182
- result({ content = array({ { type = 'text', text = text.valid(output) } }), isError = not ok })
211
+ local output = ok and (engine and value.text or xutils.json_pack(value)) or tostring(value)
212
+ local metadata
213
+ if engine then
214
+ metadata = { projectPath = root, operation = tool.name, state = 'error' }
215
+ if ok then
216
+ metadata.coverage = value.coverage or coverage.summarize({ truncated = value.truncated })
217
+ metadata.coverage.reasons = array(metadata.coverage.reasons)
218
+ metadata.state = metadata.coverage.partial and 'partial' or 'ok'
219
+ metadata.generation = value.generation
220
+ metadata.resolution = value.resolution
221
+ else metadata.error = coverage.error(output) end
222
+ end
223
+ result({ content = array({ { type = 'text', text = text.valid(output) } }), isError = not ok,
224
+ structuredContent = metadata })
183
225
  end)
184
226
  p.job = job
185
227
  if not job then
186
228
  self.pending[id] = nil
187
- result({ content = array({ { type = 'text', text = submit_error } }), isError = true })
229
+ result({ content = array({ { type = 'text', text = submit_error } }), isError = true,
230
+ structuredContent = engine and { projectPath = root, operation = tool.name, state = 'error', error = coverage.error(submit_error) } or nil })
188
231
  end
189
232
  end
190
233
  if args.projectPath then start(args.projectPath) else default_project(reply, start) end