luminos/luminos_lib
Jeff Smith a1b17300e8 refactor(ai): single-source tool registration via register_tool() (#56)
Adding a tool used to require updating two parallel structures in
ai.py: a name->handler entry in _TOOL_DISPATCH and a schema dict in
_DIR_TOOLS (or _SYNTHESIS_TOOLS or _SURVEY_TOOLS). Forgetting one half
was silent. Internals.md §9.1 documented this as a 5-step process.

Replaced both with a single register_tool() call per (tool, scope):

    register_tool(
        name="read_file",
        description="...",
        schema={...},
        scopes=["dir"],
        handler=_tool_read_file,
    )

The function appends the schema to one or more scope lists
(_DIR_TOOLS / _SYNTHESIS_TOOLS / _SURVEY_TOOLS) and lands the handler
in _TOOL_DISPATCH. Tools intercepted by the loop body (submit_report,
submit_survey) register schema only with handler=None.

Tools whose schema differs by scope (submit_report has different shapes
in dir vs synthesis loops) get one register_tool() call per scope.
flag is also registered twice because it appears in dir + synthesis at
different positions in each list — the order is preserved with two
calls rather than reordered for fewer calls.

Verification:
- _DIR_TOOLS, _SYNTHESIS_TOOLS, _SURVEY_TOOLS contain the same names
  in the same order as before.
- _TOOL_DISPATCH contains the same 10 handlers as before.
- 164 tests pass.

No behavior change. Phase 3.5 (#39) MCP backend will eventually replace
this with dynamic discovery from the connected MCP server, at which
point register_tool() collapses to a one-line forward.
2026-04-11 10:18:40 -06:00
..
__init__.py chore: initial project scaffold 2026-03-30 09:57:11 -06:00
ai.py refactor(ai): single-source tool registration via register_tool() (#56) 2026-04-11 10:18:40 -06:00
ast_parser.py refactor: extract AST parsing into luminos_lib/ast_parser.py 2026-03-30 14:34:02 -06:00
cache.py feat: AI investigation is the product, drop zero-dep constraint (#64) 2026-04-11 09:43:47 -06:00
code.py feat: in-place per-file progress for classify, count, and large-file steps 2026-04-06 14:26:37 -06:00
disk.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00
filetypes.py feat(filetypes): expose raw signals to survey, remove classifier bias (#42) 2026-04-06 22:36:14 -06:00
prompts.py feat(filetypes): expose raw signals to survey, remove classifier bias (#42) 2026-04-06 22:36:14 -06:00
recency.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00
report.py feat: add chain-of-thought observability tools 2026-03-30 13:02:19 -06:00
tree.py feat: add -x/--exclude flag to exclude directories from scan and AI analysis 2026-04-06 14:32:12 -06:00