serena.cli#


find_project_root(root=None)[source]#

Find project root by walking up from CWD.

Returns the nearest ancestor that is either an explicit Serena project (contains .serena/project.yml) or a git root (contains .git, which may be a directory or, for git worktrees and submodules, a pointer file). The nearest such directory wins; a .serena/project.yml at the same level takes priority over .git only because they resolve to the same directory.

Walking up with a single pass (rather than searching all levels for .serena/project.yml first and only then for .git) ensures a git worktree nested under another Serena project resolves to the worktree itself, instead of being hijacked by the ancestor project’s .serena/project.yml.

Parameters:

root (str | Path | None) – If provided, constrains the search to this directory and below (acts as a virtual filesystem root). Search stops at this boundary.

Returns:

absolute path to project root or None if not suitable root is found

Return type:

str | None

class ProjectType[source]#

Bases: ParamType

ParamType allowing either a project name or a path to a project directory.

name: str = '[PROJECT_NAME|PROJECT_PATH]'#

the descriptive name of this type

convert(value, param, ctx)[source]#

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value (str) – The value to convert.

  • param (Any) – The parameter that is using this type to convert its value. May be None.

  • ctx (Any) – The current context that arrived at this value. May be None.

Return type:

str

class TopLevelCommands[source]#

Bases: AutoRegisteringGroup

Root CLI group containing the core Serena commands.

class ModeCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘mode’ subcommands.

class ContextCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘context’ subcommands.

class SerenaConfigCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘config’ subcommands.

class ProjectCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘project’ subcommands.

is_ignored_path = <Command is_ignored_path>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

index_file = <Command index-file>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

health_check = <Command health-check>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

class ToolCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘tool’ subcommands.

class MemoryCommands[source]#

Bases: AutoRegisteringGroup

Group for ‘memories’ subcommands; manage and inspect a project’s memory files.

class PromptCommands[source]#

Bases: AutoRegisteringGroup

create_override = <Command create-override>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

edit_override = <Command edit-override>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

delete_override = <Command delete-override>#
Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any