context-gen-cli 1.0.0__tar.gz → 1.2.4__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 (23) hide show
  1. context_gen_cli-1.2.4/PKG-INFO +137 -0
  2. context_gen_cli-1.2.4/README.md +110 -0
  3. context_gen_cli-1.2.4/context_gen/cli.py +287 -0
  4. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen/generator.py +73 -0
  5. context_gen_cli-1.2.4/context_gen/mcp/__init__.py +3 -0
  6. context_gen_cli-1.2.4/context_gen/mcp/advanced_tools.py +475 -0
  7. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen/scanner.py +25 -13
  8. context_gen_cli-1.2.4/context_gen_cli.egg-info/PKG-INFO +137 -0
  9. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen_cli.egg-info/SOURCES.txt +4 -1
  10. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen_cli.egg-info/entry_points.txt +1 -0
  11. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/pyproject.toml +2 -1
  12. context_gen_cli-1.2.4/tests/test_advanced_tools.py +74 -0
  13. context_gen_cli-1.0.0/PKG-INFO +0 -53
  14. context_gen_cli-1.0.0/README.md +0 -26
  15. context_gen_cli-1.0.0/context_gen/cli.py +0 -124
  16. context_gen_cli-1.0.0/context_gen_cli.egg-info/PKG-INFO +0 -53
  17. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen/__init__.py +0 -0
  18. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen/extractor.py +0 -0
  19. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen/graph.py +0 -0
  20. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen_cli.egg-info/dependency_links.txt +0 -0
  21. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen_cli.egg-info/requires.txt +0 -0
  22. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/context_gen_cli.egg-info/top_level.txt +0 -0
  23. {context_gen_cli-1.0.0 → context_gen_cli-1.2.4}/setup.cfg +0 -0
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: context-gen-cli
3
+ Version: 1.2.4
4
+ Summary: A modern CLI tool that scans any project, builds an AST-based dependency graph, and generates structured LLM context (agent.md / agent.json).
5
+ Author: yakkshit
6
+ License-Expression: MIT
7
+ Keywords: llm,context,agent,cli,code-analysis,ast,graph,mcp
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Code Generators
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: typer[all]>=0.12.0
21
+ Requires-Dist: rich>=13.7.0
22
+ Requires-Dist: pathspec>=0.12.1
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
25
+ Requires-Dist: build>=1.1.0; extra == "dev"
26
+ Requires-Dist: twine>=5.0.0; extra == "dev"
27
+
28
+ # ⚡ context-gen-cli (Python Edition)
29
+
30
+ [![PyPI version](https://img.shields.io/pypi/v/context-gen-cli.svg?color=3775a9)](https://pypi.org/project/context-gen-cli/)
31
+ [![Python Versions](https://img.shields.io/pypi/pyversions/context-gen-cli.svg)](https://pypi.org/project/context-gen-cli/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
33
+
34
+ > ⚡ **Fast, AST-powered Python CLI tool that scans any project, extracts architecture models, and generates structured LLM context (`agent.md`, `agent.json`, `agent.yaml`).**
35
+
36
+ ---
37
+
38
+ ## 🌟 Highlights
39
+
40
+ - **100% Accurate Python Dependency Graphs**: Built using Python's native `ast` (Abstract Syntax Tree) module to resolve imports, relative packages, entry points, and utilities without regex guesswork.
41
+ - **⚡ All-In-One Default Mode (`-d`)**: Auto-generates triple context formats in `context/` and runs a live auto-sync watcher in the background.
42
+ - **`.gitignore` & Multi-Ignore Respect**: Automatically parses rules from `.gitignore`, `.npmignore`, `.dockerignore`, `.contextignore`, `.ignore`, and filters `.env*` secrets.
43
+ - **Triple Format Output**: Generates Markdown (`agent.md`), MCP-compatible structured JSON (`agent.json`), and clean YAML (`agent.yaml`).
44
+ - **🔄 Auto-Sync Watch Mode (`-w`)**: Monitors workspace changes and updates context files automatically on save.
45
+ - **Configuration Parity**: Seamlessly reads `.context-gen.json` if present to maintain unified project settings with the Node.js edition.
46
+ - **Modern CLI**: Styled with `typer` and `rich` for rich terminal output and progress reporting.
47
+
48
+ ---
49
+
50
+ ## 📦 Installation
51
+
52
+ Install from PyPI using `pip` (or `pipx` / `uv`):
53
+
54
+ ```bash
55
+ pip install context-gen-cli
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 🚀 Quick Start
61
+
62
+ ### 1. ⚡ All-In-One Default Mode (Recommended)
63
+ Generates all formats in `context/` and starts the live auto-sync watcher in background:
64
+
65
+ ```bash
66
+ context-gen -d
67
+ ```
68
+
69
+ ### 2. Generate All Formats (Markdown, JSON, YAML)
70
+ Scans the current directory and outputs `agent.md`, `agent.json`, and `agent.yaml` in `context/`:
71
+
72
+ ```bash
73
+ context-gen .
74
+ ```
75
+
76
+ ### 3. Generate Specific Format (JSON / MD / YAML)
77
+ Generate only the format you need:
78
+
79
+ ```bash
80
+ # Generate MCP-ready JSON
81
+ context-gen . --format json
82
+
83
+ # Generate Markdown
84
+ context-gen . --format md
85
+
86
+ # Generate YAML
87
+ context-gen . --format yaml
88
+ ```
89
+
90
+ ### 4. Watch Mode
91
+ Keep context files fresh automatically on every file edit:
92
+
93
+ ```bash
94
+ context-gen . --watch
95
+ ```
96
+
97
+ ### 5. Custom Output Destination & Directory Depth
98
+ ```bash
99
+ context-gen ./my-project -o custom/docs/context.md --max-depth 4
100
+ ```
101
+
102
+ ---
103
+
104
+ ## 📖 CLI Reference
105
+
106
+ ```text
107
+ Usage: context-gen [OPTIONS] [PATH]
108
+
109
+ Arguments:
110
+ [PATH] Target project directory to analyze [default: .]
111
+
112
+ Options:
113
+ -d, --default ⚡ Zero-config default mode: generate all formats in context/ and run live auto-sync watcher
114
+ -f, --format [all|md|json|yaml] Output format [default: all]
115
+ -o, --output PATH Custom output file path (e.g. context/agent.md or custom.json)
116
+ -w, --watch Watch directory and auto-regenerate context on file changes
117
+ --max-depth INTEGER Maximum directory depth to scan (1-10) [default: 3]
118
+ --help Show this message and exit
119
+ ```
120
+
121
+ ---
122
+
123
+ ## 🌐 Node.js & Live MCP Server
124
+
125
+ Looking for the live MCP server with interactive SSE streaming and public tunnels? Check out the [Node.js edition](https://www.npmjs.com/package/context-gen-cli):
126
+
127
+ ```bash
128
+ npx context-gen-cli -d
129
+ # or
130
+ npx context-gen-cli --mcp
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 📄 License
136
+
137
+ MIT © [yakkshit](https://github.com/yakkshit)
@@ -0,0 +1,110 @@
1
+ # ⚡ context-gen-cli (Python Edition)
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/context-gen-cli.svg?color=3775a9)](https://pypi.org/project/context-gen-cli/)
4
+ [![Python Versions](https://img.shields.io/pypi/pyversions/context-gen-cli.svg)](https://pypi.org/project/context-gen-cli/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ > ⚡ **Fast, AST-powered Python CLI tool that scans any project, extracts architecture models, and generates structured LLM context (`agent.md`, `agent.json`, `agent.yaml`).**
8
+
9
+ ---
10
+
11
+ ## 🌟 Highlights
12
+
13
+ - **100% Accurate Python Dependency Graphs**: Built using Python's native `ast` (Abstract Syntax Tree) module to resolve imports, relative packages, entry points, and utilities without regex guesswork.
14
+ - **⚡ All-In-One Default Mode (`-d`)**: Auto-generates triple context formats in `context/` and runs a live auto-sync watcher in the background.
15
+ - **`.gitignore` & Multi-Ignore Respect**: Automatically parses rules from `.gitignore`, `.npmignore`, `.dockerignore`, `.contextignore`, `.ignore`, and filters `.env*` secrets.
16
+ - **Triple Format Output**: Generates Markdown (`agent.md`), MCP-compatible structured JSON (`agent.json`), and clean YAML (`agent.yaml`).
17
+ - **🔄 Auto-Sync Watch Mode (`-w`)**: Monitors workspace changes and updates context files automatically on save.
18
+ - **Configuration Parity**: Seamlessly reads `.context-gen.json` if present to maintain unified project settings with the Node.js edition.
19
+ - **Modern CLI**: Styled with `typer` and `rich` for rich terminal output and progress reporting.
20
+
21
+ ---
22
+
23
+ ## 📦 Installation
24
+
25
+ Install from PyPI using `pip` (or `pipx` / `uv`):
26
+
27
+ ```bash
28
+ pip install context-gen-cli
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 🚀 Quick Start
34
+
35
+ ### 1. ⚡ All-In-One Default Mode (Recommended)
36
+ Generates all formats in `context/` and starts the live auto-sync watcher in background:
37
+
38
+ ```bash
39
+ context-gen -d
40
+ ```
41
+
42
+ ### 2. Generate All Formats (Markdown, JSON, YAML)
43
+ Scans the current directory and outputs `agent.md`, `agent.json`, and `agent.yaml` in `context/`:
44
+
45
+ ```bash
46
+ context-gen .
47
+ ```
48
+
49
+ ### 3. Generate Specific Format (JSON / MD / YAML)
50
+ Generate only the format you need:
51
+
52
+ ```bash
53
+ # Generate MCP-ready JSON
54
+ context-gen . --format json
55
+
56
+ # Generate Markdown
57
+ context-gen . --format md
58
+
59
+ # Generate YAML
60
+ context-gen . --format yaml
61
+ ```
62
+
63
+ ### 4. Watch Mode
64
+ Keep context files fresh automatically on every file edit:
65
+
66
+ ```bash
67
+ context-gen . --watch
68
+ ```
69
+
70
+ ### 5. Custom Output Destination & Directory Depth
71
+ ```bash
72
+ context-gen ./my-project -o custom/docs/context.md --max-depth 4
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 📖 CLI Reference
78
+
79
+ ```text
80
+ Usage: context-gen [OPTIONS] [PATH]
81
+
82
+ Arguments:
83
+ [PATH] Target project directory to analyze [default: .]
84
+
85
+ Options:
86
+ -d, --default ⚡ Zero-config default mode: generate all formats in context/ and run live auto-sync watcher
87
+ -f, --format [all|md|json|yaml] Output format [default: all]
88
+ -o, --output PATH Custom output file path (e.g. context/agent.md or custom.json)
89
+ -w, --watch Watch directory and auto-regenerate context on file changes
90
+ --max-depth INTEGER Maximum directory depth to scan (1-10) [default: 3]
91
+ --help Show this message and exit
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 🌐 Node.js & Live MCP Server
97
+
98
+ Looking for the live MCP server with interactive SSE streaming and public tunnels? Check out the [Node.js edition](https://www.npmjs.com/package/context-gen-cli):
99
+
100
+ ```bash
101
+ npx context-gen-cli -d
102
+ # or
103
+ npx context-gen-cli --mcp
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 📄 License
109
+
110
+ MIT © [yakkshit](https://github.com/yakkshit)
@@ -0,0 +1,287 @@
1
+ """
2
+ context_gen.cli: Typer-based CLI entry point for context-gen-cli (Python Edition).
3
+ """
4
+
5
+ import json
6
+ import time
7
+ from datetime import datetime
8
+ from enum import Enum
9
+ from pathlib import Path
10
+ from typing import List, Optional
11
+ import typer
12
+ from rich.console import Console
13
+ from rich.panel import Panel
14
+ from rich.table import Table
15
+
16
+ from context_gen.scanner import scan_project
17
+ from context_gen.extractor import extract_metadata
18
+ from context_gen.graph import build_dependency_graph
19
+ from context_gen.generator import generate_agent_md, generate_agent_json, generate_agent_yaml
20
+
21
+ app = typer.Typer(
22
+ name="context-gen",
23
+ help="⚡ Generate graph-based project context (agent.md, agent.json, agent.yaml) for LLMs.",
24
+ add_completion=False,
25
+ no_args_is_help=False
26
+ )
27
+ console = Console()
28
+
29
+
30
+ class OutputFormat(str, Enum):
31
+ """Supported output formats."""
32
+ ALL = "all"
33
+ MD = "md"
34
+ JSON = "json"
35
+ YAML = "yaml"
36
+
37
+
38
+ def execute_generation(
39
+ target_dir: Path,
40
+ format_choice: OutputFormat,
41
+ output_override: Optional[Path] = None,
42
+ max_depth: int = 3,
43
+ verbose: bool = True
44
+ ) -> dict:
45
+ """Scans and generates the requested context format files."""
46
+ scan_result = scan_project(str(target_dir), max_depth=max_depth)
47
+ files = scan_result["files"]
48
+ tree = scan_result["tree"]
49
+
50
+ metadata = extract_metadata(str(target_dir), files)
51
+ graph = build_dependency_graph(files, str(target_dir))
52
+
53
+ # Read output directory from .context-gen.json if available
54
+ config_file = target_dir / ".context-gen.json"
55
+ output_dir_name = "context"
56
+ if config_file.is_file():
57
+ try:
58
+ with open(config_file, "r", encoding="utf-8") as f:
59
+ cfg = json.load(f)
60
+ output_dir_name = cfg.get("outputDir", "context")
61
+ except Exception:
62
+ pass
63
+
64
+ dest_dir = target_dir / output_dir_name
65
+ dest_dir.mkdir(parents=True, exist_ok=True)
66
+
67
+ generated_files: List[Path] = []
68
+
69
+ if output_override:
70
+ out_file = output_override.resolve()
71
+ out_file.parent.mkdir(parents=True, exist_ok=True)
72
+ if format_choice == OutputFormat.JSON:
73
+ json_data = generate_agent_json(metadata, graph, tree, str(target_dir))
74
+ out_file.write_text(json.dumps(json_data, indent=2), encoding="utf-8")
75
+ elif format_choice == OutputFormat.YAML:
76
+ yaml_text = generate_agent_yaml(metadata, graph, tree, str(target_dir))
77
+ out_file.write_text(yaml_text, encoding="utf-8")
78
+ else:
79
+ md_text = generate_agent_md(metadata, graph, tree)
80
+ out_file.write_text(md_text, encoding="utf-8")
81
+ generated_files.append(out_file)
82
+ else:
83
+ # Determine formats to generate
84
+ formats_to_build = ["md", "json", "yaml"] if format_choice == OutputFormat.ALL else [format_choice.value]
85
+
86
+ if "md" in formats_to_build:
87
+ md_file = dest_dir / "agent.md"
88
+ md_text = generate_agent_md(metadata, graph, tree)
89
+ md_file.write_text(md_text, encoding="utf-8")
90
+ generated_files.append(md_file)
91
+
92
+ if "json" in formats_to_build:
93
+ json_file = dest_dir / "agent.json"
94
+ json_data = generate_agent_json(metadata, graph, tree, str(target_dir))
95
+ json_file.write_text(json.dumps(json_data, indent=2), encoding="utf-8")
96
+ generated_files.append(json_file)
97
+
98
+ if "yaml" in formats_to_build:
99
+ yaml_file = dest_dir / "agent.yaml"
100
+ yaml_text = generate_agent_yaml(metadata, graph, tree, str(target_dir))
101
+ yaml_file.write_text(yaml_text, encoding="utf-8")
102
+ generated_files.append(yaml_file)
103
+
104
+ return {
105
+ "files": files,
106
+ "graph": graph,
107
+ "metadata": metadata,
108
+ "generated_files": generated_files,
109
+ "output_dir": dest_dir
110
+ }
111
+
112
+
113
+ def run_watch_loop(target_dir: Path, format_choice: OutputFormat, max_depth: int = 3) -> None:
114
+ """Runs a live background file watch loop that regenerates context on changes."""
115
+ console.print(
116
+ Panel(
117
+ f"[bold cyan]👀 Watch Mode Active[/bold cyan]\n"
118
+ f"[dim]Monitoring workspace:[/dim] [green]{target_dir}[/green]\n"
119
+ f"[dim]Auto-updating context files on save. Press [bold]Ctrl+C[/bold] to exit.[/dim]",
120
+ border_style="cyan"
121
+ )
122
+ )
123
+
124
+ last_snapshot = {}
125
+
126
+ def get_snapshot():
127
+ snap = {}
128
+ for p in target_dir.rglob("*"):
129
+ if p.is_file():
130
+ rel = p.relative_to(target_dir).as_posix()
131
+ if not any(token in rel for token in ["context/", "node_modules/", ".git/", "__pycache__/", ".venv/", "agent."]):
132
+ try:
133
+ snap[rel] = p.stat().st_mtime
134
+ except Exception:
135
+ pass
136
+ return snap
137
+
138
+ last_snapshot = get_snapshot()
139
+
140
+ try:
141
+ while True:
142
+ time.sleep(1.0)
143
+ current_snapshot = get_snapshot()
144
+
145
+ changed = False
146
+ for f, mtime in current_snapshot.items():
147
+ if f not in last_snapshot or last_snapshot[f] != mtime:
148
+ changed = True
149
+ break
150
+
151
+ if not changed and set(last_snapshot.keys()) != set(current_snapshot.keys()):
152
+ changed = True
153
+
154
+ if changed:
155
+ last_snapshot = current_snapshot
156
+ time_str = datetime.now().strftime("%H:%M:%S")
157
+ console.print(f"[dim][{time_str}][/dim] [bold green]🔄 Project changed. Regenerating context files...[/bold green]")
158
+ execute_generation(target_dir, format_choice, max_depth=max_depth, verbose=False)
159
+ console.print(f"[dim][{time_str}][/dim] [bold cyan]✓ Context files updated & synced in context/![/bold cyan]")
160
+ except KeyboardInterrupt:
161
+ console.print("\n[bold yellow]👋 Stopping watch mode...[/bold yellow]")
162
+
163
+
164
+ @app.command()
165
+ def main(
166
+ path: Path = typer.Argument(
167
+ default=Path("."),
168
+ help="Target project directory to analyze.",
169
+ file_okay=False,
170
+ dir_okay=True,
171
+ readable=True,
172
+ resolve_path=True,
173
+ ),
174
+ project: Optional[Path] = typer.Option(
175
+ None,
176
+ "--project",
177
+ "-p",
178
+ help="Target project directory to analyze.",
179
+ file_okay=False,
180
+ dir_okay=True,
181
+ readable=True,
182
+ resolve_path=True,
183
+ ),
184
+ default_mode: bool = typer.Option(
185
+ False,
186
+ "--default",
187
+ "-d",
188
+ help="⚡ Zero-config default mode: generate all formats in context/ and run live auto-sync watcher.",
189
+ ),
190
+ format: OutputFormat = typer.Option(
191
+ OutputFormat.ALL,
192
+ "--format",
193
+ "-f",
194
+ help="Output format: 'all', 'md', 'json', or 'yaml'.",
195
+ case_sensitive=False,
196
+ ),
197
+ mcp: bool = typer.Option(
198
+ False,
199
+ "--mcp",
200
+ "-m",
201
+ help="Start MCP server mode.",
202
+ ),
203
+ interactive: bool = typer.Option(
204
+ False,
205
+ "--interactive",
206
+ "-i",
207
+ help="Run in interactive mode.",
208
+ ),
209
+ output: Optional[Path] = typer.Option(
210
+ None,
211
+ "--output",
212
+ "-o",
213
+ help="Custom output file path (e.g. context/agent.md or custom.json).",
214
+ ),
215
+ watch: bool = typer.Option(
216
+ False,
217
+ "--watch",
218
+ "-w",
219
+ help="Watch directory and auto-regenerate context on file changes.",
220
+ ),
221
+ max_depth: int = typer.Option(
222
+ 3,
223
+ "--max-depth",
224
+ help="Maximum directory depth to scan.",
225
+ min=1,
226
+ max=10,
227
+ ),
228
+ ) -> None:
229
+ """
230
+ Scan a project, build an AST-powered dependency graph, and generate LLM context.
231
+ """
232
+ target_dir = (project or path).resolve()
233
+
234
+ # If -d / --default is supplied, generate all formats and keep watch running
235
+ if default_mode:
236
+ console.print(
237
+ Panel.fit(
238
+ f"[bold cyan]⚡ context-gen-cli (Python All-In-One Mode -d)[/bold cyan]\n"
239
+ f"[dim]Target:[/dim] [green]{target_dir}[/green]\n"
240
+ f"[dim]Mode:[/dim] [yellow]Auto-Generate All Formats + Live Background Watcher[/yellow]",
241
+ border_style="cyan"
242
+ )
243
+ )
244
+ res = execute_generation(target_dir, OutputFormat.ALL, max_depth=max_depth)
245
+ table = Table(show_header=False, box=None)
246
+ table.add_row("[bold]Scanned Files:[/bold]", f"[cyan]{len(res['files'])}[/cyan]")
247
+ table.add_row("[bold]AST Graph Edges:[/bold]", f"[cyan]{len(res['graph']['edges'])}[/cyan]")
248
+ table.add_row("[bold]Tech Stack:[/bold]", f"[green]{', '.join(res['metadata']['techStack'])}[/green]")
249
+ table.add_row("[bold]Generated Files:[/bold]", f"[yellow]{', '.join(f.name for f in res['generated_files'])}[/yellow]")
250
+ console.print(Panel(table, title="[bold green]✅ Context Generated in context/[/bold green]", border_style="green"))
251
+ run_watch_loop(target_dir, OutputFormat.ALL, max_depth=max_depth)
252
+ return
253
+
254
+ console.print(
255
+ Panel.fit(
256
+ f"[bold cyan]⚡ context-gen-cli (Python Edition)[/bold cyan]\n"
257
+ f"[dim]Analyzing target:[/dim] [green]{target_dir}[/green]\n"
258
+ f"[dim]Format:[/dim] [yellow]{format.value.upper()}[/yellow]",
259
+ border_style="cyan"
260
+ )
261
+ )
262
+
263
+ with console.status("[bold green]Scanning directory and parsing AST graph...[/bold green]"):
264
+ res = execute_generation(target_dir, format, output_override=output, max_depth=max_depth)
265
+
266
+ # Display completion summary
267
+ table = Table(show_header=False, box=None)
268
+ table.add_row("[bold]Scanned Files:[/bold]", f"[cyan]{len(res['files'])}[/cyan]")
269
+ table.add_row("[bold]AST Graph Edges:[/bold]", f"[cyan]{len(res['graph']['edges'])}[/cyan]")
270
+ table.add_row("[bold]Tech Stack:[/bold]", f"[green]{', '.join(res['metadata']['techStack'])}[/green]")
271
+ table.add_row("[bold]Output Destination:[/bold]", f"[yellow]{res['output_dir']}[/yellow]")
272
+ table.add_row("[bold]Generated Files:[/bold]", f"[green]{', '.join(f.name for f in res['generated_files'])}[/green]")
273
+
274
+ console.print(
275
+ Panel(
276
+ table,
277
+ title="[bold green]✅ Context Generated Successfully[/bold green]",
278
+ border_style="green"
279
+ )
280
+ )
281
+
282
+ if watch:
283
+ run_watch_loop(target_dir, format, max_depth=max_depth)
284
+
285
+
286
+ if __name__ == "__main__":
287
+ app()
@@ -151,3 +151,76 @@ def generate_agent_md(
151
151
  ])
152
152
 
153
153
  return "\n".join(lines)
154
+
155
+
156
+ def generate_agent_yaml(
157
+ metadata: Dict[str, Any],
158
+ graph: Dict[str, Any],
159
+ tree: str = "",
160
+ project_path: str = ""
161
+ ) -> str:
162
+ """
163
+ Generates clean, structured YAML representation of the project context.
164
+
165
+ Args:
166
+ metadata (Dict[str, Any]): Project metadata from extractor.
167
+ graph (Dict[str, Any]): AST dependency graph.
168
+ tree (str): Visual directory tree.
169
+ project_path (str): Root project path.
170
+
171
+ Returns:
172
+ str: Formatted YAML string.
173
+ """
174
+ now_iso = datetime.now(timezone.utc).isoformat()
175
+ path_val = project_path or metadata.get("projectPath", "")
176
+ overview = metadata.get("overview", "").replace('"', '\\"')
177
+
178
+ lines: List[str] = [
179
+ "# Project Architecture & Context Model (YAML)",
180
+ "# Generated automatically by context-gen-cli (Python Edition)",
181
+ "version: \"1.0.0\"",
182
+ f"generated_at: \"{now_iso}\"",
183
+ f"project_path: \"{path_val}\"",
184
+ f"overview: \"{overview}\"",
185
+ "",
186
+ "tech_stack:",
187
+ ]
188
+
189
+ for tech in metadata.get("techStack", ["Python"]):
190
+ lines.append(f" - \"{tech}\"")
191
+
192
+ lines.extend([
193
+ "",
194
+ "entry_points:",
195
+ ])
196
+ for ep in graph.get("entryPoints", []):
197
+ lines.append(f" - \"{ep}\"")
198
+
199
+ lines.extend([
200
+ "",
201
+ "utilities:",
202
+ ])
203
+ for u in graph.get("utilities", []):
204
+ lines.append(f" - \"{u}\"")
205
+
206
+ lines.extend([
207
+ "",
208
+ "key_files:",
209
+ ])
210
+ for kf in metadata.get("keyFiles", []):
211
+ desc = kf['description'].replace('"', '\\"')
212
+ lines.append(f" - path: \"{kf['path']}\"")
213
+ lines.append(f" description: \"{desc}\"")
214
+
215
+ lines.extend([
216
+ "",
217
+ "dependency_edges:",
218
+ ])
219
+ for edge in graph.get("edges", []):
220
+ lines.append(f" - from: \"{edge['from']}\"")
221
+ lines.append(f" to: \"{edge['to']}\"")
222
+ lines.append(f" type: \"{edge.get('type', 'import')}\"")
223
+
224
+ lines.append("")
225
+ return "\n".join(lines)
226
+
@@ -0,0 +1,3 @@
1
+ """
2
+ context_gen.mcp: Model Context Protocol tools and server integrations for context-gen-cli.
3
+ """