mycode-ai 0.1.0__tar.gz

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.
Files changed (76) hide show
  1. mycode_ai-0.1.0/LICENSE +21 -0
  2. mycode_ai-0.1.0/PKG-INFO +161 -0
  3. mycode_ai-0.1.0/README.md +143 -0
  4. mycode_ai-0.1.0/pyproject.toml +39 -0
  5. mycode_ai-0.1.0/setup.cfg +4 -0
  6. mycode_ai-0.1.0/src/mycode/__init__.py +145 -0
  7. mycode_ai-0.1.0/src/mycode/__main__.py +7 -0
  8. mycode_ai-0.1.0/src/mycode/cli.py +177 -0
  9. mycode_ai-0.1.0/src/mycode/engine.py +2440 -0
  10. mycode_ai-0.1.0/src/mycode/ingester.py +1039 -0
  11. mycode_ai-0.1.0/src/mycode/interface.py +752 -0
  12. mycode_ai-0.1.0/src/mycode/js_ingester.py +1141 -0
  13. mycode_ai-0.1.0/src/mycode/library/__init__.py +24 -0
  14. mycode_ai-0.1.0/src/mycode/library/loader.py +502 -0
  15. mycode_ai-0.1.0/src/mycode/pipeline.py +850 -0
  16. mycode_ai-0.1.0/src/mycode/profiles/javascript/anthropic_node.json +183 -0
  17. mycode_ai-0.1.0/src/mycode/profiles/javascript/axios.json +181 -0
  18. mycode_ai-0.1.0/src/mycode/profiles/javascript/chartjs.json +231 -0
  19. mycode_ai-0.1.0/src/mycode/profiles/javascript/dotenv.json +133 -0
  20. mycode_ai-0.1.0/src/mycode/profiles/javascript/express.json +218 -0
  21. mycode_ai-0.1.0/src/mycode/profiles/javascript/google_auth_library.json +198 -0
  22. mycode_ai-0.1.0/src/mycode/profiles/javascript/langchainjs.json +185 -0
  23. mycode_ai-0.1.0/src/mycode/profiles/javascript/mongoose.json +188 -0
  24. mycode_ai-0.1.0/src/mycode/profiles/javascript/nextjs.json +217 -0
  25. mycode_ai-0.1.0/src/mycode/profiles/javascript/node_core.json +221 -0
  26. mycode_ai-0.1.0/src/mycode/profiles/javascript/openai_node.json +186 -0
  27. mycode_ai-0.1.0/src/mycode/profiles/javascript/plotlyjs.json +233 -0
  28. mycode_ai-0.1.0/src/mycode/profiles/javascript/prisma.json +196 -0
  29. mycode_ai-0.1.0/src/mycode/profiles/javascript/react.json +262 -0
  30. mycode_ai-0.1.0/src/mycode/profiles/javascript/react_chartjs_2.json +225 -0
  31. mycode_ai-0.1.0/src/mycode/profiles/javascript/react_plotlyjs.json +226 -0
  32. mycode_ai-0.1.0/src/mycode/profiles/javascript/socketio.json +227 -0
  33. mycode_ai-0.1.0/src/mycode/profiles/javascript/stripe.json +181 -0
  34. mycode_ai-0.1.0/src/mycode/profiles/javascript/supabase_js.json +185 -0
  35. mycode_ai-0.1.0/src/mycode/profiles/javascript/svelte.json +225 -0
  36. mycode_ai-0.1.0/src/mycode/profiles/javascript/tailwindcss.json +216 -0
  37. mycode_ai-0.1.0/src/mycode/profiles/javascript/threejs.json +243 -0
  38. mycode_ai-0.1.0/src/mycode/profiles/javascript/zod.json +180 -0
  39. mycode_ai-0.1.0/src/mycode/profiles/python/anthropic.json +225 -0
  40. mycode_ai-0.1.0/src/mycode/profiles/python/chromadb.json +232 -0
  41. mycode_ai-0.1.0/src/mycode/profiles/python/fastapi.json +236 -0
  42. mycode_ai-0.1.0/src/mycode/profiles/python/flask.json +236 -0
  43. mycode_ai-0.1.0/src/mycode/profiles/python/gradio.json +228 -0
  44. mycode_ai-0.1.0/src/mycode/profiles/python/httpx.json +246 -0
  45. mycode_ai-0.1.0/src/mycode/profiles/python/langchain.json +235 -0
  46. mycode_ai-0.1.0/src/mycode/profiles/python/llamaindex.json +229 -0
  47. mycode_ai-0.1.0/src/mycode/profiles/python/numpy.json +219 -0
  48. mycode_ai-0.1.0/src/mycode/profiles/python/openai.json +228 -0
  49. mycode_ai-0.1.0/src/mycode/profiles/python/os_pathlib.json +232 -0
  50. mycode_ai-0.1.0/src/mycode/profiles/python/pandas.json +236 -0
  51. mycode_ai-0.1.0/src/mycode/profiles/python/pydantic.json +230 -0
  52. mycode_ai-0.1.0/src/mycode/profiles/python/requests.json +231 -0
  53. mycode_ai-0.1.0/src/mycode/profiles/python/sqlalchemy.json +232 -0
  54. mycode_ai-0.1.0/src/mycode/profiles/python/sqlite3.json +224 -0
  55. mycode_ai-0.1.0/src/mycode/profiles/python/streamlit.json +239 -0
  56. mycode_ai-0.1.0/src/mycode/profiles/python/supabase.json +229 -0
  57. mycode_ai-0.1.0/src/mycode/recorder.py +513 -0
  58. mycode_ai-0.1.0/src/mycode/report.py +1700 -0
  59. mycode_ai-0.1.0/src/mycode/scenario.py +1365 -0
  60. mycode_ai-0.1.0/src/mycode/session.py +783 -0
  61. mycode_ai-0.1.0/src/mycode_ai.egg-info/PKG-INFO +161 -0
  62. mycode_ai-0.1.0/src/mycode_ai.egg-info/SOURCES.txt +74 -0
  63. mycode_ai-0.1.0/src/mycode_ai.egg-info/dependency_links.txt +1 -0
  64. mycode_ai-0.1.0/src/mycode_ai.egg-info/entry_points.txt +2 -0
  65. mycode_ai-0.1.0/src/mycode_ai.egg-info/top_level.txt +1 -0
  66. mycode_ai-0.1.0/tests/test_engine.py +1649 -0
  67. mycode_ai-0.1.0/tests/test_ingester.py +1311 -0
  68. mycode_ai-0.1.0/tests/test_integration.py +542 -0
  69. mycode_ai-0.1.0/tests/test_interface.py +679 -0
  70. mycode_ai-0.1.0/tests/test_js_ingester.py +1085 -0
  71. mycode_ai-0.1.0/tests/test_library.py +831 -0
  72. mycode_ai-0.1.0/tests/test_pipeline.py +869 -0
  73. mycode_ai-0.1.0/tests/test_recorder.py +760 -0
  74. mycode_ai-0.1.0/tests/test_report.py +1903 -0
  75. mycode_ai-0.1.0/tests/test_scenario.py +2013 -0
  76. mycode_ai-0.1.0/tests/test_session.py +966 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Machine Adjacent Systems
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: mycode-ai
3
+ Version: 0.1.0
4
+ Summary: Stress-testing tool for AI-generated code
5
+ Author: Machine Adjacent Systems
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Manav-Guha/mycode
8
+ Project-URL: Repository, https://github.com/Manav-Guha/mycode
9
+ Project-URL: Issues, https://github.com/Manav-Guha/mycode/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Testing
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: license-file
18
+
19
+ # myCode
20
+
21
+ **Built it with AI? Test it before it breaks.**
22
+
23
+ Stress-testing tool for AI-generated code. Point it at your project, describe what it does, and find out where it breaks under real-world conditions.
24
+
25
+ ## What It Does
26
+
27
+ You built an app with ChatGPT, Cursor, Claude, or Copilot. It works on your machine. But what happens when 100 users hit it at once? When the CSV grows to 100,000 rows? When someone uploads a 50MB file? When the API you depend on goes slow?
28
+
29
+ myCode answers these questions. It reads your code, understands your dependencies, generates stress scenarios, runs your actual code under escalating conditions, and tells you — in plain language — where it breaks.
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ pip install mycode-ai
35
+ mycode ~/path/to/your/project
36
+ ```
37
+
38
+ That's it. myCode will:
39
+ 1. Ask you what your project does (in your words, not engineering language)
40
+ 2. Show you what it plans to test and let you approve
41
+ 3. Run stress tests in a safe sandbox (your original files are never touched)
42
+ 4. Give you a diagnostic report
43
+
44
+ ## What It Tests
45
+
46
+ - **Data volume scaling** — what happens as your data grows from 100 rows to 100,000
47
+ - **Memory pressure** — does your app leak memory over repeated use
48
+ - **Concurrent load** — multiple users or processes hitting shared resources
49
+ - **Edge case inputs** — malformed data, empty values, unexpected types
50
+ - **Dependency interactions** — where one component's failure cascades into another
51
+
52
+ ## Supported Languages
53
+
54
+ - Python (Flask, FastAPI, Streamlit, pandas, NumPy, SQLAlchemy, LangChain, and more)
55
+ - JavaScript/Node.js (React, Next.js, Express, Three.js, Prisma, Socket.io, and more)
56
+
57
+ 36 dependency profiles included. Unrecognized dependencies get generic stress testing.
58
+
59
+ ## Example Output
60
+
61
+ ```
62
+ ============================================================
63
+ myCode Diagnostic Report
64
+ ============================================================
65
+
66
+ We found some problems that could affect your Incident Tracker under real-world conditions.
67
+
68
+ - When your Incident Tracker is handling multiple users at once, requests timed out under load.
69
+ - When your Incident Tracker is downloading large responses, the system hits memory limits.
70
+ - When your Incident Tracker receives unexpected input, the code crashes instead of handling it gracefully.
71
+
72
+ Found 3 critical issue(s) and 25 warning(s) across 70 scenarios.
73
+ Performance degradation detected in 11 area(s).
74
+ ```
75
+
76
+ ## Offline Mode
77
+
78
+ Run without any API calls:
79
+
80
+ ```bash
81
+ mycode ~/path/to/your/project --offline
82
+ ```
83
+
84
+ Uses template-based scenario generation instead of LLM. Still runs all stress tests and produces a full report.
85
+
86
+ ## Online Mode (Gemini Flash)
87
+
88
+ With an API key, myCode uses Gemini Flash to generate a natural-language summary of findings:
89
+
90
+ ```bash
91
+ export GEMINI_API_KEY=your_key_here
92
+ mycode ~/path/to/your/project
93
+ ```
94
+
95
+ Or pass it directly:
96
+
97
+ ```bash
98
+ mycode ~/path/to/your/project --api-key your_key_here
99
+ ```
100
+
101
+ Free tier: get a Gemini API key at https://aistudio.google.com/apikey (1,000 requests/day, no credit card).
102
+
103
+ ## How It Works
104
+
105
+ 1. **Ingester** parses your code (AST analysis), maps dependencies, identifies coupling points
106
+ 2. **Conversational interface** asks what your project does and how you expect it to be used
107
+ 3. **Scenario generator** creates stress test configurations based on your code + your intent
108
+ 4. **Execution engine** runs your actual code in a sandbox with synthetic data under escalating conditions
109
+ 5. **Report generator** translates raw results into plain-language diagnostics
110
+
111
+ Your original files are never modified. Everything runs in a temporary environment that is destroyed on completion.
112
+
113
+ ## Safety
114
+
115
+ - Your code is copied into a temporary sandbox — originals are never touched
116
+ - Resource caps (memory, CPU, timeout) prevent runaway processes
117
+ - Sandbox is destroyed on completion, crash, or interrupt (Ctrl+C)
118
+ - No data is collected without explicit opt-in consent
119
+ - No source code is ever sent to any API — only project descriptions and dependency names
120
+
121
+ **Important:** myCode executes your project's code on your machine. Do not point it at code you do not trust.
122
+
123
+ ## What myCode Is NOT
124
+
125
+ - Not a linter or code reviewer
126
+ - Not a security scanner
127
+ - Not a code generator — myCode never modifies your code
128
+ - Not a guarantee of code quality — it's a diagnostic tool
129
+
130
+ ## Requirements
131
+
132
+ - Python 3.10+
133
+ - Node.js 18+ (for JavaScript project testing)
134
+
135
+ ## Validated Against Real Projects
136
+
137
+ myCode has been tested against real-world projects across Python and JavaScript:
138
+
139
+ | Project | Language | Scenarios | Critical Issues | Result |
140
+ |---------|----------|-----------|-----------------|--------|
141
+ | Multi-framework web app (Flask + FastAPI + Streamlit) | Python | 70 | 3 | Timeouts under load, memory scaling issues |
142
+ | Analysis tool (React + charting libraries) | JavaScript | 25 | 4 | Edge case input crashes, memory growth |
143
+ | Multi-component framework (React) | JavaScript | 19 | 0 | All clean |
144
+ | Expense tracker (React) | JavaScript | 5 | 0 | Mostly clean |
145
+ | CLI tool — myCode self-test (26 files, 24K lines) | Python | 279 | 0 | All clean |
146
+
147
+ 398 total scenarios, 7 critical issues found, 0 myCode errors.
148
+
149
+ [See full anonymized test reports →](docs/validation-reports.md)
150
+
151
+ ## Contact
152
+
153
+ Machine.Adjacent.Systems@protonmail.com
154
+
155
+ ## License
156
+
157
+ MIT
158
+
159
+ ---
160
+
161
+ *myCode diagnoses — it does not prescribe. Interpret results in your context.*
@@ -0,0 +1,143 @@
1
+ # myCode
2
+
3
+ **Built it with AI? Test it before it breaks.**
4
+
5
+ Stress-testing tool for AI-generated code. Point it at your project, describe what it does, and find out where it breaks under real-world conditions.
6
+
7
+ ## What It Does
8
+
9
+ You built an app with ChatGPT, Cursor, Claude, or Copilot. It works on your machine. But what happens when 100 users hit it at once? When the CSV grows to 100,000 rows? When someone uploads a 50MB file? When the API you depend on goes slow?
10
+
11
+ myCode answers these questions. It reads your code, understands your dependencies, generates stress scenarios, runs your actual code under escalating conditions, and tells you — in plain language — where it breaks.
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ pip install mycode-ai
17
+ mycode ~/path/to/your/project
18
+ ```
19
+
20
+ That's it. myCode will:
21
+ 1. Ask you what your project does (in your words, not engineering language)
22
+ 2. Show you what it plans to test and let you approve
23
+ 3. Run stress tests in a safe sandbox (your original files are never touched)
24
+ 4. Give you a diagnostic report
25
+
26
+ ## What It Tests
27
+
28
+ - **Data volume scaling** — what happens as your data grows from 100 rows to 100,000
29
+ - **Memory pressure** — does your app leak memory over repeated use
30
+ - **Concurrent load** — multiple users or processes hitting shared resources
31
+ - **Edge case inputs** — malformed data, empty values, unexpected types
32
+ - **Dependency interactions** — where one component's failure cascades into another
33
+
34
+ ## Supported Languages
35
+
36
+ - Python (Flask, FastAPI, Streamlit, pandas, NumPy, SQLAlchemy, LangChain, and more)
37
+ - JavaScript/Node.js (React, Next.js, Express, Three.js, Prisma, Socket.io, and more)
38
+
39
+ 36 dependency profiles included. Unrecognized dependencies get generic stress testing.
40
+
41
+ ## Example Output
42
+
43
+ ```
44
+ ============================================================
45
+ myCode Diagnostic Report
46
+ ============================================================
47
+
48
+ We found some problems that could affect your Incident Tracker under real-world conditions.
49
+
50
+ - When your Incident Tracker is handling multiple users at once, requests timed out under load.
51
+ - When your Incident Tracker is downloading large responses, the system hits memory limits.
52
+ - When your Incident Tracker receives unexpected input, the code crashes instead of handling it gracefully.
53
+
54
+ Found 3 critical issue(s) and 25 warning(s) across 70 scenarios.
55
+ Performance degradation detected in 11 area(s).
56
+ ```
57
+
58
+ ## Offline Mode
59
+
60
+ Run without any API calls:
61
+
62
+ ```bash
63
+ mycode ~/path/to/your/project --offline
64
+ ```
65
+
66
+ Uses template-based scenario generation instead of LLM. Still runs all stress tests and produces a full report.
67
+
68
+ ## Online Mode (Gemini Flash)
69
+
70
+ With an API key, myCode uses Gemini Flash to generate a natural-language summary of findings:
71
+
72
+ ```bash
73
+ export GEMINI_API_KEY=your_key_here
74
+ mycode ~/path/to/your/project
75
+ ```
76
+
77
+ Or pass it directly:
78
+
79
+ ```bash
80
+ mycode ~/path/to/your/project --api-key your_key_here
81
+ ```
82
+
83
+ Free tier: get a Gemini API key at https://aistudio.google.com/apikey (1,000 requests/day, no credit card).
84
+
85
+ ## How It Works
86
+
87
+ 1. **Ingester** parses your code (AST analysis), maps dependencies, identifies coupling points
88
+ 2. **Conversational interface** asks what your project does and how you expect it to be used
89
+ 3. **Scenario generator** creates stress test configurations based on your code + your intent
90
+ 4. **Execution engine** runs your actual code in a sandbox with synthetic data under escalating conditions
91
+ 5. **Report generator** translates raw results into plain-language diagnostics
92
+
93
+ Your original files are never modified. Everything runs in a temporary environment that is destroyed on completion.
94
+
95
+ ## Safety
96
+
97
+ - Your code is copied into a temporary sandbox — originals are never touched
98
+ - Resource caps (memory, CPU, timeout) prevent runaway processes
99
+ - Sandbox is destroyed on completion, crash, or interrupt (Ctrl+C)
100
+ - No data is collected without explicit opt-in consent
101
+ - No source code is ever sent to any API — only project descriptions and dependency names
102
+
103
+ **Important:** myCode executes your project's code on your machine. Do not point it at code you do not trust.
104
+
105
+ ## What myCode Is NOT
106
+
107
+ - Not a linter or code reviewer
108
+ - Not a security scanner
109
+ - Not a code generator — myCode never modifies your code
110
+ - Not a guarantee of code quality — it's a diagnostic tool
111
+
112
+ ## Requirements
113
+
114
+ - Python 3.10+
115
+ - Node.js 18+ (for JavaScript project testing)
116
+
117
+ ## Validated Against Real Projects
118
+
119
+ myCode has been tested against real-world projects across Python and JavaScript:
120
+
121
+ | Project | Language | Scenarios | Critical Issues | Result |
122
+ |---------|----------|-----------|-----------------|--------|
123
+ | Multi-framework web app (Flask + FastAPI + Streamlit) | Python | 70 | 3 | Timeouts under load, memory scaling issues |
124
+ | Analysis tool (React + charting libraries) | JavaScript | 25 | 4 | Edge case input crashes, memory growth |
125
+ | Multi-component framework (React) | JavaScript | 19 | 0 | All clean |
126
+ | Expense tracker (React) | JavaScript | 5 | 0 | Mostly clean |
127
+ | CLI tool — myCode self-test (26 files, 24K lines) | Python | 279 | 0 | All clean |
128
+
129
+ 398 total scenarios, 7 critical issues found, 0 myCode errors.
130
+
131
+ [See full anonymized test reports →](docs/validation-reports.md)
132
+
133
+ ## Contact
134
+
135
+ Machine.Adjacent.Systems@protonmail.com
136
+
137
+ ## License
138
+
139
+ MIT
140
+
141
+ ---
142
+
143
+ *myCode diagnoses — it does not prescribe. Interpret results in your context.*
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mycode-ai"
7
+ version = "0.1.0"
8
+ description = "Stress-testing tool for AI-generated code"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ {name = "Machine Adjacent Systems"},
13
+ ]
14
+ license = "MIT"
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Software Development :: Testing",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/Manav-Guha/mycode"
24
+ Repository = "https://github.com/Manav-Guha/mycode"
25
+ Issues = "https://github.com/Manav-Guha/mycode/issues"
26
+
27
+ [project.scripts]
28
+ mycode = "mycode.cli:main"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+
33
+ [tool.setuptools.package-data]
34
+ mycode = ["profiles/**/*.json"]
35
+
36
+ [tool.pytest.ini_options]
37
+ markers = [
38
+ "slow: integration tests that create real virtual environments",
39
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,145 @@
1
+ """myCode — Stress-testing tool for AI-generated code."""
2
+
3
+ from mycode.ingester import (
4
+ CouplingPoint,
5
+ DependencyInfo,
6
+ FileAnalysis,
7
+ FunctionFlow,
8
+ IngestionError,
9
+ IngestionResult,
10
+ ProjectIngester,
11
+ )
12
+ from mycode.js_ingester import JsProjectIngester
13
+ from mycode.library import (
14
+ ComponentLibrary,
15
+ DependencyProfile,
16
+ LibraryError,
17
+ ProfileMatch,
18
+ ProfileNotFoundError,
19
+ )
20
+ from mycode.scenario import (
21
+ LLMConfig,
22
+ LLMError,
23
+ LLMResponseError,
24
+ ScenarioError,
25
+ ScenarioGenerator,
26
+ ScenarioGeneratorResult,
27
+ StressTestScenario,
28
+ )
29
+ from mycode.engine import (
30
+ EngineError,
31
+ ExecutionEngine,
32
+ ExecutionEngineResult,
33
+ ScenarioResult,
34
+ StepResult,
35
+ )
36
+ from mycode.interface import (
37
+ ConversationalInterface,
38
+ InterfaceError,
39
+ InterfaceResult,
40
+ OperationalIntent,
41
+ ScenarioReview,
42
+ TerminalIO,
43
+ UserIO,
44
+ summarize_ingestion,
45
+ )
46
+ from mycode.report import (
47
+ DegradationPoint,
48
+ DiagnosticReport,
49
+ Finding,
50
+ ReportError,
51
+ ReportGenerator,
52
+ )
53
+ from mycode.recorder import (
54
+ ConsentError,
55
+ InteractionRecorder,
56
+ RecorderError,
57
+ SessionRecord,
58
+ )
59
+ from mycode.pipeline import (
60
+ LanguageDetectionError,
61
+ PipelineConfig,
62
+ PipelineError,
63
+ PipelineResult,
64
+ StageResult,
65
+ detect_language,
66
+ run_pipeline,
67
+ )
68
+ from mycode.session import (
69
+ DependencyInstallError,
70
+ EnvironmentInfo,
71
+ ResourceCaps,
72
+ SessionError,
73
+ SessionManager,
74
+ SessionResult,
75
+ VenvCreationError,
76
+ )
77
+
78
+ __all__ = [
79
+ # Session Manager (C1)
80
+ "SessionManager",
81
+ "ResourceCaps",
82
+ "EnvironmentInfo",
83
+ "SessionResult",
84
+ "SessionError",
85
+ "VenvCreationError",
86
+ "DependencyInstallError",
87
+ # Project Ingester (C2)
88
+ "ProjectIngester",
89
+ "IngestionResult",
90
+ "IngestionError",
91
+ "FileAnalysis",
92
+ "DependencyInfo",
93
+ "FunctionFlow",
94
+ "CouplingPoint",
95
+ # JS Project Ingester (C3)
96
+ "JsProjectIngester",
97
+ # Component Library (C4)
98
+ "ComponentLibrary",
99
+ "DependencyProfile",
100
+ "ProfileMatch",
101
+ "LibraryError",
102
+ "ProfileNotFoundError",
103
+ # Scenario Generator (D1)
104
+ "ScenarioGenerator",
105
+ "ScenarioGeneratorResult",
106
+ "StressTestScenario",
107
+ "LLMConfig",
108
+ "ScenarioError",
109
+ "LLMError",
110
+ "LLMResponseError",
111
+ # Execution Engine (D2)
112
+ "ExecutionEngine",
113
+ "ExecutionEngineResult",
114
+ "ScenarioResult",
115
+ "StepResult",
116
+ "EngineError",
117
+ # Pipeline (D3)
118
+ "run_pipeline",
119
+ "detect_language",
120
+ "PipelineConfig",
121
+ "PipelineResult",
122
+ "StageResult",
123
+ "PipelineError",
124
+ "LanguageDetectionError",
125
+ # Conversational Interface (E1)
126
+ "ConversationalInterface",
127
+ "InterfaceResult",
128
+ "OperationalIntent",
129
+ "ScenarioReview",
130
+ "InterfaceError",
131
+ "TerminalIO",
132
+ "UserIO",
133
+ "summarize_ingestion",
134
+ # Report Generator (E2)
135
+ "ReportGenerator",
136
+ "DiagnosticReport",
137
+ "Finding",
138
+ "DegradationPoint",
139
+ "ReportError",
140
+ # Interaction Recorder (E3)
141
+ "InteractionRecorder",
142
+ "SessionRecord",
143
+ "RecorderError",
144
+ "ConsentError",
145
+ ]
@@ -0,0 +1,7 @@
1
+ """Allow running myCode as: python -m mycode"""
2
+
3
+ import sys
4
+
5
+ from mycode.cli import main
6
+
7
+ sys.exit(main())
@@ -0,0 +1,177 @@
1
+ """myCode CLI — stress-test AI-generated code from the command line.
2
+
3
+ Usage::
4
+
5
+ python -m mycode /path/to/project [options]
6
+
7
+ Options::
8
+
9
+ --offline Use offline mode (no LLM API calls)
10
+ --language LANG Force language (python or javascript)
11
+ --consent Opt in to anonymous interaction recording
12
+ --api-key KEY API key for LLM backend
13
+ --api-base URL Base URL for OpenAI-compatible API
14
+ --model MODEL Model identifier
15
+ --skip-version-check Skip PyPI/npm version lookups
16
+ --non-interactive Skip conversational interface
17
+ --verbose / -v Enable verbose logging
18
+ """
19
+
20
+ import argparse
21
+ import logging
22
+ import os
23
+ import sys
24
+ from pathlib import Path
25
+
26
+ from mycode.interface import TerminalIO
27
+ from mycode.pipeline import PipelineConfig, run_pipeline
28
+ from mycode.scenario import LLMConfig
29
+
30
+
31
+ def build_parser() -> argparse.ArgumentParser:
32
+ """Build the CLI argument parser."""
33
+ parser = argparse.ArgumentParser(
34
+ prog="mycode",
35
+ description=(
36
+ "myCode — Stress-test AI-generated code before it breaks.\n\n"
37
+ "Point myCode at your project, describe what it does, "
38
+ "and get a plain-language report showing where it breaks."
39
+ ),
40
+ formatter_class=argparse.RawDescriptionHelpFormatter,
41
+ )
42
+ parser.add_argument(
43
+ "project_path",
44
+ type=Path,
45
+ help="Path to the project directory to test",
46
+ )
47
+ parser.add_argument(
48
+ "--offline",
49
+ action="store_true",
50
+ default=False,
51
+ help="Run without LLM API calls (uses offline scenario generation)",
52
+ )
53
+ parser.add_argument(
54
+ "--language",
55
+ choices=["python", "javascript"],
56
+ default=None,
57
+ help="Force project language (auto-detected if not specified)",
58
+ )
59
+ parser.add_argument(
60
+ "--consent",
61
+ action="store_true",
62
+ default=False,
63
+ help="Opt in to anonymous interaction recording",
64
+ )
65
+ parser.add_argument(
66
+ "--api-key",
67
+ default=None,
68
+ help="API key for the LLM backend",
69
+ )
70
+ parser.add_argument(
71
+ "--api-base",
72
+ default=None,
73
+ help="Base URL for OpenAI-compatible API endpoint",
74
+ )
75
+ parser.add_argument(
76
+ "--model",
77
+ default=None,
78
+ help="LLM model identifier",
79
+ )
80
+ parser.add_argument(
81
+ "--skip-version-check",
82
+ action="store_true",
83
+ default=False,
84
+ help="Skip PyPI/npm version lookups (faster)",
85
+ )
86
+ parser.add_argument(
87
+ "--verbose", "-v",
88
+ action="store_true",
89
+ default=False,
90
+ help="Enable verbose logging",
91
+ )
92
+ parser.add_argument(
93
+ "--non-interactive",
94
+ action="store_true",
95
+ default=False,
96
+ help="Skip conversational interface (use default stress testing profile)",
97
+ )
98
+ return parser
99
+
100
+
101
+ def main(argv: list[str] | None = None) -> int:
102
+ """CLI entry point. Returns exit code (0=success, 1=failure)."""
103
+ parser = build_parser()
104
+ args = parser.parse_args(argv)
105
+
106
+ # Configure logging
107
+ level = logging.DEBUG if args.verbose else logging.WARNING
108
+ logging.basicConfig(level=level, format="%(levelname)s: %(message)s")
109
+
110
+ # Validate project path
111
+ project = Path(args.project_path).resolve()
112
+ if not project.exists():
113
+ print(f"Error: Project path does not exist: {project}", file=sys.stderr)
114
+ return 1
115
+ if not project.is_dir():
116
+ print(f"Error: Project path is not a directory: {project}", file=sys.stderr)
117
+ return 1
118
+
119
+ # Build LLM config — flag takes precedence, then env var
120
+ api_key = args.api_key or os.environ.get("GEMINI_API_KEY")
121
+ llm_config = None
122
+ if api_key:
123
+ kwargs: dict = {"api_key": api_key}
124
+ if args.api_base:
125
+ kwargs["base_url"] = args.api_base
126
+ if args.model:
127
+ kwargs["model"] = args.model
128
+ llm_config = LLMConfig(**kwargs)
129
+
130
+ # Offline mode: explicit flag or no API key available
131
+ offline = args.offline or (api_key is None)
132
+
133
+ # Build pipeline config
134
+ non_interactive = args.non_interactive or not sys.stdin.isatty()
135
+ config = PipelineConfig(
136
+ project_path=project,
137
+ language=args.language,
138
+ llm_config=llm_config,
139
+ offline=offline,
140
+ skip_version_check=args.skip_version_check,
141
+ consent=args.consent,
142
+ io=TerminalIO(),
143
+ operational_intent="General stress testing" if non_interactive else "",
144
+ auto_approve_scenarios=non_interactive,
145
+ )
146
+
147
+ # Run pipeline
148
+ result = run_pipeline(config)
149
+
150
+ # Display report
151
+ if result.report:
152
+ print(result.report.as_text())
153
+ elif result.execution:
154
+ print("\n--- Execution Results (report generation failed) ---")
155
+ print(f"Scenarios completed: {result.execution.scenarios_completed}")
156
+ print(f"Scenarios failed: {result.execution.scenarios_failed}")
157
+ if result.warnings:
158
+ print("\nWarnings:")
159
+ for w in result.warnings:
160
+ print(f" - {w}")
161
+ else:
162
+ failed = result.failed_stage
163
+ if failed:
164
+ print(f"\nPipeline failed at stage: {failed}")
165
+ for s in result.stages:
166
+ if not s.success:
167
+ print(f" Error ({s.stage}): {s.error}")
168
+ if result.warnings:
169
+ print("\nWarnings:")
170
+ for w in result.warnings:
171
+ print(f" - {w}")
172
+
173
+ # Recording path
174
+ if result.recording_path:
175
+ print(f"\nSession recorded: {result.recording_path}")
176
+
177
+ return 0 if result.success else 1