@capagents/forgeqe 3.3.1 → 3.3.2

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 (217) hide show
  1. package/HOW_TO_USE.md +32 -0
  2. package/dist/docs-site/docs/area-setup/index.html +1 -0
  3. package/dist/docs-site/docs/area-test-cases/index.html +25 -0
  4. package/dist/docs-site/docs/search.js +1 -1
  5. package/dist/forgeqe.js +1922 -1906
  6. package/dist/requirement-agent/requirements_agent/__init__.py +3 -0
  7. package/dist/requirement-agent/requirements_agent/__main__.py +5 -0
  8. package/dist/requirement-agent/requirements_agent/agent.py +363 -0
  9. package/dist/requirement-agent/requirements_agent/chat_session.py +424 -0
  10. package/dist/requirement-agent/requirements_agent/cli.py +870 -0
  11. package/dist/requirement-agent/requirements_agent/config.py +403 -0
  12. package/dist/requirement-agent/requirements_agent/console_ui.py +632 -0
  13. package/dist/requirement-agent/requirements_agent/context/__init__.py +3 -0
  14. package/dist/requirement-agent/requirements_agent/context/aggregate.py +214 -0
  15. package/dist/requirement-agent/requirements_agent/context/base.py +14 -0
  16. package/dist/requirement-agent/requirements_agent/context/folder.py +107 -0
  17. package/dist/requirement-agent/requirements_agent/context/given.py +70 -0
  18. package/dist/requirement-agent/requirements_agent/context/graph.py +181 -0
  19. package/dist/requirement-agent/requirements_agent/context/knowledge.py +192 -0
  20. package/dist/requirement-agent/requirements_agent/context/mcp.py +24 -0
  21. package/dist/requirement-agent/requirements_agent/context/memory.py +144 -0
  22. package/dist/requirement-agent/requirements_agent/context/personas.py +214 -0
  23. package/dist/requirement-agent/requirements_agent/context/rag.py +148 -0
  24. package/dist/requirement-agent/requirements_agent/context/untrusted.py +56 -0
  25. package/dist/requirement-agent/requirements_agent/docs/HOW_TO_USE.md +505 -0
  26. package/dist/requirement-agent/requirements_agent/docs/requirements-agent-architecture.html +348 -0
  27. package/dist/requirement-agent/requirements_agent/docs_cmd.py +51 -0
  28. package/dist/requirement-agent/requirements_agent/export/__init__.py +3 -0
  29. package/dist/requirement-agent/requirements_agent/export/markdown.py +55 -0
  30. package/dist/requirement-agent/requirements_agent/export/pdf.py +82 -0
  31. package/dist/requirement-agent/requirements_agent/export/requirements_json.py +120 -0
  32. package/dist/requirement-agent/requirements_agent/init_cmd.py +191 -0
  33. package/dist/requirement-agent/requirements_agent/llm/__init__.py +3 -0
  34. package/dist/requirement-agent/requirements_agent/llm/base.py +49 -0
  35. package/dist/requirement-agent/requirements_agent/llm/copilot.py +171 -0
  36. package/dist/requirement-agent/requirements_agent/llm/mock.py +144 -0
  37. package/dist/requirement-agent/requirements_agent/llm/providers.py +277 -0
  38. package/dist/requirement-agent/requirements_agent/llm/router.py +35 -0
  39. package/dist/requirement-agent/requirements_agent/models.py +73 -0
  40. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/analyst.md +29 -0
  41. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/architect.md +28 -0
  42. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/bmad-orchestrator.md +26 -0
  43. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/dev.md +27 -0
  44. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/pm.md +27 -0
  45. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/po.md +27 -0
  46. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/qa.md +28 -0
  47. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/sm.md +26 -0
  48. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-analyst.md +8 -0
  49. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-architect.md +11 -0
  50. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-dev.md +11 -0
  51. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-orchestrator.md +9 -0
  52. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-pm.md +9 -0
  53. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-po.md +10 -0
  54. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-qa.md +11 -0
  55. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-sm.md +8 -0
  56. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/bmad-kb.md +19 -0
  57. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/requirements-standards-baseline.md +188 -0
  58. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/technical-preferences.md +54 -0
  59. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/utils/template-format.md +7 -0
  60. package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/workflows/greenfield-fullstack.yml +177 -0
  61. package/dist/requirement-agent/requirements_agent/pipeline/__init__.py +3 -0
  62. package/dist/requirement-agent/requirements_agent/pipeline/brd.py +86 -0
  63. package/dist/requirement-agent/requirements_agent/pipeline/pack.py +233 -0
  64. package/dist/requirement-agent/requirements_agent/pipeline/progress.py +60 -0
  65. package/dist/requirement-agent/requirements_agent/pipeline/prompts.py +150 -0
  66. package/dist/requirement-agent/requirements_agent/pipeline/quality.py +124 -0
  67. package/dist/requirement-agent/requirements_agent/pipeline/refine.py +386 -0
  68. package/dist/requirement-agent/requirements_agent/pipeline/sections.py +117 -0
  69. package/dist/requirement-agent/requirements_agent/pipeline/spec_circuit.py +142 -0
  70. package/dist/requirement-agent/requirements_agent/shell/__init__.py +7 -0
  71. package/dist/requirement-agent/requirements_agent/shell/actions.py +208 -0
  72. package/dist/requirement-agent/requirements_agent/shell/app.py +902 -0
  73. package/dist/requirement-agent/requirements_agent/shell/commands.py +206 -0
  74. package/dist/requirement-agent/requirements_agent/shell/progress_pane.py +114 -0
  75. package/dist/requirement-agent/requirements_agent/shell/ref_picker.py +59 -0
  76. package/dist/requirement-agent/requirements_agent/shell/refs.py +120 -0
  77. package/dist/requirement-agent/requirements_agent/shell/session.py +362 -0
  78. package/dist/requirement-agent/requirements_agent/shell/transcript.py +241 -0
  79. package/dist/requirement-agent/requirements_agent/shell/usage.py +64 -0
  80. package/dist/requirement-agent/requirements_agent/shell/usage_llm.py +64 -0
  81. package/dist/requirement-agent/requirements_agent/shell/worker.py +378 -0
  82. package/dist/requirement-agent/requirements_agent/tuios_hook.py +182 -0
  83. package/dist/requirement-agent/requirements_agent/webops.py +627 -0
  84. package/dist/template.html +67 -67
  85. package/dist/web/assets/{3d-force-graph-Df2wOlpF.js → 3d-force-graph-DDyP5jcf.js} +1 -1
  86. package/dist/web/assets/Agent-sLaNlaQo.js +8 -0
  87. package/dist/web/assets/AgentWork-Dv0G4bt3.js +2 -0
  88. package/dist/web/assets/ApiTests-Bnw2qgWw.js +15 -0
  89. package/dist/web/assets/Browse-CBt1JY2E.js +1 -0
  90. package/dist/web/assets/Chat-DIWdnIZK.js +3 -0
  91. package/dist/web/assets/CommandPalette-DD04oS83.js +1 -0
  92. package/dist/web/assets/Compare-D0Ao8dZ6.js +1 -0
  93. package/dist/web/assets/Cost-BY_8-9Qt.js +1 -0
  94. package/dist/web/assets/{Data-Be3ZNkUu.js → Data-BC7R_FbW.js} +4 -4
  95. package/dist/web/assets/Desktop-CSQ2xLg0.js +1 -0
  96. package/dist/web/assets/DesktopReview-CCOhUdeJ.js +2 -0
  97. package/dist/web/assets/DeviceScreen-BHmTd9Q-.js +1 -0
  98. package/dist/web/assets/Evidence-9W4pqIkC.js +1 -0
  99. package/dist/web/assets/{Explore-AtSStzNg.js → Explore-BndXiEf8.js} +2 -2
  100. package/dist/web/assets/Features-BrfsTC9Q.js +1 -0
  101. package/dist/web/assets/{Flags-GxmNrnSn.js → Flags-DyykkeHU.js} +2 -2
  102. package/dist/web/assets/Flaky-C3gj_Brn.js +1 -0
  103. package/dist/web/assets/Impact-Z8nbNhbe.js +3 -0
  104. package/dist/web/assets/Jobs-CJWXAqSy.js +5 -0
  105. package/dist/web/assets/KindPage-C45x_cFz.js +6 -0
  106. package/dist/web/assets/LiveDevice-DGdLDigO.js +1 -0
  107. package/dist/web/assets/Migration-QFI5ctp7.js +8 -0
  108. package/dist/web/assets/Mobile-CuswZyee.js +1 -0
  109. package/dist/web/assets/Observability-CknZ_xBN.js +1 -0
  110. package/dist/web/assets/PageAgent-B2bmmMaP.js +1 -0
  111. package/dist/web/assets/Product-CrtwDiMv.js +12 -0
  112. package/dist/web/assets/Production-BMsytC2i.js +1 -0
  113. package/dist/web/assets/Quality-B4Aw6N3_.js +1 -0
  114. package/dist/web/assets/Readiness-CVIzTFX-.js +1 -0
  115. package/dist/web/assets/Record-B2Ic8Taj.js +1 -0
  116. package/dist/web/assets/Regression-bCIAE3Ne.js +5 -0
  117. package/dist/web/assets/RelationGraph-kG4YVMzl.js +1 -0
  118. package/dist/web/assets/Reports-NAZ-26Ub.js +2 -0
  119. package/dist/web/assets/Requirements-BkpiF-Bt.js +2 -0
  120. package/dist/web/assets/Responsive-CsaoisJq.js +3 -0
  121. package/dist/web/assets/RunDiff-BC-3Wg1b.js +1 -0
  122. package/dist/web/assets/Settings-DyBed-J5.js +21 -0
  123. package/dist/web/assets/Steps-DcQxQ4yA.js +2 -0
  124. package/dist/web/assets/TestData-wpUeU9Er.js +2 -0
  125. package/dist/web/assets/TestManagement-D0njkyAT.js +4 -0
  126. package/dist/web/assets/WhatsNew-BxIAAwgH.js +1 -0
  127. package/dist/web/assets/agentSettingsSheet-BdB7IXah.js +1 -0
  128. package/dist/web/assets/choice-C4-yW2x9.js +1 -0
  129. package/dist/web/assets/code-Jek8uWUO.js +1 -0
  130. package/dist/web/assets/{coverage-DirEXtfZ.js → coverage-q-ib7wOq.js} +1 -1
  131. package/dist/web/assets/dataParts-B2-a-pOD.js +3 -0
  132. package/dist/web/assets/desktopAppPath-C-p0zU40.js +1 -0
  133. package/dist/web/assets/frame-CjpZWX_X.js +13 -0
  134. package/dist/web/assets/index-BH5RbDNY.css +2 -0
  135. package/dist/web/assets/index-CfGXe_De.js +55 -0
  136. package/dist/web/assets/line-icons-CwCZidXs.js +1 -0
  137. package/dist/web/assets/logos-P2LOMyTK.js +1 -0
  138. package/dist/web/assets/{markdown-BnrLv6Iw.js → markdown-dXSsS-mD.js} +5 -5
  139. package/dist/web/assets/nav-BZfNOkhX.js +1 -0
  140. package/dist/web/assets/pageBack-BwKT31j3.js +3 -0
  141. package/dist/web/assets/palette-L37b4wTE.js +1 -0
  142. package/dist/web/assets/{paletteCommands-LXIICD4V.js → paletteCommands-zqGCORJu.js} +1 -1
  143. package/dist/web/assets/parts-3o6HnCp1.js +1 -0
  144. package/dist/web/assets/preload-helper-BupTYkQW.js +1 -0
  145. package/dist/web/assets/productParts-BDiEg0z6.js +1 -0
  146. package/dist/web/assets/qualityParts--CnSadOZ.js +1 -0
  147. package/dist/web/assets/radio-BLI4Ubhk.js +1 -0
  148. package/dist/web/assets/react-BDur5s0O.js +1 -0
  149. package/dist/web/assets/{recordTest-BzKpS4m5.js → recordTest-D092f975.js} +1 -1
  150. package/dist/web/assets/route-oDy8sV6H.js +1 -0
  151. package/dist/web/assets/sectionList-XiKcJNEK.js +1 -0
  152. package/dist/web/assets/step-mark-CaKf4dAR.js +1 -0
  153. package/dist/web/assets/stepper-naqAN_Nb.js +1 -0
  154. package/dist/web/assets/utils-DJRAScIl.js +1 -0
  155. package/dist/web/assets/wizardParts-DLlOHVMx.js +1 -0
  156. package/dist/web/index.html +14 -12
  157. package/docs/user-guide.html +26 -0
  158. package/package.json +2 -1
  159. package/py/forgeqe_engine/cli.py +7 -0
  160. package/dist/web/assets/Agent-CRfgRnq2.js +0 -8
  161. package/dist/web/assets/AgentWork-DqiO3LUi.js +0 -2
  162. package/dist/web/assets/ApiTests-DCAnizu5.js +0 -15
  163. package/dist/web/assets/Browse-D5VDHN9Z.js +0 -1
  164. package/dist/web/assets/Chat-CLGQ1ymU.js +0 -3
  165. package/dist/web/assets/CommandPalette-D3F4iHrP.js +0 -1
  166. package/dist/web/assets/Compare-B1WN67Ny.js +0 -1
  167. package/dist/web/assets/Cost-Dk4m3r8z.js +0 -1
  168. package/dist/web/assets/Desktop-B3GcbaPu.js +0 -1
  169. package/dist/web/assets/DesktopReview-DfvAL3m8.js +0 -2
  170. package/dist/web/assets/DeviceScreen-DJqblqBh.js +0 -1
  171. package/dist/web/assets/Evidence-BsA7vCZG.js +0 -1
  172. package/dist/web/assets/Features-CDBlFLaJ.js +0 -1
  173. package/dist/web/assets/Flaky-C062Mh6z.js +0 -1
  174. package/dist/web/assets/Impact-BeXw3-oL.js +0 -3
  175. package/dist/web/assets/Jobs-QYWqmdDI.js +0 -5
  176. package/dist/web/assets/KindPage-C2g51s9c.js +0 -6
  177. package/dist/web/assets/LiveDevice-C9LRZMhC.js +0 -1
  178. package/dist/web/assets/Migration-ByUU0Oa_.js +0 -8
  179. package/dist/web/assets/Mobile-Dd3jL0Cn.js +0 -1
  180. package/dist/web/assets/Observability-Dx4ZCRDj.js +0 -1
  181. package/dist/web/assets/PageAgent-DYBOhs2x.js +0 -1
  182. package/dist/web/assets/Product-Ch1XAeAT.js +0 -12
  183. package/dist/web/assets/Production-TEdyFmo4.js +0 -1
  184. package/dist/web/assets/Quality-DH8EdI2u.js +0 -1
  185. package/dist/web/assets/Readiness-B8S7Ex0C.js +0 -1
  186. package/dist/web/assets/Record-uFQ-YaHg.js +0 -1
  187. package/dist/web/assets/Regression-CSDT2AnY.js +0 -5
  188. package/dist/web/assets/RelationGraph-gc0Xmklt.js +0 -1
  189. package/dist/web/assets/Reports-CSHhRfWv.js +0 -2
  190. package/dist/web/assets/Responsive-CEG1hbbQ.js +0 -3
  191. package/dist/web/assets/RunDiff-CHrMivzC.js +0 -1
  192. package/dist/web/assets/Settings-B63s0b1g.js +0 -21
  193. package/dist/web/assets/Steps-BsDjv-pm.js +0 -2
  194. package/dist/web/assets/TestData-CJoCXihI.js +0 -2
  195. package/dist/web/assets/TestManagement-Dkb-paWh.js +0 -4
  196. package/dist/web/assets/WhatsNew-Dtk9mJU4.js +0 -1
  197. package/dist/web/assets/agentSettingsSheet-BlM8KSpN.js +0 -1
  198. package/dist/web/assets/choice-CiFogD01.js +0 -1
  199. package/dist/web/assets/code-DzYywAs5.js +0 -1
  200. package/dist/web/assets/dataParts-Di7PdPHu.js +0 -3
  201. package/dist/web/assets/desktopAppPath-B8j1-pX0.js +0 -1
  202. package/dist/web/assets/frame-CNLw552P.js +0 -13
  203. package/dist/web/assets/index-DLuCgQKX.js +0 -55
  204. package/dist/web/assets/index-DRcPg81h.css +0 -2
  205. package/dist/web/assets/line-icons-B-O8oBsY.js +0 -1
  206. package/dist/web/assets/nav-Ds_6IERv.js +0 -1
  207. package/dist/web/assets/pageBack-DJxbEPfN.js +0 -3
  208. package/dist/web/assets/palette-H2g-hemT.js +0 -1
  209. package/dist/web/assets/parts-DKRLtrjs.js +0 -1
  210. package/dist/web/assets/preload-helper-BML5SvL4.js +0 -1
  211. package/dist/web/assets/productParts-imNtw-1N.js +0 -1
  212. package/dist/web/assets/qualityParts-DJhFlgCm.js +0 -1
  213. package/dist/web/assets/radio-CbR6ODxQ.js +0 -1
  214. package/dist/web/assets/route-DjewvmpL.js +0 -1
  215. package/dist/web/assets/sectionList-0umoKvRv.js +0 -1
  216. package/dist/web/assets/step-mark-g8Eb6foB.js +0 -1
  217. package/dist/web/assets/stepper-CzZIC36d.js +0 -1
@@ -0,0 +1,277 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import re
5
+ from typing import Any, Dict, List, Optional
6
+
7
+ from openai import AzureOpenAI, OpenAI
8
+
9
+ from requirements_agent.config import LlmConfig
10
+ from requirements_agent.llm.base import ChatMessage, ChatResult, DeltaCallback, LlmClient
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ def _normalize_azure_endpoint(endpoint: str) -> str:
16
+ ep = (endpoint or "").strip().rstrip("/")
17
+ if ep.endswith("/openai"):
18
+ ep = ep[: -len("/openai")]
19
+ return ep
20
+
21
+
22
+ def _model_uses_completion_tokens(model: str) -> bool:
23
+ """gpt-5 / o-series / reasoning SKUs reject legacy max_tokens."""
24
+ name = (model or "").lower().replace("_", "-")
25
+ if not name:
26
+ return False
27
+ return bool(
28
+ re.search(r"\bgpt-5\b", name)
29
+ or name.startswith("o1")
30
+ or name.startswith("o3")
31
+ or name.startswith("o4")
32
+ or "reasoning" in name
33
+ )
34
+
35
+
36
+ def _model_drops_temperature(model: str) -> bool:
37
+ name = (model or "").lower().replace("_", "-")
38
+ return _model_uses_completion_tokens(name)
39
+
40
+
41
+ def _usage_from_resp(resp: Any) -> Dict[str, Any]:
42
+ usage = {}
43
+ if getattr(resp, "usage", None):
44
+ usage = {
45
+ "input_tokens": getattr(resp.usage, "prompt_tokens", 0) or 0,
46
+ "output_tokens": getattr(resp.usage, "completion_tokens", 0) or 0,
47
+ "total_tokens": getattr(resp.usage, "total_tokens", 0) or 0,
48
+ }
49
+ return usage
50
+
51
+
52
+ def _build_chat_params(
53
+ model: str,
54
+ messages: List[ChatMessage],
55
+ *,
56
+ max_tokens: int,
57
+ temperature: Optional[float],
58
+ seed: Optional[int],
59
+ force_modern: bool = False,
60
+ ) -> Dict[str, Any]:
61
+ modern = force_modern or _model_uses_completion_tokens(model)
62
+ params: Dict[str, Any] = {
63
+ "model": model,
64
+ "messages": [{"role": m.role, "content": m.content} for m in messages],
65
+ }
66
+ if modern:
67
+ params["max_completion_tokens"] = max_tokens
68
+ else:
69
+ params["max_tokens"] = max_tokens
70
+
71
+ if temperature is not None and not _model_drops_temperature(model):
72
+ params["temperature"] = temperature
73
+
74
+ if seed is not None and not modern:
75
+ params["seed"] = seed
76
+ return params
77
+
78
+
79
+ def _create_with_fallback(client: Any, params: Dict[str, Any], label: str) -> Any:
80
+ try:
81
+ return client.chat.completions.create(**params)
82
+ except Exception as e:
83
+ err = str(e).lower()
84
+ retry = dict(params)
85
+ changed = False
86
+ if "max_tokens" in err or "max_completion_tokens" in err or "unsupported_parameter" in err:
87
+ retry.pop("max_tokens", None)
88
+ retry["max_completion_tokens"] = params.get("max_tokens") or params.get("max_completion_tokens") or 4096
89
+ changed = True
90
+ if "temperature" in err or "unsupported_parameter" in err or "unsupported_value" in err:
91
+ retry.pop("temperature", None)
92
+ changed = True
93
+ if "seed" in err:
94
+ retry.pop("seed", None)
95
+ changed = True
96
+ if not changed:
97
+ raise
98
+ logger.info("%s chat retrying with adjusted params after: %s", label, e)
99
+ return client.chat.completions.create(**retry)
100
+
101
+
102
+ def _stream_with_fallback(
103
+ client: Any,
104
+ params: Dict[str, Any],
105
+ label: str,
106
+ on_delta: Optional[DeltaCallback],
107
+ ) -> ChatResult:
108
+ stream_params = dict(params)
109
+ stream_params["stream"] = True
110
+ # Some Azure SKUs need stream_options for usage; ignore if unsupported
111
+ try:
112
+ stream = _create_with_fallback(client, stream_params, f"{label}-stream")
113
+ except Exception as e:
114
+ err = str(e).lower()
115
+ if "stream" in err or "unsupported" in err:
116
+ logger.info("%s streaming unsupported, falling back to one-shot: %s", label, e)
117
+ resp = _create_with_fallback(client, params, label)
118
+ content = (resp.choices[0].message.content or "").strip()
119
+ if on_delta and content:
120
+ on_delta(content, content)
121
+ return ChatResult(content=content, usage=_usage_from_resp(resp))
122
+ raise
123
+
124
+ parts: List[str] = []
125
+ usage: Dict[str, Any] = {}
126
+ for chunk in stream:
127
+ if getattr(chunk, "usage", None):
128
+ usage = _usage_from_resp(chunk)
129
+ choices = getattr(chunk, "choices", None) or []
130
+ if not choices:
131
+ continue
132
+ delta = getattr(choices[0], "delta", None)
133
+ piece = (getattr(delta, "content", None) or "") if delta is not None else ""
134
+ if not piece:
135
+ continue
136
+ parts.append(piece)
137
+ if on_delta:
138
+ on_delta(piece, "".join(parts))
139
+ content = "".join(parts).strip()
140
+ return ChatResult(content=content, usage=usage)
141
+
142
+
143
+ class OpenAICompatClient(LlmClient):
144
+ def __init__(self, config: LlmConfig):
145
+ self.config = config
146
+ kwargs = {"api_key": config.api_key or "EMPTY"}
147
+ if config.endpoint:
148
+ kwargs["base_url"] = config.endpoint.rstrip("/")
149
+ self._client = OpenAI(**kwargs)
150
+ self._model = config.model
151
+
152
+ def chat(
153
+ self,
154
+ messages: List[ChatMessage],
155
+ *,
156
+ max_tokens: int = 4096,
157
+ temperature: Optional[float] = None,
158
+ seed: Optional[int] = None,
159
+ ) -> ChatResult:
160
+ temp = self.config.temperature if temperature is None else temperature
161
+ params = _build_chat_params(
162
+ self._model, messages, max_tokens=max_tokens, temperature=temp, seed=seed
163
+ )
164
+ resp = _create_with_fallback(self._client, params, "OpenAI")
165
+ content = (resp.choices[0].message.content or "").strip()
166
+ return ChatResult(content=content, usage=_usage_from_resp(resp))
167
+
168
+ def stream_chat(
169
+ self,
170
+ messages: List[ChatMessage],
171
+ *,
172
+ max_tokens: int = 4096,
173
+ temperature: Optional[float] = None,
174
+ seed: Optional[int] = None,
175
+ on_delta: Optional[DeltaCallback] = None,
176
+ ) -> ChatResult:
177
+ temp = self.config.temperature if temperature is None else temperature
178
+ params = _build_chat_params(
179
+ self._model, messages, max_tokens=max_tokens, temperature=temp, seed=seed
180
+ )
181
+ return _stream_with_fallback(self._client, params, "OpenAI", on_delta)
182
+
183
+
184
+ class AzureLlmClient(LlmClient):
185
+ def __init__(self, config: LlmConfig):
186
+ self.config = config
187
+ endpoint = _normalize_azure_endpoint(config.endpoint)
188
+ if not endpoint:
189
+ raise ValueError(
190
+ "Azure LLM requires endpoint. Set it in llms.json for this profile "
191
+ f"('{config.profile or 'azure'}')."
192
+ )
193
+ entra = (config.auth or "").lower() == "entra"
194
+ if not config.api_key and not entra:
195
+ env_name = config.api_key_env or "RA_AZURE_API_KEY"
196
+ raise ValueError(
197
+ f"Azure LLM requires api_key. Export {env_name}=... in this shell "
198
+ f"(profile '{config.profile or 'azure'}'), or set api_key in llms.json."
199
+ )
200
+ # Newer deployments (gpt-5.*) need a recent API version
201
+ api_version = config.api_version or "2024-05-01-preview"
202
+ model_hint = (config.deployment or config.model or "").lower()
203
+ if _model_uses_completion_tokens(model_hint) and api_version < "2024-12":
204
+ # Keep user override, but prefer a safer default when still on old preview
205
+ if api_version in ("2024-05-01-preview", "2024-06-01", "2024-08-01-preview"):
206
+ api_version = "2024-12-01-preview"
207
+ logger.info("Using Azure api_version=%s for gpt-5 / reasoning deployment", api_version)
208
+ if entra:
209
+ # Keyless sign-in with Microsoft Entra ID, as ForgeQE's `auth: entra` profiles: managed identity, workload
210
+ # identity or az login. azure-identity ships in ForgeQE's engine; standalone, pip install azure-identity.
211
+ try:
212
+ from azure.identity import DefaultAzureCredential, get_bearer_token_provider
213
+ except ImportError as e:
214
+ raise ValueError(
215
+ f"Profile '{config.profile or 'azure'}' signs in with Entra ID (auth: entra): pip install azure-identity."
216
+ ) from e
217
+ kwargs: Dict[str, Any] = {}
218
+ if config.managed_identity_client_id:
219
+ kwargs["managed_identity_client_id"] = config.managed_identity_client_id
220
+ token_provider = get_bearer_token_provider(
221
+ DefaultAzureCredential(**kwargs), "https://cognitiveservices.azure.com/.default"
222
+ )
223
+ self._client = AzureOpenAI(
224
+ azure_ad_token_provider=token_provider,
225
+ api_version=api_version,
226
+ azure_endpoint=endpoint,
227
+ )
228
+ else:
229
+ self._client = AzureOpenAI(
230
+ api_key=config.api_key,
231
+ api_version=api_version,
232
+ azure_endpoint=endpoint,
233
+ )
234
+ self._deployment = config.deployment or config.model
235
+
236
+ def chat(
237
+ self,
238
+ messages: List[ChatMessage],
239
+ *,
240
+ max_tokens: int = 4096,
241
+ temperature: Optional[float] = None,
242
+ seed: Optional[int] = None,
243
+ ) -> ChatResult:
244
+ temp = self.config.temperature if temperature is None else temperature
245
+ params = _build_chat_params(
246
+ self._deployment, messages, max_tokens=max_tokens, temperature=temp, seed=seed
247
+ )
248
+ resp = _create_with_fallback(self._client, params, "Azure")
249
+ content = (resp.choices[0].message.content or "").strip()
250
+ return ChatResult(content=content, usage=_usage_from_resp(resp))
251
+
252
+ def stream_chat(
253
+ self,
254
+ messages: List[ChatMessage],
255
+ *,
256
+ max_tokens: int = 4096,
257
+ temperature: Optional[float] = None,
258
+ seed: Optional[int] = None,
259
+ on_delta: Optional[DeltaCallback] = None,
260
+ ) -> ChatResult:
261
+ temp = self.config.temperature if temperature is None else temperature
262
+ params = _build_chat_params(
263
+ self._deployment, messages, max_tokens=max_tokens, temperature=temp, seed=seed
264
+ )
265
+ return _stream_with_fallback(self._client, params, "Azure", on_delta)
266
+
267
+
268
+ class OllamaClient(OpenAICompatClient):
269
+ def __init__(self, config: LlmConfig):
270
+ cfg = LlmConfig(
271
+ provider="ollama",
272
+ model=config.model or "llama3.2",
273
+ api_key=config.api_key or "ollama",
274
+ endpoint=(config.endpoint or "http://127.0.0.1:11434/v1").rstrip("/"),
275
+ temperature=config.temperature,
276
+ )
277
+ super().__init__(cfg)
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ from requirements_agent.config import LlmConfig
4
+ from requirements_agent.llm.base import LlmClient
5
+ from requirements_agent.llm.mock import MockLlmClient
6
+ from requirements_agent.llm.providers import AzureLlmClient, OllamaClient, OpenAICompatClient
7
+
8
+
9
+ # Cloud vendors' own OpenAI-compatible endpoints, the same ones ForgeQE uses for these providers (src/llm.ts), so a
10
+ # ForgeQE llms.json profile runs here unchanged.
11
+ VENDOR_ENDPOINTS = {
12
+ "anthropic": "https://api.anthropic.com/v1",
13
+ "gemini": "https://generativelanguage.googleapis.com/v1beta/openai",
14
+ }
15
+
16
+
17
+ def build_llm_client(config: LlmConfig) -> LlmClient:
18
+ provider = (config.provider or "mock").lower().strip()
19
+ if provider in ("mock", "none", "dry-run", "dryrun"):
20
+ return MockLlmClient()
21
+ if provider == "azure":
22
+ return AzureLlmClient(config)
23
+ if provider == "ollama":
24
+ return OllamaClient(config)
25
+ if provider in VENDOR_ENDPOINTS:
26
+ if not config.endpoint:
27
+ config.endpoint = VENDOR_ENDPOINTS[provider]
28
+ return OpenAICompatClient(config)
29
+ if provider in ("openai", "openai_compatible", "compatible"):
30
+ return OpenAICompatClient(config)
31
+ if provider in ("github_copilot", "copilot"):
32
+ from requirements_agent.llm.copilot import CopilotClient
33
+
34
+ return CopilotClient(config)
35
+ raise ValueError(f"Unknown LLM provider: {provider}")
@@ -0,0 +1,73 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Dict, List, Optional
5
+
6
+
7
+ @dataclass
8
+ class Section:
9
+ agent_id: str
10
+ heading: str
11
+ content: str
12
+
13
+
14
+ @dataclass
15
+ class ContextChunk:
16
+ source: str
17
+ content: str
18
+ score: Optional[float] = None
19
+ meta: Dict[str, Any] = field(default_factory=dict)
20
+
21
+
22
+ @dataclass
23
+ class ContextBundle:
24
+ # Each of these holds <data> blocks (context/untrusted.py): text other people wrote, never instructions.
25
+ attachments_md: str = ""
26
+ retrieved_md: str = ""
27
+ # Earlier decisions from review memory (context/memory.py).
28
+ memory_md: str = ""
29
+ sources: List[Dict[str, Any]] = field(default_factory=list)
30
+ # The business personas reviewing this requirement, checked (context/personas.py).
31
+ personas: List[Dict[str, Any]] = field(default_factory=list)
32
+
33
+ def summary(self) -> Dict[str, Any]:
34
+ by: Dict[str, int] = {}
35
+ for s in self.sources:
36
+ key = str(s.get("provider") or "context")
37
+ by[key] = by.get(key, 0) + 1
38
+ return {
39
+ "enabled": bool(self.retrieved_md.strip() or self.attachments_md.strip() or self.memory_md.strip() or self.personas),
40
+ "excerpts_injected": len(self.sources),
41
+ "by_provider": by,
42
+ "personas": [{"id": p.get("id"), "name": p.get("name"), "role": p.get("role")} for p in self.personas],
43
+ "sources": self.sources,
44
+ }
45
+
46
+
47
+ @dataclass
48
+ class QualityScore:
49
+ success: bool
50
+ overall_score: int = 0
51
+ dimensions: Dict[str, int] = field(default_factory=dict)
52
+ rationale: str = ""
53
+ top_gaps: List[str] = field(default_factory=list)
54
+ error: Optional[str] = None
55
+
56
+
57
+ @dataclass
58
+ class ReviewResult:
59
+ success: bool
60
+ report_markdown: str = ""
61
+ sections: List[Section] = field(default_factory=list)
62
+ context: Optional[ContextBundle] = None
63
+ error: Optional[str] = None
64
+
65
+
66
+ @dataclass
67
+ class RunArtifacts:
68
+ out_dir: str
69
+ spec_circuit_path: Optional[str] = None
70
+ brd_path: Optional[str] = None
71
+ quality_path: Optional[str] = None
72
+ pdf_paths: List[str] = field(default_factory=list)
73
+ meta_path: Optional[str] = None
@@ -0,0 +1,29 @@
1
+ # Business Analyst — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No elicitation chat, *commands, or “pick an option.” **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Requirement clarity from a business perspective: gaps, assumptions, stakeholders, workflows, ambiguous language, and discovery questions.
8
+
9
+ ## Output contract
10
+
11
+ Use `###` subsections aligned to your analysis, for example:
12
+
13
+ - ### Scope interpretation
14
+ - ### Missing business context
15
+ - ### Stakeholders & workflows
16
+ - ### Ambiguities and assumptions
17
+ - ### Risks
18
+ - ### Questions for discovery
19
+ - ### Recommendation summary
20
+
21
+ Ground recommendations in the requirement and shared baselines.
22
+
23
+ ```yaml
24
+ dependencies:
25
+ checklists:
26
+ - spec-circuit-analyst
27
+ utils:
28
+ - template-format
29
+ ```
@@ -0,0 +1,28 @@
1
+ # Solution Architect — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No interactive architecture workshop. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Technical structure, NFRs, security and trust boundaries, data lifecycle, integration and operational risks, and concrete decision suggestions.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### System context assumptions
14
+ - ### Key NFR gaps
15
+ - ### Security & trust boundaries
16
+ - ### Data model & lifecycle risks
17
+ - ### Integration & dependency risks
18
+ - ### Operational concerns (observability, resilience, cost)
19
+ - ### Suggested architecture decisions
20
+ - ### Open questions
21
+
22
+ ```yaml
23
+ dependencies:
24
+ checklists:
25
+ - spec-circuit-architect
26
+ utils:
27
+ - template-format
28
+ ```
@@ -0,0 +1,26 @@
1
+ # BMAD Atlas — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No interactive shell, *commands, numbered menus, or party mode. **Use all bundled references** as authoritative. Produce one section only; the user cannot reply.
4
+
5
+ ## Role
6
+
7
+ You kick off the multi-role review: infer applicable domains, document type, complexity, and what later specialists should emphasize.
8
+
9
+ ## Output contract
10
+
11
+ Start with the required `##` heading from the step instruction. Use `###` subsections, roughly:
12
+
13
+ - ### Scope and document type
14
+ - ### Likely domains (security, privacy, compliance, AI/automation, etc.)
15
+ - ### Critical unknowns
16
+ - ### Review emphasis for downstream roles
17
+
18
+ Stay under the global word limit unless safety demands more.
19
+
20
+ ```yaml
21
+ dependencies:
22
+ checklists:
23
+ - spec-circuit-orchestrator
24
+ utils:
25
+ - template-format
26
+ ```
@@ -0,0 +1,27 @@
1
+ # Developer — Spec circuit (technical feasibility reviewer)
2
+
3
+ **Operating mode:** Single-pass automated review. You are **not** coding or editing story files in a repo. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Implementation feasibility: hidden assumptions, missing contracts, integration and concurrency risks, secure defaults, instrumentation, and code-level test constraints.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### Feasibility summary
14
+ - ### Hidden assumptions & constraints
15
+ - ### Contracts, schemas, and interfaces
16
+ - ### Integration & state management risks
17
+ - ### Security implementation gaps
18
+ - ### Instrumentation & operations hooks
19
+ - ### Suggested engineering acceptance constraints
20
+
21
+ ```yaml
22
+ dependencies:
23
+ checklists:
24
+ - spec-circuit-dev
25
+ utils:
26
+ - template-format
27
+ ```
@@ -0,0 +1,27 @@
1
+ # Product Manager — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No interactive PRD authoring session. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Product scope shaping: MVP vs future, metrics, trade-offs, non-goals, release/adoption risk, and cross-functional dependencies.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### Problem vs solution clarity
14
+ - ### MVP vs future state
15
+ - ### Non-goals and scope discipline
16
+ - ### Success metrics / KPIs
17
+ - ### Value vs complexity trade-offs
18
+ - ### Release and adoption risks
19
+ - ### Cross-functional dependencies
20
+
21
+ ```yaml
22
+ dependencies:
23
+ checklists:
24
+ - spec-circuit-pm
25
+ utils:
26
+ - template-format
27
+ ```
@@ -0,0 +1,27 @@
1
+ # Product Owner — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No backlog grooming chat. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Backlog and story quality: testable acceptance criteria, slicing, edge states, NFRs in AC, traceability, rollout and operational acceptance where relevant.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### Acceptance criteria testability
14
+ - ### Story / feature slicing
15
+ - ### Preconditions, postconditions, error and permission states
16
+ - ### Non-functional acceptance hooks
17
+ - ### Definition of ready gaps
18
+ - ### Traceability to outcomes
19
+ - ### Rollout, data, and API dependencies
20
+
21
+ ```yaml
22
+ dependencies:
23
+ checklists:
24
+ - spec-circuit-po
25
+ utils:
26
+ - template-format
27
+ ```
@@ -0,0 +1,28 @@
1
+ # QA — Spec circuit (review mode)
2
+
3
+ **Operating mode:** Single-pass automated review. No interactive test-planning session. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Quality and verification: testability of requirements, path coverage, environments, security test hooks, observability checks, regression/flaky risk, and evidence expectations.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### Testability assessment
14
+ - ### Happy / edge / failure path coverage
15
+ - ### Negative & abuse testing
16
+ - ### Contract & API testing
17
+ - ### Data & environment readiness
18
+ - ### Security & compliance test hooks
19
+ - ### Observability & audit evidence
20
+ - ### Regression & determinism risks
21
+
22
+ ```yaml
23
+ dependencies:
24
+ checklists:
25
+ - spec-circuit-qa
26
+ utils:
27
+ - template-format
28
+ ```
@@ -0,0 +1,26 @@
1
+ # Scrum Master — Spec circuit (delivery readiness)
2
+
3
+ **Operating mode:** Single-pass automated review. Not a story-drafting or handoff bot. **Use all bundled references** as authoritative.
4
+
5
+ ## Role
6
+
7
+ Delivery readiness: refinement quality, sequencing, sprintability, blockers, escalations, and rework/thrash risk.
8
+
9
+ ## Output contract
10
+
11
+ Suggested `###` subsections:
12
+
13
+ - ### Refinement readiness
14
+ - ### Dependency sequencing
15
+ - ### Sprintability & spikes
16
+ - ### Blockers and escalations
17
+ - ### Thrash / rework risk
18
+ - ### Planning recommendations
19
+
20
+ ```yaml
21
+ dependencies:
22
+ checklists:
23
+ - spec-circuit-sm
24
+ utils:
25
+ - template-format
26
+ ```
@@ -0,0 +1,8 @@
1
+ # Spec circuit — business analyst checklist
2
+
3
+ - [ ] **Scope interpretation:** What is in/out? Implicit scope creep?
4
+ - [ ] **Missing business context:** Stakeholders, personas, jurisdictions, policies, workflows not stated.
5
+ - [ ] **Ambiguous language:** Vague verbs (manage, support, track) and adjectives (fast, secure, scalable) without measures.
6
+ - [ ] **Domain assumptions:** Payments, PII, regulated workflows, audit—assumed but not documented?
7
+ - [ ] **Assumptions / missing info / business risks / discovery questions** called out explicitly.
8
+ - [ ] **Suggested refinements:** Sharper problem statement, boundaries, measurable outcomes.
@@ -0,0 +1,11 @@
1
+ # Spec circuit — architect checklist
2
+
3
+ - [ ] **System context:** Actors, trust zones, external systems (assumptions explicit).
4
+ - [ ] **Trust boundaries & IAM:** AuthN/AuthZ model, tenancy, RBAC/ABAC gaps.
5
+ - [ ] **Secrets & crypto:** Key management, rotation, data at rest/in transit.
6
+ - [ ] **Data model & lifecycle:** Classification, retention, migration, PII flows.
7
+ - [ ] **Resilience:** Retries, idempotency, timeouts, degradation, DLQ/compensation.
8
+ - [ ] **Integration failure modes:** Partner/API outages, partial failures, reconciliation.
9
+ - [ ] **Observability & audit:** Logs, metrics, traces, security audit events.
10
+ - [ ] **Cost & operability:** Scaling limits, runbooks, env promotion topology.
11
+ - [ ] **Open questions & suggested decisions** (concise).
@@ -0,0 +1,11 @@
1
+ # Spec circuit — technical feasibility (dev) checklist
2
+
3
+ *Not implementation—feasibility and engineering risk review.*
4
+
5
+ - [ ] **Hidden assumptions:** Stack, hosting, latency, data volumes, compliance tooling.
6
+ - [ ] **Missing contracts:** APIs, events, schemas, versioning, compatibility.
7
+ - [ ] **Integration blockers:** Auth flows, webhooks, batch vs real-time, rate limits.
8
+ - [ ] **State / concurrency:** Race conditions, locking, idempotent writes, saga needs.
9
+ - [ ] **Security implementation:** Secure defaults, input validation, SSRF/file upload risks.
10
+ - [ ] **Instrumentation:** Logs/metrics/tracing hooks; feature flags; kill switches.
11
+ - [ ] **Testability from code:** Seams for unit/integration tests; test data constraints.
@@ -0,0 +1,9 @@
1
+ # Spec circuit — orchestrator checklist
2
+
3
+ Use this to frame the review; keep output short and structured.
4
+
5
+ - [ ] **Domains:** Which areas apply (security, privacy, payments, PII, AI/automation, regulated sector)?
6
+ - [ ] **Document type:** Idea, PRD slice, epic, story, NFR list, integration spec?
7
+ - [ ] **Complexity:** Single service vs platform; internal vs external users; data sensitivity?
8
+ - [ ] **Critical unknowns:** Top 3–5 gaps that block confident downstream review.
9
+ - [ ] **Emphasis:** What should Analyst, PM, PO, Architect, Dev-feasibility, QA, SM stress for *this* requirement?
@@ -0,0 +1,9 @@
1
+ # Spec circuit — product manager checklist
2
+
3
+ - [ ] **Problem vs solution:** Is the *problem* clear vs premature solution detail?
4
+ - [ ] **MVP vs future:** What is minimum lovable scope; what is deferred?
5
+ - [ ] **Scope creep / non-goals:** Explicit out-of-scope statements needed?
6
+ - [ ] **Success metrics:** KPIs or measurable outcomes (adoption, latency, conversion, cost).
7
+ - [ ] **Value vs complexity:** High-cost areas; trade-off recommendations.
8
+ - [ ] **Release & adoption risks:** Dependencies, change management, operational readiness.
9
+ - [ ] **Cross-functional dependencies:** Legal, security, data, infra, partner APIs.