MCPcopy Index your code
hub / github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge / main

Function main

main.py:39–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38# --- Main Function ---
39def main():
40 parser = argparse.ArgumentParser(description="Generate a tutorial for a GitHub codebase or local directory.")
41
42 # Create mutually exclusive group for source
43 source_group = parser.add_mutually_exclusive_group(required=True)
44 source_group.add_argument("--repo", help="URL of the public GitHub repository.")
45 source_group.add_argument("--dir", help="Path to local directory.")
46
47 parser.add_argument("-n", "--name", help="Project name (optional, derived from repo/directory if omitted).")
48 parser.add_argument("-t", "--token", help="GitHub personal access token (optional, reads from GITHUB_TOKEN env var if not provided).")
49 parser.add_argument("-o", "--output", default="output", help="Base directory for output (default: ./output).")
50 parser.add_argument("-i", "--include", nargs="+", help="Include file patterns (e.g. '*.py' '*.js'). Defaults to common code files if not specified.")
51 parser.add_argument("-e", "--exclude", nargs="+", help="Exclude file patterns (e.g. 'tests/*' 'docs/*'). Defaults to test/build directories if not specified.")
52 parser.add_argument("-s", "--max-size", type=int, default=100000, help="Maximum file size in bytes (default: 100000, about 100KB).")
53 # Add language parameter for multi-language support
54 parser.add_argument("--language", default="english", help="Language for the generated tutorial (default: english)")
55 # Add use_cache parameter to control LLM caching
56 parser.add_argument("--no-cache", action="store_true", help="Disable LLM response caching (default: caching enabled)")
57 # Add max_abstraction_num parameter to control the number of abstractions
58 parser.add_argument("--max-abstractions", type=int, default=10, help="Maximum number of abstractions to identify (default: 10)")
59
60 args = parser.parse_args()
61
62 # Get GitHub token from argument or environment variable if using repo
63 github_token = None
64 if args.repo:
65 github_token = args.token or os.environ.get('GITHUB_TOKEN')
66 if not github_token:
67 print("Warning: No GitHub token provided. You might hit rate limits for public repositories.")
68
69 # Initialize the shared dictionary with inputs
70 shared = {
71 "repo_url": args.repo,
72 "local_dir": args.dir,
73 "project_name": args.name, # Can be None, FetchRepo will derive it
74 "github_token": github_token,
75 "output_dir": args.output, # Base directory for CombineTutorial output
76
77 # Add include/exclude patterns and max file size
78 "include_patterns": set(args.include) if args.include else DEFAULT_INCLUDE_PATTERNS,
79 "exclude_patterns": set(args.exclude) if args.exclude else DEFAULT_EXCLUDE_PATTERNS,
80 "max_file_size": args.max_size,
81
82 # Add language for multi-language support
83 "language": args.language,
84
85 # Add use_cache flag (inverse of no-cache flag)
86 "use_cache": not args.no_cache,
87
88 # Add max_abstraction_num parameter
89 "max_abstraction_num": args.max_abstractions,
90
91 # Outputs will be populated by the nodes
92 "files": [],
93 "abstractions": [],
94 "relationships": {},
95 "chapter_order": [],
96 "chapters": [],

Callers 1

main.pyFile · 0.85

Calls 1

create_tutorial_flowFunction · 0.90

Tested by

no test coverage detected