@scemoon/cdh 1.0.9 → 1.0.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -2
- package/ai-dlc-skill/SKILL.md +0 -106
- package/ai-dlc-skill/architecture/project-structure.md +0 -78
- package/ai-dlc-skill/brownfield/README.md +0 -36
- package/ai-dlc-skill/brownfield/entry.md +0 -45
- package/ai-dlc-skill/brownfield/generate-context.sh +0 -64
- package/ai-dlc-skill/brownfield/scripts/deps.sh +0 -27
- package/ai-dlc-skill/brownfield/scripts/discover.sh +0 -34
- package/ai-dlc-skill/brownfield/scripts/extract-api.sh +0 -45
- package/ai-dlc-skill/components/backend.md +0 -47
- package/ai-dlc-skill/components/desktop.md +0 -63
- package/ai-dlc-skill/components/mya.md +0 -219
- package/ai-dlc-skill/components/native.md +0 -73
- package/ai-dlc-skill/components/tta.md +0 -235
- package/ai-dlc-skill/components/web.md +0 -77
- package/ai-dlc-skill/components/wxa.md +0 -219
- package/ai-dlc-skill/contracts/README.md +0 -25
- package/ai-dlc-skill/core/adaptive-flow.md +0 -107
- package/ai-dlc-skill/core/security.md +0 -29
- package/ai-dlc-skill/core/task-registry.md +0 -153
- package/ai-dlc-skill/cross-tool/README.md +0 -20
- package/ai-dlc-skill/cross-tool/cline/export.sh +0 -38
- package/ai-dlc-skill/cross-tool/copilot/export.sh +0 -41
- package/ai-dlc-skill/cross-tool/cursor/export.sh +0 -53
- package/ai-dlc-skill/cross-tool/onecode/export.sh +0 -27
- package/ai-dlc-skill/cross-tool/opencode/export.sh +0 -38
- package/ai-dlc-skill/phases/debug/entry.md +0 -48
- package/ai-dlc-skill/phases/debug/lifecycle.md +0 -284
- package/ai-dlc-skill/phases/deliver/entry.md +0 -35
- package/ai-dlc-skill/phases/deliver/lifecycle.md +0 -185
- package/ai-dlc-skill/phases/deliver/prompt.md +0 -54
- package/ai-dlc-skill/phases/deliver/rules.md +0 -61
- package/ai-dlc-skill/phases/plan/design_system/accessibility.md +0 -268
- package/ai-dlc-skill/phases/plan/design_system/atomic_design.md +0 -341
- package/ai-dlc-skill/phases/plan/design_system/component_spec.md +0 -398
- package/ai-dlc-skill/phases/plan/design_system/design_tokens.md +0 -190
- package/ai-dlc-skill/phases/plan/design_system/iconography.md +0 -299
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/desktop.md +0 -318
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/mya.md +0 -354
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/native.md +0 -328
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/tta.md +0 -394
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/web.md +0 -287
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/wxa.md +0 -374
- package/ai-dlc-skill/phases/plan/design_system/theme_system.md +0 -318
- package/ai-dlc-skill/phases/plan/entry.md +0 -33
- package/ai-dlc-skill/phases/plan/lifecycle.md +0 -260
- package/ai-dlc-skill/phases/plan/prompt.md +0 -75
- package/ai-dlc-skill/phases/plan/rules.md +0 -60
- package/ai-dlc-skill/phases/understand/entry.md +0 -36
- package/ai-dlc-skill/phases/understand/lifecycle.md +0 -184
- package/ai-dlc-skill/phases/understand/prompt.md +0 -58
- package/ai-dlc-skill/phases/understand/rules.md +0 -49
- package/ai-dlc-skill/phases/verify/config/base_url.md +0 -65
- package/ai-dlc-skill/phases/verify/entry.md +0 -59
- package/ai-dlc-skill/phases/verify/gates/browser_e2e.md +0 -96
- package/ai-dlc-skill/phases/verify/lifecycle.md +0 -217
- package/ai-dlc-skill/phases/verify/prompt.md +0 -73
- package/ai-dlc-skill/phases/verify/rules.md +0 -91
- package/ai-dlc-skill/phases/verify/runners/playwright_local.md +0 -103
- package/ai-dlc-skill/practices/bdd.md +0 -119
- package/ai-dlc-skill/practices/sdd.md +0 -84
- package/ai-dlc-skill/practices/tdd.md +0 -128
- package/ai-dlc-skill/providers/README.md +0 -114
- package/ai-dlc-skill/providers/aliyun/SKILL.md +0 -204
- package/ai-dlc-skill/providers/aliyun/api/rest-api.md +0 -214
- package/ai-dlc-skill/providers/aliyun/api/sdk.md +0 -307
- package/ai-dlc-skill/providers/aliyun/best-practices/database-design.md +0 -363
- package/ai-dlc-skill/providers/aliyun/best-practices/function-design.md +0 -424
- package/ai-dlc-skill/providers/aliyun/best-practices/troubleshooting.md +0 -258
- package/ai-dlc-skill/providers/aliyun/cli/database.md +0 -263
- package/ai-dlc-skill/providers/aliyun/cli/functions.md +0 -263
- package/ai-dlc-skill/providers/aliyun/cli/hosting.md +0 -226
- package/ai-dlc-skill/providers/aliyun/cli/setup.md +0 -235
- package/ai-dlc-skill/providers/aliyun/cli/storage.md +0 -315
- package/ai-dlc-skill/providers/aliyun/deployment.yaml +0 -66
- package/ai-dlc-skill/providers/aliyun/integration/ci-cd.md +0 -288
- package/ai-dlc-skill/providers/aliyun/preview.yaml +0 -84
- package/ai-dlc-skill/providers/aliyun/provider.yaml +0 -160
- package/ai-dlc-skill/providers/aliyun/security/authentication.md +0 -254
- package/ai-dlc-skill/providers/aliyun/services/cdn-hosting.md +0 -220
- package/ai-dlc-skill/providers/aliyun/services/database.md +0 -319
- package/ai-dlc-skill/providers/aliyun/services/function-compute.md +0 -273
- package/ai-dlc-skill/providers/aliyun/services/overview.md +0 -163
- package/ai-dlc-skill/providers/aliyun/services/serverless-app-engine.md +0 -266
- package/ai-dlc-skill/providers/aliyun/services/storage.md +0 -269
- package/ai-dlc-skill/providers/tcb/SKILL.md +0 -208
- package/ai-dlc-skill/providers/tcb/api/rest-api.md +0 -338
- package/ai-dlc-skill/providers/tcb/api/sdk.md +0 -288
- package/ai-dlc-skill/providers/tcb/best-practices/database-design.md +0 -452
- package/ai-dlc-skill/providers/tcb/best-practices/function-design.md +0 -502
- package/ai-dlc-skill/providers/tcb/best-practices/troubleshooting.md +0 -462
- package/ai-dlc-skill/providers/tcb/cli/cls.md +0 -133
- package/ai-dlc-skill/providers/tcb/cli/database.md +0 -230
- package/ai-dlc-skill/providers/tcb/cli/env.md +0 -207
- package/ai-dlc-skill/providers/tcb/cli/functions.md +0 -276
- package/ai-dlc-skill/providers/tcb/cli/hosting.md +0 -219
- package/ai-dlc-skill/providers/tcb/cli/setup.md +0 -218
- package/ai-dlc-skill/providers/tcb/cli/storage.md +0 -233
- package/ai-dlc-skill/providers/tcb/deployment.yaml +0 -111
- package/ai-dlc-skill/providers/tcb/integration/ci-cd.md +0 -309
- package/ai-dlc-skill/providers/tcb/integration/mcp-server.md +0 -371
- package/ai-dlc-skill/providers/tcb/preview.yaml +0 -83
- package/ai-dlc-skill/providers/tcb/provider.yaml +0 -172
- package/ai-dlc-skill/providers/tcb/security/authentication.md +0 -241
- package/ai-dlc-skill/providers/tcb/services/cloud-database.md +0 -299
- package/ai-dlc-skill/providers/tcb/services/cloud-functions.md +0 -265
- package/ai-dlc-skill/providers/tcb/services/cloud-hosting.md +0 -264
- package/ai-dlc-skill/providers/tcb/services/cloud-run.md +0 -285
- package/ai-dlc-skill/providers/tcb/services/cloud-storage.md +0 -245
- package/ai-dlc-skill/providers/tcb/services/overview.md +0 -174
- package/ai-dlc-skill/pybdd/README.md +0 -41
- package/ai-dlc-skill/pybdd/conftest.py +0 -17
- package/ai-dlc-skill/pybdd/example/auth/login.feature +0 -32
- package/ai-dlc-skill/pybdd/pytest.ini +0 -5
- package/ai-dlc-skill/pybdd/steps/.gitkeep +0 -1
- package/ai-dlc-skill/pybdd/steps/test_example_steps.py +0 -65
- package/ai-dlc-skill/requirements.md +0 -140
- package/ai-dlc-skill/skill.yaml +0 -135
- package/ai-dlc-skill/templates/brownfield/context.md +0 -78
- package/ai-dlc-skill/templates/integration/CHANGELOG.md +0 -41
- package/ai-dlc-skill/templates/integration/asyncapi.yaml +0 -43
- package/ai-dlc-skill/templates/integration/contract-diff.md +0 -63
- package/ai-dlc-skill/templates/integration/contract-spec.md +0 -49
- package/ai-dlc-skill/templates/integration/openapi.yaml +0 -18
- package/ai-dlc-skill/templates/integration/runtime-contract.yaml +0 -36
- package/ai-dlc-skill/templates/plan/design.md +0 -49
- package/ai-dlc-skill/templates/plan/task-list.md +0 -32
- package/ai-dlc-skill/templates/project/README.md +0 -126
- package/ai-dlc-skill/templates/project/template.md +0 -119
- package/ai-dlc-skill/templates/understand/feature.feature +0 -30
- package/ai-dlc-skill/templates/understand/intent.md +0 -29
- package/ai-dlc-skill/templates/understand/spec-delta.md +0 -47
- package/ai-dlc-skill/templates/verify/test-unit.py +0 -27
- package/ai-dlc-skill/walkthrough/collect.sh +0 -50
- package/ai-dlc-skill/walkthrough/template.md +0 -54
- package/cdh/__init__.py +0 -0
- package/cdh/__main__.py +0 -4
- package/cdh/__pycache__/__init__.cpython-314.pyc +0 -0
- package/cdh/__pycache__/cli.cpython-314.pyc +0 -0
- package/cdh/__pycache__/cli_logging.cpython-314.pyc +0 -0
- package/cdh/__pycache__/config.cpython-314.pyc +0 -0
- package/cdh/__pycache__/project_loader.cpython-314.pyc +0 -0
- package/cdh/__pycache__/scaffold.cpython-314.pyc +0 -0
- package/cdh/__pycache__/session_store.cpython-314.pyc +0 -0
- package/cdh/cdh_session_aggregator.py +0 -258
- package/cdh/cli.py +0 -3000
- package/cdh/cli_logging.py +0 -45
- package/cdh/config.py +0 -28
- package/cdh/event_loop/__init__.py +0 -7
- package/cdh/event_loop/bus.py +0 -123
- package/cdh/event_loop/events.py +0 -25
- package/cdh/event_loop/runner.py +0 -28
- package/cdh/event_loop/scheduler.py +0 -158
- package/cdh/generators/__init__.py +0 -35
- package/cdh/generators/_runtime.py +0 -176
- package/cdh/generators/ada/MANIFEST.toml +0 -14
- package/cdh/generators/ada/template.ads.tmpl +0 -7
- package/cdh/generators/bash/MANIFEST.toml +0 -14
- package/cdh/generators/bash/template.sh.tmpl +0 -16
- package/cdh/generators/builtin_index.json +0 -590
- package/cdh/generators/c/MANIFEST.toml +0 -14
- package/cdh/generators/c/template.h.tmpl +0 -20
- package/cdh/generators/cli.py +0 -379
- package/cdh/generators/clojure/MANIFEST.toml +0 -14
- package/cdh/generators/clojure/template.clj.tmpl +0 -13
- package/cdh/generators/cobol/MANIFEST.toml +0 -14
- package/cdh/generators/cobol/template.cbl.tmpl +0 -14
- package/cdh/generators/cpp/MANIFEST.toml +0 -14
- package/cdh/generators/cpp/template.hpp.tmpl +0 -32
- package/cdh/generators/crystal/MANIFEST.toml +0 -14
- package/cdh/generators/crystal/template.cr.tmpl +0 -11
- package/cdh/generators/csharp/MANIFEST.toml +0 -23
- package/cdh/generators/csharp/template.cs.tmpl +0 -14
- package/cdh/generators/cython/MANIFEST.toml +0 -14
- package/cdh/generators/cython/template.pyx.tmpl +0 -17
- package/cdh/generators/d/MANIFEST.toml +0 -14
- package/cdh/generators/d/template.d.tmpl +0 -24
- package/cdh/generators/dart/MANIFEST.toml +0 -17
- package/cdh/generators/dart/template.dart.tmpl +0 -27
- package/cdh/generators/elixir/MANIFEST.toml +0 -17
- package/cdh/generators/elixir/template.ex.tmpl +0 -27
- package/cdh/generators/elm/MANIFEST.toml +0 -14
- package/cdh/generators/elm/template.elm.tmpl +0 -20
- package/cdh/generators/erlang/MANIFEST.toml +0 -14
- package/cdh/generators/erlang/template.erl.tmpl +0 -18
- package/cdh/generators/fortran/MANIFEST.toml +0 -14
- package/cdh/generators/fortran/template.f90.tmpl +0 -24
- package/cdh/generators/fsharp/MANIFEST.toml +0 -14
- package/cdh/generators/fsharp/template.fs.tmpl +0 -17
- package/cdh/generators/go/MANIFEST.toml +0 -18
- package/cdh/generators/go/imports.go.tmpl +0 -3
- package/cdh/generators/go/template.go.tmpl +0 -9
- package/cdh/generators/graphql-schema/MANIFEST.toml +0 -18
- package/cdh/generators/graphql-schema/template.graphqls.tmpl +0 -12
- package/cdh/generators/groovy/MANIFEST.toml +0 -14
- package/cdh/generators/groovy/template.groovy.tmpl +0 -28
- package/cdh/generators/hack/MANIFEST.toml +0 -14
- package/cdh/generators/hack/template.hh.tmpl +0 -24
- package/cdh/generators/haskell/MANIFEST.toml +0 -14
- package/cdh/generators/haskell/template.hs.tmpl +0 -20
- package/cdh/generators/haxe/MANIFEST.toml +0 -14
- package/cdh/generators/haxe/template.hx.tmpl +0 -20
- package/cdh/generators/idris/MANIFEST.toml +0 -14
- package/cdh/generators/idris/template.idr.tmpl +0 -22
- package/cdh/generators/java/MANIFEST.toml +0 -18
- package/cdh/generators/java/template.java.tmpl +0 -13
- package/cdh/generators/julia/MANIFEST.toml +0 -14
- package/cdh/generators/julia/template.jl.tmpl +0 -27
- package/cdh/generators/kotlin/MANIFEST.toml +0 -18
- package/cdh/generators/kotlin/template.kt.tmpl +0 -12
- package/cdh/generators/lua/MANIFEST.toml +0 -14
- package/cdh/generators/lua/template.lua.tmpl +0 -27
- package/cdh/generators/matlab/MANIFEST.toml +0 -14
- package/cdh/generators/matlab/template.m.tmpl +0 -26
- package/cdh/generators/nim/MANIFEST.toml +0 -14
- package/cdh/generators/nim/template.nim.tmpl +0 -12
- package/cdh/generators/nix/MANIFEST.toml +0 -14
- package/cdh/generators/nix/template.nix.tmpl +0 -8
- package/cdh/generators/objective-c/MANIFEST.toml +0 -14
- package/cdh/generators/objective-c/template.m.tmpl +0 -31
- package/cdh/generators/ocaml/MANIFEST.toml +0 -14
- package/cdh/generators/ocaml/template.ml.tmpl +0 -13
- package/cdh/generators/pascal/MANIFEST.toml +0 -14
- package/cdh/generators/pascal/template.pas.tmpl +0 -5
- package/cdh/generators/perl/MANIFEST.toml +0 -14
- package/cdh/generators/perl/template.pm.tmpl +0 -27
- package/cdh/generators/php/MANIFEST.toml +0 -17
- package/cdh/generators/php/template.php.tmpl +0 -31
- package/cdh/generators/powershell/MANIFEST.toml +0 -14
- package/cdh/generators/powershell/template.ps1.tmpl +0 -20
- package/cdh/generators/protobuf/MANIFEST.toml +0 -18
- package/cdh/generators/protobuf/template.proto.tmpl +0 -13
- package/cdh/generators/python/MANIFEST.toml +0 -18
- package/cdh/generators/python/template.py.tmpl +0 -12
- package/cdh/generators/r/MANIFEST.toml +0 -14
- package/cdh/generators/r/template.R.tmpl +0 -29
- package/cdh/generators/racket/MANIFEST.toml +0 -14
- package/cdh/generators/racket/template.rkt.tmpl +0 -15
- package/cdh/generators/registry.py +0 -211
- package/cdh/generators/ruby/MANIFEST.toml +0 -17
- package/cdh/generators/ruby/template.rb.tmpl +0 -27
- package/cdh/generators/rust/MANIFEST.toml +0 -18
- package/cdh/generators/rust/template.rs.tmpl +0 -16
- package/cdh/generators/scala/MANIFEST.toml +0 -20
- package/cdh/generators/scala/template.scala.tmpl +0 -13
- package/cdh/generators/scheme/MANIFEST.toml +0 -14
- package/cdh/generators/scheme/template.scm.tmpl +0 -16
- package/cdh/generators/solidity/MANIFEST.toml +0 -14
- package/cdh/generators/solidity/template.sol.tmpl +0 -24
- package/cdh/generators/swift/MANIFEST.toml +0 -18
- package/cdh/generators/swift/template.swift.tmpl +0 -10
- package/cdh/generators/typescript/MANIFEST.toml +0 -18
- package/cdh/generators/typescript/template.ts.tmpl +0 -7
- package/cdh/generators/version.py +0 -214
- package/cdh/generators/zig/MANIFEST.toml +0 -14
- package/cdh/generators/zig/template.zig.tmpl +0 -20
- package/cdh/logging.py +0 -314
- package/cdh/optimizer/__init__.py +0 -7
- package/cdh/optimizer/loop.py +0 -201
- package/cdh/optimizer/mutation.py +0 -85
- package/cdh/optimizer/reward.py +0 -51
- package/cdh/optimizer/tracker.py +0 -118
- package/cdh/project_loader.py +0 -1022
- package/cdh/rules/patterns.yaml +0 -132
- package/cdh/rules/spectral.yaml +0 -301
- package/cdh/scaffold.py +0 -1436
- package/cdh/session_store.py +0 -221
- package/cdh/state_schema.py +0 -127
- package/cdh/tools/__init__.py +0 -57
- package/cdh/tools/cls_search.py +0 -406
- package/cdh/tools/contract_diff.py +0 -644
- package/cdh/tools/deploy_stack.py +0 -590
- package/cdh/tools/generate_shared.py +0 -300
- package/cdh/tools/iac_gen.py +0 -224
- package/cdh/tools/otel_export.py +0 -125
- package/cdh/tools/pattern_detect.py +0 -451
- package/cdh/tools/retrofit_labels.py +0 -505
- package/cdh/trace/__init__.py +0 -101
- package/cdh/trace/__pycache__/__init__.cpython-314.pyc +0 -0
- package/cdh/trace/dashboard/__init__.py +0 -61
- package/cdh/trace/dashboard/api.py +0 -1032
- package/cdh/trace/dashboard/app.html +0 -1321
- package/cdh/trace/dashboard/server.py +0 -310
- package/cdh/trace/otel_exporter.py +0 -462
- package/cdh/trace/otel_tracer.py +0 -281
- package/cdh/tui.py +0 -1084
- package/cdh/validators/__init__.py +0 -16
- package/cdh/validators/__pycache__/__init__.cpython-314.pyc +0 -0
- package/cdh/validators/__pycache__/bdd.cpython-314.pyc +0 -0
- package/cdh/validators/__pycache__/dag.cpython-314.pyc +0 -0
- package/cdh/validators/__pycache__/ears.cpython-314.pyc +0 -0
- package/cdh/validators/__pycache__/fr_namespace.cpython-314.pyc +0 -0
- package/cdh/validators/bdd.py +0 -144
- package/cdh/validators/dag.py +0 -179
- package/cdh/validators/ears.py +0 -452
- package/cdh/validators/fr_namespace.py +0 -143
- package/cdh/validators/spectral.py +0 -475
- package/cdh/verification/__init__.py +0 -3
- package/cdh/verification/aggregation.py +0 -53
- package/cdh/verification/gates/__init__.py +0 -5
- package/cdh/verification/gates/base.py +0 -18
- package/cdh/verification/gates/lint_gate.py +0 -37
- package/cdh/verification/gates/test_gate.py +0 -41
- package/cdh/verification/loop.py +0 -93
- package/cdh/verification/policy.py +0 -24
- package/onecode/__init__.py +0 -1
- package/onecode/__main__.py +0 -4
- package/onecode/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/__pycache__/cli.cpython-314.pyc +0 -0
- package/onecode/__pycache__/commands.cpython-314.pyc +0 -0
- package/onecode/__pycache__/config.cpython-314.pyc +0 -0
- package/onecode/__pycache__/migrate.cpython-314.pyc +0 -0
- package/onecode/agent/__init__.py +0 -0
- package/onecode/agent/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/cdh_loader.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/checkpoint.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/context.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/engine.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/hooks.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/onecode_agent_acp.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/permissions.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/permissions_store.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/project_doc.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/session.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/turn_record.cpython-314.pyc +0 -0
- package/onecode/agent/agents/__init__.py +0 -29
- package/onecode/agent/agents/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/agents/__pycache__/types.cpython-314.pyc +0 -0
- package/onecode/agent/agents/prompts/build-agent.md +0 -50
- package/onecode/agent/agents/prompts/compaction-instructions.md +0 -12
- package/onecode/agent/agents/prompts/explore-agent.md +0 -42
- package/onecode/agent/agents/prompts/plan-agent.md +0 -44
- package/onecode/agent/agents/prompts/plan-gate-hard.md +0 -4
- package/onecode/agent/agents/prompts/plan-gate-soft.md +0 -3
- package/onecode/agent/agents/prompts/solo-agent.md +0 -57
- package/onecode/agent/agents/prompts/subagent-constraints.md +0 -10
- package/onecode/agent/agents/prompts/summary-instructions.md +0 -7
- package/onecode/agent/agents/prompts/title-instructions.md +0 -3
- package/onecode/agent/agents/prompts/tool-descriptions.md +0 -129
- package/onecode/agent/agents/types.py +0 -786
- package/onecode/agent/attachments.py +0 -112
- package/onecode/agent/cdh_loader.py +0 -3
- package/onecode/agent/checkpoint.py +0 -285
- package/onecode/agent/context.py +0 -465
- package/onecode/agent/engine.py +0 -3547
- package/onecode/agent/event_bridge.py +0 -75
- package/onecode/agent/hooks.py +0 -86
- package/onecode/agent/onecode_agent_acp.py +0 -2993
- package/onecode/agent/permissions.py +0 -150
- package/onecode/agent/permissions_store.py +0 -73
- package/onecode/agent/project_doc.py +0 -19
- package/onecode/agent/question_detect.py +0 -230
- package/onecode/agent/session.py +0 -3
- package/onecode/agent/snapshot.py +0 -144
- package/onecode/agent/tools/__init__.py +0 -17
- package/onecode/agent/tools/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/agent_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/apply_patch_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/bash_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/communication_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/config_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/cron_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/errors.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/file_ops.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/file_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/git_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/lsp_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/mcp_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/permission_handler.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/permissions.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/protocol.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/registry.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/sandbox.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/schema_validation.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/skill_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/todo_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/web_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/agent_tools.py +0 -128
- package/onecode/agent/tools/apply_patch_tool.py +0 -138
- package/onecode/agent/tools/bash_tool.py +0 -121
- package/onecode/agent/tools/communication_tools.py +0 -154
- package/onecode/agent/tools/config_tool.py +0 -130
- package/onecode/agent/tools/cron_tools.py +0 -178
- package/onecode/agent/tools/errors.py +0 -17
- package/onecode/agent/tools/file_ops.py +0 -221
- package/onecode/agent/tools/file_tools.py +0 -225
- package/onecode/agent/tools/git_tools.py +0 -88
- package/onecode/agent/tools/lsp_tools.py +0 -404
- package/onecode/agent/tools/mcp_tools.py +0 -211
- package/onecode/agent/tools/permission_handler.py +0 -46
- package/onecode/agent/tools/permissions.py +0 -77
- package/onecode/agent/tools/protocol.py +0 -20
- package/onecode/agent/tools/registry.py +0 -210
- package/onecode/agent/tools/sandbox.py +0 -460
- package/onecode/agent/tools/schema_validation.py +0 -100
- package/onecode/agent/tools/skill_tools.py +0 -52
- package/onecode/agent/tools/todo_tools.py +0 -208
- package/onecode/agent/tools/web_tools.py +0 -530
- package/onecode/agent/turn_record.py +0 -28
- package/onecode/builtin_skills/agent-browser/SKILL.md +0 -212
- package/onecode/builtin_skills/agent-browser/skill.yaml +0 -8
- package/onecode/builtin_skills/cloudbase/SKILL.md +0 -162
- package/onecode/builtin_skills/cloudbase/skill.yaml +0 -7
- package/onecode/builtin_skills/git/SKILL.md +0 -64
- package/onecode/builtin_skills/git/skill.yaml +0 -7
- package/onecode/builtin_skills/shell/SKILL.md +0 -58
- package/onecode/builtin_skills/shell/skill.yaml +0 -8
- package/onecode/builtin_skills/skill-creator/SKILL.md +0 -106
- package/onecode/builtin_skills/skill-creator/skill.yaml +0 -8
- package/onecode/cli.py +0 -1325
- package/onecode/codebase/__init__.py +0 -69
- package/onecode/codebase/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/chunker.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/indexer.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/retriever.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/storage.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/tools.cpython-314.pyc +0 -0
- package/onecode/codebase/chunker.py +0 -125
- package/onecode/codebase/indexer.py +0 -154
- package/onecode/codebase/retriever.py +0 -240
- package/onecode/codebase/storage.py +0 -153
- package/onecode/codebase/tools.py +0 -59
- package/onecode/commands.py +0 -673
- package/onecode/config.py +0 -539
- package/onecode/config_screen.py +0 -486
- package/onecode/cron/__init__.py +0 -3
- package/onecode/lsp/__init__.py +0 -3
- package/onecode/mcp/__init__.py +0 -11
- package/onecode/mcp/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/client.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/cloudbase.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/config.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/manager.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/oauth.cpython-314.pyc +0 -0
- package/onecode/mcp/client.py +0 -305
- package/onecode/mcp/cloudbase.py +0 -188
- package/onecode/mcp/config.py +0 -363
- package/onecode/mcp/manager.py +0 -603
- package/onecode/mcp/oauth.py +0 -199
- package/onecode/memory/__init__.py +0 -106
- package/onecode/memory/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/backend.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/pyramid.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/recall.cpython-314.pyc +0 -0
- package/onecode/memory/backend.py +0 -179
- package/onecode/memory/pyramid.py +0 -145
- package/onecode/memory/recall.py +0 -322
- package/onecode/migrate.py +0 -122
- package/onecode/models/__init__.py +0 -4
- package/onecode/models/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/errors.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/messages.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/ollama_manager.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/provider.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/registry.cpython-314.pyc +0 -0
- package/onecode/models/errors.py +0 -104
- package/onecode/models/messages.py +0 -750
- package/onecode/models/ollama_manager.py +0 -167
- package/onecode/models/provider.py +0 -730
- package/onecode/models/providers/__init__.py +0 -17
- package/onecode/models/providers/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/anthropic_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/deepseek_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/glm_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/minimax_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/minimaxi_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/ollama_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/openai_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/anthropic_provider.py +0 -286
- package/onecode/models/providers/deepseek_provider.py +0 -221
- package/onecode/models/providers/glm_provider.py +0 -219
- package/onecode/models/providers/minimax_provider.py +0 -182
- package/onecode/models/providers/minimaxi_provider.py +0 -426
- package/onecode/models/providers/ollama_provider.py +0 -183
- package/onecode/models/providers/openai_provider.py +0 -234
- package/onecode/models/registry.py +0 -349
- package/onecode/server/__init__.py +0 -3
- package/onecode/server/app.py +0 -251
- package/onecode/skills/__init__.py +0 -11
- package/onecode/skills/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/argument_substitution.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/create.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/frontmatter.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/loader.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/model.cpython-314.pyc +0 -0
- package/onecode/skills/argument_substitution.py +0 -38
- package/onecode/skills/bootstrap.py +0 -37
- package/onecode/skills/create.py +0 -56
- package/onecode/skills/frontmatter.py +0 -33
- package/onecode/skills/loader.py +0 -215
- package/onecode/skills/manager.py +0 -75
- package/onecode/skills/model.py +0 -43
- package/onecode/storage/__init__.py +0 -0
- package/onecode/storage/activity.py +0 -63
- package/onecode/storage/project.py +0 -54
- package/onecode/storage/session.py +0 -112
- package/onecode/tasks/__init__.py +0 -26
- package/onecode/tasks/manager.py +0 -232
- package/onecode/tasks/models.py +0 -240
- package/onecode/trace/__init__.py +0 -0
- package/onecode/trace/tracer.py +0 -173
- package/onecode/utils/__init__.py +0 -0
- package/onecode/utils/helpers.py +0 -20
- package/onecode/verification/__init__.py +0 -5
- package/onecode/verification/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/verification/__pycache__/aggregation.cpython-314.pyc +0 -0
- package/onecode/verification/__pycache__/loop.cpython-314.pyc +0 -0
- package/onecode/verification/__pycache__/policy.cpython-314.pyc +0 -0
- package/onecode/verification/aggregation.py +0 -53
- package/onecode/verification/gates/__init__.py +0 -6
- package/onecode/verification/gates/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/verification/gates/__pycache__/base.cpython-314.pyc +0 -0
- package/onecode/verification/gates/__pycache__/lint_gate.cpython-314.pyc +0 -0
- package/onecode/verification/gates/__pycache__/test_gate.cpython-314.pyc +0 -0
- package/onecode/verification/gates/__pycache__/type_gate.cpython-314.pyc +0 -0
- package/onecode/verification/gates/base.py +0 -20
- package/onecode/verification/gates/lint_gate.py +0 -45
- package/onecode/verification/gates/test_gate.py +0 -62
- package/onecode/verification/gates/type_gate.py +0 -46
- package/onecode/verification/loop.py +0 -95
- package/onecode/verification/policy.py +0 -29
- package/pyproject.toml +0 -84
- package/tui/__init__.py +0 -46
- package/tui/__main__.py +0 -4
- package/tui/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/__pycache__/_loop.cpython-314.pyc +0 -0
- package/tui/__pycache__/_path_fuzzy_search.cpython-314.pyc +0 -0
- package/tui/__pycache__/_path_match.cpython-314.pyc +0 -0
- package/tui/__pycache__/agent.cpython-314.pyc +0 -0
- package/tui/__pycache__/agent_schema.cpython-314.pyc +0 -0
- package/tui/__pycache__/agents.cpython-314.pyc +0 -0
- package/tui/__pycache__/answer.cpython-314.pyc +0 -0
- package/tui/__pycache__/app.cpython-314.pyc +0 -0
- package/tui/__pycache__/atomic.cpython-314.pyc +0 -0
- package/tui/__pycache__/complete.cpython-314.pyc +0 -0
- package/tui/__pycache__/constants.cpython-314.pyc +0 -0
- package/tui/__pycache__/conversation_markdown.cpython-314.pyc +0 -0
- package/tui/__pycache__/db.cpython-314.pyc +0 -0
- package/tui/__pycache__/dec.cpython-314.pyc +0 -0
- package/tui/__pycache__/directory.cpython-314.pyc +0 -0
- package/tui/__pycache__/directory_watcher.cpython-314.pyc +0 -0
- package/tui/__pycache__/format_path.cpython-314.pyc +0 -0
- package/tui/__pycache__/fuzzy.cpython-314.pyc +0 -0
- package/tui/__pycache__/fuzzy_index.cpython-314.pyc +0 -0
- package/tui/__pycache__/history.cpython-314.pyc +0 -0
- package/tui/__pycache__/jsonrpc.cpython-314.pyc +0 -0
- package/tui/__pycache__/menus.cpython-314.pyc +0 -0
- package/tui/__pycache__/message_log.cpython-314.pyc +0 -0
- package/tui/__pycache__/messages.cpython-314.pyc +0 -0
- package/tui/__pycache__/path_complete.cpython-314.pyc +0 -0
- package/tui/__pycache__/path_filter.cpython-314.pyc +0 -0
- package/tui/__pycache__/paths.cpython-314.pyc +0 -0
- package/tui/__pycache__/pill.cpython-314.pyc +0 -0
- package/tui/__pycache__/platform_commands.cpython-314.pyc +0 -0
- package/tui/__pycache__/protocol.cpython-314.pyc +0 -0
- package/tui/__pycache__/session_tracker.cpython-314.pyc +0 -0
- package/tui/__pycache__/settings.cpython-314.pyc +0 -0
- package/tui/__pycache__/settings_schema.cpython-314.pyc +0 -0
- package/tui/__pycache__/shell.cpython-314.pyc +0 -0
- package/tui/__pycache__/shell_read.cpython-314.pyc +0 -0
- package/tui/__pycache__/slash_command.cpython-314.pyc +0 -0
- package/tui/__pycache__/version.cpython-314.pyc +0 -0
- package/tui/_loop.py +0 -86
- package/tui/_path_fuzzy_search.py +0 -48
- package/tui/_path_match.py +0 -141
- package/tui/about.py +0 -95
- package/tui/acp/__pycache__/agent.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/api.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/encode_tool_call_id.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/event_tap.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/messages.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/prompt.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/protocol.cpython-314.pyc +0 -0
- package/tui/acp/agent.py +0 -1212
- package/tui/acp/api.py +0 -79
- package/tui/acp/encode_tool_call_id.py +0 -12
- package/tui/acp/event_tap.py +0 -107
- package/tui/acp/messages.py +0 -222
- package/tui/acp/prompt.py +0 -53
- package/tui/acp/protocol.py +0 -551
- package/tui/agent.py +0 -70
- package/tui/agent_schema.py +0 -76
- package/tui/agents.py +0 -46
- package/tui/ansi/__init__.py +0 -1
- package/tui/ansi/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_ansi.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_ansi_colors.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_control_codes.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_keys.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_sgr_styles.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_stream_parser.cpython-314.pyc +0 -0
- package/tui/ansi/_ansi.py +0 -1689
- package/tui/ansi/_ansi_colors.py +0 -264
- package/tui/ansi/_control_codes.py +0 -37
- package/tui/ansi/_keys.py +0 -251
- package/tui/ansi/_sgr_styles.py +0 -64
- package/tui/ansi/_stream_parser.py +0 -418
- package/tui/answer.py +0 -12
- package/tui/app.py +0 -1195
- package/tui/atomic.py +0 -37
- package/tui/cli.py +0 -208
- package/tui/code_analyze.py +0 -27
- package/tui/complete.py +0 -38
- package/tui/constants.py +0 -61
- package/tui/conversation_markdown.py +0 -30
- package/tui/danger.py +0 -372
- package/tui/data/agents/ampcode.com.toml +0 -52
- package/tui/data/agents/augmentcode.com.toml +0 -41
- package/tui/data/agents/cdh.cloud-dev-harness.toml +0 -23
- package/tui/data/agents/claude.com.toml +0 -42
- package/tui/data/agents/copilot.github.com.toml +0 -29
- package/tui/data/agents/crowai.dev.toml +0 -36
- package/tui/data/agents/cursor.com.toml +0 -38
- package/tui/data/agents/deepagents.langchain.com +0 -34
- package/tui/data/agents/docker.com.toml +0 -60
- package/tui/data/agents/geminicli.com.toml +0 -28
- package/tui/data/agents/goose.ai.toml +0 -52
- package/tui/data/agents/inference.huggingface.co.toml +0 -41
- package/tui/data/agents/kimi.com.toml +0 -35
- package/tui/data/agents/kiro.dev.toml +0 -43
- package/tui/data/agents/onecode.dev.toml +0 -22
- package/tui/data/agents/openai.com.toml +0 -53
- package/tui/data/agents/openclaw.ai.toml +0 -37
- package/tui/data/agents/opencode.ai.toml +0 -39
- package/tui/data/agents/openhands.dev.toml +0 -46
- package/tui/data/agents/stakpak.dev.toml +0 -62
- package/tui/data/agents/vibe.mistral.ai.toml +0 -31
- package/tui/data/agents/vtcode.dev.toml +0 -63
- package/tui/data/images/frog.png +0 -0
- package/tui/data/sounds/question.wav +0 -0
- package/tui/data/sounds/turn-over.wav +0 -0
- package/tui/db.py +0 -213
- package/tui/dec.py +0 -332
- package/tui/diff_utils.py +0 -131
- package/tui/directory.py +0 -234
- package/tui/directory_suggester.py +0 -93
- package/tui/directory_watcher.py +0 -231
- package/tui/format_path.py +0 -25
- package/tui/fuzzy.py +0 -140
- package/tui/fuzzy_index.py +0 -275
- package/tui/gist.py +0 -33
- package/tui/history.py +0 -138
- package/tui/jsonrpc.py +0 -599
- package/tui/menus.py +0 -14
- package/tui/message_log.py +0 -69
- package/tui/messages.py +0 -144
- package/tui/option_content.py +0 -51
- package/tui/os.py +0 -0
- package/tui/path_complete.py +0 -217
- package/tui/path_filter.py +0 -124
- package/tui/paths.py +0 -87
- package/tui/pill.py +0 -23
- package/tui/platform_commands.py +0 -52
- package/tui/prompt/__pycache__/extract.cpython-314.pyc +0 -0
- package/tui/prompt/__pycache__/resource.cpython-314.pyc +0 -0
- package/tui/prompt/extract.py +0 -19
- package/tui/prompt/resource.py +0 -68
- package/tui/protocol.py +0 -28
- package/tui/screens/__init__.py +0 -0
- package/tui/screens/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/diff_screen.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/main.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/sessions.cpython-314.pyc +0 -0
- package/tui/screens/action_modal.py +0 -94
- package/tui/screens/agent_modal.py +0 -175
- package/tui/screens/command_edit_modal.py +0 -74
- package/tui/screens/diff_explorer_screen.py +0 -419
- package/tui/screens/diff_screen.py +0 -84
- package/tui/screens/ide_screen.py +0 -461
- package/tui/screens/main.py +0 -397
- package/tui/screens/main.tcss +0 -662
- package/tui/screens/permissions.py +0 -404
- package/tui/screens/permissions.tcss +0 -72
- package/tui/screens/projects.tcss +0 -84
- package/tui/screens/projects_app.py +0 -341
- package/tui/screens/projects_screen.py +0 -277
- package/tui/screens/session_resume_modal.py +0 -172
- package/tui/screens/session_resume_modal.tcss +0 -35
- package/tui/screens/sessions.py +0 -171
- package/tui/screens/sessions.tcss +0 -119
- package/tui/screens/settings.py +0 -293
- package/tui/screens/settings.tcss +0 -113
- package/tui/screens/store.py +0 -502
- package/tui/screens/store.tcss +0 -274
- package/tui/screens/tool_content_screen.py +0 -59
- package/tui/screens/trace.py +0 -317
- package/tui/session_tracker.py +0 -123
- package/tui/settings.py +0 -353
- package/tui/settings_schema.py +0 -467
- package/tui/shell.py +0 -304
- package/tui/shell_read.py +0 -42
- package/tui/slash_command.py +0 -34
- package/tui/tui.tcss +0 -246
- package/tui/twitter.py +0 -38
- package/tui/version.py +0 -80
- package/tui/visuals/__init__.py +0 -0
- package/tui/visuals/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/visuals/__pycache__/columns.cpython-314.pyc +0 -0
- package/tui/visuals/columns.py +0 -272
- package/tui/widgets/__init__.py +0 -0
- package/tui/widgets/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/agent_response.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/agent_thought.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/aidlc.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/ask_user.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/condensed_path.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/context_stats.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/conversation.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/diff_view.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/flash.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/future_text.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/grid_select.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/highlighted_textarea.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/load_more.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/menu.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/modified_files.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/non_selectable_label.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/note.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/path_search.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/pending_prompts.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/plan.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/project_directory_tree.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/prompt.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/question.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_grid_select.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_summary.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_tabs.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/shell_terminal.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/side_bar.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/slash_complete.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/strike_text.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/terminal.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/throbber.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/tool_call.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/user_input.cpython-314.pyc +0 -0
- package/tui/widgets/acp_content.py +0 -70
- package/tui/widgets/agent_response.py +0 -76
- package/tui/widgets/agent_thought.py +0 -167
- package/tui/widgets/aidlc.py +0 -334
- package/tui/widgets/ask_user.py +0 -604
- package/tui/widgets/command_pane.py +0 -223
- package/tui/widgets/condensed_path.py +0 -115
- package/tui/widgets/context_stats.py +0 -66
- package/tui/widgets/conversation.py +0 -3235
- package/tui/widgets/danger_warning.py +0 -65
- package/tui/widgets/diff_view.py +0 -69
- package/tui/widgets/directory_input.py +0 -8
- package/tui/widgets/edit_field.py +0 -206
- package/tui/widgets/flash.py +0 -81
- package/tui/widgets/future_text.py +0 -126
- package/tui/widgets/grid_select.py +0 -234
- package/tui/widgets/highlighted_textarea.py +0 -183
- package/tui/widgets/load_more.py +0 -24
- package/tui/widgets/mandelbrot.py +0 -294
- package/tui/widgets/markdown_note.py +0 -13
- package/tui/widgets/menu.py +0 -147
- package/tui/widgets/model_status.py +0 -230
- package/tui/widgets/modified_files.py +0 -315
- package/tui/widgets/non_selectable_label.py +0 -5
- package/tui/widgets/note.py +0 -18
- package/tui/widgets/path_search.py +0 -492
- package/tui/widgets/pending_prompts.py +0 -36
- package/tui/widgets/plan.py +0 -285
- package/tui/widgets/project_directory_tree.py +0 -102
- package/tui/widgets/project_grid_select.py +0 -68
- package/tui/widgets/project_summary.py +0 -33
- package/tui/widgets/prompt.py +0 -935
- package/tui/widgets/question.py +0 -360
- package/tui/widgets/session_grid_select.py +0 -230
- package/tui/widgets/session_summary.py +0 -115
- package/tui/widgets/session_tabs.py +0 -194
- package/tui/widgets/shell_result.py +0 -35
- package/tui/widgets/shell_terminal.py +0 -40
- package/tui/widgets/side_bar.py +0 -124
- package/tui/widgets/slash_complete.py +0 -235
- package/tui/widgets/strike_text.py +0 -70
- package/tui/widgets/subagent.py +0 -287
- package/tui/widgets/subagent_screen.py +0 -715
- package/tui/widgets/terminal.py +0 -576
- package/tui/widgets/terminal_tool.py +0 -360
- package/tui/widgets/throbber.py +0 -100
- package/tui/widgets/tool_call.py +0 -432
- package/tui/widgets/user_input.py +0 -23
- package/tui/widgets/version.py +0 -5
- package/tui/widgets/welcome.py +0 -31
|
@@ -1,1032 +0,0 @@
|
|
|
1
|
-
"""Trace dashboard API — all SQL queries."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
import sqlite3
|
|
7
|
-
from datetime import datetime, timedelta
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from typing import Any
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def _connect(db_path: Path) -> sqlite3.Connection | None:
|
|
13
|
-
if not db_path.exists():
|
|
14
|
-
return None
|
|
15
|
-
conn = sqlite3.connect(str(db_path))
|
|
16
|
-
conn.row_factory = sqlite3.Row
|
|
17
|
-
try:
|
|
18
|
-
conn.execute("SELECT COUNT(*) FROM traces")
|
|
19
|
-
except sqlite3.OperationalError:
|
|
20
|
-
conn.close()
|
|
21
|
-
return None
|
|
22
|
-
conn.execute("PRAGMA journal_mode=WAL")
|
|
23
|
-
return conn
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _require_db(db_path: Path):
|
|
27
|
-
"""Return a connection or raise a clear error about empty DB."""
|
|
28
|
-
conn = _connect(db_path)
|
|
29
|
-
if conn is None:
|
|
30
|
-
raise EmptyTraceDB("No traces yet. Run an agent session to collect data.")
|
|
31
|
-
return conn
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class EmptyTraceDB(Exception):
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def _json_val(column: str) -> str:
|
|
39
|
-
"""Return a SQLite expression to extract a value from the data JSON column.
|
|
40
|
-
|
|
41
|
-
Checks both top-level and nested kwargs paths.
|
|
42
|
-
"""
|
|
43
|
-
return (
|
|
44
|
-
f"COALESCE(JSON_EXTRACT(data, '$.{column}'), "
|
|
45
|
-
f"JSON_EXTRACT(data, '$.kwargs.{column}'))"
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def _tags_val(key: str) -> str:
|
|
50
|
-
"""Return a SQLite expression to extract a tag from the tags JSON column."""
|
|
51
|
-
return f"JSON_EXTRACT(tags, '$.{key}')"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def _model_val() -> str:
|
|
55
|
-
"""Return a SQLite expression to extract model from data.kwargs.model or tags.model."""
|
|
56
|
-
return (
|
|
57
|
-
"COALESCE("
|
|
58
|
-
"JSON_EXTRACT(data, '$.kwargs.model'), "
|
|
59
|
-
"JSON_EXTRACT(data, '$.model'), "
|
|
60
|
-
f"{_tags_val('model')}"
|
|
61
|
-
")"
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def _parse_row(row: sqlite3.Row) -> dict:
|
|
66
|
-
d = dict(row)
|
|
67
|
-
if isinstance(d.get("tags"), str):
|
|
68
|
-
try:
|
|
69
|
-
d["tags"] = json.loads(d["tags"])
|
|
70
|
-
except (json.JSONDecodeError, TypeError):
|
|
71
|
-
d["tags"] = {}
|
|
72
|
-
if isinstance(d.get("data"), str):
|
|
73
|
-
try:
|
|
74
|
-
data = json.loads(d["data"])
|
|
75
|
-
d["data"] = data
|
|
76
|
-
for k, v in data.items():
|
|
77
|
-
if k not in d or d[k] is None:
|
|
78
|
-
d[k] = v
|
|
79
|
-
if isinstance(data.get("kwargs"), dict):
|
|
80
|
-
for k, v in data["kwargs"].items():
|
|
81
|
-
if k not in d or d[k] is None:
|
|
82
|
-
d[k] = v
|
|
83
|
-
if k not in data:
|
|
84
|
-
data[k] = v
|
|
85
|
-
except (json.JSONDecodeError, TypeError):
|
|
86
|
-
d["data"] = {}
|
|
87
|
-
d["type"] = d.pop("trace_type", d.get("type", ""))
|
|
88
|
-
d["function"] = d.pop("function_name", d.get("function", ""))
|
|
89
|
-
return d
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def _percentile(sorted_data: list[float], p: float) -> float:
|
|
93
|
-
if not sorted_data:
|
|
94
|
-
return 0.0
|
|
95
|
-
idx = int(len(sorted_data) * p / 100.0)
|
|
96
|
-
idx = min(idx, len(sorted_data) - 1)
|
|
97
|
-
return sorted_data[idx]
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def get_overview(db_path: Path, start: str | None = None, end: str | None = None) -> dict:
|
|
101
|
-
conn = _connect(db_path)
|
|
102
|
-
if conn is None:
|
|
103
|
-
return {
|
|
104
|
-
"total": 0, "total_today": 0, "sessions": 0, "agents": 0,
|
|
105
|
-
"avg_duration": 0, "p50_duration": 0, "p95_duration": 0, "p99_duration": 0,
|
|
106
|
-
"error_count": 0, "error_rate": 0,
|
|
107
|
-
"total_tokens": 0, "input_tokens": 0, "output_tokens": 0,
|
|
108
|
-
"cached_tokens": 0, "cache_hit_rate": 0,
|
|
109
|
-
"total_cost": 0, "estimated_cost": True,
|
|
110
|
-
"lines_added": 0, "tokens_per_kloc": 0,
|
|
111
|
-
"type_distribution": {}, "hourly": [], "agent_breakdown": [],
|
|
112
|
-
"model_breakdown": [], "daily_cost": [], "db_path": str(db_path),
|
|
113
|
-
}
|
|
114
|
-
try:
|
|
115
|
-
now = datetime.utcnow()
|
|
116
|
-
today_start = now.strftime("%Y-%m-%dT00:00:00")
|
|
117
|
-
|
|
118
|
-
time_filter = ""
|
|
119
|
-
time_params: list[Any] = []
|
|
120
|
-
if start:
|
|
121
|
-
time_filter += " AND timestamp >= ?"
|
|
122
|
-
time_params.append(start)
|
|
123
|
-
if end:
|
|
124
|
-
time_filter += " AND timestamp <= ?"
|
|
125
|
-
time_params.append(end)
|
|
126
|
-
|
|
127
|
-
total = conn.execute(f"SELECT COUNT(*) FROM traces WHERE 1=1{time_filter}", time_params).fetchone()[0]
|
|
128
|
-
total_today = conn.execute(
|
|
129
|
-
f"SELECT COUNT(*) FROM traces WHERE timestamp >= ?{time_filter}", (today_start, *time_params)
|
|
130
|
-
).fetchone()[0]
|
|
131
|
-
sessions = conn.execute(
|
|
132
|
-
f"SELECT COUNT(DISTINCT session_id) FROM traces WHERE 1=1{time_filter}", time_params
|
|
133
|
-
).fetchone()[0]
|
|
134
|
-
agents = conn.execute(
|
|
135
|
-
f"SELECT COUNT(DISTINCT {_tags_val('agent')}) FROM traces WHERE {_tags_val('agent')} IS NOT NULL{time_filter}", time_params
|
|
136
|
-
).fetchone()[0]
|
|
137
|
-
|
|
138
|
-
durations = [
|
|
139
|
-
float(r[0])
|
|
140
|
-
for r in conn.execute(
|
|
141
|
-
f"SELECT {_json_val('duration_ms')} FROM traces WHERE {_json_val('duration_ms')} IS NOT NULL{time_filter}",
|
|
142
|
-
time_params
|
|
143
|
-
).fetchall()
|
|
144
|
-
if r[0] is not None
|
|
145
|
-
]
|
|
146
|
-
sorted_d = sorted(durations)
|
|
147
|
-
avg_duration = sum(sorted_d) / len(sorted_d) if sorted_d else 0
|
|
148
|
-
p50 = _percentile(sorted_d, 50)
|
|
149
|
-
p95 = _percentile(sorted_d, 95)
|
|
150
|
-
p99 = _percentile(sorted_d, 99)
|
|
151
|
-
|
|
152
|
-
type_dist = {
|
|
153
|
-
r["trace_type"]: r["cnt"]
|
|
154
|
-
for r in conn.execute(
|
|
155
|
-
f"SELECT trace_type, COUNT(*) as cnt FROM traces WHERE 1=1{time_filter} GROUP BY trace_type ORDER BY cnt DESC",
|
|
156
|
-
time_params
|
|
157
|
-
).fetchall()
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
week_ago = (now - timedelta(days=7)).isoformat()
|
|
161
|
-
hourly_filter = " AND timestamp >= ?"
|
|
162
|
-
hourly_params = [start] if start else [week_ago]
|
|
163
|
-
hourly = [
|
|
164
|
-
{"bucket": r["bucket"], "count": r["cnt"]}
|
|
165
|
-
for r in conn.execute(
|
|
166
|
-
f"""SELECT strftime('%Y-%m-%dT%H:00:00', timestamp) as bucket,
|
|
167
|
-
COUNT(*) as cnt
|
|
168
|
-
FROM traces WHERE 1=1{hourly_filter}
|
|
169
|
-
GROUP BY bucket ORDER BY bucket""",
|
|
170
|
-
hourly_params,
|
|
171
|
-
).fetchall()
|
|
172
|
-
]
|
|
173
|
-
|
|
174
|
-
errors = conn.execute(
|
|
175
|
-
f"SELECT COUNT(*) FROM traces WHERE {_json_val('error')} IS NOT NULL AND {_json_val('error')} != ''{time_filter}",
|
|
176
|
-
time_params
|
|
177
|
-
).fetchone()[0]
|
|
178
|
-
|
|
179
|
-
total_tokens = conn.execute(
|
|
180
|
-
f"SELECT COALESCE(SUM({_json_val('token_count')}), 0) FROM traces WHERE 1=1{time_filter}",
|
|
181
|
-
time_params
|
|
182
|
-
).fetchone()[0]
|
|
183
|
-
input_tokens = conn.execute(
|
|
184
|
-
f"SELECT COALESCE(SUM({_json_val('input_tokens')}), 0) FROM traces WHERE 1=1{time_filter}",
|
|
185
|
-
time_params
|
|
186
|
-
).fetchone()[0]
|
|
187
|
-
output_tokens = conn.execute(
|
|
188
|
-
f"SELECT COALESCE(SUM({_json_val('output_tokens')}), 0) FROM traces WHERE 1=1{time_filter}",
|
|
189
|
-
time_params
|
|
190
|
-
).fetchone()[0]
|
|
191
|
-
cached_tokens = conn.execute(
|
|
192
|
-
f"SELECT COALESCE(SUM({_json_val('cached_input_tokens')}), 0) FROM traces WHERE 1=1{time_filter}",
|
|
193
|
-
time_params
|
|
194
|
-
).fetchone()[0]
|
|
195
|
-
cache_hit_rate = round(cached_tokens / input_tokens * 100, 1) if input_tokens else 0
|
|
196
|
-
|
|
197
|
-
total_lines_added = conn.execute(
|
|
198
|
-
f"SELECT COALESCE(SUM({_json_val('lines_added')}), 0) FROM traces WHERE 1=1{time_filter}",
|
|
199
|
-
time_params
|
|
200
|
-
).fetchone()[0]
|
|
201
|
-
tokens_per_kloc = (
|
|
202
|
-
round(total_tokens / (total_lines_added / 1000), 2)
|
|
203
|
-
if total_lines_added else 0
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
agent_breakdown = [
|
|
207
|
-
{"agent": r["agent"], "count": r["cnt"]}
|
|
208
|
-
for r in conn.execute(
|
|
209
|
-
f"SELECT MAX({_tags_val('agent')}) as agent, COUNT(*) as cnt FROM traces WHERE {_tags_val('agent')} IS NOT NULL{time_filter} GROUP BY LOWER({_tags_val('agent')}) ORDER BY cnt DESC",
|
|
210
|
-
time_params
|
|
211
|
-
).fetchall()
|
|
212
|
-
]
|
|
213
|
-
|
|
214
|
-
model_breakdown = [
|
|
215
|
-
{
|
|
216
|
-
"model": r["model"],
|
|
217
|
-
"count": r["cnt"],
|
|
218
|
-
"total_tokens": r["tokens"],
|
|
219
|
-
"avg_duration": round(r["avg_dur"], 3) if r["avg_dur"] else 0,
|
|
220
|
-
}
|
|
221
|
-
for r in conn.execute(
|
|
222
|
-
f"""SELECT {_model_val()} as model,
|
|
223
|
-
COUNT(*) as cnt,
|
|
224
|
-
COALESCE(SUM({_json_val('token_count')}), 0) as tokens,
|
|
225
|
-
AVG({_json_val('duration_ms')}) as avg_dur
|
|
226
|
-
FROM traces
|
|
227
|
-
WHERE {_model_val()} IS NOT NULL AND {_model_val()} != ''{time_filter}
|
|
228
|
-
GROUP BY model
|
|
229
|
-
ORDER BY tokens DESC
|
|
230
|
-
LIMIT 10""",
|
|
231
|
-
time_params
|
|
232
|
-
).fetchall()
|
|
233
|
-
]
|
|
234
|
-
|
|
235
|
-
daily_cost = [
|
|
236
|
-
{
|
|
237
|
-
"day": r["day"],
|
|
238
|
-
"total_tokens": r["total_tokens"],
|
|
239
|
-
"input_tokens": r["total_input"],
|
|
240
|
-
"output_tokens": r["total_output"],
|
|
241
|
-
}
|
|
242
|
-
for r in conn.execute(
|
|
243
|
-
f"""SELECT strftime('%%Y-%%m-%%d', timestamp) as day,
|
|
244
|
-
SUM(COALESCE({_json_val('token_count')}, 0)) as total_tokens,
|
|
245
|
-
SUM(COALESCE({_json_val('input_tokens')}, 0)) as total_input,
|
|
246
|
-
SUM(COALESCE({_json_val('output_tokens')}, 0)) as total_output
|
|
247
|
-
FROM traces
|
|
248
|
-
WHERE {_json_val('token_count')} IS NOT NULL{time_filter}
|
|
249
|
-
GROUP BY day
|
|
250
|
-
ORDER BY day DESC
|
|
251
|
-
LIMIT 30""",
|
|
252
|
-
time_params
|
|
253
|
-
).fetchall()
|
|
254
|
-
]
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
"total": total,
|
|
258
|
-
"total_today": total_today,
|
|
259
|
-
"sessions": sessions,
|
|
260
|
-
"agents": agents,
|
|
261
|
-
"avg_duration": round(avg_duration, 3),
|
|
262
|
-
"p50_duration": round(p50, 3),
|
|
263
|
-
"p95_duration": round(p95, 3),
|
|
264
|
-
"p99_duration": round(p99, 3),
|
|
265
|
-
"error_count": errors,
|
|
266
|
-
"error_rate": round(errors / total * 100, 2) if total else 0,
|
|
267
|
-
"total_tokens": total_tokens,
|
|
268
|
-
"input_tokens": input_tokens,
|
|
269
|
-
"output_tokens": output_tokens,
|
|
270
|
-
"cached_tokens": cached_tokens,
|
|
271
|
-
"cache_hit_rate": cache_hit_rate,
|
|
272
|
-
"total_cost": 0,
|
|
273
|
-
"estimated_cost": True,
|
|
274
|
-
"lines_added": total_lines_added,
|
|
275
|
-
"tokens_per_kloc": tokens_per_kloc,
|
|
276
|
-
"type_distribution": type_dist,
|
|
277
|
-
"hourly": hourly,
|
|
278
|
-
"agent_breakdown": agent_breakdown,
|
|
279
|
-
"model_breakdown": model_breakdown,
|
|
280
|
-
"daily_cost": daily_cost,
|
|
281
|
-
"db_path": str(db_path),
|
|
282
|
-
}
|
|
283
|
-
finally:
|
|
284
|
-
conn.close()
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
def get_traces(
|
|
288
|
-
db_path: Path,
|
|
289
|
-
limit: int = 50,
|
|
290
|
-
offset: int = 0,
|
|
291
|
-
trace_type: str | None = None,
|
|
292
|
-
agent: str | None = None,
|
|
293
|
-
model: str | None = None,
|
|
294
|
-
status: str | None = None,
|
|
295
|
-
session_id: str | None = None,
|
|
296
|
-
search: str | None = None,
|
|
297
|
-
start: str | None = None,
|
|
298
|
-
end: str | None = None,
|
|
299
|
-
user_id: str | None = None,
|
|
300
|
-
env: str | None = None,
|
|
301
|
-
tag: str | None = None,
|
|
302
|
-
) -> dict:
|
|
303
|
-
conn = _connect(db_path)
|
|
304
|
-
if conn is None:
|
|
305
|
-
return {"traces": [], "total": 0, "limit": limit, "offset": offset}
|
|
306
|
-
try:
|
|
307
|
-
where = ["1=1"]
|
|
308
|
-
params: list[Any] = []
|
|
309
|
-
|
|
310
|
-
if trace_type:
|
|
311
|
-
where.append("trace_type = ?")
|
|
312
|
-
params.append(trace_type)
|
|
313
|
-
if agent:
|
|
314
|
-
where.append("{} = ?".format(_tags_val("agent")))
|
|
315
|
-
params.append(agent)
|
|
316
|
-
if model:
|
|
317
|
-
where.append("{} = ?".format(_json_val("model")))
|
|
318
|
-
params.append(model)
|
|
319
|
-
if status:
|
|
320
|
-
where.append("{} = ?".format(_json_val("status")))
|
|
321
|
-
params.append(status)
|
|
322
|
-
if session_id:
|
|
323
|
-
where.append("session_id = ?")
|
|
324
|
-
params.append(session_id)
|
|
325
|
-
if search:
|
|
326
|
-
where.append("function_name LIKE ?")
|
|
327
|
-
params.append(f"%{search}%")
|
|
328
|
-
if start:
|
|
329
|
-
where.append("timestamp >= ?")
|
|
330
|
-
params.append(start)
|
|
331
|
-
if end:
|
|
332
|
-
where.append("timestamp <= ?")
|
|
333
|
-
params.append(end)
|
|
334
|
-
if user_id:
|
|
335
|
-
where.append("{} = ?".format(_tags_val("user_id")))
|
|
336
|
-
params.append(user_id)
|
|
337
|
-
if env:
|
|
338
|
-
where.append("{} = ?".format(_tags_val("environment")))
|
|
339
|
-
params.append(env)
|
|
340
|
-
if tag:
|
|
341
|
-
where.append("{} LIKE ?".format(_tags_val("tags")))
|
|
342
|
-
params.append(f"%{tag}%")
|
|
343
|
-
|
|
344
|
-
where_clause = " AND ".join(where)
|
|
345
|
-
|
|
346
|
-
# Count total matching
|
|
347
|
-
count_row = conn.execute(
|
|
348
|
-
f"SELECT COUNT(*) FROM traces WHERE {where_clause}", params
|
|
349
|
-
).fetchone()[0]
|
|
350
|
-
|
|
351
|
-
# Fetch rows
|
|
352
|
-
rows = conn.execute(
|
|
353
|
-
f"SELECT * FROM traces WHERE {where_clause} ORDER BY timestamp DESC LIMIT ? OFFSET ?",
|
|
354
|
-
[*params, limit, offset],
|
|
355
|
-
).fetchall()
|
|
356
|
-
|
|
357
|
-
traces = [_parse_row(r) for r in rows]
|
|
358
|
-
return {"traces": traces, "total": count_row, "limit": limit, "offset": offset}
|
|
359
|
-
finally:
|
|
360
|
-
conn.close()
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
def get_sessions(db_path: Path, limit: int = 100, offset: int = 0) -> dict:
|
|
364
|
-
conn = _connect(db_path)
|
|
365
|
-
if conn is None:
|
|
366
|
-
return {"sessions": [], "total": 0, "limit": limit, "offset": offset}
|
|
367
|
-
try:
|
|
368
|
-
count_row = conn.execute(
|
|
369
|
-
"SELECT COUNT(DISTINCT session_id) FROM traces"
|
|
370
|
-
).fetchone()[0]
|
|
371
|
-
|
|
372
|
-
rows = conn.execute(
|
|
373
|
-
f"""SELECT session_id,
|
|
374
|
-
COUNT(*) as span_count,
|
|
375
|
-
MIN(timestamp) as first_ts,
|
|
376
|
-
MAX(timestamp) as last_ts,
|
|
377
|
-
COUNT(DISTINCT {_tags_val('agent')}) as agent_count,
|
|
378
|
-
COUNT(DISTINCT {_json_val('model')}) as model_count,
|
|
379
|
-
MAX({_json_val('error')}) as last_error,
|
|
380
|
-
SUM(CASE WHEN {_json_val('status')} IN ('error','failed') THEN 1 ELSE 0 END) as error_spans,
|
|
381
|
-
SUM(COALESCE({_json_val('token_count')}, 0)) as total_tokens,
|
|
382
|
-
SUM(COALESCE({_json_val('lines_added')}, 0)) as lines_added
|
|
383
|
-
FROM traces
|
|
384
|
-
GROUP BY session_id
|
|
385
|
-
ORDER BY last_ts DESC
|
|
386
|
-
LIMIT ? OFFSET ?""",
|
|
387
|
-
(limit, offset),
|
|
388
|
-
).fetchall()
|
|
389
|
-
|
|
390
|
-
sessions_list = []
|
|
391
|
-
for r in rows:
|
|
392
|
-
d = dict(r)
|
|
393
|
-
agents = conn.execute(
|
|
394
|
-
"SELECT DISTINCT {} FROM traces WHERE session_id = ? AND {} IS NOT NULL".format(
|
|
395
|
-
_tags_val("agent"), _tags_val("agent")
|
|
396
|
-
),
|
|
397
|
-
(d["session_id"],),
|
|
398
|
-
).fetchall()
|
|
399
|
-
d["agents"] = [a[0] for a in agents if a[0]]
|
|
400
|
-
sessions_list.append(d)
|
|
401
|
-
|
|
402
|
-
return {"sessions": sessions_list, "total": count_row, "limit": limit, "offset": offset}
|
|
403
|
-
finally:
|
|
404
|
-
conn.close()
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
def get_session_detail(db_path: Path, session_id: str) -> dict | None:
|
|
408
|
-
conn = _connect(db_path)
|
|
409
|
-
if conn is None:
|
|
410
|
-
return None
|
|
411
|
-
try:
|
|
412
|
-
rows = conn.execute(
|
|
413
|
-
"SELECT * FROM traces WHERE session_id = ? ORDER BY timestamp ASC",
|
|
414
|
-
(session_id,),
|
|
415
|
-
).fetchall()
|
|
416
|
-
|
|
417
|
-
if not rows:
|
|
418
|
-
return None
|
|
419
|
-
|
|
420
|
-
spans = [_parse_row(r) for r in rows]
|
|
421
|
-
|
|
422
|
-
# Build call tree from parent_span_id
|
|
423
|
-
span_map: dict[str, dict] = {}
|
|
424
|
-
root_spans: list[dict] = []
|
|
425
|
-
orphan_spans: list[dict] = []
|
|
426
|
-
|
|
427
|
-
for s in spans:
|
|
428
|
-
s["children"] = []
|
|
429
|
-
span_id = s.get("id", "")
|
|
430
|
-
if span_id:
|
|
431
|
-
span_map[span_id] = s
|
|
432
|
-
|
|
433
|
-
# Build tree
|
|
434
|
-
subagent_parents: dict[str, dict] = {}
|
|
435
|
-
for s in spans:
|
|
436
|
-
pid = s.get("parent_span_id", "") or ""
|
|
437
|
-
if pid == "session_root" or not pid:
|
|
438
|
-
root_spans.append(s)
|
|
439
|
-
elif pid.startswith("subagent:"):
|
|
440
|
-
sa_id = pid[len("subagent:"):]
|
|
441
|
-
if sa_id not in subagent_parents:
|
|
442
|
-
subagent_parents[sa_id] = []
|
|
443
|
-
subagent_parents[sa_id].append(s)
|
|
444
|
-
else:
|
|
445
|
-
parent = span_map.get(pid)
|
|
446
|
-
if parent:
|
|
447
|
-
parent.setdefault("children", []).append(s)
|
|
448
|
-
else:
|
|
449
|
-
orphan_spans.append(s)
|
|
450
|
-
|
|
451
|
-
# Attach subagent children to their parent span.
|
|
452
|
-
# Preferred: match by explicit subagent_id (recorded on subagent_start since the fix).
|
|
453
|
-
# Fallback: pair remaining subagent children with subagent_start roots in emission order.
|
|
454
|
-
matched_ids: set[str] = set()
|
|
455
|
-
for s in root_spans:
|
|
456
|
-
s_data = s.get("data") or {}
|
|
457
|
-
if isinstance(s_data, str):
|
|
458
|
-
try:
|
|
459
|
-
s_data = json.loads(s_data)
|
|
460
|
-
except Exception:
|
|
461
|
-
s_data = {}
|
|
462
|
-
s_tags = s.get("tags") or {}
|
|
463
|
-
if isinstance(s_tags, str):
|
|
464
|
-
try:
|
|
465
|
-
s_tags = json.loads(s_tags)
|
|
466
|
-
except Exception:
|
|
467
|
-
s_tags = {}
|
|
468
|
-
sa_id = s_data.get("subagent_id") or s_tags.get("subagent_id")
|
|
469
|
-
if sa_id and sa_id in subagent_parents:
|
|
470
|
-
s.setdefault("children", []).extend(subagent_parents[sa_id])
|
|
471
|
-
matched_ids.add(sa_id)
|
|
472
|
-
|
|
473
|
-
# Sequential fallback for data without an explicit subagent_id link:
|
|
474
|
-
# subagent_start spans carry agent_type and appear in the same order as their children.
|
|
475
|
-
if subagent_parents:
|
|
476
|
-
subagent_roots = [
|
|
477
|
-
s for s in root_spans
|
|
478
|
-
if not (s.get("data") or {}).get("children") and (
|
|
479
|
-
s.get("function") == "subagent_start"
|
|
480
|
-
or (s.get("data") or {}).get("agent_type")
|
|
481
|
-
)
|
|
482
|
-
]
|
|
483
|
-
remaining = [sid for sid in subagent_parents if sid not in matched_ids]
|
|
484
|
-
for i, sa_id in enumerate(remaining):
|
|
485
|
-
if i < len(subagent_roots):
|
|
486
|
-
subagent_roots[i].setdefault("children", []).extend(subagent_parents[sa_id])
|
|
487
|
-
|
|
488
|
-
# Never drop data: attach any still-orphaned spans to the root level.
|
|
489
|
-
if orphan_spans:
|
|
490
|
-
root_spans.extend(orphan_spans)
|
|
491
|
-
|
|
492
|
-
stats = _compute_session_stats(spans)
|
|
493
|
-
|
|
494
|
-
return {"session_id": session_id, "spans": spans, "tree": root_spans, "stats": stats}
|
|
495
|
-
finally:
|
|
496
|
-
conn.close()
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
def _matches_subagent(span: dict, subagent_id: str, _children: list) -> bool:
|
|
500
|
-
tags = span.get("tags") or {}
|
|
501
|
-
data = span.get("data") or {}
|
|
502
|
-
# Check various places where subagent_id could be stored
|
|
503
|
-
if isinstance(tags, dict) and tags.get("subagent_id") == subagent_id:
|
|
504
|
-
return True
|
|
505
|
-
if isinstance(data, dict) and data.get("subagent_id") == subagent_id:
|
|
506
|
-
return True
|
|
507
|
-
if subagent_id in (span.get("agent_type") or ""):
|
|
508
|
-
return True
|
|
509
|
-
return False
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
def _compute_session_stats(spans: list[dict]) -> dict:
|
|
513
|
-
if not spans:
|
|
514
|
-
return {}
|
|
515
|
-
|
|
516
|
-
first = spans[0]
|
|
517
|
-
last = spans[-1]
|
|
518
|
-
total_dur = 0
|
|
519
|
-
total_tokens = 0
|
|
520
|
-
total_lines = 0
|
|
521
|
-
errors = []
|
|
522
|
-
agents = set()
|
|
523
|
-
models = set()
|
|
524
|
-
tool_calls = 0
|
|
525
|
-
tools: dict[str, int] = {}
|
|
526
|
-
|
|
527
|
-
for s in spans:
|
|
528
|
-
d = s.get("data") or {}
|
|
529
|
-
if isinstance(d, str):
|
|
530
|
-
try:
|
|
531
|
-
d = json.loads(d)
|
|
532
|
-
except Exception:
|
|
533
|
-
d = {}
|
|
534
|
-
tags = s.get("tags") or {}
|
|
535
|
-
if isinstance(tags, str):
|
|
536
|
-
try:
|
|
537
|
-
tags = json.loads(tags)
|
|
538
|
-
except Exception:
|
|
539
|
-
tags = {}
|
|
540
|
-
|
|
541
|
-
dur = float(d.get("duration_ms") or s.get("duration_ms") or 0)
|
|
542
|
-
total_dur += dur
|
|
543
|
-
|
|
544
|
-
tok = int(d.get("token_count") or s.get("token_count") or 0)
|
|
545
|
-
total_tokens += tok
|
|
546
|
-
|
|
547
|
-
loc = int(d.get("lines_added") or s.get("lines_added") or 0)
|
|
548
|
-
total_lines += loc
|
|
549
|
-
|
|
550
|
-
if isinstance(tags, dict) and tags.get("agent"):
|
|
551
|
-
agents.add(tags["agent"])
|
|
552
|
-
|
|
553
|
-
model = d.get("model") or d.get("kwargs", {}).get("model") or s.get("model")
|
|
554
|
-
if model:
|
|
555
|
-
models.add(model)
|
|
556
|
-
|
|
557
|
-
if s.get("function") == "tool_call":
|
|
558
|
-
tool_calls += 1
|
|
559
|
-
tname = d.get("tool_name") or s.get("tool_name", "")
|
|
560
|
-
if tname:
|
|
561
|
-
tools[tname] = tools.get(tname, 0) + 1
|
|
562
|
-
|
|
563
|
-
err = d.get("error") or s.get("error")
|
|
564
|
-
if err:
|
|
565
|
-
errors.append({"span_id": s.get("id", ""), "function": s.get("function", ""), "error": err})
|
|
566
|
-
|
|
567
|
-
tokens_per_kloc = round(total_tokens / (total_lines / 1000), 2) if total_lines else 0
|
|
568
|
-
return {
|
|
569
|
-
"first_ts": first.get("timestamp"),
|
|
570
|
-
"last_ts": last.get("timestamp"),
|
|
571
|
-
"duration_ms": total_dur,
|
|
572
|
-
"total_tokens": total_tokens,
|
|
573
|
-
"lines_added": total_lines,
|
|
574
|
-
"tokens_per_kloc": tokens_per_kloc,
|
|
575
|
-
"agents": list(agents),
|
|
576
|
-
"models": list(models),
|
|
577
|
-
"tool_calls": tool_calls,
|
|
578
|
-
"tools": tools,
|
|
579
|
-
"errors": errors,
|
|
580
|
-
"error_count": len(errors),
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
def get_agents(db_path: Path) -> list[dict]:
|
|
585
|
-
conn = _connect(db_path)
|
|
586
|
-
if conn is None:
|
|
587
|
-
return []
|
|
588
|
-
try:
|
|
589
|
-
return [
|
|
590
|
-
{
|
|
591
|
-
"agent": r["agent"],
|
|
592
|
-
"span_count": r["span_count"],
|
|
593
|
-
"session_count": r["session_count"],
|
|
594
|
-
"avg_duration": r["avg_dur"] if r["avg_dur"] else 0,
|
|
595
|
-
"error_count": r["error_count"],
|
|
596
|
-
}
|
|
597
|
-
for r in conn.execute(
|
|
598
|
-
f"""SELECT {_tags_val('agent')} as agent,
|
|
599
|
-
COUNT(*) as span_count,
|
|
600
|
-
COUNT(DISTINCT session_id) as session_count,
|
|
601
|
-
AVG({_json_val('duration_ms')}) as avg_dur,
|
|
602
|
-
SUM(CASE WHEN {_json_val('status')} IN ('error','failed') OR ({_json_val('error')} IS NOT NULL AND {_json_val('error')} != '') THEN 1 ELSE 0 END) as error_count
|
|
603
|
-
FROM traces
|
|
604
|
-
WHERE {_tags_val('agent')} IS NOT NULL
|
|
605
|
-
GROUP BY agent
|
|
606
|
-
ORDER BY span_count DESC"""
|
|
607
|
-
).fetchall()
|
|
608
|
-
]
|
|
609
|
-
finally:
|
|
610
|
-
conn.close()
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
def get_user_stats(db_path: Path) -> list[dict]:
|
|
614
|
-
conn = _connect(db_path)
|
|
615
|
-
if conn is None:
|
|
616
|
-
return []
|
|
617
|
-
try:
|
|
618
|
-
return [
|
|
619
|
-
{
|
|
620
|
-
"user_id": r["user_id"],
|
|
621
|
-
"trace_count": r["trace_count"],
|
|
622
|
-
"session_count": r["session_count"],
|
|
623
|
-
"total_tokens": r["total_tokens"],
|
|
624
|
-
"total_cost": r["total_cost"],
|
|
625
|
-
}
|
|
626
|
-
for r in conn.execute(
|
|
627
|
-
f"""SELECT {_tags_val('user_id')} as user_id,
|
|
628
|
-
COUNT(*) as trace_count,
|
|
629
|
-
COUNT(DISTINCT session_id) as session_count,
|
|
630
|
-
COALESCE(SUM({_json_val('token_count')}), 0) as total_tokens,
|
|
631
|
-
0 as total_cost
|
|
632
|
-
FROM traces
|
|
633
|
-
WHERE {_tags_val('user_id')} IS NOT NULL AND {_tags_val('user_id')} != ''
|
|
634
|
-
GROUP BY user_id
|
|
635
|
-
ORDER BY trace_count DESC
|
|
636
|
-
LIMIT 100"""
|
|
637
|
-
).fetchall()
|
|
638
|
-
]
|
|
639
|
-
finally:
|
|
640
|
-
conn.close()
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
def get_tag_stats(db_path: Path) -> list[dict]:
|
|
644
|
-
conn = _connect(db_path)
|
|
645
|
-
if conn is None:
|
|
646
|
-
return []
|
|
647
|
-
try:
|
|
648
|
-
tags_data = conn.execute(
|
|
649
|
-
f"SELECT tags FROM traces WHERE tags IS NOT NULL"
|
|
650
|
-
).fetchall()
|
|
651
|
-
tag_counts: dict[str, int] = {}
|
|
652
|
-
for row in tags_data:
|
|
653
|
-
try:
|
|
654
|
-
tags = json.loads(row[0]) if isinstance(row[0], str) else row[0]
|
|
655
|
-
if isinstance(tags, dict):
|
|
656
|
-
for k, v in tags.items():
|
|
657
|
-
key = str(k)
|
|
658
|
-
val = str(v) if v is not None else ""
|
|
659
|
-
tag_key = f"{key}={val}"
|
|
660
|
-
tag_counts[tag_key] = tag_counts.get(tag_key, 0) + 1
|
|
661
|
-
except:
|
|
662
|
-
pass
|
|
663
|
-
return sorted(
|
|
664
|
-
[{"tag": k, "count": v} for k, v in tag_counts.items()],
|
|
665
|
-
key=lambda x: x["count"],
|
|
666
|
-
reverse=True
|
|
667
|
-
)[:50]
|
|
668
|
-
finally:
|
|
669
|
-
conn.close()
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
def get_env_stats(db_path: Path) -> dict:
|
|
673
|
-
conn = _connect(db_path)
|
|
674
|
-
if conn is None:
|
|
675
|
-
return {"environments": [], "current": None}
|
|
676
|
-
try:
|
|
677
|
-
envs = [
|
|
678
|
-
{"environment": r["env"], "count": r["cnt"], "error_rate": r["error_rate"]}
|
|
679
|
-
for r in conn.execute(
|
|
680
|
-
f"""SELECT {_tags_val('environment')} as env,
|
|
681
|
-
COUNT(*) as cnt,
|
|
682
|
-
SUM(CASE WHEN {_json_val('error')} IS NOT NULL AND {_json_val('error')} != '' THEN 1 ELSE 0 END) * 100.0 / COUNT(*) as error_rate
|
|
683
|
-
FROM traces
|
|
684
|
-
WHERE {_tags_val('environment')} IS NOT NULL
|
|
685
|
-
GROUP BY env
|
|
686
|
-
ORDER BY cnt DESC"""
|
|
687
|
-
).fetchall()
|
|
688
|
-
]
|
|
689
|
-
return {"environments": envs}
|
|
690
|
-
finally:
|
|
691
|
-
conn.close()
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
def get_scatter_data(db_path: Path, limit: int = 500) -> list[dict]:
|
|
695
|
-
conn = _connect(db_path)
|
|
696
|
-
if conn is None:
|
|
697
|
-
return []
|
|
698
|
-
try:
|
|
699
|
-
rows = conn.execute(
|
|
700
|
-
f"""SELECT
|
|
701
|
-
{_json_val('duration_ms')} as duration_ms,
|
|
702
|
-
{_json_val('token_count')} as token_count,
|
|
703
|
-
{_json_val('model')} as model,
|
|
704
|
-
{_json_val('status')} as status,
|
|
705
|
-
timestamp
|
|
706
|
-
FROM traces
|
|
707
|
-
WHERE {_json_val('duration_ms')} IS NOT NULL
|
|
708
|
-
AND {_json_val('token_count')} IS NOT NULL
|
|
709
|
-
AND {_json_val('model')} IS NOT NULL
|
|
710
|
-
ORDER BY timestamp DESC
|
|
711
|
-
LIMIT ?""",
|
|
712
|
-
(limit,)
|
|
713
|
-
).fetchall()
|
|
714
|
-
return [
|
|
715
|
-
{
|
|
716
|
-
"x": float(r["duration_ms"] or 0),
|
|
717
|
-
"y": int(r["token_count"] or 0),
|
|
718
|
-
"model": r["model"] or "unknown",
|
|
719
|
-
"status": r["status"] or "unknown",
|
|
720
|
-
"timestamp": r["timestamp"],
|
|
721
|
-
}
|
|
722
|
-
for r in rows
|
|
723
|
-
]
|
|
724
|
-
finally:
|
|
725
|
-
conn.close()
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
def get_model_stats(db_path: Path) -> list[dict]:
|
|
729
|
-
conn = _connect(db_path)
|
|
730
|
-
if conn is None:
|
|
731
|
-
return []
|
|
732
|
-
try:
|
|
733
|
-
return [
|
|
734
|
-
{
|
|
735
|
-
"model": r["model"],
|
|
736
|
-
"span_count": r["span_count"],
|
|
737
|
-
"total_tokens": r["total_tokens"],
|
|
738
|
-
"input_tokens": r["input_tokens"],
|
|
739
|
-
"output_tokens": r["output_tokens"],
|
|
740
|
-
"avg_duration": round(r["avg_dur"], 3) if r["avg_dur"] else 0,
|
|
741
|
-
"error_count": r["error_count"],
|
|
742
|
-
"error_rate": round(r["error_count"] / r["span_count"] * 100, 2) if r["span_count"] else 0,
|
|
743
|
-
"success_rate": round((r["span_count"] - r["error_count"]) / r["span_count"] * 100, 2) if r["span_count"] else 0,
|
|
744
|
-
}
|
|
745
|
-
for r in conn.execute(
|
|
746
|
-
f"""SELECT {_model_val()} as model,
|
|
747
|
-
COUNT(*) as span_count,
|
|
748
|
-
COALESCE(SUM({_json_val('token_count')}), 0) as total_tokens,
|
|
749
|
-
COALESCE(SUM({_json_val('input_tokens')}), 0) as input_tokens,
|
|
750
|
-
COALESCE(SUM({_json_val('output_tokens')}), 0) as output_tokens,
|
|
751
|
-
AVG({_json_val('duration_ms')}) as avg_dur,
|
|
752
|
-
SUM(CASE WHEN {_json_val('status')} IN ('error','failed') OR ({_json_val('error')} IS NOT NULL AND {_json_val('error')} != '') THEN 1 ELSE 0 END) as error_count
|
|
753
|
-
FROM traces
|
|
754
|
-
WHERE {_model_val()} IS NOT NULL AND {_model_val()} != ''
|
|
755
|
-
GROUP BY model
|
|
756
|
-
ORDER BY total_tokens DESC"""
|
|
757
|
-
).fetchall()
|
|
758
|
-
]
|
|
759
|
-
finally:
|
|
760
|
-
conn.close()
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
def get_tool_stats(db_path: Path) -> list[dict]:
|
|
764
|
-
conn = _connect(db_path)
|
|
765
|
-
if conn is None:
|
|
766
|
-
return []
|
|
767
|
-
try:
|
|
768
|
-
return [
|
|
769
|
-
{
|
|
770
|
-
"tool": r["tool"],
|
|
771
|
-
"call_count": r["call_count"],
|
|
772
|
-
"avg_duration": r["avg_dur"] if r["avg_dur"] else 0,
|
|
773
|
-
"error_count": r["error_count"],
|
|
774
|
-
}
|
|
775
|
-
for r in conn.execute(
|
|
776
|
-
f"""SELECT {_json_val('tool_name')} as tool,
|
|
777
|
-
COUNT(*) as call_count,
|
|
778
|
-
AVG({_json_val('duration_ms')}) as avg_dur,
|
|
779
|
-
SUM(CASE WHEN {_json_val('status')} IN ('error','failed') THEN 1 ELSE 0 END) as error_count
|
|
780
|
-
FROM traces
|
|
781
|
-
WHERE {_json_val('tool_name')} IS NOT NULL AND {_json_val('tool_name')} != ''
|
|
782
|
-
GROUP BY tool
|
|
783
|
-
ORDER BY call_count DESC"""
|
|
784
|
-
).fetchall()
|
|
785
|
-
]
|
|
786
|
-
finally:
|
|
787
|
-
conn.close()
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
def get_error_stats(db_path: Path) -> list[dict]:
|
|
791
|
-
conn = _connect(db_path)
|
|
792
|
-
if conn is None:
|
|
793
|
-
return []
|
|
794
|
-
try:
|
|
795
|
-
return [
|
|
796
|
-
{
|
|
797
|
-
"error": r["error"],
|
|
798
|
-
"count": r["cnt"],
|
|
799
|
-
"latest": r["latest"],
|
|
800
|
-
"latest_session": r["latest_session"],
|
|
801
|
-
}
|
|
802
|
-
for r in conn.execute(
|
|
803
|
-
f"""SELECT {_json_val('error')} as error,
|
|
804
|
-
COUNT(*) as cnt,
|
|
805
|
-
MAX(timestamp) as latest,
|
|
806
|
-
(SELECT session_id FROM traces WHERE {_json_val('error')} IS NOT NULL AND {_json_val('error')} != '' ORDER BY timestamp DESC LIMIT 1) as latest_session
|
|
807
|
-
FROM traces
|
|
808
|
-
WHERE {_json_val('error')} IS NOT NULL AND {_json_val('error')} != ''
|
|
809
|
-
GROUP BY error
|
|
810
|
-
ORDER BY cnt DESC"""
|
|
811
|
-
).fetchall()
|
|
812
|
-
]
|
|
813
|
-
finally:
|
|
814
|
-
conn.close()
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
def get_latency_stats(db_path: Path) -> dict:
|
|
818
|
-
conn = _connect(db_path)
|
|
819
|
-
if conn is None:
|
|
820
|
-
return {"p50": 0, "p95": 0, "p99": 0, "histogram": []}
|
|
821
|
-
try:
|
|
822
|
-
durations = sorted([
|
|
823
|
-
float(r[0])
|
|
824
|
-
for r in conn.execute(
|
|
825
|
-
"SELECT {} FROM traces WHERE {} IS NOT NULL AND {} > 0".format(
|
|
826
|
-
_json_val("duration_ms"), _json_val("duration_ms"), _json_val("duration_ms")
|
|
827
|
-
)
|
|
828
|
-
).fetchall()
|
|
829
|
-
if r[0] is not None
|
|
830
|
-
])
|
|
831
|
-
|
|
832
|
-
if not durations:
|
|
833
|
-
return {"p50": 0, "p95": 0, "p99": 0, "histogram": []}
|
|
834
|
-
|
|
835
|
-
p50 = _percentile(durations, 50)
|
|
836
|
-
p95 = _percentile(durations, 95)
|
|
837
|
-
p99 = _percentile(durations, 99)
|
|
838
|
-
|
|
839
|
-
max_dur = max(durations)
|
|
840
|
-
bucket_count = 20
|
|
841
|
-
bucket_size = max_dur / bucket_count
|
|
842
|
-
histogram = [0] * bucket_count
|
|
843
|
-
for d in durations:
|
|
844
|
-
idx = min(int(d / bucket_size), bucket_count - 1)
|
|
845
|
-
histogram[idx] += 1
|
|
846
|
-
|
|
847
|
-
buckets = [
|
|
848
|
-
{"range": f"{round(i * bucket_size, 2)}-{round((i + 1) * bucket_size, 2)}", "count": histogram[i]}
|
|
849
|
-
for i in range(bucket_count)
|
|
850
|
-
]
|
|
851
|
-
|
|
852
|
-
return {
|
|
853
|
-
"p50": round(p50, 3),
|
|
854
|
-
"p95": round(p95, 3),
|
|
855
|
-
"p99": round(p99, 99),
|
|
856
|
-
"avg": round(sum(durations) / len(durations), 3),
|
|
857
|
-
"total": len(durations),
|
|
858
|
-
"histogram": buckets,
|
|
859
|
-
}
|
|
860
|
-
finally:
|
|
861
|
-
conn.close()
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
def get_cost_stats(db_path: Path, model_prices: dict[str, float] | None = None) -> dict:
|
|
865
|
-
conn = _connect(db_path)
|
|
866
|
-
if conn is None:
|
|
867
|
-
return {"total_tokens": 0, "total_input": 0, "total_output": 0, "daily": [], "by_model": []}
|
|
868
|
-
try:
|
|
869
|
-
# Only treat prices as real when the caller supplied a non-empty map.
|
|
870
|
-
# Otherwise we must NOT fabricate a cost (no prices => estimated=false, cost=0).
|
|
871
|
-
prices = model_prices or {}
|
|
872
|
-
has_real_prices = bool(prices)
|
|
873
|
-
|
|
874
|
-
# By day
|
|
875
|
-
daily = []
|
|
876
|
-
for r in conn.execute(
|
|
877
|
-
f"""SELECT strftime('%%Y-%%m-%%d', timestamp) as day,
|
|
878
|
-
SUM(COALESCE({_json_val('token_count')}, 0)) as total_tokens,
|
|
879
|
-
SUM(COALESCE({_json_val('input_tokens')}, 0)) as total_input,
|
|
880
|
-
SUM(COALESCE({_json_val('output_tokens')}, 0)) as total_output
|
|
881
|
-
FROM traces
|
|
882
|
-
WHERE {_json_val('token_count')} IS NOT NULL
|
|
883
|
-
GROUP BY day
|
|
884
|
-
ORDER BY day ASC"""
|
|
885
|
-
).fetchall():
|
|
886
|
-
entry = dict(r)
|
|
887
|
-
entry["cost"] = 0
|
|
888
|
-
entry["cost_details"] = {}
|
|
889
|
-
daily.append(entry)
|
|
890
|
-
|
|
891
|
-
# Total
|
|
892
|
-
total_tokens = conn.execute(
|
|
893
|
-
"SELECT COALESCE(SUM({}), 0) FROM traces".format(_json_val("token_count"))
|
|
894
|
-
).fetchone()[0]
|
|
895
|
-
total_input = conn.execute(
|
|
896
|
-
"SELECT COALESCE(SUM({}), 0) FROM traces".format(_json_val("input_tokens"))
|
|
897
|
-
).fetchone()[0]
|
|
898
|
-
total_output = conn.execute(
|
|
899
|
-
"SELECT COALESCE(SUM({}), 0) FROM traces".format(_json_val("output_tokens"))
|
|
900
|
-
).fetchone()[0]
|
|
901
|
-
|
|
902
|
-
# By model
|
|
903
|
-
by_model = [
|
|
904
|
-
{
|
|
905
|
-
"model": r["model"],
|
|
906
|
-
"tokens": r["tokens"],
|
|
907
|
-
"cost": round(r["tokens"] / 1000 * prices[r["model"]], 4) if has_real_prices else 0,
|
|
908
|
-
}
|
|
909
|
-
for r in conn.execute(
|
|
910
|
-
f"""SELECT {_json_val('model')} as model,
|
|
911
|
-
SUM(COALESCE({_json_val('token_count')}, 0)) as tokens
|
|
912
|
-
FROM traces
|
|
913
|
-
WHERE {_json_val('model')} IS NOT NULL AND {_json_val('model')} != ''
|
|
914
|
-
GROUP BY model
|
|
915
|
-
ORDER BY tokens DESC"""
|
|
916
|
-
).fetchall()
|
|
917
|
-
]
|
|
918
|
-
|
|
919
|
-
return {
|
|
920
|
-
"total_tokens": total_tokens,
|
|
921
|
-
"total_input": total_input,
|
|
922
|
-
"total_output": total_output,
|
|
923
|
-
"daily": daily,
|
|
924
|
-
"by_model": by_model,
|
|
925
|
-
"prices": prices,
|
|
926
|
-
"estimated": not has_real_prices,
|
|
927
|
-
}
|
|
928
|
-
finally:
|
|
929
|
-
conn.close()
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
def get_loc_stats(db_path: Path) -> dict:
|
|
933
|
-
"""Lines-of-code productivity metrics.
|
|
934
|
-
|
|
935
|
-
Returns total lines added (Edit/Write), total tokens, and the derived
|
|
936
|
-
"tokens per 1k lines of code" efficiency metric, both overall and broken
|
|
937
|
-
down per model.
|
|
938
|
-
"""
|
|
939
|
-
conn = _connect(db_path)
|
|
940
|
-
if conn is None:
|
|
941
|
-
return {
|
|
942
|
-
"total_lines_added": 0,
|
|
943
|
-
"total_tokens": 0,
|
|
944
|
-
"tokens_per_kloc": 0,
|
|
945
|
-
"by_model": [],
|
|
946
|
-
}
|
|
947
|
-
try:
|
|
948
|
-
total_lines = conn.execute(
|
|
949
|
-
"SELECT COALESCE(SUM({}), 0) FROM traces".format(_json_val("lines_added"))
|
|
950
|
-
).fetchone()[0]
|
|
951
|
-
total_tokens = conn.execute(
|
|
952
|
-
"SELECT COALESCE(SUM({}), 0) FROM traces".format(_json_val("token_count"))
|
|
953
|
-
).fetchone()[0]
|
|
954
|
-
|
|
955
|
-
by_model = [
|
|
956
|
-
{
|
|
957
|
-
"model": r["model"],
|
|
958
|
-
"lines_added": r["lines"],
|
|
959
|
-
"tokens": r["tokens"],
|
|
960
|
-
"tokens_per_kloc": (
|
|
961
|
-
round(r["tokens"] / (r["lines"] / 1000), 2) if r["lines"] else 0
|
|
962
|
-
),
|
|
963
|
-
}
|
|
964
|
-
for r in conn.execute(
|
|
965
|
-
f"""SELECT {_json_val('model')} as model,
|
|
966
|
-
COALESCE(SUM({_json_val('lines_added')}), 0) as lines,
|
|
967
|
-
COALESCE(SUM({_json_val('token_count')}), 0) as tokens
|
|
968
|
-
FROM traces
|
|
969
|
-
WHERE {_json_val('model')} IS NOT NULL AND {_json_val('model')} != ''
|
|
970
|
-
GROUP BY model
|
|
971
|
-
ORDER BY tokens DESC"""
|
|
972
|
-
).fetchall()
|
|
973
|
-
]
|
|
974
|
-
|
|
975
|
-
return {
|
|
976
|
-
"total_lines_added": total_lines,
|
|
977
|
-
"total_tokens": total_tokens,
|
|
978
|
-
"tokens_per_kloc": (
|
|
979
|
-
round(total_tokens / (total_lines / 1000), 2) if total_lines else 0
|
|
980
|
-
),
|
|
981
|
-
"by_model": by_model,
|
|
982
|
-
}
|
|
983
|
-
finally:
|
|
984
|
-
conn.close()
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
def export_traces(
|
|
988
|
-
db_path: Path,
|
|
989
|
-
fmt: str = "json",
|
|
990
|
-
trace_type: str | None = None,
|
|
991
|
-
agent: str | None = None,
|
|
992
|
-
session_id: str | None = None,
|
|
993
|
-
limit: int = 500,
|
|
994
|
-
) -> Any:
|
|
995
|
-
conn = _connect(db_path)
|
|
996
|
-
if conn is None:
|
|
997
|
-
return [] if fmt == "json" else ""
|
|
998
|
-
conn.close()
|
|
999
|
-
result = get_traces(
|
|
1000
|
-
db_path=db_path,
|
|
1001
|
-
limit=limit,
|
|
1002
|
-
offset=0,
|
|
1003
|
-
trace_type=trace_type,
|
|
1004
|
-
agent=agent,
|
|
1005
|
-
session_id=session_id,
|
|
1006
|
-
)
|
|
1007
|
-
if fmt == "json":
|
|
1008
|
-
return result["traces"]
|
|
1009
|
-
elif fmt == "csv":
|
|
1010
|
-
import io
|
|
1011
|
-
|
|
1012
|
-
output = io.StringIO()
|
|
1013
|
-
traces = result["traces"]
|
|
1014
|
-
if traces:
|
|
1015
|
-
keys = ["id", "session_id", "timestamp", "type", "function", "agent", "model", "duration_ms"]
|
|
1016
|
-
output.write(",".join(keys) + "\n")
|
|
1017
|
-
for t in traces:
|
|
1018
|
-
tags = t.get("tags") or {}
|
|
1019
|
-
data = t.get("data") or {}
|
|
1020
|
-
row = [
|
|
1021
|
-
str(t.get("id", "")),
|
|
1022
|
-
str(t.get("session_id", "")),
|
|
1023
|
-
str(t.get("timestamp", "")),
|
|
1024
|
-
str(t.get("type", "")),
|
|
1025
|
-
str(t.get("function", "")),
|
|
1026
|
-
str((tags if isinstance(tags, dict) else {}).get("agent", "")),
|
|
1027
|
-
str(data.get("model", "")),
|
|
1028
|
-
str(data.get("duration_ms", "")),
|
|
1029
|
-
]
|
|
1030
|
-
output.write(",".join(row) + "\n")
|
|
1031
|
-
return output.getvalue()
|
|
1032
|
-
return result["traces"]
|