(arguments: dict)
| 3707 | ) |
| 3708 | |
| 3709 | def _tool_get_node(arguments: dict) -> str: |
| 3710 | from graphify.sections import is_section_node as _is_section_node |
| 3711 | |
| 3712 | raw = _node_arg(arguments) |
| 3713 | if not raw: |
| 3714 | return "Provide a node label or id (accepted keys: label, node_id, id)." |
| 3715 | label = raw |
| 3716 | nid, err = _resolve_single_node(G, label) |
| 3717 | if err: |
| 3718 | return err |
| 3719 | d = G.nodes[nid] |
| 3720 | attrs = d.get("attributes") |
| 3721 | attrs_line = [] |
| 3722 | if isinstance(attrs, dict) and attrs: |
| 3723 | raw_attrs = json.dumps(attrs, sort_keys=True) |
| 3724 | if len(raw_attrs) > 1000: |
| 3725 | raw_attrs = raw_attrs[:997] + "..." |
| 3726 | attrs_line = [f" Attributes: {_CONTROL_CHAR_RE.sub('', raw_attrs)}"] |
| 3727 | # Sanitise every LLM-derived field before concatenation (F-010). |
| 3728 | return "\n".join([ |
| 3729 | f"Node: {sanitize_label(d.get('label', nid))}", |
| 3730 | f" ID: {sanitize_label(nid)}", |
| 3731 | f" Source: {sanitize_label(str(d.get('source_file', '')))} {sanitize_label(str(d.get('source_location', '')))}", |
| 3732 | # A C/C++/ObjC symbol declared in a header and defined in the sibling |
| 3733 | # impl file is ONE node keyed to the header, so Source alone points at |
| 3734 | # the declaration. Name where it is implemented too, when known. |
| 3735 | *([f" Defined in: {sanitize_label(str(d.get('definition_file', '')))} " |
| 3736 | f"{sanitize_label(str(d.get('definition_location', '')))}"] |
| 3737 | if d.get("definition_file") else []), |
| 3738 | *([" Section: get_section returns this Markdown section's text"] |
| 3739 | if _is_section_node(d) else []), |
| 3740 | f" Type: {sanitize_label(str(d.get('file_type', '')))}", |
| 3741 | f" Community: {sanitize_label(str(d.get('community_name') or d.get('community', '')))}", |
| 3742 | f" Degree: {G.degree(nid)}", |
| 3743 | *attrs_line, |
| 3744 | ]) |
| 3745 | |
| 3746 | def _tool_get_section(arguments: dict) -> str: |
| 3747 | from graphify.sections import ( |
nothing calls this directly
no test coverage detected