File size: 2,429 Bytes
4d393e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | """
`dw status` command.
Displays workspace context, document inventory, workflows, and pending knowledge PRs.
"""
from __future__ import annotations
import time
from typing import Optional
import typer
from diffweave.cli.config import get_active_workspace, load_config
from diffweave.cli.output import render_status, print_error, print_json, console
from diffweave.mcp.client import DiffWeaveMCPClient
def status_command(
workspace_id: Optional[str] = typer.Option(None, "--workspace", "-w", help="Workspace UUID override"),
watch: bool = typer.Option(False, "--watch", help="Continuously refresh status (watch mode)"),
interval: int = typer.Option(3, "--interval", "-i", help="Watch refresh interval in seconds"),
as_json: bool = typer.Option(False, "--json", help="Output machine-readable JSON"),
):
"""
Show workspace knowledge staging, active workflows, and review status.
"""
try:
active_ws_id = get_active_workspace(workspace_id)
except Exception as e:
print_error(str(e))
raise typer.Exit(code=1)
client = DiffWeaveMCPClient()
config = load_config()
ws_name = config.get("workspace_name", "DocWeave Workspace")
def _fetch_and_render():
# Fetch status data from DocWeave MCP
docs = client.call_tool_sync("list_documents", {"workspace_id": active_ws_id})
stats = client.call_tool_sync("get_dashboard_stats", {"workspace_id": active_ws_id})
pending = client.call_tool_sync("list_pending_proposals", {"workspace_id": active_ws_id})
if as_json:
print_json({
"workspace_id": active_ws_id,
"workspace_name": ws_name,
"stats": stats,
"documents": docs,
"pending_proposals": pending,
})
else:
render_status(
workspace_name=ws_name,
workspace_id=active_ws_id,
docs=docs,
stats=stats,
pending_proposals=pending,
)
if watch:
console.print("[dim]Starting DiffWeave watch mode (Ctrl+C to stop)...[/dim]\n")
try:
while True:
console.clear()
_fetch_and_render()
time.sleep(interval)
except KeyboardInterrupt:
console.print("\n[dim]Stopped watch mode.[/dim]")
else:
_fetch_and_render()
|