@capagents/forgeqe 3.3.0 → 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.
- package/HOW_TO_USE.md +32 -0
- package/dist/docs-site/docs/area-setup/index.html +1 -0
- package/dist/docs-site/docs/area-test-cases/index.html +25 -0
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/forgeqe.js +1922 -1906
- package/dist/requirement-agent/requirements_agent/__init__.py +3 -0
- package/dist/requirement-agent/requirements_agent/__main__.py +5 -0
- package/dist/requirement-agent/requirements_agent/agent.py +363 -0
- package/dist/requirement-agent/requirements_agent/chat_session.py +424 -0
- package/dist/requirement-agent/requirements_agent/cli.py +870 -0
- package/dist/requirement-agent/requirements_agent/config.py +403 -0
- package/dist/requirement-agent/requirements_agent/console_ui.py +632 -0
- package/dist/requirement-agent/requirements_agent/context/__init__.py +3 -0
- package/dist/requirement-agent/requirements_agent/context/aggregate.py +214 -0
- package/dist/requirement-agent/requirements_agent/context/base.py +14 -0
- package/dist/requirement-agent/requirements_agent/context/folder.py +107 -0
- package/dist/requirement-agent/requirements_agent/context/given.py +70 -0
- package/dist/requirement-agent/requirements_agent/context/graph.py +181 -0
- package/dist/requirement-agent/requirements_agent/context/knowledge.py +192 -0
- package/dist/requirement-agent/requirements_agent/context/mcp.py +24 -0
- package/dist/requirement-agent/requirements_agent/context/memory.py +144 -0
- package/dist/requirement-agent/requirements_agent/context/personas.py +214 -0
- package/dist/requirement-agent/requirements_agent/context/rag.py +148 -0
- package/dist/requirement-agent/requirements_agent/context/untrusted.py +56 -0
- package/dist/requirement-agent/requirements_agent/docs/HOW_TO_USE.md +505 -0
- package/dist/requirement-agent/requirements_agent/docs/requirements-agent-architecture.html +348 -0
- package/dist/requirement-agent/requirements_agent/docs_cmd.py +51 -0
- package/dist/requirement-agent/requirements_agent/export/__init__.py +3 -0
- package/dist/requirement-agent/requirements_agent/export/markdown.py +55 -0
- package/dist/requirement-agent/requirements_agent/export/pdf.py +82 -0
- package/dist/requirement-agent/requirements_agent/export/requirements_json.py +120 -0
- package/dist/requirement-agent/requirements_agent/init_cmd.py +191 -0
- package/dist/requirement-agent/requirements_agent/llm/__init__.py +3 -0
- package/dist/requirement-agent/requirements_agent/llm/base.py +49 -0
- package/dist/requirement-agent/requirements_agent/llm/copilot.py +171 -0
- package/dist/requirement-agent/requirements_agent/llm/mock.py +144 -0
- package/dist/requirement-agent/requirements_agent/llm/providers.py +277 -0
- package/dist/requirement-agent/requirements_agent/llm/router.py +35 -0
- package/dist/requirement-agent/requirements_agent/models.py +73 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/analyst.md +29 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/architect.md +28 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/bmad-orchestrator.md +26 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/dev.md +27 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/pm.md +27 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/po.md +27 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/qa.md +28 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/agents/sm.md +26 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-analyst.md +8 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-architect.md +11 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-dev.md +11 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-orchestrator.md +9 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-pm.md +9 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-po.md +10 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-qa.md +11 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/checklists/spec-circuit-sm.md +8 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/bmad-kb.md +19 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/requirements-standards-baseline.md +188 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/data/technical-preferences.md +54 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/utils/template-format.md +7 -0
- package/dist/requirement-agent/requirements_agent/packs/bmad-core-spec/workflows/greenfield-fullstack.yml +177 -0
- package/dist/requirement-agent/requirements_agent/pipeline/__init__.py +3 -0
- package/dist/requirement-agent/requirements_agent/pipeline/brd.py +86 -0
- package/dist/requirement-agent/requirements_agent/pipeline/pack.py +233 -0
- package/dist/requirement-agent/requirements_agent/pipeline/progress.py +60 -0
- package/dist/requirement-agent/requirements_agent/pipeline/prompts.py +150 -0
- package/dist/requirement-agent/requirements_agent/pipeline/quality.py +124 -0
- package/dist/requirement-agent/requirements_agent/pipeline/refine.py +386 -0
- package/dist/requirement-agent/requirements_agent/pipeline/sections.py +117 -0
- package/dist/requirement-agent/requirements_agent/pipeline/spec_circuit.py +142 -0
- package/dist/requirement-agent/requirements_agent/shell/__init__.py +7 -0
- package/dist/requirement-agent/requirements_agent/shell/actions.py +208 -0
- package/dist/requirement-agent/requirements_agent/shell/app.py +902 -0
- package/dist/requirement-agent/requirements_agent/shell/commands.py +206 -0
- package/dist/requirement-agent/requirements_agent/shell/progress_pane.py +114 -0
- package/dist/requirement-agent/requirements_agent/shell/ref_picker.py +59 -0
- package/dist/requirement-agent/requirements_agent/shell/refs.py +120 -0
- package/dist/requirement-agent/requirements_agent/shell/session.py +362 -0
- package/dist/requirement-agent/requirements_agent/shell/transcript.py +241 -0
- package/dist/requirement-agent/requirements_agent/shell/usage.py +64 -0
- package/dist/requirement-agent/requirements_agent/shell/usage_llm.py +64 -0
- package/dist/requirement-agent/requirements_agent/shell/worker.py +378 -0
- package/dist/requirement-agent/requirements_agent/tuios_hook.py +182 -0
- package/dist/requirement-agent/requirements_agent/webops.py +627 -0
- package/dist/template.html +66 -66
- package/dist/web/assets/{3d-force-graph-DgKpiu6s.js → 3d-force-graph-DDyP5jcf.js} +1 -1
- package/dist/web/assets/Agent-sLaNlaQo.js +8 -0
- package/dist/web/assets/AgentWork-Dv0G4bt3.js +2 -0
- package/dist/web/assets/ApiTests-Bnw2qgWw.js +15 -0
- package/dist/web/assets/Browse-CBt1JY2E.js +1 -0
- package/dist/web/assets/Chat-DIWdnIZK.js +3 -0
- package/dist/web/assets/CommandPalette-DD04oS83.js +1 -0
- package/dist/web/assets/Compare-D0Ao8dZ6.js +1 -0
- package/dist/web/assets/Cost-BY_8-9Qt.js +1 -0
- package/dist/web/assets/{Data-CkQGUNww.js → Data-BC7R_FbW.js} +4 -4
- package/dist/web/assets/Desktop-CSQ2xLg0.js +1 -0
- package/dist/web/assets/DesktopReview-CCOhUdeJ.js +2 -0
- package/dist/web/assets/DeviceScreen-BHmTd9Q-.js +1 -0
- package/dist/web/assets/Evidence-9W4pqIkC.js +1 -0
- package/dist/web/assets/{Explore-k0Y19Q5T.js → Explore-BndXiEf8.js} +2 -2
- package/dist/web/assets/Features-BrfsTC9Q.js +1 -0
- package/dist/web/assets/{Flags-CXFDO-k_.js → Flags-DyykkeHU.js} +2 -2
- package/dist/web/assets/Flaky-C3gj_Brn.js +1 -0
- package/dist/web/assets/Impact-Z8nbNhbe.js +3 -0
- package/dist/web/assets/Jobs-CJWXAqSy.js +5 -0
- package/dist/web/assets/KindPage-C45x_cFz.js +6 -0
- package/dist/web/assets/LiveDevice-DGdLDigO.js +1 -0
- package/dist/web/assets/Migration-QFI5ctp7.js +8 -0
- package/dist/web/assets/Mobile-CuswZyee.js +1 -0
- package/dist/web/assets/Observability-CknZ_xBN.js +1 -0
- package/dist/web/assets/PageAgent-B2bmmMaP.js +1 -0
- package/dist/web/assets/Product-CrtwDiMv.js +12 -0
- package/dist/web/assets/Production-BMsytC2i.js +1 -0
- package/dist/web/assets/Quality-B4Aw6N3_.js +1 -0
- package/dist/web/assets/Readiness-CVIzTFX-.js +1 -0
- package/dist/web/assets/Record-B2Ic8Taj.js +1 -0
- package/dist/web/assets/Regression-bCIAE3Ne.js +5 -0
- package/dist/web/assets/RelationGraph-kG4YVMzl.js +1 -0
- package/dist/web/assets/Reports-NAZ-26Ub.js +2 -0
- package/dist/web/assets/Requirements-BkpiF-Bt.js +2 -0
- package/dist/web/assets/Responsive-CsaoisJq.js +3 -0
- package/dist/web/assets/RunDiff-BC-3Wg1b.js +1 -0
- package/dist/web/assets/Settings-DyBed-J5.js +21 -0
- package/dist/web/assets/Steps-DcQxQ4yA.js +2 -0
- package/dist/web/assets/TestData-wpUeU9Er.js +2 -0
- package/dist/web/assets/TestManagement-D0njkyAT.js +4 -0
- package/dist/web/assets/WhatsNew-BxIAAwgH.js +1 -0
- package/dist/web/assets/agentSettingsSheet-BdB7IXah.js +1 -0
- package/dist/web/assets/choice-C4-yW2x9.js +1 -0
- package/dist/web/assets/code-Jek8uWUO.js +1 -0
- package/dist/web/assets/{coverage-DirEXtfZ.js → coverage-q-ib7wOq.js} +1 -1
- package/dist/web/assets/dataParts-B2-a-pOD.js +3 -0
- package/dist/web/assets/desktopAppPath-C-p0zU40.js +1 -0
- package/dist/web/assets/frame-CjpZWX_X.js +13 -0
- package/dist/web/assets/index-BH5RbDNY.css +2 -0
- package/dist/web/assets/index-CfGXe_De.js +55 -0
- package/dist/web/assets/line-icons-CwCZidXs.js +1 -0
- package/dist/web/assets/logos-P2LOMyTK.js +1 -0
- package/dist/web/assets/{markdown-BnrLv6Iw.js → markdown-dXSsS-mD.js} +5 -5
- package/dist/web/assets/nav-BZfNOkhX.js +1 -0
- package/dist/web/assets/pageBack-BwKT31j3.js +3 -0
- package/dist/web/assets/palette-L37b4wTE.js +1 -0
- package/dist/web/assets/{paletteCommands-LXIICD4V.js → paletteCommands-zqGCORJu.js} +1 -1
- package/dist/web/assets/parts-3o6HnCp1.js +1 -0
- package/dist/web/assets/preload-helper-BupTYkQW.js +1 -0
- package/dist/web/assets/productParts-BDiEg0z6.js +1 -0
- package/dist/web/assets/qualityParts--CnSadOZ.js +1 -0
- package/dist/web/assets/radio-BLI4Ubhk.js +1 -0
- package/dist/web/assets/react-BDur5s0O.js +1 -0
- package/dist/web/assets/{recordTest-BzKpS4m5.js → recordTest-D092f975.js} +1 -1
- package/dist/web/assets/route-oDy8sV6H.js +1 -0
- package/dist/web/assets/sectionList-XiKcJNEK.js +1 -0
- package/dist/web/assets/step-mark-CaKf4dAR.js +1 -0
- package/dist/web/assets/stepper-naqAN_Nb.js +1 -0
- package/dist/web/assets/utils-DJRAScIl.js +1 -0
- package/dist/web/assets/wizardParts-DLlOHVMx.js +1 -0
- package/dist/web/index.html +14 -12
- package/docs/user-guide.html +26 -0
- package/package.json +2 -1
- package/py/forgeqe_engine/cli.py +7 -0
- package/dist/web/assets/Agent-BP11jrsE.js +0 -8
- package/dist/web/assets/AgentWork-DqiO3LUi.js +0 -2
- package/dist/web/assets/ApiTests-CLFt0wGW.js +0 -15
- package/dist/web/assets/Browse-D5VDHN9Z.js +0 -1
- package/dist/web/assets/Chat-BqqaT-n0.js +0 -3
- package/dist/web/assets/CommandPalette-D3F4iHrP.js +0 -1
- package/dist/web/assets/Compare-KeUsk4G3.js +0 -1
- package/dist/web/assets/Cost-CDdSNCkt.js +0 -1
- package/dist/web/assets/Desktop-COKu5aHU.js +0 -1
- package/dist/web/assets/DesktopReview-CMpXNurd.js +0 -2
- package/dist/web/assets/DeviceScreen-DJqblqBh.js +0 -1
- package/dist/web/assets/Evidence-CPevi78T.js +0 -1
- package/dist/web/assets/Features-D_miisXy.js +0 -1
- package/dist/web/assets/Flaky-CzaQIwXC.js +0 -1
- package/dist/web/assets/Impact-pos046GB.js +0 -3
- package/dist/web/assets/Jobs-C0TtzWA4.js +0 -5
- package/dist/web/assets/KindPage-DAvgKrwt.js +0 -6
- package/dist/web/assets/LiveDevice-C9LRZMhC.js +0 -1
- package/dist/web/assets/Migration-kYknzHdK.js +0 -8
- package/dist/web/assets/Mobile-AVi39qoN.js +0 -1
- package/dist/web/assets/Observability-l1ZN4JL0.js +0 -1
- package/dist/web/assets/PageAgent-DzVjKKYz.js +0 -1
- package/dist/web/assets/Product-CrnXTDkX.js +0 -12
- package/dist/web/assets/Production-B4VlKTlL.js +0 -1
- package/dist/web/assets/Quality-CtjVY15v.js +0 -1
- package/dist/web/assets/Readiness-RUzKklxF.js +0 -1
- package/dist/web/assets/Record-f87pdoaN.js +0 -1
- package/dist/web/assets/Regression-RSnjP5hS.js +0 -5
- package/dist/web/assets/RelationGraph-gc0Xmklt.js +0 -1
- package/dist/web/assets/Reports-881BJZ_u.js +0 -2
- package/dist/web/assets/Responsive-251XAuZE.js +0 -3
- package/dist/web/assets/RunDiff-DG0hKKDs.js +0 -1
- package/dist/web/assets/Settings-Cv3kUuOx.js +0 -21
- package/dist/web/assets/Steps-Cyjk5JtV.js +0 -2
- package/dist/web/assets/TestData-TcXA9UmV.js +0 -2
- package/dist/web/assets/TestManagement-D0e2N_Xr.js +0 -4
- package/dist/web/assets/WhatsNew-COVX946M.js +0 -1
- package/dist/web/assets/agentSettingsSheet-DGFh1_iF.js +0 -1
- package/dist/web/assets/choice-CiFogD01.js +0 -1
- package/dist/web/assets/code-DzYywAs5.js +0 -1
- package/dist/web/assets/dataParts-Di7PdPHu.js +0 -3
- package/dist/web/assets/desktopAppPath-B8j1-pX0.js +0 -1
- package/dist/web/assets/frame-CNLw552P.js +0 -13
- package/dist/web/assets/index-CuN17Qrj.js +0 -55
- package/dist/web/assets/index-Dchrk5Yt.css +0 -2
- package/dist/web/assets/line-icons-B-O8oBsY.js +0 -1
- package/dist/web/assets/nav-Ds_6IERv.js +0 -1
- package/dist/web/assets/pageBack-DJxbEPfN.js +0 -3
- package/dist/web/assets/palette-H2g-hemT.js +0 -1
- package/dist/web/assets/parts-DKRLtrjs.js +0 -1
- package/dist/web/assets/preload-helper-BML5SvL4.js +0 -1
- package/dist/web/assets/productParts-DvrCr604.js +0 -1
- package/dist/web/assets/qualityParts-BYx5phEI.js +0 -1
- package/dist/web/assets/radio-CbR6ODxQ.js +0 -1
- package/dist/web/assets/route-DjewvmpL.js +0 -1
- package/dist/web/assets/sectionList-0umoKvRv.js +0 -1
- package/dist/web/assets/step-mark-g8Eb6foB.js +0 -1
- package/dist/web/assets/stepper-CzZIC36d.js +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
import shlex
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import List, Optional, Tuple
|
|
8
|
+
|
|
9
|
+
HELP = """Commands (deliberately small)
|
|
10
|
+
|
|
11
|
+
/title <name> Set project title
|
|
12
|
+
/brief <path> Load design brief from a file
|
|
13
|
+
/out <dir> Set output folder (default ./out)
|
|
14
|
+
/open <report.md> Open an existing report to chat/refine
|
|
15
|
+
|
|
16
|
+
/ref Add reference (menu)
|
|
17
|
+
/ref <path> Add file/folder
|
|
18
|
+
/ref <url> Add URL reference
|
|
19
|
+
/ref @workspace Add current workspace
|
|
20
|
+
/ref @git Add git repository context
|
|
21
|
+
|
|
22
|
+
/analyse [focus] Start Spec Circuit analysis (alias: /run)
|
|
23
|
+
/report [--format pdf|md|both]
|
|
24
|
+
/find <text> Search the current report
|
|
25
|
+
/questions Show open questions from last analysis
|
|
26
|
+
/risk Show risks
|
|
27
|
+
/gaps Show gaps / findings
|
|
28
|
+
/fix <n> [answer] Resolve gap/question N in one step (alias: /gap)
|
|
29
|
+
/trace Show section outline
|
|
30
|
+
|
|
31
|
+
/context Show references
|
|
32
|
+
/clear-context Remove references
|
|
33
|
+
/section <n|name> Pin a section for refine
|
|
34
|
+
/section clear Unpin
|
|
35
|
+
|
|
36
|
+
/status Agent status
|
|
37
|
+
/stop Stop current operation
|
|
38
|
+
/undo Revert last refine
|
|
39
|
+
/yes Accept last refine (after confirm prompt)
|
|
40
|
+
/help This help
|
|
41
|
+
/exit Leave the shell (alias: /quit)
|
|
42
|
+
|
|
43
|
+
Quick start:
|
|
44
|
+
/title Identity Hub SSO
|
|
45
|
+
/brief ./brief.md
|
|
46
|
+
/ref ./contracts/
|
|
47
|
+
/analyse
|
|
48
|
+
/fix 1 Prefer OAuth2 PKCE
|
|
49
|
+
|
|
50
|
+
Natural language works too — paste a path to attach it, or after /section 8:
|
|
51
|
+
Add p95 latency < 300ms
|
|
52
|
+
""".strip()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class ParsedCommand:
|
|
57
|
+
name: str
|
|
58
|
+
args: str = ""
|
|
59
|
+
raw: str = ""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
_CMD = re.compile(r"^/(?P<name>[\w-]+)(?:\s+(?P<args>.*))?$", re.DOTALL)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def parse_input(text: str) -> Tuple[str, Optional[ParsedCommand]]:
|
|
66
|
+
"""Return ('command', ParsedCommand) or ('message', None)."""
|
|
67
|
+
raw = (text or "").strip()
|
|
68
|
+
if not raw:
|
|
69
|
+
return "empty", None
|
|
70
|
+
if raw.startswith("/"):
|
|
71
|
+
m = _CMD.match(raw)
|
|
72
|
+
if not m:
|
|
73
|
+
return "command", ParsedCommand(name="help", raw=raw)
|
|
74
|
+
name = m.group("name").lower()
|
|
75
|
+
# aliases
|
|
76
|
+
aliases = {
|
|
77
|
+
"analyze": "analyse",
|
|
78
|
+
"run": "analyse",
|
|
79
|
+
"go": "analyse",
|
|
80
|
+
"start": "analyse",
|
|
81
|
+
"done": "report",
|
|
82
|
+
"finish": "report",
|
|
83
|
+
"refs": "context",
|
|
84
|
+
"doc": "ref",
|
|
85
|
+
"docs": "ref",
|
|
86
|
+
"design": "brief",
|
|
87
|
+
"brief-file": "brief",
|
|
88
|
+
"q": "quit",
|
|
89
|
+
"exit": "quit",
|
|
90
|
+
"h": "help",
|
|
91
|
+
"?": "help",
|
|
92
|
+
"ls": "trace",
|
|
93
|
+
"sections": "trace",
|
|
94
|
+
"questions": "questions",
|
|
95
|
+
"asks": "questions",
|
|
96
|
+
"gap": "fix",
|
|
97
|
+
"resolve": "fix",
|
|
98
|
+
"fix-gap": "fix",
|
|
99
|
+
"yes": "yes",
|
|
100
|
+
"keep": "keep",
|
|
101
|
+
"confirm": "confirm",
|
|
102
|
+
"ok": "yes",
|
|
103
|
+
"undo": "undo",
|
|
104
|
+
"revert": "undo",
|
|
105
|
+
}
|
|
106
|
+
name = aliases.get(name, name)
|
|
107
|
+
return "command", ParsedCommand(name=name, args=(m.group("args") or "").strip(), raw=raw)
|
|
108
|
+
return "message", None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def split_report_format(args: str) -> str:
|
|
112
|
+
a = (args or "").strip()
|
|
113
|
+
if "--format" in a:
|
|
114
|
+
parts = a.split()
|
|
115
|
+
for i, p in enumerate(parts):
|
|
116
|
+
if p == "--format" and i + 1 < len(parts):
|
|
117
|
+
return parts[i + 1].lower()
|
|
118
|
+
if p.startswith("--format="):
|
|
119
|
+
return p.split("=", 1)[1].lower()
|
|
120
|
+
if a in ("pdf", "md", "both"):
|
|
121
|
+
return a
|
|
122
|
+
return "md"
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def is_url(text: str) -> bool:
|
|
126
|
+
t = (text or "").strip().lower()
|
|
127
|
+
return t.startswith("http://") or t.startswith("https://")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def path_completions(partial: str, *, cwd: str = ".", limit: int = 12) -> List[str]:
|
|
131
|
+
"""Simple filesystem completions for /ref ./... or /brief ./..."""
|
|
132
|
+
from pathlib import Path
|
|
133
|
+
|
|
134
|
+
raw = partial or ""
|
|
135
|
+
stripped = False
|
|
136
|
+
for prefix in ("/ref ", "/brief ", "/design ", "/open ", "/out "):
|
|
137
|
+
if raw.startswith(prefix):
|
|
138
|
+
raw = raw[len(prefix) :]
|
|
139
|
+
stripped = True
|
|
140
|
+
break
|
|
141
|
+
if not stripped and raw.startswith("/ref"):
|
|
142
|
+
raw = raw[4:].strip()
|
|
143
|
+
if not raw or raw.startswith("@") or is_url(raw):
|
|
144
|
+
return []
|
|
145
|
+
p = Path(raw).expanduser()
|
|
146
|
+
if raw.endswith("/") or raw.endswith("\\"):
|
|
147
|
+
directory = p
|
|
148
|
+
prefix_name = ""
|
|
149
|
+
else:
|
|
150
|
+
directory = p.parent if p.parent.as_posix() != "" else Path(cwd)
|
|
151
|
+
prefix_name = p.name
|
|
152
|
+
try:
|
|
153
|
+
if not directory.exists():
|
|
154
|
+
directory = Path(cwd) / directory
|
|
155
|
+
if not directory.is_dir():
|
|
156
|
+
return []
|
|
157
|
+
items = []
|
|
158
|
+
for child in sorted(directory.iterdir(), key=lambda x: (not x.is_dir(), x.name.lower())):
|
|
159
|
+
if prefix_name and not child.name.startswith(prefix_name):
|
|
160
|
+
continue
|
|
161
|
+
if child.name.startswith("."):
|
|
162
|
+
continue
|
|
163
|
+
rel = child.as_posix()
|
|
164
|
+
if child.is_dir():
|
|
165
|
+
rel += "/"
|
|
166
|
+
items.append(rel)
|
|
167
|
+
if len(items) >= limit:
|
|
168
|
+
break
|
|
169
|
+
return items
|
|
170
|
+
except OSError:
|
|
171
|
+
return []
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def looks_like_path(text: str) -> bool:
|
|
175
|
+
t = (text or "").strip().strip("'\"")
|
|
176
|
+
if not t or "\n" in t or " " in t and not t.startswith((".", "/", "~")):
|
|
177
|
+
# allow spaces only if quoted path-like - keep simple
|
|
178
|
+
if " " in t:
|
|
179
|
+
return False
|
|
180
|
+
if is_url(t):
|
|
181
|
+
return True
|
|
182
|
+
if t.startswith(("./", "../", "/", "~/", "@")):
|
|
183
|
+
return True
|
|
184
|
+
if "/" in t or t.endswith((".md", ".txt", ".pdf", ".docx", ".json", ".yaml", ".yml")):
|
|
185
|
+
return True
|
|
186
|
+
return False
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def ref_token(args: str, windows: Optional[bool] = None) -> str:
|
|
190
|
+
"""
|
|
191
|
+
The path or link of a /ref command, quotes and all ("/ref 'My Specs/a.md'"). On Windows a backslash is a path's
|
|
192
|
+
separator, not an escape, so C:\\Users\\me\\spec.md keeps its backslashes (shlex's POSIX mode would drop them).
|
|
193
|
+
"""
|
|
194
|
+
windows = os.name == "nt" if windows is None else windows
|
|
195
|
+
token = args.strip()
|
|
196
|
+
try:
|
|
197
|
+
parts = shlex.split(token, posix=not windows)
|
|
198
|
+
except ValueError:
|
|
199
|
+
return token
|
|
200
|
+
if not parts:
|
|
201
|
+
return token
|
|
202
|
+
first = parts[0]
|
|
203
|
+
if windows and len(first) >= 2 and first[0] == first[-1] and first[0] in "\"'":
|
|
204
|
+
first = first[1:-1]
|
|
205
|
+
return first
|
|
206
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from textual.app import ComposeResult
|
|
4
|
+
from textual.containers import Vertical, VerticalScroll
|
|
5
|
+
from textual.widgets import Label, ProgressBar, Static
|
|
6
|
+
|
|
7
|
+
from requirements_agent.pipeline.pack import REVIEW_PIPELINE
|
|
8
|
+
from requirements_agent.shell.session import ShellSession
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _bar(pct: int, width: int = 14) -> str:
|
|
12
|
+
pct = max(0, min(100, int(pct)))
|
|
13
|
+
filled = int(round(pct / 100 * width))
|
|
14
|
+
return "█" * filled + "░" * (width - filled)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _wrap_live(text: str, *, max_chars: int = 3500) -> str:
|
|
18
|
+
"""Prefer the tail of the stream, but keep as much as fits the pane."""
|
|
19
|
+
t = (text or "").strip() or "—"
|
|
20
|
+
if len(t) > max_chars:
|
|
21
|
+
t = "…\n" + t[-max_chars:]
|
|
22
|
+
return t
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ProgressPane(Vertical):
|
|
26
|
+
"""Right pane: stats on top, Live fills remaining height."""
|
|
27
|
+
|
|
28
|
+
def compose(self) -> ComposeResult:
|
|
29
|
+
yield Label("Progress", id="prog-title")
|
|
30
|
+
yield Static("", id="stats-line")
|
|
31
|
+
yield Static("", id="progress-line")
|
|
32
|
+
yield ProgressBar(total=100, show_eta=False, id="progress-bar")
|
|
33
|
+
yield Label("Stages", id="stages-title")
|
|
34
|
+
yield Static("", id="stages-block")
|
|
35
|
+
yield Label("Personas", id="mid-title")
|
|
36
|
+
yield Static("", id="personas-block")
|
|
37
|
+
yield Label("Live", id="live-title")
|
|
38
|
+
with VerticalScroll(id="live-scroll"):
|
|
39
|
+
yield Static("—", id="live-block", classes="live-block")
|
|
40
|
+
|
|
41
|
+
def refresh_from(self, session: ShellSession) -> None:
|
|
42
|
+
self.query_one("#stats-line", Static).update(
|
|
43
|
+
f"Refs {len(session.refs)} Findings {session.finding_count} Risks {session.risk_count}"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
pct = session.progress_pct
|
|
47
|
+
self.query_one("#progress-line", Static).update(f"{_bar(pct)} {pct}%")
|
|
48
|
+
self.query_one("#progress-bar", ProgressBar).update(progress=pct)
|
|
49
|
+
|
|
50
|
+
order = [
|
|
51
|
+
("memory", "Memory"),
|
|
52
|
+
("review", "Spec Circuit"),
|
|
53
|
+
("score", "Quality"),
|
|
54
|
+
("questions", "Questions"),
|
|
55
|
+
("consolidate", "BRD"),
|
|
56
|
+
("export", "Export"),
|
|
57
|
+
]
|
|
58
|
+
phase_rank = {k: i for i, (k, _) in enumerate(order)}
|
|
59
|
+
cur = phase_rank.get(session.phase, -1)
|
|
60
|
+
if session.progress_pct >= 100 or session.ui_mode in ("refine", "done"):
|
|
61
|
+
cur = len(order)
|
|
62
|
+
stage_lines = []
|
|
63
|
+
for i, (_key, label) in enumerate(order):
|
|
64
|
+
if i < cur or session.progress_pct >= 100 or session.ui_mode in ("refine", "done"):
|
|
65
|
+
icon = "✓"
|
|
66
|
+
elif i == cur and session.status != "idle":
|
|
67
|
+
icon = "●"
|
|
68
|
+
else:
|
|
69
|
+
icon = "○"
|
|
70
|
+
stage_lines.append(f"{icon} {label}")
|
|
71
|
+
self.query_one("#stages-block", Static).update("\n".join(stage_lines))
|
|
72
|
+
|
|
73
|
+
mid = self.query_one("#mid-title", Label)
|
|
74
|
+
live_title = self.query_one("#live-title", Label)
|
|
75
|
+
mid_block = self.query_one("#personas-block", Static)
|
|
76
|
+
live_block = self.query_one("#live-block", Static)
|
|
77
|
+
|
|
78
|
+
if session.ui_mode in ("refine", "done") and session.active_doc():
|
|
79
|
+
mid.update("Sections")
|
|
80
|
+
live_title.update("Questions")
|
|
81
|
+
sections = session.section_outline()
|
|
82
|
+
mid_block.update(
|
|
83
|
+
"\n".join(f"[{s['index']}] {s['heading']}" for s in sections[:20])
|
|
84
|
+
+ ("\n…" if len(sections) > 20 else "")
|
|
85
|
+
if sections
|
|
86
|
+
else "(none)"
|
|
87
|
+
)
|
|
88
|
+
qs = session.open_questions
|
|
89
|
+
if qs:
|
|
90
|
+
# Use full pane width — no artificial 70-char crunch
|
|
91
|
+
live_block.update(
|
|
92
|
+
"\n".join(
|
|
93
|
+
f"• [{q.get('category', '?')}] {q.get('text') or ''}"
|
|
94
|
+
for q in qs[:30]
|
|
95
|
+
)
|
|
96
|
+
+ (f"\n… +{len(qs) - 30} more" if len(qs) > 30 else "")
|
|
97
|
+
)
|
|
98
|
+
else:
|
|
99
|
+
live_block.update("—")
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
mid.update("Personas")
|
|
103
|
+
live_title.update("Live")
|
|
104
|
+
persona_lines = []
|
|
105
|
+
for idx, (_aid, heading) in enumerate(REVIEW_PIPELINE, start=1):
|
|
106
|
+
if session.progress_pct >= 70 or session.persona_step > idx:
|
|
107
|
+
icon = "✓"
|
|
108
|
+
elif session.phase == "review" and session.persona_step == idx:
|
|
109
|
+
icon = "●"
|
|
110
|
+
else:
|
|
111
|
+
icon = "○"
|
|
112
|
+
persona_lines.append(f"{icon} {heading} {idx}/8")
|
|
113
|
+
mid_block.update("\n".join(persona_lines))
|
|
114
|
+
live_block.update(_wrap_live(session.live_preview or session.active_persona or "—"))
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from textual.app import ComposeResult
|
|
4
|
+
from textual.containers import Vertical
|
|
5
|
+
from textual.screen import ModalScreen
|
|
6
|
+
from textual.widgets import Button, Input, Label, OptionList
|
|
7
|
+
from textual.widgets.option_list import Option
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RefPickerScreen(ModalScreen[str]):
|
|
11
|
+
"""Add Reference menu when user types /ref with no args."""
|
|
12
|
+
|
|
13
|
+
CSS = """
|
|
14
|
+
RefPickerScreen { align: center middle; }
|
|
15
|
+
#ref-dialog {
|
|
16
|
+
width: 64;
|
|
17
|
+
height: auto;
|
|
18
|
+
border: round $accent;
|
|
19
|
+
background: $surface;
|
|
20
|
+
padding: 1 2;
|
|
21
|
+
}
|
|
22
|
+
#ref-dialog Label { margin-bottom: 1; }
|
|
23
|
+
#ref-filter { margin: 1 0; }
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def compose(self) -> ComposeResult:
|
|
27
|
+
with Vertical(id="ref-dialog"):
|
|
28
|
+
yield Label("Add Reference")
|
|
29
|
+
yield OptionList(
|
|
30
|
+
Option("File or folder", id="path"),
|
|
31
|
+
Option("URL", id="url"),
|
|
32
|
+
Option("Workspace", id="workspace"),
|
|
33
|
+
Option("Git repository", id="git"),
|
|
34
|
+
Option("ADO / Jira (coming soon)", id="ado"),
|
|
35
|
+
Option("Cancel", id="cancel"),
|
|
36
|
+
id="ref-options",
|
|
37
|
+
)
|
|
38
|
+
yield Input(placeholder="Type to filter or paste path/URL…", id="ref-filter")
|
|
39
|
+
yield Button("Use filter value", variant="primary", id="ref-use")
|
|
40
|
+
|
|
41
|
+
def on_option_list_option_selected(self, event: OptionList.OptionSelected) -> None:
|
|
42
|
+
oid = event.option_id
|
|
43
|
+
if oid == "cancel":
|
|
44
|
+
self.dismiss("")
|
|
45
|
+
elif oid == "path":
|
|
46
|
+
self.dismiss("__ask_path__")
|
|
47
|
+
elif oid == "url":
|
|
48
|
+
self.dismiss("__ask_url__")
|
|
49
|
+
elif oid == "workspace":
|
|
50
|
+
self.dismiss("@workspace")
|
|
51
|
+
elif oid == "git":
|
|
52
|
+
self.dismiss("@git")
|
|
53
|
+
elif oid == "ado":
|
|
54
|
+
self.dismiss("__ado_stub__")
|
|
55
|
+
|
|
56
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
57
|
+
if event.button.id == "ref-use":
|
|
58
|
+
val = self.query_one("#ref-filter", Input).value.strip()
|
|
59
|
+
self.dismiss(val)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Optional, Tuple
|
|
7
|
+
from urllib.parse import urlparse
|
|
8
|
+
|
|
9
|
+
import httpx
|
|
10
|
+
|
|
11
|
+
from requirements_agent.shell.session import Reference
|
|
12
|
+
|
|
13
|
+
_IGNORE_DIRS = {
|
|
14
|
+
".git",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"__pycache__",
|
|
17
|
+
".venv",
|
|
18
|
+
"venv",
|
|
19
|
+
"dist",
|
|
20
|
+
"build",
|
|
21
|
+
".tox",
|
|
22
|
+
".pytest_cache",
|
|
23
|
+
".mypy_cache",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_path_ref(path_str: str, *, cwd: Optional[Path] = None) -> Tuple[Optional[Reference], str]:
|
|
28
|
+
cwd = cwd or Path.cwd()
|
|
29
|
+
p = Path(path_str).expanduser()
|
|
30
|
+
if not p.is_absolute():
|
|
31
|
+
p = (cwd / p).resolve()
|
|
32
|
+
else:
|
|
33
|
+
p = p.resolve()
|
|
34
|
+
if not p.exists():
|
|
35
|
+
return None, f"Not found: {p}"
|
|
36
|
+
kind = "path"
|
|
37
|
+
detail = "directory" if p.is_dir() else f"{p.stat().st_size:,} bytes"
|
|
38
|
+
return Reference(kind=kind, label=p.name, path=str(p), detail=detail), f"Attached {p}"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def add_url_ref(url: str) -> Tuple[Optional[Reference], str]:
|
|
42
|
+
url = (url or "").strip()
|
|
43
|
+
if not (url.startswith("http://") or url.startswith("https://")):
|
|
44
|
+
return None, "URL must start with http:// or https://"
|
|
45
|
+
try:
|
|
46
|
+
with httpx.Client(timeout=20.0, follow_redirects=True) as client:
|
|
47
|
+
resp = client.get(url)
|
|
48
|
+
resp.raise_for_status()
|
|
49
|
+
text = resp.text
|
|
50
|
+
except Exception as e:
|
|
51
|
+
return None, f"Fetch failed: {e}"
|
|
52
|
+
|
|
53
|
+
# Persist a cache file under .ra-refs so FolderProvider can read it
|
|
54
|
+
cache_dir = Path.cwd() / ".ra-refs"
|
|
55
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
56
|
+
host = urlparse(url).netloc.replace(":", "_")
|
|
57
|
+
slug = re.sub(r"[^a-zA-Z0-9._-]+", "-", urlparse(url).path.strip("/"))[:80] or "index"
|
|
58
|
+
cache_path = cache_dir / f"{host}-{slug}.md"
|
|
59
|
+
body = text
|
|
60
|
+
# strip crude HTML tags if looks like HTML
|
|
61
|
+
if "<html" in text.lower() or "<body" in text.lower():
|
|
62
|
+
body = re.sub(r"(?is)<script.*?>.*?</script>", " ", text)
|
|
63
|
+
body = re.sub(r"(?is)<style.*?>.*?</style>", " ", body)
|
|
64
|
+
body = re.sub(r"(?s)<[^>]+>", " ", body)
|
|
65
|
+
body = re.sub(r"\s+", " ", body)
|
|
66
|
+
clipped = body.strip()[:80_000]
|
|
67
|
+
cache_path.write_text(
|
|
68
|
+
f"# URL reference\n\nSource: {url}\n\n{clipped}\n",
|
|
69
|
+
encoding="utf-8",
|
|
70
|
+
)
|
|
71
|
+
return (
|
|
72
|
+
Reference(kind="url", label=url, path=str(cache_path), detail=f"{len(clipped):,} chars cached"),
|
|
73
|
+
f"URL reference added ({len(clipped):,} chars)",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def add_workspace_ref(cwd: Optional[Path] = None) -> Tuple[Optional[Reference], str]:
|
|
78
|
+
cwd = (cwd or Path.cwd()).resolve()
|
|
79
|
+
# Prefer attaching cwd; FolderProvider walks files. Warn if huge.
|
|
80
|
+
file_count = 0
|
|
81
|
+
for p in cwd.rglob("*"):
|
|
82
|
+
if any(part in _IGNORE_DIRS for part in p.parts):
|
|
83
|
+
continue
|
|
84
|
+
if p.is_file():
|
|
85
|
+
file_count += 1
|
|
86
|
+
if file_count > 500:
|
|
87
|
+
break
|
|
88
|
+
detail = f"workspace · ~{file_count}{'+' if file_count > 500 else ''} files"
|
|
89
|
+
return (
|
|
90
|
+
Reference(kind="workspace", label=str(cwd), path=str(cwd), detail=detail),
|
|
91
|
+
f"Workspace attached: {cwd}",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def add_git_ref(cwd: Optional[Path] = None) -> Tuple[Optional[Reference], str]:
|
|
96
|
+
cwd = (cwd or Path.cwd()).resolve()
|
|
97
|
+
try:
|
|
98
|
+
def _run(args: list) -> str:
|
|
99
|
+
r = subprocess.run(args, cwd=str(cwd), capture_output=True, text=True, timeout=15)
|
|
100
|
+
return (r.stdout or r.stderr or "").strip()
|
|
101
|
+
|
|
102
|
+
status = _run(["git", "status", "-sb"])
|
|
103
|
+
if not status or "not a git repository" in status.lower():
|
|
104
|
+
return None, "Not a git repository"
|
|
105
|
+
log = _run(["git", "log", "-5", "--oneline"])
|
|
106
|
+
diffstat = _run(["git", "diff", "--stat", "HEAD"])
|
|
107
|
+
content = (
|
|
108
|
+
f"# Git context\n\nRepo: {cwd}\n\n## status\n```\n{status}\n```\n\n"
|
|
109
|
+
f"## recent commits\n```\n{log}\n```\n\n## diffstat\n```\n{diffstat or '(clean)'}\n```\n"
|
|
110
|
+
)
|
|
111
|
+
cache_dir = Path.cwd() / ".ra-refs"
|
|
112
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
113
|
+
cache_path = cache_dir / "git-context.md"
|
|
114
|
+
cache_path.write_text(content, encoding="utf-8")
|
|
115
|
+
return (
|
|
116
|
+
Reference(kind="git", label="git", path=str(cache_path), detail="status + log + diffstat"),
|
|
117
|
+
"Git context attached",
|
|
118
|
+
)
|
|
119
|
+
except Exception as e:
|
|
120
|
+
return None, f"Git failed: {e}"
|