Enforces the 'Zero-Parsing' AI architecture (Vercel AI SDK + React 19 + Gemini) for financial applications. Use when the user asks to build, refactor, or modernize financial dashboards or chat interfaces.
stock-terminal-next.[ ] Backend: Implement AIStreamProtocol in FastAPI (SSE with Type Codes 0, 2, 9).
[ ] Agent: Use Gemini 3.0/1.5 with Pydantic schemas (structured output) to enforce valid JSON for widgets.
[ ] Frontend: Use ai/react (useChat) and zustand (State) instead of manual fetch loops.
[ ] Testing: Verify streaming protocol using httpx (backend) and msw (frontend).
Stop parsing LLM output with Regex. Strictly separate Content (Text) from Data (Tool Calls, Charts).
0: "content"2: [{"chart": ...}]9: {...}backend/protocol.py)import json
from typing import Any
class AIStreamProtocol:
@staticmethod
def text(content: str) -> str:
"""Type 0: Text Part"""
return f'0:{json.dumps(content)}\n'
@staticmethod
def data(payload: Any) -> str:
"""Type 2: Data Part (Widgets, Charts). Must be a list."""
return f'2:{json.dumps([payload])}\n'
@staticmethod
def tool_call(call_id: str, name: str, args: dict) -> str:
"""Type 9: Tool Call"""
payload = {"toolCallId": call_id, "toolName": name, "args": args}
return f'9:{json.dumps(payload)}\n'
backend/agent.py)Use Pydantic V2 to enforce schema.
class AgentResponse(BaseModel):
part: Union[LineChart, TextResponse]
# When streaming:
# yield AIStreamProtocol.text(chunk.text)
# yield AIStreamProtocol.data(widget_object)
src/store/dashboardStore.ts)Use Zustand to hold the "active chart" state, avoiding prop drilling.
interface DashboardState {
activeChart: ChartData | null;
setActiveChart: (chart: ChartData | null) => void;
}
export const useDashboardStore = create<DashboardState>((set) => ({ ... }));
useTerminalChat.ts)Use useChat from Vercel AI SDK. Listen for data events to update global state.
import { useChat } from 'ai/react';
export function useTerminalChat() {
const setActiveChart = useDashboardStore((s) => s.setActiveChart);
const { messages, data } = useChat({
api: 'http://localhost:8001/chat',
});
// Effect: Update chart when new Data (Type 2) arrives
useEffect(() => {
if (!data) return;
const latest = data[data.length - 1];
if (latest && latest.type === 'line_chart') setActiveChart(latest);
}, [data, setActiveChart]);
return { messages };
}
httpx to consume the streaming response line-by-line and assert 0: and 2: prefixes.msw to mock the SSE stream (TextEncoder -> controller.enqueue).npx skills add jchavezar/building-financial-apps下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer