Skip to content

Code Metrics

Generated: 2026-05-28 01:32 UTC


Lines of Code

Files Code Comment Blank Total
Source (src/terok/) 139 26 728 5 470 2 359 34 557
Tests (tests/) 168 37 017 3 351 3 644 44 012
Combined 307 63 745 8 821 6 003 78 569
  • Comment/code ratio: 20%
  • Test/source ratio: 138.5%
Source by module (click to expand)
Module Files Code Comment Blank
terok/ 139 26 728 5 470 2 359
terok/cli/ 22 4 611 728 403
terok/cli/commands/ 18 4 310 586 351
terok/cli/commands/_completers.py 86 13 12
terok/cli/commands/_desktop_entry.py 342 79 15
terok/cli/commands/_storage_view.py 183 38 57
terok/cli/commands/acp.py 290 78 13
terok/cli/commands/agents.py 96 18 20
terok/cli/commands/auth.py 102 28 21
terok/cli/commands/clearance.py 13 10 9
terok/cli/commands/completions.py 115 13 20
terok/cli/commands/image.py 254 12 15
terok/cli/commands/info.py 431 50 2
terok/cli/commands/panic.py 69 17 20
terok/cli/commands/project.py 334 25 45
terok/cli/commands/setup.py 312 49 15
terok/cli/commands/shield.py 177 22 16
terok/cli/commands/sickbay.py 655 61 22
terok/cli/commands/task.py 688 59 45
terok/cli/commands/uninstall.py 163 6 3
terok/cli/__init__.py 2 3 3
terok/cli/__main__.py 3 3 3
terok/cli/main.py 210 89 40
terok/cli/tree.py 86 47 6
terok/lib/ 75 11 042 2 990 1 070
terok/lib/api/ 9 594 371 33
terok/lib/api/__init__.py 221 238 6
terok/lib/api/agents.py 75 8 1
terok/lib/api/clearance.py 27 32 10
terok/lib/api/gate.py 7 20 1
terok/lib/api/project.py 70 21 3
terok/lib/api/setup.py 42 12 4
terok/lib/api/shield.py 40 12 2
terok/lib/api/task.py 94 16 3
terok/lib/api/vault.py 18 12 3
terok/lib/core/ 12 2 323 529 303
terok/lib/core/config.py 605 162 71
terok/lib/core/images.py 69 22 22
terok/lib/core/paths.py 130 64 32
terok/lib/core/project_model.py 115 24 13
terok/lib/core/projects.py 504 58 33
terok/lib/core/runtime.py 94 19 5
terok/lib/core/task_display.py 47 19 23
terok/lib/core/task_state.py 53 42 28
terok/lib/core/version.py 191 30 17
terok/lib/core/work_status.py 136 38 20
terok/lib/core/yaml_schema.py 379 48 38
terok/lib/domain/ 15 2 924 778 236
terok/lib/domain/wizards/ 2 554 97 36
terok/lib/domain/wizards/new_project.py 554 94 35
terok/lib/domain/auth.py 98 55 12
terok/lib/domain/image_cleanup.py 159 54 24
terok/lib/domain/log_format.py 218 67 53
terok/lib/domain/panic.py 248 88 7
terok/lib/domain/project.py 719 146 21
terok/lib/domain/project_state.py 190 34 15
terok/lib/domain/ssh.py 13 23 1
terok/lib/domain/storage.py 160 93 23
terok/lib/domain/task.py 174 56 16
terok/lib/domain/task_credentials.py 146 20 6
terok/lib/domain/task_logs.py 208 24 11
terok/lib/domain/vault.py 37 18 11
terok/lib/integrations/ 5 191 168 7
terok/lib/integrations/__init__.py 8 11 2
terok/lib/integrations/clearance.py 30 9 1
terok/lib/integrations/executor.py 50 55 1
terok/lib/integrations/sandbox.py 78 82 2
terok/lib/integrations/shield.py 25 11 1
terok/lib/orchestration/ 23 4 517 931 408
terok/lib/orchestration/task_runners/ 8 1 427 277 147
terok/lib/orchestration/task_runners/__init__.py 18 26 3
terok/lib/orchestration/task_runners/cli.py 142 24 19
terok/lib/orchestration/task_runners/config.py 66 22 18
terok/lib/orchestration/task_runners/container.py 261 45 24
terok/lib/orchestration/task_runners/headless.py 358 89 29
terok/lib/orchestration/task_runners/restart.py 119 14 19
terok/lib/orchestration/task_runners/shield.py 156 31 23
terok/lib/orchestration/task_runners/toad.py 307 26 12
terok/lib/orchestration/tasks/ 7 1 477 276 110
terok/lib/orchestration/tasks/__init__.py 101 31 3
terok/lib/orchestration/tasks/archive.py 84 13 9
terok/lib/orchestration/tasks/identity.py 102 33 14
terok/lib/orchestration/tasks/lifecycle.py 587 59 23
terok/lib/orchestration/tasks/meta.py 266 59 15
terok/lib/orchestration/tasks/naming.py 47 31 22
terok/lib/orchestration/tasks/query.py 290 50 24
terok/lib/orchestration/agent_config.py 57 32 17
terok/lib/orchestration/container_doctor.py 523 111 26
terok/lib/orchestration/container_exec.py 61 16 8
terok/lib/orchestration/environment.py 472 108 24
terok/lib/orchestration/hooks.py 133 34 17
terok/lib/orchestration/image.py 362 60 53
terok/lib/orchestration/ports.py 5 14 6
terok/lib/util/ 10 493 205 82
terok/lib/util/ansi.py 46 28 19
terok/lib/util/check_reporter.py 165 47 20
terok/lib/util/emoji.py 85 30 17
terok/lib/util/fs.py 34 38 7
terok/lib/util/host_cmd.py 32 26 9
terok/lib/util/logging_utils.py 51 14 2
terok/lib/util/net.py 3 9 4
terok/lib/util/subprocess_env.py 26 6 1
terok/lib/util/yaml.py 51 4 2
terok/resources/ 6 263 44 43
terok/resources/desktop/ 2 90 18 5
terok/resources/instructions/ 1 36 0 18
terok/resources/presets/ 3 137 26 20
terok/tui/ 32 10 702 1 664 821
terok/tui/widgets/ 7 877 135 86
terok/tui/widgets/__init__.py 29 12 3
terok/tui/widgets/panic_button.py 57 16 16
terok/tui/widgets/project_list.py 140 23 14
terok/tui/widgets/project_state.py 267 19 16
terok/tui/widgets/status_bar.py 21 14 6
terok/tui/widgets/task_detail.py 208 33 21
terok/tui/widgets/task_list.py 155 18 10
terok/tui/__init__.py 2 3 3
terok/tui/__main__.py 3 3 3
terok/tui/_worker_entry.py 72 6 4
terok/tui/agents_screen.py 194 28 12
terok/tui/app.py 1 729 157 78
terok/tui/askpass.py 71 18 4
terok/tui/askpass_protocol.py 61 34 19
terok/tui/askpass_service.py 308 56 6
terok/tui/clearance_screen.py 326 60 14
terok/tui/clipboard.py 132 49 29
terok/tui/console_log.py 293 63 13
terok/tui/console_output_screen.py 106 16 10
terok/tui/log_viewer.py 498 45 4
terok/tui/polling.py 200 66 64
terok/tui/project_actions.py 762 96 38
terok/tui/screens.py 2 089 356 224
terok/tui/selinux_fix_screen.py 123 20 4
terok/tui/serve.py 321 51 41
terok/tui/setup_screen.py 142 45 11
terok/tui/shell_launch.py 134 60 21
terok/tui/task_actions.py 900 44 16
terok/tui/text_screens.py 112 20 20
terok/tui/wizard_screens.py 795 196 77
terok/tui/worker_actions.py 310 16 7
terok/tui/worker_log_screen.py 142 21 13
terok/ui_utils/ 3 88 32 17
terok/ui_utils/editor.py 53 2 1
terok/ui_utils/terminal.py 35 27 15
terok/__init__.py 22 12 5

Architecture

Layer Overview

graph LR
    core["core (20 modules)"]
    domain["domain (22 modules)"]
    integrations["integrations (4 modules)"]
    orchestration["orchestration (9 modules)"]
    presentation["presentation (2 modules)"]
    domain -->|38 deps| core
    domain -->|8 deps| integrations
    domain -->|14 deps| orchestration
    orchestration --> ?
    orchestration -->|39 deps| core
    orchestration -->|4 deps| integrations
    presentation --> ?
    presentation -->|15 deps| core
    presentation -->|21 deps| domain
    presentation -->|4 deps| orchestration

Module Dependency Graph

graph TD
    terok.cli -->|9| terok.lib.api
    terok.cli -->|5| terok.lib.core
    terok.cli -->|3| terok.lib.domain
    terok.cli -->|4| terok.lib.orchestration
    terok.cli -->|3| terok.lib.util
    terok.cli --> terok.ui_utils.terminal
    terok.lib.api -->|6| terok.lib.core
    terok.lib.api -->|11| terok.lib.domain
    terok.lib.api -->|8| terok.lib.integrations
    terok.lib.api -->|4| terok.lib.orchestration
    terok.lib.core --> terok
    terok.lib.core -->|4| terok.lib.util
    terok.lib.domain -->|27| terok.lib.core
    terok.lib.domain -->|10| terok.lib.orchestration
    terok.lib.domain -->|4| terok.lib.util
    terok.lib.domain --> terok.ui_utils.editor
    terok.lib.orchestration -->|25| terok.lib.core
    terok.lib.orchestration -->|4| terok.lib.integrations
    terok.lib.orchestration -->|15| terok.lib.util
    terok.lib.util --> terok.lib.core
    terok.tui -->|9| terok.lib.api
    terok.tui --> terok.lib.core
    terok.tui -->|5| terok.lib.util
    terok.tui --> terok.ui_utils.terminal
    terok.ui_utils.terminal --> terok.lib.util

Module Boundaries

57 modules, 200 dependency edges — all boundaries validated.

Module Summary

57 modules across 5 layers (click to expand)
Module Layer Deps Description
terok.cli presentation 25 CLI frontend
terok.tui presentation 16 should extend api first; extending this allowlist is a design smell.
terok.lib.domain.panic domain 5 Emergency panic (cross-project lockdown)
terok.lib.domain.ssh domain 3 SSH provisioning workflow — mint, bind, render, pause for deploy-key registration.
terok.lib.domain.auth domain 3 Host-wide and project-scoped auth flow.
terok.lib.api domain 11 helpers that don't fit into a single sub-module.
terok.lib.api.vault domain 2
terok.lib.api.gate domain 2
terok.lib.api.shield domain 2
terok.lib.api.agents domain 5
terok.lib.api.clearance domain 1
terok.lib.api.setup domain 1
terok.lib.api.task domain 6
terok.lib.api.project domain 7
terok.lib.domain.vault domain 1 Vault access primitive (shared open/close handshake)
terok.lib.domain.task_credentials domain 2 translation that the sandbox itself doesn't model.
terok.lib.domain.project domain 13 Rich domain object: Project (Aggregate Root)
terok.lib.domain.task domain 5 Rich domain object: Task (Entity)
terok.lib.domain.task_logs domain 5 Task log viewing and streaming
terok.lib.domain.log_format domain 1 Agent log formatters (Claude stream-json, plain text)
terok.lib.domain.image_cleanup domain 2 Image listing & cleanup
terok.lib.domain.storage domain 4 Storage usage aggregation across package stack
terok.lib.orchestration.agent_config orchestration 2 Agent config resolution (terok-specific stack composition)
terok.lib.domain.project_state domain 7 Project infrastructure state (queries podman & filesystem)
terok.lib.domain.wizards.new_project domain 3 Interactive project creation
terok.lib.orchestration.task_runners orchestration 16 toad / headless / restart submodules behind a re-export init.
terok.lib.orchestration.tasks orchestration 18 init.
terok.lib.orchestration.environment orchestration 4 Task environment & volume mounts
terok.lib.orchestration.image orchestration 5 Dockerfile generation & image building
terok.lib.orchestration.ports orchestration 0 Task port allocation (delegates to terok-sandbox port registry)
terok.lib.orchestration.hooks orchestration 1 Task lifecycle hooks (host-side)
terok.lib.orchestration.container_exec orchestration 3 Container-based command execution (sandboxed git via podman exec)
terok.lib.orchestration.container_doctor orchestration 5 In-container health checks (layered doctor protocol via podman exec)
terok core 0 Top-level package (version metadata only)
terok.lib.core.version core 1 Version info
terok.lib.core.paths core 0 Path resolution (FHS/XDG)
terok.lib.core.config core 3 Configuration management
terok.lib.core.project_model core 0 Project and preset data models (pure types, no I/O)
terok.lib.core.yaml_schema core 0 Raw YAML schema models (Pydantic validation, no I/O)
terok.lib.core.projects core 4 Project discovery, loading, and preset management
terok.lib.core.images core 1 Image naming conventions
terok.lib.core.runtime core 1 Process-wide ContainerRuntime accessor
terok.lib.core.task_state core 1 Task lifecycle state — domain value object, status computation, container naming
terok.lib.core.task_display core 0 Presentation tables for task lifecycle, mode, and project badges
terok.lib.core.work_status core 1 Agent work status reading
terok.ui_utils.terminal core 1 Terminal ANSI formatting
terok.ui_utils.editor core 0 $EDITOR launching
terok.lib.util.fs core 0 Archive directory and filename helpers (timestamp + collision-free names)
terok.lib.util.ansi core 0 ANSI color utilities
terok.lib.util.logging_utils core 1 Debug logging stub
terok.lib.util.emoji core 0 Emoji display-width utilities
terok.lib.util.yaml core 0 Centralised YAML I/O (round-trip via ruamel.yaml)
terok.lib.util.host_cmd core 0 Host-side subprocess safety guards
terok.lib.integrations.executor integrations 0
terok.lib.integrations.sandbox integrations 0
terok.lib.integrations.clearance integrations 0
terok.lib.integrations.shield integrations 0

Test Coverage

Overall line coverage: 76.3% (9909/12994 statements).

Each rectangle is a source file. Area is proportional to the number of statements; colour encodes the coverage percentage (green = fully covered, red = uncovered). Files are grouped by the first 3 directory levels.

Cognitive Complexity

Threshold: 15 (functions above this are listed below)

Warning

complexipy cache not found — skipping complexity report.

Dead Code Analysis

Confidence Location Issue
100% confidence src/terok/lib/domain/task_logs.py:149 unused variable 'signum'

Docstring Coverage

  • Needed: 7; Found: 5; Missing: 2; Coverage: 71.4%
  • Needed: 25; Found: 24; Missing: 1; Coverage: 96.0%
  • Needed: 18; Found: 17; Missing: 1; Coverage: 94.4%
  • Needed: 16; Found: 13; Missing: 3; Coverage: 81.2%
  • Needed: 4; Found: 3; Missing: 1; Coverage: 75.0%
  • Needed: 13; Found: 8; Missing: 5; Coverage: 61.5%
  • Needed: 76; Found: 75; Missing: 1; Coverage: 98.7%
  • Needed: 21; Found: 20; Missing: 1; Coverage: 95.2%
  • Needed: 23; Found: 22; Missing: 1; Coverage: 95.7%
  • Needed: 19; Found: 17; Missing: 2; Coverage: 89.5%
  • Needed: 56; Found: 47; Missing: 9; Coverage: 83.9%
  • Needed: 174; Found: 173; Missing: 1; Coverage: 99.4%
  • Needed: 19; Found: 17; Missing: 2; Coverage: 89.5%
  • Needed: 72; Found: 60; Missing: 12; Coverage: 83.3%
  • Needed: 47; Found: 36; Missing: 11; Coverage: 76.6%
  • Needed: 1646 - Found: 1593 - Missing: 53
  • Total coverage: 96.8% - Grade: Excellent

Generated by scc, complexipy, vulture, tach, and docstr-coverage.