Code Metrics¶
Generated: 2026-07-11 17:54 UTC
Lines of Code¶
| Files | Code | Comment | Blank | Total | |
|---|---|---|---|---|---|
Source (src/terok/) |
141 | 29 459 | 5 724 | 2 223 | 37 406 |
Tests (tests/) |
178 | 39 351 | 3 531 | 3 536 | 46 418 |
| Combined | 319 | 68 810 | 9 255 | 5 759 | 83 824 |
- Comment/code ratio: 19%
- Test/source ratio: 133.6%
Source by module (click to expand)
| Module | Files | Code | Comment | Blank |
|---|---|---|---|---|
terok/ |
141 | 29 459 | 5 724 | 2 223 |
terok/cli/ |
22 | 4 684 | 812 | 366 |
terok/cli/commands/ |
18 | 4 381 | 670 | 314 |
terok/cli/commands/_completers.py |
— | 66 | 12 | 11 |
terok/cli/commands/_desktop_entry.py |
— | 341 | 79 | 15 |
terok/cli/commands/_storage_view.py |
— | 183 | 38 | 57 |
terok/cli/commands/acp.py |
— | 290 | 78 | 13 |
terok/cli/commands/agents.py |
— | 153 | 35 | 1 |
terok/cli/commands/auth.py |
— | 181 | 25 | 3 |
terok/cli/commands/clearance.py |
— | 13 | 10 | 9 |
terok/cli/commands/completions.py |
— | 115 | 13 | 20 |
terok/cli/commands/image.py |
— | 255 | 12 | 15 |
terok/cli/commands/info.py |
— | 410 | 56 | 3 |
terok/cli/commands/panic.py |
— | 86 | 22 | 2 |
terok/cli/commands/project.py |
— | 338 | 29 | 44 |
terok/cli/commands/setup.py |
— | 323 | 49 | 15 |
terok/cli/commands/shield.py |
— | 158 | 44 | 24 |
terok/cli/commands/sickbay.py |
— | 628 | 80 | 32 |
terok/cli/commands/task.py |
— | 698 | 60 | 46 |
terok/cli/commands/uninstall.py |
— | 143 | 20 | 3 |
terok/cli/__init__.py |
— | 2 | 3 | 3 |
terok/cli/__main__.py |
— | 3 | 3 | 3 |
terok/cli/main.py |
— | 212 | 89 | 40 |
terok/cli/tree.py |
— | 86 | 47 | 6 |
terok/lib/ |
76 | 12 455 | 3 034 | 1 028 |
terok/lib/api/ |
10 | 872 | 409 | 41 |
terok/lib/api/__init__.py |
— | 228 | 245 | 6 |
terok/lib/api/agents.py |
— | 91 | 8 | 1 |
terok/lib/api/clearance.py |
— | 22 | 17 | 3 |
terok/lib/api/gate.py |
— | 22 | 7 | 1 |
terok/lib/api/project.py |
— | 74 | 21 | 3 |
terok/lib/api/setup.py |
— | 38 | 12 | 4 |
terok/lib/api/shield.py |
— | 40 | 12 | 2 |
terok/lib/api/ssh_routing.py |
— | 120 | 17 | 5 |
terok/lib/api/task.py |
— | 102 | 16 | 3 |
terok/lib/api/vault.py |
— | 135 | 54 | 13 |
terok/lib/core/ |
12 | 2 474 | 521 | 290 |
terok/lib/core/config.py |
— | 644 | 164 | 63 |
terok/lib/core/images.py |
— | 69 | 22 | 22 |
terok/lib/core/paths.py |
— | 123 | 64 | 32 |
terok/lib/core/project_model.py |
— | 159 | 22 | 12 |
terok/lib/core/projects.py |
— | 525 | 41 | 29 |
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 |
— | 433 | 57 | 38 |
terok/lib/domain/ |
15 | 3 347 | 739 | 227 |
terok/lib/domain/wizards/ |
2 | 678 | 72 | 18 |
terok/lib/domain/wizards/new_project.py |
— | 678 | 69 | 17 |
terok/lib/domain/auth.py |
— | 227 | 75 | 15 |
terok/lib/domain/image_cleanup.py |
— | 159 | 54 | 24 |
terok/lib/domain/log_format.py |
— | 218 | 67 | 53 |
terok/lib/domain/panic.py |
— | 336 | 43 | 13 |
terok/lib/domain/project.py |
— | 720 | 144 | 21 |
terok/lib/domain/project_state.py |
— | 213 | 57 | 17 |
terok/lib/domain/ssh.py |
— | 13 | 23 | 1 |
terok/lib/domain/storage.py |
— | 223 | 64 | 23 |
terok/lib/domain/task.py |
— | 176 | 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 |
— | 30 | 37 | 9 |
terok/lib/integrations/ |
5 | 188 | 198 | 7 |
terok/lib/integrations/__init__.py |
— | 8 | 11 | 2 |
terok/lib/integrations/clearance.py |
— | 16 | 24 | 1 |
terok/lib/integrations/executor.py |
— | 53 | 58 | 1 |
terok/lib/integrations/sandbox.py |
— | 86 | 94 | 2 |
terok/lib/integrations/shield.py |
— | 25 | 11 | 1 |
terok/lib/orchestration/ |
23 | 5 133 | 945 | 380 |
terok/lib/orchestration/task_runners/ |
8 | 1 661 | 304 | 98 |
terok/lib/orchestration/task_runners/__init__.py |
— | 24 | 26 | 3 |
terok/lib/orchestration/task_runners/cli.py |
— | 106 | 45 | 2 |
terok/lib/orchestration/task_runners/config.py |
— | 60 | 22 | 18 |
terok/lib/orchestration/task_runners/container.py |
— | 319 | 34 | 21 |
terok/lib/orchestration/task_runners/headless.py |
— | 425 | 25 | 14 |
terok/lib/orchestration/task_runners/restart.py |
— | 295 | 34 | 22 |
terok/lib/orchestration/task_runners/shield.py |
— | 206 | 68 | 16 |
terok/lib/orchestration/task_runners/toad.py |
— | 226 | 50 | 2 |
terok/lib/orchestration/tasks/ |
7 | 1 618 | 294 | 114 |
terok/lib/orchestration/tasks/__init__.py |
— | 105 | 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 |
— | 649 | 83 | 31 |
terok/lib/orchestration/tasks/meta.py |
— | 266 | 59 | 15 |
terok/lib/orchestration/tasks/naming.py |
— | 47 | 31 | 22 |
terok/lib/orchestration/tasks/query.py |
— | 365 | 44 | 20 |
terok/lib/orchestration/agent_config.py |
— | 36 | 27 | 13 |
terok/lib/orchestration/container_doctor.py |
— | 742 | 86 | 22 |
terok/lib/orchestration/container_exec.py |
— | 63 | 20 | 9 |
terok/lib/orchestration/environment.py |
— | 513 | 103 | 48 |
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 | 441 | 214 | 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 |
— | 44 | 16 | 2 |
terok/lib/util/net.py |
— | 3 | 9 | 4 |
terok/lib/util/subprocess_env.py |
— | 26 | 6 | 1 |
terok/lib/util/yaml.py |
— | 6 | 11 | 2 |
terok/resources/ |
3 | 126 | 18 | 23 |
terok/resources/desktop/ |
2 | 90 | 18 | 5 |
terok/resources/instructions/ |
1 | 36 | 0 | 18 |
terok/tui/ |
36 | 12 084 | 1 816 | 784 |
terok/tui/widgets/ |
9 | 1 049 | 171 | 108 |
terok/tui/widgets/__init__.py |
— | 30 | 13 | 3 |
terok/tui/widgets/ansi_log.py |
— | 46 | 6 | 2 |
terok/tui/widgets/panic_button.py |
— | 57 | 16 | 16 |
terok/tui/widgets/project_list.py |
— | 90 | 23 | 14 |
terok/tui/widgets/project_state.py |
— | 237 | 27 | 33 |
terok/tui/widgets/routing_matrix.py |
— | 205 | 21 | 3 |
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 |
— | 193 | 28 | 12 |
terok/tui/app.py |
— | 1 797 | 281 | 113 |
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 |
— | 335 | 61 | 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/key_routing_screen.py |
— | 475 | 53 | 5 |
terok/tui/log_viewer.py |
— | 498 | 46 | 4 |
terok/tui/polling.py |
— | 336 | 93 | 62 |
terok/tui/project_actions.py |
— | 936 | 121 | 42 |
terok/tui/screens.py |
— | 2 360 | 186 | 118 |
terok/tui/selinux_fix_screen.py |
— | 123 | 20 | 4 |
terok/tui/serve.py |
— | 324 | 51 | 41 |
terok/tui/setup_screen.py |
— | 142 | 45 | 11 |
terok/tui/shell_launch.py |
— | 134 | 60 | 21 |
terok/tui/task_actions.py |
— | 871 | 75 | 18 |
terok/tui/task_watcher.py |
— | 139 | 15 | 5 |
terok/tui/text_screens.py |
— | 112 | 20 | 20 |
terok/tui/wizard_screens.py |
— | 809 | 198 | 77 |
terok/tui/worker_actions.py |
— | 259 | 23 | 5 |
terok/tui/worker_log_screen.py |
— | 144 | 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 (23 modules)"]
integrations["integrations (4 modules)"]
orchestration["orchestration (9 modules)"]
presentation["presentation (2 modules)"]
domain -->|39 deps| core
domain -->|9 deps| integrations
domain -->|14 deps| orchestration
orchestration --> ?
orchestration -->|39 deps| core
orchestration -->|4 deps| integrations
presentation --> ?
presentation -->|15 deps| core
presentation -->|22 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 -->|7| terok.lib.core
terok.lib.api -->|13| terok.lib.domain
terok.lib.api -->|9| 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 -->|10| 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¶
58 modules, 206 dependency edges — all boundaries validated.
Module Summary¶
58 modules across 5 layers (click to expand)
| Module | Layer | Deps | Description |
|---|---|---|---|
terok.cli |
presentation | 25 | CLI frontend |
terok.tui |
presentation | 17 | 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.ssh_routing |
domain | 4 | |
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 | 5 | 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 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 and loading |
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: 79.5% (11059/13907 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)
- Functions analyzed: 1395
- Median complexity: 1 · Average: 2.5 · Max: 75
- Within threshold (15): 98% (1367/1395)
0– 3 │ ██████████████████████████████ 1083 (77.6%)
4– 6 │ ████ 152 (10.9%)
7– 9 │ ██ 83 ( 5.9%)
10– 12 │ █ 35 ( 2.5%)
13– 15 │ 14 ( 1.0%) ◄ threshold
16– 18 │ 11 ( 0.8%)
19– 21 │ 9 ( 0.6%)
22– 25 │ 0 ( 0.0%)
26+ │ 8 ( 0.6%)
28 functions exceeding threshold:
| Complexity | Function | File |
|---|---|---|
| 75 | render_project_details |
src/terok/tui/widgets/project_state.py |
| 43 | task_logs |
src/terok/lib/domain/task_logs.py |
| 43 | LogViewerScreen::_stream_logs |
src/terok/tui/log_viewer.py |
| 38 | cmd_overview |
src/terok/cli/commands/_storage_view.py |
| 32 | render_task_details |
src/terok/tui/widgets/task_detail.py |
| 29 | ClaudeStreamJsonFormatter::_handle_user |
src/terok/lib/domain/log_format.py |
| 29 | _TuiLogFormatter::_handle_user |
src/terok/tui/log_viewer.py |
| 26 | _dispatch_task_sub |
src/terok/cli/commands/task.py |
| 21 | cmd_detail |
src/terok/cli/commands/_storage_view.py |
| 21 | get_version_info |
src/terok/lib/core/version.py |
| 21 | task_list |
src/terok/lib/orchestration/tasks/query.py |
| 20 | is_completion_installed |
src/terok/cli/commands/completions.py |
| 20 | dispatch |
src/terok/cli/commands/shield.py |
| 20 | get_project_state |
src/terok/lib/domain/project_state.py |
| 20 | task_status |
src/terok/lib/orchestration/tasks/lifecycle.py |
| 19 | _format_type |
src/terok/cli/commands/info.py |
| 19 | VaultStatusSnapshot::load |
src/terok/lib/api/vault.py |
| 18 | validate_answer |
src/terok/lib/domain/wizards/new_project.py |
| 17 | _cmd_sickbay |
src/terok/cli/commands/sickbay.py |
| 17 | _parent_process_has_name |
src/terok/tui/shell_launch.py |
| 16 | _add_field |
src/terok/cli/commands/info.py |
| 16 | _cmd_project_delete |
src/terok/cli/commands/project.py |
| 16 | _check_unfired_hooks |
src/terok/cli/commands/sickbay.py |
| 16 | main |
src/terok/cli/main.py |
| 16 | get_storage_overview |
src/terok/lib/domain/storage.py |
| 16 | collect_wizard_inputs |
src/terok/lib/domain/wizards/new_project.py |
| 16 | _gate_token_check |
src/terok/lib/orchestration/container_doctor.py |
| 16 | PollingMixin::_sync_worker |
src/terok/tui/polling.py |
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: 22; Found: 21; Missing: 1; Coverage: 95.5%
- Needed: 32; Found: 31; Missing: 1; Coverage: 96.9%
- Needed: 20; Found: 19; Missing: 1; Coverage: 95.0%
- Needed: 16; Found: 13; Missing: 3; Coverage: 81.2%
- Needed: 13; Found: 8; Missing: 5; Coverage: 61.5%
- Needed: 90; Found: 89; Missing: 1; Coverage: 98.9%
- Needed: 21; Found: 20; Missing: 1; Coverage: 95.2%
- Needed: 23; Found: 22; Missing: 1; Coverage: 95.7%
- Needed: 27; Found: 24; Missing: 3; Coverage: 88.9%
- Needed: 55; Found: 46; Missing: 9; Coverage: 83.6%
- Needed: 177; Found: 176; Missing: 1; Coverage: 99.4%
- Needed: 19; Found: 17; Missing: 2; Coverage: 89.5%
- Needed: 72; Found: 60; Missing: 12; Coverage: 83.3%
- Needed: 23; Found: 21; Missing: 2; Coverage: 91.3%
- Needed: 47; Found: 36; Missing: 11; Coverage: 76.6%
- Needed: 1810 - Found: 1754 - Missing: 56
- Total coverage: 96.9% - Grade: Excellent
Generated by scc, complexipy, vulture, tach, and docstr-coverage.