clearai-dsh 0.3.0 → 0.4.0

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 (148) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +28 -28
  3. package/README.zh-CN.md +28 -28
  4. package/lib/client.js +861 -2555
  5. package/lib/domain-language.js +552 -48
  6. package/lib/fold.js +351 -1015
  7. package/lib/host.js +47 -557
  8. package/lib/invariant.js +9 -12
  9. package/lib/knowledge-view.js +363 -226
  10. package/lib/lang.js +81 -0
  11. package/package.json +1 -1
  12. package/presets/clearai/agent.cordis.yml +54 -82
  13. package/presets/clearai/clearai.patch.yml +54 -82
  14. package/presets/clearai/plugins/clearai-kernel.js +1590 -5437
  15. package/presets/clearai/plugins/ontology.js +56 -14
  16. package/presets/clearai/plugins/prompts.js +73 -363
  17. package/presets/clearai/skills/clearai-loop/SKILL.md +73 -59
  18. package/presets/clearai/plugins/brain.js +0 -547
  19. package/presets/clearai/plugins/commands.js +0 -199
  20. package/presets/clearai/template/knowledge/README.md +0 -25
  21. package/presets/clearai/template/memory/README.md +0 -34
  22. package/presets/clearai/template/project.md +0 -49
  23. package/presets/clearai/template/skills/README.md +0 -37
  24. package/presets/clearai/template/skills/chart-diagram-qa/SKILL.md +0 -43
  25. package/presets/clearai/template/skills/citation-management/SKILL.md +0 -73
  26. package/presets/clearai/template/skills/citation-management/references/bibtex_formatting.md +0 -908
  27. package/presets/clearai/template/skills/citation-management/references/citation_validation.md +0 -794
  28. package/presets/clearai/template/skills/citation-management/references/google_scholar_search.md +0 -725
  29. package/presets/clearai/template/skills/citation-management/references/metadata_extraction.md +0 -870
  30. package/presets/clearai/template/skills/citation-management/references/pubmed_search.md +0 -839
  31. package/presets/clearai/template/skills/citation-management/scripts/doi_to_bibtex.py +0 -204
  32. package/presets/clearai/template/skills/citation-management/scripts/extract_metadata.py +0 -569
  33. package/presets/clearai/template/skills/citation-management/scripts/format_bibtex.py +0 -349
  34. package/presets/clearai/template/skills/citation-management/scripts/generate_schematic.py +0 -139
  35. package/presets/clearai/template/skills/citation-management/scripts/generate_schematic_ai.py +0 -817
  36. package/presets/clearai/template/skills/citation-management/scripts/search_google_scholar.py +0 -282
  37. package/presets/clearai/template/skills/citation-management/scripts/search_pubmed.py +0 -398
  38. package/presets/clearai/template/skills/citation-management/scripts/validate_citations.py +0 -497
  39. package/presets/clearai/template/skills/data-analysis/SKILL.md +0 -92
  40. package/presets/clearai/template/skills/data-analysis/checklists/readiness_check.md +0 -23
  41. package/presets/clearai/template/skills/data-analysis/templates/analysis_report.md.tpl +0 -63
  42. package/presets/clearai/template/skills/data-analysis/templates/cleaning_rules_draft.yaml.tpl +0 -32
  43. package/presets/clearai/template/skills/data-analysis/templates/data_dictionary.md.tpl +0 -12
  44. package/presets/clearai/template/skills/data-analysis/templates/domain_knowledge_template.md.tpl +0 -316
  45. package/presets/clearai/template/skills/data-analysis/templates/feature_candidates.json.tpl +0 -20
  46. package/presets/clearai/template/skills/data-analysis/templates/quality_scorecard.md.tpl +0 -30
  47. package/presets/clearai/template/skills/data-analysis/workflows/01-data-profiling.md +0 -42
  48. package/presets/clearai/template/skills/data-analysis/workflows/02-quality-audit.md +0 -36
  49. package/presets/clearai/template/skills/data-analysis/workflows/03-physical-correlation.md +0 -25
  50. package/presets/clearai/template/skills/data-analysis/workflows/04-unstructured-mining.md +0 -26
  51. package/presets/clearai/template/skills/data-qa-analysis/SKILL.md +0 -102
  52. package/presets/clearai/template/skills/data-qa-analysis/checklists/readiness_check.md +0 -62
  53. package/presets/clearai/template/skills/data-qa-analysis/templates/best_in_class_report.md.tpl +0 -56
  54. package/presets/clearai/template/skills/data-qa-analysis/templates/cleaning_rules_draft.yaml.tpl +0 -56
  55. package/presets/clearai/template/skills/data-qa-analysis/templates/data_dictionary.md.tpl +0 -13
  56. package/presets/clearai/template/skills/data-qa-analysis/templates/data_source_inventory_and_lineage.md.tpl +0 -146
  57. package/presets/clearai/template/skills/data-qa-analysis/templates/data_status_report.md.tpl +0 -60
  58. package/presets/clearai/template/skills/data-qa-analysis/templates/steady_state_rules.yaml.tpl +0 -41
  59. package/presets/clearai/template/skills/data-qa-analysis/templates/subsystem_registry.md.tpl +0 -101
  60. package/presets/clearai/template/skills/data-qa-analysis/templates/unified_execution_plan.md.tpl +0 -100
  61. package/presets/clearai/template/skills/data-qa-analysis/workflows/01-data-source-inventory-and-lineage.md +0 -194
  62. package/presets/clearai/template/skills/data-qa-analysis/workflows/02-data-alignment-and-tag-semantics.md +0 -122
  63. package/presets/clearai/template/skills/data-qa-analysis/workflows/03-steady-state-identification.md +0 -126
  64. package/presets/clearai/template/skills/data-qa-analysis/workflows/04-consumption-analysis.md +0 -152
  65. package/presets/clearai/template/skills/data-qa-analysis/workflows/05-best-in-class-and-optimization-space.md +0 -78
  66. package/presets/clearai/template/skills/domain-presearch/SKILL.md +0 -131
  67. package/presets/clearai/template/skills/domain-presearch/checklists/domain_checklist.md +0 -24
  68. package/presets/clearai/template/skills/domain-presearch/references/figure_code.md +0 -78
  69. package/presets/clearai/template/skills/domain-presearch/references/strategic_frameworks.md +0 -38
  70. package/presets/clearai/template/skills/exploration-loop/SKILL.md +0 -81
  71. package/presets/clearai/template/skills/exploratory-data-analysis/SKILL.md +0 -77
  72. package/presets/clearai/template/skills/exploratory-data-analysis/references/bioinformatics_genomics_formats.md +0 -664
  73. package/presets/clearai/template/skills/exploratory-data-analysis/references/chemistry_molecular_formats.md +0 -664
  74. package/presets/clearai/template/skills/exploratory-data-analysis/references/general_scientific_formats.md +0 -518
  75. package/presets/clearai/template/skills/exploratory-data-analysis/references/microscopy_imaging_formats.md +0 -620
  76. package/presets/clearai/template/skills/exploratory-data-analysis/references/proteomics_metabolomics_formats.md +0 -517
  77. package/presets/clearai/template/skills/exploratory-data-analysis/references/spectroscopy_analytical_formats.md +0 -633
  78. package/presets/clearai/template/skills/exploratory-data-analysis/scripts/eda_analyzer.py +0 -547
  79. package/presets/clearai/template/skills/hypothesis-generation/SKILL.md +0 -73
  80. package/presets/clearai/template/skills/hypothesis-generation/references/experimental_design_patterns.md +0 -329
  81. package/presets/clearai/template/skills/hypothesis-generation/references/hypothesis_quality_criteria.md +0 -198
  82. package/presets/clearai/template/skills/hypothesis-generation/references/literature_search_strategies.md +0 -622
  83. package/presets/clearai/template/skills/hypothesis-generation/scripts/generate_schematic.py +0 -139
  84. package/presets/clearai/template/skills/hypothesis-generation/scripts/generate_schematic_ai.py +0 -817
  85. package/presets/clearai/template/skills/literature-review/SKILL.md +0 -72
  86. package/presets/clearai/template/skills/literature-review/references/citation_styles.md +0 -166
  87. package/presets/clearai/template/skills/literature-review/references/database_strategies.md +0 -455
  88. package/presets/clearai/template/skills/literature-review/scripts/generate_pdf.py +0 -176
  89. package/presets/clearai/template/skills/literature-review/scripts/generate_schematic.py +0 -139
  90. package/presets/clearai/template/skills/literature-review/scripts/generate_schematic_ai.py +0 -817
  91. package/presets/clearai/template/skills/literature-review/scripts/search_databases.py +0 -303
  92. package/presets/clearai/template/skills/literature-review/scripts/verify_citations.py +0 -221
  93. package/presets/clearai/template/skills/paper-lookup/SKILL.md +0 -59
  94. package/presets/clearai/template/skills/paper-lookup/references/arxiv.md +0 -161
  95. package/presets/clearai/template/skills/paper-lookup/references/biorxiv.md +0 -118
  96. package/presets/clearai/template/skills/paper-lookup/references/core.md +0 -150
  97. package/presets/clearai/template/skills/paper-lookup/references/crossref.md +0 -181
  98. package/presets/clearai/template/skills/paper-lookup/references/medrxiv.md +0 -104
  99. package/presets/clearai/template/skills/paper-lookup/references/openalex.md +0 -174
  100. package/presets/clearai/template/skills/paper-lookup/references/pmc.md +0 -152
  101. package/presets/clearai/template/skills/paper-lookup/references/pubmed.md +0 -124
  102. package/presets/clearai/template/skills/paper-lookup/references/semantic-scholar.md +0 -203
  103. package/presets/clearai/template/skills/paper-lookup/references/unpaywall.md +0 -127
  104. package/presets/clearai/template/skills/process-presearch/SKILL.md +0 -196
  105. package/presets/clearai/template/skills/process-presearch/checklists/process_checklist.md +0 -18
  106. package/presets/clearai/template/skills/process-presearch/references/figure_code.md +0 -107
  107. package/presets/clearai/template/skills/process-presearch/references/source_attribution_example.md +0 -22
  108. package/presets/clearai/template/skills/process-understanding-extraction/SKILL.md +0 -69
  109. package/presets/clearai/template/skills/process-understanding-extraction/checklists/readiness_check.md +0 -34
  110. package/presets/clearai/template/skills/process-understanding-extraction/templates/docx_raw_dump_extractor.py.tpl +0 -132
  111. package/presets/clearai/template/skills/process-understanding-extraction/templates/entity_map_unit_topology.json.tpl +0 -86
  112. package/presets/clearai/template/skills/process-understanding-extraction/templates/process_brief.md.tpl +0 -89
  113. package/presets/clearai/template/skills/process-understanding-extraction/templates/process_brief_builder_from_raw_dump.py.tpl +0 -203
  114. package/presets/clearai/template/skills/process-understanding-extraction/templates/process_flow_mermaid.md.tpl +0 -41
  115. package/presets/clearai/template/skills/process-understanding-extraction/templates/unified_execution_plan.md.tpl +0 -53
  116. package/presets/clearai/template/skills/process-understanding-extraction/workflows/01-process-doc-discovery.md +0 -173
  117. package/presets/clearai/template/skills/process-understanding-extraction/workflows/02-process-understanding-and-diagramming.md +0 -106
  118. package/presets/clearai/template/skills/scientific-brainstorming/SKILL.md +0 -64
  119. package/presets/clearai/template/skills/scientific-brainstorming/references/brainstorming_methods.md +0 -326
  120. package/presets/clearai/template/skills/scientific-critical-thinking/SKILL.md +0 -72
  121. package/presets/clearai/template/skills/scientific-critical-thinking/references/common_biases.md +0 -364
  122. package/presets/clearai/template/skills/scientific-critical-thinking/references/evidence_hierarchy.md +0 -485
  123. package/presets/clearai/template/skills/scientific-critical-thinking/references/experimental_design.md +0 -496
  124. package/presets/clearai/template/skills/scientific-critical-thinking/references/logical_fallacies.md +0 -478
  125. package/presets/clearai/template/skills/scientific-critical-thinking/references/scientific_method.md +0 -169
  126. package/presets/clearai/template/skills/scientific-critical-thinking/references/statistical_pitfalls.md +0 -506
  127. package/presets/clearai/template/skills/skill-creator/SKILL.md +0 -109
  128. package/presets/clearai/template/skills/skill-creator/references/authoring-guide.md +0 -89
  129. package/presets/clearai/template/skills/statistical-analysis/SKILL.md +0 -79
  130. package/presets/clearai/template/skills/statistical-analysis/references/assumptions_and_diagnostics.md +0 -369
  131. package/presets/clearai/template/skills/statistical-analysis/references/bayesian_statistics.md +0 -653
  132. package/presets/clearai/template/skills/statistical-analysis/references/effect_sizes_and_power.md +0 -578
  133. package/presets/clearai/template/skills/statistical-analysis/references/reporting_standards.md +0 -469
  134. package/presets/clearai/template/skills/statistical-analysis/references/test_selection_guide.md +0 -129
  135. package/presets/clearai/template/skills/statistical-analysis/scripts/assumption_checks.py +0 -538
  136. package/presets/clearai/template/skills/web-artifact/SKILL.md +0 -165
  137. package/presets/clearai/template/skills/web-artifact/assets/renderer/renderer.css +0 -229
  138. package/presets/clearai/template/skills/web-artifact/assets/renderer/renderer.js +0 -373
  139. package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/LICENSE +0 -263
  140. package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/UPSTREAM.md +0 -26
  141. package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/elk.bundled.js +0 -6605
  142. package/presets/clearai/template/skills/web-artifact/references/when-drawing-a-topology.md +0 -150
  143. package/presets/clearai/template/skills/web-artifact/references/when-the-page-must-work-offline.md +0 -62
  144. package/presets/clearai/template/skills/web-artifact/scripts/check_artifact.py +0 -167
  145. package/presets/clearai/template/skills/web-artifact/scripts/render_topology.js +0 -272
  146. package/presets/clearai/template/skills/what-if-oracle/LICENSE.txt +0 -5
  147. package/presets/clearai/template/skills/what-if-oracle/SKILL.md +0 -72
  148. package/presets/clearai/template/skills/what-if-oracle/references/scenario-templates.md +0 -154
@@ -1,176 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- PDF Generation Script for Literature Reviews
4
- Converts markdown files to professionally formatted PDFs with proper styling.
5
- """
6
-
7
- import subprocess
8
- import sys
9
- import os
10
- from pathlib import Path
11
-
12
- def generate_pdf(
13
- markdown_file: str,
14
- output_pdf: str = None,
15
- citation_style: str = "apa",
16
- template: str = None,
17
- toc: bool = True,
18
- number_sections: bool = True
19
- ) -> bool:
20
- """
21
- Generate a PDF from a markdown file using pandoc.
22
-
23
- Args:
24
- markdown_file: Path to the markdown file
25
- output_pdf: Path for output PDF (defaults to same name as markdown)
26
- citation_style: Citation style (apa, nature, chicago, etc.)
27
- template: Path to custom LaTeX template
28
- toc: Include table of contents
29
- number_sections: Number the sections
30
-
31
- Returns:
32
- True if successful, False otherwise
33
- """
34
-
35
- # Verify markdown file exists
36
- if not os.path.exists(markdown_file):
37
- print(f"Error: Markdown file not found: {markdown_file}")
38
- return False
39
-
40
- # Set default output path
41
- if output_pdf is None:
42
- output_pdf = Path(markdown_file).with_suffix('.pdf')
43
-
44
- # Check if pandoc is installed
45
- try:
46
- subprocess.run(['pandoc', '--version'], capture_output=True, check=True)
47
- except (subprocess.CalledProcessError, FileNotFoundError):
48
- print("Error: pandoc is not installed.")
49
- print("Install with: brew install pandoc (macOS) or apt-get install pandoc (Linux)")
50
- return False
51
-
52
- # Build pandoc command
53
- cmd = [
54
- 'pandoc',
55
- markdown_file,
56
- '-o', str(output_pdf),
57
- '--pdf-engine=xelatex', # Better Unicode support
58
- '-V', 'geometry:margin=1in',
59
- '-V', 'fontsize=11pt',
60
- '-V', 'colorlinks=true',
61
- '-V', 'linkcolor=blue',
62
- '-V', 'urlcolor=blue',
63
- '-V', 'citecolor=blue',
64
- ]
65
-
66
- # Add table of contents
67
- if toc:
68
- cmd.extend(['--toc', '--toc-depth=3'])
69
-
70
- # Add section numbering
71
- if number_sections:
72
- cmd.append('--number-sections')
73
-
74
- # Add citation processing if bibliography exists
75
- bib_file = Path(markdown_file).with_suffix('.bib')
76
- if bib_file.exists():
77
- cmd.extend([
78
- '--citeproc',
79
- '--bibliography', str(bib_file),
80
- '--csl', f'{citation_style}.csl' if not citation_style.endswith('.csl') else citation_style
81
- ])
82
-
83
- # Add custom template if provided
84
- if template and os.path.exists(template):
85
- cmd.extend(['--template', template])
86
-
87
- # Execute pandoc
88
- try:
89
- print(f"Generating PDF: {output_pdf}")
90
- print(f"Command: {' '.join(cmd)}")
91
- result = subprocess.run(cmd, capture_output=True, text=True, check=True)
92
- print(f"✓ PDF generated successfully: {output_pdf}")
93
- return True
94
- except subprocess.CalledProcessError as e:
95
- print(f"Error generating PDF:")
96
- print(f"STDOUT: {e.stdout}")
97
- print(f"STDERR: {e.stderr}")
98
- return False
99
-
100
- def check_dependencies():
101
- """Check if required dependencies are installed."""
102
- dependencies = {
103
- 'pandoc': 'pandoc --version',
104
- 'xelatex': 'xelatex --version'
105
- }
106
-
107
- missing = []
108
- for name, cmd in dependencies.items():
109
- try:
110
- subprocess.run(cmd.split(), capture_output=True, check=True)
111
- print(f"✓ {name} is installed")
112
- except (subprocess.CalledProcessError, FileNotFoundError):
113
- print(f"✗ {name} is NOT installed")
114
- missing.append(name)
115
-
116
- if missing:
117
- print("\n" + "="*60)
118
- print("Missing dependencies:")
119
- for dep in missing:
120
- if dep == 'pandoc':
121
- print(" - pandoc: brew install pandoc (macOS) or apt-get install pandoc (Linux)")
122
- elif dep == 'xelatex':
123
- print(" - xelatex: brew install --cask mactex (macOS) or apt-get install texlive-xetex (Linux)")
124
- return False
125
-
126
- return True
127
-
128
- def main():
129
- """Command-line interface."""
130
- if len(sys.argv) < 2:
131
- print("Usage: python generate_pdf.py <markdown_file> [output_pdf] [--citation-style STYLE]")
132
- print("\nOptions:")
133
- print(" --citation-style STYLE Citation style (default: apa)")
134
- print(" --no-toc Disable table of contents")
135
- print(" --no-numbers Disable section numbering")
136
- print(" --check-deps Check if dependencies are installed")
137
- sys.exit(1)
138
-
139
- # Check dependencies mode
140
- if '--check-deps' in sys.argv:
141
- check_dependencies()
142
- sys.exit(0)
143
-
144
- # Parse arguments
145
- markdown_file = sys.argv[1]
146
- output_pdf = sys.argv[2] if len(sys.argv) > 2 and not sys.argv[2].startswith('--') else None
147
-
148
- citation_style = 'apa'
149
- toc = True
150
- number_sections = True
151
-
152
- # Parse optional flags
153
- if '--citation-style' in sys.argv:
154
- idx = sys.argv.index('--citation-style')
155
- if idx + 1 < len(sys.argv):
156
- citation_style = sys.argv[idx + 1]
157
-
158
- if '--no-toc' in sys.argv:
159
- toc = False
160
-
161
- if '--no-numbers' in sys.argv:
162
- number_sections = False
163
-
164
- # Generate PDF
165
- success = generate_pdf(
166
- markdown_file,
167
- output_pdf,
168
- citation_style=citation_style,
169
- toc=toc,
170
- number_sections=number_sections
171
- )
172
-
173
- sys.exit(0 if success else 1)
174
-
175
- if __name__ == "__main__":
176
- main()
@@ -1,139 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Scientific schematic generation using Nano Banana 2.
4
-
5
- Generate any scientific diagram by describing it in natural language.
6
- Nano Banana 2 handles everything automatically with smart iterative refinement.
7
-
8
- Smart iteration: Only regenerates if quality is below threshold for your document type.
9
- Quality review: Uses Gemini 3.1 Pro Preview for professional scientific evaluation.
10
-
11
- Usage:
12
- # Generate for journal paper (highest quality threshold)
13
- python generate_schematic.py "CONSORT flowchart" -o flowchart.png --doc-type journal
14
-
15
- # Generate for presentation (lower threshold, faster)
16
- python generate_schematic.py "Transformer architecture" -o transformer.png --doc-type presentation
17
-
18
- # Generate for poster
19
- python generate_schematic.py "MAPK signaling pathway" -o pathway.png --doc-type poster
20
- """
21
-
22
- import argparse
23
- import os
24
- import subprocess
25
- import sys
26
- from pathlib import Path
27
-
28
-
29
- def main():
30
- """Command-line interface."""
31
- parser = argparse.ArgumentParser(
32
- description="Generate scientific schematics using AI with smart iterative refinement",
33
- formatter_class=argparse.RawDescriptionHelpFormatter,
34
- epilog="""
35
- How it works:
36
- Simply describe your diagram in natural language
37
- Nano Banana 2 generates it automatically with:
38
- - Smart iteration (only regenerates if quality is below threshold)
39
- - Quality review by Gemini 3.1 Pro Preview
40
- - Document-type aware quality thresholds
41
- - Publication-ready output
42
-
43
- Document Types (quality thresholds):
44
- journal 8.5/10 - Nature, Science, peer-reviewed journals
45
- conference 8.0/10 - Conference papers
46
- thesis 8.0/10 - Dissertations, theses
47
- grant 8.0/10 - Grant proposals
48
- preprint 7.5/10 - arXiv, bioRxiv, etc.
49
- report 7.5/10 - Technical reports
50
- poster 7.0/10 - Academic posters
51
- presentation 6.5/10 - Slides, talks
52
- default 7.5/10 - General purpose
53
-
54
- Examples:
55
- # Generate for journal paper (strict quality)
56
- python generate_schematic.py "CONSORT participant flow" -o flowchart.png --doc-type journal
57
-
58
- # Generate for poster (moderate quality)
59
- python generate_schematic.py "Transformer architecture" -o arch.png --doc-type poster
60
-
61
- # Generate for slides (faster, lower threshold)
62
- python generate_schematic.py "System diagram" -o system.png --doc-type presentation
63
-
64
- # Custom max iterations
65
- python generate_schematic.py "Complex pathway" -o pathway.png --iterations 2
66
-
67
- # Verbose output
68
- python generate_schematic.py "Circuit diagram" -o circuit.png -v
69
-
70
- Environment Variables:
71
- OPENROUTER_API_KEY Required for AI generation
72
- """
73
- )
74
-
75
- parser.add_argument("prompt",
76
- help="Description of the diagram to generate")
77
- parser.add_argument("-o", "--output", required=True,
78
- help="Output file path")
79
- parser.add_argument("--doc-type", default="default",
80
- choices=["journal", "conference", "poster", "presentation",
81
- "report", "grant", "thesis", "preprint", "default"],
82
- help="Document type for quality threshold (default: default)")
83
- parser.add_argument("--iterations", type=int, default=2,
84
- help="Maximum refinement iterations (default: 2, max: 2)")
85
- parser.add_argument("--api-key",
86
- help="OpenRouter API key (or use OPENROUTER_API_KEY env var)")
87
- parser.add_argument("-v", "--verbose", action="store_true",
88
- help="Verbose output")
89
-
90
- args = parser.parse_args()
91
-
92
- # Check for API key
93
- api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")
94
- if not api_key:
95
- print("Error: OPENROUTER_API_KEY environment variable not set")
96
- print("\nFor AI generation, you need an OpenRouter API key.")
97
- print("Get one at: https://openrouter.ai/keys")
98
- print("\nSet it with:")
99
- print(" export OPENROUTER_API_KEY='your_api_key'")
100
- print("\nOr use --api-key flag")
101
- sys.exit(1)
102
-
103
- # Find AI generation script
104
- script_dir = Path(__file__).parent
105
- ai_script = script_dir / "generate_schematic_ai.py"
106
-
107
- if not ai_script.exists():
108
- print(f"Error: AI generation script not found: {ai_script}")
109
- sys.exit(1)
110
-
111
- # Build command
112
- cmd = [sys.executable, str(ai_script), args.prompt, "-o", args.output]
113
-
114
- if args.doc_type != "default":
115
- cmd.extend(["--doc-type", args.doc_type])
116
-
117
- # Enforce max 2 iterations
118
- iterations = min(args.iterations, 2)
119
- if iterations != 2:
120
- cmd.extend(["--iterations", str(iterations)])
121
-
122
- if args.verbose:
123
- cmd.append("-v")
124
-
125
- # Execute — pass API key via environment to avoid exposure in process listings
126
- try:
127
- env = os.environ.copy()
128
- if api_key:
129
- env["OPENROUTER_API_KEY"] = api_key
130
- result = subprocess.run(cmd, check=False, env=env)
131
- sys.exit(result.returncode)
132
- except Exception as e:
133
- print(f"Error executing AI generation: {e}")
134
- sys.exit(1)
135
-
136
-
137
- if __name__ == "__main__":
138
- main()
139
-