comptext-codex 5.0.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.
@@ -0,0 +1,55 @@
1
+ """Module A: Core Commands - Essential CompText DSL commands for text manipulation."""
2
+
3
+ import re
4
+ from typing import Any, Dict
5
+
6
+ from comptext_codex.registry import codex_module, codex_command
7
+ from .base import BaseModule
8
+
9
+
10
+ @codex_module(
11
+ code="A",
12
+ name="Core Commands",
13
+ purpose="Essential CompText DSL commands for text manipulation",
14
+ token_priority="high",
15
+ security={"pii_safe": True, "threat_model": "prompt_injection_hardened"},
16
+ privacy={"dp_budget": "epsilon<=1.0_per_call", "federated_ready": True},
17
+ )
18
+ class ModuleA(BaseModule):
19
+ """Core Commands module for text manipulation and basic operations."""
20
+
21
+ @codex_command(
22
+ syntax="@A:compress <text>",
23
+ description="Compress text by removing redundancy while preserving meaning",
24
+ aliases=["shrink", "condense"],
25
+ examples=["@A:compress The quick brown fox jumps over the lazy dog multiple times repeatedly"],
26
+ token_cost_hint=50,
27
+ )
28
+ def execute_compress(self, text: str = "", *, context: Dict[str, Any] = None, **kwargs) -> str:
29
+ if not text:
30
+ return ""
31
+ words = text.split()
32
+ seen: set = set()
33
+ compressed = []
34
+ for word in words:
35
+ wl = word.lower()
36
+ if wl not in seen or wl in {"the", "a", "an"}:
37
+ compressed.append(word)
38
+ seen.add(wl)
39
+ result = " ".join(compressed)
40
+ result = re.sub(r"\b(\w+)\s+\1\b", r"\1", result, flags=re.IGNORECASE)
41
+ return result
42
+
43
+ @codex_command(
44
+ syntax="@A:expand <compressed_text>",
45
+ description="Expand compressed text to full verbose form",
46
+ aliases=["elaborate", "verbose"],
47
+ examples=["@A:expand QBF jump dog"],
48
+ token_cost_hint=100,
49
+ )
50
+ def execute_expand(self, compressed_text: str = "", *, context: Dict[str, Any] = None, **kwargs) -> str:
51
+ return f"Expanded form: {compressed_text}"
52
+
53
+
54
+ def get_module() -> ModuleA:
55
+ return ModuleA()
@@ -0,0 +1,84 @@
1
+ """Module B: Analysis - Text analysis and insight generation."""
2
+
3
+ from typing import Any, Dict, List
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="B",
11
+ name="Analysis",
12
+ purpose="Text analysis and insight generation",
13
+ token_priority="medium",
14
+ security={"pii_safe": True, "threat_model": "model_leakage_guardrails"},
15
+ privacy={"dp_budget": "epsilon<=0.5_per_call", "federated_ready": True},
16
+ )
17
+ class ModuleB(BaseModule):
18
+ """Analysis module for text analysis and code inspection."""
19
+
20
+ @codex_command(
21
+ syntax="@B:analyze <text>",
22
+ description="Perform deep semantic analysis",
23
+ examples=["@B:analyze Customer feedback shows positive sentiment"],
24
+ token_cost_hint=75,
25
+ )
26
+ def execute_analyze(self, text: str = "", *, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
27
+ words = text.split()
28
+ sentences = text.split(".")
29
+ return {
30
+ "word_count": len(words),
31
+ "sentence_count": len(sentences),
32
+ "avg_word_length": sum(len(w) for w in words) / max(len(words), 1),
33
+ "sentiment": self._analyze_sentiment(text),
34
+ "keywords": self._extract_keywords(text),
35
+ }
36
+
37
+ @codex_command(
38
+ syntax="@CODE_ANALYZE[type, ...]",
39
+ description="Analyze code for performance bottlenecks and issues",
40
+ aliases=["code_review"],
41
+ token_cost_hint=80,
42
+ )
43
+ def execute_code_analyze(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
44
+ code = context.get("code", "") if context else ""
45
+ analysis_types = list(args)
46
+ results: Dict[str, Any] = {
47
+ "code_length": len(code),
48
+ "line_count": len(code.split("\n")),
49
+ "issues": [],
50
+ }
51
+ if "perf_bottleneck" in analysis_types:
52
+ results["issues"].append({"type": "performance", "severity": "medium", "message": "Potential nested loop detected"})
53
+ if "complexity" in analysis_types:
54
+ results["complexity_score"] = self._calculate_complexity(code)
55
+ return results
56
+
57
+ # -- helpers ---------------------------------------------------------------
58
+
59
+ def _analyze_sentiment(self, text: str) -> str:
60
+ positive = {"good", "great", "excellent", "positive", "happy"}
61
+ negative = {"bad", "poor", "negative", "sad", "terrible"}
62
+ tl = text.lower()
63
+ p = sum(1 for w in positive if w in tl)
64
+ n = sum(1 for w in negative if w in tl)
65
+ if p > n:
66
+ return "positive"
67
+ if n > p:
68
+ return "negative"
69
+ return "neutral"
70
+
71
+ def _extract_keywords(self, text: str) -> List[str]:
72
+ stop = {"the", "a", "an", "and", "or", "but", "in", "on", "at", "to", "for"}
73
+ words = text.lower().split()
74
+ return list(set(w for w in words if w not in stop and len(w) > 3))[:5]
75
+
76
+ def _calculate_complexity(self, code: str) -> int:
77
+ c = 1
78
+ for kw in ("if ", "for ", "while ", "and ", "or "):
79
+ c += code.count(kw)
80
+ return c
81
+
82
+
83
+ def get_module() -> ModuleB:
84
+ return ModuleB()
@@ -0,0 +1,199 @@
1
+ """Module C: Formatting - Document formatting and structure."""
2
+
3
+ import json
4
+ import re
5
+ from typing import Any, Dict, List
6
+
7
+ from comptext_codex.registry import codex_module, codex_command
8
+ from .base import BaseModule
9
+
10
+
11
+ @codex_module(
12
+ code="C",
13
+ name="Formatting",
14
+ purpose="Document formatting and structure",
15
+ token_priority="medium",
16
+ security={"pii_safe": True, "threat_model": "template_injection_controls"},
17
+ )
18
+ class ModuleC(BaseModule):
19
+ """Formatting module for document structure and styling."""
20
+
21
+ @codex_command(syntax="@C:format[type=<format>] <text>", description="Format text according to specified style", aliases=["style"], token_cost_hint=40)
22
+ def execute_format(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
23
+ fmt = kwargs.get("type", "markdown")
24
+ text = " ".join(args) if args else (context or {}).get("_last_result", "")
25
+ formatters = {"markdown": self._format_markdown, "json": self._format_json, "html": self._format_html, "xml": self._format_xml, "yaml": self._format_yaml, "csv": self._format_csv}
26
+ return formatters.get(fmt, lambda x: x)(text)
27
+
28
+ @codex_command(syntax="@C:markdown[style=<style>] <text>", description="Advanced markdown formatting with styles", token_cost_hint=40)
29
+ def execute_markdown(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
30
+ style = kwargs.get("style", "standard")
31
+ text = " ".join(args) if args else ""
32
+ if style == "github":
33
+ return self._format_github_markdown(text)
34
+ if style == "minimal":
35
+ return self._format_minimal_markdown(text)
36
+ return self._format_markdown(text)
37
+
38
+ @codex_command(syntax="@C:json[indent=<n>] <text>", description="Format and prettify JSON", token_cost_hint=30)
39
+ def execute_json(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
40
+ indent = kwargs.get("indent", 2)
41
+ sort_keys = kwargs.get("sort_keys", False)
42
+ text = " ".join(args) if args else ""
43
+ return self._format_json(text, indent=indent, sort_keys=sort_keys)
44
+
45
+ @codex_command(syntax="@C:html[semantic=<bool>] <text>", description="Generate semantic HTML", token_cost_hint=40)
46
+ def execute_html(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
47
+ semantic = kwargs.get("semantic", True)
48
+ minify = kwargs.get("minify", False)
49
+ text = " ".join(args) if args else ""
50
+ html = self._format_html(text, semantic=semantic)
51
+ if minify:
52
+ html = re.sub(r"\s+", " ", html).strip()
53
+ return html
54
+
55
+ @codex_command(syntax="@C:table[format=<format>] <data>", description="Format data as table", token_cost_hint=50)
56
+ def execute_table(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
57
+ fmt = kwargs.get("format", "markdown")
58
+ headers = kwargs.get("headers", [])
59
+ text = " ".join(args) if args else ""
60
+ if fmt == "markdown":
61
+ return self._format_markdown_table(text, headers)
62
+ if fmt == "html":
63
+ return self._format_html_table(text, headers)
64
+ if fmt == "ascii":
65
+ return self._format_ascii_table(text, headers)
66
+ return text
67
+
68
+ @codex_command(syntax="@C:code[lang=<lang>] <code>", description="Format code with syntax highlighting markers", token_cost_hint=20)
69
+ def execute_code(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
70
+ lang = kwargs.get("lang", "python")
71
+ inline = kwargs.get("inline", False)
72
+ text = " ".join(args) if args else ""
73
+ return f"`{text}`" if inline else f"```{lang}\n{text}\n```"
74
+
75
+ @codex_command(syntax="@C:list[ordered=<bool>] <items>", description="Format items as list", token_cost_hint=20)
76
+ def execute_list(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
77
+ ordered = kwargs.get("ordered", False)
78
+ items = list(args) if args else []
79
+ if ordered:
80
+ return "\n".join(f"{i+1}. {item}" for i, item in enumerate(items))
81
+ return "\n".join(f"- {item}" for item in items)
82
+
83
+ @codex_command(syntax="@C:prettify[type=<type>] <content>", description="Auto-detect and prettify content", token_cost_hint=40)
84
+ def execute_prettify(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
85
+ content = " ".join(args) if args else ""
86
+ ctype = kwargs.get("type", "auto")
87
+ if ctype == "auto":
88
+ ctype = self._detect_content_type(content)
89
+ return self.execute_format(content, context=context, type=ctype)
90
+
91
+ # -- helpers ---------------------------------------------------------------
92
+
93
+ def _format_markdown(self, text: str) -> str:
94
+ lines = text.split("\n")
95
+ out = []
96
+ for line in lines:
97
+ line = line.strip()
98
+ if not line:
99
+ out.append("")
100
+ elif line.startswith("#"):
101
+ out.append(line)
102
+ elif len(line) < 60 and not any(c in line for c in [".", ",", "!"]):
103
+ out.append(f"## {line}")
104
+ else:
105
+ out.append(line)
106
+ return "\n".join(out)
107
+
108
+ def _format_github_markdown(self, text: str) -> str:
109
+ parts = text.split("\n")
110
+ return f"# {parts[0]}\n\n{chr(10).join(parts[1:])}\n\n---\n*Generated with CompText*\n"
111
+
112
+ def _format_minimal_markdown(self, text: str) -> str:
113
+ return text.replace("\n\n", "\n")
114
+
115
+ def _format_json(self, text: str, indent: int = 2, sort_keys: bool = False) -> str:
116
+ try:
117
+ data = json.loads(text) if text.strip().startswith(("{", "[")) else {"content": text}
118
+ return json.dumps(data, indent=indent, sort_keys=sort_keys, ensure_ascii=False)
119
+ except Exception:
120
+ return json.dumps({"content": text}, indent=indent)
121
+
122
+ def _format_html(self, text: str, semantic: bool = True) -> str:
123
+ if semantic:
124
+ parts = [p.strip() for p in text.split("\n\n") if p.strip()]
125
+ html = [f"<h2>{p}</h2>" if len(p) < 60 and "\n" not in p else f"<p>{p}</p>" for p in parts]
126
+ return f"<article>\n {' '.join(html)}\n</article>"
127
+ return f"<div><p>{text}</p></div>"
128
+
129
+ def _format_xml(self, text: str) -> str:
130
+ return f'<?xml version="1.0" encoding="UTF-8"?>\n<document>\n <content>{text}</content>\n</document>'
131
+
132
+ def _format_yaml(self, text: str) -> str:
133
+ return "\n".join(line if ":" in line else f"content: {line}" for line in text.split("\n"))
134
+
135
+ def _format_csv(self, text: str) -> str:
136
+ return "\n".join(f'"{line}"' for line in text.split("\n") if line.strip())
137
+
138
+ def _format_markdown_table(self, text: str, headers: List[str]) -> str:
139
+ lines = [l.strip() for l in text.split("\n") if l.strip()]
140
+ if not headers and lines:
141
+ headers = ["Column 1", "Column 2", "Column 3"]
142
+ h = "| " + " | ".join(headers) + " |"
143
+ s = "| " + " | ".join(["---"] * len(headers)) + " |"
144
+ rows = []
145
+ for line in lines:
146
+ cells = line.split(",")[:len(headers)]
147
+ cells += [""] * (len(headers) - len(cells))
148
+ rows.append("| " + " | ".join(cells) + " |")
149
+ return "\n".join([h, s] + rows)
150
+
151
+ def _format_html_table(self, text: str, headers: List[str]) -> str:
152
+ lines = [l.strip() for l in text.split("\n") if l.strip()]
153
+ parts = ["<table>"]
154
+ if headers:
155
+ parts += [" <thead>", " <tr>"] + [f" <th>{h}</th>" for h in headers] + [" </tr>", " </thead>"]
156
+ parts.append(" <tbody>")
157
+ for line in lines:
158
+ parts.append(" <tr>")
159
+ for cell in line.split(","):
160
+ parts.append(f" <td>{cell.strip()}</td>")
161
+ parts.append(" </tr>")
162
+ parts += [" </tbody>", "</table>"]
163
+ return "\n".join(parts)
164
+
165
+ def _format_ascii_table(self, text: str, headers: List[str]) -> str:
166
+ lines = [l.strip() for l in text.split("\n") if l.strip()]
167
+ cw = [len(h) for h in headers] if headers else [10, 10, 10]
168
+ for line in lines:
169
+ for i, cell in enumerate(line.split(",")):
170
+ if i < len(cw):
171
+ cw[i] = max(cw[i], len(cell.strip()))
172
+ out = ["\u250c" + "\u252c".join("\u2500" * (w + 2) for w in cw) + "\u2510"]
173
+ if headers:
174
+ out.append("\u2502" + "\u2502".join(f" {h:<{w}} " for h, w in zip(headers, cw)) + "\u2502")
175
+ out.append("\u251c" + "\u253c".join("\u2500" * (w + 2) for w in cw) + "\u2524")
176
+ for line in lines:
177
+ cells = line.split(",")
178
+ cells += [""] * (len(cw) - len(cells))
179
+ out.append("\u2502" + "\u2502".join(f" {c.strip():<{w}} " for c, w in zip(cells, cw)) + "\u2502")
180
+ out.append("\u2514" + "\u2534".join("\u2500" * (w + 2) for w in cw) + "\u2518")
181
+ return "\n".join(out)
182
+
183
+ def _detect_content_type(self, content: str) -> str:
184
+ c = content.strip()
185
+ if c.startswith(("{", "[")):
186
+ return "json"
187
+ if c.startswith("<"):
188
+ return "html"
189
+ if "<?xml" in c:
190
+ return "xml"
191
+ if c.count("\n") > 2 and all(":" in l for l in c.split("\n")[:3]):
192
+ return "yaml"
193
+ if "," in c and c.count(",") > 3:
194
+ return "csv"
195
+ return "markdown"
196
+
197
+
198
+ def get_module() -> ModuleC:
199
+ return ModuleC()
@@ -0,0 +1,31 @@
1
+ """Module D: AI Control - Model selection, prompt governance, safety filters."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="D",
11
+ name="AI Control",
12
+ purpose="Model selection, prompt governance, and safety filters",
13
+ token_priority="high",
14
+ security={"pii_safe": True, "threat_model": "safety_policy_enforced"},
15
+ privacy={"dp_budget": "epsilon<=0.5_per_call", "federated_ready": True},
16
+ )
17
+ class ModuleD(BaseModule):
18
+ """AI Control module for model management and safety."""
19
+
20
+ @codex_command(syntax="@MODEL_SELECT[model_name]", description="Select and configure AI model", token_cost_hint=30)
21
+ def execute_model_select(self, *args, context: Dict[str, Any] = None, model: str = None, **kwargs) -> Dict[str, Any]:
22
+ model_name = model or (args[0] if args else "default")
23
+ return {"selected_model": model_name, "config": kwargs, "safety_level": kwargs.get("safety", "medium")}
24
+
25
+ @codex_command(syntax="@SAFETY_FILTER[level]", description="Apply safety filters to content", token_cost_hint=20)
26
+ def execute_safety_filter(self, *args, context: Dict[str, Any] = None, level: str = "medium", **kwargs) -> Dict[str, Any]:
27
+ return {"filter_level": level, "filters_applied": ["pii_detection", "harmful_content", "bias_check"], "status": "active"}
28
+
29
+
30
+ def get_module() -> ModuleD:
31
+ return ModuleD()
@@ -0,0 +1,33 @@
1
+ """Module E: ML Pipelines - AutoML, feature engineering, experiment tracking."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="E",
11
+ name="ML Pipelines",
12
+ purpose="AutoML, feature engineering, and experiment tracking",
13
+ token_priority="high",
14
+ security={"pii_safe": False, "threat_model": "dataset_access_controlled"},
15
+ privacy={"dp_budget": "epsilon<=2.0_per_job", "federated_ready": True},
16
+ )
17
+ class ModuleE(BaseModule):
18
+ """ML Pipelines module for machine learning workflows."""
19
+
20
+ @codex_command(syntax="@AUTOML[task, metric, ...]", description="Run AutoML pipeline", token_cost_hint=100)
21
+ def execute_automl(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ task = kwargs.get("task", "classification")
23
+ metric = kwargs.get("metric", "accuracy")
24
+ models = kwargs.get("models", ["rf", "xgb"])
25
+ return {"task": task, "metric": metric, "best_model": "xgboost", "score": 0.87, "models_evaluated": models, "hyperparameters": {"max_depth": 7, "learning_rate": 0.05}}
26
+
27
+ @codex_command(syntax="@FEATURE_ENG[auto, ...]", description="Perform feature engineering", token_cost_hint=80)
28
+ def execute_feature_eng(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
29
+ return {"features_created": 15, "feature_types": ["polynomial", "interaction", "aggregation"], "importance_scores": {"feature_1": 0.32, "feature_2": 0.24}}
30
+
31
+
32
+ def get_module() -> ModuleE:
33
+ return ModuleE()
@@ -0,0 +1,31 @@
1
+ """Module F: Documentation - API docs, tutorials, changelogs, design docs."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="F",
11
+ name="Documentation",
12
+ purpose="API docs, tutorials, changelogs, and design docs",
13
+ token_priority="medium",
14
+ security={"pii_safe": True, "threat_model": "content_sanitization"},
15
+ privacy={"dp_budget": "epsilon<=0.2_per_call"},
16
+ )
17
+ class ModuleF(BaseModule):
18
+ """Documentation module for generating various docs."""
19
+
20
+ @codex_command(syntax="@DOC_GEN[type, format, ...]", description="Generate documentation", token_cost_hint=60)
21
+ def execute_doc_gen(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ return {"type": kwargs.get("type", "api"), "format": kwargs.get("format", "markdown"), "sections": ["Overview", "API Reference", "Examples"], "generated": True}
23
+
24
+ @codex_command(syntax="@CHANGELOG[format, since, ...]", description="Generate changelog", token_cost_hint=50)
25
+ def execute_changelog(self, *args, context: Dict[str, Any] = None, **kwargs) -> str:
26
+ since = kwargs.get("since", "v1.0.0")
27
+ return f"# Changelog\n\n## [Unreleased]\n\n### Added\n- New features since {since}\n\n### Changed\n- Updated components\n\n### Fixed\n- Bug fixes\n"
28
+
29
+
30
+ def get_module() -> ModuleF:
31
+ return ModuleF()
@@ -0,0 +1,31 @@
1
+ """Module G: Testing - Test generation, coverage insights, quality gates."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="G",
11
+ name="Testing",
12
+ purpose="Test generation, coverage insights, and quality gates",
13
+ token_priority="medium",
14
+ security={"pii_safe": True, "threat_model": "sandbox_execution"},
15
+ privacy={"dp_budget": "epsilon<=0.3_per_suite", "federated_ready": True},
16
+ )
17
+ class ModuleG(BaseModule):
18
+ """Testing module for test generation and quality assurance."""
19
+
20
+ @codex_command(syntax="@TEST_GEN[framework, coverage, ...]", description="Generate tests for code", token_cost_hint=70)
21
+ def execute_test_gen(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ return {"framework": kwargs.get("framework", "pytest"), "tests_generated": 15, "coverage_target": kwargs.get("coverage", 80), "test_types": ["unit", "integration", "edge_cases"]}
23
+
24
+ @codex_command(syntax="@COVERAGE[threshold, ...]", description="Analyze code coverage", token_cost_hint=40)
25
+ def execute_coverage(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
26
+ threshold = kwargs.get("threshold", 80)
27
+ return {"coverage": 87.5, "threshold": threshold, "passed": True, "uncovered_lines": 42}
28
+
29
+
30
+ def get_module() -> ModuleG:
31
+ return ModuleG()
@@ -0,0 +1,31 @@
1
+ """Module H: Database - Schema design, migrations, query optimization."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="H",
11
+ name="Database",
12
+ purpose="Schema design, migrations, and query optimization",
13
+ token_priority="medium",
14
+ security={"pii_safe": False, "threat_model": "sql_injection_scanning"},
15
+ privacy={"dp_budget": "epsilon<=1.0_per_call"},
16
+ )
17
+ class ModuleH(BaseModule):
18
+ """Database module for schema and query operations."""
19
+
20
+ @codex_command(syntax="@SCHEMA_DESIGN[entities, ...]", description="Design database schema", token_cost_hint=70)
21
+ def execute_schema_design(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ entities = kwargs.get("entities", [])
23
+ return {"schema": "generated", "tables": len(entities) if entities else 5, "relationships": ["one-to-many", "many-to-many"], "indexes": ["primary_key", "foreign_key", "composite"]}
24
+
25
+ @codex_command(syntax="@QUERY_OPTIMIZE[query, ...]", description="Optimize database query", token_cost_hint=50)
26
+ def execute_query_optimize(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
27
+ return {"original_query": kwargs.get("query", ""), "optimized": True, "improvements": ["added index", "removed subquery"], "performance_gain": "3x faster"}
28
+
29
+
30
+ def get_module() -> ModuleH:
31
+ return ModuleH()
@@ -0,0 +1,42 @@
1
+ """Module I: Security - Vulnerability scans, compliance checks, threat modeling."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="I",
11
+ name="Security",
12
+ purpose="Vulnerability scans, compliance checks, and threat modeling",
13
+ token_priority="high",
14
+ security={"pii_safe": True, "threat_model": "hardened"},
15
+ privacy={"dp_budget": "epsilon<=0.5_per_call", "audit_logging": True},
16
+ )
17
+ class ModuleI(BaseModule):
18
+ """Security module for vulnerability and compliance checks."""
19
+
20
+ @codex_command(syntax="@SEC_SCAN[type, severity, ...]", description="Scan for security vulnerabilities", token_cost_hint=60)
21
+ def execute_sec_scan(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ scan_type = kwargs.get("type", "code")
23
+ return {
24
+ "scan_type": scan_type,
25
+ "vulnerabilities_found": 3,
26
+ "severity_levels": {"critical": 1, "high": 2, "medium": 0},
27
+ "recommendations": ["Fix SQL injection", "Update dependencies", "Enable HTTPS"],
28
+ }
29
+
30
+ @codex_command(syntax="@GDPR[audit, ...]", description="Perform GDPR compliance audit", token_cost_hint=55)
31
+ def execute_gdpr(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
32
+ audit = kwargs.get("audit", "full")
33
+ return {
34
+ "audit_type": audit,
35
+ "compliant": False,
36
+ "issues": ["Missing consent forms", "PII not encrypted", "No deletion mechanism"],
37
+ "recommendations": ["Implement consent management", "Encrypt PII with AES-256", "Add deletion endpoints"],
38
+ }
39
+
40
+
41
+ def get_module() -> ModuleI:
42
+ return ModuleI()
@@ -0,0 +1,38 @@
1
+ """Module J: DevOps - CI/CD workflows, observability, release automation."""
2
+
3
+ from typing import Any, Dict
4
+
5
+ from comptext_codex.registry import codex_module, codex_command
6
+ from .base import BaseModule
7
+
8
+
9
+ @codex_module(
10
+ code="J",
11
+ name="DevOps",
12
+ purpose="CI/CD workflows, observability, and release automation",
13
+ token_priority="medium",
14
+ security={"pii_safe": True, "threat_model": "supply_chain_checks"},
15
+ privacy={"dp_budget": "epsilon<=0.1_per_call", "federated_ready": True},
16
+ )
17
+ class ModuleJ(BaseModule):
18
+ """DevOps module for CI/CD and infrastructure."""
19
+
20
+ @codex_command(syntax="@DEPLOY[platform, ...]", description="Generate deployment configuration", token_cost_hint=60)
21
+ def execute_deploy(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
22
+ platform = kwargs.get("platform", "k8s")
23
+ return {
24
+ "platform": platform,
25
+ "replicas": kwargs.get("replicas", 3),
26
+ "config_generated": True,
27
+ "resources": {"cpu": kwargs.get("cpu", "500m"), "memory": kwargs.get("mem", "1Gi")},
28
+ "manifests": ["deployment.yaml", "service.yaml", "ingress.yaml"],
29
+ }
30
+
31
+ @codex_command(syntax="@CI_CD[stages, ...]", description="Generate CI/CD pipeline", token_cost_hint=60)
32
+ def execute_ci_cd(self, *args, context: Dict[str, Any] = None, **kwargs) -> Dict[str, Any]:
33
+ stages = kwargs.get("stages", ["build", "test", "deploy"])
34
+ return {"stages": stages, "pipeline": "generated", "triggers": kwargs.get("triggers", ["push_main"]), "workflow_file": ".github/workflows/ci.yml"}
35
+
36
+
37
+ def get_module() -> ModuleJ:
38
+ return ModuleJ()