-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_logic_agent.py
More file actions
102 lines (87 loc) · 2.99 KB
/
Copy pathgenerate_logic_agent.py
File metadata and controls
102 lines (87 loc) · 2.99 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
#!/usr/bin/env python3
"""Generate logic analysis skeleton + Cursor Logic Analyst agent prompt."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from src.logic_analyst import ( # noqa: E402
build_logic_agent_prompt_document,
build_logic_skeleton,
load_extraction_report,
logic_agent_prompt_path,
logic_skeleton_path,
)
def main() -> int:
parser = argparse.ArgumentParser(
description=(
"Build LOGIC_ANALYSIS skeleton and LOGIC_AGENT_PROMPT "
"for label/VBA reflection (no LLM call)."
)
)
parser.add_argument(
"extraction",
type=Path,
help="Path to extractions/<name>_extraction.json",
)
parser.add_argument(
"--workbook",
type=Path,
default=None,
help="Optional .xlsx/.xlsm path for agent cross-check",
)
parser.add_argument(
"--skeleton-only",
action="store_true",
help="Write only specs/<name>_LOGIC_ANALYSIS.md",
)
parser.add_argument(
"--prompt-only",
action="store_true",
help="Write only specs/<name>_LOGIC_AGENT_PROMPT.md",
)
parser.add_argument(
"--lang",
default="en",
choices=["fr", "en"],
help="Language hint for the agent task (default: en)",
)
args = parser.parse_args()
if not args.extraction.is_file():
print(f"Error: file not found — {args.extraction}", file=sys.stderr)
return 1
report = load_extraction_report(args.extraction)
skeleton_path = logic_skeleton_path(args.extraction)
prompt_path = logic_agent_prompt_path(args.extraction)
write_skeleton = not args.prompt_only
write_prompt = not args.skeleton_only
if write_skeleton:
skeleton_path.parent.mkdir(parents=True, exist_ok=True)
skeleton_path.write_text(
build_logic_skeleton(report, source_json=args.extraction),
encoding="utf-8",
)
print(f" -> {skeleton_path}")
if write_prompt:
prompt_path.parent.mkdir(parents=True, exist_ok=True)
prompt_path.write_text(
build_logic_agent_prompt_document(
report,
extraction_path=args.extraction,
workbook_path=args.workbook,
language=args.lang,
),
encoding="utf-8",
)
print(f" -> {prompt_path}")
if write_skeleton and write_prompt:
print("\nWorkflow:")
print(" 1. extract.py — static_cells + user_context must be in the JSON")
print(" 2. Logic Analyst (reflection): static text + user context -> domain/purpose")
print(" 3. Same agent links formulas/VBA to that domain -> LOGIC_ANALYSIS.md")
print(" 4. Use LOGIC_ANALYSIS as source of truth before FUNCTIONAL_SPEC / migration")
return 0
if __name__ == "__main__":
raise SystemExit(main())