forked from mengyxu/noob-components
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.0 KiB
78 lines
2.0 KiB
#!/usr/bin/env python3 |
|
# -*- coding: utf-8 -*- |
|
""" |
|
Git and Session Context utilities. |
|
|
|
Entry shim — delegates to session_context and packages_context. |
|
|
|
Provides: |
|
output_json - Output context in JSON format |
|
output_text - Output context in text format |
|
""" |
|
|
|
from __future__ import annotations |
|
|
|
import json |
|
|
|
from .git import run_git |
|
from .session_context import ( |
|
get_context_json, |
|
get_context_text, |
|
get_context_record_json, |
|
get_context_text_record, |
|
output_json, |
|
output_text, |
|
) |
|
from .packages_context import ( |
|
get_context_packages_text, |
|
get_context_packages_json, |
|
) |
|
|
|
# Backward-compatible alias — external modules import this name |
|
_run_git_command = run_git |
|
|
|
|
|
# ============================================================================= |
|
# Main Entry |
|
# ============================================================================= |
|
|
|
def main() -> None: |
|
"""CLI entry point.""" |
|
import argparse |
|
|
|
parser = argparse.ArgumentParser(description="Get Session Context for AI Agent") |
|
parser.add_argument( |
|
"--json", |
|
"-j", |
|
action="store_true", |
|
help="Output in JSON format (works with any --mode)", |
|
) |
|
parser.add_argument( |
|
"--mode", |
|
"-m", |
|
choices=["default", "record", "packages"], |
|
default="default", |
|
help="Output mode: default (full context), record (for record-session), packages (package info only)", |
|
) |
|
|
|
args = parser.parse_args() |
|
|
|
if args.mode == "record": |
|
if args.json: |
|
print(json.dumps(get_context_record_json(), indent=2, ensure_ascii=False)) |
|
else: |
|
print(get_context_text_record()) |
|
elif args.mode == "packages": |
|
if args.json: |
|
print(json.dumps(get_context_packages_json(), indent=2, ensure_ascii=False)) |
|
else: |
|
print(get_context_packages_text()) |
|
else: |
|
if args.json: |
|
output_json() |
|
else: |
|
output_text() |
|
|
|
|
|
if __name__ == "__main__": |
|
main()
|
|
|