Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ cortex install "tools for video compression"
| **Audit Trail** | Complete history in `~/.cortex/history.db` |
| **Hardware-Aware** | Detects GPU, CPU, memory for optimized packages |
| **Multi-LLM Support** | Works with Claude, GPT-4, or local Ollama models |
| **Auto-Documentation** | [NEW] Automatically generates system and software guides |

---

Expand Down Expand Up @@ -192,6 +193,7 @@ cortex role set <slug>
| `cortex rollback <id>` | Undo a specific installation |
| `cortex --version` | Show version information |
| `cortex --help` | Display help message |
| `cortex docs <cmd>` | [NEW] Generate and view software documentation |

#### Daemon Commands

Expand Down Expand Up @@ -275,6 +277,7 @@ cortex/
│ ├── packages.py # Package manager wrapper
│ ├── hardware_detection.py
│ ├── installation_history.py
│ ├── docs_generator.py # [NEW] Documentation system
│ └── utils/ # Utility modules
├── daemon/ # C++ background daemon (cortexd)
│ ├── src/ # Daemon source code
Expand All @@ -284,6 +287,7 @@ cortex/
│ └── README.md # Daemon documentation
├── tests/ # Python test suite
├── docs/ # Documentation
│ └── modules/ # [README_DOCS_GENERATOR.md](docs/modules/README_DOCS_GENERATOR.md)
├── examples/ # Example scripts
└── scripts/ # Utility scripts
```
Expand Down
66 changes: 59 additions & 7 deletions cortex/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
ParseResult,
format_package_list,
)
from cortex.docs_generator import DocsGenerator
from cortex.env_manager import EnvironmentManager, get_env_manager
from cortex.i18n import (
SUPPORTED_LANGUAGES,
LanguageConfig,
get_language,
set_language,
t,
)
from cortex.i18n import SUPPORTED_LANGUAGES, LanguageConfig, get_language, set_language, t
from cortex.installation_history import InstallationHistory, InstallationStatus, InstallationType
from cortex.llm.interpreter import CommandInterpreter
from cortex.network_config import NetworkConfig
Expand Down Expand Up @@ -3881,6 +3876,30 @@ def main():
help="Enable verbose output",
)

# Automatic Documentation Generator
docs_parser = subparsers.add_parser("docs", help="Automatic documentation generator")
docs_subparsers = docs_parser.add_subparsers(dest="docs_action", help="Documentation actions")

# docs generate
gen_parser = docs_subparsers.add_parser("generate", help="Generate documentation for software")
gen_parser.add_argument("software", help="Software/Package name")

# docs export
exp_parser = docs_subparsers.add_parser("export", help="Export documentation to file")
exp_parser.add_argument("software", help="Software/Package name")
exp_parser.add_argument(
"--format", choices=["md", "pdf", "html"], default="md", help="Export format (default: md)"
)

# docs view
view_parser = docs_subparsers.add_parser("view", help="View documentation guide")
view_parser.add_argument("software", help="Software/Package name")
view_parser.add_argument(
"guide",
choices=["installation", "config", "quick-start", "troubleshooting"],
help="Guide type to view",
)

# System Health Score
health_parser = subparsers.add_parser("health", help="System health score and recommendations")
health_parser.add_argument(
Expand Down Expand Up @@ -4034,6 +4053,39 @@ def main():
packages=getattr(args, "packages", None),
verbose=getattr(args, "verbose", False),
)
elif args.command == "docs":
try:
docs_gen = DocsGenerator()
if args.docs_action == "generate":
cx_print(f"📄 Generating documentation for {args.software}...", "info")
paths = docs_gen.generate_software_docs(args.software)
console.print("\nCreated:")
for name, path in paths.items():
console.print(f" - {name}")
return 0
elif args.docs_action == "export":
path = docs_gen.export_docs(args.software, format=args.format)
if "failed" in path.lower():
cx_print(path, "warning")
else:
cx_print(f"✓ Exported to {path}", "success")
return 0
elif args.docs_action == "view":
docs_gen.view_guide(args.software, args.guide)
return 0
else:
docs_parser.print_help()
return 1
except (ValueError, OSError, ImportError) as e:
cx_print(f"Documentation error: {e}", "error")
return 1
except Exception as e:
cx_print(f"Unexpected documentation error: {e}", "error")
if args.verbose:
import traceback

traceback.print_exc()
return 1
elif args.command == "health":
from cortex.health_score import run_health_check

Expand Down
Loading