tradingcodex 0.1.0__py3-none-any.whl
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.
- apps/__init__.py +1 -0
- apps/audit/__init__.py +1 -0
- apps/audit/admin.py +6 -0
- apps/audit/apps.py +8 -0
- apps/audit/migrations/0001_initial.py +35 -0
- apps/audit/migrations/__init__.py +0 -0
- apps/audit/models.py +22 -0
- apps/harness/__init__.py +1 -0
- apps/harness/admin.py +6 -0
- apps/harness/apps.py +8 -0
- apps/harness/migrations/0001_initial.py +35 -0
- apps/harness/migrations/__init__.py +0 -0
- apps/harness/models.py +22 -0
- apps/harness/templatetags/__init__.py +1 -0
- apps/integrations/__init__.py +1 -0
- apps/integrations/admin.py +6 -0
- apps/integrations/apps.py +8 -0
- apps/integrations/migrations/0001_initial.py +29 -0
- apps/integrations/migrations/__init__.py +0 -0
- apps/integrations/models.py +16 -0
- apps/integrations/services.py +31 -0
- apps/mcp/__init__.py +1 -0
- apps/mcp/admin.py +20 -0
- apps/mcp/apps.py +8 -0
- apps/mcp/migrations/0001_initial.py +168 -0
- apps/mcp/migrations/__init__.py +0 -0
- apps/mcp/models.py +154 -0
- apps/mcp/services.py +327 -0
- apps/orders/__init__.py +1 -0
- apps/orders/admin.py +6 -0
- apps/orders/apps.py +8 -0
- apps/orders/migrations/0001_initial.py +79 -0
- apps/orders/migrations/__init__.py +0 -0
- apps/orders/models.py +66 -0
- apps/orders/services.py +107 -0
- apps/policy/__init__.py +1 -0
- apps/policy/admin.py +6 -0
- apps/policy/apps.py +8 -0
- apps/policy/migrations/0001_initial.py +75 -0
- apps/policy/migrations/__init__.py +0 -0
- apps/policy/models.py +61 -0
- apps/policy/services.py +110 -0
- apps/portfolio/__init__.py +1 -0
- apps/portfolio/admin.py +6 -0
- apps/portfolio/apps.py +8 -0
- apps/portfolio/migrations/0001_initial.py +67 -0
- apps/portfolio/migrations/__init__.py +0 -0
- apps/portfolio/models.py +53 -0
- apps/research/__init__.py +1 -0
- apps/research/admin.py +1 -0
- apps/research/apps.py +8 -0
- apps/research/migrations/__init__.py +0 -0
- apps/research/models.py +1 -0
- apps/workflows/__init__.py +1 -0
- apps/workflows/admin.py +6 -0
- apps/workflows/apps.py +8 -0
- apps/workflows/migrations/0001_initial.py +51 -0
- apps/workflows/migrations/__init__.py +0 -0
- apps/workflows/models.py +44 -0
- tradingcodex-0.1.0.dist-info/METADATA +337 -0
- tradingcodex-0.1.0.dist-info/RECORD +254 -0
- tradingcodex-0.1.0.dist-info/WHEEL +5 -0
- tradingcodex-0.1.0.dist-info/entry_points.txt +2 -0
- tradingcodex-0.1.0.dist-info/licenses/LICENSE +202 -0
- tradingcodex-0.1.0.dist-info/licenses/NOTICE +24 -0
- tradingcodex-0.1.0.dist-info/top_level.txt +4 -0
- tradingcodex_cli/__init__.py +1 -0
- tradingcodex_cli/__main__.py +124 -0
- tradingcodex_cli/commands/__init__.py +2 -0
- tradingcodex_cli/commands/bootstrap.py +157 -0
- tradingcodex_cli/commands/db.py +36 -0
- tradingcodex_cli/commands/doctor.py +230 -0
- tradingcodex_cli/commands/mcp.py +186 -0
- tradingcodex_cli/commands/orders.py +89 -0
- tradingcodex_cli/commands/policy.py +21 -0
- tradingcodex_cli/commands/profile.py +110 -0
- tradingcodex_cli/commands/research.py +76 -0
- tradingcodex_cli/commands/skills.py +93 -0
- tradingcodex_cli/commands/strategies.py +67 -0
- tradingcodex_cli/commands/subagents.py +106 -0
- tradingcodex_cli/commands/utils.py +134 -0
- tradingcodex_cli/commands/workspaces.py +53 -0
- tradingcodex_cli/generator.py +234 -0
- tradingcodex_cli/mcp_stdio.py +26 -0
- tradingcodex_cli/service_autostart.py +127 -0
- tradingcodex_service/__init__.py +5 -0
- tradingcodex_service/admin.py +1 -0
- tradingcodex_service/api.py +486 -0
- tradingcodex_service/application/__init__.py +2 -0
- tradingcodex_service/application/agents.py +1470 -0
- tradingcodex_service/application/audit.py +71 -0
- tradingcodex_service/application/common.py +88 -0
- tradingcodex_service/application/components.py +299 -0
- tradingcodex_service/application/harness.py +747 -0
- tradingcodex_service/application/markdown_preview.py +179 -0
- tradingcodex_service/application/orders.py +404 -0
- tradingcodex_service/application/policy.py +150 -0
- tradingcodex_service/application/portfolio.py +166 -0
- tradingcodex_service/application/research.py +356 -0
- tradingcodex_service/application/runtime.py +321 -0
- tradingcodex_service/asgi.py +6 -0
- tradingcodex_service/mcp_http.py +59 -0
- tradingcodex_service/mcp_runtime.py +565 -0
- tradingcodex_service/settings.py +91 -0
- tradingcodex_service/templates/web/activity.html +24 -0
- tradingcodex_service/templates/web/agent_skills.html +111 -0
- tradingcodex_service/templates/web/agents.html +121 -0
- tradingcodex_service/templates/web/base.html +150 -0
- tradingcodex_service/templates/web/dashboard.html +109 -0
- tradingcodex_service/templates/web/fragments/role_inspector.html +81 -0
- tradingcodex_service/templates/web/fragments/starter_prompt.html +24 -0
- tradingcodex_service/templates/web/fragments/topology_canvas.html +85 -0
- tradingcodex_service/templates/web/harness.html +87 -0
- tradingcodex_service/templates/web/mcp_router.html +250 -0
- tradingcodex_service/templates/web/orders.html +68 -0
- tradingcodex_service/templates/web/policy.html +81 -0
- tradingcodex_service/templates/web/portfolio.html +52 -0
- tradingcodex_service/templates/web/research.html +73 -0
- tradingcodex_service/templates/web/starter_prompt.html +40 -0
- tradingcodex_service/templates/web/strategies.html +74 -0
- tradingcodex_service/urls.py +42 -0
- tradingcodex_service/version.py +1 -0
- tradingcodex_service/web.py +885 -0
- tradingcodex_service/wsgi.py +6 -0
- workspace_templates/__init__.py +1 -0
- workspace_templates/modules/audit/files/.tradingcodex/audit/README.md +5 -0
- workspace_templates/modules/audit/files/trading/audit/.gitkeep +1 -0
- workspace_templates/modules/audit/module.json +16 -0
- workspace_templates/modules/codex-base/files/.codex/config.toml +272 -0
- workspace_templates/modules/codex-base/files/.codex/hooks/tradingcodex_hook.py +173 -0
- workspace_templates/modules/codex-base/files/.codex/hooks.json +105 -0
- workspace_templates/modules/codex-base/files/.codex/prompts/base_instructions/head-manager.md +129 -0
- workspace_templates/modules/codex-base/files/.codex/rules/tradingcodex.rules +50 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/capabilities.yaml +56 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/cli.py +16 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/config.yaml +53 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/policy-bindings.yaml +16 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/principals.yaml +17 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/roles.yaml +27 -0
- workspace_templates/modules/codex-base/files/AGENTS.md +56 -0
- workspace_templates/modules/codex-base/files/pyproject.toml +13 -0
- workspace_templates/modules/codex-base/files/tcx +35 -0
- workspace_templates/modules/codex-base/module.json +17 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/policies/access-policies.yaml +39 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/policies/restricted-list.yaml +6 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/approval_receipt.schema.json +14 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/audit_event.schema.json +11 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/evidence_pack.schema.json +16 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/execution_result.schema.json +12 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/fundamental_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/news_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/order_intent.schema.json +30 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/portfolio_review.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/postmortem_report.schema.json +14 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/risk_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/technical_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/thesis.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/valuation.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/scripts/validate-order-intent.py +15 -0
- workspace_templates/modules/enforcement-guardrails/module.json +19 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/execution-operator.toml +71 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/fundamental-analyst.toml +62 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/instrument-analyst.toml +64 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/macro-analyst.toml +64 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/news-analyst.toml +63 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/portfolio-manager.toml +62 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/risk-manager.toml +65 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/technical-analyst.toml +63 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/valuation-analyst.toml +59 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/head-manager.yaml +66 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/skill-change-proposals/.gitkeep +1 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/subagent-registry.yaml +56 -0
- workspace_templates/modules/fixed-subagents/module.json +23 -0
- workspace_templates/modules/guidance-guardrails/files/.tradingcodex/guidance/guardrails.md +17 -0
- workspace_templates/modules/guidance-guardrails/files/.tradingcodex/guidance/task-quality-checklist.md +37 -0
- workspace_templates/modules/guidance-guardrails/module.json +18 -0
- workspace_templates/modules/information-barriers/files/.tradingcodex/policies/information-barriers.yaml +211 -0
- workspace_templates/modules/information-barriers/files/.tradingcodex/secrets.md +9 -0
- workspace_templates/modules/information-barriers/files/trading/approvals/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/market-data/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/approved/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/draft/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/executed/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/rejected/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/portfolio/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/fundamental/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/instrument/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/macro/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/news/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/policy/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/portfolio/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/postmortem/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/risk/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/technical/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/valuation/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/research/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/module.json +19 -0
- workspace_templates/modules/paper-trading/files/.tradingcodex/mcp/adapters/paper-trading.py +4 -0
- workspace_templates/modules/paper-trading/module.json +16 -0
- workspace_templates/modules/postmortem/files/.tradingcodex/workflows/postmortem.yaml +12 -0
- workspace_templates/modules/postmortem/module.json +16 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/investment-workflow-map/SKILL.md +106 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/investment-workflow-map/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-optional-skills/SKILL.md +101 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-optional-skills/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-subagents/SKILL.md +140 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-subagents/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/orchestrate-workflow/SKILL.md +140 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/orchestrate-workflow/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/postmortem/SKILL.md +31 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/postmortem/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/scenario-quality-gates/SKILL.md +138 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/scenario-quality-gates/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/strategy-creator/SKILL.md +109 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/strategy-creator/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/synthesize-decision/SKILL.md +54 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/synthesize-decision/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/execution-operator/execute-paper-order/SKILL.md +35 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/execution-operator/execute-paper-order/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/fundamental-analyst/fundamental-analysis/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/fundamental-analyst/fundamental-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/instrument-analyst/instrument-analysis/SKILL.md +40 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/instrument-analyst/instrument-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/macro-analyst/macro-analysis/SKILL.md +40 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/macro-analyst/macro-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/news-analyst/news-analysis/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/news-analyst/news-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/create-order-intent/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/create-order-intent/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/portfolio-review/SKILL.md +44 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/portfolio-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/approve-order/SKILL.md +38 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/approve-order/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/policy-review/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/policy-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/review-risk/SKILL.md +45 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/review-risk/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/collect-evidence/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/collect-evidence/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/external-data-source-gate/SKILL.md +66 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/external-data-source-gate/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/technical-analyst/technical-analysis/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/technical-analyst/technical-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/valuation-analyst/valuation-review/SKILL.md +47 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/valuation-analyst/valuation-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/module.json +37 -0
- workspace_templates/modules/stub-execution/files/.tradingcodex/mcp/adapters/stub-execution.py +4 -0
- workspace_templates/modules/stub-execution/module.json +15 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/adapters/live-adapter.contract.md +25 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/enforcer/README.md +5 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/gateway/README.md +8 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/server.py +27 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/smoke-call.py +18 -0
- workspace_templates/modules/tradingcodex-mcp/module.json +24 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
TradingCodex
|
|
2
|
+
Copyright 2026 TradingCodex Authors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the TradingCodex project.
|
|
5
|
+
|
|
6
|
+
Unless a file, directory, or separately distributed artifact states otherwise,
|
|
7
|
+
the source code, generated workspace templates, and project documentation in
|
|
8
|
+
this repository are licensed under the Apache License, Version 2.0.
|
|
9
|
+
|
|
10
|
+
The name "TradingCodex", future TradingCodex logos, and other TradingCodex
|
|
11
|
+
project marks are trademarks or service marks of their respective owners.
|
|
12
|
+
The Apache License, Version 2.0 does not grant trademark rights. See
|
|
13
|
+
TRADEMARKS.md for project trademark guidance.
|
|
14
|
+
|
|
15
|
+
Generated workspaces are scaffolds copied from this repository. The copied
|
|
16
|
+
TradingCodex scaffold files remain under the repository license unless marked
|
|
17
|
+
otherwise. User-created research notes, portfolio data, order artifacts,
|
|
18
|
+
configuration secrets, and other user-provided content remain owned by the
|
|
19
|
+
user unless the user separately chooses to license them.
|
|
20
|
+
|
|
21
|
+
Hosted services, managed deployments, verified broker or market-data adapters,
|
|
22
|
+
enterprise policy packs, compliance packs, support agreements, and other
|
|
23
|
+
official commercial offerings may be distributed under separate commercial
|
|
24
|
+
terms.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__all__ = ["main"]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from tradingcodex_cli.commands.bootstrap import attach, configure_workspace_env, init, service, update
|
|
7
|
+
from tradingcodex_cli.commands.db import db
|
|
8
|
+
from tradingcodex_cli.commands.doctor import doctor
|
|
9
|
+
from tradingcodex_cli.commands.mcp import mcp
|
|
10
|
+
from tradingcodex_cli.commands.orders import approve, audit, postmortem, quality_check, risk_check, validate
|
|
11
|
+
from tradingcodex_cli.commands.policy import policy
|
|
12
|
+
from tradingcodex_cli.commands.profile import profile
|
|
13
|
+
from tradingcodex_cli.commands.research import research
|
|
14
|
+
from tradingcodex_cli.commands.skills import skills
|
|
15
|
+
from tradingcodex_cli.commands.strategies import strategies
|
|
16
|
+
from tradingcodex_cli.commands.subagents import subagents
|
|
17
|
+
from tradingcodex_cli.commands.utils import _safe_read
|
|
18
|
+
from tradingcodex_cli.commands.workspaces import workspace
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main(argv: list[str] | None = None) -> None:
|
|
22
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
23
|
+
if not argv or argv[0] in {"--help", "-h", "help"}:
|
|
24
|
+
print_help()
|
|
25
|
+
return
|
|
26
|
+
command = argv.pop(0)
|
|
27
|
+
try:
|
|
28
|
+
if command == "init":
|
|
29
|
+
init(argv)
|
|
30
|
+
elif command == "attach":
|
|
31
|
+
attach(argv)
|
|
32
|
+
elif command == "update":
|
|
33
|
+
update(argv)
|
|
34
|
+
elif command == "doctor":
|
|
35
|
+
root = configure_workspace_env(Path.cwd())
|
|
36
|
+
doctor(root, _option_value(argv, "--layer") or "all")
|
|
37
|
+
elif command == "service":
|
|
38
|
+
service(argv)
|
|
39
|
+
elif command in {"subagents", "skills", "strategies", "policy", "mcp", "db", "workspace", "profile", "validate", "risk-check", "approve", "quality-check", "audit", "postmortem", "research", "explain-policy"}:
|
|
40
|
+
root = configure_workspace_env(Path.cwd())
|
|
41
|
+
dispatch_workspace_command(root, command, argv)
|
|
42
|
+
else:
|
|
43
|
+
raise ValueError(f"Unknown command: {command}")
|
|
44
|
+
except Exception as exc:
|
|
45
|
+
print(f"{program_name()}: {exc}", file=sys.stderr)
|
|
46
|
+
sys.exit(1)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def dispatch_workspace_command(root: Path, command: str, argv: list[str]) -> None:
|
|
50
|
+
if command == "subagents":
|
|
51
|
+
subagents(root, argv)
|
|
52
|
+
elif command == "skills":
|
|
53
|
+
skills(root, argv)
|
|
54
|
+
elif command == "strategies":
|
|
55
|
+
strategies(root, argv)
|
|
56
|
+
elif command == "policy":
|
|
57
|
+
policy(root, argv)
|
|
58
|
+
elif command == "mcp":
|
|
59
|
+
mcp(root, argv)
|
|
60
|
+
elif command == "db":
|
|
61
|
+
db(root, argv)
|
|
62
|
+
elif command == "workspace":
|
|
63
|
+
workspace(root, argv)
|
|
64
|
+
elif command == "profile":
|
|
65
|
+
profile(root, argv)
|
|
66
|
+
elif command == "validate":
|
|
67
|
+
validate(root, argv)
|
|
68
|
+
elif command == "risk-check":
|
|
69
|
+
risk_check(root, argv)
|
|
70
|
+
elif command == "approve":
|
|
71
|
+
approve(root, argv)
|
|
72
|
+
elif command == "quality-check":
|
|
73
|
+
quality_check(root, argv)
|
|
74
|
+
elif command == "audit":
|
|
75
|
+
audit(root, argv)
|
|
76
|
+
elif command == "postmortem":
|
|
77
|
+
postmortem(root, argv)
|
|
78
|
+
elif command == "research":
|
|
79
|
+
research(root, argv)
|
|
80
|
+
elif command == "explain-policy":
|
|
81
|
+
print("TradingCodex policy model:")
|
|
82
|
+
print("Principal -> Role -> Policy -> Action -> Resource -> Condition\n")
|
|
83
|
+
print("Explicit deny wins. TradingCodex MCP is the only executable trading boundary.\n")
|
|
84
|
+
print(_safe_read(root / ".tradingcodex" / "policies" / "access-policies.yaml"))
|
|
85
|
+
else:
|
|
86
|
+
raise ValueError(f"Unknown command: {command}")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _option_value(args: list[str], name: str) -> str | None:
|
|
90
|
+
try:
|
|
91
|
+
return args[args.index(name) + 1]
|
|
92
|
+
except Exception:
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def program_name() -> str:
|
|
97
|
+
name = Path(sys.argv[0]).name
|
|
98
|
+
return name if name == "tcx" else "tcx"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def print_help() -> None:
|
|
102
|
+
print("""TradingCodex Python/Django
|
|
103
|
+
|
|
104
|
+
Usage:
|
|
105
|
+
tcx attach [workspace] [--overwrite]
|
|
106
|
+
tcx init <workspace> [--overwrite]
|
|
107
|
+
tcx update [workspace] [--no-doctor]
|
|
108
|
+
tcx init --list-modules
|
|
109
|
+
tcx doctor [--layer <layer>]
|
|
110
|
+
tcx workspace status|list
|
|
111
|
+
tcx profile status|list|create|select
|
|
112
|
+
tcx subagents list|status|inspect|diff|project|state|plan|skills|prompt
|
|
113
|
+
tcx skills list [--all]|inspect|propose-add|propose-update|apply-proposal
|
|
114
|
+
tcx skills optional list|inspect|create|update|activate|archive|delete
|
|
115
|
+
tcx strategies list|inspect|create|update|activate|archive|delete
|
|
116
|
+
tcx db path|status|migrate
|
|
117
|
+
tcx research list
|
|
118
|
+
tcx mcp stdio
|
|
119
|
+
tcx service runserver [addrport] [django runserver args]
|
|
120
|
+
""")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from tradingcodex_cli.commands.doctor import doctor
|
|
8
|
+
from tradingcodex_cli.generator import (
|
|
9
|
+
DEFAULT_MODULE_IDS,
|
|
10
|
+
bootstrap_workspace,
|
|
11
|
+
load_module_registry,
|
|
12
|
+
resolve_module_graph,
|
|
13
|
+
templates_dir,
|
|
14
|
+
)
|
|
15
|
+
from tradingcodex_cli.service_autostart import DEFAULT_SERVICE_ADDR
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
PROGRAM_NAME = "tcx"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def init(argv: list[str]) -> None:
|
|
22
|
+
parser = argparse.ArgumentParser(prog=f"{PROGRAM_NAME} init")
|
|
23
|
+
parser.add_argument("project_dir", nargs="?")
|
|
24
|
+
parser.add_argument("--overwrite", action="store_true", help="overwrite files at matching generated workspace paths")
|
|
25
|
+
parser.add_argument("--force", "-f", action="store_true", help=argparse.SUPPRESS)
|
|
26
|
+
parser.add_argument("--dry-run", action="store_true")
|
|
27
|
+
parser.add_argument("--list-modules", action="store_true")
|
|
28
|
+
args = parser.parse_args(argv)
|
|
29
|
+
if args.list_modules:
|
|
30
|
+
registry = load_module_registry(templates_dir())
|
|
31
|
+
for module in resolve_module_graph(registry, DEFAULT_MODULE_IDS):
|
|
32
|
+
print(f"{module.id}: {module.description}")
|
|
33
|
+
return
|
|
34
|
+
if not args.project_dir:
|
|
35
|
+
parser.print_help()
|
|
36
|
+
raise SystemExit(1)
|
|
37
|
+
result = bootstrap_workspace(args.project_dir, force=args.overwrite or args.force, dry_run=args.dry_run)
|
|
38
|
+
if args.dry_run:
|
|
39
|
+
print(f"TradingCodex dry run: {result['targetDir']}")
|
|
40
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
41
|
+
print(f"Capabilities: {', '.join(result['capabilities'])}")
|
|
42
|
+
return
|
|
43
|
+
_finish_bootstrap(result["targetDir"])
|
|
44
|
+
print(f"TradingCodex workspace created: {result['targetDir']}")
|
|
45
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
46
|
+
print_workspace_summary(Path(result["targetDir"]))
|
|
47
|
+
print("\nNext:")
|
|
48
|
+
print(f" cd {result['targetDir']}")
|
|
49
|
+
print(" ./tcx doctor")
|
|
50
|
+
print(f" Open the workspace in Codex and trust it; TradingCodex MCP will start the local dashboard service at http://{DEFAULT_SERVICE_ADDR}/")
|
|
51
|
+
print(" Fully quit and restart Codex, then start from a new thread in this generated workspace so project MCP config is reloaded.")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def attach(argv: list[str]) -> None:
|
|
55
|
+
parser = argparse.ArgumentParser(prog=f"{PROGRAM_NAME} attach")
|
|
56
|
+
parser.add_argument("project_dir", nargs="?", default=".")
|
|
57
|
+
parser.add_argument("--overwrite", action="store_true", help="overwrite matching generated workspace files")
|
|
58
|
+
parser.add_argument("--dry-run", action="store_true")
|
|
59
|
+
args = parser.parse_args(argv)
|
|
60
|
+
target = Path(args.project_dir).resolve()
|
|
61
|
+
force = args.overwrite or (target / ".tradingcodex" / "generated" / "module-lock.json").exists()
|
|
62
|
+
result = bootstrap_workspace(target, force=force, dry_run=args.dry_run)
|
|
63
|
+
if args.dry_run:
|
|
64
|
+
print(f"TradingCodex attach dry run: {result['targetDir']}")
|
|
65
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
66
|
+
return
|
|
67
|
+
_finish_bootstrap(result["targetDir"])
|
|
68
|
+
print(f"TradingCodex workspace attached: {result['targetDir']}")
|
|
69
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
70
|
+
print_workspace_summary(Path(result["targetDir"]))
|
|
71
|
+
print("\nNext:")
|
|
72
|
+
print(" ./tcx doctor")
|
|
73
|
+
print(" Open this workspace in Codex and trust it so project-scoped TradingCodex MCP is loaded.")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def update(argv: list[str]) -> None:
|
|
77
|
+
parser = argparse.ArgumentParser(prog=f"{PROGRAM_NAME} update")
|
|
78
|
+
parser.add_argument("project_dir", nargs="?", default=".")
|
|
79
|
+
parser.add_argument("--dry-run", action="store_true")
|
|
80
|
+
parser.add_argument("--no-doctor", action="store_true", help="skip ./tcx doctor after update")
|
|
81
|
+
args = parser.parse_args(argv)
|
|
82
|
+
target = Path(args.project_dir).resolve()
|
|
83
|
+
if not is_generated_workspace(target):
|
|
84
|
+
raise ValueError(f"Not a TradingCodex generated workspace: {target}. Use tcx attach for first-time setup.")
|
|
85
|
+
result = bootstrap_workspace(target, force=True, dry_run=args.dry_run)
|
|
86
|
+
if args.dry_run:
|
|
87
|
+
print(f"TradingCodex update dry run: {result['targetDir']}")
|
|
88
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
89
|
+
return
|
|
90
|
+
_finish_bootstrap(result["targetDir"])
|
|
91
|
+
print(f"TradingCodex workspace updated: {result['targetDir']}")
|
|
92
|
+
print(f"Modules: {', '.join(result['modules'])}")
|
|
93
|
+
print_workspace_summary(Path(result["targetDir"]))
|
|
94
|
+
if args.no_doctor:
|
|
95
|
+
print("\nNext:")
|
|
96
|
+
print(" ./tcx doctor")
|
|
97
|
+
print(" Fully quit and restart Codex, then start from a new thread so project MCP config is reloaded.")
|
|
98
|
+
return
|
|
99
|
+
print("\nRunning doctor:")
|
|
100
|
+
doctor(Path(result["targetDir"]), "all")
|
|
101
|
+
print("\nNext:")
|
|
102
|
+
print(" Fully quit and restart Codex, then start from a new thread so project MCP config is reloaded.")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def service(argv: list[str]) -> None:
|
|
106
|
+
sub = argv[0] if argv else "runserver"
|
|
107
|
+
if sub != "runserver":
|
|
108
|
+
raise ValueError(f"Usage: {PROGRAM_NAME} service runserver [addrport] [django runserver args]")
|
|
109
|
+
from django.core.management import execute_from_command_line
|
|
110
|
+
from tradingcodex_cli.service_autostart import compatible_service_running, service_http_url
|
|
111
|
+
|
|
112
|
+
configure_workspace_env(Path.cwd())
|
|
113
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tradingcodex_service.settings")
|
|
114
|
+
runserver_args = argv[1:]
|
|
115
|
+
if not runserver_args or runserver_args[0].startswith("-"):
|
|
116
|
+
runserver_args = [DEFAULT_SERVICE_ADDR, *runserver_args]
|
|
117
|
+
addr = runserver_args[0]
|
|
118
|
+
if compatible_service_running(addr):
|
|
119
|
+
print(f"TradingCodex service already running at {service_http_url(addr)}")
|
|
120
|
+
return
|
|
121
|
+
execute_from_command_line(["manage.py", "runserver", *runserver_args])
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def configure_workspace_env(root: Path, *, force: bool = False) -> Path:
|
|
125
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tradingcodex_service.settings")
|
|
126
|
+
if force or not os.environ.get("TRADINGCODEX_WORKSPACE_ROOT"):
|
|
127
|
+
os.environ["TRADINGCODEX_WORKSPACE_ROOT"] = str(root.resolve())
|
|
128
|
+
return Path(os.environ["TRADINGCODEX_WORKSPACE_ROOT"]).resolve()
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def print_workspace_summary(root: Path) -> None:
|
|
132
|
+
from tradingcodex_service.application.runtime import ensure_workspace_manifest, tradingcodex_db_path
|
|
133
|
+
|
|
134
|
+
manifest = ensure_workspace_manifest(root)
|
|
135
|
+
profile = manifest["active_profile"]
|
|
136
|
+
print(f"Workspace: {manifest['project_name']}")
|
|
137
|
+
print(f"Workspace ID: {manifest['workspace_id']}")
|
|
138
|
+
print(f"Active Profile: {profile['label']} ({profile['portfolio_id']}/{profile['account_id']}/{profile['strategy_id']})")
|
|
139
|
+
print(f"Central DB: {tradingcodex_db_path()}")
|
|
140
|
+
print(f"MCP Scope: {manifest['mcp_scope']}")
|
|
141
|
+
print(f"Execution Mode: {manifest['execution_mode']}")
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def is_generated_workspace(path: Path) -> bool:
|
|
145
|
+
return (
|
|
146
|
+
(path / ".tradingcodex" / "workspace.json").is_file()
|
|
147
|
+
and (path / ".tradingcodex" / "generated" / "module-lock.json").is_file()
|
|
148
|
+
and (path / "tcx").is_file()
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _finish_bootstrap(target_dir: str) -> None:
|
|
153
|
+
root = configure_workspace_env(Path(target_dir), force=True)
|
|
154
|
+
from tradingcodex_service.application.runtime import ensure_runtime_database, persist_workspace_context_if_available
|
|
155
|
+
|
|
156
|
+
ensure_runtime_database(root)
|
|
157
|
+
persist_workspace_context_if_available(root)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from tradingcodex_service.application.runtime import (
|
|
6
|
+
ensure_runtime_database,
|
|
7
|
+
persist_workspace_context_if_available,
|
|
8
|
+
tradingcodex_db_path,
|
|
9
|
+
tradingcodex_home,
|
|
10
|
+
)
|
|
11
|
+
from tradingcodex_cli.commands.utils import print_json
|
|
12
|
+
|
|
13
|
+
def db(root: Path, argv: list[str]) -> None:
|
|
14
|
+
sub = argv[0] if argv else "status"
|
|
15
|
+
if sub == "path":
|
|
16
|
+
print(str(tradingcodex_db_path()))
|
|
17
|
+
return
|
|
18
|
+
if sub == "migrate":
|
|
19
|
+
ensure_runtime_database(root)
|
|
20
|
+
print_json({"status": "migrated", "db_path": str(tradingcodex_db_path()), "db_canonical": True, "workspace_context": persist_workspace_context_if_available(root)})
|
|
21
|
+
return
|
|
22
|
+
if sub == "status":
|
|
23
|
+
ensure_runtime_database(root)
|
|
24
|
+
db_path = tradingcodex_db_path()
|
|
25
|
+
print_json({
|
|
26
|
+
"status": "ok",
|
|
27
|
+
"home": str(tradingcodex_home()),
|
|
28
|
+
"db_path": str(db_path),
|
|
29
|
+
"db_exists": db_path.exists(),
|
|
30
|
+
"workspace_root": str(root),
|
|
31
|
+
"workspace_is_provenance_only": True,
|
|
32
|
+
"db_canonical": True,
|
|
33
|
+
"workspace_context": persist_workspace_context_if_available(root),
|
|
34
|
+
})
|
|
35
|
+
return
|
|
36
|
+
raise ValueError("Usage: tcx db status|path|migrate")
|