Skip to content

perf: improve startup speed#132

Merged
stdrc merged 4 commits intomainfrom
rc/improve-startup-speed
Oct 30, 2025
Merged

perf: improve startup speed#132
stdrc merged 4 commits intomainfrom
rc/improve-startup-speed

Conversation

@stdrc
Copy link
Copy Markdown
Contributor

@stdrc stdrc commented Oct 30, 2025

time uv run kimi --help

~0.7s → ~0.09s

time uv run kimi  # exit at the beginning of ShellApp.run

~0.86s → ~0.66s

time uv run kimi --acp  # exit at the beginning of ACPServer.run

~0.86s → ~0.60s

Fix #20

stdrc added 2 commits October 30, 2025 19:19
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings October 30, 2025 11:45
@stdrc stdrc marked this pull request as draft October 30, 2025 11:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the codebase to improve import organization and reduce circular dependencies by:

  • Moving the KimiCLI class from src/kimi_cli/__init__.py to a new dedicated src/kimi_cli/app.py module
  • Relocating InputFormat and OutputFormat type definitions from kimi_cli.ui.print to kimi_cli.cli
  • Converting top-level imports in cli.py and agent.py to lazy imports to break circular dependencies

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/kimi_cli/init.py Removed entire KimiCLI class definition (now empty/deleted)
src/kimi_cli/app.py New file containing the relocated KimiCLI class with identical implementation
src/kimi_cli/cli.py Added InputFormat/OutputFormat type definitions and converted several top-level imports to lazy imports within the kimi() function
src/kimi_cli/ui/print/init.py Removed InputFormat/OutputFormat definitions and now imports them from kimi_cli.cli instead
src/kimi_cli/soul/agent.py Converted fastmcp and MCPTool imports to lazy imports within _load_mcp_tools() function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc marked this pull request as ready for review October 30, 2025 12:04
Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc requested a review from Copilot October 30, 2025 12:15
@stdrc stdrc merged commit 9c585d5 into main Oct 30, 2025
14 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return self._runtime.session

@contextlib.contextmanager
def _app_env(self) -> Generator[None]:
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Generator type hint is incomplete. It should specify all three type parameters: Generator[None, None, None] representing the yielded type, the send type, and the return type.

Suggested change
def _app_env(self) -> Generator[None]:
def _app_env(self) -> Generator[None, None, None]:

Copilot uses AI. Check for mistakes.
Args:
session (Session): A session created by `Session.create` or `Session.continue_`.
yolo (bool, optional): Approve all actions without confirmation. Defaults to False.
stream (bool, optional): Use stream mode when calling LLM API. Defaults to True.
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mcp_configs parameter is missing from the docstring. It should be documented with its type, purpose, and default value.

Suggested change
stream (bool, optional): Use stream mode when calling LLM API. Defaults to True.
stream (bool, optional): Use stream mode when calling LLM API. Defaults to True.
mcp_configs (list[dict[str, Any]] | None, optional): List of MCP configuration dictionaries to use when loading the agent. Defaults to None.

Copilot uses AI. Check for mistakes.
@stdrc stdrc deleted the rc/improve-startup-speed branch October 30, 2025 12:17
@Epsirom
Copy link
Copy Markdown
Collaborator

Epsirom commented Oct 30, 2025

Is that true?
When did you become a wizard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: improve startup speed

3 participants