Are we tiny?#

gptme is intended to be small and simple, and focus on doing the right thing in the right way, rather than all the things in all the ways.

The benefits of this approach are many:

  • It is easier to understand and maintain.

  • It is easier to contribute to.

  • It is easier to learn.

  • It is easier to extend.

  • It is more fun to work on.

Being aggressive about keeping things small and simple is a way to keep the project maintainable and fun to work on. The fastest way to kill a project is to make it too big and complex, and suffer burnout as a result.

Another major benefit of keeping things small and simple is that it makes it easier for AI to understand and work with the codebase. This is a major goal of the project, and it is important to keep in mind that the simpler the codebase is, the easier it will be for AI to work with it:

“The simpler your API is, the more effectively the AI can harness it when generating code.”

Kenneth Reitz (and many others)

To that end, in this document we will present some statistics about the current state of the project, trying to be mindful to keep an eye on this page and make sure we are not growing too much.

Startup time#

$ make bench-import
make[2]: Entering directory '/home/runner/work/gptme/gptme'
Benchmarking import time for gptme
time poetry run python -X importtime -m gptme --model openai --non-interactive 2>&1 | grep "import time" | cut -d'|' -f 2- | sort -n | tail -n 10
     305854 | openai
     361656 |                 mcp
     361679 |               mcp.types
     361942 |             gptme.mcp.client
     362074 |           gptme.mcp
     362105 |         gptme.mcp.client
     362423 |       gptme.tools.mcp_adapter
     488808 |     gptme.prompts
     783082 |   gptme.cli
     839467 | gptme

real	0m1.851s
user	0m1.641s
sys	0m0.227s
make[2]: Leaving directory '/home/runner/work/gptme/gptme'
$ make bench-startup
make[2]: Entering directory '/home/runner/work/gptme/gptme'
Benchmarking startup time for gptme
hyperfine "poetry run gptme '/exit'" -M 5 || poetry run gptme '/exit' || exit 1
Benchmark 1: poetry run gptme '/exit'
  Time (mean ± σ):      1.795 s ±  0.026 s    [User: 1.592 s, System: 0.200 s]
  Range (min … max):    1.769 s …  1.827 s    5 runs
 
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

Lines of code#

LoC Core#

$ make cloc-core
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/*.py gptme/llm/*.py gptme/util/*.py gptme/tools/__init__.py gptme/tools/base.py --by-file
github.com/AlDanial/cloc v 1.98  T=0.09 s (547.4 files/s, 153438.5 lines/s)
-----------------------------------------------------------------------------------
File                                            blank        comment           code
-----------------------------------------------------------------------------------
gptme/config.py                                   139            112            506
gptme/llm/llm_openai.py                           112             58            464
gptme/setup.py                                    107             55            462
gptme/llm/models.py                                69             51            434
gptme/util/context.py                             118            177            412
gptme/llm/llm_anthropic.py                         87             68            399
gptme/tools/base.py                                99             87            388
gptme/util/cli.py                                 114             55            388
gptme/prompts.py                                  114            133            380
gptme/logmanager.py                                75             62            341
gptme/commands.py                                  85             47            329
gptme/chat.py                                      70             71            310
gptme/cli.py                                       49             37            303
gptme/util/prompt.py                               76             98            296
gptme/message.py                                   60             65            242
gptme/telemetry.py                                 71             31            242
gptme/llm/__init__.py                              60             51            241
gptme/util/gh.py                                   50             57            239
gptme/ncurses.py                                   39              5            238
gptme/util/_sound_sounddevice.py                   52             52            208
gptme/util/ask_execute.py                          53             46            203
gptme/util/sound.py                                65             72            200
gptme/tools/__init__.py                            59             37            179
gptme/llm/llm_openai_models.py                      2             11            169
gptme/util/__init__.py                             35             21            154
gptme/util/_telemetry.py                           42             26            154
gptme/util/auto_naming.py                          44             38            119
gptme/llm/utils.py                                 38             48            103
gptme/codeblock.py                                 26             33             92
gptme/util/tree.py                                 21             13             91
gptme/util/export.py                               17             25             86
gptme/util/reduce.py                               24             32             75
gptme/util/generate_name.py                         5              6             69
gptme/init.py                                      20              8             68
gptme/util/_sound_cmd.py                           22             17             64
gptme/dirs.py                                      27             14             55
gptme/__version__.py                                9              7             45
gptme/util/cost.py                                 12             20             43
gptme/util/clipboard.py                             8              2             35
gptme/util/terminal.py                             23             21             34
gptme/wut.py                                       13             12             31
gptme/util/content.py                              12             14             24
gptme/util/useredit.py                             12             13             21
gptme/util/interrupt.py                            13             14             20
gptme/constants.py                                  9             11             15
gptme/__init__.py                                   1              1              8
gptme/__main__.py                                   1              0              3
-----------------------------------------------------------------------------------
SUM:                                             2259           1934           8982
-----------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC LLM#

$ make cloc-llm
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/llm/*.py --by-file
github.com/AlDanial/cloc v 1.98  T=0.02 s (293.8 files/s, 120720.2 lines/s)
---------------------------------------------------------------------------------
File                                          blank        comment           code
---------------------------------------------------------------------------------
gptme/llm/llm_openai.py                         112             58            464
gptme/llm/models.py                              69             51            434
gptme/llm/llm_anthropic.py                       87             68            399
gptme/llm/__init__.py                            60             51            241
gptme/llm/llm_openai_models.py                    2             11            169
gptme/llm/utils.py                               38             48            103
---------------------------------------------------------------------------------
SUM:                                            368            287           1810
---------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC Tools#

$ make cloc-tools
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/tools/*.py --by-file
github.com/AlDanial/cloc v 1.98  T=0.05 s (549.5 files/s, 144442.4 lines/s)
-------------------------------------------------------------------------------------
File                                              blank        comment           code
-------------------------------------------------------------------------------------
gptme/tools/shell.py                                110            110            503
gptme/tools/computer.py                             150            218            436
gptme/tools/base.py                                  99             87            388
gptme/tools/_browser_playwright.py                   89             29            259
gptme/tools/tts.py                                  103            118            239
gptme/tools/save.py                                  47             44            208
gptme/tools/patch.py                                 46             61            200
gptme/tools/tmux.py                                  54             73            198
gptme/tools/__init__.py                              59             37            179
gptme/tools/todo.py                                  69             79            179
gptme/tools/morph.py                                 43             42            178
gptme/tools/python.py                                56             49            172
gptme/tools/mcp_adapter.py                           31             23            155
gptme/tools/chats.py                                 43             49            142
gptme/tools/rag.py                                   63             75            141
gptme/tools/_browser_thread.py                       23              4            117
gptme/tools/subagent.py                              37             29            105
gptme/tools/choice.py                                30             25            103
gptme/tools/browser.py                               40             87             84
gptme/tools/_browser_perplexity.py                   20             18             58
gptme/tools/vision.py                                19             12             53
gptme/tools/screenshot.py                            14             12             44
gptme/tools/_browser_lynx.py                          9             13             30
gptme/tools/youtube.py                               10              1             26
gptme/tools/gh.py                                    14             21             16
gptme/tools/read.py                                   6              8             13
-------------------------------------------------------------------------------------
SUM:                                               1284           1324           4226
-------------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC Server#

$ make cloc-server
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/server --by-file
github.com/AlDanial/cloc v 1.98  T=0.03 s (472.9 files/s, 152268.7 lines/s)
------------------------------------------------------------------------------------------
File                                                   blank        comment           code
------------------------------------------------------------------------------------------
gptme/server/tasks_api.py                                171            110            580
gptme/server/api_v2_sessions.py                          138            112            542
gptme/server/openapi_docs.py                             176            140            455
gptme/server/api.py                                       84             79            338
gptme/server/static/main.js                               35             45            316
gptme/server/api_v2.py                                    68             45            302
gptme/server/server-api-improvements.md                   40              0            202
gptme/server/workspace_api.py                             57             55            170
gptme/server/static/index.html                            11             15            148
gptme/server/static/style.css                             27              4            143
gptme/server/api_v2_agents.py                             32             23            138
gptme/server/static/computer.html                          1              1             90
gptme/server/cli.py                                       19              8             79
gptme/server/api_v2_common.py                             48             24             69
gptme/server/__init__.py                                   2              3              3
gptme/server/__main__.py                                   1              0              3
------------------------------------------------------------------------------------------
SUM:                                                     910            664           3578
------------------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC Tests#

$ make cloc-tests
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc tests --by-file
github.com/AlDanial/cloc v 1.98  T=0.05 s (851.3 files/s, 135783.3 lines/s)
--------------------------------------------------------------------------------------------
File                                                     blank        comment           code
--------------------------------------------------------------------------------------------
tests/test_config.py                                        92            203            388
tests/test_cli.py                                           85             52            319
tests/test_llm_openai.py                                    28              0            244
tests/test_server_v2.py                                     67             33            228
tests/test_llm_anthropic.py                                 26              0            221
tests/conftest.py                                           57             31            183
tests/test_mcp.py                                           40             30            161
tests/test_context.py                                       67             42            149
tests/test_dspy_integration.py                              60             36            144
tests/test_tree.py                                          53             29            142
tests/test_tools_shell.py                                   48             96            133
tests/test_tool_use.py                                       8             18            132
tests/test_dspy_basic.py                                    48             24            131
tests/test_prompt.py                                        35             36            120
tests/test_tools_todo.py                                    53             45            114
tests/test_util_cli.py                                      34             28            105
tests/test_auto_naming.py                                   35             23            101
tests/test_tools_computer.py                                36             27             91
tests/test_tools_patch.py                                   47            111             82
tests/test_server.py                                        26             10             79
tests/test_prompt_tools.py                                   4              4             77
tests/test_server_v2_auto_stepping.py                       17             11             74
tests/test_tools.py                                         44              5             74
tests/test_tools_save.py                                    16             10             65
tests/test_codeblock.py                                     32             61             61
tests/test_tools_tts.py                                     29             37             60
tests/test_server_v2_tool_confirmation.py                   16             14             55
tests/test_eval.py                                           8              9             49
tests/test_server_v2_sse.py                                 15             13             49
tests/test-integration.sh                                   22             36             43
tests/test_message.py                                       10             17             39
tests/test_reduce.py                                        10              2             39
tests/test_util.py                                          28             51             37
tests/test_tools_rag.py                                     14              7             35
tests/test_chat.py                                          16             28             28
tests/test_chat_config.py                                    8              7             26
tests/test_tools_python.py                                  19              1             26
tests/test_browser.py                                       14             10             24
tests/test_prompts.py                                        8              4             19
tests/test_logmanager.py                                     8              5             18
tests/test_tools_chats.py                                    2              0             15
tests/test_tools_subagent.py                                 7             10             11
--------------------------------------------------------------------------------------------
SUM:                                                      1292           1216           4191
--------------------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC Eval#

$ make cloc-eval
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/eval/**.py --by-file
github.com/AlDanial/cloc v 1.98  T=0.01 s (583.5 files/s, 81248.8 lines/s)
-------------------------------------------------------------------------------------
File                                   blank        comment           code
-------------------------------------------------------------------------------------
gptme/eval/main.py                        55             22            365
gptme/eval/run.py                         48             32            296
gptme/eval/agents.py                      16              6             84
gptme/eval/execenv.py                     10             14             55
gptme/eval/types.py                       14             12             37
gptme/eval/filestore.py                    5              2             32
gptme/eval/__init__.py                     1              0              4
gptme/eval/__main__.py                     1              0              3
-------------------------------------------------------------------------------------
SUM:                                     150             88            876
-------------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

LoC Total#

$ make cloc-total
make[2]: Entering directory '/home/runner/work/gptme/gptme'
cloc gptme/logmanager.py gptme/chat.py gptme/telemetry.py gptme/__version__.py gptme/message.py gptme/init.py gptme/setup.py gptme/dirs.py gptme/ncurses.py gptme/__main__.py gptme/commands.py gptme/__init__.py gptme/prompts.py gptme/tools/base.py gptme/tools/mcp_adapter.py gptme/tools/subagent.py gptme/tools/patch.py gptme/tools/gh.py gptme/tools/morph.py gptme/tools/shell.py gptme/tools/_browser_thread.py gptme/tools/chats.py gptme/tools/read.py gptme/tools/tmux.py gptme/tools/computer.py gptme/tools/__init__.py gptme/tools/youtube.py gptme/tools/_browser_perplexity.py gptme/tools/_browser_lynx.py gptme/tools/browser.py gptme/tools/_browser_playwright.py gptme/tools/rag.py gptme/tools/python.py gptme/tools/todo.py gptme/tools/tts.py gptme/tools/vision.py gptme/tools/choice.py gptme/tools/screenshot.py gptme/tools/save.py gptme/config.py gptme/mcp/__init__.py gptme/mcp/client.py gptme/constants.py gptme/codeblock.py gptme/util/cost.py gptme/util/_sound_sounddevice.py gptme/util/auto_naming.py gptme/util/ask_execute.py gptme/util/interrupt.py gptme/util/gh.py gptme/util/sound.py gptme/util/tree.py gptme/util/__init__.py gptme/util/prompt.py gptme/util/terminal.py gptme/util/context.py gptme/util/export.py gptme/util/generate_name.py gptme/util/clipboard.py gptme/util/useredit.py gptme/util/cli.py gptme/util/reduce.py gptme/util/_sound_cmd.py gptme/util/content.py gptme/util/_telemetry.py gptme/server/api_v2_sessions.py gptme/server/api_v2_common.py gptme/server/__main__.py gptme/server/api.py gptme/server/tasks_api.py gptme/server/__init__.py gptme/server/api_v2_agents.py gptme/server/api_v2.py gptme/server/workspace_api.py gptme/server/openapi_docs.py gptme/server/cli.py gptme/eval/types.py gptme/eval/dspy/signatures.py gptme/eval/dspy/prompt_optimizer.py gptme/eval/dspy/experiments.py gptme/eval/dspy/__main__.py gptme/eval/dspy/__init__.py gptme/eval/dspy/metrics.py gptme/eval/dspy/tasks.py gptme/eval/dspy/cli.py gptme/eval/__main__.py gptme/eval/main.py gptme/eval/execenv.py gptme/eval/__init__.py gptme/eval/agents.py gptme/eval/run.py gptme/eval/filestore.py gptme/eval/suites/basic.py gptme/eval/suites/__init__.py gptme/eval/suites/browser.py gptme/eval/suites/init_projects.py gptme/cli.py gptme/llm/models.py gptme/llm/llm_anthropic.py gptme/llm/utils.py gptme/llm/llm_openai.py gptme/llm/__init__.py gptme/llm/llm_openai_models.py gptme/wut.py tests/test_tree.py tests/test_util_cli.py tests/test_tools_todo.py tests/test_util.py tests/test_config.py tests/test_server_v2_tool_confirmation.py tests/test_tools_shell.py tests/test_dspy_basic.py tests/test_eval.py tests/test_reduce.py tests/test_llm_openai.py tests/test_prompt.py tests/test_prompt_tools.py tests/test_tools_subagent.py tests/test_tool_use.py tests/test_tools_patch.py tests/test_tools_python.py tests/test_cli.py tests/test_tools_save.py tests/test_context.py tests/test_chat.py tests/test_tools_computer.py tests/test_browser.py tests/test_tools_tts.py tests/test_tools.py tests/test_dspy_integration.py tests/test_message.py tests/test_auto_naming.py tests/test_server_v2_auto_stepping.py tests/test_tools_chats.py tests/test_prompts.py tests/test_chat_config.py tests/test_llm_anthropic.py tests/test_server_v2.py tests/test_server.py tests/test_codeblock.py tests/test_tools_rag.py tests/conftest.py tests/test_mcp.py tests/test_server_v2_sse.py tests/test_logmanager.py scripts/gh-pr-view-with-pr-comments.py scripts/auto_rename_logs.py scripts/convert_convo.py scripts/treeofthoughts.py scripts/train/collect.py scripts/check_rst_formatting.py scripts/list_user_messages.py scripts/shorten_details.py scripts/describe_api.py scripts/summarize_project.py scripts/gpt_todoer.py scripts/reduce_context.py  --by-file
github.com/AlDanial/cloc v 1.98  T=0.23 s (687.3 files/s, 157497.3 lines/s)
--------------------------------------------------------------------------------------------
File                                                     blank        comment           code
--------------------------------------------------------------------------------------------
gptme/server/tasks_api.py                                  171            110            580
gptme/server/api_v2_sessions.py                            138            112            542
gptme/config.py                                            139            112            506
gptme/tools/shell.py                                       110            110            503
gptme/llm/llm_openai.py                                    112             58            464
gptme/setup.py                                             107             55            462
gptme/server/openapi_docs.py                               176            140            455
gptme/eval/dspy/tasks.py                                   114            428            448
gptme/tools/computer.py                                    150            218            436
gptme/llm/models.py                                         69             51            434
gptme/util/context.py                                      118            177            412
gptme/llm/llm_anthropic.py                                  87             68            399
gptme/tools/base.py                                         99             87            388
gptme/util/cli.py                                          114             55            388
tests/test_config.py                                        92            203            388
gptme/prompts.py                                           114            133            380
gptme/eval/main.py                                          55             22            365
gptme/logmanager.py                                         75             62            341
gptme/server/api.py                                         84             79            338
gptme/commands.py                                           85             47            329
tests/test_cli.py                                           85             52            319
gptme/chat.py                                               70             71            310
gptme/eval/dspy/prompt_optimizer.py                         84             96            304
gptme/cli.py                                                49             37            303
gptme/server/api_v2.py                                      68             45            302
scripts/gh-pr-view-with-pr-comments.py                      54             36            297
gptme/eval/run.py                                           48             32            296
gptme/util/prompt.py                                        76             98            296
gptme/tools/_browser_playwright.py                          89             29            259
gptme/eval/dspy/experiments.py                              71             62            248
tests/test_llm_openai.py                                    28              0            244
gptme/message.py                                            60             65            242
gptme/telemetry.py                                          71             31            242
gptme/llm/__init__.py                                       60             51            241
gptme/tools/tts.py                                         103            118            239
gptme/util/gh.py                                            50             57            239
gptme/ncurses.py                                            39              5            238
tests/test_server_v2.py                                     67             33            228
tests/test_llm_anthropic.py                                 26              0            221
gptme/tools/save.py                                         47             44            208
gptme/util/_sound_sounddevice.py                            52             52            208
gptme/util/ask_execute.py                                   53             46            203
gptme/tools/patch.py                                        46             61            200
gptme/util/sound.py                                         65             72            200
gptme/tools/tmux.py                                         54             73            198
gptme/eval/dspy/metrics.py                                  68             83            189
tests/conftest.py                                           57             31            183
gptme/eval/dspy/cli.py                                      50             34            180
gptme/tools/__init__.py                                     59             37            179
gptme/tools/todo.py                                         69             79            179
gptme/tools/morph.py                                        43             42            178
scripts/reduce_context.py                                   59             72            177
gptme/tools/python.py                                       56             49            172
gptme/server/workspace_api.py                               57             55            170
gptme/llm/llm_openai_models.py                               2             11            169
tests/test_mcp.py                                           40             30            161
gptme/tools/mcp_adapter.py                                  31             23            155
gptme/util/__init__.py                                      35             21            154
gptme/util/_telemetry.py                                    42             26            154
tests/test_context.py                                       67             42            149
scripts/check_rst_formatting.py                             41             52            147
tests/test_dspy_integration.py                              60             36            144
gptme/tools/chats.py                                        43             49            142
tests/test_tree.py                                          53             29            142
gptme/tools/rag.py                                          63             75            141
gptme/server/api_v2_agents.py                               32             23            138
gptme/mcp/client.py                                         32             11            136
tests/test_tools_shell.py                                   48             96            133
tests/test_tool_use.py                                       8             18            132
tests/test_dspy_basic.py                                    48             24            131
tests/test_prompt.py                                        35             36            120
gptme/util/auto_naming.py                                   44             38            119
gptme/tools/_browser_thread.py                              23              4            117
scripts/auto_rename_logs.py                                 33             23            114
tests/test_tools_todo.py                                    53             45            114
scripts/gpt_todoer.py                                       47             25            107
gptme/tools/subagent.py                                     37             29            105
tests/test_util_cli.py                                      34             28            105
gptme/llm/utils.py                                          38             48            103
gptme/tools/choice.py                                       30             25            103
scripts/train/collect.py                                    34             52            103
tests/test_auto_naming.py                                   35             23            101
scripts/treeofthoughts.py                                   33             35             97
gptme/codeblock.py                                          26             33             92
gptme/util/tree.py                                          21             13             91
tests/test_tools_computer.py                                36             27             91
gptme/util/export.py                                        17             25             86
gptme/eval/agents.py                                        16              6             84
gptme/tools/browser.py                                      40             87             84
tests/test_tools_patch.py                                   47            111             82
scripts/convert_convo.py                                    33             54             81
gptme/server/cli.py                                         19              8             79
tests/test_server.py                                        26             10             79
tests/test_prompt_tools.py                                   4              4             77
gptme/util/reduce.py                                        24             32             75
tests/test_server_v2_auto_stepping.py                       17             11             74
tests/test_tools.py                                         44              5             74
gptme/eval/suites/basic.py                                  17              0             69
gptme/server/api_v2_common.py                               48             24             69
gptme/util/generate_name.py                                  5              6             69
gptme/init.py                                               20              8             68
tests/test_tools_save.py                                    16             10             65
gptme/util/_sound_cmd.py                                    22             17             64
gptme/eval/suites/init_projects.py                          21              1             62
tests/test_codeblock.py                                     32             61             61
tests/test_tools_tts.py                                     29             37             60
gptme/tools/_browser_perplexity.py                          20             18             58
gptme/eval/dspy/signatures.py                               19             21             56
gptme/dirs.py                                               27             14             55
gptme/eval/execenv.py                                       10             14             55
tests/test_server_v2_tool_confirmation.py                   16             14             55
scripts/describe_api.py                                     28             25             54
gptme/tools/vision.py                                       19             12             53
tests/test_eval.py                                           8              9             49
tests/test_server_v2_sse.py                                 15             13             49
gptme/__version__.py                                         9              7             45
gptme/tools/screenshot.py                                   14             12             44
gptme/util/cost.py                                          12             20             43
tests/test_message.py                                       10             17             39
tests/test_reduce.py                                        10              2             39
gptme/eval/types.py                                         14             12             37
tests/test_util.py                                          28             51             37
gptme/util/clipboard.py                                      8              2             35
tests/test_tools_rag.py                                     14              7             35
gptme/util/terminal.py                                      23             21             34
scripts/shorten_details.py                                  11              6             33
gptme/eval/filestore.py                                      5              2             32
scripts/list_user_messages.py                               10              9             32
gptme/wut.py                                                13             12             31
gptme/tools/_browser_lynx.py                                 9             13             30
tests/test_chat.py                                          16             28             28
gptme/tools/youtube.py                                      10              1             26
scripts/summarize_project.py                                11              1             26
tests/test_chat_config.py                                    8              7             26
tests/test_tools_python.py                                  19              1             26
gptme/util/content.py                                       12             14             24
tests/test_browser.py                                       14             10             24
gptme/util/useredit.py                                      12             13             21
gptme/util/interrupt.py                                     13             14             20
gptme/eval/suites/__init__.py                                3              0             19
tests/test_prompts.py                                        8              4             19
tests/test_logmanager.py                                     8              5             18
gptme/eval/suites/browser.py                                 5              0             17
gptme/tools/gh.py                                           14             21             16
gptme/constants.py                                           9             11             15
tests/test_tools_chats.py                                    2              0             15
gptme/tools/read.py                                          6              8             13
tests/test_tools_subagent.py                                 7             10             11
gptme/__init__.py                                            1              1              8
gptme/eval/dspy/__init__.py                                  5              6              8
gptme/eval/__init__.py                                       1              0              4
gptme/__main__.py                                            1              0              3
gptme/eval/__main__.py                                       1              0              3
gptme/eval/dspy/__main__.py                                  3              5              3
gptme/server/__init__.py                                     2              3              3
gptme/server/__main__.py                                     1              0              3
gptme/mcp/__init__.py                                        1              0              2
--------------------------------------------------------------------------------------------
SUM:                                                      6488           6138          23353
--------------------------------------------------------------------------------------------
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

Code Metrics#

$ make metrics
make[2]: Entering directory '/home/runner/work/gptme/gptme'
=== Code Metrics Summary ===

Project Overview:
  Files: 161
  Total blocks: 1290
  Average complexity: 4.467441860465116

Most Complex Functions (D+):
  gptme/telemetry.py
      F 215:0 record_llm_request - D
  gptme/prompts.py
      F 353:0 prompt_workspace - D
      F 492:0 prompt_chat_history - D
  gptme/tools/shell.py
      M 210:4 ShellSession._run - E
  gptme/tools/tmux.py
      F 150:0 execute_tmux - D
  gptme/tools/computer.py
      F 433:0 computer - D
  gptme/config.py
      F 658:0 setup_config_from_cli - D
      M 540:4 Config.mcp - D
  gptme/util/ask_execute.py
      F 87:0 ask_execute - D
      F 206:0 execute_with_confirmation - D
  gptme/util/gh.py
      F 184:0 get_github_pr_content - D
  gptme/util/context.py
      F 603:0 _resource_to_codeblock - D
  gptme/server/api_v2_sessions.py
      F 182:0 step - D
  gptme/server/tasks_api.py
      F 357:0 get_git_status - D
  gptme/server/api_v2_agents.py
      F 43:0 api_agents_put - D
  gptme/server/openapi_docs.py
      F 521:0 _convert_to_openapi_nullable - D
  gptme/eval/main.py
      F 199:0 main - D
  gptme/cli.py
      F 145:0 main - D
  gptme/llm/llm_anthropic.py
      F 214:0 stream - D
  gptme/llm/llm_openai.py
      F 268:0 stream - D
  gptme/llm/__init__.py
      F 120:0 _reply_stream - D
  tests/test_config.py
      F 501:0 test_project_config_loaded_from_toml - D
      F 529:0 test_project_config_loaded_from_json - D
  tests/test_server_v2_auto_stepping.py
      F 15:0 test_auto_stepping - D
  scripts/gh-pr-view-with-pr-comments.py
      M 173:4 PRViewer.get_comments - D
  scripts/auto_rename_logs.py
      F 30:0 auto_rename_logs - D
  scripts/check_rst_formatting.py
      F 26:0 check_file - E

Largest Files (>300 SLOC):
   828 gptme/eval/dspy/tasks.py
   580 gptme/server/tasks_api.py
   564 tests/test_config.py
   551 gptme/tools/shell.py
   542 gptme/server/api_v2_sessions.py
   508 gptme/config.py
   492 gptme/tools/computer.py
   479 gptme/server/openapi_docs.py
   471 gptme/setup.py
   465 gptme/llm/llm_openai.py
   452 gptme/util/context.py
   445 gptme/llm/models.py
   427 gptme/prompts.py
   399 gptme/llm/llm_anthropic.py
   394 gptme/tools/base.py
   390 gptme/util/cli.py
   367 gptme/eval/main.py
   344 gptme/logmanager.py
   339 gptme/server/api.py
   332 gptme/commands.py
   328 tests/test_cli.py
   316 gptme/util/prompt.py
   310 gptme/chat.py
   309 gptme/cli.py
   305 gptme/eval/dspy/prompt_optimizer.py
   302 gptme/server/api_v2.py

make[3]: Entering directory '/home/runner/work/gptme/gptme'
Most Duplicated Files:
npm warn exec The following package was not found and will be installed: jscpd@4.0.5
Clone found (python):
 - gptme/util/_sound_sounddevice.py [95:5 - 106:67] (11 lines, 101 tokens)
   gptme/util/_sound_sounddevice.py [55:5 - 66:27]

Clone found (python):
 - gptme/server/api.py [168:5 - 178:43] (10 lines, 83 tokens)
   gptme/server/api_v2.py [147:5 - 157:4]

Clone found (python):
 - gptme/server/api.py [179:5 - 187:2] (8 lines, 94 tokens)
   gptme/server/api_v2.py [157:5 - 165:2]

Clone found (python):
 - gptme/mcp/client.py [102:13 - 109:3] (7 lines, 75 tokens)
   gptme/mcp/client.py [68:13 - 73:21]

Clone found (python):
 - gptme/llm/llm_openai.py [271:5 - 285:15] (14 lines, 98 tokens)
   gptme/llm/llm_openai.py [195:5 - 208:5]

Clone found (python):
 - gptme/llm/llm_anthropic.py [232:7 - 245:3] (13 lines, 108 tokens)
   gptme/llm/llm_anthropic.py [182:7 - 196:8]

Clone found (python):
 - scripts/generate_sounds.py [165:2 - 173:13] (8 lines, 81 tokens)
   scripts/generate_sounds.py [91:2 - 99:11]

Clone found (python):
 - gptme/telemetry.py [308:5 - 319:11] (11 lines, 90 tokens)
   gptme/telemetry.py [74:9 - 85:10]

┌────────────┬────────────────┬─────────────┬──────────────┬──────────────┬──────────────────┬───────────────────┐
│ Format     │ Files analyzed │ Total lines │ Total tokens │ Clones found │ Duplicated lines │ Duplicated tokens │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ python     │ 118            │ 30565       │ 205866       │ 8            │ 82 (0.27%)       │ 730 (0.35%)       │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ css        │ 1              │ 173         │ 1045         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ javascript │ 1              │ 395         │ 3314         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ markup     │ 2              │ 264         │ 2183         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ markdown   │ 4              │ 861         │ 5685         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ bash       │ 8              │ 313         │ 1491         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ url        │ 1              │ 2           │ 16           │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ Total:     │ 135            │ 32573       │ 219600       │ 8            │ 82 (0.25%)       │ 730 (0.33%)       │
└────────────┴────────────────┴─────────────┴──────────────┴──────────────┴──────────────────┴───────────────────┘
Found 8 clones.
Detection time:: 2.304s
make[3]: Leaving directory '/home/runner/work/gptme/gptme'
make[2]: Leaving directory '/home/runner/work/gptme/gptme'

The metrics above show:

  • Project Overview: Basic stats about the codebase size and complexity

  • Complex Functions: Functions rated D+ (high complexity, should be refactored)

  • Large Files: Files over 300 SLOC (should be split into smaller modules)

  • Duplicated Files: Using jscpd to find duplicated code

We should aim to:

  • Keep average complexity below 4.0

  • Have no E-rated functions (extremely complex)

  • Have few D-rated functions (very complex)

  • Keep files under 300 SLOC where possible