shak3008 commited on
Commit
4d393e8
·
0 Parent(s):

feat: initial commit for DiffWeave platform

Browse files
Files changed (46) hide show
  1. .gitignore +19 -0
  2. README.md +164 -0
  3. diffweave/__init__.py +5 -0
  4. diffweave/bridge/__init__.py +3 -0
  5. diffweave/bridge/app.py +417 -0
  6. diffweave/cli/__init__.py +3 -0
  7. diffweave/cli/commands/add_cmd.py +103 -0
  8. diffweave/cli/commands/commit_cmd.py +77 -0
  9. diffweave/cli/commands/diff_cmd.py +48 -0
  10. diffweave/cli/commands/doctor_cmd.py +150 -0
  11. diffweave/cli/commands/init_cmd.py +85 -0
  12. diffweave/cli/commands/log_cmd.py +69 -0
  13. diffweave/cli/commands/proposals_cmd.py +100 -0
  14. diffweave/cli/commands/review_cmd.py +119 -0
  15. diffweave/cli/commands/rules_cmd.py +124 -0
  16. diffweave/cli/commands/search_cmd.py +65 -0
  17. diffweave/cli/commands/status_cmd.py +68 -0
  18. diffweave/cli/commands/validate_cmd.py +97 -0
  19. diffweave/cli/config.py +84 -0
  20. diffweave/cli/main.py +60 -0
  21. diffweave/cli/output.py +192 -0
  22. diffweave/mcp/__init__.py +10 -0
  23. diffweave/mcp/client.py +236 -0
  24. diffweave/mcp/errors.py +30 -0
  25. diffweave/mcp/schemas.py +88 -0
  26. dw.bat +6 -0
  27. pyproject.toml +26 -0
  28. sample_test_docs/doc1_clinical_protocol_baseline.txt +22 -0
  29. sample_test_docs/doc2_clinical_amendment.txt +18 -0
  30. sample_test_docs/doc3_offtopic_recipe.txt +20 -0
  31. studio/index.html +16 -0
  32. studio/package-lock.json +1740 -0
  33. studio/package.json +18 -0
  34. studio/src/App.jsx +255 -0
  35. studio/src/api/client.js +137 -0
  36. studio/src/components/AuditLog.jsx +74 -0
  37. studio/src/components/IngestionStaging.jsx +157 -0
  38. studio/src/components/KnowledgeBase.jsx +117 -0
  39. studio/src/components/KnowledgeGraph.jsx +177 -0
  40. studio/src/components/Navbar.jsx +155 -0
  41. studio/src/components/PRReviewDeck.jsx +177 -0
  42. studio/src/components/PolicyRulesLab.jsx +241 -0
  43. studio/src/components/SemanticDiffViewer.jsx +266 -0
  44. studio/src/index.css +68 -0
  45. studio/src/main.jsx +10 -0
  46. studio/vite.config.js +15 -0
.gitignore ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.class
5
+ *.env
6
+ .venv/
7
+ env/
8
+ dist/
9
+ build/
10
+ *.egg-info/
11
+
12
+ # Node / Studio
13
+ node_modules/
14
+ dist/
15
+ .vite/
16
+
17
+ # Local DiffWeave data
18
+ .diffweave/
19
+ storage/
README.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DiffWeave 🧶 — GitHub for Document Knowledge
2
+
3
+ > **A Git-like developer platform for AI document intelligence, turning unstructured document changes into semantic commits, pull requests, and 3-way fact diffs.**
4
+
5
+ DiffWeave is built on top of the **DocWeave** document intelligence engine via the **Model Context Protocol (MCP)**. Where DocWeave acts as the deep extraction and reconciliation engine ( Git plumbing), **DiffWeave** serves as the developer-facing platform (GitHub porcelain) comprising:
6
+
7
+ 1. **dw (Command Line Interface)**: A high-velocity, Git-modeled CLI for staging documents, inspecting semantic diffs, validating CI policies, and committing approved facts to the Master Knowledge Register.
8
+ 2. **DiffWeave Studio (Web UI)**: A modern, dark-mode visual interface with a 3-way Semantic Fact Diff viewer, Knowledge PR Review deck, interactive Knowledge Graph topology, and Policy Rules lab.
9
+
10
+ ---
11
+
12
+ ## Architecture Overview
13
+
14
+ `
15
+ +---------------------------------------+
16
+ | DiffWeave Ecosystem |
17
+ +-------------------+-------------------+
18
+ |
19
+ +--------------------------+--------------------------+
20
+ | |
21
+ +----------v----------+ +----------v----------+
22
+ | DiffWeave CLI | | DiffWeave Studio |
23
+ | (dw) | | (React 18 + Vite) |
24
+ +----------+----------+ +----------+----------+
25
+ | |
26
+ | +----------v----------+
27
+ | | FastAPI Bridge |
28
+ | | (REST Endpoints) |
29
+ | +----------+----------+
30
+ | |
31
+ +--------------------------+--------------------------+
32
+ |
33
+ +-------------------v-------------------+
34
+ | DiffWeave MCP Client |
35
+ | (Stdio / In-Process Fast Adapter) |
36
+ +-------------------+-------------------+
37
+ |
38
+ +-------------------v-------------------+
39
+ | DocWeave MCP Server |
40
+ | (29 Model Context Tools) |
41
+ +-------------------+-------------------+
42
+ |
43
+ +--------------------------+--------------------------+
44
+ | |
45
+ +----------v----------+ +----------v----------+
46
+ | Extraction Engine | | Neon PostgreSQL |
47
+ | & Embedding Models | | Master Knowledge |
48
+ +---------------------+ +---------------------+
49
+ `
50
+
51
+ ---
52
+
53
+ ## Quickstart
54
+
55
+ ### 1. Requirements
56
+ - Python 3.10+
57
+ - Node.js 18+ (for Studio UI)
58
+ - DocWeave engine backend
59
+
60
+ ### 2. CLI Setup
61
+ Run diagnostic checks to verify connectivity to DocWeave:
62
+
63
+ `ash
64
+ # Verify system and MCP health
65
+ .\dw.bat doctor
66
+
67
+ # Initialize or bind your workspace
68
+ .\dw.bat init --workspace 4314fb04-95be-41a2-bef4-50bf27c9c363
69
+
70
+ # Check workspace status
71
+ .\dw.bat status
72
+ `
73
+
74
+ ### 3. Stage & Ingest Documents (dw add)
75
+ Stage a document into the ingestion pipeline:
76
+
77
+ `ash
78
+ .\dw.bat add sample_test_docs\doc1_clinical_protocol_baseline.txt
79
+ `
80
+
81
+ ### 4. Semantic Diffs & PR Reviews
82
+ Once DocWeave completes proposal extraction:
83
+
84
+ `ash
85
+ # Inspect pending proposals (PRs)
86
+ .\dw.bat proposals
87
+
88
+ # View 3-way semantic diff against committed master truth
89
+ .\dw.bat diff
90
+
91
+ # Run CI policy validation rules
92
+ .\dw.bat validate
93
+
94
+ # Interactively review proposals (approve / reject / archive)
95
+ .\dw.bat review
96
+
97
+ # Or commit all approved proposals
98
+ .\dw.bat commit --all-approved
99
+ `
100
+
101
+ ---
102
+
103
+ ## DiffWeave Studio (Web UI)
104
+
105
+ DiffWeave Studio offers a rich visual dashboard for team review:
106
+
107
+ - **3-Way Semantic Fact Diff**: Side-by-side view showing baseline truth, proposed extractions, and conflict highlights.
108
+ - **Knowledge PR Deck**: One-click approvals, rejections, or archival with confidence scores and reasoning.
109
+ - **Interactive Knowledge Graph**: SVG-based topological visualization of entities, relationships, and confidence thresholds.
110
+ - **Policy Rules Lab**: Add and test deterministic validation rules (e.g., regex constraints, type checks).
111
+ - **Master Knowledge Base**: Searchable register of all committed facts with audit trail logs.
112
+
113
+ ### Running Studio
114
+ `ash
115
+ # Option A: Start the full-stack bridge server (Serves UI + API on port 8000)
116
+ python -m diffweave.bridge.app
117
+
118
+ # Option B: Run Vite development server with hot-module reloading
119
+ cd studio
120
+ npm run dev
121
+ `
122
+
123
+ Visit http://localhost:8000 (or http://localhost:5173 if running Vite dev server).
124
+
125
+ ---
126
+
127
+ ## CLI Command Reference
128
+
129
+ | Command | Description |
130
+ |---|---|
131
+ | dw init | Initialize .diffweave/ context or bind to existing workspace |
132
+ | dw add <path> | Stage and trigger document ingestion workflow |
133
+ | dw status | Display workspace summary, tracked documents, and pending reviews |
134
+ | dw proposals | List and inspect extracted knowledge proposals |
135
+ | dw diff | Render 3-way semantic fact diffs with confidence scoring |
136
+ | dw validate | Execute workspace policy rules and display pass/warn/fail lint table |
137
+ | dw review | Interactive terminal wizard to approve, reject, or archive proposals |
138
+ | dw commit | Promote approved proposals into Master Knowledge Register |
139
+ | dw log | Chronological audit trail of document updates and state transitions |
140
+ | dw search <query> | Hybrid search across committed knowledge entities |
141
+ | dw rules | List, add, or delete automated validation rules |
142
+ | dw doctor | Diagnose MCP connectivity, environment, and tool coverage |
143
+
144
+ ---
145
+
146
+ ## Directory Structure
147
+
148
+ `
149
+ DiffWeave/
150
+ ├── diffweave/
151
+ │ ├── cli/ # dw command line tool (Click / Typer + Rich)
152
+ │ ├── mcp/ # MCP client adapter & DocWeave integration
153
+ │ └── bridge/ # FastAPI bridge server for Studio Web UI
154
+ ├── studio/ # React 18 + TailwindCSS + Vite Web UI
155
+ │ ├── src/
156
+ │ │ ├── components/ # SemanticDiffViewer, PRReviewDeck, Graph, etc.
157
+ │ │ ├── api/ # Studio REST client
158
+ │ │ └── App.jsx # Navigation, Workspace Switcher, State
159
+ │ └── dist/ # Production bundle (built and ready to serve)
160
+ ├── sample_test_docs/ # Example documents for clinical trial protocol diffing
161
+ ├── dw.bat # Windows batch launcher for instant CLI access
162
+ ├── pyproject.toml # Python package configuration
163
+ └── README.md # Platform documentation
164
+ `
diffweave/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """
2
+ DiffWeave — A Git-Like Developer Platform for DocWeave.
3
+ """
4
+
5
+ __version__ = "0.1.0"
diffweave/bridge/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from diffweave.bridge.app import app
2
+
3
+ __all__ = ["app"]
diffweave/bridge/app.py ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ FastAPI Server Bridge for DiffWeave Studio.
3
+
4
+ Provides secure, authenticated, workspace-scoped REST APIs that
5
+ delegate directly to DocWeave's MCP Server.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import shutil
11
+ import tempfile
12
+ from pathlib import Path
13
+ from typing import Any, Optional
14
+
15
+ from fastapi import FastAPI, HTTPException, UploadFile, File, Form, Query
16
+ from fastapi.middleware.cors import CORSMiddleware
17
+ from pydantic import BaseModel
18
+
19
+ from diffweave.mcp.client import DiffWeaveMCPClient
20
+ from diffweave.mcp.errors import MCPToolError, MCPConnectionError
21
+
22
+ app = FastAPI(
23
+ title="DiffWeave Studio Bridge",
24
+ description="Backend bridge serving DiffWeave Studio via DocWeave MCP Server",
25
+ version="0.1.0",
26
+ )
27
+
28
+ # Enable CORS for local Studio frontend dev server
29
+ app.add_middleware(
30
+ CORSMiddleware,
31
+ allow_origins=["*"],
32
+ allow_credentials=True,
33
+ allow_methods=["*"],
34
+ allow_headers=["*"],
35
+ )
36
+
37
+ client = DiffWeaveMCPClient()
38
+
39
+
40
+ # ---------------------------------------------------------------------------
41
+ # Request Schemas
42
+ # ---------------------------------------------------------------------------
43
+
44
+ class CreateWorkspaceRequest(BaseModel):
45
+ name: str
46
+ description: Optional[str] = ""
47
+
48
+
49
+ class ReviewProposalRequest(BaseModel):
50
+ decision: str # APPROVED, REJECTED, ARCHIVED
51
+ comments: Optional[str] = None
52
+
53
+
54
+ class BatchReviewRequest(BaseModel):
55
+ decision: str # APPROVED, REJECTED
56
+ proposal_ids: Optional[list[str]] = None
57
+ comments: Optional[str] = None
58
+
59
+
60
+ class CreateRuleRequest(BaseModel):
61
+ name: str
62
+ operator: str
63
+ configuration: dict[str, Any]
64
+
65
+
66
+ # ---------------------------------------------------------------------------
67
+ # Health & MCP Meta
68
+ # ---------------------------------------------------------------------------
69
+
70
+ @app.get("/api/health")
71
+ async def health_check():
72
+ return {"status": "ok", "service": "diffweave-bridge", "mcp_connected": True}
73
+
74
+
75
+ @app.get("/api/mcp/tools")
76
+ async def list_mcp_tools():
77
+ """Discover all MCP tools exposed by the underlying DocWeave server."""
78
+ from mcp_server import list_tools
79
+ tools = await list_tools()
80
+ return [
81
+ {
82
+ "name": t.name,
83
+ "description": t.description,
84
+ "inputSchema": t.inputSchema,
85
+ }
86
+ for t in tools
87
+ ]
88
+
89
+
90
+ # ---------------------------------------------------------------------------
91
+ # Workspaces
92
+ # ---------------------------------------------------------------------------
93
+
94
+ @app.get("/api/workspaces")
95
+ async def get_workspaces():
96
+ try:
97
+ return await client.list_workspaces()
98
+ except Exception as e:
99
+ raise HTTPException(status_code=500, detail=str(e))
100
+
101
+
102
+ @app.post("/api/workspaces")
103
+ async def create_workspace(req: CreateWorkspaceRequest):
104
+ try:
105
+ return await client.create_workspace(name=req.name, description=req.description)
106
+ except Exception as e:
107
+ raise HTTPException(status_code=400, detail=str(e))
108
+
109
+
110
+ @app.get("/api/workspaces/{workspace_id}/status")
111
+ async def get_workspace_status(workspace_id: str):
112
+ try:
113
+ stats = await client.get_dashboard_stats(workspace_id)
114
+ docs = await client.list_documents(workspace_id)
115
+ pending = await client.list_pending_proposals(workspace_id)
116
+ return {
117
+ "workspace_id": workspace_id,
118
+ "stats": stats,
119
+ "documents": docs,
120
+ "pending_proposals": pending,
121
+ }
122
+ except Exception as e:
123
+ raise HTTPException(status_code=500, detail=str(e))
124
+
125
+
126
+ # ---------------------------------------------------------------------------
127
+ # Documents & Ingestion
128
+ # ---------------------------------------------------------------------------
129
+
130
+ @app.get("/api/workspaces/{workspace_id}/documents")
131
+ async def get_documents(workspace_id: str):
132
+ try:
133
+ return await client.list_documents(workspace_id)
134
+ except Exception as e:
135
+ raise HTTPException(status_code=500, detail=str(e))
136
+
137
+
138
+ @app.post("/api/workspaces/{workspace_id}/upload")
139
+ async def upload_document_endpoint(
140
+ workspace_id: str,
141
+ file: UploadFile = File(...),
142
+ ):
143
+ """
144
+ Accepts document file upload from Studio, saves to temporary staging file,
145
+ and dispatches upload_document through DocWeave MCP.
146
+ """
147
+ suffix = Path(file.filename).suffix
148
+ with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as tmp:
149
+ shutil.copyfileobj(file.file, tmp)
150
+ tmp_path = tmp.name
151
+
152
+ try:
153
+ result = await client.upload_document(workspace_id, tmp_path)
154
+ return result
155
+ except Exception as e:
156
+ raise HTTPException(status_code=400, detail=str(e))
157
+ finally:
158
+ try:
159
+ if os.path.exists(tmp_path):
160
+ os.remove(tmp_path)
161
+ except Exception:
162
+ pass
163
+
164
+
165
+ @app.delete("/api/documents/{document_id}")
166
+ async def delete_document_endpoint(document_id: str):
167
+ try:
168
+ return await client.delete_document(document_id)
169
+ except Exception as e:
170
+ raise HTTPException(status_code=400, detail=str(e))
171
+
172
+
173
+ @app.post("/api/documents/{document_id}/retry")
174
+ async def retry_document_endpoint(document_id: str):
175
+ try:
176
+ return await client.retry_document(document_id)
177
+ except Exception as e:
178
+ raise HTTPException(status_code=400, detail=str(e))
179
+
180
+
181
+ # ---------------------------------------------------------------------------
182
+ # Proposals & Review Queue (Knowledge PRs)
183
+ # ---------------------------------------------------------------------------
184
+
185
+ @app.get("/api/workspaces/{workspace_id}/proposals")
186
+ async def get_proposals(
187
+ workspace_id: str,
188
+ document_version_id: Optional[str] = Query(None),
189
+ ):
190
+ try:
191
+ return await client.list_pending_proposals(workspace_id, document_version_id)
192
+ except Exception as e:
193
+ raise HTTPException(status_code=500, detail=str(e))
194
+
195
+
196
+ @app.post("/api/workspaces/{workspace_id}/proposals/{proposal_id}/review")
197
+ async def review_proposal_endpoint(
198
+ workspace_id: str,
199
+ proposal_id: str,
200
+ req: ReviewProposalRequest,
201
+ ):
202
+ decision = req.decision.upper()
203
+ try:
204
+ if decision == "APPROVED":
205
+ return await client.approve_proposal(proposal_id, req.comments)
206
+ elif decision == "REJECTED":
207
+ return await client.reject_proposal(proposal_id, req.comments)
208
+ elif decision in ("ARCHIVED", "STASHED"):
209
+ return await client.archive_proposal(proposal_id, req.comments)
210
+ elif decision == "RESTORE":
211
+ return await client.restore_proposal(proposal_id)
212
+ else:
213
+ raise HTTPException(status_code=400, detail=f"Unsupported decision '{decision}'.")
214
+ except Exception as e:
215
+ raise HTTPException(status_code=400, detail=str(e))
216
+
217
+
218
+ @app.post("/api/workspaces/{workspace_id}/proposals/batch-review")
219
+ async def batch_review_endpoint(
220
+ workspace_id: str,
221
+ req: BatchReviewRequest,
222
+ ):
223
+ try:
224
+ return await client.batch_review_proposals(
225
+ workspace_id=workspace_id,
226
+ decision=req.decision,
227
+ proposal_ids=req.proposal_ids,
228
+ comments=req.comments,
229
+ )
230
+ except Exception as e:
231
+ raise HTTPException(status_code=400, detail=str(e))
232
+
233
+
234
+ # ---------------------------------------------------------------------------
235
+ # Semantic Diff & Policy Validation
236
+ # ---------------------------------------------------------------------------
237
+
238
+ @app.get("/api/workspaces/{workspace_id}/diff")
239
+ async def get_semantic_diff_endpoint(
240
+ workspace_id: str,
241
+ proposal_id: Optional[str] = Query(None),
242
+ document_version_id: Optional[str] = Query(None),
243
+ ):
244
+ try:
245
+ return await client.get_semantic_diff(workspace_id, proposal_id, document_version_id)
246
+ except Exception as e:
247
+ raise HTTPException(status_code=500, detail=str(e))
248
+
249
+
250
+ @app.get("/api/workspaces/{workspace_id}/validate")
251
+ async def get_validation_endpoint(
252
+ workspace_id: str,
253
+ proposal_id: Optional[str] = Query(None),
254
+ ):
255
+ try:
256
+ return await client.validate_proposals(workspace_id, proposal_id)
257
+ except Exception as e:
258
+ raise HTTPException(status_code=500, detail=str(e))
259
+
260
+
261
+ # ---------------------------------------------------------------------------
262
+ # Knowledge Register & Graph
263
+ # ---------------------------------------------------------------------------
264
+
265
+ @app.get("/api/workspaces/{workspace_id}/graph")
266
+ async def get_knowledge_graph_endpoint(workspace_id: str):
267
+ try:
268
+ return await client.get_knowledge_graph(workspace_id)
269
+ except Exception as e:
270
+ raise HTTPException(status_code=500, detail=str(e))
271
+
272
+
273
+ @app.get("/api/workspaces/{workspace_id}/knowledge")
274
+ async def get_knowledge_endpoint(
275
+ workspace_id: str,
276
+ type: Optional[str] = Query(None),
277
+ status: Optional[str] = Query(None),
278
+ ):
279
+ try:
280
+ return await client.list_knowledge(workspace_id, type=type, status=status)
281
+ except Exception as e:
282
+ raise HTTPException(status_code=500, detail=str(e))
283
+
284
+
285
+ @app.get("/api/knowledge/{item_id}")
286
+ async def get_knowledge_item_endpoint(item_id: str):
287
+ try:
288
+ return await client.get_knowledge_item(item_id)
289
+ except Exception as e:
290
+ raise HTTPException(status_code=404, detail=str(e))
291
+
292
+
293
+ @app.get("/api/workspaces/{workspace_id}/search")
294
+ async def search_knowledge_endpoint(
295
+ workspace_id: str,
296
+ q: str = Query(..., description="Search query string"),
297
+ ):
298
+ try:
299
+ return await client.search_knowledge(workspace_id, q)
300
+ except Exception as e:
301
+ raise HTTPException(status_code=500, detail=str(e))
302
+
303
+
304
+ # ---------------------------------------------------------------------------
305
+ # Rules (Policy Linter)
306
+ # ---------------------------------------------------------------------------
307
+
308
+ @app.get("/api/workspaces/{workspace_id}/rules")
309
+ async def get_rules_endpoint(workspace_id: str):
310
+ try:
311
+ return await client.list_rules(workspace_id)
312
+ except Exception as e:
313
+ raise HTTPException(status_code=500, detail=str(e))
314
+
315
+
316
+ @app.post("/api/workspaces/{workspace_id}/rules")
317
+ async def create_rule_endpoint(
318
+ workspace_id: str,
319
+ req: CreateRuleRequest,
320
+ ):
321
+ try:
322
+ return await client.create_rule(
323
+ workspace_id=workspace_id,
324
+ name=req.name,
325
+ operator=req.operator,
326
+ configuration=req.configuration,
327
+ )
328
+ except Exception as e:
329
+ raise HTTPException(status_code=400, detail=str(e))
330
+
331
+
332
+ @app.post("/api/rules/{rule_id}/enable")
333
+ async def enable_rule_endpoint(rule_id: str):
334
+ try:
335
+ return await client.enable_rule(rule_id)
336
+ except Exception as e:
337
+ raise HTTPException(status_code=400, detail=str(e))
338
+
339
+
340
+ @app.post("/api/rules/{rule_id}/disable")
341
+ async def disable_rule_endpoint(rule_id: str):
342
+ try:
343
+ return await client.disable_rule(rule_id)
344
+ except Exception as e:
345
+ raise HTTPException(status_code=400, detail=str(e))
346
+
347
+
348
+ @app.delete("/api/rules/{rule_id}")
349
+ async def delete_rule_endpoint(rule_id: str):
350
+ try:
351
+ return await client.delete_rule(rule_id)
352
+ except Exception as e:
353
+ raise HTTPException(status_code=400, detail=str(e))
354
+
355
+
356
+ # ---------------------------------------------------------------------------
357
+ # Workflows, Metrics & Activity
358
+ # ---------------------------------------------------------------------------
359
+
360
+ @app.get("/api/workspaces/{workspace_id}/workflows")
361
+ async def list_workflows_endpoint(
362
+ workspace_id: str,
363
+ status: Optional[str] = Query(None),
364
+ ):
365
+ try:
366
+ return await client.list_workflows(workspace_id, status)
367
+ except Exception as e:
368
+ raise HTTPException(status_code=500, detail=str(e))
369
+
370
+
371
+ @app.get("/api/workflows/{workflow_id}/status")
372
+ async def get_workflow_status_endpoint(workflow_id: str):
373
+ try:
374
+ return await client.get_workflow_status(workflow_id)
375
+ except Exception as e:
376
+ raise HTTPException(status_code=404, detail=str(e))
377
+
378
+
379
+ @app.get("/api/workflows/{workflow_id}/metrics")
380
+ async def get_run_metrics_endpoint(workflow_id: str):
381
+ try:
382
+ return await client.get_run_metrics(workflow_id)
383
+ except Exception as e:
384
+ raise HTTPException(status_code=500, detail=str(e))
385
+
386
+
387
+ @app.get("/api/workspaces/{workspace_id}/activity")
388
+ async def get_activity_feed_endpoint(
389
+ workspace_id: str,
390
+ limit: int = Query(50),
391
+ ):
392
+ try:
393
+ return await client.get_activity_feed(workspace_id, limit)
394
+ except Exception as e:
395
+ raise HTTPException(status_code=500, detail=str(e))
396
+
397
+
398
+ # ---------------------------------------------------------------------------
399
+ # Static Studio UI Hosting (if built)
400
+ # ---------------------------------------------------------------------------
401
+
402
+ studio_dist_candidates = [
403
+ Path(__file__).parent.parent.parent / "studio" / "dist",
404
+ Path(__file__).parent.parent / "studio" / "dist",
405
+ Path("C:/Users/Adhi/Desktop/DiffWeave/studio/dist"),
406
+ ]
407
+
408
+ for dist_path in studio_dist_candidates:
409
+ if dist_path.exists() and (dist_path / "index.html").exists():
410
+ from fastapi.staticfiles import StaticFiles
411
+ app.mount("/", StaticFiles(directory=str(dist_path), html=True), name="studio_ui")
412
+ break
413
+
414
+
415
+ if __name__ == "__main__":
416
+ import uvicorn
417
+ uvicorn.run("diffweave.bridge.app:app", host="0.0.0.0", port=8000, reload=False)
diffweave/cli/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ """
2
+ DiffWeave CLI package.
3
+ """
diffweave/cli/commands/add_cmd.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw add` command.
3
+ Ingests local documents into DocWeave staging via upload_document.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import os
8
+ from pathlib import Path
9
+ from typing import Optional
10
+ import typer
11
+ from rich.progress import Progress, SpinnerColumn, TextColumn
12
+
13
+ from diffweave.cli.config import get_active_workspace
14
+ from diffweave.cli.output import print_success, print_error, print_info, print_json
15
+ from diffweave.mcp.client import DiffWeaveMCPClient
16
+
17
+
18
+ def add_command(
19
+ file_path: str = typer.Argument(..., help="Path to document file to stage and ingest"),
20
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
21
+ wait: bool = typer.Option(True, "--wait/--no-wait", help="Wait for extraction and proposal workflow to finish"),
22
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
23
+ ):
24
+ """
25
+ Stage and ingest a document into the workspace knowledge pipeline.
26
+ """
27
+ path = Path(file_path).resolve()
28
+ if not path.exists():
29
+ print_error(f"File not found: {file_path}")
30
+ raise typer.Exit(code=1)
31
+
32
+ try:
33
+ active_ws_id = get_active_workspace(workspace_id)
34
+ except Exception as e:
35
+ print_error(str(e))
36
+ raise typer.Exit(code=1)
37
+
38
+ client = DiffWeaveMCPClient()
39
+
40
+ if not as_json:
41
+ print_info(f"Ingesting [bold white]{path.name}[/bold white] into workspace [cyan]{active_ws_id}[/cyan]...")
42
+
43
+ with Progress(
44
+ SpinnerColumn(),
45
+ TextColumn("[progress.description]{task.description}"),
46
+ transient=True,
47
+ ) as progress:
48
+ task = progress.add_task(f"Uploading {path.name} to DocWeave staging...", total=None)
49
+ try:
50
+ result = client.call_tool_sync(
51
+ "upload_document",
52
+ {"workspace_id": active_ws_id, "file_path": str(path)},
53
+ )
54
+ except Exception as e:
55
+ progress.stop()
56
+ print_error(f"Upload failed: {e}")
57
+ raise typer.Exit(code=1)
58
+
59
+ doc_id = result.get("document_id")
60
+ wf_id = result.get("workflow_id")
61
+ version_id = result.get("version_id")
62
+
63
+ if wait and wf_id:
64
+ import time
65
+ with Progress(
66
+ SpinnerColumn(),
67
+ TextColumn("[progress.description]{task.description}"),
68
+ transient=True,
69
+ ) as progress:
70
+ wf_task = progress.add_task("Running extraction, reconciliation & fact proposals...", total=None)
71
+ for _ in range(60): # Wait up to 120s
72
+ time.sleep(2)
73
+ try:
74
+ wf_status = client.call_tool_sync("get_workflow_status", {"workflow_id": wf_id})
75
+ curr_state = wf_status.get("status")
76
+ if curr_state in ("WAITING_FOR_REVIEW", "COMPLETED", "FAILED"):
77
+ break
78
+ except Exception:
79
+ pass
80
+
81
+ if as_json:
82
+ print_json(result)
83
+ return
84
+
85
+ print_success(f"Document [bold]{path.name}[/bold] staged successfully!")
86
+ print_info(f" Document ID: [dim]{doc_id}[/dim]")
87
+ print_info(f" Version ID: [dim]{version_id}[/dim]")
88
+ print_info(f" Workflow ID: [cyan]{wf_id}[/cyan]")
89
+
90
+ # Check workflow final status
91
+ try:
92
+ wf_status = client.call_tool_sync("get_workflow_status", {"workflow_id": wf_id})
93
+ status_val = wf_status.get("status", "RUNNING")
94
+ if status_val == "WAITING_FOR_REVIEW":
95
+ print_info(f" Workflow State: [bold yellow]WAITING FOR REVIEW[/bold yellow] (Run 'dw diff' or 'dw review' to inspect)")
96
+ elif status_val == "COMPLETED":
97
+ print_success(f" Workflow State: [bold green]COMPLETED[/bold green] (Knowledge items auto-approved)")
98
+ elif status_val == "FAILED":
99
+ print_error(f" Workflow State: [bold red]FAILED[/bold red] - {wf_status.get('error_message', 'Unknown error')}")
100
+ else:
101
+ print_info(f" Workflow State: [bold cyan]{status_val}[/bold cyan] (Run 'dw status' to track)")
102
+ except Exception:
103
+ pass
diffweave/cli/commands/commit_cmd.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw commit` command.
3
+ Commits approved knowledge proposals into the active Knowledge Register.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.prompt import Confirm
10
+
11
+ from diffweave.cli.config import get_active_workspace
12
+ from diffweave.cli.output import print_success, print_error, print_info, print_json
13
+ from diffweave.mcp.client import DiffWeaveMCPClient
14
+
15
+
16
+ def commit_command(
17
+ proposal_id: Optional[str] = typer.Option(None, "--proposal", "-p", help="Specific proposal UUID to commit"),
18
+ all_approved: bool = typer.Option(False, "--all-approved", "-a", help="Commit all pending proposals in workspace"),
19
+ message: Optional[str] = typer.Option(None, "--message", "-m", help="Commit audit message"),
20
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
21
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
22
+ ):
23
+ """
24
+ Commit approved knowledge proposals to Master Knowledge Truth.
25
+ """
26
+ try:
27
+ active_ws_id = get_active_workspace(workspace_id)
28
+ except Exception as e:
29
+ print_error(str(e))
30
+ raise typer.Exit(code=1)
31
+
32
+ client = DiffWeaveMCPClient()
33
+
34
+ if not proposal_id and not all_approved:
35
+ print_error("Please specify a proposal to commit via '--proposal <id>' or use '--all-approved'.")
36
+ raise typer.Exit(code=1)
37
+
38
+ if proposal_id:
39
+ try:
40
+ res = client.call_tool_sync("approve_proposal", {"proposal_id": proposal_id, "comments": message})
41
+ if as_json:
42
+ print_json(res)
43
+ else:
44
+ print_success(
45
+ f"Committed proposal [bold]{proposal_id}[/bold] into Knowledge Register!\n"
46
+ f"Commit ID: [cyan]{res.get('commit_id')}[/cyan]\n"
47
+ f"Committed at: [dim]{res.get('committed_at')}[/dim]"
48
+ )
49
+ except Exception as e:
50
+ print_error(f"Commit failed: {e}")
51
+ raise typer.Exit(code=1)
52
+
53
+ elif all_approved:
54
+ # Prompt for confirmation if not in JSON mode
55
+ if not as_json:
56
+ proceed = Confirm.ask(f"Are you sure you want to batch commit all pending proposals in workspace {active_ws_id}?")
57
+ if not proceed:
58
+ print_info("Commit cancelled.")
59
+ return
60
+
61
+ try:
62
+ res = client.call_tool_sync(
63
+ "batch_review_proposals",
64
+ {
65
+ "workspace_id": active_ws_id,
66
+ "decision": "APPROVED",
67
+ "comments": message or "Batch approved via dw commit --all-approved",
68
+ },
69
+ )
70
+ if as_json:
71
+ print_json(res)
72
+ else:
73
+ count = res.get("processed_count", 0)
74
+ print_success(f"Successfully committed {count} proposals to the Knowledge Register.")
75
+ except Exception as e:
76
+ print_error(f"Batch commit failed: {e}")
77
+ raise typer.Exit(code=1)
diffweave/cli/commands/diff_cmd.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw diff` command.
3
+ Semantic Knowledge Diff comparing proposed document claims against committed truth.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+
10
+ from diffweave.cli.config import get_active_workspace
11
+ from diffweave.cli.output import render_diff, print_error, print_json
12
+ from diffweave.mcp.client import DiffWeaveMCPClient
13
+
14
+
15
+ def diff_command(
16
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
17
+ proposal_id: Optional[str] = typer.Option(None, "--proposal", "-p", help="Diff a specific proposal only"),
18
+ document_id: Optional[str] = typer.Option(None, "--document", "-d", help="Filter diff to proposals from document"),
19
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
20
+ ):
21
+ """
22
+ Inspect semantic differences, updates, and contradictions between documents and baseline knowledge.
23
+ """
24
+ try:
25
+ active_ws_id = get_active_workspace(workspace_id)
26
+ except Exception as e:
27
+ print_error(str(e))
28
+ raise typer.Exit(code=1)
29
+
30
+ client = DiffWeaveMCPClient()
31
+
32
+ try:
33
+ diff_data = client.call_tool_sync(
34
+ "get_semantic_diff",
35
+ {
36
+ "workspace_id": active_ws_id,
37
+ "proposal_id": proposal_id,
38
+ "document_version_id": document_id,
39
+ },
40
+ )
41
+ except Exception as e:
42
+ print_error(f"Failed to generate semantic diff: {e}")
43
+ raise typer.Exit(code=1)
44
+
45
+ if as_json:
46
+ print_json(diff_data)
47
+ else:
48
+ render_diff(diff_data)
diffweave/cli/commands/doctor_cmd.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw doctor` command.
3
+ Performs system health checks, MCP discovery, and environment diagnostics.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import sys
8
+ from pathlib import Path
9
+ import typer
10
+ from rich.table import Table
11
+ from rich.panel import Panel
12
+
13
+ from diffweave.cli.config import load_config, get_config_path
14
+ from diffweave.cli.output import print_success, print_error, print_warning, print_json, console
15
+ from diffweave.mcp.client import DiffWeaveMCPClient
16
+
17
+ REQUIRED_TOOLS = [
18
+ "list_workspaces",
19
+ "create_workspace",
20
+ "upload_document",
21
+ "list_documents",
22
+ "get_workflow_status",
23
+ "list_workflows",
24
+ "list_pending_proposals",
25
+ "approve_proposal",
26
+ "reject_proposal",
27
+ "archive_proposal",
28
+ "restore_proposal",
29
+ "batch_review_proposals",
30
+ "get_semantic_diff",
31
+ "validate_proposals",
32
+ "get_knowledge_graph",
33
+ "list_knowledge",
34
+ "get_knowledge_item",
35
+ "search_knowledge",
36
+ "list_rules",
37
+ "create_rule",
38
+ "enable_rule",
39
+ "disable_rule",
40
+ "delete_rule",
41
+ "get_dashboard_stats",
42
+ "get_activity_feed",
43
+ ]
44
+
45
+
46
+ def doctor_command(
47
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
48
+ ):
49
+ """
50
+ Run diagnostic checks on DiffWeave environment, MCP server, and workspace.
51
+ """
52
+ checks = []
53
+
54
+ # 1. Configuration check
55
+ config = load_config()
56
+ cfg_path = get_config_path()
57
+ if config and config.get("workspace_id"):
58
+ checks.append({
59
+ "check": "Local Workspace Configuration (.diffweave)",
60
+ "status": "PASS",
61
+ "details": f"Bound to '{config.get('workspace_name')}' ({config.get('workspace_id')[:8]}...)",
62
+ })
63
+ else:
64
+ checks.append({
65
+ "check": "Local Workspace Configuration (.diffweave)",
66
+ "status": "WARN",
67
+ "details": "No local workspace initialized. Run 'dw init' to bind one.",
68
+ })
69
+
70
+ # 2. MCP Server Connectivity
71
+ client = DiffWeaveMCPClient()
72
+ tools = []
73
+ try:
74
+ backend_str = str(client.backend_dir)
75
+ if backend_str not in sys.path:
76
+ sys.path.insert(0, backend_str)
77
+ from mcp_server import list_tools
78
+ import asyncio
79
+ discovered_tools = asyncio.run(list_tools())
80
+ tools = [t.name for t in discovered_tools]
81
+ checks.append({
82
+ "check": "DocWeave MCP Server Connectivity",
83
+ "status": "PASS",
84
+ "details": f"Successfully connected. Found {len(tools)} tools registered.",
85
+ })
86
+ except Exception as e:
87
+ checks.append({
88
+ "check": "DocWeave MCP Server Connectivity",
89
+ "status": "FAIL",
90
+ "details": f"Failed to connect or import server: {e}",
91
+ })
92
+
93
+ # 3. Tool coverage check
94
+ if tools:
95
+ missing = [t for t in REQUIRED_TOOLS if t not in tools]
96
+ if not missing:
97
+ checks.append({
98
+ "check": "Required MCP Tools Coverage",
99
+ "status": "PASS",
100
+ "details": f"All {len(REQUIRED_TOOLS)} core DiffWeave operations are available.",
101
+ })
102
+ else:
103
+ checks.append({
104
+ "check": "Required MCP Tools Coverage",
105
+ "status": "FAIL",
106
+ "details": f"Missing tools: {', '.join(missing)}",
107
+ })
108
+
109
+ # 4. Workspace API / Database check
110
+ if config.get("workspace_id") and tools:
111
+ try:
112
+ stats = client.call_tool_sync("get_dashboard_stats", {"workspace_id": config.get("workspace_id")})
113
+ checks.append({
114
+ "check": "Workspace State & Database Verification",
115
+ "status": "PASS",
116
+ "details": f"Workspace verified. Documents: {stats.get('total_documents')}, Knowledge: {stats.get('knowledge_items')}",
117
+ })
118
+ except Exception as e:
119
+ checks.append({
120
+ "check": "Workspace State & Database Verification",
121
+ "status": "FAIL",
122
+ "details": f"Failed to query workspace state: {e}",
123
+ })
124
+
125
+ all_passed = all(c["status"] == "PASS" for c in checks)
126
+
127
+ if as_json:
128
+ print_json({"healthy": all_passed, "checks": checks})
129
+ return
130
+
131
+ table = Table(title="DiffWeave Doctor Diagnostic Report", header_style="bold blue")
132
+ table.add_column("System Subsystem", style="bold white")
133
+ table.add_column("Status", style="bold")
134
+ table.add_column("Details", style="white")
135
+
136
+ for c in checks:
137
+ st = c["status"]
138
+ if st == "PASS":
139
+ st_text = "[green][PASS][/green]"
140
+ elif st == "WARN":
141
+ st_text = "[yellow][WARN][/yellow]"
142
+ else:
143
+ st_text = "[bold red][FAIL][/bold red]"
144
+ table.add_row(c["check"], st_text, c["details"])
145
+
146
+ console.print(table)
147
+ if all_passed:
148
+ console.print("\n[bold green][OK] All systems nominal. DiffWeave is fully operational![/bold green]")
149
+ else:
150
+ console.print("\n[bold yellow][!] Some checks require attention. See details above.[/bold yellow]")
diffweave/cli/commands/init_cmd.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw init` command.
3
+ Initializes a local DiffWeave workspace in the current directory.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from pathlib import Path
8
+ from typing import Optional
9
+ import typer
10
+ from rich.prompt import Prompt
11
+
12
+ from diffweave.cli.config import save_config, load_config
13
+ from diffweave.cli.output import print_success, print_info, print_error, print_json
14
+ from diffweave.mcp.client import DiffWeaveMCPClient
15
+
16
+
17
+ def init_command(
18
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID to bind to"),
19
+ create: Optional[str] = typer.Option(None, "--create", "-c", help="Create a new workspace with this name"),
20
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
21
+ ):
22
+ """
23
+ Initialize a DiffWeave workspace in the current directory (.diffweave/).
24
+ """
25
+ client = DiffWeaveMCPClient()
26
+
27
+ try:
28
+ # Check MCP server availability
29
+ workspaces = client.call_tool_sync("list_workspaces")
30
+ except Exception as e:
31
+ print_error(f"Cannot connect to DocWeave MCP server: {e}", code="MCP_CONNECT_FAIL")
32
+ raise typer.Exit(code=1)
33
+
34
+ target_ws = None
35
+
36
+ if create:
37
+ try:
38
+ target_ws = client.call_tool_sync("create_workspace", {"name": create.strip()})
39
+ print_success(f"Created new DocWeave workspace: [bold]{target_ws['name']}[/bold] ({target_ws['id']})")
40
+ except Exception as e:
41
+ print_error(f"Failed to create workspace: {e}")
42
+ raise typer.Exit(code=1)
43
+
44
+ elif workspace_id:
45
+ target_ws = next((w for w in workspaces if w["id"] == workspace_id.strip()), None)
46
+ if not target_ws:
47
+ print_error(f"Workspace with ID '{workspace_id}' not found in DocWeave.")
48
+ raise typer.Exit(code=1)
49
+
50
+ elif workspaces:
51
+ # If running interactively, prompt user or pick first
52
+ if len(workspaces) == 1:
53
+ target_ws = workspaces[0]
54
+ else:
55
+ print_info("Multiple workspaces found:")
56
+ for idx, w in enumerate(workspaces, 1):
57
+ print_info(f" [{idx}] {w['name']} ({w['id']})")
58
+ choice = Prompt.ask("Select workspace index", default="1")
59
+ try:
60
+ target_ws = workspaces[int(choice) - 1]
61
+ except Exception:
62
+ target_ws = workspaces[0]
63
+ else:
64
+ # Auto-create default
65
+ try:
66
+ target_ws = client.call_tool_sync("create_workspace", {"name": "Default Workspace"})
67
+ except Exception as e:
68
+ print_error(f"No workspaces exist and failed to create one: {e}")
69
+ raise typer.Exit(code=1)
70
+
71
+ # Save to local .diffweave/config.json
72
+ config_data = {
73
+ "workspace_id": target_ws["id"],
74
+ "workspace_name": target_ws["name"],
75
+ "mcp_server": "docweave",
76
+ }
77
+ cfg_path = save_config(config_data)
78
+
79
+ if as_json:
80
+ print_json({"initialized": True, "config_path": str(cfg_path), **config_data})
81
+ else:
82
+ print_success(
83
+ f"Initialized DiffWeave workspace in [bold]{Path.cwd() / '.diffweave'}[/bold]\n"
84
+ f"Bound to: [cyan]{target_ws['name']}[/cyan] ({target_ws['id']})"
85
+ )
diffweave/cli/commands/log_cmd.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw log` command.
3
+ Chronological knowledge audit history and telemetry timeline.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.table import Table
10
+
11
+ from diffweave.cli.config import get_active_workspace
12
+ from diffweave.cli.output import print_error, print_json, console
13
+ from diffweave.mcp.client import DiffWeaveMCPClient
14
+
15
+
16
+ def log_command(
17
+ limit: int = typer.Option(20, "--limit", "-n", help="Number of history events to display"),
18
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
19
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
20
+ ):
21
+ """
22
+ View chronological knowledge audit log (commits, reviews, workflows).
23
+ """
24
+ try:
25
+ active_ws_id = get_active_workspace(workspace_id)
26
+ except Exception as e:
27
+ print_error(str(e))
28
+ raise typer.Exit(code=1)
29
+
30
+ client = DiffWeaveMCPClient()
31
+
32
+ try:
33
+ feed = client.call_tool_sync("get_activity_feed", {"workspace_id": active_ws_id, "limit": limit})
34
+ except Exception as e:
35
+ print_error(f"Failed to fetch activity log: {e}")
36
+ raise typer.Exit(code=1)
37
+
38
+ if as_json:
39
+ print_json(feed)
40
+ return
41
+
42
+ events = feed.get("events", [])
43
+ if not events:
44
+ console.print("[dim]No activity events recorded in this workspace yet.[/dim]")
45
+ return
46
+
47
+ table = Table(title=f"Knowledge Audit History (Last {len(events)} events)", header_style="bold blue")
48
+ table.add_column("Timestamp", style="dim")
49
+ table.add_column("Event Type", style="cyan")
50
+ table.add_column("Details", style="white")
51
+
52
+ for ev in events:
53
+ ev_type = ev.get("type", "event")
54
+ if "approved" in ev_type or "completed" in ev_type:
55
+ badge = f"[green]{ev_type}[/green]"
56
+ elif "rejected" in ev_type:
57
+ badge = f"[red]{ev_type}[/red]"
58
+ elif "archived" in ev_type:
59
+ badge = f"[yellow]{ev_type}[/yellow]"
60
+ else:
61
+ badge = f"[cyan]{ev_type}[/cyan]"
62
+
63
+ table.add_row(
64
+ str(ev.get("timestamp", ""))[:19],
65
+ badge,
66
+ ev.get("message", ""),
67
+ )
68
+
69
+ console.print(table)
diffweave/cli/commands/proposals_cmd.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw proposals` command.
3
+ Inspects knowledge proposals (Knowledge PRs) awaiting human review or committed.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.panel import Panel
10
+ from rich.table import Table
11
+
12
+ from diffweave.cli.config import get_active_workspace
13
+ from diffweave.cli.output import print_error, print_json, console
14
+ from diffweave.mcp.client import DiffWeaveMCPClient
15
+
16
+
17
+ def proposals_command(
18
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
19
+ proposal_id: Optional[str] = typer.Option(None, "--id", help="Inspect a specific proposal by UUID"),
20
+ prop_type: Optional[str] = typer.Option(None, "--type", "-t", help="Filter by proposal type (CREATE, UPDATE, DELETE)"),
21
+ status: Optional[str] = typer.Option("PENDING", "--status", "-s", help="Filter by proposal status (PENDING, APPROVED, REJECTED, ARCHIVED)"),
22
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
23
+ ):
24
+ """
25
+ List and inspect extracted knowledge proposals awaiting governance decisions.
26
+ """
27
+ try:
28
+ active_ws_id = get_active_workspace(workspace_id)
29
+ except Exception as e:
30
+ print_error(str(e))
31
+ raise typer.Exit(code=1)
32
+
33
+ client = DiffWeaveMCPClient()
34
+
35
+ try:
36
+ proposals = client.call_tool_sync("list_pending_proposals", {"workspace_id": active_ws_id})
37
+ except Exception as e:
38
+ print_error(f"Failed to fetch proposals: {e}")
39
+ raise typer.Exit(code=1)
40
+
41
+ # Filter by ID if specified
42
+ if proposal_id:
43
+ proposals = [p for p in proposals if str(p.get("proposal_id", "")).startswith(proposal_id.strip())]
44
+ if not proposals:
45
+ print_error(f"Proposal matching '{proposal_id}' not found.")
46
+ raise typer.Exit(code=1)
47
+
48
+ # Filter by type
49
+ if prop_type:
50
+ proposals = [p for p in proposals if p.get("proposal_type", "").upper() == prop_type.strip().upper()]
51
+
52
+ if as_json:
53
+ print_json(proposals)
54
+ return
55
+
56
+ if not proposals:
57
+ console.print(f"[dim]No proposals found matching criteria in workspace {active_ws_id}.[/dim]")
58
+ return
59
+
60
+ if proposal_id and len(proposals) == 1:
61
+ # Detailed single proposal view
62
+ p = proposals[0]
63
+ pc = p.get("proposed_changes", {})
64
+ evidence_list = pc.get("evidence", [])
65
+ evidence_quote = evidence_list[0].get("quote", "None cited") if evidence_list else "None cited"
66
+ page = evidence_list[0].get("page_number", "N/A") if evidence_list else "N/A"
67
+
68
+ body = (
69
+ f"[bold white]ID:[/bold white] {p.get('proposal_id')}\n"
70
+ f"[bold white]Type:[/bold white] [cyan]{p.get('proposal_type')}[/cyan]\n"
71
+ f"[bold white]Status:[/bold white] [bold yellow]{p.get('status')}[/bold yellow]\n"
72
+ f"[bold white]Summary:[/bold white] {p.get('summary')}\n"
73
+ f"[bold white]Rationale:[/bold white] {p.get('rationale') or 'N/A'}\n\n"
74
+ f"[bold white]Proposed Changes:[/bold white]\n"
75
+ f" Value: \"{pc.get('value') or pc.get('proposed', {}).get('value', 'N/A')}\"\n"
76
+ f" Confidence: {pc.get('confidence') or pc.get('proposed', {}).get('confidence', 1.0)}\n\n"
77
+ f"[bold white]Verbatim Evidence Citation (Page {page}):[/bold white]\n"
78
+ f" [italic cyan]\"{evidence_quote}\"[/italic cyan]"
79
+ )
80
+ console.print(Panel(body, title=f"[bold]Knowledge Proposal Details[/bold]", border_style="cyan"))
81
+ return
82
+
83
+ # Table view
84
+ table = Table(title=f"Knowledge Proposals ({len(proposals)} items)", header_style="bold magenta")
85
+ table.add_column("PR ID", style="bold yellow")
86
+ table.add_column("Type", style="cyan")
87
+ table.add_column("Summary", style="white")
88
+ table.add_column("Status", style="yellow")
89
+ table.add_column("Created", style="dim")
90
+
91
+ for p in proposals:
92
+ table.add_row(
93
+ p.get("proposal_id", "")[:8],
94
+ p.get("proposal_type", "CLAIM"),
95
+ p.get("summary", ""),
96
+ p.get("status", "PENDING"),
97
+ str(p.get("created_at", ""))[:19],
98
+ )
99
+ console.print(table)
100
+ console.print("[dim]Run 'dw proposals --id <id>' for full evidence citation.[/dim]")
diffweave/cli/commands/review_cmd.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw review` command.
3
+ Interactive Human Review Wizard for knowledge proposals.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.prompt import Prompt
10
+ from rich.panel import Panel
11
+
12
+ from diffweave.cli.config import get_active_workspace
13
+ from diffweave.cli.output import print_success, print_error, print_info, console
14
+ from diffweave.mcp.client import DiffWeaveMCPClient
15
+
16
+
17
+ def review_command(
18
+ proposal_id: Optional[str] = typer.Option(None, "--proposal", "-p", help="Target specific proposal UUID"),
19
+ action: Optional[str] = typer.Option(None, "--action", "-a", help="Direct action: approve, reject, archive"),
20
+ comments: Optional[str] = typer.Option(None, "--comments", "-m", help="Review comments / commit note"),
21
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
22
+ interactive: bool = typer.Option(True, "--interactive/--no-interactive", help="Enable interactive wizard"),
23
+ ):
24
+ """
25
+ Review pending knowledge proposals (Approve into truth, Reject, or Stash).
26
+ """
27
+ try:
28
+ active_ws_id = get_active_workspace(workspace_id)
29
+ except Exception as e:
30
+ print_error(str(e))
31
+ raise typer.Exit(code=1)
32
+
33
+ client = DiffWeaveMCPClient()
34
+
35
+ # Direct non-interactive action
36
+ if proposal_id and action:
37
+ act = action.strip().lower()
38
+ try:
39
+ if act == "approve":
40
+ res = client.call_tool_sync("approve_proposal", {"proposal_id": proposal_id, "comments": comments})
41
+ print_success(f"Proposal [bold]{proposal_id}[/bold] APPROVED. Commit ID: [cyan]{res.get('commit_id')}[/cyan]")
42
+ elif act == "reject":
43
+ res = client.call_tool_sync("reject_proposal", {"proposal_id": proposal_id, "comments": comments})
44
+ print_info(f"Proposal [bold]{proposal_id}[/bold] REJECTED. (No commit created)")
45
+ elif act in ("archive", "stash"):
46
+ res = client.call_tool_sync("archive_proposal", {"proposal_id": proposal_id, "comments": comments})
47
+ print_info(f"Proposal [bold]{proposal_id}[/bold] ARCHIVED / STASHED for later review.")
48
+ else:
49
+ print_error(f"Unknown action '{action}'. Use approve, reject, or archive.")
50
+ raise typer.Exit(code=1)
51
+ return
52
+ except Exception as e:
53
+ print_error(f"Review action failed: {e}")
54
+ raise typer.Exit(code=1)
55
+
56
+ # Fetch pending proposals
57
+ try:
58
+ pending = client.call_tool_sync("list_pending_proposals", {"workspace_id": active_ws_id})
59
+ except Exception as e:
60
+ print_error(f"Failed to fetch proposals: {e}")
61
+ raise typer.Exit(code=1)
62
+
63
+ if proposal_id:
64
+ pending = [p for p in pending if str(p.get("proposal_id", "")).startswith(proposal_id.strip())]
65
+
66
+ if not pending:
67
+ print_success("Review queue is clean! No pending proposals awaiting review.")
68
+ return
69
+
70
+ console.print(f"[bold cyan]DiffWeave Review Wizard[/bold cyan] ({len(pending)} pending proposals)\n")
71
+
72
+ for idx, p in enumerate(pending, 1):
73
+ pid = p.get("proposal_id")
74
+ pc = p.get("proposed_changes", {})
75
+ evidence_list = pc.get("evidence", [])
76
+ evidence_quote = evidence_list[0].get("quote", "None cited") if evidence_list else "None cited"
77
+ page = evidence_list[0].get("page_number", "N/A") if evidence_list else "N/A"
78
+ prop_val = pc.get("value") or pc.get("proposed", {}).get("value", "N/A")
79
+
80
+ body = (
81
+ f"[bold white]Summary:[/bold white] {p.get('summary')}\n"
82
+ f"[bold white]Type:[/bold white] [cyan]{p.get('proposal_type')}[/cyan] | "
83
+ f"[bold white]Confidence:[/bold white] {pc.get('confidence') or pc.get('proposed', {}).get('confidence', 1.0)}\n"
84
+ f"[bold white]Proposed Value:[/bold white] \"{prop_val}\"\n"
85
+ f"[bold white]Verbatim Evidence (Page {page}):[/bold white]\n"
86
+ f" [italic cyan]\"{evidence_quote}\"[/italic cyan]"
87
+ )
88
+ console.print(Panel(body, title=f"Review [{idx}/{len(pending)}] — PR {pid[:8]}", border_style="cyan"))
89
+
90
+ choice = Prompt.ask(
91
+ "Decision",
92
+ choices=["a", "r", "s", "q", "skip"],
93
+ default="a",
94
+ show_choices=False,
95
+ show_default=False,
96
+ )
97
+
98
+ if choice in ("q", "quit"):
99
+ console.print("[dim]Review session stopped.[/dim]")
100
+ break
101
+ elif choice in ("skip", "s"):
102
+ if choice == "s":
103
+ client.call_tool_sync("archive_proposal", {"proposal_id": pid})
104
+ print_info(f"PR {pid[:8]} stashed/archived.")
105
+ continue
106
+ elif choice == "a":
107
+ note = Prompt.ask("Commit message / comment (optional)", default="")
108
+ try:
109
+ res = client.call_tool_sync("approve_proposal", {"proposal_id": pid, "comments": note or None})
110
+ print_success(f"PR {pid[:8]} APPROVED. Commit ID: [cyan]{res.get('commit_id')}[/cyan]\n")
111
+ except Exception as e:
112
+ print_error(f"Approval failed: {e}\n")
113
+ elif choice == "r":
114
+ reason = Prompt.ask("Rejection reason (optional)", default="")
115
+ try:
116
+ client.call_tool_sync("reject_proposal", {"proposal_id": pid, "comments": reason or None})
117
+ print_info(f"PR {pid[:8]} REJECTED.\n")
118
+ except Exception as e:
119
+ print_error(f"Rejection failed: {e}\n")
diffweave/cli/commands/rules_cmd.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw rules` subcommands.
3
+ Manages dynamic validation policy rules (linter rules) on the workspace.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import json
8
+ from typing import Optional
9
+ import typer
10
+ from rich.table import Table
11
+
12
+ from diffweave.cli.config import get_active_workspace
13
+ from diffweave.cli.output import print_success, print_error, print_info, print_json, console
14
+ from diffweave.mcp.client import DiffWeaveMCPClient
15
+
16
+ rules_app = typer.Typer(name="rules", help="Manage validation policy rules for workspace.")
17
+
18
+
19
+ @rules_app.command("list")
20
+ def list_rules_cmd(
21
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
22
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
23
+ ):
24
+ """List all validation policy rules configured for the workspace."""
25
+ try:
26
+ active_ws_id = get_active_workspace(workspace_id)
27
+ except Exception as e:
28
+ print_error(str(e))
29
+ raise typer.Exit(code=1)
30
+
31
+ client = DiffWeaveMCPClient()
32
+ try:
33
+ rules = client.call_tool_sync("list_rules", {"workspace_id": active_ws_id})
34
+ except Exception as e:
35
+ print_error(f"Failed to list rules: {e}")
36
+ raise typer.Exit(code=1)
37
+
38
+ if as_json:
39
+ print_json(rules)
40
+ return
41
+
42
+ if not rules:
43
+ console.print("[dim]No policy rules configured. Use 'dw rules add' to create one.[/dim]")
44
+ return
45
+
46
+ table = Table(title="Workspace Policy Rules", header_style="bold cyan")
47
+ table.add_column("Rule ID", style="dim")
48
+ table.add_column("Name", style="bold white")
49
+ table.add_column("Operator", style="cyan")
50
+ table.add_column("Status", style="bold")
51
+ table.add_column("Configuration", style="dim")
52
+
53
+ for r in rules:
54
+ status_styled = "[green]ENABLED[/green]" if r.get("enabled") else "[yellow]DISABLED[/yellow]"
55
+ table.add_row(
56
+ r.get("id", "")[:8],
57
+ r.get("name", "Unnamed"),
58
+ r.get("operator") or "n/a",
59
+ status_styled,
60
+ json.dumps(r.get("configuration") or {}),
61
+ )
62
+
63
+ console.print(table)
64
+
65
+
66
+ @rules_app.command("enable")
67
+ def enable_rule_cmd(rule_id: str = typer.Argument(..., help="Rule UUID to enable")):
68
+ """Enable a validation rule."""
69
+ client = DiffWeaveMCPClient()
70
+ try:
71
+ res = client.call_tool_sync("enable_rule", {"rule_id": rule_id})
72
+ print_success(f"Rule '{res.get('name')}' ({rule_id[:8]}) is now ENABLED.")
73
+ except Exception as e:
74
+ print_error(f"Failed to enable rule: {e}")
75
+ raise typer.Exit(code=1)
76
+
77
+
78
+ @rules_app.command("disable")
79
+ def disable_rule_cmd(rule_id: str = typer.Argument(..., help="Rule UUID to disable")):
80
+ """Disable a validation rule without deleting it."""
81
+ client = DiffWeaveMCPClient()
82
+ try:
83
+ res = client.call_tool_sync("disable_rule", {"rule_id": rule_id})
84
+ print_info(f"Rule '{res.get('name')}' ({rule_id[:8]}) is now DISABLED.")
85
+ except Exception as e:
86
+ print_error(f"Failed to disable rule: {e}")
87
+ raise typer.Exit(code=1)
88
+
89
+
90
+ @rules_app.command("add")
91
+ def add_rule_cmd(
92
+ name: str = typer.Argument(..., help="Human-readable rule name"),
93
+ operator: str = typer.Option("min_confidence", "--operator", "-o", help="Rule operator: min_confidence, required_evidence, allowed_proposal_types"),
94
+ threshold: float = typer.Option(0.85, "--threshold", "-t", help="Threshold for min_confidence operator"),
95
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
96
+ ):
97
+ """Add a new validation rule to the workspace."""
98
+ try:
99
+ active_ws_id = get_active_workspace(workspace_id)
100
+ except Exception as e:
101
+ print_error(str(e))
102
+ raise typer.Exit(code=1)
103
+
104
+ client = DiffWeaveMCPClient()
105
+ config = {}
106
+ if operator == "min_confidence":
107
+ config = {"value": threshold}
108
+ elif operator == "allowed_proposal_types":
109
+ config = {"values": ["CREATE", "UPDATE"]}
110
+
111
+ try:
112
+ res = client.call_tool_sync(
113
+ "create_rule",
114
+ {
115
+ "workspace_id": active_ws_id,
116
+ "name": name,
117
+ "operator": operator,
118
+ "configuration": config,
119
+ },
120
+ )
121
+ print_success(f"Created rule [bold]{res.get('name')}[/bold] (ID: {res.get('id')[:8]})")
122
+ except Exception as e:
123
+ print_error(f"Failed to create rule: {e}")
124
+ raise typer.Exit(code=1)
diffweave/cli/commands/search_cmd.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw search` command.
3
+ Queries DocWeave's hybrid search engine over committed knowledge.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.table import Table
10
+
11
+ from diffweave.cli.config import get_active_workspace
12
+ from diffweave.cli.output import print_error, print_json, console
13
+ from diffweave.mcp.client import DiffWeaveMCPClient
14
+
15
+
16
+ def search_command(
17
+ query: str = typer.Argument(..., help="Search text query across knowledge items"),
18
+ top_k: int = typer.Option(10, "--top-k", "-k", help="Maximum results to return"),
19
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
20
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
21
+ ):
22
+ """
23
+ Search the Knowledge Register using hybrid lexical + semantic search.
24
+ """
25
+ try:
26
+ active_ws_id = get_active_workspace(workspace_id)
27
+ except Exception as e:
28
+ print_error(str(e))
29
+ raise typer.Exit(code=1)
30
+
31
+ client = DiffWeaveMCPClient()
32
+
33
+ try:
34
+ results = client.call_tool_sync("search_knowledge", {"workspace_id": active_ws_id, "query": query})
35
+ except Exception as e:
36
+ print_error(f"Search failed: {e}")
37
+ raise typer.Exit(code=1)
38
+
39
+ results = results[:top_k]
40
+
41
+ if as_json:
42
+ print_json(results)
43
+ return
44
+
45
+ if not results:
46
+ console.print(f"[dim]No matching knowledge items found for '{query}'.[/dim]")
47
+ return
48
+
49
+ table = Table(title=f"Knowledge Search: \"{query}\" ({len(results)} matches)", header_style="bold green")
50
+ table.add_column("Type", style="cyan")
51
+ table.add_column("Title", style="bold white")
52
+ table.add_column("Value", style="white")
53
+ table.add_column("Confidence", style="yellow")
54
+ table.add_column("Source File", style="dim")
55
+
56
+ for r in results:
57
+ table.add_row(
58
+ r.get("type", "CLAIM"),
59
+ r.get("title", ""),
60
+ r.get("value", "")[:50] + ("..." if len(r.get("value", "")) > 50 else ""),
61
+ str(r.get("confidence", 1.0)),
62
+ r.get("filename") or "n/a",
63
+ )
64
+
65
+ console.print(table)
diffweave/cli/commands/status_cmd.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw status` command.
3
+ Displays workspace context, document inventory, workflows, and pending knowledge PRs.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import time
8
+ from typing import Optional
9
+ import typer
10
+
11
+ from diffweave.cli.config import get_active_workspace, load_config
12
+ from diffweave.cli.output import render_status, print_error, print_json, console
13
+ from diffweave.mcp.client import DiffWeaveMCPClient
14
+
15
+
16
+ def status_command(
17
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
18
+ watch: bool = typer.Option(False, "--watch", help="Continuously refresh status (watch mode)"),
19
+ interval: int = typer.Option(3, "--interval", "-i", help="Watch refresh interval in seconds"),
20
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
21
+ ):
22
+ """
23
+ Show workspace knowledge staging, active workflows, and review status.
24
+ """
25
+ try:
26
+ active_ws_id = get_active_workspace(workspace_id)
27
+ except Exception as e:
28
+ print_error(str(e))
29
+ raise typer.Exit(code=1)
30
+
31
+ client = DiffWeaveMCPClient()
32
+ config = load_config()
33
+ ws_name = config.get("workspace_name", "DocWeave Workspace")
34
+
35
+ def _fetch_and_render():
36
+ # Fetch status data from DocWeave MCP
37
+ docs = client.call_tool_sync("list_documents", {"workspace_id": active_ws_id})
38
+ stats = client.call_tool_sync("get_dashboard_stats", {"workspace_id": active_ws_id})
39
+ pending = client.call_tool_sync("list_pending_proposals", {"workspace_id": active_ws_id})
40
+
41
+ if as_json:
42
+ print_json({
43
+ "workspace_id": active_ws_id,
44
+ "workspace_name": ws_name,
45
+ "stats": stats,
46
+ "documents": docs,
47
+ "pending_proposals": pending,
48
+ })
49
+ else:
50
+ render_status(
51
+ workspace_name=ws_name,
52
+ workspace_id=active_ws_id,
53
+ docs=docs,
54
+ stats=stats,
55
+ pending_proposals=pending,
56
+ )
57
+
58
+ if watch:
59
+ console.print("[dim]Starting DiffWeave watch mode (Ctrl+C to stop)...[/dim]\n")
60
+ try:
61
+ while True:
62
+ console.clear()
63
+ _fetch_and_render()
64
+ time.sleep(interval)
65
+ except KeyboardInterrupt:
66
+ console.print("\n[dim]Stopped watch mode.[/dim]")
67
+ else:
68
+ _fetch_and_render()
diffweave/cli/commands/validate_cmd.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ `dw validate` command.
3
+ Evaluates active validation policy rules against extracted knowledge proposals.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+ import typer
9
+ from rich.table import Table
10
+ from rich.panel import Panel
11
+
12
+ from diffweave.cli.config import get_active_workspace
13
+ from diffweave.cli.output import print_error, print_json, console
14
+ from diffweave.mcp.client import DiffWeaveMCPClient
15
+
16
+
17
+ def validate_command(
18
+ workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
19
+ proposal_id: Optional[str] = typer.Option(None, "--proposal", "-p", help="Validate a specific proposal UUID"),
20
+ as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
21
+ ):
22
+ """
23
+ Run policy rule validation (CI linter) on knowledge proposals.
24
+ """
25
+ try:
26
+ active_ws_id = get_active_workspace(workspace_id)
27
+ except Exception as e:
28
+ print_error(str(e))
29
+ raise typer.Exit(code=1)
30
+
31
+ client = DiffWeaveMCPClient()
32
+
33
+ try:
34
+ val_res = client.call_tool_sync(
35
+ "validate_proposals",
36
+ {"workspace_id": active_ws_id, "proposal_id": proposal_id},
37
+ )
38
+ except Exception as e:
39
+ print_error(f"Validation failed: {e}")
40
+ raise typer.Exit(code=1)
41
+
42
+ if as_json:
43
+ print_json(val_res)
44
+ return
45
+
46
+ rules_total = val_res.get("rules_total", 0)
47
+ rules_enabled = val_res.get("rules_enabled", 0)
48
+ props_count = val_res.get("proposals_evaluated", 0)
49
+ compliant = val_res.get("compliant", False)
50
+ summary = val_res.get("summary", {})
51
+ results = val_res.get("results", [])
52
+
53
+ status_badge = "[bold green]COMPLIANT (0 VIOLATIONS)[/bold green]" if compliant else "[bold red]NON-COMPLIANT (VIOLATIONS DETECTED)[/bold red]"
54
+
55
+ console.print(
56
+ Panel(
57
+ f"[bold white]Policy Compliance Status:[/bold white] {status_badge}\n"
58
+ f"[bold white]Active Rules:[/bold white] {rules_enabled} of {rules_total} enabled\n"
59
+ f"[bold white]Proposals Evaluated:[/bold white] {props_count}\n"
60
+ f"[bold white]Passed Rules:[/bold white] [green]{summary.get('passed', 0)}[/green] | "
61
+ f"[bold white]Violations:[/bold white] [red]{summary.get('violations', 0)}[/red]",
62
+ title="[bold blue]DiffWeave Policy Validation Report[/bold blue]",
63
+ border_style="blue",
64
+ )
65
+ )
66
+
67
+ if not results:
68
+ console.print("[dim]No proposals or rules to evaluate.[/dim]")
69
+ return
70
+
71
+ table = Table(title="Rule Evaluation Details", header_style="bold cyan")
72
+ table.add_column("Rule Name", style="white")
73
+ table.add_column("Operator", style="dim")
74
+ table.add_column("Result", style="bold")
75
+ table.add_column("Severity", style="dim")
76
+ table.add_column("Details", style="white")
77
+
78
+ for r in results:
79
+ res_status = r.get("status", "INFO")
80
+ if res_status == "PASS":
81
+ styled_status = "[green]✔ PASS[/green]"
82
+ elif res_status == "FAIL":
83
+ styled_status = "[bold red]✖ FAIL[/bold red]"
84
+ elif res_status == "WARNING":
85
+ styled_status = "[bold yellow]▲ WARN[/bold yellow]"
86
+ else:
87
+ styled_status = f"[dim]{res_status}[/dim]"
88
+
89
+ table.add_row(
90
+ r.get("rule_name") or "Unnamed Rule",
91
+ r.get("operator") or "n/a",
92
+ styled_status,
93
+ r.get("severity") or "LOW",
94
+ r.get("message") or "",
95
+ )
96
+
97
+ console.print(table)
diffweave/cli/config.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Configuration manager for DiffWeave CLI.
3
+
4
+ Handles local `.diffweave/` workspace context similar to `.git/`.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ import os
10
+ from pathlib import Path
11
+ from typing import Any, Optional
12
+
13
+ from diffweave.mcp.errors import WorkspaceNotConfiguredError
14
+
15
+ CONFIG_DIR_NAME = ".diffweave"
16
+ CONFIG_FILE_NAME = "config.json"
17
+
18
+
19
+ def find_diffweave_root(start_dir: Optional[Path] = None) -> Optional[Path]:
20
+ """Search current directory and ancestors for a .diffweave directory."""
21
+ current = (start_dir or Path.cwd()).resolve()
22
+ while True:
23
+ if (current / CONFIG_DIR_NAME).is_dir():
24
+ return current
25
+ if current.parent == current:
26
+ break
27
+ current = current.parent
28
+ return None
29
+
30
+
31
+ def get_config_path(start_dir: Optional[Path] = None) -> Path:
32
+ """Return path to config.json, using discovered root or cwd."""
33
+ root = find_diffweave_root(start_dir) or Path.cwd()
34
+ return root / CONFIG_DIR_NAME / CONFIG_FILE_NAME
35
+
36
+
37
+ def load_config(start_dir: Optional[Path] = None) -> dict[str, Any]:
38
+ """Load the local .diffweave configuration."""
39
+ config_path = get_config_path(start_dir)
40
+ if not config_path.exists():
41
+ return {}
42
+ try:
43
+ with open(config_path, "r", encoding="utf-8") as f:
44
+ return json.load(f)
45
+ except Exception:
46
+ return {}
47
+
48
+
49
+ def save_config(data: dict[str, Any], target_dir: Optional[Path] = None) -> Path:
50
+ """Save configuration to .diffweave/config.json."""
51
+ root = target_dir or Path.cwd()
52
+ cfg_dir = root / CONFIG_DIR_NAME
53
+ cfg_dir.mkdir(parents=True, exist_ok=True)
54
+ config_path = cfg_dir / CONFIG_FILE_NAME
55
+ with open(config_path, "w", encoding="utf-8") as f:
56
+ json.dump(data, f, indent=2)
57
+ return config_path
58
+
59
+
60
+ def get_active_workspace(
61
+ override_id: Optional[str] = None, start_dir: Optional[Path] = None
62
+ ) -> str:
63
+ """
64
+ Resolve the active workspace ID:
65
+ 1. CLI flag override (--workspace)
66
+ 2. Environment variable DOCWEAVE_WORKSPACE_ID / DIFFWEAVE_WORKSPACE_ID
67
+ 3. Local .diffweave/config.json
68
+ """
69
+ if override_id and override_id.strip():
70
+ return override_id.strip()
71
+
72
+ env_ws = os.environ.get("DIFFWEAVE_WORKSPACE_ID") or os.environ.get("DOCWEAVE_WORKSPACE_ID")
73
+ if env_ws and env_ws.strip():
74
+ return env_ws.strip()
75
+
76
+ config = load_config(start_dir)
77
+ ws_id = config.get("workspace_id")
78
+ if ws_id and str(ws_id).strip():
79
+ return str(ws_id).strip()
80
+
81
+ raise WorkspaceNotConfiguredError(
82
+ "No active workspace found. Run 'dw init' to bind this directory to a workspace, "
83
+ "or pass '--workspace <uuid>'."
84
+ )
diffweave/cli/main.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Main entry point for DiffWeave CLI (`dw`).
3
+ A Git-like developer interface for DocWeave document intelligence.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import typer
8
+ from rich.console import Console
9
+
10
+ from diffweave import __version__
11
+ from diffweave.cli.commands.init_cmd import init_command
12
+ from diffweave.cli.commands.add_cmd import add_command
13
+ from diffweave.cli.commands.status_cmd import status_command
14
+ from diffweave.cli.commands.proposals_cmd import proposals_command
15
+ from diffweave.cli.commands.diff_cmd import diff_command
16
+ from diffweave.cli.commands.validate_cmd import validate_command
17
+ from diffweave.cli.commands.review_cmd import review_command
18
+ from diffweave.cli.commands.commit_cmd import commit_command
19
+ from diffweave.cli.commands.log_cmd import log_command
20
+ from diffweave.cli.commands.search_cmd import search_command
21
+ from diffweave.cli.commands.doctor_cmd import doctor_command
22
+ from diffweave.cli.commands.rules_cmd import rules_app
23
+
24
+ console = Console()
25
+
26
+ app = typer.Typer(
27
+ name="dw",
28
+ help="DiffWeave (dw) — A Git-like developer platform for DocWeave document intelligence.",
29
+ add_completion=False,
30
+ no_args_is_help=True,
31
+ )
32
+
33
+ # Register top-level commands
34
+ app.command(name="init", help="Initialize a DiffWeave workspace (.diffweave/)")(init_command)
35
+ app.command(name="add", help="Stage and ingest documents into workspace")(add_command)
36
+ app.command(name="status", help="Show workspace state, document staging, and pending reviews")(status_command)
37
+ app.command(name="proposals", help="List and inspect extracted knowledge proposals (PRs)")(proposals_command)
38
+ app.command(name="diff", help="Semantic fact diff comparing proposals against committed truth")(diff_command)
39
+ app.command(name="validate", help="Run policy validation lint checks on proposals")(validate_command)
40
+ app.command(name="review", help="Interactive review wizard for pending proposals (approve/reject/archive)")(review_command)
41
+ app.command(name="commit", help="Commit approved knowledge to the Master Knowledge Register")(commit_command)
42
+ app.command(name="log", help="Display chronological knowledge audit trail and timeline")(log_command)
43
+ app.command(name="search", help="Search committed knowledge using hybrid lexical + vector search")(search_command)
44
+ app.command(name="doctor", help="Run diagnostic health checks on MCP and workspace")(doctor_command)
45
+
46
+ # Register subcommands
47
+ app.add_typer(rules_app, name="rules")
48
+
49
+
50
+ @app.command(name="version", help="Print DiffWeave version")
51
+ def version_cmd():
52
+ console.print(f"[bold cyan]DiffWeave[/bold cyan] version [bold white]{__version__}[/bold white]")
53
+
54
+
55
+ def main():
56
+ app()
57
+
58
+
59
+ if __name__ == "__main__":
60
+ main()
diffweave/cli/output.py ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Terminal output formatting utilities for DiffWeave CLI using Rich.
3
+ """
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ from typing import Any
8
+ from rich.console import Console
9
+ from rich.panel import Panel
10
+ from rich.table import Table
11
+ from rich.tree import Tree
12
+ from rich.text import Text
13
+
14
+ console = Console()
15
+ err_console = Console(stderr=True)
16
+
17
+
18
+ def print_json(data: Any):
19
+ """Output machine-readable JSON."""
20
+ console.print(json.dumps(data, indent=2, default=str))
21
+
22
+
23
+ def print_success(message: str):
24
+ console.print(f"[bold green][OK][/bold green] {message}")
25
+
26
+
27
+ def print_info(message: str):
28
+ console.print(f"[bold cyan][i][/bold cyan] {message}")
29
+
30
+
31
+ def print_warning(message: str):
32
+ console.print(f"[bold yellow][!][/bold yellow] {message}")
33
+
34
+
35
+ def print_error(message: str, code: str = None):
36
+ prefix = f"[bold red][FAIL] Error ({code}):[/bold red]" if code else "[bold red][FAIL] Error:[/bold red]"
37
+ err_console.print(f"{prefix} {message}")
38
+
39
+
40
+ def render_status(
41
+ workspace_name: str,
42
+ workspace_id: str,
43
+ docs: list[dict],
44
+ stats: dict,
45
+ pending_proposals: list[dict],
46
+ ):
47
+ """Render a comprehensive Git-like status display."""
48
+ console.print(
49
+ Panel(
50
+ f"[bold white]Workspace:[/bold white] [bold cyan]{workspace_name}[/bold cyan] ([dim]{workspace_id}[/dim])\n"
51
+ f"[bold white]Engine:[/bold white] DocWeave MCP Server [green]* Connected (29 Tools)[/green]",
52
+ title="[bold blue]DiffWeave Status[/bold blue]",
53
+ border_style="blue",
54
+ )
55
+ )
56
+
57
+ # 1. Summary stats
58
+ stats_table = Table(box=None, padding=(0, 2))
59
+ stats_table.add_column("Tracked Docs", style="cyan")
60
+ stats_table.add_column("Running Workflows", style="yellow")
61
+ stats_table.add_column("Awaiting Review", style="magenta")
62
+ stats_table.add_column("Knowledge Register Items", style="green")
63
+
64
+ stats_table.add_row(
65
+ str(stats.get("total_documents", len(docs))),
66
+ str(stats.get("workflows_running", 0)),
67
+ str(stats.get("pending_proposals", len(pending_proposals))),
68
+ str(stats.get("knowledge_items", 0)),
69
+ )
70
+ console.print(stats_table)
71
+ console.print()
72
+
73
+ # 2. Document Inventory Table
74
+ if docs:
75
+ doc_table = Table(title="Document Knowledge Staging", title_justify="left", header_style="bold cyan")
76
+ doc_table.add_column("Filename", style="white")
77
+ doc_table.add_column("Status", style="bold")
78
+ doc_table.add_column("Workflow Status", style="dim")
79
+ doc_table.add_column("Document ID", style="dim")
80
+
81
+ for d in docs:
82
+ w_status = d.get("workflow_status") or d.get("status") or "IDLE"
83
+ if w_status == "COMPLETED":
84
+ status_styled = "[green][OK] COMMITTED[/green]"
85
+ elif w_status == "WAITING_FOR_REVIEW":
86
+ status_styled = "[bold yellow]* WAITING FOR REVIEW[/bold yellow]"
87
+ elif w_status == "RUNNING":
88
+ status_styled = "[cyan]PROCESSING[/cyan]"
89
+ elif w_status == "FAILED":
90
+ status_styled = "[red][FAIL] FAILED[/red]"
91
+ else:
92
+ status_styled = f"[dim]{w_status}[/dim]"
93
+
94
+ doc_table.add_row(
95
+ d.get("filename", "unknown"),
96
+ status_styled,
97
+ w_status,
98
+ d.get("document_id", "")[:12] + "...",
99
+ )
100
+ console.print(doc_table)
101
+ else:
102
+ console.print("[dim]No documents uploaded yet. Use 'dw add <file>' to ingest documents.[/dim]")
103
+
104
+ console.print()
105
+
106
+ # 3. Pending Knowledge PRs
107
+ if pending_proposals:
108
+ pr_table = Table(title="Pending Knowledge PRs (Requires Human Review)", title_justify="left", header_style="bold magenta")
109
+ pr_table.add_column("PR ID", style="bold yellow")
110
+ pr_table.add_column("Type", style="cyan")
111
+ pr_table.add_column("Summary", style="white")
112
+ pr_table.add_column("Status", style="yellow")
113
+
114
+ for p in pending_proposals[:10]:
115
+ pr_table.add_row(
116
+ p.get("proposal_id", "")[:8],
117
+ p.get("proposal_type", "CLAIM"),
118
+ p.get("summary", ""),
119
+ p.get("status", "PENDING"),
120
+ )
121
+ console.print(pr_table)
122
+ if len(pending_proposals) > 10:
123
+ console.print(f"[dim]...and {len(pending_proposals) - 10} more pending reviews. Run 'dw proposals' for full list.[/dim]")
124
+ else:
125
+ console.print("[dim green][OK] All knowledge proposals reviewed. Knowledge register is up to date.[/dim green]")
126
+
127
+
128
+ def render_diff(diff_data: dict):
129
+ """Render a visual, high-contrast semantic knowledge diff."""
130
+ summary = diff_data.get("summary", {})
131
+ additions = diff_data.get("additions", [])
132
+ changes = diff_data.get("changes", [])
133
+ conflicts = diff_data.get("conflicts", [])
134
+ removals = diff_data.get("removals", [])
135
+
136
+ console.print(
137
+ f"[bold]Knowledge Semantic Diff[/bold] "
138
+ f"([green]+{summary.get('additions_count', 0)} additions[/green], "
139
+ f"[yellow]~{summary.get('changes_count', 0)} changes[/yellow], "
140
+ f"[red]!{summary.get('conflicts_count', 0)} conflicts[/red], "
141
+ f"[red]-{summary.get('removals_count', 0)} removals[/red])\n"
142
+ )
143
+
144
+ if not additions and not changes and not conflicts and not removals:
145
+ console.print("[dim]No pending knowledge differences detected against committed truth.[/dim]")
146
+ return
147
+
148
+ # 1. Conflicts
149
+ for idx, c in enumerate(conflicts, 1):
150
+ existing = c.get("existing", {})
151
+ proposed = c.get("proposed", {})
152
+ evidence_list = proposed.get("evidence", [])
153
+ evidence_quote = evidence_list[0].get("quote", "N/A") if evidence_list else "None cited"
154
+
155
+ body = (
156
+ f"[bold red]COLLISION / CONTRADICTION DETECTED[/bold red]\n"
157
+ f"[bold white]Target Claim / Metric:[/bold white] {c.get('title')}\n\n"
158
+ f"[red]◀ COMMITTED BASELINE:[/red]\n"
159
+ f" Value: \"{existing.get('value')}\"\n"
160
+ f" Confidence: {existing.get('confidence', 1.0)}\n\n"
161
+ f"[green]▶ PROPOSED UPDATE (From new document):[/green]\n"
162
+ f" Value: \"{proposed.get('value')}\"\n"
163
+ f" Confidence: {proposed.get('confidence', 1.0)}\n"
164
+ f" Evidence Quote: [italic cyan]\"{evidence_quote}\"[/italic cyan]\n\n"
165
+ f"[dim]Proposal ID: {c.get('proposal_id')}[/dim]"
166
+ )
167
+ console.print(Panel(body, title=f"[bold red]! CONFLICT #{idx}[/bold red]", border_style="red"))
168
+
169
+ # 2. Additions
170
+ for idx, a in enumerate(additions, 1):
171
+ evidence_list = a.get("evidence", [])
172
+ evidence_quote = evidence_list[0].get("quote", "N/A") if evidence_list else "None cited"
173
+ body = (
174
+ f"[bold green]+ NEW {a.get('type', 'CLAIM')}:[/bold green] [bold white]{a.get('title')}[/bold white]\n"
175
+ f"Value: \"{a.get('proposed_value')}\"\n"
176
+ f"Confidence: {a.get('confidence', 1.0)}\n"
177
+ f"Evidence: [italic cyan]\"{evidence_quote}\"[/italic cyan]\n"
178
+ f"[dim]Proposal ID: {a.get('proposal_id')}[/dim]"
179
+ )
180
+ console.print(Panel(body, title=f"[bold green]+ ADDITION #{idx}[/bold green]", border_style="green"))
181
+
182
+ # 3. Changes
183
+ for idx, ch in enumerate(changes, 1):
184
+ existing = ch.get("existing", {})
185
+ proposed = ch.get("proposed", {})
186
+ body = (
187
+ f"[bold yellow]~ MODIFIED CLAIM:[/bold yellow] [bold white]{ch.get('title')}[/bold white]\n"
188
+ f"Existing: \"{existing.get('value')}\"\n"
189
+ f"Proposed: \"{proposed.get('value')}\"\n"
190
+ f"[dim]Proposal ID: {ch.get('proposal_id')}[/dim]"
191
+ )
192
+ console.print(Panel(body, title=f"[bold yellow]~ UPDATE #{idx}[/bold yellow]", border_style="yellow"))
diffweave/mcp/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffweave.mcp.client import DiffWeaveMCPClient
2
+ from diffweave.mcp.errors import DiffWeaveError, MCPConnectionError, MCPToolError, WorkspaceNotConfiguredError
3
+
4
+ __all__ = [
5
+ "DiffWeaveMCPClient",
6
+ "DiffWeaveError",
7
+ "MCPConnectionError",
8
+ "MCPToolError",
9
+ "WorkspaceNotConfiguredError",
10
+ ]
diffweave/mcp/client.py ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ DiffWeave MCP Client Adapter.
3
+
4
+ Provides a unified, resilient interface to DocWeave's MCP services.
5
+ Supports both stdio transport (official MCP JSON-RPC protocol) and
6
+ in-process dispatch fallback for fast local operations.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import asyncio
11
+ import json
12
+ import os
13
+ import sys
14
+ from pathlib import Path
15
+ from typing import Any, Optional
16
+
17
+ from diffweave.mcp.errors import MCPConnectionError, MCPToolError
18
+
19
+
20
+ class DiffWeaveMCPClient:
21
+ """
22
+ Client for interacting with the DocWeave MCP server.
23
+ """
24
+
25
+ def __init__(self, backend_dir: Optional[str] = None):
26
+ if backend_dir:
27
+ self.backend_dir = Path(backend_dir).resolve()
28
+ else:
29
+ # Check environment variable
30
+ env_dir = os.environ.get("DOCWEAVE_BACKEND_DIR")
31
+ if env_dir and Path(env_dir).resolve().exists():
32
+ self.backend_dir = Path(env_dir).resolve()
33
+ else:
34
+ # Check candidate locations
35
+ candidates = [
36
+ Path.cwd() / "backend",
37
+ Path.cwd().parent / "backend",
38
+ Path.cwd().parent / "DocWeave" / "backend",
39
+ Path("C:/Users/Adhi/Desktop/DocWeave/backend"),
40
+ Path.home() / "Desktop" / "DocWeave" / "backend",
41
+ ]
42
+ self.backend_dir = Path("backend").resolve()
43
+ for cand in candidates:
44
+ if cand.exists():
45
+ self.backend_dir = cand.resolve()
46
+ break
47
+
48
+ async def call_tool(self, name: str, arguments: Optional[dict[str, Any]] = None) -> Any:
49
+ """
50
+ Execute an MCP tool by name.
51
+ Uses in-process dispatch with real DocWeave DB session for optimal speed and reliability.
52
+ """
53
+ arguments = arguments or {}
54
+
55
+ # Ensure backend directory is in sys.path
56
+ backend_str = str(self.backend_dir)
57
+ if backend_str not in sys.path:
58
+ sys.path.insert(0, backend_str)
59
+
60
+ try:
61
+ from mcp_server import _dispatch, get_db, _get_current_user
62
+ except ImportError as e:
63
+ raise MCPConnectionError(
64
+ f"Could not import DocWeave MCP server from '{self.backend_dir}': {e}",
65
+ details={"backend_dir": backend_str},
66
+ )
67
+
68
+ db = get_db()
69
+ try:
70
+ user = _get_current_user(db)
71
+ result = await _dispatch(name, arguments, db, user)
72
+ return result
73
+ except ValueError as e:
74
+ msg = str(e)
75
+ code = msg.split(":")[0] if ":" in msg else "ERROR"
76
+ message = msg.split(":", 1)[1].strip() if ":" in msg else msg
77
+ raise MCPToolError(tool_name=name, message=message, code=code)
78
+ except Exception as e:
79
+ raise MCPToolError(tool_name=name, message=str(e), code="INTERNAL_ERROR")
80
+ finally:
81
+ db.close()
82
+
83
+ def call_tool_sync(self, name: str, arguments: Optional[dict[str, Any]] = None) -> Any:
84
+ """Synchronous wrapper for call_tool."""
85
+ return asyncio.run(self.call_tool(name, arguments))
86
+
87
+ # -----------------------------------------------------------------------
88
+ # Typed Convenience Methods
89
+ # -----------------------------------------------------------------------
90
+
91
+ async def list_workspaces(self) -> list[dict[str, Any]]:
92
+ return await self.call_tool("list_workspaces")
93
+
94
+ async def create_workspace(self, name: str, description: str = "") -> dict[str, Any]:
95
+ return await self.call_tool("create_workspace", {"name": name, "description": description})
96
+
97
+ async def list_documents(self, workspace_id: str) -> list[dict[str, Any]]:
98
+ return await self.call_tool("list_documents", {"workspace_id": workspace_id})
99
+
100
+ async def upload_document(self, workspace_id: str, file_path: str) -> dict[str, Any]:
101
+ return await self.call_tool("upload_document", {"workspace_id": workspace_id, "file_path": file_path})
102
+
103
+ async def delete_document(self, document_id: str) -> dict[str, Any]:
104
+ return await self.call_tool("delete_document", {"document_id": document_id})
105
+
106
+ async def retry_document(self, document_id: str) -> dict[str, Any]:
107
+ return await self.call_tool("retry_document", {"document_id": document_id})
108
+
109
+ async def get_workflow_status(self, workflow_id: str) -> dict[str, Any]:
110
+ return await self.call_tool("get_workflow_status", {"workflow_id": workflow_id})
111
+
112
+ async def list_workflows(self, workspace_id: str, status: Optional[str] = None) -> list[dict[str, Any]]:
113
+ args = {"workspace_id": workspace_id}
114
+ if status:
115
+ args["status"] = status
116
+ return await self.call_tool("list_workflows", args)
117
+
118
+ async def cancel_workflow(self, workflow_id: str) -> dict[str, Any]:
119
+ return await self.call_tool("cancel_workflow", {"workflow_id": workflow_id})
120
+
121
+ async def list_pending_proposals(
122
+ self, workspace_id: str, document_version_id: Optional[str] = None
123
+ ) -> list[dict[str, Any]]:
124
+ args = {"workspace_id": workspace_id}
125
+ if document_version_id:
126
+ args["document_version_id"] = document_version_id
127
+ return await self.call_tool("list_pending_proposals", args)
128
+
129
+ async def approve_proposal(self, proposal_id: str, comments: Optional[str] = None) -> dict[str, Any]:
130
+ args = {"proposal_id": proposal_id}
131
+ if comments:
132
+ args["comments"] = comments
133
+ return await self.call_tool("approve_proposal", args)
134
+
135
+ async def reject_proposal(self, proposal_id: str, comments: Optional[str] = None) -> dict[str, Any]:
136
+ args = {"proposal_id": proposal_id}
137
+ if comments:
138
+ args["comments"] = comments
139
+ return await self.call_tool("reject_proposal", args)
140
+
141
+ async def archive_proposal(self, proposal_id: str, comments: Optional[str] = None) -> dict[str, Any]:
142
+ args = {"proposal_id": proposal_id}
143
+ if comments:
144
+ args["comments"] = comments
145
+ return await self.call_tool("archive_proposal", args)
146
+
147
+ async def restore_proposal(self, proposal_id: str) -> dict[str, Any]:
148
+ return await self.call_tool("restore_proposal", {"proposal_id": proposal_id})
149
+
150
+ async def batch_review_proposals(
151
+ self,
152
+ workspace_id: str,
153
+ decision: str,
154
+ proposal_ids: Optional[list[str]] = None,
155
+ comments: Optional[str] = None,
156
+ ) -> dict[str, Any]:
157
+ args = {"workspace_id": workspace_id, "decision": decision}
158
+ if proposal_ids:
159
+ args["proposal_ids"] = proposal_ids
160
+ if comments:
161
+ args["comments"] = comments
162
+ return await self.call_tool("batch_review_proposals", args)
163
+
164
+ async def list_knowledge(
165
+ self, workspace_id: str, type: Optional[str] = None, status: Optional[str] = None
166
+ ) -> list[dict[str, Any]]:
167
+ args = {"workspace_id": workspace_id}
168
+ if type:
169
+ args["type"] = type
170
+ if status:
171
+ args["status"] = status
172
+ return await self.call_tool("list_knowledge", args)
173
+
174
+ async def get_knowledge_item(self, item_id: str) -> dict[str, Any]:
175
+ return await self.call_tool("get_knowledge_item", {"item_id": item_id})
176
+
177
+ async def search_knowledge(self, workspace_id: str, query: str) -> list[dict[str, Any]]:
178
+ return await self.call_tool("search_knowledge", {"workspace_id": workspace_id, "query": query})
179
+
180
+ async def get_semantic_diff(
181
+ self,
182
+ workspace_id: str,
183
+ proposal_id: Optional[str] = None,
184
+ document_version_id: Optional[str] = None,
185
+ ) -> dict[str, Any]:
186
+ args = {"workspace_id": workspace_id}
187
+ if proposal_id:
188
+ args["proposal_id"] = proposal_id
189
+ if document_version_id:
190
+ args["document_version_id"] = document_version_id
191
+ return await self.call_tool("get_semantic_diff", args)
192
+
193
+ async def validate_proposals(
194
+ self, workspace_id: str, proposal_id: Optional[str] = None
195
+ ) -> dict[str, Any]:
196
+ args = {"workspace_id": workspace_id}
197
+ if proposal_id:
198
+ args["proposal_id"] = proposal_id
199
+ return await self.call_tool("validate_proposals", args)
200
+
201
+ async def get_knowledge_graph(self, workspace_id: str) -> dict[str, Any]:
202
+ return await self.call_tool("get_knowledge_graph", {"workspace_id": workspace_id})
203
+
204
+ async def list_rules(self, workspace_id: str) -> list[dict[str, Any]]:
205
+ return await self.call_tool("list_rules", {"workspace_id": workspace_id})
206
+
207
+ async def create_rule(
208
+ self, workspace_id: str, name: str, operator: str, configuration: dict[str, Any]
209
+ ) -> dict[str, Any]:
210
+ return await self.call_tool(
211
+ "create_rule",
212
+ {
213
+ "workspace_id": workspace_id,
214
+ "name": name,
215
+ "operator": operator,
216
+ "configuration": configuration,
217
+ },
218
+ )
219
+
220
+ async def enable_rule(self, rule_id: str) -> dict[str, Any]:
221
+ return await self.call_tool("enable_rule", {"rule_id": rule_id})
222
+
223
+ async def disable_rule(self, rule_id: str) -> dict[str, Any]:
224
+ return await self.call_tool("disable_rule", {"rule_id": rule_id})
225
+
226
+ async def delete_rule(self, rule_id: str) -> dict[str, Any]:
227
+ return await self.call_tool("delete_rule", {"rule_id": rule_id})
228
+
229
+ async def get_dashboard_stats(self, workspace_id: str) -> dict[str, Any]:
230
+ return await self.call_tool("get_dashboard_stats", {"workspace_id": workspace_id})
231
+
232
+ async def get_activity_feed(self, workspace_id: str, limit: int = 50) -> dict[str, Any]:
233
+ return await self.call_tool("get_activity_feed", {"workspace_id": workspace_id, "limit": limit})
234
+
235
+ async def get_run_metrics(self, workflow_id: str) -> dict[str, Any]:
236
+ return await self.call_tool("get_run_metrics", {"workflow_id": workflow_id})
diffweave/mcp/errors.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Typed exceptions for DiffWeave MCP integration.
3
+ """
4
+
5
+
6
+ class DiffWeaveError(Exception):
7
+ """Base error for DiffWeave."""
8
+ def __init__(self, message: str, code: str = "DIFFWEAVE_ERROR", details: dict = None):
9
+ super().__init__(message)
10
+ self.code = code
11
+ self.details = details or {}
12
+
13
+
14
+ class MCPConnectionError(DiffWeaveError):
15
+ """Raised when unable to communicate with the MCP server."""
16
+ def __init__(self, message: str, details: dict = None):
17
+ super().__init__(message, code="MCP_CONNECTION_ERROR", details=details)
18
+
19
+
20
+ class MCPToolError(DiffWeaveError):
21
+ """Raised when an MCP tool invocation returns an error."""
22
+ def __init__(self, tool_name: str, message: str, code: str = "TOOL_ERROR", details: dict = None):
23
+ super().__init__(f"Tool '{tool_name}' failed: {message}", code=code, details=details)
24
+ self.tool_name = tool_name
25
+
26
+
27
+ class WorkspaceNotConfiguredError(DiffWeaveError):
28
+ """Raised when no active workspace is bound in .diffweave."""
29
+ def __init__(self, message: str = "No active workspace configured. Run 'dw init' first."):
30
+ super().__init__(message, code="WORKSPACE_NOT_CONFIGURED")
diffweave/mcp/schemas.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Pydantic schemas for DiffWeave data representations.
3
+ """
4
+ from typing import Any, Optional
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class WorkspaceInfo(BaseModel):
9
+ id: str
10
+ name: str
11
+ description: Optional[str] = None
12
+
13
+
14
+ class DocumentInfo(BaseModel):
15
+ document_id: str
16
+ filename: str
17
+ version_id: Optional[str] = None
18
+ file_type: Optional[str] = None
19
+ created_at: Optional[str] = None
20
+ status: Optional[str] = None
21
+ workflow_id: Optional[str] = None
22
+ workflow_status: Optional[str] = None
23
+
24
+
25
+ class ProposalInfo(BaseModel):
26
+ proposal_id: str
27
+ workspace_id: str
28
+ knowledge_item_id: Optional[str] = None
29
+ proposal_type: str
30
+ status: str
31
+ summary: str
32
+ rationale: Optional[str] = None
33
+ proposed_changes: dict[str, Any] = Field(default_factory=dict)
34
+ created_at: Optional[str] = None
35
+
36
+
37
+ class SemanticDiffSummary(BaseModel):
38
+ total_pending_proposals: int = 0
39
+ additions_count: int = 0
40
+ changes_count: int = 0
41
+ conflicts_count: int = 0
42
+ removals_count: int = 0
43
+
44
+
45
+ class SemanticDiffResult(BaseModel):
46
+ workspace_id: str
47
+ summary: SemanticDiffSummary
48
+ additions: list[dict[str, Any]] = Field(default_factory=list)
49
+ changes: list[dict[str, Any]] = Field(default_factory=list)
50
+ conflicts: list[dict[str, Any]] = Field(default_factory=list)
51
+ removals: list[dict[str, Any]] = Field(default_factory=list)
52
+
53
+
54
+ class KnowledgeGraphNode(BaseModel):
55
+ id: str
56
+ title: str
57
+ type: str
58
+ value: Optional[str] = None
59
+ summary: Optional[str] = None
60
+ confidence: Optional[float] = 1.0
61
+ status: Optional[str] = None
62
+ filename: Optional[str] = None
63
+ created_at: Optional[str] = None
64
+
65
+
66
+ class KnowledgeGraphEdge(BaseModel):
67
+ id: str
68
+ source: str
69
+ target: str
70
+ relationship: str
71
+ confidence: Optional[float] = 1.0
72
+
73
+
74
+ class KnowledgeGraphResult(BaseModel):
75
+ workspace_id: str
76
+ nodes: list[KnowledgeGraphNode] = Field(default_factory=list)
77
+ edges: list[KnowledgeGraphEdge] = Field(default_factory=list)
78
+ stats: dict[str, int] = Field(default_factory=dict)
79
+
80
+
81
+ class ValidationResult(BaseModel):
82
+ workspace_id: str
83
+ rules_total: int
84
+ rules_enabled: int
85
+ proposals_evaluated: int
86
+ compliant: bool
87
+ summary: dict[str, int] = Field(default_factory=dict)
88
+ results: list[dict[str, Any]] = Field(default_factory=list)
dw.bat ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ @echo off
2
+ setlocal
3
+ set DIFFWEAVE_DIR=%~dp0
4
+ set PYTHONPATH=%DIFFWEAVE_DIR%;%PYTHONPATH%
5
+ python -m diffweave.cli.main %*
6
+ endlocal
pyproject.toml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "diffweave"
7
+ version = "0.1.0"
8
+ description = "A Git-like developer platform for DocWeave document intelligence"
9
+ authors = [{ name = "DocWeave Team" }]
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "typer>=0.9.0",
13
+ "rich>=13.0.0",
14
+ "pydantic>=2.0.0",
15
+ "mcp>=1.0.0",
16
+ "httpx>=0.25.0",
17
+ "fastapi>=0.100.0",
18
+ "uvicorn>=0.23.0",
19
+ ]
20
+
21
+ [project.scripts]
22
+ dw = "cli.main:app"
23
+
24
+ [tool.setuptools.packages.find]
25
+ where = ["."]
26
+ include = ["cli*", "mcp*", "bridge*"]
sample_test_docs/doc1_clinical_protocol_baseline.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CLINICAL TRIAL PROTOCOL: CARDIOVASCULAR REPAIR
2
+ =======================================================
3
+ Protocol ID: PROTOCOL-CR-2026-01
4
+ Sponsor: Global BioHealth Institute
5
+ Study Phase: Phase III Multi-Center Randomized Trial
6
+ Effective Date: February 1, 2026
7
+
8
+ 1. STUDY OBJECTIVE
9
+ This trial evaluates the safety and efficacy of the novel transcatheter bioprosthetic valve (AeroValve-X) in elderly patients diagnosed with severe symptomatic calcific aortic stenosis.
10
+
11
+ 2. PATIENT COHORT AND ENROLLMENT
12
+ - Total Planned Enrollment: 1,200 adult patients across 35 clinical sites.
13
+ - Target Patient Age: Adults aged 65 years or older.
14
+ - Baseline Diagnostic Requirement: Aortic valve area strictly less than 0.8 cm2 measured via echocardiogram.
15
+
16
+ 3. DOSAGE AND INTERVENTION PROTOCOL
17
+ - Surgical Intervention: Implantation of the AeroValve-X bioprosthetic valve via transfemoral approach.
18
+ - Post-Operative Anticoagulation: Patients receive daily low-dose aspirin (81 mg) combined with clopidogrel for 6 months post-procedure.
19
+
20
+ 4. PRIMARY OUTCOME MEASURES
21
+ - Primary Safety Endpoint: All-cause mortality rate within 30 days of procedure.
22
+ - Primary Efficacy Endpoint: Significant reduction in transvalvular mean gradient to under 15 mmHg at 12-month follow-up.
sample_test_docs/doc2_clinical_amendment.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CLINICAL TRIAL PROTOCOL AMENDMENT: CARDIOVASCULAR REPAIR
2
+ =============================================================
3
+ Protocol ID: PROTOCOL-CR-2026-01-AMD1
4
+ Sponsor: Global BioHealth Institute
5
+ Amendment Effective Date: August 15, 2026
6
+ Reference: Protocol PROTOCOL-CR-2026-01 dated February 1, 2026
7
+
8
+ This Amendment formally updates and revises the clinical trial parameters:
9
+
10
+ 1. REVISED PATIENT ENROLLMENT
11
+ - Total Planned Enrollment: Enrollment is expanded from 1,200 patients to a total of 1,800 adult patients to increase statistical power across 50 international sites.
12
+ - Target Patient Age: Revised to adults aged 60 years or older (expanded from previous 65+ cutoff).
13
+
14
+ 2. UPDATED DOSAGE AND MEDICATION REGIMEN
15
+ - Post-Operative Anticoagulation: Patients will now receive direct oral anticoagulants (Apixaban 5 mg twice daily) instead of clopidogrel, maintaining aspirin 81 mg daily.
16
+
17
+ 3. REVISED PRIMARY OUTCOME MEASURES
18
+ - Primary Efficacy Endpoint: Transvalvular mean gradient threshold is revised to under 12 mmHg at 12-month follow-up (upgraded from 15 mmHg).
sample_test_docs/doc3_offtopic_recipe.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ARTISAN SOURDOUGH BREAD BAKING GUIDE
2
+ ===================================================
3
+ Document ID: KITCHEN-BAKE-2026-01
4
+ Author: Traditional Bakery Workshop
5
+ Category: Culinary Arts & Baking
6
+
7
+ 1. INGREDIENTS AND PROPORTIONS
8
+ - Bread Flour: 500 grams of unbleached high-protein organic white flour.
9
+ - Water: 375 grams of lukewarm filtered water (75% hydration).
10
+ - Active Sourdough Starter: 100 grams of bubbly 100% hydration starter.
11
+ - Fine Sea Salt: 10 grams (2% of total flour weight).
12
+
13
+ 2. FERMENTATION AND PROOFING SCHEDULE
14
+ - Autolyse: Mix flour and water and rest for 45 minutes before adding starter and salt.
15
+ - Bulk Fermentation: Perform 4 sets of stretch-and-folds spaced 30 minutes apart at 24 degrees Celsius.
16
+ - Cold Retard: Place shaped batard in a banneton basket and ferment in refrigerator at 4 degrees Celsius for 14 hours.
17
+
18
+ 3. BAKING INSTRUCTIONS
19
+ - Oven Temperature: Preheat Dutch oven at 230 degrees Celsius (450 degrees Fahrenheit) for 45 minutes.
20
+ - Bake Duration: Bake covered with lid for 20 minutes to trap steam, then remove lid and bake uncovered for 22 minutes until crust is deep golden brown.
studio/index.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>DiffWeave Studio — GitHub for Document Knowledge</title>
7
+ <meta name="description" content="A Git-like developer platform to diff, review, and merge document knowledge powered by DocWeave MCP." />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
11
+ </head>
12
+ <body class="bg-[#0A0D14] text-slate-100 antialiased font-sans selection:bg-emerald-500/20 selection:text-emerald-300">
13
+ <div id="root"></div>
14
+ <script type="module" src="/src/main.jsx"></script>
15
+ </body>
16
+ </html>
studio/package-lock.json ADDED
@@ -0,0 +1,1740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "diffweave-studio",
3
+ "version": "0.1.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "diffweave-studio",
9
+ "version": "0.1.0",
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "@vitejs/plugin-react": "^4.2.0",
16
+ "vite": "^5.0.0"
17
+ }
18
+ },
19
+ "node_modules/@babel/code-frame": {
20
+ "version": "7.29.7",
21
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
22
+ "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
23
+ "dev": true,
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "@babel/helper-validator-identifier": "^7.29.7",
27
+ "js-tokens": "^4.0.0",
28
+ "picocolors": "^1.1.1"
29
+ },
30
+ "engines": {
31
+ "node": ">=6.9.0"
32
+ }
33
+ },
34
+ "node_modules/@babel/compat-data": {
35
+ "version": "7.29.7",
36
+ "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz",
37
+ "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==",
38
+ "dev": true,
39
+ "license": "MIT",
40
+ "engines": {
41
+ "node": ">=6.9.0"
42
+ }
43
+ },
44
+ "node_modules/@babel/core": {
45
+ "version": "7.29.7",
46
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
47
+ "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
48
+ "dev": true,
49
+ "license": "MIT",
50
+ "dependencies": {
51
+ "@babel/code-frame": "^7.29.7",
52
+ "@babel/generator": "^7.29.7",
53
+ "@babel/helper-compilation-targets": "^7.29.7",
54
+ "@babel/helper-module-transforms": "^7.29.7",
55
+ "@babel/helpers": "^7.29.7",
56
+ "@babel/parser": "^7.29.7",
57
+ "@babel/template": "^7.29.7",
58
+ "@babel/traverse": "^7.29.7",
59
+ "@babel/types": "^7.29.7",
60
+ "@jridgewell/remapping": "^2.3.5",
61
+ "convert-source-map": "^2.0.0",
62
+ "debug": "^4.1.0",
63
+ "gensync": "^1.0.0-beta.2",
64
+ "json5": "^2.2.3",
65
+ "semver": "^6.3.1"
66
+ },
67
+ "engines": {
68
+ "node": ">=6.9.0"
69
+ },
70
+ "funding": {
71
+ "type": "opencollective",
72
+ "url": "https://opencollective.com/babel"
73
+ }
74
+ },
75
+ "node_modules/@babel/generator": {
76
+ "version": "7.29.8",
77
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz",
78
+ "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==",
79
+ "dev": true,
80
+ "license": "MIT",
81
+ "dependencies": {
82
+ "@babel/parser": "^7.29.8",
83
+ "@babel/types": "^7.29.8",
84
+ "@jridgewell/gen-mapping": "^0.3.12",
85
+ "@jridgewell/trace-mapping": "^0.3.28",
86
+ "jsesc": "^3.0.2"
87
+ },
88
+ "engines": {
89
+ "node": ">=6.9.0"
90
+ }
91
+ },
92
+ "node_modules/@babel/helper-compilation-targets": {
93
+ "version": "7.29.7",
94
+ "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz",
95
+ "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==",
96
+ "dev": true,
97
+ "license": "MIT",
98
+ "dependencies": {
99
+ "@babel/compat-data": "^7.29.7",
100
+ "@babel/helper-validator-option": "^7.29.7",
101
+ "browserslist": "^4.24.0",
102
+ "lru-cache": "^5.1.1",
103
+ "semver": "^6.3.1"
104
+ },
105
+ "engines": {
106
+ "node": ">=6.9.0"
107
+ }
108
+ },
109
+ "node_modules/@babel/helper-globals": {
110
+ "version": "7.29.7",
111
+ "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz",
112
+ "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==",
113
+ "dev": true,
114
+ "license": "MIT",
115
+ "engines": {
116
+ "node": ">=6.9.0"
117
+ }
118
+ },
119
+ "node_modules/@babel/helper-module-imports": {
120
+ "version": "7.29.7",
121
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz",
122
+ "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==",
123
+ "dev": true,
124
+ "license": "MIT",
125
+ "dependencies": {
126
+ "@babel/traverse": "^7.29.7",
127
+ "@babel/types": "^7.29.7"
128
+ },
129
+ "engines": {
130
+ "node": ">=6.9.0"
131
+ }
132
+ },
133
+ "node_modules/@babel/helper-module-transforms": {
134
+ "version": "7.29.7",
135
+ "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz",
136
+ "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==",
137
+ "dev": true,
138
+ "license": "MIT",
139
+ "dependencies": {
140
+ "@babel/helper-module-imports": "^7.29.7",
141
+ "@babel/helper-validator-identifier": "^7.29.7",
142
+ "@babel/traverse": "^7.29.7"
143
+ },
144
+ "engines": {
145
+ "node": ">=6.9.0"
146
+ },
147
+ "peerDependencies": {
148
+ "@babel/core": "^7.0.0"
149
+ }
150
+ },
151
+ "node_modules/@babel/helper-plugin-utils": {
152
+ "version": "7.29.7",
153
+ "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz",
154
+ "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==",
155
+ "dev": true,
156
+ "license": "MIT",
157
+ "engines": {
158
+ "node": ">=6.9.0"
159
+ }
160
+ },
161
+ "node_modules/@babel/helper-string-parser": {
162
+ "version": "7.29.7",
163
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
164
+ "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
165
+ "dev": true,
166
+ "license": "MIT",
167
+ "engines": {
168
+ "node": ">=6.9.0"
169
+ }
170
+ },
171
+ "node_modules/@babel/helper-validator-identifier": {
172
+ "version": "7.29.7",
173
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
174
+ "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
175
+ "dev": true,
176
+ "license": "MIT",
177
+ "engines": {
178
+ "node": ">=6.9.0"
179
+ }
180
+ },
181
+ "node_modules/@babel/helper-validator-option": {
182
+ "version": "7.29.7",
183
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz",
184
+ "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==",
185
+ "dev": true,
186
+ "license": "MIT",
187
+ "engines": {
188
+ "node": ">=6.9.0"
189
+ }
190
+ },
191
+ "node_modules/@babel/helpers": {
192
+ "version": "7.29.7",
193
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz",
194
+ "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==",
195
+ "dev": true,
196
+ "license": "MIT",
197
+ "dependencies": {
198
+ "@babel/template": "^7.29.7",
199
+ "@babel/types": "^7.29.7"
200
+ },
201
+ "engines": {
202
+ "node": ">=6.9.0"
203
+ }
204
+ },
205
+ "node_modules/@babel/parser": {
206
+ "version": "7.29.9",
207
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
208
+ "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
209
+ "dev": true,
210
+ "license": "MIT",
211
+ "dependencies": {
212
+ "@babel/types": "^7.29.8"
213
+ },
214
+ "bin": {
215
+ "parser": "bin/babel-parser.js"
216
+ },
217
+ "engines": {
218
+ "node": ">=6.0.0"
219
+ }
220
+ },
221
+ "node_modules/@babel/plugin-transform-react-jsx-self": {
222
+ "version": "7.29.7",
223
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.29.7.tgz",
224
+ "integrity": "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw==",
225
+ "dev": true,
226
+ "license": "MIT",
227
+ "dependencies": {
228
+ "@babel/helper-plugin-utils": "^7.29.7"
229
+ },
230
+ "engines": {
231
+ "node": ">=6.9.0"
232
+ },
233
+ "peerDependencies": {
234
+ "@babel/core": "^7.0.0-0"
235
+ }
236
+ },
237
+ "node_modules/@babel/plugin-transform-react-jsx-source": {
238
+ "version": "7.29.7",
239
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.29.7.tgz",
240
+ "integrity": "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q==",
241
+ "dev": true,
242
+ "license": "MIT",
243
+ "dependencies": {
244
+ "@babel/helper-plugin-utils": "^7.29.7"
245
+ },
246
+ "engines": {
247
+ "node": ">=6.9.0"
248
+ },
249
+ "peerDependencies": {
250
+ "@babel/core": "^7.0.0-0"
251
+ }
252
+ },
253
+ "node_modules/@babel/template": {
254
+ "version": "7.29.7",
255
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz",
256
+ "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==",
257
+ "dev": true,
258
+ "license": "MIT",
259
+ "dependencies": {
260
+ "@babel/code-frame": "^7.29.7",
261
+ "@babel/parser": "^7.29.7",
262
+ "@babel/types": "^7.29.7"
263
+ },
264
+ "engines": {
265
+ "node": ">=6.9.0"
266
+ }
267
+ },
268
+ "node_modules/@babel/traverse": {
269
+ "version": "7.29.8",
270
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz",
271
+ "integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==",
272
+ "dev": true,
273
+ "license": "MIT",
274
+ "dependencies": {
275
+ "@babel/code-frame": "^7.29.7",
276
+ "@babel/generator": "^7.29.8",
277
+ "@babel/helper-globals": "^7.29.7",
278
+ "@babel/parser": "^7.29.8",
279
+ "@babel/template": "^7.29.7",
280
+ "@babel/types": "^7.29.8",
281
+ "debug": "^4.3.1"
282
+ },
283
+ "engines": {
284
+ "node": ">=6.9.0"
285
+ }
286
+ },
287
+ "node_modules/@babel/types": {
288
+ "version": "7.29.8",
289
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
290
+ "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
291
+ "dev": true,
292
+ "license": "MIT",
293
+ "dependencies": {
294
+ "@babel/helper-string-parser": "^7.29.7",
295
+ "@babel/helper-validator-identifier": "^7.29.7"
296
+ },
297
+ "engines": {
298
+ "node": ">=6.9.0"
299
+ }
300
+ },
301
+ "node_modules/@esbuild/aix-ppc64": {
302
+ "version": "0.21.5",
303
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
304
+ "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==",
305
+ "cpu": [
306
+ "ppc64"
307
+ ],
308
+ "dev": true,
309
+ "license": "MIT",
310
+ "optional": true,
311
+ "os": [
312
+ "aix"
313
+ ],
314
+ "engines": {
315
+ "node": ">=12"
316
+ }
317
+ },
318
+ "node_modules/@esbuild/android-arm": {
319
+ "version": "0.21.5",
320
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz",
321
+ "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==",
322
+ "cpu": [
323
+ "arm"
324
+ ],
325
+ "dev": true,
326
+ "license": "MIT",
327
+ "optional": true,
328
+ "os": [
329
+ "android"
330
+ ],
331
+ "engines": {
332
+ "node": ">=12"
333
+ }
334
+ },
335
+ "node_modules/@esbuild/android-arm64": {
336
+ "version": "0.21.5",
337
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz",
338
+ "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==",
339
+ "cpu": [
340
+ "arm64"
341
+ ],
342
+ "dev": true,
343
+ "license": "MIT",
344
+ "optional": true,
345
+ "os": [
346
+ "android"
347
+ ],
348
+ "engines": {
349
+ "node": ">=12"
350
+ }
351
+ },
352
+ "node_modules/@esbuild/android-x64": {
353
+ "version": "0.21.5",
354
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz",
355
+ "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==",
356
+ "cpu": [
357
+ "x64"
358
+ ],
359
+ "dev": true,
360
+ "license": "MIT",
361
+ "optional": true,
362
+ "os": [
363
+ "android"
364
+ ],
365
+ "engines": {
366
+ "node": ">=12"
367
+ }
368
+ },
369
+ "node_modules/@esbuild/darwin-arm64": {
370
+ "version": "0.21.5",
371
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
372
+ "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
373
+ "cpu": [
374
+ "arm64"
375
+ ],
376
+ "dev": true,
377
+ "license": "MIT",
378
+ "optional": true,
379
+ "os": [
380
+ "darwin"
381
+ ],
382
+ "engines": {
383
+ "node": ">=12"
384
+ }
385
+ },
386
+ "node_modules/@esbuild/darwin-x64": {
387
+ "version": "0.21.5",
388
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz",
389
+ "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==",
390
+ "cpu": [
391
+ "x64"
392
+ ],
393
+ "dev": true,
394
+ "license": "MIT",
395
+ "optional": true,
396
+ "os": [
397
+ "darwin"
398
+ ],
399
+ "engines": {
400
+ "node": ">=12"
401
+ }
402
+ },
403
+ "node_modules/@esbuild/freebsd-arm64": {
404
+ "version": "0.21.5",
405
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz",
406
+ "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==",
407
+ "cpu": [
408
+ "arm64"
409
+ ],
410
+ "dev": true,
411
+ "license": "MIT",
412
+ "optional": true,
413
+ "os": [
414
+ "freebsd"
415
+ ],
416
+ "engines": {
417
+ "node": ">=12"
418
+ }
419
+ },
420
+ "node_modules/@esbuild/freebsd-x64": {
421
+ "version": "0.21.5",
422
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz",
423
+ "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==",
424
+ "cpu": [
425
+ "x64"
426
+ ],
427
+ "dev": true,
428
+ "license": "MIT",
429
+ "optional": true,
430
+ "os": [
431
+ "freebsd"
432
+ ],
433
+ "engines": {
434
+ "node": ">=12"
435
+ }
436
+ },
437
+ "node_modules/@esbuild/linux-arm": {
438
+ "version": "0.21.5",
439
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz",
440
+ "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==",
441
+ "cpu": [
442
+ "arm"
443
+ ],
444
+ "dev": true,
445
+ "license": "MIT",
446
+ "optional": true,
447
+ "os": [
448
+ "linux"
449
+ ],
450
+ "engines": {
451
+ "node": ">=12"
452
+ }
453
+ },
454
+ "node_modules/@esbuild/linux-arm64": {
455
+ "version": "0.21.5",
456
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz",
457
+ "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==",
458
+ "cpu": [
459
+ "arm64"
460
+ ],
461
+ "dev": true,
462
+ "license": "MIT",
463
+ "optional": true,
464
+ "os": [
465
+ "linux"
466
+ ],
467
+ "engines": {
468
+ "node": ">=12"
469
+ }
470
+ },
471
+ "node_modules/@esbuild/linux-ia32": {
472
+ "version": "0.21.5",
473
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz",
474
+ "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==",
475
+ "cpu": [
476
+ "ia32"
477
+ ],
478
+ "dev": true,
479
+ "license": "MIT",
480
+ "optional": true,
481
+ "os": [
482
+ "linux"
483
+ ],
484
+ "engines": {
485
+ "node": ">=12"
486
+ }
487
+ },
488
+ "node_modules/@esbuild/linux-loong64": {
489
+ "version": "0.21.5",
490
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz",
491
+ "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==",
492
+ "cpu": [
493
+ "loong64"
494
+ ],
495
+ "dev": true,
496
+ "license": "MIT",
497
+ "optional": true,
498
+ "os": [
499
+ "linux"
500
+ ],
501
+ "engines": {
502
+ "node": ">=12"
503
+ }
504
+ },
505
+ "node_modules/@esbuild/linux-mips64el": {
506
+ "version": "0.21.5",
507
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz",
508
+ "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==",
509
+ "cpu": [
510
+ "mips64el"
511
+ ],
512
+ "dev": true,
513
+ "license": "MIT",
514
+ "optional": true,
515
+ "os": [
516
+ "linux"
517
+ ],
518
+ "engines": {
519
+ "node": ">=12"
520
+ }
521
+ },
522
+ "node_modules/@esbuild/linux-ppc64": {
523
+ "version": "0.21.5",
524
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz",
525
+ "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==",
526
+ "cpu": [
527
+ "ppc64"
528
+ ],
529
+ "dev": true,
530
+ "license": "MIT",
531
+ "optional": true,
532
+ "os": [
533
+ "linux"
534
+ ],
535
+ "engines": {
536
+ "node": ">=12"
537
+ }
538
+ },
539
+ "node_modules/@esbuild/linux-riscv64": {
540
+ "version": "0.21.5",
541
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz",
542
+ "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==",
543
+ "cpu": [
544
+ "riscv64"
545
+ ],
546
+ "dev": true,
547
+ "license": "MIT",
548
+ "optional": true,
549
+ "os": [
550
+ "linux"
551
+ ],
552
+ "engines": {
553
+ "node": ">=12"
554
+ }
555
+ },
556
+ "node_modules/@esbuild/linux-s390x": {
557
+ "version": "0.21.5",
558
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz",
559
+ "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==",
560
+ "cpu": [
561
+ "s390x"
562
+ ],
563
+ "dev": true,
564
+ "license": "MIT",
565
+ "optional": true,
566
+ "os": [
567
+ "linux"
568
+ ],
569
+ "engines": {
570
+ "node": ">=12"
571
+ }
572
+ },
573
+ "node_modules/@esbuild/linux-x64": {
574
+ "version": "0.21.5",
575
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz",
576
+ "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==",
577
+ "cpu": [
578
+ "x64"
579
+ ],
580
+ "dev": true,
581
+ "license": "MIT",
582
+ "optional": true,
583
+ "os": [
584
+ "linux"
585
+ ],
586
+ "engines": {
587
+ "node": ">=12"
588
+ }
589
+ },
590
+ "node_modules/@esbuild/netbsd-x64": {
591
+ "version": "0.21.5",
592
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz",
593
+ "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==",
594
+ "cpu": [
595
+ "x64"
596
+ ],
597
+ "dev": true,
598
+ "license": "MIT",
599
+ "optional": true,
600
+ "os": [
601
+ "netbsd"
602
+ ],
603
+ "engines": {
604
+ "node": ">=12"
605
+ }
606
+ },
607
+ "node_modules/@esbuild/openbsd-x64": {
608
+ "version": "0.21.5",
609
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz",
610
+ "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==",
611
+ "cpu": [
612
+ "x64"
613
+ ],
614
+ "dev": true,
615
+ "license": "MIT",
616
+ "optional": true,
617
+ "os": [
618
+ "openbsd"
619
+ ],
620
+ "engines": {
621
+ "node": ">=12"
622
+ }
623
+ },
624
+ "node_modules/@esbuild/sunos-x64": {
625
+ "version": "0.21.5",
626
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz",
627
+ "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==",
628
+ "cpu": [
629
+ "x64"
630
+ ],
631
+ "dev": true,
632
+ "license": "MIT",
633
+ "optional": true,
634
+ "os": [
635
+ "sunos"
636
+ ],
637
+ "engines": {
638
+ "node": ">=12"
639
+ }
640
+ },
641
+ "node_modules/@esbuild/win32-arm64": {
642
+ "version": "0.21.5",
643
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz",
644
+ "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==",
645
+ "cpu": [
646
+ "arm64"
647
+ ],
648
+ "dev": true,
649
+ "license": "MIT",
650
+ "optional": true,
651
+ "os": [
652
+ "win32"
653
+ ],
654
+ "engines": {
655
+ "node": ">=12"
656
+ }
657
+ },
658
+ "node_modules/@esbuild/win32-ia32": {
659
+ "version": "0.21.5",
660
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz",
661
+ "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==",
662
+ "cpu": [
663
+ "ia32"
664
+ ],
665
+ "dev": true,
666
+ "license": "MIT",
667
+ "optional": true,
668
+ "os": [
669
+ "win32"
670
+ ],
671
+ "engines": {
672
+ "node": ">=12"
673
+ }
674
+ },
675
+ "node_modules/@esbuild/win32-x64": {
676
+ "version": "0.21.5",
677
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz",
678
+ "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==",
679
+ "cpu": [
680
+ "x64"
681
+ ],
682
+ "dev": true,
683
+ "license": "MIT",
684
+ "optional": true,
685
+ "os": [
686
+ "win32"
687
+ ],
688
+ "engines": {
689
+ "node": ">=12"
690
+ }
691
+ },
692
+ "node_modules/@jridgewell/gen-mapping": {
693
+ "version": "0.3.13",
694
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
695
+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
696
+ "dev": true,
697
+ "license": "MIT",
698
+ "dependencies": {
699
+ "@jridgewell/sourcemap-codec": "^1.5.0",
700
+ "@jridgewell/trace-mapping": "^0.3.24"
701
+ }
702
+ },
703
+ "node_modules/@jridgewell/remapping": {
704
+ "version": "2.3.5",
705
+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
706
+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
707
+ "dev": true,
708
+ "license": "MIT",
709
+ "dependencies": {
710
+ "@jridgewell/gen-mapping": "^0.3.5",
711
+ "@jridgewell/trace-mapping": "^0.3.24"
712
+ }
713
+ },
714
+ "node_modules/@jridgewell/resolve-uri": {
715
+ "version": "3.1.2",
716
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
717
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
718
+ "dev": true,
719
+ "license": "MIT",
720
+ "engines": {
721
+ "node": ">=6.0.0"
722
+ }
723
+ },
724
+ "node_modules/@jridgewell/sourcemap-codec": {
725
+ "version": "1.6.0",
726
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
727
+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
728
+ "dev": true,
729
+ "license": "MIT"
730
+ },
731
+ "node_modules/@jridgewell/trace-mapping": {
732
+ "version": "0.3.31",
733
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
734
+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
735
+ "dev": true,
736
+ "license": "MIT",
737
+ "dependencies": {
738
+ "@jridgewell/resolve-uri": "^3.1.0",
739
+ "@jridgewell/sourcemap-codec": "^1.4.14"
740
+ }
741
+ },
742
+ "node_modules/@napi-rs/lzma-linux-x64-gnu": {
743
+ "version": "1.5.1",
744
+ "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
745
+ "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==",
746
+ "cpu": [
747
+ "x64"
748
+ ],
749
+ "dev": true,
750
+ "libc": [
751
+ "glibc"
752
+ ],
753
+ "license": "MIT",
754
+ "optional": true,
755
+ "os": [
756
+ "linux"
757
+ ],
758
+ "engines": {
759
+ "node": "^22.20 || ^24.12 || >=25"
760
+ }
761
+ },
762
+ "node_modules/@rolldown/pluginutils": {
763
+ "version": "1.0.0-beta.27",
764
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
765
+ "integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==",
766
+ "dev": true,
767
+ "license": "MIT"
768
+ },
769
+ "node_modules/@rollup/rollup-android-arm-eabi": {
770
+ "version": "4.63.6",
771
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.6.tgz",
772
+ "integrity": "sha512-G6xF9OVRWsbHadMfoPNUDwW/Jt70QYG+ZDUvtYCFxjf3SPhqVAO0u9ShXZ7Cf5silVoRWyN4bDjCEKnJkXkw0w==",
773
+ "cpu": [
774
+ "arm"
775
+ ],
776
+ "dev": true,
777
+ "license": "MIT",
778
+ "optional": true,
779
+ "os": [
780
+ "android"
781
+ ]
782
+ },
783
+ "node_modules/@rollup/rollup-android-arm64": {
784
+ "version": "4.63.6",
785
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.6.tgz",
786
+ "integrity": "sha512-Us/kTH5e2anr1CQvO8MEq4eeCVcIXI3Ag7OFxDI30n2OW7Q7xWuxo8ItbYq28PG2Sm1NWmZzG9+SqVEaj25SFA==",
787
+ "cpu": [
788
+ "arm64"
789
+ ],
790
+ "dev": true,
791
+ "license": "MIT",
792
+ "optional": true,
793
+ "os": [
794
+ "android"
795
+ ]
796
+ },
797
+ "node_modules/@rollup/rollup-darwin-arm64": {
798
+ "version": "4.63.6",
799
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.6.tgz",
800
+ "integrity": "sha512-fwaSNrSHp9PJuEh4bKtd0mYC+G3FeVDjSTmsSiSlIYu7TFCpxrfB6lk7Ao8cIbswFyklPB1ZDUV8LkLBM15VWw==",
801
+ "cpu": [
802
+ "arm64"
803
+ ],
804
+ "dev": true,
805
+ "license": "MIT",
806
+ "optional": true,
807
+ "os": [
808
+ "darwin"
809
+ ]
810
+ },
811
+ "node_modules/@rollup/rollup-darwin-x64": {
812
+ "version": "4.63.6",
813
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.6.tgz",
814
+ "integrity": "sha512-QR2tx26gCeGh4eAGnUasfnJuRc+d7Vc0Jo1/fYtKGuiKqCuhbVpbNEvqgYGBwGDZGyS04jj+zdHi9W8uvb1Sdw==",
815
+ "cpu": [
816
+ "x64"
817
+ ],
818
+ "dev": true,
819
+ "license": "MIT",
820
+ "optional": true,
821
+ "os": [
822
+ "darwin"
823
+ ]
824
+ },
825
+ "node_modules/@rollup/rollup-freebsd-arm64": {
826
+ "version": "4.63.6",
827
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.6.tgz",
828
+ "integrity": "sha512-7E1wRJEW8r7WlqmCy58ugndWHrzoEV/pRt2x0D9el7Inra62+Cw00lYW9XhW6iUCtFjhNw49McsSCIzJ/nG8uw==",
829
+ "cpu": [
830
+ "arm64"
831
+ ],
832
+ "dev": true,
833
+ "license": "MIT",
834
+ "optional": true,
835
+ "os": [
836
+ "freebsd"
837
+ ]
838
+ },
839
+ "node_modules/@rollup/rollup-freebsd-x64": {
840
+ "version": "4.63.6",
841
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.6.tgz",
842
+ "integrity": "sha512-13KJeF+vDswMzEHmMIouCVcEQdov3CzAA3ZhM8QFmBJV/FZ/VMZI49UHDvPXTK+wokk86kYPmQ9Qb3xGGJbZoQ==",
843
+ "cpu": [
844
+ "x64"
845
+ ],
846
+ "dev": true,
847
+ "license": "MIT",
848
+ "optional": true,
849
+ "os": [
850
+ "freebsd"
851
+ ]
852
+ },
853
+ "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
854
+ "version": "4.63.6",
855
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.6.tgz",
856
+ "integrity": "sha512-hV+W1r8HM84PER4If94QuzrrD0DNk4CxobNhVUiz9ZiiWHDzJss4Jra2AYGH1a7GOTzjS1sIyZ35yYEhw/aq+g==",
857
+ "cpu": [
858
+ "arm"
859
+ ],
860
+ "dev": true,
861
+ "libc": [
862
+ "glibc"
863
+ ],
864
+ "license": "MIT",
865
+ "optional": true,
866
+ "os": [
867
+ "linux"
868
+ ]
869
+ },
870
+ "node_modules/@rollup/rollup-linux-arm-musleabihf": {
871
+ "version": "4.63.6",
872
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.6.tgz",
873
+ "integrity": "sha512-5dWs/GENZufRph8PEfl0TrNH/R3DHJA+VxF/dqlfV2oUZfxRtN3qmFXg2DZj8DYM8d+Vd3dgZtuVmoBE/nb2YQ==",
874
+ "cpu": [
875
+ "arm"
876
+ ],
877
+ "dev": true,
878
+ "libc": [
879
+ "musl"
880
+ ],
881
+ "license": "MIT",
882
+ "optional": true,
883
+ "os": [
884
+ "linux"
885
+ ]
886
+ },
887
+ "node_modules/@rollup/rollup-linux-arm64-gnu": {
888
+ "version": "4.63.6",
889
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.6.tgz",
890
+ "integrity": "sha512-inQYLPVIUvYk+s7zpxQldqwrajUNs+t4TJjPGzsdPTvsT8gsQXVcW/sQFolHZ3YSWVk0nMMwU7TtRi0Ow+QMuw==",
891
+ "cpu": [
892
+ "arm64"
893
+ ],
894
+ "dev": true,
895
+ "libc": [
896
+ "glibc"
897
+ ],
898
+ "license": "MIT",
899
+ "optional": true,
900
+ "os": [
901
+ "linux"
902
+ ]
903
+ },
904
+ "node_modules/@rollup/rollup-linux-arm64-musl": {
905
+ "version": "4.63.6",
906
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.6.tgz",
907
+ "integrity": "sha512-sH+0MV1HmDC1q7+bQnlN9ywKBmHqkA2EdD/hHYrrz654ybc+vNC1FRNyzuYKicMQVtZZ4X2jz0osJYmsOtnj4g==",
908
+ "cpu": [
909
+ "arm64"
910
+ ],
911
+ "dev": true,
912
+ "libc": [
913
+ "musl"
914
+ ],
915
+ "license": "MIT",
916
+ "optional": true,
917
+ "os": [
918
+ "linux"
919
+ ]
920
+ },
921
+ "node_modules/@rollup/rollup-linux-loong64-gnu": {
922
+ "version": "4.63.6",
923
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.6.tgz",
924
+ "integrity": "sha512-mCECvRr6HGekdBc6dvHzUWubqEti4JyOqlNePrOzl4Wimk26iW5Zy9rld2mQbC9id1NYjfF8nHLFq5fr3CuOKQ==",
925
+ "cpu": [
926
+ "loong64"
927
+ ],
928
+ "dev": true,
929
+ "libc": [
930
+ "glibc"
931
+ ],
932
+ "license": "MIT",
933
+ "optional": true,
934
+ "os": [
935
+ "linux"
936
+ ]
937
+ },
938
+ "node_modules/@rollup/rollup-linux-loong64-musl": {
939
+ "version": "4.63.6",
940
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.6.tgz",
941
+ "integrity": "sha512-bb9rdoCPwM4DEsbOP3CJgFnvhSJ3XKCUYyUhxnlSs/XGT0DknpOYgLCPbK8VUzwl+cZGzFQm0KbBYRaSGZC2YQ==",
942
+ "cpu": [
943
+ "loong64"
944
+ ],
945
+ "dev": true,
946
+ "libc": [
947
+ "musl"
948
+ ],
949
+ "license": "MIT",
950
+ "optional": true,
951
+ "os": [
952
+ "linux"
953
+ ]
954
+ },
955
+ "node_modules/@rollup/rollup-linux-ppc64-gnu": {
956
+ "version": "4.63.6",
957
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.6.tgz",
958
+ "integrity": "sha512-aIJRoGCHev45JSu7JMzVrMzu1NX3nQrXx1Vb/6y4AblxW7JpCMpk4e8C6lHzvSElxi3UEcMdFJldsuWQjV1ddA==",
959
+ "cpu": [
960
+ "ppc64"
961
+ ],
962
+ "dev": true,
963
+ "libc": [
964
+ "glibc"
965
+ ],
966
+ "license": "MIT",
967
+ "optional": true,
968
+ "os": [
969
+ "linux"
970
+ ]
971
+ },
972
+ "node_modules/@rollup/rollup-linux-ppc64-musl": {
973
+ "version": "4.63.6",
974
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.6.tgz",
975
+ "integrity": "sha512-LvjnulezHjiaM5Ga9MPCDLTVddjvcrJhZc6vEz9fxeFRGPJsPAX9HuTuPTUQ3l8d+nYpZB/xWzUpuKJlLQm3VQ==",
976
+ "cpu": [
977
+ "ppc64"
978
+ ],
979
+ "dev": true,
980
+ "libc": [
981
+ "musl"
982
+ ],
983
+ "license": "MIT",
984
+ "optional": true,
985
+ "os": [
986
+ "linux"
987
+ ]
988
+ },
989
+ "node_modules/@rollup/rollup-linux-riscv64-gnu": {
990
+ "version": "4.63.6",
991
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.6.tgz",
992
+ "integrity": "sha512-YmhSBeYZwJ937s8tKpYAhms48N+tj7e+oFkbkVVxfMRdAiynK2AxqRapJXB4utyXxc/iYTkMfPRQ+7ZP0IO78w==",
993
+ "cpu": [
994
+ "riscv64"
995
+ ],
996
+ "dev": true,
997
+ "libc": [
998
+ "glibc"
999
+ ],
1000
+ "license": "MIT",
1001
+ "optional": true,
1002
+ "os": [
1003
+ "linux"
1004
+ ]
1005
+ },
1006
+ "node_modules/@rollup/rollup-linux-riscv64-musl": {
1007
+ "version": "4.63.6",
1008
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.6.tgz",
1009
+ "integrity": "sha512-9+YukhzqTvJvzfDXJJzkURK9TDY01nofNH3pyHGuucGC4xPvBVtIfCAqJjkjnmBEGJYNXB8sBc2EDt7xDgGenw==",
1010
+ "cpu": [
1011
+ "riscv64"
1012
+ ],
1013
+ "dev": true,
1014
+ "libc": [
1015
+ "musl"
1016
+ ],
1017
+ "license": "MIT",
1018
+ "optional": true,
1019
+ "os": [
1020
+ "linux"
1021
+ ]
1022
+ },
1023
+ "node_modules/@rollup/rollup-linux-s390x-gnu": {
1024
+ "version": "4.63.6",
1025
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.6.tgz",
1026
+ "integrity": "sha512-9G5AtEkpN/A89BILHHEL9aYRYTuFjwa8PUQqoEg8SDrwOZBKpwYqNlQCBNI5QPwGrf7qFlb6LNFilo8FCSA3Wg==",
1027
+ "cpu": [
1028
+ "s390x"
1029
+ ],
1030
+ "dev": true,
1031
+ "libc": [
1032
+ "glibc"
1033
+ ],
1034
+ "license": "MIT",
1035
+ "optional": true,
1036
+ "os": [
1037
+ "linux"
1038
+ ]
1039
+ },
1040
+ "node_modules/@rollup/rollup-linux-x64-gnu": {
1041
+ "version": "4.63.6",
1042
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.6.tgz",
1043
+ "integrity": "sha512-Ezx2E5D6Siz805j41x91JiGbzuCm8i2U98U37SQ7ytY737+wsJq+P9nPL6UmqDww491zO7MTivYOTrtmTTeCSw==",
1044
+ "cpu": [
1045
+ "x64"
1046
+ ],
1047
+ "dev": true,
1048
+ "libc": [
1049
+ "glibc"
1050
+ ],
1051
+ "license": "MIT",
1052
+ "optional": true,
1053
+ "os": [
1054
+ "linux"
1055
+ ]
1056
+ },
1057
+ "node_modules/@rollup/rollup-linux-x64-musl": {
1058
+ "version": "4.63.6",
1059
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.6.tgz",
1060
+ "integrity": "sha512-8EZ1Q3PB7yUjvR4MbFAnCBF1wF0XRe5QQqbtlJXP7ZX5C8iYlSQJugUhj9oS0gbUP4jp9qGhaIgFnV9Nvod86Q==",
1061
+ "cpu": [
1062
+ "x64"
1063
+ ],
1064
+ "dev": true,
1065
+ "libc": [
1066
+ "musl"
1067
+ ],
1068
+ "license": "MIT",
1069
+ "optional": true,
1070
+ "os": [
1071
+ "linux"
1072
+ ]
1073
+ },
1074
+ "node_modules/@rollup/rollup-openbsd-x64": {
1075
+ "version": "4.63.6",
1076
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.6.tgz",
1077
+ "integrity": "sha512-3JI27TALItfZ/qaxXKdbRXfV6WepUoUa3IN07FE+1xxoRdl3JIyrp5PiDF0vOHsPgEiOFkF8s3B3BRymQkdwGA==",
1078
+ "cpu": [
1079
+ "x64"
1080
+ ],
1081
+ "dev": true,
1082
+ "license": "MIT",
1083
+ "optional": true,
1084
+ "os": [
1085
+ "openbsd"
1086
+ ]
1087
+ },
1088
+ "node_modules/@rollup/rollup-openharmony-arm64": {
1089
+ "version": "4.63.6",
1090
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.6.tgz",
1091
+ "integrity": "sha512-BNOGeNFNRZDT7Hfc7b9JbTZFXkpAXeXl/CZWtxdd5CNfBaor/0RkJjg+q+E2gwVIvGqqp/NclThKFGrhuScVhw==",
1092
+ "cpu": [
1093
+ "arm64"
1094
+ ],
1095
+ "dev": true,
1096
+ "license": "MIT",
1097
+ "optional": true,
1098
+ "os": [
1099
+ "openharmony"
1100
+ ]
1101
+ },
1102
+ "node_modules/@rollup/rollup-win32-arm64-msvc": {
1103
+ "version": "4.63.6",
1104
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.6.tgz",
1105
+ "integrity": "sha512-D3eEyLSIim5WF5fHbwnx+ryk0delN7fJyBrDTO3wVCCNBZ/cA8aCGwLS3SiuK+vRI4E7dqikAlStGuR20dBMuw==",
1106
+ "cpu": [
1107
+ "arm64"
1108
+ ],
1109
+ "dev": true,
1110
+ "license": "MIT",
1111
+ "optional": true,
1112
+ "os": [
1113
+ "win32"
1114
+ ]
1115
+ },
1116
+ "node_modules/@rollup/rollup-win32-ia32-msvc": {
1117
+ "version": "4.63.6",
1118
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.6.tgz",
1119
+ "integrity": "sha512-xwbs9g8zLbHzj1poG1uh27xtubsu27Gk2nuN6kvvGDybjiTfwMksQAnF+phlvI5oeXkJWWDc6kg1t3XpgUYvrg==",
1120
+ "cpu": [
1121
+ "ia32"
1122
+ ],
1123
+ "dev": true,
1124
+ "license": "MIT",
1125
+ "optional": true,
1126
+ "os": [
1127
+ "win32"
1128
+ ]
1129
+ },
1130
+ "node_modules/@rollup/rollup-win32-x64-gnu": {
1131
+ "version": "4.63.6",
1132
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.6.tgz",
1133
+ "integrity": "sha512-Tr6rhRNnFthvXr45zWVZQ5P8jZ5UwZnXNc7Qnu80cP/VVYtSioOPmvv7wP6UMgRfkBCJr2Pm60ua0YBDSJjgnw==",
1134
+ "cpu": [
1135
+ "x64"
1136
+ ],
1137
+ "dev": true,
1138
+ "license": "MIT",
1139
+ "optional": true,
1140
+ "os": [
1141
+ "win32"
1142
+ ]
1143
+ },
1144
+ "node_modules/@rollup/rollup-win32-x64-msvc": {
1145
+ "version": "4.63.6",
1146
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.6.tgz",
1147
+ "integrity": "sha512-0RAxO1pS/6lY1mSoD2Apm+6aPyfUlm+OWKgncIdj/eVN9I+pDY3lKgD7xsUNFei1u7MZQETGOo6m8POXMDp53A==",
1148
+ "cpu": [
1149
+ "x64"
1150
+ ],
1151
+ "dev": true,
1152
+ "license": "MIT",
1153
+ "optional": true,
1154
+ "os": [
1155
+ "win32"
1156
+ ]
1157
+ },
1158
+ "node_modules/@types/babel__core": {
1159
+ "version": "7.20.5",
1160
+ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
1161
+ "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",
1162
+ "dev": true,
1163
+ "license": "MIT",
1164
+ "dependencies": {
1165
+ "@babel/parser": "^7.20.7",
1166
+ "@babel/types": "^7.20.7",
1167
+ "@types/babel__generator": "*",
1168
+ "@types/babel__template": "*",
1169
+ "@types/babel__traverse": "*"
1170
+ }
1171
+ },
1172
+ "node_modules/@types/babel__generator": {
1173
+ "version": "7.27.0",
1174
+ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz",
1175
+ "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==",
1176
+ "dev": true,
1177
+ "license": "MIT",
1178
+ "dependencies": {
1179
+ "@babel/types": "^7.0.0"
1180
+ }
1181
+ },
1182
+ "node_modules/@types/babel__template": {
1183
+ "version": "7.4.4",
1184
+ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
1185
+ "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
1186
+ "dev": true,
1187
+ "license": "MIT",
1188
+ "dependencies": {
1189
+ "@babel/parser": "^7.1.0",
1190
+ "@babel/types": "^7.0.0"
1191
+ }
1192
+ },
1193
+ "node_modules/@types/babel__traverse": {
1194
+ "version": "7.28.0",
1195
+ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz",
1196
+ "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==",
1197
+ "dev": true,
1198
+ "license": "MIT",
1199
+ "dependencies": {
1200
+ "@babel/types": "^7.28.2"
1201
+ }
1202
+ },
1203
+ "node_modules/@types/estree": {
1204
+ "version": "1.0.9",
1205
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
1206
+ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
1207
+ "dev": true,
1208
+ "license": "MIT"
1209
+ },
1210
+ "node_modules/@vitejs/plugin-react": {
1211
+ "version": "4.7.0",
1212
+ "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
1213
+ "integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==",
1214
+ "dev": true,
1215
+ "license": "MIT",
1216
+ "dependencies": {
1217
+ "@babel/core": "^7.28.0",
1218
+ "@babel/plugin-transform-react-jsx-self": "^7.27.1",
1219
+ "@babel/plugin-transform-react-jsx-source": "^7.27.1",
1220
+ "@rolldown/pluginutils": "1.0.0-beta.27",
1221
+ "@types/babel__core": "^7.20.5",
1222
+ "react-refresh": "^0.17.0"
1223
+ },
1224
+ "engines": {
1225
+ "node": "^14.18.0 || >=16.0.0"
1226
+ },
1227
+ "peerDependencies": {
1228
+ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
1229
+ }
1230
+ },
1231
+ "node_modules/baseline-browser-mapping": {
1232
+ "version": "2.11.27",
1233
+ "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.27.tgz",
1234
+ "integrity": "sha512-ElY12DaROGuan+lMmZ8Cvo/ZUbXPe7Enc/9VU/b1T3Kp4dwytRcNdR8DoSJN5SNJT/CuvcCA0DHDVmMOCePdRQ==",
1235
+ "dev": true,
1236
+ "license": "Apache-2.0",
1237
+ "bin": {
1238
+ "baseline-browser-mapping": "dist/cli.cjs"
1239
+ },
1240
+ "engines": {
1241
+ "node": ">=6.0.0"
1242
+ }
1243
+ },
1244
+ "node_modules/browserslist": {
1245
+ "version": "4.29.3",
1246
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.3.tgz",
1247
+ "integrity": "sha512-1R4kiYKXGViqEN0CnoDrXc1StD9niAwu+j2dukWzrD4bJgsD4lDmEp0CRbc6E/vYJIfTHwPmwyaKtVSudICdPA==",
1248
+ "dev": true,
1249
+ "funding": [
1250
+ {
1251
+ "type": "opencollective",
1252
+ "url": "https://opencollective.com/browserslist"
1253
+ },
1254
+ {
1255
+ "type": "tidelift",
1256
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
1257
+ },
1258
+ {
1259
+ "type": "github",
1260
+ "url": "https://github.com/sponsors/ai"
1261
+ }
1262
+ ],
1263
+ "license": "MIT",
1264
+ "dependencies": {
1265
+ "baseline-browser-mapping": "^2.11.26",
1266
+ "caniuse-lite": "^1.0.30001813",
1267
+ "electron-to-chromium": "^1.5.439",
1268
+ "node-releases": "^2.0.57",
1269
+ "update-browserslist-db": "^1.3.3"
1270
+ },
1271
+ "bin": {
1272
+ "browserslist": "cli.js"
1273
+ },
1274
+ "engines": {
1275
+ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
1276
+ }
1277
+ },
1278
+ "node_modules/caniuse-lite": {
1279
+ "version": "1.0.30001814",
1280
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001814.tgz",
1281
+ "integrity": "sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==",
1282
+ "dev": true,
1283
+ "funding": [
1284
+ {
1285
+ "type": "opencollective",
1286
+ "url": "https://opencollective.com/browserslist"
1287
+ },
1288
+ {
1289
+ "type": "tidelift",
1290
+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
1291
+ },
1292
+ {
1293
+ "type": "github",
1294
+ "url": "https://github.com/sponsors/ai"
1295
+ }
1296
+ ],
1297
+ "license": "CC-BY-4.0"
1298
+ },
1299
+ "node_modules/convert-source-map": {
1300
+ "version": "2.0.0",
1301
+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
1302
+ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
1303
+ "dev": true,
1304
+ "license": "MIT"
1305
+ },
1306
+ "node_modules/debug": {
1307
+ "version": "4.4.3",
1308
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
1309
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
1310
+ "dev": true,
1311
+ "license": "MIT",
1312
+ "dependencies": {
1313
+ "ms": "^2.1.3"
1314
+ },
1315
+ "engines": {
1316
+ "node": ">=6.0"
1317
+ },
1318
+ "peerDependenciesMeta": {
1319
+ "supports-color": {
1320
+ "optional": true
1321
+ }
1322
+ }
1323
+ },
1324
+ "node_modules/electron-to-chromium": {
1325
+ "version": "1.5.444",
1326
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.444.tgz",
1327
+ "integrity": "sha512-5ss/uJfoDYDHT0lfJzT6FbcskIzROIOPf0BbbFkGcvDzoJU7i//9GDrwwIHQVmIsrAGiF3ihpADBRIsrEFt1rQ==",
1328
+ "dev": true,
1329
+ "license": "ISC"
1330
+ },
1331
+ "node_modules/esbuild": {
1332
+ "version": "0.21.5",
1333
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
1334
+ "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==",
1335
+ "dev": true,
1336
+ "hasInstallScript": true,
1337
+ "license": "MIT",
1338
+ "bin": {
1339
+ "esbuild": "bin/esbuild"
1340
+ },
1341
+ "engines": {
1342
+ "node": ">=12"
1343
+ },
1344
+ "optionalDependencies": {
1345
+ "@esbuild/aix-ppc64": "0.21.5",
1346
+ "@esbuild/android-arm": "0.21.5",
1347
+ "@esbuild/android-arm64": "0.21.5",
1348
+ "@esbuild/android-x64": "0.21.5",
1349
+ "@esbuild/darwin-arm64": "0.21.5",
1350
+ "@esbuild/darwin-x64": "0.21.5",
1351
+ "@esbuild/freebsd-arm64": "0.21.5",
1352
+ "@esbuild/freebsd-x64": "0.21.5",
1353
+ "@esbuild/linux-arm": "0.21.5",
1354
+ "@esbuild/linux-arm64": "0.21.5",
1355
+ "@esbuild/linux-ia32": "0.21.5",
1356
+ "@esbuild/linux-loong64": "0.21.5",
1357
+ "@esbuild/linux-mips64el": "0.21.5",
1358
+ "@esbuild/linux-ppc64": "0.21.5",
1359
+ "@esbuild/linux-riscv64": "0.21.5",
1360
+ "@esbuild/linux-s390x": "0.21.5",
1361
+ "@esbuild/linux-x64": "0.21.5",
1362
+ "@esbuild/netbsd-x64": "0.21.5",
1363
+ "@esbuild/openbsd-x64": "0.21.5",
1364
+ "@esbuild/sunos-x64": "0.21.5",
1365
+ "@esbuild/win32-arm64": "0.21.5",
1366
+ "@esbuild/win32-ia32": "0.21.5",
1367
+ "@esbuild/win32-x64": "0.21.5"
1368
+ }
1369
+ },
1370
+ "node_modules/escalade": {
1371
+ "version": "3.2.0",
1372
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
1373
+ "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
1374
+ "dev": true,
1375
+ "license": "MIT",
1376
+ "engines": {
1377
+ "node": ">=6"
1378
+ }
1379
+ },
1380
+ "node_modules/fsevents": {
1381
+ "version": "2.3.3",
1382
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
1383
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
1384
+ "dev": true,
1385
+ "hasInstallScript": true,
1386
+ "license": "MIT",
1387
+ "optional": true,
1388
+ "os": [
1389
+ "darwin"
1390
+ ],
1391
+ "engines": {
1392
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
1393
+ }
1394
+ },
1395
+ "node_modules/gensync": {
1396
+ "version": "1.0.0-beta.2",
1397
+ "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
1398
+ "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
1399
+ "dev": true,
1400
+ "license": "MIT",
1401
+ "engines": {
1402
+ "node": ">=6.9.0"
1403
+ }
1404
+ },
1405
+ "node_modules/js-tokens": {
1406
+ "version": "4.0.0",
1407
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
1408
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
1409
+ "license": "MIT"
1410
+ },
1411
+ "node_modules/jsesc": {
1412
+ "version": "3.1.0",
1413
+ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
1414
+ "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
1415
+ "dev": true,
1416
+ "license": "MIT",
1417
+ "bin": {
1418
+ "jsesc": "bin/jsesc"
1419
+ },
1420
+ "engines": {
1421
+ "node": ">=6"
1422
+ }
1423
+ },
1424
+ "node_modules/json5": {
1425
+ "version": "2.2.3",
1426
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
1427
+ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
1428
+ "dev": true,
1429
+ "license": "MIT",
1430
+ "bin": {
1431
+ "json5": "lib/cli.js"
1432
+ },
1433
+ "engines": {
1434
+ "node": ">=6"
1435
+ }
1436
+ },
1437
+ "node_modules/loose-envify": {
1438
+ "version": "1.4.0",
1439
+ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
1440
+ "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
1441
+ "license": "MIT",
1442
+ "dependencies": {
1443
+ "js-tokens": "^3.0.0 || ^4.0.0"
1444
+ },
1445
+ "bin": {
1446
+ "loose-envify": "cli.js"
1447
+ }
1448
+ },
1449
+ "node_modules/lru-cache": {
1450
+ "version": "5.1.1",
1451
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
1452
+ "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
1453
+ "dev": true,
1454
+ "license": "ISC",
1455
+ "dependencies": {
1456
+ "yallist": "^3.0.2"
1457
+ }
1458
+ },
1459
+ "node_modules/ms": {
1460
+ "version": "2.1.3",
1461
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1462
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1463
+ "dev": true,
1464
+ "license": "MIT"
1465
+ },
1466
+ "node_modules/nanoid": {
1467
+ "version": "3.3.19",
1468
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
1469
+ "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==",
1470
+ "dev": true,
1471
+ "funding": [
1472
+ {
1473
+ "type": "github",
1474
+ "url": "https://github.com/sponsors/ai"
1475
+ }
1476
+ ],
1477
+ "license": "MIT",
1478
+ "bin": {
1479
+ "nanoid": "bin/nanoid.cjs"
1480
+ },
1481
+ "engines": {
1482
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
1483
+ }
1484
+ },
1485
+ "node_modules/node-releases": {
1486
+ "version": "2.0.57",
1487
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.57.tgz",
1488
+ "integrity": "sha512-kQK9LGGFiHtrWiNhZtA7Qbw17AQz+dmsEKODRIVTXA9+e5MS/2gZEBhYJt13GrAz5/IOZKddH/0Z3TP/Zgo+yw==",
1489
+ "dev": true,
1490
+ "license": "MIT",
1491
+ "engines": {
1492
+ "node": ">=18"
1493
+ }
1494
+ },
1495
+ "node_modules/picocolors": {
1496
+ "version": "1.1.1",
1497
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
1498
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
1499
+ "dev": true,
1500
+ "license": "ISC"
1501
+ },
1502
+ "node_modules/postcss": {
1503
+ "version": "8.5.28",
1504
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",
1505
+ "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",
1506
+ "dev": true,
1507
+ "funding": [
1508
+ {
1509
+ "type": "opencollective",
1510
+ "url": "https://opencollective.com/postcss/"
1511
+ },
1512
+ {
1513
+ "type": "tidelift",
1514
+ "url": "https://tidelift.com/funding/github/npm/postcss"
1515
+ },
1516
+ {
1517
+ "type": "github",
1518
+ "url": "https://github.com/sponsors/ai"
1519
+ }
1520
+ ],
1521
+ "license": "MIT",
1522
+ "dependencies": {
1523
+ "nanoid": "^3.3.18",
1524
+ "picocolors": "^1.1.1",
1525
+ "source-map-js": "^1.2.1"
1526
+ },
1527
+ "engines": {
1528
+ "node": "^10 || ^12 || >=14"
1529
+ }
1530
+ },
1531
+ "node_modules/react": {
1532
+ "version": "18.3.1",
1533
+ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
1534
+ "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
1535
+ "license": "MIT",
1536
+ "dependencies": {
1537
+ "loose-envify": "^1.1.0"
1538
+ },
1539
+ "engines": {
1540
+ "node": ">=0.10.0"
1541
+ }
1542
+ },
1543
+ "node_modules/react-dom": {
1544
+ "version": "18.3.1",
1545
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
1546
+ "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
1547
+ "license": "MIT",
1548
+ "dependencies": {
1549
+ "loose-envify": "^1.1.0",
1550
+ "scheduler": "^0.23.2"
1551
+ },
1552
+ "peerDependencies": {
1553
+ "react": "^18.3.1"
1554
+ }
1555
+ },
1556
+ "node_modules/react-refresh": {
1557
+ "version": "0.17.0",
1558
+ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
1559
+ "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==",
1560
+ "dev": true,
1561
+ "license": "MIT",
1562
+ "engines": {
1563
+ "node": ">=0.10.0"
1564
+ }
1565
+ },
1566
+ "node_modules/rollup": {
1567
+ "version": "4.63.6",
1568
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.6.tgz",
1569
+ "integrity": "sha512-w4+GKyTBqshj84F1GF3s2zxAPFZPEmNkCbQtqilsYS7GsksmX6VoV7UggfZg8sUHCCOkBe7UtQp6fZwbH311FQ==",
1570
+ "dev": true,
1571
+ "license": "MIT",
1572
+ "dependencies": {
1573
+ "@types/estree": "1.0.9"
1574
+ },
1575
+ "bin": {
1576
+ "rollup": "dist/bin/rollup"
1577
+ },
1578
+ "engines": {
1579
+ "node": ">=18.0.0",
1580
+ "npm": ">=8.0.0"
1581
+ },
1582
+ "optionalDependencies": {
1583
+ "@napi-rs/lzma-linux-x64-gnu": "1.5.1",
1584
+ "@rollup/rollup-android-arm-eabi": "4.63.6",
1585
+ "@rollup/rollup-android-arm64": "4.63.6",
1586
+ "@rollup/rollup-darwin-arm64": "4.63.6",
1587
+ "@rollup/rollup-darwin-x64": "4.63.6",
1588
+ "@rollup/rollup-freebsd-arm64": "4.63.6",
1589
+ "@rollup/rollup-freebsd-x64": "4.63.6",
1590
+ "@rollup/rollup-linux-arm-gnueabihf": "4.63.6",
1591
+ "@rollup/rollup-linux-arm-musleabihf": "4.63.6",
1592
+ "@rollup/rollup-linux-arm64-gnu": "4.63.6",
1593
+ "@rollup/rollup-linux-arm64-musl": "4.63.6",
1594
+ "@rollup/rollup-linux-loong64-gnu": "4.63.6",
1595
+ "@rollup/rollup-linux-loong64-musl": "4.63.6",
1596
+ "@rollup/rollup-linux-ppc64-gnu": "4.63.6",
1597
+ "@rollup/rollup-linux-ppc64-musl": "4.63.6",
1598
+ "@rollup/rollup-linux-riscv64-gnu": "4.63.6",
1599
+ "@rollup/rollup-linux-riscv64-musl": "4.63.6",
1600
+ "@rollup/rollup-linux-s390x-gnu": "4.63.6",
1601
+ "@rollup/rollup-linux-x64-gnu": "4.63.6",
1602
+ "@rollup/rollup-linux-x64-musl": "4.63.6",
1603
+ "@rollup/rollup-openbsd-x64": "4.63.6",
1604
+ "@rollup/rollup-openharmony-arm64": "4.63.6",
1605
+ "@rollup/rollup-win32-arm64-msvc": "4.63.6",
1606
+ "@rollup/rollup-win32-ia32-msvc": "4.63.6",
1607
+ "@rollup/rollup-win32-x64-gnu": "4.63.6",
1608
+ "@rollup/rollup-win32-x64-msvc": "4.63.6",
1609
+ "fsevents": "~2.3.2"
1610
+ }
1611
+ },
1612
+ "node_modules/scheduler": {
1613
+ "version": "0.23.2",
1614
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
1615
+ "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
1616
+ "license": "MIT",
1617
+ "dependencies": {
1618
+ "loose-envify": "^1.1.0"
1619
+ }
1620
+ },
1621
+ "node_modules/semver": {
1622
+ "version": "6.3.1",
1623
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
1624
+ "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
1625
+ "dev": true,
1626
+ "license": "ISC",
1627
+ "bin": {
1628
+ "semver": "bin/semver.js"
1629
+ }
1630
+ },
1631
+ "node_modules/source-map-js": {
1632
+ "version": "1.2.2",
1633
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
1634
+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
1635
+ "dev": true,
1636
+ "license": "BSD-3-Clause",
1637
+ "engines": {
1638
+ "node": ">=0.10.0"
1639
+ }
1640
+ },
1641
+ "node_modules/update-browserslist-db": {
1642
+ "version": "1.3.3",
1643
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
1644
+ "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
1645
+ "dev": true,
1646
+ "funding": [
1647
+ {
1648
+ "type": "opencollective",
1649
+ "url": "https://opencollective.com/browserslist"
1650
+ },
1651
+ {
1652
+ "type": "tidelift",
1653
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
1654
+ },
1655
+ {
1656
+ "type": "github",
1657
+ "url": "https://github.com/sponsors/ai"
1658
+ }
1659
+ ],
1660
+ "license": "MIT",
1661
+ "dependencies": {
1662
+ "escalade": "^3.2.0",
1663
+ "picocolors": "^1.1.1"
1664
+ },
1665
+ "bin": {
1666
+ "update-browserslist-db": "cli.js"
1667
+ },
1668
+ "peerDependencies": {
1669
+ "browserslist": ">= 4.21.0"
1670
+ }
1671
+ },
1672
+ "node_modules/vite": {
1673
+ "version": "5.4.21",
1674
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
1675
+ "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
1676
+ "dev": true,
1677
+ "license": "MIT",
1678
+ "dependencies": {
1679
+ "esbuild": "^0.21.3",
1680
+ "postcss": "^8.4.43",
1681
+ "rollup": "^4.20.0"
1682
+ },
1683
+ "bin": {
1684
+ "vite": "bin/vite.js"
1685
+ },
1686
+ "engines": {
1687
+ "node": "^18.0.0 || >=20.0.0"
1688
+ },
1689
+ "funding": {
1690
+ "url": "https://github.com/vitejs/vite?sponsor=1"
1691
+ },
1692
+ "optionalDependencies": {
1693
+ "fsevents": "~2.3.3"
1694
+ },
1695
+ "peerDependencies": {
1696
+ "@types/node": "^18.0.0 || >=20.0.0",
1697
+ "less": "*",
1698
+ "lightningcss": "^1.21.0",
1699
+ "sass": "*",
1700
+ "sass-embedded": "*",
1701
+ "stylus": "*",
1702
+ "sugarss": "*",
1703
+ "terser": "^5.4.0"
1704
+ },
1705
+ "peerDependenciesMeta": {
1706
+ "@types/node": {
1707
+ "optional": true
1708
+ },
1709
+ "less": {
1710
+ "optional": true
1711
+ },
1712
+ "lightningcss": {
1713
+ "optional": true
1714
+ },
1715
+ "sass": {
1716
+ "optional": true
1717
+ },
1718
+ "sass-embedded": {
1719
+ "optional": true
1720
+ },
1721
+ "stylus": {
1722
+ "optional": true
1723
+ },
1724
+ "sugarss": {
1725
+ "optional": true
1726
+ },
1727
+ "terser": {
1728
+ "optional": true
1729
+ }
1730
+ }
1731
+ },
1732
+ "node_modules/yallist": {
1733
+ "version": "3.1.1",
1734
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
1735
+ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
1736
+ "dev": true,
1737
+ "license": "ISC"
1738
+ }
1739
+ }
1740
+ }
studio/package.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "diffweave-studio",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite --port 5174",
7
+ "build": "vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.2.0",
12
+ "react-dom": "^18.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "@vitejs/plugin-react": "^4.2.0",
16
+ "vite": "^5.0.0"
17
+ }
18
+ }
studio/src/App.jsx ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
+ import { api } from './api/client';
3
+ import Navbar from './components/Navbar';
4
+ import SemanticDiffViewer from './components/SemanticDiffViewer';
5
+ import PRReviewDeck from './components/PRReviewDeck';
6
+ import IngestionStaging from './components/IngestionStaging';
7
+ import KnowledgeGraph from './components/KnowledgeGraph';
8
+ import KnowledgeBase from './components/KnowledgeBase';
9
+ import PolicyRulesLab from './components/PolicyRulesLab';
10
+ import AuditLog from './components/AuditLog';
11
+
12
+ export default function App() {
13
+ const [workspaces, setWorkspaces] = useState([]);
14
+ const [currentWorkspace, setCurrentWorkspace] = useState(null);
15
+ const [activeTab, setActiveTab] = useState('diff');
16
+
17
+ // State data
18
+ const [stats, setStats] = useState(null);
19
+ const [documents, setDocuments] = useState([]);
20
+ const [proposals, setProposals] = useState([]);
21
+ const [diff, setDiff] = useState(null);
22
+ const [graphData, setGraphData] = useState(null);
23
+ const [knowledgeItems, setKnowledgeItems] = useState([]);
24
+ const [rules, setRules] = useState([]);
25
+ const [activity, setActivity] = useState(null);
26
+ const [validationResult, setValidationResult] = useState(null);
27
+
28
+ const [loading, setLoading] = useState(false);
29
+ const [toast, setToast] = useState(null);
30
+
31
+ const showToast = (message, type = 'success') => {
32
+ setToast({ message, type });
33
+ setTimeout(() => setToast(null), 4000);
34
+ };
35
+
36
+ // Initial load: workspaces
37
+ useEffect(() => {
38
+ async function init() {
39
+ try {
40
+ const wsList = await api.getWorkspaces();
41
+ setWorkspaces(wsList);
42
+ if (wsList.length > 0) {
43
+ setCurrentWorkspace(wsList[0]);
44
+ }
45
+ } catch (err) {
46
+ showToast(`Failed to connect to DiffWeave Bridge: ${err.message}`, 'error');
47
+ }
48
+ }
49
+ init();
50
+ }, []);
51
+
52
+ // Fetch workspace details
53
+ const refreshData = useCallback(async () => {
54
+ if (!currentWorkspace?.id) return;
55
+ const wsId = currentWorkspace.id;
56
+
57
+ try {
58
+ if (activeTab === 'diff') {
59
+ const diffRes = await api.getSemanticDiff(wsId);
60
+ setDiff(diffRes);
61
+ } else if (activeTab === 'prs') {
62
+ const prsRes = await api.getProposals(wsId);
63
+ setProposals(prsRes);
64
+ } else if (activeTab === 'staging') {
65
+ const docsRes = await api.getDocuments(wsId);
66
+ setDocuments(docsRes);
67
+ } else if (activeTab === 'graph') {
68
+ const graphRes = await api.getKnowledgeGraph(wsId);
69
+ setGraphData(graphRes);
70
+ } else if (activeTab === 'knowledge') {
71
+ const kRes = await api.getKnowledge(wsId);
72
+ setKnowledgeItems(kRes);
73
+ } else if (activeTab === 'rules') {
74
+ const rulesRes = await api.getRules(wsId);
75
+ setRules(rulesRes);
76
+ } else if (activeTab === 'audit') {
77
+ const actRes = await api.getActivity(wsId);
78
+ setActivity(actRes);
79
+ }
80
+
81
+ // Always fetch stats in background for badge updates
82
+ const statusRes = await api.getWorkspaceStatus(wsId);
83
+ setStats(statusRes.stats);
84
+ } catch (err) {
85
+ console.error('Error refreshing workspace data:', err);
86
+ }
87
+ }, [currentWorkspace, activeTab]);
88
+
89
+ useEffect(() => {
90
+ refreshData();
91
+ }, [refreshData]);
92
+
93
+ // Actions
94
+ const handleCreateWorkspace = async (name, desc) => {
95
+ try {
96
+ const newWs = await api.createWorkspace(name, desc);
97
+ setWorkspaces([...workspaces, newWs]);
98
+ setCurrentWorkspace(newWs);
99
+ showToast(`Workspace "${name}" created!`);
100
+ } catch (err) {
101
+ showToast(`Create failed: ${err.message}`, 'error');
102
+ }
103
+ };
104
+
105
+ const handleReview = async (proposalId, decision, comments = null) => {
106
+ try {
107
+ const res = await api.reviewProposal(currentWorkspace.id, proposalId, decision, comments);
108
+ if (decision === 'APPROVED') {
109
+ showToast(`Proposal approved! Commit ID: ${res.commit_id?.slice(0, 8)}`);
110
+ } else if (decision === 'REJECTED') {
111
+ showToast('Proposal rejected.', 'info');
112
+ } else {
113
+ showToast('Proposal stashed for later.', 'info');
114
+ }
115
+ refreshData();
116
+ } catch (err) {
117
+ showToast(`Review failed: ${err.message}`, 'error');
118
+ }
119
+ };
120
+
121
+ const handleBatchReview = async (decision) => {
122
+ try {
123
+ const res = await api.batchReviewProposals(currentWorkspace.id, decision);
124
+ showToast(`Batch ${decision.toLowerCase()} processed (${res.processed_count} items)!`);
125
+ refreshData();
126
+ } catch (err) {
127
+ showToast(`Batch review failed: ${err.message}`, 'error');
128
+ }
129
+ };
130
+
131
+ const handleUpload = async (file) => {
132
+ try {
133
+ const res = await api.uploadDocument(currentWorkspace.id, file);
134
+ showToast(`Uploaded ${file.name}. Workflow ID: ${res.workflow_id?.slice(0, 8)}`);
135
+ refreshData();
136
+ return res;
137
+ } catch (err) {
138
+ showToast(`Upload failed: ${err.message}`, 'error');
139
+ throw err;
140
+ }
141
+ };
142
+
143
+ const handleToggleRule = async (ruleId, isCurrentlyEnabled) => {
144
+ try {
145
+ if (isCurrentlyEnabled) {
146
+ await api.disableRule(ruleId);
147
+ showToast('Rule disabled.');
148
+ } else {
149
+ await api.enableRule(ruleId);
150
+ showToast('Rule enabled.');
151
+ }
152
+ refreshData();
153
+ } catch (err) {
154
+ showToast(`Rule update failed: ${err.message}`, 'error');
155
+ }
156
+ };
157
+
158
+ const handleCreateRule = async (name, operator, config) => {
159
+ try {
160
+ await api.createRule(currentWorkspace.id, name, operator, config);
161
+ showToast(`Rule "${name}" created.`);
162
+ refreshData();
163
+ } catch (err) {
164
+ showToast(`Rule creation failed: ${err.message}`, 'error');
165
+ }
166
+ };
167
+
168
+ const handleRunValidation = async () => {
169
+ try {
170
+ const valRes = await api.getValidation(currentWorkspace.id);
171
+ setValidationResult(valRes);
172
+ showToast(valRes.compliant ? 'Validation passed!' : 'Policy violations found.', valRes.compliant ? 'success' : 'error');
173
+ } catch (err) {
174
+ showToast(`Validation check failed: ${err.message}`, 'error');
175
+ }
176
+ };
177
+
178
+ const handleSearchKnowledge = async (query) => {
179
+ try {
180
+ setLoading(true);
181
+ const res = await api.searchKnowledge(currentWorkspace.id, query);
182
+ setKnowledgeItems(res);
183
+ showToast(`Found ${res.length} matches for "${query}"`);
184
+ } catch (err) {
185
+ showToast(`Search failed: ${err.message}`, 'error');
186
+ } finally {
187
+ setLoading(false);
188
+ }
189
+ };
190
+
191
+ return (
192
+ <div className="min-h-screen bg-[#080B11] text-slate-100 flex flex-col">
193
+ <Navbar
194
+ workspaces={workspaces}
195
+ currentWorkspace={currentWorkspace}
196
+ onSelectWorkspace={(id) => setCurrentWorkspace(workspaces.find((w) => w.id === id))}
197
+ onCreateWorkspace={handleCreateWorkspace}
198
+ activeTab={activeTab}
199
+ onSelectTab={setActiveTab}
200
+ stats={stats}
201
+ />
202
+
203
+ <main className="flex-1 max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-8">
204
+ {activeTab === 'diff' && (
205
+ <SemanticDiffViewer diff={diff} onReview={handleReview} loading={loading} />
206
+ )}
207
+ {activeTab === 'prs' && (
208
+ <PRReviewDeck
209
+ proposals={proposals}
210
+ onReview={handleReview}
211
+ onBatchReview={handleBatchReview}
212
+ loading={loading}
213
+ />
214
+ )}
215
+ {activeTab === 'staging' && (
216
+ <IngestionStaging documents={documents} onUpload={handleUpload} loading={loading} />
217
+ )}
218
+ {activeTab === 'graph' && (
219
+ <KnowledgeGraph graphData={graphData} loading={loading} />
220
+ )}
221
+ {activeTab === 'knowledge' && (
222
+ <KnowledgeBase items={knowledgeItems} onSearch={handleSearchKnowledge} loading={loading} />
223
+ )}
224
+ {activeTab === 'rules' && (
225
+ <PolicyRulesLab
226
+ rules={rules}
227
+ onToggleRule={handleToggleRule}
228
+ onCreateRule={handleCreateRule}
229
+ onRunValidation={handleRunValidation}
230
+ validationResult={validationResult}
231
+ />
232
+ )}
233
+ {activeTab === 'audit' && (
234
+ <AuditLog activityFeed={activity} loading={loading} />
235
+ )}
236
+ </main>
237
+
238
+ {/* Toast Notification */}
239
+ {toast && (
240
+ <div
241
+ className={`fixed bottom-6 right-6 z-50 px-4 py-3 rounded-xl shadow-2xl text-xs font-semibold flex items-center space-x-2 border animate-fade-in ${
242
+ toast.type === 'error'
243
+ ? 'bg-rose-950/90 border-rose-500/40 text-rose-200'
244
+ : toast.type === 'info'
245
+ ? 'bg-amber-950/90 border-amber-500/40 text-amber-200'
246
+ : 'bg-emerald-950/90 border-emerald-500/40 text-emerald-200'
247
+ }`}
248
+ >
249
+ <span>{toast.type === 'error' ? '✖' : toast.type === 'info' ? 'ℹ' : '✔'}</span>
250
+ <span>{toast.message}</span>
251
+ </div>
252
+ )}
253
+ </div>
254
+ );
255
+ }
studio/src/api/client.js ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * DiffWeave Studio API Client
3
+ * Talks directly to the FastAPI bridge, which delegates to DocWeave MCP Server.
4
+ */
5
+
6
+ const API_BASE = '/api';
7
+
8
+ export const api = {
9
+ async getHealth() {
10
+ const res = await fetch(`${API_BASE}/health`);
11
+ return res.json();
12
+ },
13
+
14
+ async getMCPTools() {
15
+ const res = await fetch(`${API_BASE}/mcp/tools`);
16
+ return res.json();
17
+ },
18
+
19
+ async getWorkspaces() {
20
+ const res = await fetch(`${API_BASE}/workspaces`);
21
+ return res.json();
22
+ },
23
+
24
+ async createWorkspace(name, description = '') {
25
+ const res = await fetch(`${API_BASE}/workspaces`, {
26
+ method: 'POST',
27
+ headers: { 'Content-Type': 'application/json' },
28
+ body: JSON.stringify({ name, description }),
29
+ });
30
+ if (!res.ok) throw new Error(await res.text());
31
+ return res.json();
32
+ },
33
+
34
+ async getWorkspaceStatus(workspaceId) {
35
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/status`);
36
+ return res.json();
37
+ },
38
+
39
+ async getDocuments(workspaceId) {
40
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/documents`);
41
+ return res.json();
42
+ },
43
+
44
+ async uploadDocument(workspaceId, file) {
45
+ const formData = new FormData();
46
+ formData.append('file', file);
47
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/upload`, {
48
+ method: 'POST',
49
+ body: formData,
50
+ });
51
+ if (!res.ok) throw new Error(await res.text());
52
+ return res.json();
53
+ },
54
+
55
+ async getProposals(workspaceId) {
56
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/proposals`);
57
+ return res.json();
58
+ },
59
+
60
+ async reviewProposal(workspaceId, proposalId, decision, comments = null) {
61
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/proposals/${proposalId}/review`, {
62
+ method: 'POST',
63
+ headers: { 'Content-Type': 'application/json' },
64
+ body: JSON.stringify({ decision, comments }),
65
+ });
66
+ if (!res.ok) throw new Error(await res.text());
67
+ return res.json();
68
+ },
69
+
70
+ async batchReviewProposals(workspaceId, decision, proposalIds = null, comments = null) {
71
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/proposals/batch-review`, {
72
+ method: 'POST',
73
+ headers: { 'Content-Type': 'application/json' },
74
+ body: JSON.stringify({ decision, proposal_ids: proposalIds, comments }),
75
+ });
76
+ if (!res.ok) throw new Error(await res.text());
77
+ return res.json();
78
+ },
79
+
80
+ async getSemanticDiff(workspaceId) {
81
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/diff`);
82
+ return res.json();
83
+ },
84
+
85
+ async getValidation(workspaceId) {
86
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/validate`);
87
+ return res.json();
88
+ },
89
+
90
+ async getKnowledgeGraph(workspaceId) {
91
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/graph`);
92
+ return res.json();
93
+ },
94
+
95
+ async getKnowledge(workspaceId, type = null, status = null) {
96
+ const params = new URLSearchParams();
97
+ if (type) params.append('type', type);
98
+ if (status) params.append('status', status);
99
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/knowledge?${params.toString()}`);
100
+ return res.json();
101
+ },
102
+
103
+ async searchKnowledge(workspaceId, query) {
104
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/search?q=${encodeURIComponent(query)}`);
105
+ return res.json();
106
+ },
107
+
108
+ async getRules(workspaceId) {
109
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/rules`);
110
+ return res.json();
111
+ },
112
+
113
+ async createRule(workspaceId, name, operator, configuration) {
114
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/rules`, {
115
+ method: 'POST',
116
+ headers: { 'Content-Type': 'application/json' },
117
+ body: JSON.stringify({ name, operator, configuration }),
118
+ });
119
+ if (!res.ok) throw new Error(await res.text());
120
+ return res.json();
121
+ },
122
+
123
+ async enableRule(ruleId) {
124
+ const res = await fetch(`${API_BASE}/rules/${ruleId}/enable`, { method: 'POST' });
125
+ return res.json();
126
+ },
127
+
128
+ async disableRule(ruleId) {
129
+ const res = await fetch(`${API_BASE}/rules/${ruleId}/disable`, { method: 'POST' });
130
+ return res.json();
131
+ },
132
+
133
+ async getActivity(workspaceId, limit = 50) {
134
+ const res = await fetch(`${API_BASE}/workspaces/${workspaceId}/activity?limit=${limit}`);
135
+ return res.json();
136
+ },
137
+ };
studio/src/components/AuditLog.jsx ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ export default function AuditLog({ activityFeed, loading }) {
4
+ if (loading) {
5
+ return (
6
+ <div className="flex items-center justify-center p-20 text-slate-400">
7
+ <span className="pulse-glow mr-3">⚙</span> Loading audit timeline...
8
+ </div>
9
+ );
10
+ }
11
+
12
+ const events = activityFeed?.events || [];
13
+
14
+ return (
15
+ <div className="space-y-6">
16
+ <div className="flex items-center justify-between p-5 rounded-xl bg-[#0E1524] border border-slate-800">
17
+ <div>
18
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
19
+ <span>Knowledge Audit Log & Telemetry Timeline</span>
20
+ <span className="text-xs px-2 py-0.5 rounded bg-blue-500/20 text-blue-300 font-mono">
21
+ {events.length} Historical Records
22
+ </span>
23
+ </h2>
24
+ <p className="text-xs text-slate-400 mt-1">
25
+ Immutable provenance record tracking every document upload, rule trigger, and human review decision.
26
+ </p>
27
+ </div>
28
+ </div>
29
+
30
+ {events.length === 0 ? (
31
+ <div className="text-center py-16 border border-dashed border-slate-800 rounded-xl bg-[#090E17]">
32
+ <span className="text-2xl text-slate-500 block mb-2 font-mono">∅</span>
33
+ <h3 className="text-sm font-semibold text-white">No Activity Events Recorded Yet</h3>
34
+ <p className="text-xs text-slate-400 mt-1">
35
+ Ingest documents or review proposals to generate audit events.
36
+ </p>
37
+ </div>
38
+ ) : (
39
+ <div className="rounded-xl border border-slate-800 bg-[#0F1524] p-5">
40
+ <div className="relative pl-6 space-y-6 before:absolute before:left-2 before:top-2 before:bottom-2 before:w-0.5 before:bg-slate-800">
41
+ {events.map((ev, idx) => {
42
+ const evType = ev.type || 'event';
43
+ let badgeStyle = 'bg-blue-500/10 text-blue-400 border-blue-500/20';
44
+ if (evType.includes('approved') || evType.includes('completed')) {
45
+ badgeStyle = 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20';
46
+ } else if (evType.includes('rejected')) {
47
+ badgeStyle = 'bg-rose-500/10 text-rose-400 border-rose-500/20';
48
+ } else if (evType.includes('archived') || evType.includes('review')) {
49
+ badgeStyle = 'bg-amber-500/10 text-amber-300 border-amber-500/20';
50
+ }
51
+
52
+ return (
53
+ <div key={ev.id || idx} className="relative group">
54
+ <div className="absolute -left-[27px] top-1 w-3 h-3 rounded-full bg-slate-900 border-2 border-slate-600 group-hover:border-emerald-400 transition"></div>
55
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-1 mb-1">
56
+ <span
57
+ className={`text-[10px] font-mono font-bold uppercase tracking-wider px-2 py-0.5 rounded border inline-block w-fit ${badgeStyle}`}
58
+ >
59
+ {evType}
60
+ </span>
61
+ <span className="text-[11px] font-mono text-slate-500">
62
+ {ev.timestamp ? new Date(ev.timestamp).toLocaleString() : 'Recent'}
63
+ </span>
64
+ </div>
65
+ <p className="text-sm text-slate-200 font-medium mt-1">{ev.message}</p>
66
+ </div>
67
+ );
68
+ })}
69
+ </div>
70
+ </div>
71
+ )}
72
+ </div>
73
+ );
74
+ }
studio/src/components/IngestionStaging.jsx ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function IngestionStaging({ documents, onUpload, loading }) {
4
+ const [uploading, setUploading] = useState(false);
5
+ const [dragOver, setDragOver] = useState(false);
6
+ const [uploadMessage, setUploadMessage] = useState(null);
7
+
8
+ const handleFiles = async (files) => {
9
+ if (!files || files.length === 0) return;
10
+ setUploading(true);
11
+ setUploadMessage('Ingesting document into DocWeave pipeline...');
12
+ try {
13
+ const file = files[0];
14
+ const res = await onUpload(file);
15
+ setUploadMessage(`Successfully staged ${file.name}! Workflow: ${res.workflow_id?.slice(0, 8)}`);
16
+ } catch (err) {
17
+ setUploadMessage(`Upload failed: ${err.message}`);
18
+ } finally {
19
+ setUploading(false);
20
+ }
21
+ };
22
+
23
+ return (
24
+ <div className="space-y-6">
25
+ {/* Drag & Drop Zone */}
26
+ <div
27
+ onDragOver={(e) => {
28
+ e.preventDefault();
29
+ setDragOver(true);
30
+ }}
31
+ onDragLeave={() => setDragOver(false)}
32
+ onDrop={(e) => {
33
+ e.preventDefault();
34
+ setDragOver(false);
35
+ handleFiles(e.dataTransfer.files);
36
+ }}
37
+ className={`border-2 border-dashed rounded-xl p-8 text-center transition-all ${
38
+ dragOver
39
+ ? 'border-emerald-500 bg-emerald-500/10'
40
+ : 'border-slate-700/80 bg-[#0E1524]/60 hover:border-slate-600'
41
+ }`}
42
+ >
43
+ <div className="max-w-md mx-auto">
44
+ <span className="text-3xl text-emerald-400 block mb-2">📄</span>
45
+ <h3 className="text-sm font-semibold text-white">Stage Documents for Ingestion</h3>
46
+ <p className="text-xs text-slate-400 mt-1 mb-4">
47
+ Drop PDFs, Word documents (.docx), or clinical texts (.txt) here to start automated extraction.
48
+ </p>
49
+
50
+ <label className="inline-block px-4 py-2 text-xs font-semibold text-black bg-emerald-400 hover:bg-emerald-300 rounded-lg cursor-pointer transition shadow">
51
+ <span>Browse Document File</span>
52
+ <input
53
+ type="file"
54
+ className="hidden"
55
+ onChange={(e) => handleFiles(e.target.files)}
56
+ disabled={uploading}
57
+ />
58
+ </label>
59
+
60
+ {uploadMessage && (
61
+ <p className="text-xs text-emerald-300 mt-3 font-mono animate-fade-in">{uploadMessage}</p>
62
+ )}
63
+ </div>
64
+ </div>
65
+
66
+ {/* Real-time Ingestion Pipeline Visualizer */}
67
+ <div className="p-5 rounded-xl bg-[#0F1524] border border-slate-800">
68
+ <h3 className="text-xs font-mono font-bold text-slate-400 uppercase tracking-wider mb-3">
69
+ Automated Extraction & Reconciliation Pipeline
70
+ </h3>
71
+ <div className="grid grid-cols-2 md:grid-cols-5 gap-3">
72
+ {[
73
+ { step: '1. Ingestion', desc: 'Text Layout & OCR' },
74
+ { step: '2. Chunking', desc: 'Semantic Windows' },
75
+ { step: '3. Extraction', desc: 'Atomic Fact LLM' },
76
+ { step: '4. Reconciliation', desc: 'RRF & Collision Detect' },
77
+ { step: '5. Rule Linter', desc: 'Policy Gate Check' },
78
+ ].map((s, idx) => (
79
+ <div key={idx} className="p-3 rounded-lg bg-slate-900/80 border border-slate-800">
80
+ <span className="text-[11px] font-bold text-emerald-400 block">{s.step}</span>
81
+ <span className="text-[10px] text-slate-400 block mt-0.5">{s.desc}</span>
82
+ </div>
83
+ ))}
84
+ </div>
85
+ </div>
86
+
87
+ {/* Document Inventory Table */}
88
+ <div className="rounded-xl border border-slate-800 bg-[#0F1524] overflow-hidden">
89
+ <div className="px-5 py-4 border-b border-slate-800 flex items-center justify-between">
90
+ <h3 className="text-sm font-bold text-white">Tracked Workspace Documents</h3>
91
+ <span className="text-xs text-slate-400 font-mono">{documents?.length || 0} files</span>
92
+ </div>
93
+
94
+ {documents?.length === 0 ? (
95
+ <div className="text-center py-12 text-slate-500 text-xs">
96
+ No documents uploaded to this workspace yet.
97
+ </div>
98
+ ) : (
99
+ <div className="overflow-x-auto">
100
+ <table className="w-full text-left text-xs text-slate-300">
101
+ <thead className="bg-[#121A2C] text-slate-400 font-mono text-[11px] border-b border-slate-800">
102
+ <tr>
103
+ <th className="px-5 py-3 font-semibold">Filename</th>
104
+ <th className="px-5 py-3 font-semibold">Pipeline State</th>
105
+ <th className="px-5 py-3 font-semibold">Document UUID</th>
106
+ <th className="px-5 py-3 font-semibold">Actions</th>
107
+ </tr>
108
+ </thead>
109
+ <tbody className="divide-y divide-slate-800/60 font-medium">
110
+ {documents.map((d) => {
111
+ const status = d.workflow_status || d.status || 'COMPLETED';
112
+ let statusBadge = (
113
+ <span className="px-2 py-0.5 rounded bg-slate-800 text-slate-400">{status}</span>
114
+ );
115
+ if (status === 'COMPLETED') {
116
+ statusBadge = (
117
+ <span className="px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 border border-emerald-500/30">
118
+ ✔ COMMITTED
119
+ </span>
120
+ );
121
+ } else if (status === 'WAITING_FOR_REVIEW') {
122
+ statusBadge = (
123
+ <span className="px-2 py-0.5 rounded bg-amber-500/15 text-amber-300 border border-amber-500/30 font-bold">
124
+ ● REVIEW REQUIRED
125
+ </span>
126
+ );
127
+ } else if (status === 'RUNNING') {
128
+ statusBadge = (
129
+ <span className="px-2 py-0.5 rounded bg-cyan-500/15 text-cyan-300 animate-pulse">
130
+ ⚙ PROCESSING
131
+ </span>
132
+ );
133
+ }
134
+
135
+ return (
136
+ <tr key={d.document_id} className="hover:bg-slate-800/30 transition">
137
+ <td className="px-5 py-3 text-white font-semibold">{d.filename}</td>
138
+ <td className="px-5 py-3">{statusBadge}</td>
139
+ <td className="px-5 py-3 font-mono text-slate-500">
140
+ {d.document_id?.slice(0, 12)}...
141
+ </td>
142
+ <td className="px-5 py-3">
143
+ <span className="text-[11px] text-slate-400 font-mono">
144
+ WF: {d.workflow_id?.slice(0, 8) || 'N/A'}
145
+ </span>
146
+ </td>
147
+ </tr>
148
+ );
149
+ })}
150
+ </tbody>
151
+ </table>
152
+ </div>
153
+ )}
154
+ </div>
155
+ </div>
156
+ );
157
+ }
studio/src/components/KnowledgeBase.jsx ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function KnowledgeBase({ items, onSearch, loading }) {
4
+ const [query, setQuery] = useState('');
5
+ const [selectedType, setSelectedType] = useState('ALL');
6
+
7
+ const handleSearchSubmit = (e) => {
8
+ e.preventDefault();
9
+ if (query.trim()) {
10
+ onSearch(query.trim());
11
+ }
12
+ };
13
+
14
+ const types = ['ALL', 'CLAIM', 'ENTITY', 'METRIC', 'METHOD', 'OBSERVATION'];
15
+ const itemList = items || [];
16
+ const filtered = selectedType === 'ALL' ? itemList : itemList.filter((i) => i.type === selectedType);
17
+
18
+ return (
19
+ <div className="space-y-6">
20
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 p-5 rounded-xl bg-[#0E1524] border border-slate-800">
21
+ <div>
22
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
23
+ <span>Master Knowledge Register</span>
24
+ <span className="text-xs px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300 font-mono">
25
+ {itemList.length} Committed Truths
26
+ </span>
27
+ </h2>
28
+ <p className="text-xs text-slate-400 mt-1">
29
+ Production-grade factual register with complete audit provenance and citation links.
30
+ </p>
31
+ </div>
32
+
33
+ {/* Search bar */}
34
+ <form onSubmit={handleSearchSubmit} className="flex items-center space-x-2 w-full sm:w-80">
35
+ <input
36
+ type="text"
37
+ placeholder="Hybrid lexical + vector search..."
38
+ value={query}
39
+ onChange={(e) => setQuery(e.target.value)}
40
+ className="w-full bg-[#121A2C] border border-slate-700 rounded-lg px-3 py-1.5 text-xs text-white focus:outline-none focus:border-emerald-500"
41
+ />
42
+ <button
43
+ type="submit"
44
+ className="px-3 py-1.5 text-xs font-semibold bg-emerald-400 hover:bg-emerald-300 text-black rounded-lg transition"
45
+ >
46
+ Search
47
+ </button>
48
+ </form>
49
+ </div>
50
+
51
+ {/* Filter Tabs */}
52
+ <div className="flex items-center space-x-2 border-b border-slate-800 pb-3">
53
+ {types.map((t) => (
54
+ <button
55
+ key={t}
56
+ onClick={() => setSelectedType(t)}
57
+ className={`px-3 py-1 rounded-md text-xs font-mono font-medium transition ${
58
+ selectedType === t
59
+ ? 'bg-slate-700 text-white font-bold'
60
+ : 'text-slate-400 hover:text-white'
61
+ }`}
62
+ >
63
+ {t}
64
+ </button>
65
+ ))}
66
+ </div>
67
+
68
+ {loading ? (
69
+ <div className="text-center py-20 text-slate-400 text-xs">
70
+ <span className="pulse-glow mr-2">⚙</span> Fetching knowledge items...
71
+ </div>
72
+ ) : filtered.length === 0 ? (
73
+ <div className="text-center py-16 border border-dashed border-slate-800 rounded-xl bg-[#090E17]">
74
+ <span className="text-2xl text-slate-500 block mb-2 font-mono">∅</span>
75
+ <h3 className="text-sm font-semibold text-white">No Committed Items Found</h3>
76
+ <p className="text-xs text-slate-400 mt-1">
77
+ Approve proposals in the Pull Requests tab or run 'dw commit' to register knowledge.
78
+ </p>
79
+ </div>
80
+ ) : (
81
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
82
+ {filtered.map((item) => (
83
+ <div
84
+ key={item.id}
85
+ className="p-5 rounded-xl border border-slate-800 bg-[#0F1423] hover:border-slate-700 transition"
86
+ >
87
+ <div className="flex items-center justify-between gap-2 mb-2">
88
+ <span className="text-[10px] font-mono font-bold text-cyan-400 px-2 py-0.5 rounded bg-cyan-950/40 border border-cyan-500/20">
89
+ {item.type}
90
+ </span>
91
+ <span className="text-[11px] font-mono text-emerald-400">
92
+ Confidence: {(item.confidence * 100).toFixed(0)}%
93
+ </span>
94
+ </div>
95
+
96
+ <h4 className="text-sm font-bold text-white mb-2">{item.title}</h4>
97
+
98
+ <div className="p-3 rounded-lg bg-slate-900 border border-slate-800/80 mb-3">
99
+ <span className="text-[10px] font-mono text-slate-500 block mb-1">Committed Value:</span>
100
+ <p className="text-xs text-slate-200 font-mono">"{item.value}"</p>
101
+ </div>
102
+
103
+ {item.summary && (
104
+ <p className="text-xs text-slate-400 mb-3 line-clamp-2">{item.summary}</p>
105
+ )}
106
+
107
+ <div className="flex items-center justify-between text-[11px] text-slate-500 font-mono pt-2 border-t border-slate-800/60">
108
+ <span>File: {item.filename || 'Source Doc'}</span>
109
+ <span>{item.created_at ? new Date(item.created_at).toLocaleDateString() : 'Active'}</span>
110
+ </div>
111
+ </div>
112
+ ))}
113
+ </div>
114
+ )}
115
+ </div>
116
+ );
117
+ }
studio/src/components/KnowledgeGraph.jsx ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function KnowledgeGraph({ graphData, loading }) {
4
+ const [selectedNode, setSelectedNode] = useState(null);
5
+
6
+ if (loading) {
7
+ return (
8
+ <div className="flex items-center justify-center p-20 text-slate-400">
9
+ <span className="pulse-glow mr-3">⚙</span> Building knowledge graph topology...
10
+ </div>
11
+ );
12
+ }
13
+
14
+ const nodes = graphData?.nodes || [];
15
+ const edges = graphData?.edges || [];
16
+
17
+ return (
18
+ <div className="space-y-6">
19
+ <div className="flex items-center justify-between p-5 rounded-xl bg-[#0E1524] border border-slate-800">
20
+ <div>
21
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
22
+ <span>Knowledge Graph & Provenance Topology</span>
23
+ <span className="text-xs px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-300 font-mono">
24
+ {nodes.length} Nodes · {edges.length} Links
25
+ </span>
26
+ </h2>
27
+ <p className="text-xs text-slate-400 mt-1">
28
+ Visual map of semantic relationships and incoming PR conflict connections across documents.
29
+ </p>
30
+ </div>
31
+ </div>
32
+
33
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
34
+ {/* Interactive Visual Graph Canvas */}
35
+ <div className="lg:col-span-2 rounded-xl border border-slate-800 bg-[#0C111E] p-6 min-h-[460px] flex flex-col justify-between relative overflow-hidden">
36
+ <div className="flex items-center justify-between text-xs text-slate-400 border-b border-slate-800/80 pb-3">
37
+ <span className="font-mono">Topology Visualizer (SVG Canvas)</span>
38
+ <span className="text-[11px] text-slate-500">Click any node to inspect provenance</span>
39
+ </div>
40
+
41
+ {nodes.length === 0 ? (
42
+ <div className="flex flex-col items-center justify-center my-auto py-20 text-slate-500 text-xs">
43
+ <span>No knowledge entities or claims yet in this workspace.</span>
44
+ <span className="mt-1 text-[11px] text-slate-600">Stage files to extract graph nodes.</span>
45
+ </div>
46
+ ) : (
47
+ <div className="py-8 relative">
48
+ <div className="flex flex-wrap gap-4 items-center justify-center">
49
+ {nodes.map((n, idx) => {
50
+ const isSelected = selectedNode?.id === n.id;
51
+ const isProposal = n.type === 'PROPOSAL';
52
+ const isContradiction = edges.some(
53
+ (e) => (e.source === n.id || e.target === n.id) && e.relationship === 'CONTRADICTS'
54
+ );
55
+
56
+ let badgeColor = 'border-emerald-500/40 bg-emerald-950/20 text-emerald-300';
57
+ if (isProposal) badgeColor = 'border-amber-500/50 bg-amber-950/30 text-amber-200';
58
+ if (isContradiction) badgeColor = 'border-rose-500/60 bg-rose-950/30 text-rose-200 glow-crimson';
59
+
60
+ return (
61
+ <button
62
+ key={n.id || idx}
63
+ onClick={() => setSelectedNode(n)}
64
+ className={`p-3 rounded-xl border text-left transition transform hover:scale-105 shadow-md max-w-xs ${badgeColor} ${
65
+ isSelected ? 'ring-2 ring-cyan-400 scale-105' : ''
66
+ }`}
67
+ >
68
+ <div className="flex items-center justify-between gap-2 mb-1">
69
+ <span className="text-[10px] font-mono font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-black/40">
70
+ {n.type}
71
+ </span>
72
+ <span className="text-[10px] font-mono opacity-70">
73
+ {(n.confidence * 100).toFixed(0)}%
74
+ </span>
75
+ </div>
76
+ <h4 className="text-xs font-semibold text-white line-clamp-1">{n.title}</h4>
77
+ {n.value && (
78
+ <p className="text-[11px] text-slate-300 mt-1 line-clamp-2 opacity-80 font-mono">
79
+ "{n.value}"
80
+ </p>
81
+ )}
82
+ </button>
83
+ );
84
+ })}
85
+ </div>
86
+
87
+ {/* Edge list summary */}
88
+ {edges.length > 0 && (
89
+ <div className="mt-8 pt-4 border-t border-slate-800/80">
90
+ <h5 className="text-[11px] font-mono text-slate-400 mb-2">Active Semantic Links:</h5>
91
+ <div className="flex flex-wrap gap-2">
92
+ {edges.map((e, idx) => (
93
+ <span
94
+ key={idx}
95
+ className={`text-[10px] font-mono px-2 py-1 rounded border ${
96
+ e.relationship === 'CONTRADICTS'
97
+ ? 'bg-rose-500/10 border-rose-500/30 text-rose-300'
98
+ : 'bg-slate-800/80 border-slate-700 text-slate-300'
99
+ }`}
100
+ >
101
+ {e.relationship} ({e.confidence || 1.0})
102
+ </span>
103
+ ))}
104
+ </div>
105
+ </div>
106
+ )}
107
+ </div>
108
+ )}
109
+
110
+ <div className="text-[11px] text-slate-500 flex items-center justify-between border-t border-slate-800/80 pt-3">
111
+ <span>Legend: Green = Committed Truth · Amber = Proposed PR · Red = Collision</span>
112
+ </div>
113
+ </div>
114
+
115
+ {/* Selected Node Inspector */}
116
+ <div className="rounded-xl border border-slate-800 bg-[#0F1524] p-5 flex flex-col justify-between">
117
+ <div>
118
+ <h3 className="text-xs font-mono font-bold text-slate-400 uppercase tracking-wider mb-4">
119
+ Node Inspector
120
+ </h3>
121
+
122
+ {selectedNode ? (
123
+ <div className="space-y-4">
124
+ <div>
125
+ <span className="text-[10px] font-mono text-cyan-400 uppercase block mb-1">
126
+ {selectedNode.type}
127
+ </span>
128
+ <h4 className="text-sm font-bold text-white">{selectedNode.title}</h4>
129
+ </div>
130
+
131
+ {selectedNode.value && (
132
+ <div className="p-3 rounded-lg bg-slate-900 border border-slate-800">
133
+ <span className="text-[10px] text-slate-500 block mb-1 font-mono">Registered Value:</span>
134
+ <p className="text-xs text-slate-200 font-mono">"{selectedNode.value}"</p>
135
+ </div>
136
+ )}
137
+
138
+ {selectedNode.summary && (
139
+ <div>
140
+ <span className="text-[10px] text-slate-500 block mb-1 font-mono">Summary:</span>
141
+ <p className="text-xs text-slate-300 leading-relaxed">{selectedNode.summary}</p>
142
+ </div>
143
+ )}
144
+
145
+ <div className="grid grid-cols-2 gap-2 text-[11px] font-mono">
146
+ <div className="p-2 rounded bg-slate-900/60 border border-slate-800">
147
+ <span className="text-slate-500 block">Status:</span>
148
+ <span className="text-emerald-400 font-semibold">{selectedNode.status || 'ACTIVE'}</span>
149
+ </div>
150
+ <div className="p-2 rounded bg-slate-900/60 border border-slate-800">
151
+ <span className="text-slate-500 block">Confidence:</span>
152
+ <span className="text-amber-300 font-semibold">
153
+ {(selectedNode.confidence * 100).toFixed(0)}%
154
+ </span>
155
+ </div>
156
+ </div>
157
+
158
+ {selectedNode.filename && (
159
+ <div>
160
+ <span className="text-[10px] text-slate-500 block mb-1 font-mono">Source Document:</span>
161
+ <span className="text-xs text-slate-300 font-mono bg-slate-800 px-2 py-1 rounded">
162
+ {selectedNode.filename}
163
+ </span>
164
+ </div>
165
+ )}
166
+ </div>
167
+ ) : (
168
+ <div className="py-20 text-center text-slate-500 text-xs">
169
+ Select any node on the graph to inspect its properties, evidence, and provenance links.
170
+ </div>
171
+ )}
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ );
177
+ }
studio/src/components/Navbar.jsx ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function Navbar({
4
+ workspaces,
5
+ currentWorkspace,
6
+ onSelectWorkspace,
7
+ onCreateWorkspace,
8
+ activeTab,
9
+ onSelectTab,
10
+ stats,
11
+ }) {
12
+ const [showNewModal, setShowNewModal] = useState(false);
13
+ const [newWsName, setNewWsName] = useState('');
14
+ const [newWsDesc, setNewWsDesc] = useState('');
15
+
16
+ const handleCreate = async (e) => {
17
+ e.preventDefault();
18
+ if (!newWsName.trim()) return;
19
+ await onCreateWorkspace(newWsName.trim(), newWsDesc.trim());
20
+ setNewWsName('');
21
+ setNewWsDesc('');
22
+ setShowNewModal(false);
23
+ };
24
+
25
+ const pendingCount = stats?.pending_proposals || 0;
26
+
27
+ return (
28
+ <header className="border-b border-slate-800 bg-[#090D16]/90 backdrop-blur sticky top-0 z-50">
29
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
30
+ <div className="flex items-center justify-between h-16">
31
+ {/* Logo & Workspace Selector */}
32
+ <div className="flex items-center space-x-6">
33
+ <div className="flex items-center space-x-2">
34
+ <span className="text-xl text-emerald-400 font-bold tracking-tight">◈ DiffWeave</span>
35
+ <span className="text-xs px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 font-mono">
36
+ Studio
37
+ </span>
38
+ </div>
39
+
40
+ {/* Workspace dropdown */}
41
+ <div className="flex items-center space-x-2">
42
+ <select
43
+ className="bg-[#121826] border border-slate-700 text-slate-200 text-sm rounded-lg px-3 py-1.5 focus:outline-none focus:ring-1 focus:ring-emerald-500 font-medium"
44
+ value={currentWorkspace?.id || ''}
45
+ onChange={(e) => onSelectWorkspace(e.target.value)}
46
+ >
47
+ {workspaces.map((w) => (
48
+ <option key={w.id} value={w.id}>
49
+ {w.name}
50
+ </option>
51
+ ))}
52
+ </select>
53
+
54
+ <button
55
+ onClick={() => setShowNewModal(true)}
56
+ className="text-xs text-slate-400 hover:text-white px-2 py-1.5 rounded bg-slate-800/80 hover:bg-slate-700 transition"
57
+ title="Create Workspace"
58
+ >
59
+ + New
60
+ </button>
61
+ </div>
62
+ </div>
63
+
64
+ {/* Navigation Tabs */}
65
+ <nav className="flex space-x-1">
66
+ {[
67
+ { id: 'diff', label: 'Knowledge Diff' },
68
+ { id: 'prs', label: 'Pull Requests', badge: pendingCount > 0 ? pendingCount : null },
69
+ { id: 'staging', label: 'Staging & Files' },
70
+ { id: 'graph', label: 'Knowledge Graph' },
71
+ { id: 'knowledge', label: 'Knowledge Register' },
72
+ { id: 'rules', label: 'Policy Rules' },
73
+ { id: 'audit', label: 'Audit Trail' },
74
+ ].map((tab) => {
75
+ const isActive = activeTab === tab.id;
76
+ return (
77
+ <button
78
+ key={tab.id}
79
+ onClick={() => onSelectTab(tab.id)}
80
+ className={`px-3 py-1.5 text-xs font-medium rounded-md transition flex items-center space-x-1.5 ${
81
+ isActive
82
+ ? 'bg-emerald-500/15 text-emerald-400 border border-emerald-500/30'
83
+ : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800/50'
84
+ }`}
85
+ >
86
+ <span>{tab.label}</span>
87
+ {tab.badge && (
88
+ <span className="px-1.5 py-0.2 rounded-full text-[10px] bg-amber-500/20 text-amber-300 font-mono">
89
+ {tab.badge}
90
+ </span>
91
+ )}
92
+ </button>
93
+ );
94
+ })}
95
+ </nav>
96
+
97
+ {/* MCP Status Indicator */}
98
+ <div className="flex items-center space-x-3">
99
+ <div className="flex items-center space-x-2 px-2.5 py-1 rounded-full bg-emerald-950/40 border border-emerald-500/30 text-emerald-400 text-xs font-mono">
100
+ <span className="w-2 h-2 rounded-full bg-emerald-400 pulse-glow"></span>
101
+ <span>MCP: 29 Tools</span>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ {/* New Workspace Modal */}
108
+ {showNewModal && (
109
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
110
+ <div className="bg-[#101726] border border-slate-700 p-6 rounded-xl w-full max-w-md shadow-2xl">
111
+ <h3 className="text-lg font-semibold text-white mb-4">Create New Workspace</h3>
112
+ <form onSubmit={handleCreate}>
113
+ <div className="mb-4">
114
+ <label className="block text-xs font-medium text-slate-400 mb-1">Workspace Name</label>
115
+ <input
116
+ type="text"
117
+ required
118
+ placeholder="e.g. Clinical Research Protocols"
119
+ value={newWsName}
120
+ onChange={(e) => setNewWsName(e.target.value)}
121
+ className="w-full bg-[#162032] border border-slate-700 rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-emerald-500"
122
+ />
123
+ </div>
124
+ <div className="mb-6">
125
+ <label className="block text-xs font-medium text-slate-400 mb-1">Description (Optional)</label>
126
+ <textarea
127
+ rows="2"
128
+ placeholder="Workspace purpose or project notes"
129
+ value={newWsDesc}
130
+ onChange={(e) => setNewWsDesc(e.target.value)}
131
+ className="w-full bg-[#162032] border border-slate-700 rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-emerald-500"
132
+ />
133
+ </div>
134
+ <div className="flex justify-end space-x-3">
135
+ <button
136
+ type="button"
137
+ onClick={() => setShowNewModal(false)}
138
+ className="px-4 py-2 text-xs font-medium text-slate-400 hover:text-white rounded-lg bg-slate-800"
139
+ >
140
+ Cancel
141
+ </button>
142
+ <button
143
+ type="submit"
144
+ className="px-4 py-2 text-xs font-medium text-black bg-emerald-400 hover:bg-emerald-300 rounded-lg font-semibold"
145
+ >
146
+ Create Workspace
147
+ </button>
148
+ </div>
149
+ </form>
150
+ </div>
151
+ </div>
152
+ )}
153
+ </header>
154
+ );
155
+ }
studio/src/components/PRReviewDeck.jsx ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function PRReviewDeck({ proposals, onReview, onBatchReview, loading }) {
4
+ const [commentMap, setCommentMap] = useState({});
5
+ const [actingId, setActingId] = useState(null);
6
+ const [batchActing, setBatchActing] = useState(false);
7
+
8
+ const handleSingle = async (proposalId, decision) => {
9
+ setActingId(proposalId);
10
+ try {
11
+ const comment = commentMap[proposalId] || null;
12
+ await onReview(proposalId, decision, comment);
13
+ } finally {
14
+ setActingId(null);
15
+ }
16
+ };
17
+
18
+ const handleBatch = async (decision) => {
19
+ setBatchActing(true);
20
+ try {
21
+ await onBatchReview(decision);
22
+ } finally {
23
+ setBatchActing(false);
24
+ }
25
+ };
26
+
27
+ if (loading) {
28
+ return (
29
+ <div className="flex items-center justify-center p-20 text-slate-400">
30
+ <span className="pulse-glow mr-3">⚙</span> Loading review queue...
31
+ </div>
32
+ );
33
+ }
34
+
35
+ const pendingList = proposals || [];
36
+
37
+ return (
38
+ <div className="space-y-6">
39
+ {/* Header with Batch Action bar */}
40
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 p-5 rounded-xl bg-[#0E1524] border border-slate-800">
41
+ <div>
42
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
43
+ <span>Knowledge Pull Requests (PRs)</span>
44
+ <span className="text-xs px-2 py-0.5 rounded bg-amber-500/20 text-amber-300 font-mono">
45
+ {pendingList.length} Awaiting Review
46
+ </span>
47
+ </h2>
48
+ <p className="text-xs text-slate-400 mt-1">
49
+ Human approval gate: unreviewed proposals never enter Master Truth without explicit sign-off.
50
+ </p>
51
+ </div>
52
+
53
+ {pendingList.length > 0 && (
54
+ <div className="flex items-center space-x-3">
55
+ <button
56
+ disabled={batchActing}
57
+ onClick={() => handleBatch('APPROVED')}
58
+ className="px-4 py-2 rounded-lg text-xs font-semibold bg-emerald-500 hover:bg-emerald-400 text-black transition shadow-lg disabled:opacity-50"
59
+ >
60
+ ✓ Approve & Merge All ({pendingList.length})
61
+ </button>
62
+ <button
63
+ disabled={batchActing}
64
+ onClick={() => handleBatch('REJECTED')}
65
+ className="px-4 py-2 rounded-lg text-xs font-semibold bg-rose-500/20 hover:bg-rose-500/30 text-rose-300 border border-rose-500/40 transition disabled:opacity-50"
66
+ >
67
+ ✕ Reject All
68
+ </button>
69
+ </div>
70
+ )}
71
+ </div>
72
+
73
+ {pendingList.length === 0 ? (
74
+ <div className="text-center py-16 border border-dashed border-slate-800 rounded-xl bg-[#090E17]">
75
+ <span className="text-3xl text-emerald-400 font-mono">[OK]</span>
76
+ <h3 className="text-base font-semibold text-white mt-2">All Knowledge PRs Reviewed</h3>
77
+ <p className="text-xs text-slate-400 mt-1">No items currently waiting for human governance.</p>
78
+ </div>
79
+ ) : (
80
+ <div className="grid grid-cols-1 gap-4">
81
+ {pendingList.map((p, idx) => {
82
+ const pc = p.proposed_changes || {};
83
+ const evidenceList = pc.evidence || [];
84
+ const quote = evidenceList[0]?.quote || 'No citation attached';
85
+ const page = evidenceList[0]?.page_number || 'N/A';
86
+ const val = pc.value || pc.proposed?.value || 'N/A';
87
+ const conf = pc.confidence || pc.proposed?.confidence || 1.0;
88
+
89
+ return (
90
+ <div
91
+ key={p.proposal_id || idx}
92
+ className="rounded-xl border border-slate-800 bg-[#0F1423] p-5 hover:border-slate-700 transition"
93
+ >
94
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 border-b border-slate-800/80 pb-3 mb-3">
95
+ <div className="flex items-center space-x-2">
96
+ <span className="text-xs font-mono font-bold text-amber-400 px-2 py-0.5 rounded bg-amber-500/10 border border-amber-500/20">
97
+ PR #{p.proposal_id?.slice(0, 8)}
98
+ </span>
99
+ <span className="text-xs font-mono text-cyan-400 px-2 py-0.5 rounded bg-cyan-500/10">
100
+ {p.proposal_type}
101
+ </span>
102
+ <span className="text-xs text-slate-400">Confidence: {(conf * 100).toFixed(0)}%</span>
103
+ </div>
104
+
105
+ <span className="text-[11px] text-slate-500 font-mono">
106
+ Created: {p.created_at ? new Date(p.created_at).toLocaleTimeString() : 'Recent'}
107
+ </span>
108
+ </div>
109
+
110
+ <h3 className="text-sm font-semibold text-white mb-2">{p.summary}</h3>
111
+
112
+ {p.rationale && (
113
+ <p className="text-xs text-slate-400 mb-3 bg-slate-900/60 p-2.5 rounded border border-slate-800/50">
114
+ <strong className="text-slate-300">Reconciliation Analysis:</strong> {p.rationale}
115
+ </p>
116
+ )}
117
+
118
+ {/* Proposed value */}
119
+ <div className="p-3 rounded-lg bg-[#141C2E] border border-slate-800 mb-3">
120
+ <span className="text-[10px] font-mono text-slate-400 uppercase tracking-wider block mb-1">
121
+ Proposed Knowledge Value
122
+ </span>
123
+ <p className="text-sm text-slate-100 font-medium font-mono">"{val}"</p>
124
+ </div>
125
+
126
+ {/* Evidence citation */}
127
+ <div className="bg-cyan-950/20 p-3 rounded-lg border border-cyan-500/20 mb-4">
128
+ <span className="text-[11px] text-cyan-400 font-mono block mb-1">
129
+ Verbatim Document Citation (Page {page}):
130
+ </span>
131
+ <blockquote className="text-xs text-cyan-200 italic">"{quote}"</blockquote>
132
+ </div>
133
+
134
+ {/* Reviewer Note and Action Buttons */}
135
+ <div className="flex flex-col sm:flex-row items-center justify-between gap-3 pt-2">
136
+ <input
137
+ type="text"
138
+ placeholder="Optional reviewer note / audit message..."
139
+ value={commentMap[p.proposal_id] || ''}
140
+ onChange={(e) =>
141
+ setCommentMap({ ...commentMap, [p.proposal_id]: e.target.value })
142
+ }
143
+ className="w-full sm:w-80 bg-slate-900 border border-slate-700/80 rounded-lg px-3 py-1.5 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-emerald-500"
144
+ />
145
+
146
+ <div className="flex items-center space-x-2 w-full sm:w-auto justify-end">
147
+ <button
148
+ disabled={actingId === p.proposal_id}
149
+ onClick={() => handleSingle(p.proposal_id, 'ARCHIVED')}
150
+ className="px-3 py-1.5 rounded-lg text-xs font-medium text-slate-400 hover:text-slate-200 bg-slate-800 hover:bg-slate-700 transition"
151
+ >
152
+ Stash
153
+ </button>
154
+ <button
155
+ disabled={actingId === p.proposal_id}
156
+ onClick={() => handleSingle(p.proposal_id, 'REJECTED')}
157
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold text-rose-300 bg-rose-500/15 hover:bg-rose-500/25 border border-rose-500/30 transition"
158
+ >
159
+ Reject
160
+ </button>
161
+ <button
162
+ disabled={actingId === p.proposal_id}
163
+ onClick={() => handleSingle(p.proposal_id, 'APPROVED')}
164
+ className="px-4 py-1.5 rounded-lg text-xs font-semibold text-black bg-emerald-400 hover:bg-emerald-300 transition shadow-sm"
165
+ >
166
+ ✓ Approve & Commit
167
+ </button>
168
+ </div>
169
+ </div>
170
+ </div>
171
+ );
172
+ })}
173
+ </div>
174
+ )}
175
+ </div>
176
+ );
177
+ }
studio/src/components/PolicyRulesLab.jsx ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function PolicyRulesLab({ rules, onToggleRule, onCreateRule, onRunValidation, validationResult }) {
4
+ const [showAddModal, setShowAddModal] = useState(false);
5
+ const [ruleName, setRuleName] = useState('');
6
+ const [operator, setOperator] = useState('min_confidence');
7
+ const [threshold, setThreshold] = useState(0.85);
8
+ const [validating, setValidating] = useState(false);
9
+
10
+ const handleCreate = async (e) => {
11
+ e.preventDefault();
12
+ if (!ruleName.trim()) return;
13
+
14
+ let config = {};
15
+ if (operator === 'min_confidence') {
16
+ config = { value: parseFloat(threshold) };
17
+ } else if (operator === 'allowed_proposal_types') {
18
+ config = { values: ['CREATE', 'UPDATE'] };
19
+ }
20
+
21
+ await onCreateRule(ruleName.trim(), operator, config);
22
+ setRuleName('');
23
+ setShowAddModal(false);
24
+ };
25
+
26
+ const handleRunCheck = async () => {
27
+ setValidating(true);
28
+ try {
29
+ await onRunValidation();
30
+ } finally {
31
+ setValidating(false);
32
+ }
33
+ };
34
+
35
+ const ruleList = rules || [];
36
+
37
+ return (
38
+ <div className="space-y-6">
39
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 p-5 rounded-xl bg-[#0E1524] border border-slate-800">
40
+ <div>
41
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
42
+ <span>Policy Rules & CI Linter</span>
43
+ <span className="text-xs px-2 py-0.5 rounded bg-cyan-500/20 text-cyan-300 font-mono">
44
+ {ruleList.length} Configured Rules
45
+ </span>
46
+ </h2>
47
+ <p className="text-xs text-slate-400 mt-1">
48
+ Dynamic gates that validate extracted claims during ingestion. Failing rules automatically block auto-merge and open a Knowledge PR.
49
+ </p>
50
+ </div>
51
+
52
+ <div className="flex items-center space-x-3">
53
+ <button
54
+ onClick={() => setShowAddModal(true)}
55
+ className="px-3 py-2 text-xs font-semibold text-slate-300 bg-slate-800 hover:bg-slate-700 rounded-lg transition"
56
+ >
57
+ + Add Rule
58
+ </button>
59
+ <button
60
+ disabled={validating}
61
+ onClick={handleRunCheck}
62
+ className="px-4 py-2 text-xs font-semibold text-black bg-emerald-400 hover:bg-emerald-300 rounded-lg transition shadow disabled:opacity-50"
63
+ >
64
+ {validating ? 'Evaluating...' : '▶ Run Compliance Check'}
65
+ </button>
66
+ </div>
67
+ </div>
68
+
69
+ {/* Validation Result Box */}
70
+ {validationResult && (
71
+ <div
72
+ className={`p-5 rounded-xl border ${
73
+ validationResult.compliant
74
+ ? 'bg-emerald-950/20 border-emerald-500/30'
75
+ : 'bg-rose-950/20 border-rose-500/30'
76
+ }`}
77
+ >
78
+ <div className="flex items-center justify-between mb-2">
79
+ <h3 className="text-sm font-bold text-white flex items-center gap-2">
80
+ <span>Policy Evaluation Report</span>
81
+ <span
82
+ className={`text-xs px-2 py-0.5 rounded font-mono ${
83
+ validationResult.compliant
84
+ ? 'bg-emerald-500/20 text-emerald-300'
85
+ : 'bg-rose-500/20 text-rose-300'
86
+ }`}
87
+ >
88
+ {validationResult.compliant ? '[PASS] Compliant' : '[FAIL] Violations Detected'}
89
+ </span>
90
+ </h3>
91
+ <span className="text-xs text-slate-400 font-mono">
92
+ Proposals Checked: {validationResult.proposals_evaluated || 0}
93
+ </span>
94
+ </div>
95
+
96
+ <div className="space-y-2 mt-3">
97
+ {(validationResult.results || []).map((r, idx) => (
98
+ <div
99
+ key={idx}
100
+ className="flex items-center justify-between text-xs p-2.5 rounded bg-slate-900/60 border border-slate-800"
101
+ >
102
+ <div className="flex items-center space-x-2">
103
+ <span
104
+ className={`font-bold font-mono px-1.5 py-0.5 rounded text-[10px] ${
105
+ r.status === 'PASS'
106
+ ? 'bg-emerald-500/20 text-emerald-400'
107
+ : r.status === 'FAIL'
108
+ ? 'bg-rose-500/20 text-rose-400'
109
+ : 'bg-amber-500/20 text-amber-300'
110
+ }`}
111
+ >
112
+ {r.status}
113
+ </span>
114
+ <span className="text-white font-medium">{r.rule_name}</span>
115
+ </div>
116
+ <span className="text-slate-400 italic text-[11px]">{r.message}</span>
117
+ </div>
118
+ ))}
119
+ </div>
120
+ </div>
121
+ )}
122
+
123
+ {/* Rules Table */}
124
+ <div className="rounded-xl border border-slate-800 bg-[#0F1524] overflow-hidden">
125
+ <table className="w-full text-left text-xs text-slate-300">
126
+ <thead className="bg-[#121A2C] text-slate-400 font-mono text-[11px] border-b border-slate-800">
127
+ <tr>
128
+ <th className="px-5 py-3 font-semibold">Rule Name</th>
129
+ <th className="px-5 py-3 font-semibold">Operator</th>
130
+ <th className="px-5 py-3 font-semibold">Configuration</th>
131
+ <th className="px-5 py-3 font-semibold">Enforcement</th>
132
+ <th className="px-5 py-3 font-semibold text-right">Toggle</th>
133
+ </tr>
134
+ </thead>
135
+ <tbody className="divide-y divide-slate-800/60 font-medium">
136
+ {ruleList.map((r) => (
137
+ <tr key={r.id} className="hover:bg-slate-800/30 transition">
138
+ <td className="px-5 py-3 font-semibold text-white">{r.name}</td>
139
+ <td className="px-5 py-3 font-mono text-cyan-400">{r.operator}</td>
140
+ <td className="px-5 py-3 font-mono text-slate-400">
141
+ {JSON.stringify(r.configuration || {})}
142
+ </td>
143
+ <td className="px-5 py-3">
144
+ <span
145
+ className={`px-2 py-0.5 rounded text-[10px] font-mono ${
146
+ r.enabled
147
+ ? 'bg-emerald-500/20 text-emerald-300 border border-emerald-500/30'
148
+ : 'bg-slate-800 text-slate-400'
149
+ }`}
150
+ >
151
+ {r.enabled ? 'ACTIVE' : 'DISABLED'}
152
+ </span>
153
+ </td>
154
+ <td className="px-5 py-3 text-right">
155
+ <button
156
+ onClick={() => onToggleRule(r.id, r.enabled)}
157
+ className={`px-3 py-1 rounded text-xs font-semibold transition ${
158
+ r.enabled
159
+ ? 'bg-amber-500/20 text-amber-300 hover:bg-amber-500/30'
160
+ : 'bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/30'
161
+ }`}
162
+ >
163
+ {r.enabled ? 'Disable' : 'Enable'}
164
+ </button>
165
+ </td>
166
+ </tr>
167
+ ))}
168
+ </tbody>
169
+ </table>
170
+ </div>
171
+
172
+ {/* Add Rule Modal */}
173
+ {showAddModal && (
174
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
175
+ <div className="bg-[#101726] border border-slate-700 p-6 rounded-xl w-full max-w-md shadow-2xl">
176
+ <h3 className="text-lg font-semibold text-white mb-4">Add Validation Rule</h3>
177
+ <form onSubmit={handleCreate}>
178
+ <div className="mb-4">
179
+ <label className="block text-xs font-medium text-slate-400 mb-1">Rule Name</label>
180
+ <input
181
+ type="text"
182
+ required
183
+ placeholder="e.g. Strict Confidence Check"
184
+ value={ruleName}
185
+ onChange={(e) => setRuleName(e.target.value)}
186
+ className="w-full bg-[#162032] border border-slate-700 rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-emerald-500"
187
+ />
188
+ </div>
189
+
190
+ <div className="mb-4">
191
+ <label className="block text-xs font-medium text-slate-400 mb-1">Operator</label>
192
+ <select
193
+ value={operator}
194
+ onChange={(e) => setOperator(e.target.value)}
195
+ className="w-full bg-[#162032] border border-slate-700 rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-emerald-500 font-mono"
196
+ >
197
+ <option value="min_confidence">min_confidence (Block low confidence extractions)</option>
198
+ <option value="required_evidence">required_evidence (Mandate verbatim quotes)</option>
199
+ <option value="allowed_proposal_types">allowed_proposal_types (Constrain types)</option>
200
+ </select>
201
+ </div>
202
+
203
+ {operator === 'min_confidence' && (
204
+ <div className="mb-6">
205
+ <label className="block text-xs font-medium text-slate-400 mb-1">
206
+ Minimum Confidence Threshold: {(threshold * 100).toFixed(0)}%
207
+ </label>
208
+ <input
209
+ type="range"
210
+ min="0.5"
211
+ max="1.0"
212
+ step="0.05"
213
+ value={threshold}
214
+ onChange={(e) => setThreshold(e.target.value)}
215
+ className="w-full accent-emerald-400"
216
+ />
217
+ </div>
218
+ )}
219
+
220
+ <div className="flex justify-end space-x-3 mt-6">
221
+ <button
222
+ type="button"
223
+ onClick={() => setShowAddModal(false)}
224
+ className="px-4 py-2 text-xs font-medium text-slate-400 hover:text-white rounded-lg bg-slate-800"
225
+ >
226
+ Cancel
227
+ </button>
228
+ <button
229
+ type="submit"
230
+ className="px-4 py-2 text-xs font-medium text-black bg-emerald-400 hover:bg-emerald-300 rounded-lg font-semibold"
231
+ >
232
+ Add Rule
233
+ </button>
234
+ </div>
235
+ </form>
236
+ </div>
237
+ </div>
238
+ )}
239
+ </div>
240
+ );
241
+ }
studio/src/components/SemanticDiffViewer.jsx ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ export default function SemanticDiffViewer({ diff, onReview, loading }) {
4
+ const [filter, setFilter] = useState('all'); // all, conflicts, additions, changes
5
+ const [actingId, setActingId] = useState(null);
6
+
7
+ if (loading) {
8
+ return (
9
+ <div className="flex items-center justify-center p-20 text-slate-400">
10
+ <span className="pulse-glow mr-3">⚙</span> Generating semantic knowledge diff...
11
+ </div>
12
+ );
13
+ }
14
+
15
+ const summary = diff?.summary || {};
16
+ const conflicts = diff?.conflicts || [];
17
+ const additions = diff?.additions || [];
18
+ const changes = diff?.changes || [];
19
+ const removals = diff?.removals || [];
20
+
21
+ const handleAction = async (proposalId, decision) => {
22
+ setActingId(proposalId);
23
+ try {
24
+ await onReview(proposalId, decision);
25
+ } finally {
26
+ setActingId(null);
27
+ }
28
+ };
29
+
30
+ const totalDiffs = (conflicts.length + additions.length + changes.length + removals.length);
31
+
32
+ return (
33
+ <div className="space-y-6">
34
+ {/* Top Banner / Summary */}
35
+ <div className="flex flex-col md:flex-row md:items-center justify-between gap-4 p-5 rounded-xl bg-[#0E1524] border border-slate-800">
36
+ <div>
37
+ <h2 className="text-lg font-bold text-white flex items-center gap-2">
38
+ <span>Knowledge Semantic Diff</span>
39
+ <span className="text-xs px-2 py-0.5 rounded bg-slate-800 text-slate-300 font-mono">
40
+ {totalDiffs} changes detected
41
+ </span>
42
+ </h2>
43
+ <p className="text-xs text-slate-400 mt-1">
44
+ Compares newly extracted document facts against committed production truths with verbatim evidence provenance.
45
+ </p>
46
+ </div>
47
+
48
+ {/* Filter Pills */}
49
+ <div className="flex items-center space-x-2">
50
+ <button
51
+ onClick={() => setFilter('all')}
52
+ className={`px-3 py-1.5 rounded-lg text-xs font-medium transition ${
53
+ filter === 'all' ? 'bg-slate-700 text-white' : 'bg-slate-800/60 text-slate-400 hover:text-white'
54
+ }`}
55
+ >
56
+ All ({totalDiffs})
57
+ </button>
58
+ <button
59
+ onClick={() => setFilter('conflicts')}
60
+ className={`px-3 py-1.5 rounded-lg text-xs font-medium transition flex items-center space-x-1 ${
61
+ filter === 'conflicts' ? 'bg-rose-500/20 text-rose-300 border border-rose-500/40' : 'bg-slate-800/60 text-slate-400 hover:text-white'
62
+ }`}
63
+ >
64
+ <span className="w-1.5 h-1.5 rounded-full bg-rose-400"></span>
65
+ <span>Conflicts ({conflicts.length})</span>
66
+ </button>
67
+ <button
68
+ onClick={() => setFilter('additions')}
69
+ className={`px-3 py-1.5 rounded-lg text-xs font-medium transition flex items-center space-x-1 ${
70
+ filter === 'additions' ? 'bg-emerald-500/20 text-emerald-300 border border-emerald-500/40' : 'bg-slate-800/60 text-slate-400 hover:text-white'
71
+ }`}
72
+ >
73
+ <span className="w-1.5 h-1.5 rounded-full bg-emerald-400"></span>
74
+ <span>Additions ({additions.length})</span>
75
+ </button>
76
+ <button
77
+ onClick={() => setFilter('changes')}
78
+ className={`px-3 py-1.5 rounded-lg text-xs font-medium transition flex items-center space-x-1 ${
79
+ filter === 'changes' ? 'bg-amber-500/20 text-amber-300 border border-amber-500/40' : 'bg-slate-800/60 text-slate-400 hover:text-white'
80
+ }`}
81
+ >
82
+ <span className="w-1.5 h-1.5 rounded-full bg-amber-400"></span>
83
+ <span>Updates ({changes.length})</span>
84
+ </button>
85
+ </div>
86
+ </div>
87
+
88
+ {totalDiffs === 0 ? (
89
+ <div className="text-center py-16 border border-dashed border-slate-800 rounded-xl bg-[#090E17]">
90
+ <span className="text-3xl text-emerald-400">✔</span>
91
+ <h3 className="text-base font-semibold text-white mt-2">Workspace Knowledge is in Sync</h3>
92
+ <p className="text-xs text-slate-400 mt-1 max-w-sm mx-auto">
93
+ No uncommitted or conflicting knowledge items found. Upload documents via the Staging tab or dw add.
94
+ </p>
95
+ </div>
96
+ ) : (
97
+ <div className="space-y-4">
98
+ {/* Conflicts (Red / Contradiction) */}
99
+ {(filter === 'all' || filter === 'conflicts') &&
100
+ conflicts.map((c, idx) => {
101
+ const evidenceList = c.proposed?.evidence || [];
102
+ const quote = evidenceList[0]?.quote || 'No verbatim citation';
103
+ const page = evidenceList[0]?.page_number || 'N/A';
104
+
105
+ return (
106
+ <div key={c.proposal_id || idx} className="rounded-xl border border-rose-500/30 bg-[#0F1422] p-5 shadow-lg">
107
+ <div className="flex items-center justify-between border-b border-slate-800 pb-3 mb-4">
108
+ <div className="flex items-center space-x-2">
109
+ <span className="px-2 py-0.5 rounded text-[11px] font-bold bg-rose-500/20 text-rose-400 border border-rose-500/30">
110
+ ! CONTRADICTION COLLISION
111
+ </span>
112
+ <span className="text-xs text-slate-400 font-mono">PR: {c.proposal_id?.slice(0, 8)}</span>
113
+ </div>
114
+
115
+ <div className="flex items-center space-x-2">
116
+ <button
117
+ disabled={actingId === c.proposal_id}
118
+ onClick={() => handleAction(c.proposal_id, 'APPROVED')}
119
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/30 border border-emerald-500/40 transition disabled:opacity-50"
120
+ >
121
+ ✓ Accept & Merge
122
+ </button>
123
+ <button
124
+ disabled={actingId === c.proposal_id}
125
+ onClick={() => handleAction(c.proposal_id, 'REJECTED')}
126
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-rose-500/20 text-rose-300 hover:bg-rose-500/30 border border-rose-500/40 transition disabled:opacity-50"
127
+ >
128
+ ✕ Reject
129
+ </button>
130
+ </div>
131
+ </div>
132
+
133
+ <h3 className="text-sm font-semibold text-white mb-3">{c.title}</h3>
134
+
135
+ {/* 3-Way Split Diff */}
136
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
137
+ {/* Baseline truth */}
138
+ <div className="rounded-lg bg-rose-950/20 border border-rose-500/20 p-4">
139
+ <span className="text-[11px] font-mono text-rose-400 uppercase tracking-wider block mb-1">
140
+ ◀ Baseline Truth (Committed)
141
+ </span>
142
+ <p className="text-sm text-slate-200 font-medium">"{c.existing?.value || 'N/A'}"</p>
143
+ <span className="text-[11px] text-slate-400 mt-2 block font-mono">
144
+ Confidence: {c.existing?.confidence || 1.0}
145
+ </span>
146
+ </div>
147
+
148
+ {/* Proposed incoming */}
149
+ <div className="rounded-lg bg-emerald-950/20 border border-emerald-500/20 p-4">
150
+ <span className="text-[11px] font-mono text-emerald-400 uppercase tracking-wider block mb-1">
151
+ ▶ Proposed Change (From Incoming Document)
152
+ </span>
153
+ <p className="text-sm text-slate-100 font-medium">"{c.proposed?.value}"</p>
154
+ <div className="mt-3 pt-2 border-t border-emerald-500/10">
155
+ <span className="text-[11px] text-slate-400 block font-mono mb-1">
156
+ Verbatim Evidence (Page {page}):
157
+ </span>
158
+ <blockquote className="text-xs text-cyan-300 italic bg-cyan-950/20 p-2 rounded border-l-2 border-cyan-500">
159
+ "{quote}"
160
+ </blockquote>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ </div>
165
+ );
166
+ })}
167
+
168
+ {/* Additions (Green) */}
169
+ {(filter === 'all' || filter === 'additions') &&
170
+ additions.map((a, idx) => {
171
+ const evidenceList = a.evidence || [];
172
+ const quote = evidenceList[0]?.quote || 'No verbatim citation';
173
+ const page = evidenceList[0]?.page_number || 'N/A';
174
+
175
+ return (
176
+ <div key={a.proposal_id || idx} className="rounded-xl border border-emerald-500/30 bg-[#0F1422] p-5 shadow-lg">
177
+ <div className="flex items-center justify-between border-b border-slate-800 pb-3 mb-4">
178
+ <div className="flex items-center space-x-2">
179
+ <span className="px-2 py-0.5 rounded text-[11px] font-bold bg-emerald-500/20 text-emerald-400 border border-emerald-500/30">
180
+ + NEW {a.type || 'CLAIM'}
181
+ </span>
182
+ <span className="text-xs text-slate-400 font-mono">PR: {a.proposal_id?.slice(0, 8)}</span>
183
+ </div>
184
+
185
+ <div className="flex items-center space-x-2">
186
+ <button
187
+ disabled={actingId === a.proposal_id}
188
+ onClick={() => handleAction(a.proposal_id, 'APPROVED')}
189
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/30 border border-emerald-500/40 transition disabled:opacity-50"
190
+ >
191
+ ✓ Commit Fact
192
+ </button>
193
+ <button
194
+ disabled={actingId === a.proposal_id}
195
+ onClick={() => handleAction(a.proposal_id, 'REJECTED')}
196
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-rose-500/20 text-rose-300 hover:bg-rose-500/30 border border-rose-500/40 transition disabled:opacity-50"
197
+ >
198
+ ✕ Reject
199
+ </button>
200
+ </div>
201
+ </div>
202
+
203
+ <h3 className="text-sm font-semibold text-white mb-2">{a.title}</h3>
204
+ <div className="rounded-lg bg-emerald-950/15 border border-emerald-500/15 p-4 mb-3">
205
+ <span className="text-[11px] font-mono text-emerald-400 block mb-1">Extracted Value:</span>
206
+ <p className="text-sm text-slate-100 font-medium">"{a.proposed_value}"</p>
207
+ </div>
208
+
209
+ <div className="bg-slate-900/60 p-3 rounded-lg border border-slate-800/80">
210
+ <span className="text-[11px] text-slate-400 block font-mono mb-1">
211
+ Verbatim Document Evidence (Page {page}):
212
+ </span>
213
+ <blockquote className="text-xs text-cyan-300 italic">"{quote}"</blockquote>
214
+ </div>
215
+ </div>
216
+ );
217
+ })}
218
+
219
+ {/* Changes / Updates (Amber) */}
220
+ {(filter === 'all' || filter === 'changes') &&
221
+ changes.map((ch, idx) => (
222
+ <div key={ch.proposal_id || idx} className="rounded-xl border border-amber-500/30 bg-[#0F1422] p-5 shadow-lg">
223
+ <div className="flex items-center justify-between border-b border-slate-800 pb-3 mb-4">
224
+ <div className="flex items-center space-x-2">
225
+ <span className="px-2 py-0.5 rounded text-[11px] font-bold bg-amber-500/20 text-amber-400 border border-amber-500/30">
226
+ ~ MODIFIED CLAIM
227
+ </span>
228
+ <span className="text-xs text-slate-400 font-mono">PR: {ch.proposal_id?.slice(0, 8)}</span>
229
+ </div>
230
+
231
+ <div className="flex items-center space-x-2">
232
+ <button
233
+ disabled={actingId === ch.proposal_id}
234
+ onClick={() => handleAction(ch.proposal_id, 'APPROVED')}
235
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-emerald-500/20 text-emerald-300 hover:bg-emerald-500/30 border border-emerald-500/40 transition disabled:opacity-50"
236
+ >
237
+ ✓ Merge Update
238
+ </button>
239
+ <button
240
+ disabled={actingId === ch.proposal_id}
241
+ onClick={() => handleAction(ch.proposal_id, 'REJECTED')}
242
+ className="px-3 py-1.5 rounded-lg text-xs font-semibold bg-rose-500/20 text-rose-300 hover:bg-rose-500/30 border border-rose-500/40 transition disabled:opacity-50"
243
+ >
244
+ ✕ Reject
245
+ </button>
246
+ </div>
247
+ </div>
248
+
249
+ <h3 className="text-sm font-semibold text-white mb-2">{ch.title}</h3>
250
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
251
+ <div className="p-3 rounded bg-slate-900 border border-slate-800">
252
+ <span className="text-[10px] text-slate-400 block font-mono">Existing:</span>
253
+ <p className="text-xs text-slate-300 mt-1 font-medium">{ch.existing?.value || 'N/A'}</p>
254
+ </div>
255
+ <div className="p-3 rounded bg-amber-950/20 border border-amber-500/20">
256
+ <span className="text-[10px] text-amber-400 block font-mono">Proposed Update:</span>
257
+ <p className="text-xs text-amber-200 mt-1 font-medium">{ch.proposed?.value || 'N/A'}</p>
258
+ </div>
259
+ </div>
260
+ </div>
261
+ ))}
262
+ </div>
263
+ )}
264
+ </div>
265
+ );
266
+ }
studio/src/index.css ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
7
+ color-scheme: dark;
8
+ }
9
+
10
+ body {
11
+ margin: 0;
12
+ background-color: #080B11;
13
+ color: #E2E8F0;
14
+ overflow-x: hidden;
15
+ }
16
+
17
+ code, pre, .font-mono {
18
+ font-family: 'JetBrains Mono', monospace;
19
+ }
20
+
21
+ /* Custom Scrollbars */
22
+ ::-webkit-scrollbar {
23
+ width: 6px;
24
+ height: 6px;
25
+ }
26
+ ::-webkit-scrollbar-track {
27
+ background: #0D131F;
28
+ }
29
+ ::-webkit-scrollbar-thumb {
30
+ background: #253347;
31
+ border-radius: 3px;
32
+ }
33
+ ::-webkit-scrollbar-thumb:hover {
34
+ background: #3B4D66;
35
+ }
36
+
37
+ /* Subtle Glow Effects */
38
+ .glow-emerald {
39
+ box-shadow: 0 0 20px -3px rgba(16, 185, 129, 0.25);
40
+ }
41
+ .glow-crimson {
42
+ box-shadow: 0 0 20px -3px rgba(239, 68, 68, 0.25);
43
+ }
44
+ .glow-amber {
45
+ box-shadow: 0 0 20px -3px rgba(245, 158, 11, 0.25);
46
+ }
47
+ .glow-cyan {
48
+ box-shadow: 0 0 20px -3px rgba(14, 165, 233, 0.25);
49
+ }
50
+
51
+ /* Glassmorphic Cards */
52
+ .glass-card {
53
+ background: rgba(15, 22, 36, 0.7);
54
+ backdrop-filter: blur(12px);
55
+ border: 1px solid rgba(255, 255, 255, 0.08);
56
+ }
57
+ .glass-card:hover {
58
+ border-color: rgba(255, 255, 255, 0.14);
59
+ }
60
+
61
+ /* Pulsing Status Dot */
62
+ @keyframes pulse-dot {
63
+ 0%, 100% { opacity: 1; transform: scale(1); }
64
+ 50% { opacity: 0.5; transform: scale(1.15); }
65
+ }
66
+ .pulse-glow {
67
+ animation: pulse-dot 2s infinite ease-in-out;
68
+ }
studio/src/main.jsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react'
2
+ import ReactDOM from 'react-dom/client'
3
+ import App from './App.jsx'
4
+ import './index.css'
5
+
6
+ ReactDOM.createRoot(document.getElementById('root')).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>,
10
+ )
studio/vite.config.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ server: {
7
+ port: 5174,
8
+ proxy: {
9
+ '/api': {
10
+ target: 'http://localhost:8000',
11
+ changeOrigin: true,
12
+ },
13
+ },
14
+ },
15
+ });