@allansantos-dev/smart-tool 0.9.81 → 0.9.82

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 (50) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/NOTICE +1 -1
  3. package/README.md +41 -13
  4. package/agent_redirect.py +32 -0
  5. package/autostart.py +32 -25
  6. package/browser_bridge.py +320 -0
  7. package/browser_control.py +76 -39
  8. package/browser_service_client.py +1 -7
  9. package/client_hooks.py +41 -42
  10. package/code_graph.py +56 -15
  11. package/code_graph_java.mjs +21 -12
  12. package/code_health.py +14 -9
  13. package/codex_config.py +3 -0
  14. package/daemon_launcher.py +37 -5
  15. package/doc_candidates.py +63 -0
  16. package/doc_check.py +9 -3
  17. package/doc_extras.py +2 -3
  18. package/doc_insights.py +26 -2
  19. package/doc_prose.py +59 -11
  20. package/doc_registry.py +241 -0
  21. package/doc_scope.py +205 -39
  22. package/doc_turn.py +205 -0
  23. package/doc_validate.py +52 -9
  24. package/document_read.py +4 -2
  25. package/edit_shape.py +119 -0
  26. package/endpoint_sync.py +3 -21
  27. package/engine_home.py +95 -0
  28. package/hook_call.py +132 -0
  29. package/hook_decision.py +100 -6
  30. package/hooks/pretool_router.py +36 -30
  31. package/hooks/turn_end.py +40 -0
  32. package/index_views.py +5 -0
  33. package/install.py +24 -9
  34. package/lazy_mcp_proxy.py +10 -9
  35. package/local_embedder.py +8 -1
  36. package/locales/pt-BR.json +1 -2
  37. package/model_breaker.py +6 -5
  38. package/package.json +2 -2
  39. package/process_limits.py +17 -3
  40. package/project_identity.py +19 -1
  41. package/project_scan.py +98 -0
  42. package/scout_access.py +48 -0
  43. package/shell_reads.py +67 -0
  44. package/smart_tool_daemon.py +144 -39
  45. package/tray.py +31 -0
  46. package/venv_launch.py +67 -0
  47. package/version.py +1 -1
  48. package/web_adapters/node/engine-home.mjs +42 -0
  49. package/web_adapters/node/package-lock.json +13 -0
  50. package/web_adapters/node/package.json +1 -0
package/client_hooks.py CHANGED
@@ -10,13 +10,15 @@ import tomllib
10
10
 
11
11
  import atomic_io
12
12
  import codex_config
13
- import daemon_launcher
14
13
  import endpoint_sync
14
+ import hook_call
15
15
 
16
16
  HOOK_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "hooks", "pretool_router.py")
17
17
  MARKER = "pretool_router.py"
18
18
  AUDIT_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "hooks", "session_audit.py")
19
19
  AUDIT_MARKER = "session_audit.py"
20
+ TURN_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "hooks", "turn_end.py")
21
+ TURN_MARKER = "turn_end.py"
20
22
  # Hook origin convention shared by every project that installs hooks: a failed command hook names its owner.
21
23
  HOOK_ORIGIN = "--hook-origin=smart-tool"
22
24
  AUDIT_MATCHER = "startup|resume|clear|compact|fork"
@@ -27,17 +29,14 @@ AUDIT_WAITING = "waiting_approval"
27
29
  OWNER = "smart-tool"
28
30
  MANAGER_TIMEOUT_S = 5
29
31
  MANAGER_HELD = ("quarantined", "held")
30
- HTTP_PATH = "/hooks/pretool"
31
- POST_PATH = "/hooks/posttool"
32
- # A redirected shell search waits for its answer in the PreToolUse (smart_tool_daemon.HOOK_SHELL_BUDGET_S).
33
- HTTP_TIMEOUT_S = 15
34
- # The PostToolUse waits for the Smart Tool answer of a redirected call (web_fetch reads a whole page).
35
- POST_TIMEOUT_S = 60
32
+ LEGACY_URL_PATHS = ("/hooks/pretool", "/hooks/posttool", "/hooks/subagent-start")
33
+ # Each entry's timeout covers the restart wait of `hook_call` plus the longest answer the daemon takes on that route
34
+ # (a redirected shell search in the PreToolUse, a whole page in the PostToolUse of web_fetch).
36
35
  HOME = os.path.expanduser("~")
37
36
  PREVIEW_TTL_S = 600
38
37
  CLIENTS = {
39
38
  "claude": {"label": "Claude Code", "names": {"claude-code"}, "files": [os.path.join(endpoint_sync.claude_dir(), "settings.json")],
40
- "docs": "https://code.claude.com/docs/en/hooks", "event": "PreToolUse", "matcher": "Grep|Glob|Read|Bash|PowerShell|WebSearch|WebFetch|Edit|MultiEdit|Write|mcp__smart-tool__smart_search|mcp__smart-tool__web_search|mcp__smart-tool__web_fetch", "http": True,
39
+ "docs": "https://code.claude.com/docs/en/hooks", "event": "PreToolUse", "matcher": "Agent|Task|Grep|Glob|Read|Bash|PowerShell|WebSearch|WebFetch|Edit|MultiEdit|Write|mcp__smart-tool__smart_search|mcp__smart-tool__web_search|mcp__smart-tool__web_fetch",
41
40
  "post_matcher": "Grep|Bash|PowerShell|WebFetch|WebSearch"},
42
41
  "codex": {"label": "Codex", "prefix": "codex", "files": [os.path.join(endpoint_sync.codex_dir(), "hooks.json"), os.path.join(endpoint_sync.codex_dir(), "config.toml")],
43
42
  "docs": "https://learn.chatgpt.com/docs/hooks", "event": "PreToolUse", "matcher": "Bash|apply_patch", "post_matcher": "Bash",
@@ -58,17 +57,30 @@ def identify(client_info):
58
57
 
59
58
 
60
59
  def _our_hook(hook):
61
- return isinstance(hook, dict) and (MARKER in str(hook.get("command", "")) or
62
- any(path in str(hook.get("url", "")) for path in (HTTP_PATH, POST_PATH)))
60
+ return isinstance(hook, dict) and (MARKER in str(hook.get("command", "")) or TURN_MARKER in str(hook.get("command", "")) or
61
+ any(path in str(hook.get("url", "")) for path in LEGACY_URL_PATHS))
62
+
63
+
64
+ def _events(client):
65
+ """Events install writes an entry of ours under for the client, known without the daemon (removal needs no URL)."""
66
+ spec = CLIENTS[client]
67
+ return [spec["event"], *(["PostToolUse"] if spec.get("post_matcher") else []), *(["SubagentStart", "Stop"] if client == "claude" else [])]
63
68
 
64
69
 
65
70
  def _entries(client):
66
71
  """{event: (matcher, handler)} of our hook entries for the client: the PreToolUse, plus the PostToolUse that returns
67
- the Smart Tool answer of a redirected call and the review of the files a shell call wrote."""
72
+ the Smart Tool answer of a redirected call and the review of the files a shell call wrote, plus, in Claude Code, the
73
+ Stop command of the end-of-turn documentation step (matcher None: Stop takes none), plus the SubagentStart that tells
74
+ every subagent about smart_scout (no matcher: it reaches every agent type)."""
68
75
  spec = CLIENTS[client]
69
76
  entries = {spec["event"]: (spec["matcher"], _handler(client))}
70
77
  if spec.get("post_matcher"):
71
- entries["PostToolUse"] = (spec["post_matcher"], _handler(client, POST_PATH, POST_TIMEOUT_S))
78
+ entries["PostToolUse"] = (spec["post_matcher"], _handler(client, "posttool"))
79
+ if "SubagentStart" in _events(client):
80
+ entries["SubagentStart"] = (None, _handler(client, "subagent-start"))
81
+ if "Stop" in _events(client):
82
+ entries["Stop"] = (None, {"type": "command", "timeout": _timeout("stop"),
83
+ "command": f"{_shell_safe(sys.executable)} {_shell_safe(TURN_SCRIPT)} {HOOK_ORIGIN}"})
72
84
  return entries
73
85
 
74
86
 
@@ -141,7 +153,7 @@ def inspect(client, trust=True, manager=True):
141
153
  text = stream.read()
142
154
  except FileNotFoundError:
143
155
  continue
144
- if MARKER not in text and HTTP_PATH not in text:
156
+ if MARKER not in text and not any(path in text for path in LEGACY_URL_PATHS):
145
157
  continue
146
158
  if not path.endswith(".json"):
147
159
  return {"state": "current", "changes": []}
@@ -167,7 +179,7 @@ def _entry_changes(event, matcher, expected, groups):
167
179
  group = ours[0]
168
180
  changes = []
169
181
  covered = str(group.get("matcher") or "").split("|")
170
- left_out = [tool for tool in matcher.split("|") if tool not in covered]
182
+ left_out = [tool for tool in (matcher or "").split("|") if tool not in covered]
171
183
  if left_out:
172
184
  changes.append(f"Its {event} entry does not cover {', '.join(left_out)}.")
173
185
  found = next(hook for hook in group["hooks"] if _our_hook(hook))
@@ -237,32 +249,20 @@ def _shell_safe(path):
237
249
  return path.replace("\\", "/")
238
250
 
239
251
 
240
- def _command(client, route=HTTP_PATH):
241
- """The command of a client without HTTP hooks for the PreToolUse route (default) or the PostToolUse one, signed with
242
- HOOK_ORIGIN at the end."""
243
- after = " --post" if route == POST_PATH else ""
244
- return f"{_shell_safe(sys.executable)} {_shell_safe(HOOK_SCRIPT)} --client {client}{after} {HOOK_ORIGIN}"
252
+ def _timeout(route):
253
+ """The entry timeout of a route: the restart wait plus the longest answer, with a second to spare."""
254
+ return hook_call.ROUTE_TIMEOUT_S[route] + 1 + hook_call.RESTART_WINDOW_S
245
255
 
246
256
 
247
- def _port_file():
248
- """The daemon's announcement file as `~/<path>`, the form the hook audit reads to know the URL port is managed."""
249
- relative = os.path.relpath(daemon_launcher.REGISTRY_PATH, os.path.expanduser("~")).replace("\\", "/")
250
- if relative.startswith(".."):
251
- raise ValueError(f"The daemon announcement ({daemon_launcher.REGISTRY_PATH}) is outside the home folder; "
252
- "the hook cannot name it as its port file.")
253
- return f"~/{relative}"
257
+ def _command(client, route):
258
+ """The command of a client for a route (`pretool`, `posttool`, `subagent-start`), signed with HOOK_ORIGIN at the
259
+ end; it finds the daemon through its run file on every call."""
260
+ return f"{_shell_safe(sys.executable)} {_shell_safe(HOOK_SCRIPT)} --client {client} --route {route} {HOOK_ORIGIN}"
254
261
 
255
262
 
256
- def _handler(client, route=HTTP_PATH, timeout=HTTP_TIMEOUT_S):
257
- """Claude Code posts the payload straight to the warm daemon (`type: "http"`, no process per tool call); other
258
- clients run the thin command that forwards to the route."""
259
- if CLIENTS[client].get("http"):
260
- registry = daemon_launcher.read_registry()
261
- if not registry or not registry.get("url"):
262
- raise ValueError("Smart Tool daemon has no registered URL; start the daemon before installing the hook.")
263
- query = f"client={client}&hook-origin={OWNER}&port-file={_port_file()}"
264
- return {"type": "http", "url": f"{registry['url']}{route}?{query}", "timeout": timeout}
265
- return {"type": "command", "command": _command(client, route), "timeout": timeout}
263
+ def _handler(client, route="pretool"):
264
+ """The command handler of a client's entry for a route."""
265
+ return {"type": "command", "command": _command(client, route), "timeout": _timeout(route)}
266
266
 
267
267
 
268
268
  def _slot(groups, is_ours):
@@ -301,7 +301,8 @@ def _plan(client_info):
301
301
  raise ValueError(f"{path}: hooks.{event} is not a list; nothing was changed.")
302
302
  before, slot = list(groups), _slot(groups, _our_hook)
303
303
  groups[:] = _without_ours(groups)
304
- changes[event] = (groups, {"matcher": matcher, "hooks": [handler]}, slot, before)
304
+ changes[event] = (groups, {"hooks": [handler]} if matcher is None else {"matcher": matcher, "hooks": [handler]},
305
+ slot, before)
305
306
  return client, spec, path, data, changes
306
307
 
307
308
 
@@ -342,9 +343,8 @@ def install(client_info, token, confirm):
342
343
 
343
344
 
344
345
  def remove(client):
345
- """Takes every redirect hook entry of ours (PreToolUse and PostToolUse) out of the client's hooks
346
- file after a backup; other hooks stay, in Codex at the approval of their new index. Returns {client, changed, file,
347
- backup}."""
346
+ """Takes every hook entry install wrote (each event of `_entries`) out of the client's hooks file after a backup;
347
+ other hooks stay, in Codex at the approval of their new index. Returns {client, changed, file, backup}."""
348
348
  path = os.path.realpath(CLIENTS[client]["files"][0])
349
349
  try:
350
350
  with open(path, encoding="utf-8") as stream:
@@ -355,8 +355,7 @@ def remove(client):
355
355
  if not isinstance(hooks, dict):
356
356
  raise ValueError(f"{path} does not have the expected format (object with 'hooks'); nothing was changed.")
357
357
  moved = {}
358
- spec = CLIENTS[client]
359
- for event in (spec["event"], *(["PostToolUse"] if spec.get("post_matcher") else [])):
358
+ for event in _events(client):
360
359
  groups = hooks.get(event)
361
360
  if not isinstance(groups, list) or not any(_ours(group) for group in groups):
362
361
  continue
package/code_graph.py CHANGED
@@ -97,6 +97,28 @@ def _snapshot(path):
97
97
  conn.close()
98
98
 
99
99
 
100
+ def python_import_targets(path,node,known):
101
+ """The files of `known` that an import statement of the Python file `path` names.
102
+
103
+ Parameters: path (str) project-relative path of the importing file; node (ast.Import or ast.ImportFrom); known
104
+ (container of str) the project's files.
105
+ Returns: list of (alias, target, base): `target` is the file the alias resolves to or None; `base` is the module file of
106
+ a `from` import (None for a plain import and when the module is not a project file).
107
+ """
108
+ def resolve_file(spec):
109
+ spec=posixpath.normpath(spec)
110
+ return next((p for p in (spec+'.py',spec+'/__init__.py','src/'+spec+'.py','src/'+spec+'/__init__.py') if p in known), None)
111
+ if isinstance(node,ast.Import):
112
+ return [(item,resolve_file(item.name.replace('.','/')),None) for item in node.names]
113
+ prefix=posixpath.dirname(path)
114
+ if node.level:
115
+ for _ in range(node.level-1):prefix=posixpath.dirname(prefix)
116
+ spec=posixpath.join(prefix,(node.module or '').replace('.','/'))
117
+ else:spec=(node.module or '').replace('.','/')
118
+ base=resolve_file(spec)
119
+ return [(item,(resolve_file(spec+'/'+item.name) if item.name!='*' else None) or base,base) for item in node.names]
120
+
121
+
100
122
  def _python_graph(sources):
101
123
  trees, symbols, dependencies, calls, unresolved, diagnostics = {}, [], [], [], [], []
102
124
  decls, aliases, scopes, classes, owners, shadow_scopes, node_symbols = {}, {}, {}, {}, {}, {}, {}
@@ -104,9 +126,6 @@ def _python_graph(sources):
104
126
  def bind_import(path,scope,name,binding):
105
127
  table=aliases[path].setdefault(scope,{})
106
128
  table[name]=binding if name not in table or table[name]==binding else None
107
- def resolve_file(spec):
108
- spec=posixpath.normpath(spec)
109
- return next((p for p in (spec+'.py',spec+'/__init__.py','src/'+spec+'.py','src/'+spec+'/__init__.py') if p in sources), None)
110
129
  for path, text in sources.items():
111
130
  if not path.endswith('.py'):
112
131
  continue
@@ -132,20 +151,11 @@ def _python_graph(sources):
132
151
  collect(tree)
133
152
  for node in ast.walk(tree):
134
153
  if isinstance(node,ast.Import):
135
- for item in node.names:
136
- spec=item.name.replace('.','/');target=resolve_file(spec)
154
+ for item,target,_base in python_import_targets(path,node,sources):
137
155
  bind_import(path,owners[id(node)],item.asname or item.name,(target,None))
138
156
  dependencies.append({'source':path,'target':target,'specifier':item.name,'line':node.lineno,'kind':'import','resolution':'resolved' if target else 'external'})
139
157
  elif isinstance(node,ast.ImportFrom):
140
- prefix=posixpath.dirname(path)
141
- if node.level:
142
- for _ in range(node.level-1):prefix=posixpath.dirname(prefix)
143
- spec=posixpath.join(prefix,(node.module or '').replace('.','/'))
144
- else:spec=(node.module or '').replace('.','/')
145
- base=resolve_file(spec)
146
- for item in node.names:
147
- target=resolve_file(spec+'/'+item.name) if item.name!='*' else None
148
- target=target or base
158
+ for item,target,base in python_import_targets(path,node,sources):
149
159
  bind_import(path,owners[id(node)],item.asname or item.name,(target,None if target and target!=base else item.name))
150
160
  dependencies.append({'source':path,'target':target,'specifier':('.'*node.level)+(node.module or '')+'.'+item.name,'line':node.lineno,'kind':'import','resolution':'resolved' if target else 'unresolved' if node.level else 'external'})
151
161
  def chain(expr):
@@ -418,7 +428,9 @@ def _disk_save(key,data):
418
428
  return None
419
429
 
420
430
 
421
- def cached_symbols(root):
431
+ def _cached_analysis(root):
432
+ """(key, analysis) of the project's current index when memory or disk holds it; (key, None) when it does not and (None,
433
+ None) when the project has no index. Starts nothing."""
422
434
  path=indexer.existing_db_path(root)
423
435
  if not path:
424
436
  return None,None
@@ -433,6 +445,35 @@ def cached_symbols(root):
433
445
  with _LOCK:
434
446
  _CACHE[key]=data
435
447
  while len(_CACHE)>3:_CACHE.popitem(last=False)
448
+ return key,data
449
+
450
+
451
+ def cached_graph(root):
452
+ """The analysis of the project's current index when memory or disk already holds it, else None: it never analyzes and
453
+ never starts the background warm-up. The caller must only read it."""
454
+ return _cached_analysis(root)[1]
455
+
456
+
457
+ def import_edges(data):
458
+ """Resolved import edges of an analysis: dict file -> set of project files it imports, every file of an edge a key."""
459
+ edges={}
460
+ for dependency in data.get('dependencies') or []:
461
+ if dependency.get('kind')=='import' and dependency.get('resolution')=='resolved' and dependency.get('target'):
462
+ edges.setdefault(dependency['source'],set()).add(dependency['target'])
463
+ edges.setdefault(dependency['target'],set())
464
+ return edges
465
+
466
+
467
+ def cached_symbols(root):
468
+ """Symbols by file of the project's current index when its analysis is cached, starting the background analysis when it
469
+ is not (the caller never waits for it).
470
+
471
+ Parameters: root (str) project folder.
472
+ Returns: tuple (dict {"symbols", "parsed", "note"} or None while no analysis is ready; str note or None).
473
+ """
474
+ key,data=_cached_analysis(root)
475
+ if key is None:
476
+ return None,None
436
477
  with _LOCK:
437
478
  state=_WARM_STATE.get(root)
438
479
  if data is None and state and state['key']==key and (state['result'] or time.time()-state['at']<WARM_RETRY_S):
@@ -9,7 +9,7 @@ if(nodeModule.registerHooks){const bundle=new URL('chevrotain/lib/chevrotain.mjs
9
9
  load(url,context,next){return url.startsWith('lodash-function:')?{format:'module',source:`import _ from ${JSON.stringify(lodash)};export default _.${url.slice(16)};`,shortCircuit:true}:next(url,context)}})}
10
10
  const {parse}=await import(new URL('java-parser/src/index.js',modules).href);
11
11
  const input=JSON.parse(fs.readFileSync(0,'utf8'));
12
- const symbols=[],dependencies=[],calls=[],unresolved=[],diagnostics=[],units=[],classes=new Map(),methodNodes=new Map(),kids=new WeakMap();
12
+ const symbols=[],dependencies=[],calls=[],unresolved=[],diagnostics=[],units=[],classes=new Map(),kids=new WeakMap(),declaredOnly=new Set();
13
13
  const {symbols:MAX_SYMBOLS,edges:MAX_EDGES}=input.limits;const leftOut={symbols:0,edges:0};
14
14
  function room(list,max,kind){if(list.length<max)return true;leftOut[kind]++;return false}
15
15
  const NO_CHILDREN=Object.freeze([]);
@@ -20,23 +20,32 @@ function identifiers(n){const out=[];function visit(node){if(node?.children)for(
20
20
  function text(u,n){return n?.location?u.text.slice(n.location.startOffset,n.location.endOffset+1):''}
21
21
  function addSymbol(u,n,name,kind){if(!room(symbols,MAX_SYMBOLS,'symbols'))return null;const s={id:u.path+'::'+name+'@'+n.location.startLine+':'+n.location.startOffset,path:u.path,name,kind,language:'java',start_line:n.location.startLine,end_line:n.location.endLine};symbols.push(s);return s}
22
22
  const classKinds=new Set(['normalClassDeclaration','normalInterfaceDeclaration','enumDeclaration','recordDeclaration']);
23
- for(const file of input.files){try{const tree=parse(file.text),pkg=first(tree,'packageDeclaration'),unit={...file,tree,package:pkg?identifiers(pkg).map(t=>t.image).join('.'): '',imports:[],classes:[]};
23
+ const METHOD_KINDS=new Set(['methodDeclaration','interfaceMethodDeclaration','constructorDeclaration','compactConstructorDeclaration']);
24
+ // Each file is parsed twice, once to index its types and once to walk its calls, so only one syntax tree is alive at a time.
25
+ for(const file of input.files){try{const tree=parse(file.text),pkg=first(tree,'packageDeclaration'),unit={...file,methodsAt:new Map(),package:pkg?identifiers(pkg).map(t=>t.image).join('.'): '',imports:[],classes:[]};
24
26
  for(const n of all(tree,'importDeclaration')){const raw=text(unit,n).replace(/^import\s+/,'').replace(/;\s*$/,'').trim(),stat=raw.startsWith('static '),spec=(stat?raw.slice(7):raw).replace(/\s+/g,'');unit.imports.push({spec,static:stat,line:n.location.startLine})}
25
- function scan(n,parent=null){let current=parent;if(classKinds.has(n.name)){const id=first(n,'typeIdentifier')||first(n,'typeName'),short=identifiers(id||n)[0]?.image;if(!short)return;const local=(parent?parent.local+'.':'')+short,fqn=(unit.package?unit.package+'.':'')+local;const symbol=addSymbol(unit,n,local,n.name==='normalInterfaceDeclaration'?'interface':'class');if(!symbol)return;current={unit,fqn,local,short,symbol,node:n,body:n.children.classBody?.[0]||n.children.interfaceBody?.[0]||n.children.recordBody?.[0]||n.children.enumBody?.[0],methods:[],fields:new Map(),extends:text(unit,n.children.classExtends?.[0]).replace(/^extends\s+/, '').trim()};classes.set(fqn,classes.has(fqn)?null:current);unit.classes.push(current)}
27
+ function scan(n,parent=null){let current=parent;if(classKinds.has(n.name)){const id=first(n,'typeIdentifier')||first(n,'typeName'),short=identifiers(id||n)[0]?.image;if(!short)return;const local=(parent?parent.local+'.':'')+short,fqn=(unit.package?unit.package+'.':'')+local;const symbol=addSymbol(unit,n,local,n.name==='normalInterfaceDeclaration'?'interface':'class');if(!symbol)return;current={unit,fqn,local,short,symbol,node:n,offset:n.location.startOffset,body:n.children.classBody?.[0]||n.children.interfaceBody?.[0]||n.children.recordBody?.[0]||n.children.enumBody?.[0],methods:[],fields:new Map(),extends:text(unit,n.children.classExtends?.[0]).replace(/^extends\s+/, '').trim()};classes.set(fqn,classes.has(fqn)?null:current);unit.classes.push(current)}
26
28
  if(current&&n.name==='classBody'&&n!==current.body)return;
27
- if(current&&['methodDeclaration','interfaceMethodDeclaration','constructorDeclaration','compactConstructorDeclaration'].includes(n.name)){const declarator=first(n,'methodDeclarator')||first(n,'constructorDeclarator'),ctor=n.name.includes('Constructor')||n.name==='constructorDeclaration',name=ctor?current.short:(declarator?.children.Identifier?.[0]?.image);if(name){const params=all(declarator||n,'formalParameter'),types=params.map(p=>text(unit,first(p,'unannType'))||'?');const signature=name+'('+types.join(',')+')';const sym=addSymbol(unit,n,current.local+'.'+signature,ctor?'constructor':'method');if(sym){sym.signature=signature;const method={symbol:sym,name,arity:params.length,types,node:n,cls:current,params,concrete:!!first(n,'block')||ctor};current.methods.push(method);methodNodes.set(n,method)}}}
28
- for(const child of children(n))scan(child,current)}scan(tree);units.push(unit)
29
+ if(current&&METHOD_KINDS.has(n.name)){const declarator=first(n,'methodDeclarator')||first(n,'constructorDeclarator'),ctor=n.name.includes('Constructor')||n.name==='constructorDeclaration',name=ctor?current.short:(declarator?.children.Identifier?.[0]?.image);if(name){const params=all(declarator||n,'formalParameter'),types=params.map(p=>text(unit,first(p,'unannType'))||'?');const signature=name+'('+types.join(',')+')';const sym=addSymbol(unit,n,current.local+'.'+signature,ctor?'constructor':'method');if(sym){sym.signature=signature;const method={symbol:sym,name,arity:params.length,types,cls:current,concrete:!!first(n,'block')||ctor};current.methods.push(method);unit.methodsAt.set(n.location.startOffset,method)}}}
30
+ for(const child of children(n))scan(child,current)}scan(tree);indexFields(unit);units.push(unit)
29
31
  }catch{diagnostics.push({path:file.path,reason:'Invalid or fragmented Java, or syntax not supported by the parser.'})}}
32
+ function indexFields(unit){for(const cl of unit.classes){for(const node of scoped(cl.body,'fieldDeclaration')){const type=text(unit,first(node,'unannType'));for(const id of all(node,'variableDeclaratorId'))putBinding(cl.fields,identifiers(id)[0]?.image,type)}cl.bodyStart=cl.body?.location.startOffset;cl.node=cl.body=null}}
30
33
  function resolveType(unit,raw,context){let name=raw.replace(/@[\w.]+(?:\([^)]*\))?/g,'').replace(/<.*>/g,'').replace(/\[\]|\.\.\./g,'').trim();if(!name||['void','boolean','byte','short','int','long','float','double','char','var'].includes(name))return null;if(classes.has(name))return classes.get(name);const candidates=new Set();const local=[context?context.fqn+'.'+name:'',unit.package?unit.package+'.'+name:name];for(const fq of local)if(classes.has(fq))candidates.add(fq);for(const item of unit.imports.filter(i=>!i.static)){if(item.spec.endsWith('.'+name)&&classes.has(item.spec))candidates.add(item.spec);if(item.spec.endsWith('.*')){const fq=item.spec.slice(0,-1)+name;if(classes.has(fq))candidates.add(fq)}}return candidates.size===1?classes.get([...candidates][0]):null}
31
- function lookupMethod(cls,name,arity,visited=new Set()){if(!cls||visited.has(cls.fqn))return null;visited.add(cls.fqn);const methods=cls.methods.filter(m=>m.name===name&&m.arity===arity&&m.concrete);if(methods.length===1)return methods[0].symbol;if(methods.length>1)return null;return cls.extends?lookupMethod(resolveType(cls.unit,cls.extends,cls),name,arity,visited):null}
34
+ function lookupMethod(cls,name,arity,visited=new Set()){if(!cls||visited.has(cls.fqn))return null;visited.add(cls.fqn);const methods=cls.methods.filter(m=>m.name===name&&m.arity===arity&&m.concrete);if(methods.length===1)return methods[0].symbol;if(methods.length>1)return null;if(cls.symbol.kind==='interface')return declaredMethod(cls,name,arity);return cls.extends?lookupMethod(resolveType(cls.unit,cls.extends,cls),name,arity,visited):null}
35
+ /**
36
+ * The method an interface of the project declares with this name and arity, reached by a call through a field or
37
+ * variable of that type; a method the interface inherits from a library has no project symbol and stays unresolved.
38
+ * @param {object} cls interface entry; @param {string} name method name; @param {number} arity argument count
39
+ * @returns {object|null} the method symbol, or null when none or more than one matches
40
+ */
41
+ function declaredMethod(cls,name,arity){const methods=cls.methods.filter(m=>m.name===name&&m.arity===arity);if(methods.length!==1)return null;declaredOnly.add(methods[0].symbol.id);return methods[0].symbol}
32
42
  function putBinding(map,name,type){if(name)map.set(name,map.has(name)&&map.get(name)!==type?null:type)}
33
43
  function scoped(node,name){const out=[];function scan(n){if(n!==node&&(classKinds.has(n.name)||n.name==='lambdaExpression'||n.name==='classBody'))return;if(n.name===name)out.push(n);for(const c of children(n))scan(c)}scan(node);return out}
34
44
  function collectVariables(unit,node,map){for(const parentName of ['fieldDeclaration','localVariableDeclaration','variableParaRegularParameter','variableArityParameter'])for(const declaration of scoped(node,parentName)){const type=text(unit,first(declaration,'unannType'));for(const id of all(declaration,'variableDeclaratorId'))putBinding(map,identifiers(id)[0]?.image,type)}}
35
- for(const unit of units){for(const cl of unit.classes){const fieldNodes=scoped(cl.body,'fieldDeclaration');for(const node of fieldNodes){const type=text(unit,first(node,'unannType'));for(const id of all(node,'variableDeclaratorId'))putBinding(cl.fields,identifiers(id)[0]?.image,type)}}}
36
- for(const unit of units){
45
+ for(const unit of units){const tree=parse(unit.text);
37
46
  for(const item of unit.imports){const spec=item.spec;let target=classes.get(item.static?spec.split('.').slice(0,-1).join('.'):spec);dependencies.push({source:unit.path,target:target?.unit.path||null,specifier:spec,line:item.line,kind:item.static?'java_static_import':'import',resolution:target?'resolved':'external'})}
38
- function walk(n,cls=null,method=null,vars=new Map(),owner=null){if(classKinds.has(n.name))cls=unit.classes.find(c=>c.node===n)||cls;if(cls&&n.name==='classBody'&&n!==cls.body)return;
39
- if(methodNodes.has(n)){method=methodNodes.get(n);vars=new Map(cls.fields);collectVariables(unit,n,vars);owner=method.symbol}
47
+ function walk(n,cls=null,method=null,vars=new Map(),owner=null){if(classKinds.has(n.name))cls=unit.classes.find(c=>c.offset===n.location.startOffset)||cls;if(cls&&n.name==='classBody'&&n.location.startOffset!==cls.bodyStart)return;
48
+ if(METHOD_KINDS.has(n.name)&&unit.methodsAt.has(n.location.startOffset)){method=unit.methodsAt.get(n.location.startOffset);vars=new Map(cls.fields);collectVariables(unit,n,vars);owner=method.symbol}
40
49
  if(n.name==='lambdaExpression'){vars=new Map(vars);for(const param of identifiers(n.children.lambdaParameters?.[0]))vars.set(param.image,null);owner=addSymbol(unit,n,(cls?.local||'')+'.lambda@'+n.location.startLine,'function')||owner}
41
50
  if(cls&&['unannType','classType','interfaceType'].includes(n.name)){const type=resolveType(unit,text(unit,n),cls);if(type&&type.unit.path!==unit.path&&room(dependencies,MAX_EDGES,'edges'))dependencies.push({source:unit.path,target:type.unit.path,specifier:type.fqn,line:n.location.startLine,kind:'java_type',resolution:'resolved'})}
42
51
  if(cls&&n.name==='primary'){
@@ -49,13 +58,13 @@ for(const unit of units){
49
58
  for(const suffix of suffixes){const invoke=suffix.children.methodInvocationSuffix?.[0];if(!invoke){chain+=text(unit,suffix);continue}const args=invoke.children.argumentList?.[0],arity=args?(args.children.expression||[]).length:0;const match=/^(?:([\w.$]+)\.)?([\w$]+)$/.exec(chain);let target=null;
50
59
  if(match&&!fluent){const receiver=match[1],name=match[2];let type=null;if(!receiver||receiver==='this')type=cls;else if(receiver==='super')type=resolveType(unit,cls.extends,cls);else if(receiver.startsWith('this.'))type=resolveType(unit,cls.fields.get(receiver.slice(5))||'',cls);else if(vars.has(receiver))type=resolveType(unit,vars.get(receiver)||'',cls);else{type=resolveType(unit,receiver,cls);link(type,invoke.location.startLine)}target=lookupMethod(type,name,arity);if(!target&&!receiver){const candidates=unit.imports.filter(i=>i.static&&(i.spec.endsWith('.'+name)||i.spec.endsWith('.*'))).map(i=>lookupMethod(classes.get(i.spec.split('.').slice(0,-1).join('.')),name,arity)).filter(Boolean);if(candidates.length===1)target=candidates[0]}}
51
60
  if(constructed&&!fluent){const methodName=/\.([\w$]+)$/.exec(chain)?.[1];if(methodName)target=lookupMethod(constructed,methodName,arity)}
52
- if(target&&room(calls,MAX_EDGES,'edges'))calls.push({source:(owner||cls.symbol).id,target:target.id,line:invoke.location.startLine,kind:'call',resolution:'static'});
61
+ if(target&&room(calls,MAX_EDGES,'edges'))calls.push({source:(owner||cls.symbol).id,target:target.id,line:invoke.location.startLine,kind:'call',resolution:declaredOnly.has(target.id)?'declared':'static'});
53
62
  else if(unresolved.length<1000)unresolved.push({path:unit.path,line:invoke.location.startLine,expression:chain.slice(0,140),reason:'External/dynamic type, interface without implementation, or ambiguous overload in the Java snapshot.'});
54
63
  fluent=true;chain+='<result>';
55
64
  }
56
65
  }
57
66
  for(const child of children(n))walk(child,cls,method,vars,owner)
58
- }walk(unit.tree)
67
+ }walk(tree)
59
68
  }
60
69
  const ids=new Set(symbols.map(s=>s.id)),linked=calls.filter(c=>ids.has(c.source)&&ids.has(c.target));
61
70
  leftOut.edges+=calls.length-linked.length;
package/code_health.py CHANGED
@@ -73,15 +73,25 @@ def coupled_with(root, paths, view_id=None, limit=DEFAULT_LIMIT):
73
73
  commits, note = doc_insights.history(root)
74
74
  if note:
75
75
  return {"files": [], "note": note}
76
- changed, rows, seen = set(paths), [], set()
77
- for first, second, shared, degree, linked in doc_insights.coupling(model, commits):
76
+ return {"files": partners(doc_insights.coupling(model, commits), set(paths))[:limit], "note": ""}
77
+
78
+
79
+ def partners(pairs, changed):
80
+ """The files that change with the changed ones, from the pairs `doc_insights.coupling` returns.
81
+
82
+ Parameters: pairs (list) rows (a, b, shared, degree, linked), strongest first; changed (set of str) the changed files.
83
+ Returns: list of {"path", "with", "shared", "degree"}, strongest first, one row per partner outside `changed`; a pair
84
+ where one file imports the other is skipped.
85
+ """
86
+ rows, seen = [], set()
87
+ for first, second, shared, degree, linked in pairs:
78
88
  if linked or (first in changed) == (second in changed):
79
89
  continue
80
90
  partner, anchor = (second, first) if first in changed else (first, second)
81
91
  if partner not in seen:
82
92
  seen.add(partner)
83
93
  rows.append({"path": partner, "with": anchor, "shared": shared, "degree": int(degree * 100)})
84
- return {"files": rows[:limit], "note": ""}
94
+ return rows
85
95
 
86
96
 
87
97
  def _pop_component(stack, on_stack, node):
@@ -146,12 +156,7 @@ def import_cycles(root, view_id=None, limit=DEFAULT_LIMIT):
146
156
  data = code_graph.build_current(root, view_id, shared=True)
147
157
  if not data.get("symbols") and not data.get("dependencies"):
148
158
  raise ValueError(f"The code graph of {root} is empty: index the project first (project_manage action=index).")
149
- edges = {}
150
- for dependency in data.get("dependencies") or []:
151
- if dependency.get("kind") == "import" and dependency.get("resolution") == "resolved" and dependency.get("target"):
152
- edges.setdefault(dependency["source"], set()).add(dependency["target"])
153
- edges.setdefault(dependency["target"], set())
154
- cycles = sorted(_components(edges), key=lambda files: (-len(files), files))
159
+ cycles = sorted(_components(code_graph.import_edges(data)), key=lambda files: (-len(files), files))
155
160
  note = code_graph.left_out_sentence(data) if data.get("truncated") else ""
156
161
  return {"cycles": [{"files": files, "size": len(files)} for files in cycles[:limit]], "total": len(cycles),
157
162
  "files_in_cycles": sum(len(files) for files in cycles), "note": note}
package/codex_config.py CHANGED
@@ -57,6 +57,9 @@ def _value(value):
57
57
  .replace("\t", "\\t") + '"'
58
58
  if isinstance(value, (list, tuple)):
59
59
  return "[" + ", ".join(_value(item) for item in value) + "]"
60
+ if isinstance(value, dict):
61
+ return "{ " + ", ".join(f"{key if _BARE_KEY.match(key) else _value(key)} = {_value(item)}"
62
+ for key, item in value.items()) + " }"
60
63
  raise TypeError(f"Unsupported value for config.toml: {value!r}")
61
64
 
62
65
 
@@ -19,8 +19,14 @@ import urllib.error
19
19
  import urllib.request
20
20
  from pathlib import Path
21
21
 
22
+ import venv_launch
23
+
22
24
  RUN_DIR = paths.DATA_DIR
23
25
  REGISTRY_PATH = os.path.join(RUN_DIR, "daemon.json")
26
+ LOG_PATH = os.path.join(RUN_DIR, "daemon.log")
27
+ SYNCHRONIZE = 0x00100000
28
+ PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
29
+ INFINITE = 0xFFFFFFFF
24
30
  LOCK_PATH = os.path.join(RUN_DIR, "daemon.lock")
25
31
  LOCK_STALE_SECONDS = 30
26
32
  UPDATE_MARKER = os.path.join(RUN_DIR, "updating")
@@ -85,12 +91,8 @@ def _spawn_daemon():
85
91
  executable = executable.with_name("python.exe")
86
92
  fd, launcher = tempfile.mkstemp(prefix="smart-tool-hidden-", suffix=".vbs")
87
93
  try:
88
- command = (f'Chr(34) & "{executable}" & Chr(34) & " " & '
89
- f'Chr(34) & "{DAEMON_SCRIPT}" & Chr(34)')
90
94
  with os.fdopen(fd, "w", encoding="utf-16") as stream:
91
- stream.write('Set sh = CreateObject("WScript.Shell")\n')
92
- stream.write(f'sh.CurrentDirectory = "{Path(DAEMON_SCRIPT).parent}"\n')
93
- stream.write(f'sh.Run {command}, 0, False\n')
95
+ stream.write(venv_launch.hidden_run_vbs(executable, DAEMON_SCRIPT, Path(DAEMON_SCRIPT).parent))
94
96
  result = subprocess.run(
95
97
  ["wscript.exe", "//B", "//NoLogo", launcher],
96
98
  stdin=subprocess.DEVNULL, capture_output=True, timeout=10,
@@ -170,6 +172,36 @@ def start_daemon_if_down():
170
172
  return False
171
173
 
172
174
 
175
+ def note_stop(message):
176
+ """Appends a stop line to the daemon log, for stops the daemon cannot write itself: the installer closing it and
177
+ the supervisor seeing it end without a word (killed, crashed)."""
178
+ os.makedirs(RUN_DIR, exist_ok=True)
179
+ with open(LOG_PATH, "a", encoding="utf-8") as stream:
180
+ stream.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} {message}\n")
181
+
182
+
183
+ def wait_for_exit(pid):
184
+ """Blocks until process `pid` ends and returns its exit code; None when it cannot be watched (already gone, not
185
+ ours to open, or not Windows), so the caller falls back to polling."""
186
+ if os.name != "nt" or not pid:
187
+ return None
188
+ import ctypes
189
+ from ctypes import wintypes
190
+ kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
191
+ kernel32.OpenProcess.restype = wintypes.HANDLE
192
+ handle = kernel32.OpenProcess(SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION, False, int(pid))
193
+ if not handle:
194
+ return None
195
+ try:
196
+ kernel32.WaitForSingleObject(wintypes.HANDLE(handle), INFINITE)
197
+ code = wintypes.DWORD()
198
+ if not kernel32.GetExitCodeProcess(wintypes.HANDLE(handle), ctypes.byref(code)):
199
+ return None
200
+ return code.value
201
+ finally:
202
+ kernel32.CloseHandle(wintypes.HANDLE(handle))
203
+
204
+
173
205
  def _wait_for_daemon(wait_seconds, poll_interval=0.1):
174
206
  deadline = time.time() + wait_seconds
175
207
  while time.time() < deadline:
@@ -0,0 +1,63 @@
1
+ """Feature candidates from the embeddings home for public functions no entry point reaches through the call graph.
2
+
3
+ The graph links a function to a feature when a call path exists; for a public function with no path at all (code the
4
+ framework calls, configuration, a handler), the cosine between its text (name, signature, first docstring line) and
5
+ each feature's text proposes at most MAX_CANDIDATES features. They are recorded as status `candidate` with their
6
+ score and shown as "possible" on both sides of the chain; the embedder never confirms a link (measured: right on the
7
+ first place 5 times in 11, margins of 0.01 to 0.03 between first and second).
8
+ """
9
+ import math
10
+
11
+ import local_embedder
12
+
13
+ MAX_CANDIDATES = 2
14
+ MAX_FLOW_NAMES = 15
15
+
16
+
17
+ def orphans(model, reached):
18
+ """Public code functions that are not an entry point and that no entry point's flow reaches.
19
+
20
+ Parameters: model (doc_scope._Model); reached (dict anchor -> features, from doc_scope.features).
21
+ """
22
+ return [anchor for anchor in model.public() if anchor not in reached]
23
+
24
+
25
+ def _function_text(model, anchor):
26
+ function = model.function_of[anchor]
27
+ return " ".join(part for part in (function["name"], function["signature"], function["doc"]) if part)
28
+
29
+
30
+ def _feature_text(model, entry):
31
+ names = [model.function_of[a]["name"] for a in model.flow(entry)[:MAX_FLOW_NAMES]]
32
+ return _function_text(model, entry) + (" uses " + ", ".join(names) if names else "")
33
+
34
+
35
+ def _cosine(a, b):
36
+ norm = math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b))
37
+ return sum(x * y for x, y in zip(a, b)) / norm if norm else 0.0
38
+
39
+
40
+ def propose(model, reached, skip=()):
41
+ """Candidate link rows for the orphan functions not in `skip` (those that already have candidates).
42
+
43
+ Returns: list of link dicts (origin embedder, status candidate, score, hops None); [] when there is nothing to
44
+ propose or no embeddings home is installed. Raises RuntimeError when the home is announced but does not answer, and
45
+ lets the home's own errors through: a candidate is never invented without vectors.
46
+ """
47
+ todo = [anchor for anchor in orphans(model, reached) if anchor not in set(skip)]
48
+ entries = model.entry_points()
49
+ if not todo or not entries or not local_embedder.configured():
50
+ return []
51
+ info = local_embedder.info()
52
+ if not info:
53
+ raise RuntimeError("The embeddings home is announced but does not answer; no feature candidate was proposed.")
54
+ vectors = local_embedder.embed(info["model"], [_function_text(model, a) for a in todo]
55
+ + [_feature_text(model, e) for e in entries])
56
+ functions, features = vectors[:len(todo)], vectors[len(todo):]
57
+ rows = []
58
+ for anchor, vector in zip(todo, functions):
59
+ ranked = sorted(((_cosine(vector, feature), entry) for entry, feature in zip(entries, features)), reverse=True)
60
+ rows += [{"feature_id": entry, "fn_id": anchor, "layer": model.layer_of.get(model.function_of[anchor]["path"]),
61
+ "hops": None, "origin": "embedder", "score": round(score, 4), "status": "candidate"}
62
+ for score, entry in ranked[:MAX_CANDIDATES]]
63
+ return rows
package/doc_check.py CHANGED
@@ -54,9 +54,12 @@ def _python_functions(source):
54
54
  for child in ast.iter_child_nodes(node):
55
55
  if isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef)):
56
56
  doc = ast.get_docstring(child)
57
+ first = child.body[0] if child.body else None
58
+ doc_lines = (first.lineno, first.end_lineno) if doc is not None else None
57
59
  returns = f" -> {ast.unparse(child.returns)}" if child.returns else ""
58
60
  found.append({"name": f"{owner}{child.name}", "start": child.lineno, "end": child.end_lineno,
59
61
  "documented": doc is not None, "doc": _first_line(doc or ""),
62
+ "docstring": doc or "", "doc_lines": doc_lines,
60
63
  "decorators": [ast.unparse(d) for d in child.decorator_list], "bases": list(bases),
61
64
  "signature": f"{child.name}({ast.unparse(child.args)}){returns}",
62
65
  "required": public and not nested and _public_name(child.name)
@@ -174,7 +177,8 @@ def _braced_functions(path, source, symbols):
174
177
  annotations, first_line = _annotations(lines, start, end)
175
178
  required = _required(path, symbol, by_id.get(symbol.get("parent")), first_line, annotations)
176
179
  found.append({"name": symbol["name"], "start": start, "end": end, "documented": block is not None,
177
- "doc": _first_line(block or ""), "signature": _SPACE.sub(" ", header.split("{")[0]).strip(),
180
+ "doc": _first_line(block or ""), "docstring": block or "",
181
+ "signature": _SPACE.sub(" ", header.split("{")[0]).strip(),
178
182
  "required": required})
179
183
  return found
180
184
 
@@ -206,7 +210,8 @@ def _go_functions(path, source):
206
210
  def add(decl, name, short, required, doc, articles=False):
207
211
  documented = bool(doc) and _go_form(doc, short, articles)
208
212
  found.append({"name": name, "start": decl["start"], "end": decl["end"], "documented": documented,
209
- "doc": _first_line(doc or ""), "signature": decl["signature"], "required": required,
213
+ "doc": _first_line(doc or ""), "docstring": doc or "", "signature": decl["signature"],
214
+ "required": required,
210
215
  "kind": decl["kind"], "convention": "go", "malformed": bool(doc) and not documented})
211
216
 
212
217
  for decl in decls:
@@ -227,7 +232,8 @@ def _go_functions(path, source):
227
232
  if decl["block"] not in reported_blocks:
228
233
  reported_blocks.add(decl["block"])
229
234
  found.append({"name": exported, "start": decl["start"], "end": decl["end"], "documented": True,
230
- "doc": _first_line(decl["group_doc"]), "signature": "", "required": importable,
235
+ "doc": _first_line(decl["group_doc"]), "docstring": decl["group_doc"], "signature": "",
236
+ "required": importable,
231
237
  "kind": decl["kind"], "convention": "go", "malformed": False})
232
238
  continue
233
239
  if decl["grouped"] and not decl["doc"]:
package/doc_extras.py CHANGED
@@ -439,7 +439,7 @@ def _flows(model, entries):
439
439
  function = model.function_of[anchor]
440
440
  diagram, left, drawn = _sequence(model, anchor)
441
441
  lines += [f'<a id="{doc_scope._escape(anchor)}"></a>', f"## {doc_scope.entry_title(model, anchor, entries)}", "",
442
- f'<!-- smart-tool:symbol id="{doc_scope._escape(anchor)}" signature="{doc_scope.signature_hash(function["signature"])}" -->',
442
+ doc_scope.symbol_marker(anchor, model.stamps(anchor)),
443
443
  "", f"Entry point in `{function['path']}`: {doc_scope.entry_link(model, anchor, entries, '../functional.md')}.", ""]
444
444
  lines += diagram if drawn else ["No call from this entry point reaches another code function."]
445
445
  if left > 0:
@@ -459,8 +459,7 @@ def _features_tests(model, covering, entries):
459
459
  for anchor, tests in covering:
460
460
  function = model.function_of[anchor]
461
461
  shown = ", ".join(f"`{model.function_of[t]['name']}`" for t in tests[:3]) + (f" (+{len(tests) - 3} more)" if len(tests) > 3 else "")
462
- marker = (f'<a id="{doc_scope._escape(anchor)}"></a><!-- smart-tool:symbol id="{doc_scope._escape(anchor)}" '
463
- f'signature="{doc_scope.signature_hash(function["signature"])}" -->')
462
+ marker = f'<a id="{doc_scope._escape(anchor)}"></a>' + doc_scope.symbol_marker(anchor, model.stamps(anchor))
464
463
  lines.append(f"| {marker}{doc_scope.entry_link(model, anchor, entries, '../functional.md')} | {len(tests)} | "
465
464
  f"{shown or 'no test reaches it'} |")
466
465
  bare = [a for a, tests in covering if not tests]