-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
122 lines (102 loc) · 4.32 KB
/
cli.py
File metadata and controls
122 lines (102 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
CLI entry point.
Runs the meeting analysis pipeline on a transcript file and writes a
Markdown report. Optionally also dumps the full pipeline result as JSON
for inspection.
Usage:
python cli.py <transcript_path> [options]
Options:
--output <path> Write Markdown report to this path
(default: output.md next to transcript)
--context <path> Path to a business context packet text file
--transcript-context "s" Optional one-liner about the meeting itself
--skip-audit Skip the audit stage (debug mode)
--json <path> Also dump full pipeline result as JSON
--quiet Suppress stage progress output
Examples:
python cli.py transcripts/01_decision_meeting.txt
python cli.py transcripts/01_decision_meeting.txt --output reports/meeting1.md
python cli.py transcripts/01_decision_meeting.txt --json result.json
python cli.py transcripts/01_decision_meeting.txt --skip-audit
"""
import sys
import json
import argparse
from pathlib import Path
from engine import run_pipeline
from exporter import to_markdown
def load_text_file(path: str) -> str:
"""Load a UTF-8 text file. Raises FileNotFoundError if missing."""
p = Path(path)
if not p.exists():
raise FileNotFoundError(f"File not found: {path}")
if path.endswith(".json"):
with open(p, "r", encoding="utf-8") as f:
data = json.load(f)
if isinstance(data, str):
return data
return json.dumps(data, indent=2)
with open(p, "r", encoding="utf-8") as f:
return f.read()
def default_output_path(transcript_path: str) -> str:
"""Default output filename: <transcript_stem>_analysis.md in cwd."""
stem = Path(transcript_path).stem
return f"{stem}_analysis.md"
def main():
parser = argparse.ArgumentParser(
description="Run the meeting analysis pipeline on a transcript.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__,
)
parser.add_argument("transcript",
help="Path to transcript file (.txt or .json)")
parser.add_argument("--output", default=None,
help="Output path for the Markdown report")
parser.add_argument("--context", default=None,
help="Path to business context packet text file")
parser.add_argument("--transcript-context", default=None,
help="Optional one-liner about the meeting itself")
parser.add_argument("--skip-audit", action="store_true",
help="Skip the audit stage (debug mode)")
parser.add_argument("--json", dest="json_path", default=None,
help="Also dump full pipeline result as JSON")
parser.add_argument("--quiet", action="store_true",
help="Suppress stage progress output")
args = parser.parse_args()
# Load inputs
transcript = load_text_file(args.transcript)
business_context = ""
if args.context:
business_context = load_text_file(args.context)
# Run pipeline
try:
result = run_pipeline(
transcript=transcript,
business_context=business_context,
transcript_context=args.transcript_context,
skip_audit=args.skip_audit,
verbose=not args.quiet,
)
except Exception as e:
print(f"\nERROR: pipeline failed: {type(e).__name__}: {e}",
file=sys.stderr)
sys.exit(1)
# Optional: dump full JSON
if args.json_path:
with open(args.json_path, "w", encoding="utf-8") as f:
json.dump(result, f, indent=2)
if not args.quiet:
print(f"Full pipeline result written to: {args.json_path}")
# Write Markdown report
output_path = args.output or default_output_path(args.transcript)
md = to_markdown(result["rendered"], audit_summary=result.get("audit"))
with open(output_path, "w", encoding="utf-8") as f:
f.write(md)
if not args.quiet:
print(f"Markdown report written to: {output_path}")
if result.get("audit"):
verdict = result["audit"].get("overall_verdict", "?")
n_ops = len(result["audit"].get("audit_log", []))
print(f"Audit verdict: {verdict} ({n_ops} operation(s))")
if __name__ == "__main__":
main()