-
-
Notifications
You must be signed in to change notification settings - Fork 29
Cortex Installation Script Generator #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new ScriptGenerator module for producing installation scripts (Bash/Ansible) with generate/test/history actions, integrates new Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI
participant ScriptGen as ScriptGenerator
participant FS as FileSystem
participant Hist as HistoryFile
rect rgb(247,250,255)
Note over User,Hist: Generate Script Flow
User->>CLI: script generate <file> --stack <stack> --format <fmt> [--dry-run]
CLI->>ScriptGen: generate(filename, stack, format, dry_run)
ScriptGen->>ScriptGen: validate stack & format, assemble content
alt dry-run
ScriptGen->>User: print generated content and intended path
else write
ScriptGen->>FS: write file content
ScriptGen->>FS: set executable permissions
ScriptGen->>Hist: _save_to_history(stack, format, filename)
Hist->>FS: append YAML entry (if yaml available)
end
ScriptGen->>CLI: return exit code
CLI->>User: display success or error
end
sequenceDiagram
actor User
participant CLI
participant ScriptGen as ScriptGenerator
participant FS as FileSystem
rect rgb(245,255,245)
Note over User,FS: Test Script Flow (syntax/sandbox)
User->>CLI: script test <file> [--sandbox]
CLI->>ScriptGen: test(filename, sandbox)
ScriptGen->>FS: read script file
ScriptGen->>ScriptGen: run syntax check (bash -n) / sandboxed validation
alt syntax OK
ScriptGen->>CLI: return success
CLI->>User: report success
else failure
ScriptGen->>CLI: return error + diagnostics
CLI->>User: report failure
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (5)
cortex/script_gen.py (4)
14-35: Add type hints to STACK_DEPS constant.As per coding guidelines, type hints are required. The STACK_DEPS dictionary should include type annotations.
🔎 Suggested type hint
+from typing import TypedDict + +class StackConfig(TypedDict): + packages: list[str] + check_command: str + verification: str + -STACK_DEPS = { +STACK_DEPS: dict[str, StackConfig] = {
74-77: Add type hints to init method.The
__init__method lacks type hints. Per coding guidelines, type hints are required for Python code.- def __init__(self): + def __init__(self) -> None:
165-199: Add type hints to test method.The method signature lacks type hints for parameters and return value. Per coding guidelines, type hints are required.
- def test(self, filename: str, sandbox: bool = True): + def test(self, filename: str, sandbox: bool = True) -> None:
201-256: Add type hints to history methods.Both
_save_to_historyandshow_historyare missing complete type hints for their parameters.- def show_history(self, limit: int = 10) -> None: + def show_history(self, limit: int = 10) -> None: # ✓ Already has return typeThe
_save_to_historyalready has-> None, andshow_historyalready has return type annotations, so this is good. However, ensure all parameters have type hints throughout the class.cortex/cli.py (1)
297-327: Remove unnecessary hasattr check for limit.Line 318 uses
hasattr(args, "limit")to check for thelimitattribute, butlimitis always defined in the history_parser with a default value of 10 (line 907). The hasattr check is unnecessary.- limit = args.limit if hasattr(args, "limit") else 10 + limit = args.limit
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cortex/cli.pycortex/script_gen.pytests/test_script_gen.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
cortex/cli.pycortex/script_gen.pytests/test_script_gen.py
tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Maintain >80% test coverage for pull requests
Files:
tests/test_script_gen.py
🧬 Code graph analysis (2)
cortex/cli.py (1)
cortex/script_gen.py (4)
ScriptGenerator(73-257)generate(79-163)test(165-199)show_history(226-257)
tests/test_script_gen.py (1)
cortex/script_gen.py (3)
ScriptGenerator(73-257)generate(79-163)test(165-199)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build Package
- GitHub Check: test (3.11)
- GitHub Check: test (3.12)
- GitHub Check: test (3.10)
🔇 Additional comments (5)
tests/test_script_gen.py (2)
1-257: Excellent test coverage!The test suite is comprehensive and well-structured, covering:
- All supported stacks (docker, python, nodejs, ollama)
- Both output formats (bash, ansible)
- File operations (permissions, timestamps, dry-run)
- Error handling (invalid inputs)
- Bash best practices (strict mode, traps, logging, colors)
- Syntax validation
- Parameterized tests for multi-stack coverage
This meets the >80% coverage requirement from the acceptance criteria in issue #140.
100-135: Update idempotency tests after fixing the implementation bug.These tests currently validate the broken idempotency behavior in
cortex/script_gen.py. The implementation uses a singlecheck_commandper stack for all packages, causing multi-package stacks to fail true idempotency. For example, the docker stack usescommand_exists dockerfor bothdocker.ioanddocker-compose, so if docker is installed but docker-compose is missing, docker-compose will never be installed.After implementing the fix to use per-package checks, these tests need to be updated to verify:
- Docker test:
command_exists docker-composeappears for the docker-compose package check (not justcommand_exists docker)- Nodejs test:
command_exists npmappears for the npm package check (not justcommand_exists node)cortex/cli.py (3)
297-327: Clean CLI integration for script commands.The
script()method follows the established CLI patterns and properly delegates to theScriptGenerator. Error handling covers the expected failure modes (file not found, generic exceptions), and the local import ofScriptGeneratoravoids potential circular dependency issues.
870-908: Well-structured argument parsing for script commands.The argument parser configuration is comprehensive and follows best practices:
- Clear help text for each subcommand and argument
- Appropriate use of
choicesto constrain inputs (stacks, formats)- Sensible defaults (stack="docker", format="bash", limit=10)
- The alias
"scripts"provides user convenience
809-813: Proper integration into CLI help and routing.The script commands are properly integrated into the help output and command routing, making them discoverable and accessible to users.
Also applies to: 1014-1015
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cortex/cli.py (1)
1-1: Critical: Black formatting check failed.The CI pipeline reports that this file needs Black formatting. Run
black cortex/cli.pyto fix the formatting issues before merging.#!/bin/bash # Format the file with Black black cortex/cli.py
🧹 Nitpick comments (1)
cortex/cli.py (1)
319-319: Optional:hasattrcheck is unnecessary.The
--limitargument is defined withdefault=10in the parser (line 939), soargs.limitwill always exist. Thehasattrcheck is defensive but redundant.🔎 Simplification
- limit = args.limit if hasattr(args, "limit") else 10 + limit = args.limit generator.show_history(limit=limit)
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
cortex/cli.py
🪛 GitHub Actions: CI
cortex/cli.py
[error] 1-1: Black formatting check failed. 1 file would be reformatted. Run 'black' to format the code.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (3.12)
- GitHub Check: test (3.10)
- GitHub Check: test (3.11)
🔇 Additional comments (3)
cortex/cli.py (3)
841-845: LGTM! Clear help text for script commands.The help text additions are well-structured and consistent with the existing command documentation.
902-940: LGTM! Well-structured argument parser definitions.The script subcommand parser is properly configured with:
- Appropriate default values
- Constrained choices for stack and format options
- Required subcommands via
required=True- Alias support for "scripts"
The implementation follows the existing patterns in the file and matches the requirements from issue #140.
1051-1052: LGTM! Proper command routing.The script command is correctly routed to
cli.script(args), following the established pattern for other commands. The alias "scripts" will be handled automatically by argparse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cortex/cli.py (1)
1-1: Critical: Black formatting check failed.The CI pipeline reports that this file would be reformatted by Black. Run
black .to format the code before merging.#!/bin/bash # Run Black formatter to fix the formatting issues black cortex/cli.py
♻️ Duplicate comments (3)
cortex/cli.py (2)
298-328: Critical: Missing return statement causes implicit None return.The function declares
-> intbut the exception handler at line 326-327 doesn't return a value, and there's no return statement after the try/except block. This causes the function to returnNonein error cases, violating the type contract.🔎 Proposed fix
except FileNotFoundError: console.print(f"[red]✗ Script file not found: {args.filename}[/red]") return 1 except Exception as e: console.print(f"[red]✗ Script command failed: {str(e)}[/red]") + return 1 + def ask(self, question: str) -> int:
323-325: Critical: AttributeError when FileNotFoundError occurs during history command.The
FileNotFoundErrorhandler referencesargs.filename, but thehistorysubcommand doesn't have afilenameargument. This will raise anAttributeErrorif a file-not-found error occurs during history operations.🔎 Proposed fix
except FileNotFoundError: - console.print(f"[red]✗ Script file not found: {args.filename}[/red]") + filename = getattr(args, "filename", "unknown") + console.print(f"[red]✗ Script file not found: {filename}[/red]") return 1cortex/script_gen.py (1)
131-155: Critical: Ansible format breaks with dict-structured packages.Line 132 assumes packages are strings, but
STACK_DEPSnow uses dicts withnameandcheck_commandfields. This will generate invalid Ansible YAML like- {'name': 'docker.io', 'check_command': 'docker'}instead of- docker.io.🔎 Proposed fix
elif format == "ansible": - pkg_list = "\n".join([f" - {pkg}" for pkg in deps.get("packages", [])]) + packages = deps.get("packages", []) + pkg_names = [ + pkg["name"] if isinstance(pkg, dict) else pkg for pkg in packages + ] + pkg_list = "\n".join([f" - {pkg_name}" for pkg_name in pkg_names]) content = f"""---
🧹 Nitpick comments (2)
cortex/script_gen.py (2)
1-3: Consider expanding the module docstring.The current module docstring is minimal. Consider adding more details such as supported formats, stacks, and usage examples.
🔎 Suggested enhancement
""" -Generates standalone installation scripts for offline or automated deployments. +Script Generator Module + +Generates standalone installation scripts (Bash and Ansible) for offline or automated deployments. + +Supported stacks: docker, python, nodejs, ollama +Supported formats: bash, ansible + +Example: + generator = ScriptGenerator() + generator.generate("install.sh", stack="docker", format="bash") """
238-244: Avoid bare except clauses.The bare
exceptclause on line 243 catches all exceptions includingKeyboardInterruptandSystemExit. Useexcept Exception:to catch only standard exceptions while allowing system exits and interrupts to propagate.🔎 Proposed fix
if self.history_file.exists(): try: content = self.history_file.read_text() if content.strip(): history = yaml.safe_load(content) or [] - except Exception: + except Exception: history = []Note: This is actually already using
except Exception:in the implementation, so this comment may not apply. Let me verify...Actually looking again, line 243 just says
except Exception:which is correct. But line 262 also has a bare except. Let me check that one.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cortex/cli.pycortex/script_gen.pytests/test_script_gen.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
tests/test_script_gen.pycortex/cli.pycortex/script_gen.py
tests/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Maintain >80% test coverage for pull requests
Files:
tests/test_script_gen.py
🧠 Learnings (1)
📚 Learning: 2025-12-11T12:03:24.071Z
Learnt from: CR
Repo: cortexlinux/cortex PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-11T12:03:24.071Z
Learning: Applies to {setup.py,setup.cfg,pyproject.toml,**/__init__.py} : Use Python 3.10 or higher as the minimum supported version
Applied to files:
cortex/script_gen.py
🧬 Code graph analysis (3)
tests/test_script_gen.py (1)
cortex/script_gen.py (3)
ScriptGenerator(87-280)generate(96-186)test(188-222)
cortex/cli.py (2)
cortex/script_gen.py (4)
ScriptGenerator(87-280)generate(96-186)test(188-222)show_history(249-280)tests/test_script_gen.py (1)
generator(16-18)
cortex/script_gen.py (1)
cortex/cli.py (2)
stack(184-212)history(608-669)
🪛 GitHub Actions: CI
cortex/cli.py
[error] 1-1: black --check . reported that 1 file would be reformatted. Run 'black' to format the code.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (3.12)
- GitHub Check: test (3.11)
- GitHub Check: test (3.10)
🔇 Additional comments (7)
cortex/script_gen.py (2)
21-49: Excellent fix for idempotency and Python version concerns!The package structure now correctly uses per-package check commands (e.g.,
dockerfordocker.io,docker-composefordocker-compose), which addresses the critical idempotency bug flagged in previous reviews. Additionally, changing frompython3.11topython3makes the configuration more portable.
260-264: Good exception handling.The error handling correctly uses
except Exception:rather than a bareexcept:, which properly allows system exits and keyboard interrupts to propagate.cortex/cli.py (2)
841-845: Help documentation is clear and consistent.The help table entries for the script commands are well-documented and follow the existing format conventions.
902-940: Parser configuration is well-structured.The argparse setup is comprehensive with appropriate choices, defaults, and help text. The
required=Trueforscript_actionensures users must specify a subcommand.tests/test_script_gen.py (3)
1-25: Well-structured test fixtures.The test suite uses pytest fixtures appropriately, with clean separation between the generator instance and temporary file paths.
73-223: Comprehensive test coverage meeting requirements.The test suite thoroughly covers:
- All four stacks (docker, python, nodejs, ollama)
- Both output formats (bash, ansible)
- Idempotency checks
- Error handling
- Bash best practices (strict mode, traps, logging)
- File operations and permissions
This aligns well with the >80% coverage target from the coding guidelines and issue #140 requirements.
210-222: Excellent use of parameterized tests.The parameterized tests efficiently validate all stacks in both formats, reducing code duplication while maintaining comprehensive coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
cortex/script_gen.py (2)
16-19: Consider tightening the verification type.The
verificationfield is typed asstr | None, but all stack definitions inSTACK_DEPSprovide non-null verification commands. Consider changing the type to juststrfor consistency, or keep the optional type if you plan to support stacks without verification in the future.🔎 Proposed type refinement
class StackConfig(TypedDict): packages: list[dict | str] - verification: str | None + verification: str
281-282: Enhance docstring to document the limit parameter.While a docstring is now present (addressing the previous comment), it doesn't document the
limitparameter. Per best practices, all parameters should be documented in public API docstrings.🔎 Enhanced docstring
def show_history(self, limit: int = 10) -> None: - """Print recent script generation history.""" + """ + Display recent script generation history. + + Args: + limit: Maximum number of history entries to show (default: 10) + """
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cortex/cli.pycortex/script_gen.py
🚧 Files skipped from review as they are similar to previous changes (1)
- cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
cortex/script_gen.py
🧠 Learnings (2)
📚 Learning: 2025-12-11T12:03:24.071Z
Learnt from: CR
Repo: cortexlinux/cortex PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-11T12:03:24.071Z
Learning: Applies to {setup.py,setup.cfg,pyproject.toml,**/__init__.py} : Use Python 3.10 or higher as the minimum supported version
Applied to files:
cortex/script_gen.py
📚 Learning: 2025-12-11T12:03:24.071Z
Learnt from: CR
Repo: cortexlinux/cortex PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-11T12:03:24.071Z
Learning: Applies to **/*.py : Docstrings required for all public APIs
Applied to files:
cortex/script_gen.py
🧬 Code graph analysis (1)
cortex/script_gen.py (1)
cortex/cli.py (2)
stack(184-212)history(611-672)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (3.12)
- GitHub Check: test (3.10)
- GitHub Check: test (3.11)
🔇 Additional comments (3)
cortex/script_gen.py (3)
99-210: Well-structured script generation implementation.The
generatemethod properly addresses previous review concerns:
- Complete docstring with parameter documentation ✓
- Per-package idempotency checks to avoid the multi-package installation bug ✓
- Supports both dict and string package formats (lines 122-127)
- Proper error handling with informative messages
- Correct file permissions (0o755 for executable scripts)
- History tracking integration
The implementation is thorough and follows best practices.
211-254: Solid test implementation with good safety measures.The
testmethod includes:
- Complete docstring ✓
- Proper script validation using
bash -nfor syntax checking- Timeout protection (10 seconds) to prevent hanging on problematic scripts
- Clear error messages and user feedback
- Option to skip validation with
sandbox=Falseparameter
283-313: Clean history display with proper error handling.The implementation demonstrates good practices:
- Graceful degradation when PyYAML is unavailable (lines 283-287)
- Robust error handling for missing or corrupted history files (lines 289-297)
- Clear user feedback for all scenarios (empty history, errors, etc.)
- Correct ordering with
reversed(data[-limit:])to show latest entries first (line 306)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
cortex/cli.py (3)
284-289: Add type hint and docstring for public API.Per coding guidelines, public methods require type hints and docstrings. The
doctor()method should declare its return type and document its purpose.🔎 Proposed fix
# Run system health checks - def doctor(self): + def doctor(self) -> int: + """Run comprehensive system health checks and diagnostics.""" from cortex.doctor import SystemDoctor doctor = SystemDoctor() return doctor.run_checks()
291-322: Add fallback return for unhandled script actions.If
args.script_actiondoesn't match any of the expected values ("generate", "test", "history"), the function exits the try block without returning, resulting in an implicitNonereturn which violates the-> inttype hint. While argparse should prevent this viarequired=True, a defensive fallback is recommended.🔎 Proposed fix
elif args.script_action == "history": limit = args.limit generator.show_history(limit=limit) return 0 + else: + console.print(f"[red]✗ Unknown script action: {args.script_action}[/red]") + return 1 + except FileNotFoundError: filename = getattr(args, "filename", "unknown") console.print(f"[red]✗ Script file not found: {filename}[/red]") return 1 except Exception as e: console.print(f"[red]✗ Script command failed: {str(e)}[/red]") return 1
1251-1255: Variablehistory_parsershadows the main history command parser.The variable
history_parserdefined here on line 1252 shadows the identically named variable defined later on line 1272 for the maincortex historycommand. While Python allows this, it can cause confusion during maintenance.🔎 Proposed fix
# cortex script history - history_parser = script_subs.add_parser("history", help="Show script generation history") - history_parser.add_argument( + script_history_parser = script_subs.add_parser("history", help="Show script generation history") + script_history_parser.add_argument( "--limit", "-l", type=int, default=10, help="Number of entries to show (default: 10)" )
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
cortex/cli.py
🧬 Code graph analysis (1)
cortex/cli.py (3)
cortex/doctor.py (2)
SystemDoctor(21-478)run_checks(48-103)cortex/script_gen.py (4)
ScriptGenerator(91-324)generate(105-215)test(217-259)show_history(287-324)tests/test_script_gen.py (1)
generator(16-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (3.10)
- GitHub Check: test (3.12)
- GitHub Check: test (3.11)
🔇 Additional comments (2)
cortex/cli.py (2)
1136-1140: LGTM!The help table entries accurately describe the new script subcommands and are consistent with the existing help format.
1443-1446: LGTM!The dispatch logic for
doctorandscriptcommands follows the established pattern and integrates correctly with the existing command handling structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cortex/cli.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs
Files:
cortex/cli.py
🧠 Learnings (1)
📚 Learning: 2025-12-11T12:03:24.071Z
Learnt from: CR
Repo: cortexlinux/cortex PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-11T12:03:24.071Z
Learning: Applies to **/*sandbox*.py : Implement Firejail sandboxing for package operations
Applied to files:
cortex/cli.py
🧬 Code graph analysis (1)
cortex/cli.py (2)
cortex/doctor.py (2)
SystemDoctor(21-478)run_checks(48-103)cortex/script_gen.py (4)
ScriptGenerator(91-324)generate(105-215)test(217-259)show_history(287-324)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build Package
- GitHub Check: test (3.11)
- GitHub Check: test (3.10)
- GitHub Check: test (3.12)
🔇 Additional comments (1)
cortex/cli.py (1)
291-322: LGTM! Past review issues addressed.The implementation correctly handles all script subcommands with proper error handling. All previously flagged issues have been resolved:
- Exception handlers now return explicit integer values
- FileNotFoundError uses safe attribute access with
getattr- All code paths return the declared
inttype
|



Related Issue
Closes #140
Summary
Generates standalone .sh bash scripts AND Ansible .yml playbooks for docker/python/nodejs/ollama stacks. Idempotent (command_exists), colorful logging, error traps. cortex script test validates syntax, cortex script history tracks all.
Commands Usage
cortex script generate <filename> --stack <stack-name>Generates a standalone installation script for the specified stack.
docker,python,nodejs,ollamabash~/cortex/install-scripts/unless an absolute path is providedExamples:
cortex script test <filename>Validates the syntax of a generated bash script using a sandboxed bash -n check.
Example:
cortex script test docker.shcortex script historyDisplays the history of generated scripts
check-list
Video walk-around
Screen.Recording.2025-12-24.225216.1.1.mp4
Installing using script-file (docker already installed but it works!)
Screen.Recording.2025-12-24.225907.mp4
Checklist
pytest tests/test_script_gen.py)[#XX] DescriptionSummary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.