(argv: list[str] | None = None)
| 92 | |
| 93 | |
| 94 | def main(argv: list[str] | None = None) -> int: |
| 95 | parser = build_parser() |
| 96 | args = parser.parse_args(argv) |
| 97 | manifest = build_port_manifest() |
| 98 | if args.command == 'summary': |
| 99 | print(QueryEnginePort(manifest).render_summary()) |
| 100 | return 0 |
| 101 | if args.command == 'manifest': |
| 102 | print(manifest.to_markdown()) |
| 103 | return 0 |
| 104 | if args.command == 'parity-audit': |
| 105 | print(run_parity_audit().to_markdown()) |
| 106 | return 0 |
| 107 | if args.command == 'setup-report': |
| 108 | print(run_setup().as_markdown()) |
| 109 | return 0 |
| 110 | if args.command == 'command-graph': |
| 111 | print(build_command_graph().as_markdown()) |
| 112 | return 0 |
| 113 | if args.command == 'tool-pool': |
| 114 | print(assemble_tool_pool().as_markdown()) |
| 115 | return 0 |
| 116 | if args.command == 'bootstrap-graph': |
| 117 | print(build_bootstrap_graph().as_markdown()) |
| 118 | return 0 |
| 119 | if args.command == 'subsystems': |
| 120 | for subsystem in manifest.top_level_modules[: args.limit]: |
| 121 | print(f'{subsystem.name}\t{subsystem.file_count}\t{subsystem.notes}') |
| 122 | return 0 |
| 123 | if args.command == 'commands': |
| 124 | if args.query: |
| 125 | print(render_command_index(limit=args.limit, query=args.query)) |
| 126 | else: |
| 127 | commands = get_commands(include_plugin_commands=not args.no_plugin_commands, include_skill_commands=not args.no_skill_commands) |
| 128 | output_lines = [f'Command entries: {len(commands)}', ''] |
| 129 | output_lines.extend(f'- {module.name} — {module.source_hint}' for module in commands[: args.limit]) |
| 130 | print('\n'.join(output_lines)) |
| 131 | return 0 |
| 132 | if args.command == 'tools': |
| 133 | if args.query: |
| 134 | print(render_tool_index(limit=args.limit, query=args.query)) |
| 135 | else: |
| 136 | permission_context = ToolPermissionContext.from_iterables(args.deny_tool, args.deny_prefix) |
| 137 | tools = get_tools(simple_mode=args.simple_mode, include_mcp=not args.no_mcp, permission_context=permission_context) |
| 138 | output_lines = [f'Tool entries: {len(tools)}', ''] |
| 139 | output_lines.extend(f'- {module.name} — {module.source_hint}' for module in tools[: args.limit]) |
| 140 | print('\n'.join(output_lines)) |
| 141 | return 0 |
| 142 | if args.command == 'route': |
| 143 | matches = PortRuntime().route_prompt(args.prompt, limit=args.limit) |
| 144 | if not matches: |
| 145 | print('No mirrored command/tool matches found.') |
| 146 | return 0 |
| 147 | for match in matches: |
| 148 | print(f'{match.kind}\t{match.name}\t{match.score}\t{match.source_hint}') |
| 149 | return 0 |
| 150 | if args.command == 'bootstrap': |
| 151 | print(PortRuntime().bootstrap_session(args.prompt, limit=args.limit).as_markdown()) |
no test coverage detected