@scemoon/cdh 1.0.8 → 1.0.9-beta.2
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/ai-dlc-skill/SKILL.md +106 -0
- package/ai-dlc-skill/architecture/project-structure.md +78 -0
- package/ai-dlc-skill/brownfield/README.md +36 -0
- package/ai-dlc-skill/brownfield/entry.md +45 -0
- package/ai-dlc-skill/brownfield/generate-context.sh +64 -0
- package/ai-dlc-skill/brownfield/scripts/deps.sh +27 -0
- package/ai-dlc-skill/brownfield/scripts/discover.sh +34 -0
- package/ai-dlc-skill/brownfield/scripts/extract-api.sh +45 -0
- package/ai-dlc-skill/components/backend.md +47 -0
- package/ai-dlc-skill/components/desktop.md +63 -0
- package/ai-dlc-skill/components/mya.md +219 -0
- package/ai-dlc-skill/components/native.md +73 -0
- package/ai-dlc-skill/components/tta.md +235 -0
- package/ai-dlc-skill/components/web.md +77 -0
- package/ai-dlc-skill/components/wxa.md +219 -0
- package/ai-dlc-skill/contracts/README.md +25 -0
- package/ai-dlc-skill/core/adaptive-flow.md +107 -0
- package/ai-dlc-skill/core/security.md +29 -0
- package/ai-dlc-skill/core/task-registry.md +153 -0
- package/ai-dlc-skill/cross-tool/README.md +20 -0
- package/ai-dlc-skill/cross-tool/cline/export.sh +38 -0
- package/ai-dlc-skill/cross-tool/copilot/export.sh +41 -0
- package/ai-dlc-skill/cross-tool/cursor/export.sh +53 -0
- package/ai-dlc-skill/cross-tool/onecode/export.sh +27 -0
- package/ai-dlc-skill/cross-tool/opencode/export.sh +38 -0
- package/ai-dlc-skill/phases/debug/entry.md +48 -0
- package/ai-dlc-skill/phases/debug/lifecycle.md +284 -0
- package/ai-dlc-skill/phases/deliver/entry.md +35 -0
- package/ai-dlc-skill/phases/deliver/lifecycle.md +185 -0
- package/ai-dlc-skill/phases/deliver/prompt.md +54 -0
- package/ai-dlc-skill/phases/deliver/rules.md +61 -0
- package/ai-dlc-skill/phases/plan/design_system/accessibility.md +268 -0
- package/ai-dlc-skill/phases/plan/design_system/atomic_design.md +341 -0
- package/ai-dlc-skill/phases/plan/design_system/component_spec.md +398 -0
- package/ai-dlc-skill/phases/plan/design_system/design_tokens.md +190 -0
- package/ai-dlc-skill/phases/plan/design_system/iconography.md +299 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/desktop.md +318 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/mya.md +354 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/native.md +328 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/tta.md +394 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/web.md +287 -0
- package/ai-dlc-skill/phases/plan/design_system/platform_ui/wxa.md +374 -0
- package/ai-dlc-skill/phases/plan/design_system/theme_system.md +318 -0
- package/ai-dlc-skill/phases/plan/entry.md +33 -0
- package/ai-dlc-skill/phases/plan/lifecycle.md +260 -0
- package/ai-dlc-skill/phases/plan/prompt.md +75 -0
- package/ai-dlc-skill/phases/plan/rules.md +60 -0
- package/ai-dlc-skill/phases/understand/entry.md +36 -0
- package/ai-dlc-skill/phases/understand/lifecycle.md +184 -0
- package/ai-dlc-skill/phases/understand/prompt.md +58 -0
- package/ai-dlc-skill/phases/understand/rules.md +49 -0
- package/ai-dlc-skill/phases/verify/config/base_url.md +65 -0
- package/ai-dlc-skill/phases/verify/entry.md +59 -0
- package/ai-dlc-skill/phases/verify/gates/browser_e2e.md +96 -0
- package/ai-dlc-skill/phases/verify/lifecycle.md +217 -0
- package/ai-dlc-skill/phases/verify/prompt.md +73 -0
- package/ai-dlc-skill/phases/verify/rules.md +91 -0
- package/ai-dlc-skill/phases/verify/runners/playwright_local.md +103 -0
- package/ai-dlc-skill/practices/bdd.md +119 -0
- package/ai-dlc-skill/practices/sdd.md +84 -0
- package/ai-dlc-skill/practices/tdd.md +128 -0
- package/ai-dlc-skill/providers/README.md +114 -0
- package/ai-dlc-skill/providers/aliyun/SKILL.md +204 -0
- package/ai-dlc-skill/providers/aliyun/api/rest-api.md +214 -0
- package/ai-dlc-skill/providers/aliyun/api/sdk.md +307 -0
- package/ai-dlc-skill/providers/aliyun/best-practices/database-design.md +363 -0
- package/ai-dlc-skill/providers/aliyun/best-practices/function-design.md +424 -0
- package/ai-dlc-skill/providers/aliyun/best-practices/troubleshooting.md +258 -0
- package/ai-dlc-skill/providers/aliyun/cli/database.md +263 -0
- package/ai-dlc-skill/providers/aliyun/cli/functions.md +263 -0
- package/ai-dlc-skill/providers/aliyun/cli/hosting.md +226 -0
- package/ai-dlc-skill/providers/aliyun/cli/setup.md +235 -0
- package/ai-dlc-skill/providers/aliyun/cli/storage.md +315 -0
- package/ai-dlc-skill/providers/aliyun/deployment.yaml +66 -0
- package/ai-dlc-skill/providers/aliyun/integration/ci-cd.md +288 -0
- package/ai-dlc-skill/providers/aliyun/preview.yaml +84 -0
- package/ai-dlc-skill/providers/aliyun/provider.yaml +160 -0
- package/ai-dlc-skill/providers/aliyun/security/authentication.md +254 -0
- package/ai-dlc-skill/providers/aliyun/services/cdn-hosting.md +220 -0
- package/ai-dlc-skill/providers/aliyun/services/database.md +319 -0
- package/ai-dlc-skill/providers/aliyun/services/function-compute.md +273 -0
- package/ai-dlc-skill/providers/aliyun/services/overview.md +163 -0
- package/ai-dlc-skill/providers/aliyun/services/serverless-app-engine.md +266 -0
- package/ai-dlc-skill/providers/aliyun/services/storage.md +269 -0
- package/ai-dlc-skill/providers/tcb/SKILL.md +208 -0
- package/ai-dlc-skill/providers/tcb/api/rest-api.md +338 -0
- package/ai-dlc-skill/providers/tcb/api/sdk.md +288 -0
- package/ai-dlc-skill/providers/tcb/best-practices/database-design.md +452 -0
- package/ai-dlc-skill/providers/tcb/best-practices/function-design.md +502 -0
- package/ai-dlc-skill/providers/tcb/best-practices/troubleshooting.md +462 -0
- package/ai-dlc-skill/providers/tcb/cli/cls.md +133 -0
- package/ai-dlc-skill/providers/tcb/cli/database.md +230 -0
- package/ai-dlc-skill/providers/tcb/cli/env.md +207 -0
- package/ai-dlc-skill/providers/tcb/cli/functions.md +276 -0
- package/ai-dlc-skill/providers/tcb/cli/hosting.md +219 -0
- package/ai-dlc-skill/providers/tcb/cli/setup.md +218 -0
- package/ai-dlc-skill/providers/tcb/cli/storage.md +233 -0
- package/ai-dlc-skill/providers/tcb/deployment.yaml +111 -0
- package/ai-dlc-skill/providers/tcb/integration/ci-cd.md +309 -0
- package/ai-dlc-skill/providers/tcb/integration/mcp-server.md +371 -0
- package/ai-dlc-skill/providers/tcb/preview.yaml +83 -0
- package/ai-dlc-skill/providers/tcb/provider.yaml +172 -0
- package/ai-dlc-skill/providers/tcb/security/authentication.md +241 -0
- package/ai-dlc-skill/providers/tcb/services/cloud-database.md +299 -0
- package/ai-dlc-skill/providers/tcb/services/cloud-functions.md +265 -0
- package/ai-dlc-skill/providers/tcb/services/cloud-hosting.md +264 -0
- package/ai-dlc-skill/providers/tcb/services/cloud-run.md +285 -0
- package/ai-dlc-skill/providers/tcb/services/cloud-storage.md +245 -0
- package/ai-dlc-skill/providers/tcb/services/overview.md +174 -0
- package/ai-dlc-skill/pybdd/README.md +41 -0
- package/ai-dlc-skill/pybdd/conftest.py +17 -0
- package/ai-dlc-skill/pybdd/example/auth/login.feature +32 -0
- package/ai-dlc-skill/pybdd/pytest.ini +5 -0
- package/ai-dlc-skill/pybdd/steps/.gitkeep +1 -0
- package/ai-dlc-skill/pybdd/steps/test_example_steps.py +65 -0
- package/ai-dlc-skill/requirements.md +140 -0
- package/ai-dlc-skill/skill.yaml +135 -0
- package/ai-dlc-skill/templates/brownfield/context.md +78 -0
- package/ai-dlc-skill/templates/integration/CHANGELOG.md +41 -0
- package/ai-dlc-skill/templates/integration/asyncapi.yaml +43 -0
- package/ai-dlc-skill/templates/integration/contract-diff.md +63 -0
- package/ai-dlc-skill/templates/integration/contract-spec.md +49 -0
- package/ai-dlc-skill/templates/integration/openapi.yaml +18 -0
- package/ai-dlc-skill/templates/integration/runtime-contract.yaml +36 -0
- package/ai-dlc-skill/templates/plan/design.md +49 -0
- package/ai-dlc-skill/templates/plan/task-list.md +32 -0
- package/ai-dlc-skill/templates/project/README.md +126 -0
- package/ai-dlc-skill/templates/project/template.md +119 -0
- package/ai-dlc-skill/templates/understand/feature.feature +30 -0
- package/ai-dlc-skill/templates/understand/intent.md +29 -0
- package/ai-dlc-skill/templates/understand/spec-delta.md +47 -0
- package/ai-dlc-skill/templates/verify/test-unit.py +27 -0
- package/ai-dlc-skill/walkthrough/collect.sh +50 -0
- package/ai-dlc-skill/walkthrough/template.md +54 -0
- package/cdh/__init__.py +0 -0
- package/cdh/__main__.py +4 -0
- 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 +258 -0
- package/cdh/cli.py +3000 -0
- package/cdh/cli_logging.py +45 -0
- package/cdh/config.py +28 -0
- package/cdh/event_loop/__init__.py +7 -0
- package/cdh/event_loop/bus.py +123 -0
- package/cdh/event_loop/events.py +25 -0
- package/cdh/event_loop/runner.py +28 -0
- package/cdh/event_loop/scheduler.py +158 -0
- package/cdh/generators/__init__.py +35 -0
- package/cdh/generators/_runtime.py +176 -0
- package/cdh/generators/ada/MANIFEST.toml +14 -0
- package/cdh/generators/ada/template.ads.tmpl +7 -0
- package/cdh/generators/bash/MANIFEST.toml +14 -0
- package/cdh/generators/bash/template.sh.tmpl +16 -0
- package/cdh/generators/builtin_index.json +590 -0
- package/cdh/generators/c/MANIFEST.toml +14 -0
- package/cdh/generators/c/template.h.tmpl +20 -0
- package/cdh/generators/cli.py +379 -0
- package/cdh/generators/clojure/MANIFEST.toml +14 -0
- package/cdh/generators/clojure/template.clj.tmpl +13 -0
- package/cdh/generators/cobol/MANIFEST.toml +14 -0
- package/cdh/generators/cobol/template.cbl.tmpl +14 -0
- package/cdh/generators/cpp/MANIFEST.toml +14 -0
- package/cdh/generators/cpp/template.hpp.tmpl +32 -0
- package/cdh/generators/crystal/MANIFEST.toml +14 -0
- package/cdh/generators/crystal/template.cr.tmpl +11 -0
- package/cdh/generators/csharp/MANIFEST.toml +23 -0
- package/cdh/generators/csharp/template.cs.tmpl +14 -0
- package/cdh/generators/cython/MANIFEST.toml +14 -0
- package/cdh/generators/cython/template.pyx.tmpl +17 -0
- package/cdh/generators/d/MANIFEST.toml +14 -0
- package/cdh/generators/d/template.d.tmpl +24 -0
- package/cdh/generators/dart/MANIFEST.toml +17 -0
- package/cdh/generators/dart/template.dart.tmpl +27 -0
- package/cdh/generators/elixir/MANIFEST.toml +17 -0
- package/cdh/generators/elixir/template.ex.tmpl +27 -0
- package/cdh/generators/elm/MANIFEST.toml +14 -0
- package/cdh/generators/elm/template.elm.tmpl +20 -0
- package/cdh/generators/erlang/MANIFEST.toml +14 -0
- package/cdh/generators/erlang/template.erl.tmpl +18 -0
- package/cdh/generators/fortran/MANIFEST.toml +14 -0
- package/cdh/generators/fortran/template.f90.tmpl +24 -0
- package/cdh/generators/fsharp/MANIFEST.toml +14 -0
- package/cdh/generators/fsharp/template.fs.tmpl +17 -0
- package/cdh/generators/go/MANIFEST.toml +18 -0
- package/cdh/generators/go/imports.go.tmpl +3 -0
- package/cdh/generators/go/template.go.tmpl +9 -0
- package/cdh/generators/graphql-schema/MANIFEST.toml +18 -0
- package/cdh/generators/graphql-schema/template.graphqls.tmpl +12 -0
- package/cdh/generators/groovy/MANIFEST.toml +14 -0
- package/cdh/generators/groovy/template.groovy.tmpl +28 -0
- package/cdh/generators/hack/MANIFEST.toml +14 -0
- package/cdh/generators/hack/template.hh.tmpl +24 -0
- package/cdh/generators/haskell/MANIFEST.toml +14 -0
- package/cdh/generators/haskell/template.hs.tmpl +20 -0
- package/cdh/generators/haxe/MANIFEST.toml +14 -0
- package/cdh/generators/haxe/template.hx.tmpl +20 -0
- package/cdh/generators/idris/MANIFEST.toml +14 -0
- package/cdh/generators/idris/template.idr.tmpl +22 -0
- package/cdh/generators/java/MANIFEST.toml +18 -0
- package/cdh/generators/java/template.java.tmpl +13 -0
- package/cdh/generators/julia/MANIFEST.toml +14 -0
- package/cdh/generators/julia/template.jl.tmpl +27 -0
- package/cdh/generators/kotlin/MANIFEST.toml +18 -0
- package/cdh/generators/kotlin/template.kt.tmpl +12 -0
- package/cdh/generators/lua/MANIFEST.toml +14 -0
- package/cdh/generators/lua/template.lua.tmpl +27 -0
- package/cdh/generators/matlab/MANIFEST.toml +14 -0
- package/cdh/generators/matlab/template.m.tmpl +26 -0
- package/cdh/generators/nim/MANIFEST.toml +14 -0
- package/cdh/generators/nim/template.nim.tmpl +12 -0
- package/cdh/generators/nix/MANIFEST.toml +14 -0
- package/cdh/generators/nix/template.nix.tmpl +8 -0
- package/cdh/generators/objective-c/MANIFEST.toml +14 -0
- package/cdh/generators/objective-c/template.m.tmpl +31 -0
- package/cdh/generators/ocaml/MANIFEST.toml +14 -0
- package/cdh/generators/ocaml/template.ml.tmpl +13 -0
- package/cdh/generators/pascal/MANIFEST.toml +14 -0
- package/cdh/generators/pascal/template.pas.tmpl +5 -0
- package/cdh/generators/perl/MANIFEST.toml +14 -0
- package/cdh/generators/perl/template.pm.tmpl +27 -0
- package/cdh/generators/php/MANIFEST.toml +17 -0
- package/cdh/generators/php/template.php.tmpl +31 -0
- package/cdh/generators/powershell/MANIFEST.toml +14 -0
- package/cdh/generators/powershell/template.ps1.tmpl +20 -0
- package/cdh/generators/protobuf/MANIFEST.toml +18 -0
- package/cdh/generators/protobuf/template.proto.tmpl +13 -0
- package/cdh/generators/python/MANIFEST.toml +18 -0
- package/cdh/generators/python/template.py.tmpl +12 -0
- package/cdh/generators/r/MANIFEST.toml +14 -0
- package/cdh/generators/r/template.R.tmpl +29 -0
- package/cdh/generators/racket/MANIFEST.toml +14 -0
- package/cdh/generators/racket/template.rkt.tmpl +15 -0
- package/cdh/generators/registry.py +211 -0
- package/cdh/generators/ruby/MANIFEST.toml +17 -0
- package/cdh/generators/ruby/template.rb.tmpl +27 -0
- package/cdh/generators/rust/MANIFEST.toml +18 -0
- package/cdh/generators/rust/template.rs.tmpl +16 -0
- package/cdh/generators/scala/MANIFEST.toml +20 -0
- package/cdh/generators/scala/template.scala.tmpl +13 -0
- package/cdh/generators/scheme/MANIFEST.toml +14 -0
- package/cdh/generators/scheme/template.scm.tmpl +16 -0
- package/cdh/generators/solidity/MANIFEST.toml +14 -0
- package/cdh/generators/solidity/template.sol.tmpl +24 -0
- package/cdh/generators/swift/MANIFEST.toml +18 -0
- package/cdh/generators/swift/template.swift.tmpl +10 -0
- package/cdh/generators/typescript/MANIFEST.toml +18 -0
- package/cdh/generators/typescript/template.ts.tmpl +7 -0
- package/cdh/generators/version.py +214 -0
- package/cdh/generators/zig/MANIFEST.toml +14 -0
- package/cdh/generators/zig/template.zig.tmpl +20 -0
- package/cdh/logging.py +314 -0
- package/cdh/optimizer/__init__.py +7 -0
- package/cdh/optimizer/loop.py +201 -0
- package/cdh/optimizer/mutation.py +85 -0
- package/cdh/optimizer/reward.py +51 -0
- package/cdh/optimizer/tracker.py +118 -0
- package/cdh/project_loader.py +1022 -0
- package/cdh/rules/patterns.yaml +132 -0
- package/cdh/rules/spectral.yaml +301 -0
- package/cdh/scaffold.py +1436 -0
- package/cdh/session_store.py +221 -0
- package/cdh/state_schema.py +127 -0
- package/cdh/tools/__init__.py +57 -0
- package/cdh/tools/cls_search.py +406 -0
- package/cdh/tools/contract_diff.py +644 -0
- package/cdh/tools/deploy_stack.py +590 -0
- package/cdh/tools/generate_shared.py +300 -0
- package/cdh/tools/iac_gen.py +224 -0
- package/cdh/tools/otel_export.py +125 -0
- package/cdh/tools/pattern_detect.py +451 -0
- package/cdh/tools/retrofit_labels.py +505 -0
- package/cdh/trace/__init__.py +101 -0
- package/cdh/trace/__pycache__/__init__.cpython-314.pyc +0 -0
- package/cdh/trace/dashboard/__init__.py +61 -0
- package/cdh/trace/dashboard/api.py +1032 -0
- package/cdh/trace/dashboard/app.html +1321 -0
- package/cdh/trace/dashboard/server.py +310 -0
- package/cdh/trace/otel_exporter.py +462 -0
- package/cdh/trace/otel_tracer.py +281 -0
- package/cdh/tui.py +1084 -0
- package/cdh/validators/__init__.py +16 -0
- 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 +144 -0
- package/cdh/validators/dag.py +179 -0
- package/cdh/validators/ears.py +452 -0
- package/cdh/validators/fr_namespace.py +143 -0
- package/cdh/validators/spectral.py +475 -0
- package/cdh/verification/__init__.py +3 -0
- package/cdh/verification/aggregation.py +53 -0
- package/cdh/verification/gates/__init__.py +5 -0
- package/cdh/verification/gates/base.py +18 -0
- package/cdh/verification/gates/lint_gate.py +37 -0
- package/cdh/verification/gates/test_gate.py +41 -0
- package/cdh/verification/loop.py +93 -0
- package/cdh/verification/policy.py +24 -0
- package/onecode/__init__.py +1 -0
- package/onecode/__main__.py +4 -0
- 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 +29 -0
- 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 +50 -0
- package/onecode/agent/agents/prompts/compaction-instructions.md +12 -0
- package/onecode/agent/agents/prompts/explore-agent.md +42 -0
- package/onecode/agent/agents/prompts/plan-agent.md +44 -0
- package/onecode/agent/agents/prompts/plan-gate-hard.md +4 -0
- package/onecode/agent/agents/prompts/plan-gate-soft.md +3 -0
- package/onecode/agent/agents/prompts/solo-agent.md +57 -0
- package/onecode/agent/agents/prompts/subagent-constraints.md +10 -0
- package/onecode/agent/agents/prompts/summary-instructions.md +7 -0
- package/onecode/agent/agents/prompts/title-instructions.md +3 -0
- package/onecode/agent/agents/prompts/tool-descriptions.md +129 -0
- package/onecode/agent/agents/types.py +786 -0
- package/onecode/agent/attachments.py +112 -0
- package/onecode/agent/cdh_loader.py +3 -0
- package/onecode/agent/checkpoint.py +285 -0
- package/onecode/agent/context.py +465 -0
- package/onecode/agent/engine.py +3547 -0
- package/onecode/agent/event_bridge.py +75 -0
- package/onecode/agent/hooks.py +86 -0
- package/onecode/agent/onecode_agent_acp.py +2993 -0
- package/onecode/agent/permissions.py +150 -0
- package/onecode/agent/permissions_store.py +73 -0
- package/onecode/agent/project_doc.py +19 -0
- package/onecode/agent/question_detect.py +230 -0
- package/onecode/agent/session.py +3 -0
- package/onecode/agent/snapshot.py +144 -0
- package/onecode/agent/tools/__init__.py +17 -0
- 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 +128 -0
- package/onecode/agent/tools/apply_patch_tool.py +138 -0
- package/onecode/agent/tools/bash_tool.py +121 -0
- package/onecode/agent/tools/communication_tools.py +154 -0
- package/onecode/agent/tools/config_tool.py +130 -0
- package/onecode/agent/tools/cron_tools.py +178 -0
- package/onecode/agent/tools/errors.py +17 -0
- package/onecode/agent/tools/file_ops.py +221 -0
- package/onecode/agent/tools/file_tools.py +225 -0
- package/onecode/agent/tools/git_tools.py +88 -0
- package/onecode/agent/tools/lsp_tools.py +404 -0
- package/onecode/agent/tools/mcp_tools.py +211 -0
- package/onecode/agent/tools/permission_handler.py +46 -0
- package/onecode/agent/tools/permissions.py +77 -0
- package/onecode/agent/tools/protocol.py +20 -0
- package/onecode/agent/tools/registry.py +210 -0
- package/onecode/agent/tools/sandbox.py +460 -0
- package/onecode/agent/tools/schema_validation.py +100 -0
- package/onecode/agent/tools/skill_tools.py +52 -0
- package/onecode/agent/tools/todo_tools.py +208 -0
- package/onecode/agent/tools/web_tools.py +530 -0
- package/onecode/agent/turn_record.py +28 -0
- package/onecode/builtin_skills/agent-browser/SKILL.md +212 -0
- package/onecode/builtin_skills/agent-browser/skill.yaml +8 -0
- package/onecode/builtin_skills/cloudbase/SKILL.md +162 -0
- package/onecode/builtin_skills/cloudbase/skill.yaml +7 -0
- package/onecode/builtin_skills/git/SKILL.md +64 -0
- package/onecode/builtin_skills/git/skill.yaml +7 -0
- package/onecode/builtin_skills/shell/SKILL.md +58 -0
- package/onecode/builtin_skills/shell/skill.yaml +8 -0
- package/onecode/builtin_skills/skill-creator/SKILL.md +106 -0
- package/onecode/builtin_skills/skill-creator/skill.yaml +8 -0
- package/onecode/cli.py +1325 -0
- package/onecode/codebase/__init__.py +69 -0
- 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 +125 -0
- package/onecode/codebase/indexer.py +154 -0
- package/onecode/codebase/retriever.py +240 -0
- package/onecode/codebase/storage.py +153 -0
- package/onecode/codebase/tools.py +59 -0
- package/onecode/commands.py +673 -0
- package/onecode/config.py +539 -0
- package/onecode/config_screen.py +486 -0
- package/onecode/cron/__init__.py +3 -0
- package/onecode/lsp/__init__.py +3 -0
- package/onecode/mcp/__init__.py +11 -0
- 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 +305 -0
- package/onecode/mcp/cloudbase.py +188 -0
- package/onecode/mcp/config.py +363 -0
- package/onecode/mcp/manager.py +603 -0
- package/onecode/mcp/oauth.py +199 -0
- package/onecode/memory/__init__.py +106 -0
- 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 +179 -0
- package/onecode/memory/pyramid.py +145 -0
- package/onecode/memory/recall.py +322 -0
- package/onecode/migrate.py +122 -0
- package/onecode/models/__init__.py +4 -0
- 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 +104 -0
- package/onecode/models/messages.py +750 -0
- package/onecode/models/ollama_manager.py +167 -0
- package/onecode/models/provider.py +730 -0
- package/onecode/models/providers/__init__.py +17 -0
- 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 +286 -0
- package/onecode/models/providers/deepseek_provider.py +221 -0
- package/onecode/models/providers/glm_provider.py +219 -0
- package/onecode/models/providers/minimax_provider.py +182 -0
- package/onecode/models/providers/minimaxi_provider.py +426 -0
- package/onecode/models/providers/ollama_provider.py +183 -0
- package/onecode/models/providers/openai_provider.py +234 -0
- package/onecode/models/registry.py +349 -0
- package/onecode/server/__init__.py +3 -0
- package/onecode/server/app.py +251 -0
- package/onecode/skills/__init__.py +11 -0
- 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 +38 -0
- package/onecode/skills/bootstrap.py +37 -0
- package/onecode/skills/create.py +56 -0
- package/onecode/skills/frontmatter.py +33 -0
- package/onecode/skills/loader.py +215 -0
- package/onecode/skills/manager.py +75 -0
- package/onecode/skills/model.py +43 -0
- package/onecode/storage/__init__.py +0 -0
- package/onecode/storage/activity.py +63 -0
- package/onecode/storage/project.py +54 -0
- package/onecode/storage/session.py +112 -0
- package/onecode/tasks/__init__.py +26 -0
- package/onecode/tasks/manager.py +232 -0
- package/onecode/tasks/models.py +240 -0
- package/onecode/trace/__init__.py +0 -0
- package/onecode/trace/tracer.py +173 -0
- package/onecode/utils/__init__.py +0 -0
- package/onecode/utils/helpers.py +20 -0
- package/onecode/verification/__init__.py +5 -0
- 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 +53 -0
- package/onecode/verification/gates/__init__.py +6 -0
- 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 +20 -0
- package/onecode/verification/gates/lint_gate.py +45 -0
- package/onecode/verification/gates/test_gate.py +62 -0
- package/onecode/verification/gates/type_gate.py +46 -0
- package/onecode/verification/loop.py +95 -0
- package/onecode/verification/policy.py +29 -0
- package/package.json +2 -2
- package/pyproject.toml +84 -0
- package/tui/__init__.py +46 -0
- package/tui/__main__.py +4 -0
- 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 +86 -0
- package/tui/_path_fuzzy_search.py +48 -0
- package/tui/_path_match.py +141 -0
- package/tui/about.py +95 -0
- 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 +1212 -0
- package/tui/acp/api.py +79 -0
- package/tui/acp/encode_tool_call_id.py +12 -0
- package/tui/acp/event_tap.py +107 -0
- package/tui/acp/messages.py +222 -0
- package/tui/acp/prompt.py +53 -0
- package/tui/acp/protocol.py +551 -0
- package/tui/agent.py +70 -0
- package/tui/agent_schema.py +76 -0
- package/tui/agents.py +46 -0
- package/tui/ansi/__init__.py +1 -0
- 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 +1689 -0
- package/tui/ansi/_ansi_colors.py +264 -0
- package/tui/ansi/_control_codes.py +37 -0
- package/tui/ansi/_keys.py +251 -0
- package/tui/ansi/_sgr_styles.py +64 -0
- package/tui/ansi/_stream_parser.py +418 -0
- package/tui/answer.py +12 -0
- package/tui/app.py +1195 -0
- package/tui/atomic.py +37 -0
- package/tui/cli.py +208 -0
- package/tui/code_analyze.py +27 -0
- package/tui/complete.py +38 -0
- package/tui/constants.py +61 -0
- package/tui/conversation_markdown.py +30 -0
- package/tui/danger.py +372 -0
- package/tui/data/agents/ampcode.com.toml +52 -0
- package/tui/data/agents/augmentcode.com.toml +41 -0
- package/tui/data/agents/cdh.cloud-dev-harness.toml +23 -0
- package/tui/data/agents/claude.com.toml +41 -0
- package/tui/data/agents/copilot.github.com.toml +29 -0
- package/tui/data/agents/crowai.dev.toml +36 -0
- package/tui/data/agents/cursor.com.toml +38 -0
- package/tui/data/agents/deepagents.langchain.com +34 -0
- package/tui/data/agents/docker.com.toml +60 -0
- package/tui/data/agents/geminicli.com.toml +28 -0
- package/tui/data/agents/goose.ai.toml +52 -0
- package/tui/data/agents/inference.huggingface.co.toml +41 -0
- package/tui/data/agents/kimi.com.toml +35 -0
- package/tui/data/agents/kiro.dev.toml +43 -0
- package/tui/data/agents/onecode.dev.toml +22 -0
- package/tui/data/agents/openai.com.toml +53 -0
- package/tui/data/agents/openclaw.ai.toml +37 -0
- package/tui/data/agents/opencode.ai.toml +39 -0
- package/tui/data/agents/openhands.dev.toml +46 -0
- package/tui/data/agents/stakpak.dev.toml +62 -0
- package/tui/data/agents/vibe.mistral.ai.toml +31 -0
- package/tui/data/agents/vtcode.dev.toml +63 -0
- 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 +213 -0
- package/tui/dec.py +332 -0
- package/tui/diff_utils.py +131 -0
- package/tui/directory.py +234 -0
- package/tui/directory_suggester.py +93 -0
- package/tui/directory_watcher.py +231 -0
- package/tui/format_path.py +25 -0
- package/tui/fuzzy.py +140 -0
- package/tui/fuzzy_index.py +275 -0
- package/tui/gist.py +33 -0
- package/tui/history.py +138 -0
- package/tui/jsonrpc.py +599 -0
- package/tui/menus.py +14 -0
- package/tui/message_log.py +69 -0
- package/tui/messages.py +144 -0
- package/tui/option_content.py +51 -0
- package/tui/os.py +0 -0
- package/tui/path_complete.py +217 -0
- package/tui/path_filter.py +124 -0
- package/tui/paths.py +87 -0
- package/tui/pill.py +23 -0
- package/tui/platform_commands.py +52 -0
- 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 +19 -0
- package/tui/prompt/resource.py +68 -0
- package/tui/protocol.py +28 -0
- 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 +94 -0
- package/tui/screens/agent_modal.py +175 -0
- package/tui/screens/command_edit_modal.py +74 -0
- package/tui/screens/diff_explorer_screen.py +419 -0
- package/tui/screens/diff_screen.py +84 -0
- package/tui/screens/ide_screen.py +461 -0
- package/tui/screens/main.py +397 -0
- package/tui/screens/main.tcss +662 -0
- package/tui/screens/permissions.py +404 -0
- package/tui/screens/permissions.tcss +72 -0
- package/tui/screens/projects.tcss +84 -0
- package/tui/screens/projects_app.py +341 -0
- package/tui/screens/projects_screen.py +277 -0
- package/tui/screens/session_resume_modal.py +172 -0
- package/tui/screens/session_resume_modal.tcss +35 -0
- package/tui/screens/sessions.py +171 -0
- package/tui/screens/sessions.tcss +119 -0
- package/tui/screens/settings.py +293 -0
- package/tui/screens/settings.tcss +113 -0
- package/tui/screens/store.py +502 -0
- package/tui/screens/store.tcss +274 -0
- package/tui/screens/tool_content_screen.py +59 -0
- package/tui/screens/trace.py +317 -0
- package/tui/session_tracker.py +123 -0
- package/tui/settings.py +353 -0
- package/tui/settings_schema.py +467 -0
- package/tui/shell.py +304 -0
- package/tui/shell_read.py +42 -0
- package/tui/slash_command.py +34 -0
- package/tui/tui.tcss +246 -0
- package/tui/twitter.py +38 -0
- package/tui/version.py +80 -0
- 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 +272 -0
- 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 +70 -0
- package/tui/widgets/agent_response.py +76 -0
- package/tui/widgets/agent_thought.py +167 -0
- package/tui/widgets/aidlc.py +334 -0
- package/tui/widgets/ask_user.py +604 -0
- package/tui/widgets/command_pane.py +223 -0
- package/tui/widgets/condensed_path.py +115 -0
- package/tui/widgets/context_stats.py +66 -0
- package/tui/widgets/conversation.py +3235 -0
- package/tui/widgets/danger_warning.py +65 -0
- package/tui/widgets/diff_view.py +69 -0
- package/tui/widgets/directory_input.py +8 -0
- package/tui/widgets/edit_field.py +206 -0
- package/tui/widgets/flash.py +81 -0
- package/tui/widgets/future_text.py +126 -0
- package/tui/widgets/grid_select.py +234 -0
- package/tui/widgets/highlighted_textarea.py +183 -0
- package/tui/widgets/load_more.py +24 -0
- package/tui/widgets/mandelbrot.py +294 -0
- package/tui/widgets/markdown_note.py +13 -0
- package/tui/widgets/menu.py +147 -0
- package/tui/widgets/model_status.py +230 -0
- package/tui/widgets/modified_files.py +315 -0
- package/tui/widgets/non_selectable_label.py +5 -0
- package/tui/widgets/note.py +18 -0
- package/tui/widgets/path_search.py +492 -0
- package/tui/widgets/pending_prompts.py +36 -0
- package/tui/widgets/plan.py +285 -0
- package/tui/widgets/project_directory_tree.py +102 -0
- package/tui/widgets/project_grid_select.py +68 -0
- package/tui/widgets/project_summary.py +33 -0
- package/tui/widgets/prompt.py +935 -0
- package/tui/widgets/question.py +360 -0
- package/tui/widgets/session_grid_select.py +230 -0
- package/tui/widgets/session_summary.py +115 -0
- package/tui/widgets/session_tabs.py +194 -0
- package/tui/widgets/shell_result.py +35 -0
- package/tui/widgets/shell_terminal.py +40 -0
- package/tui/widgets/side_bar.py +124 -0
- package/tui/widgets/slash_complete.py +235 -0
- package/tui/widgets/strike_text.py +70 -0
- package/tui/widgets/subagent.py +287 -0
- package/tui/widgets/subagent_screen.py +715 -0
- package/tui/widgets/terminal.py +576 -0
- package/tui/widgets/terminal_tool.py +360 -0
- package/tui/widgets/throbber.py +100 -0
- package/tui/widgets/tool_call.py +432 -0
- package/tui/widgets/user_input.py +23 -0
- package/tui/widgets/version.py +5 -0
- package/tui/widgets/welcome.py +31 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""retrofit_labels.py — Brownfield migration tool.
|
|
3
|
+
|
|
4
|
+
Scans existing source code for TODO/FIXME/XXX/HACK/REQ/AS-A comments,
|
|
5
|
+
extracts them as candidate requirements, prompts the user to confirm or
|
|
6
|
+
skip each candidate, and emits a spec-delta.md per confirmed candidate.
|
|
7
|
+
Tree-sitter enriches candidates with structural context when available.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
retrofit_labels.py [--project-root PATH]
|
|
11
|
+
[--extensions .py,.ts,.js,.java,.go]
|
|
12
|
+
[--output-dir PATH]
|
|
13
|
+
[--batch]
|
|
14
|
+
[--from-source PATH]
|
|
15
|
+
[--ast-level none|function|class|module]
|
|
16
|
+
[--use-ast | --no-ast]
|
|
17
|
+
[--include-imports]
|
|
18
|
+
[--include-signatures | --no-include-signatures]
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import re
|
|
25
|
+
import sys
|
|
26
|
+
from dataclasses import dataclass, field
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from typing import Any, Iterator, Optional
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
PATTERN = re.compile(r"(?:TODO|FIXME|XXX|HACK|REQ|AS-A):?\s*(.*)")
|
|
32
|
+
FR_PREFIX = "BE-FR-"
|
|
33
|
+
EARS_PREFIX = "the system shall"
|
|
34
|
+
FUNCTION_NODES = {"function_definition", "function_declaration", "method_definition", "method_declaration"}
|
|
35
|
+
CLASS_NODES = {"class_definition", "class_declaration", "interface_declaration", "enum_declaration"}
|
|
36
|
+
IMPORT_NODES = {"import_statement", "import_from_statement", "import_declaration", "package_clause"}
|
|
37
|
+
LANGUAGE_MODULES = {
|
|
38
|
+
".py": ("tree_sitter_python", "python"),
|
|
39
|
+
".js": ("tree_sitter_javascript", "javascript"),
|
|
40
|
+
".jsx": ("tree_sitter_javascript", "javascript"),
|
|
41
|
+
".ts": ("tree_sitter_typescript", "typescript"),
|
|
42
|
+
".tsx": ("tree_sitter_typescript", "tsx"),
|
|
43
|
+
".java": ("tree_sitter_java", "java"),
|
|
44
|
+
".go": ("tree_sitter_go", "go"),
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class Definition:
|
|
50
|
+
kind: str
|
|
51
|
+
name: str
|
|
52
|
+
signature: str = ""
|
|
53
|
+
decorators: list[str] = field(default_factory=list)
|
|
54
|
+
docstring: str = ""
|
|
55
|
+
bases: list[str] = field(default_factory=list)
|
|
56
|
+
start_line: int = 0
|
|
57
|
+
end_line: int = 0
|
|
58
|
+
start_byte: int = 0
|
|
59
|
+
end_byte: int = 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class SourceContext:
|
|
64
|
+
module: str
|
|
65
|
+
imports: list[str] = field(default_factory=list)
|
|
66
|
+
functions: list[Definition] = field(default_factory=list)
|
|
67
|
+
classes: list[Definition] = field(default_factory=list)
|
|
68
|
+
ast_used: bool = False
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass
|
|
72
|
+
class Candidate:
|
|
73
|
+
file: Path
|
|
74
|
+
line: int
|
|
75
|
+
raw: str
|
|
76
|
+
tag: str
|
|
77
|
+
text: str
|
|
78
|
+
ears: str
|
|
79
|
+
context: Optional[Definition] = None
|
|
80
|
+
class_context: Optional[Definition] = None
|
|
81
|
+
source_context: Optional[SourceContext] = None
|
|
82
|
+
snippet: str = ""
|
|
83
|
+
ast_level: str = "function"
|
|
84
|
+
include_imports: bool = False
|
|
85
|
+
include_signatures: bool = True
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def rel_path(self) -> str:
|
|
89
|
+
try:
|
|
90
|
+
return str(self.file.resolve().relative_to(Path.cwd().resolve()))
|
|
91
|
+
except ValueError:
|
|
92
|
+
return str(self.file)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class TreeSitterAnalyzer:
|
|
96
|
+
def __init__(self) -> None:
|
|
97
|
+
self._languages: dict[str, Any] = {}
|
|
98
|
+
self._parser_class: Any = None
|
|
99
|
+
try:
|
|
100
|
+
from tree_sitter import Language, Parser
|
|
101
|
+
|
|
102
|
+
self._language_class = Language
|
|
103
|
+
self._parser_class = Parser
|
|
104
|
+
except ImportError:
|
|
105
|
+
self._language_class = None
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def available(self) -> bool:
|
|
109
|
+
return self._parser_class is not None
|
|
110
|
+
|
|
111
|
+
def _language(self, suffix: str) -> Any:
|
|
112
|
+
if suffix in self._languages:
|
|
113
|
+
return self._languages[suffix]
|
|
114
|
+
module_info = LANGUAGE_MODULES.get(suffix)
|
|
115
|
+
if not module_info or not self.available:
|
|
116
|
+
return None
|
|
117
|
+
module_name, dialect = module_info
|
|
118
|
+
try:
|
|
119
|
+
module = __import__(module_name)
|
|
120
|
+
factory = getattr(module, "language", None)
|
|
121
|
+
if suffix in {".ts", ".tsx"}:
|
|
122
|
+
factory = getattr(module, f"language_{dialect}", factory)
|
|
123
|
+
language = factory() if factory else None
|
|
124
|
+
if language is not None and self._language_class is not None:
|
|
125
|
+
try:
|
|
126
|
+
language = self._language_class(language)
|
|
127
|
+
except (TypeError, ValueError):
|
|
128
|
+
pass
|
|
129
|
+
self._languages[suffix] = language
|
|
130
|
+
return language
|
|
131
|
+
except (ImportError, AttributeError, TypeError, ValueError):
|
|
132
|
+
self._languages[suffix] = None
|
|
133
|
+
return None
|
|
134
|
+
|
|
135
|
+
def _parser(self, suffix: str) -> Any:
|
|
136
|
+
language = self._language(suffix)
|
|
137
|
+
if language is None:
|
|
138
|
+
return None
|
|
139
|
+
try:
|
|
140
|
+
return self._parser_class(language)
|
|
141
|
+
except TypeError:
|
|
142
|
+
parser = self._parser_class()
|
|
143
|
+
try:
|
|
144
|
+
parser.language = language
|
|
145
|
+
except (AttributeError, TypeError):
|
|
146
|
+
parser.set_language(language)
|
|
147
|
+
return parser
|
|
148
|
+
|
|
149
|
+
def analyze(self, path: Path, source: bytes) -> SourceContext:
|
|
150
|
+
result = SourceContext(module=path.stem)
|
|
151
|
+
parser = self._parser(path.suffix.lower())
|
|
152
|
+
if parser is None:
|
|
153
|
+
return result
|
|
154
|
+
try:
|
|
155
|
+
root = parser.parse(source).root_node
|
|
156
|
+
except (AttributeError, TypeError, ValueError):
|
|
157
|
+
return result
|
|
158
|
+
result.ast_used = True
|
|
159
|
+
stack = [root]
|
|
160
|
+
while stack:
|
|
161
|
+
node = stack.pop()
|
|
162
|
+
if node.type in IMPORT_NODES:
|
|
163
|
+
value = _node_text(node, source).strip()
|
|
164
|
+
if value and value not in result.imports:
|
|
165
|
+
result.imports.append(value)
|
|
166
|
+
if node.type in FUNCTION_NODES:
|
|
167
|
+
result.functions.append(self._function(node, source))
|
|
168
|
+
elif node.type in CLASS_NODES:
|
|
169
|
+
result.classes.append(self._class(node, source))
|
|
170
|
+
stack.extend(reversed(node.children))
|
|
171
|
+
return result
|
|
172
|
+
|
|
173
|
+
def _function(self, node: Any, source: bytes) -> Definition:
|
|
174
|
+
name_node = node.child_by_field_name("name")
|
|
175
|
+
name = _node_text(name_node, source).strip() if name_node else "<anonymous>"
|
|
176
|
+
body = node.child_by_field_name("body")
|
|
177
|
+
signature_end = body.start_byte if body else node.end_byte
|
|
178
|
+
signature = source[node.start_byte:signature_end].decode("utf-8", "replace").strip().rstrip("{: ")
|
|
179
|
+
decorators: list[str] = []
|
|
180
|
+
parent = node.parent
|
|
181
|
+
if parent is not None and parent.type in {"decorated_definition", "decorator"}:
|
|
182
|
+
decorators = [
|
|
183
|
+
_node_text(child, source).strip()
|
|
184
|
+
for child in parent.children
|
|
185
|
+
if child.type == "decorator"
|
|
186
|
+
]
|
|
187
|
+
return Definition(
|
|
188
|
+
kind="function",
|
|
189
|
+
name=name,
|
|
190
|
+
signature=" ".join(signature.split()),
|
|
191
|
+
decorators=decorators,
|
|
192
|
+
docstring=_extract_docstring(body, source),
|
|
193
|
+
start_line=node.start_point[0] + 1,
|
|
194
|
+
end_line=node.end_point[0] + 1,
|
|
195
|
+
start_byte=node.start_byte,
|
|
196
|
+
end_byte=node.end_byte,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
def _class(self, node: Any, source: bytes) -> Definition:
|
|
200
|
+
name_node = node.child_by_field_name("name")
|
|
201
|
+
name = _node_text(name_node, source).strip() if name_node else "<anonymous>"
|
|
202
|
+
bases_node = node.child_by_field_name("superclasses") or node.child_by_field_name("interfaces")
|
|
203
|
+
bases = []
|
|
204
|
+
if bases_node is not None:
|
|
205
|
+
bases = [
|
|
206
|
+
_node_text(child, source).strip()
|
|
207
|
+
for child in bases_node.named_children
|
|
208
|
+
if _node_text(child, source).strip()
|
|
209
|
+
]
|
|
210
|
+
body = node.child_by_field_name("body")
|
|
211
|
+
return Definition(
|
|
212
|
+
kind="class",
|
|
213
|
+
name=name,
|
|
214
|
+
bases=bases,
|
|
215
|
+
docstring=_extract_docstring(body, source),
|
|
216
|
+
start_line=node.start_point[0] + 1,
|
|
217
|
+
end_line=node.end_point[0] + 1,
|
|
218
|
+
start_byte=node.start_byte,
|
|
219
|
+
end_byte=node.end_byte,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _node_text(node: Any, source: bytes) -> str:
|
|
224
|
+
return source[node.start_byte:node.end_byte].decode("utf-8", "replace")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _extract_docstring(body: Any, source: bytes) -> str:
|
|
228
|
+
if body is None:
|
|
229
|
+
return ""
|
|
230
|
+
named = list(body.named_children)
|
|
231
|
+
if not named:
|
|
232
|
+
return ""
|
|
233
|
+
first = named[0]
|
|
234
|
+
expression = first.named_children[0] if first.type == "expression_statement" and first.named_children else first
|
|
235
|
+
if expression.type not in {"string", "string_literal"}:
|
|
236
|
+
return ""
|
|
237
|
+
text = _node_text(expression, source).strip()
|
|
238
|
+
return re.sub(r"^(?:[rubfRUBF]*)(?:'''|\"\"\"|'|\")|(?:'''|\"\"\"|'|\")$", "", text).strip()
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _iter_source_files(root: Path, extensions: list[str], from_source: Optional[Path]) -> Iterator[Path]:
|
|
242
|
+
base = (root / from_source) if from_source else root
|
|
243
|
+
if not base.exists():
|
|
244
|
+
return
|
|
245
|
+
ext_set = {e.lower() if e.startswith(".") else f".{e.lower()}" for e in extensions}
|
|
246
|
+
for path in base.rglob("*"):
|
|
247
|
+
if path.is_file() and path.suffix.lower() in ext_set:
|
|
248
|
+
yield path
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _strip_comment(text: str) -> str:
|
|
252
|
+
for prefix in ("#", "//", "--", "/*", "*"):
|
|
253
|
+
if text.lstrip().startswith(prefix):
|
|
254
|
+
text = text.lstrip()[len(prefix):]
|
|
255
|
+
break
|
|
256
|
+
return text.strip().rstrip("*/").strip()
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _scope_phrase(name: str) -> str:
|
|
260
|
+
words = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", name)
|
|
261
|
+
words = re.sub(r"[_\-.]+", " ", words).strip().lower()
|
|
262
|
+
return words
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def _to_ears(text: str, scope: str = "") -> str:
|
|
266
|
+
stripped = text.strip()
|
|
267
|
+
if not stripped:
|
|
268
|
+
return stripped
|
|
269
|
+
lowered = stripped.lower()
|
|
270
|
+
if lowered.startswith(EARS_PREFIX):
|
|
271
|
+
requirement = stripped if stripped.endswith(".") else f"{stripped}."
|
|
272
|
+
else:
|
|
273
|
+
rest = stripped[0].lower() + stripped[1:]
|
|
274
|
+
requirement = f"{EARS_PREFIX} {rest.rstrip('.')} .".replace(" .", ".")
|
|
275
|
+
if scope:
|
|
276
|
+
return f"While {_scope_phrase(scope)}, {requirement}"
|
|
277
|
+
return requirement
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def _smallest_enclosing(definitions: list[Definition], line: int) -> Optional[Definition]:
|
|
281
|
+
matches = [item for item in definitions if item.start_line <= line <= item.end_line]
|
|
282
|
+
return min(matches, key=lambda item: item.end_line - item.start_line, default=None)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def _snippet(lines: list[str], line: int, context: Optional[Definition]) -> str:
|
|
286
|
+
start = max(1, line - 2)
|
|
287
|
+
end = min(len(lines), line + 2)
|
|
288
|
+
if context:
|
|
289
|
+
start = max(context.start_line, start)
|
|
290
|
+
end = min(context.end_line, end)
|
|
291
|
+
width = len(str(end))
|
|
292
|
+
return "\n".join(f"{number:>{width}} | {lines[number - 1]}" for number in range(start, end + 1))
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def _next_fr_id(output_dir: Path) -> str:
|
|
296
|
+
if not output_dir.exists():
|
|
297
|
+
return f"{FR_PREFIX}001"
|
|
298
|
+
nums: list[int] = []
|
|
299
|
+
for file in output_dir.glob("spec-delta-*.md"):
|
|
300
|
+
match = re.search(r"spec-delta-(\d+)", file.name)
|
|
301
|
+
if match:
|
|
302
|
+
nums.append(int(match.group(1)))
|
|
303
|
+
return f"{FR_PREFIX}{(max(nums) if nums else 0) + 1:03d}"
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def scan(
|
|
307
|
+
root: Path,
|
|
308
|
+
extensions: list[str],
|
|
309
|
+
from_source: Optional[Path],
|
|
310
|
+
use_ast: bool = True,
|
|
311
|
+
ast_level: str = "function",
|
|
312
|
+
include_imports: bool = False,
|
|
313
|
+
include_signatures: bool = True,
|
|
314
|
+
) -> list[Candidate]:
|
|
315
|
+
found: list[Candidate] = []
|
|
316
|
+
analyzer = TreeSitterAnalyzer() if use_ast else None
|
|
317
|
+
for path in _iter_source_files(root, extensions, from_source):
|
|
318
|
+
try:
|
|
319
|
+
source = path.read_bytes()
|
|
320
|
+
lines = source.decode("utf-8", "replace").splitlines()
|
|
321
|
+
except OSError:
|
|
322
|
+
continue
|
|
323
|
+
source_context = analyzer.analyze(path, source) if analyzer else SourceContext(module=path.stem)
|
|
324
|
+
for idx, line in enumerate(lines, start=1):
|
|
325
|
+
for match in PATTERN.finditer(line):
|
|
326
|
+
raw = match.group(1).strip()
|
|
327
|
+
if not raw:
|
|
328
|
+
continue
|
|
329
|
+
tag = line[match.start():match.end()].split(":", 1)[0].split()[0]
|
|
330
|
+
cleaned = _strip_comment(raw)
|
|
331
|
+
function_context = _smallest_enclosing(source_context.functions, idx)
|
|
332
|
+
class_context = _smallest_enclosing(source_context.classes, idx)
|
|
333
|
+
if ast_level == "function":
|
|
334
|
+
context = function_context or class_context
|
|
335
|
+
elif ast_level == "class":
|
|
336
|
+
context = class_context
|
|
337
|
+
elif ast_level == "module":
|
|
338
|
+
context = Definition("module", source_context.module, start_line=1, end_line=len(lines))
|
|
339
|
+
else:
|
|
340
|
+
context = None
|
|
341
|
+
found.append(
|
|
342
|
+
Candidate(
|
|
343
|
+
file=path,
|
|
344
|
+
line=idx,
|
|
345
|
+
raw=line.strip(),
|
|
346
|
+
tag=tag,
|
|
347
|
+
text=cleaned,
|
|
348
|
+
ears=_to_ears(cleaned, context.name if context else ""),
|
|
349
|
+
context=context,
|
|
350
|
+
class_context=class_context,
|
|
351
|
+
source_context=source_context,
|
|
352
|
+
snippet=_snippet(lines, idx, context),
|
|
353
|
+
ast_level=ast_level,
|
|
354
|
+
include_imports=include_imports,
|
|
355
|
+
include_signatures=include_signatures,
|
|
356
|
+
)
|
|
357
|
+
)
|
|
358
|
+
return found
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def _confirm(prompt: str, batch: bool) -> bool:
|
|
362
|
+
if batch:
|
|
363
|
+
return True
|
|
364
|
+
try:
|
|
365
|
+
answer = input(f"{prompt} [y/N/q]: ").strip().lower()
|
|
366
|
+
except EOFError:
|
|
367
|
+
return False
|
|
368
|
+
if answer in ("q", "quit"):
|
|
369
|
+
raise KeyboardInterrupt
|
|
370
|
+
return answer in ("y", "yes")
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def _markdown_value(value: str) -> str:
|
|
374
|
+
return value.replace("`", "\\`").replace("\n", " ")
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def render_spec_delta(fr_id: str, candidate: Candidate) -> str:
|
|
378
|
+
title = candidate.text[:80].rstrip(".").strip() or candidate.tag
|
|
379
|
+
context = candidate.context
|
|
380
|
+
ast_used = bool(candidate.source_context and candidate.source_context.ast_used)
|
|
381
|
+
parts = [
|
|
382
|
+
"---",
|
|
383
|
+
f"id: {fr_id}",
|
|
384
|
+
f"title: {title}",
|
|
385
|
+
"status: draft",
|
|
386
|
+
f"source: {candidate.rel_path}:{candidate.line}",
|
|
387
|
+
f"tag: {candidate.tag}",
|
|
388
|
+
f"analysis: {'tree-sitter' if ast_used else 'regex'}",
|
|
389
|
+
]
|
|
390
|
+
if context:
|
|
391
|
+
parts.extend((f"scope: {context.kind}", f"scope_name: {context.name}"))
|
|
392
|
+
parts.extend(("---", "", f"# {fr_id}: {title}", ""))
|
|
393
|
+
parts.extend(
|
|
394
|
+
(
|
|
395
|
+
f"**Source**: `{candidate.rel_path}:{candidate.line}`",
|
|
396
|
+
f"**Original**: `{_markdown_value(candidate.raw)}`",
|
|
397
|
+
f"**Analysis**: {'tree-sitter AST' if ast_used else 'regex fallback'}",
|
|
398
|
+
)
|
|
399
|
+
)
|
|
400
|
+
if context:
|
|
401
|
+
parts.append(f"**Scope**: {context.kind} `{context.name}`")
|
|
402
|
+
if candidate.class_context and candidate.class_context is not context:
|
|
403
|
+
parts.append(f"**Enclosing class**: `{candidate.class_context.name}`")
|
|
404
|
+
parts.extend(("", "## Requirement (EARS)", "", candidate.ears, "", "## Source Context", ""))
|
|
405
|
+
if context and candidate.include_signatures and context.signature:
|
|
406
|
+
parts.extend(("### Signature", "", f"```{candidate.file.suffix.lstrip('.')}", context.signature, "```", ""))
|
|
407
|
+
if context and context.decorators:
|
|
408
|
+
parts.extend(("### Decorators", "", *(f"- `{_markdown_value(item)}`" for item in context.decorators), ""))
|
|
409
|
+
if context and context.bases:
|
|
410
|
+
parts.extend(("### Base Classes", "", *(f"- `{_markdown_value(item)}`" for item in context.bases), ""))
|
|
411
|
+
if context and context.docstring:
|
|
412
|
+
parts.extend(("### Docstring", "", context.docstring, ""))
|
|
413
|
+
if candidate.include_imports and candidate.source_context and candidate.source_context.imports:
|
|
414
|
+
parts.extend(("### Imports", "", f"```{candidate.file.suffix.lstrip('.')}", *candidate.source_context.imports, "```", ""))
|
|
415
|
+
parts.extend(("### Code Snippet", "", f"```{candidate.file.suffix.lstrip('.')}", candidate.snippet, "```", ""))
|
|
416
|
+
if candidate.source_context and candidate.ast_level == "module":
|
|
417
|
+
if candidate.source_context.classes:
|
|
418
|
+
parts.extend(("### Classes", "", *(f"- `{item.name}`" for item in candidate.source_context.classes), ""))
|
|
419
|
+
if candidate.source_context.functions:
|
|
420
|
+
parts.extend(("### Functions", "", *(f"- `{item.name}`" for item in candidate.source_context.functions), ""))
|
|
421
|
+
parts.extend(("## Rationale", "", "Recovered from source-level comment during brownfield retrofit.", ""))
|
|
422
|
+
return "\n".join(parts)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def _write_delta(output_dir: Path, fr_id: str, body: str) -> Path:
|
|
426
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
427
|
+
number = int(fr_id[len(FR_PREFIX):])
|
|
428
|
+
output = output_dir / f"spec-delta-{number:03d}.md"
|
|
429
|
+
output.write_text(body, encoding="utf-8")
|
|
430
|
+
return output
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def main(argv: Optional[list[str]] = None) -> int:
|
|
434
|
+
parser = argparse.ArgumentParser(description="Retrofit source-level comments into spec-delta requirements.")
|
|
435
|
+
parser.add_argument("--project-root", default=".", type=Path)
|
|
436
|
+
parser.add_argument(
|
|
437
|
+
"--extensions",
|
|
438
|
+
default=".py,.ts,.tsx,.js,.jsx,.java,.go",
|
|
439
|
+
help="Comma-separated extension list (default: .py,.ts,.tsx,.js,.jsx,.java,.go)",
|
|
440
|
+
)
|
|
441
|
+
parser.add_argument("--output-dir", default="aidlc/openspec/changes/retrofit/", type=Path)
|
|
442
|
+
parser.add_argument("--batch", action="store_true", help="Auto-confirm all candidates without prompting.")
|
|
443
|
+
parser.add_argument("--from-source", default=None, type=Path, help="Scan only this subdirectory of --project-root.")
|
|
444
|
+
parser.add_argument(
|
|
445
|
+
"--ast-level",
|
|
446
|
+
choices=("none", "function", "class", "module"),
|
|
447
|
+
default="function",
|
|
448
|
+
help="Structural scope included in requirements and output (default: function).",
|
|
449
|
+
)
|
|
450
|
+
ast_group = parser.add_mutually_exclusive_group()
|
|
451
|
+
ast_group.add_argument("--use-ast", dest="use_ast", action="store_true", help="Use tree-sitter when available (default).")
|
|
452
|
+
ast_group.add_argument("--no-ast", dest="use_ast", action="store_false", help="Disable tree-sitter analysis.")
|
|
453
|
+
parser.set_defaults(use_ast=True)
|
|
454
|
+
parser.add_argument("--include-imports", action="store_true", help="Include module imports in output.")
|
|
455
|
+
parser.add_argument(
|
|
456
|
+
"--include-signatures",
|
|
457
|
+
action=argparse.BooleanOptionalAction,
|
|
458
|
+
default=True,
|
|
459
|
+
help="Include enclosing function signatures in output (default: true).",
|
|
460
|
+
)
|
|
461
|
+
args = parser.parse_args(argv)
|
|
462
|
+
|
|
463
|
+
root = args.project_root.resolve()
|
|
464
|
+
if not root.exists():
|
|
465
|
+
print(f"project root does not exist: {root}", file=sys.stderr)
|
|
466
|
+
return 2
|
|
467
|
+
|
|
468
|
+
extensions = [extension.strip() for extension in args.extensions.split(",") if extension.strip()]
|
|
469
|
+
output_dir = (root / args.output_dir).resolve() if not args.output_dir.is_absolute() else args.output_dir.resolve()
|
|
470
|
+
candidates = scan(
|
|
471
|
+
root,
|
|
472
|
+
extensions,
|
|
473
|
+
args.from_source,
|
|
474
|
+
use_ast=args.use_ast,
|
|
475
|
+
ast_level=args.ast_level,
|
|
476
|
+
include_imports=args.include_imports,
|
|
477
|
+
include_signatures=args.include_signatures,
|
|
478
|
+
)
|
|
479
|
+
if not candidates:
|
|
480
|
+
print("No candidate comments found.", file=sys.stderr)
|
|
481
|
+
return 0
|
|
482
|
+
|
|
483
|
+
written: list[Path] = []
|
|
484
|
+
try:
|
|
485
|
+
for candidate in candidates:
|
|
486
|
+
scope = f" in {candidate.context.kind} {candidate.context.name}" if candidate.context else ""
|
|
487
|
+
header = f"[{candidate.rel_path}:{candidate.line}] ({candidate.tag}) {candidate.text}{scope}"
|
|
488
|
+
if _confirm(header, args.batch):
|
|
489
|
+
fr_id = _next_fr_id(output_dir)
|
|
490
|
+
output = _write_delta(output_dir, fr_id, render_spec_delta(fr_id, candidate))
|
|
491
|
+
written.append(output)
|
|
492
|
+
try:
|
|
493
|
+
shown = output.relative_to(root)
|
|
494
|
+
except ValueError:
|
|
495
|
+
shown = output
|
|
496
|
+
print(f" wrote {shown}", file=sys.stderr)
|
|
497
|
+
except KeyboardInterrupt:
|
|
498
|
+
print("\nAborted by user.", file=sys.stderr)
|
|
499
|
+
|
|
500
|
+
print(f"\n{len(written)} spec-delta file(s) written to {output_dir}")
|
|
501
|
+
return 0
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
if __name__ == "__main__":
|
|
505
|
+
sys.exit(main())
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""CDH Trace — centralized agenttrace integration at the ACP protocol layer.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
from cdh.trace import add_trace
|
|
5
|
+
add_trace("ACP", "agent_message_chunk", session_id=sid, tags={...})
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from agenttrace import TraceManager
|
|
13
|
+
|
|
14
|
+
_TRACER: TraceManager | None = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_tracer() -> TraceManager:
|
|
18
|
+
global _TRACER
|
|
19
|
+
if _TRACER is None:
|
|
20
|
+
db_path = _get_db_path()
|
|
21
|
+
db_path.parent.mkdir(parents=True, exist_ok=True)
|
|
22
|
+
_TRACER = TraceManager(db_path=str(db_path))
|
|
23
|
+
return _TRACER
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_db_path() -> Path:
|
|
27
|
+
return _get_db_path()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _get_db_path() -> Path:
|
|
31
|
+
return Path.home() / ".cdh" / "traces" / "traces.db"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def add_trace(
|
|
35
|
+
trace_type: str,
|
|
36
|
+
func_name: str,
|
|
37
|
+
session_id: str | None = None,
|
|
38
|
+
duration: float | None = None,
|
|
39
|
+
parent_span_id: str | None = None,
|
|
40
|
+
note: str | None = None,
|
|
41
|
+
tags: dict | None = None,
|
|
42
|
+
model: str | None = None,
|
|
43
|
+
token_count: int | None = None,
|
|
44
|
+
input_tokens: int | None = None,
|
|
45
|
+
output_tokens: int | None = None,
|
|
46
|
+
cached_input_tokens: int | None = None,
|
|
47
|
+
status: str | None = None,
|
|
48
|
+
error: str | None = None,
|
|
49
|
+
tool_name: str | None = None,
|
|
50
|
+
tool_kind: str | None = None,
|
|
51
|
+
agent_type: str | None = None,
|
|
52
|
+
cost_amount: float | None = None,
|
|
53
|
+
cost_currency: str | None = None,
|
|
54
|
+
lines_added: int | None = None,
|
|
55
|
+
extra_data: dict | None = None,
|
|
56
|
+
) -> None:
|
|
57
|
+
data = {}
|
|
58
|
+
if model is not None:
|
|
59
|
+
data["model"] = model
|
|
60
|
+
if token_count is not None:
|
|
61
|
+
data["token_count"] = token_count
|
|
62
|
+
if input_tokens is not None:
|
|
63
|
+
data["input_tokens"] = input_tokens
|
|
64
|
+
if output_tokens is not None:
|
|
65
|
+
data["output_tokens"] = output_tokens
|
|
66
|
+
if cached_input_tokens is not None:
|
|
67
|
+
data["cached_input_tokens"] = cached_input_tokens
|
|
68
|
+
if status is not None:
|
|
69
|
+
data["status"] = status
|
|
70
|
+
if error is not None:
|
|
71
|
+
data["error"] = error
|
|
72
|
+
if tool_name is not None:
|
|
73
|
+
data["tool_name"] = tool_name
|
|
74
|
+
if tool_kind is not None:
|
|
75
|
+
data["tool_kind"] = tool_kind
|
|
76
|
+
if agent_type is not None:
|
|
77
|
+
data["agent_type"] = agent_type
|
|
78
|
+
if parent_span_id is not None:
|
|
79
|
+
data["parent_span_id"] = parent_span_id
|
|
80
|
+
if note is not None:
|
|
81
|
+
data["note"] = note
|
|
82
|
+
if cost_amount is not None:
|
|
83
|
+
data["cost_amount"] = cost_amount
|
|
84
|
+
if cost_currency is not None:
|
|
85
|
+
data["cost_currency"] = cost_currency
|
|
86
|
+
if lines_added is not None:
|
|
87
|
+
data["lines_added"] = lines_added
|
|
88
|
+
if extra_data:
|
|
89
|
+
data.update(extra_data)
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
get_tracer().add_trace(
|
|
93
|
+
trace_type=trace_type,
|
|
94
|
+
func_name=func_name,
|
|
95
|
+
kwargs=data if data else None,
|
|
96
|
+
tags=tags,
|
|
97
|
+
session_id=session_id,
|
|
98
|
+
duration=duration,
|
|
99
|
+
)
|
|
100
|
+
except Exception:
|
|
101
|
+
pass
|
|
Binary file
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Trace dashboard — built-in web UI with Chart.js, no npm needed.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
from cdh.trace.dashboard import run_dashboard
|
|
5
|
+
run_dashboard(port=5173)
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import webbrowser
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from cdh.trace import get_db_path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _load_app_html() -> str:
|
|
18
|
+
"""Load the frontend HTML from the app.html file in this package."""
|
|
19
|
+
pkg_dir = Path(__file__).resolve().parent
|
|
20
|
+
html_path = pkg_dir / "app.html"
|
|
21
|
+
return html_path.read_text(encoding="utf-8")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def run_dashboard(port: int = 5173, host: str = "127.0.0.1") -> None:
|
|
25
|
+
"""Start the trace dashboard web server.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
port: HTTP port (default 5173).
|
|
29
|
+
host: Bind address (default 127.0.0.1).
|
|
30
|
+
"""
|
|
31
|
+
db_path = get_db_path()
|
|
32
|
+
app_html = _load_app_html()
|
|
33
|
+
|
|
34
|
+
print(f"Trace DB: {db_path}")
|
|
35
|
+
print("")
|
|
36
|
+
print(f"Starting CDH Trace Dashboard at http://{host}:{port}")
|
|
37
|
+
print("Press Ctrl+C to stop.")
|
|
38
|
+
print("")
|
|
39
|
+
|
|
40
|
+
from cdh.trace.dashboard.server import make_server
|
|
41
|
+
|
|
42
|
+
server = make_server(host, port, app_html, db_path)
|
|
43
|
+
|
|
44
|
+
# Don't open browser in headless/CI environments
|
|
45
|
+
_try_open_browser = True
|
|
46
|
+
display = os.environ.get("DISPLAY")
|
|
47
|
+
if display is not None and not display:
|
|
48
|
+
_try_open_browser = False
|
|
49
|
+
if "DISPLAY" not in os.environ:
|
|
50
|
+
_try_open_browser = False
|
|
51
|
+
if _try_open_browser:
|
|
52
|
+
try:
|
|
53
|
+
webbrowser.open(f"http://{host}:{port}")
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
server.serve_forever()
|
|
59
|
+
except KeyboardInterrupt:
|
|
60
|
+
print("\nShutting down...")
|
|
61
|
+
server.server_close()
|